1import{aJ as A,r as s,j as e,aG as V,w as o,c6 as W,c7 as $,c8 as q,c9 as J,B as X,ca as Y,cb as Z,cc as Q,cd as y,c5 as ee,b0 as T,b1 as ae,ce as I,z as te,bF as re,cf as O,P as se,cg as ie}from"./index-DSUwSCTj.js";import{I as ne}from"./input-Dz-UFTBa.js";import{S as z}from"./skeleton-4QRnOWKS.js";import{S as de}from"./shield-check-B9AqX_6Z.js";import{L as oe}from"./log-out-DMhrUbQE.js";import{F as le}from"./folder-open-qVmXv1X0.js";import{U as ce}from"./users-19SJu4Cp.js";import{u as ue}from"./useAdminGuard-DCwxu-CY.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const be=A("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const pe=A("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const fe=A("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);var me="Separator",E="horizontal",xe=["horizontal","vertical"],B=s.forwardRef((t,a)=>{const{decorative:r,orientation:i=E,...n}=t,d=he(i)?i:E,p=r?{role:"none"}:{"aria-orientation":d==="vertical"?d:void 0,role:"separator"};return e.jsx(V.div,{"data-orientation":d,...p,...n,ref:a})});B.displayName=me;function he(t){return xe.includes(t)}var D=B;const L=s.forwardRef(({className:t,orientation:a="horizontal",decorative:r=!0,...i},n)=>e.jsx(D,{ref:n,decorative:r,orientation:a,className:o("shrink-0 bg-border",a==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...i}));L.displayName=D.displayName;const ge="sidebar:state",ve=60*60*24*7,we="16rem",je="18rem",Se="3rem",Ne="b",G=s.createContext(null);function k(){const t=s.useContext(G);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}const P=s.forwardRef(({defaultOpen:t=!0,open:a,onOpenChange:r,className:i,style:n,children:d,...c},p)=>{const u=W(),[m,b]=s.useState(!1),[g,l]=s.useState(t),h=a??g,R=s.useCallback(f=>{const x=typeof f=="function"?f(h):f;r?r(x):l(x),document.cookie=`${ge}=${x}; path=/; max-age=${ve}`},[r,h]),M=s.useCallback(()=>u?b(f=>!f):R(f=>!f),[u,R,b]);s.useEffect(()=>{const f=x=>{x.key===Ne&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),M())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[M]);const C=h?"expanded":"collapsed",U=s.useMemo(()=>({state:C,open:h,setOpen:R,isMobile:u,openMobile:m,setOpenMobile:b,toggleSidebar:M}),[C,h,R,u,m,b,M]);return e.jsx(G.Provider,{value:U,children:e.jsx($,{delayDuration:0,children:e.jsx("div",{style:{"--sidebar-width":we,"--sidebar-width-icon":Se,...n},className:o("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",i),ref:p,...c,children:d})})})});P.displayName="SidebarProvider";const F=s.forwardRef(({side:t="left",variant:a="sidebar",collapsible:r="offcanvas",className:i,children:n,...d},c)=>{const{isMobile:p,state:u,openMobile:m,setOpenMobile:b}=k();return r==="none"?e.jsx("div",{className:o("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",i),ref:c,...d,children:n}):p?e.jsx(q,{open:m,onOpenChange:b,...d,children:e.jsx(J,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":je},side:t,children:e.jsx("div",{className:"flex h-full w-full flex-col",children:n})})}):e.jsxs("div",{ref:c,className:"group peer hidden text-sidebar-foreground md:block","data-state":u,"data-collapsible":u==="collapsed"?r:"","data-variant":a,"data-side":t,children:[e.jsx("div",{className:o("relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",a==="floating"||a==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),e.jsx("div",{className:o("fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",t==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",a==="floating"||a==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",i),...d,children:e.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:n})})]})});F.displayName="Sidebar";const H=s.forwardRef(({className:t,onClick:a,...r},i)=>{const{toggleSidebar:n}=k();return e.jsxs(X,{ref:i,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:o("h-7 w-7",t),onClick:d=>{a==null||a(d),n()},...r,children:[e.jsx(pe,{}),e.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});H.displayName="SidebarTrigger";const ye=s.forwardRef(({className:t,...a},r)=>{const{toggleSidebar:i}=k();return e.jsx("button",{ref:r,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:i,title:"Toggle Sidebar",className:o("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] group-data-[side=left]:-right-4 group-data-[side=right]:left-0 hover:after:bg-sidebar-border sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",t),...a})});ye.displayName="SidebarRail";const ke=s.forwardRef(({className:t,...a},r)=>e.jsx("main",{ref:r,className:o("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-
16h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",t),...a}));ke.displayName="SidebarInset";const Re=s.forwardRef(({className:t,...a},r)=>e.jsx(ne,{ref:r,"data-sidebar":"input",className:o("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",t),...a}));Re.displayName="SidebarInput";const Me=s.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-sidebar":"header",className:o("flex flex-col gap-2 p-2",t),...a}));Me.displayName="SidebarHeader";const _e=s.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-sidebar":"footer",className:o("flex flex-col gap-2 p-2",t),...a}));_e.displayName="SidebarFooter";const Ie=s.forwardRef(({className:t,...a},r)=>e.jsx(L,{ref:r,"data-sidebar":"separator",className:o("mx-2 w-auto bg-sidebar-border",t),...a}));Ie.displayName="SidebarSeparator";const K=s.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-sidebar":"content",className:o("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",t),...a}));K.displayName="SidebarContent";const v=s.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-sidebar":"group",className:o("relative flex w-full min-w-0 flex-col p-2",t),...a}));v.displayName="SidebarGroup";const _=s.forwardRef(({className:t,asChild:a=!1,...r},i)=>{const n=a?y:"div";return e.jsx(n,{ref:i,"data-sidebar":"group-label",className:o("flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",t),...r})});_.displayName="SidebarGroupLabel";const Oe=s.forwardRef(({className:t,asChild:a=!1,...r},i)=>{const n=a?y:"button";return e.jsx(n,{ref:i,"data-sidebar":"group-action",className:o("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",t),...r})});Oe.displayName="SidebarGroupAction";const w=s.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-sidebar":"group-content",className:o("w-full text-sm",t),...a}));w.displayName="SidebarGroupContent";const j=s.forwardRef(({className:t,...a},r)=>e.jsx("ul",{ref:r,"data-sidebar":"menu",className:o("flex w-full min-w-0 flex-col gap-1",t),...a}));j.displayName="SidebarMenu";const S=s.forwardRef(({className:t,...a},r)=>e.jsx("li",{ref:r,"data-sidebar":"menu-item",className:o("group/menu-item relative",t),...a}));S.displayName="SidebarMenuItem";const Ae=ee("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),N=s.forwardRef(({asChild:t=!1,isActive:a=!1,variant:r="default",size:i="default",tooltip:n,className:d,...c},p)=>{const u=t?y:"button",{isMobile:m,state:b}=k(),g=e.jsx(u,{ref:p,"data-sidebar":"menu-button","data-size":i,"data-active":a,className:o(Ae({variant:r,size:i}),d),...c});return n?(typeof n=="string"&&(n={children:n}),e.jsxs(Y,{children:[e.jsx(Z,{asChild:!0,children:g}),e.jsx(Q,{side:"right",align:"center",hidden:b!=="collapsed"||m,...n})]})):g});N.displayName="SidebarMenuButton";const Ce=s.forwardRef(({className:t,asChild:a=!1,showOnHover:r=!1,...i},n)=>{const d=a?y:"button";return e.jsx(d,{ref:n,"data-sidebar":"menu-action",className:o("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform peer-hover/menu-button:text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",t),...i})});Ce.displayName="SidebarMenuAction";const ze=s.forwardRef(({className:t,...a},r)=>e.jsx("div",{ref:r,"data-sidebar":"menu-badge",className:o("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",t),...a}));ze.displayName="SidebarMenuBadge";const Ee=s.forwardRef(({className:t,showIcon:a=!1,...r},i)=>{const n=s.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return e.jsxs("div",{ref:i,"data-sidebar":"menu-skeleton",className:o("flex h-8 items-center gap-2 rounded-md px-2",t),...r,children:[a&&e.jsx(z,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),e.jsx(z,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":n}})]})});
16Ee.displayName="SidebarMenuSkeleton";const Te=s.forwardRef(({className:t,...a},r)=>e.jsx("ul",{ref:r,"data-sidebar":"menu-sub",className:o("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",t),...a}));Te.displayName="SidebarMenuSub";const Be=s.forwardRef(({...t},a)=>e.jsx("li",{ref:a,...t}));Be.displayName="SidebarMenuSubItem";const De=s.forwardRef(({asChild:t=!1,size:a="md",isActive:r,className:i,...n},d)=>{const c=t?y:"a";return e.jsx(c,{ref:d,"data-sidebar":"menu-sub-button","data-size":a,"data-active":r,className:o("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",a==="sm"&&"text-xs",a==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",i),...n})});De.displayName="SidebarMenuSubButton";function Le({email:t,level:a="super_admin",canEdit:r=!0,canViewStats:i=!0}){const{state:n}=k(),d=n==="collapsed",{pathname:c}=T(),p=ae(),u=i?[{title:"Overview",url:"/admin",icon:be,end:!0},{title:"Orders",url:"/admin/orders",icon:fe,end:!0}]:[],m=[...r?[{title:"eBooks",url:"/admin/ebooks",icon:te,end:!0},{title:"Media",url:"/admin/media",icon:le,end:!0}]:[],...i?[{title:"Customers",url:"/admin/ebook-customers",icon:ce,end:!0}]:[]],b=(l,h=!1)=>h?c===l:c.startsWith(l),g=async()=>{await re.auth.signOut(),p("/admin/login",{replace:!0})};return e.jsx(F,{collapsible:"icon",children:e.jsxs(K,{children:[e.jsxs("div",{className:"px-4 py-5 border-b border-border",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.25em] text-accent",style:{fontFamily:"Oswald, sans-serif",fontStyle:"italic"},children:"EBT"}),!d&&e.jsx("p",{className:"text-lg text-foreground uppercase leading-tight",style:{fontFamily:"Oswald, sans-serif",fontWeight:700,fontStyle:"italic"},children:"Admin"})]}),e.jsxs(v,{children:[e.jsx(_,{children:"Store"}),e.jsx(w,{children:e.jsx(j,{children:u.map(l=>e.jsx(S,{children:e.jsx(N,{asChild:!0,isActive:b(l.url,l.end),children:e.jsxs(I,{to:l.url,end:l.end,className:"flex items-center gap-2",children:[e.jsx(l.icon,{className:"h-4 w-4"}),!d&&e.jsx("span",{children:l.title})]})})},l.title))})})]}),e.jsxs(v,{children:[e.jsx(_,{children:"Catalog"}),e.jsx(w,{children:e.jsx(j,{children:m.map(l=>e.jsx(S,{children:e.jsx(N,{asChild:!0,isActive:b(l.url,l.end),children:e.jsxs(I,{to:l.url,end:l.end,className:"flex items-center gap-2",children:[e.jsx(l.icon,{className:"h-4 w-4"}),!d&&e.jsx("span",{children:l.title})]})})},l.title))})})]}),a==="super_admin"&&e.jsxs(v,{children:[e.jsx(_,{children:"Access"}),e.jsx(w,{children:e.jsx(j,{children:e.jsx(S,{children:e.jsx(N,{asChild:!0,isActive:b("/admin/users",!0),children:e.jsxs(I,{to:"/admin/users",end:!0,className:"flex items-center gap-2",children:[e.jsx(de,{className:"h-4 w-4"}),!d&&e.jsx("span",{children:"Users"})]})})})})})]}),e.jsx(v,{className:"mt-auto",children:e.jsxs(w,{children:[e.jsx(j,{children:e.jsx(S,{children:e.jsxs(N,{onClick:g,className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-4 w-4"}),!d&&e.jsx("span",{children:"Sign Out"})]})})}),!d&&t&&e.jsx("p",{className:"px-3 mt-3 text-xs text-muted-foreground truncate",children:t})]})})]})})}const $e=()=>{const{loading:t,isAdmin:a,email:r,level:i,canEdit:n,canViewStats:d}=ue(),{pathname:c}=T();if(t||!a)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})});const p=["/admin","/admin/overview","/admin/orders","/admin/ebook-customers"],u=["/admin/ebooks","/admin/media"];return!d&&p.includes(c)?e.jsx(O,{to:"/admin/ebooks",replace:!0}):!n&&u.includes(c)?e.jsx(O,{to:"/admin/overview",replace:!0}):i!=="super_admin"&&c==="/admin/users"?e.jsx(O,{to:d?"/admin/overview":"/admin/ebooks",replace:!0}):e.jsxs(e.Fragment,{children:[e.jsx(se,{title:"Admin Dashboard",description:"EBT Online admin dashboard"}),e.jsx(P,{children:e.jsxs("div",{className:"min-h-screen flex w-full bg-background",children:[e.jsx(Le,{email:r,level:i,canEdit:n,canViewStats:d}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("header",{className:"h-14 flex items-center border-b border-border bg-card px-4 gap-3",children:[e.jsx(H,{}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:r})]}),e.jsx("main",{className:"flex-1 p-6 md:p-8",children:e.jsx(ie,{c
16ontext:{email:r,level:i,canEdit:n,canViewStats:d}})})]})]})})]})};export{$e as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.