@pelatform/starter 0.1.7 → 0.1.9

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/index.js CHANGED
@@ -1,12 +1,15 @@
1
1
  "use client";
2
2
  import {
3
3
  defaultAuthQueryOptions,
4
- fileToBase64,
5
4
  getPasswordSchema,
6
5
  getTranslations,
7
- resizeAndCropImage,
6
+ request,
7
+ setLastVisitedWorkspace,
8
8
  socialProviders
9
- } from "./chunk-2ZAZ77F6.js";
9
+ } from "./chunk-7Y52PHJN.js";
10
+ import {
11
+ WORKSPACE_SCOPED_PREFIXES
12
+ } from "./chunk-K5RU54UL.js";
10
13
 
11
14
  // src/config/hook.ts
12
15
  import { useContext } from "react";
@@ -133,7 +136,8 @@ var defaultConfig = {
133
136
  },
134
137
  custom: {
135
138
  ACCEPT_INVITATION: "/join",
136
- NEW_WORKSPACE: "/new"
139
+ NEW_WORKSPACE: "/new",
140
+ VERIFY_EMAIL: "/verify"
137
141
  }
138
142
  },
139
143
  ui: {
@@ -416,6 +420,7 @@ function useDeletePasskey(options) {
416
420
  const { queryKey } = useContext8(QueryContext);
417
421
  return useAuthMutation({
418
422
  queryKey: queryKey.listPasskeys,
423
+ // @ts-expect-error - passkeyClient does not exist
419
424
  mutationFn: authClient.passkey.deletePasskey,
420
425
  options
421
426
  });
@@ -425,6 +430,7 @@ function useListPasskeys(options) {
425
430
  const { queryKey } = useContext8(QueryContext);
426
431
  return useAuthQuery({
427
432
  queryKey: queryKey.listPasskeys,
433
+ // @ts-expect-error - passkeyClient does not exist
428
434
  queryFn: authClient.passkey.listUserPasskeys,
429
435
  options
430
436
  });
@@ -469,11 +475,27 @@ function useRevokeSessions(options) {
469
475
  });
470
476
  }
471
477
 
478
+ // src/hooks/use-invitation.ts
479
+ import { useContext as useContext10 } from "react";
480
+ function useInvitation(params, options) {
481
+ const { authClient } = useConfig();
482
+ const { queryKey: key } = useContext10(QueryContext);
483
+ const queryKey = [key.invitationKey, JSON.stringify(params)];
484
+ return useAuthQuery({
485
+ queryKey,
486
+ queryFn: (fnParams) => authClient.organization.getInvitation({
487
+ ...params,
488
+ ...fnParams
489
+ }),
490
+ options
491
+ });
492
+ }
493
+
472
494
  // src/hooks/use-layout.ts
473
- import { createContext as createContext2, useContext as useContext10 } from "react";
495
+ import { createContext as createContext2, useContext as useContext11 } from "react";
474
496
  var LayoutContext = createContext2(void 0);
475
497
  var useLayout = () => {
476
- const context = useContext10(LayoutContext);
498
+ const context = useContext11(LayoutContext);
477
499
  if (!context) {
478
500
  throw new Error("useLayout must be used within a LayoutProvider");
479
501
  }
@@ -506,10 +528,10 @@ function useOnSuccessTransition(redirectToProp) {
506
528
  }
507
529
 
508
530
  // src/hooks/use-update-user.ts
509
- import { useContext as useContext11 } from "react";
531
+ import { useContext as useContext12 } from "react";
510
532
  function useUpdateUser(options) {
511
533
  const { authClient } = useConfig();
512
- const { queryKey } = useContext11(QueryContext);
534
+ const { queryKey } = useContext12(QueryContext);
513
535
  return useAuthMutation({
514
536
  queryKey: queryKey.session,
515
537
  mutationFn: authClient.updateUser,
@@ -521,20 +543,15 @@ function useUpdateUser(options) {
521
543
  });
522
544
  }
523
545
 
524
- // src/hooks/use-invitation.ts
525
- import { useContext as useContext12 } from "react";
526
- function useInvitation(params, options) {
527
- const { authClient } = useConfig();
528
- const { queryKey: key } = useContext12(QueryContext);
529
- const queryKey = [key.invitationKey, JSON.stringify(params)];
530
- return useAuthQuery({
531
- queryKey,
532
- queryFn: (fnParams) => authClient.organization.getInvitation({
533
- ...params,
534
- ...fnParams
535
- }),
536
- options
537
- });
546
+ // src/hooks/use-workspace.ts
547
+ import { createContext as createContext3, useContext as useContext13 } from "react";
548
+ var WorkspaceContext = createContext3(void 0);
549
+ function useWorkspace() {
550
+ const context = useContext13(WorkspaceContext);
551
+ if (context === void 0) {
552
+ throw new Error("useWorkspace must be used within a WorkspaceProvider");
553
+ }
554
+ return context;
538
555
  }
539
556
 
540
557
  // src/ui/account/dialogs/backup-codes.tsx
@@ -822,6 +839,7 @@ function WorkspaceLogo({
822
839
  isPending,
823
840
  size,
824
841
  workspace,
842
+ image,
825
843
  ...props
826
844
  }) {
827
845
  const t = useTranslations3();
@@ -850,7 +868,7 @@ function WorkspaceLogo({
850
868
  /* @__PURE__ */ jsx5(
851
869
  AvatarImage,
852
870
  {
853
- src: src || void 0,
871
+ src: image || src || void 0,
854
872
  alt: name || t("systems.ORGANIZATION"),
855
873
  className: classNames?.image
856
874
  }
@@ -1568,6 +1586,7 @@ function DeleteAccountCard({
1568
1586
  import { useRef, useState as useState5 } from "react";
1569
1587
  import { Trash2Icon, UploadCloudIcon } from "lucide-react";
1570
1588
  import { useTranslations as useTranslations9 } from "next-intl";
1589
+ import { fileToBase64, resizeAndCropImage } from "pelatform-ui";
1571
1590
  import { AlertToast as AlertToast3 } from "pelatform-ui/components";
1572
1591
  import {
1573
1592
  Button as Button8,
@@ -2438,6 +2457,7 @@ function PasskeysCard({ className, classNames, ...props }) {
2438
2457
  isPending: passkeysPending,
2439
2458
  refetch: refetchPasskeys
2440
2459
  } = useListPasskeys();
2460
+ const typedPasskeys = passkeys;
2441
2461
  const isPending = sessionPending || passkeysPending;
2442
2462
  const isFresh = session ? Date.now() - new Date(session?.createdAt).getTime() < auth.freshAge * 1e3 : false;
2443
2463
  const [showFreshnessDialog, setShowFreshnessDialog] = useState8(false);
@@ -2479,7 +2499,7 @@ function PasskeysCard({ className, classNames, ...props }) {
2479
2499
  actionLabel: t("systems.ADD_PASSKEY"),
2480
2500
  isPending,
2481
2501
  ...props,
2482
- children: isPending ? /* @__PURE__ */ jsx20("div", { className: cn15("grid gap-4", classNames?.grid), children: /* @__PURE__ */ jsx20(SkeletonViewComponent, { classNames }) }) : passkeys && passkeys.length > 0 && /* @__PURE__ */ jsx20("div", { className: cn15("grid gap-4", classNames?.grid), children: passkeys?.map((passkey) => /* @__PURE__ */ jsx20(PasskeyCell, { classNames, passkey }, passkey.id)) })
2502
+ children: isPending ? /* @__PURE__ */ jsx20("div", { className: cn15("grid gap-4", classNames?.grid), children: /* @__PURE__ */ jsx20(SkeletonViewComponent, { classNames }) }) : typedPasskeys && typedPasskeys.length > 0 && /* @__PURE__ */ jsx20("div", { className: cn15("grid gap-4", classNames?.grid), children: typedPasskeys.map((passkey) => /* @__PURE__ */ jsx20(PasskeyCell, { classNames, passkey }, passkey.id)) })
2483
2503
  }
2484
2504
  ) }) })
2485
2505
  ] });
@@ -5371,9 +5391,9 @@ function AuthForm({
5371
5391
  }
5372
5392
 
5373
5393
  // src/ui/layouts/auth.tsx
5374
- import Link5 from "next/link";
5394
+ import Link6 from "next/link";
5375
5395
  import { usePathname } from "next/navigation";
5376
- import { useTranslations as useTranslations43 } from "next-intl";
5396
+ import { useTranslations as useTranslations44 } from "next-intl";
5377
5397
  import { LayoutBlank } from "pelatform-ui/components";
5378
5398
 
5379
5399
  // src/ui/shared/logo.tsx
@@ -5396,15 +5416,33 @@ function LogoWithHref({ className, href = "/" }) {
5396
5416
  ] });
5397
5417
  }
5398
5418
 
5399
- // src/ui/layouts/loader.tsx
5419
+ // src/ui/shared/signed-in-hint.tsx
5420
+ import Link5 from "next/link";
5400
5421
  import { useTranslations as useTranslations41 } from "next-intl";
5422
+ import { Button as Button31 } from "pelatform-ui/default";
5423
+ import { jsx as jsx49, jsxs as jsxs42 } from "react/jsx-runtime";
5424
+ function SignedInHint({ linkHref = "/signin" }) {
5425
+ const t = useTranslations41("customs.common.signed");
5426
+ const { isPending, user } = useSession();
5427
+ return /* @__PURE__ */ jsxs42("div", { className: "fixed start-0 bottom-0 z-40 m-5 flex flex-col gap-2", children: [
5428
+ /* @__PURE__ */ jsxs42("div", { className: "flex items-center gap-1 text-muted-foreground text-xs", children: [
5429
+ t("text"),
5430
+ " ",
5431
+ isPending || !user ? /* @__PURE__ */ jsx49("span", { className: "h-3 w-32 animate-pulse rounded-md border bg-muted-foreground" }) : /* @__PURE__ */ jsx49("b", { className: "text-foreground", children: user.email })
5432
+ ] }),
5433
+ /* @__PURE__ */ jsx49(Button31, { variant: "mono", className: "h-8 w-fit rounded-lg px-3 text-xs shadow-sm", children: /* @__PURE__ */ jsx49(Link5, { href: linkHref, children: t("button") }) })
5434
+ ] });
5435
+ }
5436
+
5437
+ // src/ui/layouts/loader.tsx
5438
+ import { useTranslations as useTranslations42 } from "next-intl";
5401
5439
  import { ScreenLoader } from "pelatform-ui/components";
5402
- import { jsx as jsx49 } from "react/jsx-runtime";
5440
+ import { jsx as jsx50 } from "react/jsx-runtime";
5403
5441
  function LayoutLoader({ children }) {
5404
- const t = useTranslations41();
5442
+ const t = useTranslations42();
5405
5443
  const { isPending } = useSession();
5406
5444
  if (isPending) {
5407
- return /* @__PURE__ */ jsx49(ScreenLoader, { loadingText: t("systems.common.status.loading") });
5445
+ return /* @__PURE__ */ jsx50(ScreenLoader, { loadingText: t("systems.common.status.loading") });
5408
5446
  }
5409
5447
  return children;
5410
5448
  }
@@ -5417,11 +5455,11 @@ import { ModeSwitcher } from "pelatform-ui/components";
5417
5455
  // src/ui/shared/language-switcher.tsx
5418
5456
  import Image from "next/image";
5419
5457
  import { useRouter as useRouter14 } from "next/navigation";
5420
- import { useLocale as useLocale3, useTranslations as useTranslations42 } from "next-intl";
5458
+ import { useLocale as useLocale3, useTranslations as useTranslations43 } from "next-intl";
5421
5459
  import {
5422
5460
  LanguageSwitcher as LanguageSwitcherBase
5423
5461
  } from "pelatform-ui/components";
5424
- import { jsx as jsx50 } from "react/jsx-runtime";
5462
+ import { jsx as jsx51 } from "react/jsx-runtime";
5425
5463
  function LanguageSwitcher({
5426
5464
  className,
5427
5465
  type,
@@ -5432,7 +5470,7 @@ function LanguageSwitcher({
5432
5470
  }) {
5433
5471
  const { i18n } = useConfig();
5434
5472
  const router = useRouter14();
5435
- const t = useTranslations42();
5473
+ const t = useTranslations43();
5436
5474
  const currentLocale = useLocale3();
5437
5475
  const availableLocales = (() => {
5438
5476
  if (!i18n.enabled) {
@@ -5456,7 +5494,7 @@ function LanguageSwitcher({
5456
5494
  document.cookie = `${i18n.localeCookieName}=${newLocale}; max-age=${60 * 60 * 24 * 365}; path=/`;
5457
5495
  router.refresh();
5458
5496
  }
5459
- return /* @__PURE__ */ jsx50(
5497
+ return /* @__PURE__ */ jsx51(
5460
5498
  LanguageSwitcherBase,
5461
5499
  {
5462
5500
  className,
@@ -5477,34 +5515,37 @@ function LanguageSwitcher({
5477
5515
  }
5478
5516
 
5479
5517
  // src/ui/layouts/toolbar.tsx
5480
- import { jsx as jsx51, jsxs as jsxs42 } from "react/jsx-runtime";
5518
+ import { jsx as jsx52, jsxs as jsxs43 } from "react/jsx-runtime";
5481
5519
  var DEFAULT_SHOW = ["darkmode"];
5482
5520
  function Toolbar(props) {
5483
- return /* @__PURE__ */ jsx51(Suspense, { fallback: null, children: /* @__PURE__ */ jsx51("div", { className: cn40("fixed end-0 bottom-0 z-40 m-5", props.className), children: /* @__PURE__ */ jsx51(ToolbarRSC, { ...props }) }) });
5521
+ return /* @__PURE__ */ jsx52(Suspense, { fallback: null, children: /* @__PURE__ */ jsx52("div", { className: cn40("fixed end-0 bottom-0 z-40 m-5", props.className), children: /* @__PURE__ */ jsx52(ToolbarRSC, { ...props }) }) });
5484
5522
  }
5485
5523
  function ToolbarRSC({ show = DEFAULT_SHOW }) {
5486
- return /* @__PURE__ */ jsx51("div", { className: "flex flex-col items-center gap-2.5", children: /* @__PURE__ */ jsxs42("div", { className: "shrink-0", children: [
5487
- show.includes("darkmode") && /* @__PURE__ */ jsx51(ModeSwitcher, { variant: "outline", size: "lg", className: "size-10 rounded-full border" }),
5488
- show.includes("help") && /* @__PURE__ */ jsx51("div", { className: "hidden" }),
5489
- show.includes("language") && /* @__PURE__ */ jsx51(LanguageSwitcher, { variant: "outline", size: "lg", className: "size-10 rounded-full border" }),
5490
- show.includes("onboarding") && /* @__PURE__ */ jsx51("div", { className: "hidden" })
5524
+ return /* @__PURE__ */ jsx52("div", { className: "flex flex-col items-center gap-2.5", children: /* @__PURE__ */ jsxs43("div", { className: "shrink-0", children: [
5525
+ show.includes("darkmode") && /* @__PURE__ */ jsx52(ModeSwitcher, { variant: "outline", size: "lg", className: "size-10 rounded-full border" }),
5526
+ show.includes("help") && /* @__PURE__ */ jsx52("div", { className: "hidden" }),
5527
+ show.includes("language") && /* @__PURE__ */ jsx52(LanguageSwitcher, { variant: "outline", size: "lg", className: "size-10 rounded-full border" }),
5528
+ show.includes("onboarding") && /* @__PURE__ */ jsx52("div", { className: "hidden" })
5491
5529
  ] }) });
5492
5530
  }
5493
5531
 
5494
5532
  // src/ui/layouts/auth.tsx
5495
- import { jsx as jsx52, jsxs as jsxs43 } from "react/jsx-runtime";
5533
+ import { jsx as jsx53, jsxs as jsxs44 } from "react/jsx-runtime";
5496
5534
  function AuthLayout({
5497
5535
  children,
5498
- logo = /* @__PURE__ */ jsx52(LogoWithName, {})
5536
+ logo = /* @__PURE__ */ jsx53(LogoWithName, {}),
5537
+ disableFooter = false,
5538
+ signInHint = false,
5539
+ signInHref
5499
5540
  }) {
5500
5541
  const { app, path } = useConfig();
5501
5542
  const pathname = usePathname();
5502
- const t = useTranslations43();
5503
- const footer = /* @__PURE__ */ jsxs43("p", { className: "px-20 py-4 text-center font-medium text-muted-foreground text-xs md:px-0", children: [
5543
+ const t = useTranslations44();
5544
+ const footer = /* @__PURE__ */ jsxs44("p", { className: "px-20 py-4 text-center font-medium text-muted-foreground text-xs md:px-0", children: [
5504
5545
  t("customs.common.agree"),
5505
5546
  " ",
5506
- /* @__PURE__ */ jsx52(
5507
- Link5,
5547
+ /* @__PURE__ */ jsx53(
5548
+ Link6,
5508
5549
  {
5509
5550
  href: path.main.TERMS,
5510
5551
  target: "_blank",
@@ -5513,8 +5554,8 @@ function AuthLayout({
5513
5554
  }
5514
5555
  ),
5515
5556
  " ",
5516
- /* @__PURE__ */ jsx52(
5517
- Link5,
5557
+ /* @__PURE__ */ jsx53(
5558
+ Link6,
5518
5559
  {
5519
5560
  href: path.main.PRIVACY,
5520
5561
  target: "_blank",
@@ -5523,19 +5564,20 @@ function AuthLayout({
5523
5564
  }
5524
5565
  )
5525
5566
  ] });
5526
- return /* @__PURE__ */ jsxs43(LayoutLoader, { children: [
5527
- /* @__PURE__ */ jsx52(Toolbar, { show: ["language"], className: "top-0!" }),
5528
- /* @__PURE__ */ jsx52(
5567
+ return /* @__PURE__ */ jsxs44(LayoutLoader, { children: [
5568
+ /* @__PURE__ */ jsx53(Toolbar, { show: ["language"], className: "top-0!" }),
5569
+ /* @__PURE__ */ jsx53(
5529
5570
  LayoutBlank,
5530
5571
  {
5531
5572
  className: "[&_.max-w-4xl]:max-w-sm [&_.max-w-4xl]:px-0",
5532
5573
  logo,
5533
5574
  logoHref: app.url,
5534
- footer: pathname === path.auth.SIGN_OUT || pathname === path.auth.CALLBACK ? null : footer,
5575
+ footer: disableFooter || pathname === path.auth.SIGN_OUT || pathname === path.auth.CALLBACK ? null : footer,
5535
5576
  children
5536
5577
  }
5537
5578
  ),
5538
- /* @__PURE__ */ jsx52(Toolbar, { show: ["darkmode"] })
5579
+ /* @__PURE__ */ jsx53(Toolbar, { show: ["darkmode"] }),
5580
+ signInHint && /* @__PURE__ */ jsx53(SignedInHint, { linkHref: signInHref || path.auth.SIGN_OUT })
5539
5581
  ] });
5540
5582
  }
5541
5583
 
@@ -5544,7 +5586,7 @@ import { useEffect as useEffect15, useState as useState18 } from "react";
5544
5586
  import { usePathname as usePathname2 } from "next/navigation";
5545
5587
  import { Menu, PanelRight } from "lucide-react";
5546
5588
  import {
5547
- Button as Button31,
5589
+ Button as Button32,
5548
5590
  Sheet,
5549
5591
  SheetBody,
5550
5592
  SheetContent,
@@ -5556,10 +5598,10 @@ import {
5556
5598
 
5557
5599
  // src/ui/shared/user-menu.tsx
5558
5600
  import { Fragment as Fragment17, useCallback as useCallback3, useEffect as useEffect14, useState as useState17 } from "react";
5559
- import Link6 from "next/link";
5601
+ import Link7 from "next/link";
5560
5602
  import { useRouter as useRouter15 } from "next/navigation";
5561
5603
  import { LogOut, PlusCircleIcon, Settings, Shield, UserStar } from "lucide-react";
5562
- import { useTranslations as useTranslations44 } from "next-intl";
5604
+ import { useTranslations as useTranslations45 } from "next-intl";
5563
5605
  import { ModeSwitcher as ModeSwitcher2, UserAvatar as UserAvatar2 } from "pelatform-ui/components";
5564
5606
  import {
5565
5607
  Badge as Badge2,
@@ -5570,11 +5612,11 @@ import {
5570
5612
  DropdownMenuTrigger as DropdownMenuTrigger3,
5571
5613
  Skeleton as Skeleton9
5572
5614
  } from "pelatform-ui/default";
5573
- import { Fragment as Fragment18, jsx as jsx53, jsxs as jsxs44 } from "react/jsx-runtime";
5615
+ import { Fragment as Fragment18, jsx as jsx54, jsxs as jsxs45 } from "react/jsx-runtime";
5574
5616
  function UserMenu({ hiddenSwitcher = false }) {
5575
5617
  const { features, path } = useConfig();
5576
5618
  const router = useRouter15();
5577
- const t = useTranslations44();
5619
+ const t = useTranslations45();
5578
5620
  const { isPending: sessionPending, user } = useSession();
5579
5621
  const { setActiveSessionAsync } = useSetActiveSession();
5580
5622
  const { data: deviceSessions, isPending: deviceSessionsPending } = useListDeviceSessions({
@@ -5607,33 +5649,33 @@ function UserMenu({ hiddenSwitcher = false }) {
5607
5649
  const userName = getName(user);
5608
5650
  const userAvatar = user?.image || void 0;
5609
5651
  const userRole = user?.role || "user";
5610
- return /* @__PURE__ */ jsxs44(DropdownMenu3, { children: [
5611
- /* @__PURE__ */ jsx53(DropdownMenuTrigger3, { className: "focus:outline-none focus:ring-0", children: isPending ? /* @__PURE__ */ jsx53(Skeleton9, { className: "size-8 shrink-0 rounded-full" }) : /* @__PURE__ */ jsx53(UserAvatar2, { className: "size-8", indicator: true, src: userAvatar, alt: userName }) }),
5612
- /* @__PURE__ */ jsxs44(DropdownMenuContent3, { className: "w-56", side: "bottom", align: "end", sideOffset: 11, children: [
5613
- /* @__PURE__ */ jsxs44("div", { className: "flex items-center gap-3 px-3 py-2", children: [
5614
- /* @__PURE__ */ jsx53(UserAvatar2, { src: userAvatar, alt: userName }),
5615
- /* @__PURE__ */ jsxs44("div", { className: "flex min-w-0 flex-1 flex-col items-start", children: [
5616
- /* @__PURE__ */ jsx53("span", { className: "truncate font-semibold text-foreground text-sm", children: userName }),
5617
- /* @__PURE__ */ jsx53("span", { className: "block w-full truncate text-muted-foreground text-xs", children: userEmail }),
5618
- /* @__PURE__ */ jsx53(Badge2, { variant: "success", appearance: "outline", size: "sm", className: "mt-1", children: userRole.toUpperCase() })
5652
+ return /* @__PURE__ */ jsxs45(DropdownMenu3, { children: [
5653
+ /* @__PURE__ */ jsx54(DropdownMenuTrigger3, { className: "focus:outline-none focus:ring-0", children: isPending ? /* @__PURE__ */ jsx54(Skeleton9, { className: "size-8 shrink-0 rounded-full" }) : /* @__PURE__ */ jsx54(UserAvatar2, { className: "size-8", indicator: true, src: userAvatar, alt: userName }) }),
5654
+ /* @__PURE__ */ jsxs45(DropdownMenuContent3, { className: "w-56", side: "bottom", align: "end", sideOffset: 11, children: [
5655
+ /* @__PURE__ */ jsxs45("div", { className: "flex items-center gap-3 px-3 py-2", children: [
5656
+ /* @__PURE__ */ jsx54(UserAvatar2, { src: userAvatar, alt: userName }),
5657
+ /* @__PURE__ */ jsxs45("div", { className: "flex min-w-0 flex-1 flex-col items-start", children: [
5658
+ /* @__PURE__ */ jsx54("span", { className: "truncate font-semibold text-foreground text-sm", children: userName }),
5659
+ /* @__PURE__ */ jsx54("span", { className: "block w-full truncate text-muted-foreground text-xs", children: userEmail }),
5660
+ /* @__PURE__ */ jsx54(Badge2, { variant: "success", appearance: "outline", size: "sm", className: "mt-1", children: userRole.toUpperCase() })
5619
5661
  ] })
5620
5662
  ] }),
5621
- /* @__PURE__ */ jsx53(DropdownMenuSeparator, {}),
5622
- /* @__PURE__ */ jsx53(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs44(Link6, { href: path.account.SETTINGS, children: [
5623
- /* @__PURE__ */ jsx53(Settings, {}),
5624
- /* @__PURE__ */ jsx53("span", { children: t("systems.navigation.preferences") })
5663
+ /* @__PURE__ */ jsx54(DropdownMenuSeparator, {}),
5664
+ /* @__PURE__ */ jsx54(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs45(Link7, { href: path.account.SETTINGS, children: [
5665
+ /* @__PURE__ */ jsx54(Settings, {}),
5666
+ /* @__PURE__ */ jsx54("span", { children: t("systems.navigation.preferences") })
5625
5667
  ] }) }),
5626
- /* @__PURE__ */ jsx53(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs44(Link6, { href: path.account.SECURITY, children: [
5627
- /* @__PURE__ */ jsx53(Shield, {}),
5628
- /* @__PURE__ */ jsx53("span", { children: t("systems.navigation.security") })
5668
+ /* @__PURE__ */ jsx54(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs45(Link7, { href: path.account.SECURITY, children: [
5669
+ /* @__PURE__ */ jsx54(Shield, {}),
5670
+ /* @__PURE__ */ jsx54("span", { children: t("systems.navigation.security") })
5629
5671
  ] }) }),
5630
- "admin" === userRole && /* @__PURE__ */ jsx53(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs44(Link6, { href: path.admin.OVERVIEW, children: [
5631
- /* @__PURE__ */ jsx53(UserStar, {}),
5632
- /* @__PURE__ */ jsx53("span", { children: "Admin Dashboard" })
5672
+ "admin" === userRole && /* @__PURE__ */ jsx54(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs45(Link7, { href: path.admin.OVERVIEW, children: [
5673
+ /* @__PURE__ */ jsx54(UserStar, {}),
5674
+ /* @__PURE__ */ jsx54("span", { children: "Admin Dashboard" })
5633
5675
  ] }) }),
5634
- !hiddenSwitcher && /* @__PURE__ */ jsxs44(Fragment18, { children: [
5635
- /* @__PURE__ */ jsx53(DropdownMenuSeparator, {}),
5636
- /* @__PURE__ */ jsx53(
5676
+ !hiddenSwitcher && /* @__PURE__ */ jsxs45(Fragment18, { children: [
5677
+ /* @__PURE__ */ jsx54(DropdownMenuSeparator, {}),
5678
+ /* @__PURE__ */ jsx54(
5637
5679
  ModeSwitcher2,
5638
5680
  {
5639
5681
  type: "sub-dropdown",
@@ -5644,31 +5686,31 @@ function UserMenu({ hiddenSwitcher = false }) {
5644
5686
  }
5645
5687
  }
5646
5688
  ),
5647
- /* @__PURE__ */ jsx53(LanguageSwitcher, { type: "sub-dropdown" })
5689
+ /* @__PURE__ */ jsx54(LanguageSwitcher, { type: "sub-dropdown" })
5648
5690
  ] }),
5649
- /* @__PURE__ */ jsx53(DropdownMenuSeparator, {}),
5650
- /* @__PURE__ */ jsx53(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs44(Link6, { href: path.auth.SIGN_OUT, children: [
5651
- /* @__PURE__ */ jsx53(LogOut, {}),
5652
- /* @__PURE__ */ jsx53("span", { children: t("systems.navigation.logout") })
5691
+ /* @__PURE__ */ jsx54(DropdownMenuSeparator, {}),
5692
+ /* @__PURE__ */ jsx54(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs45(Link7, { href: path.auth.SIGN_OUT, children: [
5693
+ /* @__PURE__ */ jsx54(LogOut, {}),
5694
+ /* @__PURE__ */ jsx54("span", { children: t("systems.navigation.logout") })
5653
5695
  ] }) }),
5654
- user && features.multiSession && /* @__PURE__ */ jsxs44(Fragment18, { children: [
5655
- /* @__PURE__ */ jsx53(DropdownMenuSeparator, {}),
5656
- !deviceSessions && deviceSessionsPending && /* @__PURE__ */ jsxs44(Fragment18, { children: [
5657
- /* @__PURE__ */ jsx53(DropdownMenuItem3, { disabled: true, children: /* @__PURE__ */ jsx53(UserView, { isPending: true }) }),
5658
- /* @__PURE__ */ jsx53(DropdownMenuSeparator, {})
5696
+ user && features.multiSession && /* @__PURE__ */ jsxs45(Fragment18, { children: [
5697
+ /* @__PURE__ */ jsx54(DropdownMenuSeparator, {}),
5698
+ !deviceSessions && deviceSessionsPending && /* @__PURE__ */ jsxs45(Fragment18, { children: [
5699
+ /* @__PURE__ */ jsx54(DropdownMenuItem3, { disabled: true, children: /* @__PURE__ */ jsx54(UserView, { isPending: true }) }),
5700
+ /* @__PURE__ */ jsx54(DropdownMenuSeparator, {})
5659
5701
  ] }),
5660
- deviceSessions?.filter((sessionData) => sessionData.user.id !== user?.id).map(({ session, user: multiUser }) => /* @__PURE__ */ jsxs44(Fragment17, { children: [
5661
- /* @__PURE__ */ jsxs44(DropdownMenuItem3, { onClick: () => switchAccount(session.token), children: [
5662
- /* @__PURE__ */ jsx53(UserAvatar2, { src: multiUser?.image || void 0, alt: getName(multiUser) }),
5663
- /* @__PURE__ */ jsxs44("div", { className: "flex min-w-0 flex-1 flex-col items-start", children: [
5664
- /* @__PURE__ */ jsx53("span", { className: "truncate font-semibold text-foreground text-xs", children: getName(multiUser) }),
5665
- /* @__PURE__ */ jsx53("span", { className: "block w-full truncate text-muted-foreground text-xs", children: multiUser?.email })
5702
+ deviceSessions?.filter((sessionData) => sessionData.user.id !== user?.id).map(({ session, user: multiUser }) => /* @__PURE__ */ jsxs45(Fragment17, { children: [
5703
+ /* @__PURE__ */ jsxs45(DropdownMenuItem3, { onClick: () => switchAccount(session.token), children: [
5704
+ /* @__PURE__ */ jsx54(UserAvatar2, { src: multiUser?.image || void 0, alt: getName(multiUser) }),
5705
+ /* @__PURE__ */ jsxs45("div", { className: "flex min-w-0 flex-1 flex-col items-start", children: [
5706
+ /* @__PURE__ */ jsx54("span", { className: "truncate font-semibold text-foreground text-xs", children: getName(multiUser) }),
5707
+ /* @__PURE__ */ jsx54("span", { className: "block w-full truncate text-muted-foreground text-xs", children: multiUser?.email })
5666
5708
  ] })
5667
5709
  ] }),
5668
- /* @__PURE__ */ jsx53(DropdownMenuSeparator, {})
5710
+ /* @__PURE__ */ jsx54(DropdownMenuSeparator, {})
5669
5711
  ] }, session.id)),
5670
- /* @__PURE__ */ jsx53(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs44(Link6, { href: path.auth.SIGN_IN, children: [
5671
- /* @__PURE__ */ jsx53(PlusCircleIcon, {}),
5712
+ /* @__PURE__ */ jsx54(DropdownMenuItem3, { asChild: true, children: /* @__PURE__ */ jsxs45(Link7, { href: path.auth.SIGN_IN, children: [
5713
+ /* @__PURE__ */ jsx54(PlusCircleIcon, {}),
5672
5714
  t("systems.ADD_ACCOUNT")
5673
5715
  ] }) })
5674
5716
  ] })
@@ -5677,32 +5719,32 @@ function UserMenu({ hiddenSwitcher = false }) {
5677
5719
  }
5678
5720
 
5679
5721
  // src/ui/layouts/header.tsx
5680
- import { jsx as jsx54, jsxs as jsxs45 } from "react/jsx-runtime";
5722
+ import { jsx as jsx55, jsxs as jsxs46 } from "react/jsx-runtime";
5681
5723
  function Header({ children }) {
5682
- return /* @__PURE__ */ jsx54("header", { className: "fixed start-0 end-0 top-0 z-10 flex h-(--header-height-mobile) shrink-0 items-stretch border-border border-b bg-background/95 pe-(--removed-body-scroll-bar-size,0px) backdrop-blur-sm supports-backdrop-filter:bg-background/60 lg:h-(--header-height)", children: /* @__PURE__ */ jsx54("div", { className: "@container flex grow items-stretch justify-between gap-2.5 pe-5", children }) });
5724
+ return /* @__PURE__ */ jsx55("header", { className: "fixed start-0 end-0 top-0 z-10 flex h-(--header-height-mobile) shrink-0 items-stretch border-border border-b bg-background/95 pe-(--removed-body-scroll-bar-size,0px) backdrop-blur-sm supports-backdrop-filter:bg-background/60 lg:h-(--header-height)", children: /* @__PURE__ */ jsx55("div", { className: "@container flex grow items-stretch justify-between gap-2.5 pe-5", children }) });
5683
5725
  }
5684
5726
  function HeaderLeft() {
5685
5727
  const { logoHeader, sidebarToggle } = useLayout();
5686
- return /* @__PURE__ */ jsx54("div", { className: "flex items-center gap-2 px-5 lg:w-(--sidebar-width)", children: /* @__PURE__ */ jsxs45("div", { className: "flex w-full items-center justify-between", children: [
5728
+ return /* @__PURE__ */ jsx55("div", { className: "flex items-center gap-2 px-5 lg:w-(--sidebar-width)", children: /* @__PURE__ */ jsxs46("div", { className: "flex w-full items-center justify-between", children: [
5687
5729
  logoHeader,
5688
- /* @__PURE__ */ jsx54(
5689
- Button31,
5730
+ /* @__PURE__ */ jsx55(
5731
+ Button32,
5690
5732
  {
5691
5733
  mode: "icon",
5692
5734
  variant: "ghost",
5693
5735
  onClick: sidebarToggle,
5694
5736
  className: "hidden text-muted-foreground hover:text-foreground lg:inline-flex",
5695
- children: /* @__PURE__ */ jsx54(PanelRight, { className: "-rotate-180 in-data-[sidebar-open=false]:rotate-0 opacity-100" })
5737
+ children: /* @__PURE__ */ jsx55(PanelRight, { className: "-rotate-180 in-data-[sidebar-open=false]:rotate-0 opacity-100" })
5696
5738
  }
5697
5739
  )
5698
5740
  ] }) });
5699
5741
  }
5700
5742
  function HeaderRight({ sidebar, button }) {
5701
5743
  const { isMobile } = useLayout();
5702
- return /* @__PURE__ */ jsxs45("nav", { className: "flex items-center gap-1.5 lg:gap-2.5", children: [
5744
+ return /* @__PURE__ */ jsxs46("nav", { className: "flex items-center gap-1.5 lg:gap-2.5", children: [
5703
5745
  button,
5704
5746
  isMobile && sidebar,
5705
- /* @__PURE__ */ jsx54(UserMenu, {})
5747
+ /* @__PURE__ */ jsx55(UserMenu, {})
5706
5748
  ] });
5707
5749
  }
5708
5750
  function HeaderSidebarMobile({ children }) {
@@ -5711,23 +5753,23 @@ function HeaderSidebarMobile({ children }) {
5711
5753
  useEffect15(() => {
5712
5754
  setIsSheetOpen(false);
5713
5755
  }, [pathname]);
5714
- return /* @__PURE__ */ jsxs45(Sheet, { open: isSheetOpen, onOpenChange: setIsSheetOpen, children: [
5715
- /* @__PURE__ */ jsx54(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsx54(Button31, { variant: "ghost", mode: "icon", size: "icon", children: /* @__PURE__ */ jsx54(Menu, { className: "size-4" }) }) }),
5716
- /* @__PURE__ */ jsxs45(SheetContent, { className: "w-(--sidebar-width) gap-0 p-0", side: "left", close: false, children: [
5717
- /* @__PURE__ */ jsxs45(SheetHeader, { className: "hidden space-y-0 p-0", children: [
5718
- /* @__PURE__ */ jsx54(SheetTitle, { className: "sr-only", children: "Navigation menu" }),
5719
- /* @__PURE__ */ jsx54(SheetDescription, { className: "sr-only", children: "NavigatSheet Description" })
5756
+ return /* @__PURE__ */ jsxs46(Sheet, { open: isSheetOpen, onOpenChange: setIsSheetOpen, children: [
5757
+ /* @__PURE__ */ jsx55(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsx55(Button32, { variant: "ghost", mode: "icon", size: "icon", children: /* @__PURE__ */ jsx55(Menu, { className: "size-4" }) }) }),
5758
+ /* @__PURE__ */ jsxs46(SheetContent, { className: "w-(--sidebar-width) gap-0 p-0", side: "left", close: false, children: [
5759
+ /* @__PURE__ */ jsxs46(SheetHeader, { className: "hidden space-y-0 p-0", children: [
5760
+ /* @__PURE__ */ jsx55(SheetTitle, { className: "sr-only", children: "Navigation menu" }),
5761
+ /* @__PURE__ */ jsx55(SheetDescription, { className: "sr-only", children: "NavigatSheet Description" })
5720
5762
  ] }),
5721
- /* @__PURE__ */ jsx54(SheetBody, { className: "flex grow flex-col p-0", children })
5763
+ /* @__PURE__ */ jsx55(SheetBody, { className: "flex grow flex-col p-0", children })
5722
5764
  ] })
5723
5765
  ] });
5724
5766
  }
5725
5767
 
5726
5768
  // src/ui/layouts/sidebar.tsx
5727
5769
  import { useCallback as useCallback4, useMemo as useMemo5 } from "react";
5728
- import Link7 from "next/link";
5770
+ import Link8 from "next/link";
5729
5771
  import { usePathname as usePathname3 } from "next/navigation";
5730
- import { useTranslations as useTranslations45 } from "next-intl";
5772
+ import { useTranslations as useTranslations47 } from "next-intl";
5731
5773
  import { BackLink } from "pelatform-ui/components";
5732
5774
  import {
5733
5775
  AccordionMenu,
@@ -5738,29 +5780,221 @@ import {
5738
5780
  AccordionMenuSub,
5739
5781
  AccordionMenuSubContent,
5740
5782
  AccordionMenuSubTrigger,
5741
- Badge as Badge3,
5783
+ Badge as Badge4,
5742
5784
  ScrollArea
5743
5785
  } from "pelatform-ui/default";
5744
- import { Fragment as Fragment19, jsx as jsx55, jsxs as jsxs46 } from "react/jsx-runtime";
5786
+
5787
+ // src/ui/workspace/switcher.tsx
5788
+ import { useRouter as useRouter16 } from "next/navigation";
5789
+ import { Building2, CheckIcon as CheckIcon4, ChevronsUpDown, PlusIcon, User } from "lucide-react";
5790
+ import { useTranslations as useTranslations46 } from "next-intl";
5791
+ import { AlertToast as AlertToast24 } from "pelatform-ui/components";
5792
+ import {
5793
+ Badge as Badge3,
5794
+ Button as Button33,
5795
+ DropdownMenu as DropdownMenu4,
5796
+ DropdownMenuContent as DropdownMenuContent4,
5797
+ DropdownMenuGroup,
5798
+ DropdownMenuItem as DropdownMenuItem4,
5799
+ DropdownMenuLabel,
5800
+ DropdownMenuSeparator as DropdownMenuSeparator2,
5801
+ DropdownMenuTrigger as DropdownMenuTrigger4,
5802
+ Skeleton as Skeleton10
5803
+ } from "pelatform-ui/default";
5804
+ import { useMediaQuery } from "pelatform-ui/hooks";
5805
+ import { jsx as jsx56, jsxs as jsxs47 } from "react/jsx-runtime";
5806
+ function WorkspaceSwitcher() {
5807
+ const { path } = useConfig();
5808
+ const { activeWorkspace, updateActiveWorkspace, workspaceList, isFetchingWorkspace } = useWorkspace();
5809
+ const router = useRouter16();
5810
+ const t = useTranslations46();
5811
+ const ownedWorkspaces = workspaceList?.filter((workspace) => workspace.currentUserRole === "owner") || [];
5812
+ const sharedWorkspaces = workspaceList?.filter((workspace) => workspace.currentUserRole !== "owner") || [];
5813
+ async function switchWorkspace(org) {
5814
+ if (org.slug === activeWorkspace?.slug) {
5815
+ return;
5816
+ }
5817
+ try {
5818
+ await updateActiveWorkspace(org);
5819
+ } catch (error) {
5820
+ console.error("Failed to switch workspace:", error);
5821
+ AlertToast24({
5822
+ message: error instanceof Error ? error.message : "Failed to switch workspace",
5823
+ icon: "destructive"
5824
+ });
5825
+ }
5826
+ }
5827
+ const showSkeleton = !activeWorkspace && isFetchingWorkspace;
5828
+ const currentSlug = activeWorkspace?.slug;
5829
+ const currentName = activeWorkspace?.name ?? "Workspace";
5830
+ const plan = activeWorkspace?.subscription?.plan ?? "free";
5831
+ const isMobile = useMediaQuery("(max-width: 640px)");
5832
+ return /* @__PURE__ */ jsx56("div", { className: "flex h-14 shrink-0 items-center gap-2 border-border border-b px-2.5 lg:h-15", children: /* @__PURE__ */ jsxs47(DropdownMenu4, { children: [
5833
+ activeWorkspace && !showSkeleton ? /* @__PURE__ */ jsx56(DropdownMenuTrigger4, { asChild: true, children: /* @__PURE__ */ jsxs47(
5834
+ Button33,
5835
+ {
5836
+ variant: "ghost",
5837
+ className: "flex w-full items-center justify-between gap-2 px-1.5 hover:bg-accent focus:shadow-none! focus:outline-none! focus:ring-0! focus:ring-offset-0!",
5838
+ children: [
5839
+ /* @__PURE__ */ jsxs47("div", { className: "flex items-center gap-2.5", children: [
5840
+ /* @__PURE__ */ jsx56(
5841
+ WorkspaceLogo,
5842
+ {
5843
+ workspace: activeWorkspace,
5844
+ classNames: { image: "w-full h-full" }
5845
+ }
5846
+ ),
5847
+ /* @__PURE__ */ jsx56("span", { className: "font-medium text-foreground text-sm", children: currentName })
5848
+ ] }),
5849
+ /* @__PURE__ */ jsx56(ChevronsUpDown, {})
5850
+ ]
5851
+ }
5852
+ ) }) : /* @__PURE__ */ jsxs47("div", { className: "flex items-center rounded-md border bg-sidebar-accent", children: [
5853
+ /* @__PURE__ */ jsx56(Skeleton10, { className: "shrink-0 rounded-md border" }),
5854
+ /* @__PURE__ */ jsxs47("div", { className: "flex w-full flex-col gap-1", children: [
5855
+ /* @__PURE__ */ jsx56(Skeleton10, { className: "h-3 w-3/4 border" }),
5856
+ /* @__PURE__ */ jsx56(Skeleton10, { className: "h-3 w-1/2 border" })
5857
+ ] })
5858
+ ] }),
5859
+ /* @__PURE__ */ jsxs47(
5860
+ DropdownMenuContent4,
5861
+ {
5862
+ className: "w-64",
5863
+ side: isMobile ? "bottom" : "right",
5864
+ align: isMobile ? "end" : "start",
5865
+ sideOffset: isMobile ? 8 : 7,
5866
+ alignOffset: isMobile ? 65 : 0,
5867
+ children: [
5868
+ /* @__PURE__ */ jsxs47(DropdownMenuLabel, { className: "flex items-center gap-1.5", children: [
5869
+ /* @__PURE__ */ jsx56(
5870
+ WorkspaceLogo,
5871
+ {
5872
+ workspace: activeWorkspace,
5873
+ classNames: { image: "w-full h-full" }
5874
+ }
5875
+ ),
5876
+ /* @__PURE__ */ jsx56("span", { className: "font-medium text-foreground text-sm", children: currentName }),
5877
+ /* @__PURE__ */ jsx56(Badge3, { size: "xs", className: "capitalize", variant: plan === "free" ? "info" : "success", children: plan })
5878
+ ] }),
5879
+ /* @__PURE__ */ jsxs47(
5880
+ DropdownMenuItem4,
5881
+ {
5882
+ className: "cursor-pointer",
5883
+ disabled: !currentSlug,
5884
+ onSelect: () => router.push(`/${currentSlug}${path.workspaces.SETTINGS}`),
5885
+ children: [
5886
+ /* @__PURE__ */ jsx56(Building2, { className: "size-4" }),
5887
+ /* @__PURE__ */ jsx56("span", { children: t("systems.SETTINGS") })
5888
+ ]
5889
+ }
5890
+ ),
5891
+ /* @__PURE__ */ jsxs47(
5892
+ DropdownMenuItem4,
5893
+ {
5894
+ className: "cursor-pointer",
5895
+ disabled: !currentSlug,
5896
+ onSelect: () => router.push(`/${currentSlug}${path.workspaces.MEMBERS}`),
5897
+ children: [
5898
+ /* @__PURE__ */ jsx56(User, { className: "size-4" }),
5899
+ /* @__PURE__ */ jsx56("span", { children: t("systems.INVITE_MEMBER") })
5900
+ ]
5901
+ }
5902
+ ),
5903
+ ownedWorkspaces.length > 0 && /* @__PURE__ */ jsxs47(DropdownMenuGroup, { children: [
5904
+ /* @__PURE__ */ jsx56(DropdownMenuSeparator2, {}),
5905
+ /* @__PURE__ */ jsx56(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: t("systems.YOUR_WORKSPACES") }),
5906
+ ownedWorkspaces.map((w) => /* @__PURE__ */ jsxs47(
5907
+ DropdownMenuItem4,
5908
+ {
5909
+ className: "flex items-center justify-between",
5910
+ onClick: () => switchWorkspace(w),
5911
+ disabled: isFetchingWorkspace || w.slug !== currentSlug,
5912
+ children: [
5913
+ /* @__PURE__ */ jsxs47("div", { className: "flex items-center gap-2", children: [
5914
+ /* @__PURE__ */ jsx56(
5915
+ WorkspaceLogo,
5916
+ {
5917
+ workspace: w,
5918
+ classNames: { base: "size-7 rounded-[0.2rem]", image: "w-full h-full" }
5919
+ }
5920
+ ),
5921
+ /* @__PURE__ */ jsx56("span", { className: "truncate font-medium text-foreground text-sm leading-5 sm:max-w-[140px]", children: w.name ?? w.slug })
5922
+ ] }),
5923
+ w.slug === currentSlug && /* @__PURE__ */ jsx56(CheckIcon4, { className: "size-4 text-primary" })
5924
+ ]
5925
+ },
5926
+ w.id
5927
+ ))
5928
+ ] }),
5929
+ sharedWorkspaces.length > 0 && /* @__PURE__ */ jsxs47(DropdownMenuGroup, { children: [
5930
+ ownedWorkspaces.length > 0 && /* @__PURE__ */ jsx56(DropdownMenuSeparator2, {}),
5931
+ /* @__PURE__ */ jsx56(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: t("systems.SHARED_WORKSPACES") }),
5932
+ sharedWorkspaces.map((w) => /* @__PURE__ */ jsxs47(
5933
+ DropdownMenuItem4,
5934
+ {
5935
+ className: "flex items-center justify-between",
5936
+ onClick: () => switchWorkspace(w),
5937
+ disabled: isFetchingWorkspace || w.slug !== currentSlug,
5938
+ children: [
5939
+ /* @__PURE__ */ jsxs47("div", { className: "flex items-center gap-2", children: [
5940
+ /* @__PURE__ */ jsx56(
5941
+ WorkspaceLogo,
5942
+ {
5943
+ workspace: w,
5944
+ classNames: { base: "size-7 rounded-[0.2rem]", image: "w-full h-full" }
5945
+ }
5946
+ ),
5947
+ /* @__PURE__ */ jsx56("span", { className: "truncate font-medium text-foreground text-sm leading-5 sm:max-w-[140px]", children: w.name ?? w.slug })
5948
+ ] }),
5949
+ w.slug === currentSlug && /* @__PURE__ */ jsx56(CheckIcon4, { className: "size-4 text-primary" })
5950
+ ]
5951
+ },
5952
+ w.id
5953
+ ))
5954
+ ] }),
5955
+ /* @__PURE__ */ jsx56(DropdownMenuSeparator2, {}),
5956
+ /* @__PURE__ */ jsxs47(
5957
+ DropdownMenuItem4,
5958
+ {
5959
+ onSelect: () => router.push(
5960
+ `${path.custom.NEW_WORKSPACE}?workspaces=${workspaceList && workspaceList.length > 0}`
5961
+ ),
5962
+ children: [
5963
+ /* @__PURE__ */ jsx56(PlusIcon, { className: "size-4" }),
5964
+ /* @__PURE__ */ jsx56("span", { children: t("systems.ADD_WORKSPACE") })
5965
+ ]
5966
+ }
5967
+ )
5968
+ ]
5969
+ }
5970
+ )
5971
+ ] }) });
5972
+ }
5973
+
5974
+ // src/ui/layouts/sidebar.tsx
5975
+ import { Fragment as Fragment19, jsx as jsx57, jsxs as jsxs48 } from "react/jsx-runtime";
5745
5976
  function Sidebar({ children }) {
5746
5977
  const { isMobile } = useLayout();
5747
5978
  if (isMobile) {
5748
5979
  return null;
5749
5980
  }
5750
- return /* @__PURE__ */ jsxs46("aside", { className: "in-data-[sidebar-open=false]:-start-full fixed start-0 top-(--header-height) bottom-0 flex w-(--sidebar-width) shrink-0 flex-col items-stretch border-border border-e transition-all duration-300", children: [
5981
+ return /* @__PURE__ */ jsxs48("aside", { className: "in-data-[sidebar-open=false]:-start-full fixed start-0 top-(--header-height) bottom-0 flex w-(--sidebar-width) shrink-0 flex-col items-stretch border-border border-e transition-all duration-300", children: [
5751
5982
  children,
5752
- /* @__PURE__ */ jsx55("div", {})
5983
+ /* @__PURE__ */ jsx57("div", {})
5753
5984
  ] });
5754
5985
  }
5755
5986
  function SidebarHeaderBack({
5756
5987
  linkHref = "/",
5757
5988
  admin = false
5758
5989
  }) {
5759
- const t = useTranslations45();
5760
- return /* @__PURE__ */ jsx55("div", { className: "flex h-14 shrink-0 items-center gap-2 border-border border-b px-2.5 lg:h-15", children: /* @__PURE__ */ jsx55(BackLink, { Link: Link7, href: linkHref, children: admin ? t("systems.common.actions.back") : t("systems.navigation.settings") }) });
5990
+ const t = useTranslations47();
5991
+ return /* @__PURE__ */ jsx57("div", { className: "flex h-14 shrink-0 items-center gap-2 border-border border-b px-2.5 lg:h-15", children: /* @__PURE__ */ jsx57(BackLink, { Link: Link8, href: linkHref, children: admin ? t("systems.common.actions.back") : t("systems.navigation.settings") }) });
5992
+ }
5993
+ function SidebarHeaderWorkspaces() {
5994
+ return /* @__PURE__ */ jsx57(WorkspaceSwitcher, {});
5761
5995
  }
5762
5996
  function SidebarContent({ children }) {
5763
- return /* @__PURE__ */ jsx55(ScrollArea, { className: "mt-2 mb-2.5 h-[calc(100vh-5.5rem)] grow lg:mt-4 lg:mb-7.5 lg:h-[calc(100vh-4rem)]", children });
5997
+ return /* @__PURE__ */ jsx57(ScrollArea, { className: "mt-2 mb-2.5 h-[calc(100vh-5.5rem)] grow lg:mt-4 lg:mb-7.5 lg:h-[calc(100vh-4rem)]", children });
5764
5998
  }
5765
5999
  function SidebarContentMenu({
5766
6000
  menu,
@@ -5802,7 +6036,7 @@ function SidebarContentMenu({
5802
6036
  [activePath, normalize]
5803
6037
  );
5804
6038
  if (type === "toggle") {
5805
- return /* @__PURE__ */ jsx55(
6039
+ return /* @__PURE__ */ jsx57(
5806
6040
  AccordionMenu,
5807
6041
  {
5808
6042
  type: "single",
@@ -5816,17 +6050,17 @@ function SidebarContentMenu({
5816
6050
  subTrigger: "text-xs font-normal text-muted-foreground hover:bg-transparent",
5817
6051
  subContent: "ps-0"
5818
6052
  },
5819
- children: menu.map((item, index) => /* @__PURE__ */ jsxs46(AccordionMenuSub, { value: item.title || "menu", children: [
5820
- /* @__PURE__ */ jsxs46(AccordionMenuSubTrigger, { value: "menu-trigger", children: [
5821
- /* @__PURE__ */ jsx55("span", { children: item.title }),
5822
- /* @__PURE__ */ jsx55(AccordionMenuIndicator, {})
6053
+ children: menu.map((item, index) => /* @__PURE__ */ jsxs48(AccordionMenuSub, { value: item.title || "menu", children: [
6054
+ /* @__PURE__ */ jsxs48(AccordionMenuSubTrigger, { value: "menu-trigger", children: [
6055
+ /* @__PURE__ */ jsx57("span", { children: item.title }),
6056
+ /* @__PURE__ */ jsx57(AccordionMenuIndicator, {})
5823
6057
  ] }),
5824
- /* @__PURE__ */ jsx55(AccordionMenuSubContent, { type: "single", collapsible: true, parentValue: "menu-trigger", children: item.children?.map((child, idx) => {
5825
- const content = /* @__PURE__ */ jsxs46(Fragment19, { children: [
5826
- child.icon && /* @__PURE__ */ jsx55(child.icon, {}),
5827
- /* @__PURE__ */ jsx55("span", { children: child.title }),
5828
- child.badge && /* @__PURE__ */ jsx55(
5829
- Badge3,
6058
+ /* @__PURE__ */ jsx57(AccordionMenuSubContent, { type: "single", collapsible: true, parentValue: "menu-trigger", children: item.children?.map((child, idx) => {
6059
+ const content = /* @__PURE__ */ jsxs48(Fragment19, { children: [
6060
+ child.icon && /* @__PURE__ */ jsx57(child.icon, {}),
6061
+ /* @__PURE__ */ jsx57("span", { children: child.title }),
6062
+ child.badge && /* @__PURE__ */ jsx57(
6063
+ Badge4,
5830
6064
  {
5831
6065
  size: "sm",
5832
6066
  variant: child.badgeVariant ?? "destructive",
@@ -5836,8 +6070,8 @@ function SidebarContentMenu({
5836
6070
  )
5837
6071
  ] });
5838
6072
  if (child.external && child.path) {
5839
- return /* @__PURE__ */ jsx55(
5840
- Link7,
6073
+ return /* @__PURE__ */ jsx57(
6074
+ Link8,
5841
6075
  {
5842
6076
  href: child.path,
5843
6077
  target: "_blank",
@@ -5848,13 +6082,13 @@ function SidebarContentMenu({
5848
6082
  child.path || `ext-${idx}`
5849
6083
  );
5850
6084
  }
5851
- return /* @__PURE__ */ jsx55(AccordionMenuItem, { value: child.path || "#", children: /* @__PURE__ */ jsx55(Link7, { href: child.path || "#", children: content }) }, idx);
6085
+ return /* @__PURE__ */ jsx57(AccordionMenuItem, { value: child.path || "#", children: /* @__PURE__ */ jsx57(Link8, { href: child.path || "#", children: content }) }, idx);
5852
6086
  }) })
5853
6087
  ] }, index))
5854
6088
  }
5855
6089
  );
5856
6090
  }
5857
- return /* @__PURE__ */ jsx55(
6091
+ return /* @__PURE__ */ jsx57(
5858
6092
  AccordionMenu,
5859
6093
  {
5860
6094
  type: "multiple",
@@ -5867,14 +6101,14 @@ function SidebarContentMenu({
5867
6101
  group: ""
5868
6102
  },
5869
6103
  children: menu.map((item, index) => {
5870
- return /* @__PURE__ */ jsxs46(AccordionMenuGroup, { children: [
5871
- /* @__PURE__ */ jsx55(AccordionMenuLabel, { children: item.title }),
6104
+ return /* @__PURE__ */ jsxs48(AccordionMenuGroup, { children: [
6105
+ /* @__PURE__ */ jsx57(AccordionMenuLabel, { children: item.title }),
5872
6106
  item.children?.map((child, idx) => {
5873
- const content = /* @__PURE__ */ jsxs46(Fragment19, { children: [
5874
- child.icon && /* @__PURE__ */ jsx55(child.icon, {}),
5875
- /* @__PURE__ */ jsx55("span", { children: child.title }),
5876
- child.badge && /* @__PURE__ */ jsx55(
5877
- Badge3,
6107
+ const content = /* @__PURE__ */ jsxs48(Fragment19, { children: [
6108
+ child.icon && /* @__PURE__ */ jsx57(child.icon, {}),
6109
+ /* @__PURE__ */ jsx57("span", { children: child.title }),
6110
+ child.badge && /* @__PURE__ */ jsx57(
6111
+ Badge4,
5878
6112
  {
5879
6113
  size: "sm",
5880
6114
  variant: child.badgeVariant ?? "destructive",
@@ -5884,8 +6118,8 @@ function SidebarContentMenu({
5884
6118
  )
5885
6119
  ] });
5886
6120
  if (child.external && child.path) {
5887
- return /* @__PURE__ */ jsx55(
5888
- Link7,
6121
+ return /* @__PURE__ */ jsx57(
6122
+ Link8,
5889
6123
  {
5890
6124
  href: child.path,
5891
6125
  target: "_blank",
@@ -5896,7 +6130,7 @@ function SidebarContentMenu({
5896
6130
  child.path || `ext-${idx}`
5897
6131
  );
5898
6132
  }
5899
- return /* @__PURE__ */ jsx55(AccordionMenuItem, { value: child.path || "#", children: /* @__PURE__ */ jsx55(Link7, { href: child.path || "#", children: content }) }, idx);
6133
+ return /* @__PURE__ */ jsx57(AccordionMenuItem, { value: child.path || "#", children: /* @__PURE__ */ jsx57(Link8, { href: child.path || "#", children: content }) }, idx);
5900
6134
  })
5901
6135
  ] }, index);
5902
6136
  })
@@ -5905,17 +6139,17 @@ function SidebarContentMenu({
5905
6139
  }
5906
6140
 
5907
6141
  // src/ui/layouts/site-footer.tsx
5908
- import Link8 from "next/link";
5909
- import { useTranslations as useTranslations46 } from "next-intl";
6142
+ import Link9 from "next/link";
6143
+ import { useTranslations as useTranslations48 } from "next-intl";
5910
6144
  import { cn as cn41 } from "pelatform-ui";
5911
6145
  import { SiteFooter as UISiteFooter } from "pelatform-ui/components";
5912
- import { Button as Button32 } from "pelatform-ui/default";
5913
- import { jsx as jsx56, jsxs as jsxs47 } from "react/jsx-runtime";
6146
+ import { Button as Button34 } from "pelatform-ui/default";
6147
+ import { jsx as jsx58, jsxs as jsxs49 } from "react/jsx-runtime";
5914
6148
  function SiteFooter({ disableProjectBy = false }) {
5915
6149
  const { app } = useConfig();
5916
- const t = useTranslations46();
5917
- return /* @__PURE__ */ jsxs47(UISiteFooter, { className: cn41("*:gap-2! *:py-0!", disableProjectBy ? "*:justify-center!" : ""), children: [
5918
- /* @__PURE__ */ jsxs47("div", { className: "text-balance text-center text-muted-foreground text-sm leading-loose md:text-left", children: [
6150
+ const t = useTranslations48();
6151
+ return /* @__PURE__ */ jsxs49(UISiteFooter, { className: cn41("*:gap-2! *:py-0!", disableProjectBy ? "*:justify-center!" : ""), children: [
6152
+ /* @__PURE__ */ jsxs49("div", { className: "text-balance text-center text-muted-foreground text-sm leading-loose md:text-left", children: [
5919
6153
  "\xA9 ",
5920
6154
  (/* @__PURE__ */ new Date()).getFullYear(),
5921
6155
  " ",
@@ -5923,11 +6157,11 @@ function SiteFooter({ disableProjectBy = false }) {
5923
6157
  ". ",
5924
6158
  t("customs.common.copyright")
5925
6159
  ] }),
5926
- !disableProjectBy && /* @__PURE__ */ jsx56("div", { className: "flex items-center gap-2.5 text-balance text-sm leading-loose", children: /* @__PURE__ */ jsxs47("div", { className: "inline-flex items-center gap-1", children: [
5927
- /* @__PURE__ */ jsx56("span", { className: "text-muted-foreground", children: t("customs.common.project_by") }),
6160
+ !disableProjectBy && /* @__PURE__ */ jsx58("div", { className: "flex items-center gap-2.5 text-balance text-sm leading-loose", children: /* @__PURE__ */ jsxs49("div", { className: "inline-flex items-center gap-1", children: [
6161
+ /* @__PURE__ */ jsx58("span", { className: "text-muted-foreground", children: t("customs.common.project_by") }),
5928
6162
  " ",
5929
- /* @__PURE__ */ jsx56(Button32, { mode: "link", underline: "dashed", children: /* @__PURE__ */ jsx56(
5930
- Link8,
6163
+ /* @__PURE__ */ jsx58(Button34, { mode: "link", underline: "dashed", children: /* @__PURE__ */ jsx58(
6164
+ Link9,
5931
6165
  {
5932
6166
  href: "https://pelatform.com",
5933
6167
  target: "_blank",
@@ -5941,9 +6175,9 @@ function SiteFooter({ disableProjectBy = false }) {
5941
6175
 
5942
6176
  // src/ui/layouts/site-header.tsx
5943
6177
  import { useState as useState19 } from "react";
5944
- import Link9 from "next/link";
5945
- import { usePathname as usePathname4, useRouter as useRouter16 } from "next/navigation";
5946
- import { useTranslations as useTranslations47 } from "next-intl";
6178
+ import Link10 from "next/link";
6179
+ import { usePathname as usePathname4, useRouter as useRouter17 } from "next/navigation";
6180
+ import { useTranslations as useTranslations49 } from "next-intl";
5947
6181
  import {
5948
6182
  MainNav,
5949
6183
  MobileNav,
@@ -5951,35 +6185,35 @@ import {
5951
6185
  ModeSwitcher as ModeSwitcher3,
5952
6186
  SiteHeader as UISiteHeader
5953
6187
  } from "pelatform-ui/components";
5954
- import { Button as Button33, Separator as Separator2 } from "pelatform-ui/default";
5955
- import { jsx as jsx57, jsxs as jsxs48 } from "react/jsx-runtime";
6188
+ import { Button as Button35, Separator as Separator2 } from "pelatform-ui/default";
6189
+ import { jsx as jsx59, jsxs as jsxs50 } from "react/jsx-runtime";
5956
6190
  function SiteHeader({
5957
6191
  menu,
5958
- logo = /* @__PURE__ */ jsx57(LogoWithHref, { href: "/home" })
6192
+ logo = /* @__PURE__ */ jsx59(LogoWithHref, { href: "/home" })
5959
6193
  }) {
5960
6194
  const { path } = useConfig();
5961
6195
  const pathname = usePathname4();
5962
- const router = useRouter16();
5963
- const t = useTranslations47();
6196
+ const router = useRouter17();
6197
+ const t = useTranslations49();
5964
6198
  const { isPending, session, user } = useSession();
5965
6199
  const [, setMobileNavOpen] = useState19(false);
5966
6200
  const isAuthenticated = !isPending && session && user;
5967
- return /* @__PURE__ */ jsxs48(UISiteHeader, { className: "backdrop-blur-none supports-backdrop-filter:bg-background", children: [
5968
- /* @__PURE__ */ jsxs48("div", { className: "flex items-center gap-4.5", children: [
6201
+ return /* @__PURE__ */ jsxs50(UISiteHeader, { className: "backdrop-blur-none supports-backdrop-filter:bg-background", children: [
6202
+ /* @__PURE__ */ jsxs50("div", { className: "flex items-center gap-4.5", children: [
5969
6203
  logo,
5970
- /* @__PURE__ */ jsx57(MainNav, { Link: Link9, pathname, items: menu })
6204
+ /* @__PURE__ */ jsx59(MainNav, { Link: Link10, pathname, items: menu })
5971
6205
  ] }),
5972
- /* @__PURE__ */ jsx57("div", { className: "flex items-center justify-end gap-3", children: /* @__PURE__ */ jsxs48("nav", { className: "flex items-center gap-0 md:gap-1", children: [
5973
- /* @__PURE__ */ jsx57(ModeSwitcher3, {}),
5974
- /* @__PURE__ */ jsx57(LanguageSwitcher, {}),
5975
- /* @__PURE__ */ jsx57(Separator2, { orientation: "vertical", className: "mx-3 h-5 max-lg:hidden" }),
5976
- /* @__PURE__ */ jsx57(MobileNav, { children: /* @__PURE__ */ jsxs48("div", { className: "flex flex-col space-y-3", children: [
6206
+ /* @__PURE__ */ jsx59("div", { className: "flex items-center justify-end gap-3", children: /* @__PURE__ */ jsxs50("nav", { className: "flex items-center gap-0 md:gap-1", children: [
6207
+ /* @__PURE__ */ jsx59(ModeSwitcher3, {}),
6208
+ /* @__PURE__ */ jsx59(LanguageSwitcher, {}),
6209
+ /* @__PURE__ */ jsx59(Separator2, { orientation: "vertical", className: "mx-3 h-5 max-lg:hidden" }),
6210
+ /* @__PURE__ */ jsx59(MobileNav, { children: /* @__PURE__ */ jsxs50("div", { className: "flex flex-col space-y-3", children: [
5977
6211
  menu?.map(
5978
- (item, navIndex) => item.href || item.children ? /* @__PURE__ */ jsx57(
6212
+ (item, navIndex) => item.href || item.children ? /* @__PURE__ */ jsx59(
5979
6213
  MobileNavItemRenderer,
5980
6214
  {
5981
6215
  item,
5982
- Link: Link9,
6216
+ Link: Link10,
5983
6217
  pathname,
5984
6218
  level: 1,
5985
6219
  onOpenChange: setMobileNavOpen
@@ -5987,8 +6221,8 @@ function SiteHeader({
5987
6221
  `nav-${navIndex}-${item.href}`
5988
6222
  ) : null
5989
6223
  ),
5990
- /* @__PURE__ */ jsx57("div", { className: "border-t pt-3", children: isAuthenticated ? /* @__PURE__ */ jsx57(
5991
- Button33,
6224
+ /* @__PURE__ */ jsx59("div", { className: "border-t pt-3", children: isAuthenticated ? /* @__PURE__ */ jsx59(
6225
+ Button35,
5992
6226
  {
5993
6227
  variant: "outline",
5994
6228
  size: "sm",
@@ -5996,36 +6230,36 @@ function SiteHeader({
5996
6230
  onClick: () => router.push(path.auth.SIGN_OUT),
5997
6231
  children: t("systems.navigation.logout")
5998
6232
  }
5999
- ) : /* @__PURE__ */ jsx57(Button33, { variant: "secondary", size: "sm", className: "w-full", children: /* @__PURE__ */ jsx57(Link9, { href: path.auth.SIGN_IN, children: t("systems.navigation.login") }) }) })
6233
+ ) : /* @__PURE__ */ jsx59(Button35, { variant: "secondary", size: "sm", className: "w-full", children: /* @__PURE__ */ jsx59(Link10, { href: path.auth.SIGN_IN, children: t("systems.navigation.login") }) }) })
6000
6234
  ] }) }),
6001
- isAuthenticated ? /* @__PURE__ */ jsx57(UserMenu, { hiddenSwitcher: true }) : /* @__PURE__ */ jsx57(Button33, { variant: "secondary", size: "sm", className: "hidden md:flex", children: /* @__PURE__ */ jsx57(Link9, { href: path.auth.SIGN_IN, children: t("systems.navigation.login") }) })
6235
+ isAuthenticated ? /* @__PURE__ */ jsx59(UserMenu, { hiddenSwitcher: true }) : /* @__PURE__ */ jsx59(Button35, { variant: "secondary", size: "sm", className: "hidden md:flex", children: /* @__PURE__ */ jsx59(Link10, { href: path.auth.SIGN_IN, children: t("systems.navigation.login") }) })
6002
6236
  ] }) })
6003
6237
  ] });
6004
6238
  }
6005
6239
  function SiteHeaderSecondary({
6006
6240
  menu,
6007
- logo = /* @__PURE__ */ jsx57(LogoWithHref, { href: "/home" }),
6241
+ logo = /* @__PURE__ */ jsx59(LogoWithHref, { href: "/home" }),
6008
6242
  loginLink
6009
6243
  }) {
6010
6244
  const pathname = usePathname4();
6011
- const t = useTranslations47();
6245
+ const t = useTranslations49();
6012
6246
  const [, setMobileNavOpen] = useState19(false);
6013
- return /* @__PURE__ */ jsxs48(UISiteHeader, { className: "backdrop-blur-none supports-backdrop-filter:bg-background", children: [
6014
- /* @__PURE__ */ jsxs48("div", { className: "flex items-center gap-4.5", children: [
6247
+ return /* @__PURE__ */ jsxs50(UISiteHeader, { className: "backdrop-blur-none supports-backdrop-filter:bg-background", children: [
6248
+ /* @__PURE__ */ jsxs50("div", { className: "flex items-center gap-4.5", children: [
6015
6249
  logo,
6016
- /* @__PURE__ */ jsx57(MainNav, { Link: Link9, pathname, items: menu })
6250
+ /* @__PURE__ */ jsx59(MainNav, { Link: Link10, pathname, items: menu })
6017
6251
  ] }),
6018
- /* @__PURE__ */ jsx57("div", { className: "flex items-center justify-end gap-3", children: /* @__PURE__ */ jsxs48("nav", { className: "flex items-center gap-0 md:gap-1", children: [
6019
- /* @__PURE__ */ jsx57(ModeSwitcher3, {}),
6020
- /* @__PURE__ */ jsx57(LanguageSwitcher, {}),
6021
- /* @__PURE__ */ jsx57(Separator2, { orientation: "vertical", className: "mx-3 h-5 max-lg:hidden" }),
6022
- /* @__PURE__ */ jsx57(MobileNav, { children: /* @__PURE__ */ jsxs48("div", { className: "flex flex-col space-y-3", children: [
6252
+ /* @__PURE__ */ jsx59("div", { className: "flex items-center justify-end gap-3", children: /* @__PURE__ */ jsxs50("nav", { className: "flex items-center gap-0 md:gap-1", children: [
6253
+ /* @__PURE__ */ jsx59(ModeSwitcher3, {}),
6254
+ /* @__PURE__ */ jsx59(LanguageSwitcher, {}),
6255
+ /* @__PURE__ */ jsx59(Separator2, { orientation: "vertical", className: "mx-3 h-5 max-lg:hidden" }),
6256
+ /* @__PURE__ */ jsx59(MobileNav, { children: /* @__PURE__ */ jsxs50("div", { className: "flex flex-col space-y-3", children: [
6023
6257
  menu?.map(
6024
- (item, navIndex) => item.href || item.children ? /* @__PURE__ */ jsx57(
6258
+ (item, navIndex) => item.href || item.children ? /* @__PURE__ */ jsx59(
6025
6259
  MobileNavItemRenderer,
6026
6260
  {
6027
6261
  item,
6028
- Link: Link9,
6262
+ Link: Link10,
6029
6263
  pathname,
6030
6264
  level: 1,
6031
6265
  onOpenChange: setMobileNavOpen
@@ -6033,9 +6267,9 @@ function SiteHeaderSecondary({
6033
6267
  `nav-${navIndex}-${item.href}`
6034
6268
  ) : null
6035
6269
  ),
6036
- loginLink && /* @__PURE__ */ jsx57("div", { className: "border-t pt-3", children: /* @__PURE__ */ jsx57(Button33, { variant: "secondary", size: "sm", className: "w-full", children: /* @__PURE__ */ jsx57(Link9, { href: loginLink, children: t("systems.navigation.login") }) }) })
6270
+ loginLink && /* @__PURE__ */ jsx59("div", { className: "border-t pt-3", children: /* @__PURE__ */ jsx59(Button35, { variant: "secondary", size: "sm", className: "w-full", children: /* @__PURE__ */ jsx59(Link10, { href: loginLink, children: t("systems.navigation.login") }) }) })
6037
6271
  ] }) }),
6038
- loginLink && /* @__PURE__ */ jsx57(Button33, { variant: "secondary", size: "sm", className: "hidden md:flex", children: /* @__PURE__ */ jsx57(Link9, { href: loginLink, children: t("systems.navigation.login") }) })
6272
+ loginLink && /* @__PURE__ */ jsx59(Button35, { variant: "secondary", size: "sm", className: "hidden md:flex", children: /* @__PURE__ */ jsx59(Link10, { href: loginLink, children: t("systems.navigation.login") }) })
6039
6273
  ] }) })
6040
6274
  ] });
6041
6275
  }
@@ -6044,7 +6278,7 @@ function SiteHeaderSecondary({
6044
6278
  import { useEffect as useEffect16, useState as useState20 } from "react";
6045
6279
  import { cn as cn42 } from "pelatform-ui";
6046
6280
  import { useIsMobile } from "pelatform-ui/hooks";
6047
- import { jsx as jsx58 } from "react/jsx-runtime";
6281
+ import { jsx as jsx60 } from "react/jsx-runtime";
6048
6282
  var SIDEBAR_WIDTH = "240px";
6049
6283
  var HEADER_HEIGHT = "54px";
6050
6284
  var SIDEBAR_WIDTH_MOBILE = "240px";
@@ -6054,7 +6288,7 @@ function LayoutProvider({
6054
6288
  style: customStyle,
6055
6289
  bodyClassName = "",
6056
6290
  className = "",
6057
- logoHeader = /* @__PURE__ */ jsx58(LogoWithHref, {})
6291
+ logoHeader = /* @__PURE__ */ jsx60(LogoWithHref, {})
6058
6292
  }) {
6059
6293
  const isMobile = useIsMobile();
6060
6294
  const [isSidebarOpen, setIsSidebarOpen] = useState20(true);
@@ -6079,7 +6313,7 @@ function LayoutProvider({
6079
6313
  };
6080
6314
  }
6081
6315
  }, [bodyClassName]);
6082
- return /* @__PURE__ */ jsx58(
6316
+ return /* @__PURE__ */ jsx60(
6083
6317
  LayoutContext.Provider,
6084
6318
  {
6085
6319
  value: {
@@ -6090,7 +6324,7 @@ function LayoutProvider({
6090
6324
  sidebarToggle,
6091
6325
  logoHeader
6092
6326
  },
6093
- children: /* @__PURE__ */ jsx58(
6327
+ children: /* @__PURE__ */ jsx60(
6094
6328
  "div",
6095
6329
  {
6096
6330
  "data-slot": "layout-wrapper",
@@ -6105,53 +6339,52 @@ function LayoutProvider({
6105
6339
  }
6106
6340
 
6107
6341
  // src/ui/layouts/wrapper.tsx
6108
- import { Fragment as Fragment20, jsx as jsx59, jsxs as jsxs49 } from "react/jsx-runtime";
6342
+ import { Fragment as Fragment20, jsx as jsx61, jsxs as jsxs51 } from "react/jsx-runtime";
6109
6343
  function LayoutWrapper({
6110
6344
  children,
6111
6345
  sidebarHeader,
6112
6346
  sidebarMenu,
6113
6347
  logoHeader
6114
6348
  }) {
6115
- const sidebarContent = /* @__PURE__ */ jsxs49(Fragment20, { children: [
6349
+ const sidebarContent = /* @__PURE__ */ jsxs51(Fragment20, { children: [
6116
6350
  sidebarHeader,
6117
- /* @__PURE__ */ jsx59(SidebarContent, { children: sidebarMenu })
6351
+ /* @__PURE__ */ jsx61(SidebarContent, { children: sidebarMenu })
6118
6352
  ] });
6119
- return /* @__PURE__ */ jsxs49(LayoutProvider, { logoHeader, children: [
6120
- /* @__PURE__ */ jsxs49(Header, { children: [
6121
- /* @__PURE__ */ jsx59(HeaderLeft, {}),
6122
- /* @__PURE__ */ jsx59(HeaderRight, { sidebar: /* @__PURE__ */ jsx59(HeaderSidebarMobile, { children: sidebarContent }) })
6353
+ return /* @__PURE__ */ jsxs51(LayoutProvider, { logoHeader, children: [
6354
+ /* @__PURE__ */ jsxs51(Header, { children: [
6355
+ /* @__PURE__ */ jsx61(HeaderLeft, {}),
6356
+ /* @__PURE__ */ jsx61(HeaderRight, { sidebar: /* @__PURE__ */ jsx61(HeaderSidebarMobile, { children: sidebarContent }) })
6123
6357
  ] }),
6124
- /* @__PURE__ */ jsxs49("div", { className: "flex grow pt-(--header-height-mobile) lg:pt-(--header-height)", children: [
6125
- /* @__PURE__ */ jsx59(Sidebar, { children: sidebarContent }),
6126
- /* @__PURE__ */ jsx59("main", { className: "grow transition-all duration-300 lg:in-data-[sidebar-open=false]:ps-0 lg:ps-(--sidebar-width)", children })
6358
+ /* @__PURE__ */ jsxs51("div", { className: "flex grow pt-(--header-height-mobile) lg:pt-(--header-height)", children: [
6359
+ /* @__PURE__ */ jsx61(Sidebar, { children: sidebarContent }),
6360
+ /* @__PURE__ */ jsx61("main", { className: "grow transition-all duration-300 lg:in-data-[sidebar-open=false]:ps-0 lg:ps-(--sidebar-width)", children })
6127
6361
  ] })
6128
6362
  ] });
6129
6363
  }
6130
6364
 
6131
6365
  // src/ui/pages/accept-invitation.tsx
6132
6366
  import { useEffect as useEffect17, useState as useState21 } from "react";
6133
- import { useRouter as useRouter17, useSearchParams as useSearchParams6 } from "next/navigation";
6134
- import { CheckIcon as CheckIcon4, XIcon } from "lucide-react";
6135
- import { useTranslations as useTranslations48 } from "next-intl";
6367
+ import { useRouter as useRouter18, useSearchParams as useSearchParams6 } from "next/navigation";
6368
+ import { CheckIcon as CheckIcon5, XIcon } from "lucide-react";
6369
+ import { useTranslations as useTranslations50 } from "next-intl";
6136
6370
  import { cn as cn43 } from "pelatform-ui";
6137
- import { AlertToast as AlertToast24 } from "pelatform-ui/components";
6138
- import { Button as Button34, Card as Card11, CardContent as CardContent3, CardHeader as CardHeader2, Skeleton as Skeleton10, Spinner as Spinner20 } from "pelatform-ui/default";
6139
- import { jsx as jsx60, jsxs as jsxs50 } from "react/jsx-runtime";
6371
+ import { AlertToast as AlertToast25 } from "pelatform-ui/components";
6372
+ import { Button as Button36, Card as Card11, CardContent as CardContent3, CardHeader as CardHeader2, Skeleton as Skeleton11, Spinner as Spinner20 } from "pelatform-ui/default";
6373
+ import { jsx as jsx62, jsxs as jsxs52 } from "react/jsx-runtime";
6140
6374
  function AcceptInvitation({
6141
6375
  className,
6142
6376
  classNames,
6143
- redirectTo: redirectToProp
6377
+ redirectTo = "/"
6144
6378
  }) {
6145
- const router = useRouter17();
6379
+ const router = useRouter18();
6146
6380
  const searchParams = useSearchParams6();
6147
- const t = useTranslations48();
6381
+ const t = useTranslations50();
6148
6382
  const { data: sessionData } = useSession();
6149
- const { redirectTo } = useOnSuccessTransition(redirectToProp);
6150
6383
  const [invitationId, setInvitationId] = useState21(null);
6151
6384
  useEffect17(() => {
6152
- const invitationIdParam = searchParams.get("invitationId");
6385
+ const invitationIdParam = searchParams.get("id");
6153
6386
  if (!invitationIdParam) {
6154
- AlertToast24({
6387
+ AlertToast25({
6155
6388
  message: t("systems.INVITATION_NOT_FOUND"),
6156
6389
  icon: "destructive"
6157
6390
  });
@@ -6161,9 +6394,9 @@ function AcceptInvitation({
6161
6394
  setInvitationId(invitationIdParam);
6162
6395
  }, [router, redirectTo, searchParams.get, t]);
6163
6396
  if (!sessionData || !invitationId) {
6164
- return /* @__PURE__ */ jsx60(AcceptInvitationSkeleton, { className, classNames });
6397
+ return /* @__PURE__ */ jsx62(AcceptInvitationSkeleton, { className, classNames });
6165
6398
  }
6166
- return /* @__PURE__ */ jsx60(
6399
+ return /* @__PURE__ */ jsx62(
6167
6400
  AcceptInvitationContent,
6168
6401
  {
6169
6402
  className,
@@ -6180,8 +6413,8 @@ function AcceptInvitationContent({
6180
6413
  redirectTo
6181
6414
  }) {
6182
6415
  const { authClient } = useConfig();
6183
- const router = useRouter17();
6184
- const t = useTranslations48();
6416
+ const router = useRouter18();
6417
+ const t = useTranslations50();
6185
6418
  const { data: invitation, isPending } = useInvitation({
6186
6419
  query: {
6187
6420
  id: invitationId
@@ -6193,7 +6426,7 @@ function AcceptInvitationContent({
6193
6426
  useEffect17(() => {
6194
6427
  if (isPending || !invitationId) return;
6195
6428
  if (!invitation) {
6196
- AlertToast24({
6429
+ AlertToast25({
6197
6430
  message: t("systems.INVITATION_NOT_FOUND"),
6198
6431
  icon: "destructive"
6199
6432
  });
@@ -6201,7 +6434,7 @@ function AcceptInvitationContent({
6201
6434
  return;
6202
6435
  }
6203
6436
  if (invitation.status !== "pending" || new Date(invitation.expiresAt) < /* @__PURE__ */ new Date()) {
6204
- AlertToast24({
6437
+ AlertToast25({
6205
6438
  message: new Date(invitation.expiresAt) < /* @__PURE__ */ new Date() ? t("systems.INVITATION_EXPIRED") : t("systems.INVITATION_NOT_FOUND"),
6206
6439
  icon: "destructive"
6207
6440
  });
@@ -6215,12 +6448,12 @@ function AcceptInvitationContent({
6215
6448
  invitationId,
6216
6449
  fetchOptions: { throw: true }
6217
6450
  });
6218
- AlertToast24({
6451
+ AlertToast25({
6219
6452
  message: t("systems.INVITATION_ACCEPTED")
6220
6453
  });
6221
6454
  router.replace(redirectTo);
6222
6455
  } catch (error) {
6223
- AlertToast24({
6456
+ AlertToast25({
6224
6457
  message: getTranslations({ error, t }),
6225
6458
  icon: "destructive"
6226
6459
  });
@@ -6234,12 +6467,12 @@ function AcceptInvitationContent({
6234
6467
  invitationId,
6235
6468
  fetchOptions: { throw: true }
6236
6469
  });
6237
- AlertToast24({
6470
+ AlertToast25({
6238
6471
  message: t("systems.INVITATION_REJECTED")
6239
6472
  });
6240
6473
  router.replace(redirectTo);
6241
6474
  } catch (error) {
6242
- AlertToast24({
6475
+ AlertToast25({
6243
6476
  message: getTranslations({ error, t }),
6244
6477
  icon: "destructive"
6245
6478
  });
@@ -6247,19 +6480,19 @@ function AcceptInvitationContent({
6247
6480
  }
6248
6481
  };
6249
6482
  if (!invitation) {
6250
- return /* @__PURE__ */ jsx60(AcceptInvitationSkeleton, { className, classNames });
6483
+ return /* @__PURE__ */ jsx62(AcceptInvitationSkeleton, { className, classNames });
6251
6484
  }
6252
- return /* @__PURE__ */ jsxs50(Card11, { className: cn43("w-full max-w-md overflow-hidden", className, classNames?.base), children: [
6253
- /* @__PURE__ */ jsx60(CardHeader2, { className: "py-4", children: /* @__PURE__ */ jsx60(
6485
+ return /* @__PURE__ */ jsxs52(Card11, { className: cn43("w-full max-w-md overflow-hidden", className, classNames?.base), children: [
6486
+ /* @__PURE__ */ jsx62(CardHeader2, { className: "py-4", children: /* @__PURE__ */ jsx62(
6254
6487
  CardHeaderComponent,
6255
6488
  {
6256
6489
  title: t("systems.ACCEPT_INVITATION"),
6257
6490
  description: t("systems.ACCEPT_INVITATION_DESCRIPTION")
6258
6491
  }
6259
6492
  ) }),
6260
- /* @__PURE__ */ jsxs50(CardContent3, { className: cn43("flex flex-col gap-6 truncate", classNames?.content), children: [
6261
- /* @__PURE__ */ jsxs50(Card11, { className: cn43("flex-row items-center p-4"), children: [
6262
- /* @__PURE__ */ jsx60(
6493
+ /* @__PURE__ */ jsxs52(CardContent3, { className: cn43("flex flex-col gap-6 truncate", classNames?.content), children: [
6494
+ /* @__PURE__ */ jsxs52(Card11, { className: cn43("flex-row items-center p-4"), children: [
6495
+ /* @__PURE__ */ jsx62(
6263
6496
  WorkspaceView,
6264
6497
  {
6265
6498
  workspace: {
@@ -6271,30 +6504,30 @@ function AcceptInvitationContent({
6271
6504
  }
6272
6505
  }
6273
6506
  ),
6274
- /* @__PURE__ */ jsx60("p", { className: "ms-auto font-semibold text-muted-foreground text-sm", children: t(`systems.${invitation?.role.toUpperCase()}`) || invitation?.role })
6507
+ /* @__PURE__ */ jsx62("p", { className: "ms-auto font-semibold text-muted-foreground text-sm", children: t(`systems.${invitation?.role.toUpperCase()}`) || invitation?.role })
6275
6508
  ] }),
6276
- /* @__PURE__ */ jsxs50("div", { className: "grid grid-cols-2 gap-3", children: [
6277
- /* @__PURE__ */ jsxs50(
6278
- Button34,
6509
+ /* @__PURE__ */ jsxs52("div", { className: "grid grid-cols-2 gap-3", children: [
6510
+ /* @__PURE__ */ jsxs52(
6511
+ Button36,
6279
6512
  {
6280
6513
  variant: "destructive",
6281
6514
  className: cn43(classNames?.button, classNames?.destructiveButton),
6282
6515
  onClick: rejectInvitation,
6283
6516
  disabled: isProcessing,
6284
6517
  children: [
6285
- isRejecting ? /* @__PURE__ */ jsx60(Spinner20, {}) : /* @__PURE__ */ jsx60(XIcon, {}),
6518
+ isRejecting ? /* @__PURE__ */ jsx62(Spinner20, {}) : /* @__PURE__ */ jsx62(XIcon, {}),
6286
6519
  t("systems.REJECT")
6287
6520
  ]
6288
6521
  }
6289
6522
  ),
6290
- /* @__PURE__ */ jsxs50(
6291
- Button34,
6523
+ /* @__PURE__ */ jsxs52(
6524
+ Button36,
6292
6525
  {
6293
6526
  className: cn43(classNames?.button, classNames?.primaryButton),
6294
6527
  onClick: acceptInvitation,
6295
6528
  disabled: isProcessing,
6296
6529
  children: [
6297
- isAccepting ? /* @__PURE__ */ jsx60(Spinner20, {}) : /* @__PURE__ */ jsx60(CheckIcon4, {}),
6530
+ isAccepting ? /* @__PURE__ */ jsx62(Spinner20, {}) : /* @__PURE__ */ jsx62(CheckIcon5, {}),
6298
6531
  t("systems.ACCEPT")
6299
6532
  ]
6300
6533
  }
@@ -6304,9 +6537,9 @@ function AcceptInvitationContent({
6304
6537
  ] });
6305
6538
  }
6306
6539
  function AcceptInvitationSkeleton({ className, classNames }) {
6307
- const t = useTranslations48();
6308
- return /* @__PURE__ */ jsxs50(Card11, { className: cn43("w-full max-w-md overflow-hidden", className, classNames?.base), children: [
6309
- /* @__PURE__ */ jsx60(CardHeader2, { className: "py-4", children: /* @__PURE__ */ jsx60(
6540
+ const t = useTranslations50();
6541
+ return /* @__PURE__ */ jsxs52(Card11, { className: cn43("w-full max-w-md overflow-hidden", className, classNames?.base), children: [
6542
+ /* @__PURE__ */ jsx62(CardHeader2, { className: "py-4", children: /* @__PURE__ */ jsx62(
6310
6543
  CardHeaderComponent,
6311
6544
  {
6312
6545
  className: "w-full",
@@ -6315,95 +6548,1331 @@ function AcceptInvitationSkeleton({ className, classNames }) {
6315
6548
  isPending: true
6316
6549
  }
6317
6550
  ) }),
6318
- /* @__PURE__ */ jsxs50(CardContent3, { className: cn43("flex flex-col gap-6 truncate", classNames?.content), children: [
6319
- /* @__PURE__ */ jsxs50(Card11, { className: cn43("flex-row items-center p-4"), children: [
6320
- /* @__PURE__ */ jsx60(WorkspaceView, { isPending: true }),
6321
- /* @__PURE__ */ jsx60(Skeleton10, { className: "ms-auto mt-0.5 h-4 w-full max-w-14 shrink-2" })
6551
+ /* @__PURE__ */ jsxs52(CardContent3, { className: cn43("flex flex-col gap-6 truncate", classNames?.content), children: [
6552
+ /* @__PURE__ */ jsxs52(Card11, { className: cn43("flex-row items-center p-4"), children: [
6553
+ /* @__PURE__ */ jsx62(WorkspaceView, { isPending: true }),
6554
+ /* @__PURE__ */ jsx62(Skeleton11, { className: "ms-auto mt-0.5 h-4 w-full max-w-14 shrink-2" })
6322
6555
  ] }),
6323
- /* @__PURE__ */ jsxs50("div", { className: "grid grid-cols-2 gap-3", children: [
6324
- /* @__PURE__ */ jsx60(Skeleton10, { className: "h-9 w-full" }),
6325
- /* @__PURE__ */ jsx60(Skeleton10, { className: "h-9 w-full" })
6556
+ /* @__PURE__ */ jsxs52("div", { className: "grid grid-cols-2 gap-3", children: [
6557
+ /* @__PURE__ */ jsx62(Skeleton11, { className: "h-9 w-full" }),
6558
+ /* @__PURE__ */ jsx62(Skeleton11, { className: "h-9 w-full" })
6326
6559
  ] })
6327
6560
  ] })
6328
6561
  ] });
6329
6562
  }
6330
6563
 
6331
- // src/ui/providers/shared.tsx
6332
- import { Suspense as Suspense2 } from "react";
6333
- import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
6334
- import { NextIntlClientProvider } from "next-intl";
6335
- import { QueryProvider, ThemeProvider } from "pelatform-ui/components";
6336
- import { Toaster as Sonner } from "pelatform-ui/default";
6337
- import { jsx as jsx61, jsxs as jsxs51 } from "react/jsx-runtime";
6338
- function SharedProviders({
6339
- children,
6340
- locale,
6341
- messages,
6342
- timeZone = "Asia/Jakarta",
6343
- sonnerPosition = "top-center"
6344
- }) {
6345
- const config = useConfig();
6346
- return /* @__PURE__ */ jsxs51(QueryProvider, { children: [
6347
- /* @__PURE__ */ jsx61(ThemeProvider, { defaultTheme: config.ui.defaultTheme, children: /* @__PURE__ */ jsx61(NextIntlClientProvider, { locale, messages, timeZone, children: /* @__PURE__ */ jsxs51(Suspense2, { children: [
6348
- children,
6349
- /* @__PURE__ */ jsx61(Sonner, { position: sonnerPosition })
6350
- ] }) }) }),
6351
- /* @__PURE__ */ jsx61(ReactQueryDevtools, { initialIsOpen: false })
6352
- ] });
6353
- }
6354
-
6355
- // src/ui/shared/empty-state.tsx
6356
- import Link10 from "next/link";
6357
- import { useTranslations as useTranslations49 } from "next-intl";
6564
+ // src/ui/pages/new-workspace.tsx
6565
+ import Link11 from "next/link";
6566
+ import { useRouter as useRouter19, useSearchParams as useSearchParams7 } from "next/navigation";
6567
+ import { zodResolver as zodResolver15 } from "@hookform/resolvers/zod";
6568
+ import { useTranslations as useTranslations51 } from "next-intl";
6569
+ import { useForm as useForm16 } from "react-hook-form";
6570
+ import slugify from "slugify";
6571
+ import { z as z15 } from "zod";
6358
6572
  import { cn as cn44 } from "pelatform-ui";
6359
- import { jsx as jsx62, jsxs as jsxs52 } from "react/jsx-runtime";
6360
- function EmptyState({
6361
- className,
6362
- icon: Icon,
6363
- title,
6364
- description,
6365
- learnMore,
6366
- learnMoreText,
6367
- children
6368
- }) {
6369
- const t = useTranslations49();
6370
- return /* @__PURE__ */ jsxs52("div", { className: cn44("flex flex-col items-center justify-center gap-y-4", className), children: [
6371
- Icon && /* @__PURE__ */ jsx62("div", { className: "flex size-14 items-center justify-center rounded-2xl border bg-muted", children: /* @__PURE__ */ jsx62(Icon, { className: "size-6 text-foreground" }) }),
6372
- /* @__PURE__ */ jsx62("p", { className: "text-center font-medium text-base text-foreground", children: title }),
6373
- description && /* @__PURE__ */ jsxs52("p", { className: "max-w-sm text-balance text-center text-muted-foreground text-sm", children: [
6374
- description,
6375
- " ",
6376
- learnMore && /* @__PURE__ */ jsxs52(
6377
- Link10,
6378
- {
6379
- href: learnMore,
6380
- className: "text-foreground underline underline-offset-2 transition-colors hover:text-primary",
6381
- children: [
6382
- learnMoreText ?? t("systems.common.ui.learnMore"),
6383
- " \u2197"
6384
- ]
6385
- }
6386
- )
6387
- ] }),
6388
- children
6573
+ import { AlertToast as AlertToast26 } from "pelatform-ui/components";
6574
+ import {
6575
+ Button as Button37,
6576
+ buttonVariants,
6577
+ Card as Card12,
6578
+ CardContent as CardContent4,
6579
+ CardHeader as CardHeader3,
6580
+ Form as Form16,
6581
+ FormControl as FormControl15,
6582
+ FormField as FormField15,
6583
+ FormItem as FormItem15,
6584
+ FormLabel as FormLabel14,
6585
+ FormMessage as FormMessage15,
6586
+ Input as Input12,
6587
+ Spinner as Spinner21
6588
+ } from "pelatform-ui/default";
6589
+ import { jsx as jsx63, jsxs as jsxs53 } from "react/jsx-runtime";
6590
+ function NewWorkspace({ className, classNames }) {
6591
+ const searchParams = useSearchParams7();
6592
+ const t = useTranslations51();
6593
+ const hasWorkspaces = searchParams.get("workspaces") === "true";
6594
+ return /* @__PURE__ */ jsxs53(Card12, { className: cn44("w-full max-w-md overflow-hidden", className, classNames?.base), children: [
6595
+ /* @__PURE__ */ jsx63(CardHeader3, { className: "py-4", children: /* @__PURE__ */ jsx63(
6596
+ CardHeaderComponent,
6597
+ {
6598
+ className: "w-full text-center",
6599
+ title: t("systems.NEW_ORGANIZATION_TITLE"),
6600
+ description: t(
6601
+ hasWorkspaces ? "systems.NEW_ORGANIZATION_DESCRIPTION_HAS" : "systems.NEW_ORGANIZATION_DESCRIPTION"
6602
+ )
6603
+ }
6604
+ ) }),
6605
+ /* @__PURE__ */ jsx63(CardContent4, { className: cn44("flex flex-col gap-6 truncate", classNames?.content), children: /* @__PURE__ */ jsx63(NewWorkspaceForm, { hasWorkspaces }) })
6389
6606
  ] });
6390
6607
  }
6391
-
6392
- // src/ui/shared/signed-in-hint.tsx
6393
- import Link11 from "next/link";
6394
- import { useTranslations as useTranslations50 } from "next-intl";
6395
- import { Button as Button35 } from "pelatform-ui/default";
6396
- import { jsx as jsx63, jsxs as jsxs53 } from "react/jsx-runtime";
6397
- function SignedInHint({ linkHref = "/signin" }) {
6398
- const t = useTranslations50("customs.common.signed");
6399
- const { isPending, user } = useSession();
6400
- return /* @__PURE__ */ jsxs53("div", { className: "fixed start-0 bottom-0 z-40 m-5 flex flex-col gap-2", children: [
6401
- /* @__PURE__ */ jsxs53("div", { className: "flex items-center gap-1 text-muted-foreground text-xs", children: [
6402
- t("text"),
6403
- " ",
6404
- isPending || !user ? /* @__PURE__ */ jsx63("span", { className: "h-3 w-32 animate-pulse rounded-md border bg-muted-foreground" }) : /* @__PURE__ */ jsx63("b", { className: "text-foreground", children: user.email })
6405
- ] }),
6406
- /* @__PURE__ */ jsx63(Button35, { variant: "mono", className: "h-8 w-fit rounded-lg px-3 text-xs shadow-sm", children: /* @__PURE__ */ jsx63(Link11, { href: linkHref, children: t("button") }) })
6608
+ function NewWorkspaceForm({ hasWorkspaces = false }) {
6609
+ const { authClient, path } = useConfig();
6610
+ const router = useRouter19();
6611
+ const t = useTranslations51();
6612
+ const RESERVED_SLUGS = [
6613
+ // Main routes
6614
+ path.main.ERROR.replace("/", ""),
6615
+ path.main.HOME.replace("/", ""),
6616
+ path.main.FEATURES.replace("/", ""),
6617
+ path.main.PRICING.replace("/", ""),
6618
+ path.main.TERMS.replace("/", ""),
6619
+ path.main.PRIVACY.replace("/", ""),
6620
+ // Auth routes
6621
+ path.auth.EMAIL_OTP.replace("/", ""),
6622
+ path.auth.FORGOT_PASSWORD.replace("/", ""),
6623
+ path.auth.MAGIC_LINK.replace("/", ""),
6624
+ path.auth.RECOVER_ACCOUNT.replace("/", ""),
6625
+ path.auth.RESET_PASSWORD.replace("/", ""),
6626
+ path.auth.SIGN_IN.replace("/", ""),
6627
+ path.auth.SIGN_OUT.replace("/", ""),
6628
+ path.auth.SIGN_UP.replace("/", ""),
6629
+ path.auth.TWO_FACTOR.replace("/", ""),
6630
+ // System routes
6631
+ "new",
6632
+ "accept",
6633
+ "invitation",
6634
+ "join",
6635
+ "verify",
6636
+ "api",
6637
+ "account",
6638
+ "accounts",
6639
+ "billing",
6640
+ "billings",
6641
+ "user",
6642
+ "users",
6643
+ "onboarding",
6644
+ "organization",
6645
+ "organizations",
6646
+ "workspace",
6647
+ "workspaces",
6648
+ "setting",
6649
+ "settings",
6650
+ "apikey",
6651
+ "apikeys",
6652
+ "member",
6653
+ "members",
6654
+ "people",
6655
+ "peoples",
6656
+ // Next.js internals
6657
+ "_next",
6658
+ "static",
6659
+ "favicon",
6660
+ "robots",
6661
+ "sitemap",
6662
+ // Future-proofing common patterns
6663
+ "admin",
6664
+ "dashboard",
6665
+ "app",
6666
+ "www",
6667
+ "home",
6668
+ "blog",
6669
+ "docs",
6670
+ "help",
6671
+ "support",
6672
+ "about",
6673
+ "contact",
6674
+ "features",
6675
+ "pricing",
6676
+ "terms",
6677
+ "privacy"
6678
+ ];
6679
+ const formSchema = z15.object({
6680
+ name: z15.string().min(1, {
6681
+ error: `${t("systems.ORGANIZATION_NAME")} ${t("systems.IS_REQUIRED")}`
6682
+ }),
6683
+ slug: z15.string().min(1, {
6684
+ error: `${t("systems.ORGANIZATION_SLUG")} ${t("systems.IS_REQUIRED")}`
6685
+ }).regex(/^[a-z0-9]+([a-z0-9-]*[a-z0-9])?$/, {
6686
+ error: `${t("systems.ORGANIZATION_SLUG")} ${t("systems.IS_INVALID")}`
6687
+ }).refine((slug) => !RESERVED_SLUGS.includes(slug), {
6688
+ error: `${t("systems.ORGANIZATION_SLUG")} ${t("systems.IS_INVALID")}`
6689
+ })
6690
+ });
6691
+ const form = useForm16({
6692
+ resolver: zodResolver15(formSchema),
6693
+ defaultValues: {
6694
+ name: "",
6695
+ slug: ""
6696
+ }
6697
+ });
6698
+ const watchedName = form.watch("name");
6699
+ const watchedSlug = form.watch("slug");
6700
+ const isSubmitting = form.formState.isSubmitting;
6701
+ const disableSubmit = isSubmitting || !form.formState.isValid || !watchedName || !watchedSlug;
6702
+ async function onSubmit({ name, slug }) {
6703
+ const { error } = await authClient.organization.checkSlug({
6704
+ slug
6705
+ });
6706
+ if (error) {
6707
+ AlertToast26({
6708
+ message: getTranslations({ error, t }),
6709
+ icon: "destructive"
6710
+ });
6711
+ console.log("check slug error", error);
6712
+ return;
6713
+ }
6714
+ try {
6715
+ const organization = await authClient.organization.create({
6716
+ name,
6717
+ slug,
6718
+ logo: `https://api.dicebear.com/9.x/glass/svg?seed=${slug}`,
6719
+ fetchOptions: { throw: true }
6720
+ });
6721
+ if (organization) {
6722
+ console.log("setting active organization", organization.id);
6723
+ await authClient.organization.setActive({
6724
+ organizationId: organization.id
6725
+ });
6726
+ console.log("active organization set", organization.id);
6727
+ router.push(`/${organization.slug}`);
6728
+ AlertToast26({
6729
+ message: t("systems.CREATE_ORGANIZATION_SUCCESS")
6730
+ });
6731
+ }
6732
+ } catch (error2) {
6733
+ AlertToast26({
6734
+ message: getTranslations({ error: error2, t }),
6735
+ icon: "destructive"
6736
+ });
6737
+ }
6738
+ }
6739
+ const handleSlugify = (slug) => {
6740
+ return slugify(slug, { lower: true, strict: true, remove: /[*+~.()'"!:@]/g });
6741
+ };
6742
+ return /* @__PURE__ */ jsx63(Form16, { ...form, children: /* @__PURE__ */ jsxs53("form", { onSubmit: form.handleSubmit(onSubmit), className: "w-full space-y-6", children: [
6743
+ /* @__PURE__ */ jsx63(
6744
+ FormField15,
6745
+ {
6746
+ control: form.control,
6747
+ name: "name",
6748
+ render: ({ field }) => /* @__PURE__ */ jsxs53(FormItem15, { children: [
6749
+ /* @__PURE__ */ jsx63(FormLabel14, { children: t("systems.ORGANIZATION_NAME") }),
6750
+ /* @__PURE__ */ jsx63(FormControl15, { children: /* @__PURE__ */ jsx63(
6751
+ Input12,
6752
+ {
6753
+ placeholder: t("systems.ORGANIZATION_NAME_PLACEHOLDER"),
6754
+ ...field,
6755
+ onChange: (e) => {
6756
+ const v = e.target.value;
6757
+ field.onChange(v);
6758
+ form.setValue("slug", handleSlugify(v), {
6759
+ shouldValidate: true,
6760
+ shouldDirty: true
6761
+ });
6762
+ },
6763
+ onBlur: () => {
6764
+ field.onBlur();
6765
+ void handleSlugify(form.getValues("slug"));
6766
+ }
6767
+ }
6768
+ ) }),
6769
+ /* @__PURE__ */ jsx63(FormMessage15, {})
6770
+ ] })
6771
+ }
6772
+ ),
6773
+ /* @__PURE__ */ jsx63(
6774
+ FormField15,
6775
+ {
6776
+ control: form.control,
6777
+ name: "slug",
6778
+ render: ({ field }) => /* @__PURE__ */ jsxs53(FormItem15, { children: [
6779
+ /* @__PURE__ */ jsx63(FormLabel14, { children: t("systems.ORGANIZATION_SLUG") }),
6780
+ /* @__PURE__ */ jsx63(FormControl15, { children: /* @__PURE__ */ jsx63(Input12, { placeholder: t("systems.ORGANIZATION_SLUG_PLACEHOLDER"), ...field }) }),
6781
+ /* @__PURE__ */ jsx63(FormMessage15, {})
6782
+ ] })
6783
+ }
6784
+ ),
6785
+ /* @__PURE__ */ jsxs53("div", { className: "flex flex-col gap-4", children: [
6786
+ /* @__PURE__ */ jsxs53(
6787
+ Button37,
6788
+ {
6789
+ type: "submit",
6790
+ className: cn44("w-full", disableSubmit && "pointer-events-auto! cursor-not-allowed"),
6791
+ disabled: disableSubmit,
6792
+ children: [
6793
+ isSubmitting && /* @__PURE__ */ jsx63(Spinner21, {}),
6794
+ t("systems.CREATE_ORGANIZATION")
6795
+ ]
6796
+ }
6797
+ ),
6798
+ hasWorkspaces && /* @__PURE__ */ jsx63(
6799
+ Link11,
6800
+ {
6801
+ href: "/",
6802
+ className: cn44(buttonVariants({ variant: "ghost", size: "lg" }), "w-full"),
6803
+ children: t("systems.common.actions.backDashboard")
6804
+ }
6805
+ )
6806
+ ] })
6807
+ ] }) });
6808
+ }
6809
+
6810
+ // src/ui/pages/verify-email.tsx
6811
+ import { useEffect as useEffect18, useState as useState22 } from "react";
6812
+ import { useRouter as useRouter20 } from "next/navigation";
6813
+ import { useTranslations as useTranslations52 } from "next-intl";
6814
+ import { cn as cn45 } from "pelatform-ui";
6815
+ import { AlertToast as AlertToast27 } from "pelatform-ui/components";
6816
+ import { Button as Button38, Card as Card13, CardContent as CardContent5, CardHeader as CardHeader4, InputOTP as InputOTP3, Spinner as Spinner22 } from "pelatform-ui/default";
6817
+ import { Fragment as Fragment21, jsx as jsx64, jsxs as jsxs54 } from "react/jsx-runtime";
6818
+ function VerifyEmail({ className, classNames, callbackUrl, email }) {
6819
+ const { authClient } = useConfig();
6820
+ const router = useRouter20();
6821
+ const t = useTranslations52();
6822
+ const [otp, setOtp] = useState22("");
6823
+ const [isLoading, setIsLoading] = useState22(false);
6824
+ const [isResendLoading, setIsResendLoading] = useState22(false);
6825
+ const [isResendSuccess, setIsResendSuccess] = useState22(false);
6826
+ const [waitingSeconds, setWaitingSeconds] = useState22(30);
6827
+ useEffect18(() => {
6828
+ if (waitingSeconds > 0) {
6829
+ const timeout = setTimeout(() => {
6830
+ setWaitingSeconds(waitingSeconds - 1);
6831
+ }, 1e3);
6832
+ return () => clearTimeout(timeout);
6833
+ }
6834
+ if (waitingSeconds === 0 && isResendSuccess) {
6835
+ setIsResendSuccess(false);
6836
+ }
6837
+ }, [waitingSeconds, isResendSuccess]);
6838
+ const handleResendCode = async () => {
6839
+ setIsResendLoading(true);
6840
+ try {
6841
+ await authClient.emailOtp.sendVerificationOtp({
6842
+ email,
6843
+ type: "email-verification"
6844
+ });
6845
+ AlertToast27({
6846
+ message: t("systems.VERIFY_EMAIL_RESEND_SUCCESS")
6847
+ });
6848
+ } catch {
6849
+ AlertToast27({
6850
+ message: t("systems.VERIFY_EMAIL_RESEND_FAILED"),
6851
+ icon: "destructive"
6852
+ });
6853
+ } finally {
6854
+ setWaitingSeconds(30);
6855
+ setIsResendLoading(false);
6856
+ setIsResendSuccess(true);
6857
+ }
6858
+ };
6859
+ const handleVerifyOtp = async () => {
6860
+ setIsLoading(true);
6861
+ try {
6862
+ const result = await authClient.emailOtp.verifyEmail({
6863
+ email,
6864
+ otp
6865
+ });
6866
+ if (result.data) {
6867
+ AlertToast27({
6868
+ message: t("systems.VERIFY_EMAIL_SUCCESS")
6869
+ });
6870
+ router.push(callbackUrl);
6871
+ } else {
6872
+ AlertToast27({
6873
+ message: t("systems.VERIFY_EMAIL_FAILED"),
6874
+ icon: "destructive"
6875
+ });
6876
+ }
6877
+ } catch {
6878
+ AlertToast27({
6879
+ message: t("systems.VERIFY_EMAIL_FAILED_TRY"),
6880
+ icon: "destructive"
6881
+ });
6882
+ } finally {
6883
+ setIsLoading(false);
6884
+ }
6885
+ };
6886
+ const emailElement = () => /* @__PURE__ */ jsx64("span", { className: "block font-medium text-foreground", children: email });
6887
+ return /* @__PURE__ */ jsxs54(Card13, { className: cn45("w-full max-w-md overflow-hidden", className, classNames?.base), children: [
6888
+ /* @__PURE__ */ jsx64(CardHeader4, { className: "py-4", children: /* @__PURE__ */ jsx64(
6889
+ CardHeaderComponent,
6890
+ {
6891
+ className: "w-full text-center",
6892
+ title: t("systems.VERIFY_EMAIL_TITLE"),
6893
+ description: /* @__PURE__ */ jsxs54(Fragment21, { children: [
6894
+ t("systems.VERIFY_EMAIL_DESCRIPTION"),
6895
+ " ",
6896
+ emailElement()
6897
+ ] })
6898
+ }
6899
+ ) }),
6900
+ /* @__PURE__ */ jsxs54(CardContent5, { className: cn45("flex flex-col gap-6 truncate", classNames?.content), children: [
6901
+ /* @__PURE__ */ jsx64(
6902
+ InputOTP3,
6903
+ {
6904
+ maxLength: 6,
6905
+ onChange: (value) => setOtp(value),
6906
+ value: otp,
6907
+ containerClassName: "justify-center",
6908
+ children: /* @__PURE__ */ jsx64(OTPInputGroup, { otpSeparators: 1 })
6909
+ }
6910
+ ),
6911
+ /* @__PURE__ */ jsxs54("div", { className: "flex w-full flex-col items-center gap-4", children: [
6912
+ /* @__PURE__ */ jsxs54(
6913
+ Button38,
6914
+ {
6915
+ className: cn45(
6916
+ "flex w-full items-center justify-center",
6917
+ otp.length !== 6 && "cursor-not-allowed"
6918
+ ),
6919
+ onClick: handleVerifyOtp,
6920
+ disabled: otp.length !== 6,
6921
+ children: [
6922
+ isLoading && /* @__PURE__ */ jsx64(Spinner22, {}),
6923
+ t("systems.VERIFY_EMAIL_BUTTON")
6924
+ ]
6925
+ }
6926
+ ),
6927
+ /* @__PURE__ */ jsxs54("div", { className: "flex flex-col items-center gap-3", children: [
6928
+ /* @__PURE__ */ jsx64("p", { className: "text-muted-foreground text-sm", children: t("systems.VERIFY_EMAIL_NOT_RECEIVE") }),
6929
+ /* @__PURE__ */ jsxs54(
6930
+ Button38,
6931
+ {
6932
+ variant: "outline",
6933
+ className: cn45(
6934
+ "text-muted-foreground",
6935
+ isResendLoading || waitingSeconds > 0 && "cursor-not-allowed"
6936
+ ),
6937
+ onClick: handleResendCode,
6938
+ disabled: waitingSeconds > 0,
6939
+ children: [
6940
+ isResendLoading && /* @__PURE__ */ jsx64(Spinner22, {}),
6941
+ isResendLoading ? `${t("systems.VERIFY_EMAIL_SENDING")}` : waitingSeconds > 0 ? `${t("systems.VERIFY_EMAIL_RESEND")} (${waitingSeconds}s)` : t("systems.VERIFY_EMAIL_RESEND")
6942
+ ]
6943
+ }
6944
+ )
6945
+ ] })
6946
+ ] })
6947
+ ] })
6948
+ ] });
6949
+ }
6950
+
6951
+ // src/ui/providers/shared.tsx
6952
+ import { Suspense as Suspense2 } from "react";
6953
+ import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
6954
+ import { NextIntlClientProvider } from "next-intl";
6955
+ import { QueryProvider, ThemeProvider } from "pelatform-ui/components";
6956
+ import { Toaster as Sonner } from "pelatform-ui/default";
6957
+ import { jsx as jsx65, jsxs as jsxs55 } from "react/jsx-runtime";
6958
+ function SharedProviders({
6959
+ children,
6960
+ locale,
6961
+ messages,
6962
+ timeZone = "Asia/Jakarta",
6963
+ sonnerPosition = "top-center"
6964
+ }) {
6965
+ const config = useConfig();
6966
+ return /* @__PURE__ */ jsxs55(QueryProvider, { children: [
6967
+ /* @__PURE__ */ jsx65(ThemeProvider, { defaultTheme: config.ui.defaultTheme, children: /* @__PURE__ */ jsx65(NextIntlClientProvider, { locale, messages, timeZone, children: /* @__PURE__ */ jsxs55(Suspense2, { children: [
6968
+ children,
6969
+ /* @__PURE__ */ jsx65(Sonner, { position: sonnerPosition })
6970
+ ] }) }) }),
6971
+ /* @__PURE__ */ jsx65(ReactQueryDevtools, { initialIsOpen: false })
6972
+ ] });
6973
+ }
6974
+
6975
+ // src/ui/providers/workspace.tsx
6976
+ import { useCallback as useCallback5, useContext as useContext14, useEffect as useEffect19, useState as useState23 } from "react";
6977
+ import { notFound, usePathname as usePathname5, useRouter as useRouter21 } from "next/navigation";
6978
+ import { useMutation as useMutation3, useQuery as useQuery3, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
6979
+ import { AlertToast as AlertToast28 } from "pelatform-ui/components";
6980
+ import { jsx as jsx66 } from "react/jsx-runtime";
6981
+ function WorkspaceProvider({
6982
+ children,
6983
+ initialWorkspace,
6984
+ workspaceSlug,
6985
+ fetchWorkspaceList: fetchWorkspaceListProp,
6986
+ fetchWorkspaceBySlug: fetchWorkspaceBySlugProp
6987
+ }) {
6988
+ const { authClient, app } = useConfig();
6989
+ const { queryKey } = useContext14(QueryContext);
6990
+ const pathname = usePathname5();
6991
+ const queryClient = useQueryClient3();
6992
+ const router = useRouter21();
6993
+ const [activeWorkspace, setActiveWorkspace] = useState23(initialWorkspace);
6994
+ const [isSwitchingWorkspace, setIsSwitchingWorkspace] = useState23(false);
6995
+ const shouldFetchWorkspace = !!workspaceSlug && (!activeWorkspace || activeWorkspace.slug !== workspaceSlug);
6996
+ const fetchWorkspaceList = fetchWorkspaceListProp || `${app.api}/workspaces`;
6997
+ const fetchWorkspaceBySlug = fetchWorkspaceBySlugProp || `${app.api}/workspace/s`;
6998
+ const { data: usersWorkspaces } = useQuery3({
6999
+ queryKey: queryKey.workspaceList,
7000
+ queryFn: async () => {
7001
+ const response = await request(fetchWorkspaceList);
7002
+ return response.data;
7003
+ }
7004
+ });
7005
+ const fetchWorkspaceData = async (slug) => {
7006
+ try {
7007
+ const response = await request(`${fetchWorkspaceBySlug}/${slug}`);
7008
+ if (response.status === 200) {
7009
+ setActiveWorkspace(response.data);
7010
+ return response.data;
7011
+ }
7012
+ if (response.status === 404) {
7013
+ console.error("Workspace not found");
7014
+ return notFound();
7015
+ }
7016
+ console.error(`Unexpected status code: ${response.status}`);
7017
+ return null;
7018
+ } catch (error) {
7019
+ console.error("Failed to fetch workspace data:", error);
7020
+ return null;
7021
+ }
7022
+ };
7023
+ const { data: fetchedActiveWorkspace, isLoading: isFetchingActiveWorkspace } = useQuery3({
7024
+ queryKey: queryKey.workspaceBySlug(workspaceSlug),
7025
+ queryFn: () => fetchWorkspaceData(workspaceSlug),
7026
+ enabled: shouldFetchWorkspace,
7027
+ initialData: initialWorkspace && initialWorkspace.slug === workspaceSlug ? initialWorkspace : void 0,
7028
+ staleTime: 5 * 60 * 1e3,
7029
+ gcTime: 10 * 60 * 1e3
7030
+ });
7031
+ const { mutateAsync: updateActiveWorkspaceMutation } = useMutation3({
7032
+ mutationFn: async (workspace) => {
7033
+ setIsSwitchingWorkspace(true);
7034
+ setActiveWorkspace(
7035
+ (prev) => ({
7036
+ ...prev,
7037
+ ...workspace
7038
+ })
7039
+ );
7040
+ if (workspace.slug) {
7041
+ setLastVisitedWorkspace(workspace.slug);
7042
+ }
7043
+ if (!workspace.id) {
7044
+ throw new Error("Workspace ID is required for switching");
7045
+ }
7046
+ const { data, error } = await authClient.organization.setActive({
7047
+ organizationId: workspace.id
7048
+ });
7049
+ if (error) {
7050
+ AlertToast28({
7051
+ message: error.message,
7052
+ icon: "destructive"
7053
+ });
7054
+ throw new Error(error.message);
7055
+ }
7056
+ return data;
7057
+ },
7058
+ onSuccess: (data) => {
7059
+ if (data) {
7060
+ queryClient.removeQueries({
7061
+ predicate: (query) => {
7062
+ const key = query.queryKey;
7063
+ return Array.isArray(key) && key.length >= 2 && typeof key[1] === "string" && WORKSPACE_SCOPED_PREFIXES.includes(key[0]);
7064
+ }
7065
+ });
7066
+ queryClient.setQueryData(queryKey.workspaceBySlug(data.slug), data);
7067
+ queryClient.setQueryData(queryKey.workspaceById(data.id), data);
7068
+ const pathSegments = pathname.split("/").filter(Boolean);
7069
+ const pathAfterWorkspace = pathSegments.slice(1).join("/");
7070
+ const newPath = pathAfterWorkspace ? `/${data.slug}/${pathAfterWorkspace}` : `/${data.slug}`;
7071
+ router.push(newPath);
7072
+ }
7073
+ setIsSwitchingWorkspace(false);
7074
+ },
7075
+ onError: (error) => {
7076
+ console.error("Failed to switch workspace:", error);
7077
+ if (initialWorkspace) {
7078
+ setActiveWorkspace(initialWorkspace);
7079
+ setLastVisitedWorkspace(initialWorkspace.slug);
7080
+ }
7081
+ setIsSwitchingWorkspace(false);
7082
+ }
7083
+ });
7084
+ const updateActiveWorkspace = useCallback5(
7085
+ async (workspace) => {
7086
+ await updateActiveWorkspaceMutation(workspace);
7087
+ },
7088
+ [updateActiveWorkspaceMutation]
7089
+ );
7090
+ useEffect19(() => {
7091
+ if (fetchedActiveWorkspace && workspaceSlug !== fetchedActiveWorkspace.slug && !isSwitchingWorkspace) {
7092
+ updateActiveWorkspace(fetchedActiveWorkspace);
7093
+ }
7094
+ }, [fetchedActiveWorkspace, workspaceSlug, isSwitchingWorkspace, updateActiveWorkspace]);
7095
+ const isFetchingWorkspace = isFetchingActiveWorkspace || isSwitchingWorkspace;
7096
+ const isOwner = activeWorkspace?.currentUserRole === "owner";
7097
+ const isAdmin = activeWorkspace?.currentUserRole === "admin";
7098
+ const isMember = activeWorkspace?.currentUserRole === "member";
7099
+ const currentUserRole = activeWorkspace?.currentUserRole || null;
7100
+ return /* @__PURE__ */ jsx66(
7101
+ WorkspaceContext.Provider,
7102
+ {
7103
+ value: {
7104
+ activeWorkspace,
7105
+ workspaceList: usersWorkspaces ?? null,
7106
+ isFetchingWorkspace,
7107
+ isOwner,
7108
+ isAdmin,
7109
+ isMember,
7110
+ currentUserRole,
7111
+ updateActiveWorkspace
7112
+ },
7113
+ children
7114
+ }
7115
+ );
7116
+ }
7117
+
7118
+ // src/ui/shared/empty-state.tsx
7119
+ import Link12 from "next/link";
7120
+ import { useTranslations as useTranslations53 } from "next-intl";
7121
+ import { cn as cn46 } from "pelatform-ui";
7122
+ import { jsx as jsx67, jsxs as jsxs56 } from "react/jsx-runtime";
7123
+ function EmptyState({
7124
+ className,
7125
+ icon: Icon,
7126
+ title,
7127
+ description,
7128
+ learnMore,
7129
+ learnMoreText,
7130
+ children
7131
+ }) {
7132
+ const t = useTranslations53();
7133
+ return /* @__PURE__ */ jsxs56("div", { className: cn46("flex flex-col items-center justify-center gap-y-4", className), children: [
7134
+ Icon && /* @__PURE__ */ jsx67("div", { className: "flex size-14 items-center justify-center rounded-2xl border bg-muted", children: /* @__PURE__ */ jsx67(Icon, { className: "size-6 text-foreground" }) }),
7135
+ /* @__PURE__ */ jsx67("p", { className: "text-center font-medium text-base text-foreground", children: title }),
7136
+ description && /* @__PURE__ */ jsxs56("p", { className: "max-w-sm text-balance text-center text-muted-foreground text-sm", children: [
7137
+ description,
7138
+ " ",
7139
+ learnMore && /* @__PURE__ */ jsxs56(
7140
+ Link12,
7141
+ {
7142
+ href: learnMore,
7143
+ className: "text-foreground underline underline-offset-2 transition-colors hover:text-primary",
7144
+ children: [
7145
+ learnMoreText ?? t("systems.common.ui.learnMore"),
7146
+ " \u2197"
7147
+ ]
7148
+ }
7149
+ )
7150
+ ] }),
7151
+ children
7152
+ ] });
7153
+ }
7154
+
7155
+ // src/ui/workspace/partials/delete.tsx
7156
+ import { useContext as useContext15, useState as useState24 } from "react";
7157
+ import { useRouter as useRouter22 } from "next/navigation";
7158
+ import { zodResolver as zodResolver16 } from "@hookform/resolvers/zod";
7159
+ import { useMutation as useMutation4, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
7160
+ import { useTranslations as useTranslations54 } from "next-intl";
7161
+ import { useForm as useForm17 } from "react-hook-form";
7162
+ import { z as z16 } from "zod";
7163
+ import { cn as cn47 } from "pelatform-ui";
7164
+ import { AlertToast as AlertToast29 } from "pelatform-ui/components";
7165
+ import {
7166
+ Button as Button39,
7167
+ Card as Card14,
7168
+ Form as Form17,
7169
+ FormControl as FormControl16,
7170
+ FormField as FormField16,
7171
+ FormItem as FormItem16,
7172
+ FormLabel as FormLabel15,
7173
+ FormMessage as FormMessage16,
7174
+ Input as Input13,
7175
+ Spinner as Spinner23
7176
+ } from "pelatform-ui/default";
7177
+ import { Fragment as Fragment22, jsx as jsx68, jsxs as jsxs57 } from "react/jsx-runtime";
7178
+ function WorkspaceDeleteCard({ className, classNames, ...props }) {
7179
+ const { activeWorkspace, isOwner } = useWorkspace();
7180
+ const t = useTranslations54();
7181
+ const [showDialog, setShowDialog] = useState24(false);
7182
+ if (!isOwner || !activeWorkspace) {
7183
+ return null;
7184
+ }
7185
+ return /* @__PURE__ */ jsxs57(Fragment22, { children: [
7186
+ /* @__PURE__ */ jsx68(
7187
+ CardComponent,
7188
+ {
7189
+ className,
7190
+ classNames,
7191
+ title: t("systems.DELETE_ORGANIZATION"),
7192
+ description: t("systems.DELETE_ORGANIZATION_DESCRIPTION"),
7193
+ actionLabel: t("systems.DELETE_ORGANIZATION"),
7194
+ action: () => setShowDialog(true),
7195
+ isDestructive: true,
7196
+ ...props
7197
+ }
7198
+ ),
7199
+ /* @__PURE__ */ jsx68(
7200
+ DeleteWorkspaceDialog,
7201
+ {
7202
+ classNames,
7203
+ open: showDialog,
7204
+ onOpenChange: setShowDialog
7205
+ }
7206
+ )
7207
+ ] });
7208
+ }
7209
+ function DeleteWorkspaceDialog({
7210
+ classNames,
7211
+ onOpenChange,
7212
+ title,
7213
+ description,
7214
+ ...props
7215
+ }) {
7216
+ const { authClient, path } = useConfig();
7217
+ const { queryKey } = useContext15(QueryContext);
7218
+ const { activeWorkspace, isOwner, updateActiveWorkspace, workspaceList } = useWorkspace();
7219
+ const queryClient = useQueryClient4();
7220
+ const router = useRouter22();
7221
+ const t = useTranslations54();
7222
+ const formSchema = z16.object({
7223
+ slug: z16.string().min(1, {
7224
+ error: `${t("systems.ORGANIZATION_SLUG")} ${t("systems.IS_REQUIRED")}`
7225
+ }).refine((val) => val === activeWorkspace?.slug, {
7226
+ error: t("systems.SLUG_DOES_NOT_MATCH")
7227
+ })
7228
+ });
7229
+ const form = useForm17({
7230
+ resolver: zodResolver16(formSchema),
7231
+ defaultValues: {
7232
+ slug: ""
7233
+ }
7234
+ });
7235
+ const disableSubmit = form.formState.isSubmitting || !form.formState.isValid;
7236
+ const { mutate: deleteMutation, isPending } = useMutation4({
7237
+ mutationFn: async ({ organizationId }) => {
7238
+ await authClient.organization.delete({
7239
+ organizationId
7240
+ });
7241
+ },
7242
+ onSuccess: async () => {
7243
+ AlertToast29({
7244
+ message: t("systems.DELETE_ORGANIZATION_SUCCESS")
7245
+ });
7246
+ const remainingWorkspaces = workspaceList?.filter((org) => org.id !== activeWorkspace?.id);
7247
+ if (!remainingWorkspaces || remainingWorkspaces.length === 0) {
7248
+ router.push(path.custom.NEW_WORKSPACE || "/");
7249
+ return;
7250
+ }
7251
+ queryClient.invalidateQueries({
7252
+ queryKey: queryKey.workspaceList
7253
+ });
7254
+ const nextWorkspace = remainingWorkspaces[0];
7255
+ if (!nextWorkspace) {
7256
+ router.push(path.custom.NEW_WORKSPACE || "/");
7257
+ return;
7258
+ }
7259
+ await updateActiveWorkspace(nextWorkspace);
7260
+ router.push(`/${nextWorkspace.slug}`);
7261
+ onOpenChange?.(false);
7262
+ },
7263
+ onError: (error) => {
7264
+ AlertToast29({
7265
+ message: getTranslations({ error, t }),
7266
+ icon: "destructive"
7267
+ });
7268
+ }
7269
+ });
7270
+ const onSubmit = () => {
7271
+ if (!isOwner || !activeWorkspace?.id) {
7272
+ return;
7273
+ }
7274
+ deleteMutation({ organizationId: activeWorkspace.id });
7275
+ };
7276
+ return /* @__PURE__ */ jsxs57(
7277
+ DialogComponent,
7278
+ {
7279
+ classNames,
7280
+ onOpenChange,
7281
+ title: title || t("systems.DELETE_ORGANIZATION"),
7282
+ description: description || t("systems.DELETE_ORGANIZATION_DESCRIPTION"),
7283
+ disableFooter: true,
7284
+ ...props,
7285
+ children: [
7286
+ /* @__PURE__ */ jsx68(Card14, { className: cn47("mb-4 flex-row p-4", classNames?.cell), children: /* @__PURE__ */ jsx68(WorkspaceView, { workspace: activeWorkspace }) }),
7287
+ /* @__PURE__ */ jsx68(Form17, { ...form, children: /* @__PURE__ */ jsxs57("form", { onSubmit: form.handleSubmit(onSubmit), children: [
7288
+ /* @__PURE__ */ jsx68(
7289
+ FormField16,
7290
+ {
7291
+ control: form.control,
7292
+ name: "slug",
7293
+ render: ({ field }) => /* @__PURE__ */ jsxs57(FormItem16, { children: [
7294
+ /* @__PURE__ */ jsxs57(FormLabel15, { className: cn47("font-normal", classNames?.label), children: [
7295
+ t("systems.DELETE_ORGANIZATION_INSTRUCTIONS"),
7296
+ " ",
7297
+ /* @__PURE__ */ jsx68("span", { className: "font-bold", children: activeWorkspace?.slug })
7298
+ ] }),
7299
+ /* @__PURE__ */ jsx68(FormControl16, { children: /* @__PURE__ */ jsx68(
7300
+ Input13,
7301
+ {
7302
+ placeholder: activeWorkspace?.slug,
7303
+ className: classNames?.input,
7304
+ autoComplete: "off",
7305
+ disabled: isPending,
7306
+ ...field
7307
+ }
7308
+ ) }),
7309
+ /* @__PURE__ */ jsx68(FormMessage16, { className: classNames?.error })
7310
+ ] })
7311
+ }
7312
+ ),
7313
+ /* @__PURE__ */ jsx68(
7314
+ DialogFooterComponent,
7315
+ {
7316
+ classNames,
7317
+ onOpenChange,
7318
+ cancelButton: true,
7319
+ cancelButtonDisabled: isPending,
7320
+ button: /* @__PURE__ */ jsxs57(
7321
+ Button39,
7322
+ {
7323
+ type: "submit",
7324
+ variant: "destructive",
7325
+ className: cn47(
7326
+ disableSubmit && "pointer-events-auto! cursor-not-allowed",
7327
+ classNames?.button,
7328
+ classNames?.destructiveButton
7329
+ ),
7330
+ disabled: disableSubmit,
7331
+ children: [
7332
+ isPending && /* @__PURE__ */ jsx68(Spinner23, {}),
7333
+ t("systems.DELETE_ORGANIZATION")
7334
+ ]
7335
+ }
7336
+ )
7337
+ }
7338
+ )
7339
+ ] }) })
7340
+ ]
7341
+ }
7342
+ );
7343
+ }
7344
+
7345
+ // src/ui/workspace/partials/logo.tsx
7346
+ import { useContext as useContext16, useRef as useRef8, useState as useState25 } from "react";
7347
+ import { useRouter as useRouter23 } from "next/navigation";
7348
+ import { useMutation as useMutation5, useQueryClient as useQueryClient5 } from "@tanstack/react-query";
7349
+ import { Trash2Icon as Trash2Icon2, UploadCloudIcon as UploadCloudIcon2 } from "lucide-react";
7350
+ import { useTranslations as useTranslations55 } from "next-intl";
7351
+ import { fileToBase64 as fileToBase642, resizeAndCropImage as resizeAndCropImage2 } from "pelatform-ui";
7352
+ import { AlertToast as AlertToast30 } from "pelatform-ui/components";
7353
+ import {
7354
+ Button as Button40,
7355
+ DropdownMenu as DropdownMenu5,
7356
+ DropdownMenuContent as DropdownMenuContent5,
7357
+ DropdownMenuItem as DropdownMenuItem5,
7358
+ DropdownMenuTrigger as DropdownMenuTrigger5
7359
+ } from "pelatform-ui/default";
7360
+ import { jsx as jsx69, jsxs as jsxs58 } from "react/jsx-runtime";
7361
+ function WorkspaceLogoCard({
7362
+ className,
7363
+ classNames,
7364
+ logo,
7365
+ ...props
7366
+ }) {
7367
+ const { authClient } = useConfig();
7368
+ const { queryKey } = useContext16(QueryContext);
7369
+ const { activeWorkspace, isOwner } = useWorkspace();
7370
+ const queryClient = useQueryClient5();
7371
+ const router = useRouter23();
7372
+ const t = useTranslations55();
7373
+ const fileInputRef = useRef8(null);
7374
+ const [logoUrl, setLogoUrl] = useState25(activeWorkspace?.logo || null);
7375
+ const [loading, setLoading] = useState25(false);
7376
+ const isBase64Logo = logoUrl?.includes("data:image");
7377
+ const isDicebearLogo = logoUrl?.includes("api.dicebear.com");
7378
+ const { mutate: updateMutation, isPending } = useMutation5({
7379
+ mutationFn: async ({ organizationId, logo: logo2 }) => {
7380
+ const res = await authClient.organization.update({
7381
+ organizationId,
7382
+ data: { logo: logo2 }
7383
+ });
7384
+ if (res?.error) {
7385
+ throw new Error(res.error.message);
7386
+ }
7387
+ return res;
7388
+ },
7389
+ onSuccess: (_, variables) => {
7390
+ setLogoUrl(variables.logo);
7391
+ AlertToast30({
7392
+ message: `${t("systems.LOGO_UPDATED")}`
7393
+ });
7394
+ queryClient.invalidateQueries({
7395
+ queryKey: queryKey.workspaceById(variables.organizationId)
7396
+ });
7397
+ router.refresh();
7398
+ },
7399
+ onError: (error) => {
7400
+ AlertToast30({
7401
+ message: getTranslations({ error, t }),
7402
+ icon: "destructive"
7403
+ });
7404
+ }
7405
+ });
7406
+ const handleLogoChange = async (file) => {
7407
+ if (!activeWorkspace?.id || !isOwner) return;
7408
+ setLoading(true);
7409
+ try {
7410
+ const resizedFile = await resizeAndCropImage2(
7411
+ file,
7412
+ crypto.randomUUID(),
7413
+ logo?.size || 256,
7414
+ logo?.extension || "png"
7415
+ );
7416
+ let image;
7417
+ if (logo?.upload) {
7418
+ image = await logo.upload(resizedFile);
7419
+ } else {
7420
+ image = await fileToBase642(resizedFile);
7421
+ }
7422
+ if (!image) {
7423
+ setLoading(false);
7424
+ return;
7425
+ }
7426
+ updateMutation({
7427
+ organizationId: activeWorkspace.id,
7428
+ logo: image
7429
+ });
7430
+ } catch (error) {
7431
+ AlertToast30({
7432
+ message: getTranslations({ error, t }),
7433
+ icon: "destructive"
7434
+ });
7435
+ }
7436
+ setLoading(false);
7437
+ };
7438
+ const handleDeleteLogo = async () => {
7439
+ if (!activeWorkspace?.id || !isOwner) return;
7440
+ setLoading(true);
7441
+ try {
7442
+ if (logoUrl && !isBase64Logo && !isDicebearLogo && logo?.delete) {
7443
+ await logo.delete(logoUrl);
7444
+ }
7445
+ const defaultLogo = `https://api.dicebear.com/9.x/glass/svg?seed=${activeWorkspace.slug}`;
7446
+ updateMutation({
7447
+ organizationId: activeWorkspace.id,
7448
+ logo: defaultLogo
7449
+ });
7450
+ } catch (error) {
7451
+ AlertToast30({
7452
+ message: getTranslations({ error, t }),
7453
+ icon: "destructive"
7454
+ });
7455
+ }
7456
+ setLoading(false);
7457
+ };
7458
+ const openFileDialog = () => {
7459
+ fileInputRef.current?.click();
7460
+ };
7461
+ return /* @__PURE__ */ jsxs58(
7462
+ CardComponent,
7463
+ {
7464
+ className,
7465
+ classNames: {
7466
+ content: "flex items-center justify-between",
7467
+ header: "w-full",
7468
+ ...classNames
7469
+ },
7470
+ title: t("systems.LOGO"),
7471
+ description: t("systems.LOGO_DESCRIPTION"),
7472
+ instructions: t("systems.LOGO_INSTRUCTIONS"),
7473
+ ...props,
7474
+ children: [
7475
+ /* @__PURE__ */ jsx69(
7476
+ "input",
7477
+ {
7478
+ ref: fileInputRef,
7479
+ type: "file",
7480
+ hidden: true,
7481
+ accept: "image/*",
7482
+ onChange: (e) => {
7483
+ const file = e.target.files?.item(0);
7484
+ if (file) handleLogoChange(file);
7485
+ e.target.value = "";
7486
+ },
7487
+ disabled: loading || !isOwner
7488
+ }
7489
+ ),
7490
+ /* @__PURE__ */ jsxs58(DropdownMenu5, { children: [
7491
+ /* @__PURE__ */ jsx69(DropdownMenuTrigger5, { asChild: true, children: /* @__PURE__ */ jsx69(Button40, { variant: "ghost", size: "icon", className: "size-fit rounded-full", disabled: !isOwner, children: /* @__PURE__ */ jsx69(
7492
+ WorkspaceLogo,
7493
+ {
7494
+ className: "size-16 lg:size-20",
7495
+ classNames: {
7496
+ fallback: "text-xl lg:text-2xl",
7497
+ ...classNames?.avatar
7498
+ },
7499
+ isPending,
7500
+ workspace: activeWorkspace,
7501
+ image: logoUrl || void 0
7502
+ }
7503
+ ) }) }),
7504
+ /* @__PURE__ */ jsxs58(DropdownMenuContent5, { align: "end", onCloseAutoFocus: (e) => e.preventDefault(), children: [
7505
+ /* @__PURE__ */ jsxs58(DropdownMenuItem5, { onClick: openFileDialog, disabled: loading || !isOwner, children: [
7506
+ /* @__PURE__ */ jsx69(UploadCloudIcon2, {}),
7507
+ t("systems.UPLOAD_LOGO")
7508
+ ] }),
7509
+ !isDicebearLogo && /* @__PURE__ */ jsxs58(
7510
+ DropdownMenuItem5,
7511
+ {
7512
+ variant: "destructive",
7513
+ onClick: handleDeleteLogo,
7514
+ disabled: loading || !isOwner,
7515
+ children: [
7516
+ /* @__PURE__ */ jsx69(Trash2Icon2, {}),
7517
+ t("systems.DELETE_LOGO")
7518
+ ]
7519
+ }
7520
+ )
7521
+ ] })
7522
+ ] })
7523
+ ]
7524
+ }
7525
+ );
7526
+ }
7527
+
7528
+ // src/ui/workspace/partials/name.tsx
7529
+ import { useContext as useContext17, useId } from "react";
7530
+ import { useRouter as useRouter24 } from "next/navigation";
7531
+ import { zodResolver as zodResolver17 } from "@hookform/resolvers/zod";
7532
+ import { useMutation as useMutation6, useQueryClient as useQueryClient6 } from "@tanstack/react-query";
7533
+ import { useTranslations as useTranslations56 } from "next-intl";
7534
+ import { useForm as useForm18 } from "react-hook-form";
7535
+ import { z as z17 } from "zod";
7536
+ import { AlertToast as AlertToast31 } from "pelatform-ui/components";
7537
+ import { Form as Form18, FormControl as FormControl17, FormField as FormField17, FormItem as FormItem17, FormMessage as FormMessage17, Input as Input14 } from "pelatform-ui/default";
7538
+ import { jsx as jsx70, jsxs as jsxs59 } from "react/jsx-runtime";
7539
+ function WorkspaceNameCard({ className, classNames, ...props }) {
7540
+ const { authClient } = useConfig();
7541
+ const { queryKey } = useContext17(QueryContext);
7542
+ const { activeWorkspace, isOwner } = useWorkspace();
7543
+ const queryClient = useQueryClient6();
7544
+ const router = useRouter24();
7545
+ const t = useTranslations56();
7546
+ const id = useId();
7547
+ const formSchema = z17.object({
7548
+ name: z17.string().min(1, {
7549
+ error: `${t("systems.ORGANIZATION_NAME")} ${t("systems.IS_REQUIRED")}`
7550
+ })
7551
+ });
7552
+ const form = useForm18({
7553
+ resolver: zodResolver17(formSchema),
7554
+ values: { name: activeWorkspace?.name || "" }
7555
+ });
7556
+ const disableSubmit = form.formState.isSubmitting || !form.formState.isValid || !form.formState.isDirty;
7557
+ const { mutate: updateMutation, isPending } = useMutation6({
7558
+ mutationFn: async ({
7559
+ organizationId,
7560
+ data
7561
+ }) => {
7562
+ const res = await authClient.organization.update({
7563
+ organizationId,
7564
+ data: {
7565
+ name: data.name
7566
+ }
7567
+ });
7568
+ if (res?.error) {
7569
+ throw new Error(res.error.message);
7570
+ }
7571
+ return res;
7572
+ },
7573
+ onSuccess: (_, variables) => {
7574
+ AlertToast31({
7575
+ message: `${t("systems.ORGANIZATION_NAME")} ${t("systems.UPDATED_SUCCESSFULLY")}`
7576
+ });
7577
+ form.reset({ name: form.getValues("name") });
7578
+ queryClient.invalidateQueries({
7579
+ queryKey: queryKey.workspaceById(variables.organizationId)
7580
+ });
7581
+ router.refresh();
7582
+ },
7583
+ onError: (error) => {
7584
+ AlertToast31({
7585
+ message: getTranslations({ error, t }),
7586
+ icon: "destructive"
7587
+ });
7588
+ }
7589
+ });
7590
+ const onSubmit = (data) => {
7591
+ if (!isOwner || !activeWorkspace?.id) {
7592
+ return;
7593
+ }
7594
+ const name = data.name.trim();
7595
+ if (activeWorkspace?.name === name) {
7596
+ AlertToast31({
7597
+ message: `${t("systems.ORGANIZATION_NAME")} ${t("systems.IS_THE_SAME")}`,
7598
+ icon: "destructive"
7599
+ });
7600
+ return;
7601
+ }
7602
+ updateMutation({
7603
+ organizationId: activeWorkspace.id,
7604
+ data: { name }
7605
+ });
7606
+ };
7607
+ return /* @__PURE__ */ jsx70(Form18, { ...form, children: /* @__PURE__ */ jsx70("form", { onSubmit: form.handleSubmit(onSubmit), children: /* @__PURE__ */ jsx70(
7608
+ CardComponent,
7609
+ {
7610
+ className,
7611
+ classNames,
7612
+ title: t("systems.ORGANIZATION_NAME"),
7613
+ description: t("systems.ORGANIZATION_NAME_DESCRIPTION"),
7614
+ instructions: t("systems.ORGANIZATION_NAME_INSTRUCTIONS"),
7615
+ actionLabel: t("systems.SAVE"),
7616
+ disabled: disableSubmit || !isOwner,
7617
+ isSubmitting: isPending,
7618
+ ...props,
7619
+ children: /* @__PURE__ */ jsx70(
7620
+ FormField17,
7621
+ {
7622
+ control: form.control,
7623
+ name: "name",
7624
+ render: ({ field }) => /* @__PURE__ */ jsxs59(FormItem17, { children: [
7625
+ /* @__PURE__ */ jsx70(FormControl17, { children: /* @__PURE__ */ jsx70(
7626
+ Input14,
7627
+ {
7628
+ id,
7629
+ className: classNames?.input,
7630
+ placeholder: t("systems.ORGANIZATION_NAME_PLACEHOLDER"),
7631
+ disabled: !isOwner,
7632
+ ...field
7633
+ }
7634
+ ) }),
7635
+ /* @__PURE__ */ jsx70(FormMessage17, { className: classNames?.error })
7636
+ ] })
7637
+ }
7638
+ )
7639
+ }
7640
+ ) }) });
7641
+ }
7642
+
7643
+ // src/ui/workspace/partials/slug.tsx
7644
+ import { useContext as useContext18, useId as useId2 } from "react";
7645
+ import { useRouter as useRouter25 } from "next/navigation";
7646
+ import { zodResolver as zodResolver18 } from "@hookform/resolvers/zod";
7647
+ import { useMutation as useMutation7, useQueryClient as useQueryClient7 } from "@tanstack/react-query";
7648
+ import { useTranslations as useTranslations57 } from "next-intl";
7649
+ import { useForm as useForm19 } from "react-hook-form";
7650
+ import { z as z18 } from "zod";
7651
+ import { AlertToast as AlertToast32 } from "pelatform-ui/components";
7652
+ import { Form as Form19, FormControl as FormControl18, FormField as FormField18, FormItem as FormItem18, FormMessage as FormMessage18, Input as Input15 } from "pelatform-ui/default";
7653
+
7654
+ // src/lib/string.ts
7655
+ function generateSlug(text) {
7656
+ const slug = text.trim().toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
7657
+ return slug;
7658
+ }
7659
+
7660
+ // src/ui/workspace/partials/slug.tsx
7661
+ import { jsx as jsx71, jsxs as jsxs60 } from "react/jsx-runtime";
7662
+ function WorkspaceSlugCard({ className, classNames, ...props }) {
7663
+ const { authClient, path } = useConfig();
7664
+ const { queryKey } = useContext18(QueryContext);
7665
+ const { activeWorkspace, isOwner } = useWorkspace();
7666
+ const queryClient = useQueryClient7();
7667
+ const router = useRouter25();
7668
+ const t = useTranslations57();
7669
+ const RESERVED_SLUGS = [
7670
+ // Main routes
7671
+ path.main.ERROR.replace("/", ""),
7672
+ path.main.HOME.replace("/", ""),
7673
+ path.main.FEATURES.replace("/", ""),
7674
+ path.main.PRICING.replace("/", ""),
7675
+ path.main.TERMS.replace("/", ""),
7676
+ path.main.PRIVACY.replace("/", ""),
7677
+ // Auth routes
7678
+ path.auth.EMAIL_OTP.replace("/", ""),
7679
+ path.auth.FORGOT_PASSWORD.replace("/", ""),
7680
+ path.auth.MAGIC_LINK.replace("/", ""),
7681
+ path.auth.RECOVER_ACCOUNT.replace("/", ""),
7682
+ path.auth.RESET_PASSWORD.replace("/", ""),
7683
+ path.auth.SIGN_IN.replace("/", ""),
7684
+ path.auth.SIGN_OUT.replace("/", ""),
7685
+ path.auth.SIGN_UP.replace("/", ""),
7686
+ path.auth.TWO_FACTOR.replace("/", ""),
7687
+ // System routes
7688
+ "new",
7689
+ "accept",
7690
+ "invitation",
7691
+ "join",
7692
+ "verify",
7693
+ "api",
7694
+ "account",
7695
+ "accounts",
7696
+ "billing",
7697
+ "billings",
7698
+ "user",
7699
+ "users",
7700
+ "onboarding",
7701
+ "organization",
7702
+ "organizations",
7703
+ "workspace",
7704
+ "workspaces",
7705
+ "setting",
7706
+ "settings",
7707
+ "apikey",
7708
+ "apikeys",
7709
+ "member",
7710
+ "members",
7711
+ "people",
7712
+ "peoples",
7713
+ // Next.js internals
7714
+ "_next",
7715
+ "static",
7716
+ "favicon",
7717
+ "robots",
7718
+ "sitemap",
7719
+ // Future-proofing common patterns
7720
+ "admin",
7721
+ "dashboard",
7722
+ "app",
7723
+ "www",
7724
+ "home",
7725
+ "blog",
7726
+ "docs",
7727
+ "help",
7728
+ "support",
7729
+ "about",
7730
+ "contact",
7731
+ "features",
7732
+ "pricing",
7733
+ "terms",
7734
+ "privacy"
7735
+ ];
7736
+ const id = useId2();
7737
+ const formSchema = z18.object({
7738
+ slug: z18.string().min(1, {
7739
+ error: `${t("systems.ORGANIZATION_SLUG")} ${t("systems.IS_REQUIRED")}`
7740
+ }).regex(/^[a-z0-9]+([a-z0-9-]*[a-z0-9])?$/, {
7741
+ error: `${t("systems.ORGANIZATION_SLUG")} ${t("systems.IS_INVALID")}`
7742
+ }).refine((slug) => !RESERVED_SLUGS.includes(slug), {
7743
+ error: `${t("systems.ORGANIZATION_SLUG")} ${t("systems.IS_INVALID")}`
7744
+ })
7745
+ });
7746
+ const form = useForm19({
7747
+ resolver: zodResolver18(formSchema),
7748
+ values: { slug: activeWorkspace?.slug || "" }
7749
+ });
7750
+ const disableSubmit = form.formState.isSubmitting || !form.formState.isValid || !form.formState.isDirty;
7751
+ const { mutate: updateMutation, isPending } = useMutation7({
7752
+ mutationFn: async ({
7753
+ organizationId,
7754
+ data
7755
+ }) => {
7756
+ const { data: checkSlug, error } = await authClient.organization.checkSlug({
7757
+ slug: data.slug
7758
+ });
7759
+ if (error) {
7760
+ throw new Error(error.message);
7761
+ }
7762
+ if (!checkSlug.status) {
7763
+ form.setError("slug", { message: t("systems.SLUG_ALREADY_TAKEN") });
7764
+ throw new Error(t("systems.SLUG_ALREADY_TAKEN"));
7765
+ }
7766
+ const res = await authClient.organization.update({
7767
+ organizationId,
7768
+ data: {
7769
+ slug: data.slug
7770
+ }
7771
+ });
7772
+ if (res?.error) {
7773
+ throw new Error(res.error.message);
7774
+ }
7775
+ return res;
7776
+ },
7777
+ onSuccess: (data, variables) => {
7778
+ if (!data) {
7779
+ return;
7780
+ }
7781
+ AlertToast32({
7782
+ message: `${t("systems.ORGANIZATION_SLUG")} ${t("systems.UPDATED_SUCCESSFULLY")}`
7783
+ });
7784
+ form.reset({ slug: data.data?.slug });
7785
+ queryClient.invalidateQueries({
7786
+ queryKey: queryKey.workspaceById(variables.organizationId)
7787
+ });
7788
+ router.replace(`/${data.data?.slug}${path.workspaces.SETTINGS}`);
7789
+ router.refresh();
7790
+ },
7791
+ onError: (error) => {
7792
+ AlertToast32({
7793
+ message: getTranslations({ error, t }),
7794
+ icon: "destructive"
7795
+ });
7796
+ }
7797
+ });
7798
+ const onSubmit = (data) => {
7799
+ if (!isOwner || !activeWorkspace?.id) {
7800
+ return;
7801
+ }
7802
+ const slug = generateSlug(data.slug);
7803
+ if (activeWorkspace?.slug === slug) {
7804
+ AlertToast32({
7805
+ message: `${t("systems.ORGANIZATION_SLUG")} ${t("systems.IS_THE_SAME")}`,
7806
+ icon: "destructive"
7807
+ });
7808
+ return;
7809
+ }
7810
+ updateMutation({
7811
+ organizationId: activeWorkspace.id,
7812
+ data: { slug }
7813
+ });
7814
+ };
7815
+ return /* @__PURE__ */ jsx71(Form19, { ...form, children: /* @__PURE__ */ jsx71("form", { onSubmit: form.handleSubmit(onSubmit), children: /* @__PURE__ */ jsx71(
7816
+ CardComponent,
7817
+ {
7818
+ className,
7819
+ classNames,
7820
+ title: t("systems.ORGANIZATION_SLUG"),
7821
+ description: t("systems.ORGANIZATION_SLUG_DESCRIPTION"),
7822
+ instructions: t("systems.ORGANIZATION_SLUG_INSTRUCTIONS"),
7823
+ actionLabel: t("systems.SAVE"),
7824
+ disabled: disableSubmit || !isOwner,
7825
+ isSubmitting: isPending,
7826
+ ...props,
7827
+ children: /* @__PURE__ */ jsx71(
7828
+ FormField18,
7829
+ {
7830
+ control: form.control,
7831
+ name: "slug",
7832
+ render: ({ field }) => /* @__PURE__ */ jsxs60(FormItem18, { children: [
7833
+ /* @__PURE__ */ jsx71(FormControl18, { children: /* @__PURE__ */ jsx71(
7834
+ Input15,
7835
+ {
7836
+ id,
7837
+ className: classNames?.input,
7838
+ placeholder: t("systems.ORGANIZATION_SLUG_PLACEHOLDER"),
7839
+ disabled: !isOwner,
7840
+ ...field
7841
+ }
7842
+ ) }),
7843
+ /* @__PURE__ */ jsx71(FormMessage18, { className: classNames?.error })
7844
+ ] })
7845
+ }
7846
+ )
7847
+ }
7848
+ ) }) });
7849
+ }
7850
+
7851
+ // src/ui/workspace/settings.tsx
7852
+ import { useTranslations as useTranslations58 } from "next-intl";
7853
+ import { cn as cn48 } from "pelatform-ui";
7854
+ import { jsx as jsx72, jsxs as jsxs61 } from "react/jsx-runtime";
7855
+ function WorkspaceSettingsCards({
7856
+ className,
7857
+ classNames,
7858
+ logo
7859
+ }) {
7860
+ const t = useTranslations58();
7861
+ const { activeWorkspace } = useWorkspace();
7862
+ return /* @__PURE__ */ jsxs61("div", { className: cn48("grid w-full gap-6 md:gap-8", className), children: [
7863
+ /* @__PURE__ */ jsx72(WorkspaceLogoCard, { classNames, logo }),
7864
+ /* @__PURE__ */ jsx72(WorkspaceNameCard, { classNames }),
7865
+ /* @__PURE__ */ jsx72(WorkspaceSlugCard, { classNames }),
7866
+ /* @__PURE__ */ jsx72(
7867
+ DisplayIdCard,
7868
+ {
7869
+ classNames,
7870
+ id: activeWorkspace?.id,
7871
+ title: t("systems.DISPLAY_ORGANIZATION_TITLE"),
7872
+ description: t("systems.DISPLAY_ORGANIZATION_DESCRIPTION")
7873
+ }
7874
+ ),
7875
+ /* @__PURE__ */ jsx72(WorkspaceDeleteCard, { classNames })
6407
7876
  ] });
6408
7877
  }
6409
7878
  export {
@@ -6452,6 +7921,8 @@ export {
6452
7921
  MagicLinkButton,
6453
7922
  MagicLinkForm,
6454
7923
  MultiAccountCard,
7924
+ NewWorkspace,
7925
+ NewWorkspaceForm,
6455
7926
  OTPInputGroup,
6456
7927
  OneTap,
6457
7928
  PasskeyButton,
@@ -6471,6 +7942,7 @@ export {
6471
7942
  SidebarContent,
6472
7943
  SidebarContentMenu,
6473
7944
  SidebarHeaderBack,
7945
+ SidebarHeaderWorkspaces,
6474
7946
  SignInForm,
6475
7947
  SignOut,
6476
7948
  SignUpForm,
@@ -6487,7 +7959,16 @@ export {
6487
7959
  UserAvatar,
6488
7960
  UserMenu,
6489
7961
  UserView,
7962
+ VerifyEmail,
7963
+ WorkspaceContext,
7964
+ WorkspaceDeleteCard,
6490
7965
  WorkspaceLogo,
7966
+ WorkspaceLogoCard,
7967
+ WorkspaceNameCard,
7968
+ WorkspaceProvider,
7969
+ WorkspaceSettingsCards,
7970
+ WorkspaceSlugCard,
7971
+ WorkspaceSwitcher,
6491
7972
  WorkspaceView,
6492
7973
  getUserName,
6493
7974
  useAccountInfo,
@@ -6513,5 +7994,6 @@ export {
6513
7994
  useSession,
6514
7995
  useSetActiveSession,
6515
7996
  useUnlinkAccount,
6516
- useUpdateUser
7997
+ useUpdateUser,
7998
+ useWorkspace
6517
7999
  };