@hachej/boring-workspace 0.1.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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +94 -0
  3. package/dist/CodeEditor-DQqOn4xz.js +266 -0
  4. package/dist/CommandPalette-aM61U-b0.js +5229 -0
  5. package/dist/FileTree-DRq_bfue.js +245 -0
  6. package/dist/MarkdownEditor-DjiHxnRv.js +349 -0
  7. package/dist/WorkspaceLoadingState-By0dZoPD.js +568 -0
  8. package/dist/agent-tool-NvxKfist.d.ts +28 -0
  9. package/dist/app-front.d.ts +485 -0
  10. package/dist/app-front.js +452 -0
  11. package/dist/app-server.d.ts +53 -0
  12. package/dist/app-server.js +769 -0
  13. package/dist/bootstrapServer-BRUqUpVW.d.ts +66 -0
  14. package/dist/boring-workspace.css +1 -0
  15. package/dist/charts.d.ts +114 -0
  16. package/dist/charts.js +143 -0
  17. package/dist/events.d.ts +178 -0
  18. package/dist/events.js +88 -0
  19. package/dist/explorer-DtLUnuah.d.ts +129 -0
  20. package/dist/panel-DnvDNQac.js +6 -0
  21. package/dist/server.d.ts +84 -0
  22. package/dist/server.js +811 -0
  23. package/dist/shared.d.ts +113 -0
  24. package/dist/shared.js +11 -0
  25. package/dist/testing-e2e.d.ts +68 -0
  26. package/dist/testing-e2e.js +45 -0
  27. package/dist/testing.d.ts +464 -0
  28. package/dist/testing.js +10984 -0
  29. package/dist/utils-B6yFEsav.js +8 -0
  30. package/dist/workspace.css +5780 -0
  31. package/dist/workspace.d.ts +2119 -0
  32. package/dist/workspace.js +1884 -0
  33. package/docs/INTERFACES.md +58 -0
  34. package/docs/PLUGIN_STRUCTURE.md +162 -0
  35. package/docs/README.md +19 -0
  36. package/docs/bridge.md +135 -0
  37. package/docs/panels.md +102 -0
  38. package/docs/plans/GENERIC_EXPLORER_PLUGIN_PLAN.md +455 -0
  39. package/docs/plans/MACRO_PLUGIN_GENERIC_HELPERS_AUDIT.md +962 -0
  40. package/docs/plans/PLUGIN_OUTPUTS_ISOLATION_PLAN.md +301 -0
  41. package/docs/plans/README.md +9 -0
  42. package/docs/plans/UI_BRIDGE_OWNERSHIP_REFACTOR.md +303 -0
  43. package/docs/plans/archive/CODE_OWNERSHIP_CLEANUP_PLAN.md +387 -0
  44. package/docs/plans/archive/COMMAND_PALETTE_REGISTRY.md +814 -0
  45. package/docs/plans/archive/DECLARATIVE_LAYOUT_MIGRATION.md +277 -0
  46. package/docs/plans/archive/PLUGIN_MODEL.md +3674 -0
  47. package/docs/plans/archive/SRC_FOLDER_REORG_PLAN.md +307 -0
  48. package/docs/plans/archive/UNIFIED_EVENT_BUS.md +647 -0
  49. package/docs/plans/archive/WORKSPACE_V2_PLAN.md +2489 -0
  50. package/docs/plugins.md +158 -0
  51. package/package.json +164 -0
