@tailor-platform/app-shell 0.14.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +11 -11
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -81,12 +81,6 @@ type Resource = CommonPageResource & {
|
|
|
81
81
|
errorBoundary?: ErrorBoundaryComponent;
|
|
82
82
|
};
|
|
83
83
|
type Modules = Array<Module>;
|
|
84
|
-
type RootConfiguration = {
|
|
85
|
-
modules: Modules;
|
|
86
|
-
settingsResources?: Resource[];
|
|
87
|
-
basePath?: string;
|
|
88
|
-
errorBoundary?: ErrorBoundaryComponent;
|
|
89
|
-
};
|
|
90
84
|
type ResourceMetaProps = {
|
|
91
85
|
/**
|
|
92
86
|
* Title of the resource used in navigation.
|
|
@@ -227,7 +221,7 @@ type DefineResourceProps = CommonProps & ReactResourceProps & {
|
|
|
227
221
|
*/
|
|
228
222
|
declare function defineResource(props: DefineResourceProps): Resource;
|
|
229
223
|
|
|
230
|
-
type AppShellProps = {
|
|
224
|
+
type AppShellProps = React.PropsWithChildren<{
|
|
231
225
|
/**
|
|
232
226
|
* App shell title
|
|
233
227
|
*/
|
|
@@ -263,9 +257,9 @@ type AppShellProps = {
|
|
|
263
257
|
*/
|
|
264
258
|
modules: Modules;
|
|
265
259
|
/**
|
|
266
|
-
*
|
|
260
|
+
* Settings resources to be included in the settings menu
|
|
267
261
|
*/
|
|
268
|
-
|
|
262
|
+
settingsResources?: Array<Resource>;
|
|
269
263
|
/**
|
|
270
264
|
* Global error boundary component applied to all routes.
|
|
271
265
|
* When an error occurs in any route component, this component will render.
|
|
@@ -296,8 +290,8 @@ type AppShellProps = {
|
|
|
296
290
|
*/
|
|
297
291
|
errorBoundary?: ErrorBoundaryComponent;
|
|
298
292
|
};
|
|
299
|
-
}
|
|
300
|
-
declare const AppShell: (props:
|
|
293
|
+
}>;
|
|
294
|
+
declare const AppShell: (props: AppShellProps) => react_jsx_runtime.JSX.Element | null;
|
|
301
295
|
|
|
302
296
|
type SidebarLayoutContainerProps = {
|
|
303
297
|
children?: (props: {
|
|
@@ -324,6 +318,12 @@ type NavItem = {
|
|
|
324
318
|
items?: Array<NavChildItem>;
|
|
325
319
|
};
|
|
326
320
|
|
|
321
|
+
type RootConfiguration = {
|
|
322
|
+
modules: Modules;
|
|
323
|
+
settingsResources: Resource[];
|
|
324
|
+
basePath?: string;
|
|
325
|
+
errorBoundary?: ErrorBoundaryComponent;
|
|
326
|
+
};
|
|
327
327
|
type AppShellContextType = {
|
|
328
328
|
title?: string;
|
|
329
329
|
icon?: ReactNode;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Table as _a}from"lucide-react";import{useEffect as Aa,useMemo as La,useState as Oa}from"react";import{createContext as ra,useContext as oa}from"react";var Y=ra({navItems:[],configurations:{modules:[]}}),R=()=>oa(Y);import{createBrowserRouter as xa,RouterProvider as ya,Navigate as Ca,redirect as ka,Outlet as Pa}from"react-router";import{NavLink as wa,Outlet as pt}from"react-router";import{Toaster as pa}from"sonner";import{Slot as na}from"@radix-ui/react-slot";import{cva as da}from"class-variance-authority";import{clsx as sa}from"clsx";import{twMerge as ia}from"tailwind-merge";function c(...t){return ia(sa(t))}import{jsx as ca}from"react/jsx-runtime";var la=da("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:o=!1,...r}){return ca(o?na:"button",{"data-slot":"button",className:c(la({variant:a,size:e,className:t})),...r})}import{Fragment as ua,jsx as h,jsxs as _}from"react/jsx-runtime";var U=({contentBorder:t,children:a})=>h("div",{className:t?"astw:p-4 astw:rounded-sm astw:border astw:shadow-xs":"",children:a}),ut=()=>_(U,{contentBorder:!0,children:[h("p",{className:"astw:font-semibold astw:leading-none astw:tracking-tight",children:"Welcome to AppShell"}),h("p",{className:"pt-4",children:"Add your GraphQL resources from configuration at first!"})]}),J=()=>_(ua,{children:[h(pt,{}),h(pa,{})]}),mt=()=>{let{configurations:t}=R();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:[h("div",{children:_("nav",{className:"astw:bg-card astw:md:w-xs astw:rounded-md astw:border astw:p-3 astw:shadow-xs",children:[h("h2",{className:"astw:text-sm astw:leading-[36px] astw:mb-2 astw:font-bold ",children:"Settings"}),h("ul",{className:"astw:flex astw:flex-col astw:gap-1",children:t.settingsResources?.map(a=>h("li",{children:h(wa,{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))})]})}),h("section",{className:"astw:bg-card astw:flex-1 astw:rounded-md astw:border astw:shadow-xs",children:h(pt,{})})]})};import{useRouteError as ma,isRouteErrorResponse as ga}from"react-router";import{AlertCircle as gt}from"lucide-react";import{jsx as x,jsxs as F}from"react/jsx-runtime";var bt=()=>{let t=ma();if(ga(t)&&t.status===404)return x("div",{className:"astw:p-6",children:F("div",{className:"astw:flex astw:items-start astw:gap-4",children:[x(gt,{className:"astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5"}),F("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:F("div",{className:"astw:flex astw:items-start astw:gap-4",children:[x(gt,{className:"astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5"}),F("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{capitalCase as ht}from"change-case";import{redirect as ba}from"react-router";var H="resources",C=(t,a)=>a?`/${a}/${H}/${t}`:`/${H}/${t}`;import{jsx as ft}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:o,resources:r,errorBoundary:i}=t,n=e?.title??ht(a),s=V(o)?{component:()=>null,loader:l=>ba(C(o.redirectTo,l))}:{component:()=>ft(U,{contentBorder:e?.contentBorder??!1,children:o({title:n,resources:r})})};return{path:a,type:"component",_type:"module",...s,meta:{title:n,...e?.breadcrumbTitle!==void 0?{breadcrumbTitle:e.breadcrumbTitle}:{},...e,menuItemClickable:!V(o),icon:t.meta?.icon},resources:r,errorBoundary:i}}function va(t){let{path:a,component:e,subResources:o,meta:r,errorBoundary:i}=t,n=r?.title??ht(a);return{_type:"resource",type:"component",path:a,meta:{title:n,icon:r?.icon,...r?.breadcrumbTitle!==void 0?{breadcrumbTitle:r.breadcrumbTitle}:{}},component:()=>ft(U,{contentBorder:r?.contentBorder??!1,children:e({title:n,resources:o})}),subResources:o,errorBoundary:i}}import{Fragment as Ra,jsx as A}from"react/jsx-runtime";var K=t=>()=>A(Ra,{children:t}),Sa=(t,a,e)=>t.reduce((o,r)=>{let i=r.errorBoundary||e,n={index:!0,Component:r.component,...r.loader&&{loader:()=>r.loader(a)}};return[...o,{path:r.path,...i&&{ErrorBoundary:K(i)},...r.resources&&r.resources.length>0?{children:[n,...r.resources.map(s=>vt(s,i))]}:{children:[n]}}]},[]),vt=(t,a)=>{let e=t.errorBoundary||a,o={index:!0,Component:t.component};return{path:t.path,...t.errorBoundary&&{ErrorBoundary:K(t.errorBoundary)},...t.subResources&&t.subResources.length>0?{children:[o,...t.subResources.map(r=>vt(r,e))]}:{children:[o]}}},xt=t=>{let{configurations:a}=R(),{rootComponent:e}=t,o=a.errorBoundary===void 0?A(bt,{}):a.errorBoundary,i=[V(e)?{index:!0,loader:()=>ka(C(e.redirectTo,a.basePath))}:{index:!0,Component:e??ut},{path:H,children:Sa(a.modules,a.basePath,o)},{path:"settings",index:!0,Component:()=>A(Ca,{to:(a.settingsResources??[])[0].path,relative:"path",replace:!0})},{path:"settings",Component:mt,children:a.settingsResources?.map(s=>({path:s.path,Component:s.component,...s.errorBoundary&&{ErrorBoundary:K(s.errorBoundary)}}))},{path:"*",loader:()=>{throw new Response("Not Found",{status:404})}}],n=xa([{path:a.basePath,element:t.children,children:o?[{element:A(Pa,{}),ErrorBoundary:K(o),children:i}]:i}]);return A(ya,{router:n})};import{createContext as Ta,useContext as Na,useEffect as za,useMemo as Ba,useState as Ma}from"react";import{jsx as Ia}from"react/jsx-runtime";var Ea={resolvedTheme:"light",theme:"system",setTheme:()=>null},yt=Ta(Ea);function Ct({children:t,storageKey:a,defaultTheme:e="system",...o}){let[r,i]=Ma(()=>localStorage.getItem(a)||e),n=Ba(()=>r!=="system"?r:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[r]);za(()=>{let l=window.document.documentElement;l.classList.remove("light","dark"),l.classList.add(n)},[n]);let s={resolvedTheme:n,theme:r,setTheme:l=>{localStorage.setItem(a,l),i(l)}};return Ia(yt.Provider,{...o,value:s,children:t})}var Q=()=>{let t=Na(yt);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};import{jsx as q}from"react/jsx-runtime";var Da=t=>{let[a,e]=Oa(!1);Aa(function(){e(!0)},[]);let o=t.configurations.basePath,r=La(()=>t.configurations.modules.map(n=>{let s=n.resources.map(l=>({title:l.meta.title,url:C(`${n.path}/${l.path}`,o)}));return{title:n.meta.title,url:n.meta.menuItemClickable?C(n.path,o):void 0,clickable:n.component,icon:n.meta.icon||q(_a,{}),isActive:!0,items:s}}),[t.configurations.modules,o]);return a?q(Y.Provider,{value:{title:t.title,icon:t.icon,configurations:{...t.configurations,basePath:o},navItems:r},children:q(Ct,{defaultTheme:"system",storageKey:"appshell-ui-theme",children:q(xt,{rootComponent:t.configurations.rootComponent,children:t.children})})}):null};import*as B from"@radix-ui/react-collapsible";import{jsx as tt}from"react/jsx-runtime";function kt({...t}){return tt(B.Root,{"data-slot":"collapsible",...t})}function Z({...t}){return tt(B.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Pt({...t}){return tt(B.CollapsibleContent,{"data-slot":"collapsible-content",...t})}import{useLocation as Jt,useMatch as oe}from"react-router";import*as b from"react";import{Slot as ot}from"@radix-ui/react-slot";import{cva as Ha}from"class-variance-authority";import{PanelLeftIcon as Va}from"lucide-react";import*as G from"react";var at=768;function St(){let[t,a]=G.useState(void 0);return G.useEffect(()=>{let e=window.matchMedia(`(max-width: ${at-1}px)`),o=()=>{a(window.innerWidth<at)};return e.addEventListener("change",o),a(window.innerWidth<at),()=>e.removeEventListener("change",o)},[]),!!t}import{jsx as Sr}from"react/jsx-runtime";import*as $a from"@radix-ui/react-separator";import{jsx as zr}from"react/jsx-runtime";import*as m from"@radix-ui/react-dialog";import{XIcon as ja}from"lucide-react";import{jsx as k,jsxs as et}from"react/jsx-runtime";function Rt({...t}){return k(m.Root,{"data-slot":"sheet",...t})}function Wa({...t}){return k(m.Portal,{"data-slot":"sheet-portal",...t})}function Ua({className:t,...a}){return k(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",...o}){return et(Wa,{children:[k(Ua,{}),et(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),...o,children:[a,et(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:[k(ja,{className:"astw:size-4"}),k("span",{className:"astw:sr-only",children:"Close"})]})]})]})}function Nt({className:t,...a}){return k("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 k(m.Title,{"data-slot":"sheet-title",className:c("astw:text-foreground astw:font-semibold",t),...a})}function Bt({className:t,...a}){return k(m.Description,{"data-slot":"sheet-description",className:c("astw:text-muted-foreground astw:text-sm",t),...a})}import{jsx as Or}from"react/jsx-runtime";import*as f from"@radix-ui/react-tooltip";import{jsx as M,jsxs as Fa}from"react/jsx-runtime";function rt({delayDuration:t=0,...a}){return M(f.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function Mt({...t}){return M(rt,{children:M(f.Root,{"data-slot":"tooltip",...t})})}function Et({...t}){return M(f.Trigger,{"data-slot":"tooltip-trigger",...t})}function It({className:t,sideOffset:a=0,children:e,...o}){return M(f.Portal,{children:Fa(f.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),...o,children:[e,M(f.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 L}from"react/jsx-runtime";var Ka="sidebar_state",qa=60*60*24*7,Ga="16rem",Xa="18rem",Ya="3rem",Ja="b",_t=b.createContext(null);function O(){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:o,style:r,children:i,...n}){let s=St(),[l,p]=b.useState(!1),[u,T]=b.useState(t),P=a??u,N=b.useCallback(v=>{let S=typeof v=="function"?v(P):v;e?e(S):T(S),document.cookie=`${Ka}=${S}; path=/; max-age=${qa}`},[e,P]),z=b.useCallback(()=>s?p(v=>!v):N(v=>!v),[s,N,p]);b.useEffect(()=>{let v=S=>{S.key===Ja&&(S.metaKey||S.ctrlKey)&&(S.preventDefault(),z())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[z]);let X=P?"expanded":"collapsed",W=b.useMemo(()=>({state:X,open:P,setOpen:N,isMobile:s,openMobile:l,setOpenMobile:p,toggleSidebar:z}),[X,P,N,s,l,p,z]);return w(_t.Provider,{value:W,children:w(rt,{delayDuration:0,children:w("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":Ga,"--sidebar-width-icon":Ya,...r},className:c("astw:group/sidebar-wrapper astw:has-data-[variant=inset]:bg-sidebar astw:flex astw:min-h-svh astw:w-full",o),...n,children:i})})})}function Lt({side:t="left",variant:a="sidebar",collapsible:e="offcanvas",className:o,children:r,...i}){let{isMobile:n,state:s,openMobile:l,setOpenMobile:p}=O();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",o),...i,children:r}):n?w(Rt,{open:l,onOpenChange:p,...i,children:L(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":Xa},side:t,children:[L(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:r})]})}):L("div",{className:"astw:group astw:peer astw:text-sidebar-foreground astw:hidden astw:md:block","data-state":s,"data-collapsible":s==="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",o),...i,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:r})})]})}function st({className:t,onClick:a,...e}){let{toggleSidebar:o}=O();return L(y,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:c("astw:text-muted-foreground",t),onClick:r=>{a?.(r),o()},...e,children:[w(Va,{className:"astw:size-4.5"}),w("span",{className:"astw:sr-only",children:"Toggle Sidebar"})]})}function Ot({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 $t({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 Wt({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 Ut({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 Qa=Ha("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 it({asChild:t=!1,isActive:a=!1,variant:e="default",size:o="default",tooltip:r,className:i,...n}){let s=t?ot:"button",{isMobile:l,state:p}=O(),u=w(s,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":o,"data-active":a,className:c(Qa({variant:e,size:o}),i),...n});return r?(typeof r=="string"&&(r={children:r}),L(Mt,{children:[w(Et,{asChild:!0,children:u}),w(It,{side:"right",align:"center",hidden:p!=="collapsed"||l,...r})]})):u}function nt({className:t,asChild:a=!1,showOnHover:e=!1,...o}){return w(a?ot:"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),...o})}function Ft({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 Ht({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 Vt({asChild:t=!1,size:a="md",isActive:e=!1,className:o,...r}){return w(t?ot:"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",o),...r})}import{ChevronRight as Xt,SunIcon as se}from"lucide-react";import{Slot as ae}from"@radix-ui/react-slot";import{ChevronRight as ee,MoreHorizontal as wo}from"lucide-react";import{Link as Za,useHref as te}from"react-router";import{jsx as Kt}from"react/jsx-runtime";function D({to:t,children:a,...e}){try{return te(t),Kt(Za,{to:t,...e,children:a})}catch{return Kt("a",{href:t,...e,children:a})}}import{jsx as E,jsxs as go}from"react/jsx-runtime";function dt({...t}){return E("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...t})}function lt({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 ct({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 wt({asChild:t,className:a,children:e,...o}){return E(t?ae:D,{"data-slot":"breadcrumb-link",className:c("astw:hover:text-foreground astw:transition-colors",a),...o,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(ee,{})})}var re=t=>t.reduce((a,e)=>{a[e.path]={title:e.meta.title,breadcrumbTitle:e.meta.breadcrumbTitle};let o=(r,i)=>{!r||r.length===0||r.forEach(n=>{let s=`${i}/${n.path}`;a[s]={title:n.meta.title,breadcrumbTitle:n.meta.breadcrumbTitle},n.subResources&&n.subResources.length>0&&o(n.subResources,s)})};return e.resources&&e.resources.length>0&&o(e.resources,e.path),a},{});function Gt(t,a,e){let o=t.split("/").filter(s=>s!=="").slice(1),r=a?(()=>{let[s,...l]=o;return l})():o,i=re(e),n=r.map((s,l)=>{let p=r.slice(0,l+1).join("/"),u=i[p];if(!u){let P=Object.entries(i).find(([N])=>{let z=N.split("/").map(W=>W.startsWith(":")?"[^/]+":W).join("/");return new RegExp(`^${z}$`).test(p)})?.[1];P&&(u=P)}let T;return u?typeof u.breadcrumbTitle=="function"?T=u.breadcrumbTitle(s):typeof u.breadcrumbTitle=="string"?T=u.breadcrumbTitle:T=u.title:T=decodeURIComponent(s),{segment:s,path:p,title:T}});return{basePath:a||null,segments:n}}import{Fragment as Yt,jsx as d,jsxs as g}from"react/jsx-runtime";var ie=()=>{let{open:t}=O();return d("div",{className:t?"astw:md:hidden":void 0,children:d(st,{className:"astw:-ml-2.5"})})},ne=t=>{let a=t.children?t.children({Outlet:J}):null,e=Q(),o=()=>{e.setTheme(e.theme==="dark"?"light":"dark")};return d(At,{className:"astw:flex astw:flex-col",children:g("div",{className:"astw:flex astw:flex-1",children:[t.sidebar??d(Qt,{}),g(Ot,{className:"astw:w-[calc(100%-var(--sidebar-width))]",children:[d("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:[d(ie,{}),d(le,{})]}),d("div",{className:"astw:flex astw:items-center astw:gap-2",children:d(y,{variant:"outline",size:"icon",onClick:o,children:d(se,{})})})]})}),d("div",{className:"astw:flex astw:flex-col astw:gap-4",children:a??d(J,{})})]})]})})},Qt=t=>{let{title:a,icon:e,navItems:o}=R(),{pathname:r}=Jt(),i=g(Dt,{children:[e,d("h1",{className:"astw:text-sm astw:mb-2 astw:mt-2 astw:px-2",children:a})]});return g(Lt,{variant:"inset",children:[g("div",{className:"astw:flex astw:justify-between astw:items-center",children:[t.header??i,d("div",{className:"astw:hidden astw:md:block",children:d(st,{className:"astw:-ml-1"})})]}),d($t,{children:d(jt,{children:d(Wt,{children:o.map(s=>d(kt,{asChild:!0,defaultOpen:s.isActive,children:g(Ut,{children:[s.url?g(Yt,{children:[d(it,{asChild:!0,tooltip:s.title,children:g(D,{to:s.url,className:s.url===r?"astw:bg-sidebar-accent astw:font-medium":void 0,children:[s.icon,d("span",{children:s.title})]})}),!!s.items?.length&&d(Z,{asChild:!0,children:g(nt,{className:"astw:data-[state=open]:rotate-90",children:[d(Xt,{}),d("span",{className:"astw:sr-only",children:"Toggle"})]})})]}):d(Yt,{children:g(Z,{className:"astw:flex astw:w-[100%] astw:[&[data-state=open]_.astw-rotate-target]:rotate-90",children:[d(it,{asChild:!0,tooltip:s.title,children:g("span",{className:"astw:flex astw:w-[100%]",children:[s.icon,d("span",{children:s.title})]})}),!!s.items?.length&&d(nt,{className:"astw-rotate-target",asChild:!0,children:g("span",{children:[d(Xt,{}),d("span",{className:"astw:sr-only",children:"Toggle"})]})})]})}),!!s.items?.length&&d(Pt,{children:d(Ft,{children:s.items?.map(l=>d(Ht,{children:d(Vt,{asChild:!0,children:d(D,{to:l.url,className:l.url===r?"astw:bg-sidebar-accent astw:font-medium":void 0,children:d("span",{children:l.title})})})},l.title))})})]})},s.title))})})}),t.footer??null]})},de=()=>{let{configurations:t}=R(),a=Jt();return Gt(a.pathname,t.basePath,t.modules)},le=()=>{let{basePath:t,segments:a}=de(),e=oe("/:prefix/settings/:suffix");return e?d(dt,{children:d(lt,{children:d("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:d(ct,{children:d(wt,{to:`/${e.params.prefix}/settings`,children:"Settings"})})})})}):d(dt,{children:d(lt,{children:a.map((o,r)=>g("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:[d(ct,{children:d(wt,{to:C(o.path,t),children:o.title})}),r<a.length-1&&d(qt,{})]},r))})})};import{useLocation as Ko,useNavigate as qo,useParams as Go,useSearchParams as Xo,useRouteError as Yo,Link as Jo}from"react-router";import{createContext as we,useCallback as aa,useContext as pe,useEffect as ue,useMemo as me,useState as ge}from"react";import*as I from"oauth4webapi";var $="oauth_pkce_verifier",j="oauth_state",Zt=({apiEndpoint:t,clientId:a,state:e,codeChallenge:o,redirectUri:r})=>{let i=new URL(`${t}/oauth2/authorize`);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",a),i.searchParams.set("redirect_uri",r??window.location.origin),i.searchParams.set("scope","openid profile email"),i.searchParams.set("state",e),i.searchParams.set("code_challenge",o),i.searchParams.set("code_challenge_method","S256"),i.toString()},ce=async({code:t,returnedState:a,apiEndpoint:e,clientId:o,redirectUri:r})=>{let i=sessionStorage.getItem($),n=sessionStorage.getItem(j);if(!t||!a||!i||!n){let l=[];throw t||l.push("code"),a||l.push("returnedState"),i||l.push("code_verifier"),n||l.push("expectedState"),new Error(`Missing params: ${l.join(", ")}`)}if(a!==n)throw new Error("State mismatch: possible CSRF attack");let s=new URLSearchParams({grant_type:"authorization_code",client_id:o,code:t,redirect_uri:r??window.location.origin,code_verifier:i});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:s.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($,t),sessionStorage.setItem(j,e),{codeChallenge:a,state:e}},Eo=async({currentUrl:t,apiEndpoint:a,clientId:e,redirectUri:o})=>{try{let r=t.searchParams.get("code"),i=t.searchParams.get("state");await ce({apiEndpoint:a,clientId:e,code:r,returnedState:i,redirectUri:o})}catch(r){console.error(r)}finally{sessionStorage.removeItem($),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 fe}from"react/jsx-runtime";var ea=we(void 0),be=()=>{let t=pe(ea);if(t===void 0)throw new Error("useBuiltinIdpAuth must be used within an BuiltinIdPAuthContextProvider");return t},he=({apiEndpoint:t,clientId:a,redirectUri:e,children:o})=>{let[r,i]=ge(!1),n=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]);ue(()=>{(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?i(!0):n()})()},[t,n]);let s=aa(async()=>{sessionStorage.removeItem($),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 fe(ea.Provider,{value:me(()=>({login:n,logout:s}),[n,s]),children:r?o:null})};export{Da as AppShell,he as BuiltinIdPAuthProvider,Qt as DefaultSidebar,Jo as Link,j as OAUTH_STATE_KEY,$ as PKCE_VERIFIER_KEY,ne as SidebarLayoutContainer,Zt as buildAuthorizationUrl,fa as defineModule,va as defineResource,ce as exchangeCodeForToken,Eo as handleOAuthCallback,ta as prepareLogin,ha as redirectToResource,R as useAppShell,be as useBuiltinIdpAuth,Ko as useLocation,qo as useNavigate,Go as useParams,Yo as useRouteError,Xo as useSearchParams,Q as useTheme};
|
|
1
|
+
import{Table as Ia}from"lucide-react";import{useEffect as _a,useMemo as Aa,useState as La}from"react";import{createContext as ea,useContext as ra}from"react";var X=ea({navItems:[],configurations:{modules:[],settingsResources:[]}}),R=()=>ra(X);import{createBrowserRouter as va,RouterProvider as xa,Navigate as ya,redirect as Ca,Outlet as ka}from"react-router";import{NavLink as ca,Outlet as wt}from"react-router";import{Toaster as wa}from"sonner";import{Slot as ia}from"@radix-ui/react-slot";import{cva as na}from"class-variance-authority";import{clsx as oa}from"clsx";import{twMerge as sa}from"tailwind-merge";function c(...t){return sa(oa(t))}import{jsx as la}from"react/jsx-runtime";var da=na("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:o=!1,...r}){return la(o?ia:"button",{"data-slot":"button",className:c(da({variant:a,size:e,className:t})),...r})}import{Fragment as pa,jsx as h,jsxs as _}from"react/jsx-runtime";var U=({contentBorder:t,children:a})=>h("div",{className:t?"astw:p-4 astw:rounded-sm astw:border astw:shadow-xs":"",children:a}),pt=()=>_(U,{contentBorder:!0,children:[h("p",{className:"astw:font-semibold astw:leading-none astw:tracking-tight",children:"Welcome to AppShell"}),h("p",{className:"pt-4",children:"Add your GraphQL resources from configuration at first!"})]}),Y=()=>_(pa,{children:[h(wt,{}),h(wa,{})]}),ut=()=>{let{configurations:t}=R();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:[h("div",{children:_("nav",{className:"astw:bg-card astw:md:w-xs astw:rounded-md astw:border astw:p-3 astw:shadow-xs",children:[h("h2",{className:"astw:text-sm astw:leading-[36px] astw:mb-2 astw:font-bold ",children:"Settings"}),h("ul",{className:"astw:flex astw:flex-col astw:gap-1",children:t.settingsResources.map(a=>h("li",{children:h(ca,{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))})]})}),h("section",{className:"astw:bg-card astw:flex-1 astw:rounded-md astw:border astw:shadow-xs",children:h(wt,{})})]})};import{useRouteError as ua,isRouteErrorResponse as ma}from"react-router";import{AlertCircle as mt}from"lucide-react";import{jsx as x,jsxs as F}from"react/jsx-runtime";var gt=()=>{let t=ua();if(ma(t)&&t.status===404)return x("div",{className:"astw:p-6",children:F("div",{className:"astw:flex astw:items-start astw:gap-4",children:[x(mt,{className:"astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5"}),F("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:F("div",{className:"astw:flex astw:items-start astw:gap-4",children:[x(mt,{className:"astw:h-5 astw:w-5 astw:text-destructive astw:flex-shrink-0 astw:mt-0.5"}),F("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{capitalCase as bt}from"change-case";import{redirect as ga}from"react-router";var C=(t,a)=>a?`/${a}/${t}`:`/${t}`;import{jsx as ht}from"react/jsx-runtime";function ba(t){return{redirectTo:t}}function H(t){return typeof t=="object"&&t!==null&&"redirectTo"in t}function ha(t){let{path:a,meta:e,component:o,resources:r,errorBoundary:d}=t,i=e?.title??bt(a),s=H(o)?{component:()=>null,loader:n=>ga(C(o.redirectTo,n))}:{component:()=>ht(U,{contentBorder:e?.contentBorder??!1,children:o({title:i,resources:r})})};return{path:a,type:"component",_type:"module",...s,meta:{title:i,...e?.breadcrumbTitle!==void 0?{breadcrumbTitle:e.breadcrumbTitle}:{},...e,menuItemClickable:!H(o),icon:t.meta?.icon},resources:r,errorBoundary:d}}function fa(t){let{path:a,component:e,subResources:o,meta:r,errorBoundary:d}=t,i=r?.title??bt(a);return{_type:"resource",type:"component",path:a,meta:{title:i,icon:r?.icon,...r?.breadcrumbTitle!==void 0?{breadcrumbTitle:r.breadcrumbTitle}:{}},component:()=>ht(U,{contentBorder:r?.contentBorder??!1,children:e({title:i,resources:o})}),subResources:o,errorBoundary:d}}import{Fragment as Sa,jsx as A}from"react/jsx-runtime";var V=t=>()=>A(Sa,{children:t}),Pa=(t,a,e)=>t.reduce((o,r)=>{let d=r.errorBoundary||e,i={index:!0,Component:r.component,...r.loader&&{loader:()=>r.loader(a)}};return[...o,{path:r.path,...d&&{ErrorBoundary:V(d)},...r.resources&&r.resources.length>0?{children:[i,...r.resources.map(s=>ft(s,d))]}:{children:[i]}}]},[]),ft=(t,a)=>{let e=t.errorBoundary||a,o={index:!0,Component:t.component};return{path:t.path,...t.errorBoundary&&{ErrorBoundary:V(t.errorBoundary)},...t.subResources&&t.subResources.length>0?{children:[o,...t.subResources.map(r=>ft(r,e))]}:{children:[o]}}},vt=t=>{let{configurations:a}=R(),{rootComponent:e}=t,o=a.errorBoundary===void 0?A(gt,{}):a.errorBoundary,r=H(e)?{index:!0,loader:()=>Ca(C(e.redirectTo,a.basePath))}:{index:!0,Component:e??pt},d=a.settingsResources.length>0?[{path:"settings",index:!0,Component:()=>A(ya,{to:a.settingsResources[0].path,relative:"path",replace:!0})},{path:"settings",Component:ut,children:a.settingsResources.map(n=>({path:n.path,Component:n.component,...n.errorBoundary&&{ErrorBoundary:V(n.errorBoundary)}}))}]:[],i=[r,{path:"/",children:Pa(a.modules,a.basePath,o)},...d,{path:"*",loader:()=>{throw new Response("Not Found",{status:404})}}],s=va([{path:a.basePath,element:t.children,children:o?[{element:A(ka,{}),ErrorBoundary:V(o),children:i}]:i}]);return A(xa,{router:s})};import{createContext as Ra,useContext as Ta,useEffect as Na,useMemo as za,useState as Ba}from"react";import{jsx as Ea}from"react/jsx-runtime";var Ma={resolvedTheme:"light",theme:"system",setTheme:()=>null},xt=Ra(Ma);function yt({children:t,storageKey:a,defaultTheme:e="system",...o}){let[r,d]=Ba(()=>localStorage.getItem(a)||e),i=za(()=>r!=="system"?r:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[r]);Na(()=>{let n=window.document.documentElement;n.classList.remove("light","dark"),n.classList.add(i)},[i]);let s={resolvedTheme:i,theme:r,setTheme:n=>{localStorage.setItem(a,n),d(n)}};return Ea(xt.Provider,{...o,value:s,children:t})}var J=()=>{let t=Ta(xt);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};import{jsx as K}from"react/jsx-runtime";var Oa=t=>{let[a,e]=La(!1);_a(function(){e(!0)},[]);let o=t.configurations.basePath,r=Aa(()=>t.configurations.modules.map(i=>{let s=i.resources.map(n=>({title:n.meta.title,url:C(`${i.path}/${n.path}`,o)}));return{title:i.meta.title,url:i.meta.menuItemClickable?C(i.path,o):void 0,clickable:i.component,icon:i.meta.icon||K(Ia,{}),isActive:!0,items:s}}),[t.configurations.modules,o]);return a?K(X.Provider,{value:{title:t.title,icon:t.icon,configurations:{modules:t.configurations.modules,settingsResources:t.configurations.settingsResources??[],errorBoundary:t.configurations.errorBoundary,basePath:o},navItems:r},children:K(yt,{defaultTheme:"system",storageKey:"appshell-ui-theme",children:K(vt,{rootComponent:t.configurations.rootComponent,children:t.children})})}):null};import*as B from"@radix-ui/react-collapsible";import{jsx as Z}from"react/jsx-runtime";function Ct({...t}){return Z(B.Root,{"data-slot":"collapsible",...t})}function Q({...t}){return Z(B.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function kt({...t}){return Z(B.CollapsibleContent,{"data-slot":"collapsible-content",...t})}import{useLocation as Yt,useMatch as re}from"react-router";import*as b from"react";import{Slot as rt}from"@radix-ui/react-slot";import{cva as Fa}from"class-variance-authority";import{PanelLeftIcon as Ha}from"lucide-react";import*as q from"react";var tt=768;function Pt(){let[t,a]=q.useState(void 0);return q.useEffect(()=>{let e=window.matchMedia(`(max-width: ${tt-1}px)`),o=()=>{a(window.innerWidth<tt)};return e.addEventListener("change",o),a(window.innerWidth<tt),()=>e.removeEventListener("change",o)},[]),!!t}import{jsx as Pr}from"react/jsx-runtime";import*as Da from"@radix-ui/react-separator";import{jsx as Nr}from"react/jsx-runtime";import*as m from"@radix-ui/react-dialog";import{XIcon as $a}from"lucide-react";import{jsx as k,jsxs as at}from"react/jsx-runtime";function St({...t}){return k(m.Root,{"data-slot":"sheet",...t})}function ja({...t}){return k(m.Portal,{"data-slot":"sheet-portal",...t})}function Wa({className:t,...a}){return k(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 Rt({className:t,children:a,side:e="right",...o}){return at(ja,{children:[k(Wa,{}),at(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),...o,children:[a,at(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:[k($a,{className:"astw:size-4"}),k("span",{className:"astw:sr-only",children:"Close"})]})]})]})}function Tt({className:t,...a}){return k("div",{"data-slot":"sheet-header",className:c("astw:flex astw:flex-col astw:gap-1.5 astw:p-4",t),...a})}function Nt({className:t,...a}){return k(m.Title,{"data-slot":"sheet-title",className:c("astw:text-foreground astw:font-semibold",t),...a})}function zt({className:t,...a}){return k(m.Description,{"data-slot":"sheet-description",className:c("astw:text-muted-foreground astw:text-sm",t),...a})}import{jsx as Lr}from"react/jsx-runtime";import*as f from"@radix-ui/react-tooltip";import{jsx as M,jsxs as Ua}from"react/jsx-runtime";function et({delayDuration:t=0,...a}){return M(f.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function Bt({...t}){return M(et,{children:M(f.Root,{"data-slot":"tooltip",...t})})}function Mt({...t}){return M(f.Trigger,{"data-slot":"tooltip-trigger",...t})}function Et({className:t,sideOffset:a=0,children:e,...o}){return M(f.Portal,{children:Ua(f.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),...o,children:[e,M(f.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 L}from"react/jsx-runtime";var Va="sidebar_state",Ka=60*60*24*7,qa="16rem",Ga="18rem",Xa="3rem",Ya="b",It=b.createContext(null);function O(){let t=b.useContext(It);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function _t({defaultOpen:t=!0,open:a,onOpenChange:e,className:o,style:r,children:d,...i}){let s=Pt(),[n,p]=b.useState(!1),[u,T]=b.useState(t),P=a??u,N=b.useCallback(v=>{let S=typeof v=="function"?v(P):v;e?e(S):T(S),document.cookie=`${Va}=${S}; path=/; max-age=${Ka}`},[e,P]),z=b.useCallback(()=>s?p(v=>!v):N(v=>!v),[s,N,p]);b.useEffect(()=>{let v=S=>{S.key===Ya&&(S.metaKey||S.ctrlKey)&&(S.preventDefault(),z())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[z]);let G=P?"expanded":"collapsed",W=b.useMemo(()=>({state:G,open:P,setOpen:N,isMobile:s,openMobile:n,setOpenMobile:p,toggleSidebar:z}),[G,P,N,s,n,p,z]);return w(It.Provider,{value:W,children:w(et,{delayDuration:0,children:w("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":qa,"--sidebar-width-icon":Xa,...r},className:c("astw:group/sidebar-wrapper astw:has-data-[variant=inset]:bg-sidebar astw:flex astw:min-h-svh astw:w-full",o),...i,children:d})})})}function At({side:t="left",variant:a="sidebar",collapsible:e="offcanvas",className:o,children:r,...d}){let{isMobile:i,state:s,openMobile:n,setOpenMobile:p}=O();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",o),...d,children:r}):i?w(St,{open:n,onOpenChange:p,...d,children:L(Rt,{"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":Ga},side:t,children:[L(Tt,{className:"astw:sr-only",children:[w(Nt,{children:"Sidebar"}),w(zt,{children:"Displays the mobile sidebar."})]}),w("div",{className:"flex h-full w-full flex-col",children:r})]})}):L("div",{className:"astw:group astw:peer astw:text-sidebar-foreground astw:hidden astw:md:block","data-state":s,"data-collapsible":s==="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",o),...d,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:r})})]})}function ot({className:t,onClick:a,...e}){let{toggleSidebar:o}=O();return L(y,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:c("astw:text-muted-foreground",t),onClick:r=>{a?.(r),o()},...e,children:[w(Ha,{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 Ot({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 Dt({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 $t({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 jt({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 Wt({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 Ja=Fa("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 st({asChild:t=!1,isActive:a=!1,variant:e="default",size:o="default",tooltip:r,className:d,...i}){let s=t?rt:"button",{isMobile:n,state:p}=O(),u=w(s,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":o,"data-active":a,className:c(Ja({variant:e,size:o}),d),...i});return r?(typeof r=="string"&&(r={children:r}),L(Bt,{children:[w(Mt,{asChild:!0,children:u}),w(Et,{side:"right",align:"center",hidden:p!=="collapsed"||n,...r})]})):u}function it({className:t,asChild:a=!1,showOnHover:e=!1,...o}){return w(a?rt:"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),...o})}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 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 Ht({asChild:t=!1,size:a="md",isActive:e=!1,className:o,...r}){return w(t?rt:"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",o),...r})}import{ChevronRight as Gt,SunIcon as oe}from"lucide-react";import{Slot as te}from"@radix-ui/react-slot";import{ChevronRight as ae,MoreHorizontal as co}from"lucide-react";import{Link as Qa,useHref as Za}from"react-router";import{jsx as Vt}from"react/jsx-runtime";function D({to:t,children:a,...e}){try{return Za(t),Vt(Qa,{to:t,...e,children:a})}catch{return Vt("a",{href:t,...e,children:a})}}import{jsx as E,jsxs as mo}from"react/jsx-runtime";function nt({...t}){return E("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...t})}function dt({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 lt({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 ct({asChild:t,className:a,children:e,...o}){return E(t?te:D,{"data-slot":"breadcrumb-link",className:c("astw:hover:text-foreground astw:transition-colors",a),...o,children:e})}function Kt({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(ae,{})})}var ee=t=>t.reduce((a,e)=>{a[e.path]={title:e.meta.title,breadcrumbTitle:e.meta.breadcrumbTitle};let o=(r,d)=>{!r||r.length===0||r.forEach(i=>{let s=`${d}/${i.path}`;a[s]={title:i.meta.title,breadcrumbTitle:i.meta.breadcrumbTitle},i.subResources&&i.subResources.length>0&&o(i.subResources,s)})};return e.resources&&e.resources.length>0&&o(e.resources,e.path),a},{});function qt(t,a,e){let o=t.split("/").filter(s=>s!=="").slice(1),r=a?(()=>{let[s,...n]=o;return n})():o,d=ee(e),i=r.map((s,n)=>{let p=r.slice(0,n+1).join("/"),u=d[p];if(!u){let P=Object.entries(d).find(([N])=>{let z=N.split("/").map(W=>W.startsWith(":")?"[^/]+":W).join("/");return new RegExp(`^${z}$`).test(p)})?.[1];P&&(u=P)}let T;return u?typeof u.breadcrumbTitle=="function"?T=u.breadcrumbTitle(s):typeof u.breadcrumbTitle=="string"?T=u.breadcrumbTitle:T=u.title:T=decodeURIComponent(s),{segment:s,path:p,title:T}});return{basePath:a||null,segments:i}}import{Fragment as Xt,jsx as l,jsxs as g}from"react/jsx-runtime";var se=()=>{let{open:t}=O();return l("div",{className:t?"astw:md:hidden":void 0,children:l(ot,{className:"astw:-ml-2.5"})})},ie=t=>{let a=t.children?t.children({Outlet:Y}):null,e=J(),o=()=>{e.setTheme(e.theme==="dark"?"light":"dark")};return l(_t,{className:"astw:flex astw:flex-col",children:g("div",{className:"astw:flex astw:flex-1",children:[t.sidebar??l(Jt,{}),g(Lt,{className:"astw:w-[calc(100%-var(--sidebar-width))]",children:[l("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:[l(se,{}),l(de,{})]}),l("div",{className:"astw:flex astw:items-center astw:gap-2",children:l(y,{variant:"outline",size:"icon",onClick:o,children:l(oe,{})})})]})}),l("div",{className:"astw:flex astw:flex-col astw:gap-4",children:a??l(Y,{})})]})]})})},Jt=t=>{let{title:a,icon:e,navItems:o}=R(),{pathname:r}=Yt(),d=g(Ot,{children:[e,l("h1",{className:"astw:text-sm astw:mb-2 astw:mt-2 astw:px-2",children:a})]});return g(At,{variant:"inset",children:[g("div",{className:"astw:flex astw:justify-between astw:items-center",children:[t.header??d,l("div",{className:"astw:hidden astw:md:block",children:l(ot,{className:"astw:-ml-1"})})]}),l(Dt,{children:l($t,{children:l(jt,{children:o.map(s=>l(Ct,{asChild:!0,defaultOpen:s.isActive,children:g(Wt,{children:[s.url?g(Xt,{children:[l(st,{asChild:!0,tooltip:s.title,children:g(D,{to:s.url,className:s.url===r?"astw:bg-sidebar-accent astw:font-medium":void 0,children:[s.icon,l("span",{children:s.title})]})}),!!s.items?.length&&l(Q,{asChild:!0,children:g(it,{className:"astw:data-[state=open]:rotate-90",children:[l(Gt,{}),l("span",{className:"astw:sr-only",children:"Toggle"})]})})]}):l(Xt,{children:g(Q,{className:"astw:flex astw:w-[100%] astw:[&[data-state=open]_.astw-rotate-target]:rotate-90",children:[l(st,{asChild:!0,tooltip:s.title,children:g("span",{className:"astw:flex astw:w-[100%]",children:[s.icon,l("span",{children:s.title})]})}),!!s.items?.length&&l(it,{className:"astw-rotate-target",asChild:!0,children:g("span",{children:[l(Gt,{}),l("span",{className:"astw:sr-only",children:"Toggle"})]})})]})}),!!s.items?.length&&l(kt,{children:l(Ut,{children:s.items?.map(n=>l(Ft,{children:l(Ht,{asChild:!0,children:l(D,{to:n.url,className:n.url===r?"astw:bg-sidebar-accent astw:font-medium":void 0,children:l("span",{children:n.title})})})},n.title))})})]})},s.title))})})}),t.footer??null]})},ne=()=>{let{configurations:t}=R(),a=Yt();return qt(a.pathname,t.basePath,t.modules)},de=()=>{let{basePath:t,segments:a}=ne(),e=re("/:prefix/settings/:suffix");return e?l(nt,{children:l(dt,{children:l("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:l(lt,{children:l(ct,{to:`/${e.params.prefix}/settings`,children:"Settings"})})})})}):l(nt,{children:l(dt,{children:a.map((o,r)=>g("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:[l(lt,{children:l(ct,{to:C(o.path,t),children:o.title})}),r<a.length-1&&l(Kt,{})]},r))})})};import{useLocation as Vo,useNavigate as Ko,useParams as qo,useSearchParams as Go,useRouteError as Xo,Link as Yo}from"react-router";import{createContext as ce,useCallback as ta,useContext as we,useEffect as pe,useMemo as ue,useState as me}from"react";import*as I from"oauth4webapi";var $="oauth_pkce_verifier",j="oauth_state",Qt=({apiEndpoint:t,clientId:a,state:e,codeChallenge:o,redirectUri:r})=>{let d=new URL(`${t}/oauth2/authorize`);return d.searchParams.set("response_type","code"),d.searchParams.set("client_id",a),d.searchParams.set("redirect_uri",r??window.location.origin),d.searchParams.set("scope","openid profile email"),d.searchParams.set("state",e),d.searchParams.set("code_challenge",o),d.searchParams.set("code_challenge_method","S256"),d.toString()},le=async({code:t,returnedState:a,apiEndpoint:e,clientId:o,redirectUri:r})=>{let d=sessionStorage.getItem($),i=sessionStorage.getItem(j);if(!t||!a||!d||!i){let n=[];throw t||n.push("code"),a||n.push("returnedState"),d||n.push("code_verifier"),i||n.push("expectedState"),new Error(`Missing params: ${n.join(", ")}`)}if(a!==i)throw new Error("State mismatch: possible CSRF attack");let s=new URLSearchParams({grant_type:"authorization_code",client_id:o,code:t,redirect_uri:r??window.location.origin,code_verifier:d});try{let n=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:s.toString()}),{access_token:p}=await n.json();return p}catch(n){throw new Error(`Token exchange failed: ${n instanceof Error?n.message:String(n)}`)}},Zt=async()=>{let t=I.generateRandomCodeVerifier(),a=await I.calculatePKCECodeChallenge(t),e=I.generateRandomState();return sessionStorage.setItem($,t),sessionStorage.setItem(j,e),{codeChallenge:a,state:e}},Mo=async({currentUrl:t,apiEndpoint:a,clientId:e,redirectUri:o})=>{try{let r=t.searchParams.get("code"),d=t.searchParams.get("state");await le({apiEndpoint:a,clientId:e,code:r,returnedState:d,redirectUri:o})}catch(r){console.error(r)}finally{sessionStorage.removeItem($),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 he}from"react/jsx-runtime";var aa=ce(void 0),ge=()=>{let t=we(aa);if(t===void 0)throw new Error("useBuiltinIdpAuth must be used within an BuiltinIdPAuthContextProvider");return t},be=({apiEndpoint:t,clientId:a,redirectUri:e,children:o})=>{let[r,d]=me(!1),i=ta(async()=>{let{codeChallenge:n,state:p}=await Zt(),u=Qt({apiEndpoint:t,clientId:a,codeChallenge:n,state:p,redirectUri:e});window.location.href=u},[t,a,e]);pe(()=>{(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?d(!0):i()})()},[t,i]);let s=ta(async()=>{sessionStorage.removeItem($),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(n){console.error(n)}},[t]);return he(aa.Provider,{value:ue(()=>({login:i,logout:s}),[i,s]),children:r?o:null})};export{Oa as AppShell,be as BuiltinIdPAuthProvider,Jt as DefaultSidebar,Yo as Link,j as OAUTH_STATE_KEY,$ as PKCE_VERIFIER_KEY,ie as SidebarLayoutContainer,Qt as buildAuthorizationUrl,ha as defineModule,fa as defineResource,le as exchangeCodeForToken,Mo as handleOAuthCallback,Zt as prepareLogin,ba as redirectToResource,R as useAppShell,ge as useBuiltinIdpAuth,Vo as useLocation,Ko as useNavigate,qo as useParams,Xo as useRouteError,Go as useSearchParams,J as useTheme};
|