@tailor-platform/app-shell 0.18.0 → 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.
package/dist/app-shell.js CHANGED
@@ -1,24 +1,25 @@
1
- import { jsx as a, jsxs as c, Fragment as N } from "react/jsx-runtime";
2
- import { AlertCircle as Y, Table as ft, XIcon as vt, PanelLeftIcon as xt, ChevronRight as D, SunIcon as yt } from "lucide-react";
3
- import * as b from "react";
4
- import { createContext as $, useContext as F, useState as K, useMemo as H, useEffect as U, useCallback as Q } from "react";
5
- import { useRouteError as Tt, isRouteErrorResponse as St, Outlet as W, NavLink as Ct, redirect as ot, Navigate as Nt, createMemoryRouter as kt, createBrowserRouter as Bt, RouterProvider as Pt, useHref as Rt, Link as _t, useLocation as it, useMatch as Et } from "react-router";
6
- import { Link as sa, useLocation as ra, useNavigate as na, useParams as oa, useRouteError as ia, useSearchParams as la } from "react-router";
7
- import { Slot as P } from "@radix-ui/react-slot";
8
- import { cva as lt } from "class-variance-authority";
9
- import { clsx as It } from "clsx";
10
- import { twMerge as At } from "tailwind-merge";
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
11
  import { capitalCase as k } from "change-case";
12
- import { Toaster as Lt } from "sonner";
13
- import * as V from "@radix-ui/react-collapsible";
12
+ import { Toaster as At } from "sonner";
13
+ import * as W from "@radix-ui/react-collapsible";
14
14
  import "@radix-ui/react-separator";
15
15
  import * as x from "@radix-ui/react-dialog";
16
- import * as S from "@radix-ui/react-tooltip";
17
- import * as M from "oauth4webapi";
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";
18
19
  function u(...t) {
19
- return At(It(t));
20
+ return Et(Rt(t));
20
21
  }
