@loomcycle/explorer 0.7.0 → 0.9.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/DocumentViewer.d.ts +6 -0
- package/dist/components/ChunkTarget.d.ts +9 -0
- package/dist/components/Connections.d.ts +2 -1
- package/dist/components/CrossReferences.d.ts +15 -1
- package/dist/components/DocTrail.d.ts +6 -0
- package/dist/components/DocUnavailable.d.ts +6 -0
- package/dist/components/DocumentViewerBody.d.ts +5 -1
- package/dist/components/IdCopy.d.ts +7 -0
- package/dist/components/Mermaid.d.ts +3 -1
- package/dist/components/PathTree.d.ts +9 -6
- package/dist/index.cjs +10 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1803 -1268
- package/dist/index.js.map +1 -1
- package/dist/lib/clipboard.d.ts +1 -0
- package/dist/lib/dataLayer.d.ts +13 -4
- package/dist/lib/docTrail.d.ts +26 -0
- package/dist/lib/lazyPathTree.d.ts +43 -0
- package/dist/styles.css +192 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,17 +1,59 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { LoomcycleClient as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import { jsx as a, jsxs as c, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as Tt, useContext as Lt, useMemo as X, useState as p, useRef as te, useEffect as H, useCallback as P, useSyncExternalStore as Mt } from "react";
|
|
3
|
+
import { LoomcycleClient as Rt } from "@loomcycle/client";
|
|
4
|
+
import Pt from "react-markdown";
|
|
5
|
+
import It from "remark-gfm";
|
|
6
|
+
const At = 4, Ot = 5e3;
|
|
7
|
+
function ze(e, t) {
|
|
7
8
|
return {
|
|
8
|
-
pathLs: (n,
|
|
9
|
-
{
|
|
10
|
-
|
|
9
|
+
pathLs: (n, r, o, s, i) => e.path(
|
|
10
|
+
{
|
|
11
|
+
op: "ls",
|
|
12
|
+
path: n,
|
|
13
|
+
scope: r,
|
|
14
|
+
recursive: o,
|
|
15
|
+
...i?.limit ? { limit: i.limit } : {},
|
|
16
|
+
...i?.cursor ? { cursor: i.cursor } : {}
|
|
17
|
+
},
|
|
18
|
+
s
|
|
19
|
+
),
|
|
20
|
+
// stat refuses a path with no dirent; that refusal IS the answer "implicit"
|
|
21
|
+
// here (the path came from a listing, so it exists). Any other failure —
|
|
22
|
+
// network, auth — is not an answer and propagates. Matched by name, not
|
|
23
|
+
// instanceof: the host's client may be a different copy of the package.
|
|
24
|
+
pathIsStored: (n, r, o) => e.path({ op: "stat", path: n, scope: r }, o).then(
|
|
25
|
+
() => !0,
|
|
26
|
+
(s) => {
|
|
27
|
+
if (s?.name === "SubstrateToolRefusedError") return !1;
|
|
28
|
+
throw s;
|
|
29
|
+
}
|
|
11
30
|
),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
31
|
+
// One recursive listing of document dirents, followed page by page until the
|
|
32
|
+
// document turns up.
|
|
33
|
+
documentPath: async (n, r, o) => {
|
|
34
|
+
let s;
|
|
35
|
+
for (let i = 0; i < At; i++) {
|
|
36
|
+
const l = await e.path(
|
|
37
|
+
{
|
|
38
|
+
op: "ls",
|
|
39
|
+
path: "/",
|
|
40
|
+
scope: r,
|
|
41
|
+
recursive: !0,
|
|
42
|
+
kind_filter: "document",
|
|
43
|
+
limit: Ot,
|
|
44
|
+
...s ? { cursor: s } : {}
|
|
45
|
+
},
|
|
46
|
+
o
|
|
47
|
+
), f = (l.entries ?? []).find(
|
|
48
|
+
(d) => d.resource_ref?.document_id === n
|
|
49
|
+
);
|
|
50
|
+
if (f) return f.full_path;
|
|
51
|
+
if (s = l.next_cursor || void 0, !s) return;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
pathMkdir: (n, r, o) => e.path({ op: "mkdir", path: n, scope: r }, o),
|
|
55
|
+
pathMv: (n, r, o, s) => e.path({ op: "mv", path: n, to: r, scope: o }, s),
|
|
56
|
+
pathRm: (n, r, o, s) => e.path({ op: "rm", path: n, scope: r, recursive: o }, s),
|
|
15
57
|
// The `as unknown as DocumentToolInput` casts below are the same pinned-SDK
|
|
16
58
|
// workaround documentReorderChunk already uses, for a different reason: the
|
|
17
59
|
// published @loomcycle/client still types `scope` as "agent" | "user", from
|
|
@@ -19,310 +61,578 @@ function _e(e, r) {
|
|
|
19
61
|
// v1.41.0 and adapters/ts is fixed at source, so these casts come out on the
|
|
20
62
|
// next client publish — they are not papering over a wire mismatch, they are
|
|
21
63
|
// waiting for a version bump.
|
|
22
|
-
documentCreate: (n,
|
|
23
|
-
{ op: "create_document", title: n, path:
|
|
24
|
-
|
|
64
|
+
documentCreate: (n, r, o, s) => e.document(
|
|
65
|
+
{ op: "create_document", title: n, path: r, scope: o },
|
|
66
|
+
s
|
|
25
67
|
),
|
|
26
|
-
documentDelete: (n,
|
|
27
|
-
documentGet: (n,
|
|
28
|
-
documentsSummary: (n,
|
|
68
|
+
documentDelete: (n, r, o) => e.document({ op: "delete_document", id: n, scope: r }, o),
|
|
69
|
+
documentGet: (n, r, o) => e.document({ op: "get_document", id: n, scope: r }, o),
|
|
70
|
+
documentsSummary: (n, r, o) => e.document(
|
|
29
71
|
// documents_summary + document_ids are RFC BN wire additions the pinned
|
|
30
72
|
// SDK type doesn't enumerate; the /v1/_document passthrough accepts them
|
|
31
73
|
// verbatim, so cast past DocumentToolInput (same pattern as update_chunk).
|
|
32
74
|
{
|
|
33
75
|
op: "documents_summary",
|
|
34
|
-
scope:
|
|
76
|
+
scope: r,
|
|
35
77
|
...n.documentIds ? { document_ids: n.documentIds } : {},
|
|
36
78
|
...n.underPath ? { under_path: n.underPath } : {}
|
|
37
79
|
},
|
|
38
80
|
o
|
|
39
81
|
),
|
|
40
|
-
documentQueryChunks: (n,
|
|
41
|
-
{ op: "query_chunks", document_id: n, scope:
|
|
82
|
+
documentQueryChunks: (n, r, o) => e.document(
|
|
83
|
+
{ op: "query_chunks", document_id: n, scope: r, limit: 1e3 },
|
|
42
84
|
o
|
|
43
85
|
),
|
|
44
|
-
documentGetChunk: (n,
|
|
45
|
-
documentCreateChunk: (n,
|
|
86
|
+
documentGetChunk: (n, r, o) => e.document({ op: "get_chunk", id: n, scope: r }, o),
|
|
87
|
+
documentCreateChunk: (n, r, o, s, i, l) => e.document(
|
|
46
88
|
{
|
|
47
89
|
op: "create_chunk",
|
|
48
90
|
document_id: n,
|
|
49
|
-
parent_id:
|
|
50
|
-
scope:
|
|
51
|
-
...
|
|
91
|
+
parent_id: r,
|
|
92
|
+
scope: s,
|
|
93
|
+
...l ? { after_id: l } : {},
|
|
52
94
|
...o
|
|
53
95
|
},
|
|
54
|
-
|
|
96
|
+
i
|
|
55
97
|
),
|
|
56
|
-
documentReorderChunk: (n,
|
|
98
|
+
documentReorderChunk: (n, r, o, s) => e.document(
|
|
57
99
|
// reorder_chunk is an RFC BP wire op the pinned SDK type doesn't
|
|
58
100
|
// enumerate; the /v1/_document passthrough accepts it verbatim.
|
|
59
|
-
{ op: "reorder_chunk", id: n, direction:
|
|
60
|
-
|
|
101
|
+
{ op: "reorder_chunk", id: n, direction: r, scope: o },
|
|
102
|
+
s
|
|
61
103
|
),
|
|
62
|
-
documentDeleteChunk: (n,
|
|
63
|
-
documentSetAsset: (n,
|
|
104
|
+
documentDeleteChunk: (n, r, o) => e.document({ op: "delete_chunk", id: n, scope: r }, o),
|
|
105
|
+
documentSetAsset: (n, r, o, s, i, l) => e.document(
|
|
64
106
|
// set_asset is an RFC BO wire op the pinned SDK type doesn't enumerate;
|
|
65
107
|
// the /v1/_document passthrough accepts it verbatim.
|
|
66
108
|
{
|
|
67
109
|
op: "set_asset",
|
|
68
110
|
id: n,
|
|
69
|
-
media_type:
|
|
111
|
+
media_type: r,
|
|
70
112
|
data: o,
|
|
71
|
-
...
|
|
72
|
-
scope:
|
|
113
|
+
...s ? { filename: s } : {},
|
|
114
|
+
scope: i
|
|
73
115
|
},
|
|
74
|
-
|
|
116
|
+
l
|
|
75
117
|
),
|
|
76
|
-
documentGetEdges: (n,
|
|
118
|
+
documentGetEdges: (n, r, o) => e.document(
|
|
77
119
|
// get_edges is an RFC BN P4 wire op the pinned SDK type doesn't
|
|
78
120
|
// enumerate; the /v1/_document passthrough accepts it verbatim.
|
|
79
|
-
{ op: "get_edges", document_id: n, scope:
|
|
121
|
+
{ op: "get_edges", document_id: n, scope: r },
|
|
80
122
|
o
|
|
81
123
|
),
|
|
82
|
-
documentUpdateChunk: (n,
|
|
124
|
+
documentUpdateChunk: (n, r, o, s, i) => e.document(
|
|
83
125
|
// `patch.fields` is unknown but DocumentToolInput.fields is a typed
|
|
84
126
|
// Record; the cast reconciles the spread (the server accepts arbitrary
|
|
85
127
|
// JSON there). Op order + arg names mirror the wire contract exactly.
|
|
86
128
|
{
|
|
87
129
|
op: "update_chunk",
|
|
88
130
|
id: n,
|
|
89
|
-
revision:
|
|
90
|
-
scope:
|
|
131
|
+
revision: r,
|
|
132
|
+
scope: s,
|
|
91
133
|
...o
|
|
92
134
|
},
|
|
93
|
-
|
|
135
|
+
i
|
|
94
136
|
),
|
|
95
|
-
documentExportMd: (n,
|
|
137
|
+
documentExportMd: (n, r, o, s) => e.document(
|
|
96
138
|
{
|
|
97
139
|
op: "export_md",
|
|
98
140
|
document_id: n,
|
|
99
|
-
scope:
|
|
141
|
+
scope: r,
|
|
100
142
|
include_metadata: o
|
|
101
143
|
},
|
|
102
|
-
|
|
144
|
+
s
|
|
103
145
|
),
|
|
104
146
|
// RFC BS document-connections + history + canvas ops. Same `as unknown as
|
|
105
147
|
// DocumentToolInput` passthrough as documentGetEdges — new wire ops the pinned
|
|
106
148
|
// SDK type doesn't enumerate; the /v1/_document passthrough accepts them
|
|
107
149
|
// verbatim (adapters/ts is fixed at source, so the casts come out on the next
|
|
108
150
|
// client publish).
|
|
109
|
-
documentBacklinks: (n,
|
|
110
|
-
{ op: "backlinks", id: n, scope:
|
|
151
|
+
documentBacklinks: (n, r, o) => e.document(
|
|
152
|
+
{ op: "backlinks", id: n, scope: r },
|
|
111
153
|
o
|
|
112
154
|
),
|
|
113
|
-
documentRelated: (n,
|
|
155
|
+
documentRelated: (n, r, o, s) => e.document(
|
|
114
156
|
{
|
|
115
157
|
op: "related",
|
|
116
158
|
id: n,
|
|
117
|
-
scope:
|
|
118
|
-
...
|
|
159
|
+
scope: r,
|
|
160
|
+
...s ? { limit: s } : {}
|
|
119
161
|
},
|
|
120
162
|
o
|
|
121
163
|
),
|
|
122
|
-
documentUnlinkedMentions: (n,
|
|
164
|
+
documentUnlinkedMentions: (n, r, o, s) => e.document(
|
|
123
165
|
{
|
|
124
166
|
op: "unlinked_mentions",
|
|
125
167
|
id: n,
|
|
126
|
-
scope:
|
|
127
|
-
...
|
|
168
|
+
scope: r,
|
|
169
|
+
...s ? { limit: s } : {}
|
|
128
170
|
},
|
|
129
171
|
o
|
|
130
172
|
),
|
|
131
|
-
documentHistory: (n,
|
|
173
|
+
documentHistory: (n, r, o, s) => e.document(
|
|
132
174
|
{
|
|
133
175
|
op: "history",
|
|
134
176
|
id: n,
|
|
135
|
-
scope:
|
|
136
|
-
...
|
|
177
|
+
scope: r,
|
|
178
|
+
...s ? { limit: s } : {}
|
|
137
179
|
},
|
|
138
180
|
o
|
|
139
181
|
),
|
|
140
|
-
documentGetVersion: (n,
|
|
141
|
-
{ op: "get_version", id: n, revision:
|
|
142
|
-
|
|
182
|
+
documentGetVersion: (n, r, o, s) => e.document(
|
|
183
|
+
{ op: "get_version", id: n, revision: r, scope: o },
|
|
184
|
+
s
|
|
143
185
|
),
|
|
144
|
-
documentDiff: (n,
|
|
186
|
+
documentDiff: (n, r, o, s, i) => e.document(
|
|
145
187
|
{
|
|
146
188
|
op: "diff",
|
|
147
189
|
id: n,
|
|
148
|
-
from_revision:
|
|
190
|
+
from_revision: r,
|
|
149
191
|
to_revision: o,
|
|
150
|
-
scope:
|
|
192
|
+
scope: s
|
|
151
193
|
},
|
|
152
|
-
|
|
194
|
+
i
|
|
153
195
|
),
|
|
154
|
-
documentExportCanvas: (n,
|
|
155
|
-
{ op: "export_canvas", document_id: n, scope:
|
|
196
|
+
documentExportCanvas: (n, r, o) => e.document(
|
|
197
|
+
{ op: "export_canvas", document_id: n, scope: r },
|
|
156
198
|
o
|
|
157
199
|
),
|
|
158
200
|
// Present only when an AssetFetch was supplied (the connection path); a bare
|
|
159
201
|
// client can't do the raw binary GET, so the op is omitted and the viewer
|
|
160
202
|
// shows a placeholder.
|
|
161
|
-
...
|
|
162
|
-
documentAssetObjectUrl: async (n,
|
|
163
|
-
const
|
|
164
|
-
o?.scopeId &&
|
|
165
|
-
const
|
|
166
|
-
`/v1/_document/asset/${encodeURIComponent(n)}?${
|
|
203
|
+
...t ? {
|
|
204
|
+
documentAssetObjectUrl: async (n, r, o) => {
|
|
205
|
+
const s = new URLSearchParams({ scope: r });
|
|
206
|
+
o?.scopeId && s.set("scope_id", o.scopeId), o?.tenant && s.set("tenant", o.tenant);
|
|
207
|
+
const i = await t(
|
|
208
|
+
`/v1/_document/asset/${encodeURIComponent(n)}?${s.toString()}`
|
|
167
209
|
);
|
|
168
|
-
if (!
|
|
169
|
-
const
|
|
170
|
-
return URL.createObjectURL(
|
|
210
|
+
if (!i.ok) throw new Error(`asset fetch failed: ${i.status}`);
|
|
211
|
+
const l = await i.blob();
|
|
212
|
+
return URL.createObjectURL(l);
|
|
171
213
|
}
|
|
172
214
|
} : {}
|
|
173
215
|
};
|
|
174
216
|
}
|
|
175
|
-
const
|
|
176
|
-
function
|
|
217
|
+
const at = Tt(null);
|
|
218
|
+
function Ut({
|
|
177
219
|
value: e,
|
|
178
|
-
children:
|
|
220
|
+
children: t
|
|
179
221
|
}) {
|
|
180
|
-
return /* @__PURE__ */
|
|
222
|
+
return /* @__PURE__ */ a(at.Provider, { value: e, children: t });
|
|
181
223
|
}
|
|
182
|
-
function
|
|
183
|
-
const e =
|
|
224
|
+
function be() {
|
|
225
|
+
const e = Lt(at);
|
|
184
226
|
if (!e)
|
|
185
227
|
throw new Error(
|
|
186
228
|
"useExplorerData must be used within <PathExplorer> or <DocumentViewer> (no ExplorerDataLayer in context)"
|
|
187
229
|
);
|
|
188
230
|
return e;
|
|
189
231
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return
|
|
232
|
+
const Oe = 500, rt = 5e3;
|
|
233
|
+
function Ue(e) {
|
|
234
|
+
return e === "" ? "/" : e;
|
|
235
|
+
}
|
|
236
|
+
function jt(e) {
|
|
237
|
+
const t = e.lastIndexOf("/");
|
|
238
|
+
return t <= 0 ? "" : e.slice(0, t);
|
|
239
|
+
}
|
|
240
|
+
function ot(e) {
|
|
241
|
+
const t = [""], n = e.split("/").filter(Boolean);
|
|
242
|
+
let r = "";
|
|
243
|
+
for (let o = 0; o < n.length - 1; o++)
|
|
244
|
+
r = `${r}/${n[o]}`, t.push(r);
|
|
245
|
+
return t;
|
|
246
|
+
}
|
|
247
|
+
function qe(e) {
|
|
248
|
+
return e instanceof Error ? e.message : String(e);
|
|
249
|
+
}
|
|
250
|
+
function Je(e, t) {
|
|
251
|
+
return {
|
|
252
|
+
entries: [...t, ...e.entries ?? []],
|
|
253
|
+
nextCursor: e.next_cursor || void 0,
|
|
254
|
+
loaded: !0,
|
|
255
|
+
loading: !1
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
class Bt {
|
|
259
|
+
constructor(t, n, r, o = Oe) {
|
|
260
|
+
this.data = t, this.scope = n, this.browse = r, this.pageLimit = o;
|
|
261
|
+
}
|
|
262
|
+
data;
|
|
263
|
+
scope;
|
|
264
|
+
browse;
|
|
265
|
+
pageLimit;
|
|
266
|
+
dirs = /* @__PURE__ */ new Map();
|
|
267
|
+
snapshot = /* @__PURE__ */ new Map();
|
|
268
|
+
listeners = /* @__PURE__ */ new Set();
|
|
269
|
+
inflight = /* @__PURE__ */ new Map();
|
|
270
|
+
// epoch bumps whenever a directory is re-listed from its first page or
|
|
271
|
+
// dropped, so a page that was in flight across that point is discarded
|
|
272
|
+
// instead of being appended to a listing it no longer continues.
|
|
273
|
+
epoch = /* @__PURE__ */ new Map();
|
|
274
|
+
getSnapshot = () => this.snapshot;
|
|
275
|
+
subscribe = (t) => (this.listeners.add(t), () => {
|
|
276
|
+
this.listeners.delete(t);
|
|
277
|
+
});
|
|
278
|
+
publish() {
|
|
279
|
+
this.snapshot = new Map(this.dirs), this.listeners.forEach((t) => t());
|
|
280
|
+
}
|
|
281
|
+
set(t, n) {
|
|
282
|
+
this.dirs.set(t, n), this.publish();
|
|
283
|
+
}
|
|
284
|
+
track(t, n) {
|
|
285
|
+
const r = n.finally(() => {
|
|
286
|
+
this.inflight.get(t) === r && this.inflight.delete(t);
|
|
287
|
+
});
|
|
288
|
+
return this.inflight.set(t, r), r;
|
|
289
|
+
}
|
|
290
|
+
// loadDir lists a directory's first page unless it is already listed. A
|
|
291
|
+
// request already in flight for it is joined rather than repeated.
|
|
292
|
+
loadDir(t) {
|
|
293
|
+
const n = this.inflight.get(t);
|
|
294
|
+
return n || (this.dirs.get(t)?.loaded ? Promise.resolve() : this.fetchFirst(t, this.pageLimit));
|
|
295
|
+
}
|
|
296
|
+
// reload re-lists a directory from its first page, asking for as many entries
|
|
297
|
+
// as it already showed so a refresh does not fold away pages the operator
|
|
298
|
+
// loaded (up to the runtime's ceiling; past it the "load more" row returns).
|
|
299
|
+
// A directory that was shown in full gets a page of headroom on top, so the
|
|
300
|
+
// entry just created in it does not split it back into "load more".
|
|
301
|
+
reload(t) {
|
|
302
|
+
const n = this.dirs.get(t), r = n?.entries.length ?? 0, o = n?.loaded && !n.nextCursor ? r + this.pageLimit : r;
|
|
303
|
+
return this.fetchFirst(t, Math.min(rt, Math.max(this.pageLimit, o)));
|
|
304
|
+
}
|
|
305
|
+
fetchFirst(t, n) {
|
|
306
|
+
const r = (this.epoch.get(t) ?? 0) + 1;
|
|
307
|
+
this.epoch.set(t, r);
|
|
308
|
+
const o = this.dirs.get(t);
|
|
309
|
+
this.set(t, {
|
|
310
|
+
entries: o?.entries ?? [],
|
|
311
|
+
nextCursor: o?.nextCursor,
|
|
312
|
+
loaded: o?.loaded ?? !1,
|
|
313
|
+
loading: !0
|
|
314
|
+
});
|
|
315
|
+
const s = this.data.pathLs(Ue(t), this.scope, !1, this.browse, { limit: n }).then(
|
|
316
|
+
(i) => {
|
|
317
|
+
this.epoch.get(t) === r && this.set(t, Je(i, []));
|
|
318
|
+
},
|
|
319
|
+
(i) => {
|
|
320
|
+
throw this.epoch.get(t) === r && this.set(t, {
|
|
321
|
+
entries: o?.entries ?? [],
|
|
322
|
+
nextCursor: o?.nextCursor,
|
|
323
|
+
loaded: o?.loaded ?? !1,
|
|
324
|
+
loading: !1,
|
|
325
|
+
error: qe(i)
|
|
326
|
+
}), i;
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
return this.track(t, s);
|
|
330
|
+
}
|
|
331
|
+
// loadMore appends a directory's next page. A no-op when it has none.
|
|
332
|
+
loadMore(t) {
|
|
333
|
+
const n = this.inflight.get(t);
|
|
334
|
+
if (n) return n;
|
|
335
|
+
const r = this.dirs.get(t);
|
|
336
|
+
if (!r?.nextCursor) return Promise.resolve();
|
|
337
|
+
const o = this.epoch.get(t) ?? 0;
|
|
338
|
+
this.set(t, { ...r, loading: !0, error: void 0 });
|
|
339
|
+
const s = this.data.pathLs(Ue(t), this.scope, !1, this.browse, {
|
|
340
|
+
limit: this.pageLimit,
|
|
341
|
+
cursor: r.nextCursor
|
|
342
|
+
}).then(
|
|
343
|
+
(i) => {
|
|
344
|
+
this.epoch.get(t) === o && this.set(t, Je(i, r.entries));
|
|
345
|
+
},
|
|
346
|
+
(i) => {
|
|
347
|
+
throw this.epoch.get(t) === o && this.set(t, { ...r, loading: !1, error: qe(i) }), i;
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
return this.track(t, s);
|
|
351
|
+
}
|
|
352
|
+
// reveal lists every ancestor of `path`, paging each one until the next path
|
|
353
|
+
// segment appears, so a deep link to an entry on a later page still resolves.
|
|
354
|
+
// Resolves false when the path is not there. Because a page is ordered by
|
|
355
|
+
// name, paging stops as soon as a page ends past the wanted name.
|
|
356
|
+
async reveal(t) {
|
|
357
|
+
const n = t.split("/").filter(Boolean);
|
|
358
|
+
let r = "";
|
|
359
|
+
for (const o of n) {
|
|
360
|
+
for (await this.loadDir(r); ; ) {
|
|
361
|
+
const s = this.dirs.get(r);
|
|
362
|
+
if (!s) return !1;
|
|
363
|
+
if (s.entries.some((f) => f.name === o)) break;
|
|
364
|
+
const i = s.entries[s.entries.length - 1];
|
|
365
|
+
if (!s.nextCursor || i && i.name > o) return !1;
|
|
366
|
+
const l = s.nextCursor;
|
|
367
|
+
if (await this.loadMore(r), this.dirs.get(r)?.nextCursor === l) return !1;
|
|
368
|
+
}
|
|
369
|
+
r = `${r}/${o}`;
|
|
370
|
+
}
|
|
371
|
+
return !0;
|
|
372
|
+
}
|
|
373
|
+
// invalidate re-lists what a change at `path` can alter: every ancestor that
|
|
374
|
+
// is already listed — not just the parent, because an implicit directory
|
|
375
|
+
// appears with its first descendant and vanishes with its last. dropSubtree
|
|
376
|
+
// also forgets the listings at/under `path` (a moved or removed directory's
|
|
377
|
+
// old children must not linger under its old name).
|
|
378
|
+
async invalidate(t, n) {
|
|
379
|
+
if (n?.dropSubtree) {
|
|
380
|
+
for (const o of [...this.dirs.keys()])
|
|
381
|
+
(o === t || o.startsWith(`${t}/`)) && (this.dirs.delete(o), this.epoch.set(o, (this.epoch.get(o) ?? 0) + 1), this.inflight.delete(o));
|
|
382
|
+
this.publish();
|
|
383
|
+
}
|
|
384
|
+
const r = ot(t).filter((o) => this.dirs.has(o));
|
|
385
|
+
await Promise.all(r.map((o) => this.reload(o)));
|
|
386
|
+
}
|
|
387
|
+
// refresh re-lists the root and every directory in `keep` that is listed, and
|
|
388
|
+
// forgets the rest (a collapsed directory re-lists when it is next opened).
|
|
389
|
+
async refresh(t) {
|
|
390
|
+
const n = new Set(t);
|
|
391
|
+
n.add("");
|
|
392
|
+
for (const o of [...this.dirs.keys()])
|
|
393
|
+
n.has(o) || (this.dirs.delete(o), this.epoch.set(o, (this.epoch.get(o) ?? 0) + 1), this.inflight.delete(o));
|
|
394
|
+
this.publish();
|
|
395
|
+
const r = [...n].filter((o) => o === "" || this.dirs.has(o));
|
|
396
|
+
await Promise.all(r.map((o) => this.reload(o)));
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
async function Ft(e, t, n, r) {
|
|
400
|
+
const o = [];
|
|
401
|
+
let s;
|
|
402
|
+
for (; ; ) {
|
|
403
|
+
const i = await e.pathLs(Ue(t), n, !0, r, {
|
|
404
|
+
limit: rt,
|
|
405
|
+
cursor: s
|
|
406
|
+
});
|
|
407
|
+
o.push(...i.entries ?? []);
|
|
408
|
+
const l = i.next_cursor || void 0;
|
|
409
|
+
if (!l || l === s) return o;
|
|
410
|
+
s = l;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
function Ze(e) {
|
|
414
|
+
const t = [];
|
|
415
|
+
for (const n of e) {
|
|
416
|
+
if (n.kind !== "document") continue;
|
|
417
|
+
const r = n.resource_ref?.document_id;
|
|
418
|
+
r && t.push(r);
|
|
419
|
+
}
|
|
420
|
+
return t;
|
|
421
|
+
}
|
|
422
|
+
function Gt(e) {
|
|
423
|
+
const t = e.fetch;
|
|
424
|
+
return new Rt({
|
|
193
425
|
baseUrl: e.baseUrl,
|
|
194
426
|
authToken: e.token || void 0,
|
|
195
|
-
fetch: (n,
|
|
427
|
+
fetch: (n, r) => t ? t(n, r) : fetch(n, r)
|
|
196
428
|
});
|
|
197
429
|
}
|
|
198
|
-
function
|
|
199
|
-
const
|
|
200
|
-
return (
|
|
430
|
+
function Ht(e) {
|
|
431
|
+
const t = e.fetch, n = (r, o) => t ? t(r, o) : fetch(r, o);
|
|
432
|
+
return (r) => {
|
|
201
433
|
const o = {};
|
|
202
|
-
return e.token && (o.Authorization = `Bearer ${e.token}`), n(e.baseUrl +
|
|
434
|
+
return e.token && (o.Authorization = `Bearer ${e.token}`), n(e.baseUrl + r, { headers: o });
|
|
203
435
|
};
|
|
204
436
|
}
|
|
205
|
-
function
|
|
206
|
-
const { dataLayer:
|
|
207
|
-
return
|
|
208
|
-
|
|
209
|
-
|
|
437
|
+
function st(e) {
|
|
438
|
+
const { dataLayer: t, client: n, connection: r } = e;
|
|
439
|
+
return X(() => t || (n ? ze(n) : r ? ze(
|
|
440
|
+
Gt(r),
|
|
441
|
+
Ht(r)
|
|
210
442
|
// RFC BO — binary image-asset GET
|
|
211
|
-
) : null), [
|
|
443
|
+
) : null), [t, n, r?.baseUrl, r?.token, r?.fetch]);
|
|
212
444
|
}
|
|
213
|
-
function
|
|
445
|
+
function it({
|
|
214
446
|
theme: e,
|
|
215
|
-
dataLayer:
|
|
447
|
+
dataLayer: t,
|
|
216
448
|
children: n
|
|
217
449
|
}) {
|
|
218
|
-
const
|
|
219
|
-
return
|
|
450
|
+
const r = e ? { "data-theme": e } : {};
|
|
451
|
+
return t ? /* @__PURE__ */ a("div", { className: "loomcycle-explorer", ...r, children: /* @__PURE__ */ a(Ut, { value: t, children: n }) }) : /* @__PURE__ */ a("div", { className: "loomcycle-explorer", ...r, children: /* @__PURE__ */ c("div", { className: "error-banner", children: [
|
|
220
452
|
"@loomcycle/explorer: provide a ",
|
|
221
|
-
/* @__PURE__ */
|
|
453
|
+
/* @__PURE__ */ a("code", { children: "connection" }),
|
|
222
454
|
", ",
|
|
223
|
-
/* @__PURE__ */
|
|
455
|
+
/* @__PURE__ */ a("code", { children: "client" }),
|
|
224
456
|
", or",
|
|
225
457
|
" ",
|
|
226
|
-
/* @__PURE__ */
|
|
458
|
+
/* @__PURE__ */ a("code", { children: "dataLayer" }),
|
|
227
459
|
" prop."
|
|
228
460
|
] }) });
|
|
229
461
|
}
|
|
230
|
-
|
|
231
|
-
|
|
462
|
+
function ct(e, t, n) {
|
|
463
|
+
const r = e[e.length - 1];
|
|
464
|
+
return [...r && r.documentId === t.documentId ? [...e.slice(0, -1), { ...r, ...dt(t) }] : [...e, t], n];
|
|
465
|
+
}
|
|
466
|
+
function lt(e, t) {
|
|
467
|
+
return t < 0 || t >= e.length - 1 ? e : e.slice(0, t + 1);
|
|
468
|
+
}
|
|
469
|
+
function je(e, t, n) {
|
|
470
|
+
const r = e[e.length - 1];
|
|
471
|
+
if (!r || r.documentId !== t) return e;
|
|
472
|
+
const o = { ...r, ...dt(n) };
|
|
473
|
+
return o.title === r.title && o.path === r.path ? e : [...e.slice(0, -1), o];
|
|
474
|
+
}
|
|
475
|
+
function dt(e) {
|
|
476
|
+
return Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0));
|
|
477
|
+
}
|
|
478
|
+
function he(e) {
|
|
479
|
+
return e.title ? e.title : e.path ? e.path.slice(e.path.lastIndexOf("/") + 1) || e.path : e.documentId.slice(0, 8);
|
|
480
|
+
}
|
|
481
|
+
const Wt = 4;
|
|
482
|
+
function Vt(e, t = Wt) {
|
|
483
|
+
const n = Array.from({ length: e }, (s, i) => ({ kind: "crumb", index: i }));
|
|
484
|
+
if (e <= t || t < 3) return n;
|
|
485
|
+
const r = t - 1, o = Array.from({ length: e - 1 - r }, (s, i) => i + 1);
|
|
486
|
+
return [n[0], { kind: "gap", hidden: o }, ...n.slice(e - r)];
|
|
487
|
+
}
|
|
488
|
+
function zt(e, t) {
|
|
489
|
+
for (const n of e.values()) {
|
|
490
|
+
const r = n.entries.find((o) => qt(o) === t);
|
|
491
|
+
if (r) return r.full_path;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
function qt(e) {
|
|
495
|
+
if (e.kind === "document")
|
|
496
|
+
return e.resource_ref?.document_id || void 0;
|
|
497
|
+
}
|
|
498
|
+
function Jt(e, t) {
|
|
499
|
+
return t && e.some((n) => n.id === t) ? t : e.find((n) => !n.parent_id)?.id;
|
|
500
|
+
}
|
|
501
|
+
function ut({ trail: e, onJump: t }) {
|
|
502
|
+
const [n, r] = p(!1);
|
|
503
|
+
if (e.length < 2) return null;
|
|
504
|
+
const o = e.length - 1, s = e[o - 1], i = Vt(e.length, n ? e.length : void 0);
|
|
505
|
+
return /* @__PURE__ */ c("nav", { className: "doc-trail", "aria-label": "Documents you came through", children: [
|
|
506
|
+
/* @__PURE__ */ a(
|
|
507
|
+
"button",
|
|
508
|
+
{
|
|
509
|
+
type: "button",
|
|
510
|
+
className: "doc-trail-back",
|
|
511
|
+
onClick: () => t(o - 1),
|
|
512
|
+
title: `Back to ${he(s)}`,
|
|
513
|
+
children: "← Back"
|
|
514
|
+
}
|
|
515
|
+
),
|
|
516
|
+
/* @__PURE__ */ a("ol", { className: "doc-trail-list", children: i.map(
|
|
517
|
+
(l) => l.kind === "gap" ? /* @__PURE__ */ a("li", { className: "doc-trail-item", children: /* @__PURE__ */ a(
|
|
518
|
+
"button",
|
|
519
|
+
{
|
|
520
|
+
type: "button",
|
|
521
|
+
className: "doc-trail-gap",
|
|
522
|
+
onClick: () => r(!0),
|
|
523
|
+
title: `Show ${l.hidden.length} more: ${l.hidden.map((f) => he(e[f])).join(" › ")}`,
|
|
524
|
+
"aria-label": `Show ${l.hidden.length} hidden documents`,
|
|
525
|
+
children: "…"
|
|
526
|
+
}
|
|
527
|
+
) }, "gap") : l.index === o ? /* @__PURE__ */ a("li", { className: "doc-trail-item", children: /* @__PURE__ */ a("span", { className: "doc-trail-current", "aria-current": "page", title: he(e[o]), children: he(e[o]) }) }, l.index) : /* @__PURE__ */ a("li", { className: "doc-trail-item", children: /* @__PURE__ */ a(
|
|
528
|
+
"button",
|
|
529
|
+
{
|
|
530
|
+
type: "button",
|
|
531
|
+
className: "doc-trail-crumb",
|
|
532
|
+
onClick: () => t(l.index),
|
|
533
|
+
title: he(e[l.index]),
|
|
534
|
+
children: he(e[l.index])
|
|
535
|
+
}
|
|
536
|
+
) }, l.index)
|
|
537
|
+
) })
|
|
538
|
+
] });
|
|
539
|
+
}
|
|
540
|
+
const Xe = 6;
|
|
541
|
+
function Zt({
|
|
232
542
|
children: e,
|
|
233
|
-
defaultLeftWidth:
|
|
543
|
+
defaultLeftWidth: t = 380,
|
|
234
544
|
minLeftWidth: n = 180,
|
|
235
|
-
minRightWidth:
|
|
545
|
+
minRightWidth: r = 240,
|
|
236
546
|
storageKey: o,
|
|
237
|
-
className:
|
|
547
|
+
className: s
|
|
238
548
|
}) {
|
|
239
|
-
const [
|
|
549
|
+
const [i, l] = p(() => {
|
|
240
550
|
if (o) {
|
|
241
|
-
const
|
|
242
|
-
if (Number.isFinite(
|
|
551
|
+
const N = localStorage.getItem(o), y = N ? parseInt(N, 10) : NaN;
|
|
552
|
+
if (Number.isFinite(y) && y >= n) return y;
|
|
243
553
|
}
|
|
244
|
-
return
|
|
245
|
-
}),
|
|
246
|
-
|
|
247
|
-
!o ||
|
|
248
|
-
}, [o,
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
}, []),
|
|
252
|
-
(
|
|
253
|
-
if (!
|
|
254
|
-
const
|
|
255
|
-
|
|
554
|
+
return t;
|
|
555
|
+
}), f = te(null), [d, h] = p(!1);
|
|
556
|
+
H(() => {
|
|
557
|
+
!o || d || localStorage.setItem(o, String(Math.round(i)));
|
|
558
|
+
}, [o, i, d]);
|
|
559
|
+
const w = P((N) => {
|
|
560
|
+
N.preventDefault(), h(!0), N.target.setPointerCapture(N.pointerId);
|
|
561
|
+
}, []), S = P(
|
|
562
|
+
(N) => {
|
|
563
|
+
if (!d || !f.current) return;
|
|
564
|
+
const y = f.current.getBoundingClientRect(), j = N.clientX - y.left, B = y.width - r - Xe, O = Math.max(n, Math.min(j, B));
|
|
565
|
+
l(O);
|
|
256
566
|
},
|
|
257
|
-
[
|
|
258
|
-
),
|
|
567
|
+
[d, n, r]
|
|
568
|
+
), g = P((N) => {
|
|
259
569
|
h(!1);
|
|
260
570
|
try {
|
|
261
|
-
|
|
571
|
+
N.target.releasePointerCapture(N.pointerId);
|
|
262
572
|
} catch {
|
|
263
573
|
}
|
|
264
574
|
}, []);
|
|
265
|
-
return /* @__PURE__ */
|
|
575
|
+
return /* @__PURE__ */ c(
|
|
266
576
|
"div",
|
|
267
577
|
{
|
|
268
|
-
ref:
|
|
269
|
-
className: `splitter ${
|
|
578
|
+
ref: f,
|
|
579
|
+
className: `splitter ${s ?? ""} ${d ? "dragging" : ""}`,
|
|
270
580
|
style: {
|
|
271
|
-
gridTemplateColumns: `${
|
|
581
|
+
gridTemplateColumns: `${i}px ${Xe}px 1fr`
|
|
272
582
|
},
|
|
273
583
|
children: [
|
|
274
|
-
/* @__PURE__ */
|
|
275
|
-
/* @__PURE__ */
|
|
584
|
+
/* @__PURE__ */ a("div", { className: "splitter-pane splitter-left", children: e[0] }),
|
|
585
|
+
/* @__PURE__ */ a(
|
|
276
586
|
"div",
|
|
277
587
|
{
|
|
278
588
|
className: "splitter-handle",
|
|
279
589
|
role: "separator",
|
|
280
590
|
"aria-orientation": "vertical",
|
|
281
|
-
"aria-valuenow": Math.round(
|
|
282
|
-
onPointerDown:
|
|
283
|
-
onPointerMove:
|
|
284
|
-
onPointerUp:
|
|
285
|
-
onPointerCancel:
|
|
591
|
+
"aria-valuenow": Math.round(i),
|
|
592
|
+
onPointerDown: w,
|
|
593
|
+
onPointerMove: S,
|
|
594
|
+
onPointerUp: g,
|
|
595
|
+
onPointerCancel: g
|
|
286
596
|
}
|
|
287
597
|
),
|
|
288
|
-
/* @__PURE__ */
|
|
598
|
+
/* @__PURE__ */ a("div", { className: "splitter-pane splitter-right", children: e[1] })
|
|
289
599
|
]
|
|
290
600
|
}
|
|
291
601
|
);
|
|
292
602
|
}
|
|
293
|
-
const
|
|
294
|
-
function
|
|
295
|
-
return
|
|
603
|
+
const Xt = ["image/png", "image/jpeg", "image/gif", "image/webp"];
|
|
604
|
+
function ht(e) {
|
|
605
|
+
return Xt.includes(e);
|
|
296
606
|
}
|
|
297
|
-
function
|
|
298
|
-
return new Promise((
|
|
299
|
-
if (!
|
|
607
|
+
function mt(e) {
|
|
608
|
+
return new Promise((t, n) => {
|
|
609
|
+
if (!ht(e.type)) {
|
|
300
610
|
n(new Error(`unsupported image type "${e.type || "unknown"}" (png, jpeg, gif, webp only)`));
|
|
301
611
|
return;
|
|
302
612
|
}
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
const o = String(
|
|
306
|
-
if (
|
|
613
|
+
const r = new FileReader();
|
|
614
|
+
r.onerror = () => n(r.error ?? new Error("failed to read file")), r.onload = () => {
|
|
615
|
+
const o = String(r.result ?? ""), s = o.indexOf(",");
|
|
616
|
+
if (s < 0) {
|
|
307
617
|
n(new Error("could not decode image data"));
|
|
308
618
|
return;
|
|
309
619
|
}
|
|
310
|
-
|
|
311
|
-
},
|
|
620
|
+
t({ mediaType: e.type, data: o.slice(s + 1) });
|
|
621
|
+
}, r.readAsDataURL(e);
|
|
312
622
|
});
|
|
313
623
|
}
|
|
314
|
-
function
|
|
624
|
+
function Qt(e) {
|
|
315
625
|
if (!e) return null;
|
|
316
|
-
for (let
|
|
317
|
-
const n = e[
|
|
318
|
-
if (n.kind === "file" &&
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
626
|
+
for (let t = 0; t < e.length; t++) {
|
|
627
|
+
const n = e[t];
|
|
628
|
+
if (n.kind === "file" && ht(n.type)) {
|
|
629
|
+
const r = n.getAsFile();
|
|
630
|
+
if (r) return r;
|
|
321
631
|
}
|
|
322
632
|
}
|
|
323
633
|
return null;
|
|
324
634
|
}
|
|
325
|
-
const
|
|
635
|
+
const Be = {
|
|
326
636
|
"doc.rfc.draft": "#c99a3a",
|
|
327
637
|
"doc.rfc.review": "#6a7bd6",
|
|
328
638
|
"doc.rfc.confirmed": "#3a9ad6",
|
|
@@ -343,125 +653,154 @@ const be = {
|
|
|
343
653
|
"chunk.backlog": "#8a8f98",
|
|
344
654
|
"chunk.implementation": "#d1863a",
|
|
345
655
|
"chunk.merged": "#3aa06a"
|
|
346
|
-
},
|
|
347
|
-
function
|
|
348
|
-
return e && Object.keys(e).length > 0 ? e :
|
|
656
|
+
}, Yt = 0.16;
|
|
657
|
+
function Ge(e) {
|
|
658
|
+
return e && Object.keys(e).length > 0 ? e : Be;
|
|
349
659
|
}
|
|
350
|
-
function
|
|
351
|
-
const
|
|
352
|
-
if (
|
|
353
|
-
if (
|
|
660
|
+
function ft(e, t, n) {
|
|
661
|
+
const r = e ?? "", o = t ?? "";
|
|
662
|
+
if (r && o && n[`doc.${r}.${o}`]) return n[`doc.${r}.${o}`];
|
|
663
|
+
if (r && n[`doc.${r}`]) return n[`doc.${r}`];
|
|
354
664
|
}
|
|
355
|
-
function
|
|
665
|
+
function Kt(e, t) {
|
|
356
666
|
const n = e ?? "";
|
|
357
|
-
return n ?
|
|
667
|
+
return n ? t[`chunk.${n}`] : void 0;
|
|
358
668
|
}
|
|
359
|
-
function
|
|
360
|
-
const
|
|
361
|
-
if (!
|
|
362
|
-
let n =
|
|
669
|
+
function en(e) {
|
|
670
|
+
const t = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
|
|
671
|
+
if (!t) return;
|
|
672
|
+
let n = t[1];
|
|
363
673
|
n.length === 3 && (n = n[0] + n[0] + n[1] + n[1] + n[2] + n[2]);
|
|
364
|
-
const
|
|
365
|
-
return `rgba(${
|
|
674
|
+
const r = parseInt(n.slice(0, 2), 16), o = parseInt(n.slice(2, 4), 16), s = parseInt(n.slice(4, 6), 16);
|
|
675
|
+
return `rgba(${r}, ${o}, ${s}, ${Yt})`;
|
|
366
676
|
}
|
|
367
|
-
function
|
|
677
|
+
function He(e) {
|
|
368
678
|
if (!e) return;
|
|
369
|
-
const
|
|
370
|
-
if (
|
|
371
|
-
return { background:
|
|
679
|
+
const t = en(e);
|
|
680
|
+
if (t)
|
|
681
|
+
return { background: t, borderLeft: `3px solid ${e}` };
|
|
682
|
+
}
|
|
683
|
+
async function tn(e) {
|
|
684
|
+
try {
|
|
685
|
+
return typeof navigator > "u" || !navigator.clipboard ? !1 : (await navigator.clipboard.writeText(e), !0);
|
|
686
|
+
} catch {
|
|
687
|
+
return !1;
|
|
688
|
+
}
|
|
372
689
|
}
|
|
373
|
-
function
|
|
374
|
-
const
|
|
375
|
-
|
|
690
|
+
function Fe({ value: e, label: t, compact: n, title: r }) {
|
|
691
|
+
const [o, s] = p("idle"), i = async (h) => {
|
|
692
|
+
h.stopPropagation(), h.preventDefault();
|
|
693
|
+
const w = await tn(e);
|
|
694
|
+
s(w ? "copied" : "error"), window.setTimeout(() => s("idle"), w ? 1200 : 1500);
|
|
695
|
+
}, l = o === "copied" ? "✓" : o === "error" ? "✗" : "⎘", f = r ?? `Copy ${t ?? "id"}: ${e}`, d = /* @__PURE__ */ a(
|
|
696
|
+
"button",
|
|
697
|
+
{
|
|
698
|
+
type: "button",
|
|
699
|
+
className: `id-copy-btn id-copy-${o}`,
|
|
700
|
+
onClick: i,
|
|
701
|
+
title: f,
|
|
702
|
+
"aria-label": f,
|
|
703
|
+
children: l
|
|
704
|
+
}
|
|
705
|
+
);
|
|
706
|
+
return n ? d : /* @__PURE__ */ c("span", { className: "id-copy", children: [
|
|
707
|
+
t && /* @__PURE__ */ a("span", { className: "id-copy-label", children: t }),
|
|
708
|
+
/* @__PURE__ */ a("code", { className: "id-copy-value", title: e, children: e }),
|
|
709
|
+
d
|
|
710
|
+
] });
|
|
711
|
+
}
|
|
712
|
+
function nn(e) {
|
|
713
|
+
const t = /* @__PURE__ */ new Map();
|
|
714
|
+
e.forEach((o) => t.set(o.id, { row: o, children: [] }));
|
|
376
715
|
const n = [];
|
|
377
716
|
e.forEach((o) => {
|
|
378
|
-
const
|
|
379
|
-
o.parent_id &&
|
|
717
|
+
const s = t.get(o.id);
|
|
718
|
+
o.parent_id && t.has(o.parent_id) ? t.get(o.parent_id).children.push(s) : n.push(s);
|
|
380
719
|
});
|
|
381
|
-
const
|
|
382
|
-
o.sort((
|
|
720
|
+
const r = (o) => {
|
|
721
|
+
o.sort((s, i) => s.row.position - i.row.position), o.forEach((s) => r(s.children));
|
|
383
722
|
};
|
|
384
|
-
return
|
|
723
|
+
return r(n), n;
|
|
385
724
|
}
|
|
386
|
-
function
|
|
725
|
+
function Qe(e) {
|
|
387
726
|
return e === "image" ? "🖼" : e === "mermaid" ? "📊" : "";
|
|
388
727
|
}
|
|
389
|
-
function
|
|
728
|
+
function pt(e, t) {
|
|
390
729
|
for (const n of e) {
|
|
391
|
-
if (n.row.id ===
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
730
|
+
if (n.row.id === t) return n;
|
|
731
|
+
const r = pt(n.children, t);
|
|
732
|
+
if (r) return r;
|
|
394
733
|
}
|
|
395
734
|
}
|
|
396
|
-
function
|
|
735
|
+
function an({
|
|
397
736
|
tree: e,
|
|
398
|
-
selectedId:
|
|
737
|
+
selectedId: t,
|
|
399
738
|
onSelect: n,
|
|
400
|
-
colorEnabled:
|
|
739
|
+
colorEnabled: r,
|
|
401
740
|
scheme: o,
|
|
402
|
-
linkedIds:
|
|
741
|
+
linkedIds: s
|
|
403
742
|
}) {
|
|
404
|
-
const [
|
|
405
|
-
|
|
406
|
-
const
|
|
407
|
-
return
|
|
743
|
+
const [i, l] = p(() => /* @__PURE__ */ new Map()), f = P((h) => {
|
|
744
|
+
l((w) => {
|
|
745
|
+
const S = new Map(w);
|
|
746
|
+
return S.set(h, w.get(h) === !1), S;
|
|
408
747
|
});
|
|
409
748
|
}, []);
|
|
410
|
-
|
|
411
|
-
if (!
|
|
412
|
-
const h =
|
|
413
|
-
h.length !== 0 &&
|
|
414
|
-
let
|
|
415
|
-
const
|
|
416
|
-
for (const
|
|
417
|
-
|
|
418
|
-
return
|
|
749
|
+
H(() => {
|
|
750
|
+
if (!t) return;
|
|
751
|
+
const h = rn(e, t);
|
|
752
|
+
h.length !== 0 && l((w) => {
|
|
753
|
+
let S = !1;
|
|
754
|
+
const g = new Map(w);
|
|
755
|
+
for (const N of h)
|
|
756
|
+
g.get(N) === !1 && (g.set(N, !0), S = !0);
|
|
757
|
+
return S ? g : w;
|
|
419
758
|
});
|
|
420
|
-
}, [e,
|
|
421
|
-
const
|
|
422
|
-
return e.length === 0 ? /* @__PURE__ */
|
|
423
|
-
|
|
759
|
+
}, [e, t]);
|
|
760
|
+
const d = r ? Ge(o) : null;
|
|
761
|
+
return e.length === 0 ? /* @__PURE__ */ a("div", { className: "empty", children: /* @__PURE__ */ a("p", { children: "No chunks." }) }) : /* @__PURE__ */ a("ul", { className: "tree chunk-tree", children: e.map((h) => /* @__PURE__ */ a(
|
|
762
|
+
gt,
|
|
424
763
|
{
|
|
425
764
|
node: h,
|
|
426
|
-
expanded:
|
|
427
|
-
toggle:
|
|
428
|
-
selectedId:
|
|
765
|
+
expanded: i,
|
|
766
|
+
toggle: f,
|
|
767
|
+
selectedId: t,
|
|
429
768
|
onSelect: n,
|
|
430
|
-
tintScheme:
|
|
431
|
-
linkedIds:
|
|
769
|
+
tintScheme: d,
|
|
770
|
+
linkedIds: s
|
|
432
771
|
},
|
|
433
772
|
h.row.id
|
|
434
773
|
)) });
|
|
435
774
|
}
|
|
436
|
-
function
|
|
437
|
-
const n = [],
|
|
438
|
-
for (const
|
|
439
|
-
if (
|
|
440
|
-
return n.push(...
|
|
441
|
-
if (
|
|
775
|
+
function rn(e, t) {
|
|
776
|
+
const n = [], r = (o, s) => {
|
|
777
|
+
for (const i of o) {
|
|
778
|
+
if (i.row.id === t)
|
|
779
|
+
return n.push(...s), !0;
|
|
780
|
+
if (r(i.children, [...s, i.row.id])) return !0;
|
|
442
781
|
}
|
|
443
782
|
return !1;
|
|
444
783
|
};
|
|
445
|
-
return
|
|
784
|
+
return r(e, []), n;
|
|
446
785
|
}
|
|
447
|
-
function
|
|
448
|
-
const
|
|
449
|
-
return /* @__PURE__ */
|
|
450
|
-
/* @__PURE__ */
|
|
451
|
-
/* @__PURE__ */
|
|
786
|
+
function gt({ node: e, expanded: t, toggle: n, selectedId: r, onSelect: o, tintScheme: s, linkedIds: i }) {
|
|
787
|
+
const l = e.children.length > 0, f = t.get(e.row.id) !== !1, d = r === e.row.id, h = s ? He(Kt(e.row.status, s)) : void 0, w = i?.has(e.row.id);
|
|
788
|
+
return /* @__PURE__ */ c("li", { className: `node chunk-node ${d ? "selected" : ""}`, children: [
|
|
789
|
+
/* @__PURE__ */ c("div", { className: "row chunk-row", style: h, children: [
|
|
790
|
+
/* @__PURE__ */ a(
|
|
452
791
|
"button",
|
|
453
792
|
{
|
|
454
793
|
type: "button",
|
|
455
794
|
className: "tree-caret",
|
|
456
|
-
"aria-label":
|
|
457
|
-
disabled: !
|
|
458
|
-
onClick: (
|
|
459
|
-
|
|
795
|
+
"aria-label": f ? "collapse" : "expand",
|
|
796
|
+
disabled: !l,
|
|
797
|
+
onClick: (S) => {
|
|
798
|
+
S.stopPropagation(), l && n(e.row.id);
|
|
460
799
|
},
|
|
461
|
-
children:
|
|
800
|
+
children: l ? f ? "▼" : "▶" : "·"
|
|
462
801
|
}
|
|
463
802
|
),
|
|
464
|
-
/* @__PURE__ */
|
|
803
|
+
/* @__PURE__ */ c(
|
|
465
804
|
"button",
|
|
466
805
|
{
|
|
467
806
|
type: "button",
|
|
@@ -469,1491 +808,1631 @@ function Be({ node: e, expanded: r, toggle: n, selectedId: a, onSelect: o, tintS
|
|
|
469
808
|
onClick: () => o(e),
|
|
470
809
|
title: e.row.title,
|
|
471
810
|
children: [
|
|
472
|
-
|
|
473
|
-
/* @__PURE__ */
|
|
474
|
-
e.row.type && /* @__PURE__ */
|
|
475
|
-
e.row.status && /* @__PURE__ */
|
|
476
|
-
|
|
811
|
+
Qe(e.row.type) && /* @__PURE__ */ a("span", { className: "chunk-type-icon", "aria-hidden": !0, children: Qe(e.row.type) }),
|
|
812
|
+
/* @__PURE__ */ a("span", { className: "chunk-title", children: e.row.title || "(untitled)" }),
|
|
813
|
+
e.row.type && /* @__PURE__ */ a("span", { className: "chunk-badge", children: e.row.type }),
|
|
814
|
+
e.row.status && /* @__PURE__ */ a("span", { className: "chunk-badge chunk-status", children: e.row.status }),
|
|
815
|
+
w && /* @__PURE__ */ a("span", { className: "chunk-link-badge", title: "Has cross-reference links", "aria-label": "linked", children: "🔗" })
|
|
477
816
|
]
|
|
478
817
|
}
|
|
479
|
-
)
|
|
818
|
+
),
|
|
819
|
+
/* @__PURE__ */ a(Fe, { value: e.row.id, compact: !0, title: `Copy chunk id: ${e.row.id}` })
|
|
480
820
|
] }),
|
|
481
|
-
|
|
482
|
-
|
|
821
|
+
l && f && /* @__PURE__ */ a("ul", { className: "children chunk-children", children: e.children.map((S) => /* @__PURE__ */ a(
|
|
822
|
+
gt,
|
|
483
823
|
{
|
|
484
|
-
node:
|
|
485
|
-
expanded:
|
|
824
|
+
node: S,
|
|
825
|
+
expanded: t,
|
|
486
826
|
toggle: n,
|
|
487
|
-
selectedId:
|
|
827
|
+
selectedId: r,
|
|
488
828
|
onSelect: o,
|
|
489
|
-
tintScheme:
|
|
490
|
-
linkedIds:
|
|
829
|
+
tintScheme: s,
|
|
830
|
+
linkedIds: i
|
|
491
831
|
},
|
|
492
|
-
|
|
832
|
+
S.row.id
|
|
493
833
|
)) })
|
|
494
834
|
] });
|
|
495
835
|
}
|
|
496
|
-
let
|
|
497
|
-
function
|
|
498
|
-
const
|
|
499
|
-
return
|
|
500
|
-
|
|
836
|
+
let on = 0;
|
|
837
|
+
function sn(e) {
|
|
838
|
+
const t = e?.closest("g.node");
|
|
839
|
+
return t ? /flowchart-(.+)-\d+$/.exec(t.id)?.[1] : void 0;
|
|
840
|
+
}
|
|
841
|
+
function Te({
|
|
842
|
+
code: e,
|
|
843
|
+
onNodeClick: t
|
|
844
|
+
}) {
|
|
845
|
+
const n = te(null), [r, o] = p({});
|
|
846
|
+
return H(() => {
|
|
847
|
+
let s = !1;
|
|
501
848
|
return (async () => {
|
|
502
849
|
try {
|
|
503
|
-
const i = (await import("mermaid")).default,
|
|
504
|
-
i.initialize({ startOnLoad: !1, theme:
|
|
505
|
-
const { svg:
|
|
506
|
-
|
|
850
|
+
const i = (await import("mermaid")).default, l = n.current?.closest("[data-theme]")?.getAttribute("data-theme"), f = l ? l === "dark" : !0;
|
|
851
|
+
i.initialize({ startOnLoad: !1, theme: f ? "dark" : "default", securityLevel: "strict" });
|
|
852
|
+
const { svg: d } = await i.render(`lc-mmd-${on++}`, e);
|
|
853
|
+
s || o({ svg: d });
|
|
507
854
|
} catch {
|
|
508
|
-
|
|
855
|
+
s || o({ err: !0 });
|
|
509
856
|
}
|
|
510
857
|
})(), () => {
|
|
511
|
-
|
|
858
|
+
s = !0;
|
|
512
859
|
};
|
|
513
|
-
}, [e]),
|
|
860
|
+
}, [e]), r.err ? /* @__PURE__ */ a("pre", { className: "md-pre md-mermaid-error", title: "diagram failed to render", children: /* @__PURE__ */ a("code", { children: e }) }) : r.svg ? /* @__PURE__ */ a(
|
|
861
|
+
"div",
|
|
862
|
+
{
|
|
863
|
+
ref: n,
|
|
864
|
+
className: t ? "md-mermaid md-mermaid-nav" : "md-mermaid",
|
|
865
|
+
onClick: t && ((s) => {
|
|
866
|
+
const i = sn(s.target);
|
|
867
|
+
i && t(i);
|
|
868
|
+
}),
|
|
869
|
+
dangerouslySetInnerHTML: { __html: r.svg }
|
|
870
|
+
}
|
|
871
|
+
) : /* @__PURE__ */ a("div", { ref: n, className: "md-mermaid md-mermaid-loading", children: "rendering diagram…" });
|
|
514
872
|
}
|
|
515
|
-
function
|
|
516
|
-
const
|
|
873
|
+
function cn({ chunk: e, scope: t, browse: n, onClose: r, onSaved: o }) {
|
|
874
|
+
const s = be(), [i, l] = p(e.title), [f, d] = p(e.type ?? ""), [h, w] = p(e.status ?? ""), [S, g] = p(e.body ?? ""), [N, y] = p(
|
|
517
875
|
e.fields ? JSON.stringify(e.fields, null, 2) : ""
|
|
518
|
-
), [
|
|
519
|
-
|
|
520
|
-
if (!
|
|
521
|
-
const
|
|
522
|
-
return () => clearTimeout(
|
|
523
|
-
}, [
|
|
524
|
-
const
|
|
525
|
-
|
|
876
|
+
), [j, B] = p((e.tags ?? []).join(", ")), [O, W] = p(!1), [q, I] = p(null), [V, z] = p(!1), Z = f === "mermaid", _ = f === "image" || !!e.asset, [R, E] = p(S);
|
|
877
|
+
H(() => {
|
|
878
|
+
if (!Z) return;
|
|
879
|
+
const x = setTimeout(() => E(S), 400);
|
|
880
|
+
return () => clearTimeout(x);
|
|
881
|
+
}, [S, Z]);
|
|
882
|
+
const m = async (x) => {
|
|
883
|
+
I(null), W(!0);
|
|
526
884
|
try {
|
|
527
|
-
const { mediaType:
|
|
528
|
-
o(
|
|
529
|
-
} catch (
|
|
530
|
-
|
|
885
|
+
const { mediaType: U, data: M } = await mt(x), ne = await s.documentSetAsset(e.id, U, M, x.name, t, n);
|
|
886
|
+
o(ne), r();
|
|
887
|
+
} catch (U) {
|
|
888
|
+
I(U instanceof Error ? U.message : String(U)), W(!1);
|
|
531
889
|
}
|
|
532
890
|
};
|
|
533
|
-
return /* @__PURE__ */
|
|
534
|
-
|
|
535
|
-
const
|
|
536
|
-
body:
|
|
537
|
-
title:
|
|
538
|
-
type:
|
|
891
|
+
return /* @__PURE__ */ a("div", { className: "modal-overlay", onClick: r, children: /* @__PURE__ */ c("form", { className: "modal chunk-editor", onClick: (x) => x.stopPropagation(), onSubmit: async (x) => {
|
|
892
|
+
x.preventDefault(), I(null), z(!1);
|
|
893
|
+
const U = {
|
|
894
|
+
body: S,
|
|
895
|
+
title: i,
|
|
896
|
+
type: f,
|
|
539
897
|
status: h,
|
|
540
898
|
// Parse the comma-separated list; replace-set is intentional (the box shows
|
|
541
899
|
// the chunk's tags, so saving makes it exactly what's in the box).
|
|
542
|
-
tags:
|
|
900
|
+
tags: j.split(",").map((M) => M.trim()).filter((M) => M !== "")
|
|
543
901
|
};
|
|
544
|
-
if (
|
|
902
|
+
if (N.trim() !== "")
|
|
545
903
|
try {
|
|
546
|
-
|
|
904
|
+
U.fields = JSON.parse(N);
|
|
547
905
|
} catch {
|
|
548
|
-
|
|
906
|
+
I("fields must be valid JSON");
|
|
549
907
|
return;
|
|
550
908
|
}
|
|
551
|
-
|
|
909
|
+
W(!0);
|
|
552
910
|
try {
|
|
553
|
-
const
|
|
554
|
-
o(
|
|
555
|
-
} catch (
|
|
556
|
-
const
|
|
557
|
-
|
|
911
|
+
const M = await s.documentUpdateChunk(e.id, e.revision, U, t, n);
|
|
912
|
+
o(M), r();
|
|
913
|
+
} catch (M) {
|
|
914
|
+
const ne = M instanceof Error ? M.message : String(M);
|
|
915
|
+
I(ne), z(/revision conflict/i.test(ne)), W(!1);
|
|
558
916
|
}
|
|
559
917
|
}, children: [
|
|
560
|
-
/* @__PURE__ */
|
|
561
|
-
/* @__PURE__ */
|
|
562
|
-
/* @__PURE__ */
|
|
563
|
-
/* @__PURE__ */
|
|
564
|
-
/* @__PURE__ */
|
|
918
|
+
/* @__PURE__ */ c("div", { className: "modal-header sticky-top", children: [
|
|
919
|
+
/* @__PURE__ */ a("h3", { children: "Edit chunk" }),
|
|
920
|
+
/* @__PURE__ */ c("div", { className: "modal-buttons modal-buttons-top", children: [
|
|
921
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: r, disabled: O, children: "cancel" }),
|
|
922
|
+
/* @__PURE__ */ a("button", { type: "submit", className: "primary", disabled: O, children: O ? "saving…" : "save" })
|
|
565
923
|
] })
|
|
566
924
|
] }),
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
925
|
+
q && /* @__PURE__ */ c("div", { className: "modal-err", children: [
|
|
926
|
+
q,
|
|
927
|
+
V && " — reopen the chunk to load the latest, then reapply your edit."
|
|
570
928
|
] }),
|
|
571
|
-
/* @__PURE__ */
|
|
572
|
-
/* @__PURE__ */
|
|
573
|
-
/* @__PURE__ */
|
|
929
|
+
/* @__PURE__ */ c("label", { className: "path-field", children: [
|
|
930
|
+
/* @__PURE__ */ a("span", { children: "Title" }),
|
|
931
|
+
/* @__PURE__ */ a("input", { className: "path-modal-input", value: i, onChange: (x) => l(x.target.value) })
|
|
574
932
|
] }),
|
|
575
|
-
/* @__PURE__ */
|
|
576
|
-
/* @__PURE__ */
|
|
577
|
-
/* @__PURE__ */
|
|
578
|
-
/* @__PURE__ */
|
|
933
|
+
/* @__PURE__ */ c("div", { className: "chunk-editor-row", children: [
|
|
934
|
+
/* @__PURE__ */ c("label", { className: "path-field", children: [
|
|
935
|
+
/* @__PURE__ */ a("span", { children: "Type" }),
|
|
936
|
+
/* @__PURE__ */ a(
|
|
579
937
|
"input",
|
|
580
938
|
{
|
|
581
939
|
className: "path-modal-input",
|
|
582
|
-
value:
|
|
940
|
+
value: f,
|
|
583
941
|
placeholder: "(none)",
|
|
584
|
-
onChange: (
|
|
942
|
+
onChange: (x) => d(x.target.value)
|
|
585
943
|
}
|
|
586
944
|
)
|
|
587
945
|
] }),
|
|
588
|
-
/* @__PURE__ */
|
|
589
|
-
/* @__PURE__ */
|
|
590
|
-
/* @__PURE__ */
|
|
946
|
+
/* @__PURE__ */ c("label", { className: "path-field", children: [
|
|
947
|
+
/* @__PURE__ */ a("span", { children: "Status" }),
|
|
948
|
+
/* @__PURE__ */ a(
|
|
591
949
|
"input",
|
|
592
950
|
{
|
|
593
951
|
className: "path-modal-input",
|
|
594
952
|
value: h,
|
|
595
953
|
placeholder: "(none)",
|
|
596
|
-
onChange: (
|
|
954
|
+
onChange: (x) => w(x.target.value)
|
|
597
955
|
}
|
|
598
956
|
)
|
|
599
957
|
] })
|
|
600
958
|
] }),
|
|
601
|
-
/* @__PURE__ */
|
|
602
|
-
/* @__PURE__ */
|
|
603
|
-
/* @__PURE__ */
|
|
959
|
+
/* @__PURE__ */ c("label", { className: "path-field", children: [
|
|
960
|
+
/* @__PURE__ */ a("span", { children: "Tags" }),
|
|
961
|
+
/* @__PURE__ */ a(
|
|
604
962
|
"input",
|
|
605
963
|
{
|
|
606
964
|
className: "path-modal-input",
|
|
607
|
-
value:
|
|
965
|
+
value: j,
|
|
608
966
|
placeholder: "comma-separated, nest with a slash: area/sub, priority/high",
|
|
609
|
-
onChange: (
|
|
967
|
+
onChange: (x) => B(x.target.value)
|
|
610
968
|
}
|
|
611
969
|
)
|
|
612
970
|
] }),
|
|
613
|
-
|
|
614
|
-
/* @__PURE__ */
|
|
615
|
-
/* @__PURE__ */
|
|
971
|
+
_ && /* @__PURE__ */ c("label", { className: "path-field", children: [
|
|
972
|
+
/* @__PURE__ */ a("span", { children: "Replace image" }),
|
|
973
|
+
/* @__PURE__ */ a(
|
|
616
974
|
"input",
|
|
617
975
|
{
|
|
618
976
|
type: "file",
|
|
619
977
|
accept: "image/png,image/jpeg,image/gif,image/webp",
|
|
620
|
-
disabled:
|
|
621
|
-
onChange: (
|
|
622
|
-
const
|
|
623
|
-
|
|
978
|
+
disabled: O,
|
|
979
|
+
onChange: (x) => {
|
|
980
|
+
const U = x.target.files?.[0];
|
|
981
|
+
U && m(U);
|
|
624
982
|
}
|
|
625
983
|
}
|
|
626
984
|
)
|
|
627
985
|
] }),
|
|
628
|
-
/* @__PURE__ */
|
|
629
|
-
/* @__PURE__ */
|
|
630
|
-
/* @__PURE__ */
|
|
986
|
+
/* @__PURE__ */ c("label", { className: "path-field", children: [
|
|
987
|
+
/* @__PURE__ */ a("span", { children: Z ? "Mermaid source" : _ ? "Caption (optional)" : "Body (Markdown)" }),
|
|
988
|
+
/* @__PURE__ */ a(
|
|
631
989
|
"textarea",
|
|
632
990
|
{
|
|
633
991
|
className: "modal-textarea chunk-body-input",
|
|
634
|
-
rows:
|
|
635
|
-
value:
|
|
636
|
-
onChange: (
|
|
992
|
+
rows: Z ? 8 : 12,
|
|
993
|
+
value: S,
|
|
994
|
+
onChange: (x) => g(x.target.value)
|
|
637
995
|
}
|
|
638
996
|
)
|
|
639
997
|
] }),
|
|
640
|
-
|
|
641
|
-
/* @__PURE__ */
|
|
642
|
-
/* @__PURE__ */
|
|
998
|
+
Z && /* @__PURE__ */ c("div", { className: "path-field", children: [
|
|
999
|
+
/* @__PURE__ */ a("span", { children: "Preview" }),
|
|
1000
|
+
/* @__PURE__ */ a("div", { className: "chunk-mermaid-preview", children: R.trim() ? /* @__PURE__ */ a(Te, { code: R }) : /* @__PURE__ */ a("p", { className: "doc-empty-body", children: "(enter Mermaid source above)" }) })
|
|
643
1001
|
] }),
|
|
644
|
-
/* @__PURE__ */
|
|
645
|
-
/* @__PURE__ */
|
|
646
|
-
/* @__PURE__ */
|
|
1002
|
+
/* @__PURE__ */ c("label", { className: "path-field", children: [
|
|
1003
|
+
/* @__PURE__ */ a("span", { children: "Fields (JSON, optional)" }),
|
|
1004
|
+
/* @__PURE__ */ a(
|
|
647
1005
|
"textarea",
|
|
648
1006
|
{
|
|
649
1007
|
className: "modal-textarea chunk-fields-input",
|
|
650
1008
|
rows: 4,
|
|
651
|
-
value:
|
|
1009
|
+
value: N,
|
|
652
1010
|
placeholder: "{}",
|
|
653
|
-
onChange: (
|
|
1011
|
+
onChange: (x) => y(x.target.value)
|
|
654
1012
|
}
|
|
655
1013
|
)
|
|
656
1014
|
] })
|
|
657
1015
|
] }) });
|
|
658
1016
|
}
|
|
659
|
-
function
|
|
660
|
-
const
|
|
661
|
-
if (!
|
|
662
|
-
let n =
|
|
1017
|
+
function ln(e) {
|
|
1018
|
+
const t = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec((e ?? "").trim());
|
|
1019
|
+
if (!t) return "#888888";
|
|
1020
|
+
let n = t[1];
|
|
663
1021
|
return n.length === 3 && (n = n[0] + n[0] + n[1] + n[1] + n[2] + n[2]), "#" + n.toLowerCase();
|
|
664
1022
|
}
|
|
665
|
-
function
|
|
1023
|
+
function dn({
|
|
666
1024
|
documentId: e,
|
|
667
|
-
rootChunkId:
|
|
1025
|
+
rootChunkId: t,
|
|
668
1026
|
docType: n,
|
|
669
|
-
docStatus:
|
|
1027
|
+
docStatus: r,
|
|
670
1028
|
chunkStatuses: o,
|
|
671
|
-
scope:
|
|
672
|
-
browse:
|
|
673
|
-
onClose:
|
|
674
|
-
onSaved:
|
|
1029
|
+
scope: s,
|
|
1030
|
+
browse: i,
|
|
1031
|
+
onClose: l,
|
|
1032
|
+
onSaved: f
|
|
675
1033
|
}) {
|
|
676
|
-
const
|
|
677
|
-
const b = new Set(Object.keys(
|
|
678
|
-
n && b.add(`doc.${n}.${
|
|
679
|
-
for (const
|
|
1034
|
+
const d = be(), [h, w] = p(null), [S, g] = p(!1), [N, y] = p({}), [j, B] = p(!1), [O, W] = p(null), [q, I] = p(null), V = X(() => {
|
|
1035
|
+
const b = new Set(Object.keys(Be));
|
|
1036
|
+
n && b.add(`doc.${n}.${r || "draft"}`);
|
|
1037
|
+
for (const C of o) C && b.add(`chunk.${C}`);
|
|
680
1038
|
return [...b].sort();
|
|
681
|
-
}, [n,
|
|
682
|
-
|
|
1039
|
+
}, [n, r, o]);
|
|
1040
|
+
H(() => {
|
|
683
1041
|
let b = !1;
|
|
684
|
-
return
|
|
1042
|
+
return d.documentGetChunk(t, s, i).then((C) => {
|
|
685
1043
|
if (b) return;
|
|
686
|
-
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
}).catch((
|
|
1044
|
+
w(C);
|
|
1045
|
+
const x = C.fields ?? {};
|
|
1046
|
+
g(x.color_enabled === !0);
|
|
1047
|
+
const U = x.color_scheme ?? {};
|
|
1048
|
+
y({ ...Be, ...U });
|
|
1049
|
+
}).catch((C) => !b && I(C instanceof Error ? C.message : String(C))), () => {
|
|
692
1050
|
b = !0;
|
|
693
1051
|
};
|
|
694
|
-
}, [
|
|
695
|
-
const
|
|
1052
|
+
}, [d, t, s, i]);
|
|
1053
|
+
const z = (b, C) => y((x) => ({ ...x, [b]: C })), Z = (b) => ({
|
|
696
1054
|
...b ?? {},
|
|
697
|
-
color_enabled:
|
|
698
|
-
color_scheme:
|
|
699
|
-
}),
|
|
1055
|
+
color_enabled: S,
|
|
1056
|
+
color_scheme: N
|
|
1057
|
+
}), _ = async () => {
|
|
700
1058
|
if (h) {
|
|
701
|
-
|
|
1059
|
+
B(!0), I(null), W(null);
|
|
702
1060
|
try {
|
|
703
|
-
await
|
|
704
|
-
|
|
1061
|
+
await d.documentUpdateChunk(
|
|
1062
|
+
t,
|
|
705
1063
|
h.revision,
|
|
706
|
-
{ fields:
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
),
|
|
1064
|
+
{ fields: Z(h.fields) },
|
|
1065
|
+
s,
|
|
1066
|
+
i
|
|
1067
|
+
), f(), l();
|
|
710
1068
|
} catch (b) {
|
|
711
|
-
|
|
1069
|
+
I(b instanceof Error ? b.message : String(b)), B(!1);
|
|
712
1070
|
}
|
|
713
1071
|
}
|
|
714
|
-
},
|
|
1072
|
+
}, R = async () => {
|
|
715
1073
|
if (!n) {
|
|
716
|
-
|
|
1074
|
+
I("this document has no type to match");
|
|
717
1075
|
return;
|
|
718
1076
|
}
|
|
719
|
-
|
|
1077
|
+
B(!0), I(null), W(null);
|
|
720
1078
|
try {
|
|
721
|
-
const { documents: b } = await
|
|
722
|
-
(
|
|
1079
|
+
const { documents: b } = await d.documentsSummary({ underPath: "/" }, s, i), C = (b ?? []).filter(
|
|
1080
|
+
(U) => U.type === n && U.document_id !== e && U.root_chunk_id
|
|
723
1081
|
);
|
|
724
|
-
let
|
|
725
|
-
for (const
|
|
1082
|
+
let x = 0;
|
|
1083
|
+
for (const U of C)
|
|
726
1084
|
try {
|
|
727
|
-
const
|
|
728
|
-
await
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
{ fields:
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
),
|
|
1085
|
+
const M = await d.documentGetChunk(U.root_chunk_id, s, i);
|
|
1086
|
+
await d.documentUpdateChunk(
|
|
1087
|
+
U.root_chunk_id,
|
|
1088
|
+
M.revision,
|
|
1089
|
+
{ fields: Z(M.fields) },
|
|
1090
|
+
s,
|
|
1091
|
+
i
|
|
1092
|
+
), x++;
|
|
735
1093
|
} catch {
|
|
736
1094
|
}
|
|
737
|
-
|
|
1095
|
+
W(`Applied to ${x} other ${n} document(s).`), f();
|
|
738
1096
|
} catch (b) {
|
|
739
|
-
|
|
1097
|
+
I(b instanceof Error ? b.message : String(b));
|
|
740
1098
|
} finally {
|
|
741
|
-
|
|
1099
|
+
B(!1);
|
|
742
1100
|
}
|
|
743
|
-
},
|
|
744
|
-
return /* @__PURE__ */
|
|
745
|
-
/* @__PURE__ */
|
|
746
|
-
/* @__PURE__ */
|
|
747
|
-
/* @__PURE__ */
|
|
748
|
-
/* @__PURE__ */
|
|
749
|
-
/* @__PURE__ */
|
|
750
|
-
|
|
751
|
-
}, disabled:
|
|
1101
|
+
}, E = V.filter((b) => b.startsWith("doc.")), m = V.filter((b) => b.startsWith("chunk."));
|
|
1102
|
+
return /* @__PURE__ */ a("div", { className: "modal-overlay", onClick: l, children: /* @__PURE__ */ c("div", { className: "modal scheme-editor", onClick: (b) => b.stopPropagation(), children: [
|
|
1103
|
+
/* @__PURE__ */ c("div", { className: "scheme-editor-head", children: [
|
|
1104
|
+
/* @__PURE__ */ a("h3", { children: "Document colors" }),
|
|
1105
|
+
/* @__PURE__ */ c("div", { className: "scheme-editor-actions", children: [
|
|
1106
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: l, disabled: j, children: "cancel" }),
|
|
1107
|
+
/* @__PURE__ */ a("button", { type: "button", className: "primary", onClick: () => {
|
|
1108
|
+
_();
|
|
1109
|
+
}, disabled: j || !h, children: j ? "saving…" : "save" })
|
|
752
1110
|
] })
|
|
753
1111
|
] }),
|
|
754
|
-
|
|
755
|
-
h ? /* @__PURE__ */
|
|
756
|
-
/* @__PURE__ */
|
|
757
|
-
/* @__PURE__ */
|
|
1112
|
+
q && /* @__PURE__ */ a("div", { className: "modal-err", children: q }),
|
|
1113
|
+
h ? /* @__PURE__ */ c(Q, { children: [
|
|
1114
|
+
/* @__PURE__ */ c("label", { className: "scheme-toggle", children: [
|
|
1115
|
+
/* @__PURE__ */ a(
|
|
758
1116
|
"input",
|
|
759
1117
|
{
|
|
760
1118
|
type: "checkbox",
|
|
761
|
-
checked:
|
|
762
|
-
onChange: (b) =>
|
|
1119
|
+
checked: S,
|
|
1120
|
+
onChange: (b) => g(b.target.checked)
|
|
763
1121
|
}
|
|
764
1122
|
),
|
|
765
|
-
/* @__PURE__ */
|
|
1123
|
+
/* @__PURE__ */ a("span", { children: "Enable coloring for this document" })
|
|
766
1124
|
] }),
|
|
767
|
-
/* @__PURE__ */
|
|
768
|
-
/* @__PURE__ */
|
|
769
|
-
/* @__PURE__ */
|
|
770
|
-
|
|
1125
|
+
/* @__PURE__ */ a("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." }),
|
|
1126
|
+
/* @__PURE__ */ c("div", { className: "scheme-group", children: [
|
|
1127
|
+
/* @__PURE__ */ a("h4", { children: "Document (type · status)" }),
|
|
1128
|
+
E.map((b) => /* @__PURE__ */ a(Ye, { label: b.slice(4), value: N[b], onChange: (C) => z(b, C) }, b))
|
|
771
1129
|
] }),
|
|
772
|
-
/* @__PURE__ */
|
|
773
|
-
/* @__PURE__ */
|
|
774
|
-
|
|
1130
|
+
/* @__PURE__ */ c("div", { className: "scheme-group", children: [
|
|
1131
|
+
/* @__PURE__ */ a("h4", { children: "Chunks (status)" }),
|
|
1132
|
+
m.map((b) => /* @__PURE__ */ a(Ye, { label: b.slice(6), value: N[b], onChange: (C) => z(b, C) }, b))
|
|
775
1133
|
] }),
|
|
776
|
-
/* @__PURE__ */
|
|
777
|
-
/* @__PURE__ */
|
|
778
|
-
|
|
779
|
-
}, disabled:
|
|
1134
|
+
/* @__PURE__ */ c("div", { className: "scheme-editor-foot", children: [
|
|
1135
|
+
/* @__PURE__ */ c("button", { type: "button", onClick: () => {
|
|
1136
|
+
R();
|
|
1137
|
+
}, disabled: j || !n, title: n ? `Apply this palette to every other ${n} document` : "This document has no type", children: [
|
|
780
1138
|
"copy to all ",
|
|
781
1139
|
n || "same-type",
|
|
782
1140
|
" documents"
|
|
783
1141
|
] }),
|
|
784
|
-
|
|
1142
|
+
O && /* @__PURE__ */ a("span", { className: "scheme-status", children: O })
|
|
785
1143
|
] })
|
|
786
|
-
] }) : /* @__PURE__ */
|
|
1144
|
+
] }) : /* @__PURE__ */ a("p", { className: "modal-context", children: "Loading…" })
|
|
787
1145
|
] }) });
|
|
788
1146
|
}
|
|
789
|
-
function
|
|
790
|
-
const
|
|
791
|
-
return /* @__PURE__ */
|
|
792
|
-
/* @__PURE__ */
|
|
793
|
-
/* @__PURE__ */
|
|
794
|
-
/* @__PURE__ */
|
|
1147
|
+
function Ye({ label: e, value: t, onChange: n }) {
|
|
1148
|
+
const r = ln(t);
|
|
1149
|
+
return /* @__PURE__ */ c("label", { className: "scheme-row", children: [
|
|
1150
|
+
/* @__PURE__ */ a("input", { type: "color", value: r, onChange: (o) => n(o.target.value) }),
|
|
1151
|
+
/* @__PURE__ */ a("span", { className: "scheme-key", children: e }),
|
|
1152
|
+
/* @__PURE__ */ a("code", { className: "scheme-hex", children: r })
|
|
795
1153
|
] });
|
|
796
1154
|
}
|
|
797
|
-
|
|
798
|
-
|
|
1155
|
+
function yt({
|
|
1156
|
+
id: e,
|
|
1157
|
+
title: t,
|
|
1158
|
+
targetDocumentId: n,
|
|
1159
|
+
documentId: r,
|
|
1160
|
+
onSelectChunk: o,
|
|
1161
|
+
onOpenDocument: s
|
|
1162
|
+
}) {
|
|
1163
|
+
const i = t || e.slice(0, 8);
|
|
1164
|
+
return !n || n === r ? /* @__PURE__ */ a("button", { type: "button", className: "doc-ref-target", onClick: () => o(e), children: i }) : s ? /* @__PURE__ */ c(
|
|
1165
|
+
"button",
|
|
1166
|
+
{
|
|
1167
|
+
type: "button",
|
|
1168
|
+
className: "doc-ref-target external",
|
|
1169
|
+
title: "In another document — opens it at this chunk",
|
|
1170
|
+
onClick: () => s(n, e, t),
|
|
1171
|
+
children: [
|
|
1172
|
+
i,
|
|
1173
|
+
" ↗"
|
|
1174
|
+
]
|
|
1175
|
+
}
|
|
1176
|
+
) : /* @__PURE__ */ c("span", { className: "doc-ref-target external", title: "In another document", children: [
|
|
1177
|
+
i,
|
|
1178
|
+
" ↗"
|
|
1179
|
+
] });
|
|
1180
|
+
}
|
|
1181
|
+
const un = 8, hn = 20;
|
|
1182
|
+
function mn(e) {
|
|
799
1183
|
return /embedder|embedding|vector|semantic|not configured/i.test(e);
|
|
800
1184
|
}
|
|
801
|
-
function
|
|
1185
|
+
function fn({
|
|
802
1186
|
documentId: e,
|
|
803
|
-
selectedId:
|
|
1187
|
+
selectedId: t,
|
|
804
1188
|
scope: n,
|
|
805
|
-
browse:
|
|
806
|
-
onSelectChunk: o
|
|
1189
|
+
browse: r,
|
|
1190
|
+
onSelectChunk: o,
|
|
1191
|
+
onOpenDocument: s
|
|
807
1192
|
}) {
|
|
808
|
-
const i =
|
|
809
|
-
|
|
810
|
-
if (!
|
|
811
|
-
const
|
|
812
|
-
let
|
|
813
|
-
return
|
|
814
|
-
i.documentBacklinks(
|
|
815
|
-
i.documentRelated(
|
|
816
|
-
i.documentUnlinkedMentions(
|
|
817
|
-
]).then(([
|
|
818
|
-
if (!
|
|
819
|
-
if (
|
|
820
|
-
|
|
1193
|
+
const i = be(), [l, f] = p(!1), [d, h] = p(!1), [w, S] = p(void 0), [g, N] = p([]), [y, j] = p([]), [B, O] = p(null), [W, q] = p([]), [I, V] = p(!1);
|
|
1194
|
+
H(() => {
|
|
1195
|
+
if (!l || !t) return;
|
|
1196
|
+
const _ = t;
|
|
1197
|
+
let R = !1;
|
|
1198
|
+
return h(!0), Promise.allSettled([
|
|
1199
|
+
i.documentBacklinks(_, n, r),
|
|
1200
|
+
i.documentRelated(_, n, r, un),
|
|
1201
|
+
i.documentUnlinkedMentions(_, n, r, hn)
|
|
1202
|
+
]).then(([E, m, b]) => {
|
|
1203
|
+
if (!R) {
|
|
1204
|
+
if (N(E.status === "fulfilled" ? E.value.backlinks ?? [] : []), m.status === "fulfilled")
|
|
1205
|
+
j(m.value.related ?? []), O(null);
|
|
821
1206
|
else {
|
|
822
|
-
|
|
823
|
-
const
|
|
824
|
-
|
|
1207
|
+
j([]);
|
|
1208
|
+
const C = m.reason instanceof Error ? m.reason.message : String(m.reason);
|
|
1209
|
+
O(mn(C) ? "semantic search not configured" : C);
|
|
825
1210
|
}
|
|
826
|
-
|
|
1211
|
+
b.status === "fulfilled" ? (q(b.value.unlinked_mentions ?? []), V(!!b.value.truncated)) : (q([]), V(!1)), S(_), h(!1);
|
|
827
1212
|
}
|
|
828
1213
|
}), () => {
|
|
829
|
-
|
|
1214
|
+
R = !0;
|
|
830
1215
|
};
|
|
831
|
-
}, [i,
|
|
832
|
-
const
|
|
833
|
-
|
|
834
|
-
|
|
1216
|
+
}, [i, l, t, n, r]);
|
|
1217
|
+
const z = (_, R, E) => /* @__PURE__ */ a(
|
|
1218
|
+
yt,
|
|
1219
|
+
{
|
|
1220
|
+
id: _,
|
|
1221
|
+
title: R,
|
|
1222
|
+
targetDocumentId: E,
|
|
1223
|
+
documentId: e,
|
|
1224
|
+
onSelectChunk: o,
|
|
1225
|
+
onOpenDocument: s
|
|
1226
|
+
}
|
|
1227
|
+
);
|
|
1228
|
+
return /* @__PURE__ */ c("div", { className: "doc-conn", children: [
|
|
1229
|
+
/* @__PURE__ */ c(
|
|
835
1230
|
"button",
|
|
836
1231
|
{
|
|
837
1232
|
type: "button",
|
|
838
1233
|
className: "doc-conn-toggle",
|
|
839
|
-
onClick: () =>
|
|
1234
|
+
onClick: () => f((_) => !_),
|
|
840
1235
|
children: [
|
|
841
|
-
|
|
1236
|
+
l ? "▼" : "▶",
|
|
842
1237
|
" Connections"
|
|
843
1238
|
]
|
|
844
1239
|
}
|
|
845
1240
|
),
|
|
846
|
-
|
|
847
|
-
/* @__PURE__ */
|
|
848
|
-
/* @__PURE__ */
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
title: y.from_title,
|
|
855
|
-
crossDoc: G(y.from_document_id),
|
|
856
|
-
onSelect: o
|
|
857
|
-
}
|
|
858
|
-
),
|
|
859
|
-
/* @__PURE__ */ t("span", { className: "doc-ref-kind", children: y.kind }),
|
|
860
|
-
y.auto && /* @__PURE__ */ t("span", { className: "doc-conn-auto", title: "Auto-linked from a [[wikilink]]", children: "auto" })
|
|
861
|
-
] }, `${y.from_id}-${y.kind}-${D}`)) })
|
|
1241
|
+
l && /* @__PURE__ */ a("div", { className: "doc-conn-body", children: t ? !!(l && t && !d && w === t) ? /* @__PURE__ */ c(Q, { children: [
|
|
1242
|
+
/* @__PURE__ */ c("div", { className: "doc-conn-group", children: [
|
|
1243
|
+
/* @__PURE__ */ a("h5", { children: "Backlinks" }),
|
|
1244
|
+
g.length === 0 ? /* @__PURE__ */ a("p", { className: "doc-conn-empty", children: "none" }) : /* @__PURE__ */ a("ul", { className: "doc-conn-list", children: g.map((_, R) => /* @__PURE__ */ c("li", { className: "doc-conn-row", children: [
|
|
1245
|
+
z(_.from_id, _.from_title, _.from_document_id),
|
|
1246
|
+
/* @__PURE__ */ a("span", { className: "doc-ref-kind", children: _.kind }),
|
|
1247
|
+
_.auto && /* @__PURE__ */ a("span", { className: "doc-conn-auto", title: "Auto-linked from a [[wikilink]]", children: "auto" })
|
|
1248
|
+
] }, `${_.from_id}-${_.kind}-${R}`)) })
|
|
862
1249
|
] }),
|
|
863
|
-
/* @__PURE__ */
|
|
864
|
-
/* @__PURE__ */
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
id: y.chunk_id,
|
|
870
|
-
title: y.title,
|
|
871
|
-
crossDoc: G(y.document_id),
|
|
872
|
-
onSelect: o
|
|
873
|
-
}
|
|
874
|
-
),
|
|
875
|
-
/* @__PURE__ */ t("span", { className: "doc-conn-score", title: "similarity score", children: y.score.toFixed(2) })
|
|
876
|
-
] }, `${y.chunk_id}-${D}`)) })
|
|
1250
|
+
/* @__PURE__ */ c("div", { className: "doc-conn-group", children: [
|
|
1251
|
+
/* @__PURE__ */ a("h5", { children: "Related" }),
|
|
1252
|
+
B ? /* @__PURE__ */ a("p", { className: "doc-conn-empty", children: B }) : y.length === 0 ? /* @__PURE__ */ a("p", { className: "doc-conn-empty", children: "none" }) : /* @__PURE__ */ a("ul", { className: "doc-conn-list", children: y.map((_, R) => /* @__PURE__ */ c("li", { className: "doc-conn-row", children: [
|
|
1253
|
+
z(_.chunk_id, _.title, _.document_id),
|
|
1254
|
+
/* @__PURE__ */ a("span", { className: "doc-conn-score", title: "similarity score", children: _.score.toFixed(2) })
|
|
1255
|
+
] }, `${_.chunk_id}-${R}`)) })
|
|
877
1256
|
] }),
|
|
878
|
-
/* @__PURE__ */
|
|
879
|
-
/* @__PURE__ */
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
{
|
|
884
|
-
id: y.chunk_id,
|
|
885
|
-
title: y.title,
|
|
886
|
-
crossDoc: G(y.document_id),
|
|
887
|
-
onSelect: o
|
|
888
|
-
}
|
|
889
|
-
) }, `${y.chunk_id}-${D}`)),
|
|
890
|
-
j && /* @__PURE__ */ t("li", { className: "doc-conn-more", "aria-hidden": !0, children: "(more…)" })
|
|
1257
|
+
/* @__PURE__ */ c("div", { className: "doc-conn-group", children: [
|
|
1258
|
+
/* @__PURE__ */ a("h5", { children: "Unlinked mentions" }),
|
|
1259
|
+
W.length === 0 ? /* @__PURE__ */ a("p", { className: "doc-conn-empty", children: "none" }) : /* @__PURE__ */ c("ul", { className: "doc-conn-list", children: [
|
|
1260
|
+
W.map((_, R) => /* @__PURE__ */ a("li", { className: "doc-conn-row", children: z(_.chunk_id, _.title, _.document_id) }, `${_.chunk_id}-${R}`)),
|
|
1261
|
+
I && /* @__PURE__ */ a("li", { className: "doc-conn-more", "aria-hidden": !0, children: "(more…)" })
|
|
891
1262
|
] })
|
|
892
1263
|
] })
|
|
893
|
-
] }) : /* @__PURE__ */
|
|
1264
|
+
] }) : /* @__PURE__ */ a("p", { className: "doc-conn-empty", children: "loading…" }) : /* @__PURE__ */ a("p", { className: "doc-conn-empty", children: "Select a chunk." }) })
|
|
894
1265
|
] });
|
|
895
1266
|
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
title: r,
|
|
899
|
-
crossDoc: n,
|
|
900
|
-
onSelect: a
|
|
901
|
-
}) {
|
|
902
|
-
const o = r || e.slice(0, 8);
|
|
903
|
-
return n ? /* @__PURE__ */ l("span", { className: "doc-ref-target external", title: "In another document", children: [
|
|
904
|
-
o,
|
|
905
|
-
" ↗"
|
|
906
|
-
] }) : /* @__PURE__ */ t("button", { type: "button", className: "doc-ref-target", onClick: () => a(e), children: o });
|
|
907
|
-
}
|
|
908
|
-
const ye = 24;
|
|
909
|
-
function Dt({
|
|
1267
|
+
const Ae = 24;
|
|
1268
|
+
function pn({
|
|
910
1269
|
edges: e,
|
|
911
|
-
documentId:
|
|
1270
|
+
documentId: t,
|
|
912
1271
|
selectedId: n,
|
|
913
|
-
onSelectChunk:
|
|
1272
|
+
onSelectChunk: r,
|
|
1273
|
+
onOpenDocument: o
|
|
914
1274
|
}) {
|
|
915
|
-
const [
|
|
1275
|
+
const [s, i] = p(!1), [l, f] = p(!1);
|
|
916
1276
|
if (e.length === 0) return null;
|
|
917
|
-
const
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
1277
|
+
const d = n ? e.filter((g) => g.from_id === n || g.to_id === n) : [], h = l ? e : e.slice(0, Ae), w = yn(h), S = (g) => {
|
|
1278
|
+
const N = bn(h, g);
|
|
1279
|
+
N && (!N.documentId || N.documentId === t ? r(N.id) : o?.(N.documentId, N.id, N.title));
|
|
1280
|
+
};
|
|
1281
|
+
return /* @__PURE__ */ c("div", { className: "doc-refs", children: [
|
|
1282
|
+
n && /* @__PURE__ */ c("div", { className: "doc-refs-list-wrap", children: [
|
|
1283
|
+
/* @__PURE__ */ a("h4", { children: "References" }),
|
|
1284
|
+
d.length === 0 ? /* @__PURE__ */ a("p", { className: "doc-refs-empty", children: "This chunk has no links." }) : /* @__PURE__ */ a("ul", { className: "doc-refs-list", children: d.map((g, N) => /* @__PURE__ */ a(
|
|
1285
|
+
gn,
|
|
923
1286
|
{
|
|
924
|
-
edge:
|
|
1287
|
+
edge: g,
|
|
925
1288
|
selectedId: n,
|
|
926
|
-
documentId:
|
|
927
|
-
onSelectChunk:
|
|
1289
|
+
documentId: t,
|
|
1290
|
+
onSelectChunk: r,
|
|
1291
|
+
onOpenDocument: o
|
|
928
1292
|
},
|
|
929
|
-
`${
|
|
1293
|
+
`${g.from_id}-${g.to_id}-${g.kind}-${N}`
|
|
930
1294
|
)) })
|
|
931
1295
|
] }),
|
|
932
|
-
/* @__PURE__ */
|
|
933
|
-
/* @__PURE__ */
|
|
934
|
-
|
|
1296
|
+
/* @__PURE__ */ c("div", { className: "doc-graph", children: [
|
|
1297
|
+
/* @__PURE__ */ c("button", { type: "button", className: "doc-graph-toggle", onClick: () => i((g) => !g), children: [
|
|
1298
|
+
s ? "▼" : "▶",
|
|
935
1299
|
" relationship graph (",
|
|
936
1300
|
e.length,
|
|
937
1301
|
")"
|
|
938
1302
|
] }),
|
|
939
|
-
|
|
940
|
-
/* @__PURE__ */
|
|
941
|
-
e.length >
|
|
1303
|
+
s && /* @__PURE__ */ c(Q, { children: [
|
|
1304
|
+
/* @__PURE__ */ a(Te, { code: w, onNodeClick: S }),
|
|
1305
|
+
e.length > Ae && /* @__PURE__ */ a("button", { type: "button", className: "doc-graph-more", onClick: () => f((g) => !g), children: l ? `show top ${Ae}` : `show all ${e.length}` })
|
|
942
1306
|
] })
|
|
943
1307
|
] })
|
|
944
1308
|
] });
|
|
945
1309
|
}
|
|
946
|
-
function
|
|
1310
|
+
function gn({
|
|
947
1311
|
edge: e,
|
|
948
|
-
selectedId:
|
|
1312
|
+
selectedId: t,
|
|
949
1313
|
documentId: n,
|
|
950
|
-
onSelectChunk:
|
|
1314
|
+
onSelectChunk: r,
|
|
1315
|
+
onOpenDocument: o
|
|
951
1316
|
}) {
|
|
952
|
-
const
|
|
953
|
-
return /* @__PURE__ */
|
|
954
|
-
/* @__PURE__ */
|
|
955
|
-
/* @__PURE__ */
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
1317
|
+
const s = e.from_id === t, i = s ? e.to_id : e.from_id, l = s ? e.to_title : e.from_title, f = s ? e.to_document_id : e.from_document_id;
|
|
1318
|
+
return /* @__PURE__ */ c("li", { className: "doc-ref", children: [
|
|
1319
|
+
/* @__PURE__ */ a("span", { className: "doc-ref-kind", children: e.kind }),
|
|
1320
|
+
/* @__PURE__ */ a("span", { className: "doc-ref-arrow", "aria-hidden": !0, children: s ? "→" : "←" }),
|
|
1321
|
+
/* @__PURE__ */ a(
|
|
1322
|
+
yt,
|
|
1323
|
+
{
|
|
1324
|
+
id: i,
|
|
1325
|
+
title: l,
|
|
1326
|
+
targetDocumentId: f,
|
|
1327
|
+
documentId: n,
|
|
1328
|
+
onSelectChunk: r,
|
|
1329
|
+
onOpenDocument: o
|
|
1330
|
+
}
|
|
1331
|
+
)
|
|
960
1332
|
] });
|
|
961
1333
|
}
|
|
962
|
-
function
|
|
963
|
-
const
|
|
1334
|
+
function yn(e) {
|
|
1335
|
+
const t = ["graph LR"];
|
|
964
1336
|
for (const n of e) {
|
|
965
|
-
const
|
|
966
|
-
|
|
1337
|
+
const r = `${De(n.from_id)}["${Ke(n.from_title, n.from_id)}"]`, o = `${De(n.to_id)}["${Ke(n.to_title, n.to_id)}"]`, s = (n.kind || "link").replace(/[|"]/g, " ");
|
|
1338
|
+
t.push(` ${r} -->|${s}| ${o}`);
|
|
967
1339
|
}
|
|
968
|
-
return
|
|
1340
|
+
return t.join(`
|
|
969
1341
|
`);
|
|
970
1342
|
}
|
|
1343
|
+
function bn(e, t) {
|
|
1344
|
+
for (const n of e) {
|
|
1345
|
+
if (De(n.from_id) === t)
|
|
1346
|
+
return { id: n.from_id, documentId: n.from_document_id, title: n.from_title };
|
|
1347
|
+
if (De(n.to_id) === t)
|
|
1348
|
+
return { id: n.to_id, documentId: n.to_document_id, title: n.to_title };
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
971
1351
|
function De(e) {
|
|
972
1352
|
return "n" + e.replace(/[^a-zA-Z0-9]/g, "");
|
|
973
1353
|
}
|
|
974
|
-
function
|
|
975
|
-
const
|
|
976
|
-
return
|
|
1354
|
+
function Ke(e, t) {
|
|
1355
|
+
const r = (e ?? "").replace(/["[\]{}|<>]/g, " ").replace(/\s+/g, " ").trim() || t.slice(0, 6);
|
|
1356
|
+
return r.length > 30 ? r.slice(0, 29) + "…" : r;
|
|
1357
|
+
}
|
|
1358
|
+
function vn({ documentId: e, scope: t, detail: n }) {
|
|
1359
|
+
return /* @__PURE__ */ c("div", { className: "doc-unavailable", role: "alert", children: [
|
|
1360
|
+
/* @__PURE__ */ a("p", { className: "doc-unavailable-lead", children: "This document can’t be opened." }),
|
|
1361
|
+
/* @__PURE__ */ c("p", { children: [
|
|
1362
|
+
"It may have been deleted, live in a scope other than ",
|
|
1363
|
+
/* @__PURE__ */ a("code", { children: t }),
|
|
1364
|
+
", or not be yours to read."
|
|
1365
|
+
] }),
|
|
1366
|
+
/* @__PURE__ */ c("p", { className: "doc-unavailable-detail", children: [
|
|
1367
|
+
/* @__PURE__ */ a("code", { children: e }),
|
|
1368
|
+
n && /* @__PURE__ */ c(Q, { children: [
|
|
1369
|
+
" — ",
|
|
1370
|
+
n
|
|
1371
|
+
] })
|
|
1372
|
+
] })
|
|
1373
|
+
] });
|
|
977
1374
|
}
|
|
978
|
-
function
|
|
979
|
-
const
|
|
980
|
-
return !Number.isFinite(
|
|
1375
|
+
function kn(e) {
|
|
1376
|
+
const t = typeof e == "number" ? e / 1e6 : Date.parse(String(e));
|
|
1377
|
+
return !Number.isFinite(t) || t <= 0 ? String(e ?? "") : new Date(t).toLocaleString();
|
|
981
1378
|
}
|
|
982
|
-
function
|
|
1379
|
+
function Nn({
|
|
983
1380
|
chunkId: e,
|
|
984
|
-
chunkTitle:
|
|
1381
|
+
chunkTitle: t,
|
|
985
1382
|
scope: n,
|
|
986
|
-
browse:
|
|
1383
|
+
browse: r,
|
|
987
1384
|
onClose: o
|
|
988
1385
|
}) {
|
|
989
|
-
const
|
|
990
|
-
|
|
991
|
-
let
|
|
992
|
-
return
|
|
993
|
-
if (
|
|
994
|
-
const
|
|
995
|
-
if (
|
|
996
|
-
const
|
|
997
|
-
|
|
1386
|
+
const s = be(), [i, l] = p([]), [f, d] = p(!0), [h, w] = p(null), [S, g] = p("none"), [N, y] = p(null), [j, B] = p(""), [O, W] = p(!1), [q, I] = p(null), [V, z] = p(null), [Z, _] = p("");
|
|
1387
|
+
H(() => {
|
|
1388
|
+
let m = !1;
|
|
1389
|
+
return d(!0), w(null), s.documentHistory(e, n, r).then((b) => {
|
|
1390
|
+
if (m) return;
|
|
1391
|
+
const C = b.revisions ?? [];
|
|
1392
|
+
if (l(C), C.length >= 2) {
|
|
1393
|
+
const x = C.map((U) => U.revision);
|
|
1394
|
+
I(Math.min(...x)), z(Math.max(...x));
|
|
998
1395
|
}
|
|
999
|
-
}).catch((b) => !
|
|
1000
|
-
|
|
1396
|
+
}).catch((b) => !m && w(b instanceof Error ? b.message : String(b))).finally(() => !m && d(!1)), () => {
|
|
1397
|
+
m = !0;
|
|
1001
1398
|
};
|
|
1002
|
-
}, [
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1399
|
+
}, [s, e, n, r]);
|
|
1400
|
+
const R = async (m) => {
|
|
1401
|
+
w(null), W(!0), y(m), g("version");
|
|
1005
1402
|
try {
|
|
1006
|
-
const b = await
|
|
1007
|
-
|
|
1403
|
+
const b = await s.documentGetVersion(e, m, n, r);
|
|
1404
|
+
B(b.body ?? "");
|
|
1008
1405
|
} catch (b) {
|
|
1009
|
-
|
|
1406
|
+
w(b instanceof Error ? b.message : String(b));
|
|
1010
1407
|
} finally {
|
|
1011
|
-
|
|
1408
|
+
W(!1);
|
|
1012
1409
|
}
|
|
1013
|
-
},
|
|
1014
|
-
if (!(
|
|
1015
|
-
|
|
1410
|
+
}, E = async () => {
|
|
1411
|
+
if (!(q === null || V === null)) {
|
|
1412
|
+
w(null), W(!0), g("diff");
|
|
1016
1413
|
try {
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1019
|
-
} catch (
|
|
1020
|
-
|
|
1414
|
+
const m = await s.documentDiff(e, q, V, n, r);
|
|
1415
|
+
_(m.diff ?? "");
|
|
1416
|
+
} catch (m) {
|
|
1417
|
+
w(m instanceof Error ? m.message : String(m));
|
|
1021
1418
|
} finally {
|
|
1022
|
-
|
|
1419
|
+
W(!1);
|
|
1023
1420
|
}
|
|
1024
1421
|
}
|
|
1025
1422
|
};
|
|
1026
|
-
return /* @__PURE__ */
|
|
1027
|
-
/* @__PURE__ */
|
|
1028
|
-
/* @__PURE__ */
|
|
1423
|
+
return /* @__PURE__ */ a("div", { className: "modal-overlay", onClick: o, children: /* @__PURE__ */ c("div", { className: "modal history-modal", onClick: (m) => m.stopPropagation(), children: [
|
|
1424
|
+
/* @__PURE__ */ c("div", { className: "modal-header sticky-top", children: [
|
|
1425
|
+
/* @__PURE__ */ c("h3", { children: [
|
|
1029
1426
|
"History",
|
|
1030
|
-
|
|
1427
|
+
t ? ` — ${t}` : ""
|
|
1031
1428
|
] }),
|
|
1032
|
-
/* @__PURE__ */
|
|
1429
|
+
/* @__PURE__ */ a("div", { className: "modal-buttons modal-buttons-top", children: /* @__PURE__ */ a("button", { type: "button", onClick: o, children: "close" }) })
|
|
1033
1430
|
] }),
|
|
1034
|
-
h && /* @__PURE__ */
|
|
1035
|
-
|
|
1036
|
-
/* @__PURE__ */
|
|
1431
|
+
h && /* @__PURE__ */ a("div", { className: "modal-err", children: h }),
|
|
1432
|
+
f ? /* @__PURE__ */ a("p", { className: "doc-empty-body", children: "loading…" }) : i.length === 0 ? /* @__PURE__ */ a("p", { className: "doc-empty-body", children: "No history recorded for this chunk." }) : /* @__PURE__ */ c(Q, { children: [
|
|
1433
|
+
/* @__PURE__ */ a("div", { className: "doc-hist-revs", children: i.map((m) => /* @__PURE__ */ c(
|
|
1037
1434
|
"button",
|
|
1038
1435
|
{
|
|
1039
1436
|
type: "button",
|
|
1040
|
-
className: "doc-hist-rev" + (
|
|
1437
|
+
className: "doc-hist-rev" + (S === "version" && N === m.revision ? " active" : ""),
|
|
1041
1438
|
onClick: () => {
|
|
1042
|
-
|
|
1439
|
+
R(m.revision);
|
|
1043
1440
|
},
|
|
1044
1441
|
children: [
|
|
1045
|
-
/* @__PURE__ */
|
|
1442
|
+
/* @__PURE__ */ c("span", { className: "doc-hist-rev-num", children: [
|
|
1046
1443
|
"rev ",
|
|
1047
|
-
|
|
1444
|
+
m.revision
|
|
1048
1445
|
] }),
|
|
1049
|
-
/* @__PURE__ */
|
|
1050
|
-
/* @__PURE__ */
|
|
1446
|
+
/* @__PURE__ */ a("span", { className: "doc-hist-rev-time", children: kn(m.created_at) }),
|
|
1447
|
+
/* @__PURE__ */ a("span", { className: "doc-hist-rev-actor", children: m.actor || "unknown" })
|
|
1051
1448
|
]
|
|
1052
1449
|
},
|
|
1053
|
-
|
|
1450
|
+
m.revision
|
|
1054
1451
|
)) }),
|
|
1055
|
-
|
|
1056
|
-
/* @__PURE__ */
|
|
1057
|
-
/* @__PURE__ */
|
|
1452
|
+
i.length >= 2 && /* @__PURE__ */ c("div", { className: "doc-hist-diffbar", children: [
|
|
1453
|
+
/* @__PURE__ */ a("span", { children: "Compare" }),
|
|
1454
|
+
/* @__PURE__ */ a(
|
|
1058
1455
|
"select",
|
|
1059
1456
|
{
|
|
1060
|
-
value:
|
|
1061
|
-
onChange: (
|
|
1457
|
+
value: q ?? "",
|
|
1458
|
+
onChange: (m) => I(m.target.value === "" ? null : Number(m.target.value)),
|
|
1062
1459
|
"aria-label": "diff from revision",
|
|
1063
|
-
children:
|
|
1460
|
+
children: i.map((m) => /* @__PURE__ */ c("option", { value: m.revision, children: [
|
|
1064
1461
|
"rev ",
|
|
1065
|
-
|
|
1066
|
-
] },
|
|
1462
|
+
m.revision
|
|
1463
|
+
] }, m.revision))
|
|
1067
1464
|
}
|
|
1068
1465
|
),
|
|
1069
|
-
/* @__PURE__ */
|
|
1070
|
-
/* @__PURE__ */
|
|
1466
|
+
/* @__PURE__ */ a("span", { "aria-hidden": !0, children: "→" }),
|
|
1467
|
+
/* @__PURE__ */ a(
|
|
1071
1468
|
"select",
|
|
1072
1469
|
{
|
|
1073
|
-
value:
|
|
1074
|
-
onChange: (
|
|
1470
|
+
value: V ?? "",
|
|
1471
|
+
onChange: (m) => z(m.target.value === "" ? null : Number(m.target.value)),
|
|
1075
1472
|
"aria-label": "diff to revision",
|
|
1076
|
-
children:
|
|
1473
|
+
children: i.map((m) => /* @__PURE__ */ c("option", { value: m.revision, children: [
|
|
1077
1474
|
"rev ",
|
|
1078
|
-
|
|
1079
|
-
] },
|
|
1475
|
+
m.revision
|
|
1476
|
+
] }, m.revision))
|
|
1080
1477
|
}
|
|
1081
1478
|
),
|
|
1082
|
-
/* @__PURE__ */
|
|
1479
|
+
/* @__PURE__ */ a(
|
|
1083
1480
|
"button",
|
|
1084
1481
|
{
|
|
1085
1482
|
type: "button",
|
|
1086
1483
|
onClick: () => {
|
|
1087
|
-
|
|
1484
|
+
E();
|
|
1088
1485
|
},
|
|
1089
|
-
disabled:
|
|
1486
|
+
disabled: O || q === null || V === null,
|
|
1090
1487
|
children: "diff"
|
|
1091
1488
|
}
|
|
1092
1489
|
)
|
|
1093
1490
|
] }),
|
|
1094
|
-
/* @__PURE__ */
|
|
1491
|
+
/* @__PURE__ */ a("div", { className: "doc-hist-output", children: O ? /* @__PURE__ */ a("p", { className: "doc-empty-body", children: "loading…" }) : S === "diff" ? /* @__PURE__ */ a(wn, { text: Z }) : S === "version" ? /* @__PURE__ */ a("pre", { className: "md-pre doc-hist-version", children: /* @__PURE__ */ a("code", { children: j || "(empty)" }) }) : /* @__PURE__ */ a("p", { className: "doc-empty-body", children: "Select a revision to view it, or compare two." }) })
|
|
1095
1492
|
] })
|
|
1096
1493
|
] }) });
|
|
1097
1494
|
}
|
|
1098
|
-
function
|
|
1099
|
-
if (!e.trim()) return /* @__PURE__ */
|
|
1100
|
-
const
|
|
1495
|
+
function wn({ text: e }) {
|
|
1496
|
+
if (!e.trim()) return /* @__PURE__ */ a("p", { className: "doc-empty-body", children: "(no differences)" });
|
|
1497
|
+
const t = e.split(`
|
|
1101
1498
|
`);
|
|
1102
|
-
return /* @__PURE__ */
|
|
1499
|
+
return /* @__PURE__ */ a("pre", { className: "md-pre doc-hist-diff", children: t.map((n, r) => {
|
|
1103
1500
|
const o = n.startsWith("+") && !n.startsWith("+++") ? "diff-add" : n.startsWith("-") && !n.startsWith("---") ? "diff-del" : n.startsWith("@@") ? "diff-hunk" : "";
|
|
1104
|
-
return /* @__PURE__ */
|
|
1501
|
+
return /* @__PURE__ */ c("span", { className: o, children: [
|
|
1105
1502
|
n,
|
|
1106
1503
|
`
|
|
1107
1504
|
`
|
|
1108
|
-
] },
|
|
1505
|
+
] }, r);
|
|
1109
1506
|
}) });
|
|
1110
1507
|
}
|
|
1111
|
-
function
|
|
1112
|
-
return /* @__PURE__ */
|
|
1508
|
+
function et({ source: e }) {
|
|
1509
|
+
return /* @__PURE__ */ a("div", { className: "md", children: /* @__PURE__ */ a(Pt, { remarkPlugins: [It], components: Cn, children: e }) });
|
|
1113
1510
|
}
|
|
1114
|
-
const
|
|
1511
|
+
const Cn = {
|
|
1115
1512
|
// react-markdown already sanitized the href; add target/rel for external links.
|
|
1116
|
-
a({ href: e, children:
|
|
1117
|
-
const n = e ?? "",
|
|
1118
|
-
return /* @__PURE__ */
|
|
1513
|
+
a({ href: e, children: t }) {
|
|
1514
|
+
const n = e ?? "", r = /^https?:\/\//i.test(n);
|
|
1515
|
+
return /* @__PURE__ */ a("a", { href: n, target: r ? "_blank" : void 0, rel: r ? "noopener noreferrer" : void 0, children: t });
|
|
1119
1516
|
},
|
|
1120
1517
|
// Let the code renderer own the block wrapper so a mermaid fence isn't wrapped
|
|
1121
1518
|
// in a <pre> (and a normal code block gets exactly one <pre>).
|
|
1122
1519
|
pre({ children: e }) {
|
|
1123
|
-
return /* @__PURE__ */
|
|
1520
|
+
return /* @__PURE__ */ a(Q, { children: e });
|
|
1124
1521
|
},
|
|
1125
|
-
code({ className: e, children:
|
|
1126
|
-
const n = /language-(\w+)/.exec(e ?? "")?.[1],
|
|
1127
|
-
return n === "mermaid" ? /* @__PURE__ */
|
|
1128
|
-
`) ? /* @__PURE__ */
|
|
1522
|
+
code({ className: e, children: t }) {
|
|
1523
|
+
const n = /language-(\w+)/.exec(e ?? "")?.[1], r = String(t ?? "");
|
|
1524
|
+
return n === "mermaid" ? /* @__PURE__ */ a(Te, { code: r.replace(/\n$/, "") }) : n || r.includes(`
|
|
1525
|
+
`) ? /* @__PURE__ */ a("pre", { className: "md-pre", children: /* @__PURE__ */ a("code", { className: e, children: t }) }) : /* @__PURE__ */ a("code", { children: t });
|
|
1129
1526
|
}
|
|
1130
1527
|
};
|
|
1131
|
-
function
|
|
1132
|
-
const
|
|
1133
|
-
return typeof
|
|
1528
|
+
function _n(e) {
|
|
1529
|
+
const t = e.fields ?? {};
|
|
1530
|
+
return typeof t.alt == "string" && t.alt.trim() !== "" ? t.alt : e.title || "image";
|
|
1134
1531
|
}
|
|
1135
|
-
function
|
|
1532
|
+
function bt({
|
|
1136
1533
|
documentId: e,
|
|
1137
|
-
scope:
|
|
1534
|
+
scope: t,
|
|
1138
1535
|
titleHint: n,
|
|
1139
|
-
browse:
|
|
1536
|
+
browse: r,
|
|
1140
1537
|
principal: o,
|
|
1141
|
-
renderAssistant:
|
|
1538
|
+
renderAssistant: s,
|
|
1539
|
+
initialChunkId: i,
|
|
1540
|
+
onOpenDocument: l,
|
|
1541
|
+
onTitle: f
|
|
1142
1542
|
}) {
|
|
1143
|
-
const
|
|
1144
|
-
() =>
|
|
1145
|
-
[
|
|
1146
|
-
), [
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
(
|
|
1162
|
-
|
|
1543
|
+
const d = be(), h = X(
|
|
1544
|
+
() => r && (r.scopeId || r.tenant) ? { scopeId: r.scopeId, tenant: r.tenant } : void 0,
|
|
1545
|
+
[r?.scopeId, r?.tenant]
|
|
1546
|
+
), [w, S] = p([]), [g, N] = p(void 0), [y, j] = p(null), [B, O] = p("chunks"), [W, q] = p(null), [I, V] = p(null), [z, Z] = p(null), _ = te(null), [R, E] = p(null), [m, b] = p(!1), [C, x] = p(!1), [U, M] = p(null), [ne, de] = p(!1), [we, ve] = p(void 0), [me, Ce] = p(null), [ue, Le] = p(0), [_e, D] = p(!1), [Y, ce] = p(null), [fe, Se] = p(!1), [pe, oe] = p([]), F = P(() => Le((u) => u + 1), []), ke = te(i);
|
|
1547
|
+
ke.current = i;
|
|
1548
|
+
const Ee = te(f);
|
|
1549
|
+
Ee.current = f;
|
|
1550
|
+
const Ne = X(() => nn(w), [w]), se = X(() => w.find((v) => !v.parent_id)?.title || n || "document", [w, n]), re = X(
|
|
1551
|
+
() => !!y && !y.parent_id,
|
|
1552
|
+
[y]
|
|
1553
|
+
), K = X(
|
|
1554
|
+
() => Y?.root_chunk_id ?? w.find((u) => !u.parent_id)?.id,
|
|
1555
|
+
[Y, w]
|
|
1556
|
+
), ee = X(
|
|
1557
|
+
() => [...new Set(w.map((u) => u.status).filter((u) => !!u))],
|
|
1558
|
+
[w]
|
|
1559
|
+
), ge = !!Y?.color_enabled, Me = X(() => {
|
|
1560
|
+
const u = /* @__PURE__ */ new Set();
|
|
1561
|
+
for (const v of pe)
|
|
1562
|
+
u.add(v.from_id), u.add(v.to_id);
|
|
1563
|
+
return u;
|
|
1564
|
+
}, [pe]), Re = X(
|
|
1565
|
+
() => ge ? He(ft(Y?.type, Y?.status, Ge(Y?.color_scheme))) : void 0,
|
|
1566
|
+
[ge, Y?.type, Y?.status, Y?.color_scheme]
|
|
1163
1567
|
);
|
|
1164
|
-
|
|
1165
|
-
let
|
|
1166
|
-
return
|
|
1167
|
-
if (
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
}).catch((
|
|
1171
|
-
|
|
1568
|
+
H(() => {
|
|
1569
|
+
let u = !1;
|
|
1570
|
+
return de(!0), M(null), Ce(null), d.documentQueryChunks(e, t, h).then((v) => {
|
|
1571
|
+
if (u) return;
|
|
1572
|
+
const T = v.chunks ?? [];
|
|
1573
|
+
S(T), ve(`${t}:${e}`), N((A) => A ?? Jt(T, ke.current));
|
|
1574
|
+
}).catch((v) => {
|
|
1575
|
+
u || (S([]), Ce(v instanceof Error ? v.message : String(v)));
|
|
1576
|
+
}).finally(() => !u && de(!1)), () => {
|
|
1577
|
+
u = !0;
|
|
1172
1578
|
};
|
|
1173
|
-
}, [
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1579
|
+
}, [d, e, t, ue, h]);
|
|
1580
|
+
const Pe = !ne && (me !== null || we === `${t}:${e}` && w.length === 0), k = X(
|
|
1581
|
+
() => w.find((u) => !u.parent_id && u.document_id === e)?.title,
|
|
1582
|
+
[w, e]
|
|
1583
|
+
);
|
|
1584
|
+
H(() => {
|
|
1585
|
+
k && Ee.current?.(e, k);
|
|
1586
|
+
}, [e, k]), H(() => {
|
|
1587
|
+
let u = !1;
|
|
1588
|
+
return d.documentGet(e, t, h).then((v) => !u && ce(v)).catch(() => !u && ce(null)), () => {
|
|
1589
|
+
u = !0;
|
|
1177
1590
|
};
|
|
1178
|
-
}, [
|
|
1179
|
-
let
|
|
1180
|
-
return
|
|
1181
|
-
|
|
1591
|
+
}, [d, e, t, ue, h]), H(() => {
|
|
1592
|
+
let u = !1;
|
|
1593
|
+
return d.documentGetEdges(e, t, h).then((v) => !u && oe(v.edges ?? [])).catch(() => !u && oe([])), () => {
|
|
1594
|
+
u = !0;
|
|
1182
1595
|
};
|
|
1183
|
-
}, [
|
|
1184
|
-
|
|
1185
|
-
}, [e,
|
|
1186
|
-
if (!
|
|
1187
|
-
|
|
1596
|
+
}, [d, e, t, ue, h]), H(() => {
|
|
1597
|
+
N(void 0), j(null), q(null), O("chunks"), ce(null), oe([]);
|
|
1598
|
+
}, [e, t]), H(() => {
|
|
1599
|
+
if (!g) {
|
|
1600
|
+
j(null);
|
|
1188
1601
|
return;
|
|
1189
1602
|
}
|
|
1190
|
-
let
|
|
1191
|
-
return
|
|
1192
|
-
|
|
1603
|
+
let u = !1;
|
|
1604
|
+
return d.documentGetChunk(g, t, h).then((v) => !u && j(v)).catch((v) => !u && M(v instanceof Error ? v.message : String(v))), () => {
|
|
1605
|
+
u = !0;
|
|
1193
1606
|
};
|
|
1194
|
-
}, [
|
|
1195
|
-
const
|
|
1196
|
-
if (!
|
|
1197
|
-
|
|
1607
|
+
}, [d, g, t, ue, h]), H(() => {
|
|
1608
|
+
const u = y?.type === "image" || !!y?.asset;
|
|
1609
|
+
if (!y || !u || !d.documentAssetObjectUrl) {
|
|
1610
|
+
V(null), Z(null);
|
|
1198
1611
|
return;
|
|
1199
1612
|
}
|
|
1200
|
-
let
|
|
1201
|
-
return
|
|
1202
|
-
if (
|
|
1203
|
-
URL.revokeObjectURL(
|
|
1613
|
+
let v = !1, T = null;
|
|
1614
|
+
return Z(null), d.documentAssetObjectUrl(y.id, t, h).then((A) => {
|
|
1615
|
+
if (v) {
|
|
1616
|
+
URL.revokeObjectURL(A);
|
|
1204
1617
|
return;
|
|
1205
1618
|
}
|
|
1206
|
-
|
|
1207
|
-
}).catch((
|
|
1208
|
-
|
|
1619
|
+
T = A, V(A);
|
|
1620
|
+
}).catch((A) => !v && Z(A instanceof Error ? A.message : String(A))), () => {
|
|
1621
|
+
v = !0, T && URL.revokeObjectURL(T);
|
|
1209
1622
|
};
|
|
1210
|
-
}, [
|
|
1211
|
-
if (
|
|
1212
|
-
|
|
1623
|
+
}, [d, y, t, h]), H(() => {
|
|
1624
|
+
if (B !== "markdown" || !g) {
|
|
1625
|
+
q(null);
|
|
1213
1626
|
return;
|
|
1214
1627
|
}
|
|
1215
|
-
const
|
|
1216
|
-
if (!
|
|
1217
|
-
let
|
|
1218
|
-
const
|
|
1219
|
-
|
|
1628
|
+
const u = pt(Ne, g);
|
|
1629
|
+
if (!u) return;
|
|
1630
|
+
let v = !1;
|
|
1631
|
+
const T = [], A = (J, xe) => {
|
|
1632
|
+
T.push({ node: J, depth: xe }), J.children.forEach(($e) => A($e, xe + 1));
|
|
1220
1633
|
};
|
|
1221
|
-
return
|
|
1222
|
-
if (
|
|
1223
|
-
const
|
|
1224
|
-
const
|
|
1225
|
-
if (
|
|
1226
|
-
return
|
|
1227
|
-
if (
|
|
1228
|
-
const
|
|
1229
|
-
return
|
|
1634
|
+
return A(u, 0), Promise.all(T.map((J) => d.documentGetChunk(J.node.row.id, t, h))).then((J) => {
|
|
1635
|
+
if (v) return;
|
|
1636
|
+
const xe = T.map(($e, xt) => {
|
|
1637
|
+
const $t = Math.min($e.depth + 1, 6), ie = J[xt], Ie = "#".repeat($t) + " " + $e.node.row.title;
|
|
1638
|
+
if (ie.type === "mermaid" && ie.body)
|
|
1639
|
+
return Ie + "\n\n```mermaid\n" + ie.body + "\n```\n";
|
|
1640
|
+
if (ie.type === "image" || ie.asset) {
|
|
1641
|
+
const Dt = ie.body ? " — " + ie.body : "";
|
|
1642
|
+
return Ie + `
|
|
1230
1643
|
|
|
1231
|
-
_🖼 image chunk_` +
|
|
1644
|
+
_🖼 image chunk_` + Dt + `
|
|
1232
1645
|
`;
|
|
1233
1646
|
}
|
|
1234
|
-
return
|
|
1647
|
+
return Ie + (ie.body ? `
|
|
1235
1648
|
|
|
1236
|
-
` +
|
|
1649
|
+
` + ie.body : "") + `
|
|
1237
1650
|
`;
|
|
1238
1651
|
}).join(`
|
|
1239
1652
|
`);
|
|
1240
|
-
|
|
1241
|
-
}).catch((
|
|
1242
|
-
|
|
1653
|
+
q(xe);
|
|
1654
|
+
}).catch((J) => !v && M(J instanceof Error ? J.message : String(J))), () => {
|
|
1655
|
+
v = !0;
|
|
1243
1656
|
};
|
|
1244
|
-
}, [
|
|
1245
|
-
const
|
|
1657
|
+
}, [d, B, g, Ne, t, ue, h]);
|
|
1658
|
+
const $ = P((u) => N(u.row.id), []), L = P(
|
|
1659
|
+
(u, v, T) => l?.(
|
|
1660
|
+
{ documentId: u, chunkId: v, title: T },
|
|
1661
|
+
{ documentId: e, chunkId: g, title: se }
|
|
1662
|
+
),
|
|
1663
|
+
[l, e, g, se]
|
|
1664
|
+
), G = P(async () => {
|
|
1246
1665
|
try {
|
|
1247
|
-
const
|
|
1248
|
-
|
|
1249
|
-
} catch (
|
|
1250
|
-
|
|
1666
|
+
const u = await d.documentExportMd(e, t, !0, h), v = new Blob([u.markdown], { type: "text/markdown" }), T = URL.createObjectURL(v), A = document.createElement("a");
|
|
1667
|
+
A.href = T, A.download = (u.title || "document").replace(/[^\w.-]+/g, "_") + ".md", A.click(), URL.revokeObjectURL(T);
|
|
1668
|
+
} catch (u) {
|
|
1669
|
+
M(u instanceof Error ? u.message : String(u));
|
|
1251
1670
|
}
|
|
1252
|
-
}, [
|
|
1671
|
+
}, [d, e, t, h]), ae = P(async () => {
|
|
1253
1672
|
try {
|
|
1254
|
-
const
|
|
1673
|
+
const u = await d.documentExportCanvas(e, t, h), v = new Blob([JSON.stringify(u.canvas, null, 2)], {
|
|
1255
1674
|
type: "application/json"
|
|
1256
|
-
}),
|
|
1257
|
-
|
|
1258
|
-
} catch (
|
|
1259
|
-
|
|
1675
|
+
}), T = URL.createObjectURL(v), A = document.createElement("a");
|
|
1676
|
+
A.href = T, A.download = (se || "document").replace(/[^\w.-]+/g, "_") + ".canvas", A.click(), URL.revokeObjectURL(T);
|
|
1677
|
+
} catch (u) {
|
|
1678
|
+
M(u instanceof Error ? u.message : String(u));
|
|
1260
1679
|
}
|
|
1261
|
-
}, [
|
|
1262
|
-
async (
|
|
1263
|
-
if (!
|
|
1264
|
-
const
|
|
1265
|
-
if (
|
|
1266
|
-
|
|
1680
|
+
}, [d, e, t, h, se]), le = !!d.documentCreateChunk && !!K, ye = P(
|
|
1681
|
+
async (u) => {
|
|
1682
|
+
if (!d.documentCreateChunk || !d.documentSetAsset) return;
|
|
1683
|
+
const v = g || K;
|
|
1684
|
+
if (v) {
|
|
1685
|
+
M(null);
|
|
1267
1686
|
try {
|
|
1268
|
-
const { mediaType:
|
|
1687
|
+
const { mediaType: T, data: A } = await mt(u), J = await d.documentCreateChunk(
|
|
1269
1688
|
e,
|
|
1270
|
-
|
|
1271
|
-
{ title:
|
|
1272
|
-
|
|
1273
|
-
|
|
1689
|
+
v,
|
|
1690
|
+
{ title: u.name || "image", type: "image" },
|
|
1691
|
+
t,
|
|
1692
|
+
h
|
|
1274
1693
|
);
|
|
1275
|
-
await
|
|
1276
|
-
} catch (
|
|
1277
|
-
|
|
1694
|
+
await d.documentSetAsset(J.id, T, A, u.name, t, h), F(), N(J.id);
|
|
1695
|
+
} catch (T) {
|
|
1696
|
+
M(T instanceof Error ? T.message : String(T));
|
|
1278
1697
|
}
|
|
1279
1698
|
}
|
|
1280
1699
|
},
|
|
1281
|
-
[
|
|
1282
|
-
),
|
|
1283
|
-
if (!
|
|
1284
|
-
const
|
|
1285
|
-
if (
|
|
1286
|
-
|
|
1700
|
+
[d, e, t, h, g, K, F]
|
|
1701
|
+
), Ct = P(async () => {
|
|
1702
|
+
if (!d.documentCreateChunk) return;
|
|
1703
|
+
const u = g || K;
|
|
1704
|
+
if (u) {
|
|
1705
|
+
M(null);
|
|
1287
1706
|
try {
|
|
1288
|
-
const
|
|
1707
|
+
const v = await d.documentCreateChunk(
|
|
1289
1708
|
e,
|
|
1290
|
-
|
|
1709
|
+
u,
|
|
1291
1710
|
{ title: "Diagram", type: "mermaid", body: `graph TD
|
|
1292
1711
|
A[Start] --> B[End]` },
|
|
1293
|
-
|
|
1294
|
-
|
|
1712
|
+
t,
|
|
1713
|
+
h
|
|
1295
1714
|
);
|
|
1296
|
-
|
|
1297
|
-
} catch (
|
|
1298
|
-
|
|
1715
|
+
F(), N(v.id), E(v);
|
|
1716
|
+
} catch (v) {
|
|
1717
|
+
M(v instanceof Error ? v.message : String(v));
|
|
1299
1718
|
}
|
|
1300
1719
|
}
|
|
1301
|
-
}, [
|
|
1302
|
-
if (!
|
|
1303
|
-
const
|
|
1304
|
-
if (
|
|
1305
|
-
|
|
1720
|
+
}, [d, e, t, h, g, K, F]), _t = P(async () => {
|
|
1721
|
+
if (!d.documentCreateChunk) return;
|
|
1722
|
+
const u = g && !re ? g : void 0, v = g || K;
|
|
1723
|
+
if (v) {
|
|
1724
|
+
M(null);
|
|
1306
1725
|
try {
|
|
1307
|
-
const
|
|
1726
|
+
const T = await d.documentCreateChunk(
|
|
1308
1727
|
e,
|
|
1309
|
-
|
|
1728
|
+
u ? "" : v,
|
|
1310
1729
|
// after_id resolves the parent server-side
|
|
1311
1730
|
{ title: "Text", body: "" },
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1731
|
+
t,
|
|
1732
|
+
h,
|
|
1733
|
+
u
|
|
1315
1734
|
);
|
|
1316
|
-
|
|
1317
|
-
} catch (
|
|
1318
|
-
|
|
1735
|
+
F(), N(T.id), E(T);
|
|
1736
|
+
} catch (T) {
|
|
1737
|
+
M(T instanceof Error ? T.message : String(T));
|
|
1319
1738
|
}
|
|
1320
1739
|
}
|
|
1321
|
-
}, [
|
|
1322
|
-
if (!(!
|
|
1323
|
-
|
|
1740
|
+
}, [d, e, t, h, g, re, K, F]), St = P(async () => {
|
|
1741
|
+
if (!(!d.documentCreateChunk || !g)) {
|
|
1742
|
+
M(null);
|
|
1324
1743
|
try {
|
|
1325
|
-
const
|
|
1744
|
+
const u = await d.documentCreateChunk(
|
|
1326
1745
|
e,
|
|
1327
|
-
|
|
1746
|
+
g,
|
|
1328
1747
|
{ title: "Text", body: "" },
|
|
1329
|
-
|
|
1330
|
-
|
|
1748
|
+
t,
|
|
1749
|
+
h
|
|
1331
1750
|
);
|
|
1332
|
-
|
|
1333
|
-
} catch (
|
|
1334
|
-
|
|
1751
|
+
F(), N(u.id), E(u);
|
|
1752
|
+
} catch (u) {
|
|
1753
|
+
M(u instanceof Error ? u.message : String(u));
|
|
1335
1754
|
}
|
|
1336
1755
|
}
|
|
1337
|
-
}, [
|
|
1338
|
-
if (!
|
|
1339
|
-
const
|
|
1340
|
-
return { canUp:
|
|
1341
|
-
}, [
|
|
1342
|
-
async (
|
|
1343
|
-
if (!(!
|
|
1344
|
-
|
|
1756
|
+
}, [d, e, t, h, g, F]), We = X(() => {
|
|
1757
|
+
if (!y || re) return { canUp: !1, canDown: !1 };
|
|
1758
|
+
const u = y.parent_id ?? "", v = w.filter((A) => (A.parent_id ?? "") === u).sort((A, J) => A.position - J.position || A.id.localeCompare(J.id)), T = v.findIndex((A) => A.id === y.id);
|
|
1759
|
+
return { canUp: T > 0, canDown: T >= 0 && T < v.length - 1 };
|
|
1760
|
+
}, [w, y, re]), Ve = P(
|
|
1761
|
+
async (u) => {
|
|
1762
|
+
if (!(!d.documentReorderChunk || !g)) {
|
|
1763
|
+
M(null);
|
|
1345
1764
|
try {
|
|
1346
|
-
await
|
|
1347
|
-
} catch (
|
|
1348
|
-
|
|
1765
|
+
await d.documentReorderChunk(g, u, t, h), F();
|
|
1766
|
+
} catch (v) {
|
|
1767
|
+
M(v instanceof Error ? v.message : String(v));
|
|
1349
1768
|
}
|
|
1350
1769
|
}
|
|
1351
1770
|
},
|
|
1352
|
-
[
|
|
1353
|
-
),
|
|
1354
|
-
if (!
|
|
1355
|
-
|
|
1356
|
-
const
|
|
1771
|
+
[d, g, t, h, F]
|
|
1772
|
+
), Et = P(async () => {
|
|
1773
|
+
if (!d.documentDeleteChunk || !y) return;
|
|
1774
|
+
M(null);
|
|
1775
|
+
const u = y.parent_id;
|
|
1357
1776
|
try {
|
|
1358
|
-
await
|
|
1359
|
-
} catch (
|
|
1360
|
-
|
|
1777
|
+
await d.documentDeleteChunk(y.id, t, h), x(!1), N(u || K), F();
|
|
1778
|
+
} catch (v) {
|
|
1779
|
+
M(v instanceof Error ? v.message : String(v)), x(!1);
|
|
1361
1780
|
}
|
|
1362
|
-
}, [
|
|
1363
|
-
return
|
|
1364
|
-
if (!
|
|
1365
|
-
const
|
|
1366
|
-
if (R ||
|
|
1367
|
-
const
|
|
1368
|
-
if (
|
|
1369
|
-
const
|
|
1370
|
-
|
|
1781
|
+
}, [d, y, t, h, K, F]);
|
|
1782
|
+
return H(() => {
|
|
1783
|
+
if (!le) return;
|
|
1784
|
+
const u = (v) => {
|
|
1785
|
+
if (R || fe) return;
|
|
1786
|
+
const T = document.activeElement, A = T?.tagName;
|
|
1787
|
+
if (A === "INPUT" || A === "TEXTAREA" || T?.isContentEditable) return;
|
|
1788
|
+
const J = Qt(v.clipboardData?.items);
|
|
1789
|
+
J && (v.preventDefault(), ye(J));
|
|
1371
1790
|
};
|
|
1372
|
-
return window.addEventListener("paste",
|
|
1373
|
-
}, [
|
|
1374
|
-
/* @__PURE__ */
|
|
1791
|
+
return window.addEventListener("paste", u), () => window.removeEventListener("paste", u);
|
|
1792
|
+
}, [le, R, fe, ye]), /* @__PURE__ */ c("div", { className: "doc-viewer", children: [
|
|
1793
|
+
/* @__PURE__ */ a(
|
|
1375
1794
|
"input",
|
|
1376
1795
|
{
|
|
1377
|
-
ref:
|
|
1796
|
+
ref: _,
|
|
1378
1797
|
type: "file",
|
|
1379
1798
|
accept: "image/png,image/jpeg,image/gif,image/webp",
|
|
1380
1799
|
style: { display: "none" },
|
|
1381
|
-
onChange: (
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1800
|
+
onChange: (u) => {
|
|
1801
|
+
const v = u.target.files?.[0];
|
|
1802
|
+
u.target.value = "", v && ye(v);
|
|
1384
1803
|
}
|
|
1385
1804
|
}
|
|
1386
1805
|
),
|
|
1387
|
-
/* @__PURE__ */
|
|
1388
|
-
/* @__PURE__ */
|
|
1389
|
-
/* @__PURE__ */
|
|
1390
|
-
|
|
1391
|
-
|
|
1806
|
+
/* @__PURE__ */ c("div", { className: "doc-toolbar", style: Re, children: [
|
|
1807
|
+
/* @__PURE__ */ a("strong", { className: "doc-title", title: se, children: se }),
|
|
1808
|
+
/* @__PURE__ */ a(Fe, { value: e, label: "doc" }),
|
|
1809
|
+
/* @__PURE__ */ c("div", { className: "doc-toolbar-actions", children: [
|
|
1810
|
+
le && /* @__PURE__ */ c(Q, { children: [
|
|
1811
|
+
/* @__PURE__ */ a(
|
|
1392
1812
|
"button",
|
|
1393
1813
|
{
|
|
1394
1814
|
type: "button",
|
|
1395
1815
|
onClick: () => {
|
|
1396
|
-
|
|
1816
|
+
_t();
|
|
1397
1817
|
},
|
|
1398
1818
|
title: "Add a text chunk AFTER the selected chunk, at the same level",
|
|
1399
1819
|
children: "+ text"
|
|
1400
1820
|
}
|
|
1401
1821
|
),
|
|
1402
|
-
/* @__PURE__ */
|
|
1822
|
+
/* @__PURE__ */ a(
|
|
1403
1823
|
"button",
|
|
1404
1824
|
{
|
|
1405
1825
|
type: "button",
|
|
1406
1826
|
onClick: () => {
|
|
1407
|
-
|
|
1827
|
+
St();
|
|
1408
1828
|
},
|
|
1409
|
-
disabled: !
|
|
1410
|
-
title:
|
|
1829
|
+
disabled: !g,
|
|
1830
|
+
title: g ? "Add a chunk NESTED UNDER the selected chunk (in the ontology, a child is a subclass)" : "Select a chunk first — this nests a new chunk under it",
|
|
1411
1831
|
children: "+ child"
|
|
1412
1832
|
}
|
|
1413
1833
|
),
|
|
1414
|
-
/* @__PURE__ */
|
|
1834
|
+
/* @__PURE__ */ a(
|
|
1415
1835
|
"button",
|
|
1416
1836
|
{
|
|
1417
1837
|
type: "button",
|
|
1418
|
-
onClick: () =>
|
|
1838
|
+
onClick: () => _.current?.click(),
|
|
1419
1839
|
title: "Add an image chunk (upload — or paste a screenshot into the view)",
|
|
1420
1840
|
children: "+ image"
|
|
1421
1841
|
}
|
|
1422
1842
|
),
|
|
1423
|
-
/* @__PURE__ */
|
|
1843
|
+
/* @__PURE__ */ a(
|
|
1424
1844
|
"button",
|
|
1425
1845
|
{
|
|
1426
1846
|
type: "button",
|
|
1427
1847
|
onClick: () => {
|
|
1428
|
-
|
|
1848
|
+
Ct();
|
|
1429
1849
|
},
|
|
1430
1850
|
title: "Add a Mermaid diagram chunk",
|
|
1431
1851
|
children: "+ diagram"
|
|
1432
1852
|
}
|
|
1433
1853
|
)
|
|
1434
1854
|
] }),
|
|
1435
|
-
/* @__PURE__ */
|
|
1855
|
+
/* @__PURE__ */ a(
|
|
1436
1856
|
"button",
|
|
1437
1857
|
{
|
|
1438
1858
|
type: "button",
|
|
1439
|
-
className:
|
|
1440
|
-
onClick: () =>
|
|
1441
|
-
disabled: !
|
|
1859
|
+
className: ge ? "active" : "",
|
|
1860
|
+
onClick: () => Se(!0),
|
|
1861
|
+
disabled: !K,
|
|
1442
1862
|
title: "Colors — tint chunk tiles + the Path tree by type/status",
|
|
1443
1863
|
children: "colors"
|
|
1444
1864
|
}
|
|
1445
1865
|
),
|
|
1446
|
-
/* @__PURE__ */
|
|
1447
|
-
|
|
1866
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: () => {
|
|
1867
|
+
G();
|
|
1448
1868
|
}, title: "Download the whole document as Markdown (.md)", children: "↓ .md" }),
|
|
1449
|
-
/* @__PURE__ */
|
|
1869
|
+
/* @__PURE__ */ a(
|
|
1450
1870
|
"button",
|
|
1451
1871
|
{
|
|
1452
1872
|
type: "button",
|
|
1453
1873
|
onClick: () => {
|
|
1454
|
-
|
|
1874
|
+
ae();
|
|
1455
1875
|
},
|
|
1456
1876
|
title: "Download the whole document as a node/edge canvas graph (.canvas)",
|
|
1457
1877
|
children: "↓ .canvas"
|
|
1458
1878
|
}
|
|
1459
1879
|
),
|
|
1460
|
-
|
|
1880
|
+
s && /* @__PURE__ */ a(
|
|
1461
1881
|
"button",
|
|
1462
1882
|
{
|
|
1463
1883
|
type: "button",
|
|
1464
|
-
className:
|
|
1465
|
-
onClick: () =>
|
|
1884
|
+
className: _e ? "active" : "",
|
|
1885
|
+
onClick: () => D((u) => !u),
|
|
1466
1886
|
title: "Document Assistant — instruct an agent to restructure/import/link chunks",
|
|
1467
1887
|
children: "assistant"
|
|
1468
1888
|
}
|
|
1469
1889
|
),
|
|
1470
|
-
/* @__PURE__ */
|
|
1890
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: F, title: "Reload", children: "↻" })
|
|
1471
1891
|
] })
|
|
1472
1892
|
] }),
|
|
1473
|
-
|
|
1474
|
-
/* @__PURE__ */
|
|
1475
|
-
/* @__PURE__ */
|
|
1476
|
-
|
|
1893
|
+
U && /* @__PURE__ */ a("div", { className: "paths-err", children: U }),
|
|
1894
|
+
Pe ? /* @__PURE__ */ a(vn, { documentId: e, scope: t, detail: me ?? void 0 }) : /* @__PURE__ */ c("div", { className: "doc-split", children: [
|
|
1895
|
+
/* @__PURE__ */ a("div", { className: "doc-chunktree", children: ne && w.length === 0 ? /* @__PURE__ */ a("div", { className: "empty", children: /* @__PURE__ */ a("p", { children: "Loading…" }) }) : /* @__PURE__ */ a(
|
|
1896
|
+
an,
|
|
1477
1897
|
{
|
|
1478
|
-
tree:
|
|
1479
|
-
selectedId:
|
|
1480
|
-
onSelect:
|
|
1481
|
-
colorEnabled:
|
|
1482
|
-
scheme:
|
|
1483
|
-
linkedIds:
|
|
1898
|
+
tree: Ne,
|
|
1899
|
+
selectedId: g,
|
|
1900
|
+
onSelect: $,
|
|
1901
|
+
colorEnabled: ge,
|
|
1902
|
+
scheme: Y?.color_scheme,
|
|
1903
|
+
linkedIds: Me
|
|
1484
1904
|
}
|
|
1485
1905
|
) }),
|
|
1486
|
-
/* @__PURE__ */
|
|
1487
|
-
/* @__PURE__ */
|
|
1488
|
-
/* @__PURE__ */
|
|
1489
|
-
/* @__PURE__ */
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
/* @__PURE__ */
|
|
1906
|
+
/* @__PURE__ */ a("div", { className: "doc-content", children: y ? /* @__PURE__ */ c(Q, { children: [
|
|
1907
|
+
/* @__PURE__ */ c("div", { className: "doc-content-head", children: [
|
|
1908
|
+
/* @__PURE__ */ a("h3", { children: y.title || "(untitled)" }),
|
|
1909
|
+
/* @__PURE__ */ c("div", { className: "doc-content-meta", children: [
|
|
1910
|
+
y.type && /* @__PURE__ */ a("span", { className: "chunk-badge", children: y.type }),
|
|
1911
|
+
y.status && /* @__PURE__ */ a("span", { className: "chunk-badge chunk-status", children: y.status }),
|
|
1912
|
+
/* @__PURE__ */ c("span", { className: "chunk-rev", children: [
|
|
1493
1913
|
"rev ",
|
|
1494
|
-
|
|
1914
|
+
y.revision
|
|
1495
1915
|
] }),
|
|
1496
|
-
|
|
1916
|
+
y.tags?.map((u) => /* @__PURE__ */ a("span", { className: "chunk-tag", children: u }, u)),
|
|
1917
|
+
/* @__PURE__ */ a(Fe, { value: y.id, label: "chunk" })
|
|
1497
1918
|
] }),
|
|
1498
|
-
/* @__PURE__ */
|
|
1499
|
-
/* @__PURE__ */
|
|
1500
|
-
/* @__PURE__ */
|
|
1919
|
+
/* @__PURE__ */ c("div", { className: "doc-content-controls", children: [
|
|
1920
|
+
/* @__PURE__ */ c("div", { className: "doc-mode-toggle", children: [
|
|
1921
|
+
/* @__PURE__ */ a(
|
|
1501
1922
|
"button",
|
|
1502
1923
|
{
|
|
1503
1924
|
type: "button",
|
|
1504
|
-
className:
|
|
1505
|
-
onClick: () =>
|
|
1925
|
+
className: B === "chunks" ? "active" : "",
|
|
1926
|
+
onClick: () => O("chunks"),
|
|
1506
1927
|
title: "This chunk's own content",
|
|
1507
1928
|
children: "chunk"
|
|
1508
1929
|
}
|
|
1509
1930
|
),
|
|
1510
|
-
/* @__PURE__ */
|
|
1931
|
+
/* @__PURE__ */ a(
|
|
1511
1932
|
"button",
|
|
1512
1933
|
{
|
|
1513
1934
|
type: "button",
|
|
1514
|
-
className:
|
|
1515
|
-
onClick: () =>
|
|
1516
|
-
title:
|
|
1935
|
+
className: B === "markdown" ? "active" : "",
|
|
1936
|
+
onClick: () => O("markdown"),
|
|
1937
|
+
title: re ? "Whole document as Markdown" : "This chunk + its sub-chunks as Markdown",
|
|
1517
1938
|
children: "markdown"
|
|
1518
1939
|
}
|
|
1519
1940
|
)
|
|
1520
1941
|
] }),
|
|
1521
|
-
/* @__PURE__ */
|
|
1522
|
-
/* @__PURE__ */
|
|
1942
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: () => E(y), children: "edit" }),
|
|
1943
|
+
/* @__PURE__ */ a(
|
|
1523
1944
|
"button",
|
|
1524
1945
|
{
|
|
1525
1946
|
type: "button",
|
|
1526
|
-
onClick: () =>
|
|
1947
|
+
onClick: () => b(!0),
|
|
1527
1948
|
title: "View this chunk's edit history + diffs",
|
|
1528
1949
|
children: "history"
|
|
1529
1950
|
}
|
|
1530
1951
|
),
|
|
1531
|
-
!
|
|
1532
|
-
/* @__PURE__ */
|
|
1952
|
+
!re && /* @__PURE__ */ c(Q, { children: [
|
|
1953
|
+
/* @__PURE__ */ a(
|
|
1533
1954
|
"button",
|
|
1534
1955
|
{
|
|
1535
1956
|
type: "button",
|
|
1536
1957
|
onClick: () => {
|
|
1537
|
-
|
|
1958
|
+
Ve("up");
|
|
1538
1959
|
},
|
|
1539
|
-
disabled: !
|
|
1960
|
+
disabled: !We.canUp,
|
|
1540
1961
|
title: "Move this chunk up within its level",
|
|
1541
1962
|
children: "↑"
|
|
1542
1963
|
}
|
|
1543
1964
|
),
|
|
1544
|
-
/* @__PURE__ */
|
|
1965
|
+
/* @__PURE__ */ a(
|
|
1545
1966
|
"button",
|
|
1546
1967
|
{
|
|
1547
1968
|
type: "button",
|
|
1548
1969
|
onClick: () => {
|
|
1549
|
-
|
|
1970
|
+
Ve("down");
|
|
1550
1971
|
},
|
|
1551
|
-
disabled: !
|
|
1972
|
+
disabled: !We.canDown,
|
|
1552
1973
|
title: "Move this chunk down within its level",
|
|
1553
1974
|
children: "↓"
|
|
1554
1975
|
}
|
|
1555
1976
|
)
|
|
1556
1977
|
] }),
|
|
1557
|
-
!
|
|
1978
|
+
!re && /* @__PURE__ */ a(
|
|
1558
1979
|
"button",
|
|
1559
1980
|
{
|
|
1560
1981
|
type: "button",
|
|
1561
1982
|
className: "danger",
|
|
1562
|
-
onClick: () =>
|
|
1983
|
+
onClick: () => x(!0),
|
|
1563
1984
|
title: "Delete this chunk and its sub-chunks",
|
|
1564
1985
|
children: "delete"
|
|
1565
1986
|
}
|
|
1566
1987
|
)
|
|
1567
1988
|
] })
|
|
1568
1989
|
] }),
|
|
1569
|
-
/* @__PURE__ */
|
|
1990
|
+
/* @__PURE__ */ a("div", { className: "doc-content-body", children: y.type === "mermaid" ? (
|
|
1570
1991
|
// RFC BO — a diagram chunk: body IS the Mermaid source.
|
|
1571
|
-
|
|
1572
|
-
/* @__PURE__ */
|
|
1573
|
-
|
|
1574
|
-
] }) : /* @__PURE__ */
|
|
1575
|
-
) :
|
|
1992
|
+
y.body ? /* @__PURE__ */ c(Q, { children: [
|
|
1993
|
+
/* @__PURE__ */ a(Te, { code: y.body }),
|
|
1994
|
+
B === "markdown" && /* @__PURE__ */ a("pre", { className: "md-pre doc-mermaid-source", children: /* @__PURE__ */ a("code", { children: y.body }) })
|
|
1995
|
+
] }) : /* @__PURE__ */ a("p", { className: "doc-empty-body", children: "(empty diagram)" })
|
|
1996
|
+
) : y.type === "image" || y.asset ? (
|
|
1576
1997
|
// RFC BO — an image chunk: bytes come from the auth'd asset GET.
|
|
1577
|
-
|
|
1998
|
+
z ? /* @__PURE__ */ c("p", { className: "doc-empty-body", children: [
|
|
1578
1999
|
"Image failed to load: ",
|
|
1579
|
-
|
|
1580
|
-
] }) :
|
|
1581
|
-
/* @__PURE__ */
|
|
1582
|
-
|
|
1583
|
-
] }) : /* @__PURE__ */
|
|
1584
|
-
) :
|
|
1585
|
-
/* @__PURE__ */
|
|
1586
|
-
|
|
2000
|
+
z
|
|
2001
|
+
] }) : I ? /* @__PURE__ */ c("figure", { className: "doc-image", children: [
|
|
2002
|
+
/* @__PURE__ */ a("img", { src: I, alt: _n(y) }),
|
|
2003
|
+
y.body && /* @__PURE__ */ a("figcaption", { children: y.body })
|
|
2004
|
+
] }) : /* @__PURE__ */ a("p", { className: "doc-empty-body", children: "Loading image…" })
|
|
2005
|
+
) : B === "markdown" ? W !== null ? /* @__PURE__ */ a(et, { source: W }) : /* @__PURE__ */ a("p", { className: "doc-empty-body", children: "Assembling Markdown…" }) : y.body ? /* @__PURE__ */ a(et, { source: y.body }) : /* @__PURE__ */ a("p", { className: "doc-empty-body", children: "(empty chunk)" }) }),
|
|
2006
|
+
/* @__PURE__ */ a(
|
|
2007
|
+
pn,
|
|
1587
2008
|
{
|
|
1588
|
-
edges:
|
|
2009
|
+
edges: pe,
|
|
1589
2010
|
documentId: e,
|
|
1590
|
-
selectedId:
|
|
1591
|
-
onSelectChunk:
|
|
2011
|
+
selectedId: g,
|
|
2012
|
+
onSelectChunk: N,
|
|
2013
|
+
onOpenDocument: l ? L : void 0
|
|
1592
2014
|
}
|
|
1593
2015
|
),
|
|
1594
|
-
/* @__PURE__ */
|
|
1595
|
-
|
|
2016
|
+
/* @__PURE__ */ a(
|
|
2017
|
+
fn,
|
|
1596
2018
|
{
|
|
1597
2019
|
documentId: e,
|
|
1598
|
-
selectedId:
|
|
1599
|
-
scope:
|
|
1600
|
-
browse:
|
|
1601
|
-
onSelectChunk:
|
|
2020
|
+
selectedId: g,
|
|
2021
|
+
scope: t,
|
|
2022
|
+
browse: h,
|
|
2023
|
+
onSelectChunk: N,
|
|
2024
|
+
onOpenDocument: l ? L : void 0
|
|
1602
2025
|
}
|
|
1603
2026
|
)
|
|
1604
|
-
] }) : /* @__PURE__ */
|
|
2027
|
+
] }) : /* @__PURE__ */ a("div", { className: "empty", children: /* @__PURE__ */ a("p", { children: "Select a chunk on the left." }) }) })
|
|
1605
2028
|
] }),
|
|
1606
|
-
|
|
2029
|
+
_e && s && /* @__PURE__ */ a("div", { className: "doc-assistant", children: s({
|
|
1607
2030
|
documentId: e,
|
|
1608
|
-
scope:
|
|
2031
|
+
scope: t,
|
|
1609
2032
|
subject: o?.subject,
|
|
1610
2033
|
// Pass the viewer's own reload so the injected assistant can refresh
|
|
1611
2034
|
// the tree + selected chunk after a turn mutates the document.
|
|
1612
|
-
onChanged:
|
|
2035
|
+
onChanged: F
|
|
1613
2036
|
}) }),
|
|
1614
|
-
R && /* @__PURE__ */
|
|
1615
|
-
|
|
2037
|
+
R && /* @__PURE__ */ a(
|
|
2038
|
+
cn,
|
|
1616
2039
|
{
|
|
1617
2040
|
chunk: R,
|
|
1618
|
-
scope:
|
|
1619
|
-
browse:
|
|
1620
|
-
onClose: () =>
|
|
1621
|
-
onSaved:
|
|
2041
|
+
scope: t,
|
|
2042
|
+
browse: h,
|
|
2043
|
+
onClose: () => E(null),
|
|
2044
|
+
onSaved: F
|
|
1622
2045
|
}
|
|
1623
2046
|
),
|
|
1624
|
-
|
|
1625
|
-
|
|
2047
|
+
m && y && /* @__PURE__ */ a(
|
|
2048
|
+
Nn,
|
|
1626
2049
|
{
|
|
1627
|
-
chunkId:
|
|
1628
|
-
chunkTitle:
|
|
1629
|
-
scope:
|
|
1630
|
-
browse:
|
|
1631
|
-
onClose: () =>
|
|
2050
|
+
chunkId: y.id,
|
|
2051
|
+
chunkTitle: y.title,
|
|
2052
|
+
scope: t,
|
|
2053
|
+
browse: h,
|
|
2054
|
+
onClose: () => b(!1)
|
|
1632
2055
|
}
|
|
1633
2056
|
),
|
|
1634
|
-
|
|
1635
|
-
|
|
2057
|
+
fe && K && /* @__PURE__ */ a(
|
|
2058
|
+
dn,
|
|
1636
2059
|
{
|
|
1637
2060
|
documentId: e,
|
|
1638
|
-
rootChunkId:
|
|
1639
|
-
docType:
|
|
1640
|
-
docStatus:
|
|
1641
|
-
chunkStatuses:
|
|
1642
|
-
scope:
|
|
1643
|
-
browse:
|
|
1644
|
-
onClose: () =>
|
|
1645
|
-
onSaved:
|
|
2061
|
+
rootChunkId: K,
|
|
2062
|
+
docType: Y?.type,
|
|
2063
|
+
docStatus: Y?.status,
|
|
2064
|
+
chunkStatuses: ee,
|
|
2065
|
+
scope: t,
|
|
2066
|
+
browse: h,
|
|
2067
|
+
onClose: () => Se(!1),
|
|
2068
|
+
onSaved: F
|
|
1646
2069
|
}
|
|
1647
2070
|
),
|
|
1648
|
-
|
|
1649
|
-
/* @__PURE__ */
|
|
1650
|
-
/* @__PURE__ */
|
|
2071
|
+
C && y && /* @__PURE__ */ a("div", { className: "modal-overlay", onClick: () => x(!1), children: /* @__PURE__ */ c("div", { className: "modal chunk-delete-confirm", onClick: (u) => u.stopPropagation(), children: [
|
|
2072
|
+
/* @__PURE__ */ a("h3", { children: "Delete chunk" }),
|
|
2073
|
+
/* @__PURE__ */ c("p", { className: "modal-context", children: [
|
|
1651
2074
|
"Delete “",
|
|
1652
|
-
|
|
2075
|
+
y.title || "(untitled)",
|
|
1653
2076
|
"” and all of its sub-chunks? This cannot be undone."
|
|
1654
2077
|
] }),
|
|
1655
|
-
/* @__PURE__ */
|
|
1656
|
-
/* @__PURE__ */
|
|
1657
|
-
/* @__PURE__ */
|
|
1658
|
-
|
|
2078
|
+
/* @__PURE__ */ c("div", { className: "modal-buttons", children: [
|
|
2079
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: () => x(!1), children: "cancel" }),
|
|
2080
|
+
/* @__PURE__ */ a("button", { type: "button", className: "danger", onClick: () => {
|
|
2081
|
+
Et();
|
|
1659
2082
|
}, children: "delete" })
|
|
1660
2083
|
] })
|
|
1661
2084
|
] }) })
|
|
1662
2085
|
] });
|
|
1663
2086
|
}
|
|
1664
|
-
function
|
|
1665
|
-
const
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
kind
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
fullPath: i,
|
|
1677
|
-
kind: "directory",
|
|
1678
|
-
explicit: !1,
|
|
1679
|
-
children: []
|
|
2087
|
+
function vt(e, t = "") {
|
|
2088
|
+
const n = e.get(t);
|
|
2089
|
+
if (!n) return [];
|
|
2090
|
+
const r = n.entries.map((o) => {
|
|
2091
|
+
const s = o.kind === "directory" && o.full_path.startsWith(`${t}/`);
|
|
2092
|
+
return {
|
|
2093
|
+
name: o.name,
|
|
2094
|
+
fullPath: o.full_path,
|
|
2095
|
+
kind: o.kind,
|
|
2096
|
+
resourceRef: o.resource_ref,
|
|
2097
|
+
listing: s ? e.get(o.full_path) : void 0,
|
|
2098
|
+
children: s ? vt(e, o.full_path) : []
|
|
1680
2099
|
};
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
}
|
|
1687
|
-
const o = (i) => {
|
|
1688
|
-
i.sort((c, s) => {
|
|
1689
|
-
const u = c.kind === "directory", g = s.kind === "directory";
|
|
1690
|
-
return u !== g ? u ? -1 : 1 : c.name.localeCompare(s.name);
|
|
1691
|
-
}), i.forEach((c) => o(c.children));
|
|
1692
|
-
};
|
|
1693
|
-
return o(r.children), r.children;
|
|
1694
|
-
}
|
|
1695
|
-
function ke(e) {
|
|
1696
|
-
const r = e.lastIndexOf("/");
|
|
1697
|
-
return r <= 0 ? "" : e.slice(0, r);
|
|
1698
|
-
}
|
|
1699
|
-
function Ot(e) {
|
|
1700
|
-
const r = [], n = (a) => {
|
|
1701
|
-
if (a.kind === "document") {
|
|
1702
|
-
const o = a.resourceRef;
|
|
1703
|
-
o?.document_id && r.push(o.document_id);
|
|
1704
|
-
}
|
|
1705
|
-
a.children.forEach(n);
|
|
1706
|
-
};
|
|
1707
|
-
return n(e), r;
|
|
2100
|
+
});
|
|
2101
|
+
return r.sort((o, s) => {
|
|
2102
|
+
const i = o.kind === "directory", l = s.kind === "directory";
|
|
2103
|
+
return i !== l ? i ? -1 : 1 : o.name.localeCompare(s.name);
|
|
2104
|
+
}), r;
|
|
1708
2105
|
}
|
|
1709
|
-
const
|
|
2106
|
+
const Sn = {
|
|
1710
2107
|
directory: "📁",
|
|
1711
2108
|
document: "📄",
|
|
1712
2109
|
volume_mount: "💾",
|
|
1713
2110
|
memory_entry: "🧠"
|
|
1714
2111
|
};
|
|
1715
|
-
function
|
|
1716
|
-
const
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
})
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
)
|
|
2112
|
+
function En(e) {
|
|
2113
|
+
const { tree: t, root: n } = e;
|
|
2114
|
+
return !n || !n.loaded && n.loading ? /* @__PURE__ */ a("div", { className: "empty", children: /* @__PURE__ */ a("p", { children: "Loading…" }) }) : n.loaded && t.length === 0 && !n.nextCursor ? /* @__PURE__ */ a("div", { className: "empty", children: /* @__PURE__ */ a("p", { children: "This tree is empty. Create a folder or document to begin." }) }) : /* @__PURE__ */ c("ul", { className: "tree path-tree", children: [
|
|
2115
|
+
t.map((r) => /* @__PURE__ */ a(Nt, { node: r, ...e }, r.fullPath)),
|
|
2116
|
+
/* @__PURE__ */ a(kt, { dir: "", listing: n, ...e })
|
|
2117
|
+
] });
|
|
2118
|
+
}
|
|
2119
|
+
function kt({
|
|
2120
|
+
dir: e,
|
|
2121
|
+
listing: t,
|
|
2122
|
+
onLoadMore: n,
|
|
2123
|
+
onRetry: r
|
|
2124
|
+
}) {
|
|
2125
|
+
const o = [];
|
|
2126
|
+
return !t || t.loading && t.entries.length === 0 ? o.push(
|
|
2127
|
+
/* @__PURE__ */ a("li", { className: "node path-status", children: /* @__PURE__ */ a("span", { className: "path-implicit", children: "loading…" }) }, "status")
|
|
2128
|
+
) : t.error ? o.push(
|
|
2129
|
+
/* @__PURE__ */ c("li", { className: "node path-status", children: [
|
|
2130
|
+
e !== "" && /* @__PURE__ */ c("span", { className: "path-err", children: [
|
|
2131
|
+
"failed to load: ",
|
|
2132
|
+
t.error
|
|
2133
|
+
] }),
|
|
2134
|
+
" ",
|
|
2135
|
+
/* @__PURE__ */ a("button", { type: "button", className: "path-more", onClick: () => r(e), children: "retry" })
|
|
2136
|
+
] }, "status")
|
|
2137
|
+
) : t.loaded && t.entries.length === 0 && e !== "" && o.push(
|
|
2138
|
+
/* @__PURE__ */ a("li", { className: "node path-status", children: /* @__PURE__ */ a("span", { className: "path-implicit", children: "empty" }) }, "status")
|
|
2139
|
+
), t?.nextCursor && !t.error && o.push(
|
|
2140
|
+
/* @__PURE__ */ a("li", { className: "node path-status", children: /* @__PURE__ */ a(
|
|
2141
|
+
"button",
|
|
2142
|
+
{
|
|
2143
|
+
type: "button",
|
|
2144
|
+
className: "path-more",
|
|
2145
|
+
disabled: t.loading,
|
|
2146
|
+
onClick: () => n(e),
|
|
2147
|
+
children: t.loading ? "loading…" : `Load more (${t.entries.length} shown)`
|
|
2148
|
+
}
|
|
2149
|
+
) }, "more")
|
|
2150
|
+
), /* @__PURE__ */ a(Q, { children: o });
|
|
1743
2151
|
}
|
|
1744
|
-
function
|
|
1745
|
-
if (e.kind !== "document" || !
|
|
2152
|
+
function xn(e, t) {
|
|
2153
|
+
if (e.kind !== "document" || !t) return;
|
|
1746
2154
|
const n = e.resourceRef;
|
|
1747
|
-
return n?.document_id ?
|
|
2155
|
+
return n?.document_id ? t.get(n.document_id) : void 0;
|
|
1748
2156
|
}
|
|
1749
|
-
function
|
|
1750
|
-
const
|
|
1751
|
-
return /* @__PURE__ */
|
|
1752
|
-
/* @__PURE__ */
|
|
1753
|
-
/* @__PURE__ */
|
|
2157
|
+
function Nt(e) {
|
|
2158
|
+
const { node: t, expanded: n, onToggle: r, selectedPath: o, onSelect: s, summaries: i } = e, l = t.kind === "directory", f = l && n.has(t.fullPath), d = o === t.fullPath, h = xn(t, i), w = h && h.color_enabled ? He(ft(h.type, h.status, Ge(h.color_scheme))) : void 0;
|
|
2159
|
+
return /* @__PURE__ */ c("li", { className: `node path-node kind-${t.kind} ${d ? "selected" : ""}`, children: [
|
|
2160
|
+
/* @__PURE__ */ c("div", { className: "row path-row", style: w, children: [
|
|
2161
|
+
/* @__PURE__ */ a(
|
|
1754
2162
|
"button",
|
|
1755
2163
|
{
|
|
1756
2164
|
type: "button",
|
|
1757
2165
|
className: "tree-caret",
|
|
1758
|
-
"aria-label":
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
2166
|
+
"aria-label": f ? "collapse" : "expand",
|
|
2167
|
+
"aria-expanded": l ? f : void 0,
|
|
2168
|
+
disabled: !l,
|
|
2169
|
+
onClick: (S) => {
|
|
2170
|
+
S.stopPropagation(), l && r(t.fullPath);
|
|
1762
2171
|
},
|
|
1763
|
-
children:
|
|
2172
|
+
children: l ? f ? "▼" : "▶" : "·"
|
|
1764
2173
|
}
|
|
1765
2174
|
),
|
|
1766
|
-
/* @__PURE__ */
|
|
2175
|
+
/* @__PURE__ */ c(
|
|
1767
2176
|
"button",
|
|
1768
2177
|
{
|
|
1769
2178
|
type: "button",
|
|
1770
2179
|
className: "path-link",
|
|
1771
|
-
onClick: () =>
|
|
1772
|
-
title:
|
|
2180
|
+
onClick: () => s(t),
|
|
2181
|
+
title: t.fullPath,
|
|
1773
2182
|
children: [
|
|
1774
|
-
/* @__PURE__ */
|
|
1775
|
-
/* @__PURE__ */
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
!e.explicit && /* @__PURE__ */ t("span", { className: "path-implicit", title: "Implicit directory (no stored entry)", children: "implicit" })
|
|
2183
|
+
/* @__PURE__ */ a("span", { className: "path-kind-icon", "aria-hidden": !0, children: Sn[t.kind] ?? "•" }),
|
|
2184
|
+
/* @__PURE__ */ a("span", { className: "path-name", children: t.name }),
|
|
2185
|
+
h?.type && /* @__PURE__ */ a("span", { className: "chunk-badge", children: h.type }),
|
|
2186
|
+
h?.status && /* @__PURE__ */ a("span", { className: "chunk-badge chunk-status", children: h.status })
|
|
1779
2187
|
]
|
|
1780
2188
|
}
|
|
1781
2189
|
)
|
|
1782
2190
|
] }),
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
{
|
|
1786
|
-
|
|
1787
|
-
expanded: r,
|
|
1788
|
-
toggle: n,
|
|
1789
|
-
selectedPath: a,
|
|
1790
|
-
onSelect: o,
|
|
1791
|
-
summaries: i
|
|
1792
|
-
},
|
|
1793
|
-
v.fullPath
|
|
1794
|
-
)) })
|
|
2191
|
+
f && /* @__PURE__ */ c("ul", { className: "children path-children", children: [
|
|
2192
|
+
t.children.map((S) => /* @__PURE__ */ a(Nt, { ...e, node: S }, S.fullPath)),
|
|
2193
|
+
/* @__PURE__ */ a(kt, { ...e, dir: t.fullPath, listing: t.listing })
|
|
2194
|
+
] })
|
|
1795
2195
|
] });
|
|
1796
2196
|
}
|
|
1797
|
-
const
|
|
1798
|
-
function
|
|
1799
|
-
return `${e}/${
|
|
2197
|
+
const tt = /^[A-Za-z0-9._-]+$/;
|
|
2198
|
+
function nt(e, t) {
|
|
2199
|
+
return `${e}/${t}`;
|
|
1800
2200
|
}
|
|
1801
|
-
function
|
|
2201
|
+
function wt(e, t) {
|
|
1802
2202
|
for (const n of e) {
|
|
1803
|
-
if (n.fullPath ===
|
|
1804
|
-
const
|
|
1805
|
-
if (
|
|
2203
|
+
if (n.fullPath === t) return n;
|
|
2204
|
+
const r = wt(n.children, t);
|
|
2205
|
+
if (r) return r;
|
|
1806
2206
|
}
|
|
1807
2207
|
}
|
|
1808
|
-
function
|
|
1809
|
-
const { theme:
|
|
1810
|
-
return /* @__PURE__ */
|
|
1811
|
-
|
|
2208
|
+
function An(e) {
|
|
2209
|
+
const { theme: t, defaultScope: n, path: r, onPathChange: o, browse: s, principal: i, renderAssistant: l, onError: f } = e, d = st(e);
|
|
2210
|
+
return /* @__PURE__ */ a(it, { theme: t, dataLayer: d, children: /* @__PURE__ */ a(
|
|
2211
|
+
$n,
|
|
1812
2212
|
{
|
|
1813
2213
|
defaultScope: n,
|
|
1814
|
-
path:
|
|
2214
|
+
path: r,
|
|
1815
2215
|
onPathChange: o,
|
|
1816
|
-
browse:
|
|
1817
|
-
principal:
|
|
1818
|
-
renderAssistant:
|
|
1819
|
-
onError:
|
|
2216
|
+
browse: s,
|
|
2217
|
+
principal: i,
|
|
2218
|
+
renderAssistant: l,
|
|
2219
|
+
onError: f
|
|
1820
2220
|
}
|
|
1821
2221
|
) });
|
|
1822
2222
|
}
|
|
1823
|
-
function
|
|
2223
|
+
function $n({
|
|
1824
2224
|
defaultScope: e,
|
|
1825
|
-
path:
|
|
2225
|
+
path: t,
|
|
1826
2226
|
onPathChange: n,
|
|
1827
|
-
browse:
|
|
2227
|
+
browse: r,
|
|
1828
2228
|
principal: o,
|
|
1829
|
-
renderAssistant:
|
|
1830
|
-
onError:
|
|
2229
|
+
renderAssistant: s,
|
|
2230
|
+
onError: i
|
|
1831
2231
|
}) {
|
|
1832
|
-
const
|
|
1833
|
-
|
|
1834
|
-
|
|
2232
|
+
const l = be(), [f, d] = p(e ?? "user"), [h, w] = p(void 0), [S, g] = p(null), [N, y] = p(null), [j, B] = p(() => /* @__PURE__ */ new Set()), O = t !== void 0 ? t : h, W = te(n);
|
|
2233
|
+
H(() => {
|
|
2234
|
+
W.current = n;
|
|
1835
2235
|
}, [n]);
|
|
1836
|
-
const
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
}, [
|
|
1840
|
-
const
|
|
1841
|
-
|
|
1842
|
-
}, []),
|
|
1843
|
-
() =>
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
}
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
}, [
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
2236
|
+
const q = te(i);
|
|
2237
|
+
H(() => {
|
|
2238
|
+
q.current = i;
|
|
2239
|
+
}, [i]);
|
|
2240
|
+
const [I, V] = p([]), z = te(0), Z = te(void 0), _ = P((k) => {
|
|
2241
|
+
Z.current = k, W.current?.(k), w(k);
|
|
2242
|
+
}, []), R = P(
|
|
2243
|
+
(k) => {
|
|
2244
|
+
z.current++, V(($) => $.length > 0 ? [] : $), _(k);
|
|
2245
|
+
},
|
|
2246
|
+
[_]
|
|
2247
|
+
);
|
|
2248
|
+
H(() => {
|
|
2249
|
+
t === void 0 || t === Z.current || (z.current++, V((k) => k.length > 0 ? [] : k));
|
|
2250
|
+
}, [t]);
|
|
2251
|
+
const E = X(
|
|
2252
|
+
() => r && (r.scopeId || r.tenant) ? { scopeId: r.scopeId, tenant: r.tenant } : void 0,
|
|
2253
|
+
[r?.scopeId, r?.tenant]
|
|
2254
|
+
), m = X(() => new Bt(l, f, E), [l, f, E]), b = Mt(m.subscribe, m.getSnapshot), C = P((k) => {
|
|
2255
|
+
q.current?.(k);
|
|
2256
|
+
}, []), [x, U] = p(() => /* @__PURE__ */ new Map()), M = te(/* @__PURE__ */ new Set()), ne = te(0), de = P(() => {
|
|
2257
|
+
ne.current++, M.current = /* @__PURE__ */ new Set(), U(/* @__PURE__ */ new Map());
|
|
2258
|
+
}, []), we = te(!0);
|
|
2259
|
+
H(() => {
|
|
2260
|
+
we.current ? we.current = !1 : (R(void 0), g(null), B(/* @__PURE__ */ new Set()), de()), m.loadDir("").catch(C);
|
|
2261
|
+
}, [m, R, de, C]), H(() => {
|
|
2262
|
+
for (const k of j)
|
|
2263
|
+
b.has(k) || m.loadDir(k).catch(C);
|
|
2264
|
+
}, [m, j, b, C]);
|
|
2265
|
+
const ve = te(null);
|
|
2266
|
+
H(() => {
|
|
2267
|
+
const k = ve.current !== null && ve.current !== m;
|
|
2268
|
+
if (ve.current = m, !O || k) return;
|
|
2269
|
+
const $ = ot(O).filter((L) => L !== "");
|
|
2270
|
+
B((L) => {
|
|
2271
|
+
if ($.every((ae) => L.has(ae))) return L;
|
|
2272
|
+
const G = new Set(L);
|
|
2273
|
+
return $.forEach((ae) => G.add(ae)), G;
|
|
2274
|
+
}), m.reveal(O).catch(C);
|
|
2275
|
+
}, [m, O, C]), H(() => {
|
|
2276
|
+
if (f === "tenant") return;
|
|
2277
|
+
const k = [];
|
|
2278
|
+
for (const L of b.values())
|
|
2279
|
+
for (const G of Ze(L.entries))
|
|
2280
|
+
M.current.has(G) || (M.current.add(G), k.push(G));
|
|
2281
|
+
const $ = ne.current;
|
|
2282
|
+
for (let L = 0; L < k.length; L += Oe)
|
|
2283
|
+
l.documentsSummary({ documentIds: k.slice(L, L + Oe) }, f, E).then((G) => {
|
|
2284
|
+
ne.current === $ && U((ae) => {
|
|
2285
|
+
const le = new Map(ae);
|
|
2286
|
+
for (const ye of G.documents ?? []) le.set(ye.document_id, ye);
|
|
2287
|
+
return le;
|
|
2288
|
+
});
|
|
2289
|
+
}).catch(() => {
|
|
2290
|
+
});
|
|
2291
|
+
}, [l, b, f, E]);
|
|
2292
|
+
const me = X(() => vt(b), [b]), Ce = P(async () => {
|
|
2293
|
+
g(null), de(), await m.refresh(j).catch(C), O && await m.reveal(O).catch(C);
|
|
2294
|
+
}, [m, j, O, de, C]), ue = P((k) => {
|
|
2295
|
+
B(($) => {
|
|
2296
|
+
const L = new Set($);
|
|
2297
|
+
return L.has(k) ? L.delete(k) : L.add(k), L;
|
|
2298
|
+
});
|
|
2299
|
+
}, []), Le = P((k) => m.loadMore(k).catch(C), [m, C]), _e = P(
|
|
2300
|
+
(k) => {
|
|
2301
|
+
(m.getSnapshot().get(k)?.loaded ? m.loadMore(k) : m.loadDir(k)).catch(C);
|
|
2302
|
+
},
|
|
2303
|
+
[m, C]
|
|
2304
|
+
), D = X(
|
|
2305
|
+
() => O ? wt(me, O) : void 0,
|
|
2306
|
+
[me, O]
|
|
2307
|
+
), Y = b.get("")?.error, ce = D?.kind === "directory" ? D.fullPath : void 0, [fe, Se] = p(null);
|
|
2308
|
+
H(() => {
|
|
2309
|
+
if (!ce || !l.pathIsStored) return;
|
|
2310
|
+
let k = !1;
|
|
2311
|
+
return l.pathIsStored(ce, f, E).then(
|
|
2312
|
+
($) => {
|
|
2313
|
+
k || Se({ path: ce, explicit: $ });
|
|
2314
|
+
},
|
|
2315
|
+
() => {
|
|
2316
|
+
}
|
|
2317
|
+
), () => {
|
|
2318
|
+
k = !0;
|
|
1880
2319
|
};
|
|
1881
|
-
}, [
|
|
1882
|
-
const
|
|
1883
|
-
(
|
|
1884
|
-
|
|
1885
|
-
), w = q(() => p ? p.kind === "directory" ? p.fullPath : ke(p.fullPath) : "", [p]), S = w || "/", T = u !== "tenant", ee = O(() => {
|
|
1886
|
-
M({
|
|
1887
|
-
title: `New folder in ${S}`,
|
|
2320
|
+
}, [l, ce, f, E]);
|
|
2321
|
+
const pe = D ? D.kind !== "directory" ? "yes" : fe?.path === D.fullPath ? fe.explicit ? "yes" : "implicit (no entry)" : void 0 : void 0, oe = X(() => D ? D.kind === "directory" ? D.fullPath : jt(D.fullPath) : "", [D]), F = oe || "/", ke = f !== "tenant", Ee = P(() => {
|
|
2322
|
+
y({
|
|
2323
|
+
title: `New folder in ${F}`,
|
|
1888
2324
|
fields: [{ key: "name", label: "Folder name", placeholder: "e.g. launches" }],
|
|
1889
2325
|
submitLabel: "Create",
|
|
1890
|
-
onSubmit: async (
|
|
1891
|
-
const
|
|
1892
|
-
if (
|
|
1893
|
-
const
|
|
1894
|
-
await
|
|
2326
|
+
onSubmit: async (k) => {
|
|
2327
|
+
const $ = k.name.trim();
|
|
2328
|
+
if (!tt.test($)) throw new Error("name may contain only [A-Za-z0-9._-]");
|
|
2329
|
+
const L = nt(oe, $);
|
|
2330
|
+
await l.pathMkdir(L, f, E), await m.invalidate(L).catch(C), R(L);
|
|
1895
2331
|
}
|
|
1896
2332
|
});
|
|
1897
|
-
}, [
|
|
1898
|
-
|
|
1899
|
-
title: `New document in ${
|
|
2333
|
+
}, [l, m, oe, F, f, E, C, R]), Ne = P(() => {
|
|
2334
|
+
y({
|
|
2335
|
+
title: `New document in ${F}`,
|
|
1900
2336
|
fields: [
|
|
1901
2337
|
{ key: "name", label: "Path name", placeholder: "e.g. launch-plan" },
|
|
1902
2338
|
{ key: "title", label: "Title", placeholder: "e.g. Launch Plan" }
|
|
1903
2339
|
],
|
|
1904
2340
|
submitLabel: "Create",
|
|
1905
|
-
onSubmit: async (
|
|
1906
|
-
const
|
|
1907
|
-
if (
|
|
1908
|
-
const
|
|
1909
|
-
await
|
|
2341
|
+
onSubmit: async (k) => {
|
|
2342
|
+
const $ = k.name.trim();
|
|
2343
|
+
if (!tt.test($)) throw new Error("name may contain only [A-Za-z0-9._-]");
|
|
2344
|
+
const L = k.title.trim() || $, G = nt(oe, $);
|
|
2345
|
+
await l.documentCreate(L, G, f, E), await m.invalidate(G).catch(C), R(G);
|
|
1910
2346
|
}
|
|
1911
2347
|
});
|
|
1912
|
-
}, [
|
|
1913
|
-
|
|
1914
|
-
title: `Rename / move ${
|
|
1915
|
-
fields: [{ key: "to", label: "New path", value:
|
|
2348
|
+
}, [l, m, oe, F, f, E, C, R]), se = P(() => {
|
|
2349
|
+
D && y({
|
|
2350
|
+
title: `Rename / move ${D.fullPath}`,
|
|
2351
|
+
fields: [{ key: "to", label: "New path", value: D.fullPath }],
|
|
1916
2352
|
submitLabel: "Move",
|
|
1917
|
-
onSubmit: async (
|
|
1918
|
-
const
|
|
1919
|
-
if (
|
|
1920
|
-
await
|
|
2353
|
+
onSubmit: async (k) => {
|
|
2354
|
+
const $ = k.to.trim();
|
|
2355
|
+
if (!$.startsWith("/")) throw new Error("path must start with /");
|
|
2356
|
+
await l.pathMv(D.fullPath, $, f, E), await Promise.all([
|
|
2357
|
+
m.invalidate(D.fullPath, { dropSubtree: !0 }),
|
|
2358
|
+
m.invalidate($)
|
|
2359
|
+
]).catch(C), R($);
|
|
1921
2360
|
}
|
|
1922
2361
|
});
|
|
1923
|
-
}, [
|
|
1924
|
-
if (!
|
|
1925
|
-
if (
|
|
1926
|
-
const
|
|
1927
|
-
|
|
1928
|
-
title: `Delete document ${
|
|
2362
|
+
}, [l, m, D, f, E, C, R]), re = P(() => {
|
|
2363
|
+
if (!D) return;
|
|
2364
|
+
if (D.kind === "document") {
|
|
2365
|
+
const L = D.resourceRef?.document_id;
|
|
2366
|
+
y({
|
|
2367
|
+
title: `Delete document ${D.fullPath}`,
|
|
1929
2368
|
message: "This deletes the document, all its chunks, and its path entry. This cannot be undone.",
|
|
1930
2369
|
fields: [],
|
|
1931
2370
|
submitLabel: "Delete",
|
|
1932
2371
|
danger: !0,
|
|
1933
2372
|
onSubmit: async () => {
|
|
1934
|
-
if (!
|
|
1935
|
-
await
|
|
2373
|
+
if (!L) throw new Error("this document dirent has no document_id");
|
|
2374
|
+
await l.documentDelete(L, f, E), await m.invalidate(D.fullPath).catch(C), R(void 0);
|
|
1936
2375
|
}
|
|
1937
2376
|
});
|
|
1938
2377
|
return;
|
|
1939
2378
|
}
|
|
1940
|
-
const
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
for (const W of x)
|
|
1949
|
-
await s.documentDelete(W, u, y);
|
|
1950
|
-
await s.pathRm(p.fullPath, u, !0, y), await D(), R(void 0);
|
|
2379
|
+
const k = D;
|
|
2380
|
+
g(null), (async () => {
|
|
2381
|
+
let $;
|
|
2382
|
+
try {
|
|
2383
|
+
$ = await Ft(l, k.fullPath, f, E);
|
|
2384
|
+
} catch (G) {
|
|
2385
|
+
g(`could not list ${k.fullPath} for delete: ${G instanceof Error ? G.message : String(G)}`);
|
|
2386
|
+
return;
|
|
1951
2387
|
}
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
2388
|
+
const L = f === "tenant" ? [] : Ze($);
|
|
2389
|
+
y({
|
|
2390
|
+
title: `Delete branch ${k.fullPath}`,
|
|
2391
|
+
message: $.length === 0 ? "This removes the (empty) folder." : "This removes the folder and everything under it" + (L.length > 0 ? ` — including ${L.length} document(s), whose chunks are deleted.` : "."),
|
|
2392
|
+
fields: [],
|
|
2393
|
+
submitLabel: "Delete",
|
|
2394
|
+
danger: !0,
|
|
2395
|
+
onSubmit: async () => {
|
|
2396
|
+
for (const G of L)
|
|
2397
|
+
await l.documentDelete(G, f, E);
|
|
2398
|
+
await l.pathRm(k.fullPath, f, !0, E), await m.invalidate(k.fullPath, { dropSubtree: !0 }).catch(C), R(void 0);
|
|
2399
|
+
}
|
|
2400
|
+
});
|
|
2401
|
+
})();
|
|
2402
|
+
}, [l, m, D, f, E, C, R]), K = D && (D.kind === "directory" || D.kind === "document"), ee = X(() => {
|
|
2403
|
+
if (I.length > 0) return I[I.length - 1];
|
|
2404
|
+
if (D?.kind === "document")
|
|
2405
|
+
return {
|
|
2406
|
+
documentId: D.resourceRef?.document_id ?? "",
|
|
2407
|
+
path: D.fullPath,
|
|
2408
|
+
title: D.name
|
|
2409
|
+
};
|
|
2410
|
+
}, [I, D]), ge = P(
|
|
2411
|
+
(k, $) => {
|
|
2412
|
+
const L = ++z.current, G = zt(m.getSnapshot(), k.documentId);
|
|
2413
|
+
V(ct(I, { ...$, path: ee?.path }, { ...k, path: G })), _(G), !(G || !l.documentPath) && l.documentPath(k.documentId, f, E).then(
|
|
2414
|
+
(ae) => {
|
|
2415
|
+
!ae || z.current !== L || (V((le) => je(le, k.documentId, { path: ae })), _(ae));
|
|
2416
|
+
},
|
|
2417
|
+
() => {
|
|
2418
|
+
}
|
|
2419
|
+
// best-effort: the document is already open by id
|
|
2420
|
+
);
|
|
2421
|
+
},
|
|
2422
|
+
[l, m, I, ee?.path, f, E, _]
|
|
2423
|
+
), Me = P(
|
|
2424
|
+
(k) => {
|
|
2425
|
+
const $ = lt(I, k);
|
|
2426
|
+
$ !== I && (z.current++, V($), _($[$.length - 1].path));
|
|
2427
|
+
},
|
|
2428
|
+
[I, _]
|
|
2429
|
+
), Re = P(
|
|
2430
|
+
(k, $) => V((L) => je(L, k, { title: $ })),
|
|
2431
|
+
[]
|
|
2432
|
+
), Pe = !!ee?.path && D?.kind === "document" && D.fullPath === ee.path;
|
|
2433
|
+
return /* @__PURE__ */ c(Q, { children: [
|
|
2434
|
+
/* @__PURE__ */ c(
|
|
2435
|
+
Zt,
|
|
1957
2436
|
{
|
|
1958
2437
|
className: "paths-view",
|
|
1959
2438
|
defaultLeftWidth: 420,
|
|
@@ -1961,164 +2440,220 @@ function Ft({
|
|
|
1961
2440
|
minRightWidth: 300,
|
|
1962
2441
|
storageKey: "loomcycle.explorer.split.paths",
|
|
1963
2442
|
children: [
|
|
1964
|
-
/* @__PURE__ */
|
|
1965
|
-
/* @__PURE__ */
|
|
1966
|
-
/* @__PURE__ */
|
|
1967
|
-
/* @__PURE__ */
|
|
1968
|
-
/* @__PURE__ */
|
|
1969
|
-
/* @__PURE__ */
|
|
1970
|
-
/* @__PURE__ */
|
|
1971
|
-
/* @__PURE__ */
|
|
2443
|
+
/* @__PURE__ */ c("div", { className: "left", children: [
|
|
2444
|
+
/* @__PURE__ */ c("div", { className: "paths-toolbar", children: [
|
|
2445
|
+
/* @__PURE__ */ c("label", { className: "paths-scope", children: [
|
|
2446
|
+
/* @__PURE__ */ a("span", { children: "scope" }),
|
|
2447
|
+
/* @__PURE__ */ c("select", { value: f, onChange: (k) => d(k.target.value), children: [
|
|
2448
|
+
/* @__PURE__ */ a("option", { value: "user", children: "user" }),
|
|
2449
|
+
/* @__PURE__ */ a("option", { value: "agent", children: "agent" }),
|
|
2450
|
+
/* @__PURE__ */ a("option", { value: "tenant", children: "tenant" })
|
|
1972
2451
|
] })
|
|
1973
2452
|
] }),
|
|
1974
|
-
/* @__PURE__ */
|
|
1975
|
-
/* @__PURE__ */
|
|
1976
|
-
/* @__PURE__ */
|
|
2453
|
+
/* @__PURE__ */ c("div", { className: "paths-toolbar-actions", children: [
|
|
2454
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: Ee, title: `New folder in ${F}`, children: "+ folder" }),
|
|
2455
|
+
/* @__PURE__ */ a(
|
|
1977
2456
|
"button",
|
|
1978
2457
|
{
|
|
1979
2458
|
type: "button",
|
|
1980
|
-
onClick:
|
|
1981
|
-
disabled: !
|
|
1982
|
-
title:
|
|
2459
|
+
onClick: Ne,
|
|
2460
|
+
disabled: !ke,
|
|
2461
|
+
title: ke ? `New document in ${F}` : "Documents are agent/user scope only",
|
|
1983
2462
|
children: "+ document"
|
|
1984
2463
|
}
|
|
1985
2464
|
),
|
|
1986
|
-
/* @__PURE__ */
|
|
1987
|
-
|
|
2465
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: () => {
|
|
2466
|
+
Ce();
|
|
1988
2467
|
}, title: "Reload the tree", children: "↻" })
|
|
1989
2468
|
] })
|
|
1990
2469
|
] }),
|
|
1991
|
-
/* @__PURE__ */
|
|
2470
|
+
/* @__PURE__ */ c("p", { className: "paths-context", children: [
|
|
1992
2471
|
"new items → ",
|
|
1993
|
-
/* @__PURE__ */
|
|
1994
|
-
|
|
2472
|
+
/* @__PURE__ */ a("code", { children: F }),
|
|
2473
|
+
E?.scopeId && /* @__PURE__ */ c(Q, { children: [
|
|
1995
2474
|
" · ",
|
|
1996
2475
|
"subject ",
|
|
1997
|
-
/* @__PURE__ */
|
|
2476
|
+
/* @__PURE__ */ a("code", { children: E.scopeId })
|
|
1998
2477
|
] }),
|
|
1999
|
-
|
|
2478
|
+
E?.tenant && /* @__PURE__ */ c(Q, { children: [
|
|
2000
2479
|
" · ",
|
|
2001
2480
|
"tenant ",
|
|
2002
|
-
/* @__PURE__ */
|
|
2481
|
+
/* @__PURE__ */ a("code", { children: E.tenant })
|
|
2003
2482
|
] })
|
|
2004
2483
|
] }),
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2484
|
+
(S || Y) && /* @__PURE__ */ a("div", { className: "paths-err", children: S || Y }),
|
|
2485
|
+
/* @__PURE__ */ a(
|
|
2486
|
+
En,
|
|
2008
2487
|
{
|
|
2009
|
-
tree:
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2488
|
+
tree: me,
|
|
2489
|
+
root: b.get(""),
|
|
2490
|
+
expanded: j,
|
|
2491
|
+
onToggle: ue,
|
|
2492
|
+
onLoadMore: Le,
|
|
2493
|
+
onRetry: _e,
|
|
2494
|
+
selectedPath: O,
|
|
2495
|
+
onSelect: (k) => R(k.fullPath),
|
|
2496
|
+
summaries: x
|
|
2013
2497
|
}
|
|
2014
2498
|
)
|
|
2015
2499
|
] }),
|
|
2016
|
-
/* @__PURE__ */
|
|
2017
|
-
/* @__PURE__ */
|
|
2018
|
-
|
|
2019
|
-
/* @__PURE__ */
|
|
2020
|
-
|
|
2021
|
-
|
|
2500
|
+
/* @__PURE__ */ a("div", { className: "right", children: ee ? /* @__PURE__ */ c("div", { className: "paths-doc", children: [
|
|
2501
|
+
/* @__PURE__ */ a(ut, { trail: I, onJump: Me }),
|
|
2502
|
+
/* @__PURE__ */ c("div", { className: "paths-doc-head", children: [
|
|
2503
|
+
ee.path ? /* @__PURE__ */ a("code", { className: "paths-doc-path", children: ee.path }) : /* @__PURE__ */ c(
|
|
2504
|
+
"span",
|
|
2505
|
+
{
|
|
2506
|
+
className: "paths-doc-path paths-doc-unfiled",
|
|
2507
|
+
title: "Opened by id — no entry for this document was found in the Path tree",
|
|
2508
|
+
children: [
|
|
2509
|
+
he(ee),
|
|
2510
|
+
" ",
|
|
2511
|
+
/* @__PURE__ */ a("em", { children: "· opened by id, not in the tree" })
|
|
2512
|
+
]
|
|
2513
|
+
}
|
|
2514
|
+
),
|
|
2515
|
+
Pe && /* @__PURE__ */ c("div", { className: "paths-detail-actions", children: [
|
|
2516
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: se, children: "rename / move" }),
|
|
2517
|
+
/* @__PURE__ */ a("button", { type: "button", className: "danger", onClick: re, children: "delete" })
|
|
2022
2518
|
] })
|
|
2023
2519
|
] }),
|
|
2024
|
-
/* @__PURE__ */
|
|
2025
|
-
|
|
2520
|
+
/* @__PURE__ */ a(
|
|
2521
|
+
bt,
|
|
2026
2522
|
{
|
|
2027
|
-
documentId:
|
|
2028
|
-
scope:
|
|
2029
|
-
titleHint:
|
|
2030
|
-
browse:
|
|
2523
|
+
documentId: ee.documentId,
|
|
2524
|
+
scope: f,
|
|
2525
|
+
titleHint: ee.title,
|
|
2526
|
+
browse: E,
|
|
2031
2527
|
principal: o,
|
|
2032
|
-
renderAssistant:
|
|
2033
|
-
|
|
2528
|
+
renderAssistant: s,
|
|
2529
|
+
initialChunkId: ee.chunkId,
|
|
2530
|
+
onOpenDocument: ge,
|
|
2531
|
+
onTitle: Re
|
|
2532
|
+
},
|
|
2533
|
+
I.length
|
|
2034
2534
|
)
|
|
2035
|
-
] }) : /* @__PURE__ */
|
|
2036
|
-
/* @__PURE__ */
|
|
2037
|
-
/* @__PURE__ */
|
|
2038
|
-
/* @__PURE__ */
|
|
2535
|
+
] }) : D ? /* @__PURE__ */ c("div", { className: "paths-detail", children: [
|
|
2536
|
+
/* @__PURE__ */ c("h2", { children: [
|
|
2537
|
+
/* @__PURE__ */ a("span", { className: "paths-detail-kind", children: D.kind }),
|
|
2538
|
+
/* @__PURE__ */ a("code", { children: D.fullPath })
|
|
2039
2539
|
] }),
|
|
2040
|
-
/* @__PURE__ */
|
|
2041
|
-
/* @__PURE__ */
|
|
2042
|
-
/* @__PURE__ */
|
|
2043
|
-
/* @__PURE__ */
|
|
2044
|
-
|
|
2540
|
+
/* @__PURE__ */ c("dl", { className: "paths-detail-meta", children: [
|
|
2541
|
+
/* @__PURE__ */ a("dt", { children: "scope" }),
|
|
2542
|
+
/* @__PURE__ */ a("dd", { children: f }),
|
|
2543
|
+
pe && /* @__PURE__ */ c(Q, { children: [
|
|
2544
|
+
/* @__PURE__ */ a("dt", { children: "stored" }),
|
|
2545
|
+
/* @__PURE__ */ a("dd", { children: pe })
|
|
2546
|
+
] })
|
|
2045
2547
|
] }),
|
|
2046
|
-
|
|
2047
|
-
/* @__PURE__ */
|
|
2048
|
-
/* @__PURE__ */
|
|
2049
|
-
] }) : /* @__PURE__ */
|
|
2548
|
+
K ? /* @__PURE__ */ c("div", { className: "paths-detail-actions", children: [
|
|
2549
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: se, children: "rename / move" }),
|
|
2550
|
+
/* @__PURE__ */ a("button", { type: "button", className: "danger", onClick: re, children: "delete" })
|
|
2551
|
+
] }) : /* @__PURE__ */ c("p", { className: "paths-readonly", children: [
|
|
2050
2552
|
"Read-only — ",
|
|
2051
|
-
|
|
2553
|
+
D.kind,
|
|
2052
2554
|
" entries are managed by their own tool."
|
|
2053
2555
|
] })
|
|
2054
|
-
] }) : /* @__PURE__ */
|
|
2556
|
+
] }) : /* @__PURE__ */ a("div", { className: "empty", children: /* @__PURE__ */ a("p", { children: "Select a path on the left, or create a folder / document." }) }) })
|
|
2055
2557
|
]
|
|
2056
2558
|
}
|
|
2057
2559
|
),
|
|
2058
|
-
|
|
2560
|
+
N && /* @__PURE__ */ a(Dn, { state: N, onClose: () => y(null) })
|
|
2059
2561
|
] });
|
|
2060
2562
|
}
|
|
2061
|
-
function
|
|
2062
|
-
const [n,
|
|
2063
|
-
() => Object.fromEntries(e.fields.map((
|
|
2064
|
-
), [o,
|
|
2065
|
-
return /* @__PURE__ */
|
|
2066
|
-
|
|
2563
|
+
function Dn({ state: e, onClose: t }) {
|
|
2564
|
+
const [n, r] = p(
|
|
2565
|
+
() => Object.fromEntries(e.fields.map((d) => [d.key, d.value ?? ""]))
|
|
2566
|
+
), [o, s] = p(!1), [i, l] = p(null);
|
|
2567
|
+
return /* @__PURE__ */ a("div", { className: "modal-overlay", onClick: t, children: /* @__PURE__ */ c("form", { className: "modal", onClick: (d) => d.stopPropagation(), onSubmit: async (d) => {
|
|
2568
|
+
d.preventDefault(), s(!0), l(null);
|
|
2067
2569
|
try {
|
|
2068
|
-
await e.onSubmit(n),
|
|
2570
|
+
await e.onSubmit(n), t();
|
|
2069
2571
|
} catch (h) {
|
|
2070
|
-
|
|
2572
|
+
l(h instanceof Error ? h.message : String(h)), s(!1);
|
|
2071
2573
|
}
|
|
2072
2574
|
}, children: [
|
|
2073
|
-
/* @__PURE__ */
|
|
2074
|
-
/* @__PURE__ */
|
|
2075
|
-
/* @__PURE__ */
|
|
2076
|
-
/* @__PURE__ */
|
|
2077
|
-
/* @__PURE__ */
|
|
2575
|
+
/* @__PURE__ */ c("div", { className: "modal-header sticky-top", children: [
|
|
2576
|
+
/* @__PURE__ */ a("h3", { children: e.title }),
|
|
2577
|
+
/* @__PURE__ */ c("div", { className: "modal-buttons modal-buttons-top", children: [
|
|
2578
|
+
/* @__PURE__ */ a("button", { type: "button", onClick: t, disabled: o, children: "cancel" }),
|
|
2579
|
+
/* @__PURE__ */ a("button", { type: "submit", className: e.danger ? "danger" : "primary", disabled: o, children: o ? "working…" : e.submitLabel })
|
|
2078
2580
|
] })
|
|
2079
2581
|
] }),
|
|
2080
|
-
e.message && /* @__PURE__ */
|
|
2081
|
-
e.fields.map((
|
|
2082
|
-
/* @__PURE__ */
|
|
2083
|
-
/* @__PURE__ */
|
|
2582
|
+
e.message && /* @__PURE__ */ a("p", { className: "modal-context", children: e.message }),
|
|
2583
|
+
e.fields.map((d, h) => /* @__PURE__ */ c("label", { className: "path-field", children: [
|
|
2584
|
+
/* @__PURE__ */ a("span", { children: d.label }),
|
|
2585
|
+
/* @__PURE__ */ a(
|
|
2084
2586
|
"input",
|
|
2085
2587
|
{
|
|
2086
2588
|
className: "path-modal-input",
|
|
2087
|
-
value: n[
|
|
2088
|
-
placeholder:
|
|
2589
|
+
value: n[d.key],
|
|
2590
|
+
placeholder: d.placeholder,
|
|
2089
2591
|
autoFocus: h === 0,
|
|
2090
|
-
onChange: (
|
|
2592
|
+
onChange: (w) => r((S) => ({ ...S, [d.key]: w.target.value }))
|
|
2091
2593
|
}
|
|
2092
2594
|
)
|
|
2093
|
-
] },
|
|
2094
|
-
|
|
2595
|
+
] }, d.key)),
|
|
2596
|
+
i && /* @__PURE__ */ a("div", { className: "modal-err", children: i })
|
|
2095
2597
|
] }) });
|
|
2096
2598
|
}
|
|
2097
|
-
function
|
|
2098
|
-
const { documentId:
|
|
2099
|
-
return /* @__PURE__ */
|
|
2100
|
-
|
|
2599
|
+
function On(e) {
|
|
2600
|
+
const { documentId: t, scope: n, browse: r, theme: o } = e, s = st(e);
|
|
2601
|
+
return /* @__PURE__ */ a(it, { theme: o, dataLayer: s, children: /* @__PURE__ */ a(
|
|
2602
|
+
Tn,
|
|
2101
2603
|
{
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
browse: o,
|
|
2106
|
-
principal: c,
|
|
2107
|
-
renderAssistant: s
|
|
2108
|
-
}
|
|
2604
|
+
...e
|
|
2605
|
+
},
|
|
2606
|
+
`${n}:${t}:${r?.scopeId ?? ""}:${r?.tenant ?? ""}`
|
|
2109
2607
|
) });
|
|
2110
2608
|
}
|
|
2609
|
+
function Tn({
|
|
2610
|
+
documentId: e,
|
|
2611
|
+
scope: t,
|
|
2612
|
+
titleHint: n,
|
|
2613
|
+
browse: r,
|
|
2614
|
+
principal: o,
|
|
2615
|
+
renderAssistant: s,
|
|
2616
|
+
onOpenDocument: i
|
|
2617
|
+
}) {
|
|
2618
|
+
const [l, f] = p([]), d = l[l.length - 1], h = P(
|
|
2619
|
+
(g, N) => {
|
|
2620
|
+
i ? i(g, N) : f((y) => ct(y, N, g));
|
|
2621
|
+
},
|
|
2622
|
+
[i]
|
|
2623
|
+
), w = P((g) => f((N) => lt(N, g)), []), S = P(
|
|
2624
|
+
(g, N) => f((y) => je(y, g, { title: N })),
|
|
2625
|
+
[]
|
|
2626
|
+
);
|
|
2627
|
+
return /* @__PURE__ */ c(Q, { children: [
|
|
2628
|
+
/* @__PURE__ */ a(ut, { trail: l, onJump: w }),
|
|
2629
|
+
/* @__PURE__ */ a(
|
|
2630
|
+
bt,
|
|
2631
|
+
{
|
|
2632
|
+
documentId: d?.documentId ?? e,
|
|
2633
|
+
scope: t,
|
|
2634
|
+
titleHint: d ? d.title : n,
|
|
2635
|
+
browse: r,
|
|
2636
|
+
principal: o,
|
|
2637
|
+
renderAssistant: s,
|
|
2638
|
+
initialChunkId: d?.chunkId,
|
|
2639
|
+
onOpenDocument: h,
|
|
2640
|
+
onTitle: S
|
|
2641
|
+
},
|
|
2642
|
+
l.length
|
|
2643
|
+
)
|
|
2644
|
+
] });
|
|
2645
|
+
}
|
|
2111
2646
|
export {
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2647
|
+
Be as DEFAULT_SCHEME,
|
|
2648
|
+
On as DocumentViewer,
|
|
2649
|
+
An as PathExplorer,
|
|
2650
|
+
Ht as assetFetchFromConnection,
|
|
2651
|
+
Kt as chunkColor,
|
|
2652
|
+
Gt as createLoomcycleClient,
|
|
2653
|
+
ze as dataLayerFromClient,
|
|
2654
|
+
ft as docColor,
|
|
2655
|
+
Ge as effectiveScheme,
|
|
2656
|
+
en as hexToTint,
|
|
2657
|
+
He as tintStyle
|
|
2123
2658
|
};
|
|
2124
2659
|
//# sourceMappingURL=index.js.map
|