@declarion/react 0.153.0 → 0.162.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.
@@ -1,693 +1,22 @@
1
- import { useUiPreferences as e } from "../../hooks/useUiPreferences.js";
2
- import { Rail as t } from "./Rail.js";
3
- import { Sidebar as n, buildSections as r } from "./Sidebar.js";
4
- import { TopBar as i } from "./TopBar.js";
5
- import { TabStrip as a } from "./TabStrip.js";
6
- import { DirtyTabsCloseDialog as o } from "./DirtyTabsCloseDialog.js";
7
- import { ImpersonationBanner as s } from "./ImpersonationBanner.js";
8
- import { ImpersonationFrame as c } from "./ImpersonationFrame.js";
9
- import { buildPendingTabClose as l, tabCloseRoute as u } from "./tab-close.js";
10
- import { CommandPalette as d } from "./CommandPalette.js";
11
- import { Icon as f } from "../primitives/Icons.js";
12
- import { IconBtn as p } from "../primitives/IconBtn.js";
13
- import { AgentChatPanel as ee } from "../agents/AgentChatPanel.js";
14
- import { ActionRunnerProvider as m } from "../actions/ActionRunner.js";
15
- import { useEmbed as te } from "../../embed/EmbedContext.js";
16
- import { useGlobalLinkInterceptor as ne } from "../../embed/useGlobalLinkInterceptor.js";
17
- import { EmbedLocationReporter as re } from "../../embed/EmbedLocationReporter.js";
18
- import { EmbedHistoryTracker as ie } from "../../embed/EmbedHistoryTracker.js";
19
- import { EmbedUnsavedGuard as ae } from "../../embed/EmbedUnsavedGuard.js";
20
- import { EmbedResizeReporter as oe } from "../../embed/EmbedResizeReporter.js";
21
- import { EmbedDirtyReporter as se } from "../../embed/EmbedDirtyReporter.js";
22
- import { useAuthStore as ce } from "../../stores/auth.js";
23
- import { useTabStore as h } from "../../stores/tabs.js";
24
- import { startListLayoutCrossTabSync as le, useListLayoutStore as ue } from "../../stores/list-layout.js";
25
- import { useTabNavigate as de } from "../../hooks/useTabNavigate.js";
26
- import { usePageStateRuntime as fe } from "../../hooks/usePageStateRuntime.js";
27
- import { UI_PREFERENCES_PARAM_CODE as pe, usePreferencesStore as g } from "../../stores/preferences.js";
28
- import { useSchema as me } from "../../hooks/useSchema.js";
29
- import { useSSE as he } from "../../hooks/useSSE.js";
30
- import { AgentOpenFollower as ge } from "../agents/AgentOpenFollower.js";
31
- import { useCurrentLocation as _e } from "../../hooks/useCurrentLocation.js";
32
- import { useImpersonation as ve } from "../../hooks/useImpersonation.js";
33
- import { useResponsiveMode as ye } from "../../hooks/useResponsiveMode.js";
34
- import { useBrandingIdentity as be } from "../../hooks/useBranding.js";
35
- import { useEffectiveParam as xe } from "../../hooks/useParams.js";
36
- import { useBrandingShell as Se } from "../../hooks/useBrandingChrome.js";
37
- import { loginPathForRedirectPath as Ce } from "../../api/auth-redirect.js";
38
- import { areaRoute as we, findNavMatch as Te } from "../../lib/schema-routing.js";
39
- import { useText as Ee } from "../../hooks/useText.js";
40
- import { builtInPageTitle as _, useTabTitle as v } from "../../hooks/useTabTitle.js";
41
- import { useActiveTabFollowsRoute as De } from "../../hooks/useActiveTabFollowsRoute.js";
42
- import { useDocumentTitle as Oe } from "../../hooks/useDocumentTitle.js";
43
- import { useCallback as y, useEffect as b, useMemo as ke, useRef as x, useState as S } from "react";
44
- import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
45
- import { Outlet as Ae, useLocation as je, useNavigate as Me } from "react-router";
1
+ import { useAuthStore as e } from "../../stores/auth.js";
2
+ import { useEmbed as t } from "../../embed/EmbedContext.js";
3
+ import { loginPathForRedirectPath as n } from "../../api/auth-redirect.js";
4
+ import { BlankScreen as r } from "../shared/BlankScreen.js";
5
+ import { loadLayout as i } from "../../lib/capabilityPrefetch.js";
6
+ import { useSSE as a } from "../../hooks/useSSE.js";
7
+ import { Suspense as o, lazy as s } from "react";
8
+ import { jsx as c } from "react/jsx-runtime";
9
+ import { Navigate as l, useLocation as u } from "react-router";
46
10
  // src/components/layout/Layout.tsx