21
- const Mt = lt(
22
+ const _t = rt(
22
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",
23
24
  {
24
25
  variants: {
@@ -51,15 +52,15 @@ function B({
51
52
  ...n
52
53
  }) {
53
54
  return /* @__PURE__ */ a(
54
- r ? P : "button",
55
+ r ? R : "button",
55
56
  {
56
57
  "data-slot": "button",
57
- className: u(Mt({ variant: e, size: s, className: t })),
58
+ className: u(_t({ variant: e, size: s, className: t })),
58
59
  ...n
59
60
  }
60
61
  );
61
62
  }
62
- const C = "en", zt = () => {
63
+ const C = "en", Pt = () => {
63
64
  try {
64
65
  if (typeof navigator > "u")
65
66
  return C;
@@ -68,13 +69,13 @@ const C = "en", zt = () => {
68
69
  } catch {
69
70
  return C;
70
71
  }
71
- }, q = (t) => (e, s) => e ? typeof e == "string" ? e : e(t) ?? s : s, dt = (t) => {
72
- const e = q(t);
72
+ }, F = (t) => (e, s) => e ? typeof e == "string" ? e : e(t) ?? s : s, nt = (t) => {
73
+ const e = F(t);
73
74
  return (s, r) => e(s, typeof s == "string" ? s : k(r));
74
- }, Dt = () => {
75
- const { configurations: t } = y(), e = q(t.locale);
75
+ }, It = () => {
76
+ const { configurations: t } = y(), e = F(t.locale);
76
77
  return (s, r) => e(s, r);
77
- }, Ot = (t) => {
78
+ }, zt = (t) => {
78
79
  const e = (s) => (r) => t[s ?? C]?.[r] ?? t.en[r];
79
80
  return {
80
81
  /**
@@ -130,7 +131,7 @@ const C = "en", zt = () => {
130
131
  return typeof o == "function" ? o(r[0]) : o;
131
132
  }
132
133
  };
133
- }, jt = Ot({
134
+ }, Dt = zt({
134
135
  en: {
135
136
  error404Title: "404 Not Found",
136
137
  error404Body: "The page you requested could not be found.",
@@ -165,14 +166,14 @@ const C = "en", zt = () => {
165
166
  close: "閉じる",
166
167
  more: "その他"
167
168
  }
168
- }), R = jt.useT, E = () => {
169
- const t = Tt(), e = R(), s = {
169
+ }), E = Dt.useT, M = () => {
170
+ const t = pt(), e = E(), s = {
170
171
  role: "alert",
171
172
  "aria-label": "default-error-boundary"
172
173
  };
173
- if (St(t) && t.status === 404)
174
+ if (vt(t) && t.status === 404)
174
175
  return /* @__PURE__ */ a("div", { ...s, className: "astw:p-6", children: /* @__PURE__ */ c("div", { className: "astw:flex astw:items-start astw:gap-4", children: [
175
- /* @__PURE__ */ a(Y, { className: "astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5" }),
176
+ /* @__PURE__ */ a(G, { className: "astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5" }),
176
177
  /* @__PURE__ */ c("div", { children: [
177
178
  /* @__PURE__ */ a("h1", { className: "astw:font-semibold astw:text-lg", children: e("error404Title") }),
178
179
  /* @__PURE__ */ a("p", { className: "astw:text-sm astw:text-muted-foreground astw:mt-1", children: e("error404Body") }),
@@ -190,7 +191,7 @@ const C = "en", zt = () => {
190
191
  ] }) });
191
192
  const r = t instanceof Error ? t.message : e("errorUnexpected");
192
193
  return /* @__PURE__ */ a("div", { ...s, className: "astw:p-6", children: /* @__PURE__ */ c("div", { className: "astw:flex astw:items-start astw:gap-4", children: [
193
- /* @__PURE__ */ a(Y, { className: "astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5" }),
194
+ /* @__PURE__ */ a(G, { className: "astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5" }),
194
195
  /* @__PURE__ */ c("div", { children: [
195
196
  /* @__PURE__ */ a("h1", { className: "astw:font-semibold astw:text-lg", children: e("errorTitle") }),
196
197
  /* @__PURE__ */ a("p", { className: "astw:text-sm astw:text-muted-foreground astw:mt-1", children: r }),
@@ -206,35 +207,35 @@ const C = "en", zt = () => {
206
207
  )
207
208
  ] })
208
209
  ] }) });
209
- }, $t = (t) => ({
210
+ }, Ot = (t) => ({
210
211
  modules: t.modules,
211
212
  settingsResources: t.settingsResources ?? [],
212
- errorBoundary: t.errorBoundary ?? /* @__PURE__ */ a(E, {}),
213
+ errorBoundary: t.errorBoundary ?? /* @__PURE__ */ a(M, {}),
213
214
  basePath: t.basePath,
214
- locale: t.locale ?? zt()
215
- }), ct = $({
215
+ locale: t.locale ?? Pt()
216
+ }), ot = O({
216
217
  navItems: [],
217
218
  configurations: {
218
219
  modules: [],
219
220
  settingsResources: [],
220
- errorBoundary: /* @__PURE__ */ a(E, {}),
221
+ errorBoundary: /* @__PURE__ */ a(M, {}),
221
222
  locale: C
222
223
  }
223
- }), y = () => F(ct), Ft = () => {
224
- const t = R();
225
- return /* @__PURE__ */ c(N, { children: [
224
+ }), y = () => $(ot), $t = () => {
225
+ const t = E();
226
+ return /* @__PURE__ */ c(S, { children: [
226
227
  /* @__PURE__ */ a("p", { className: "astw:font-semibold astw:leading-none astw:tracking-tight", children: t("welcomeTitle") }),
227
228
  /* @__PURE__ */ a("p", { className: "pt-4", children: t("welcomeBody") })
228
229
  ] });
229
- }, J = () => /* @__PURE__ */ c(N, { children: [
230
- /* @__PURE__ */ a(W, {}),
231
- /* @__PURE__ */ a(Lt, {})
232
- ] }), Kt = () => {
233
- const { configurations: t } = y(), e = R(), s = Dt();
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();
234
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: [
235
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: [
236
237
  /* @__PURE__ */ a("h2", { className: "astw:text-sm astw:leading-[36px] astw:mb-2 astw:font-bold ", children: e("settings") }),
237
- /* @__PURE__ */ a("ul", { className: "astw:flex astw:flex-col astw:gap-1", children: t.settingsResources.map((r) => /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(Ct, { to: `./${r.path}`, children: ({ isActive: n }) => /* @__PURE__ */ c(
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(
238
239
  B,
239
240
  {
240
241
  variant: n ? "secondary" : "ghost",
@@ -246,29 +247,29 @@ const C = "en", zt = () => {
246
247
  }
247
248
  ) }) }, r.path)) })
248
249
  ] }) }),
249
- /* @__PURE__ */ a("section", { className: "astw:bg-card astw:flex-1 astw:rounded-md astw:border astw:shadow-xs", children: /* @__PURE__ */ a(W, {}) })
250
+ /* @__PURE__ */ a("section", { className: "astw:bg-card astw:flex-1 astw:rounded-md astw:border astw:shadow-xs", children: /* @__PURE__ */ a(H, {}) })
250
251
  ] });
251
252
  };
252
- function qe(t) {
253
+ function Fe(t) {
253
254
  return {
254
255
  redirectTo: t
255
256
  };
256
257
  }
257
- function O(t) {
258
+ function z(t) {
258
259
  return typeof t == "object" && t !== null && "redirectTo" in t;
259
260
  }
260
- const wt = (t, e) => () => {
261
- const { configurations: s } = y(), { metaTitle: r, fallbackTitle: n } = t, l = q(s.locale)(r, n);
261
+ const it = (t, e) => () => {
262
+ const { configurations: s } = y(), { metaTitle: r, fallbackTitle: n } = t, l = F(s.locale)(r, n);
262
263
  return e(l);
263
264
  };
264
- function Ge(t) {
265
- const { path: e, meta: s, component: r, resources: n, errorBoundary: o } = t, l = s?.title ?? k(e), d = k(e), i = O(r) ? {
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) ? {
266
267
  // Use loader for redirects
267
268
  component: () => null,
268
- loader: () => ot(r.redirectTo)
269
+ loader: () => at(r.redirectTo)
269
270
  } : {
270
271
  // Regular component with locale-aware title
271
- component: wt(
272
+ component: it(
272
273
  { metaTitle: l, fallbackTitle: d },
273
274
  (w) => r({ title: w, resources: n })
274
275
  )
@@ -282,14 +283,14 @@ function Ge(t) {
282
283
  title: l,
283
284
  ...s?.breadcrumbTitle !== void 0 ? { breadcrumbTitle: s.breadcrumbTitle } : {},
284
285
  ...s,
285
- menuItemClickable: !O(r),
286
+ menuItemClickable: !z(r),
286
287
  icon: t.meta?.icon
287
288
  },
288
289
  resources: n,
289
- errorBoundary: o || /* @__PURE__ */ a(E, {})
290
+ errorBoundary: o || /* @__PURE__ */ a(M, {})
290
291
  };
291
292
  }
292
- function Xe(t) {
293
+ function Ke(t) {
293
294
  const { path: e, component: s, subResources: r, meta: n, errorBoundary: o } = t, l = n?.title ?? k(e), d = k(e);
294
295
  return {
295
296
  _type: "resource",
@@ -300,15 +301,15 @@ function Xe(t) {
300
301
  icon: n?.icon,
301
302
  ...n?.breadcrumbTitle !== void 0 ? { breadcrumbTitle: n.breadcrumbTitle } : {}
302
303
  },
303
- component: wt(
304
+ component: it(
304
305
  { metaTitle: l, fallbackTitle: d },
305
306
  (i) => s({ title: i, resources: r })
306
307
  ),
307
308
  subResources: r,
308
- errorBoundary: o ?? /* @__PURE__ */ a(E, {})
309
+ errorBoundary: o ?? /* @__PURE__ */ a(M, {})
309
310
  };
310
311
  }
311
- const G = (t) => () => /* @__PURE__ */ a(N, { children: t }), ut = (t, e, s) => {
312
+ const Q = (t) => () => /* @__PURE__ */ a(S, { children: t }), lt = (t, e, s) => {
312
313
  const r = t.errorBoundary || s, n = {
313
314
  index: !0,
314
315
  Component: t.component,
@@ -317,38 +318,38 @@ const G = (t) => () => /* @__PURE__ */ a(N, { children: t }), ut = (t, e, s) =>
317
318
  return {
318
319
  path: t.path,
319
320
  ...t.errorBoundary && {
320
- ErrorBoundary: G(t.errorBoundary)
321
+ ErrorBoundary: Q(t.errorBoundary)
321
322
  },
322
323
  ...e && e.length > 0 ? {
323
324
  children: [
324
325
  n,
325
326
  ...e.map(
326
- (o) => ut(o, o.subResources, r)
327
+ (o) => lt(o, o.subResources, r)
327
328
  )
328
329
  ]
329
330
  } : {
330
331
  children: [n]
331
332
  }
332
333
  };
333
- }, Ht = (t) => t.map(
334
- (e) => ut(e, e.resources, e.errorBoundary)
335
- ), Ut = ({
334
+ }, Ut = (t) => t.map(
335
+ (e) => lt(e, e.resources, e.errorBoundary)
336
+ ), Ht = ({
336
337
  modules: t,
337
338
  settingsResources: e,
338
339
  rootComponent: s
339
340
  }) => {
340
- const r = O(s) ? {
341
+ const r = z(s) ? {
341
342
  index: !0,
342
- loader: () => ot(s.redirectTo)
343
+ loader: () => at(s.redirectTo)
343
344
  } : {
344
345
  index: !0,
345
- Component: s ?? Ft
346
+ Component: s ?? $t
346
347
  }, n = e.length > 0 ? [
347
348
  {
348
349
  path: "settings",
349
350
  index: !0,
350
351
  Component: () => /* @__PURE__ */ a(
351
- Nt,
352
+ yt,
352
353
  {
353
354
  to: e[0].path,
354
355
  relative: "path",
@@ -358,12 +359,12 @@ const G = (t) => () => /* @__PURE__ */ a(N, { children: t }), ut = (t, e, s) =>
358
359
  },
359
360
  {
360
361
  path: "settings",
361
- Component: Kt,
362
+ Component: jt,
362
363
  children: e.map((o) => ({
363
364
  path: o.path,
364
365
  Component: o.component,
365
366
  ...o.errorBoundary && {
366
- ErrorBoundary: G(o.errorBoundary)
367
+ ErrorBoundary: Q(o.errorBoundary)
367
368
  }
368
369
  }))
369
370
  }
@@ -371,7 +372,7 @@ const G = (t) => () => /* @__PURE__ */ a(N, { children: t }), ut = (t, e, s) =>
371
372
  return [
372
373
  r,
373
374
  {
374
- children: Ht(t)
375
+ children: Ut(t)
375
376
  },
376
377
  ...n,
377
378
  {
@@ -382,7 +383,7 @@ const G = (t) => () => /* @__PURE__ */ a(N, { children: t }), ut = (t, e, s) =>
382
383
  }
383
384
  ];
384
385
  }, Wt = (t) => {
385
- const { configurations: e } = y(), { rootComponent: s, children: r } = t, n = Ut({
386
+ const { configurations: e } = y(), { rootComponent: s, children: r } = t, n = Ht({
386
387
  modules: e.modules,
387
388
  settingsResources: e.settingsResources,
388
389
  rootComponent: s
@@ -391,34 +392,34 @@ const G = (t) => () => /* @__PURE__ */ a(N, { children: t }), ut = (t, e, s) =>
391
392
  element: r,
392
393
  children: o ? [
393
394
  {
394
- element: /* @__PURE__ */ a(W, {}),
395
- ErrorBoundary: G(o),
395
+ element: /* @__PURE__ */ a(H, {}),
396
+ ErrorBoundary: Q(o),
396
397
  children: n
397
398
  }
398
399
  ] : n
399
400
  }
400
- ], d = e.basePath ? "/" + e.basePath : void 0, i = t.memory ? kt(l, {
401
+ ], d = e.basePath ? "/" + e.basePath : void 0, i = t.memory ? Tt(l, {
401
402
  basename: d,
402
403
  ...t.initialEntries ? { initialEntries: t.initialEntries } : {}
403
- }) : Bt(l, {
404
+ }) : Nt(l, {
404
405
  basename: d
405
406
  });
406
- return /* @__PURE__ */ a(Pt, { router: i });
407
- }, Vt = {
407
+ return /* @__PURE__ */ a(Ct, { router: i });
408
+ }, Ft = {
408
409
  resolvedTheme: "light",
409
410
  theme: "system",
410
411
  setTheme: () => null
411
- }, mt = $(Vt);
412
- function qt({
412
+ }, dt = O(Ft);
413
+ function Qt({
413
414
  children: t,
414
415
  storageKey: e,
415
416
  defaultTheme: s = "system",
416
417
  ...r
417
418
  }) {
418
- const [n, o] = K(
419
+ const [n, o] = j(
419
420
  () => localStorage.getItem(e) || s
420
- ), l = H(() => n !== "system" ? n : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", [n]);
421
- U(() => {
421
+ ), l = U(() => n !== "system" ? n : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", [n]);
422
+ L(() => {
422
423
  const i = window.document.documentElement;
423
424
  i.classList.remove("light", "dark"), i.classList.add(l);
424
425
  }, [l]);
@@ -429,20 +430,20 @@ function qt({
429
430
  localStorage.setItem(e, i), o(i);
430
431
  }
431
432
  };
432
- return /* @__PURE__ */ a(mt.Provider, { ...r, value: d, children: t });
433
+ return /* @__PURE__ */ a(dt.Provider, { ...r, value: d, children: t });
433
434
  }
434
- const Gt = () => {
435
- const t = F(mt);
435
+ const Kt = () => {
436
+ const t = $(dt);
436
437
  if (t === void 0)
437
438
  throw new Error("useTheme must be used within a ThemeProvider");
438
439
  return t;
439
- }, Ye = (t) => {
440
- const [e, s] = K(!1);
441
- U(function() {
440
+ }, Ge = (t) => {
441
+ const [e, s] = j(!1);
442
+ L(function() {
442
443
  s(!0);
443
444
  }, []);
444
- const r = $t(t), n = H(() => {
445
- const o = t.modules, l = dt(r.locale);
445
+ const r = Ot(t), n = U(() => {
446
+ const o = t.modules, l = nt(r.locale);
446
447
  return o.map((d) => {
447
448
  const i = l(d.meta.title, d.path), w = d.resources.map((m) => ({
448
449
  title: l(m.meta.title, m.path),
@@ -452,14 +453,14 @@ const Gt = () => {
452
453
  title: i,
453
454
  url: d.meta.menuItemClickable ? d.path : void 0,
454
455
  clickable: d.component,
455
- icon: d.meta.icon || /* @__PURE__ */ a(ft, {}),
456
+ icon: d.meta.icon || /* @__PURE__ */ a(ht, {}),
456
457
  isActive: !0,
457
458
  items: w
458
459
  };
459
460
  });
460
461
  }, [t.modules, r.locale]);
461
462
  return e ? /* @__PURE__ */ a(
462
- ct.Provider,
463
+ ot.Provider,
463
464
  {
464
465
  value: {
465
466
  title: t.title,
@@ -467,58 +468,58 @@ const Gt = () => {
467
468
  configurations: r,
468
469
  navItems: n
469
470
  },
470
- children: /* @__PURE__ */ a(qt, { defaultTheme: "system", storageKey: "appshell-ui-theme", children: /* @__PURE__ */ a(Wt, { rootComponent: t.rootComponent, children: t.children }) })
471
+ children: /* @__PURE__ */ a(Qt, { defaultTheme: "system", storageKey: "appshell-ui-theme", children: /* @__PURE__ */ a(Wt, { rootComponent: t.rootComponent, children: t.children }) })
471
472
  }
472
473
  ) : null;
473
474
  };
474
- function Xt({
475
+ function Gt({
475
476
  ...t
476
477
  }) {
477
- return /* @__PURE__ */ a(V.Root, { "data-slot": "collapsible", ...t });
478
+ return /* @__PURE__ */ a(W.Root, { "data-slot": "collapsible", ...t });
478
479
  }
479
- function Z({
480
+ function q({
480
481
  ...t
481
482
  }) {
482
483
  return /* @__PURE__ */ a(
483
- V.CollapsibleTrigger,
484
+ W.CollapsibleTrigger,
484
485
  {
485
486
  "data-slot": "collapsible-trigger",
486
487
  ...t
487
488
  }
488
489
  );
489
490
  }
490
- function Yt({
491
+ function Vt({
491
492
  ...t
492
493
  }) {
493
494
  return /* @__PURE__ */ a(
494
- V.CollapsibleContent,
495
+ W.CollapsibleContent,
495
496
  {
496
497
  "data-slot": "collapsible-content",
497
498
  ...t
498
499
  }
499
500
  );
500
501
  }
501
- const z = 768;
502
- function Qt() {
503
- const [t, e] = b.useState(
502
+ const P = 768;
503
+ function qt() {
504
+ const [t, e] = g.useState(
504
505
  void 0
505
506
  );
506
- return b.useEffect(() => {
507
- const s = window.matchMedia(`(max-width: ${z - 1}px)`), r = () => {
508
- e(window.innerWidth < z);
507
+ return g.useEffect(() => {
508
+ const s = window.matchMedia(`(max-width: ${P - 1}px)`), r = () => {
509
+ e(window.innerWidth < P);
509
510
  };
510
- return s.addEventListener("change", r), e(window.innerWidth < z), () => s.removeEventListener("change", r);
511
+ return s.addEventListener("change", r), e(window.innerWidth < P), () => s.removeEventListener("change", r);
511
512
  }, []), !!t;
512
513
  }
513
- function Jt({ ...t }) {
514
+ function Xt({ ...t }) {
514
515
  return /* @__PURE__ */ a(x.Root, { "data-slot": "sheet", ...t });
515
516
  }
516
- function Zt({
517
+ function Yt({
517
518
  ...t
518
519
  }) {
519
520
  return /* @__PURE__ */ a(x.Portal, { "data-slot": "sheet-portal", ...t });
520
521
  }
521
- function te({
522
+ function Jt({
522
523
  className: t,
523
524
  ...e
524
525
  }) {
@@ -534,14 +535,14 @@ function te({
534
535
  }
535
536
  );
536
537
  }
537
- function ee({
538
+ function Zt({
538
539
  className: t,
539
540
  children: e,
540
541
  side: s = "right",
541
542
  ...r
542
543
  }) {
543
- return /* @__PURE__ */ c(Zt, { children: [
544
- /* @__PURE__ */ a(te, {}),
544
+ return /* @__PURE__ */ c(Yt, { children: [
545
+ /* @__PURE__ */ a(Jt, {}),
545
546
  /* @__PURE__ */ c(
546
547
  x.Content,
547
548
  {
@@ -558,7 +559,7 @@ function ee({
558
559
  children: [
559
560
  e,
560
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: [
561
- /* @__PURE__ */ a(vt, { className: "astw:size-4" }),
562
+ /* @__PURE__ */ a(bt, { className: "astw:size-4" }),
562
563
  /* @__PURE__ */ a("span", { className: "astw:sr-only", children: "Close" })
563
564
  ] })
564
565
  ]
@@ -566,7 +567,7 @@ function ee({
566
567
  )
567
568
  ] });
568
569
  }
569
- function ae({ className: t, ...e }) {
570
+ function te({ className: t, ...e }) {
570
571
  return /* @__PURE__ */ a(
571
572
  "div",
572
573
  {
@@ -576,7 +577,7 @@ function ae({ className: t, ...e }) {
576
577
  }
577
578
  );
578
579
  }
579
- function se({
580
+ function ee({
580
581
  className: t,
581
582
  ...e
582
583
  }) {
@@ -589,7 +590,7 @@ function se({
589
590
  }
590
591
  );
591
592
  }
592
- function re({
593
+ function ae({
593
594
  className: t,
594
595
  ...e
595
596
  }) {
@@ -602,12 +603,12 @@ function re({
602
603
  }
603
604
  );
604
605
  }
605
- function ht({
606
+ function ct({
606
607
  delayDuration: t = 0,
607
608
  ...e
608
609
  }) {
609
610
  return /* @__PURE__ */ a(
610
- S.Provider,
611
+ N.Provider,
611
612
  {
612
613
  "data-slot": "tooltip-provider",
613
614
  delayDuration: t,
@@ -615,24 +616,24 @@ function ht({
615
616
  }
616
617
  );
617
618
  }
618
- function ne({
619
+ function se({
619
620
  ...t
620
621
  }) {
621
- return /* @__PURE__ */ a(ht, { children: /* @__PURE__ */ a(S.Root, { "data-slot": "tooltip", ...t }) });
622
+ return /* @__PURE__ */ a(ct, { children: /* @__PURE__ */ a(N.Root, { "data-slot": "tooltip", ...t }) });
622
623
  }
623
- function oe({
624
+ function re({
624
625
  ...t
625
626
  }) {
626
- return /* @__PURE__ */ a(S.Trigger, { "data-slot": "tooltip-trigger", ...t });
627
+ return /* @__PURE__ */ a(N.Trigger, { "data-slot": "tooltip-trigger", ...t });
627
628
  }
628
- function ie({
629
+ function ne({
629
630
  className: t,
630
631
  sideOffset: e = 0,
631
632
  children: s,
632
633
  ...r
633
634
  }) {
634
- return /* @__PURE__ */ a(S.Portal, { children: /* @__PURE__ */ c(
635
- S.Content,
635
+ return /* @__PURE__ */ a(N.Portal, { children: /* @__PURE__ */ c(
636
+ N.Content,
636
637
  {
637
638
  "data-slot": "tooltip-content",
638
639
  sideOffset: e,
@@ -643,19 +644,19 @@ function ie({
643
644
  ...r,
644
645
  children: [
645
646
  s,
646
- /* @__PURE__ */ a(S.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]" })
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]" })
647
648
  ]
648
649
  }
649
650
  ) });
650
651
  }
651
- const le = "sidebar_state", de = 3600 * 24 * 7, ce = "16rem", we = "18rem", ue = "3rem", me = "b", pt = b.createContext(null);
652
- function I() {
653
- const t = b.useContext(pt);
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);
654
655
  if (!t)
655
656
  throw new Error("useSidebar must be used within a SidebarProvider.");
656
657
  return t;
657
658
  }
658
- function he({
659
+ function ue({
659
660
  defaultOpen: t = !0,
660
661
  open: e,
661
662
  onOpenChange: s,
@@ -664,38 +665,38 @@ function he({
664
665
  children: o,
665
666
  ...l
666
667
  }) {
667
- const d = Qt(), [i, w] = b.useState(!1), [m, h] = b.useState(t), g = e ?? m, v = b.useCallback(
668
- (p) => {
669
- const f = typeof p == "function" ? p(g) : p;
670
- s ? s(f) : h(f), document.cookie = `${le}=${f}; path=/; max-age=${de}`;
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}`;
671
672
  },
672
- [s, g]
673
- ), T = b.useCallback(() => d ? w((p) => !p) : v((p) => !p), [d, v, w]);
674
- b.useEffect(() => {
675
- const p = (f) => {
676
- f.key === me && (f.metaKey || f.ctrlKey) && (f.preventDefault(), T());
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());
677
678
  };
678
- return window.addEventListener("keydown", p), () => window.removeEventListener("keydown", p);
679
+ return window.addEventListener("keydown", b), () => window.removeEventListener("keydown", b);
679
680
  }, [T]);
680
- const _ = g ? "expanded" : "collapsed", X = b.useMemo(
681
+ const A = f ? "expanded" : "collapsed", K = g.useMemo(
681
682
  () => ({
682
- state: _,
683
- open: g,
683
+ state: A,
684
+ open: f,
684
685
  setOpen: v,
685
686
  isMobile: d,
686
687
  openMobile: i,
687
688
  setOpenMobile: w,
688
689
  toggleSidebar: T
689
690
  }),
690
- [_, g, v, d, i, w, T]
691
+ [A, f, v, d, i, w, T]
691
692
  );
692
- return /* @__PURE__ */ a(pt.Provider, { value: X, children: /* @__PURE__ */ a(ht, { delayDuration: 0, children: /* @__PURE__ */ a(
693
+ return /* @__PURE__ */ a(wt.Provider, { value: K, children: /* @__PURE__ */ a(ct, { delayDuration: 0, children: /* @__PURE__ */ a(
693
694
  "div",
694
695
  {
695
696
  "data-slot": "sidebar-wrapper",
696
697
  style: {
697
- "--sidebar-width": ce,
698
- "--sidebar-width-icon": ue,
698
+ "--sidebar-width": le,
699
+ "--sidebar-width-icon": ce,
699
700
  ...n
700
701
  },
701
702
  className: u(
@@ -707,7 +708,7 @@ function he({
707
708
  }
708
709
  ) }) });
709
710
  }
710
- function pe({
711
+ function me({
711
712
  side: t = "left",
712
713
  variant: e = "sidebar",
713
714
  collapsible: s = "offcanvas",
@@ -715,7 +716,7 @@ function pe({
715
716
  children: n,
716
717
  ...o
717
718
  }) {
718
- const { isMobile: l, state: d, openMobile: i, setOpenMobile: w } = I();
719
+ const { isMobile: l, state: d, openMobile: i, setOpenMobile: w } = _();
719
720
  return s === "none" ? /* @__PURE__ */ a(
720
721
  "div",
721
722
  {
@@ -727,21 +728,21 @@ function pe({
727
728
  ...o,
728
729
  children: n
729
730
  }
730
- ) : l ? /* @__PURE__ */ a(Jt, { open: i, onOpenChange: w, ...o, children: /* @__PURE__ */ c(
731
- ee,
731
+ ) : l ? /* @__PURE__ */ a(Xt, { open: i, onOpenChange: w, ...o, children: /* @__PURE__ */ c(
732
+ Zt,
732
733
  {
733
734
  "data-sidebar": "sidebar",
734
735
  "data-slot": "sidebar",
735
736
  "data-mobile": "true",
736
737
  className: "astw:bg-sidebar astw:text-sidebar-foreground astw:w-(--sidebar-width) astw:p-0 astw:[&>button]:hidden",
737
738
  style: {
738
- "--sidebar-width": we
739
+ "--sidebar-width": de
739
740
  },
740
741
  side: t,
741
742
  children: [
742
- /* @__PURE__ */ c(ae, { className: "astw:sr-only", children: [
743
- /* @__PURE__ */ a(se, { children: "Sidebar" }),
744
- /* @__PURE__ */ a(re, { children: "Displays the mobile sidebar." })
743
+ /* @__PURE__ */ c(te, { className: "astw:sr-only", children: [
744
+ /* @__PURE__ */ a(ee, { children: "Sidebar" }),
745
+ /* @__PURE__ */ a(ae, { children: "Displays the mobile sidebar." })
745
746
  ] }),
746
747
  /* @__PURE__ */ a("div", { className: "flex h-full w-full flex-col", children: n })
747
748
  ]
@@ -796,12 +797,12 @@ function pe({
796
797
  }
797
798
  );
798
799
  }
799
- function gt({
800
+ function ut({
800
801
  className: t,
801
802
  onClick: e,
802
803
  ...s
803
804
  }) {
804
- const { toggleSidebar: r } = I();
805
+ const { toggleSidebar: r } = _();
805
806
  return /* @__PURE__ */ c(
806
807
  B,
807
808
  {
@@ -815,13 +816,13 @@ function gt({
815
816
  },
816
817
  ...s,
817
818
  children: [
818
- /* @__PURE__ */ a(xt, { className: "astw:size-4.5" }),
819
+ /* @__PURE__ */ a(ft, { className: "astw:size-4.5" }),
819
820
  /* @__PURE__ */ a("span", { className: "astw:sr-only", children: "Toggle Sidebar" })
820
821
  ]
821
822
  }
822
823
  );
823
824
  }
824
- function ge({ className: t, ...e }) {
825
+ function he({ className: t, ...e }) {
825
826
  return /* @__PURE__ */ a(
826
827
  "main",
827
828
  {
@@ -861,7 +862,7 @@ function fe({ className: t, ...e }) {
861
862
  }
862
863
  );
863
864
  }
864
- function ve({ className: t, ...e }) {
865
+ function ge({ className: t, ...e }) {
865
866
  return /* @__PURE__ */ a(
866
867
  "div",
867
868
  {
@@ -872,7 +873,7 @@ function ve({ className: t, ...e }) {
872
873
  }
873
874
  );
874
875
  }
875
- function xe({ className: t, ...e }) {
876
+ function pe({ className: t, ...e }) {
876
877
  return /* @__PURE__ */ a(
877
878
  "ul",
878
879
  {
@@ -883,7 +884,7 @@ function xe({ className: t, ...e }) {
883
884
  }
884
885
  );
885
886
  }
886
- function ye({ className: t, ...e }) {
887
+ function ve({ className: t, ...e }) {
887
888
  return /* @__PURE__ */ a(
888
889
  "li",
889
890
  {
@@ -894,7 +895,7 @@ function ye({ className: t, ...e }) {
894
895
  }
895
896
  );
896
897
  }
897
- const Te = lt(
898
+ const xe = rt(
898
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",
899
900
  {
900
901
  variants: {
@@ -914,7 +915,7 @@ const Te = lt(
914
915
  }
915
916
  }
916
917
  );
917
- function tt({
918
+ function X({
918
919
  asChild: t = !1,
919
920
  isActive: e = !1,
920
921
  variant: s = "default",
@@ -923,23 +924,23 @@ function tt({
923
924
  className: o,
924
925
  ...l
925
926
  }) {
926
- const d = t ? P : "button", { isMobile: i, state: w } = I(), m = /* @__PURE__ */ a(
927
+ const d = t ? R : "button", { isMobile: i, state: w } = _(), m = /* @__PURE__ */ a(
927
928
  d,
928
929
  {
929
930
  "data-slot": "sidebar-menu-button",
930
931
  "data-sidebar": "menu-button",
931
932
  "data-size": r,
932
933
  "data-active": e,
933
- className: u(Te({ variant: s, size: r }), o),
934
+ className: u(xe({ variant: s, size: r }), o),
934
935
  ...l
935
936
  }
936
937
  );
937
938
  return n ? (typeof n == "string" && (n = {
938
939
  children: n
939
- }), /* @__PURE__ */ c(ne, { children: [
940
- /* @__PURE__ */ a(oe, { asChild: !0, children: m }),
940
+ }), /* @__PURE__ */ c(se, { children: [
941
+ /* @__PURE__ */ a(re, { asChild: !0, children: m }),
941
942
  /* @__PURE__ */ a(
942
- ie,
943
+ ne,
943
944
  {
944
945
  side: "right",
945
946
  align: "center",
@@ -949,14 +950,14 @@ function tt({
949
950
  )
950
951
  ] })) : m;
951
952
  }
952
- function et({
953
+ function Y({
953
954
  className: t,
954
955
  asChild: e = !1,
955
956
  showOnHover: s = !1,
956
957
  ...r
957
958
  }) {
958
959
  return /* @__PURE__ */ a(
959
- e ? P : "button",
960
+ e ? R : "button",
960
961
  {
961
962
  "data-slot": "sidebar-menu-action",
962
963
  "data-sidebar": "menu-action",
@@ -975,7 +976,7 @@ function et({
975
976
  }
976
977
  );
977
978
  }
978
- function Se({ className: t, ...e }) {
979
+ function ye({ className: t, ...e }) {
979
980
  return /* @__PURE__ */ a(
980
981
  "ul",
981
982
  {
@@ -990,7 +991,7 @@ function Se({ className: t, ...e }) {
990
991
  }
991
992
  );
992
993
  }
993
- function Ce({
994
+ function Te({
994
995
  className: t,
995
996
  ...e
996
997
  }) {
@@ -1012,7 +1013,7 @@ function Ne({
1012
1013
  ...n
1013
1014
  }) {
1014
1015
  return /* @__PURE__ */ a(
1015
- t ? P : "a",
1016
+ t ? R : "a",
1016
1017
  {
1017
1018
  "data-slot": "sidebar-menu-sub-button",
1018
1019
  "data-sidebar": "menu-sub-button",
@@ -1030,17 +1031,17 @@ function Ne({
1030
1031
  }
1031
1032
  );
1032
1033
  }
1033
- function j({ to: t, children: e, ...s }) {
1034
+ function D({ to: t, children: e, ...s }) {
1034
1035
  try {
1035
- return Rt(t), /* @__PURE__ */ a(_t, { to: t, ...s, children: e });
1036
+ return St(t), /* @__PURE__ */ a(kt, { to: t, ...s, children: e });
1036
1037
  } catch {
1037
1038
  return /* @__PURE__ */ a("a", { href: t, ...s, children: e });
1038
1039
  }
1039
1040
  }
1040
- function at({ ...t }) {
1041
+ function J({ ...t }) {
1041
1042
  return /* @__PURE__ */ a("nav", { "aria-label": "breadcrumb", "data-slot": "breadcrumb", ...t });
1042
1043
  }
1043
- function st({ className: t, ...e }) {
1044
+ function Z({ className: t, ...e }) {
1044
1045
  return /* @__PURE__ */ a(
1045
1046
  "ol",
1046
1047
  {
@@ -1053,7 +1054,7 @@ function st({ className: t, ...e }) {
1053
1054
  }
1054
1055
  );
1055
1056
  }
1056
- function rt({ className: t, ...e }) {
1057
+ function tt({ className: t, ...e }) {
1057
1058
  return /* @__PURE__ */ a(
1058
1059
  "li",
1059
1060
  {
@@ -1063,14 +1064,14 @@ function rt({ className: t, ...e }) {
1063
1064
  }
1064
1065
  );
1065
1066
  }
1066
- function nt({
1067
+ function et({
1067
1068
  asChild: t,
1068
1069
  className: e,
1069
1070
  children: s,
1070
1071
  ...r
1071
1072
  }) {
1072
1073
  return /* @__PURE__ */ a(
1073
- t ? P : j,
1074
+ t ? R : D,
1074
1075
  {
1075
1076
  "data-slot": "breadcrumb-link",
1076
1077
  className: u("astw:hover:text-foreground astw:transition-colors", e),
@@ -1079,7 +1080,7 @@ function nt({
1079
1080
  }
1080
1081
  );
1081
1082
  }
1082
- function ke({
1083
+ function Ce({
1083
1084
  children: t,
1084
1085
  className: e,
1085
1086
  ...s
@@ -1092,12 +1093,12 @@ function ke({
1092
1093
  "aria-hidden": "true",
1093
1094
  className: u("astw:[&>svg]:size-3.5", e),
1094
1095
  ...s,
1095
- children: t ?? /* @__PURE__ */ a(D, {})
1096
+ children: t ?? /* @__PURE__ */ a(I, {})
1096
1097
  }
1097
1098
  );
1098
1099
  }
1099
- const Be = (t, e) => {
1100
- const s = dt(e);
1100
+ const Se = (t, e) => {
1101
+ const s = nt(e);
1101
1102
  return t.reduce(
1102
1103
  (r, n) => {
1103
1104
  const o = s(n.meta.title, n.path);
@@ -1125,24 +1126,24 @@ const Be = (t, e) => {
1125
1126
  {}
1126
1127
  );
1127
1128
  };
1128
- function Pe(t, e, s, r) {
1129
- const n = t.split("/").filter((i) => i !== ""), o = e && n[0] === e ? n.slice(1) : n, l = Be(s, r), d = o.map((i, w) => {
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) => {
1130
1131
  const m = o.slice(0, w + 1).join("/");
1131
1132
  let h = l[m];
1132
1133
  if (!h) {
1133
1134
  const v = Object.entries(l).find(
1134
1135
  ([T]) => {
1135
- const _ = T.split("/").map((p) => p.startsWith(":") ? "[^/]+" : p).join("/");
1136
- return new RegExp(`^${_}$`).test(m);
1136
+ const A = T.split("/").map((b) => b.startsWith(":") ? "[^/]+" : b).join("/");
1137
+ return new RegExp(`^${A}$`).test(m);
1137
1138
  }
1138
1139
  )?.[1];
1139
1140
  v && (h = v);
1140
1141
  }
1141
- let g;
1142
- return h ? typeof h.breadcrumbTitle == "function" ? g = h.breadcrumbTitle(i) : typeof h.breadcrumbTitle == "string" ? g = h.breadcrumbTitle : g = h.title : g = decodeURIComponent(i), {
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), {
1143
1144
  segment: i,
1144
1145
  path: m,
1145
- title: g
1146
+ title: f
1146
1147
  };
1147
1148
  });
1148
1149
  return {
@@ -1150,45 +1151,45 @@ function Pe(t, e, s, r) {
1150
1151
  segments: d
1151
1152
  };
1152
1153
  }
1153
- const Re = () => {
1154
- const { open: t } = I();
1155
- return /* @__PURE__ */ a("div", { className: t ? "astw:md:hidden" : void 0, children: /* @__PURE__ */ a(gt, { className: "astw:-ml-2.5" }) });
1156
- }, Qe = (t) => {
1157
- const e = t.children ? t.children({ Outlet: J }) : null, s = Gt(), r = () => {
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 = () => {
1158
1159
  s.setTheme(s.theme === "dark" ? "light" : "dark");
1159
1160
  };
1160
- return /* @__PURE__ */ a(he, { className: "astw:flex astw:flex-col", children: /* @__PURE__ */ c("div", { className: "astw:flex astw:flex-1", children: [
1161
- t.sidebar ?? /* @__PURE__ */ a(_e, {}),
1162
- /* @__PURE__ */ c(ge, { className: "astw:w-[calc(100%-var(--sidebar-width))]", children: [
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: [
1163
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: [
1164
1165
  /* @__PURE__ */ c("div", { className: "astw:flex astw:items-center astw:gap-2", children: [
1165
- /* @__PURE__ */ a(Re, {}),
1166
- /* @__PURE__ */ a(Ie, {})
1166
+ /* @__PURE__ */ a(Be, {}),
1167
+ /* @__PURE__ */ a(Ae, {})
1167
1168
  ] }),
1168
- /* @__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(yt, {}) }) })
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, {}) }) })
1169
1170
  ] }) }),
1170
- /* @__PURE__ */ a("div", { className: "astw:flex astw:flex-col astw:gap-4", children: e ?? /* @__PURE__ */ a(J, {}) })
1171
+ /* @__PURE__ */ a("div", { className: "astw:flex astw:flex-col astw:gap-4", children: e ?? /* @__PURE__ */ a(V, {}) })
1171
1172
  ] })
1172
1173
  ] }) });
1173
- }, _e = (t) => {
1174
- const { title: e, icon: s, navItems: r } = y(), { pathname: n } = it(), o = R(), l = /* @__PURE__ */ c(be, { children: [
1174
+ }, Re = (t) => {
1175
+ const { title: e, icon: s, navItems: r } = y(), { pathname: n } = st(), o = E(), l = /* @__PURE__ */ c(be, { children: [
1175
1176
  s,
1176
1177
  /* @__PURE__ */ a("h1", { className: "astw:text-sm astw:mb-2 astw:mt-2 astw:px-2", children: e })
1177
1178
  ] });
1178
- return /* @__PURE__ */ c(pe, { variant: "inset", children: [
1179
+ return /* @__PURE__ */ c(me, { variant: "inset", children: [
1179
1180
  /* @__PURE__ */ c("div", { className: "astw:flex astw:justify-between astw:items-center", children: [
1180
1181
  t.header ?? l,
1181
- /* @__PURE__ */ a("div", { className: "astw:hidden astw:md:block", children: /* @__PURE__ */ a(gt, { className: "astw:-ml-1" }) })
1182
+ /* @__PURE__ */ a("div", { className: "astw:hidden astw:md:block", children: /* @__PURE__ */ a(ut, { className: "astw:-ml-1" }) })
1182
1183
  ] }),
1183
- /* @__PURE__ */ a(fe, { children: /* @__PURE__ */ a(ve, { children: /* @__PURE__ */ a(xe, { children: r.map((i) => /* @__PURE__ */ a(
1184
- Xt,
1184
+ /* @__PURE__ */ a(fe, { children: /* @__PURE__ */ a(ge, { children: /* @__PURE__ */ a(pe, { children: r.map((i) => /* @__PURE__ */ a(
1185
+ Gt,
1185
1186
  {
1186
1187
  asChild: !0,
1187
1188
  defaultOpen: i.isActive,
1188
- children: /* @__PURE__ */ c(ye, { children: [
1189
- i.url ? /* @__PURE__ */ c(N, { children: [
1190
- /* @__PURE__ */ a(tt, { asChild: !0, tooltip: i.title, children: /* @__PURE__ */ c(
1191
- j,
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,
1192
1193
  {
1193
1194
  to: i.url,
1194
1195
  className: i.url === n ? "astw:bg-sidebar-accent astw:font-medium" : void 0,
@@ -1198,29 +1199,29 @@ const Re = () => {
1198
1199
  ]
1199
1200
  }
1200
1201
  ) }),
1201
- !!i.items?.length && /* @__PURE__ */ a(Z, { asChild: !0, children: /* @__PURE__ */ c(et, { className: "astw:data-[state=open]:rotate-90", children: [
1202
- /* @__PURE__ */ a(D, {}),
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, {}),
1203
1204
  /* @__PURE__ */ a("span", { className: "astw:sr-only", children: o("toggle") })
1204
1205
  ] }) })
1205
- ] }) : /* @__PURE__ */ a(N, { children: /* @__PURE__ */ c(Z, { className: "astw:flex astw:w-[100%] astw:[&[data-state=open]_.astw-rotate-target]:rotate-90", children: [
1206
- /* @__PURE__ */ a(tt, { asChild: !0, tooltip: i.title, children: /* @__PURE__ */ c("span", { className: "astw:flex astw:w-[100%]", children: [
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: [
1207
1208
  i.icon,
1208
1209
  /* @__PURE__ */ a("span", { children: i.title })
1209
1210
  ] }) }),
1210
1211
  !!i.items?.length && /* @__PURE__ */ a(
1211
- et,
1212
+ Y,
1212
1213
  {
1213
1214
  className: "astw-rotate-target",
1214
1215
  asChild: !0,
1215
1216
  children: /* @__PURE__ */ c("span", { children: [
1216
- /* @__PURE__ */ a(D, {}),
1217
+ /* @__PURE__ */ a(I, {}),
1217
1218
  /* @__PURE__ */ a("span", { className: "astw:sr-only", children: o("toggle") })
1218
1219
  ] })
1219
1220
  }
1220
1221
  )
1221
1222
  ] }) }),
1222
- !!i.items?.length && /* @__PURE__ */ a(Yt, { children: /* @__PURE__ */ a(Se, { children: i.items?.map((w) => /* @__PURE__ */ a(Ce, { children: /* @__PURE__ */ a(Ne, { asChild: !0, children: /* @__PURE__ */ a(
1223
- j,
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,
1224
1225
  {
1225
1226
  to: w.url,
1226
1227
  className: w.url === n ? "astw:bg-sidebar-accent astw:font-medium" : void 0,
@@ -1234,188 +1235,82 @@ const Re = () => {
1234
1235
  t.footer ?? null
1235
1236
  ] });
1236
1237
  }, Ee = () => {
1237
- const { configurations: t } = y(), e = it();
1238
- return Pe(
1238
+ const { configurations: t } = y(), e = st();
1239
+ return ke(
1239
1240
  e.pathname,
1240
1241
  t.basePath,
1241
1242
  t.modules,
1242
1243
  t.locale
1243
1244
  );
1244
- }, Ie = () => {
1245
- const { segments: t } = Ee(), e = Et("/:prefix/settings/:suffix"), s = R();
1246
- return e ? /* @__PURE__ */ a(at, { children: /* @__PURE__ */ a(st, { children: /* @__PURE__ */ a("div", { className: "astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground", children: /* @__PURE__ */ a(rt, { children: /* @__PURE__ */ a(nt, { to: `/${e.params.prefix}/settings`, children: s("settings") }) }) }) }) }) : /* @__PURE__ */ a(at, { children: /* @__PURE__ */ a(st, { children: t.map((r, n) => /* @__PURE__ */ c(
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(
1247
1248
  "div",
1248
1249
  {
1249
1250
  className: "astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",
1250
1251
  children: [
1251
- /* @__PURE__ */ a(rt, { children: /* @__PURE__ */ a(nt, { to: r.path, children: r.title }) }),
1252
- n < t.length - 1 && /* @__PURE__ */ a(ke, {})
1252
+ /* @__PURE__ */ a(tt, { children: /* @__PURE__ */ a(et, { to: r.path, children: r.title }) }),
1253
+ n < t.length - 1 && /* @__PURE__ */ a(Ce, {})
1253
1254
  ]
1254
1255
  },
1255
1256
  n
1256
1257
  )) }) });
1257
- }, A = "oauth_pkce_verifier", L = "oauth_state", Ae = ({
1258
- apiEndpoint: t,
1259
- clientId: e,
1260
- state: s,
1261
- codeChallenge: r,
1262
- redirectUri: n
1263
- }) => {
1264
- const o = new URL(`${t}/oauth2/authorize`);
1265
- return o.searchParams.set("response_type", "code"), o.searchParams.set("client_id", e), o.searchParams.set(
1266
- "redirect_uri",
1267
- n ?? window.location.origin
1268
- ), o.searchParams.set("scope", "openid profile email"), o.searchParams.set("state", s), o.searchParams.set("code_challenge", r), o.searchParams.set("code_challenge_method", "S256"), o.toString();
1269
- }, Le = async ({
1270
- code: t,
1271
- returnedState: e,
1272
- apiEndpoint: s,
1273
- clientId: r,
1274
- redirectUri: n
1275
- }) => {
1276
- const o = sessionStorage.getItem(A), l = sessionStorage.getItem(L);
1277
- if (!t || !e || !o || !l) {
1278
- const i = [];
1279
- throw t || i.push("code"), e || i.push("returnedState"), o || i.push("code_verifier"), l || i.push("expectedState"), new Error(`Missing params: ${i.join(", ")}`);
1280
- }
1281
- if (e !== l)
1282
- throw new Error("State mismatch: possible CSRF attack");
1283
- const d = new URLSearchParams({
1284
- grant_type: "authorization_code",
1285
- client_id: r,
1286
- code: t,
1287
- redirect_uri: n ?? window.location.origin,
1288
- code_verifier: o
1289
- });
1290
- try {
1291
- const i = await fetch(`${s}/oauth2/token`, {
1292
- method: "POST",
1293
- headers: {
1294
- "Content-Type": "application/x-www-form-urlencoded",
1295
- Accept: "application/json",
1296
- "X-Tailor-Nonce": crypto.randomUUID()
1297
- },
1298
- credentials: "include",
1299
- body: d.toString()
1300
- }), { access_token: w } = await i.json();
1301
- return w;
1302
- } catch (i) {
1303
- throw new Error(
1304
- `Token exchange failed: ${i instanceof Error ? i.message : String(i)}`
1305
- );
1306
- }
1307
- }, Me = async () => {
1308
- const t = M.generateRandomCodeVerifier(), e = await M.calculatePKCECodeChallenge(t), s = M.generateRandomState();
1309
- return sessionStorage.setItem(A, t), sessionStorage.setItem(L, s), { codeChallenge: e, state: s };
1310
- }, Je = async ({
1311
- currentUrl: t,
1312
- apiEndpoint: e,
1313
- clientId: s,
1314
- redirectUri: r
1315
- }) => {
1316
- try {
1317
- const n = t.searchParams.get("code"), o = t.searchParams.get("state");
1318
- await Le({
1319
- apiEndpoint: e,
1320
- clientId: s,
1321
- code: n,
1322
- returnedState: o,
1323
- redirectUri: r
1324
- });
1325
- } catch (n) {
1326
- console.error(n);
1327
- } finally {
1328
- sessionStorage.removeItem(A), sessionStorage.removeItem(L), t.searchParams.delete("code"), t.searchParams.delete("state"), t.searchParams.delete("error"), t.searchParams.delete("error_description"), window.history.replaceState({}, document.title, t.toString());
1329
- }
1330
- }, bt = $(void 0), Ze = () => {
1331
- const t = F(bt);
1332
- if (t === void 0)
1333
- throw new Error(
1334
- "useBuiltinIdpAuth must be used within an BuiltinIdPAuthContextProvider"
1335
- );
1336
- return t;
1337
- }, ta = ({
1338
- apiEndpoint: t,
1339
- clientId: e,
1340
- redirectUri: s,
1341
- children: r
1342
- }) => {
1343
- const [n, o] = K(!1), l = Q(async () => {
1344
- const { codeChallenge: i, state: w } = await Me(), m = Ae({
1345
- apiEndpoint: t,
1346
- clientId: e,
1347
- codeChallenge: i,
1348
- state: w,
1349
- redirectUri: s
1350
- });
1351
- window.location.href = m;
1352
- }, [t, e, s]);
1353
- U(() => {
1354
- (async () => (await (await fetch(`${t}/query`, {
1355
- method: "POST",
1356
- headers: {
1357
- "Content-Type": "application/json",
1358
- "X-Tailor-Nonce": crypto.randomUUID()
1359
- },
1360
- credentials: "include",
1361
- // Include HTTP-only cookies
1362
- body: JSON.stringify({
1363
- query: "query Myself(){ me { id }}"
1364
- })
1365
- })).json()).data.me ? o(!0) : l())();
1366
- }, [t, l]);
1367
- const d = Q(async () => {
1368
- sessionStorage.removeItem(A), sessionStorage.removeItem(L);
1369
- try {
1370
- await fetch(`${t}/oauth2/revoke`, {
1371
- method: "POST",
1372
- headers: {
1373
- "Content-Type": "application/x-www-form-urlencoded",
1374
- "X-Tailor-Nonce": crypto.randomUUID()
1375
- },
1376
- credentials: "include",
1377
- body: ""
1378
- }), window.location.href = "/";
1379
- } catch (i) {
1380
- console.error(i);
1381
- }
1382
- }, [t]);
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;
1383
1279
  return /* @__PURE__ */ a(
1384
- bt.Provider,
1280
+ mt.Provider,
1385
1281
  {
1386
- value: H(
1387
- () => ({
1388
- login: l,
1389
- logout: d
1390
- }),
1391
- [l, d]
1392
- ),
1393
- children: n ? r : null
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
1394
1290
  }
1395
1291
  );
1292
+ }, Xe = () => {
1293
+ const t = $(mt);
1294
+ if (!t)
1295
+ throw new Error("useAuth must be used within an AuthProvider");
1296
+ return t;
1396
1297
  };
1397
1298
  export {
1398
- Ye as AppShell,
1399
- ta as BuiltinIdPAuthProvider,
1400
- _e as DefaultSidebar,
1401
- sa as Link,
1402
- L as OAUTH_STATE_KEY,
1403
- A as PKCE_VERIFIER_KEY,
1404
- Qe as SidebarLayout,
1405
- Ae as buildAuthorizationUrl,
1406
- Ot as defineI18nLabels,
1407
- Ge as defineModule,
1408
- Xe as defineResource,
1409
- Le as exchangeCodeForToken,
1410
- Je as handleOAuthCallback,
1411
- Me as prepareLogin,
1412
- qe as redirectToResource,
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,
1413
1308
  y as useAppShell,
1414
- Ze as useBuiltinIdpAuth,
1415
- ra as useLocation,
1416
- na as useNavigate,
1417
- oa as useParams,
1418
- ia as useRouteError,
1419
- la as useSearchParams,
1420
- Gt as useTheme
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
1421
1316
  };