@tailor-platform/app-shell 0.17.0 → 0.17.1
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.d.ts +3 -3
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ type Module = Omit<CommonPageResource, "meta"> & {
|
|
|
68
68
|
};
|
|
69
69
|
resources: Array<Resource>;
|
|
70
70
|
loader?: () => Response;
|
|
71
|
-
errorBoundary
|
|
71
|
+
errorBoundary: ErrorBoundaryComponent;
|
|
72
72
|
};
|
|
73
73
|
/**
|
|
74
74
|
* A resource that can be included in the sub-content in the root resource.
|
|
@@ -78,7 +78,7 @@ type Module = Omit<CommonPageResource, "meta"> & {
|
|
|
78
78
|
type Resource = CommonPageResource & {
|
|
79
79
|
_type: "resource";
|
|
80
80
|
subResources?: Array<Resource>;
|
|
81
|
-
errorBoundary
|
|
81
|
+
errorBoundary: ErrorBoundaryComponent;
|
|
82
82
|
};
|
|
83
83
|
type Modules = Array<Module>;
|
|
84
84
|
type ResourceMetaProps = {
|
|
@@ -297,7 +297,7 @@ type RootConfiguration = {
|
|
|
297
297
|
modules: Modules;
|
|
298
298
|
settingsResources: Resource[];
|
|
299
299
|
basePath?: string;
|
|
300
|
-
errorBoundary
|
|
300
|
+
errorBoundary: ErrorBoundaryComponent;
|
|
301
301
|
};
|
|
302
302
|
type NavChildItem = {
|
|
303
303
|
title: string;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Table as Ba}from"lucide-react";import{useEffect as Ma,useMemo as Ea,useState as Ia}from"react";import{createContext as ta,useContext as aa}from"react";var q=ta({navItems:[],configurations:{modules:[],settingsResources:[]}}),P=()=>aa(q);import{createBrowserRouter as ma,RouterProvider as ga,Navigate as ba,redirect as ha,Outlet as fa}from"react-router";import{NavLink as da,Outlet as lt}from"react-router";import{Toaster as la}from"sonner";import{Slot as oa}from"@radix-ui/react-slot";import{cva as sa}from"class-variance-authority";import{clsx as ea}from"clsx";import{twMerge as ra}from"tailwind-merge";function c(...t){return ra(ea(t))}import{jsx as na}from"react/jsx-runtime";var ia=sa("astw:inline-flex astw:items-center astw:justify-center astw:gap-2 astw:whitespace-nowrap astw:rounded-md astw:text-sm astw:font-medium astw:transition-all astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:[&_svg]:pointer-events-none astw:[&_svg:not([class*='size-'])]:size-4 astw:shrink-0 astw:[&_svg]:shrink-0 astw:outline-none astw:focus-visible:border-ring astw:focus-visible:ring-ring/50 astw:focus-visible:ring-[3px] astw:aria-invalid:ring-destructive/20 astw:dark:aria-invalid:ring-destructive/40 astw:aria-invalid:border-destructive",{variants:{variant:{default:"astw:bg-primary astw:text-primary-foreground astw:shadow-xs astw:hover:bg-primary/90",destructive:"astw:bg-destructive astw:text-white astw:shadow-xs astw:hover:bg-destructive/90 astw:focus-visible:ring-destructive/20 astw:dark:focus-visible:ring-destructive/40 astw:dark:bg-destructive/60",outline:"astw:border astw:bg-background astw:shadow-xs astw:hover:bg-accent astw:hover:text-accent-foreground astw:dark:bg-input/30 astw:dark:border-input astw:dark:hover:bg-input/50",secondary:"astw:bg-secondary astw:text-secondary-foreground astw:shadow-xs astw:hover:bg-secondary/80",ghost:"astw:hover:bg-accent astw:hover:text-accent-foreground astw:dark:hover:bg-accent/50",link:"astw:text-primary astw:underline-offset-4 astw:hover:underline"},size:{default:"astw:h-9 astw:px-4 astw:py-2 astw:has-[>svg]:px-3",sm:"astw:h-8 astw:rounded-md astw:gap-1.5 astw:px-3 astw:has-[>svg]:px-2.5",lg:"astw:h-10 astw:rounded-md astw:px-6 astw:has-[>svg]:px-4",icon:"astw:size-9"}},defaultVariants:{variant:"default",size:"default"}});function y({className:t,variant:a,size:e,asChild:r=!1,...o}){return na(r?oa:"button",{"data-slot":"button",className:c(ia({variant:a,size:e,className:t})),...o})}import{Fragment as pt,jsx as f,jsxs as I}from"react/jsx-runtime";var ct=()=>I(pt,{children:[f("p",{className:"astw:font-semibold astw:leading-none astw:tracking-tight",children:"Welcome to AppShell"}),f("p",{className:"pt-4",children:"Add your GraphQL resources from configuration at first!"})]}),G=()=>I(pt,{children:[f(lt,{}),f(la,{})]}),wt=()=>{let{configurations:t}=P();return I("div",{className:"astw:mx-auto astw:flex-col astw:flex astw:md:flex-row astw:max-w-5xl astw:gap-[10px] astw:w-full",children:[f("div",{children:I("nav",{className:"astw:bg-card astw:md:w-xs astw:rounded-md astw:border astw:p-3 astw:shadow-xs",children:[f("h2",{className:"astw:text-sm astw:leading-[36px] astw:mb-2 astw:font-bold ",children:"Settings"}),f("ul",{className:"astw:flex astw:flex-col astw:gap-1",children:t.settingsResources.map(a=>f("li",{children:f(da,{to:`./${a.path}`,children:({isActive:e})=>I(y,{variant:e?"secondary":"ghost",className:"astw:w-full astw:justify-start",children:[a.meta.icon,a.meta.title]})})},a.path))})]})}),f("section",{className:"astw:bg-card astw:flex-1 astw:rounded-md astw:border astw:shadow-xs",children:f(lt,{})})]})};import{capitalCase as ut}from"change-case";import{redirect as ca}from"react-router";function wa(t){return{redirectTo:t}}function $(t){return typeof t=="object"&&t!==null&&"redirectTo"in t}function pa(t){let{path:a,meta:e,component:r,resources:o,errorBoundary:s}=t,l=e?.title??ut(a),i=$(r)?{component:()=>null,loader:()=>ca(r.redirectTo)}:{component:()=>r({title:l,resources:o})};return{path:a,type:"component",_type:"module",...i,meta:{title:l,...e?.breadcrumbTitle!==void 0?{breadcrumbTitle:e.breadcrumbTitle}:{},...e,menuItemClickable:!$(r),icon:t.meta?.icon},resources:o,errorBoundary:s}}function ua(t){let{path:a,component:e,subResources:r,meta:o,errorBoundary:s}=t,l=o?.title??ut(a);return{_type:"resource",type:"component",path:a,meta:{title:l,icon:o?.icon,...o?.breadcrumbTitle!==void 0?{breadcrumbTitle:o.breadcrumbTitle}:{}},component:()=>e({title:l,resources:r}),subResources:r,errorBoundary:s}}import{Fragment as xa,jsx as F}from"react/jsx-runtime";var H=t=>()=>F(xa,{children:t}),va=(t,a)=>t.reduce((e,r)=>{let o=r.errorBoundary||a,s={index:!0,Component:r.component,loader:r.loader};return[...e,{path:r.path,...o&&{ErrorBoundary:H(o)},...r.resources&&r.resources.length>0?{children:[s,...r.resources.map(l=>mt(l,o))]}:{children:[s]}}]},[]),mt=(t,a)=>{let e=t.errorBoundary||a,r={index:!0,Component:t.component};return{path:t.path,...t.errorBoundary&&{ErrorBoundary:H(t.errorBoundary)},...t.subResources&&t.subResources.length>0?{children:[r,...t.subResources.map(o=>mt(o,e))]}:{children:[r]}}},gt=t=>{let{configurations:a}=P(),{rootComponent:e}=t,r=$(e)?{index:!0,loader:()=>ha(e.redirectTo)}:{index:!0,Component:e??ct},o=a.settingsResources.length>0?[{path:"settings",index:!0,Component:()=>F(ba,{to:a.settingsResources[0].path,relative:"path",replace:!0})},{path:"settings",Component:wt,children:a.settingsResources.map(d=>({path:d.path,Component:d.component,...d.errorBoundary&&{ErrorBoundary:H(d.errorBoundary)}}))}]:[],s=a.errorBoundary,l=[r,{children:va(a.modules,s)},...o,{path:"*",loader:()=>{throw new Response("Not Found",{status:404})}}],i=ma([{element:t.children,children:s?[{element:F(fa,{}),ErrorBoundary:H(s),children:l}]:l}],{basename:a.basePath?"/"+a.basePath:void 0});return F(ga,{router:i})};import{createContext as ya,useContext as Ca,useEffect as ka,useMemo as Sa,useState as Pa}from"react";import{jsx as Ta}from"react/jsx-runtime";var Ra={resolvedTheme:"light",theme:"system",setTheme:()=>null},bt=ya(Ra);function ht({children:t,storageKey:a,defaultTheme:e="system",...r}){let[o,s]=Pa(()=>localStorage.getItem(a)||e),l=Sa(()=>o!=="system"?o:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[o]);ka(()=>{let d=window.document.documentElement;d.classList.remove("light","dark"),d.classList.add(l)},[l]);let i={resolvedTheme:l,theme:o,setTheme:d=>{localStorage.setItem(a,d),s(d)}};return Ta(bt.Provider,{...r,value:i,children:t})}var X=()=>{let t=Ca(bt);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};import{useRouteError as Na,isRouteErrorResponse as za}from"react-router";import{AlertCircle as ft}from"lucide-react";import{jsx as x,jsxs as V}from"react/jsx-runtime";var vt=()=>{let t=Na();if(za(t)&&t.status===404)return x("div",{className:"astw:p-6",children:V("div",{className:"astw:flex astw:items-start astw:gap-4",children:[x(ft,{className:"astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5"}),V("div",{children:[x("h1",{className:"astw:font-semibold astw:text-lg",children:"404 Not Found"}),x("p",{className:"astw:text-sm astw:text-muted-foreground astw:mt-1",children:"The page you requested could not be found."}),x(y,{variant:"outline",size:"sm",className:"astw:mt-4",onClick:()=>window.history.back(),children:"Go Back"})]})]})});let a=t instanceof Error?t.message:"An unexpected error occurred";return x("div",{className:"astw:p-6",children:V("div",{className:"astw:flex astw:items-start astw:gap-4",children:[x(ft,{className:"astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5"}),V("div",{children:[x("h1",{className:"astw:font-semibold astw:text-lg",children:"Something went wrong"}),x("p",{className:"astw:text-sm astw:text-muted-foreground astw:mt-1",children:a}),x(y,{variant:"outline",size:"sm",className:"astw:mt-4",onClick:()=>window.location.reload(),children:"Try Again"})]})]})})};import{jsx as _}from"react/jsx-runtime";var _a=t=>{let[a,e]=Ia(!1);Ma(function(){e(!0)},[]);let r=Ea(()=>t.modules.map(s=>{let l=s.resources.map(i=>({title:i.meta.title,url:`${s.path}/${i.path}`}));return{title:s.meta.title,url:s.meta.menuItemClickable?s.path:void 0,clickable:s.component,icon:s.meta.icon||_(Ba,{}),isActive:!0,items:l}}),[t.modules]);return a?_(q.Provider,{value:{title:t.title,icon:t.icon,configurations:{modules:t.modules,settingsResources:t.settingsResources??[],errorBoundary:t.errorBoundary??_(vt,{}),basePath:t.basePath},navItems:r},children:_(ht,{defaultTheme:"system",storageKey:"appshell-ui-theme",children:_(gt,{rootComponent:t.rootComponent,children:t.children})})}):null};import*as z from"@radix-ui/react-collapsible";import{jsx as J}from"react/jsx-runtime";function xt({...t}){return J(z.Root,{"data-slot":"collapsible",...t})}function Y({...t}){return J(z.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function yt({...t}){return J(z.CollapsibleContent,{"data-slot":"collapsible-content",...t})}import{useLocation as Gt,useMatch as te}from"react-router";import*as b from"react";import{Slot as at}from"@radix-ui/react-slot";import{cva as Ua}from"class-variance-authority";import{PanelLeftIcon as $a}from"lucide-react";import*as K from"react";var Q=768;function Ct(){let[t,a]=K.useState(void 0);return K.useEffect(()=>{let e=window.matchMedia(`(max-width: ${Q-1}px)`),r=()=>{a(window.innerWidth<Q)};return e.addEventListener("change",r),a(window.innerWidth<Q),()=>e.removeEventListener("change",r)},[]),!!t}import{jsx as gr}from"react/jsx-runtime";import*as Aa from"@radix-ui/react-separator";import{jsx as vr}from"react/jsx-runtime";import*as m from"@radix-ui/react-dialog";import{XIcon as La}from"lucide-react";import{jsx as C,jsxs as Z}from"react/jsx-runtime";function kt({...t}){return C(m.Root,{"data-slot":"sheet",...t})}function Oa({...t}){return C(m.Portal,{"data-slot":"sheet-portal",...t})}function Da({className:t,...a}){return C(m.Overlay,{"data-slot":"sheet-overlay",className:c("astw:data-[state=open]:animate-in astw:data-[state=closed]:animate-out astw:data-[state=closed]:fade-out-0 astw:data-[state=open]:fade-in-0 astw:fixed astw:inset-0 astw:z-50 astw:bg-black/50",t),...a})}function St({className:t,children:a,side:e="right",...r}){return Z(Oa,{children:[C(Da,{}),Z(m.Content,{"data-slot":"sheet-content",className:c("astw:bg-background astw:data-[state=open]:animate-in astw:data-[state=closed]:animate-out astw:fixed astw:z-50 astw:flex astw:flex-col astw:gap-4 astw:shadow-lg astw:transition astw:ease-in-out astw:data-[state=closed]:duration-300 astw:data-[state=open]:duration-500",e==="right"&&"astw:data-[state=closed]:slide-out-to-right astw:data-[state=open]:slide-in-from-right astw:inset-y-0 astw:right-0 astw:h-full astw:w-3/4 astw:border-l astw:sm:max-w-sm",e==="left"&&"astw:data-[state=closed]:slide-out-to-left astw:data-[state=open]:slide-in-from-left astw:inset-y-0 astw:left-0 astw:h-full astw:w-3/4 astw:border-r astw:sm:max-w-sm",e==="top"&&"astw:data-[state=closed]:slide-out-to-top astw:data-[state=open]:slide-in-from-top astw:inset-x-0 astw:top-0 astw:h-auto astw:border-b",e==="bottom"&&"astw:data-[state=closed]:slide-out-to-bottom astw:data-[state=open]:slide-in-from-bottom astw:inset-x-0 astw:bottom-0 astw:h-auto astw:border-t",t),...r,children:[a,Z(m.Close,{className:"astw:ring-offset-bg astw:focus:ring-ring astw:data-[state=open]:bg-secondary astw:absolute astw:top-4 astw:right-4 astw:rounded-xs astw:opacity-70 astw:transition-opacity astw:hover:opacity-100 astw:focus:ring-2 astw:focus:ring-offset-2 astw:focus:outline-hidden astw:disabled:pointer-events-none",children:[C(La,{className:"astw:size-4"}),C("span",{className:"astw:sr-only",children:"Close"})]})]})]})}function Pt({className:t,...a}){return C("div",{"data-slot":"sheet-header",className:c("astw:flex astw:flex-col astw:gap-1.5 astw:p-4",t),...a})}function Rt({className:t,...a}){return C(m.Title,{"data-slot":"sheet-title",className:c("astw:text-foreground astw:font-semibold",t),...a})}function Tt({className:t,...a}){return C(m.Description,{"data-slot":"sheet-description",className:c("astw:text-muted-foreground astw:text-sm",t),...a})}import{jsx as Tr}from"react/jsx-runtime";import*as h from"@radix-ui/react-tooltip";import{jsx as B,jsxs as ja}from"react/jsx-runtime";function tt({delayDuration:t=0,...a}){return B(h.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function Nt({...t}){return B(tt,{children:B(h.Root,{"data-slot":"tooltip",...t})})}function zt({...t}){return B(h.Trigger,{"data-slot":"tooltip-trigger",...t})}function Bt({className:t,sideOffset:a=0,children:e,...r}){return B(h.Portal,{children:ja(h.Content,{"data-slot":"tooltip-content",sideOffset:a,className:c("astw:bg-primary astw:text-primary-foreground astw:animate-in astw:fade-in-0 astw:zoom-in-95 astw:data-[state=closed]:animate-out astw:data-[state=closed]:fade-out-0 astw:data-[state=closed]:zoom-out-95 astw:data-[side=bottom]:slide-in-from-top-2 astw:data-[side=left]:slide-in-from-right-2 astw:data-[side=right]:slide-in-from-left-2 astw:data-[side=top]:slide-in-from-bottom-2 astw:z-50 astw:w-fit astw:origin-(--radix-tooltip-content-transform-origin) astw:rounded-md astw:px-3 astw:py-1.5 astw:text-xs astw:text-balance",t),...r,children:[e,B(h.Arrow,{className:"astw:bg-primary astw:fill-primary astw:z-50 astw:size-2.5 astw:translate-y-[calc(-50%_-_2px)] astw:rotate-45 astw:rounded-[2px]"})]})})}import{jsx as w,jsxs as A}from"react/jsx-runtime";var Fa="sidebar_state",Ha=60*60*24*7,Va="16rem",Ka="18rem",Wa="3rem",qa="b",Mt=b.createContext(null);function L(){let t=b.useContext(Mt);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function Et({defaultOpen:t=!0,open:a,onOpenChange:e,className:r,style:o,children:s,...l}){let i=Ct(),[d,p]=b.useState(!1),[u,R]=b.useState(t),k=a??u,T=b.useCallback(v=>{let S=typeof v=="function"?v(k):v;e?e(S):R(S),document.cookie=`${Fa}=${S}; path=/; max-age=${Ha}`},[e,k]),N=b.useCallback(()=>i?p(v=>!v):T(v=>!v),[i,T,p]);b.useEffect(()=>{let v=S=>{S.key===qa&&(S.metaKey||S.ctrlKey)&&(S.preventDefault(),N())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[N]);let W=k?"expanded":"collapsed",U=b.useMemo(()=>({state:W,open:k,setOpen:T,isMobile:i,openMobile:d,setOpenMobile:p,toggleSidebar:N}),[W,k,T,i,d,p,N]);return w(Mt.Provider,{value:U,children:w(tt,{delayDuration:0,children:w("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":Va,"--sidebar-width-icon":Wa,...o},className:c("astw:group/sidebar-wrapper astw:has-data-[variant=inset]:bg-sidebar astw:flex astw:min-h-svh astw:w-full",r),...l,children:s})})})}function It({side:t="left",variant:a="sidebar",collapsible:e="offcanvas",className:r,children:o,...s}){let{isMobile:l,state:i,openMobile:d,setOpenMobile:p}=L();return e==="none"?w("div",{"data-slot":"sidebar",className:c("astw:bg-sidebar astw:text-sidebar-foreground astw:flex astw:h-full astw:w-(--sidebar-width) astw:flex-col",r),...s,children:o}):l?w(kt,{open:d,onOpenChange:p,...s,children:A(St,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"astw:bg-sidebar astw:text-sidebar-foreground astw:w-(--sidebar-width) astw:p-0 astw:[&>button]:hidden",style:{"--sidebar-width":Ka},side:t,children:[A(Pt,{className:"astw:sr-only",children:[w(Rt,{children:"Sidebar"}),w(Tt,{children:"Displays the mobile sidebar."})]}),w("div",{className:"flex h-full w-full flex-col",children:o})]})}):A("div",{className:"astw:group astw:peer astw:text-sidebar-foreground astw:hidden astw:md:block","data-state":i,"data-collapsible":i==="collapsed"?e:"","data-variant":a,"data-side":t,"data-slot":"sidebar",children:[w("div",{"data-slot":"sidebar-gap",className:c("astw:relative astw:w-(--sidebar-width) astw:bg-transparent astw:transition-[width] astw:duration-200 astw:ease-linear","astw:group-data-[collapsible=offcanvas]:w-0","astw:group-data-[side=right]:rotate-180",a==="floating"||a==="inset"?"astw:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"astw:group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),w("div",{"data-slot":"sidebar-container",className:c("astw:fixed astw:inset-y-0 astw:z-10 astw:hidden astw:h-svh astw:w-(--sidebar-width) astw:transition-[left,right,width] astw:duration-200 astw:ease-linear astw:md:flex",t==="left"?"astw:left-0 astw:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"astw:right-0 astw:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",a==="floating"||a==="inset"?"astw:p-2 astw:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"astw:group-data-[collapsible=icon]:w-(--sidebar-width-icon) astw:group-data-[side=left]:border-r astw:group-data-[side=right]:border-l",a==="inset"&&"astw:border-x astw:border-x-border",r),...s,children:w("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"astw:bg-sidebar astw:group-data-[variant=floating]:border-sidebar-border astw:flex astw:h-full astw:w-full astw:flex-col astw:group-data-[variant=floating]:rounded-lg astw:group-data-[variant=floating]:border astw:group-data-[variant=floating]:shadow-sm",children:o})})]})}function et({className:t,onClick:a,...e}){let{toggleSidebar:r}=L();return A(y,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:c("astw:text-muted-foreground",t),onClick:o=>{a?.(o),r()},...e,children:[w($a,{className:"astw:size-4.5"}),w("span",{className:"astw:sr-only",children:"Toggle Sidebar"})]})}function _t({className:t,...a}){return w("main",{"data-slot":"sidebar-inset",className:c("astw:bg-background astw:relative astw:flex astw:w-full astw:flex-1 astw:flex-col","astw:px-4 astw:md:peer-data-[variant=inset]:px-8 astw:md:peer-data-[variant=inset]:py-2",t),...a})}function At({className:t,...a}){return w("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:c("astw:flex astw:flex-row astw:items-center astw:gap-0.5 astw:p-2",t),...a})}function Lt({className:t,...a}){return w("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:c("astw:flex astw:min-h-0 astw:flex-1 astw:flex-col astw:gap-2 astw:overflow-auto astw:group-data-[collapsible=icon]:overflow-hidden",t),...a})}function Ot({className:t,...a}){return w("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:c("astw:relative astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:p-2",t),...a})}function Dt({className:t,...a}){return w("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:c("astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:gap-1",t),...a})}function jt({className:t,...a}){return w("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:c("astw:group/menu-item astw:relative",t),...a})}var Ga=Ua("astw:peer/menu-button astw:flex astw:w-full astw:items-center astw:gap-2 astw:overflow-hidden astw:rounded-md astw:p-2 astw:text-left astw:text-sm astw:outline-hidden astw:ring-sidebar-ring astw:transition-[width,height,padding] astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:focus-visible:ring-2 astw:active:bg-sidebar-accent astw:active:text-sidebar-accent-foreground astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:group-has-data-[sidebar=menu-action]/menu-item:pr-8 astw:aria-disabled:pointer-events-none astw:aria-disabled:opacity-50 astw:data-[active=true]:bg-sidebar-accent astw:data-[active=true]:font-medium astw:data-[active=true]:text-sidebar-accent-foreground astw:data-[state=open]:hover:bg-sidebar-accent astw:data-[state=open]:hover:text-sidebar-accent-foreground astw:group-data-[collapsible=icon]:size-8! astw:group-data-[collapsible=icon]:p-2! astw:[&>span:last-child]:truncate astw:[&>svg]:size-4 astw:[&>svg]:shrink-0",{variants:{variant:{default:"astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground",outline:"astw:bg-background astw:shadow-[0_0_0_1px_hsl(var(--sidebar-border))] astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"astw:h-8 astw:text-sm",sm:"astw:h-7 astw:rounded-md astw:gap-1.5 astw:px-3 astw:has-[>svg]:px-2.5",lg:"astw:h-12 astw:text-sm astw:group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function rt({asChild:t=!1,isActive:a=!1,variant:e="default",size:r="default",tooltip:o,className:s,...l}){let i=t?at:"button",{isMobile:d,state:p}=L(),u=w(i,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":r,"data-active":a,className:c(Ga({variant:e,size:r}),s),...l});return o?(typeof o=="string"&&(o={children:o}),A(Nt,{children:[w(zt,{asChild:!0,children:u}),w(Bt,{side:"right",align:"center",hidden:p!=="collapsed"||d,...o})]})):u}function ot({className:t,asChild:a=!1,showOnHover:e=!1,...r}){return w(a?at:"button",{"data-slot":"sidebar-menu-action","data-sidebar":"menu-action",className:c("astw:text-sidebar-foreground astw:ring-sidebar-ring astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:peer-hover/menu-button:text-sidebar-accent-foreground astw:absolute astw:top-1.5 astw:right-1 astw:flex astw:aspect-square astw:w-5 astw:items-center astw:justify-center astw:rounded-md astw:p-0 astw:outline-hidden astw:transition-transform astw:focus-visible:ring-2 astw:[&>svg]:size-4 astw:[&>svg]:shrink-0","astw:after:absolute astw:after:-inset-2 astw:md:after:hidden","astw:peer-data-[size=sm]/menu-button:top-1","astw:peer-data-[size=default]/menu-button:top-1.5","astw:peer-data-[size=lg]/menu-button:top-2.5","astw:group-data-[collapsible=icon]:hidden",e&&"astw:peer-data-[active=true]/menu-button:text-sidebar-accent-foreground astw:group-focus-within/menu-item:opacity-100 astw:group-hover/menu-item:opacity-100 astw:data-[state=open]:opacity-100 astw:md:opacity-0",t),...r})}function Ut({className:t,...a}){return w("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:c("astw:border-sidebar-border astw:mx-3.5 astw:flex astw:min-w-0 astw:translate-x-px astw:flex-col astw:gap-1 astw:border-l astw:px-2.5 astw:py-0.5","astw:group-data-[collapsible=icon]:hidden",t),...a})}function $t({className:t,...a}){return w("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:c("astw:group/menu-sub-item astw:relative",t),...a})}function Ft({asChild:t=!1,size:a="md",isActive:e=!1,className:r,...o}){return w(t?at:"a",{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":a,"data-active":e,className:c("astw:text-sidebar-foreground astw:ring-sidebar-ring astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:active:bg-sidebar-accent astw:active:text-sidebar-accent-foreground astw:[&>svg]:text-sidebar-accent-foreground astw:flex astw:h-7 astw:min-w-0 astw:-translate-x-px astw:items-center astw:gap-2 astw:overflow-hidden astw:rounded-md astw:px-2 astw:outline-hidden astw:focus-visible:ring-2 astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:aria-disabled:pointer-events-none astw:aria-disabled:opacity-50 astw:[&>span:last-child]:truncate astw:[&>svg]:size-4 astw:[&>svg]:shrink-0","astw:data-[active=true]:bg-sidebar-accent astw:data-[active=true]:text-sidebar-accent-foreground",a==="sm"&&"astw:text-xs",a==="md"&&"astw:text-sm","astw:group-data-[collapsible=icon]:hidden",r),...o})}import{ChevronRight as Wt,SunIcon as ae}from"lucide-react";import{Slot as Ja}from"@radix-ui/react-slot";import{ChevronRight as Qa,MoreHorizontal as to}from"lucide-react";import{Link as Xa,useHref as Ya}from"react-router";import{jsx as Ht}from"react/jsx-runtime";function O({to:t,children:a,...e}){try{return Ya(t),Ht(Xa,{to:t,...e,children:a})}catch{return Ht("a",{href:t,...e,children:a})}}import{jsx as M,jsxs as oo}from"react/jsx-runtime";function st({...t}){return M("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...t})}function it({className:t,...a}){return M("ol",{"data-slot":"breadcrumb-list",className:c("astw:text-muted-foreground astw:flex astw:flex-wrap astw:items-center astw:gap-1.5 astw:text-sm astw:break-words astw:sm:gap-2.5",t),...a})}function nt({className:t,...a}){return M("li",{"data-slot":"breadcrumb-item",className:c("astw:inline-flex astw:items-center astw:gap-1.5",t),...a})}function dt({asChild:t,className:a,children:e,...r}){return M(t?Ja:O,{"data-slot":"breadcrumb-link",className:c("astw:hover:text-foreground astw:transition-colors",a),...r,children:e})}function Vt({children:t,className:a,...e}){return M("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:c("astw:[&>svg]:size-3.5",a),...e,children:t??M(Qa,{})})}var Za=t=>t.reduce((a,e)=>{a[e.path]={title:e.meta.title,breadcrumbTitle:e.meta.breadcrumbTitle};let r=(o,s)=>{!o||o.length===0||o.forEach(l=>{let i=`${s}/${l.path}`;a[i]={title:l.meta.title,breadcrumbTitle:l.meta.breadcrumbTitle},l.subResources&&l.subResources.length>0&&r(l.subResources,i)})};return e.resources&&e.resources.length>0&&r(e.resources,e.path),a},{});function Kt(t,a,e){let r=t.split("/").filter(i=>i!=="").slice(1),o=a?(()=>{let[i,...d]=r;return d})():r,s=Za(e),l=o.map((i,d)=>{let p=o.slice(0,d+1).join("/"),u=s[p];if(!u){let k=Object.entries(s).find(([T])=>{let N=T.split("/").map(U=>U.startsWith(":")?"[^/]+":U).join("/");return new RegExp(`^${N}$`).test(p)})?.[1];k&&(u=k)}let R;return u?typeof u.breadcrumbTitle=="function"?R=u.breadcrumbTitle(i):typeof u.breadcrumbTitle=="string"?R=u.breadcrumbTitle:R=u.title:R=decodeURIComponent(i),{segment:i,path:p,title:R}});return{basePath:a||null,segments:l}}import{Fragment as qt,jsx as n,jsxs as g}from"react/jsx-runtime";var ee=()=>{let{open:t}=L();return n("div",{className:t?"astw:md:hidden":void 0,children:n(et,{className:"astw:-ml-2.5"})})},re=t=>{let a=t.children?t.children({Outlet:G}):null,e=X(),r=()=>{e.setTheme(e.theme==="dark"?"light":"dark")};return n(Et,{className:"astw:flex astw:flex-col",children:g("div",{className:"astw:flex astw:flex-1",children:[t.sidebar??n(Xt,{}),g(_t,{className:"astw:w-[calc(100%-var(--sidebar-width))]",children:[n("header",{className:"astw:flex astw:h-14 astw:shrink-0 astw:items-center astw:gap-2 astw:transition-[width,height] astw:ease-linear astw:group-has-data-[collapsible=icon]/sidebar-wrapper:h-12",children:g("div",{className:"astw:flex astw:w-full astw:items-center astw:justify-between",children:[g("div",{className:"astw:flex astw:items-center astw:gap-2",children:[n(ee,{}),n(se,{})]}),n("div",{className:"astw:flex astw:items-center astw:gap-2",children:n(y,{variant:"outline",size:"icon",onClick:r,children:n(ae,{})})})]})}),n("div",{className:"astw:flex astw:flex-col astw:gap-4",children:a??n(G,{})})]})]})})},Xt=t=>{let{title:a,icon:e,navItems:r}=P(),{pathname:o}=Gt(),s=g(At,{children:[e,n("h1",{className:"astw:text-sm astw:mb-2 astw:mt-2 astw:px-2",children:a})]});return g(It,{variant:"inset",children:[g("div",{className:"astw:flex astw:justify-between astw:items-center",children:[t.header??s,n("div",{className:"astw:hidden astw:md:block",children:n(et,{className:"astw:-ml-1"})})]}),n(Lt,{children:n(Ot,{children:n(Dt,{children:r.map(i=>n(xt,{asChild:!0,defaultOpen:i.isActive,children:g(jt,{children:[i.url?g(qt,{children:[n(rt,{asChild:!0,tooltip:i.title,children:g(O,{to:i.url,className:i.url===o?"astw:bg-sidebar-accent astw:font-medium":void 0,children:[i.icon,n("span",{children:i.title})]})}),!!i.items?.length&&n(Y,{asChild:!0,children:g(ot,{className:"astw:data-[state=open]:rotate-90",children:[n(Wt,{}),n("span",{className:"astw:sr-only",children:"Toggle"})]})})]}):n(qt,{children:g(Y,{className:"astw:flex astw:w-[100%] astw:[&[data-state=open]_.astw-rotate-target]:rotate-90",children:[n(rt,{asChild:!0,tooltip:i.title,children:g("span",{className:"astw:flex astw:w-[100%]",children:[i.icon,n("span",{children:i.title})]})}),!!i.items?.length&&n(ot,{className:"astw-rotate-target",asChild:!0,children:g("span",{children:[n(Wt,{}),n("span",{className:"astw:sr-only",children:"Toggle"})]})})]})}),!!i.items?.length&&n(yt,{children:n(Ut,{children:i.items?.map(d=>n($t,{children:n(Ft,{asChild:!0,children:n(O,{to:d.url,className:d.url===o?"astw:bg-sidebar-accent astw:font-medium":void 0,children:n("span",{children:d.title})})})},d.title))})})]})},i.title))})})}),t.footer??null]})},oe=()=>{let{configurations:t}=P(),a=Gt();return Kt(a.pathname,t.basePath,t.modules)},se=()=>{let{segments:t}=oe(),a=te("/:prefix/settings/:suffix");return a?n(st,{children:n(it,{children:n("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:n(nt,{children:n(dt,{to:`/${a.params.prefix}/settings`,children:"Settings"})})})})}):n(st,{children:n(it,{children:t.map((e,r)=>g("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:[n(nt,{children:n(dt,{to:e.path,children:e.title})}),r<t.length-1&&n(Vt,{})]},r))})})};import{useLocation as Ao,useNavigate as Lo,useParams as Oo,useSearchParams as Do,useRouteError as jo,Link as Uo}from"react-router";import{createContext as ne,useCallback as Qt,useContext as de,useEffect as le,useMemo as ce,useState as we}from"react";import*as E from"oauth4webapi";var D="oauth_pkce_verifier",j="oauth_state",Yt=({apiEndpoint:t,clientId:a,state:e,codeChallenge:r,redirectUri:o})=>{let s=new URL(`${t}/oauth2/authorize`);return s.searchParams.set("response_type","code"),s.searchParams.set("client_id",a),s.searchParams.set("redirect_uri",o??window.location.origin),s.searchParams.set("scope","openid profile email"),s.searchParams.set("state",e),s.searchParams.set("code_challenge",r),s.searchParams.set("code_challenge_method","S256"),s.toString()},ie=async({code:t,returnedState:a,apiEndpoint:e,clientId:r,redirectUri:o})=>{let s=sessionStorage.getItem(D),l=sessionStorage.getItem(j);if(!t||!a||!s||!l){let d=[];throw t||d.push("code"),a||d.push("returnedState"),s||d.push("code_verifier"),l||d.push("expectedState"),new Error(`Missing params: ${d.join(", ")}`)}if(a!==l)throw new Error("State mismatch: possible CSRF attack");let i=new URLSearchParams({grant_type:"authorization_code",client_id:r,code:t,redirect_uri:o??window.location.origin,code_verifier:s});try{let d=await fetch(`${e}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Tailor-Nonce":crypto.randomUUID()},credentials:"include",body:i.toString()}),{access_token:p}=await d.json();return p}catch(d){throw new Error(`Token exchange failed: ${d instanceof Error?d.message:String(d)}`)}},Jt=async()=>{let t=E.generateRandomCodeVerifier(),a=await E.calculatePKCECodeChallenge(t),e=E.generateRandomState();return sessionStorage.setItem(D,t),sessionStorage.setItem(j,e),{codeChallenge:a,state:e}},yo=async({currentUrl:t,apiEndpoint:a,clientId:e,redirectUri:r})=>{try{let o=t.searchParams.get("code"),s=t.searchParams.get("state");await ie({apiEndpoint:a,clientId:e,code:o,returnedState:s,redirectUri:r})}catch(o){console.error(o)}finally{sessionStorage.removeItem(D),sessionStorage.removeItem(j),t.searchParams.delete("code"),t.searchParams.delete("state"),t.searchParams.delete("error"),t.searchParams.delete("error_description"),window.history.replaceState({},document.title,t.toString())}};import{jsx as me}from"react/jsx-runtime";var Zt=ne(void 0),pe=()=>{let t=de(Zt);if(t===void 0)throw new Error("useBuiltinIdpAuth must be used within an BuiltinIdPAuthContextProvider");return t},ue=({apiEndpoint:t,clientId:a,redirectUri:e,children:r})=>{let[o,s]=we(!1),l=Qt(async()=>{let{codeChallenge:d,state:p}=await Jt(),u=Yt({apiEndpoint:t,clientId:a,codeChallenge:d,state:p,redirectUri:e});window.location.href=u},[t,a,e]);le(()=>{(async()=>{(await(await fetch(`${t}/query`,{method:"POST",headers:{"Content-Type":"application/json","X-Tailor-Nonce":crypto.randomUUID()},credentials:"include",body:JSON.stringify({query:"query Myself(){ me { id }}"})})).json()).data.me?s(!0):l()})()},[t,l]);let i=Qt(async()=>{sessionStorage.removeItem(D),sessionStorage.removeItem(j);try{await fetch(`${t}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Tailor-Nonce":crypto.randomUUID()},credentials:"include",body:""}),window.location.href="/"}catch(d){console.error(d)}},[t]);return me(Zt.Provider,{value:ce(()=>({login:l,logout:i}),[l,i]),children:o?r:null})};export{_a as AppShell,ue as BuiltinIdPAuthProvider,Xt as DefaultSidebar,Uo as Link,j as OAUTH_STATE_KEY,D as PKCE_VERIFIER_KEY,re as SidebarLayout,Yt as buildAuthorizationUrl,pa as defineModule,ua as defineResource,ie as exchangeCodeForToken,yo as handleOAuthCallback,Jt as prepareLogin,wa as redirectToResource,P as useAppShell,pe as useBuiltinIdpAuth,Ao as useLocation,Lo as useNavigate,Oo as useParams,jo as useRouteError,Do as useSearchParams,X as useTheme};
|
|
1
|
+
import{Table as Aa}from"lucide-react";import{useEffect as Oa,useMemo as La,useState as Da}from"react";import{createContext as wa,useContext as pa}from"react";import{useRouteError as la,isRouteErrorResponse as ca}from"react-router";import{Slot as sa}from"@radix-ui/react-slot";import{cva as ia}from"class-variance-authority";import{clsx as ra}from"clsx";import{twMerge as oa}from"tailwind-merge";function c(...t){return oa(ra(t))}import{jsx as da}from"react/jsx-runtime";var na=ia("astw:inline-flex astw:items-center astw:justify-center astw:gap-2 astw:whitespace-nowrap astw:rounded-md astw:text-sm astw:font-medium astw:transition-all astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:[&_svg]:pointer-events-none astw:[&_svg:not([class*='size-'])]:size-4 astw:shrink-0 astw:[&_svg]:shrink-0 astw:outline-none astw:focus-visible:border-ring astw:focus-visible:ring-ring/50 astw:focus-visible:ring-[3px] astw:aria-invalid:ring-destructive/20 astw:dark:aria-invalid:ring-destructive/40 astw:aria-invalid:border-destructive",{variants:{variant:{default:"astw:bg-primary astw:text-primary-foreground astw:shadow-xs astw:hover:bg-primary/90",destructive:"astw:bg-destructive astw:text-white astw:shadow-xs astw:hover:bg-destructive/90 astw:focus-visible:ring-destructive/20 astw:dark:focus-visible:ring-destructive/40 astw:dark:bg-destructive/60",outline:"astw:border astw:bg-background astw:shadow-xs astw:hover:bg-accent astw:hover:text-accent-foreground astw:dark:bg-input/30 astw:dark:border-input astw:dark:hover:bg-input/50",secondary:"astw:bg-secondary astw:text-secondary-foreground astw:shadow-xs astw:hover:bg-secondary/80",ghost:"astw:hover:bg-accent astw:hover:text-accent-foreground astw:dark:hover:bg-accent/50",link:"astw:text-primary astw:underline-offset-4 astw:hover:underline"},size:{default:"astw:h-9 astw:px-4 astw:py-2 astw:has-[>svg]:px-3",sm:"astw:h-8 astw:rounded-md astw:gap-1.5 astw:px-3 astw:has-[>svg]:px-2.5",lg:"astw:h-10 astw:rounded-md astw:px-6 astw:has-[>svg]:px-4",icon:"astw:size-9"}},defaultVariants:{variant:"default",size:"default"}});function y({className:t,variant:a,size:e,asChild:r=!1,...o}){return da(r?sa:"button",{"data-slot":"button",className:c(na({variant:a,size:e,className:t})),...o})}import{AlertCircle as lt}from"lucide-react";import{jsx as x,jsxs as H}from"react/jsx-runtime";var T=()=>{let t=la(),a={role:"alert","aria-label":"default-error-boundary"};if(ca(t)&&t.status===404)return x("div",{...a,className:"astw:p-6",children:H("div",{className:"astw:flex astw:items-start astw:gap-4",children:[x(lt,{className:"astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5"}),H("div",{children:[x("h1",{className:"astw:font-semibold astw:text-lg",children:"404 Not Found"}),x("p",{className:"astw:text-sm astw:text-muted-foreground astw:mt-1",children:"The page you requested could not be found."}),x(y,{variant:"outline",size:"sm",className:"astw:mt-4",onClick:()=>window.history.back(),children:"Go Back"})]})]})});let e=t instanceof Error?t.message:"An unexpected error occurred";return x("div",{...a,className:"astw:p-6",children:H("div",{className:"astw:flex astw:items-start astw:gap-4",children:[x(lt,{className:"astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5"}),H("div",{children:[x("h1",{className:"astw:font-semibold astw:text-lg",children:"Something went wrong"}),x("p",{className:"astw:text-sm astw:text-muted-foreground astw:mt-1",children:e}),x(y,{variant:"outline",size:"sm",className:"astw:mt-4",onClick:()=>window.location.reload(),children:"Try Again"})]})]})})};import{jsx as ua}from"react/jsx-runtime";var q=wa({navItems:[],configurations:{modules:[],settingsResources:[],errorBoundary:ua(T,{})}}),P=()=>pa(q);import{Outlet as Ra,createMemoryRouter as Pa,createBrowserRouter as Sa,RouterProvider as Ta}from"react-router";import{Navigate as xa,redirect as ya}from"react-router";import{NavLink as ma,Outlet as ct}from"react-router";import{Toaster as ga}from"sonner";import{Fragment as ut,jsx as f,jsxs as _}from"react/jsx-runtime";var wt=()=>_(ut,{children:[f("p",{className:"astw:font-semibold astw:leading-none astw:tracking-tight",children:"Welcome to AppShell"}),f("p",{className:"pt-4",children:"Add your GraphQL resources from configuration at first!"})]}),G=()=>_(ut,{children:[f(ct,{}),f(ga,{})]}),pt=()=>{let{configurations:t}=P();return _("div",{className:"astw:mx-auto astw:flex-col astw:flex astw:md:flex-row astw:max-w-5xl astw:gap-[10px] astw:w-full",children:[f("div",{children:_("nav",{className:"astw:bg-card astw:md:w-xs astw:rounded-md astw:border astw:p-3 astw:shadow-xs",children:[f("h2",{className:"astw:text-sm astw:leading-[36px] astw:mb-2 astw:font-bold ",children:"Settings"}),f("ul",{className:"astw:flex astw:flex-col astw:gap-1",children:t.settingsResources.map(a=>f("li",{children:f(ma,{to:`./${a.path}`,children:({isActive:e})=>_(y,{variant:e?"secondary":"ghost",className:"astw:w-full astw:justify-start",children:[a.meta.icon,a.meta.title]})})},a.path))})]})}),f("section",{className:"astw:bg-card astw:flex-1 astw:rounded-md astw:border astw:shadow-xs",children:f(ct,{})})]})};import{capitalCase as mt}from"change-case";import{redirect as ba}from"react-router";import{jsx as gt}from"react/jsx-runtime";function ha(t){return{redirectTo:t}}function V(t){return typeof t=="object"&&t!==null&&"redirectTo"in t}function fa(t){let{path:a,meta:e,component:r,resources:o,errorBoundary:s}=t,d=e?.title??mt(a),i=V(r)?{component:()=>null,loader:()=>ba(r.redirectTo)}:{component:()=>r({title:d,resources:o})};return{path:a,type:"component",_type:"module",...i,meta:{title:d,...e?.breadcrumbTitle!==void 0?{breadcrumbTitle:e.breadcrumbTitle}:{},...e,menuItemClickable:!V(r),icon:t.meta?.icon},resources:o,errorBoundary:s||gt(T,{})}}function va(t){let{path:a,component:e,subResources:r,meta:o,errorBoundary:s}=t,d=o?.title??mt(a);return{_type:"resource",type:"component",path:a,meta:{title:d,icon:o?.icon,...o?.breadcrumbTitle!==void 0?{breadcrumbTitle:o.breadcrumbTitle}:{}},component:()=>e({title:d,resources:r}),subResources:r,errorBoundary:s??gt(T,{})}}import{Fragment as ka,jsx as ft}from"react/jsx-runtime";var F=t=>()=>ft(ka,{children:t}),bt=(t,a,e)=>{let r=t.errorBoundary||e,o={index:!0,Component:t.component,...t.loader&&{loader:t.loader}};return{path:t.path,...t.errorBoundary&&{ErrorBoundary:F(t.errorBoundary)},...a&&a.length>0?{children:[o,...a.map(s=>bt(s,s.subResources,r))]}:{children:[o]}}},Ca=t=>t.map(a=>bt(a,a.resources,a.errorBoundary)),ht=({modules:t,settingsResources:a,rootComponent:e})=>{let r=V(e)?{index:!0,loader:()=>ya(e.redirectTo)}:{index:!0,Component:e??wt},o=a.length>0?[{path:"settings",index:!0,Component:()=>ft(xa,{to:a[0].path,relative:"path",replace:!0})},{path:"settings",Component:pt,children:a.map(s=>({path:s.path,Component:s.component,...s.errorBoundary&&{ErrorBoundary:F(s.errorBoundary)}}))}]:[];return[r,{children:Ca(t)},...o,{path:"*",loader:()=>{throw new Response("Not Found",{status:404})}}]};import{jsx as vt}from"react/jsx-runtime";var xt=t=>{let{configurations:a}=P(),{rootComponent:e,children:r}=t,o=ht({modules:a.modules,settingsResources:a.settingsResources,rootComponent:e}),s=a.errorBoundary,d=[{element:r,children:s?[{element:vt(Ra,{}),ErrorBoundary:F(s),children:o}]:o}],i=a.basePath?"/"+a.basePath:void 0,l=t.memory?Pa(d,{basename:i,...t.initialEntries?{initialEntries:t.initialEntries}:{}}):Sa(d,{basename:i});return vt(Ta,{router:l})};import{createContext as Na,useContext as za,useEffect as Ba,useMemo as Ma,useState as Ea}from"react";import{jsx as _a}from"react/jsx-runtime";var Ia={resolvedTheme:"light",theme:"system",setTheme:()=>null},yt=Na(Ia);function Ct({children:t,storageKey:a,defaultTheme:e="system",...r}){let[o,s]=Ea(()=>localStorage.getItem(a)||e),d=Ma(()=>o!=="system"?o:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[o]);Ba(()=>{let l=window.document.documentElement;l.classList.remove("light","dark"),l.classList.add(d)},[d]);let i={resolvedTheme:d,theme:o,setTheme:l=>{localStorage.setItem(a,l),s(l)}};return _a(yt.Provider,{...r,value:i,children:t})}var X=()=>{let t=za(yt);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};import{jsx as A}from"react/jsx-runtime";var Ua=t=>{let[a,e]=Da(!1);Oa(function(){e(!0)},[]);let r=La(()=>t.modules.map(s=>{let d=s.resources.map(i=>({title:i.meta.title,url:`${s.path}/${i.path}`}));return{title:s.meta.title,url:s.meta.menuItemClickable?s.path:void 0,clickable:s.component,icon:s.meta.icon||A(Aa,{}),isActive:!0,items:d}}),[t.modules]);return a?A(q.Provider,{value:{title:t.title,icon:t.icon,configurations:{modules:t.modules,settingsResources:t.settingsResources??[],errorBoundary:t.errorBoundary??A(T,{}),basePath:t.basePath},navItems:r},children:A(Ct,{defaultTheme:"system",storageKey:"appshell-ui-theme",children:A(xt,{rootComponent:t.rootComponent,children:t.children})})}):null};import*as B from"@radix-ui/react-collapsible";import{jsx as J}from"react/jsx-runtime";function kt({...t}){return J(B.Root,{"data-slot":"collapsible",...t})}function Y({...t}){return J(B.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Rt({...t}){return J(B.CollapsibleContent,{"data-slot":"collapsible-content",...t})}import{useLocation as Jt,useMatch as se}from"react-router";import*as b from"react";import{Slot as at}from"@radix-ui/react-slot";import{cva as Ka}from"class-variance-authority";import{PanelLeftIcon as Wa}from"lucide-react";import*as K from"react";var Q=768;function Pt(){let[t,a]=K.useState(void 0);return K.useEffect(()=>{let e=window.matchMedia(`(max-width: ${Q-1}px)`),r=()=>{a(window.innerWidth<Q)};return e.addEventListener("change",r),a(window.innerWidth<Q),()=>e.removeEventListener("change",r)},[]),!!t}import{jsx as zr}from"react/jsx-runtime";import*as ja from"@radix-ui/react-separator";import{jsx as Ir}from"react/jsx-runtime";import*as m from"@radix-ui/react-dialog";import{XIcon as $a}from"lucide-react";import{jsx as C,jsxs as Z}from"react/jsx-runtime";function St({...t}){return C(m.Root,{"data-slot":"sheet",...t})}function Ha({...t}){return C(m.Portal,{"data-slot":"sheet-portal",...t})}function Va({className:t,...a}){return C(m.Overlay,{"data-slot":"sheet-overlay",className:c("astw:data-[state=open]:animate-in astw:data-[state=closed]:animate-out astw:data-[state=closed]:fade-out-0 astw:data-[state=open]:fade-in-0 astw:fixed astw:inset-0 astw:z-50 astw:bg-black/50",t),...a})}function Tt({className:t,children:a,side:e="right",...r}){return Z(Ha,{children:[C(Va,{}),Z(m.Content,{"data-slot":"sheet-content",className:c("astw:bg-background astw:data-[state=open]:animate-in astw:data-[state=closed]:animate-out astw:fixed astw:z-50 astw:flex astw:flex-col astw:gap-4 astw:shadow-lg astw:transition astw:ease-in-out astw:data-[state=closed]:duration-300 astw:data-[state=open]:duration-500",e==="right"&&"astw:data-[state=closed]:slide-out-to-right astw:data-[state=open]:slide-in-from-right astw:inset-y-0 astw:right-0 astw:h-full astw:w-3/4 astw:border-l astw:sm:max-w-sm",e==="left"&&"astw:data-[state=closed]:slide-out-to-left astw:data-[state=open]:slide-in-from-left astw:inset-y-0 astw:left-0 astw:h-full astw:w-3/4 astw:border-r astw:sm:max-w-sm",e==="top"&&"astw:data-[state=closed]:slide-out-to-top astw:data-[state=open]:slide-in-from-top astw:inset-x-0 astw:top-0 astw:h-auto astw:border-b",e==="bottom"&&"astw:data-[state=closed]:slide-out-to-bottom astw:data-[state=open]:slide-in-from-bottom astw:inset-x-0 astw:bottom-0 astw:h-auto astw:border-t",t),...r,children:[a,Z(m.Close,{className:"astw:ring-offset-bg astw:focus:ring-ring astw:data-[state=open]:bg-secondary astw:absolute astw:top-4 astw:right-4 astw:rounded-xs astw:opacity-70 astw:transition-opacity astw:hover:opacity-100 astw:focus:ring-2 astw:focus:ring-offset-2 astw:focus:outline-hidden astw:disabled:pointer-events-none",children:[C($a,{className:"astw:size-4"}),C("span",{className:"astw:sr-only",children:"Close"})]})]})]})}function Nt({className:t,...a}){return C("div",{"data-slot":"sheet-header",className:c("astw:flex astw:flex-col astw:gap-1.5 astw:p-4",t),...a})}function zt({className:t,...a}){return C(m.Title,{"data-slot":"sheet-title",className:c("astw:text-foreground astw:font-semibold",t),...a})}function Bt({className:t,...a}){return C(m.Description,{"data-slot":"sheet-description",className:c("astw:text-muted-foreground astw:text-sm",t),...a})}import{jsx as $r}from"react/jsx-runtime";import*as h from"@radix-ui/react-tooltip";import{jsx as M,jsxs as Fa}from"react/jsx-runtime";function tt({delayDuration:t=0,...a}){return M(h.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function Mt({...t}){return M(tt,{children:M(h.Root,{"data-slot":"tooltip",...t})})}function Et({...t}){return M(h.Trigger,{"data-slot":"tooltip-trigger",...t})}function It({className:t,sideOffset:a=0,children:e,...r}){return M(h.Portal,{children:Fa(h.Content,{"data-slot":"tooltip-content",sideOffset:a,className:c("astw:bg-primary astw:text-primary-foreground astw:animate-in astw:fade-in-0 astw:zoom-in-95 astw:data-[state=closed]:animate-out astw:data-[state=closed]:fade-out-0 astw:data-[state=closed]:zoom-out-95 astw:data-[side=bottom]:slide-in-from-top-2 astw:data-[side=left]:slide-in-from-right-2 astw:data-[side=right]:slide-in-from-left-2 astw:data-[side=top]:slide-in-from-bottom-2 astw:z-50 astw:w-fit astw:origin-(--radix-tooltip-content-transform-origin) astw:rounded-md astw:px-3 astw:py-1.5 astw:text-xs astw:text-balance",t),...r,children:[e,M(h.Arrow,{className:"astw:bg-primary astw:fill-primary astw:z-50 astw:size-2.5 astw:translate-y-[calc(-50%_-_2px)] astw:rotate-45 astw:rounded-[2px]"})]})})}import{jsx as w,jsxs as O}from"react/jsx-runtime";var qa="sidebar_state",Ga=60*60*24*7,Xa="16rem",Ya="18rem",Ja="3rem",Qa="b",_t=b.createContext(null);function L(){let t=b.useContext(_t);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function At({defaultOpen:t=!0,open:a,onOpenChange:e,className:r,style:o,children:s,...d}){let i=Pt(),[l,p]=b.useState(!1),[u,S]=b.useState(t),k=a??u,N=b.useCallback(v=>{let R=typeof v=="function"?v(k):v;e?e(R):S(R),document.cookie=`${qa}=${R}; path=/; max-age=${Ga}`},[e,k]),z=b.useCallback(()=>i?p(v=>!v):N(v=>!v),[i,N,p]);b.useEffect(()=>{let v=R=>{R.key===Qa&&(R.metaKey||R.ctrlKey)&&(R.preventDefault(),z())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[z]);let W=k?"expanded":"collapsed",$=b.useMemo(()=>({state:W,open:k,setOpen:N,isMobile:i,openMobile:l,setOpenMobile:p,toggleSidebar:z}),[W,k,N,i,l,p,z]);return w(_t.Provider,{value:$,children:w(tt,{delayDuration:0,children:w("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":Xa,"--sidebar-width-icon":Ja,...o},className:c("astw:group/sidebar-wrapper astw:has-data-[variant=inset]:bg-sidebar astw:flex astw:min-h-svh astw:w-full",r),...d,children:s})})})}function Ot({side:t="left",variant:a="sidebar",collapsible:e="offcanvas",className:r,children:o,...s}){let{isMobile:d,state:i,openMobile:l,setOpenMobile:p}=L();return e==="none"?w("div",{"data-slot":"sidebar",className:c("astw:bg-sidebar astw:text-sidebar-foreground astw:flex astw:h-full astw:w-(--sidebar-width) astw:flex-col",r),...s,children:o}):d?w(St,{open:l,onOpenChange:p,...s,children:O(Tt,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"astw:bg-sidebar astw:text-sidebar-foreground astw:w-(--sidebar-width) astw:p-0 astw:[&>button]:hidden",style:{"--sidebar-width":Ya},side:t,children:[O(Nt,{className:"astw:sr-only",children:[w(zt,{children:"Sidebar"}),w(Bt,{children:"Displays the mobile sidebar."})]}),w("div",{className:"flex h-full w-full flex-col",children:o})]})}):O("div",{className:"astw:group astw:peer astw:text-sidebar-foreground astw:hidden astw:md:block","data-state":i,"data-collapsible":i==="collapsed"?e:"","data-variant":a,"data-side":t,"data-slot":"sidebar",children:[w("div",{"data-slot":"sidebar-gap",className:c("astw:relative astw:w-(--sidebar-width) astw:bg-transparent astw:transition-[width] astw:duration-200 astw:ease-linear","astw:group-data-[collapsible=offcanvas]:w-0","astw:group-data-[side=right]:rotate-180",a==="floating"||a==="inset"?"astw:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"astw:group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),w("div",{"data-slot":"sidebar-container",className:c("astw:fixed astw:inset-y-0 astw:z-10 astw:hidden astw:h-svh astw:w-(--sidebar-width) astw:transition-[left,right,width] astw:duration-200 astw:ease-linear astw:md:flex",t==="left"?"astw:left-0 astw:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"astw:right-0 astw:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",a==="floating"||a==="inset"?"astw:p-2 astw:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"astw:group-data-[collapsible=icon]:w-(--sidebar-width-icon) astw:group-data-[side=left]:border-r astw:group-data-[side=right]:border-l",a==="inset"&&"astw:border-x astw:border-x-border",r),...s,children:w("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"astw:bg-sidebar astw:group-data-[variant=floating]:border-sidebar-border astw:flex astw:h-full astw:w-full astw:flex-col astw:group-data-[variant=floating]:rounded-lg astw:group-data-[variant=floating]:border astw:group-data-[variant=floating]:shadow-sm",children:o})})]})}function et({className:t,onClick:a,...e}){let{toggleSidebar:r}=L();return O(y,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:c("astw:text-muted-foreground",t),onClick:o=>{a?.(o),r()},...e,children:[w(Wa,{className:"astw:size-4.5"}),w("span",{className:"astw:sr-only",children:"Toggle Sidebar"})]})}function Lt({className:t,...a}){return w("main",{"data-slot":"sidebar-inset",className:c("astw:bg-background astw:relative astw:flex astw:w-full astw:flex-1 astw:flex-col","astw:px-4 astw:md:peer-data-[variant=inset]:px-8 astw:md:peer-data-[variant=inset]:py-2",t),...a})}function Dt({className:t,...a}){return w("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:c("astw:flex astw:flex-row astw:items-center astw:gap-0.5 astw:p-2",t),...a})}function Ut({className:t,...a}){return w("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:c("astw:flex astw:min-h-0 astw:flex-1 astw:flex-col astw:gap-2 astw:overflow-auto astw:group-data-[collapsible=icon]:overflow-hidden",t),...a})}function jt({className:t,...a}){return w("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:c("astw:relative astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:p-2",t),...a})}function $t({className:t,...a}){return w("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:c("astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:gap-1",t),...a})}function Ht({className:t,...a}){return w("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:c("astw:group/menu-item astw:relative",t),...a})}var Za=Ka("astw:peer/menu-button astw:flex astw:w-full astw:items-center astw:gap-2 astw:overflow-hidden astw:rounded-md astw:p-2 astw:text-left astw:text-sm astw:outline-hidden astw:ring-sidebar-ring astw:transition-[width,height,padding] astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:focus-visible:ring-2 astw:active:bg-sidebar-accent astw:active:text-sidebar-accent-foreground astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:group-has-data-[sidebar=menu-action]/menu-item:pr-8 astw:aria-disabled:pointer-events-none astw:aria-disabled:opacity-50 astw:data-[active=true]:bg-sidebar-accent astw:data-[active=true]:font-medium astw:data-[active=true]:text-sidebar-accent-foreground astw:data-[state=open]:hover:bg-sidebar-accent astw:data-[state=open]:hover:text-sidebar-accent-foreground astw:group-data-[collapsible=icon]:size-8! astw:group-data-[collapsible=icon]:p-2! astw:[&>span:last-child]:truncate astw:[&>svg]:size-4 astw:[&>svg]:shrink-0",{variants:{variant:{default:"astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground",outline:"astw:bg-background astw:shadow-[0_0_0_1px_hsl(var(--sidebar-border))] astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"astw:h-8 astw:text-sm",sm:"astw:h-7 astw:rounded-md astw:gap-1.5 astw:px-3 astw:has-[>svg]:px-2.5",lg:"astw:h-12 astw:text-sm astw:group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function rt({asChild:t=!1,isActive:a=!1,variant:e="default",size:r="default",tooltip:o,className:s,...d}){let i=t?at:"button",{isMobile:l,state:p}=L(),u=w(i,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":r,"data-active":a,className:c(Za({variant:e,size:r}),s),...d});return o?(typeof o=="string"&&(o={children:o}),O(Mt,{children:[w(Et,{asChild:!0,children:u}),w(It,{side:"right",align:"center",hidden:p!=="collapsed"||l,...o})]})):u}function ot({className:t,asChild:a=!1,showOnHover:e=!1,...r}){return w(a?at:"button",{"data-slot":"sidebar-menu-action","data-sidebar":"menu-action",className:c("astw:text-sidebar-foreground astw:ring-sidebar-ring astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:peer-hover/menu-button:text-sidebar-accent-foreground astw:absolute astw:top-1.5 astw:right-1 astw:flex astw:aspect-square astw:w-5 astw:items-center astw:justify-center astw:rounded-md astw:p-0 astw:outline-hidden astw:transition-transform astw:focus-visible:ring-2 astw:[&>svg]:size-4 astw:[&>svg]:shrink-0","astw:after:absolute astw:after:-inset-2 astw:md:after:hidden","astw:peer-data-[size=sm]/menu-button:top-1","astw:peer-data-[size=default]/menu-button:top-1.5","astw:peer-data-[size=lg]/menu-button:top-2.5","astw:group-data-[collapsible=icon]:hidden",e&&"astw:peer-data-[active=true]/menu-button:text-sidebar-accent-foreground astw:group-focus-within/menu-item:opacity-100 astw:group-hover/menu-item:opacity-100 astw:data-[state=open]:opacity-100 astw:md:opacity-0",t),...r})}function Vt({className:t,...a}){return w("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:c("astw:border-sidebar-border astw:mx-3.5 astw:flex astw:min-w-0 astw:translate-x-px astw:flex-col astw:gap-1 astw:border-l astw:px-2.5 astw:py-0.5","astw:group-data-[collapsible=icon]:hidden",t),...a})}function Ft({className:t,...a}){return w("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:c("astw:group/menu-sub-item astw:relative",t),...a})}function Kt({asChild:t=!1,size:a="md",isActive:e=!1,className:r,...o}){return w(t?at:"a",{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":a,"data-active":e,className:c("astw:text-sidebar-foreground astw:ring-sidebar-ring astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:active:bg-sidebar-accent astw:active:text-sidebar-accent-foreground astw:[&>svg]:text-sidebar-accent-foreground astw:flex astw:h-7 astw:min-w-0 astw:-translate-x-px astw:items-center astw:gap-2 astw:overflow-hidden astw:rounded-md astw:px-2 astw:outline-hidden astw:focus-visible:ring-2 astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:aria-disabled:pointer-events-none astw:aria-disabled:opacity-50 astw:[&>span:last-child]:truncate astw:[&>svg]:size-4 astw:[&>svg]:shrink-0","astw:data-[active=true]:bg-sidebar-accent astw:data-[active=true]:text-sidebar-accent-foreground",a==="sm"&&"astw:text-xs",a==="md"&&"astw:text-sm","astw:group-data-[collapsible=icon]:hidden",r),...o})}import{ChevronRight as Xt,SunIcon as ie}from"lucide-react";import{Slot as ee}from"@radix-ui/react-slot";import{ChevronRight as re,MoreHorizontal as go}from"lucide-react";import{Link as te,useHref as ae}from"react-router";import{jsx as Wt}from"react/jsx-runtime";function D({to:t,children:a,...e}){try{return ae(t),Wt(te,{to:t,...e,children:a})}catch{return Wt("a",{href:t,...e,children:a})}}import{jsx as E,jsxs as vo}from"react/jsx-runtime";function st({...t}){return E("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...t})}function it({className:t,...a}){return E("ol",{"data-slot":"breadcrumb-list",className:c("astw:text-muted-foreground astw:flex astw:flex-wrap astw:items-center astw:gap-1.5 astw:text-sm astw:break-words astw:sm:gap-2.5",t),...a})}function nt({className:t,...a}){return E("li",{"data-slot":"breadcrumb-item",className:c("astw:inline-flex astw:items-center astw:gap-1.5",t),...a})}function dt({asChild:t,className:a,children:e,...r}){return E(t?ee:D,{"data-slot":"breadcrumb-link",className:c("astw:hover:text-foreground astw:transition-colors",a),...r,children:e})}function qt({children:t,className:a,...e}){return E("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:c("astw:[&>svg]:size-3.5",a),...e,children:t??E(re,{})})}var oe=t=>t.reduce((a,e)=>{a[e.path]={title:e.meta.title,breadcrumbTitle:e.meta.breadcrumbTitle};let r=(o,s)=>{!o||o.length===0||o.forEach(d=>{let i=`${s}/${d.path}`;a[i]={title:d.meta.title,breadcrumbTitle:d.meta.breadcrumbTitle},d.subResources&&d.subResources.length>0&&r(d.subResources,i)})};return e.resources&&e.resources.length>0&&r(e.resources,e.path),a},{});function Gt(t,a,e){let r=t.split("/").filter(i=>i!==""),o=a&&r[0]===a?r.slice(1):r,s=oe(e),d=o.map((i,l)=>{let p=o.slice(0,l+1).join("/"),u=s[p];if(!u){let k=Object.entries(s).find(([N])=>{let z=N.split("/").map($=>$.startsWith(":")?"[^/]+":$).join("/");return new RegExp(`^${z}$`).test(p)})?.[1];k&&(u=k)}let S;return u?typeof u.breadcrumbTitle=="function"?S=u.breadcrumbTitle(i):typeof u.breadcrumbTitle=="string"?S=u.breadcrumbTitle:S=u.title:S=decodeURIComponent(i),{segment:i,path:p,title:S}});return{basePath:a||null,segments:d}}import{Fragment as Yt,jsx as n,jsxs as g}from"react/jsx-runtime";var ne=()=>{let{open:t}=L();return n("div",{className:t?"astw:md:hidden":void 0,children:n(et,{className:"astw:-ml-2.5"})})},de=t=>{let a=t.children?t.children({Outlet:G}):null,e=X(),r=()=>{e.setTheme(e.theme==="dark"?"light":"dark")};return n(At,{className:"astw:flex astw:flex-col",children:g("div",{className:"astw:flex astw:flex-1",children:[t.sidebar??n(Qt,{}),g(Lt,{className:"astw:w-[calc(100%-var(--sidebar-width))]",children:[n("header",{className:"astw:flex astw:h-14 astw:shrink-0 astw:items-center astw:gap-2 astw:transition-[width,height] astw:ease-linear astw:group-has-data-[collapsible=icon]/sidebar-wrapper:h-12",children:g("div",{className:"astw:flex astw:w-full astw:items-center astw:justify-between",children:[g("div",{className:"astw:flex astw:items-center astw:gap-2",children:[n(ne,{}),n(ce,{})]}),n("div",{className:"astw:flex astw:items-center astw:gap-2",children:n(y,{variant:"outline",size:"icon",onClick:r,children:n(ie,{})})})]})}),n("div",{className:"astw:flex astw:flex-col astw:gap-4",children:a??n(G,{})})]})]})})},Qt=t=>{let{title:a,icon:e,navItems:r}=P(),{pathname:o}=Jt(),s=g(Dt,{children:[e,n("h1",{className:"astw:text-sm astw:mb-2 astw:mt-2 astw:px-2",children:a})]});return g(Ot,{variant:"inset",children:[g("div",{className:"astw:flex astw:justify-between astw:items-center",children:[t.header??s,n("div",{className:"astw:hidden astw:md:block",children:n(et,{className:"astw:-ml-1"})})]}),n(Ut,{children:n(jt,{children:n($t,{children:r.map(i=>n(kt,{asChild:!0,defaultOpen:i.isActive,children:g(Ht,{children:[i.url?g(Yt,{children:[n(rt,{asChild:!0,tooltip:i.title,children:g(D,{to:i.url,className:i.url===o?"astw:bg-sidebar-accent astw:font-medium":void 0,children:[i.icon,n("span",{children:i.title})]})}),!!i.items?.length&&n(Y,{asChild:!0,children:g(ot,{className:"astw:data-[state=open]:rotate-90",children:[n(Xt,{}),n("span",{className:"astw:sr-only",children:"Toggle"})]})})]}):n(Yt,{children:g(Y,{className:"astw:flex astw:w-[100%] astw:[&[data-state=open]_.astw-rotate-target]:rotate-90",children:[n(rt,{asChild:!0,tooltip:i.title,children:g("span",{className:"astw:flex astw:w-[100%]",children:[i.icon,n("span",{children:i.title})]})}),!!i.items?.length&&n(ot,{className:"astw-rotate-target",asChild:!0,children:g("span",{children:[n(Xt,{}),n("span",{className:"astw:sr-only",children:"Toggle"})]})})]})}),!!i.items?.length&&n(Rt,{children:n(Vt,{children:i.items?.map(l=>n(Ft,{children:n(Kt,{asChild:!0,children:n(D,{to:l.url,className:l.url===o?"astw:bg-sidebar-accent astw:font-medium":void 0,children:n("span",{children:l.title})})})},l.title))})})]})},i.title))})})}),t.footer??null]})},le=()=>{let{configurations:t}=P(),a=Jt();return Gt(a.pathname,t.basePath,t.modules)},ce=()=>{let{segments:t}=le(),a=se("/:prefix/settings/:suffix");return a?n(st,{children:n(it,{children:n("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:n(nt,{children:n(dt,{to:`/${a.params.prefix}/settings`,children:"Settings"})})})})}):n(st,{children:n(it,{children:t.map((e,r)=>g("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:[n(nt,{children:n(dt,{to:e.path,children:e.title})}),r<t.length-1&&n(qt,{})]},r))})})};import{useLocation as Xo,useNavigate as Yo,useParams as Jo,useSearchParams as Qo,useRouteError as Zo,Link as ts}from"react-router";import{createContext as pe,useCallback as aa,useContext as ue,useEffect as me,useMemo as ge,useState as be}from"react";import*as I from"oauth4webapi";var U="oauth_pkce_verifier",j="oauth_state",Zt=({apiEndpoint:t,clientId:a,state:e,codeChallenge:r,redirectUri:o})=>{let s=new URL(`${t}/oauth2/authorize`);return s.searchParams.set("response_type","code"),s.searchParams.set("client_id",a),s.searchParams.set("redirect_uri",o??window.location.origin),s.searchParams.set("scope","openid profile email"),s.searchParams.set("state",e),s.searchParams.set("code_challenge",r),s.searchParams.set("code_challenge_method","S256"),s.toString()},we=async({code:t,returnedState:a,apiEndpoint:e,clientId:r,redirectUri:o})=>{let s=sessionStorage.getItem(U),d=sessionStorage.getItem(j);if(!t||!a||!s||!d){let l=[];throw t||l.push("code"),a||l.push("returnedState"),s||l.push("code_verifier"),d||l.push("expectedState"),new Error(`Missing params: ${l.join(", ")}`)}if(a!==d)throw new Error("State mismatch: possible CSRF attack");let i=new URLSearchParams({grant_type:"authorization_code",client_id:r,code:t,redirect_uri:o??window.location.origin,code_verifier:s});try{let l=await fetch(`${e}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Tailor-Nonce":crypto.randomUUID()},credentials:"include",body:i.toString()}),{access_token:p}=await l.json();return p}catch(l){throw new Error(`Token exchange failed: ${l instanceof Error?l.message:String(l)}`)}},ta=async()=>{let t=I.generateRandomCodeVerifier(),a=await I.calculatePKCECodeChallenge(t),e=I.generateRandomState();return sessionStorage.setItem(U,t),sessionStorage.setItem(j,e),{codeChallenge:a,state:e}},Ao=async({currentUrl:t,apiEndpoint:a,clientId:e,redirectUri:r})=>{try{let o=t.searchParams.get("code"),s=t.searchParams.get("state");await we({apiEndpoint:a,clientId:e,code:o,returnedState:s,redirectUri:r})}catch(o){console.error(o)}finally{sessionStorage.removeItem(U),sessionStorage.removeItem(j),t.searchParams.delete("code"),t.searchParams.delete("state"),t.searchParams.delete("error"),t.searchParams.delete("error_description"),window.history.replaceState({},document.title,t.toString())}};import{jsx as ve}from"react/jsx-runtime";var ea=pe(void 0),he=()=>{let t=ue(ea);if(t===void 0)throw new Error("useBuiltinIdpAuth must be used within an BuiltinIdPAuthContextProvider");return t},fe=({apiEndpoint:t,clientId:a,redirectUri:e,children:r})=>{let[o,s]=be(!1),d=aa(async()=>{let{codeChallenge:l,state:p}=await ta(),u=Zt({apiEndpoint:t,clientId:a,codeChallenge:l,state:p,redirectUri:e});window.location.href=u},[t,a,e]);me(()=>{(async()=>{(await(await fetch(`${t}/query`,{method:"POST",headers:{"Content-Type":"application/json","X-Tailor-Nonce":crypto.randomUUID()},credentials:"include",body:JSON.stringify({query:"query Myself(){ me { id }}"})})).json()).data.me?s(!0):d()})()},[t,d]);let i=aa(async()=>{sessionStorage.removeItem(U),sessionStorage.removeItem(j);try{await fetch(`${t}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Tailor-Nonce":crypto.randomUUID()},credentials:"include",body:""}),window.location.href="/"}catch(l){console.error(l)}},[t]);return ve(ea.Provider,{value:ge(()=>({login:d,logout:i}),[d,i]),children:o?r:null})};export{Ua as AppShell,fe as BuiltinIdPAuthProvider,Qt as DefaultSidebar,ts as Link,j as OAUTH_STATE_KEY,U as PKCE_VERIFIER_KEY,de as SidebarLayout,Zt as buildAuthorizationUrl,fa as defineModule,va as defineResource,we as exchangeCodeForToken,Ao as handleOAuthCallback,ta as prepareLogin,ha as redirectToResource,P as useAppShell,he as useBuiltinIdpAuth,Xo as useLocation,Yo as useNavigate,Jo as useParams,Zo as useRouteError,Qo as useSearchParams,X as useTheme};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/app-shell",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./styles": "./dist/index.css",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@types/node": "^22",
|
|
55
55
|
"@types/react": "^19",
|
|
56
56
|
"@types/react-dom": "^19",
|
|
57
|
-
"
|
|
57
|
+
"happy-dom": "^20.0.11",
|
|
58
58
|
"msw": "^2.11.2",
|
|
59
59
|
"postcss": "^8",
|
|
60
60
|
"prettier": "^3.6.2",
|