1try{!function(){var e="u">typeof window?window:"u">typeof global?global:"u">typeof globalThis?globalThis:"u">typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="199dd08e-c06e-4280-9e99-4aff5f03146b",e._sentryDebugIdIdentifier="sentry-dbid-199dd08e-c06e-4280-9e99-4aff5f03146b")}()}catch(e){}(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6309],{626:(e,t,s)=>{"use strict";s.d(t,{AM:()=>n,Wv:()=>o,dT:()=>d,hl:()=>m,iN:()=>c});var a=s(62021),r=s(74361),i=s(70249),l=s(70297);let n=i.bL,o=i.l9,d=i.Mz,c=i.bm;i.i3;let m=r.forwardRef(({className:e,align:t="center",sideOffset:s=4,...r},n)=>(0,a.jsx)(i.ZL,{children:(0,a.jsx)(i.UC,{ref:n,align:t,sideOffset:s,className:(0,l.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-[1500] w-72 rounded-md border p-4 shadow-md outline-none",e),...r})}));m.displayName=i.UC.displayName},9608:(e,t,s)=>{"use strict";s.d(t,{E:()=>o});var a=s(62021),r=s(74361),i=s(8771),l=s(70297);let n=(0,i.F)("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",brandSubtle:"border-transparent bg-levPlum-100 text-levPlum-600 shadow-none dark:bg-levPlum-900/50 dark:text-levPlum-300",ghost:"border-transparent bg-transparent text-secondary-foreground hover:bg-secondary/50",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"secondary"}}),o=r.forwardRef(({className:e,variant:t,...s},r)=>(0,a.jsx)("span",{ref:r,className:(0,l.cn)(n({variant:t}),e),...s}));o.displayName="Badge"},13540:(e,t,s)=>{"use strict";s.d(t,{l:()=>i});var a=s(62021),r=s(97250);let i=({label:e,rows:t=8})=>(0,a.jsxs)("div",{className:"flex flex-col gap-6 p-8",role:"status","aria-label":e,children:[(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsx)(r.E,{className:"h-7 w-40"}),(0,a.jsx)(r.E,{className:"h-9 w-72"}),(0,a.jsx)(r.E,{className:"ml-auto h-9 w-24"})]}),(0,a.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border/60",children:[(0,a.jsxs)("div",{className:"flex gap-6 border-b border-border/60 px-5 py-3",children:[(0,a.jsx)(r.E,{className:"h-3 w-24"}),(0,a.jsx)(r.E,{className:"h-3 w-32"}),(0,a.jsx)(r.E,{className:"ml-auto h-3 w-20"})]}),Array.from({length:t},(e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-6 border-b border-border/60 px-5 py-4 last:border-b-0",children:[(0,a.jsx)(r.E,{className:"h-8 w-8 rounded-full"}),(0,a.jsx)(r.E,{className:"h-4 w-1/3"}),(0,a.jsx)(r.E,{className:"h-4 w-1/5"}),(0,a.jsx)(r.E,{className:"ml-auto h-4 w-16"})]},t))]})]})},19845:(e,t,s)=>{"use strict";s.d(t,{p:()=>l});var a=s(62021),r=s(74361),i=s(70297);let l=r.forwardRef(({className:e,type:t,...s},r)=>(0,a.jsx)("input",{type:t,className:(0,i.cn)("border-input file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring aria-[invalid=true]:border-destructive dark:aria-[invalid=true]:border-destructive flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-1 focus-visible:ring-inset focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:border-slate-500",e),ref:r,...s}));l.displayName="Input"},32482:(e,t,s)=>{"use strict";s.d(t,{Z:()=>a});let a=e=>{if(e.includes(",")){let t=e.split(",").map(e=>e.trim()),s=t[0],a=t[1];return s&&a?`${a[0]?.toUpperCase()}${s[0]?.toUpperCase()}`:t[0]?.toUpperCase()||""}let t=e.split(/[\s,]+/).filter(e=>e.length>0).map(e=>e[0]?.toUpperCase());return 3===t.length?(t[0]||"")+(t[2]||""):t.slice(0,2).join("")}},36636:(e,t,s)=>{"use strict";s.d(t,{Fz:()=>d,$b:()=>u,e8:()=>x,Hn:()=>h});var a=s(94889),r=s(27416),i=s(83067);let l=i.fc(a.PollResponseSlotStatus),n=i.Ik({status:l,comment:i.Yj(),start:i.Yj(),end:i.Yj()}),o=i.Ik({name:i.Yj(),cells:i.YO(n),pollResponseId:i.Yj()});
1i.Ik({responses:i.YO(o)});let d={[r.tpq.USER_BOOKED_DIFFERENT_TIME]:"You have already booked a different time. Multiple bookings are not allowed.",[r.tpq.TIME_SLOT_ALREADY_BOOKED]:"This time slot has already been booked. Please select another time.",[r.tpq.TIME_SLOT_MODIFIED]:"That time is no longer available. We've refreshed the available times so you can choose another."};i.Ik({responses:i.YO(o),iana:i.Yj(),originalResponses:i.YO(o)}),i.Ik({pollId:i.Yj()});let c=i.Ik({email:i.Yj()}),m=i.Ik({optionUserId:i.Yj()});i.KC([m,c]);let u="Licenses are not enabled for this team",x="Not enough licenses available";i.YO(i.Ik({date:i.Yj().describe("Date in YYYY-MM-DD format"),iana:i.Yj().describe("IANA time zone")})),i.Ik({schedulingRequest:i.Yj().min(1,"Scheduling request is required"),mentionedEmployees:i.YO(i.Ik({name:i.Yj(),email:i.Yj().email(),id:i.Yj()})),iana:i.Yj().min(1,"IANA timezone is required")}),i.Ik({issueId:i.Yj().min(1,"Issue ID is required"),newStatus:i.fc(a.IssueStatus)}),i.Ik({issueIds:i.YO(i.Yj().min(1)).min(1,"At least one issue ID required")}),i.Ik({schedulingAlertId:i.Yj().min(1,"Scheduling alert ID is required"),deletedEventId:i.Yj().min(1,"Deleted event ID is required")});let h=i.Ik({suggestedMeetingTimes:i.YO(r.yJb),nextHasMoreTimes:i.zM(),hasBlockedCalendars:i.zM()});i.Ik({enabled:i.zM(),sendTime:i.Yj(),dailyDigestIana:i.Yj(),excludedFavoriteCalendarIds:i.YO(i.ai())}).nullable(),i.Ik({enabled:i.zM(),sendTime:i.Yj(),dailyDigestIana:i.Yj(),excludedFavoriteCalendarIds:i.YO(i.ai())})},40479:(e,t,s)=>{"use strict";s.d(t,{Di:()=>m,bq:()=>c,eb:()=>p,gC:()=>h,l6:()=>o,yv:()=>d});var a=s(62021),r=s(74361),i=s(72298),l=s(70297),n=s(88399);let o=i.bL;i.YJ;let d=i.WT,c=r.forwardRef(({className:e,children:t,...s},r)=>(0,a.jsxs)(i.l9,{ref:r,className:(0,l.cn)("border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring aria-[invalid=true]:border-destructive dark:aria-[invalid=true]:border-destructive flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-inset disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-500 [&>span]:line-clamp-1",e),...s,children:[t,(0,a.jsx)(i.In,{asChild:!0,children:(0,a.jsx)(n.D3D,{className:"h-4 w-4 opacity-50"})})]}));c.displayName=i.l9.displayName;let m=r.forwardRef(({className:e,children:t,...s},r)=>(0,a.jsx)(i.l9,{ref:r,className:(0,l.cn)(e),...s,children:t}));m.displayName=i.l9.displayName;let u=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i.PP,{ref:s,className:(0,l.cn)("flex cursor-default items-center justify-center py-1",e),...t,children:(0,a.jsx)(n.Mtm,{className:"h-4 w-4"})}));u.displayName=i.PP.displayName;let x=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i.wn,{ref:s,className:(0,l.cn)("flex cursor-default items-center justify-center py-1",e),...t,children:(0,a.jsx)(n.D3D,{className:"h-4 w-4"})}));x.displayName=i.wn.displayName;let h=r.forwardRef(({className:e,children:t,position:s="popper",...r},n)=>(0,a.jsx)(i.ZL,{children:(0,a.jsxs)(i.UC,{ref:n,className:(0,l.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-[1500] max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md","popper"===s&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,...r,children:[(0,a.jsx)(u,{}),(0,a.jsx)(i.LM,{className:(0,l.cn)("p-1","popper"===s&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),(0,a.jsx)(x,{})]})}));h.displayName=i.UC.displayName,r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i.JU,{ref:s,className:(0,l.cn)("px-2 py-1.5 text-sm font-semibold",e),...t})).displayName=i.JU.displayName;let p=r.forwardRef(({className:e,children:t,...s},r)=>(0,a.jsxs)(i.q7,{ref:r,className:(0,l.cn)("focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...s,children:[(0,a.jsx)("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,a.jsx)(i.VF,{children:(0,a.jsx)(n.Srz,{className:"h-4 w-4"})})}),(0,a.jsx)(i.p4,{children:t})]}));p.displayName=i.q7.displayName,r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i.wv,{ref:s,className:(0,l.cn)("bg-muted -mx-1 my-1 h-px",e),...t})).displayName=i.wv.displayName},46343:(e,t,s)=>{"use strict";s.d(t,{$:()=>c,r:()=>d});var a=s(62021),r=s(74361),i=s(80193),l=s(8771),n=s(72976),o=s(70297);let d=(0,l.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-buttonPrimary text-buttonPrimary-foreground shadow hover:bg-buttonPrimary-hover",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-primary/50 text-secondary-foreground bg-background shadow-sm hover:bg-accent hover:text-accent-foreground hover:border-accent",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"text-secondary-foreground hover:bg-accent hover:text-accent-foreground",ghostPurple:"bg-buttonGhostPurple text-buttonGhostPurple-foreground hover:bg-buttonGhostPurple-hover",link:"text-primary underline-offset-4 hover:underline",destructiveOutline:"border border-destructive text-destructive bg-background shadow-sm hover:border-destructive hover:bg-destructive/10 hover:text-destructive dark:border-red-400 dark:text-red-400 dark:hover:border-red-400 dark:hover:text-red-400",outlinePurple:"border border-buttonOutlinePurple-border bg-background text-buttonOutlinePurple-foreground shadow-sm hover:bg-buttonOutlinePurple-hover hover:border-buttonOutlinePurple-hover-border hover:text-buttonOutlinePurple-hover-foreground"},size:{default:"h-9 px-4 py-2",xs:"h-6 px-2 py-1 text-xs",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9",iconMd:"h-8 w-8",iconSm:"h-6 w-6",iconXs:"h-4 w-4"}},defaultVariants:{variant:"default",size:"default"}}),c=r.forwardRef(({className:e,variant:t,size:s,asChild:r=!1,isLoading:l,children:c,...m},u)=>r?(0,a.jsx)(i.DX,{className:(0,o.cn)(d({variant:t,size:s,className:e})),ref:u,...m,children:c}):(0,a.jsxs)("button",{className:(0,o.cn)(d({variant:t,size:s,className:e})),ref:u,...m,disabled:l||m.disabled,"aria-busy":l||void 0,children:[l&&(0,a.jsx)(n.A,{className:"animate-spin","aria-hidden":"true"}),c]}));c.displayName="Button"},49933:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin",function(){return s(78685)}])},53038:(e,t,s)=>{"use strict";s.d(t,{$:()=>b,Cy:()=>g,NB:()=>p,PI:()=>v,Qm:()=>r,XP:()=>h,rI:()=>u});var a=s(42420);let r=e=>{navigator.sendBeacon("/api/auditlog/send",JSON.stringify(e))},i=e=>/^rgba?\(/.test(e)?(e=>{let t=e.trim();if("#"===t[0])return 4===t.length?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`:t;let s=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*([0-9.]+))?\s*\)$/i.exec(t);if(!s)return null;let a=Number(s[1]),r=Number(s[2]),i=Number(s[3]),l=void 0===s[4]?1:Number(s[4]);return l<1&&(a=Math.round(a*l+255*(1-l)),r=Math.round(r*l+255*(1-l)),i=Math.round(i*l+255*(1-l))),`#${a.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`})(e)??e:e,l=new Set(["-webkit-text-fill-color"]),n=e=>{let t=globalThis.getComputedStyle(e),s="";for(let a=0;a<t.length;a++){let r=t[a];if(!r||l.has(r))continue;if("color"===r){let t=e.style.color;t&&(s+=`color:${i(t)};`);continue}let n=t.getPropertyValue(r);n=i(n),s+=`${r}:${n};`}return s},o=(e,t)=>{let s=n(e);for(let[a,r]of(t.setAttribute("style",s),t.removeAttribute("class"),[...e.children].entries()))if(r instanceof HTMLElement){let e=[...t.children][a];if(!(e instanceof HTMLElement))continue;o(r,e)}},d=(e,t)=>{let s=e.textContent??"",a=e===t.startContainer?t.startOffset:0,r=e===t.endContainer?t.endOffset:s.length;return s.slice(a,r)},c=e=>{let t=e.cloneNode(!1);if(!(t instanceof HTMLElement))throw TypeError("Expected HTMLElement clone for clipboard selection serialization");return t.setAttribute("style",n(e)),t.removeAttribute("class"),t},m=(e,t,s)=>{for(let a of e.childNodes){if(!t.intersectsNode(a))continue;if(a instanceof Text){let e=d(a,t);
1if(!e)continue;s.append(s.ownerDocument.createTextNode(e));continue}if(!(a instanceof HTMLElement))continue;let e=c(a);m(a,t,e),0!==e.childNodes.length&&s.append(e)}},u=e=>{let t=new DOMParser().parseFromString(e,"text/html");for(let e of t.querySelectorAll("a"))(e.getAttribute("href")??"").includes("gridPlaceholder=true")&&e.replaceWith(e.textContent??"");return t.body.innerHTML},x=e=>{let t=document.documentElement,s=t.classList.contains("dark"),a=t.style.colorScheme;s&&t.classList.remove("dark"),t.style.colorScheme="light";try{return e()}finally{s&&t.classList.add("dark"),t.style.colorScheme=a}},h=e=>e?x(()=>(e=>{if(!e)return"";let t=e.cloneNode(!0);return t instanceof HTMLElement?(o(e,t),t.outerHTML):""})(e)):"",p=(e,t)=>x(()=>{let s;return s=e.ownerDocument.createElement("div"),m(e,t,s),s.firstChild?s.outerHTML:""}),f=async e=>new Promise((t,s)=>{let a=new FileReader;a.addEventListener("load",()=>{if("string"==typeof a.result){let e=a.result.split(",")[1];if(!e)return void s(Error("Failed to read file"));t(e)}else s(Error("Failed to read file"))}),a.addEventListener("error",()=>s(a.error)),a.readAsDataURL(e)}),g=async e=>await Promise.all(e.map(async e=>{let t=await f(e);return{"@odata.type":"#microsoft.graph.fileAttachment",name:e.name,contentBytes:t,contentType:e.type}})),b=e=>e.replaceAll(/[\t\n\f\r ]+/g," ").trim(),v=(e,t=new Date)=>{if(!e)return"";let s="",r=e instanceof Date?e:new Date(e),i=r>t;let l=(s=(0,a.B)(r,t,{addSuffix:!1})).includes("about")?s.split("about ")[1]:s;return i?`in ${l}`:`${l} ago`}},64599:()=>{},70382:(e,t,s)=>{"use strict";s.d(t,{C:()=>d,z:()=>o});var a=s(62021),r=s(74361),i=s(41501),l=s(70297),n=s(88399);let o=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i.bL,{className:(0,l.cn)("grid gap-2",e),...t,ref:s}));o.displayName=i.bL.displayName;let d=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i.q7,{ref:s,className:(0,l.cn)("border-primary text-primary focus-visible:ring-ring aspect-square h-4 w-4 rounded-full border shadow focus:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:(0,a.jsx)(i.C1,{className:"flex items-center justify-center",children:(0,a.jsx)(n.RiX,{className:"fill-primary h-3.5 w-3.5"})})}));d.displayName=i.q7.displayName},73801:(e,t,s)=>{"use strict";s.d(t,{T:()=>l});var a=s(62021),r=s(74361),i=s(70297);let l=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)("textarea",{className:(0,i.cn)("border-input placeholder:text-muted-foreground focus-visible:ring-ring aria-[invalid=true]:border-destructive dark:aria-[invalid=true]:border-destructive flex min-h-[60px] w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-sm focus-visible:ring-1 focus-visible:ring-inset focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:border-slate-500",e),ref:s,...t}));l.displayName="Textarea"},78288:(e,t,s)=>{"use strict";s.d(t,{BK:()=>c,Ni:()=>u,eu:()=>d,q5:()=>m});var a=s(62021),r=s(74361),i=s(82114),l=s(98105),n=s(32482),o=s(70297);let d=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i.bL,{ref:s,className:(0,o.cn)("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full [container-type:inline-size]",e),...t}));d.displayName=i.bL.displayName;let c=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i._V,{ref:s,className:(0,o.cn)("aspect-square h-full w-full",e),...t}));c.displayName=i._V.displayName;let m=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i.H4,{ref:s,className:(0,o.cn)("bg-muted flex h-full w-full items-center justify-center rounded-full text-[min(45cqw,1rem)] font-medium leading-none",e),...t}));m.displayName=i.H4.displayName;let u=r.forwardRef(({getInitials:e=n.Z,name:t,...s},r)=>{let i="string"==typeof t?e(t):"";return(0,a.jsx)(m,{ref:r,...s,children:i||(0,a.jsx)(l.A,{"aria-hidden":"true",className:"h-[65%] w-[65%] shrink-0"})})});u.displayName="AvatarNameFallback"},78685:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>ta});var a,r,i=s(62021),l=s(60548),n=s(57344),o=s.n(n),d=s(74361),c=s(78658),m=s(85908),u=s(87064),x=s(37504),h=s(41657),p=s(85566),f=s(63331),g=s(91268),b=s(62909),v=s(79863),j=s(95795),y=s(6598);let N=async()=>{let e=await fetch("/api/teams");if(!e.ok)throw Error("Network response was not ok");let t=(await e.json()).data[0];if(!t)throw Error("No team found");return t},w=()=>{let{data:e,error:t,isLoading:s}=(0,l.I)({queryKey:[y.tc],queryFn:()=>N()});return{isLoading:s,isError:!!t,team:e}};var E=s(5811),I=s(45935),C=s(70297);let S=({icon:e,label:t,collapsed:s,onClick:a,active:r=!1})=>(0,i.jsxs)("button",{type:"button",onClick:a,"aria-current":r?"page":void 0,"aria-label":s?t:void 0,title:s?t:void 0,className:(0,C.cn)("flex h-8 w-full items-center gap-2 rounded-md px-2.5 text-left text-sm transition-colors duration-150 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sidebar-foreground
1/60 [&_svg]:size-4 [&_svg]:shrink-0",r?"bg-sidebar-accent text-sidebar-accent-foreground":"text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"),children:[e,(0,i.jsx)("span",{className:(0,C.cn)("whitespace-nowrap transition-opacity duration-200",s&&"opacity-0"),children:t})]}),k=(0,d.memo)(({view:e,setView:t,collapsed:s})=>{let{team:a}=w(),{flags:r}=(0,m.A)(),{data:l}=(0,v.useSession)(),n=s?"w-16":"w-64";if(null===r)return(0,i.jsx)("nav",{className:(0,C.cn)(n,"shrink-0"),"aria-label":"Admin"});let o=r.adminAuditLogViewEnabled??!1,d=r.adminAiUsageViewEnabled??!1,c=(a,r,l)=>(0,i.jsx)(S,{icon:l,label:r,collapsed:s,active:e===a,onClick:()=>t(a)},a);return(0,i.jsxs)("nav",{className:(0,C.cn)(n,"flex shrink-0 flex-col gap-6 overflow-hidden px-3 pt-4 pb-3 transition-[width] duration-200 ease-in-out motion-reduce:transition-none"),"aria-label":"Admin",children:[(0,i.jsxs)("div",{className:"relative flex h-8 items-center px-2.5",children:[(0,i.jsx)(j.R,{iconMode:"light",iconHeight:18,className:(0,C.cn)("transition-opacity duration-200",s&&"opacity-0")}),(0,i.jsx)(j.R,{iconMode:"light",showText:!1,iconWidth:18,iconHeight:18,className:(0,C.cn)("absolute left-2.5 transition-opacity duration-200",!s&&"opacity-0")})]}),(0,i.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,i.jsx)("span",{className:(0,C.cn)("flex h-8 items-center whitespace-nowrap px-2.5 text-xs font-medium uppercase tracking-wider text-sidebar-foreground/70 transition-opacity duration-200",s&&"opacity-0"),"aria-hidden":s,children:"Admin Portal"}),o&&c(e8.AUDIT_LOG,"Activity Log",(0,i.jsx)(h.A,{})),c(e8.USER_MANAGEMENT,"User Management",(0,i.jsx)(p.A,{})),d&&c(e8.AI_USAGE,"AI Usage",(0,i.jsx)(f.A,{})),a?.isSCIMEnabled&&c(e8.SCIM,"SCIM",(0,i.jsx)(g.A,{}))]}),(0,i.jsxs)("div",{className:"mt-auto flex flex-col gap-0.5",children:[l?.user.email&&(0,i.jsx)("span",{className:(0,C.cn)("truncate whitespace-nowrap px-2.5 pb-1 text-xs text-sidebar-foreground/60 transition-opacity duration-200",s&&"opacity-0"),"aria-hidden":s,children:l.user.email}),(0,i.jsx)(S,{icon:(0,i.jsx)(b.A,{}),label:"Sign out",collapsed:s,onClick:()=>(0,E.OD)(I.BV.Login)})]})]})});var A=s(19845),L=s(46343),M=s(99149),T=s(1117),D=s(88488),U=s(2334),R=s(52590),$=s(75273),O=s(28248),F=s(45197),_=s(60288),z=s(68804),P=s(83333),Y=s(98519),V=s(95771),q=s(94889);let H=({isOpen:e,onSubmit:t,isLoading:s,onClose:a})=>{let{register:r,handleSubmit:l,formState:{errors:n},reset:o}=(0,P.mN)({defaultValues:{email:"",role:q.Role.MEMBER}}),c=l(({email:e,role:s})=>{t({email:e,role:s})});return(0,d.useEffect)(()=>{e||o({email:"",role:q.Role.MEMBER})},[e,o]),(0,i.jsx)(V.lG,{open:e,onOpenChange:e=>{e||a()},children:(0,i.jsxs)(V.Cf,{topAligned:!0,children:[(0,i.jsx)(V.c7,{children:(0,i.jsx)(V.L3,{children:"Invite User"})}),(0,i.jsxs)("form",{onSubmit:c,children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{children:[(0,i.jsx)(Y.J,{htmlFor:"email",className:"text-sm font-medium",children:"Email address"}),(0,i.jsx)(A.p,{id:"email",placeholder:"Enter email","aria-invalid":!!n.email,"aria-describedby":n.email?"email-error":void 0,...r("email",{required:"Email is required",pattern:{value:/\S+@\S+\.\S+/,message:"Entered value does not match email format"}})}),n.email&&(0,i.jsx)("p",{id:"email-error",className:"mt-1 text-sm text-destructive",children:n.email.message})]}),(0,i.jsxs)("div",{className:"mt-4",children:[(0,i.jsx)(Y.J,{htmlFor:"role",className:"text-sm font-medium",children:"Role"}),(0,i.jsxs)("select",{id:"role",className:(0,C.cn)("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring dark:border-slate-500",n.role&&"border-destructive dark:border-destructive"),"aria-invalid":!!n.role,"aria-describedby":n.role?"role-error":void 0,...r("role",{required:"Role is required"}),children:[(0,i.jsx)("option",{value:"",children:"Select role"}),(0,i.jsx)("option",{value:q.Role.MEMBER,children:"Member"}),(0,i.jsx)("option",{value:q.Role.ADMIN,children:"Admin"})]}),n.role&&(0,i.jsx)("p",{id:"role-error",className:"mt-1 text-sm text-destructive",children:n.role.message})]})]}),(0,i.jsxs)(V.Es,{children:[(0,i.jsx)(L.$,{variant:"ghost",type:"button",onClick:a,children:"Cancel"}),(0,i.jsx)(L.$,{isLoading:s,type:"submit",children:"Invite"})]})]})]})})};var B=s(13540),G=s(40479),J=s(48172),K=s(39157),Z=s(2392),W=s(73854),Q=s(94428);let X=({isOpen:e,onClose:t,onConfirm:s,title:a,message:r,isLoading:l,confirmText:n="Confirm",cancelText:o="Cancel"})=>(0,i.jsx)(V.lG,{open:e,onOpenChange:e=>{e||t()},children:(0,i.jsxs)(V.Cf,{topAligned:!0,children:[(0,i.jsx)(V.c7,{children:(0,i.jsx)(V.L3,{children:a})}),(0,i.jsx)("div",{children:r}),(0,i.jsxs)(V.Es,{children:[(0,i.jsx)(L.$,{variant:"ghost",onClick:t,children:o}),(0,i.jsx)(L.$,{isLoading:l,onClick:s,children:n})]})]})});var ee=s(13247),et=s(95958),es=s(73801),ea=s(70382),er=s(76789);let ei=({action:e,userCount:t,onConfirm:s,onBack:a,isLoading:r})=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(V.c7,{children:(0,i.jsx)(V.L3,{children:"Confirm Bulk Action"})}),(0,i.jsx)("div",{children:(0,i.jsxs)("p",{className:"text-foreground",children:["Are you sure you want to ","add-licenses"===e?"add":"remove"," ","licenses ","add-licenses"===e?"to":"from"," ",t," ",1===t?"user":"users","?"]})}),(0,i.jsxs)(V.Es,{children:[(0,i.jsx)(L.$,{variant:"ghost",type:"button",onClick:a,children:"Back"}),(0,i.jsx)(L.$,{isLoading:r,type:"button",onClick:s,children:"Confirm"})]})]}),el=e=>[...new Set(e.split(/[\s,]+/).map(e=>e.trim()).filter(e=>e.length>0))],en=({isOpen:e,onSubmit:t,isLoading:s,onClose:a,verifyBulkActionInputs:r})=>{let{register:l,handleSubmit:n,formState:{errors:o},reset:c,getValues:m,control:u}=(0,P.mN)({defaultValues:{userInputs:"",action:"add-licenses"}}),[x,h]=(0,d.useState)(null),[p,f]=(0,d.useState)(!1),g=n(e=>{let t=r(el(e.userInputs),e.action);t.inputErrors.length>0?h(t):t.output.length>0&&f(!0)});return((0,d.useEffect)(()=>{e||(c({userInputs:"",action:"add-licenses"}),h(null),f(!1))},[e,c]),p)?(0,i.jsx)(V.lG,{open:e,onOpenChange:e=>{e||a()},children:(0,i.jsx)(V.Cf,{topAligned:!0,className:"max-w-lg",onEscapeKeyDown:e=>{e.preventDefault(),f(!1)},onInteractOutside:e=>{e.preventDefault(),f(!1)},children:(0,i.jsx)(ei,{action:m("action"),userCount:x?.output.length||0,onConfirm:()=>{let e=el(m("userInputs")),s=m("action");t({teamMemberIds:r(e,s).output.map(e=>e.teamMemberId),action:s})},onBack:()=>f(!1),isLoading:s})})}):(0,i.jsx)(V.lG,{open:e,onOpenChange:e=>{e||a()},children:(0,i.jsxs)(V.Cf,{topAligned:!0,className:"max-w-lg",children:[(0,i.jsx)(V.c7,{children:(0,i.jsx)(V.L3,{children:"Bulk User Action"})}),(0,i.jsxs)("form",{onSubmit:g,children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"flex justify-between",children:[(0,i.jsxs)(Y.J,{htmlFor:"userInputs",className:"text-sm font-medium",children:["User email addresses",(0,i.jsx)(er.ID,{label:"Separated by commas, spaces or new lines",name:"user-email-addresses"})]}),(0,i.jsx)("div",{children:x&&x.output.length>0&&0===x.inputErrors.length&&(0,i.jsxs)("div",{className:"flex items-center gap-1",children:[(0,i.jsx)(Z.mU9,{className:"text-green-500"}),(0,i.jsxs)("span",{className:"text-sm text-foreground",children:[x.output.length," user",x.output.length>
11?"s":""," ","validated"]})]})})]}),(0,i.jsx)(es.T,{id:"userInputs",placeholder:"[email protected], [email protected]",rows:5,"aria-invalid":!!o.userInputs,"aria-describedby":o.userInputs?"userInputs-error":void 0,...l("userInputs",{required:"At least one email is required",onBlur:()=>{let e=el(m("userInputs"));e.length>0?h(r(e,m("action"))):h(null)}}),className:"resize-none"}),o.userInputs&&(0,i.jsx)("p",{id:"userInputs-error",className:"mt-1 text-sm text-destructive",children:o.userInputs.message})]}),(0,i.jsx)("div",{className:"mt-4",children:(0,i.jsx)(P.xI,{control:u,name:"action",render:({field:e})=>(0,i.jsxs)(ea.z,{value:e.value,onValueChange:e.onChange,className:"flex flex-row items-center gap-5",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(ea.C,{value:"add-licenses",id:"action-add"}),(0,i.jsx)(Y.J,{htmlFor:"action-add",children:"Add Licenses"})]}),(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(ea.C,{value:"remove-licenses",id:"action-remove"}),(0,i.jsx)(Y.J,{htmlFor:"action-remove",children:"Remove Licenses"})]})]})})}),x&&(0,i.jsx)("div",{className:"mt-4 flex flex-col gap-3",children:x.inputErrors.length>0&&(0,i.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,i.jsx)("p",{className:"font-medium text-foreground",children:"Invalid Users"}),(0,i.jsx)("div",{className:"max-h-[150px] overflow-y-auto",children:(0,i.jsx)("ul",{className:"space-y-1",children:x.inputErrors.map(e=>(0,i.jsxs)("li",{className:"flex items-center text-sm text-foreground",children:[(0,i.jsx)(Z._Jm,{className:"mr-2 shrink-0 text-red-500"}),e]},e))})})]})})]}),(0,i.jsxs)(V.Es,{children:[(0,i.jsx)(L.$,{variant:"ghost",type:"button",onClick:a,children:"Cancel"}),(0,i.jsx)(L.$,{isLoading:s,type:"submit",children:x&&x.inputErrors.length>0?"Verify":"Apply"})]})]})]})})};var eo=s(36636),ed=((a={}).ACTIVE="ACTIVE",a.DEACTIVATED="DEACTIVATED",a.INVITED="INVITED",a.UNLICENSED="UNLICENSED",a),ec=s(53038),em=s(27416),eu=s(9608),ex=s(78288);let eh=({userStatus:e})=>{let{statusClassName:t,icon:s,text:a}=(e=>{switch(e){case ed.ACTIVE:return{statusClassName:"border-green-200 bg-green-100 text-green-800 dark:border-green-800 dark:bg-green-900/40 dark:text-green-200",icon:(0,i.jsx)(Z.mU9,{className:"mr-1"}),text:"Active"};case ed.INVITED:return{statusClassName:"border-yellow-200 bg-yellow-100 text-yellow-800 dark:border-yellow-800 dark:bg-yellow-900/40 dark:text-yellow-200",icon:(0,i.jsx)(W.w_X,{className:"mr-1"}),text:"Invited"};case ed.UNLICENSED:return{statusClassName:"border-red-200 bg-red-100 text-red-800 dark:border-red-800 dark:bg-red-900/40 dark:text-red-200",icon:(0,i.jsx)(Z._Jm,{className:"mr-1"}),text:"Unlicensed"};case ed.DEACTIVATED:return{statusClassName:"border-gray-200 bg-gray-100 text-gray-800 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200",icon:(0,i.jsx)(Z._Jm,{className:"mr-1"}),text:"Deactivated"}}})(e);return(0,i.jsx)(eu.E,{variant:"outline",className:(0,C.cn)("rounded-full px-2 py-1",t),children:(0,i.jsxs)("span",{className:"inline-flex items-center",children:[s,a]})})},ep=[{value:"ALL",label:"All statuses"},{value:ed.ACTIVE,label:"Active"},{value:ed.DEACTIVATED,label:"Deactivated"},{value:ed.INVITED,label:"Invited"},{value:ed.UNLICENSED,label:"Unlicensed"}],ef=(0,J.FB)(),eg=(0,d.memo)(({cells:e})=>(0,i.jsx)($.Hj,{children:e.map(e=>(0,i.jsx)($.nA,{children:(0,K.Kv)(e.column.columnDef.cell,e.getContext())},e.id))}));eg.displayName="UserTableRow";let eb=(0,d.memo)(({columns:e,tableState:t,userList:s,setQuery:a,setSorting:r,initialState:l})=>{let n=(0,K.N4)({data:s,columns:e,getCoreRowModel:(0,J.HT)(),getFilteredRowModel:(0,J.hM)(),getSortedRowModel:(0,J.h5)(),state:t,onGlobalFilterChange:a,onSortingChange:r,initialState:l,getRowId:e=>e.id});return(0,i.jsxs)($.XI,{containerClassName:"overflow-visible",children:[(0,i.jsx)($.A0,{className:"bg-background sticky top-0 z-10",children:n.getHeaderGroups().map(e=>(0,i.jsx)($.Hj,{children:e.headers.map(e=>(0,i.jsx)($.nd,{children:e.isPlaceholder?null:(0,K.Kv)(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,i.jsx)($.BF,{children:n.getRowModel().rows.map(e=>(0,i.jsx)(eg,{cells:e.getVisibleCells()},e.id))})]})});
1eb.displayName="UserTable";let ev=(0,d.memo)(({name:e})=>(0,i.jsxs)("div",{className:"flex items-center",children:[(0,i.jsx)(ex.eu,{className:"h-8 w-8",children:(0,i.jsx)(ex.Ni,{className:"bg-levPlum-400 text-white",name:e})}),e?(0,i.jsx)("span",{className:"ml-2",children:e}):(0,i.jsx)("span",{className:"ml-2 text-gray-500 italic dark:text-gray-400",children:"Invited"})]}));ev.displayName="UserName";let ej=(0,d.memo)(({email:e})=>(0,i.jsx)(i.Fragment,{children:e}));ej.displayName="UserEmail";let ey=(0,d.memo)(({role:e})=>(0,i.jsx)(i.Fragment,{children:(0,C.ZH)(e.toLowerCase())}));ey.displayName="UserRole";let eN=(0,d.memo)(({lastActiveAt:e})=>{if(!e)return(0,i.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"N/A"});let t=(0,ec.PI)(e);return(0,i.jsx)("span",{children:t})});eN.displayName="UserLastActive";let ew=(0,d.memo)(({userName:e,id:t,userStatus:s,licensesEnabled:a,isSCIMEnabled:r,onAction:l})=>{let n=s===ed.ACTIVE||s===ed.UNLICENSED;return s===ed.UNLICENSED||s===ed.ACTIVE&&a||n&&!r||s===ed.DEACTIVATED&&!r||s===ed.INVITED?(0,i.jsxs)(O.rI,{modal:!1,children:[(0,i.jsx)(O.ty,{asChild:!0,children:(0,i.jsx)(M.K,{"aria-label":"Options",icon:(0,i.jsx)(Q.ZZB,{}),variant:"ghost",size:"iconMd",className:"data-[state=open]:bg-gray-100 dark:data-[state=open]:bg-white/10"})}),(0,i.jsxs)(O.SQ,{children:[s===ed.UNLICENSED&&(0,i.jsx)(O._2,{onSelect:()=>l("assignLicense",t,e),children:"Assign License"}),s===ed.ACTIVE&&a&&(0,i.jsx)(O._2,{onSelect:()=>l("removeLicense",t,e),children:"Remove License"}),n&&!r&&(0,i.jsx)(O._2,{onSelect:()=>l("deactivateUser",t,e),children:"Deactivate User"}),s===ed.DEACTIVATED&&!r&&(0,i.jsx)(O._2,{onSelect:()=>l("reactivateUser",t,e),children:"Reactivate User"}),s===ed.INVITED&&(0,i.jsx)(O._2,{onSelect:()=>l("deleteInvitation",t,e),children:"Delete Invitation"})]})]}):null});ew.displayName="UserMenu";let eE=({team:e,userList:t,licenseInfo:s})=>{let[a,r]=(0,d.useState)({isOpen:!1,title:"",message:"",onConfirm:()=>{},action:""}),[l,n]=(0,d.useState)(""),[o,c]=(0,d.useState)("ALL"),[u,x]=(0,d.useState)(!1),[h,p]=(0,d.useState)(!1),f=(0,F.jE)(),[g,b]=(0,d.useState)([{id:"name",desc:!1}]),{flags:v}=(0,m.A)(),j=v?.adminLastActiveColumnEnabled??!1,N=(0,_.n)({mutationFn:async t=>{let s=await fetch(`/api/teams/${e.slug}/members/${t}/license`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!s.ok)throw Error((await s.json()).error||"Failed to assign license")},onSuccess:()=>{f.invalidateQueries([y.nH]),z.oR.success("License Assigned"),r(e=>({...e,isOpen:!1}))},onMutate:()=>{r(e=>({...e,isLoading:!0}))},onError:e=>{z.oR.error("Failed to assign license",{description:"No licenses available"===e.message?"You have reached the maximum number of licenses":void 0})},onSettled:()=>{"assignLicense"===a.action&&r(e=>({...e,isLoading:!1}))}}),w=(0,_.n)({mutationFn:async t=>{if(!(await fetch(`/api/teams/${e.slug}/members/${t}/license`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw Error("Failed to remove license")},onSuccess:()=>{f.invalidateQueries([y.nH]),z.oR.success("License Removed"),r(e=>({...e,isOpen:!1}))},onMutate:()=>{r(e=>({...e,isLoading:!0}))},onError:()=>{z.oR.error("Failed to remove license")},onSettled:()=>{"removeLicense"===a.action&&r(e=>({...e,isLoading:!1}))}}),E=(0,_.n)({mutationFn:async t=>{let s=await fetch(`/api/teams/${e.slug}/members/${t}/status`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({active:!1})});if(!s.ok)throw Error((await s.json()).error||"Failed to deactivate user")},onSuccess:()=>{f.invalidateQueries([y.nH]),z.oR.success("User Deactivated"),r(e=>({...e,isOpen:!1}))},onMutate:()=>{r(e=>({...e,isLoading:!0}))},onError:e=>{z.oR.error("Failed to deactivate user",{description:e.message})},onSettled:()=>{"deactivateUser"===a.action&&r(e=>({...e,isLoading:!1}))}}),I=(0,_.n)({mutationFn:async t=>{let s=await fetch(`/api/teams/${e.slug}/members/${t}/status`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({active:!0})});if(!s.ok)throw Error((await s.json()).error||"Failed to reactivate user")},onSuccess:()=>{f.invalidateQueries([y.nH]),z.oR.success("User Reactivated"),r(e=>({...e,isOpen:!1}))},onMutate:()=>{r(e=>({...e,isLoading:!0}))},onError:e=>{z.oR.error("Failed to reactivate user",{description:e.message})},onSettled:()=>{"reactivateUser"===a.action&&r(e=>({...e,isLoading:!1}))}}),S=(0,_.n)({mutationFn:async t=>{if(!(await fetch(`/api/teams/${e.slug}/invitations?id=${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw Error("Failed to delete invitation")},onSuccess:()=>{f.invalidateQueries([y.nH]),z.oR.success("Invitation Deleted"),r(e=>({...e,isOpen:!1}))},onMutate:()=>{r(e=>({...e,isLoading:!0}))},onError:()=>{z.oR.error("Failed to delete invitation")},onSettled:()=>{"deleteInvitation"===a.action&&r(e=>({...e,isLoading:!1}))}}),k=(0,d.useCallback)((e,t,s="this user")=>{switch(e){case"assignLicense":r({isOpen:!0,title:"Assign License",message:`Are you sure you want to assign a license to ${s}?`,onConfirm:()=>{N.mutate(t)},action:"assignLicense"});break;case"removeLicense":r({isOpen:!0,title:"Remove License",message:`Are you sure you want to remove the license from ${s}?`,onConfirm:()=>{w.mutate(t)},action:"removeLicense"});break;case"deactivateUser":r({isOpen:!0,title:"Deactivate User",message:`Are you sure you want to deactivate ${s}? They will no longer be able to sign in and their license will be removed.`,onConfirm:()=>{E.mutate(t)},action:"deactivateUser"});break;case"reactivateUser":r({isOpen:!0,title:"Reactivate User",message:`Are you sure you want to reactivate ${s}? They will be able to sign in again.`,onConfirm:()=>{I.mutate(t)},action:"reactivateUser"});break;case"deleteInvitation":r({isOpen:!0,title:"Delete Invitation",message:"Are you sure you want to delete this invitation?",onConfirm:()=>{S.mutate(t)},action:"deleteInvitation"})}},[N.mutate,w.mutate,E.mutate,I.mutate,S.mutate,r]),M=(0,d.useMemo)(()=>[ef.accessor("name",{cell:e=>(0,i.jsx)(ev,{name:e.getValue()}),header:({column:e})=>(0,i.jsxs)("div",{className:"flex cursor-pointer items-center",onClick:e.getToggleSortingHandler(),children:[(0,i.jsx)("span",{children:"Name"}),{asc:(0,i.jsx)(T.A,{className:"ml-1 h-3 w-3"}),desc:(0,i.jsx)(D.A,{className:"ml-1 h-3 w-3"})}[String(e.getIsSorted())]??null]})}),ef.accessor("email",{cell:e=>(0,i.jsx)(ej,{email:e.getValue()}),header:({column:e})=>(0,i.jsxs)("div",{className:"flex cursor-pointer items-center",onClick:e.getToggleSortingHandler(),children:[(0,i.jsx)("span",{children:"Email"}),{asc:(0,i.jsx)(T.A,{className:"ml-1 h-3 w-3"}),desc:(0,i.jsx)(D.A,{className:"ml-1 h-3 w-3"})}[String(e.getIsSorted())]??null]})}),ef.accessor("role",{cell:e=>(0,i.jsx)(ey,{role:e.getValue()}),header:({column:e})=>(0,i.jsxs)("div",{className:"flex cursor-pointer items-center",onClick:e.getToggleSortingHandler(),children:[(0,i.jsx)("span",{children:"Role"}),{asc:(0,i.jsx)(T.A,{className:"ml-1 h-3 w-3"}),desc:(0,i.jsx)(D.A,{className:"ml-1 h-3 w-3"})}[String(e.getIsSorted())]??null]})}),ef.accessor("userStatus",{cell:e=>(0,i.jsx)(eh,{userStatus:e.getValue()}),header:({column:e})=>(0,i.jsxs)("div",{className:"flex cursor-pointer items-center",onClick:e.getToggleSortingHandler(),children:[(0,i.jsx)("span",{children:"Status"}),{asc:(0,i.jsx)(T.A,{className:"ml-1 h-3 w-3"}),desc:(0,i.jsx)(D.A,{className:"ml-1 h-3 w-3"})}[String(e.getIsSorted())]??null]})}),...j?[ef.accessor("lastActiveAt",{cell:e=>(0,i.jsx)(eN,{lastActiveAt:e.getValue()}),header:({column:e})=>(0,i.jsxs)("div",{className:"flex cursor-pointer items-center",onClick:e.getToggleSortingHandler(),children:[(0,i.jsx)("span",{children:"Last Active"}),{asc:(0,i.jsx)(T.A,{className:"ml-1 h-3 w-3"}),desc:(0,i.jsx)(D.A,{className:"ml-1 h-3 w-3"})}[String(e.getIsSorted())]??null]}),sortingFn:"datetime",sortUndefined:"last"})]:[],ef.accessor("id",{cell:e=>
1(0,i.jsx)(ew,{userName:e.row.original.name||e.row.original.email,id:e.getValue(),userStatus:e.row.original.userStatus,licensesEnabled:e.row.original.licensesEnabled,isSCIMEnabled:e.row.original.isSCIMEnabled,onAction:k}),header:()=>null})],[k,j]),$=(0,d.useMemo)(()=>({globalFilter:l,sorting:g}),[l,g]),O=(0,d.useMemo)(()=>({sorting:[{id:"name",desc:!1}]}),[]),P=(0,_.n)({mutationFn:async t=>{if(!(await fetch(`/api/teams/${e.slug}/invitations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,sentViaEmail:!0})})).ok)throw Error("Failed to send invitation")},onError:()=>{z.oR.error("Failed to send invitation")},onSuccess:()=>{z.oR.success("Invitation Sent"),f.invalidateQueries([y.nH]),x(!1)}}),Y=(0,_.n)({mutationFn:async t=>{let s=await fetch(`/api/teams/${e.slug}/bulk`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw Error((await s.json()).error||"Failed to perform bulk action");return s.json()},onSuccess:(e,{action:t})=>{f.invalidateQueries([y.nH]),z.oR.success("add-licenses"===t?"Licenses added successfully":"Licenses removed successfully"),p(!1)},onError:e=>{let t=e.message!==eo.$b&&e.message!==eo.e8?void 0:e.message;z.oR.error("Failed to save",{description:t})}}),V=(0,d.useCallback)((e,s)=>{let a={output:[],inputErrors:[]};for(let r of e){let e=t.find(e=>e.id===r||e.email.toLowerCase()===r.toLowerCase());e?"add-licenses"===s&&e.userStatus===ed.DEACTIVATED?a.inputErrors.push(`${e.email} (cannot assign license to a deactivated user)`):a.output.push({teamMemberId:e.id,input:r}):a.inputErrors.push(r)}return a},[t]),{isLoading:q}=N,{isLoading:B}=w,{isLoading:J}=E,{isLoading:K}=I,{isLoading:W}=S,Q=(0,d.useMemo)(()=>({assignLicense:{isLoading:q},removeLicense:{isLoading:B},deactivateUser:{isLoading:J},reactivateUser:{isLoading:K},deleteInvitation:{isLoading:W}}),[q,B,J,K,W]),es=Q[a.action]?.isLoading??!1,ea=(0,d.useMemo)(()=>"ALL"===o?t:t.filter(e=>e.userStatus===o),[t,o]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"flex h-full flex-col gap-6 overflow-hidden px-8 pt-6 pb-4",children:(0,i.jsxs)("div",{className:"flex grow flex-col gap-4 overflow-hidden",children:[(0,i.jsxs)("div",{className:"flex w-full flex-wrap items-center justify-between gap-2",children:[(0,i.jsxs)("div",{className:"flex items-center gap-2",children:[(0,i.jsx)(A.p,{value:l,onChange:e=>n(e.target.value),placeholder:"Search users",className:"h-9 min-w-[150px] max-w-[250px] flex-1"}),(0,i.jsxs)(G.l6,{value:o,onValueChange:e=>{let t=ep.find(t=>t.value===e);t&&c(t.value)},children:[(0,i.jsx)(G.bq,{className:"h-9 w-[170px]","aria-label":"Status",children:(0,i.jsx)(G.yv,{})}),(0,i.jsx)(G.gC,{children:ep.map(e=>(0,i.jsx)(G.eb,{value:e.value,children:e.label},e.value))})]})]}),(0,i.jsxs)("div",{className:"flex shrink-0 items-center gap-4",children:[s.enabled&&(0,i.jsxs)("span",{className:"whitespace-nowrap text-sm text-muted-foreground",children:[s.used," / ",s.total," licenses used"]}),(0,i.jsxs)("div",{className:"flex gap-2",children:[s.enabled&&!e.isSCIMEnabled&&(0,i.jsxs)(L.$,{variant:"outline",size:"sm",className:"h-9 text-sm",type:"button",onClick:()=>p(!0),children:[(0,i.jsx)(Z.O_p,{}),"Bulk Action"]}),(0,i.jsxs)(L.$,{variant:"outline",size:"sm",className:"h-9 text-sm",type:"button",onClick:()=>{let e=et.c9.local().toFormat("yyyy-MM-dd");((e,t,s)=>{let a=[["Name","Email","Role","Status"],...e.map(e=>[e.name||"Invited",e.email,(0,C.ZH)(e.role.toLowerCase()),e.userStatus])];if(s){let t=Intl.DateTimeFormat().resolvedOptions().timeZone||"local",s=(0,em.F_u)(et.c9.local(),t);for(let[r,i]of(a?.[0]?.push(`Last active at (${s})`),a.entries()))if(r>0){let s=e[r-1]?.lastActiveAt,a=s?et.c9.fromJSDate(new Date(s)).setZone(t).toISO({includeOffset:!1}):"";i.push(a)}}let r=ee.utils.aoa_to_sheet(a),i=ee.utils.book_new();ee.utils.book_append_sheet(i,r,"Users"),(0,ee.writeFile)(i,t)})(ea,`Levenza Users ${e}.csv`,j)},children:[(0,i.jsx)(U.A,{className:"h-4 w-4"}),"Download"]}),!e.isSCIMEnabled&&(0,i.jsxs)(L.$,{variant:"outline",size:"sm",className:"h-9 text-sm",type:"button",onClick:()=>x(!0),children:[(0,i.jsx)(R.A,{className:"h-4 w-4"}),"Add User"]})]})]})]}),(0,i.jsx)("div",{className:"grow overflow-y-auto",children:(0,i.jsx)(eb,{columns:M,tableState:$,userList:ea,setQuery:n,setSorting:b,initialState:O})})]})}),(0,i.jsx)(H,{onSubmit:({email:e,role:t})=>{P.mutate({email:e,role:t})},isOpen:u,onClose:()=>x(!1),isLoading:P.isLoading}),(0,i.jsx)(en,{isOpen:h,onClose:()=>p(!1),isLoading:Y.isLoading,onSubmit:({teamMemberIds:e,action:t})=>{Y.mutate({teamMemberIds:e,action:t})},verifyBulkActionInputs:V}),(0,i.jsx)(X,{isOpen:a.isOpen,title:a.title,message:a.message,onConfirm:a.onConfirm,onClose:()=>r(e=>({...e,isOpen:!1})),isLoading:es})]})},eI=()=>{let{team:e,isError:t,isLoading:s}=w(),{data:a,isLoading:r,isError:n}=(0,l.I)({queryKey:[y.nH],queryFn:async()=>{let e=await fetch("/api/admin/users");if(!e.ok)throw Error("Failed to fetch users");let{teamMembers:t,invitations:s,team:a}=await e.json(),r="number"==typeof a.License?.maxUserLicenses,i=a.License?.maxUserLicenses||null,l=a.TeamMembers.filter(e=>e.UserLicense).length;return{userList:[...t.map(e=>{var t,s;return{name:e.User.name,email:e.User.email,role:e.role,id:e.id,userStatus:(t=e.isActive,s=!!e.UserLicense,t?r&&!s?ed.UNLICENSED:ed.ACTIVE:ed.DEACTIVATED),licensesEnabled:r,lastActiveAt:e.lastActiveAt?new Date(e.lastActiveAt):void 0,isSCIMEnabled:a.isSCIMEnabled}}),...s.filter(e=>!!e.email).map(e=>({name:null,email:e.email,role:e.role,id:e.id,userStatus:ed.INVITED,licensesEnabled:r,lastActiveAt:void 0,isSCIMEnabled:a.isSCIMEnabled}))].sort((e,t)=>
1e.email.localeCompare(t.email)),licenseInfo:{enabled:r,total:i,used:l,available:i?i-l:null}}}});if(r||s)return(0,i.jsx)(B.l,{label:"Loading users"});if(n||t||!e||!a)return(0,i.jsx)("p",{children:"Error fetching users"});let{userList:o,licenseInfo:d}=a;return(0,i.jsx)(eE,{licenseInfo:d,userList:o,team:e})};var eC=s(85302),eS=s(25475),ek=s(83635),eA=s(80171);let eL=()=>{let{team:e}=w(),t=e?.slug,[s,a]=(0,d.useState)(!1),[r,n]=(0,d.useState)(!1),[o,c]=(0,d.useState)(!1),m=(0,d.useRef)(null),u=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>{m.current&&clearTimeout(m.current),u.current&&clearTimeout(u.current)},[]);let{data:x,isError:h,isLoading:p}=(0,l.I)({queryKey:[y.SR,t],queryFn:async()=>{let e=await fetch(`/api/admin/scim/credentials?slug=${t}`);if(!e.ok)throw Error("Failed to fetch SCIM credentials");return(await e.json()).credentials},enabled:!!t}),f=(e,t)=>{navigator.clipboard.writeText(e),"url"===t?(n(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>n(!1),2e3)):(c(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>c(!1),2e3))};return p?(0,i.jsx)("div",{className:"flex items-center justify-center p-6",children:"Loading SCIM configuration..."}):h?(0,i.jsx)("div",{className:"p-6 text-red-500",children:"Failed to load SCIM configuration. Please try again."}):x?(0,i.jsx)("div",{className:"mt-10 flex flex-col items-center gap-4",children:(0,i.jsxs)("div",{className:"max-w-2xl space-y-6 p-6",children:[(0,i.jsx)("h2",{className:"mb-4 text-2xl font-semibold",children:"SCIM Configuration"}),(0,i.jsx)("p",{className:"mb-6 text-gray-600",children:"Use these credentials to configure SCIM provisioning with your identity provider."}),(0,i.jsxs)("div",{className:"space-y-4",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{htmlFor:"scim-url",className:"mb-1 block text-sm font-medium",children:"SCIM URL"}),(0,i.jsxs)("div",{className:"flex",children:[(0,i.jsx)(A.p,{id:"scim-url",value:x.url,readOnly:!0,className:"flex-1 font-mono text-sm"}),(0,i.jsxs)(L.$,{variant:"outline",size:"sm",disabled:r,className:"ml-2 h-9 w-9",onClick:()=>f(x.url,"url"),children:[r?(0,i.jsx)(eC.A,{}):(0,i.jsx)(eS.A,{}),(0,i.jsx)("span",{className:"sr-only",children:r?"URL Copied":"Copy URL"})]})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{htmlFor:"scim-secret",className:"mb-1 block text-sm font-medium",children:"SCIM Secret Token"}),(0,i.jsxs)("div",{className:"flex",children:[(0,i.jsx)(A.p,{id:"scim-secret",type:s?"text":"password",value:x.secret,readOnly:!0,className:(0,C.cn)("flex-1 font-mono text-sm",s?"":"tracking-widest")}),(0,i.jsxs)(L.$,{variant:"outline",size:"sm",className:"ml-2 h-9 w-9",onClick:()=>a(!s),children:[s?(0,i.jsx)(ek.A,{}):(0,i.jsx)(eA.A,{}),(0,i.jsx)("span",{className:"sr-only",children:s?"Hide Secret":"Show Secret"})]}),(0,i.jsxs)(L.$,{variant:"outline",size:"sm",className:"ml-2 h-9 w-9",disabled:o,onClick:()=>f(x.secret,"secret"),children:[o?(0,i.jsx)(eC.A,{}):(0,i.jsx)(eS.A,{}),(0,i.jsx)("span",{className:"sr-only",children:o?"Secret Copied":"Copy Secret"})]})]})]})]})]})}):(0,i.jsx)("div",{className:"p-6",children:"No SCIM configuration available."})};var eM=s(83067),eT="2026-01",eD=eM.Ik({teamName:eM.Yj(),month:eM.Yj(),dataThrough:eM.Yj().nullable(),totals:eM.Ik({credits:eM.ai(),activeUsers:eM.ai()}),daily:eM.YO(eM.Ik({day:eM.Yj(),credits:eM.ai()})),limits:eM.Ik({members:eM.ai(),orgMonthlyCredits:eM.ai(),perUserMonthlyCredits:eM.ai()}),activity:eM.YO(eM.Ik({key:eM.k5(["meetingsScheduled","meetingsUpdated","meetingsCanceled","emailsSent","draftsWritten","emailsOrganized","timesheetsSubmitted"]),count:eM.ai()})),users:eM.YO(eM.Ik({userId:eM.Yj(),email:eM.Yj().nullable(),name:eM.Yj().nullable(),credits:eM.ai()}))}),eU=eM.Yj().regex(/^\d{4}-(0[1-9]|1[0-2])$/);eM.Ik({month:eU}).refine(({month:e})=>e>=eT);var eR=s(3638),e$=(...e)=>(0,eR.$)(e),eO=new Intl.NumberFormat("en-US",{maximumFractionDigits:0}),eF=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}),e_=e=>Math.ceil(Number(e.toFixed(6))),ez=e=>eO.format(e_(e)),eP=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}),eY=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",timeZone:"UTC"}),eV=e=>eY.format(new Date(`${e}T00:00:00Z`)),eq=({points:e,label:t})=>{let[s,a]=(0,d.useState)(null),r=((e,t=4)=>{if(!(e>0))return Array.from({length:t+1},(e,t)=>t);let s=Math.max(e/t,1),a=10**Math.floor(Math.log10(s)),r=[1,2,2.5,5,10].map(e=>e*a).find(e=>Number.isInteger(e)&&e>=s)??10*a;return Array.from({length:t+1},(e,t)=>Number((t*r).toPrecision(12)))})(Math.max(...e.map(e=>e.projected??e.actual??0),0)),l=r.at(-1)??1,n=t=>e.length<=1?0:t/(e.length-1)*600,o=e=>180-e/l*180,c=e.flatMap((e,t)=>null===e.actual?[]:[`${n(t)},${o(e.actual)}`]),m=e.flatMap((e,t)=>null===e.projected?[]:[`${n(t)},${o(e.projected)}`]),u=1===c.length?e.find(e=>null!==e.actual):void 0,x=null===s?void 0:e[s],h=x?.actual??x?.projected??null,p=null===s||e.length<=1?0:s/(e.length-1)*100;return(0,i.jsxs)("div",{className:"flex gap-3",children:[(0,i.jsx)("div",{className:"text-muted-foreground relative h-44 w-10 shrink-0 text-right text-xs tabular-nums",children:r.map(e=>(0,i.jsx)("span",{className:"absolute right-0 -translate-y-1/2",style:{to
1p:`${(1-e/l)*100}%`},children:eP.format(e)},e))}),(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsxs)("div",{className:"relative h-44 touch-none",onPointerMove:t=>{let s=t.currentTarget.getBoundingClientRect();a(Math.round(Math.min(Math.max((t.clientX-s.left)/s.width,0),1)*(e.length-1)))},onPointerLeave:()=>a(null),children:[(0,i.jsxs)("svg",{viewBox:"0 0 600 180",preserveAspectRatio:"none",className:"absolute inset-0 h-full w-full overflow-visible",role:"img","aria-label":t,children:[r.map(e=>(0,i.jsx)("line",{x1:0,x2:600,y1:o(e),y2:o(e),className:0===e?"stroke-border":"stroke-border/60",strokeWidth:1,vectorEffect:"non-scaling-stroke"},e)),c.length>1&&(0,i.jsx)("polygon",{points:`0,180 ${c.join(" ")} ${n(c.length-1)},180`,className:"fill-levPlum-500/10"}),c.length>1&&(0,i.jsx)("polyline",{points:c.join(" "),fill:"none",className:"stroke-levPlum-500",strokeWidth:2,vectorEffect:"non-scaling-stroke"}),m.length>1&&(0,i.jsx)("polyline",{points:m.join(" "),fill:"none",className:"stroke-levPlum-500/60",strokeWidth:2,strokeDasharray:"5 5",vectorEffect:"non-scaling-stroke"})]}),u?.actual!=null&&(0,i.jsx)("div",{"data-testid":"ai-usage-chart-single-point",className:"bg-levPlum-500 border-background pointer-events-none absolute size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2",style:{left:"0%",top:`${(1-u.actual/l)*100}%`}}),x&&null!==h&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"bg-border pointer-events-none absolute inset-y-0 w-px",style:{left:`${p}%`}}),(0,i.jsx)("div",{className:e$("border-background pointer-events-none absolute size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2",null===x.actual?"bg-levPlum-300":"bg-levPlum-500"),style:{left:`${p}%`,top:`${(1-h/l)*100}%`}}),(0,i.jsxs)("div",{role:"tooltip",className:e$("border-border/60 bg-background pointer-events-none absolute top-0 z-10 rounded-md border px-2.5 py-1.5 text-xs whitespace-nowrap shadow-[var(--shadow-card)]",p>70?"-translate-x-[calc(100%+8px)]":"translate-x-2"),style:{left:`${p}%`},children:[(0,i.jsx)("p",{className:"text-muted-foreground",children:eV(x.day)}),(0,i.jsx)("p",{className:"text-foreground mt-0.5 tabular-nums",children:null===x.actual?`~${ez(h)} projected`:`${ez(h)} credits`})]})]})]}),(0,i.jsxs)("table",{className:"sr-only",children:[(0,i.jsx)("caption",{children:t}),(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{scope:"col",children:"Day"}),(0,i.jsx)("th",{scope:"col",children:"Credits used"}),(0,i.jsx)("th",{scope:"col",children:"Projected"})]})}),(0,i.jsx)("tbody",{children:e.map(e=>(0,i.jsxs)("tr",{children:[(0,i.jsx)("th",{scope:"row",children:eV(e.day)}),(0,i.jsx)("td",{children:null===e.actual?"â":ez(e.actual)}),(0,i.jsx)("td",{children:null===e.projected?"â":ez(e.projected)})]},e.day))})]}),(0,i.jsxs)("div",{className:"text-muted-foreground mt-2 flex justify-between text-xs tabular-nums",children:[(0,i.jsx)("span",{children:e[0]?eV(e[0].day):""}),(0,i.jsx)("span",{children:e.at(-1)?eV(e.at(-1)?.day??""):""})]})]})]})},eH=new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric",timeZone:"UTC"}),eB="rounded-xl border border-border/60 bg-background shadow-[var(--shadow-card)]",eG=({usage:e,today:t,monthPicker:s})=>(0,i.jsx)("div",{className:"@container",children:(0,i.jsx)("div",{className:"mx-auto w-full max-w-5xl px-4 pt-6 pb-8 @xl:px-8",children:(0,i.jsx)(eJ,{title:"Summary",action:s,children:e.error?(0,i.jsx)("p",{className:"text-destructive text-sm",role:"alert",children:e.error.message}):e.isLoading||!e.data?(0,i.jsx)(eK,{}):(0,i.jsx)(eZ,{report:e.data,today:t})})})}),eJ=({title:e,action:t,children:s})=>(0,i.jsxs)("section",{className:"mb-10",children:[(0,i.jsxs)("div",{className:"mb-3 flex min-h-8 flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[(0,i.jsx)("h2",{className:"text-foreground text-base font-medium",children:e}),t]}),s]}),eK=()=>(0,i.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"ai-usage-skeleton",children:[(0,i.jsx)("div",{className:"grid gap-4 @2xl:grid-cols-3",children:[0,1,2].map(e=>(0,i.jsx)("div",{className:"bg-primary/10 h-[104px] animate-pulse rounded-xl"},e))}),(0,i.jsx)("div",{className:"bg-primary/10 h-72 animate-pulse rounded-xl"})]}),eZ=({report:e,today:t})=>{var s;let a,r,l,{credits:n,activeUsers:o}=e.totals,c=(0,d.useMemo)(()=>{var s;let a,r,i,l,n,o,d,c;return s=e.daily,a=s.filter(e=>e.day<t),r=s.find(e=>e.day===t),l=0===(i=a.slice(-7)).length?0:i.reduce((e,t)=>
1e+t.credits,0)/i.length,n=void 0!==r&&a.length>=3,o=a.at(-1)?.day,d=0,c=0,{points:s.map(e=>e.day<t?(d+=e.credits,c=d,{day:e.day,actual:d,projected:n&&e.day===o?d:null}):e.day===t?(d+=e.credits,c+=Math.max(e.credits,l),{day:e.day,actual:d,projected:n?c:null}):(c+=l,{day:e.day,actual:null,projected:n?c:null})),toDate:d,projected:n?c:null,dailyRunRate:l}},[e.daily,t]),m=(a=(s=e.month)===t.slice(0,7),{isCurrent:a,label:r=(e=>{let[t,s]=e.split("-").map(Number);if(void 0===t||void 0===s)throw Error(`Invalid month: ${e}`);return eH.format(new Date(Date.UTC(t,s-1,1)))})(s),inMonth:a?"this month":`in ${r}`});return(0,i.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,i.jsxs)("div",{className:"grid gap-4 @2xl:grid-cols-3",children:[(0,i.jsx)(eW,{value:ez(n),label:"Credits consumed",detail:null===c.projected?m.isCurrent?"This month so far":m.label:`~${l=c.projected,eF.format(e_(l))} projected by month end`}),(0,i.jsx)(eW,{value:String(o),label:"Active members",detail:"Used Levenza Agent"}),(0,i.jsx)(eW,{value:0===o?"â":ez(n/o),label:"Average per person",detail:"Credits per active member"})]}),(0,i.jsxs)("section",{className:e$(eB,"p-5"),children:[(0,i.jsxs)("div",{className:"mb-4 flex flex-wrap items-baseline justify-between gap-2",children:[(0,i.jsxs)("h3",{className:"text-foreground text-sm font-medium",children:["Credits ",m.inMonth]}),null!==c.projected&&(0,i.jsx)("span",{className:"text-muted-foreground text-xs",children:"Dashed line projects the last 7 full days' pace to month end"})]}),(0,i.jsx)(eq,{points:c.points,label:`Credits used ${m.inMonth}`})]}),(0,i.jsx)(e0,{users:e.users,inMonth:m.inMonth}),(0,i.jsx)(eX,{activity:e.activity}),(0,i.jsx)(e1,{limits:e.limits,used:n,inMonth:m.inMonth})]})},eW=({value:e,label:t,detail:s})=>(0,i.jsxs)("div",{className:e$(eB,"p-5"),children:[(0,i.jsx)("p",{className:"text-foreground text-2xl tabular-nums",children:e}),(0,i.jsx)("p",{className:"text-foreground mt-2 text-sm",children:t}),(0,i.jsx)("p",{className:"text-muted-foreground mt-0.5 text-sm",children:s})]}),eQ={meetingsScheduled:"Meetings scheduled",meetingsUpdated:"Meetings updated",meetingsCanceled:"Meetings canceled",emailsSent:"Emails sent",draftsWritten:"Email drafts written",emailsOrganized:"Emails organized",timesheetsSubmitted:"Timesheets submitted"},eX=({activity:e})=>(0,i.jsxs)("section",{className:"mt-6","data-testid":"ai-usage-activity",children:[(0,i.jsx)("h3",{className:"text-foreground mb-3 text-base font-medium",children:"What are the results?"}),(0,i.jsx)("dl",{className:"grid grid-cols-2 gap-4 @xl:grid-cols-3 @3xl:grid-cols-4",children:e.map(e=>(0,i.jsxs)("div",{className:e$(eB,"flex flex-col-reverse p-5"),children:[(0,i.jsx)("dt",{className:"text-muted-foreground mt-1 text-sm",children:eQ[e.key]}),(0,i.jsx)("dd",{className:"text-foreground text-2xl tabular-nums",children:e.count.toLocaleString("en-US")})]},e.key))})]}),e0=({users:e,inMonth:t})=>{let[s,a]=(0,d.useState)(!1),r=s?e:e.slice(0,5);return(0,i.jsxs)("section",{className:e$(eB,"p-5"),children:[(0,i.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-4",children:[(0,i.jsx)("h3",{className:"text-foreground text-sm font-medium",children:"Who's using Levenza?"}),e.length>5&&(0,i.jsx)("button",{type:"button",onClick:()=>a(e=>!e),className:"bg-muted text-foreground hover:bg-muted/70 focus-visible:ring-ring rounded-md px-2.5 py-1 text-xs transition-colors focus-visible:ring-1 focus-visible:outline-none",children:s?"Show top 5":`See all ${e.length}`})]}),0===e.length?(0,i.jsxs)("p",{className:"text-muted-foreground py-6 text-center text-sm",children:["No AI usage ",t,"."]}):(0,i.jsx)("div",{className:e$(s&&"max-h-[27rem] overflow-y-auto"),children:(0,i.jsxs)("table",{className:"w-full text-sm",children:[(0,i.jsx)("thead",{className:"bg-background sticky top-0",children:(0,i.jsxs)("tr",{className:"text-muted-foreground text-xs",children:[(0,i.jsx)("th",{className:"pb-2 text-left font-normal",children:"Member"}),(0,i.jsx)("th",{className:"pb-2 text-right font-normal",children:"Credits consumed"})]})}),(0,i.jsx)("tbody",{children:r.map(e=>{let t;return(0,i.jsxs)("tr",{className:"border-border/60 border-t",children:[(0,i.jsx)("td",{className:"max-w-0 py-2.5 pr-4",children:(0,i.jsx)("span",{className:"text-foreground block truncate",children:e.email??e.name??e.userId})}),(0,i.jsx)("td",{className:"text-foreground py-2.5 text-right tabular-nums",children:(t=e.credits)>0&&t<1?"<1":ez(t)})]},e.userId)})})]})})]})},e1=({limits:e,used:t,inMonth:s})=>{let a=e.orgMonthlyCredits>0?Math.min(t/e.orgMonthlyCredits,1):0;return(0,i.jsxs)("section",{className:e$(eB,"p-5"),"data-testid":"ai-usage-limits",children:[(0,i.jsx)("h3",{className:"text-foreground text-sm font-medium",children:"Usage limits"}),(0,i.jsxs)("dl",{className:"mt-4 grid gap-x-8 gap-y-5 @xl:grid-cols-2",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("dt",{className:"text-muted-foreground text-xs",children:"Organization limit"}),(0,i.jsxs)("dd",{className:"text-foreground mt-1 text-sm tabular-nums",children:[ez(t)," of ",ez(e.orgMonthlyCredits)," ","credits used ",s]}),(0,i.jsx)("div",{className:"bg-muted mt-2 h-1.5 overflow-hidden rounded-full",role:"progressbar","aria-label":"Organization limit used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(100*a),children:(0,i.jsx)("div",{className:e$("h-full rounded-full",a>=1?"bg-destructive":"bg-levPlum-500"),style:{width:`${100*a}%`}})}),(0,i.jsxs)("p",{className:"text-muted-foreground mt-1.5 text-xs",children:[ez(e.orgMonthlyCredits/Math.max(e.members,1))," ","credits per member each month, for ",e.members," ",1===e.members?"member":"members"]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("dt",{className:"text-muted-foreground text-xs",children:"Per-person limit"}),(0,i.jsxs)("dd",{className:"text-foreground mt-1 text-sm tabular-nums",children:[ez(e.per
1UserMonthlyCredits)," credits a month"]})]})]}),(0,i.jsx)("p",{className:"text-muted-foreground mt-5 text-xs",children:"To change these limits, contact your Levenza account manager. Usage alerts are coming soon."})]})},e2=async e=>{try{let t=await e.json();if("object"==typeof t&&null!==t&&"error"in t&&"string"==typeof t.error)return t.error}catch{}return`AI usage request failed (${e.status})`},e4=async e=>{let t=await fetch(e);if(!t.ok)throw Error(await e2(t));return eD.parse(await t.json())};let e5=()=>{let e=new Date().toISOString().slice(0,10),t=(0,d.useMemo)(()=>(e=>{let t=[],s=Number(e.slice(0,4)),a=Number(e.slice(5,7))-1;for(;;){let e=`${s}-${String(a+1).padStart(2,"0")}`;if(e<eT)break;t.push({value:e,label:eH.format(new Date(Date.UTC(s,a,1)))}),(a-=1)<0&&(a=11,s-=1)}return t})(e),[e]),[s,a]=(0,d.useState)(t[0]?.value??e.slice(0,7)),r=(0,l.I)({queryKey:["admin-ai-usage",s],queryFn:()=>e4(`/api/admin/ai-usage?${new URLSearchParams({month:s})}`),staleTime:3e5});return(0,i.jsx)(eG,{usage:r,today:e,monthPicker:(0,i.jsxs)(G.l6,{value:s,onValueChange:a,children:[(0,i.jsx)(G.bq,{className:"h-9 w-44","aria-label":"Month",children:(0,i.jsx)(G.yv,{})}),(0,i.jsx)(G.gC,{children:t.map(e=>(0,i.jsx)(G.eb,{value:e.value,children:e.label},e.value))})]})})},e3=o()(()=>s.e(4265).then(s.bind(s,54265)),{loadableGenerated:{webpack:()=>[54265]},ssr:!1,loading:()=>(0,i.jsx)(B.l,{label:"Loading activity log"})});var e8=((r={}).AUDIT_LOG="AUDIT_LOG",r.USER_MANAGEMENT="USER_MANAGEMENT",r.SCIM="SCIM",r.AI_USAGE="AI_USAGE",r);let e9={AUDIT_LOG:"Activity Log",USER_MANAGEMENT:"User Management",SCIM:"SCIM",AI_USAGE:"AI Usage"},e6="admin-sidebar-collapsed",e7="(max-width: 767px)",te=()=>{try{if(globalThis.matchMedia(e7).matches)return!0;return"true"===globalThis.localStorage.getItem(e6)}catch{return!1}},tt=({view:e})=>{switch(e){case"AUDIT_LOG":return(0,i.jsx)(e3,{});case"USER_MANAGEMENT":return(0,i.jsx)(eI,{});case"SCIM":return(0,i.jsx)(eL,{});case"AI_USAGE":return(0,i.jsx)(e5,{});default:return(0,i.jsx)("div",{})}},ts=()=>{let{flags:e}=(0,m.A)(),t=null!==e,s=e?.adminAuditLogViewEnabled??!1,[a,r]=(0,d.useState)();(0,d.useEffect)(()=>{let e=document.documentElement,t=e.classList.contains("dark"),s=e.style.colorScheme,a=()=>{e.classList.contains("dark")&&e.classList.remove("dark"),"light"!==e.style.colorScheme&&(e.style.colorScheme="light")};a();let r=new MutationObserver(a);return r.observe(e,{attributes:!0,attributeFilter:["class","style"]}),()=>{r.disconnect();let a=(0,x.SE)();null!==a?(0,x.Ps)((0,x.zt)(a)):(t&&e.classList.add("dark"),e.style.colorScheme=s)}},[]);let[l,n]=(0,d.useState)(te),o=(0,d.useCallback)(()=>{n(e=>{try{globalThis.localStorage.setItem(e6,String(!e))}catch{}return!e})},[]);return((0,d.useEffect)(()=>{let e=globalThis.matchMedia(e7),t=e=>{e.matches&&n(!0)};return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),t)?(t&&!a&&r(s?"AUDIT_LOG":"USER_MANAGEMENT"),(0,i.jsx)(u.y.Provider,{value:!0,children:(0,i.jsxs)("div",{className:"force-light-mode bg-sidebar flex h-screen w-screen overflow-hidden",children:[(0,i.jsx)(k,{view:a,setView:r,collapsed:l}),(0,i.jsx)("div",{className:"flex min-w-0 flex-1 py-2 pr-2",children:(0,i.jsxs)("main",{className:"bg-card text-card-foreground flex min-w-0 flex-1 flex-col overflow-hidden rounded-xl shadow-[0_0_0_1px_hsl(var(--foreground)/0.09),0_4px_18px_rgb(0_0_0/0.06)]",children:[(0,i.jsxs)("header",{className:"border-border/60 flex h-12 shrink-0 items-center gap-2 border-b px-4",children:[(0,i.jsx)("button",{type:"button",onClick:o,"aria-label":l?"Expand sidebar":"Collapse sidebar","aria-expanded":!l,title:l?"Expand sidebar":"Collapse sidebar",className:"text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-ring -ml-1 flex size-7 items-center justify-center rounded-md transition-colors focus-visible:ring-1 focus-visible:outline-none [&_svg]:size-4",children:(0,i.jsx)(c.A,{})}),(0,i.jsx)("span",{className:"bg-border mx-1 h-4 w-px","aria-hidden":!0}),(0,i.jsx)("h1",{className:"text-foreground text-sm font-medium",children:a?e9[a]:""})]}),(0,i.jsx)("div",{className:"relative min-h-0 flex-1 overflow-y-auto",children:a&&(0,i.jsx)(tt,{view:a})})]})})]})})):(0,i.jsx)("div",{})},ta=()=>{let{data:e}=(0,l.I)({queryKey:["fetchUserRole"],queryFn:async()=>{let e=await fetch("/api/admin/role");
1if(!e.ok)throw Error("Failed to fetch role");return(await e.json()).data.isAdmin}});return e?(0,i.jsx)(ts,{}):!1===e?(0,i.jsx)("div",{children:"Unauthorized"}):null}},87116:()=>{},89832:(e,t,s)=>{"use strict";s.d(t,{Bc:()=>n,PR:()=>c,ZI:()=>m,k$:()=>d,m_:()=>o});var a=s(62021),r=s(74361),i=s(98966),l=s(70297);let n=i.Kq,o=i.bL,d=i.l9,c=i.i3,m=r.forwardRef(({className:e,sideOffset:t=4,...s},r)=>(0,a.jsx)(i.ZL,{children:(0,a.jsx)(i.UC,{ref:r,sideOffset:t,className:(0,l.cn)("animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-[1800] rounded-md border bg-white px-3 py-1.5 text-xs text-black shadow-md dark:border-slate-700 dark:bg-slate-800 dark:text-slate-50",e),...s})}));m.displayName=i.UC.displayName},95771:(e,t,s)=>{"use strict";s.d(t,{Cf:()=>x,Es:()=>p,HM:()=>m,L3:()=>f,LC:()=>u,ZJ:()=>c,c7:()=>h,lG:()=>o,rr:()=>g,zM:()=>d});var a=s(62021),r=s(74361),i=s(67435),l=s(88399),n=s(70297);let o=i.bL,d=i.l9,c=i.ZL,m=i.bm,u=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i.hJ,{ref:s,className:(0,n.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80",e),...t}));u.displayName=i.hJ.displayName;let x=r.forwardRef(({className:e,children:t,overlayClassName:s,overlayOnClick:r,overlayOnDoubleClick:o,hideCloseButton:d,nonDismissible:m,topAligned:x,onInteractOutside:h,onEscapeKeyDown:p,...f},g)=>(0,a.jsxs)(c,{children:[(0,a.jsx)(u,{className:s,onClick:r,onDoubleClick:o}),(0,a.jsxs)(i.UC,{ref:g,className:(0,n.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg",x&&"top-[3.75rem] translate-y-0",e),onInteractOutside:h??(m?e=>e.preventDefault():void 0),onEscapeKeyDown:p??(m?e=>e.preventDefault():void 0),...f,children:[t,!d&&!m&&(0,a.jsxs)(i.bm,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-4 top-4 z-[60] inline-flex h-8 w-8 items-center justify-center rounded-md opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none",children:[(0,a.jsx)(l.MKb,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));x.displayName=i.UC.displayName;let h=({className:e,...t})=>(0,a.jsx)("div",{className:(0,n.cn)("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});h.displayName="DialogHeader";let p=({className:e,...t})=>(0,a.jsx)("div",{className:(0,n.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});p.displayName="DialogFooter";let f=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i.hE,{ref:s,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",e),...t}));f.displayName=i.hE.displayName;let g=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i.VY,{ref:s,className:(0,n.cn)("text-muted-foreground text-sm",e),...t}));g.displayName=i.VY.displayName},95795:(e,t,s)=>{"use strict";s.d(t,{R:()=>c});var a=s(62021),r=s(28732),i=s.n(r),l=s(74361),n=s(70297);let o=1080/206,d="Levenza logo",c=(0,l.memo)(({iconMode:e="auto",showText:t=!0,className:s,priority:r=!1,iconWidth:l=28,iconHeight:c=28})=>{let m=t?"/logo/levenza-logo-deep-plum.svg":"/logo/levenza-logomark-deep-plum.svg",u=t?"/logo/levenza-logo-bright-plum-cream.svg":"/logo/levenza-logomark-cream.svg",x=t?Math.round(c*o):l,h={"aria-hidden":!0,alt:"",height:c,width:x};return"dark"===e?(0,a.jsxs)("span",{className:(0,n.cn)("inline-flex items-center",s
1),children:[(0,a.jsx)("span",{className:"sr-only",children:d}),(0,a.jsx)(i(),{...h,priority:r,src:m})]}):"light"===e?(0,a.jsxs)("span",{className:(0,n.cn)("inline-flex items-center",s),children:[(0,a.jsx)("span",{className:"sr-only",children:d}),(0,a.jsx)(i(),{...h,priority:r,src:u})]}):(0,a.jsxs)("span",{className:(0,n.cn)("inline-flex items-center",s),children:[(0,a.jsx)("span",{className:"sr-only",children:d}),(0,a.jsx)(i(),{...h,priority:!1,src:m,className:"block dark:hidden"}),(0,a.jsx)(i(),{...h,priority:!1,src:u,className:"hidden dark:block"})]})});c.displayName="BrandWordmark"},98519:(e,t,s)=>{"use strict";s.d(t,{J:()=>d});var a=s(62021),r=s(74361),i=s(86724),l=s(8771),n=s(70297);let o=(0,l.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),d=r.forwardRef(({className:e,...t},s)=>(0,a.jsx)(i.b,{ref:s,className:(0,n.cn)(o(),e),...t}));d.displayName=i.b.displayName},99149:(e,t,s)=>{"use strict";s.d(t,{K:()=>o});var a=s(62021),r=s(74361),i=s(46343),l=s(70297);let n="bg-muted text-accent-foreground hover:bg-muted/80",o=r.forwardRef(({icon:e,children:t,size:s="icon",type:o,asChild:d,isLoading:c,isActive:m,activeClassName:u=n,className:x,...h},p)=>{let f=(0,l.cn)(x,m&&u),g=void 0===m?void 0:m?"on":"off";if(d){if(!r.isValidElement(t))throw Error("IconButton with `asChild` requires a single React element child");let l="button"===t.type?t.props.type??o??"button":t.props.type;return(0,a.jsx)(i.$,{ref:p,asChild:!0,size:s,className:f,"data-state":g,...h,children:r.cloneElement(t,void 0===l?{}:{type:l},(0,a.jsxs)(a.Fragment,{children:[e,t.props.children]}))})}return(0,a.jsxs)(i.$,{ref:p,type:o??"button",size:s,isLoading:c,className:f,"data-state":g,...h,children:[e,t]})});o.displayName="IconButton"}},e=>{e.O(0,[6757,3378,5272,6791,5803,4247,8347,9135,9139,118,1100,2420,5350,8224,9918,7177,1375,4886,636,6593,8792],()=>e(e.s=49933)),_N_E=e.O()}]);
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.