@@ -0,0 +1,1884 @@
1
+ var qe = Object.defineProperty;
2
+ var _e = (e, t, r) => t in e ? qe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var ne = (e, t, r) => _e(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { d as ae, u as Ne, p as Be, P as Ae, a as $e, b as Ke, D as Ve } from "./CommandPalette-aM61U-b0.js";
5
+ import { A as xr, C as yr, c as br, e as vr, f as Sr, F as Nr, g as Cr, M as Tr, h as Pr, i as kr, j as Er, k as wr, l as Mr, R as Dr, S as Ir, m as Rr, n as Or, T as Fr, W as Lr, o as zr, q as qr, r as _r, s as Br, t as Ar, v as $r, w as Kr, x as Vr, y as Qr, z as jr, B as Gr, E as Hr, G as Wr, H as Ur, I as Xr, J as Jr, K as Yr, L as Zr, N as ea, O as ta, Q as ra, U as aa, V as na, X as la, Y as oa, Z as sa, _ as ca, $ as ia, a0 as ua, a1 as da, a2 as pa, a3 as fa, a4 as ma, a5 as ga, a6 as ha, a7 as xa, a8 as ya, a9 as ba, aa as va, ab as Sa, ac as Na, ad as Ca, ae as Ta, af as Pa, ag as ka, ah as Ea } from "./CommandPalette-aM61U-b0.js";
6
+ import { jsxs as h, jsx as a, Fragment as Qe } from "react/jsx-runtime";
7
+ import { useSyncExternalStore as je, useState as V, useEffect as U, useRef as w, useCallback as S, useReducer as Ge, useMemo as Z, Suspense as He, Component as We } from "react";
8
+ import { FilterIcon as Ue, XIcon as Xe, ChevronDownIcon as Ce, ChevronRightIcon as Te, Database as Je, BarChart3 as pe, MenuIcon as Ye, PanelLeftOpenIcon as Ze, PanelLeftCloseIcon as et, PinIcon as tt } from "lucide-react";
9
+ import { EmptyState as Pe, Toolbar as rt, Input as ke, Popover as at, PopoverTrigger as nt, PopoverContent as lt, Button as J, Spinner as ot, ChipButton as st, Chip as ct, Sheet as it, SheetContent as ut, SheetHeader as dt, SheetTitle as pt, SheetDescription as ft, Kbd as le, ErrorState as mt, IconButton as Ee } from "@hachej/boring-ui-kit";
10
+ import { Toaster as Ma, dismissToast as Da, toast as Ia } from "@hachej/boring-ui-kit";
11
+ import { c as H } from "./utils-B6yFEsav.js";
12
+ import { d as we } from "./panel-DnvDNQac.js";
13
+ import { C as Oa, T as Fa, W as La, b as za } from "./WorkspaceLoadingState-By0dZoPD.js";
14
+ import { C as _a, c as Ba } from "./CodeEditor-DQqOn4xz.js";
15
+ import { FileTree as $a } from "./FileTree-DRq_bfue.js";
16
+ import { MarkdownEditor as Va } from "./MarkdownEditor-DjiHxnRv.js";
17
+ function re(e, t) {
18
+ const { pluginId: r, ...n } = e;
19
+ return t ? { ...n, pluginId: t } : n;
20
+ }
21
+ function fe(e, t) {
22
+ const r = [];
23
+ for (const n of e.panels ?? [])
24
+ r.push(re({ type: "panel", panel: n }, t));
25
+ for (const n of e.commands ?? [])
26
+ r.push(re({ type: "command", command: n }, t));
27
+ for (const n of e.catalogs ?? [])
28
+ r.push(re({ type: "catalog", catalog: n }, t));
29
+ for (const n of e.agentTools ?? [])
30
+ r.push(
31
+ re({ type: "agent-tool", id: n.name, tool: n }, t)
32
+ );
33
+ for (const n of e.outputs ?? [])
34
+ r.push(re(n, t));
35
+ return r;
36
+ }
37
+ function gt(e) {
38
+ return e.map((r) => r == null ? void 0 : r.trim()).filter((r) => !!r).join(`
39
+
40
+ `) || void 0;
41
+ }
42
+ function er(e) {
43
+ const t = e.adoptOutputs !== !1, r = e.plugins.flatMap(
44
+ (l) => fe(l, t ? void 0 : l.id)
45
+ ), n = fe(
46
+ {
47
+ id: e.id,
48
+ panels: e.panels,
49
+ commands: e.commands,
50
+ catalogs: e.catalogs,
51
+ agentTools: e.agentTools,
52
+ outputs: e.outputs
53
+ },
54
+ void 0
55
+ );
56
+ return ae({
57
+ id: e.id,
58
+ label: e.label,
59
+ systemPrompt: gt([
60
+ ...e.plugins.map((l) => l.systemPrompt),
61
+ e.systemPrompt
62
+ ]),
63
+ outputs: [...r, ...n]
64
+ });
65
+ }
66
+ function tr() {
67
+ const e = Ne();
68
+ return je(e.subscribe, e.getSnapshot);
69
+ }
70
+ function me(e) {
71
+ return typeof window > "u" ? !1 : window.innerWidth < e;
72
+ }
73
+ function ge(e = 1024) {
74
+ const [t, r] = V(() => me(e));
75
+ return U(() => {
76
+ const n = () => {
77
+ r(me(e));
78
+ };
79
+ return n(), window.addEventListener("resize", n), () => {
80
+ window.removeEventListener("resize", n);
81
+ };
82
+ }, [e]), t;
83
+ }
84
+ function ht({
85
+ isNarrowViewport: e,
86
+ isCollapsed: t,
87
+ setCollapsed: r
88
+ }) {
89
+ const n = w(t), l = w(!1), o = w(null);
90
+ return U(() => {
91
+ n.current = t;
92
+ }, [t]), U(() => {
93
+ const p = o.current, c = p !== !0 && e, s = p === !0 && !e;
94
+ if (o.current = e, e && c && !n.current) {
95
+ l.current = !0, r(!0);
96
+ return;
97
+ }
98
+ s && l.current && (l.current = !1, r(!1));
99
+ }, [e, r]), S(() => {
100
+ l.current = !1;
101
+ }, []);
102
+ }
103
+ function rr(e) {
104
+ const [t, r] = V([]), n = w(t);
105
+ n.current = t, U(() => {
106
+ if (!e) {
107
+ r([]);
108
+ return;
109
+ }
110
+ function s() {
111
+ try {
112
+ const d = e.toJSON(), x = [];
113
+ if (d && typeof d == "object" && "panels" in d) {
114
+ const T = d;
115
+ if (T.panels)
116
+ for (const [, v] of Object.entries(T.panels))
117
+ v.id && x.push({
118
+ id: v.id,
119
+ component: v.contentComponent ?? v.id,
120
+ params: v.params
121
+ });
122
+ }
123
+ const u = n.current;
124
+ (u.length !== x.length || u.some((T, v) => {
125
+ var C;
126
+ return T.id !== ((C = x[v]) == null ? void 0 : C.id);
127
+ })) && r(x);
128
+ } catch {
129
+ }
130
+ }
131
+ s();
132
+ const i = setInterval(s, 500);
133
+ return () => clearInterval(i);
134
+ }, [e]);
135
+ const l = S(
136
+ (s) => {
137
+ e == null || e.addPanel("artifacts", {
138
+ id: s.id,
139
+ component: s.component,
140
+ params: s.params
141
+ });
142
+ },
143
+ [e]
144
+ ), o = S(
145
+ (s) => {
146
+ e == null || e.removePanel(s);
147
+ },
148
+ [e]
149
+ ), p = S(
150
+ (s) => {
151
+ e == null || e.activatePanel(s);
152
+ },
153
+ [e]
154
+ ), c = S(
155
+ (s) => n.current.some((i) => i.id === s),
156
+ []
157
+ );
158
+ return { panels: t, open: l, close: o, activate: p, isOpen: c };
159
+ }
160
+ function ar(e, t = {}) {
161
+ const r = t.toolPanelMap ?? {}, n = S(
162
+ (o) => r[o],
163
+ [r]
164
+ );
165
+ return { openForTool: S(
166
+ (o, p) => {
167
+ const c = r[o];
168
+ if (!c) return;
169
+ const s = `artifact-${p.path}`;
170
+ e.isOpen(s) ? e.activate(s) : e.open({ id: s, component: c, params: p });
171
+ },
172
+ [r, e]
173
+ ), resolvePanel: n };
174
+ }
175
+ const ce = { items: [], total: 0, hasMore: !1, loading: !1 };
176
+ function xt(e, t) {
177
+ switch (t.type) {
178
+ case "setPendingQuery":
179
+ return { ...e, pendingQuery: t.query };
180
+ case "applyQuery":
181
+ return {
182
+ ...e,
183
+ query: t.query,
184
+ pendingQuery: t.query,
185
+ topItems: [],
186
+ topTotal: 0,
187
+ topHasMore: !1,
188
+ topOffset: 0,
189
+ expanded: {},
190
+ groups: {}
191
+ };
192
+ case "setFilters":
193
+ return {
194
+ ...e,
195
+ filters: t.filters,
196
+ topItems: [],
197
+ topTotal: 0,
198
+ topHasMore: !1,
199
+ topOffset: 0,
200
+ expanded: {},
201
+ groups: {}
202
+ };
203
+ case "expandGroup":
204
+ return { ...e, expanded: { ...e.expanded, [t.value]: !0 } };
205
+ case "collapseGroup":
206
+ return { ...e, expanded: { ...e.expanded, [t.value]: !1 } };
207
+ case "topResolved":
208
+ return {
209
+ ...e,
210
+ topItems: t.append ? [...e.topItems, ...t.items] : t.items,
211
+ topTotal: t.total,
212
+ topHasMore: t.hasMore,
213
+ topOffset: t.offset + t.items.length
214
+ };
215
+ case "groupResolved": {
216
+ const r = e.groups[t.value] ?? ce;
217
+ return {
218
+ ...e,
219
+ groups: {
220
+ ...e.groups,
221
+ [t.value]: {
222
+ items: t.append ? [...r.items, ...t.items] : t.items,
223
+ total: t.total,
224
+ hasMore: t.hasMore,
225
+ loading: !1
226
+ }
227
+ }
228
+ };
229
+ }
230
+ case "groupLoading": {
231
+ const r = e.groups[t.value] ?? ce;
232
+ return {
233
+ ...e,
234
+ groups: { ...e.groups, [t.value]: { ...r, loading: t.loading } }
235
+ };
236
+ }
237
+ case "facetsResolved":
238
+ return { ...e, facets: t.facets };
239
+ case "loading":
240
+ return { ...e, loading: t.loading };
241
+ }
242
+ }
243
+ const yt = {
244
+ query: "",
245
+ pendingQuery: "",
246
+ filters: {},
247
+ topItems: [],
248
+ topTotal: 0,
249
+ topHasMore: !1,
250
+ topOffset: 0,
251
+ expanded: {},
252
+ groups: {},
253
+ facets: null,
254
+ loading: !1
255
+ };
256
+ function oe(e) {
257
+ return e instanceof DOMException && e.name === "AbortError";
258
+ }
259
+ function bt(e) {
260
+ const {
261
+ adapter: t,
262
+ facets: r,
263
+ groupBy: n,
264
+ pageSize: l = 50,
265
+ debounceMs: o = 200,
266
+ query: p
267
+ } = e, c = p !== void 0, [s, i] = Ge(xt, yt), d = w(s);
268
+ d.current = s;
269
+ const x = w(t);
270
+ x.current = t;
271
+ const u = w({ pageSize: l, groupBy: n, hasFacets: !!(r != null && r.length) });
272
+ u.current = { pageSize: l, groupBy: n, hasFacets: !!(r != null && r.length) };
273
+ const P = w(null), T = w(/* @__PURE__ */ new Map()), v = w(null), C = w(null), I = w(!0), j = S(
274
+ async (f) => {
275
+ var D;
276
+ (D = P.current) == null || D.abort();
277
+ const N = new AbortController();
278
+ P.current = N, i({ type: "loading", loading: !0 });
279
+ const b = {
280
+ query: f.query,
281
+ filters: f.filters,
282
+ offset: f.offset,
283
+ limit: u.current.pageSize,
284
+ signal: N.signal
285
+ };
286
+ try {
287
+ const k = await x.current.search(b);
288
+ if (!I.current || N.signal.aborted) return;
289
+ i({
290
+ type: "topResolved",
291
+ items: k.items,
292
+ total: k.total,
293
+ hasMore: k.hasMore,
294
+ offset: f.offset,
295
+ append: f.append
296
+ });
297
+ } catch (k) {
298
+ if (oe(k)) return;
299
+ console.error("DataExplorer: search failed", k);
300
+ } finally {
301
+ I.current && P.current === N && i({ type: "loading", loading: !1 });
302
+ }
303
+ },
304
+ []
305
+ ), L = S(
306
+ async (f) => {
307
+ var k;
308
+ const N = u.current.groupBy;
309
+ if (!N) return;
310
+ (k = T.current.get(f.groupValue)) == null || k.abort();
311
+ const b = new AbortController();
312
+ T.current.set(f.groupValue, b), i({ type: "groupLoading", value: f.groupValue, loading: !0 });
313
+ const D = {
314
+ query: f.query,
315
+ filters: f.filters,
316
+ group: { key: N, value: f.groupValue },
317
+ offset: f.offset,
318
+ limit: u.current.pageSize,
319
+ signal: b.signal
320
+ };
321
+ try {
322
+ const W = await x.current.search(D);
323
+ if (!I.current || b.signal.aborted) return;
324
+ i({
325
+ type: "groupResolved",
326
+ value: f.groupValue,
327
+ items: W.items,
328
+ total: W.total,
329
+ hasMore: W.hasMore,
330
+ append: f.append
331
+ });
332
+ } catch (W) {
333
+ if (oe(W)) return;
334
+ console.error("DataExplorer: group search failed", W), I.current && i({ type: "groupLoading", value: f.groupValue, loading: !1 });
335
+ }
336
+ },
337
+ []
338
+ ), z = S(async (f) => {
339
+ var D;
340
+ if (!u.current.hasFacets) return;
341
+ const N = x.current.fetchFacets;
342
+ if (!N) return;
343
+ (D = v.current) == null || D.abort();
344
+ const b = new AbortController();
345
+ v.current = b;
346
+ try {
347
+ const k = await N({ filters: f, signal: b.signal });
348
+ if (!I.current || b.signal.aborted) return;
349
+ i({ type: "facetsResolved", facets: k });
350
+ } catch (k) {
351
+ if (oe(k)) return;
352
+ console.error("DataExplorer: fetchFacets failed", k);
353
+ }
354
+ }, []), g = S(
355
+ (f, N) => {
356
+ j({ query: f, filters: N, offset: 0, append: !1 }), z(N);
357
+ },
358
+ [j, z]
359
+ ), R = w(c);
360
+ R.current = c;
361
+ const Q = S(
362
+ (f) => {
363
+ R.current || (i({ type: "setPendingQuery", query: f }), C.current && clearTimeout(C.current), C.current = setTimeout(() => {
364
+ i({ type: "applyQuery", query: f }), g(f, d.current.filters);
365
+ }, o));
366
+ },
367
+ [o, g]
368
+ ), O = S(
369
+ (f, N) => {
370
+ const b = d.current.filters[f] ?? [], D = b.includes(N) ? b.filter((W) => W !== N) : [...b, N], k = { ...d.current.filters };
371
+ D.length ? k[f] = D : delete k[f], i({ type: "setFilters", filters: k }), g(d.current.query, k);
372
+ },
373
+ [g]
374
+ ), q = S(() => {
375
+ i({ type: "setFilters", filters: {} }), g(d.current.query, {});
376
+ }, [g]), y = S(
377
+ (f) => {
378
+ var b;
379
+ const N = (((b = d.current.groups[f]) == null ? void 0 : b.items.length) ?? 0) > 0;
380
+ i({ type: "expandGroup", value: f }), N || L({
381
+ groupValue: f,
382
+ query: d.current.query,
383
+ filters: d.current.filters,
384
+ offset: 0,
385
+ append: !1
386
+ });
387
+ },
388
+ [L]
389
+ ), _ = S((f) => {
390
+ i({ type: "collapseGroup", value: f });
391
+ }, []), B = S(() => {
392
+ const f = d.current;
393
+ f.topHasMore && j({
394
+ query: f.query,
395
+ filters: f.filters,
396
+ offset: f.topOffset,
397
+ append: !0
398
+ });
399
+ }, [j]), X = S(
400
+ (f) => {
401
+ const N = d.current, b = N.groups[f];
402
+ b != null && b.hasMore && L({
403
+ groupValue: f,
404
+ query: N.query,
405
+ filters: N.filters,
406
+ offset: b.items.length,
407
+ append: !0
408
+ });
409
+ },
410
+ [L]
411
+ );
412
+ U(() => {
413
+ I.current = !0;
414
+ const f = R.current ? p ?? "" : "";
415
+ return f && i({ type: "applyQuery", query: f }), g(f, {}), () => {
416
+ var N, b;
417
+ I.current = !1, C.current && clearTimeout(C.current), (N = P.current) == null || N.abort(), (b = v.current) == null || b.abort();
418
+ for (const D of T.current.values()) D.abort();
419
+ T.current.clear();
420
+ };
421
+ }, []);
422
+ const ee = w(p);
423
+ U(() => {
424
+ if (!c || ee.current === p) return;
425
+ ee.current = p;
426
+ const f = p ?? "";
427
+ i({ type: "applyQuery", query: f }), g(f, d.current.filters);
428
+ }, [c, p, g]);
429
+ const te = S(
430
+ (f) => s.groups[f] ?? ce,
431
+ [s.groups]
432
+ ), Y = S(
433
+ (f) => !!s.expanded[f],
434
+ [s.expanded]
435
+ );
436
+ return {
437
+ query: s.pendingQuery,
438
+ filters: s.filters,
439
+ facets: s.facets,
440
+ topItems: s.topItems,
441
+ topTotal: s.topTotal,
442
+ topHasMore: s.topHasMore,
443
+ loading: s.loading,
444
+ getGroup: te,
445
+ isExpanded: Y,
446
+ setQuery: Q,
447
+ toggleFilter: O,
448
+ clearFilters: q,
449
+ expandGroup: y,
450
+ collapseGroup: _,
451
+ loadMoreTop: B,
452
+ loadMoreGroup: X
453
+ };
454
+ }
455
+ function ie({
456
+ adapter: e,
457
+ facets: t,
458
+ groupBy: r,
459
+ onActivate: n,
460
+ getDragPayload: l,
461
+ emptyState: o = "No results",
462
+ searchPlaceholder: p = "Search…",
463
+ searchable: c = !0,
464
+ query: s,
465
+ pageSize: i,
466
+ debounceMs: d,
467
+ className: x
468
+ }) {
469
+ const u = bt({
470
+ adapter: e,
471
+ facets: t,
472
+ groupBy: r,
473
+ pageSize: i,
474
+ debounceMs: d,
475
+ query: s
476
+ }), T = c && !(s !== void 0), v = (s ?? u.query ?? "").length > 0, C = !!r && !v, I = Object.values(u.filters).some((g) => g.length > 0), j = Object.values(u.filters).reduce((g, R) => g + R.length, 0), L = Z(() => {
477
+ var O, q;
478
+ if (!C || !r) return [];
479
+ const g = t == null ? void 0 : t.find((y) => y.key === r), Q = [...((O = u.facets) == null ? void 0 : O[r]) ?? []];
480
+ if ((q = g == null ? void 0 : g.order) != null && q.length) {
481
+ const y = (_) => {
482
+ const B = g.order.indexOf(_);
483
+ return B === -1 ? Number.MAX_SAFE_INTEGER : B;
484
+ };
485
+ Q.sort((_, B) => y(_.value) - y(B.value));
486
+ }
487
+ return Q.map((y) => ({
488
+ value: y.value,
489
+ count: y.count,
490
+ label: g != null && g.formatValue ? g.formatValue(y.value) : y.value
491
+ }));
492
+ }, [C, r, t, u.facets]), z = !u.loading && !C && u.topItems.length === 0 && u.query.length === 0 && !I;
493
+ return /* @__PURE__ */ h("div", { className: H("flex h-full flex-col", x), "data-slot": "data-explorer", children: [
494
+ T || t != null && t.length ? /* @__PURE__ */ a(
495
+ vt,
496
+ {
497
+ searchable: T,
498
+ searchPlaceholder: p,
499
+ query: u.query,
500
+ onQueryChange: u.setQuery,
501
+ facetConfigs: t,
502
+ facets: u.facets,
503
+ filters: u.filters,
504
+ filterCount: j,
505
+ onToggleFilter: u.toggleFilter,
506
+ onClearFilters: u.clearFilters,
507
+ total: C ? null : u.topTotal
508
+ }
509
+ ) : null,
510
+ /* @__PURE__ */ a("div", { className: "flex-1 overflow-y-auto", "data-slot": "data-explorer-list", children: z ? /* @__PURE__ */ a("div", { className: "flex h-full items-center justify-center px-4 py-8", children: /* @__PURE__ */ a(Pe, { className: "min-h-0 border-0", description: o }) }) : C ? /* @__PURE__ */ a(
511
+ Ct,
512
+ {
513
+ entries: L,
514
+ isExpanded: u.isExpanded,
515
+ getGroup: u.getGroup,
516
+ onExpand: u.expandGroup,
517
+ onCollapse: u.collapseGroup,
518
+ onLoadMoreGroup: u.loadMoreGroup,
519
+ onActivate: n,
520
+ getDragPayload: l
521
+ }
522
+ ) : /* @__PURE__ */ a(
523
+ Nt,
524
+ {
525
+ items: u.topItems,
526
+ hasMore: u.topHasMore,
527
+ loading: u.loading,
528
+ onLoadMore: u.loadMoreTop,
529
+ onActivate: n,
530
+ getDragPayload: l
531
+ }
532
+ ) })
533
+ ] });
534
+ }
535
+ function vt({
536
+ searchable: e,
537
+ searchPlaceholder: t,
538
+ query: r,
539
+ onQueryChange: n,
540
+ facetConfigs: l,
541
+ facets: o,
542
+ filters: p,
543
+ filterCount: c,
544
+ onToggleFilter: s,
545
+ onClearFilters: i,
546
+ total: d
547
+ }) {
548
+ return /* @__PURE__ */ h(rt, { className: "border-b border-border/60 px-2 py-1.5", children: [
549
+ e ? /* @__PURE__ */ a(
550
+ ke,
551
+ {
552
+ "aria-label": "Search",
553
+ placeholder: t,
554
+ value: r,
555
+ onChange: (x) => n(x.target.value),
556
+ className: "h-7 flex-1 rounded-sm border-transparent bg-muted/40 px-2 text-[12.5px] shadow-none focus-visible:bg-background focus-visible:ring-1"
557
+ }
558
+ ) : null,
559
+ d != null ? /* @__PURE__ */ a("span", { className: "px-1 font-mono text-[10.5px] uppercase tracking-[0.05em] text-muted-foreground/80", children: d.toLocaleString() }) : null,
560
+ l != null && l.length ? /* @__PURE__ */ h(at, { children: [
561
+ /* @__PURE__ */ h(
562
+ nt,
563
+ {
564
+ "aria-label": "Filters",
565
+ className: H(
566
+ "inline-flex h-7 items-center gap-1 rounded-sm px-1.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",
567
+ c > 0 && "bg-muted text-foreground"
568
+ ),
569
+ children: [
570
+ /* @__PURE__ */ a(Ue, { size: 12 }),
571
+ c > 0 ? /* @__PURE__ */ a("span", { className: "font-mono text-[10px]", children: c }) : null
572
+ ]
573
+ }
574
+ ),
575
+ /* @__PURE__ */ h(
576
+ lt,
577
+ {
578
+ align: "end",
579
+ sideOffset: 6,
580
+ className: "w-64 space-y-3 p-3 text-[12px]",
581
+ children: [
582
+ l.map((x) => /* @__PURE__ */ a(
583
+ St,
584
+ {
585
+ config: x,
586
+ values: (o == null ? void 0 : o[x.key]) ?? [],
587
+ selected: p[x.key] ?? [],
588
+ onToggle: s
589
+ },
590
+ x.key
591
+ )),
592
+ c > 0 ? /* @__PURE__ */ h(J, { type: "button", variant: "ghost", size: "xs", onClick: i, className: "gap-1 text-[11px] text-muted-foreground hover:text-foreground", children: [
593
+ /* @__PURE__ */ a(Xe, { size: 11 }),
594
+ " Clear all"
595
+ ] }) : null
596
+ ]
597
+ }
598
+ )
599
+ ] }) : null
600
+ ] });
601
+ }
602
+ function St({
603
+ config: e,
604
+ values: t,
605
+ selected: r,
606
+ onToggle: n
607
+ }) {
608
+ if (!t.length) return null;
609
+ const l = e.order ? [...t].sort((o, p) => {
610
+ const c = e.order.indexOf(o.value), s = e.order.indexOf(p.value);
611
+ return (c === -1 ? 999 : c) - (s === -1 ? 999 : s);
612
+ }) : t;
613
+ return /* @__PURE__ */ h("div", { className: "space-y-1.5", children: [
614
+ /* @__PURE__ */ a("div", { className: "font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground", children: e.label }),
615
+ /* @__PURE__ */ a("div", { className: "flex flex-wrap gap-1", children: l.map((o) => {
616
+ const p = r.includes(o.value), c = e.formatValue ? e.formatValue(o.value) : o.value;
617
+ return /* @__PURE__ */ h(
618
+ st,
619
+ {
620
+ type: "button",
621
+ selected: p,
622
+ onClick: () => n(e.key, o.value),
623
+ className: "gap-1 rounded-sm text-[11px]",
624
+ children: [
625
+ c,
626
+ /* @__PURE__ */ a("span", { className: "font-mono text-[10px] text-muted-foreground/80", children: o.count.toLocaleString() })
627
+ ]
628
+ },
629
+ o.value
630
+ );
631
+ }) })
632
+ ] });
633
+ }
634
+ function Nt({
635
+ items: e,
636
+ hasMore: t,
637
+ loading: r,
638
+ onLoadMore: n,
639
+ onActivate: l,
640
+ getDragPayload: o
641
+ }) {
642
+ return /* @__PURE__ */ h("ul", { className: "flex flex-col px-1 py-1", children: [
643
+ e.map((p) => /* @__PURE__ */ a(
644
+ Me,
645
+ {
646
+ row: p,
647
+ onActivate: l,
648
+ getDragPayload: o
649
+ },
650
+ p.id
651
+ )),
652
+ t ? /* @__PURE__ */ a("li", { className: "px-3 py-2", children: /* @__PURE__ */ a(J, { type: "button", variant: "ghost", size: "xs", onClick: n, disabled: r, className: "w-full justify-start text-[11px] text-muted-foreground hover:text-foreground", children: r ? "Loading…" : "Load more" }) }) : null
653
+ ] });
654
+ }
655
+ function Ct({
656
+ entries: e,
657
+ isExpanded: t,
658
+ getGroup: r,
659
+ onExpand: n,
660
+ onCollapse: l,
661
+ onLoadMoreGroup: o,
662
+ onActivate: p,
663
+ getDragPayload: c
664
+ }) {
665
+ return /* @__PURE__ */ a("ul", { className: "flex flex-col py-1", children: e.map((s) => {
666
+ const i = t(s.value), d = r(s.value);
667
+ return /* @__PURE__ */ h("li", { children: [
668
+ /* @__PURE__ */ h(
669
+ J,
670
+ {
671
+ type: "button",
672
+ variant: "ghost",
673
+ size: "sm",
674
+ "aria-expanded": i,
675
+ onClick: () => i ? l(s.value) : n(s.value),
676
+ className: "group mx-1 h-auto w-[calc(100%-0.5rem)] justify-start gap-1.5 px-1.5 py-1 text-left hover:bg-muted/40",
677
+ children: [
678
+ i ? /* @__PURE__ */ a(Ce, { size: 11, className: "text-muted-foreground/80" }) : /* @__PURE__ */ a(Te, { size: 11, className: "text-muted-foreground/80" }),
679
+ /* @__PURE__ */ a("span", { className: "text-[12.5px] font-medium text-foreground", children: s.label }),
680
+ /* @__PURE__ */ a("span", { className: "ml-auto font-mono text-[10.5px] text-muted-foreground/80", children: s.count.toLocaleString() })
681
+ ]
682
+ }
683
+ ),
684
+ i ? /* @__PURE__ */ h("ul", { className: "flex flex-col", children: [
685
+ d.items.map((x) => /* @__PURE__ */ a(
686
+ Me,
687
+ {
688
+ row: x,
689
+ indent: !0,
690
+ onActivate: p,
691
+ getDragPayload: c
692
+ },
693
+ x.id
694
+ )),
695
+ d.loading && d.items.length === 0 ? /* @__PURE__ */ h("li", { className: "flex items-center gap-1.5 pl-7 pr-3 py-1.5 text-[11px] text-muted-foreground/80", children: [
696
+ /* @__PURE__ */ a(ot, { className: "size-3" }),
697
+ "Loading…"
698
+ ] }) : null,
699
+ d.hasMore ? /* @__PURE__ */ a("li", { className: "pl-7 pr-3 py-1", children: /* @__PURE__ */ a(J, { type: "button", variant: "ghost", size: "xs", onClick: () => o(s.value), disabled: d.loading, className: "text-[11px] text-muted-foreground hover:text-foreground", children: d.loading ? "Loading…" : "Load more" }) }) : null
700
+ ] }) : null
701
+ ] }, s.value);
702
+ }) });
703
+ }
704
+ function Me({
705
+ row: e,
706
+ indent: t,
707
+ onActivate: r,
708
+ getDragPayload: n
709
+ }) {
710
+ var i;
711
+ const l = !!r, o = n == null ? void 0 : n(e);
712
+ return /* @__PURE__ */ h(
713
+ "li",
714
+ {
715
+ ...l ? { role: "button", tabIndex: 0, onClick: () => r == null ? void 0 : r(e), onKeyDown: (d) => {
716
+ l && (d.key === "Enter" || d.key === " ") && (d.preventDefault(), r == null || r(e));
717
+ } } : {},
718
+ ...!!o ? { draggable: !0, onDragStart: (d) => {
719
+ o && (d.dataTransfer.setData(o.mimeType, o.value), d.dataTransfer.setData("text/plain", o.value), d.dataTransfer.effectAllowed = "copy");
720
+ } } : {},
721
+ className: H(
722
+ "group mx-1 flex items-start gap-2 rounded-md px-1.5 py-1",
723
+ "transition-colors duration-120 ease-[cubic-bezier(0.22,1,0.36,1)]",
724
+ l && "cursor-pointer hover:bg-foreground/5",
725
+ t && "pl-7"
726
+ ),
727
+ title: e.title,
728
+ children: [
729
+ e.leading ? /* @__PURE__ */ a(he, { badge: e.leading }) : null,
730
+ /* @__PURE__ */ h("span", { className: "flex min-w-0 flex-1 flex-col", children: [
731
+ /* @__PURE__ */ a("span", { className: "truncate text-[12.5px] font-medium leading-tight text-foreground", children: e.title }),
732
+ e.subtitle ? /* @__PURE__ */ a("span", { className: "truncate text-[11.5px] leading-snug text-muted-foreground/85", children: e.subtitle }) : null
733
+ ] }),
734
+ (i = e.trailing) != null && i.length ? /* @__PURE__ */ a("span", { className: "flex shrink-0 items-center gap-1", children: e.trailing.map((d, x) => /* @__PURE__ */ a(he, { badge: d }, x)) }) : null,
735
+ e.meta ? /* @__PURE__ */ a("span", { className: "shrink-0 self-center font-mono text-[10.5px] text-muted-foreground/80", children: e.meta }) : null
736
+ ]
737
+ }
738
+ );
739
+ }
740
+ function he({ badge: e }) {
741
+ return /* @__PURE__ */ a(
742
+ ct,
743
+ {
744
+ "aria-hidden": "true",
745
+ title: e.tooltip,
746
+ className: "mt-[1px] h-[16px] min-w-[24px] rounded-[3px] border-0 bg-muted/60 px-1 font-mono text-[9.5px] uppercase tracking-[0.06em] text-muted-foreground group-hover:text-foreground",
747
+ children: e.code
748
+ }
749
+ );
750
+ }
751
+ const nr = "explorer";
752
+ function Tt(e) {
753
+ return e.mode ? e.mode : e.sectionedAdapter ? "sectioned" : e.groupBy ? "grouped" : "flat";
754
+ }
755
+ function Pt(e) {
756
+ const t = Tt(e);
757
+ if (t === "sectioned") {
758
+ if (!e.sectionedAdapter)
759
+ throw new Error(`explorer "${e.id}" requires sectionedAdapter for sectioned mode`);
760
+ return {
761
+ mode: t,
762
+ sectionedAdapter: e.sectionedAdapter,
763
+ onActivate: e.onActivate,
764
+ getDragPayload: e.getDragPayload,
765
+ emptyState: e.emptyState,
766
+ searchPlaceholder: e.searchPlaceholder,
767
+ searchable: e.searchable,
768
+ query: e.query,
769
+ pageSize: e.pageSize,
770
+ className: e.className
771
+ };
772
+ }
773
+ if (!e.adapter)
774
+ throw new Error(`explorer "${e.id}" requires adapter for ${t} mode`);
775
+ if (t === "grouped" && !e.groupBy)
776
+ throw new Error(`explorer "${e.id}" requires groupBy for grouped mode`);
777
+ return {
778
+ mode: t,
779
+ adapter: e.adapter,
780
+ facets: e.facets,
781
+ groupBy: t === "grouped" ? e.groupBy : void 0,
782
+ onActivate: e.onActivate,
783
+ getDragPayload: e.getDragPayload,
784
+ emptyState: e.emptyState,
785
+ searchPlaceholder: e.searchPlaceholder,
786
+ searchable: e.searchable,
787
+ query: e.query,
788
+ pageSize: e.pageSize,
789
+ debounceMs: e.debounceMs,
790
+ className: e.className
791
+ };
792
+ }
793
+ function xe(e) {
794
+ if (e.mode === "sectioned") {
795
+ const {
796
+ sectionedAdapter: l,
797
+ mode: o,
798
+ adapter: p,
799
+ facets: c,
800
+ groupBy: s,
801
+ ...i
802
+ } = e;
803
+ return /* @__PURE__ */ a(Et, { adapter: l, ...i });
804
+ }
805
+ const { mode: t, sectionedAdapter: r, ...n } = e;
806
+ return /* @__PURE__ */ a(ie, { ...n });
807
+ }
808
+ function kt(e) {
809
+ const t = [], r = e.label ?? "Explorer", n = Pt(e), l = e.source ?? "app";
810
+ function o({ params: c, className: s }) {
811
+ return /* @__PURE__ */ a(
812
+ xe,
813
+ {
814
+ ...n,
815
+ query: (c == null ? void 0 : c.searchQuery) ?? (c == null ? void 0 : c.query) ?? n.query,
816
+ className: s ?? n.className ?? "h-full"
817
+ }
818
+ );
819
+ }
820
+ function p({ className: c }) {
821
+ return /* @__PURE__ */ a(xe, { ...n, className: c ?? n.className ?? "h-full" });
822
+ }
823
+ if (e.leftTab !== !1) {
824
+ const c = e.leftTab ?? {};
825
+ t.push({
826
+ type: "left-tab",
827
+ id: c.id ?? e.id,
828
+ title: c.title ?? c.label ?? r,
829
+ icon: c.icon,
830
+ component: o,
831
+ source: l,
832
+ chromeless: !0
833
+ });
834
+ }
835
+ if (e.panel) {
836
+ const c = we({
837
+ id: e.panel.id ?? `${e.id}-panel`,
838
+ title: e.panel.title ?? e.panel.label ?? r,
839
+ icon: e.panel.icon,
840
+ component: p,
841
+ placement: "center",
842
+ source: l
843
+ });
844
+ t.push({ type: "panel", panel: c });
845
+ }
846
+ if (e.catalog) {
847
+ if (!e.adapter)
848
+ throw new Error(`explorer "${e.id}" catalog requires a flat/grouped adapter`);
849
+ const c = {
850
+ id: e.catalog.id ?? e.id,
851
+ label: e.catalog.label ?? r,
852
+ adapter: e.adapter,
853
+ onSelect: e.catalog.onSelect ?? e.onActivate ?? (() => {
854
+ })
855
+ };
856
+ t.push({ type: "catalog", catalog: c });
857
+ }
858
+ return t;
859
+ }
860
+ function lr(e) {
861
+ return ae({
862
+ id: e.pluginId ?? e.id,
863
+ label: e.label ?? "Explorer",
864
+ outputs: kt(e)
865
+ });
866
+ }
867
+ function se(e) {
868
+ return e instanceof DOMException && e.name === "AbortError";
869
+ }
870
+ function Et({
871
+ adapter: e,
872
+ onActivate: t,
873
+ getDragPayload: r,
874
+ emptyState: n = "No results",
875
+ searchPlaceholder: l = "Search…",
876
+ searchable: o = !0,
877
+ query: p,
878
+ pageSize: c = 50,
879
+ className: s
880
+ }) {
881
+ const i = p !== void 0, [d, x] = V(p ?? ""), [u, P] = V([]), [T, v] = V({}), [C, I] = V({}), [j, L] = V({}), [z, g] = V(!1), [R, Q] = V({}), [O, q] = V({}), [y, _] = V({}), [B, X] = V({}), ee = w(null), te = w(/* @__PURE__ */ new Map()), Y = p ?? d, f = w(T);
882
+ f.current = T;
883
+ const N = w(O);
884
+ N.current = O;
885
+ const b = S(
886
+ async (m, M, E) => {
887
+ var $;
888
+ ($ = te.current.get(m)) == null || $.abort();
889
+ const A = new AbortController();
890
+ te.current.set(m, A), Q((K) => ({ ...K, [m]: !0 }));
891
+ try {
892
+ const K = y[m] ?? {}, F = await e.searchSection(m, {
893
+ query: Y,
894
+ globalFilters: {},
895
+ filters: K,
896
+ limit: c,
897
+ offset: M,
898
+ signal: A.signal
899
+ });
900
+ if (A.signal.aborted) return;
901
+ v((G) => ({
902
+ ...G,
903
+ [m]: E ? [...G[m] ?? [], ...F.items] : F.items
904
+ })), I((G) => ({ ...G, [m]: F.total })), L((G) => ({ ...G, [m]: F.hasMore }));
905
+ } catch (K) {
906
+ se(K) || console.error("Explorer: section search failed", K);
907
+ } finally {
908
+ te.current.get(m) === A && Q((K) => ({ ...K, [m]: !1 }));
909
+ }
910
+ },
911
+ [e, Y, c, y]
912
+ ), D = S(
913
+ async (m) => {
914
+ if (e.fetchSectionFacets)
915
+ try {
916
+ const M = await e.fetchSectionFacets(m, {
917
+ query: Y,
918
+ globalFilters: {},
919
+ filters: y[m] ?? {}
920
+ });
921
+ X((E) => ({ ...E, [m]: M }));
922
+ } catch (M) {
923
+ se(M) || console.error("Explorer: section facets failed", M);
924
+ }
925
+ },
926
+ [e, Y, y]
927
+ ), k = w(b), W = w(D);
928
+ k.current = b, W.current = D, U(() => {
929
+ var M;
930
+ (M = ee.current) == null || M.abort();
931
+ const m = new AbortController();
932
+ return ee.current = m, g(!0), e.sections({ query: Y, globalFilters: {}, signal: m.signal }).then((E) => {
933
+ if (m.signal.aborted) return;
934
+ P(E);
935
+ const A = {};
936
+ for (const $ of E) A[$.id] = !!$.defaultExpanded;
937
+ q(A), v({}), L({}), I({});
938
+ for (const $ of E)
939
+ $.defaultExpanded && (W.current($.id), k.current($.id, 0, !1));
940
+ }).catch((E) => {
941
+ se(E) || console.error("Explorer: sections failed", E);
942
+ }).finally(() => {
943
+ ee.current === m && g(!1);
944
+ }), () => m.abort();
945
+ }, [e, Y]);
946
+ const Oe = S(
947
+ (m) => {
948
+ q((M) => {
949
+ const E = !M[m];
950
+ return E && !(m in f.current) && (D(m), b(m, 0, !1)), { ...M, [m]: E };
951
+ });
952
+ },
953
+ [D, b]
954
+ ), Fe = S(
955
+ (m, M, E) => {
956
+ _((A) => {
957
+ const $ = A[m] ?? {}, K = $[M] ?? [], F = K.includes(E) ? K.filter((ze) => ze !== E) : [...K, E], G = { ...$ };
958
+ return F.length ? G[M] = F : delete G[M], { ...A, [m]: G };
959
+ }), v((A) => ({ ...A, [m]: [] }));
960
+ },
961
+ []
962
+ );
963
+ U(() => {
964
+ for (const m of Object.keys(y))
965
+ N.current[m] && (D(m), b(m, 0, !1));
966
+ }, [y, D, b]);
967
+ const Le = !z && u.length === 0;
968
+ return /* @__PURE__ */ h("div", { className: H("flex h-full flex-col", s), "data-slot": "sectioned-explorer", children: [
969
+ o && !i ? /* @__PURE__ */ a("div", { className: "border-b border-border/60 px-2 py-1.5", children: /* @__PURE__ */ a(
970
+ ke,
971
+ {
972
+ "aria-label": "Search",
973
+ placeholder: l,
974
+ value: d,
975
+ onChange: (m) => x(m.target.value),
976
+ className: "h-7 rounded-sm border-transparent bg-muted/40 px-2 text-[12.5px] shadow-none focus-visible:bg-background focus-visible:ring-1"
977
+ }
978
+ ) }) : null,
979
+ /* @__PURE__ */ a("div", { className: "flex-1 overflow-y-auto", "data-slot": "sectioned-explorer-list", children: Le ? /* @__PURE__ */ a("div", { className: "flex h-full items-center justify-center px-4 py-8 text-[12px] text-muted-foreground", children: n }) : /* @__PURE__ */ a("ul", { className: "flex flex-col py-1", children: u.map((m) => {
980
+ const M = !!O[m.id], E = T[m.id] ?? [], A = Object.fromEntries(
981
+ (m.filters ?? []).map((F) => [F.key, F.values ?? []])
982
+ ), $ = B[m.id] ?? A, K = y[m.id] ?? {};
983
+ return /* @__PURE__ */ h("li", { children: [
984
+ /* @__PURE__ */ h(
985
+ "button",
986
+ {
987
+ type: "button",
988
+ "aria-expanded": M,
989
+ onClick: () => Oe(m.id),
990
+ className: H(
991
+ "group mx-1 flex w-[calc(100%-0.5rem)] items-center gap-1.5 rounded-md px-1.5 py-1 text-left",
992
+ "transition-colors duration-120 ease-[cubic-bezier(0.22,1,0.36,1)] hover:bg-muted/40"
993
+ ),
994
+ children: [
995
+ M ? /* @__PURE__ */ a(Ce, { size: 11 }) : /* @__PURE__ */ a(Te, { size: 11 }),
996
+ /* @__PURE__ */ a("span", { className: "min-w-0 flex-1 truncate text-[12.5px] font-medium text-foreground", children: m.title }),
997
+ /* @__PURE__ */ a("span", { className: "font-mono text-[10.5px] text-muted-foreground/80", children: (C[m.id] ?? m.count ?? 0).toLocaleString() })
998
+ ]
999
+ }
1000
+ ),
1001
+ M ? /* @__PURE__ */ h("div", { children: [
1002
+ /* @__PURE__ */ a(
1003
+ wt,
1004
+ {
1005
+ configs: m.filters ?? [],
1006
+ facets: $,
1007
+ selected: K,
1008
+ onToggle: (F, G) => Fe(m.id, F, G)
1009
+ }
1010
+ ),
1011
+ /* @__PURE__ */ h("ul", { className: "flex flex-col", children: [
1012
+ E.map((F) => /* @__PURE__ */ a(
1013
+ Mt,
1014
+ {
1015
+ row: F,
1016
+ indent: !0,
1017
+ onActivate: t,
1018
+ getDragPayload: r
1019
+ },
1020
+ F.id
1021
+ )),
1022
+ R[m.id] && E.length === 0 ? /* @__PURE__ */ a("li", { className: "py-1.5 pl-7 pr-3 text-[11px] text-muted-foreground/80", children: "Loading…" }) : null,
1023
+ j[m.id] ? /* @__PURE__ */ a("li", { className: "py-1 pl-7 pr-3", children: /* @__PURE__ */ a(
1024
+ "button",
1025
+ {
1026
+ type: "button",
1027
+ onClick: () => b(m.id, E.length, !0),
1028
+ disabled: R[m.id],
1029
+ className: "text-[11px] text-muted-foreground hover:text-foreground disabled:opacity-60",
1030
+ children: R[m.id] ? "Loading…" : "Load more"
1031
+ }
1032
+ ) }) : null
1033
+ ] })
1034
+ ] }) : null
1035
+ ] }, m.id);
1036
+ }) }) })
1037
+ ] });
1038
+ }
1039
+ function wt({
1040
+ configs: e,
1041
+ facets: t,
1042
+ selected: r,
1043
+ onToggle: n
1044
+ }) {
1045
+ return e.length ? /* @__PURE__ */ a("div", { className: "space-y-1 px-7 py-1", children: e.map((l) => {
1046
+ const o = t[l.key] ?? l.values ?? [];
1047
+ return o.length ? /* @__PURE__ */ a("div", { className: "flex flex-wrap gap-1", children: o.map((p) => {
1048
+ var i;
1049
+ const c = ((i = r[l.key]) == null ? void 0 : i.includes(p.value)) ?? !1, s = l.formatValue ? l.formatValue(p.value) : p.value;
1050
+ return /* @__PURE__ */ h(
1051
+ "button",
1052
+ {
1053
+ type: "button",
1054
+ onClick: () => n(l.key, p.value),
1055
+ className: H(
1056
+ "rounded border px-1.5 py-0.5 text-[10.5px] transition-colors",
1057
+ c ? "border-foreground/30 bg-foreground/10 text-foreground" : "border-border/70 text-muted-foreground hover:text-foreground"
1058
+ ),
1059
+ children: [
1060
+ s,
1061
+ /* @__PURE__ */ a("span", { className: "ml-1 font-mono opacity-70", children: p.count })
1062
+ ]
1063
+ },
1064
+ p.value
1065
+ );
1066
+ }) }, l.key) : null;
1067
+ }) }) : null;
1068
+ }
1069
+ function Mt({
1070
+ row: e,
1071
+ indent: t,
1072
+ onActivate: r,
1073
+ getDragPayload: n
1074
+ }) {
1075
+ var s;
1076
+ const l = !!r, o = n == null ? void 0 : n(e);
1077
+ return /* @__PURE__ */ h(
1078
+ "li",
1079
+ {
1080
+ ...l ? { role: "button", tabIndex: 0, onClick: () => r == null ? void 0 : r(e), onKeyDown: (i) => {
1081
+ l && (i.key === "Enter" || i.key === " ") && (i.preventDefault(), r == null || r(e));
1082
+ } } : {},
1083
+ ...o ? { draggable: !0, onDragStart: (i) => {
1084
+ o && (i.dataTransfer.setData(o.mimeType, o.value), i.dataTransfer.setData("text/plain", o.value), i.dataTransfer.effectAllowed = "copy");
1085
+ } } : {},
1086
+ className: H(
1087
+ "group mx-1 flex items-start gap-2 rounded-md px-1.5 py-1",
1088
+ "transition-colors duration-120 ease-[cubic-bezier(0.22,1,0.36,1)]",
1089
+ l && "cursor-pointer hover:bg-foreground/5",
1090
+ t && "pl-7"
1091
+ ),
1092
+ title: e.title,
1093
+ children: [
1094
+ e.leading ? /* @__PURE__ */ a(ye, { badge: e.leading }) : null,
1095
+ /* @__PURE__ */ h("span", { className: "flex min-w-0 flex-1 flex-col", children: [
1096
+ /* @__PURE__ */ a("span", { className: "truncate text-[12.5px] font-medium leading-tight text-foreground", children: e.title }),
1097
+ e.subtitle ? /* @__PURE__ */ a("span", { className: "truncate text-[11.5px] leading-snug text-muted-foreground/85", children: e.subtitle }) : null
1098
+ ] }),
1099
+ (s = e.trailing) != null && s.length ? /* @__PURE__ */ a("span", { className: "flex shrink-0 items-center gap-1", children: e.trailing.map((i, d) => /* @__PURE__ */ a(ye, { badge: i }, d)) }) : null,
1100
+ e.meta ? /* @__PURE__ */ a("span", { className: "shrink-0 self-center font-mono text-[10.5px] text-muted-foreground/80", children: e.meta }) : null
1101
+ ]
1102
+ }
1103
+ );
1104
+ }
1105
+ function ye({ badge: e }) {
1106
+ return /* @__PURE__ */ a(
1107
+ "span",
1108
+ {
1109
+ "aria-hidden": "true",
1110
+ title: e.tooltip,
1111
+ className: "mt-[1px] inline-flex h-[16px] min-w-[24px] shrink-0 items-center justify-center rounded-[3px] bg-muted/60 px-1 font-mono text-[9.5px] font-medium uppercase tracking-[0.06em] text-muted-foreground group-hover:text-foreground",
1112
+ children: e.code
1113
+ }
1114
+ );
1115
+ }
1116
+ const ue = "data-catalog", or = "query_data_catalog", de = "data-catalog.open-row";
1117
+ function Dt(e) {
1118
+ let t = 2166136261;
1119
+ for (let r = 0; r < e.length; r++)
1120
+ t ^= e.charCodeAt(r), t = Math.imul(t, 16777619);
1121
+ return (t >>> 0).toString(36);
1122
+ }
1123
+ function be(e) {
1124
+ return e.trim().replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32) || "row";
1125
+ }
1126
+ function It(e, t = "data") {
1127
+ const r = Dt(e), n = be(e), l = be(t), o = `${n}-${r}`, p = Math.max(0, 64 - o.length - 1), c = l.slice(0, p);
1128
+ return c ? `${c}-${o}` : o.slice(0, 64);
1129
+ }
1130
+ function De(e, t) {
1131
+ const r = {
1132
+ ...t.params ?? {},
1133
+ // Keep routing keys authoritative even when callers pass extra params.
1134
+ row: e,
1135
+ catalogId: t.catalogId,
1136
+ ...t.title ? { title: t.title } : {}
1137
+ };
1138
+ Be({
1139
+ kind: "openSurface",
1140
+ params: {
1141
+ kind: t.surfaceKind ?? de,
1142
+ target: e.id,
1143
+ meta: r
1144
+ }
1145
+ });
1146
+ }
1147
+ function Rt(e) {
1148
+ return (t) => De(t, e);
1149
+ }
1150
+ function Ot(e) {
1151
+ if (!e || typeof e != "object") return !1;
1152
+ const t = e;
1153
+ return typeof t.id == "string" && typeof t.title == "string";
1154
+ }
1155
+ function ve(e, t) {
1156
+ const r = e[t];
1157
+ return typeof r == "string" && r.length > 0 ? r : void 0;
1158
+ }
1159
+ function Ft(e) {
1160
+ const t = e.surfaceKind ?? de, r = e.panelIdPrefix ?? e.id;
1161
+ return {
1162
+ id: e.surfaceResolverId ?? `${e.id}-row`,
1163
+ source: e.source,
1164
+ resolve(n) {
1165
+ if (n.kind !== t) return;
1166
+ const l = n.meta ?? {}, o = ve(l, "catalogId");
1167
+ if (o && o !== e.catalogId) return;
1168
+ const p = Ot(l.row) ? l.row : void 0, {
1169
+ catalogId: c,
1170
+ row: s,
1171
+ title: i,
1172
+ ...d
1173
+ } = l;
1174
+ return {
1175
+ id: It(n.target, r),
1176
+ component: e.visualizationPanelId,
1177
+ title: ve(l, "title") ?? (p == null ? void 0 : p.title) ?? e.visualizationTitle,
1178
+ params: {
1179
+ ...d,
1180
+ ...p ? { row: p } : { query: n.target }
1181
+ },
1182
+ score: 0
1183
+ };
1184
+ }
1185
+ };
1186
+ }
1187
+ function Lt(e) {
1188
+ if (!e || typeof e != "object") return;
1189
+ const t = e;
1190
+ if (!(typeof t.id != "string" || typeof t.title != "string"))
1191
+ return t;
1192
+ }
1193
+ function Ie(e) {
1194
+ if (e) {
1195
+ if ("searchQuery" in e && typeof e.searchQuery == "string")
1196
+ return e.searchQuery;
1197
+ if ("query" in e && typeof e.query == "string") return e.query;
1198
+ }
1199
+ }
1200
+ function zt(e) {
1201
+ const t = Ie(e);
1202
+ return { query: t, controlled: t !== void 0 };
1203
+ }
1204
+ function qt(e, t) {
1205
+ const r = Lt(e == null ? void 0 : e.row), n = Ie(e) ?? (r == null ? void 0 : r.id);
1206
+ return {
1207
+ row: r,
1208
+ query: n,
1209
+ controlled: n !== void 0,
1210
+ title: (r == null ? void 0 : r.title) ?? t
1211
+ };
1212
+ }
1213
+ function _t(e) {
1214
+ return Z(() => zt(e), [e]);
1215
+ }
1216
+ function Bt(e, t) {
1217
+ return Z(
1218
+ () => qt(e, t),
1219
+ [t, e]
1220
+ );
1221
+ }
1222
+ function sr(e) {
1223
+ const { catalogId: t, surfaceKind: r, title: n, params: l } = e;
1224
+ return S(
1225
+ (o) => De(o, { catalogId: t, surfaceKind: r, title: n, params: l }),
1226
+ [t, r, n, l]
1227
+ );
1228
+ }
1229
+ function Re(e) {
1230
+ const t = e.id ?? ue, r = e.label ?? "Data", n = e.catalogId ?? t, l = e.catalogLabel ?? r, o = e.leftTabId ?? `${t}-tab`, p = e.leftTabTitle ?? r, c = e.visualizationPanelId ?? `${t}-visualization`, s = e.visualizationTitle ?? `${r} View`, i = e.surfaceKind ?? de, d = e.source ?? "app", x = e.includeVisualizationPanel ?? !0, u = e.includeLeftTab ?? !0, P = e.includeCatalog ?? !0, T = e.includeSurfaceResolver ?? (x && !e.onSelect), v = e.emptyState ?? "No data found", C = e.searchPlaceholder ?? `Search ${r.toLowerCase()}...`, I = e.onSelect ?? (x ? Rt({
1231
+ catalogId: n,
1232
+ surfaceKind: i
1233
+ }) : () => {
1234
+ });
1235
+ function j({ params: g, className: R }) {
1236
+ const { query: Q, controlled: O } = _t(g), q = g == null ? void 0 : g.bridge, y = (_) => I(_, { params: g, bridge: q });
1237
+ return /* @__PURE__ */ a(
1238
+ ie,
1239
+ {
1240
+ adapter: e.adapter,
1241
+ facets: e.facets,
1242
+ groupBy: e.groupBy,
1243
+ onActivate: y,
1244
+ getDragPayload: e.getDragPayload,
1245
+ emptyState: v,
1246
+ searchPlaceholder: C,
1247
+ query: O ? Q : void 0,
1248
+ searchable: !O,
1249
+ pageSize: e.pageSize,
1250
+ debounceMs: e.debounceMs,
1251
+ className: R ?? "h-full"
1252
+ }
1253
+ );
1254
+ }
1255
+ function L({
1256
+ params: g,
1257
+ api: R,
1258
+ className: Q
1259
+ }) {
1260
+ const { row: O, query: q, controlled: y, title: _ } = Bt(
1261
+ g,
1262
+ s
1263
+ ), B = (X) => I(X, {});
1264
+ return /* @__PURE__ */ h(
1265
+ Ae,
1266
+ {
1267
+ title: _,
1268
+ icon: e.visualizationIcon ?? pe,
1269
+ panelApi: R,
1270
+ className: Q,
1271
+ children: [
1272
+ O ? /* @__PURE__ */ h("div", { className: "border-b border-border/60 px-3 py-2", children: [
1273
+ /* @__PURE__ */ a("div", { className: "truncate text-sm font-medium text-foreground", children: O.title }),
1274
+ /* @__PURE__ */ a("div", { className: "truncate text-xs text-muted-foreground", children: O.subtitle ?? O.id })
1275
+ ] }) : null,
1276
+ /* @__PURE__ */ a(
1277
+ ie,
1278
+ {
1279
+ adapter: e.adapter,
1280
+ facets: e.facets,
1281
+ groupBy: e.groupBy,
1282
+ onActivate: B,
1283
+ getDragPayload: e.getDragPayload,
1284
+ emptyState: v,
1285
+ searchPlaceholder: C,
1286
+ query: y ? q : void 0,
1287
+ searchable: !y,
1288
+ pageSize: e.pageSize,
1289
+ debounceMs: e.debounceMs,
1290
+ className: "h-full"
1291
+ }
1292
+ )
1293
+ ]
1294
+ }
1295
+ );
1296
+ }
1297
+ const z = [];
1298
+ if (u && z.push({
1299
+ type: "left-tab",
1300
+ id: o,
1301
+ title: p,
1302
+ icon: e.leftTabIcon ?? Je,
1303
+ component: j,
1304
+ source: d,
1305
+ chromeless: !0
1306
+ }), x) {
1307
+ const g = we({
1308
+ id: c,
1309
+ title: s,
1310
+ icon: e.visualizationIcon ?? pe,
1311
+ component: e.visualizationComponent ?? L,
1312
+ placement: "center",
1313
+ source: d
1314
+ });
1315
+ z.push({
1316
+ type: "panel",
1317
+ panel: g
1318
+ });
1319
+ }
1320
+ if (P) {
1321
+ const g = {
1322
+ id: n,
1323
+ label: l,
1324
+ adapter: e.adapter,
1325
+ onSelect: (R) => I(R, {})
1326
+ };
1327
+ z.push({ type: "catalog", catalog: g });
1328
+ }
1329
+ return T && z.push({
1330
+ type: "surface-resolver",
1331
+ resolver: Ft({
1332
+ id: t,
1333
+ catalogId: n,
1334
+ visualizationPanelId: c,
1335
+ visualizationTitle: s,
1336
+ panelIdPrefix: t,
1337
+ surfaceKind: i,
1338
+ surfaceResolverId: e.surfaceResolverId,
1339
+ source: d
1340
+ })
1341
+ }), z;
1342
+ }
1343
+ function cr(e) {
1344
+ const t = e.pluginId ?? e.id ?? ue;
1345
+ return ae({
1346
+ id: t,
1347
+ label: e.label ?? "Data Catalog",
1348
+ outputs: Re(e)
1349
+ });
1350
+ }
1351
+ function ir(e, t) {
1352
+ return ae({
1353
+ ...e,
1354
+ outputs: [...e.outputs ?? [], ...Re(t)]
1355
+ });
1356
+ }
1357
+ function ur(e) {
1358
+ return {
1359
+ id: e.catalogId ?? e.id ?? ue,
1360
+ label: e.catalogLabel ?? e.label ?? "Data",
1361
+ adapter: e.adapter,
1362
+ onSelect: (t) => {
1363
+ var r;
1364
+ return (r = e.onSelect) == null ? void 0 : r.call(e, t, {});
1365
+ }
1366
+ };
1367
+ }
1368
+ const At = 768, $t = 1024;
1369
+ function Kt(e) {
1370
+ return {
1371
+ ...e,
1372
+ groups: e.groups.filter((t) => t.id !== "sidebar")
1373
+ };
1374
+ }
1375
+ function Vt({
1376
+ layout: e,
1377
+ className: t
1378
+ }) {
1379
+ var q;
1380
+ const r = Ne(), n = $e(), l = Ke(), o = ge(At), p = ge($t), c = p && !o, s = Z(
1381
+ () => e.groups.find((y) => y.id === "sidebar" && y.panel),
1382
+ [e]
1383
+ ), i = s == null ? void 0 : s.panel, d = !!i, x = ht({
1384
+ isNarrowViewport: d && p,
1385
+ isCollapsed: n.collapsed,
1386
+ setCollapsed: (y) => l({ collapsed: y })
1387
+ }), [u, P] = V(!1);
1388
+ U(() => {
1389
+ (!d || !o && !c) && P(!1);
1390
+ }, [d, o, c]);
1391
+ const T = d && (o || c && n.collapsed), v = d && !o && (!c || !n.collapsed), C = Z(
1392
+ () => v ? e : Kt(e),
1393
+ [v, e]
1394
+ ), I = Z(() => {
1395
+ const y = v ? "inline-sidebar" : "overlay-sidebar", _ = C.groups.map((B) => {
1396
+ let X = "";
1397
+ try {
1398
+ X = JSON.stringify(B.params ?? null);
1399
+ } catch {
1400
+ X = "unserializable";
1401
+ }
1402
+ return `${B.id}:${B.panel ?? ""}:${X}`;
1403
+ }).join(",");
1404
+ return `${C.version}:${y}:${_}`;
1405
+ }, [C, v]), j = Z(() => r.getComponents(), [r]), L = i ? j[i] : null, z = i ? ((q = r.get(i)) == null ? void 0 : q.title) ?? "Sidebar" : "Sidebar", g = S(() => {
1406
+ P(!0);
1407
+ }, []), R = S(() => {
1408
+ x(), l({ collapsed: !1 }), P(!1);
1409
+ }, [x, l]), Q = S(() => {
1410
+ x(), l({ collapsed: !0 }), P(!1);
1411
+ }, [x, l]), O = S(
1412
+ (y) => {
1413
+ y.target.closest("[role='treeitem']") && P(!1);
1414
+ },
1415
+ []
1416
+ );
1417
+ return /* @__PURE__ */ h("div", { className: "relative h-full w-full", children: [
1418
+ c && d && n.collapsed && /* @__PURE__ */ a(
1419
+ "div",
1420
+ {
1421
+ className: "pointer-events-none absolute inset-y-0 left-0 z-20 w-10 border-r border-border bg-background/95",
1422
+ "aria-hidden": "true"
1423
+ }
1424
+ ),
1425
+ T && /* @__PURE__ */ a(
1426
+ "div",
1427
+ {
1428
+ className: H(
1429
+ "absolute z-30",
1430
+ o ? "left-2 top-2" : "left-1 top-2"
1431
+ ),
1432
+ children: /* @__PURE__ */ a(
1433
+ J,
1434
+ {
1435
+ type: "button",
1436
+ variant: "outline",
1437
+ size: "icon-sm",
1438
+ onClick: g,
1439
+ "aria-label": o ? "Open sidebar menu" : "Open collapsed sidebar",
1440
+ children: o ? /* @__PURE__ */ a(Ye, { className: "h-4 w-4" }) : /* @__PURE__ */ a(Ze, { className: "h-4 w-4" })
1441
+ }
1442
+ )
1443
+ }
1444
+ ),
1445
+ c && d && !n.collapsed && /* @__PURE__ */ a("div", { className: "absolute left-2 top-2 z-30", children: /* @__PURE__ */ a(
1446
+ J,
1447
+ {
1448
+ type: "button",
1449
+ variant: "outline",
1450
+ size: "icon-sm",
1451
+ onClick: Q,
1452
+ "aria-label": "Collapse sidebar",
1453
+ children: /* @__PURE__ */ a(et, { className: "h-4 w-4" })
1454
+ }
1455
+ ) }),
1456
+ /* @__PURE__ */ a(
1457
+ Ve,
1458
+ {
1459
+ layout: C,
1460
+ className: H(
1461
+ t,
1462
+ c && d && n.collapsed && "pl-10"
1463
+ )
1464
+ },
1465
+ I
1466
+ ),
1467
+ T && /* @__PURE__ */ a(it, { open: u, onOpenChange: P, children: /* @__PURE__ */ h(
1468
+ ut,
1469
+ {
1470
+ side: "left",
1471
+ className: "w-[85vw] max-w-sm p-0",
1472
+ children: [
1473
+ /* @__PURE__ */ h(dt, { className: "flex flex-row items-center justify-between border-b border-border px-4 py-3", children: [
1474
+ /* @__PURE__ */ h("div", { children: [
1475
+ /* @__PURE__ */ a(pt, { children: z }),
1476
+ /* @__PURE__ */ a(ft, { className: "sr-only", children: "Responsive sidebar panel" })
1477
+ ] }),
1478
+ c && /* @__PURE__ */ h(
1479
+ J,
1480
+ {
1481
+ type: "button",
1482
+ variant: "outline",
1483
+ size: "sm",
1484
+ onClick: R,
1485
+ "aria-label": "Pin sidebar open",
1486
+ children: [
1487
+ /* @__PURE__ */ a(tt, { className: "h-4 w-4" }),
1488
+ "Pin"
1489
+ ]
1490
+ }
1491
+ )
1492
+ ] }),
1493
+ /* @__PURE__ */ a(
1494
+ "div",
1495
+ {
1496
+ className: "h-full min-h-0 overflow-auto",
1497
+ onClickCapture: O,
1498
+ children: L ? /* @__PURE__ */ a(He, { fallback: /* @__PURE__ */ a(Se, {}), children: /* @__PURE__ */ a(L, {}) }) : /* @__PURE__ */ a(Se, {})
1499
+ }
1500
+ )
1501
+ ]
1502
+ }
1503
+ ) })
1504
+ ] });
1505
+ }
1506
+ function Se() {
1507
+ return /* @__PURE__ */ a("div", { className: "flex h-full min-h-[240px] items-center justify-center text-sm text-muted-foreground", children: "Loading sidebar..." });
1508
+ }
1509
+ function Qt(e = {}) {
1510
+ const { sidebar: t = "filetree", center: r = "empty", right: n } = e, l = [
1511
+ {
1512
+ id: "sidebar",
1513
+ position: "left",
1514
+ panel: t,
1515
+ locked: !0,
1516
+ collapsible: !0,
1517
+ collapsedWidth: 40,
1518
+ constraints: { minWidth: 200, maxWidthViewportRatio: 0.5 }
1519
+ },
1520
+ {
1521
+ id: "center",
1522
+ position: "center",
1523
+ panel: r,
1524
+ dynamic: !0,
1525
+ placeholder: "empty",
1526
+ constraints: { minWidth: 300 }
1527
+ }
1528
+ ];
1529
+ return n && l.push({
1530
+ id: "right",
1531
+ position: "right",
1532
+ panel: n,
1533
+ hideHeader: !0,
1534
+ constraints: { minWidth: 250 }
1535
+ }), { version: "2.0", groups: l };
1536
+ }
1537
+ function dr(e) {
1538
+ return /* @__PURE__ */ a(Vt, { layout: Qt(e), className: e.className });
1539
+ }
1540
+ function pr({ className: e, onOpenFile: t }) {
1541
+ return /* @__PURE__ */ a(
1542
+ Pe,
1543
+ {
1544
+ className: H("h-full border-0 text-muted-foreground", e),
1545
+ title: "No file open",
1546
+ description: "Open a file to get started",
1547
+ actions: t ? /* @__PURE__ */ a(J, { type: "button", variant: "outline", onClick: t, children: "Open file" }) : null,
1548
+ children: /* @__PURE__ */ h("div", { className: "space-y-2 text-sm", children: [
1549
+ /* @__PURE__ */ h("div", { className: "flex items-center gap-3", children: [
1550
+ /* @__PURE__ */ a(le, { children: "⌘P" }),
1551
+ /* @__PURE__ */ a("span", { children: "Open file" })
1552
+ ] }),
1553
+ /* @__PURE__ */ h("div", { className: "flex items-center gap-3", children: [
1554
+ /* @__PURE__ */ a(le, { children: "⌘⇧P" }),
1555
+ /* @__PURE__ */ a("span", { children: "Command palette" })
1556
+ ] }),
1557
+ /* @__PURE__ */ h("div", { className: "flex items-center gap-3", children: [
1558
+ /* @__PURE__ */ a(le, { children: "⌘B" }),
1559
+ /* @__PURE__ */ a("span", { children: "Toggle sidebar" })
1560
+ ] })
1561
+ ] })
1562
+ }
1563
+ );
1564
+ }
1565
+ class fr extends We {
1566
+ constructor() {
1567
+ super(...arguments);
1568
+ ne(this, "state", { hasError: !1, error: null });
1569
+ ne(this, "handleRetry", () => {
1570
+ this.setState({ hasError: !1, error: null });
1571
+ });
1572
+ }
1573
+ static getDerivedStateFromError(r) {
1574
+ return { hasError: !0, error: r };
1575
+ }
1576
+ componentDidCatch(r, n) {
1577
+ const { panelId: l, onError: o } = this.props;
1578
+ console.error(`[PanelErrorBoundary] Panel "${l}" crashed:`, r, n.componentStack), o == null || o({
1579
+ panelId: l,
1580
+ error: r.message,
1581
+ stack: n.componentStack ?? void 0
1582
+ });
1583
+ }
1584
+ render() {
1585
+ var r;
1586
+ return this.state.hasError ? /* @__PURE__ */ a("div", { className: "flex h-full items-center justify-center p-6", children: /* @__PURE__ */ a(
1587
+ mt,
1588
+ {
1589
+ className: "w-full max-w-md",
1590
+ title: "Something went wrong",
1591
+ description: /* @__PURE__ */ h(Qe, { children: [
1592
+ "Panel ",
1593
+ /* @__PURE__ */ a("code", { className: "rounded bg-muted px-1 py-0.5 text-xs", children: this.props.panelId }),
1594
+ " ",
1595
+ "encountered an error."
1596
+ ] }),
1597
+ details: (r = this.state.error) == null ? void 0 : r.message,
1598
+ actions: /* @__PURE__ */ a(J, { type: "button", variant: "outline", onClick: this.handleRetry, children: "Retry" })
1599
+ }
1600
+ ) }) : this.props.children;
1601
+ }
1602
+ }
1603
+ function mr({
1604
+ sessions: e,
1605
+ activeId: t,
1606
+ onSwitch: r,
1607
+ onCreate: n,
1608
+ onDelete: l,
1609
+ className: o
1610
+ }) {
1611
+ const [p, c] = V(null), s = w({}), i = Z(() => e.map((u) => u.id), [e]);
1612
+ U(() => {
1613
+ if (i.length === 0) {
1614
+ c(null);
1615
+ return;
1616
+ }
1617
+ c((u) => u && i.includes(u) ? u : t && i.includes(t) ? t : i[0] ?? null);
1618
+ }, [i, t]);
1619
+ const d = S((u) => {
1620
+ var P;
1621
+ c(u), (P = s.current[u]) == null || P.focus();
1622
+ }, []), x = S(
1623
+ (u, P) => {
1624
+ if (u.target !== u.currentTarget) return;
1625
+ if (u.key === "Enter" || u.key === " ") {
1626
+ u.preventDefault(), r == null || r(P);
1627
+ return;
1628
+ }
1629
+ const T = i.indexOf(P);
1630
+ if (T < 0) return;
1631
+ let v = T;
1632
+ if (u.key === "ArrowDown")
1633
+ v = Math.min(T + 1, i.length - 1);
1634
+ else if (u.key === "ArrowUp")
1635
+ v = Math.max(T - 1, 0);
1636
+ else if (u.key === "Home")
1637
+ v = 0;
1638
+ else if (u.key === "End")
1639
+ v = i.length - 1;
1640
+ else
1641
+ return;
1642
+ u.preventDefault();
1643
+ const C = i[v];
1644
+ C && d(C);
1645
+ },
1646
+ [d, r, i]
1647
+ );
1648
+ return /* @__PURE__ */ h(
1649
+ "div",
1650
+ {
1651
+ "data-boring-workspace-part": "session-list",
1652
+ className: H("flex h-full flex-col", o),
1653
+ role: "navigation",
1654
+ "aria-label": "Sessions",
1655
+ children: [
1656
+ /* @__PURE__ */ h("div", { className: "flex items-center justify-between border-b border-border px-3 py-2", children: [
1657
+ /* @__PURE__ */ a("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wider", children: "Sessions" }),
1658
+ n && /* @__PURE__ */ a(Ee, { type: "button", variant: "ghost", size: "icon-xs", onClick: n, "aria-label": "New session", children: /* @__PURE__ */ a(
1659
+ "svg",
1660
+ {
1661
+ width: "16",
1662
+ height: "16",
1663
+ viewBox: "0 0 16 16",
1664
+ fill: "none",
1665
+ stroke: "currentColor",
1666
+ strokeWidth: "1.5",
1667
+ strokeLinecap: "round",
1668
+ children: /* @__PURE__ */ a("path", { d: "M8 3v10M3 8h10" })
1669
+ }
1670
+ ) })
1671
+ ] }),
1672
+ /* @__PURE__ */ h("div", { className: "flex-1 overflow-y-auto", role: "list", "aria-label": "Session list", children: [
1673
+ e.length === 0 && /* @__PURE__ */ a("div", { className: "px-3 py-6 text-center text-sm text-muted-foreground", children: "No sessions" }),
1674
+ e.map((u) => /* @__PURE__ */ a(
1675
+ jt,
1676
+ {
1677
+ session: u,
1678
+ isActive: u.id === t,
1679
+ isFocused: u.id === p,
1680
+ onSwitch: r,
1681
+ onDelete: l,
1682
+ onFocus: () => c(u.id),
1683
+ onKeyDown: x,
1684
+ rowRef: (P) => {
1685
+ s.current[u.id] = P;
1686
+ }
1687
+ },
1688
+ u.id
1689
+ ))
1690
+ ] })
1691
+ ]
1692
+ }
1693
+ );
1694
+ }
1695
+ function jt({
1696
+ session: e,
1697
+ isActive: t,
1698
+ isFocused: r,
1699
+ onSwitch: n,
1700
+ onDelete: l,
1701
+ onFocus: o,
1702
+ onKeyDown: p,
1703
+ rowRef: c
1704
+ }) {
1705
+ return /* @__PURE__ */ h(
1706
+ "div",
1707
+ {
1708
+ ref: c,
1709
+ role: "listitem",
1710
+ "data-boring-workspace-part": "session-row",
1711
+ "data-boring-state": t ? "selected" : void 0,
1712
+ "data-focused": r ? "true" : "false",
1713
+ className: H(
1714
+ "group flex items-center gap-2 border-b border-border px-3 py-2 text-sm cursor-pointer transition-colors",
1715
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
1716
+ t ? "bg-accent text-accent-foreground" : "text-foreground hover:bg-accent/50"
1717
+ ),
1718
+ onClick: () => n == null ? void 0 : n(e.id),
1719
+ onFocus: o,
1720
+ onKeyDown: (s) => p(s, e.id),
1721
+ tabIndex: r ? 0 : -1,
1722
+ "aria-current": t ? "true" : void 0,
1723
+ children: [
1724
+ /* @__PURE__ */ a("span", { className: "flex-1 truncate", children: e.title }),
1725
+ t && /* @__PURE__ */ a(
1726
+ "span",
1727
+ {
1728
+ className: "h-1.5 w-1.5 shrink-0 rounded-full bg-primary",
1729
+ "aria-label": "Active"
1730
+ }
1731
+ ),
1732
+ l && /* @__PURE__ */ a(
1733
+ Ee,
1734
+ {
1735
+ type: "button",
1736
+ variant: "ghost",
1737
+ size: "icon-xs",
1738
+ className: "shrink-0 text-muted-foreground opacity-0 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100 group-data-[focused=true]:opacity-100",
1739
+ onClick: (s) => {
1740
+ s.stopPropagation(), l(e.id);
1741
+ },
1742
+ tabIndex: r ? 0 : -1,
1743
+ "aria-label": `Delete ${e.title}`,
1744
+ children: /* @__PURE__ */ a(
1745
+ "svg",
1746
+ {
1747
+ width: "14",
1748
+ height: "14",
1749
+ viewBox: "0 0 14 14",
1750
+ fill: "none",
1751
+ stroke: "currentColor",
1752
+ strokeWidth: "1.5",
1753
+ strokeLinecap: "round",
1754
+ children: /* @__PURE__ */ a("path", { d: "M3.5 3.5l7 7M10.5 3.5l-7 7" })
1755
+ }
1756
+ )
1757
+ }
1758
+ )
1759
+ ]
1760
+ }
1761
+ );
1762
+ }
1763
+ export {
1764
+ xr as ArtifactSurfacePane,
1765
+ yr as CatalogRegistry,
1766
+ Oa as ChatLayout,
1767
+ _a as CodeEditor,
1768
+ br as CodeEditorPane,
1769
+ vr as CommandPalette,
1770
+ Sr as CommandRegistry,
1771
+ or as DATA_CATALOG_DEFAULT_TOOL_NAME,
1772
+ ue as DATA_CATALOG_PLUGIN_ID,
1773
+ de as DATA_CATALOG_ROW_SURFACE_KIND,
1774
+ ie as DataExplorer,
1775
+ Ve as DockviewShell,
1776
+ nr as EXPLORER_PLUGIN_ID,
1777
+ pr as EmptyPane,
1778
+ xe as ExplorerView,
1779
+ $a as FileTree,
1780
+ Nr as FileTreePane,
1781
+ Cr as FileTreeView,
1782
+ dr as IdeLayout,
1783
+ Tr as MAX_PANELS,
1784
+ Va as MarkdownEditor,
1785
+ Pr as MarkdownEditorPane,
1786
+ fr as PanelErrorBoundary,
1787
+ kr as PanelRegistry,
1788
+ Er as PluginError,
1789
+ wr as PluginErrorBoundary,
1790
+ Mr as PluginErrorProvider,
1791
+ Dr as RegistryProvider,
1792
+ Vt as ResponsiveDockviewShell,
1793
+ Ir as SessionBrowser,
1794
+ mr as SessionList,
1795
+ Rr as SurfaceResolverRegistry,
1796
+ Or as SurfaceShell,
1797
+ Fr as ThemeProvider,
1798
+ Ma as Toaster,
1799
+ Fa as TopBar,
1800
+ Lr as WORKSPACE_OPEN_PATH_SURFACE_KIND,
1801
+ zr as WorkbenchLeftPane,
1802
+ La as WorkspaceLoadingState,
1803
+ qr as WorkspaceProvider,
1804
+ _r as agentMeta,
1805
+ ir as appendDataCatalogOutputs,
1806
+ Br as bindStore,
1807
+ Ar as bootstrap,
1808
+ za as buildChatLayout,
1809
+ Qt as buildIdeLayout,
1810
+ $r as closePanelSchema,
1811
+ H as cn,
1812
+ er as composePlugins,
1813
+ Kr as createBridge,
1814
+ Vr as createBridgeClient,
1815
+ ur as createDataCatalogCatalog,
1816
+ Rt as createDataCatalogOpenHandler,
1817
+ Re as createDataCatalogOutputs,
1818
+ cr as createDataCatalogPlugin,
1819
+ Ft as createDataCatalogSurfaceResolver,
1820
+ kt as createExplorerOutputs,
1821
+ lr as createExplorerPlugin,
1822
+ Ba as createShadcnTheme,
1823
+ Qr as createWorkspaceStore,
1824
+ It as dataCatalogPanelInstanceId,
1825
+ ae as defineFrontPlugin,
1826
+ we as definePanel,
1827
+ Da as dismissToast,
1828
+ jr as emitAgentData,
1829
+ Gr as emitFilesystemAgentFileChange,
1830
+ Hr as events,
1831
+ Wr as expandToFileSchema,
1832
+ Ur as filesystemEvents,
1833
+ Xr as filesystemPlugin,
1834
+ Jr as formatShortcut,
1835
+ Yr as getFileIcon,
1836
+ Zr as navigateToLineSchema,
1837
+ ea as notificationSchema,
1838
+ ta as onFilesystemChanged,
1839
+ De as openDataCatalogVisualization,
1840
+ ra as openFileSchema,
1841
+ aa as openPanelSchema,
1842
+ Be as postUiCommand,
1843
+ Lt as readDataCatalogRow,
1844
+ zt as resolveDataCatalogControlledQuery,
1845
+ Ie as resolveDataCatalogQuery,
1846
+ qt as resolveDataCatalogVisualizationState,
1847
+ Ia as toast,
1848
+ na as useActiveFile,
1849
+ la as useActivePanel,
1850
+ tr as useActivePanels,
1851
+ rr as useArtifactPanels,
1852
+ ar as useArtifactRouting,
1853
+ oa as useAutoOpenAgentFiles,
1854
+ sa as useCatalogRegistry,
1855
+ ca as useCatalogs,
1856
+ ia as useCommandRegistry,
1857
+ ua as useCommands,
1858
+ sr as useDataCatalogOpenVisualization,
1859
+ _t as useDataCatalogQuery,
1860
+ Bt as useDataCatalogVisualizationState,
1861
+ da as useDirtyFiles,
1862
+ pa as useDockviewApi,
1863
+ fa as useEditorLifecycle,
1864
+ ma as useEvent,
1865
+ bt as useExplorerState,
1866
+ ga as useHydrationComplete,
1867
+ ha as useKeyboardShortcuts,
1868
+ xa as useOpenPanels,
1869
+ ya as usePluginErrors,
1870
+ Ne as useRegistry,
1871
+ ba as useResetLayout,
1872
+ ht as useResponsiveSidebarCollapse,
1873
+ Ke as useSetSidebar,
1874
+ $e as useSidebarState,
1875
+ va as useSurfaceResolverRegistry,
1876
+ Sa as useTheme,
1877
+ Na as useThemePreference,
1878
+ ge as useViewportBreakpoint,
1879
+ Ca as useWorkspaceBridge,
1880
+ Ta as useWorkspaceChatPanel,
1881
+ Pa as useWorkspaceContext,
1882
+ ka as useWorkspaceContextOptional,
1883
+ Ea as userMeta
1884
+ };