47
- var E = "default";
48
- function D() {
49
- let r = Ee();
50
- ne(), fe();
51
- let { isAuthenticated: f, isLoading: p, user: _, activeTenant: v } = ce(), C = te(), D = Me(), O = de(), k = y((e) => O(e, { topLevel: !0 }), [O]), A = je(), { data: j } = me(), Re = ye(), M = g((e) => e.sidebar), ze = g((e) => e.tabsPosition), N = g((e) => e.aiSurface), Be = g((e) => e.colorScheme), { set: P } = e(), Ve = g((e) => e.hydrateFromParameter), F = xe(pe), He = F.source && F.source !== "public" ? _?.id : void 0, I = Se(), L = h((e) => e.tabs), Ue = h((e) => e.activeTabId), We = h((e) => e.closeTabs), Ge = h((e) => e.switchTab), [R, z] = S(E), [Ke, B] = S(!1), [qe, Je] = S("default"), [V, H] = S(!1), [Ye, U] = S(), [Xe, W] = S(!1), [Ze, G] = S(!1), Qe = x(null), $e = x(null), [K, q] = S(null), J = N !== "off" && I.isVisible("show_command_palette"), Y = N === "panel" || N === "both", et = N === "command" || N === "both", tt = be(), nt = tt?.ai_name?.trim() ?? "", X = Re.category === "phone" || Re.category === "tablet", rt = I.isVisible("show_topbar"), it = !X && I.isVisible("show_rail"), at = !X && I.isVisible("show_sidebar"), ot = !X && I.isVisible("show_tabs"), st = X && I.isVisible("show_sidebar"), ct = X && I.isVisible("show_tabs"), lt = Ne(!X && Y && V), ut = I.isVisible("show_tenant_switcher"), dt = I.isVisible("show_breadcrumbs"), ft = I.isVisible("show_theme_toggle"), Z = y((e = "default") => {
52
- J && (Je(e), B(!0));
53
- }, [J]), Q = y((e) => {
54
- if (e.length === 0) return;
55
- let t = h.getState(), n = !t.activeTabId || e.includes(t.activeTabId), r = We(e);
56
- if (!n) return;
57
- let i = u(r);
58
- D({
59
- pathname: i.pathname,
60
- search: i.search
61
- }, { replace: i.replace });
62
- }, [We, D]), $ = y((e, t) => {
63
- let n = h.getState(), r = l(n.tabs, n.activeTabId, e, t);
64
- r && (r.dirtyTabs.length > 0 ? q(r) : Q(r.ids));
65
- }, [Q]), pt = y(() => {
66
- q(null);
67
- }, []), mt = y(() => {
68
- K && (q(null), Q(K.cleanIds));
69
- }, [K, Q]), ht = y(() => {
70
- K && (q(null), Q(K.ids));
71
- }, [K, Q]);
72
- he();
73
- let gt = _e(), { isImpersonating: _t } = ve();
74
- b(() => {
75
- C.enabled || !p && !f && D(Ce(`${A.pathname}${A.search}${A.hash}`), { replace: !0 });
76
- }, [
77
- C.enabled,
78
- p,
79
- f,
80
- D,
81
- A.hash,
82
- A.pathname,
83
- A.search
84
- ]), b(() => {
85
- let e = _?.id || null, t = v?.id || null;
86
- h.getState().setScope(t, e), ue.getState().setScope(t, e), e && t && (h.getState().hydrate(), ue.getState().hydrate(), le());
87
- }, [_?.id, v?.id]), De(), Oe(), b(() => {
88
- Ve(F.value, He);
89
- }, [
90
- F.value,
91
- He,
92
- _?.id,
93
- Ve
94
- ]), b(() => {
95
- if (!j) return;
96
- let e = Te(j.navigation, j.screens, A.pathname)?.area;
97
- if (e) {
98
- z(e);
99
- return;
100
- }
101
- let t = R;
102
- if ((j.navigation ?? []).some((e) => (e.area || E) === t)) return;
103
- let n = (j.navigation ?? [])[0]?.area || E;
104
- n !== t && z(n);
105
- }, [
106
- j,
107
- A.pathname,
108
- R
109
- ]), b(() => {
110
- W(!1), G(!1);
111
- }, [A.pathname, A.search]), b(() => {
112
- let e = (e) => {
113
- let t = document.activeElement, n = !!t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable), r = e.metaKey || e.ctrlKey;
114
- r && e.key.toLowerCase() === "k" ? (e.preventDefault(), Z("default")) : r && e.key.toLowerCase() === "t" ? (e.preventDefault(), Z("new")) : r && e.key.toLowerCase() === "b" ? (e.preventDefault(), P("sidebar", M === "collapsed" ? "wide" : "collapsed")) : r && e.key.toLowerCase() === "w" ? (e.preventDefault(), $("current")) : r && e.key === "/" ? (e.preventDefault(), Y && H((e) => !e)) : e.key === "/" && !n ? (e.preventDefault(), Z("default")) : e.key === "Escape" && B(!1);
115
- };
116
- return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
117
- }, [
118
- Z,
119
- $,
120
- P,
121
- M,
122
- Y
123
- ]);
124
- let vt = ke(() => j ? Le(r, j.navigation, j.screens, A.pathname, L, k) : [], [
125
- r,
126
- j,
127
- A.pathname,
128
- L,
129
- k
130
- ]);
131
- if (p) return /* @__PURE__ */ w("div", {
132
- style: {
133
- display: "flex",
134
- height: "var(--app-height)",
135
- alignItems: "center",
136
- justifyContent: "center",
137
- background: "var(--background)",
138
- color: "var(--text-3)"
139
- },
140
- children: r("shell.loading", "Loading…")
11
+ var d = s(() => i().then((e) => ({ default: e.Layout })));
12
+ function f() {
13
+ let i = e((e) => e.isLoading), s = e((e) => e.isAuthenticated), f = t(), p = u();
14
+ return a(), i || f.enabled && !s ? /* @__PURE__ */ c(r, {}) : s ? /* @__PURE__ */ c(o, {
15
+ fallback: /* @__PURE__ */ c(r, {}),
16
+ children: /* @__PURE__ */ c(d, {})
17
+ }) : /* @__PURE__ */ c(l, {
18
+ to: n(`${p.pathname}${p.search}${p.hash}`),
19
+ replace: !0
141
20
  });
142
- if (!f) return null;
143
- let yt = (e) => {
144
- z(e);
145
- let t = j ? we(j, e) ?? void 0 : void 0;
146
- t && k(t);
147
- }, bt = (e) => {
148
- switch (e.type) {
149
- case "nav":
150
- e.route && k(e.route);
151
- break;
152
- case "new":
153
- e.route && k(e.route + "/new");
154
- break;
155
- case "open":
156
- e.route && k(e.route);
157
- break;
158
- case "ai":
159
- Y && (U(e.q), H(!0));
160
- break;
161
- case "ai-panel":
162
- Y && (U(void 0), H(!0));
163
- break;
164
- case "theme":
165
- P("colorScheme", Be === "dark" ? "light" : "dark");
166
- break;
167
- case "tab-close": e.tabCloseScope && $(e.tabCloseScope);
168
- }
169
- };
170
- return C.enabled ? /* @__PURE__ */ T(m, { children: [
171
- /* @__PURE__ */ w(re, {}),
172
- /* @__PURE__ */ w(ie, {}),
173
- /* @__PURE__ */ w(ae, {}),
174
- /* @__PURE__ */ w(se, {}),
175
- /* @__PURE__ */ w(oe, {}),
176
- /* @__PURE__ */ w("div", {
177
- id: "app-embed",
178
- className: "flex min-h-0 flex-col overflow-auto",
179
- style: { height: "var(--app-height)" },
180
- children: /* @__PURE__ */ w(Ae, {})
181
- })
182
- ] }) : /* @__PURE__ */ w(m, { children: /* @__PURE__ */ T("div", {
183
- id: "app",
184
- "data-sidebar": M,
185
- "data-mobile-shell": X ? "true" : void 0,
186
- style: Pe({
187
- mobileShell: X,
188
- showBanner: _t,
189
- showTopbar: rt,
190
- showRail: it,
191
- showSidebar: at,
192
- sidebarMode: M,
193
- showAssistant: lt
194
- }),
195
- children: [
196
- _t && /* @__PURE__ */ w(s, {}),
197
- /* @__PURE__ */ w(c, {}),
198
- rt && /* @__PURE__ */ w(i, {
199
- breadcrumbs: vt,
200
- onCrumbClick: (e) => e.onClick && e.onClick(),
201
- showNavButton: st,
202
- navButtonRef: Qe,
203
- onOpenNav: () => W(!0),
204
- showTabsButton: ct,
205
- tabsButtonRef: $e,
206
- onOpenTabs: () => G(!0),
207
- mobileTabCount: L.length,
208
- onCmdK: () => Z("default"),
209
- onToggleAI: () => Y && H((e) => !e),
210
- aiOpen: V,
211
- onOpenProfile: () => k("/profile"),
212
- onOpenPrefs: () => k("/preferences"),
213
- showTenantSwitcher: ut,
214
- showBreadcrumbs: dt,
215
- showThemeToggle: ft
216
- }),
217
- it && /* @__PURE__ */ w(t, {
218
- activeArea: R,
219
- onPick: yt,
220
- onToggleAI: () => Y && H((e) => !e),
221
- aiOpen: V,
222
- onCmdK: () => Z("default"),
223
- areas: j?.areas,
224
- branding: tt
225
- }),
226
- at && /* @__PURE__ */ w(n, { activeArea: R }),
227
- /* @__PURE__ */ T("main", {
228
- style: {
229
- gridArea: "main",
230
- overflow: "hidden",
231
- display: "flex",
232
- flexDirection: "column",
233
- minWidth: 0
234
- },
235
- children: [
236
- ot && ze === "top" && /* @__PURE__ */ w(a, {
237
- onNew: () => Z("new"),
238
- onCloseRequest: $
239
- }),
240
- /* @__PURE__ */ w("div", {
241
- style: {
242
- flex: 1,
243
- overflow: "auto",
244
- minHeight: 0,
245
- display: "flex",
246
- flexDirection: "column"
247
- },
248
- children: /* @__PURE__ */ w(Ae, {})
249
- }),
250
- ot && ze === "bottom" && /* @__PURE__ */ w(a, {
251
- onNew: () => Z("new"),
252
- onCloseRequest: $
253
- })
254
- ]
255
- }),
256
- J && /* @__PURE__ */ w(d, {
257
- open: Ke,
258
- mode: qe,
259
- onClose: () => B(!1),
260
- onAction: (e) => bt(e),
261
- schema: j,
262
- includeAI: et,
263
- aiName: nt
264
- }),
265
- /* @__PURE__ */ w(ge, {}),
266
- Y && V && /* @__PURE__ */ w(ee, {
267
- open: V,
268
- docked: lt,
269
- onClose: () => {
270
- H(!1), U(void 0);
271
- },
272
- title: nt,
273
- askOnOpen: Ye,
274
- context: gt ?? void 0
275
- }),
276
- st && /* @__PURE__ */ w(Fe, {
277
- open: Xe,
278
- activeArea: R,
279
- schema: j,
280
- returnFocusRef: Qe,
281
- onClose: () => W(!1),
282
- onNavigate: k
283
- }),
284
- ct && /* @__PURE__ */ w(Ie, {
285
- open: Ze,
286
- tabs: L,
287
- activeTabId: Ue,
288
- returnFocusRef: $e,
289
- onClose: () => G(!1),
290
- onSwitch: (e) => {
291
- Ge(e.id), D({
292
- pathname: e.pathname,
293
- search: e.search
294
- }, { replace: !1 }), G(!1);
295
- },
296
- onCloseTab: (e) => $("current", e)
297
- }),
298
- /* @__PURE__ */ w(o, {
299
- pending: K,
300
- onCancel: pt,
301
- onCloseClean: mt,
302
- onDiscardAll: ht
303
- })
304
- ]
305
- }) });
306
21
  }
307
- function Ne(e) {
308
- return b(() => {
309
- let t = document.documentElement.style;
310
- return t.setProperty("--assistant-open-w", e ? "var(--assistant-w)" : "0px"), () => {
311
- t.removeProperty("--assistant-open-w");
312
- };
313
- }, [e]), e;
314
- }
315
- function Pe({ mobileShell: e, showBanner: t, showTopbar: n, showRail: r, showSidebar: i, sidebarMode: a, showAssistant: o }) {
316
- let s = [
317
- ...t ? ["auto"] : [],
318
- ...n ? ["var(--topbar-h)"] : [],
319
- "minmax(0, 1fr)"
320
- ].join(" "), c = (e) => {
321
- let r = (t) => `"${e.map(() => t).join(" ")}"`;
322
- return [
323
- ...t ? [r("banner")] : [],
324
- ...n ? [r("topbar")] : [],
325
- `"${e.join(" ")}"`
326
- ].join(" ");
327
- };
328
- if (e) return {
329
- height: "var(--app-height)",
330
- display: "grid",
331
- gridTemplateRows: s,
332
- gridTemplateColumns: "minmax(0, 1fr)",
333
- gridTemplateAreas: c(["main"]),
334
- overflow: "hidden"
335
- };
336
- let l = [], u = [];
337
- return r && (l.push("var(--rail-w)"), u.push("rail")), i && (l.push(a === "collapsed" || a === "icon-only" ? "56px" : "var(--sidebar-w)"), u.push("sidebar")), l.push("minmax(0, 1fr)"), u.push("main"), o && (l.push("var(--assistant-w)"), u.push("assistant")), {
338
- height: "var(--app-height)",
339
- display: "grid",
340
- gridTemplateRows: s,
341
- gridTemplateColumns: l.join(" "),
342
- gridTemplateAreas: c(u),
343
- overflow: "hidden"
344
- };
345
- }
346
- var O = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex='-1'])";
347
- function k(e) {
348
- return e ? Array.from(e.querySelectorAll(O)).filter((e) => !e.hasAttribute("disabled") && e.getAttribute("aria-hidden") !== "true") : [];
349
- }
350
- function A(e) {
351
- k(e)[0]?.focus();
352
- }
353
- function j(e, t) {
354
- let n = k(e);
355
- if (n.length === 0) {
356
- t.preventDefault();
357
- return;
358
- }
359
- let r = n[0], i = n[n.length - 1], a = document.activeElement;
360
- t.shiftKey && a === r ? (t.preventDefault(), i.focus()) : !t.shiftKey && a === i && (t.preventDefault(), r.focus());
361
- }
362
- function Fe({ open: e, activeArea: t, schema: n, returnFocusRef: i, onClose: a, onNavigate: o }) {
363
- let s = Ee(), [c, l] = S(t), u = x(null);
364
- if (b(() => {
365
- e && l(t);
366
- }, [e, t]), b(() => {
367
- if (!e) return;
368
- let t = document.activeElement instanceof HTMLElement ? document.activeElement : null, n = i.current;
369
- requestAnimationFrame(() => A(u.current));
370
- let r = (e) => {
371
- e.key === "Escape" ? (e.preventDefault(), a()) : e.key === "Tab" && j(u.current, e);
372
- };
373
- return window.addEventListener("keydown", r), () => {
374
- window.removeEventListener("keydown", r), (n ?? t)?.focus();
375
- };
376
- }, [
377
- e,
378
- a,
379
- i
380
- ]), !e || !n) return null;
381
- let d = Array.from(new Set((n.navigation ?? []).map((e) => e.area || E)));
382
- d.length === 0 && d.push(E);
383
- let ee = (e) => {
384
- let t = n.areas?.find((t) => t.code === e);
385
- return s(t?.name) || (e === E ? s("shell.nav.title", "Navigation") : e);
386
- }, m = (e, t) => {
387
- let r = e.screen ? n.screens[e.screen] : void 0, i = [...e.items ?? [], ...e.children ?? []], c = s(e.name) || (r ? s(r.display?.name) : "");
388
- return /* @__PURE__ */ T("div", {
389
- style: {
390
- display: "flex",
391
- flexDirection: "column",
392
- gap: 2
393
- },
394
- children: [r?.route ? /* @__PURE__ */ T("button", {
395
- type: "button",
396
- onClick: () => {
397
- o(r.route), a();
398
- },
399
- style: {
400
- minHeight: 40,
401
- border: 0,
402
- borderRadius: "var(--radius-md)",
403
- background: "transparent",
404
- color: "var(--text-2)",
405
- display: "flex",
406
- alignItems: "center",
407
- gap: 8,
408
- padding: `0 10px 0 ${10 + t * 14}px`,
409
- fontSize: 13,
410
- textAlign: "left",
411
- cursor: "pointer"
412
- },
413
- children: [/* @__PURE__ */ w("span", { style: { width: 12 } }), /* @__PURE__ */ w("span", {
414
- style: {
415
- minWidth: 0,
416
- overflow: "hidden",
417
- textOverflow: "ellipsis",
418
- whiteSpace: "nowrap"
419
- },
420
- children: c || r.route
421
- })]
422
- }) : c ? /* @__PURE__ */ w("div", {
423
- style: {
424
- padding: `7px 10px 5px ${10 + t * 14}px`,
425
- color: "var(--text-3)",
426
- fontSize: 10.5,
427
- fontWeight: 700,
428
- letterSpacing: "0.08em",
429
- textTransform: "uppercase"
430
- },
431
- children: c
432
- }) : null, i.map((e) => m(e, t + 1))]
433
- }, `${t}-${e.screen ?? c}`);
434
- };
435
- return /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w("div", {
436
- "data-testid": "mobile-nav-backdrop",
437
- onClick: a,
438
- style: {
439
- position: "fixed",
440
- inset: 0,
441
- background: "var(--scrim-lite)",
442
- zIndex: 120
443
- }
444
- }), /* @__PURE__ */ T("aside", {
445
- ref: u,
446
- role: "dialog",
447
- "aria-modal": "true",
448
- "aria-label": s("shell.nav.title", "Navigation"),
449
- "data-testid": "mobile-nav-drawer",
450
- style: {
451
- position: "fixed",
452
- top: 0,
453
- bottom: 0,
454
- left: 0,
455
- width: 320,
456
- maxWidth: "calc(100vw - var(--safe-area-right) - 24px)",
457
- background: "var(--sidebar)",
458
- color: "var(--sidebar-fg)",
459
- borderRight: "1px solid var(--border)",
460
- boxShadow: "var(--shadow-lg)",
461
- zIndex: 121,
462
- display: "flex",
463
- flexDirection: "column",
464
- padding: "calc(10px + var(--safe-area-top)) 10px calc(10px + var(--safe-area-bottom)) calc(10px + var(--safe-area-left))",
465
- boxSizing: "border-box",
466
- overflow: "hidden"
467
- },
468
- children: [/* @__PURE__ */ T("div", {
469
- style: {
470
- display: "flex",
471
- alignItems: "center",
472
- gap: 8,
473
- minHeight: 36,
474
- padding: "0 2px 8px"
475
- },
476
- children: [/* @__PURE__ */ w("strong", {
477
- style: {
478
- fontSize: 13,
479
- flex: 1
480
- },
481
- children: s("shell.nav.title", "Navigation")
482
- }), /* @__PURE__ */ w(p, {
483
- icon: /* @__PURE__ */ w(f.x, { size: 15 }),
484
- title: s("shell.nav.close", "Close navigation"),
485
- onClick: a
486
- })]
487
- }), /* @__PURE__ */ w("nav", {
488
- style: {
489
- overflowY: "auto",
490
- overscrollBehavior: "contain",
491
- display: "flex",
492
- flexDirection: "column",
493
- gap: 6
494
- },
495
- children: d.map((e) => {
496
- let i = c === e, a = r(s, n.navigation ?? [], e);
497
- return /* @__PURE__ */ T("section", { children: [/* @__PURE__ */ T("button", {
498
- type: "button",
499
- onClick: () => l(i ? "" : e),
500
- style: {
501
- width: "100%",
502
- minHeight: 42,
503
- border: "1px solid var(--border)",
504
- borderRadius: "var(--radius-md)",
505
- background: e === t ? "var(--sidebar-active)" : "var(--sidebar-hover)",
506
- color: "var(--sidebar-fg)",
507
- display: "flex",
508
- alignItems: "center",
509
- gap: 8,
510
- padding: "0 10px",
511
- fontSize: 13,
512
- fontWeight: 650,
513
- cursor: "pointer"
514
- },
515
- "aria-expanded": i,
516
- children: [/* @__PURE__ */ w("span", {
517
- style: {
518
- flex: 1,
519
- textAlign: "left"
520
- },
521
- children: ee(e)
522
- }), w(i ? f.down : f.right, { size: 13 })]
523
- }), i && /* @__PURE__ */ w("div", {
524
- style: { padding: "6px 0 4px" },
525
- children: a.flatMap((t) => [t.title ? /* @__PURE__ */ w("div", {
526
- style: {
527
- padding: "8px 10px 4px",
528
- color: "var(--text-3)",
529
- fontSize: 10,
530
- fontWeight: 700,
531
- letterSpacing: "0.08em",
532
- textTransform: "uppercase"
533
- },
534
- children: t.title
535
- }, `${e}-${t.title}`) : null, ...t.items.map((e) => m(e, 0))])
536
- })] }, e);
537
- })
538
- })]
539
- })] });
540
- }
541
- function Ie({ open: e, tabs: t, activeTabId: n, returnFocusRef: r, onClose: i, onSwitch: a, onCloseTab: o }) {
542
- let s = Ee(), c = v(), l = x(null);
543
- return b(() => {
544
- if (!e) return;
545
- let t = document.activeElement instanceof HTMLElement ? document.activeElement : null, n = r.current;
546
- requestAnimationFrame(() => A(l.current));
547
- let a = (e) => {
548
- e.key === "Escape" ? (e.preventDefault(), i()) : e.key === "Tab" && j(l.current, e);
549
- };
550
- return window.addEventListener("keydown", a), () => {
551
- window.removeEventListener("keydown", a), (n ?? t)?.focus();
552
- };
553
- }, [
554
- e,
555
- i,
556
- r
557
- ]), e ? /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w("div", {
558
- "data-testid": "mobile-tabs-backdrop",
559
- onClick: i,
560
- style: {
561
- position: "fixed",
562
- inset: 0,
563
- background: "var(--scrim-lite)",
564
- zIndex: 122
565
- }
566
- }), /* @__PURE__ */ T("section", {
567
- ref: l,
568
- role: "dialog",
569
- "aria-modal": "true",
570
- "aria-label": s("shell.tabs.open_tabs", "Open tabs"),
571
- "data-testid": "mobile-tabs-menu",
572
- style: {
573
- position: "fixed",
574
- top: "calc(var(--topbar-h) + var(--safe-area-top) + 8px)",
575
- right: "calc(var(--safe-area-right) + 10px)",
576
- width: 320,
577
- maxWidth: "calc(100vw - var(--safe-area-left) - var(--safe-area-right) - 20px)",
578
- maxHeight: "calc(var(--app-height) - var(--topbar-h) - var(--safe-area-top) - var(--safe-area-bottom) - 16px)",
579
- overflowY: "auto",
580
- overscrollBehavior: "contain",
581
- background: "var(--surface)",
582
- border: "1px solid var(--border)",
583
- borderRadius: "var(--radius-md)",
584
- boxShadow: "var(--shadow-lg)",
585
- zIndex: 123,
586
- padding: 6,
587
- boxSizing: "border-box"
588
- },
589
- children: [/* @__PURE__ */ T("div", {
590
- style: {
591
- display: "flex",
592
- alignItems: "center",
593
- gap: 8,
594
- padding: "4px 4px 8px"
595
- },
596
- children: [/* @__PURE__ */ w("strong", {
597
- style: {
598
- flex: 1,
599
- fontSize: 13
600
- },
601
- children: s("shell.tabs.open_tabs", "Open tabs")
602
- }), /* @__PURE__ */ w(p, {
603
- icon: /* @__PURE__ */ w(f.x, { size: 14 }),
604
- title: s("shell.tabs.close_menu", "Close tabs menu"),
605
- onClick: i
606
- })]
607
- }), t.length === 0 ? /* @__PURE__ */ w("div", {
608
- style: {
609
- padding: 10,
610
- color: "var(--text-3)",
611
- fontSize: 12
612
- },
613
- children: s("shell.tabs.none_open", "No open tabs")
614
- }) : t.map((e) => /* @__PURE__ */ T("div", {
615
- style: {
616
- display: "grid",
617
- gridTemplateColumns: "minmax(0, 1fr) auto",
618
- gap: 4,
619
- alignItems: "center",
620
- borderRadius: "var(--radius-md)",
621
- background: e.id === n ? "var(--surface-3)" : "transparent"
622
- },
623
- children: [/* @__PURE__ */ T("button", {
624
- type: "button",
625
- onClick: () => a(e),
626
- style: {
627
- minHeight: 38,
628
- border: 0,
629
- background: "transparent",
630
- color: "var(--text-2)",
631
- display: "flex",
632
- alignItems: "center",
633
- gap: 8,
634
- minWidth: 0,
635
- padding: "0 8px",
636
- textAlign: "left",
637
- cursor: "pointer"
638
- },
639
- children: [/* @__PURE__ */ w(f.layers, { size: 13 }), /* @__PURE__ */ w("span", {
640
- style: {
641
- overflow: "hidden",
642
- textOverflow: "ellipsis",
643
- whiteSpace: "nowrap"
644
- },
645
- children: c(e)
646
- })]
647
- }), e.closable && /* @__PURE__ */ w(p, {
648
- icon: /* @__PURE__ */ w(f.x, { size: 12 }),
649
- title: s("shell.tabs.close_named", "Close {title}", { title: c(e) }),
650
- onClick: () => o(e.id)
651
- })]
652
- }, e.id))]
653
- })] }) : null;
654
- }
655
- function Le(e, t, n, r, i, a) {
656
- let o = Te(t, n, r)?.chain;
657
- if (!o || o.length === 0) {
658
- let t = Object.values(n).find((e) => e.route === r);
659
- if (t?.display?.name) return [{
660
- label: e(t.display.name),
661
- icon: t.display.icon,
662
- isLast: !0
663
- }];
664
- let i = _(e, r);
665
- return i ? [{
666
- label: i,
667
- isLast: !0
668
- }] : [];
669
- }
670
- let s = [];
671
- for (let t = 0; t < o.length; t++) {
672
- let i = o[t], c = t === o.length - 1, l = i.screen ? n[i.screen] : void 0;
673
- s.push({
674
- label: e(i.name) || i.screen || "",
675
- icon: i.icon,
676
- onClick: l ? () => {
677
- a(l.route);
678
- } : void 0,
679
- isLast: c && (!l || l.route === r)
680
- });
681
- }
682
- let c = o[o.length - 1], l = c.screen ? n[c.screen] : void 0;
683
- if (l && r !== l.route && r.startsWith(l.route + "/")) {
684
- let t = i.find((e) => e.pathname === r);
685
- s.push({
686
- label: t?.title || e("shell.crumbs.record", "Record"),
687
- icon: "file",
688
- isLast: !0
689
- });
690
- }
691
- return s;
692
- }
693
- export { D as Layout, Le as buildCrumbs };
22
+ export { f as Layout };