@tailor-platform/app-shell 0.17.1 → 0.19.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.
@@ -0,0 +1,1316 @@
1
+ import { jsx as a, jsxs as c, Fragment as S } from "react/jsx-runtime";
2
+ import { AlertCircle as G, Table as ht, XIcon as bt, PanelLeftIcon as ft, ChevronRight as I, SunIcon as gt } from "lucide-react";
3
+ import * as g from "react";
4
+ import { createContext as O, useContext as $, useState as j, useMemo as U, useEffect as L } from "react";
5
+ import { useRouteError as pt, isRouteErrorResponse as vt, Outlet as H, NavLink as xt, redirect as at, Navigate as yt, createMemoryRouter as Tt, createBrowserRouter as Nt, RouterProvider as Ct, useHref as St, Link as kt, useLocation as st, useMatch as Bt } from "react-router";
6
+ import { Link as Ze, useLocation as ta, useNavigate as ea, useParams as aa, useRouteError as sa, useSearchParams as ra } from "react-router";
7
+ import { Slot as R } from "@radix-ui/react-slot";
8
+ import { cva as rt } from "class-variance-authority";
9
+ import { clsx as Rt } from "clsx";
10
+ import { twMerge as Et } from "tailwind-merge";
11
+ import { capitalCase as k } from "change-case";
12
+ import { Toaster as At } from "sonner";
13
+ import * as W from "@radix-ui/react-collapsible";
14
+ import "@radix-ui/react-separator";
15
+ import * as x from "@radix-ui/react-dialog";
16
+ import * as N from "@radix-ui/react-tooltip";
17
+ import { print as Lt } from "graphql";
18
+ import { createAuthClient as Mt } from "@tailor-platform/auth-browser-client";
19
+ function u(...t) {
20
+ return Et(Rt(t));
21
+ }
22
+ const _t = rt(
23
+ "astw:inline-flex astw:items-center astw:justify-center astw:gap-2 astw:whitespace-nowrap astw:rounded-md astw:text-sm astw:font-medium astw:transition-all astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:[&_svg]:pointer-events-none astw:[&_svg:not([class*='size-'])]:size-4 astw:shrink-0 astw:[&_svg]:shrink-0 astw:outline-none astw:focus-visible:border-ring astw:focus-visible:ring-ring/50 astw:focus-visible:ring-[3px] astw:aria-invalid:ring-destructive/20 astw:dark:aria-invalid:ring-destructive/40 astw:aria-invalid:border-destructive",
24
+ {
25
+ variants: {
26
+ variant: {
27
+ default: "astw:bg-primary astw:text-primary-foreground astw:shadow-xs astw:hover:bg-primary/90",
28
+ destructive: "astw:bg-destructive astw:text-white astw:shadow-xs astw:hover:bg-destructive/90 astw:focus-visible:ring-destructive/20 astw:dark:focus-visible:ring-destructive/40 astw:dark:bg-destructive/60",
29
+ outline: "astw:border astw:bg-background astw:shadow-xs astw:hover:bg-accent astw:hover:text-accent-foreground astw:dark:bg-input/30 astw:dark:border-input astw:dark:hover:bg-input/50",
30
+ secondary: "astw:bg-secondary astw:text-secondary-foreground astw:shadow-xs astw:hover:bg-secondary/80",
31
+ ghost: "astw:hover:bg-accent astw:hover:text-accent-foreground astw:dark:hover:bg-accent/50",
32
+ link: "astw:text-primary astw:underline-offset-4 astw:hover:underline"
33
+ },
34
+ size: {
35
+ default: "astw:h-9 astw:px-4 astw:py-2 astw:has-[>svg]:px-3",
36
+ sm: "astw:h-8 astw:rounded-md astw:gap-1.5 astw:px-3 astw:has-[>svg]:px-2.5",
37
+ lg: "astw:h-10 astw:rounded-md astw:px-6 astw:has-[>svg]:px-4",
38
+ icon: "astw:size-9"
39
+ }
40
+ },
41
+ defaultVariants: {
42
+ variant: "default",
43
+ size: "default"
44
+ }
45
+ }
46
+ );
47
+ function B({
48
+ className: t,
49
+ variant: e,
50
+ size: s,
51
+ asChild: r = !1,
52
+ ...n
53
+ }) {
54
+ return /* @__PURE__ */ a(
55
+ r ? R : "button",
56
+ {
57
+ "data-slot": "button",
58
+ className: u(_t({ variant: e, size: s, className: t })),
59
+ ...n
60
+ }
61
+ );
62
+ }
63
+ const C = "en", Pt = () => {
64
+ try {
65
+ if (typeof navigator > "u")
66
+ return C;
67
+ const t = navigator.languages?.[0] ?? navigator.language;
68
+ return t ? new Intl.Locale(t).language : C;
69
+ } catch {
70
+ return C;
71
+ }
72
+ }, F = (t) => (e, s) => e ? typeof e == "string" ? e : e(t) ?? s : s, nt = (t) => {
73
+ const e = F(t);
74
+ return (s, r) => e(s, typeof s == "string" ? s : k(r));
75
+ }, It = () => {
76
+ const { configurations: t } = y(), e = F(t.locale);
77
+ return (s, r) => e(s, r);
78
+ }, zt = (t) => {
79
+ const e = (s) => (r) => t[s ?? C]?.[r] ?? t.en[r];
80
+ return {
81
+ /**
82
+ * Hook to get the translated label resolver function.
83
+ *
84
+ * @example
85
+ * ```tsx
86
+ * import { useT } from "./i18n-labels";
87
+ *
88
+ * const YourComponent = () => {
89
+ * const t = useT();
90
+ *
91
+ * return (
92
+ * <div>
93
+ * {t("staticLabel")}
94
+ * {t("dynamicLabel", { name: "John" })}
95
+ * </div>
96
+ * );
97
+ * }
98
+ * ```
99
+ */
100
+ useT: () => {
101
+ const { configurations: s } = y(), r = e(s.locale);
102
+ return ((n, ...o) => {
103
+ const l = r(n);
104
+ return typeof l == "function" ? l(o[0]) : l;
105
+ });
106
+ },
107
+ /**
108
+ * A function to get the translater for a specific label key.
109
+ * This is expected to be used in `meta.title` in module/resource definitions.
110
+ *
111
+ * Note: When using dynamic labels with props in meta.title, the props are
112
+ * bound at definition time (when calling labels.t), not at render time.
113
+ *
114
+ * @example
115
+ * ```tsx
116
+ * import { labels } from "./i18n-labels";
117
+ *
118
+ * const resource = defineResource({
119
+ * path: "example",
120
+ * meta: {
121
+ * title: labels.t("someLabelKey"),
122
+ * // or with props for dynamic labels
123
+ * title: labels.t("dynamicKey", { id: "123" }),
124
+ * },
125
+ * component: ExampleComponent,
126
+ * });
127
+ * ```
128
+ */
129
+ t: (s, ...r) => (n) => {
130
+ const o = e(n)(s);
131
+ return typeof o == "function" ? o(r[0]) : o;
132
+ }
133
+ };
134
+ }, Dt = zt({
135
+ en: {
136
+ error404Title: "404 Not Found",
137
+ error404Body: "The page you requested could not be found.",
138
+ goBack: "Go Back",
139
+ errorUnexpected: "An unexpected error occurred",
140
+ errorTitle: "Something went wrong",
141
+ tryAgain: "Try Again",
142
+ welcomeTitle: "Welcome to AppShell",
143
+ welcomeBody: "Add your GraphQL resources from configuration at first!",
144
+ settings: "Settings",
145
+ toggle: "Toggle",
146
+ toggleSidebar: "Toggle Sidebar",
147
+ sidebar: "Sidebar",
148
+ sidebarDesc: "Displays the mobile sidebar.",
149
+ close: "Close",
150
+ more: "More"
151
+ },
152
+ ja: {
153
+ error404Title: "404 ページが見つかりません",
154
+ error404Body: "お探しのページは存在しません。",
155
+ goBack: "戻る",
156
+ errorUnexpected: "予期しないエラーが発生しました",
157
+ errorTitle: "問題が発生しました",
158
+ tryAgain: "再試行",
159
+ welcomeTitle: "AppShell へようこそ",
160
+ welcomeBody: "まず設定から GraphQL リソースを追加してください。",
161
+ settings: "設定",
162
+ toggle: "切り替え",
163
+ toggleSidebar: "サイドバーを切り替え",
164
+ sidebar: "サイドバー",
165
+ sidebarDesc: "モバイル用サイドバーを表示します。",
166
+ close: "閉じる",
167
+ more: "その他"
168
+ }
169
+ }), E = Dt.useT, M = () => {
170
+ const t = pt(), e = E(), s = {
171
+ role: "alert",
172
+ "aria-label": "default-error-boundary"
173
+ };
174
+ if (vt(t) && t.status === 404)
175
+ return /* @__PURE__ */ a("div", { ...s, className: "astw:p-6", children: /* @__PURE__ */ c("div", { className: "astw:flex astw:items-start astw:gap-4", children: [
176
+ /* @__PURE__ */ a(G, { className: "astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5" }),
177
+ /* @__PURE__ */ c("div", { children: [
178
+ /* @__PURE__ */ a("h1", { className: "astw:font-semibold astw:text-lg", children: e("error404Title") }),
179
+ /* @__PURE__ */ a("p", { className: "astw:text-sm astw:text-muted-foreground astw:mt-1", children: e("error404Body") }),
180
+ /* @__PURE__ */ a(
181
+ B,
182
+ {
183
+ variant: "outline",
184
+ size: "sm",
185
+ className: "astw:mt-4",
186
+ onClick: () => window.history.back(),
187
+ children: e("goBack")
188
+ }
189
+ )
190
+ ] })
191
+ ] }) });
192
+ const r = t instanceof Error ? t.message : e("errorUnexpected");
193
+ return /* @__PURE__ */ a("div", { ...s, className: "astw:p-6", children: /* @__PURE__ */ c("div", { className: "astw:flex astw:items-start astw:gap-4", children: [
194
+ /* @__PURE__ */ a(G, { className: "astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5" }),
195
+ /* @__PURE__ */ c("div", { children: [
196
+ /* @__PURE__ */ a("h1", { className: "astw:font-semibold astw:text-lg", children: e("errorTitle") }),
197
+ /* @__PURE__ */ a("p", { className: "astw:text-sm astw:text-muted-foreground astw:mt-1", children: r }),
198
+ /* @__PURE__ */ a(
199
+ B,
200
+ {
201
+ variant: "outline",
202
+ size: "sm",
203
+ className: "astw:mt-4",
204
+ onClick: () => window.location.reload(),
205
+ children: e("tryAgain")
206
+ }
207
+ )
208
+ ] })
209
+ ] }) });
210
+ }, Ot = (t) => ({
211
+ modules: t.modules,
212
+ settingsResources: t.settingsResources ?? [],
213
+ errorBoundary: t.errorBoundary ?? /* @__PURE__ */ a(M, {}),
214
+ basePath: t.basePath,
215
+ locale: t.locale ?? Pt()
216
+ }), ot = O({
217
+ navItems: [],
218
+ configurations: {
219
+ modules: [],
220
+ settingsResources: [],
221
+ errorBoundary: /* @__PURE__ */ a(M, {}),
222
+ locale: C
223
+ }
224
+ }), y = () => $(ot), $t = () => {
225
+ const t = E();
226
+ return /* @__PURE__ */ c(S, { children: [
227
+ /* @__PURE__ */ a("p", { className: "astw:font-semibold astw:leading-none astw:tracking-tight", children: t("welcomeTitle") }),
228
+ /* @__PURE__ */ a("p", { className: "pt-4", children: t("welcomeBody") })
229
+ ] });
230
+ }, V = () => /* @__PURE__ */ c(S, { children: [
231
+ /* @__PURE__ */ a(H, {}),
232
+ /* @__PURE__ */ a(At, {})
233
+ ] }), jt = () => {
234
+ const { configurations: t } = y(), e = E(), s = It();
235
+ return /* @__PURE__ */ c("div", { className: "astw:mx-auto astw:flex-col astw:flex astw:md:flex-row astw:max-w-5xl astw:gap-[10px] astw:w-full", children: [
236
+ /* @__PURE__ */ a("div", { children: /* @__PURE__ */ c("nav", { className: "astw:bg-card astw:md:w-xs astw:rounded-md astw:border astw:p-3 astw:shadow-xs", children: [
237
+ /* @__PURE__ */ a("h2", { className: "astw:text-sm astw:leading-[36px] astw:mb-2 astw:font-bold ", children: e("settings") }),
238
+ /* @__PURE__ */ a("ul", { className: "astw:flex astw:flex-col astw:gap-1", children: t.settingsResources.map((r) => /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(xt, { to: `./${r.path}`, children: ({ isActive: n }) => /* @__PURE__ */ c(
239
+ B,
240
+ {
241
+ variant: n ? "secondary" : "ghost",
242
+ className: "astw:w-full astw:justify-start",
243
+ children: [
244
+ r.meta.icon,
245
+ s(r.meta.title, r.path)
246
+ ]
247
+ }
248
+ ) }) }, r.path)) })
249
+ ] }) }),
250
+ /* @__PURE__ */ a("section", { className: "astw:bg-card astw:flex-1 astw:rounded-md astw:border astw:shadow-xs", children: /* @__PURE__ */ a(H, {}) })
251
+ ] });
252
+ };
253
+ function Fe(t) {
254
+ return {
255
+ redirectTo: t
256
+ };
257
+ }
258
+ function z(t) {
259
+ return typeof t == "object" && t !== null && "redirectTo" in t;
260
+ }
261
+ const it = (t, e) => () => {
262
+ const { configurations: s } = y(), { metaTitle: r, fallbackTitle: n } = t, l = F(s.locale)(r, n);
263
+ return e(l);
264
+ };
265
+ function Qe(t) {
266
+ const { path: e, meta: s, component: r, resources: n, errorBoundary: o } = t, l = s?.title ?? k(e), d = k(e), i = z(r) ? {
267
+ // Use loader for redirects
268
+ component: () => null,
269
+ loader: () => at(r.redirectTo)
270
+ } : {
271
+ // Regular component with locale-aware title
272
+ component: it(
273
+ { metaTitle: l, fallbackTitle: d },
274
+ (w) => r({ title: w, resources: n })
275
+ )
276
+ };
277
+ return {
278
+ path: e,
279
+ type: "component",
280
+ _type: "module",
281
+ ...i,
282
+ meta: {
283
+ title: l,
284
+ ...s?.breadcrumbTitle !== void 0 ? { breadcrumbTitle: s.breadcrumbTitle } : {},
285
+ ...s,
286
+ menuItemClickable: !z(r),
287
+ icon: t.meta?.icon
288
+ },
289
+ resources: n,
290
+ errorBoundary: o || /* @__PURE__ */ a(M, {})
291
+ };
292
+ }
293
+ function Ke(t) {
294
+ const { path: e, component: s, subResources: r, meta: n, errorBoundary: o } = t, l = n?.title ?? k(e), d = k(e);
295
+ return {
296
+ _type: "resource",
297
+ type: "component",
298
+ path: e,
299
+ meta: {
300
+ title: l,
301
+ icon: n?.icon,
302
+ ...n?.breadcrumbTitle !== void 0 ? { breadcrumbTitle: n.breadcrumbTitle } : {}
303
+ },
304
+ component: it(
305
+ { metaTitle: l, fallbackTitle: d },
306
+ (i) => s({ title: i, resources: r })
307
+ ),
308
+ subResources: r,
309
+ errorBoundary: o ?? /* @__PURE__ */ a(M, {})
310
+ };
311
+ }
312
+ const Q = (t) => () => /* @__PURE__ */ a(S, { children: t }), lt = (t, e, s) => {
313
+ const r = t.errorBoundary || s, n = {
314
+ index: !0,
315
+ Component: t.component,
316
+ ...t.loader && { loader: t.loader }
317
+ };
318
+ return {
319
+ path: t.path,
320
+ ...t.errorBoundary && {
321
+ ErrorBoundary: Q(t.errorBoundary)
322
+ },
323
+ ...e && e.length > 0 ? {
324
+ children: [
325
+ n,
326
+ ...e.map(
327
+ (o) => lt(o, o.subResources, r)
328
+ )
329
+ ]
330
+ } : {
331
+ children: [n]
332
+ }
333
+ };
334
+ }, Ut = (t) => t.map(
335
+ (e) => lt(e, e.resources, e.errorBoundary)
336
+ ), Ht = ({
337
+ modules: t,
338
+ settingsResources: e,
339
+ rootComponent: s
340
+ }) => {
341
+ const r = z(s) ? {
342
+ index: !0,
343
+ loader: () => at(s.redirectTo)
344
+ } : {
345
+ index: !0,
346
+ Component: s ?? $t
347
+ }, n = e.length > 0 ? [
348
+ {
349
+ path: "settings",
350
+ index: !0,
351
+ Component: () => /* @__PURE__ */ a(
352
+ yt,
353
+ {
354
+ to: e[0].path,
355
+ relative: "path",
356
+ replace: !0
357
+ }
358
+ )
359
+ },
360
+ {
361
+ path: "settings",
362
+ Component: jt,
363
+ children: e.map((o) => ({
364
+ path: o.path,
365
+ Component: o.component,
366
+ ...o.errorBoundary && {
367
+ ErrorBoundary: Q(o.errorBoundary)
368
+ }
369
+ }))
370
+ }
371
+ ] : [];
372
+ return [
373
+ r,
374
+ {
375
+ children: Ut(t)
376
+ },
377
+ ...n,
378
+ {
379
+ path: "*",
380
+ loader: () => {
381
+ throw new Response("Not Found", { status: 404 });
382
+ }
383
+ }
384
+ ];
385
+ }, Wt = (t) => {
386
+ const { configurations: e } = y(), { rootComponent: s, children: r } = t, n = Ht({
387
+ modules: e.modules,
388
+ settingsResources: e.settingsResources,
389
+ rootComponent: s
390
+ }), o = e.errorBoundary, l = [
391
+ {
392
+ element: r,
393
+ children: o ? [
394
+ {
395
+ element: /* @__PURE__ */ a(H, {}),
396
+ ErrorBoundary: Q(o),
397
+ children: n
398
+ }
399
+ ] : n
400
+ }
401
+ ], d = e.basePath ? "/" + e.basePath : void 0, i = t.memory ? Tt(l, {
402
+ basename: d,
403
+ ...t.initialEntries ? { initialEntries: t.initialEntries } : {}
404
+ }) : Nt(l, {
405
+ basename: d
406
+ });
407
+ return /* @__PURE__ */ a(Ct, { router: i });
408
+ }, Ft = {
409
+ resolvedTheme: "light",
410
+ theme: "system",
411
+ setTheme: () => null
412
+ }, dt = O(Ft);
413
+ function Qt({
414
+ children: t,
415
+ storageKey: e,
416
+ defaultTheme: s = "system",
417
+ ...r
418
+ }) {
419
+ const [n, o] = j(
420
+ () => localStorage.getItem(e) || s
421
+ ), l = U(() => n !== "system" ? n : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", [n]);
422
+ L(() => {
423
+ const i = window.document.documentElement;
424
+ i.classList.remove("light", "dark"), i.classList.add(l);
425
+ }, [l]);
426
+ const d = {
427
+ resolvedTheme: l,
428
+ theme: n,
429
+ setTheme: (i) => {
430
+ localStorage.setItem(e, i), o(i);
431
+ }
432
+ };
433
+ return /* @__PURE__ */ a(dt.Provider, { ...r, value: d, children: t });
434
+ }
435
+ const Kt = () => {
436
+ const t = $(dt);
437
+ if (t === void 0)
438
+ throw new Error("useTheme must be used within a ThemeProvider");
439
+ return t;
440
+ }, Ge = (t) => {
441
+ const [e, s] = j(!1);
442
+ L(function() {
443
+ s(!0);
444
+ }, []);
445
+ const r = Ot(t), n = U(() => {
446
+ const o = t.modules, l = nt(r.locale);
447
+ return o.map((d) => {
448
+ const i = l(d.meta.title, d.path), w = d.resources.map((m) => ({
449
+ title: l(m.meta.title, m.path),
450
+ url: `${d.path}/${m.path}`
451
+ }));
452
+ return {
453
+ title: i,
454
+ url: d.meta.menuItemClickable ? d.path : void 0,
455
+ clickable: d.component,
456
+ icon: d.meta.icon || /* @__PURE__ */ a(ht, {}),
457
+ isActive: !0,
458
+ items: w
459
+ };
460
+ });
461
+ }, [t.modules, r.locale]);
462
+ return e ? /* @__PURE__ */ a(
463
+ ot.Provider,
464
+ {
465
+ value: {
466
+ title: t.title,
467
+ icon: t.icon,
468
+ configurations: r,
469
+ navItems: n
470
+ },
471
+ children: /* @__PURE__ */ a(Qt, { defaultTheme: "system", storageKey: "appshell-ui-theme", children: /* @__PURE__ */ a(Wt, { rootComponent: t.rootComponent, children: t.children }) })
472
+ }
473
+ ) : null;
474
+ };
475
+ function Gt({
476
+ ...t
477
+ }) {
478
+ return /* @__PURE__ */ a(W.Root, { "data-slot": "collapsible", ...t });
479
+ }
480
+ function q({
481
+ ...t
482
+ }) {
483
+ return /* @__PURE__ */ a(
484
+ W.CollapsibleTrigger,
485
+ {
486
+ "data-slot": "collapsible-trigger",
487
+ ...t
488
+ }
489
+ );
490
+ }
491
+ function Vt({
492
+ ...t
493
+ }) {
494
+ return /* @__PURE__ */ a(
495
+ W.CollapsibleContent,
496
+ {
497
+ "data-slot": "collapsible-content",
498
+ ...t
499
+ }
500
+ );
501
+ }
502
+ const P = 768;
503
+ function qt() {
504
+ const [t, e] = g.useState(
505
+ void 0
506
+ );
507
+ return g.useEffect(() => {
508
+ const s = window.matchMedia(`(max-width: ${P - 1}px)`), r = () => {
509
+ e(window.innerWidth < P);
510
+ };
511
+ return s.addEventListener("change", r), e(window.innerWidth < P), () => s.removeEventListener("change", r);
512
+ }, []), !!t;
513
+ }
514
+ function Xt({ ...t }) {
515
+ return /* @__PURE__ */ a(x.Root, { "data-slot": "sheet", ...t });
516
+ }
517
+ function Yt({
518
+ ...t
519
+ }) {
520
+ return /* @__PURE__ */ a(x.Portal, { "data-slot": "sheet-portal", ...t });
521
+ }
522
+ function Jt({
523
+ className: t,
524
+ ...e
525
+ }) {
526
+ return /* @__PURE__ */ a(
527
+ x.Overlay,
528
+ {
529
+ "data-slot": "sheet-overlay",
530
+ className: u(
531
+ "astw:data-[state=open]:animate-in astw:data-[state=closed]:animate-out astw:data-[state=closed]:fade-out-0 astw:data-[state=open]:fade-in-0 astw:fixed astw:inset-0 astw:z-50 astw:bg-black/50",
532
+ t
533
+ ),
534
+ ...e
535
+ }
536
+ );
537
+ }
538
+ function Zt({
539
+ className: t,
540
+ children: e,
541
+ side: s = "right",
542
+ ...r
543
+ }) {
544
+ return /* @__PURE__ */ c(Yt, { children: [
545
+ /* @__PURE__ */ a(Jt, {}),
546
+ /* @__PURE__ */ c(
547
+ x.Content,
548
+ {
549
+ "data-slot": "sheet-content",
550
+ className: u(
551
+ "astw:bg-background astw:data-[state=open]:animate-in astw:data-[state=closed]:animate-out astw:fixed astw:z-50 astw:flex astw:flex-col astw:gap-4 astw:shadow-lg astw:transition astw:ease-in-out astw:data-[state=closed]:duration-300 astw:data-[state=open]:duration-500",
552
+ s === "right" && "astw:data-[state=closed]:slide-out-to-right astw:data-[state=open]:slide-in-from-right astw:inset-y-0 astw:right-0 astw:h-full astw:w-3/4 astw:border-l astw:sm:max-w-sm",
553
+ s === "left" && "astw:data-[state=closed]:slide-out-to-left astw:data-[state=open]:slide-in-from-left astw:inset-y-0 astw:left-0 astw:h-full astw:w-3/4 astw:border-r astw:sm:max-w-sm",
554
+ s === "top" && "astw:data-[state=closed]:slide-out-to-top astw:data-[state=open]:slide-in-from-top astw:inset-x-0 astw:top-0 astw:h-auto astw:border-b",
555
+ s === "bottom" && "astw:data-[state=closed]:slide-out-to-bottom astw:data-[state=open]:slide-in-from-bottom astw:inset-x-0 astw:bottom-0 astw:h-auto astw:border-t",
556
+ t
557
+ ),
558
+ ...r,
559
+ children: [
560
+ e,
561
+ /* @__PURE__ */ c(x.Close, { className: "astw:ring-offset-bg astw:focus:ring-ring astw:data-[state=open]:bg-secondary astw:absolute astw:top-4 astw:right-4 astw:rounded-xs astw:opacity-70 astw:transition-opacity astw:hover:opacity-100 astw:focus:ring-2 astw:focus:ring-offset-2 astw:focus:outline-hidden astw:disabled:pointer-events-none", children: [
562
+ /* @__PURE__ */ a(bt, { className: "astw:size-4" }),
563
+ /* @__PURE__ */ a("span", { className: "astw:sr-only", children: "Close" })
564
+ ] })
565
+ ]
566
+ }
567
+ )
568
+ ] });
569
+ }
570
+ function te({ className: t, ...e }) {
571
+ return /* @__PURE__ */ a(
572
+ "div",
573
+ {
574
+ "data-slot": "sheet-header",
575
+ className: u("astw:flex astw:flex-col astw:gap-1.5 astw:p-4", t),
576
+ ...e
577
+ }
578
+ );
579
+ }
580
+ function ee({
581
+ className: t,
582
+ ...e
583
+ }) {
584
+ return /* @__PURE__ */ a(
585
+ x.Title,
586
+ {
587
+ "data-slot": "sheet-title",
588
+ className: u("astw:text-foreground astw:font-semibold", t),
589
+ ...e
590
+ }
591
+ );
592
+ }
593
+ function ae({
594
+ className: t,
595
+ ...e
596
+ }) {
597
+ return /* @__PURE__ */ a(
598
+ x.Description,
599
+ {
600
+ "data-slot": "sheet-description",
601
+ className: u("astw:text-muted-foreground astw:text-sm", t),
602
+ ...e
603
+ }
604
+ );
605
+ }
606
+ function ct({
607
+ delayDuration: t = 0,
608
+ ...e
609
+ }) {
610
+ return /* @__PURE__ */ a(
611
+ N.Provider,
612
+ {
613
+ "data-slot": "tooltip-provider",
614
+ delayDuration: t,
615
+ ...e
616
+ }
617
+ );
618
+ }
619
+ function se({
620
+ ...t
621
+ }) {
622
+ return /* @__PURE__ */ a(ct, { children: /* @__PURE__ */ a(N.Root, { "data-slot": "tooltip", ...t }) });
623
+ }
624
+ function re({
625
+ ...t
626
+ }) {
627
+ return /* @__PURE__ */ a(N.Trigger, { "data-slot": "tooltip-trigger", ...t });
628
+ }
629
+ function ne({
630
+ className: t,
631
+ sideOffset: e = 0,
632
+ children: s,
633
+ ...r
634
+ }) {
635
+ return /* @__PURE__ */ a(N.Portal, { children: /* @__PURE__ */ c(
636
+ N.Content,
637
+ {
638
+ "data-slot": "tooltip-content",
639
+ sideOffset: e,
640
+ className: u(
641
+ "astw:bg-primary astw:text-primary-foreground astw:animate-in astw:fade-in-0 astw:zoom-in-95 astw:data-[state=closed]:animate-out astw:data-[state=closed]:fade-out-0 astw:data-[state=closed]:zoom-out-95 astw:data-[side=bottom]:slide-in-from-top-2 astw:data-[side=left]:slide-in-from-right-2 astw:data-[side=right]:slide-in-from-left-2 astw:data-[side=top]:slide-in-from-bottom-2 astw:z-50 astw:w-fit astw:origin-(--radix-tooltip-content-transform-origin) astw:rounded-md astw:px-3 astw:py-1.5 astw:text-xs astw:text-balance",
642
+ t
643
+ ),
644
+ ...r,
645
+ children: [
646
+ s,
647
+ /* @__PURE__ */ a(N.Arrow, { className: "astw:bg-primary astw:fill-primary astw:z-50 astw:size-2.5 astw:translate-y-[calc(-50%_-_2px)] astw:rotate-45 astw:rounded-[2px]" })
648
+ ]
649
+ }
650
+ ) });
651
+ }
652
+ const oe = "sidebar_state", ie = 3600 * 24 * 7, le = "16rem", de = "18rem", ce = "3rem", we = "b", wt = g.createContext(null);
653
+ function _() {
654
+ const t = g.useContext(wt);
655
+ if (!t)
656
+ throw new Error("useSidebar must be used within a SidebarProvider.");
657
+ return t;
658
+ }
659
+ function ue({
660
+ defaultOpen: t = !0,
661
+ open: e,
662
+ onOpenChange: s,
663
+ className: r,
664
+ style: n,
665
+ children: o,
666
+ ...l
667
+ }) {
668
+ const d = qt(), [i, w] = g.useState(!1), [m, h] = g.useState(t), f = e ?? m, v = g.useCallback(
669
+ (b) => {
670
+ const p = typeof b == "function" ? b(f) : b;
671
+ s ? s(p) : h(p), document.cookie = `${oe}=${p}; path=/; max-age=${ie}`;
672
+ },
673
+ [s, f]
674
+ ), T = g.useCallback(() => d ? w((b) => !b) : v((b) => !b), [d, v, w]);
675
+ g.useEffect(() => {
676
+ const b = (p) => {
677
+ p.key === we && (p.metaKey || p.ctrlKey) && (p.preventDefault(), T());
678
+ };
679
+ return window.addEventListener("keydown", b), () => window.removeEventListener("keydown", b);
680
+ }, [T]);
681
+ const A = f ? "expanded" : "collapsed", K = g.useMemo(
682
+ () => ({
683
+ state: A,
684
+ open: f,
685
+ setOpen: v,
686
+ isMobile: d,
687
+ openMobile: i,
688
+ setOpenMobile: w,
689
+ toggleSidebar: T
690
+ }),
691
+ [A, f, v, d, i, w, T]
692
+ );
693
+ return /* @__PURE__ */ a(wt.Provider, { value: K, children: /* @__PURE__ */ a(ct, { delayDuration: 0, children: /* @__PURE__ */ a(
694
+ "div",
695
+ {
696
+ "data-slot": "sidebar-wrapper",
697
+ style: {
698
+ "--sidebar-width": le,
699
+ "--sidebar-width-icon": ce,
700
+ ...n
701
+ },
702
+ className: u(
703
+ "astw:group/sidebar-wrapper astw:has-data-[variant=inset]:bg-sidebar astw:flex astw:min-h-svh astw:w-full",
704
+ r
705
+ ),
706
+ ...l,
707
+ children: o
708
+ }
709
+ ) }) });
710
+ }
711
+ function me({
712
+ side: t = "left",
713
+ variant: e = "sidebar",
714
+ collapsible: s = "offcanvas",
715
+ className: r,
716
+ children: n,
717
+ ...o
718
+ }) {
719
+ const { isMobile: l, state: d, openMobile: i, setOpenMobile: w } = _();
720
+ return s === "none" ? /* @__PURE__ */ a(
721
+ "div",
722
+ {
723
+ "data-slot": "sidebar",
724
+ className: u(
725
+ "astw:bg-sidebar astw:text-sidebar-foreground astw:flex astw:h-full astw:w-(--sidebar-width) astw:flex-col",
726
+ r
727
+ ),
728
+ ...o,
729
+ children: n
730
+ }
731
+ ) : l ? /* @__PURE__ */ a(Xt, { open: i, onOpenChange: w, ...o, children: /* @__PURE__ */ c(
732
+ Zt,
733
+ {
734
+ "data-sidebar": "sidebar",
735
+ "data-slot": "sidebar",
736
+ "data-mobile": "true",
737
+ className: "astw:bg-sidebar astw:text-sidebar-foreground astw:w-(--sidebar-width) astw:p-0 astw:[&>button]:hidden",
738
+ style: {
739
+ "--sidebar-width": de
740
+ },
741
+ side: t,
742
+ children: [
743
+ /* @__PURE__ */ c(te, { className: "astw:sr-only", children: [
744
+ /* @__PURE__ */ a(ee, { children: "Sidebar" }),
745
+ /* @__PURE__ */ a(ae, { children: "Displays the mobile sidebar." })
746
+ ] }),
747
+ /* @__PURE__ */ a("div", { className: "flex h-full w-full flex-col", children: n })
748
+ ]
749
+ }
750
+ ) }) : /* @__PURE__ */ c(
751
+ "div",
752
+ {
753
+ className: "astw:group astw:peer astw:text-sidebar-foreground astw:hidden astw:md:block",
754
+ "data-state": d,
755
+ "data-collapsible": d === "collapsed" ? s : "",
756
+ "data-variant": e,
757
+ "data-side": t,
758
+ "data-slot": "sidebar",
759
+ children: [
760
+ /* @__PURE__ */ a(
761
+ "div",
762
+ {
763
+ "data-slot": "sidebar-gap",
764
+ className: u(
765
+ "astw:relative astw:w-(--sidebar-width) astw:bg-transparent astw:transition-[width] astw:duration-200 astw:ease-linear",
766
+ "astw:group-data-[collapsible=offcanvas]:w-0",
767
+ "astw:group-data-[side=right]:rotate-180",
768
+ e === "floating" || e === "inset" ? "astw:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "astw:group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
769
+ )
770
+ }
771
+ ),
772
+ /* @__PURE__ */ a(
773
+ "div",
774
+ {
775
+ "data-slot": "sidebar-container",
776
+ className: u(
777
+ "astw:fixed astw:inset-y-0 astw:z-10 astw:hidden astw:h-svh astw:w-(--sidebar-width) astw:transition-[left,right,width] astw:duration-200 astw:ease-linear astw:md:flex",
778
+ t === "left" ? "astw:left-0 astw:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "astw:right-0 astw:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
779
+ // Adjust the padding for floating and inset variants.
780
+ e === "floating" || e === "inset" ? "astw:p-2 astw:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "astw:group-data-[collapsible=icon]:w-(--sidebar-width-icon) astw:group-data-[side=left]:border-r astw:group-data-[side=right]:border-l",
781
+ e === "inset" && "astw:border-x astw:border-x-border",
782
+ r
783
+ ),
784
+ ...o,
785
+ children: /* @__PURE__ */ a(
786
+ "div",
787
+ {
788
+ "data-sidebar": "sidebar",
789
+ "data-slot": "sidebar-inner",
790
+ className: "astw:bg-sidebar astw:group-data-[variant=floating]:border-sidebar-border astw:flex astw:h-full astw:w-full astw:flex-col astw:group-data-[variant=floating]:rounded-lg astw:group-data-[variant=floating]:border astw:group-data-[variant=floating]:shadow-sm",
791
+ children: n
792
+ }
793
+ )
794
+ }
795
+ )
796
+ ]
797
+ }
798
+ );
799
+ }
800
+ function ut({
801
+ className: t,
802
+ onClick: e,
803
+ ...s
804
+ }) {
805
+ const { toggleSidebar: r } = _();
806
+ return /* @__PURE__ */ c(
807
+ B,
808
+ {
809
+ "data-sidebar": "trigger",
810
+ "data-slot": "sidebar-trigger",
811
+ variant: "ghost",
812
+ size: "icon",
813
+ className: u("astw:text-muted-foreground", t),
814
+ onClick: (n) => {
815
+ e?.(n), r();
816
+ },
817
+ ...s,
818
+ children: [
819
+ /* @__PURE__ */ a(ft, { className: "astw:size-4.5" }),
820
+ /* @__PURE__ */ a("span", { className: "astw:sr-only", children: "Toggle Sidebar" })
821
+ ]
822
+ }
823
+ );
824
+ }
825
+ function he({ className: t, ...e }) {
826
+ return /* @__PURE__ */ a(
827
+ "main",
828
+ {
829
+ "data-slot": "sidebar-inset",
830
+ className: u(
831
+ "astw:bg-background astw:relative astw:flex astw:w-full astw:flex-1 astw:flex-col",
832
+ "astw:px-4 astw:md:peer-data-[variant=inset]:px-8 astw:md:peer-data-[variant=inset]:py-2",
833
+ // astw:md:peer-data-[variant=inset]:peer-data-[state=collapsed]:pl-2
834
+ t
835
+ ),
836
+ ...e
837
+ }
838
+ );
839
+ }
840
+ function be({ className: t, ...e }) {
841
+ return /* @__PURE__ */ a(
842
+ "div",
843
+ {
844
+ "data-slot": "sidebar-header",
845
+ "data-sidebar": "header",
846
+ className: u("astw:flex astw:flex-row astw:items-center astw:gap-0.5 astw:p-2", t),
847
+ ...e
848
+ }
849
+ );
850
+ }
851
+ function fe({ className: t, ...e }) {
852
+ return /* @__PURE__ */ a(
853
+ "div",
854
+ {
855
+ "data-slot": "sidebar-content",
856
+ "data-sidebar": "content",
857
+ className: u(
858
+ "astw:flex astw:min-h-0 astw:flex-1 astw:flex-col astw:gap-2 astw:overflow-auto astw:group-data-[collapsible=icon]:overflow-hidden",
859
+ t
860
+ ),
861
+ ...e
862
+ }
863
+ );
864
+ }
865
+ function ge({ className: t, ...e }) {
866
+ return /* @__PURE__ */ a(
867
+ "div",
868
+ {
869
+ "data-slot": "sidebar-group",
870
+ "data-sidebar": "group",
871
+ className: u("astw:relative astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:p-2", t),
872
+ ...e
873
+ }
874
+ );
875
+ }
876
+ function pe({ className: t, ...e }) {
877
+ return /* @__PURE__ */ a(
878
+ "ul",
879
+ {
880
+ "data-slot": "sidebar-menu",
881
+ "data-sidebar": "menu",
882
+ className: u("astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:gap-1", t),
883
+ ...e
884
+ }
885
+ );
886
+ }
887
+ function ve({ className: t, ...e }) {
888
+ return /* @__PURE__ */ a(
889
+ "li",
890
+ {
891
+ "data-slot": "sidebar-menu-item",
892
+ "data-sidebar": "menu-item",
893
+ className: u("astw:group/menu-item astw:relative", t),
894
+ ...e
895
+ }
896
+ );
897
+ }
898
+ const xe = rt(
899
+ "astw:peer/menu-button astw:flex astw:w-full astw:items-center astw:gap-2 astw:overflow-hidden astw:rounded-md astw:p-2 astw:text-left astw:text-sm astw:outline-hidden astw:ring-sidebar-ring astw:transition-[width,height,padding] astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:focus-visible:ring-2 astw:active:bg-sidebar-accent astw:active:text-sidebar-accent-foreground astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:group-has-data-[sidebar=menu-action]/menu-item:pr-8 astw:aria-disabled:pointer-events-none astw:aria-disabled:opacity-50 astw:data-[active=true]:bg-sidebar-accent astw:data-[active=true]:font-medium astw:data-[active=true]:text-sidebar-accent-foreground astw:data-[state=open]:hover:bg-sidebar-accent astw:data-[state=open]:hover:text-sidebar-accent-foreground astw:group-data-[collapsible=icon]:size-8! astw:group-data-[collapsible=icon]:p-2! astw:[&>span:last-child]:truncate astw:[&>svg]:size-4 astw:[&>svg]:shrink-0",
900
+ {
901
+ variants: {
902
+ variant: {
903
+ default: "astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground",
904
+ outline: "astw:bg-background astw:shadow-[0_0_0_1px_hsl(var(--sidebar-border))] astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"
905
+ },
906
+ size: {
907
+ default: "astw:h-8 astw:text-sm",
908
+ sm: "astw:h-7 astw:rounded-md astw:gap-1.5 astw:px-3 astw:has-[>svg]:px-2.5",
909
+ lg: "astw:h-12 astw:text-sm astw:group-data-[collapsible=icon]:p-0!"
910
+ }
911
+ },
912
+ defaultVariants: {
913
+ variant: "default",
914
+ size: "default"
915
+ }
916
+ }
917
+ );
918
+ function X({
919
+ asChild: t = !1,
920
+ isActive: e = !1,
921
+ variant: s = "default",
922
+ size: r = "default",
923
+ tooltip: n,
924
+ className: o,
925
+ ...l
926
+ }) {
927
+ const d = t ? R : "button", { isMobile: i, state: w } = _(), m = /* @__PURE__ */ a(
928
+ d,
929
+ {
930
+ "data-slot": "sidebar-menu-button",
931
+ "data-sidebar": "menu-button",
932
+ "data-size": r,
933
+ "data-active": e,
934
+ className: u(xe({ variant: s, size: r }), o),
935
+ ...l
936
+ }
937
+ );
938
+ return n ? (typeof n == "string" && (n = {
939
+ children: n
940
+ }), /* @__PURE__ */ c(se, { children: [
941
+ /* @__PURE__ */ a(re, { asChild: !0, children: m }),
942
+ /* @__PURE__ */ a(
943
+ ne,
944
+ {
945
+ side: "right",
946
+ align: "center",
947
+ hidden: w !== "collapsed" || i,
948
+ ...n
949
+ }
950
+ )
951
+ ] })) : m;
952
+ }
953
+ function Y({
954
+ className: t,
955
+ asChild: e = !1,
956
+ showOnHover: s = !1,
957
+ ...r
958
+ }) {
959
+ return /* @__PURE__ */ a(
960
+ e ? R : "button",
961
+ {
962
+ "data-slot": "sidebar-menu-action",
963
+ "data-sidebar": "menu-action",
964
+ className: u(
965
+ "astw:text-sidebar-foreground astw:ring-sidebar-ring astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:peer-hover/menu-button:text-sidebar-accent-foreground astw:absolute astw:top-1.5 astw:right-1 astw:flex astw:aspect-square astw:w-5 astw:items-center astw:justify-center astw:rounded-md astw:p-0 astw:outline-hidden astw:transition-transform astw:focus-visible:ring-2 astw:[&>svg]:size-4 astw:[&>svg]:shrink-0",
966
+ // Increases the hit area of the button on mobile.
967
+ "astw:after:absolute astw:after:-inset-2 astw:md:after:hidden",
968
+ "astw:peer-data-[size=sm]/menu-button:top-1",
969
+ "astw:peer-data-[size=default]/menu-button:top-1.5",
970
+ "astw:peer-data-[size=lg]/menu-button:top-2.5",
971
+ "astw:group-data-[collapsible=icon]:hidden",
972
+ s && "astw:peer-data-[active=true]/menu-button:text-sidebar-accent-foreground astw:group-focus-within/menu-item:opacity-100 astw:group-hover/menu-item:opacity-100 astw:data-[state=open]:opacity-100 astw:md:opacity-0",
973
+ t
974
+ ),
975
+ ...r
976
+ }
977
+ );
978
+ }
979
+ function ye({ className: t, ...e }) {
980
+ return /* @__PURE__ */ a(
981
+ "ul",
982
+ {
983
+ "data-slot": "sidebar-menu-sub",
984
+ "data-sidebar": "menu-sub",
985
+ className: u(
986
+ "astw:border-sidebar-border astw:mx-3.5 astw:flex astw:min-w-0 astw:translate-x-px astw:flex-col astw:gap-1 astw:border-l astw:px-2.5 astw:py-0.5",
987
+ "astw:group-data-[collapsible=icon]:hidden",
988
+ t
989
+ ),
990
+ ...e
991
+ }
992
+ );
993
+ }
994
+ function Te({
995
+ className: t,
996
+ ...e
997
+ }) {
998
+ return /* @__PURE__ */ a(
999
+ "li",
1000
+ {
1001
+ "data-slot": "sidebar-menu-sub-item",
1002
+ "data-sidebar": "menu-sub-item",
1003
+ className: u("astw:group/menu-sub-item astw:relative", t),
1004
+ ...e
1005
+ }
1006
+ );
1007
+ }
1008
+ function Ne({
1009
+ asChild: t = !1,
1010
+ size: e = "md",
1011
+ isActive: s = !1,
1012
+ className: r,
1013
+ ...n
1014
+ }) {
1015
+ return /* @__PURE__ */ a(
1016
+ t ? R : "a",
1017
+ {
1018
+ "data-slot": "sidebar-menu-sub-button",
1019
+ "data-sidebar": "menu-sub-button",
1020
+ "data-size": e,
1021
+ "data-active": s,
1022
+ className: u(
1023
+ "astw:text-sidebar-foreground astw:ring-sidebar-ring astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:active:bg-sidebar-accent astw:active:text-sidebar-accent-foreground astw:[&>svg]:text-sidebar-accent-foreground astw:flex astw:h-7 astw:min-w-0 astw:-translate-x-px astw:items-center astw:gap-2 astw:overflow-hidden astw:rounded-md astw:px-2 astw:outline-hidden astw:focus-visible:ring-2 astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:aria-disabled:pointer-events-none astw:aria-disabled:opacity-50 astw:[&>span:last-child]:truncate astw:[&>svg]:size-4 astw:[&>svg]:shrink-0",
1024
+ "astw:data-[active=true]:bg-sidebar-accent astw:data-[active=true]:text-sidebar-accent-foreground",
1025
+ e === "sm" && "astw:text-xs",
1026
+ e === "md" && "astw:text-sm",
1027
+ "astw:group-data-[collapsible=icon]:hidden",
1028
+ r
1029
+ ),
1030
+ ...n
1031
+ }
1032
+ );
1033
+ }
1034
+ function D({ to: t, children: e, ...s }) {
1035
+ try {
1036
+ return St(t), /* @__PURE__ */ a(kt, { to: t, ...s, children: e });
1037
+ } catch {
1038
+ return /* @__PURE__ */ a("a", { href: t, ...s, children: e });
1039
+ }
1040
+ }
1041
+ function J({ ...t }) {
1042
+ return /* @__PURE__ */ a("nav", { "aria-label": "breadcrumb", "data-slot": "breadcrumb", ...t });
1043
+ }
1044
+ function Z({ className: t, ...e }) {
1045
+ return /* @__PURE__ */ a(
1046
+ "ol",
1047
+ {
1048
+ "data-slot": "breadcrumb-list",
1049
+ className: u(
1050
+ "astw:text-muted-foreground astw:flex astw:flex-wrap astw:items-center astw:gap-1.5 astw:text-sm astw:break-words astw:sm:gap-2.5",
1051
+ t
1052
+ ),
1053
+ ...e
1054
+ }
1055
+ );
1056
+ }
1057
+ function tt({ className: t, ...e }) {
1058
+ return /* @__PURE__ */ a(
1059
+ "li",
1060
+ {
1061
+ "data-slot": "breadcrumb-item",
1062
+ className: u("astw:inline-flex astw:items-center astw:gap-1.5", t),
1063
+ ...e
1064
+ }
1065
+ );
1066
+ }
1067
+ function et({
1068
+ asChild: t,
1069
+ className: e,
1070
+ children: s,
1071
+ ...r
1072
+ }) {
1073
+ return /* @__PURE__ */ a(
1074
+ t ? R : D,
1075
+ {
1076
+ "data-slot": "breadcrumb-link",
1077
+ className: u("astw:hover:text-foreground astw:transition-colors", e),
1078
+ ...r,
1079
+ children: s
1080
+ }
1081
+ );
1082
+ }
1083
+ function Ce({
1084
+ children: t,
1085
+ className: e,
1086
+ ...s
1087
+ }) {
1088
+ return /* @__PURE__ */ a(
1089
+ "li",
1090
+ {
1091
+ "data-slot": "breadcrumb-separator",
1092
+ role: "presentation",
1093
+ "aria-hidden": "true",
1094
+ className: u("astw:[&>svg]:size-3.5", e),
1095
+ ...s,
1096
+ children: t ?? /* @__PURE__ */ a(I, {})
1097
+ }
1098
+ );
1099
+ }
1100
+ const Se = (t, e) => {
1101
+ const s = nt(e);
1102
+ return t.reduce(
1103
+ (r, n) => {
1104
+ const o = s(n.meta.title, n.path);
1105
+ r[n.path] = {
1106
+ title: o,
1107
+ breadcrumbTitle: n.meta.breadcrumbTitle
1108
+ };
1109
+ const l = (d, i) => {
1110
+ !d || d.length === 0 || d.forEach((w) => {
1111
+ const m = `${i}/${w.path}`, h = s(
1112
+ w.meta.title,
1113
+ w.path
1114
+ );
1115
+ r[m] = {
1116
+ title: h,
1117
+ breadcrumbTitle: w.meta.breadcrumbTitle
1118
+ }, w.subResources && w.subResources.length > 0 && l(
1119
+ w.subResources,
1120
+ m
1121
+ );
1122
+ });
1123
+ };
1124
+ return n.resources && n.resources.length > 0 && l(n.resources, n.path), r;
1125
+ },
1126
+ {}
1127
+ );
1128
+ };
1129
+ function ke(t, e, s, r) {
1130
+ const n = t.split("/").filter((i) => i !== ""), o = e && n[0] === e ? n.slice(1) : n, l = Se(s, r), d = o.map((i, w) => {
1131
+ const m = o.slice(0, w + 1).join("/");
1132
+ let h = l[m];
1133
+ if (!h) {
1134
+ const v = Object.entries(l).find(
1135
+ ([T]) => {
1136
+ const A = T.split("/").map((b) => b.startsWith(":") ? "[^/]+" : b).join("/");
1137
+ return new RegExp(`^${A}$`).test(m);
1138
+ }
1139
+ )?.[1];
1140
+ v && (h = v);
1141
+ }
1142
+ let f;
1143
+ return h ? typeof h.breadcrumbTitle == "function" ? f = h.breadcrumbTitle(i) : typeof h.breadcrumbTitle == "string" ? f = h.breadcrumbTitle : f = h.title : f = decodeURIComponent(i), {
1144
+ segment: i,
1145
+ path: m,
1146
+ title: f
1147
+ };
1148
+ });
1149
+ return {
1150
+ basePath: e || null,
1151
+ segments: d
1152
+ };
1153
+ }
1154
+ const Be = () => {
1155
+ const { open: t } = _();
1156
+ return /* @__PURE__ */ a("div", { className: t ? "astw:md:hidden" : void 0, children: /* @__PURE__ */ a(ut, { className: "astw:-ml-2.5" }) });
1157
+ }, Ve = (t) => {
1158
+ const e = t.children ? t.children({ Outlet: V }) : null, s = Kt(), r = () => {
1159
+ s.setTheme(s.theme === "dark" ? "light" : "dark");
1160
+ };
1161
+ return /* @__PURE__ */ a(ue, { className: "astw:flex astw:flex-col", children: /* @__PURE__ */ c("div", { className: "astw:flex astw:flex-1", children: [
1162
+ t.sidebar ?? /* @__PURE__ */ a(Re, {}),
1163
+ /* @__PURE__ */ c(he, { className: "astw:w-[calc(100%-var(--sidebar-width))]", children: [
1164
+ /* @__PURE__ */ a("header", { className: "astw:flex astw:h-14 astw:shrink-0 astw:items-center astw:gap-2 astw:transition-[width,height] astw:ease-linear astw:group-has-data-[collapsible=icon]/sidebar-wrapper:h-12", children: /* @__PURE__ */ c("div", { className: "astw:flex astw:w-full astw:items-center astw:justify-between", children: [
1165
+ /* @__PURE__ */ c("div", { className: "astw:flex astw:items-center astw:gap-2", children: [
1166
+ /* @__PURE__ */ a(Be, {}),
1167
+ /* @__PURE__ */ a(Ae, {})
1168
+ ] }),
1169
+ /* @__PURE__ */ a("div", { className: "astw:flex astw:items-center astw:gap-2", children: /* @__PURE__ */ a(B, { variant: "outline", size: "icon", onClick: r, children: /* @__PURE__ */ a(gt, {}) }) })
1170
+ ] }) }),
1171
+ /* @__PURE__ */ a("div", { className: "astw:flex astw:flex-col astw:gap-4", children: e ?? /* @__PURE__ */ a(V, {}) })
1172
+ ] })
1173
+ ] }) });
1174
+ }, Re = (t) => {
1175
+ const { title: e, icon: s, navItems: r } = y(), { pathname: n } = st(), o = E(), l = /* @__PURE__ */ c(be, { children: [
1176
+ s,
1177
+ /* @__PURE__ */ a("h1", { className: "astw:text-sm astw:mb-2 astw:mt-2 astw:px-2", children: e })
1178
+ ] });
1179
+ return /* @__PURE__ */ c(me, { variant: "inset", children: [
1180
+ /* @__PURE__ */ c("div", { className: "astw:flex astw:justify-between astw:items-center", children: [
1181
+ t.header ?? l,
1182
+ /* @__PURE__ */ a("div", { className: "astw:hidden astw:md:block", children: /* @__PURE__ */ a(ut, { className: "astw:-ml-1" }) })
1183
+ ] }),
1184
+ /* @__PURE__ */ a(fe, { children: /* @__PURE__ */ a(ge, { children: /* @__PURE__ */ a(pe, { children: r.map((i) => /* @__PURE__ */ a(
1185
+ Gt,
1186
+ {
1187
+ asChild: !0,
1188
+ defaultOpen: i.isActive,
1189
+ children: /* @__PURE__ */ c(ve, { children: [
1190
+ i.url ? /* @__PURE__ */ c(S, { children: [
1191
+ /* @__PURE__ */ a(X, { asChild: !0, tooltip: i.title, children: /* @__PURE__ */ c(
1192
+ D,
1193
+ {
1194
+ to: i.url,
1195
+ className: i.url === n ? "astw:bg-sidebar-accent astw:font-medium" : void 0,
1196
+ children: [
1197
+ i.icon,
1198
+ /* @__PURE__ */ a("span", { children: i.title })
1199
+ ]
1200
+ }
1201
+ ) }),
1202
+ !!i.items?.length && /* @__PURE__ */ a(q, { asChild: !0, children: /* @__PURE__ */ c(Y, { className: "astw:data-[state=open]:rotate-90", children: [
1203
+ /* @__PURE__ */ a(I, {}),
1204
+ /* @__PURE__ */ a("span", { className: "astw:sr-only", children: o("toggle") })
1205
+ ] }) })
1206
+ ] }) : /* @__PURE__ */ a(S, { children: /* @__PURE__ */ c(q, { className: "astw:flex astw:w-[100%] astw:[&[data-state=open]_.astw-rotate-target]:rotate-90", children: [
1207
+ /* @__PURE__ */ a(X, { asChild: !0, tooltip: i.title, children: /* @__PURE__ */ c("span", { className: "astw:flex astw:w-[100%]", children: [
1208
+ i.icon,
1209
+ /* @__PURE__ */ a("span", { children: i.title })
1210
+ ] }) }),
1211
+ !!i.items?.length && /* @__PURE__ */ a(
1212
+ Y,
1213
+ {
1214
+ className: "astw-rotate-target",
1215
+ asChild: !0,
1216
+ children: /* @__PURE__ */ c("span", { children: [
1217
+ /* @__PURE__ */ a(I, {}),
1218
+ /* @__PURE__ */ a("span", { className: "astw:sr-only", children: o("toggle") })
1219
+ ] })
1220
+ }
1221
+ )
1222
+ ] }) }),
1223
+ !!i.items?.length && /* @__PURE__ */ a(Vt, { children: /* @__PURE__ */ a(ye, { children: i.items?.map((w) => /* @__PURE__ */ a(Te, { children: /* @__PURE__ */ a(Ne, { asChild: !0, children: /* @__PURE__ */ a(
1224
+ D,
1225
+ {
1226
+ to: w.url,
1227
+ className: w.url === n ? "astw:bg-sidebar-accent astw:font-medium" : void 0,
1228
+ children: /* @__PURE__ */ a("span", { children: w.title })
1229
+ }
1230
+ ) }) }, w.title)) }) })
1231
+ ] })
1232
+ },
1233
+ i.title
1234
+ )) }) }) }),
1235
+ t.footer ?? null
1236
+ ] });
1237
+ }, Ee = () => {
1238
+ const { configurations: t } = y(), e = st();
1239
+ return ke(
1240
+ e.pathname,
1241
+ t.basePath,
1242
+ t.modules,
1243
+ t.locale
1244
+ );
1245
+ }, Ae = () => {
1246
+ const { segments: t } = Ee(), e = Bt("/:prefix/settings/:suffix"), s = E();
1247
+ return e ? /* @__PURE__ */ a(J, { children: /* @__PURE__ */ a(Z, { children: /* @__PURE__ */ a("div", { className: "astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground", children: /* @__PURE__ */ a(tt, { children: /* @__PURE__ */ a(et, { to: `/${e.params.prefix}/settings`, children: s("settings") }) }) }) }) }) : /* @__PURE__ */ a(J, { children: /* @__PURE__ */ a(Z, { children: t.map((r, n) => /* @__PURE__ */ c(
1248
+ "div",
1249
+ {
1250
+ className: "astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",
1251
+ children: [
1252
+ /* @__PURE__ */ a(tt, { children: /* @__PURE__ */ a(et, { to: r.path, children: r.title }) }),
1253
+ n < t.length - 1 && /* @__PURE__ */ a(Ce, {})
1254
+ ]
1255
+ },
1256
+ n
1257
+ )) }) });
1258
+ }, mt = O(null), qe = (t) => {
1259
+ const e = U(
1260
+ () => Mt({
1261
+ clientId: t.clientId,
1262
+ appUri: t.apiEndpoint,
1263
+ redirectUri: t.redirectUri,
1264
+ meQuery: t.meQuery && (typeof t.meQuery == "string" ? t.meQuery : Lt(t.meQuery))
1265
+ }),
1266
+ [t.clientId, t.apiEndpoint, t.redirectUri, t.meQuery]
1267
+ ), [s, r] = j(
1268
+ () => e.getState()
1269
+ );
1270
+ L(() => {
1271
+ t.autoLogin && (s.isLoading || s.isAuthenticated || (async () => await e.login())());
1272
+ }, [s.isLoading, s.isAuthenticated, t.autoLogin]), L(
1273
+ () => e.addEventListener((o) => {
1274
+ o.type === "auth_state_changed" && r(o.data);
1275
+ }),
1276
+ [e]
1277
+ );
1278
+ const n = t.guardComponent && (s.isLoading || !s.isAuthenticated) ? /* @__PURE__ */ a(t.guardComponent, {}) : t.children;
1279
+ return /* @__PURE__ */ a(
1280
+ mt.Provider,
1281
+ {
1282
+ value: {
1283
+ authState: s,
1284
+ login: async () => e.login(),
1285
+ logout: async () => e.logout(),
1286
+ checkAuthStatus: async () => e.checkAuthStatus(),
1287
+ handleCallback: async () => e.handleCallback()
1288
+ },
1289
+ children: n
1290
+ }
1291
+ );
1292
+ }, Xe = () => {
1293
+ const t = $(mt);
1294
+ if (!t)
1295
+ throw new Error("useAuth must be used within an AuthProvider");
1296
+ return t;
1297
+ };
1298
+ export {
1299
+ Ge as AppShell,
1300
+ qe as AuthProvider,
1301
+ Re as DefaultSidebar,
1302
+ Ze as Link,
1303
+ Ve as SidebarLayout,
1304
+ zt as defineI18nLabels,
1305
+ Qe as defineModule,
1306
+ Ke as defineResource,
1307
+ Fe as redirectToResource,
1308
+ y as useAppShell,
1309
+ Xe as useAuth,
1310
+ ta as useLocation,
1311
+ ea as useNavigate,
1312
+ aa as useParams,
1313
+ sa as useRouteError,
1314
+ ra as useSearchParams,
1315
+ Kt as useTheme
1316
+ };