codepiper 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AnalyticsPage-B2Jo5KhD.js","assets/react-vendor-B5MgMUHH.js","assets/chart-vendor-DlOHLaCG.js","assets/monaco-core-DQ5Mk8AK.js","assets/monaco-core-B_19GPAS.css","assets/PoliciesPage-Co0wDxU6.js","assets/trash-2-kiez5gqY.js","assets/pencil-BQdMfs6R.js","assets/tabs-8Wa2H5Vg.js","assets/SessionDetailPage-B02hN2vV.js","assets/refresh-cw-Bk2hIBMy.js","assets/terminal-vendor-Cs8KPbV3.js","assets/terminal-vendor-LcAfv9l9.css","assets/SettingsPage-CsblfgAu.js","assets/WorkflowsPage-D6nmynEV.js"])))=>i.map(i=>d[i]);
2
- var Nc=Object.defineProperty;var Ec=(e,t,n)=>t in e?Nc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var le=(e,t,n)=>Ec(e,typeof t!="symbol"?t+"":t,n);import{r as c,j as o,R as cs,a as Ot,W as P,v as ls,c as Ir,u as gt,d as In,N as vn,B as Cc,e as kc,f as ze,h as jc,i as Pc}from"./react-vendor-B5MgMUHH.js";import{_ as Zt}from"./monaco-core-DQ5Mk8AK.js";import{c as Tc}from"./chart-vendor-DlOHLaCG.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();async function Ge(e,t){const n=(t==null?void 0:t.timeoutMs)??15e3,r=new AbortController,s=setTimeout(()=>r.abort(),n);let a;try{a=await fetch(`/api${e}`,{...t,signal:r.signal,headers:{"Content-Type":"application/json",...t==null?void 0:t.headers}})}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request to ${e} timed out after ${n}ms. Please retry.`):i}finally{clearTimeout(s)}if(!a.ok){const i=await a.json().catch(()=>({})),l=new Error(i.error||`HTTP ${a.status}`);throw l.status=a.status,l.code=i.code,l.mfaRequired=i.mfaRequired,l.mfaSetupRequired=i.mfaSetupRequired,l.setupRequired=i.setupRequired,l.retryAfter=i.retryAfter,l}return a.json()}const jt={getStatus:()=>Ge("/auth/status"),setup:e=>Ge("/auth/setup",{method:"POST",body:JSON.stringify({password:e})}),login:(e,t)=>Ge("/auth/login",{method:"POST",body:JSON.stringify({password:e,totpCode:t})}),logout:()=>Ge("/auth/logout",{method:"POST"}),changePassword:(e,t)=>Ge("/auth/password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:t})}),mfaSetup:()=>Ge("/auth/mfa/setup",{method:"POST",timeoutMs:1e4}),mfaVerify:e=>Ge("/auth/mfa/verify",{method:"POST",body:JSON.stringify({totpCode:e})}),listSessions:()=>Ge("/auth/sessions"),revokeAllSessions:()=>Ge("/auth/sessions/revoke-all",{method:"POST"})},ds=c.createContext(null),go={setupRequired:!1,mfaEnabled:!1,mfaSetupRequired:!1,onboardingPending:!1,authenticated:!1};function _c({children:e}){const[t,n]=c.useState(!0),[r,s]=c.useState(go),a=c.useCallback(async()=>{try{const m=await jt.getStatus();s(m)}catch{s(go)}finally{n(!1)}},[]);c.useEffect(()=>{a()},[a]);const i=c.useCallback(async(m,p)=>{try{return await jt.login(m,p),await a(),{}}catch(h){if(h.mfaSetupRequired)return s(u=>({...u,setupRequired:!1,mfaSetupRequired:!0,onboardingPending:!0,authenticated:!1})),{mfaSetupRequired:!0};if(h.mfaRequired)return{mfaRequired:!0};throw h}},[a]),l=c.useCallback(async m=>(await jt.setup(m)).mfaSetupRequired?(s({setupRequired:!1,mfaEnabled:!1,mfaSetupRequired:!0,onboardingPending:!0,authenticated:!1}),{mfaSetupRequired:!0}):(await a(),{}),[a]),d=c.useCallback(async()=>{try{await jt.logout()}catch(m){console.warn("[auth] Server-side logout failed — session may remain active:",m)}await a()},[a]),f=c.useMemo(()=>({isAuthenticated:r.authenticated,isLoading:t,setupRequired:r.setupRequired,mfaEnabled:r.mfaEnabled,mfaSetupRequired:r.mfaSetupRequired??!1,onboardingPending:r.onboardingPending??!1,login:i,setup:l,logout:d,checkAuth:a}),[r,t,i,l,d,a]);return o.jsx(ds.Provider,{value:f,children:e})}function Mn(){const e=c.useContext(ds);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function Rc(){const{login:e,mfaEnabled:t,onboardingPending:n}=Mn(),[r,s]=c.useState(""),[a,i]=c.useState(""),[l,d]=c.useState(!1),[f,m]=c.useState(""),[p,h]=c.useState(!1),u=async x=>{x.preventDefault(),m(""),h(!0);try{const g=await e(r,a||void 0);g.mfaRequired&&(d(!0),i("")),g.mfaSetupRequired&&m("MFA setup is required before first sign-in. Continue in setup.")}catch(g){g.status===429?m(`Too many attempts. Try again in ${g.retryAfter||60} seconds.`):m(g.message||"Login failed")}finally{h(!1)}};return o.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background noise",children:o.jsxs("div",{className:"w-full max-w-sm mx-auto p-8",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/icon.svg",alt:"CodePiper",className:"h-20 mx-auto mb-4"}),o.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:"CodePiper"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Sign in to continue"}),n&&o.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"First-time setup: sign in with your daemon bootstrap password to continue to MFA."})]}),o.jsxs("form",{onSubmit:u,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:"Password"}),o.jsx("input",{id:"password",type:"password",value:r,onChange:x=>s(x.target.value),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50",placeholder:"Enter your password",autoFocus:!0,required:!0})]}),(l||t)&&o.jsxs("div",{children:[o.jsx("label",{htmlFor:"totp",className:"block text-sm font-medium text-foreground mb-1",children:"Authenticator Code"}),o.jsx("input",{id:"totp",type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:a,onChange:x=>i(x.target.value.replace(/\D/g,"")),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50 tracking-widest text-center text-lg",placeholder:"000000",autoFocus:l}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Enter the 6-digit code from your authenticator app or a recovery code"})]}),f&&o.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:f}),o.jsx("button",{type:"submit",disabled:p||!r,className:"w-full py-2 px-4 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-primary/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:p?"Signing in...":"Sign in"})]})]})})}function Ac(){const{setup:e,mfaSetupRequired:t,checkAuth:n}=Mn(),[r,s]=c.useState(t?"mfa":"password"),[a,i]=c.useState(""),[l,d]=c.useState(""),[f,m]=c.useState(""),[p,h]=c.useState(null),[u,x]=c.useState([]),[g,y]=c.useState(""),[b,v]=c.useState(""),[w,E]=c.useState(!1),[S,C]=c.useState(!1),k=()=>{v(""),h(null)};c.useEffect(()=>{t&&r==="password"&&s("mfa")},[t,r]),c.useEffect(()=>{if(r!=="mfa"||p||S||b)return;let D=!1;return(async()=>{C(!0),v("");try{const T=await jt.mfaSetup();D||h({qrDataUrl:T.qrDataUrl,secret:T.secret})}catch(T){D||v(T.message||"Failed to start MFA setup")}finally{D||C(!1)}})(),()=>{D=!0}},[r,p,S,b]);const I=async D=>{if(D.preventDefault(),y(""),a.length<8){y("Password must be at least 8 characters");return}if(a!==l){y("Passwords do not match");return}E(!0);try{if((await e(a)).mfaSetupRequired){s("mfa");return}}catch(W){y(W.message||"Setup failed")}finally{E(!1)}},H=async()=>{v(""),C(!0);try{const D=await jt.mfaVerify(f);x(D.recoveryCodes),s("recovery")}catch(D){v(D.message||"Failed to verify MFA code")}finally{C(!1)}};return o.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background noise",children:o.jsxs("div",{className:"w-full max-w-md mx-auto p-8",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/icon.svg",alt:"CodePiper",className:"h-20 mx-auto mb-4"}),o.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:"CodePiper Setup"}),o.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[r==="password"&&"Step 1 of 2: Create your admin password",r==="mfa"&&"Step 2 of 2: MFA is required before first sign-in",r==="recovery"&&"Save your recovery codes, then continue"]})]}),r==="password"&&o.jsxs("form",{onSubmit:I,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:"Password"}),o.jsx("input",{id:"password",type:"password",value:a,onChange:D=>i(D.target.value),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50",placeholder:"Minimum 8 characters",autoFocus:!0,required:!0,minLength:8})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:"Confirm Password"}),o.jsx("input",{id:"confirmPassword",type:"password",value:l,onChange:D=>d(D.target.value),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50",placeholder:"Re-enter your password",required:!0,minLength:8})]}),g&&o.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:g}),o.jsx("button",{type:"submit",disabled:w||a.length<8,className:"w-full py-2 px-4 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-primary/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:w?"Saving password...":"Continue to MFA setup"})]}),r==="mfa"&&o.jsxs("div",{className:"space-y-4",children:[S&&!p&&o.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"Generating authenticator QR code..."}),!(S||p)&&b&&o.jsxs("div",{className:"space-y-3",children:[o.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:b}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsx("button",{type:"button",onClick:k,className:"w-full py-2 px-4 rounded-md border border-border text-foreground hover:bg-muted transition-colors",children:"Retry setup"}),o.jsx("button",{type:"button",onClick:()=>void n(),className:"w-full py-2 px-4 rounded-md border border-border text-foreground hover:bg-muted transition-colors",children:"Back to sign-in"})]})]}),p&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code."}),p.qrDataUrl?o.jsx("div",{className:"flex justify-center",children:o.jsx("img",{src:p.qrDataUrl,alt:"MFA setup QR code",className:"w-52 h-52"})}):o.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"QR rendering is unavailable in this environment. Use the setup key below."}),o.jsxs("details",{children:[o.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer",children:"Can't scan? Enter setup key manually"}),o.jsx("code",{className:"block mt-2 p-2 bg-muted rounded text-xs font-mono break-all",children:p.secret})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"totpCode",className:"block text-sm font-medium text-foreground mb-1",children:"Authenticator code"}),o.jsx("input",{id:"totpCode",type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:f,onChange:D=>m(D.target.value.replace(/\D/g,"")),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground tracking-widest text-center text-lg focus:outline-none focus:ring-2 focus:ring-primary/50",placeholder:"000000",autoFocus:!0})]}),b&&o.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:b}),o.jsx("button",{type:"button",onClick:H,disabled:S||f.length!==6,className:"w-full py-2 px-4 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:S?"Verifying...":"Verify MFA and continue"})]})]}),r==="recovery"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"Save these recovery codes in a secure place. Each code can be used once if you lose access to your authenticator."}),o.jsx("div",{className:"grid grid-cols-2 gap-2 p-3 bg-muted rounded-md",children:u.map(D=>o.jsx("code",{className:"text-sm font-mono text-center py-1",children:D},D))}),o.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(u.join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AnalyticsPage-DqhM5ADr.js","assets/react-vendor-B5MgMUHH.js","assets/chart-vendor-DlOHLaCG.js","assets/monaco-core-DQ5Mk8AK.js","assets/monaco-core-B_19GPAS.css","assets/PoliciesPage-U-K61nH-.js","assets/trash-2-CP0E4E_1.js","assets/pencil-Da7xVL3F.js","assets/tabs-B571nOS8.js","assets/SessionDetailPage-BSz5hcHE.js","assets/refresh-cw-CPonRjbV.js","assets/terminal-vendor-Cs8KPbV3.js","assets/terminal-vendor-LcAfv9l9.css","assets/SettingsPage-Dlrev9PO.js","assets/WorkflowsPage-Chn2r8wA.js"])))=>i.map(i=>d[i]);
2
+ var Nc=Object.defineProperty;var Ec=(e,t,n)=>t in e?Nc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var le=(e,t,n)=>Ec(e,typeof t!="symbol"?t+"":t,n);import{r as c,j as o,R as cs,a as Ot,W as _,v as ls,c as Ir,u as gt,d as In,N as vn,B as Cc,e as kc,f as ze,h as jc,i as Pc}from"./react-vendor-B5MgMUHH.js";import{_ as Zt}from"./monaco-core-DQ5Mk8AK.js";import{c as Tc}from"./chart-vendor-DlOHLaCG.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();async function Ge(e,t){const n=(t==null?void 0:t.timeoutMs)??15e3,r=new AbortController,s=setTimeout(()=>r.abort(),n);let a;try{a=await fetch(`/api${e}`,{...t,signal:r.signal,headers:{"Content-Type":"application/json",...t==null?void 0:t.headers}})}catch(i){throw i instanceof DOMException&&i.name==="AbortError"?new Error(`Request to ${e} timed out after ${n}ms. Please retry.`):i}finally{clearTimeout(s)}if(!a.ok){const i=await a.json().catch(()=>({})),l=new Error(i.error||`HTTP ${a.status}`);throw l.status=a.status,l.code=i.code,l.mfaRequired=i.mfaRequired,l.mfaSetupRequired=i.mfaSetupRequired,l.setupRequired=i.setupRequired,l.retryAfter=i.retryAfter,l}return a.json()}const jt={getStatus:()=>Ge("/auth/status"),setup:e=>Ge("/auth/setup",{method:"POST",body:JSON.stringify({password:e})}),login:(e,t)=>Ge("/auth/login",{method:"POST",body:JSON.stringify({password:e,totpCode:t})}),logout:()=>Ge("/auth/logout",{method:"POST"}),changePassword:(e,t)=>Ge("/auth/password",{method:"POST",body:JSON.stringify({currentPassword:e,newPassword:t})}),mfaSetup:()=>Ge("/auth/mfa/setup",{method:"POST",timeoutMs:1e4}),mfaVerify:e=>Ge("/auth/mfa/verify",{method:"POST",body:JSON.stringify({totpCode:e})}),listSessions:()=>Ge("/auth/sessions"),revokeAllSessions:()=>Ge("/auth/sessions/revoke-all",{method:"POST"})},ds=c.createContext(null),go={setupRequired:!1,mfaEnabled:!1,mfaSetupRequired:!1,onboardingPending:!1,authenticated:!1};function _c({children:e}){const[t,n]=c.useState(!0),[r,s]=c.useState(go),a=c.useCallback(async()=>{try{const m=await jt.getStatus();s(m)}catch{s(go)}finally{n(!1)}},[]);c.useEffect(()=>{a()},[a]);const i=c.useCallback(async(m,p)=>{try{return await jt.login(m,p),await a(),{}}catch(h){if(h.mfaSetupRequired)return s(u=>({...u,setupRequired:!1,mfaSetupRequired:!0,onboardingPending:!0,authenticated:!1})),{mfaSetupRequired:!0};if(h.mfaRequired)return{mfaRequired:!0};throw h}},[a]),l=c.useCallback(async m=>(await jt.setup(m)).mfaSetupRequired?(s({setupRequired:!1,mfaEnabled:!1,mfaSetupRequired:!0,onboardingPending:!0,authenticated:!1}),{mfaSetupRequired:!0}):(await a(),{}),[a]),d=c.useCallback(async()=>{try{await jt.logout()}catch(m){console.warn("[auth] Server-side logout failed — session may remain active:",m)}await a()},[a]),f=c.useMemo(()=>({isAuthenticated:r.authenticated,isLoading:t,setupRequired:r.setupRequired,mfaEnabled:r.mfaEnabled,mfaSetupRequired:r.mfaSetupRequired??!1,onboardingPending:r.onboardingPending??!1,login:i,setup:l,logout:d,checkAuth:a}),[r,t,i,l,d,a]);return o.jsx(ds.Provider,{value:f,children:e})}function Mn(){const e=c.useContext(ds);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function Rc(){const{login:e,mfaEnabled:t,onboardingPending:n}=Mn(),[r,s]=c.useState(""),[a,i]=c.useState(""),[l,d]=c.useState(!1),[f,m]=c.useState(""),[p,h]=c.useState(!1),u=async x=>{x.preventDefault(),m(""),h(!0);try{const g=await e(r,a||void 0);g.mfaRequired&&(d(!0),i("")),g.mfaSetupRequired&&m("MFA setup is required before first sign-in. Continue in setup.")}catch(g){g.status===429?m(`Too many attempts. Try again in ${g.retryAfter||60} seconds.`):m(g.message||"Login failed")}finally{h(!1)}};return o.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background noise",children:o.jsxs("div",{className:"w-full max-w-sm mx-auto p-8",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/icon.svg",alt:"CodePiper",className:"h-20 mx-auto mb-4"}),o.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:"CodePiper"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Sign in to continue"}),n&&o.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"First-time setup: sign in with your daemon bootstrap password to continue to MFA."})]}),o.jsxs("form",{onSubmit:u,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:"Password"}),o.jsx("input",{id:"password",type:"password",value:r,onChange:x=>s(x.target.value),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50",placeholder:"Enter your password",autoFocus:!0,required:!0})]}),(l||t)&&o.jsxs("div",{children:[o.jsx("label",{htmlFor:"totp",className:"block text-sm font-medium text-foreground mb-1",children:"Authenticator Code"}),o.jsx("input",{id:"totp",type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:a,onChange:x=>i(x.target.value.replace(/\D/g,"")),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50 tracking-widest text-center text-lg",placeholder:"000000",autoFocus:l}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Enter the 6-digit code from your authenticator app or a recovery code"})]}),f&&o.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:f}),o.jsx("button",{type:"submit",disabled:p||!r,className:"w-full py-2 px-4 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-primary/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:p?"Signing in...":"Sign in"})]})]})})}function Ac(){const{setup:e,mfaSetupRequired:t,checkAuth:n}=Mn(),[r,s]=c.useState(t?"mfa":"password"),[a,i]=c.useState(""),[l,d]=c.useState(""),[f,m]=c.useState(""),[p,h]=c.useState(null),[u,x]=c.useState([]),[g,y]=c.useState(""),[b,v]=c.useState(""),[w,E]=c.useState(!1),[S,C]=c.useState(!1),[k,I]=c.useState(0),W=()=>{v(""),h(null),I(j=>j+1)};c.useEffect(()=>{t&&r==="password"&&s("mfa")},[t,r]),c.useEffect(()=>{if(r!=="mfa"||p)return;const j=k+1;let D=!1;return(async()=>{C(!0),v("");try{const T=await jt.mfaSetup();D||h({qrDataUrl:T.qrDataUrl,secret:T.secret})}catch(T){D||(console.warn(`[auth] MFA setup attempt ${j} failed`,T),v(T.message||"Failed to start MFA setup"))}finally{D||C(!1)}})(),()=>{D=!0}},[r,p,k]);const B=async j=>{if(j.preventDefault(),y(""),a.length<8){y("Password must be at least 8 characters");return}if(a!==l){y("Passwords do not match");return}E(!0);try{if((await e(a)).mfaSetupRequired){s("mfa");return}}catch(D){y(D.message||"Setup failed")}finally{E(!1)}},H=async()=>{v(""),C(!0);try{const j=await jt.mfaVerify(f);x(j.recoveryCodes),s("recovery")}catch(j){v(j.message||"Failed to verify MFA code")}finally{C(!1)}};return o.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background noise",children:o.jsxs("div",{className:"w-full max-w-md mx-auto p-8",children:[o.jsxs("div",{className:"text-center mb-8",children:[o.jsx("img",{src:"/icon.svg",alt:"CodePiper",className:"h-20 mx-auto mb-4"}),o.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:"CodePiper Setup"}),o.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[r==="password"&&"Step 1 of 2: Create your admin password",r==="mfa"&&"Step 2 of 2: MFA is required before first sign-in",r==="recovery"&&"Save your recovery codes, then continue"]})]}),r==="password"&&o.jsxs("form",{onSubmit:B,className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:"Password"}),o.jsx("input",{id:"password",type:"password",value:a,onChange:j=>i(j.target.value),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50",placeholder:"Minimum 8 characters",autoFocus:!0,required:!0,minLength:8})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:"Confirm Password"}),o.jsx("input",{id:"confirmPassword",type:"password",value:l,onChange:j=>d(j.target.value),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground placeholder-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50",placeholder:"Re-enter your password",required:!0,minLength:8})]}),g&&o.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:g}),o.jsx("button",{type:"submit",disabled:w||a.length<8,className:"w-full py-2 px-4 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-primary/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:w?"Saving password...":"Continue to MFA setup"})]}),r==="mfa"&&o.jsxs("div",{className:"space-y-4",children:[S&&!p&&o.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"Generating authenticator QR code..."}),!(S||p)&&b&&o.jsxs("div",{className:"space-y-3",children:[o.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:b}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsx("button",{type:"button",onClick:W,className:"w-full py-2 px-4 rounded-md border border-border text-foreground hover:bg-muted transition-colors",children:"Retry setup"}),o.jsx("button",{type:"button",onClick:()=>void n(),className:"w-full py-2 px-4 rounded-md border border-border text-foreground hover:bg-muted transition-colors",children:"Back to sign-in"})]})]}),p&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, 1Password, etc.), then enter the 6-digit code."}),p.qrDataUrl?o.jsx("div",{className:"flex justify-center",children:o.jsx("img",{src:p.qrDataUrl,alt:"MFA setup QR code",className:"w-52 h-52"})}):o.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"QR rendering is unavailable in this environment. Use the setup key below."}),o.jsxs("details",{children:[o.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer",children:"Can't scan? Enter setup key manually"}),o.jsx("code",{className:"block mt-2 p-2 bg-muted rounded text-xs font-mono break-all",children:p.secret})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:"totpCode",className:"block text-sm font-medium text-foreground mb-1",children:"Authenticator code"}),o.jsx("input",{id:"totpCode",type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:f,onChange:j=>m(j.target.value.replace(/\D/g,"")),className:"w-full px-3 py-2 rounded-md border border-border bg-background text-foreground tracking-widest text-center text-lg focus:outline-none focus:ring-2 focus:ring-primary/50",placeholder:"000000",autoFocus:!0})]}),b&&o.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:b}),o.jsx("button",{type:"button",onClick:H,disabled:S||f.length!==6,className:"w-full py-2 px-4 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:S?"Verifying...":"Verify MFA and continue"})]})]}),r==="recovery"&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"Save these recovery codes in a secure place. Each code can be used once if you lose access to your authenticator."}),o.jsx("div",{className:"grid grid-cols-2 gap-2 p-3 bg-muted rounded-md",children:u.map(j=>o.jsx("code",{className:"text-sm font-mono text-center py-1",children:j},j))}),o.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(u.join(`
3
3
  `)),className:"w-full py-2 px-4 rounded-md border border-border text-foreground hover:bg-muted transition-colors text-sm",children:"Copy recovery codes"}),o.jsx("button",{type:"button",onClick:()=>void n(),className:"w-full py-2 px-4 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors",children:"Enter dashboard"})]})]})})}function Ic({children:e}){const{isAuthenticated:t,isLoading:n,setupRequired:r,mfaSetupRequired:s}=Mn();return n?o.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background noise",children:o.jsx("div",{className:"text-muted-foreground text-sm",children:"Loading..."})}):r||s?o.jsx(Ac,{}):t?o.jsx(o.Fragment,{children:e}):o.jsx(Rc,{})}/**
4
4
  * @license lucide-react v0.564.0 - ISC
5
5
  *
@@ -195,10 +195,10 @@ var Nc=Object.defineProperty;var Ec=(e,t,n)=>t in e?Nc(e,t,{enumerable:!0,config
195
195
  *
196
196
  * This source code is licensed under the ISC license.
197
197
  * See the LICENSE file in the root directory of this source tree.
198
- */const Al=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Il=ee("zap",Al);function B(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e==null||e(s),n===!1||!s.defaultPrevented)return t==null?void 0:t(s)}}function yo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dn(...e){return t=>{let n=!1;const r=e.map(s=>{const a=yo(s,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let s=0;s<r.length;s++){const a=r[s];typeof a=="function"?a():yo(e[s],null)}}}}function oe(...e){return c.useCallback(Dn(...e),e)}function Ml(e,t){const n=c.createContext(t),r=a=>{const{children:i,...l}=a,d=c.useMemo(()=>l,Object.values(l));return o.jsx(n.Provider,{value:d,children:i})};r.displayName=e+"Provider";function s(a){const i=c.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,s]}function yt(e,t=[]){let n=[];function r(a,i){const l=c.createContext(i),d=n.length;n=[...n,i];const f=p=>{var b;const{scope:h,children:u,...x}=p,g=((b=h==null?void 0:h[e])==null?void 0:b[d])||l,y=c.useMemo(()=>x,Object.values(x));return o.jsx(g.Provider,{value:y,children:u})};f.displayName=a+"Provider";function m(p,h){var g;const u=((g=h==null?void 0:h[e])==null?void 0:g[d])||l,x=c.useContext(u);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[f,m]}const s=()=>{const a=n.map(i=>c.createContext(i));return function(l){const d=(l==null?void 0:l[e])||a;return c.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return s.scopeName=e,[r,Ol(s,...t)]}function Ol(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=r.reduce((l,{useScope:d,scopeName:f})=>{const p=d(a)[`__scope${f}`];return{...l,...p}},{});return c.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var me=globalThis!=null&&globalThis.document?c.useLayoutEffect:()=>{},Dl=cs[" useInsertionEffect ".trim().toString()]||me;function Kt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[s,a,i]=Ll({defaultProp:t,onChange:n}),l=e!==void 0,d=l?e:s;{const m=c.useRef(e!==void 0);c.useEffect(()=>{const p=m.current;p!==l&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),m.current=l},[l,r])}const f=c.useCallback(m=>{var p;if(l){const h=$l(m)?m(e):m;h!==e&&((p=i.current)==null||p.call(i,h))}else a(m)},[l,e,a,i]);return[d,f]}function Ll({defaultProp:e,onChange:t}){const[n,r]=c.useState(e),s=c.useRef(n),a=c.useRef(t);return Dl(()=>{a.current=t},[t]),c.useEffect(()=>{var i;s.current!==n&&((i=a.current)==null||i.call(a,n),s.current=n)},[n,s]),[n,r,a]}function $l(e){return typeof e=="function"}function At(e){const t=Fl(e),n=c.forwardRef((r,s)=>{const{children:a,...i}=r,l=c.Children.toArray(a),d=l.find(Ul);if(d){const f=d.props.children,m=l.map(p=>p===d?c.Children.count(f)>1?c.Children.only(null):c.isValidElement(f)?f.props.children:null:p);return o.jsx(t,{...i,ref:s,children:c.isValidElement(f)?c.cloneElement(f,void 0,m):null})}return o.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function Fl(e){const t=c.forwardRef((n,r)=>{const{children:s,...a}=n;if(c.isValidElement(s)){const i=Hl(s),l=Wl(a,s.props);return s.type!==c.Fragment&&(l.ref=r?Dn(r,i):i),c.cloneElement(s,l)}return c.Children.count(s)>1?c.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Bl=Symbol("radix.slottable");function Ul(e){return c.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Bl}function Wl(e,t){const n={...t};for(const r in t){const s=e[r],a=t[r];/^on[A-Z]/.test(r)?s&&a?n[r]=(...l)=>{const d=a(...l);return s(...l),d}:s&&(n[r]=s):r==="style"?n[r]={...s,...a}:r==="className"&&(n[r]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function Hl(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Vl=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Q=Vl.reduce((e,t)=>{const n=At(`Primitive.${t}`),r=c.forwardRef((s,a)=>{const{asChild:i,...l}=s,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(d,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function bs(e,t){e&&Ot.flushSync(()=>e.dispatchEvent(t))}function Dr(e){const t=e+"CollectionProvider",[n,r]=yt(t),[s,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:y,children:b}=g,v=P.useRef(null),w=P.useRef(new Map).current;return o.jsx(s,{scope:y,itemMap:w,collectionRef:v,children:b})};i.displayName=t;const l=e+"CollectionSlot",d=At(l),f=P.forwardRef((g,y)=>{const{scope:b,children:v}=g,w=a(l,b),E=oe(y,w.collectionRef);return o.jsx(d,{ref:E,children:v})});f.displayName=l;const m=e+"CollectionItemSlot",p="data-radix-collection-item",h=At(m),u=P.forwardRef((g,y)=>{const{scope:b,children:v,...w}=g,E=P.useRef(null),S=oe(y,E),C=a(m,b);return P.useEffect(()=>(C.itemMap.set(E,{ref:E,...w}),()=>void C.itemMap.delete(E))),o.jsx(h,{[p]:"",ref:S,children:v})});u.displayName=m;function x(g){const y=a(e+"CollectionConsumer",g);return P.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const w=Array.from(v.querySelectorAll(`[${p}]`));return Array.from(y.itemMap.values()).sort((C,k)=>w.indexOf(C.ref.current)-w.indexOf(k.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:f,ItemSlot:u},x,r]}var ql=c.createContext(void 0);function Lr(e){const t=c.useContext(ql);return e||t||"ltr"}function We(e){const t=c.useRef(e);return c.useEffect(()=>{t.current=e}),c.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Kl(e,t=globalThis==null?void 0:globalThis.document){const n=We(e);c.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var zl="DismissableLayer",pr="dismissableLayer.update",Gl="dismissableLayer.pointerDownOutside",Yl="dismissableLayer.focusOutside",bo,vs=c.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ln=c.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...d}=e,f=c.useContext(vs),[m,p]=c.useState(null),h=(m==null?void 0:m.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,u]=c.useState({}),x=oe(t,k=>p(k)),g=Array.from(f.layers),[y]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),b=g.indexOf(y),v=m?g.indexOf(m):-1,w=f.layersWithOutsidePointerEventsDisabled.size>0,E=v>=b,S=Zl(k=>{const I=k.target,H=[...f.branches].some(D=>D.contains(I));!E||H||(s==null||s(k),i==null||i(k),k.defaultPrevented||l==null||l())},h),C=Ql(k=>{const I=k.target;[...f.branches].some(D=>D.contains(I))||(a==null||a(k),i==null||i(k),k.defaultPrevented||l==null||l())},h);return Kl(k=>{v===f.layers.size-1&&(r==null||r(k),!k.defaultPrevented&&l&&(k.preventDefault(),l()))},h),c.useEffect(()=>{if(m)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(bo=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(m)),f.layers.add(m),vo(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=bo)}},[m,h,n,f]),c.useEffect(()=>()=>{m&&(f.layers.delete(m),f.layersWithOutsidePointerEventsDisabled.delete(m),vo())},[m,f]),c.useEffect(()=>{const k=()=>u({});return document.addEventListener(pr,k),()=>document.removeEventListener(pr,k)},[]),o.jsx(Q.div,{...d,ref:x,style:{pointerEvents:w?E?"auto":"none":void 0,...e.style},onFocusCapture:B(e.onFocusCapture,C.onFocusCapture),onBlurCapture:B(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:B(e.onPointerDownCapture,S.onPointerDownCapture)})});Ln.displayName=zl;var Jl="DismissableLayerBranch",Xl=c.forwardRef((e,t)=>{const n=c.useContext(vs),r=c.useRef(null),s=oe(t,r);return c.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),o.jsx(Q.div,{...e,ref:s})});Xl.displayName=Jl;function Zl(e,t=globalThis==null?void 0:globalThis.document){const n=We(e),r=c.useRef(!1),s=c.useRef(()=>{});return c.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let d=function(){ws(Gl,n,f,{discrete:!0})};const f={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=d,t.addEventListener("click",s.current,{once:!0})):d()}else t.removeEventListener("click",s.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Ql(e,t=globalThis==null?void 0:globalThis.document){const n=We(e),r=c.useRef(!1);return c.useEffect(()=>{const s=a=>{a.target&&!r.current&&ws(Yl,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function vo(){const e=new CustomEvent(pr);document.dispatchEvent(e)}function ws(e,t,n,{discrete:r}){const s=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?bs(s,a):s.dispatchEvent(a)}var tr=0;function $r(){c.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??wo()),document.body.insertAdjacentElement("beforeend",e[1]??wo()),tr++,()=>{tr===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),tr--}},[])}function wo(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var nr="focusScope.autoFocusOnMount",rr="focusScope.autoFocusOnUnmount",So={bubbles:!1,cancelable:!0},ed="FocusScope",$n=c.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,d]=c.useState(null),f=We(s),m=We(a),p=c.useRef(null),h=oe(t,g=>d(g)),u=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(r){let g=function(w){if(u.paused||!l)return;const E=w.target;l.contains(E)?p.current=E:rt(p.current,{select:!0})},y=function(w){if(u.paused||!l)return;const E=w.relatedTarget;E!==null&&(l.contains(E)||rt(p.current,{select:!0}))},b=function(w){if(document.activeElement===document.body)for(const S of w)S.removedNodes.length>0&&rt(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",y);const v=new MutationObserver(b);return l&&v.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",y),v.disconnect()}}},[r,l,u.paused]),c.useEffect(()=>{if(l){Eo.add(u);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(nr,So);l.addEventListener(nr,f),l.dispatchEvent(b),b.defaultPrevented||(td(ad(Ss(l)),{select:!0}),document.activeElement===g&&rt(l))}return()=>{l.removeEventListener(nr,f),setTimeout(()=>{const b=new CustomEvent(rr,So);l.addEventListener(rr,m),l.dispatchEvent(b),b.defaultPrevented||rt(g??document.body,{select:!0}),l.removeEventListener(rr,m),Eo.remove(u)},0)}}},[l,f,m,u]);const x=c.useCallback(g=>{if(!n&&!r||u.paused)return;const y=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,b=document.activeElement;if(y&&b){const v=g.currentTarget,[w,E]=nd(v);w&&E?!g.shiftKey&&b===E?(g.preventDefault(),n&&rt(w,{select:!0})):g.shiftKey&&b===w&&(g.preventDefault(),n&&rt(E,{select:!0})):b===v&&g.preventDefault()}},[n,r,u.paused]);return o.jsx(Q.div,{tabIndex:-1,...i,ref:h,onKeyDown:x})});$n.displayName=ed;function td(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(rt(r,{select:t}),document.activeElement!==n)return}function nd(e){const t=Ss(e),n=No(t,e),r=No(t.reverse(),e);return[n,r]}function Ss(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function No(e,t){for(const n of e)if(!rd(n,{upTo:t}))return n}function rd(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function od(e){return e instanceof HTMLInputElement&&"select"in e}function rt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&od(e)&&t&&e.select()}}var Eo=sd();function sd(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Co(e,t),e.unshift(t)},remove(t){var n;e=Co(e,t),(n=e[0])==null||n.resume()}}}function Co(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ad(e){return e.filter(t=>t.tagName!=="A")}var id=cs[" useId ".trim().toString()]||(()=>{}),cd=0;function Ye(e){const[t,n]=c.useState(id());return me(()=>{n(r=>r??String(cd++))},[e]),t?`radix-${t}`:""}const ld=["top","right","bottom","left"],ot=Math.min,Ee=Math.max,wn=Math.round,un=Math.floor,Ue=e=>({x:e,y:e}),dd={left:"right",right:"left",bottom:"top",top:"bottom"},ud={start:"end",end:"start"};function mr(e,t,n){return Ee(e,ot(t,n))}function Je(e,t){return typeof e=="function"?e(t):e}function Xe(e){return e.split("-")[0]}function Dt(e){return e.split("-")[1]}function Fr(e){return e==="x"?"y":"x"}function Br(e){return e==="y"?"height":"width"}const fd=new Set(["top","bottom"]);function Be(e){return fd.has(Xe(e))?"y":"x"}function Ur(e){return Fr(Be(e))}function pd(e,t,n){n===void 0&&(n=!1);const r=Dt(e),s=Ur(e),a=Br(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=Sn(i)),[i,Sn(i)]}function md(e){const t=Sn(e);return[hr(e),t,hr(t)]}function hr(e){return e.replace(/start|end/g,t=>ud[t])}const ko=["left","right"],jo=["right","left"],hd=["top","bottom"],gd=["bottom","top"];function xd(e,t,n){switch(e){case"top":case"bottom":return n?t?jo:ko:t?ko:jo;case"left":case"right":return t?hd:gd;default:return[]}}function yd(e,t,n,r){const s=Dt(e);let a=xd(Xe(e),n==="start",r);return s&&(a=a.map(i=>i+"-"+s),t&&(a=a.concat(a.map(hr)))),a}function Sn(e){return e.replace(/left|right|bottom|top/g,t=>dd[t])}function bd(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ns(e){return typeof e!="number"?bd(e):{top:e,right:e,bottom:e,left:e}}function Nn(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function Po(e,t,n){let{reference:r,floating:s}=e;const a=Be(t),i=Ur(t),l=Br(i),d=Xe(t),f=a==="y",m=r.x+r.width/2-s.width/2,p=r.y+r.height/2-s.height/2,h=r[l]/2-s[l]/2;let u;switch(d){case"top":u={x:m,y:r.y-s.height};break;case"bottom":u={x:m,y:r.y+r.height};break;case"right":u={x:r.x+r.width,y:p};break;case"left":u={x:r.x-s.width,y:p};break;default:u={x:r.x,y:r.y}}switch(Dt(t)){case"start":u[i]-=h*(n&&f?-1:1);break;case"end":u[i]+=h*(n&&f?-1:1);break}return u}async function vd(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:a,rects:i,elements:l,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:m="viewport",elementContext:p="floating",altBoundary:h=!1,padding:u=0}=Je(t,e),x=Ns(u),y=l[h?p==="floating"?"reference":"floating":p],b=Nn(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(y)))==null||n?y:y.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:f,rootBoundary:m,strategy:d})),v=p==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),E=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},S=Nn(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:w,strategy:d}):v);return{top:(b.top-S.top+x.top)/E.y,bottom:(S.bottom-b.bottom+x.bottom)/E.y,left:(b.left-S.left+x.left)/E.x,right:(S.right-b.right+x.right)/E.x}}const wd=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:a=[],platform:i}=n,l=a.filter(Boolean),d=await(i.isRTL==null?void 0:i.isRTL(t));let f=await i.getElementRects({reference:e,floating:t,strategy:s}),{x:m,y:p}=Po(f,r,d),h=r,u={},x=0;for(let y=0;y<l.length;y++){var g;const{name:b,fn:v}=l[y],{x:w,y:E,data:S,reset:C}=await v({x:m,y:p,initialPlacement:r,placement:h,strategy:s,middlewareData:u,rects:f,platform:{...i,detectOverflow:(g=i.detectOverflow)!=null?g:vd},elements:{reference:e,floating:t}});m=w??m,p=E??p,u={...u,[b]:{...u[b],...S}},C&&x<=50&&(x++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(f=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:s}):C.rects),{x:m,y:p}=Po(f,h,d)),y=-1)}return{x:m,y:p,placement:h,strategy:s,middlewareData:u}},Sd=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:a,platform:i,elements:l,middlewareData:d}=t,{element:f,padding:m=0}=Je(e,t)||{};if(f==null)return{};const p=Ns(m),h={x:n,y:r},u=Ur(s),x=Br(u),g=await i.getDimensions(f),y=u==="y",b=y?"top":"left",v=y?"bottom":"right",w=y?"clientHeight":"clientWidth",E=a.reference[x]+a.reference[u]-h[u]-a.floating[x],S=h[u]-a.reference[u],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(f));let k=C?C[w]:0;(!k||!await(i.isElement==null?void 0:i.isElement(C)))&&(k=l.floating[w]||a.floating[x]);const I=E/2-S/2,H=k/2-g[x]/2-1,D=ot(p[b],H),W=ot(p[v],H),T=D,L=k-g[x]-W,$=k/2-g[x]/2+I,_=mr(T,$,L),j=!d.arrow&&Dt(s)!=null&&$!==_&&a.reference[x]/2-($<T?D:W)-g[x]/2<0,R=j?$<T?$-T:$-L:0;return{[u]:h[u]+R,data:{[u]:_,centerOffset:$-_-R,...j&&{alignmentOffset:R}},reset:j}}}),Nd=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:a,rects:i,initialPlacement:l,platform:d,elements:f}=t,{mainAxis:m=!0,crossAxis:p=!0,fallbackPlacements:h,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:g=!0,...y}=Je(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const b=Xe(s),v=Be(l),w=Xe(l)===l,E=await(d.isRTL==null?void 0:d.isRTL(f.floating)),S=h||(w||!g?[Sn(l)]:md(l)),C=x!=="none";!h&&C&&S.push(...yd(l,g,x,E));const k=[l,...S],I=await d.detectOverflow(t,y),H=[];let D=((r=a.flip)==null?void 0:r.overflows)||[];if(m&&H.push(I[b]),p){const $=pd(s,i,E);H.push(I[$[0]],I[$[1]])}if(D=[...D,{placement:s,overflows:H}],!H.every($=>$<=0)){var W,T;const $=(((W=a.flip)==null?void 0:W.index)||0)+1,_=k[$];if(_&&(!(p==="alignment"?v!==Be(_):!1)||D.every(A=>Be(A.placement)===v?A.overflows[0]>0:!0)))return{data:{index:$,overflows:D},reset:{placement:_}};let j=(T=D.filter(R=>R.overflows[0]<=0).sort((R,A)=>R.overflows[1]-A.overflows[1])[0])==null?void 0:T.placement;if(!j)switch(u){case"bestFit":{var L;const R=(L=D.filter(A=>{if(C){const N=Be(A.placement);return N===v||N==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(N=>N>0).reduce((N,U)=>N+U,0)]).sort((A,N)=>A[1]-N[1])[0])==null?void 0:L[0];R&&(j=R);break}case"initialPlacement":j=l;break}if(s!==j)return{reset:{placement:j}}}return{}}}};function To(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function _o(e){return ld.some(t=>e[t]>=0)}const Ed=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...a}=Je(e,t);switch(s){case"referenceHidden":{const i=await r.detectOverflow(t,{...a,elementContext:"reference"}),l=To(i,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:_o(l)}}}case"escaped":{const i=await r.detectOverflow(t,{...a,altBoundary:!0}),l=To(i,n.floating);return{data:{escapedOffsets:l,escaped:_o(l)}}}default:return{}}}}},Es=new Set(["left","top"]);async function Cd(e,t){const{placement:n,platform:r,elements:s}=e,a=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=Xe(n),l=Dt(n),d=Be(n)==="y",f=Es.has(i)?-1:1,m=a&&d?-1:1,p=Je(t,e);let{mainAxis:h,crossAxis:u,alignmentAxis:x}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof x=="number"&&(u=l==="end"?x*-1:x),d?{x:u*m,y:h*f}:{x:h*f,y:u*m}}const kd=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:a,placement:i,middlewareData:l}=t,d=await Cd(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+d.x,y:a+d.y,data:{...d,placement:i}}}}},jd=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:a}=t,{mainAxis:i=!0,crossAxis:l=!1,limiter:d={fn:b=>{let{x:v,y:w}=b;return{x:v,y:w}}},...f}=Je(e,t),m={x:n,y:r},p=await a.detectOverflow(t,f),h=Be(Xe(s)),u=Fr(h);let x=m[u],g=m[h];if(i){const b=u==="y"?"top":"left",v=u==="y"?"bottom":"right",w=x+p[b],E=x-p[v];x=mr(w,x,E)}if(l){const b=h==="y"?"top":"left",v=h==="y"?"bottom":"right",w=g+p[b],E=g-p[v];g=mr(w,g,E)}const y=d.fn({...t,[u]:x,[h]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[u]:i,[h]:l}}}}}},Pd=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:a,middlewareData:i}=t,{offset:l=0,mainAxis:d=!0,crossAxis:f=!0}=Je(e,t),m={x:n,y:r},p=Be(s),h=Fr(p);let u=m[h],x=m[p];const g=Je(l,t),y=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(d){const w=h==="y"?"height":"width",E=a.reference[h]-a.floating[w]+y.mainAxis,S=a.reference[h]+a.reference[w]-y.mainAxis;u<E?u=E:u>S&&(u=S)}if(f){var b,v;const w=h==="y"?"width":"height",E=Es.has(Xe(s)),S=a.reference[p]-a.floating[w]+(E&&((b=i.offset)==null?void 0:b[p])||0)+(E?0:y.crossAxis),C=a.reference[p]+a.reference[w]+(E?0:((v=i.offset)==null?void 0:v[p])||0)-(E?y.crossAxis:0);x<S?x=S:x>C&&(x=C)}return{[h]:u,[p]:x}}}},Td=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:a,platform:i,elements:l}=t,{apply:d=()=>{},...f}=Je(e,t),m=await i.detectOverflow(t,f),p=Xe(s),h=Dt(s),u=Be(s)==="y",{width:x,height:g}=a.floating;let y,b;p==="top"||p==="bottom"?(y=p,b=h===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(b=p,y=h==="end"?"top":"bottom");const v=g-m.top-m.bottom,w=x-m.left-m.right,E=ot(g-m[y],v),S=ot(x-m[b],w),C=!t.middlewareData.shift;let k=E,I=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(I=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=v),C&&!h){const D=Ee(m.left,0),W=Ee(m.right,0),T=Ee(m.top,0),L=Ee(m.bottom,0);u?I=x-2*(D!==0||W!==0?D+W:Ee(m.left,m.right)):k=g-2*(T!==0||L!==0?T+L:Ee(m.top,m.bottom))}await d({...t,availableWidth:I,availableHeight:k});const H=await i.getDimensions(l.floating);return x!==H.width||g!==H.height?{reset:{rects:!0}}:{}}}};function Fn(){return typeof window<"u"}function Lt(e){return Cs(e)?(e.nodeName||"").toLowerCase():"#document"}function Ce(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ve(e){var t;return(t=(Cs(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Cs(e){return Fn()?e instanceof Node||e instanceof Ce(e).Node:!1}function Oe(e){return Fn()?e instanceof Element||e instanceof Ce(e).Element:!1}function He(e){return Fn()?e instanceof HTMLElement||e instanceof Ce(e).HTMLElement:!1}function Ro(e){return!Fn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ce(e).ShadowRoot}const _d=new Set(["inline","contents"]);function Qt(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=De(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!_d.has(s)}const Rd=new Set(["table","td","th"]);function Ad(e){return Rd.has(Lt(e))}const Id=[":popover-open",":modal"];function Bn(e){return Id.some(t=>{try{return e.matches(t)}catch{return!1}})}const Md=["transform","translate","scale","rotate","perspective"],Od=["transform","translate","scale","rotate","perspective","filter"],Dd=["paint","layout","strict","content"];function Wr(e){const t=Hr(),n=Oe(e)?De(e):e;return Md.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Od.some(r=>(n.willChange||"").includes(r))||Dd.some(r=>(n.contain||"").includes(r))}function Ld(e){let t=st(e);for(;He(t)&&!It(t);){if(Wr(t))return t;if(Bn(t))return null;t=st(t)}return null}function Hr(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const $d=new Set(["html","body","#document"]);function It(e){return $d.has(Lt(e))}function De(e){return Ce(e).getComputedStyle(e)}function Un(e){return Oe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function st(e){if(Lt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ro(e)&&e.host||Ve(e);return Ro(t)?t.host:t}function ks(e){const t=st(e);return It(t)?e.ownerDocument?e.ownerDocument.body:e.body:He(t)&&Qt(t)?t:ks(t)}function zt(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=ks(e),a=s===((r=e.ownerDocument)==null?void 0:r.body),i=Ce(s);if(a){const l=gr(i);return t.concat(i,i.visualViewport||[],Qt(s)?s:[],l&&n?zt(l):[])}return t.concat(s,zt(s,[],n))}function gr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function js(e){const t=De(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=He(e),a=s?e.offsetWidth:n,i=s?e.offsetHeight:r,l=wn(n)!==a||wn(r)!==i;return l&&(n=a,r=i),{width:n,height:r,$:l}}function Vr(e){return Oe(e)?e:e.contextElement}function _t(e){const t=Vr(e);if(!He(t))return Ue(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:a}=js(t);let i=(a?wn(n.width):n.width)/r,l=(a?wn(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const Fd=Ue(0);function Ps(e){const t=Ce(e);return!Hr()||!t.visualViewport?Fd:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Bd(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ce(e)?!1:t}function ft(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),a=Vr(e);let i=Ue(1);t&&(r?Oe(r)&&(i=_t(r)):i=_t(e));const l=Bd(a,n,r)?Ps(a):Ue(0);let d=(s.left+l.x)/i.x,f=(s.top+l.y)/i.y,m=s.width/i.x,p=s.height/i.y;if(a){const h=Ce(a),u=r&&Oe(r)?Ce(r):r;let x=h,g=gr(x);for(;g&&r&&u!==x;){const y=_t(g),b=g.getBoundingClientRect(),v=De(g),w=b.left+(g.clientLeft+parseFloat(v.paddingLeft))*y.x,E=b.top+(g.clientTop+parseFloat(v.paddingTop))*y.y;d*=y.x,f*=y.y,m*=y.x,p*=y.y,d+=w,f+=E,x=Ce(g),g=gr(x)}}return Nn({width:m,height:p,x:d,y:f})}function Wn(e,t){const n=Un(e).scrollLeft;return t?t.left+n:ft(Ve(e)).left+n}function Ts(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Wn(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Ud(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const a=s==="fixed",i=Ve(r),l=t?Bn(t.floating):!1;if(r===i||l&&a)return n;let d={scrollLeft:0,scrollTop:0},f=Ue(1);const m=Ue(0),p=He(r);if((p||!p&&!a)&&((Lt(r)!=="body"||Qt(i))&&(d=Un(r)),He(r))){const u=ft(r);f=_t(r),m.x=u.x+r.clientLeft,m.y=u.y+r.clientTop}const h=i&&!p&&!a?Ts(i,d):Ue(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+m.x+h.x,y:n.y*f.y-d.scrollTop*f.y+m.y+h.y}}function Wd(e){return Array.from(e.getClientRects())}function Hd(e){const t=Ve(e),n=Un(e),r=e.ownerDocument.body,s=Ee(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Ee(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Wn(e);const l=-n.scrollTop;return De(r).direction==="rtl"&&(i+=Ee(t.clientWidth,r.clientWidth)-s),{width:s,height:a,x:i,y:l}}const Ao=25;function Vd(e,t){const n=Ce(e),r=Ve(e),s=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,l=0,d=0;if(s){a=s.width,i=s.height;const m=Hr();(!m||m&&t==="fixed")&&(l=s.offsetLeft,d=s.offsetTop)}const f=Wn(r);if(f<=0){const m=r.ownerDocument,p=m.body,h=getComputedStyle(p),u=m.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,x=Math.abs(r.clientWidth-p.clientWidth-u);x<=Ao&&(a-=x)}else f<=Ao&&(a+=f);return{width:a,height:i,x:l,y:d}}const qd=new Set(["absolute","fixed"]);function Kd(e,t){const n=ft(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,a=He(e)?_t(e):Ue(1),i=e.clientWidth*a.x,l=e.clientHeight*a.y,d=s*a.x,f=r*a.y;return{width:i,height:l,x:d,y:f}}function Io(e,t,n){let r;if(t==="viewport")r=Vd(e,n);else if(t==="document")r=Hd(Ve(e));else if(Oe(t))r=Kd(t,n);else{const s=Ps(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Nn(r)}function _s(e,t){const n=st(e);return n===t||!Oe(n)||It(n)?!1:De(n).position==="fixed"||_s(n,t)}function zd(e,t){const n=t.get(e);if(n)return n;let r=zt(e,[],!1).filter(l=>Oe(l)&&Lt(l)!=="body"),s=null;const a=De(e).position==="fixed";let i=a?st(e):e;for(;Oe(i)&&!It(i);){const l=De(i),d=Wr(i);!d&&l.position==="fixed"&&(s=null),(a?!d&&!s:!d&&l.position==="static"&&!!s&&qd.has(s.position)||Qt(i)&&!d&&_s(e,i))?r=r.filter(m=>m!==i):s=l,i=st(i)}return t.set(e,r),r}function Gd(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?Bn(t)?[]:zd(t,this._c):[].concat(n),r],l=i[0],d=i.reduce((f,m)=>{const p=Io(t,m,s);return f.top=Ee(p.top,f.top),f.right=ot(p.right,f.right),f.bottom=ot(p.bottom,f.bottom),f.left=Ee(p.left,f.left),f},Io(t,l,s));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Yd(e){const{width:t,height:n}=js(e);return{width:t,height:n}}function Jd(e,t,n){const r=He(t),s=Ve(t),a=n==="fixed",i=ft(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const d=Ue(0);function f(){d.x=Wn(s)}if(r||!r&&!a)if((Lt(t)!=="body"||Qt(s))&&(l=Un(t)),r){const u=ft(t,!0,a,t);d.x=u.x+t.clientLeft,d.y=u.y+t.clientTop}else s&&f();a&&!r&&s&&f();const m=s&&!r&&!a?Ts(s,l):Ue(0),p=i.left+l.scrollLeft-d.x-m.x,h=i.top+l.scrollTop-d.y-m.y;return{x:p,y:h,width:i.width,height:i.height}}function or(e){return De(e).position==="static"}function Mo(e,t){if(!He(e)||De(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ve(e)===n&&(n=n.ownerDocument.body),n}function Rs(e,t){const n=Ce(e);if(Bn(e))return n;if(!He(e)){let s=st(e);for(;s&&!It(s);){if(Oe(s)&&!or(s))return s;s=st(s)}return n}let r=Mo(e,t);for(;r&&Ad(r)&&or(r);)r=Mo(r,t);return r&&It(r)&&or(r)&&!Wr(r)?n:r||Ld(e)||n}const Xd=async function(e){const t=this.getOffsetParent||Rs,n=this.getDimensions,r=await n(e.floating);return{reference:Jd(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Zd(e){return De(e).direction==="rtl"}const Qd={convertOffsetParentRelativeRectToViewportRelativeRect:Ud,getDocumentElement:Ve,getClippingRect:Gd,getOffsetParent:Rs,getElementRects:Xd,getClientRects:Wd,getDimensions:Yd,getScale:_t,isElement:Oe,isRTL:Zd};function As(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function eu(e,t){let n=null,r;const s=Ve(e);function a(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function i(l,d){l===void 0&&(l=!1),d===void 0&&(d=1),a();const f=e.getBoundingClientRect(),{left:m,top:p,width:h,height:u}=f;if(l||t(),!h||!u)return;const x=un(p),g=un(s.clientWidth-(m+h)),y=un(s.clientHeight-(p+u)),b=un(m),w={rootMargin:-x+"px "+-g+"px "+-y+"px "+-b+"px",threshold:Ee(0,ot(1,d))||1};let E=!0;function S(C){const k=C[0].intersectionRatio;if(k!==d){if(!E)return i();k?i(!1,k):r=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!As(f,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(S,{...w,root:s.ownerDocument})}catch{n=new IntersectionObserver(S,w)}n.observe(e)}return i(!0),a}function tu(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,f=Vr(e),m=s||a?[...f?zt(f):[],...zt(t)]:[];m.forEach(b=>{s&&b.addEventListener("scroll",n,{passive:!0}),a&&b.addEventListener("resize",n)});const p=f&&l?eu(f,n):null;let h=-1,u=null;i&&(u=new ResizeObserver(b=>{let[v]=b;v&&v.target===f&&u&&(u.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=u)==null||w.observe(t)})),n()}),f&&!d&&u.observe(f),u.observe(t));let x,g=d?ft(e):null;d&&y();function y(){const b=ft(e);g&&!As(g,b)&&n(),g=b,x=requestAnimationFrame(y)}return n(),()=>{var b;m.forEach(v=>{s&&v.removeEventListener("scroll",n),a&&v.removeEventListener("resize",n)}),p==null||p(),(b=u)==null||b.disconnect(),u=null,d&&cancelAnimationFrame(x)}}const nu=kd,ru=jd,ou=Nd,su=Td,au=Ed,Oo=Sd,iu=Pd,cu=(e,t,n)=>{const r=new Map,s={platform:Qd,...n},a={...s.platform,_c:r};return wd(e,t,{...s,platform:a})};var lu=typeof document<"u",du=function(){},xn=lu?c.useLayoutEffect:du;function En(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!En(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const a=s[r];if(!(a==="_owner"&&e.$$typeof)&&!En(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Is(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Do(e,t){const n=Is(e);return Math.round(t*n)/n}function sr(e){const t=c.useRef(e);return xn(()=>{t.current=e}),t}function uu(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:a,floating:i}={},transform:l=!0,whileElementsMounted:d,open:f}=e,[m,p]=c.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,u]=c.useState(r);En(h,r)||u(r);const[x,g]=c.useState(null),[y,b]=c.useState(null),v=c.useCallback(A=>{A!==C.current&&(C.current=A,g(A))},[]),w=c.useCallback(A=>{A!==k.current&&(k.current=A,b(A))},[]),E=a||x,S=i||y,C=c.useRef(null),k=c.useRef(null),I=c.useRef(m),H=d!=null,D=sr(d),W=sr(s),T=sr(f),L=c.useCallback(()=>{if(!C.current||!k.current)return;const A={placement:t,strategy:n,middleware:h};W.current&&(A.platform=W.current),cu(C.current,k.current,A).then(N=>{const U={...N,isPositioned:T.current!==!1};$.current&&!En(I.current,U)&&(I.current=U,Ot.flushSync(()=>{p(U)}))})},[h,t,n,W,T]);xn(()=>{f===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,p(A=>({...A,isPositioned:!1})))},[f]);const $=c.useRef(!1);xn(()=>($.current=!0,()=>{$.current=!1}),[]),xn(()=>{if(E&&(C.current=E),S&&(k.current=S),E&&S){if(D.current)return D.current(E,S,L);L()}},[E,S,L,D,H]);const _=c.useMemo(()=>({reference:C,floating:k,setReference:v,setFloating:w}),[v,w]),j=c.useMemo(()=>({reference:E,floating:S}),[E,S]),R=c.useMemo(()=>{const A={position:n,left:0,top:0};if(!j.floating)return A;const N=Do(j.floating,m.x),U=Do(j.floating,m.y);return l?{...A,transform:"translate("+N+"px, "+U+"px)",...Is(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:U}},[n,l,j.floating,m.x,m.y]);return c.useMemo(()=>({...m,update:L,refs:_,elements:j,floatingStyles:R}),[m,L,_,j,R])}const fu=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Oo({element:r.current,padding:s}).fn(n):{}:r?Oo({element:r,padding:s}).fn(n):{}}}},pu=(e,t)=>({...nu(e),options:[e,t]}),mu=(e,t)=>({...ru(e),options:[e,t]}),hu=(e,t)=>({...iu(e),options:[e,t]}),gu=(e,t)=>({...ou(e),options:[e,t]}),xu=(e,t)=>({...su(e),options:[e,t]}),yu=(e,t)=>({...au(e),options:[e,t]}),bu=(e,t)=>({...fu(e),options:[e,t]});var vu="Arrow",Ms=c.forwardRef((e,t)=>{const{children:n,width:r=10,height:s=5,...a}=e;return o.jsx(Q.svg,{...a,ref:t,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ms.displayName=vu;var wu=Ms;function Su(e){const[t,n]=c.useState(void 0);return me(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const a=s[0];let i,l;if("borderBoxSize"in a){const d=a.borderBoxSize,f=Array.isArray(d)?d[0]:d;i=f.inlineSize,l=f.blockSize}else i=e.offsetWidth,l=e.offsetHeight;n({width:i,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var qr="Popper",[Os,Hn]=yt(qr),[Nu,Ds]=Os(qr),Ls=e=>{const{__scopePopper:t,children:n}=e,[r,s]=c.useState(null);return o.jsx(Nu,{scope:t,anchor:r,onAnchorChange:s,children:n})};Ls.displayName=qr;var $s="PopperAnchor",Fs=c.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,a=Ds($s,n),i=c.useRef(null),l=oe(t,i),d=c.useRef(null);return c.useEffect(()=>{const f=d.current;d.current=(r==null?void 0:r.current)||i.current,f!==d.current&&a.onAnchorChange(d.current)}),r?null:o.jsx(Q.div,{...s,ref:l})});Fs.displayName=$s;var Kr="PopperContent",[Eu,Cu]=Os(Kr),Bs=c.forwardRef((e,t)=>{var M,Z,X,J,q,Y;const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:m=0,sticky:p="partial",hideWhenDetached:h=!1,updatePositionStrategy:u="optimized",onPlaced:x,...g}=e,y=Ds(Kr,n),[b,v]=c.useState(null),w=oe(t,ce=>v(ce)),[E,S]=c.useState(null),C=Su(E),k=(C==null?void 0:C.width)??0,I=(C==null?void 0:C.height)??0,H=r+(a!=="center"?"-"+a:""),D=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},W=Array.isArray(f)?f:[f],T=W.length>0,L={padding:D,boundary:W.filter(ju),altBoundary:T},{refs:$,floatingStyles:_,placement:j,isPositioned:R,middlewareData:A}=uu({strategy:"fixed",placement:H,whileElementsMounted:(...ce)=>tu(...ce,{animationFrame:u==="always"}),elements:{reference:y.anchor},middleware:[pu({mainAxis:s+I,alignmentAxis:i}),d&&mu({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?hu():void 0,...L}),d&&gu({...L}),xu({...L,apply:({elements:ce,rects:de,availableWidth:$e,availableHeight:Pe})=>{const{width:we,height:Te}=de.reference,Se=ce.floating.style;Se.setProperty("--radix-popper-available-width",`${$e}px`),Se.setProperty("--radix-popper-available-height",`${Pe}px`),Se.setProperty("--radix-popper-anchor-width",`${we}px`),Se.setProperty("--radix-popper-anchor-height",`${Te}px`)}}),E&&bu({element:E,padding:l}),Pu({arrowWidth:k,arrowHeight:I}),h&&yu({strategy:"referenceHidden",...L})]}),[N,U]=Hs(j),te=We(x);me(()=>{R&&(te==null||te())},[R,te]);const V=(M=A.arrow)==null?void 0:M.x,z=(Z=A.arrow)==null?void 0:Z.y,G=((X=A.arrow)==null?void 0:X.centerOffset)!==0,[ne,ie]=c.useState();return me(()=>{b&&ie(window.getComputedStyle(b).zIndex)},[b]),o.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{..._,transform:R?_.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ne,"--radix-popper-transform-origin":[(J=A.transformOrigin)==null?void 0:J.x,(q=A.transformOrigin)==null?void 0:q.y].join(" "),...((Y=A.hide)==null?void 0:Y.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx(Eu,{scope:n,placedSide:N,onArrowChange:S,arrowX:V,arrowY:z,shouldHideArrow:G,children:o.jsx(Q.div,{"data-side":N,"data-align":U,...g,ref:w,style:{...g.style,animation:R?void 0:"none"}})})})});Bs.displayName=Kr;var Us="PopperArrow",ku={top:"bottom",right:"left",bottom:"top",left:"right"},Ws=c.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,a=Cu(Us,r),i=ku[a.placedSide];return o.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:o.jsx(wu,{...s,ref:n,style:{...s.style,display:"block"}})})});Ws.displayName=Us;function ju(e){return e!==null}var Pu=e=>({name:"transformOrigin",options:e,fn(t){var y,b,v;const{placement:n,rects:r,middlewareData:s}=t,i=((y=s.arrow)==null?void 0:y.centerOffset)!==0,l=i?0:e.arrowWidth,d=i?0:e.arrowHeight,[f,m]=Hs(n),p={start:"0%",center:"50%",end:"100%"}[m],h=(((b=s.arrow)==null?void 0:b.x)??0)+l/2,u=(((v=s.arrow)==null?void 0:v.y)??0)+d/2;let x="",g="";return f==="bottom"?(x=i?p:`${h}px`,g=`${-d}px`):f==="top"?(x=i?p:`${h}px`,g=`${r.floating.height+d}px`):f==="right"?(x=`${-d}px`,g=i?p:`${u}px`):f==="left"&&(x=`${r.floating.width+d}px`,g=i?p:`${u}px`),{data:{x,y:g}}}});function Hs(e){const[t,n="center"]=e.split("-");return[t,n]}var Vs=Ls,qs=Fs,Ks=Bs,zs=Ws,Tu="Portal",Vn=c.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[s,a]=c.useState(!1);me(()=>a(!0),[]);const i=n||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?ls.createPortal(o.jsx(Q.div,{...r,ref:t}),i):null});Vn.displayName=Tu;function _u(e,t){return c.useReducer((n,r)=>t[n][r]??n,e)}var it=e=>{const{present:t,children:n}=e,r=Ru(t),s=typeof n=="function"?n({present:r.isPresent}):c.Children.only(n),a=oe(r.ref,Au(s));return typeof n=="function"||r.isPresent?c.cloneElement(s,{ref:a}):null};it.displayName="Presence";function Ru(e){const[t,n]=c.useState(),r=c.useRef(null),s=c.useRef(e),a=c.useRef("none"),i=e?"mounted":"unmounted",[l,d]=_u(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return c.useEffect(()=>{const f=fn(r.current);a.current=l==="mounted"?f:"none"},[l]),me(()=>{const f=r.current,m=s.current;if(m!==e){const h=a.current,u=fn(f);e?d("MOUNT"):u==="none"||(f==null?void 0:f.display)==="none"?d("UNMOUNT"):d(m&&h!==u?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,d]),me(()=>{if(t){let f;const m=t.ownerDocument.defaultView??window,p=u=>{const g=fn(r.current).includes(CSS.escape(u.animationName));if(u.target===t&&g&&(d("ANIMATION_END"),!s.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",f=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=u=>{u.target===t&&(a.current=fn(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{m.clearTimeout(f),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:c.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function fn(e){return(e==null?void 0:e.animationName)||"none"}function Au(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ar="rovingFocusGroup.onEntryFocus",Iu={bubbles:!1,cancelable:!0},en="RovingFocusGroup",[xr,Gs,Mu]=Dr(en),[Ou,Ys]=yt(en,[Mu]),[Du,Lu]=Ou(en),Js=c.forwardRef((e,t)=>o.jsx(xr.Provider,{scope:e.__scopeRovingFocusGroup,children:o.jsx(xr.Slot,{scope:e.__scopeRovingFocusGroup,children:o.jsx($u,{...e,ref:t})})}));Js.displayName=en;var $u=c.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:s=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:m=!1,...p}=e,h=c.useRef(null),u=oe(t,h),x=Lr(a),[g,y]=Kt({prop:i,defaultProp:l??null,onChange:d,caller:en}),[b,v]=c.useState(!1),w=We(f),E=Gs(n),S=c.useRef(!1),[C,k]=c.useState(0);return c.useEffect(()=>{const I=h.current;if(I)return I.addEventListener(ar,w),()=>I.removeEventListener(ar,w)},[w]),o.jsx(Du,{scope:n,orientation:r,dir:x,loop:s,currentTabStopId:g,onItemFocus:c.useCallback(I=>y(I),[y]),onItemShiftTab:c.useCallback(()=>v(!0),[]),onFocusableItemAdd:c.useCallback(()=>k(I=>I+1),[]),onFocusableItemRemove:c.useCallback(()=>k(I=>I-1),[]),children:o.jsx(Q.div,{tabIndex:b||C===0?-1:0,"data-orientation":r,...p,ref:u,style:{outline:"none",...e.style},onMouseDown:B(e.onMouseDown,()=>{S.current=!0}),onFocus:B(e.onFocus,I=>{const H=!S.current;if(I.target===I.currentTarget&&H&&!b){const D=new CustomEvent(ar,Iu);if(I.currentTarget.dispatchEvent(D),!D.defaultPrevented){const W=E().filter(j=>j.focusable),T=W.find(j=>j.active),L=W.find(j=>j.id===g),_=[T,L,...W].filter(Boolean).map(j=>j.ref.current);Qs(_,m)}}S.current=!1}),onBlur:B(e.onBlur,()=>v(!1))})})}),Xs="RovingFocusGroupItem",Zs=c.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:s=!1,tabStopId:a,children:i,...l}=e,d=Ye(),f=a||d,m=Lu(Xs,n),p=m.currentTabStopId===f,h=Gs(n),{onFocusableItemAdd:u,onFocusableItemRemove:x,currentTabStopId:g}=m;return c.useEffect(()=>{if(r)return u(),()=>x()},[r,u,x]),o.jsx(xr.ItemSlot,{scope:n,id:f,focusable:r,active:s,children:o.jsx(Q.span,{tabIndex:p?0:-1,"data-orientation":m.orientation,...l,ref:t,onMouseDown:B(e.onMouseDown,y=>{r?m.onItemFocus(f):y.preventDefault()}),onFocus:B(e.onFocus,()=>m.onItemFocus(f)),onKeyDown:B(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){m.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const b=Uu(y,m.orientation,m.dir);if(b!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let w=h().filter(E=>E.focusable).map(E=>E.ref.current);if(b==="last")w.reverse();else if(b==="prev"||b==="next"){b==="prev"&&w.reverse();const E=w.indexOf(y.currentTarget);w=m.loop?Wu(w,E+1):w.slice(E+1)}setTimeout(()=>Qs(w))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});Zs.displayName=Xs;var Fu={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Bu(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Uu(e,t,n){const r=Bu(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Fu[r]}function Qs(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Wu(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Hu=Js,Vu=Zs,qu=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Et=new WeakMap,pn=new WeakMap,mn={},ir=0,ea=function(e){return e&&(e.host||ea(e.parentNode))},Ku=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=ea(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},zu=function(e,t,n,r){var s=Ku(t,Array.isArray(e)?e:[e]);mn[n]||(mn[n]=new WeakMap);var a=mn[n],i=[],l=new Set,d=new Set(s),f=function(p){!p||l.has(p)||(l.add(p),f(p.parentNode))};s.forEach(f);var m=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(h){if(l.has(h))m(h);else try{var u=h.getAttribute(r),x=u!==null&&u!=="false",g=(Et.get(h)||0)+1,y=(a.get(h)||0)+1;Et.set(h,g),a.set(h,y),i.push(h),g===1&&x&&pn.set(h,!0),y===1&&h.setAttribute(n,"true"),x||h.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return m(t),l.clear(),ir++,function(){i.forEach(function(p){var h=Et.get(p)-1,u=a.get(p)-1;Et.set(p,h),a.set(p,u),h||(pn.has(p)||p.removeAttribute(r),pn.delete(p)),u||p.removeAttribute(n)}),ir--,ir||(Et=new WeakMap,Et=new WeakMap,pn=new WeakMap,mn={})}},zr=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),s=qu(e);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live], script"))),zu(r,s,n,"aria-hidden")):function(){return null}},yr=["Enter"," "],Gu=["ArrowDown","PageUp","Home"],ta=["ArrowUp","PageDown","End"],Yu=[...Gu,...ta],Ju={ltr:[...yr,"ArrowRight"],rtl:[...yr,"ArrowLeft"]},Xu={ltr:["ArrowLeft"],rtl:["ArrowRight"]},tn="Menu",[Gt,Zu,Qu]=Dr(tn),[bt,na]=yt(tn,[Qu,Hn,Ys]),qn=Hn(),ra=Ys(),[ef,vt]=bt(tn),[tf,nn]=bt(tn),oa=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:s,onOpenChange:a,modal:i=!0}=e,l=qn(t),[d,f]=c.useState(null),m=c.useRef(!1),p=We(a),h=Lr(s);return c.useEffect(()=>{const u=()=>{m.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>m.current=!1;return document.addEventListener("keydown",u,{capture:!0}),()=>{document.removeEventListener("keydown",u,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),o.jsx(Vs,{...l,children:o.jsx(ef,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:f,children:o.jsx(tf,{scope:t,onClose:c.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:m,dir:h,modal:i,children:r})})})};oa.displayName=tn;var nf="MenuAnchor",Gr=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,s=qn(n);return o.jsx(qs,{...s,...r,ref:t})});Gr.displayName=nf;var Yr="MenuPortal",[rf,sa]=bt(Yr,{forceMount:void 0}),aa=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:s}=e,a=vt(Yr,t);return o.jsx(rf,{scope:t,forceMount:n,children:o.jsx(it,{present:n||a.open,children:o.jsx(Vn,{asChild:!0,container:s,children:r})})})};aa.displayName=Yr;var je="MenuContent",[of,Jr]=bt(je),ia=c.forwardRef((e,t)=>{const n=sa(je,e.__scopeMenu),{forceMount:r=n.forceMount,...s}=e,a=vt(je,e.__scopeMenu),i=nn(je,e.__scopeMenu);return o.jsx(Gt.Provider,{scope:e.__scopeMenu,children:o.jsx(it,{present:r||a.open,children:o.jsx(Gt.Slot,{scope:e.__scopeMenu,children:i.modal?o.jsx(sf,{...s,ref:t}):o.jsx(af,{...s,ref:t})})})})}),sf=c.forwardRef((e,t)=>{const n=vt(je,e.__scopeMenu),r=c.useRef(null),s=oe(t,r);return c.useEffect(()=>{const a=r.current;if(a)return zr(a)},[]),o.jsx(Xr,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:B(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),af=c.forwardRef((e,t)=>{const n=vt(je,e.__scopeMenu);return o.jsx(Xr,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),cf=At("MenuContent.ScrollLock"),Xr=c.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:l,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:h,onDismiss:u,disableOutsideScroll:x,...g}=e,y=vt(je,n),b=nn(je,n),v=qn(n),w=ra(n),E=Zu(n),[S,C]=c.useState(null),k=c.useRef(null),I=oe(t,k,y.onContentChange),H=c.useRef(0),D=c.useRef(""),W=c.useRef(0),T=c.useRef(null),L=c.useRef("right"),$=c.useRef(0),_=x?Ir:c.Fragment,j=x?{as:cf,allowPinchZoom:!0}:void 0,R=N=>{var M,Z;const U=D.current+N,te=E().filter(X=>!X.disabled),V=document.activeElement,z=(M=te.find(X=>X.ref.current===V))==null?void 0:M.textValue,G=te.map(X=>X.textValue),ne=vf(G,U,z),ie=(Z=te.find(X=>X.textValue===ne))==null?void 0:Z.ref.current;(function X(J){D.current=J,window.clearTimeout(H.current),J!==""&&(H.current=window.setTimeout(()=>X(""),1e3))})(U),ie&&setTimeout(()=>ie.focus())};c.useEffect(()=>()=>window.clearTimeout(H.current),[]),$r();const A=c.useCallback(N=>{var te,V;return L.current===((te=T.current)==null?void 0:te.side)&&Sf(N,(V=T.current)==null?void 0:V.area)},[]);return o.jsx(of,{scope:n,searchRef:D,onItemEnter:c.useCallback(N=>{A(N)&&N.preventDefault()},[A]),onItemLeave:c.useCallback(N=>{var U;A(N)||((U=k.current)==null||U.focus(),C(null))},[A]),onTriggerLeave:c.useCallback(N=>{A(N)&&N.preventDefault()},[A]),pointerGraceTimerRef:W,onPointerGraceIntentChange:c.useCallback(N=>{T.current=N},[]),children:o.jsx(_,{...j,children:o.jsx($n,{asChild:!0,trapped:s,onMountAutoFocus:B(a,N=>{var U;N.preventDefault(),(U=k.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:o.jsx(Ln,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:h,onDismiss:u,children:o.jsx(Hu,{asChild:!0,...w,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:B(d,N=>{b.isUsingKeyboardRef.current||N.preventDefault()}),preventScrollOnEntryFocus:!0,children:o.jsx(Ks,{role:"menu","aria-orientation":"vertical","data-state":Na(y.open),"data-radix-menu-content":"",dir:b.dir,...v,...g,ref:I,style:{outline:"none",...g.style},onKeyDown:B(g.onKeyDown,N=>{const te=N.target.closest("[data-radix-menu-content]")===N.currentTarget,V=N.ctrlKey||N.altKey||N.metaKey,z=N.key.length===1;te&&(N.key==="Tab"&&N.preventDefault(),!V&&z&&R(N.key));const G=k.current;if(N.target!==G||!Yu.includes(N.key))return;N.preventDefault();const ie=E().filter(M=>!M.disabled).map(M=>M.ref.current);ta.includes(N.key)&&ie.reverse(),yf(ie)}),onBlur:B(e.onBlur,N=>{N.currentTarget.contains(N.target)||(window.clearTimeout(H.current),D.current="")}),onPointerMove:B(e.onPointerMove,Yt(N=>{const U=N.target,te=$.current!==N.clientX;if(N.currentTarget.contains(U)&&te){const V=N.clientX>$.current?"right":"left";L.current=V,$.current=N.clientX}}))})})})})})})});ia.displayName=je;var lf="MenuGroup",Zr=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(Q.div,{role:"group",...r,ref:t})});Zr.displayName=lf;var df="MenuLabel",ca=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(Q.div,{...r,ref:t})});ca.displayName=df;var Cn="MenuItem",Lo="menu.itemSelect",Kn=c.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...s}=e,a=c.useRef(null),i=nn(Cn,e.__scopeMenu),l=Jr(Cn,e.__scopeMenu),d=oe(t,a),f=c.useRef(!1),m=()=>{const p=a.current;if(!n&&p){const h=new CustomEvent(Lo,{bubbles:!0,cancelable:!0});p.addEventListener(Lo,u=>r==null?void 0:r(u),{once:!0}),bs(p,h),h.defaultPrevented?f.current=!1:i.onClose()}};return o.jsx(la,{...s,ref:d,disabled:n,onClick:B(e.onClick,m),onPointerDown:p=>{var h;(h=e.onPointerDown)==null||h.call(e,p),f.current=!0},onPointerUp:B(e.onPointerUp,p=>{var h;f.current||(h=p.currentTarget)==null||h.click()}),onKeyDown:B(e.onKeyDown,p=>{const h=l.searchRef.current!=="";n||h&&p.key===" "||yr.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Kn.displayName=Cn;var la=c.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:s,...a}=e,i=Jr(Cn,n),l=ra(n),d=c.useRef(null),f=oe(t,d),[m,p]=c.useState(!1),[h,u]=c.useState("");return c.useEffect(()=>{const x=d.current;x&&u((x.textContent??"").trim())},[a.children]),o.jsx(Gt.ItemSlot,{scope:n,disabled:r,textValue:s??h,children:o.jsx(Vu,{asChild:!0,...l,focusable:!r,children:o.jsx(Q.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:f,onPointerMove:B(e.onPointerMove,Yt(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:B(e.onPointerLeave,Yt(x=>i.onItemLeave(x))),onFocus:B(e.onFocus,()=>p(!0)),onBlur:B(e.onBlur,()=>p(!1))})})})}),uf="MenuCheckboxItem",da=c.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...s}=e;return o.jsx(ha,{scope:e.__scopeMenu,checked:n,children:o.jsx(Kn,{role:"menuitemcheckbox","aria-checked":kn(n)?"mixed":n,...s,ref:t,"data-state":eo(n),onSelect:B(s.onSelect,()=>r==null?void 0:r(kn(n)?!0:!n),{checkForDefaultPrevented:!1})})})});da.displayName=uf;var ua="MenuRadioGroup",[ff,pf]=bt(ua,{value:void 0,onValueChange:()=>{}}),fa=c.forwardRef((e,t)=>{const{value:n,onValueChange:r,...s}=e,a=We(r);return o.jsx(ff,{scope:e.__scopeMenu,value:n,onValueChange:a,children:o.jsx(Zr,{...s,ref:t})})});fa.displayName=ua;var pa="MenuRadioItem",ma=c.forwardRef((e,t)=>{const{value:n,...r}=e,s=pf(pa,e.__scopeMenu),a=n===s.value;return o.jsx(ha,{scope:e.__scopeMenu,checked:a,children:o.jsx(Kn,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":eo(a),onSelect:B(r.onSelect,()=>{var i;return(i=s.onValueChange)==null?void 0:i.call(s,n)},{checkForDefaultPrevented:!1})})})});ma.displayName=pa;var Qr="MenuItemIndicator",[ha,mf]=bt(Qr,{checked:!1}),ga=c.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...s}=e,a=mf(Qr,n);return o.jsx(it,{present:r||kn(a.checked)||a.checked===!0,children:o.jsx(Q.span,{...s,ref:t,"data-state":eo(a.checked)})})});ga.displayName=Qr;var hf="MenuSeparator",xa=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(Q.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});xa.displayName=hf;var gf="MenuArrow",ya=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,s=qn(n);return o.jsx(zs,{...s,...r,ref:t})});ya.displayName=gf;var xf="MenuSub",[Rg,ba]=bt(xf),Ut="MenuSubTrigger",va=c.forwardRef((e,t)=>{const n=vt(Ut,e.__scopeMenu),r=nn(Ut,e.__scopeMenu),s=ba(Ut,e.__scopeMenu),a=Jr(Ut,e.__scopeMenu),i=c.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:d}=a,f={__scopeMenu:e.__scopeMenu},m=c.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return c.useEffect(()=>m,[m]),c.useEffect(()=>{const p=l.current;return()=>{window.clearTimeout(p),d(null)}},[l,d]),o.jsx(Gr,{asChild:!0,...f,children:o.jsx(la,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":Na(n.open),...e,ref:Dn(t,s.onTriggerChange),onClick:p=>{var h;(h=e.onClick)==null||h.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:B(e.onPointerMove,Yt(p=>{a.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:B(e.onPointerLeave,Yt(p=>{var u,x;m();const h=(u=n.content)==null?void 0:u.getBoundingClientRect();if(h){const g=(x=n.content)==null?void 0:x.dataset.side,y=g==="right",b=y?-5:5,v=h[y?"left":"right"],w=h[y?"right":"left"];a.onPointerGraceIntentChange({area:[{x:p.clientX+b,y:p.clientY},{x:v,y:h.top},{x:w,y:h.top},{x:w,y:h.bottom},{x:v,y:h.bottom}],side:g}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(p),p.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:B(e.onKeyDown,p=>{var u;const h=a.searchRef.current!=="";e.disabled||h&&p.key===" "||Ju[r.dir].includes(p.key)&&(n.onOpenChange(!0),(u=n.content)==null||u.focus(),p.preventDefault())})})})});va.displayName=Ut;var wa="MenuSubContent",Sa=c.forwardRef((e,t)=>{const n=sa(je,e.__scopeMenu),{forceMount:r=n.forceMount,...s}=e,a=vt(je,e.__scopeMenu),i=nn(je,e.__scopeMenu),l=ba(wa,e.__scopeMenu),d=c.useRef(null),f=oe(t,d);return o.jsx(Gt.Provider,{scope:e.__scopeMenu,children:o.jsx(it,{present:r||a.open,children:o.jsx(Gt.Slot,{scope:e.__scopeMenu,children:o.jsx(Xr,{id:l.contentId,"aria-labelledby":l.triggerId,...s,ref:f,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{var p;i.isUsingKeyboardRef.current&&((p=d.current)==null||p.focus()),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:B(e.onFocusOutside,m=>{m.target!==l.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:B(e.onEscapeKeyDown,m=>{i.onClose(),m.preventDefault()}),onKeyDown:B(e.onKeyDown,m=>{var u;const p=m.currentTarget.contains(m.target),h=Xu[i.dir].includes(m.key);p&&h&&(a.onOpenChange(!1),(u=l.trigger)==null||u.focus(),m.preventDefault())})})})})})});Sa.displayName=wa;function Na(e){return e?"open":"closed"}function kn(e){return e==="indeterminate"}function eo(e){return kn(e)?"indeterminate":e?"checked":"unchecked"}function yf(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function bf(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function vf(e,t,n){const s=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=bf(e,Math.max(a,0));s.length===1&&(i=i.filter(f=>f!==n));const d=i.find(f=>f.toLowerCase().startsWith(s.toLowerCase()));return d!==n?d:void 0}function wf(e,t){const{x:n,y:r}=e;let s=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const l=t[a],d=t[i],f=l.x,m=l.y,p=d.x,h=d.y;m>r!=h>r&&n<(p-f)*(r-m)/(h-m)+f&&(s=!s)}return s}function Sf(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return wf(n,t)}function Yt(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Nf=oa,Ef=Gr,Cf=aa,kf=ia,jf=Zr,Pf=ca,Tf=Kn,_f=da,Rf=fa,Af=ma,If=ga,Mf=xa,Of=ya,Df=va,Lf=Sa,zn="DropdownMenu",[$f]=yt(zn,[na]),he=na(),[Ff,Ea]=$f(zn),Ca=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:s,defaultOpen:a,onOpenChange:i,modal:l=!0}=e,d=he(t),f=c.useRef(null),[m,p]=Kt({prop:s,defaultProp:a??!1,onChange:i,caller:zn});return o.jsx(Ff,{scope:t,triggerId:Ye(),triggerRef:f,contentId:Ye(),open:m,onOpenChange:p,onOpenToggle:c.useCallback(()=>p(h=>!h),[p]),modal:l,children:o.jsx(Nf,{...d,open:m,onOpenChange:p,dir:r,modal:l,children:n})})};Ca.displayName=zn;var ka="DropdownMenuTrigger",ja=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...s}=e,a=Ea(ka,n),i=he(n);return o.jsx(Ef,{asChild:!0,...i,children:o.jsx(Q.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...s,ref:Dn(t,a.triggerRef),onPointerDown:B(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(a.onOpenToggle(),a.open||l.preventDefault())}),onKeyDown:B(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&a.onOpenToggle(),l.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});ja.displayName=ka;var Bf="DropdownMenuPortal",Pa=e=>{const{__scopeDropdownMenu:t,...n}=e,r=he(t);return o.jsx(Cf,{...r,...n})};Pa.displayName=Bf;var Ta="DropdownMenuContent",_a=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Ea(Ta,n),a=he(n),i=c.useRef(!1);return o.jsx(kf,{id:s.contentId,"aria-labelledby":s.triggerId,...a,...r,ref:t,onCloseAutoFocus:B(e.onCloseAutoFocus,l=>{var d;i.current||(d=s.triggerRef.current)==null||d.focus(),i.current=!1,l.preventDefault()}),onInteractOutside:B(e.onInteractOutside,l=>{const d=l.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,m=d.button===2||f;(!s.modal||m)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});_a.displayName=Ta;var Uf="DropdownMenuGroup",Wf=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(jf,{...s,...r,ref:t})});Wf.displayName=Uf;var Hf="DropdownMenuLabel",Ra=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Pf,{...s,...r,ref:t})});Ra.displayName=Hf;var Vf="DropdownMenuItem",Aa=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Tf,{...s,...r,ref:t})});Aa.displayName=Vf;var qf="DropdownMenuCheckboxItem",Ia=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(_f,{...s,...r,ref:t})});Ia.displayName=qf;var Kf="DropdownMenuRadioGroup",Ma=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Rf,{...s,...r,ref:t})});Ma.displayName=Kf;var zf="DropdownMenuRadioItem",Oa=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Af,{...s,...r,ref:t})});Oa.displayName=zf;var Gf="DropdownMenuItemIndicator",Da=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(If,{...s,...r,ref:t})});Da.displayName=Gf;var Yf="DropdownMenuSeparator",La=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Mf,{...s,...r,ref:t})});La.displayName=Yf;var Jf="DropdownMenuArrow",Xf=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Of,{...s,...r,ref:t})});Xf.displayName=Jf;var Zf="DropdownMenuSubTrigger",$a=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Df,{...s,...r,ref:t})});$a.displayName=Zf;var Qf="DropdownMenuSubContent",Fa=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Lf,{...s,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Fa.displayName=Qf;var ep=Ca,tp=ja,np=Pa,Ba=_a,Ua=Ra,Wa=Aa,Ha=Ia,rp=Ma,Va=Oa,qa=Da,Ka=La,za=$a,Ga=Fa;function F(...e){return Tc(e)}const op=new Set(["RUNNING","STARTING","NEEDS_PERMISSION","NEEDS_INPUT"]);function to(e){return op.has(e.status)}function br(e){return e.status==="NEEDS_PERMISSION"||e.status==="NEEDS_INPUT"}function jn(e){const t=new Date,n=typeof e=="string"?new Date(e):e,r=Math.floor((t.getTime()-n.getTime())/1e3);return r<60?"just now":r<3600?`${Math.floor(r/60)}m ago`:r<86400?`${Math.floor(r/3600)}h ago`:r<604800?`${Math.floor(r/86400)}d ago`:n.toLocaleDateString()}function Pt(e,t){return e.length<=t?e:`${e.slice(0,t)}...`}function Ya(e){switch(e){case"RUNNING":return"green";case"STARTING":return"yellow";case"CRASHED":return"red";case"STOPPED":return"gray";case"NEEDS_PERMISSION":return"blue";case"NEEDS_INPUT":return"cyan";default:return"gray"}}const Ja=ep,Xa=tp,sp=rp,ap=c.forwardRef(({className:e,inset:t,children:n,...r},s)=>o.jsxs(za,{ref:s,className:F("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ml-auto h-4 w-4",children:o.jsx("path",{d:"M6.1584 3.13508C6.35985 2.94621 6.67627 2.95642 6.86514 3.15788L10.6151 7.15788C10.7954 7.3502 10.7954 7.64949 10.6151 7.84182L6.86514 11.8418C6.67627 12.0433 6.35985 12.0535 6.1584 11.8646C5.95694 11.6757 5.94673 11.3593 6.1356 11.1579L9.565 7.49985L6.1356 3.84182C5.94673 3.64036 5.95694 3.32394 6.1584 3.13508Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})]}));ap.displayName=za.displayName;const ip=c.forwardRef(({className:e,...t},n)=>o.jsx(Ga,{ref:n,className:F("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));ip.displayName=Ga.displayName;const no=c.forwardRef(({className:e,sideOffset:t=4,...n},r)=>o.jsx(np,{children:o.jsx(Ba,{ref:r,sideOffset:t,className:F("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",e),...n})}));no.displayName=Ba.displayName;const Wt=c.forwardRef(({className:e,inset:t,...n},r)=>o.jsx(Wa,{ref:r,className:F("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Wt.displayName=Wa.displayName;const cp=c.forwardRef(({className:e,children:t,checked:n,...r},s)=>o.jsxs(Ha,{ref:s,className:F("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(qa,{children:o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",children:o.jsx("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})})}),t]}));cp.displayName=Ha.displayName;const Za=c.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(Va,{ref:r,className:F("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(qa,{children:o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 fill-current",children:o.jsx("path",{d:"M9.875 7.5C9.875 8.81168 8.81168 9.875 7.5 9.875C6.18832 9.875 5.125 8.81168 5.125 7.5C5.125 6.18832 6.18832 5.125 7.5 5.125C8.81168 5.125 9.875 6.18832 9.875 7.5Z",fill:"currentColor"})})})}),t]}));Za.displayName=Va.displayName;const Qa=c.forwardRef(({className:e,inset:t,...n},r)=>o.jsx(Ua,{ref:r,className:F("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Qa.displayName=Ua.displayName;const ro=c.forwardRef(({className:e,...t},n)=>o.jsx(Ka,{ref:n,className:F("-mx-1 my-1 h-px bg-muted",e),...t}));ro.displayName=Ka.displayName;const ei="codepiper.theme",ti="codepiper-dark",ni="codepiper-light",oo=[{id:"codepiper-dark",label:"CodePiper Dark",description:"Default dark theme with cyan accents.",mode:"dark",themeColor:"#0e1016",monacoTheme:"vs-dark",ui:{background:"#0e1016",foreground:"#f3f4f6",card:"#161b22",cardForeground:"#f3f4f6",popover:"#161b22",popoverForeground:"#f3f4f6",primary:"#06b6d4",primaryForeground:"#0e1016",secondary:"#222a35",secondaryForeground:"#f3f4f6",muted:"#222a35",mutedForeground:"#9ca3af",accent:"#243142",accentForeground:"#f3f4f6",destructive:"#dc2626",destructiveForeground:"#f8fafc",border:"#243142",input:"#243142",ring:"#06b6d4"},terminal:{background:"#0e1016",foreground:"#d4d4e0",cursor:"#67e8f9",cursorAccent:"#0e1016",selectionBackground:"#06b6d430",selectionForeground:"#d4d4e0",black:"#3a3a4a",red:"#f87171",green:"#4ade80",yellow:"#fbbf24",blue:"#60a5fa",magenta:"#c084fc",cyan:"#22d3ee",white:"#d4d4e0",brightBlack:"#5a5a6a",brightRed:"#fca5a5",brightGreen:"#86efac",brightYellow:"#fde68a",brightBlue:"#93c5fd",brightMagenta:"#d8b4fe",brightCyan:"#67e8f9",brightWhite:"#f0f0f8"}},{id:"codepiper-light",label:"CodePiper Light",description:"Editorial light theme with crisp contrast and sapphire accents.",mode:"light",themeColor:"#f5f7fb",monacoTheme:"vs",ui:{background:"#f5f7fb",foreground:"#121826",card:"#ffffff",cardForeground:"#121826",popover:"#ffffff",popoverForeground:"#121826",primary:"#1f5bd8",primaryForeground:"#f8fbff",secondary:"#e8edf6",secondaryForeground:"#172235",muted:"#eef2f8",mutedForeground:"#57627a",accent:"#dfe8f8",accentForeground:"#122038",destructive:"#c62828",destructiveForeground:"#ffffff",border:"#cad5e4",input:"#c4d0e0",ring:"#1f5bd8"},terminal:{background:"#f7faff",foreground:"#102035",cursor:"#1c2f4a",cursorAccent:"#ffffff",selectionBackground:"#1f5bd829",selectionForeground:"#102035",black:"#1e2a3f",red:"#c62828",green:"#2e7d32",yellow:"#93610d",blue:"#1e5bd7",magenta:"#7b2cbf",cyan:"#0e7490",white:"#d6e1f0",brightBlack:"#5a6a83",brightRed:"#ef4444",brightGreen:"#22a55a",brightYellow:"#b7791f",brightBlue:"#2563eb",brightMagenta:"#9333ea",brightCyan:"#0891b2",brightWhite:"#ffffff"}},{id:"dracula",label:"Dracula",description:"Popular high-contrast purple theme.",mode:"dark",themeColor:"#282a36",monacoTheme:"vs-dark",ui:{background:"#282a36",foreground:"#f8f8f2",card:"#303442",cardForeground:"#f8f8f2",popover:"#303442",popoverForeground:"#f8f8f2",primary:"#bd93f9",primaryForeground:"#282a36",secondary:"#3b3f51",secondaryForeground:"#f8f8f2",muted:"#3b3f51",mutedForeground:"#bdc2d6",accent:"#44475a",accentForeground:"#f8f8f2",destructive:"#ff5555",destructiveForeground:"#ffffff",border:"#44475a",input:"#44475a",ring:"#8be9fd"},terminal:{background:"#282a36",foreground:"#f8f8f2",cursor:"#f8f8f2",cursorAccent:"#282a36",selectionBackground:"#44475a99",selectionForeground:"#f8f8f2",black:"#21222c",red:"#ff5555",green:"#50fa7b",yellow:"#f1fa8c",blue:"#bd93f9",magenta:"#ff79c6",cyan:"#8be9fd",white:"#f8f8f2",brightBlack:"#6272a4",brightRed:"#ff6e6e",brightGreen:"#69ff94",brightYellow:"#ffffa5",brightBlue:"#d6acff",brightMagenta:"#ff92df",brightCyan:"#a4ffff",brightWhite:"#ffffff"}},{id:"nord",label:"Nord",description:"Arctic blue palette from the Nord project.",mode:"dark",themeColor:"#2e3440",monacoTheme:"vs-dark",ui:{background:"#2e3440",foreground:"#d8dee9",card:"#3b4252",cardForeground:"#d8dee9",popover:"#3b4252",popoverForeground:"#d8dee9",primary:"#88c0d0",primaryForeground:"#2e3440",secondary:"#434c5e",secondaryForeground:"#d8dee9",muted:"#434c5e",mutedForeground:"#b7c0cf",accent:"#4c566a",accentForeground:"#eceff4",destructive:"#bf616a",destructiveForeground:"#eceff4",border:"#4c566a",input:"#4c566a",ring:"#81a1c1"},terminal:{background:"#2e3440",foreground:"#d8dee9",cursor:"#d8dee9",cursorAccent:"#2e3440",selectionBackground:"#4c566a99",selectionForeground:"#eceff4",black:"#3b4252",red:"#bf616a",green:"#a3be8c",yellow:"#ebcb8b",blue:"#81a1c1",magenta:"#b48ead",cyan:"#88c0d0",white:"#e5e9f0",brightBlack:"#4c566a",brightRed:"#bf616a",brightGreen:"#a3be8c",brightYellow:"#ebcb8b",brightBlue:"#81a1c1",brightMagenta:"#b48ead",brightCyan:"#8fbcbb",brightWhite:"#eceff4"}},{id:"gruvbox-dark",label:"Gruvbox Dark",description:"Retro contrast palette popular in Vim and terminal workflows.",mode:"dark",themeColor:"#282828",monacoTheme:"vs-dark",ui:{background:"#282828",foreground:"#ebdbb2",card:"#32302f",cardForeground:"#ebdbb2",popover:"#32302f",popoverForeground:"#ebdbb2",primary:"#fabd2f",primaryForeground:"#282828",secondary:"#3c3836",secondaryForeground:"#ebdbb2",muted:"#3c3836",mutedForeground:"#bdae93",accent:"#504945",accentForeground:"#fbf1c7",destructive:"#fb4934",destructiveForeground:"#fbf1c7",border:"#504945",input:"#504945",ring:"#d79921"},terminal:{background:"#282828",foreground:"#ebdbb2",cursor:"#ebdbb2",cursorAccent:"#282828",selectionBackground:"#50494599",selectionForeground:"#fbf1c7",black:"#282828",red:"#cc241d",green:"#98971a",yellow:"#d79921",blue:"#458588",magenta:"#b16286",cyan:"#689d6a",white:"#a89984",brightBlack:"#928374",brightRed:"#fb4934",brightGreen:"#b8bb26",brightYellow:"#fabd2f",brightBlue:"#83a598",brightMagenta:"#d3869b",brightCyan:"#8ec07c",brightWhite:"#ebdbb2"}},{id:"solarized-dark",label:"Solarized Dark",description:"Low-contrast classic palette by Ethan Schoonover.",mode:"dark",themeColor:"#002b36",monacoTheme:"vs-dark",ui:{background:"#002b36",foreground:"#839496",card:"#073642",cardForeground:"#93a1a1",popover:"#073642",popoverForeground:"#93a1a1",primary:"#268bd2",primaryForeground:"#002b36",secondary:"#0b3f4a",secondaryForeground:"#93a1a1",muted:"#0b3f4a",mutedForeground:"#657b83",accent:"#0f4754",accentForeground:"#eee8d5",destructive:"#dc322f",destructiveForeground:"#fdf6e3",border:"#0f4754",input:"#0f4754",ring:"#2aa198"},terminal:{background:"#002b36",foreground:"#839496",cursor:"#839496",cursorAccent:"#002b36",selectionBackground:"#073642cc",selectionForeground:"#93a1a1",black:"#073642",red:"#dc322f",green:"#859900",yellow:"#b58900",blue:"#268bd2",magenta:"#d33682",cyan:"#2aa198",white:"#eee8d5",brightBlack:"#002b36",brightRed:"#cb4b16",brightGreen:"#586e75",brightYellow:"#657b83",brightBlue:"#839496",brightMagenta:"#6c71c4",brightCyan:"#93a1a1",brightWhite:"#fdf6e3"}}],lp=new Map(oo.map(e=>[e.id,e]));function yn(e){if(e)return lp.get(e)}function dp(e){const t=e.trim().toLowerCase();if(/^#[0-9a-f]{6}$/.test(t))return t;if(/^#[0-9a-f]{3}$/.test(t)){const[n,r,s]=t.slice(1).split("");return`#${n}${n}${r}${r}${s}${s}`}throw new Error(`Invalid hex color: ${e}`)}function up(e){const t=dp(e),n=Number.parseInt(t.slice(1,3),16),r=Number.parseInt(t.slice(3,5),16),s=Number.parseInt(t.slice(5,7),16);return{r:n,g:r,b:s}}function fp({r:e,g:t,b:n}){const r=e/255,s=t/255,a=n/255,i=Math.max(r,s,a),l=Math.min(r,s,a),d=i-l;let f=0;d>0&&(i===r?f=(s-a)/d%6:i===s?f=(a-r)/d+2:f=(r-s)/d+4),f=Math.round(f*60),f<0&&(f+=360);const m=(i+l)/2,p=d===0?0:d/(1-Math.abs(2*m-1)),h=Math.round(p*100),u=Math.round(m*100);return`${f} ${h}% ${u}%`}function pp(e){return fp(up(e))}const mp={background:"--background",foreground:"--foreground",card:"--card",cardForeground:"--card-foreground",popover:"--popover",popoverForeground:"--popover-foreground",primary:"--primary",primaryForeground:"--primary-foreground",secondary:"--secondary",secondaryForeground:"--secondary-foreground",muted:"--muted",mutedForeground:"--muted-foreground",accent:"--accent",accentForeground:"--accent-foreground",destructive:"--destructive",destructiveForeground:"--destructive-foreground",border:"--border",input:"--input",ring:"--ring"};function hp(e){document.documentElement.style.colorScheme=e}function gp(e){const t=document.querySelector('meta[name="theme-color"]');t instanceof HTMLMetaElement&&(t.content=e)}function xp(e){const t=document.documentElement;t.dataset.theme=e.id,t.classList.toggle("dark",e.mode==="dark");for(const[n,r]of Object.entries(mp)){const s=n;t.style.setProperty(r,pp(e.ui[s]))}hp(e.mode),gp(e.themeColor)}function yp(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function bp(){const e=localStorage.getItem("theme");if(e==="dark")return ti;if(e==="light")return ni}function vp(){const e=localStorage.getItem(ei),t=yn(e);if(t)return t;const n=bp(),r=yn(n);if(r)return r;const a=yp()==="dark"?ti:ni;return yn(a)??oo[0]}function wp(e){localStorage.setItem(ei,e)}const ri=c.createContext(null);function Sp({children:e}){const[t,n]=c.useState(()=>vp());c.useEffect(()=>{xp(t),wp(t.id)},[t]);const r=c.useCallback(a=>{const i=yn(a);i&&n(i)},[]),s=c.useMemo(()=>({theme:t,themes:oo,setTheme:r}),[t,r]);return o.jsx(ri.Provider,{value:s,children:e})}function so(){const e=c.useContext(ri);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}function $o({color:e,className:t}){return o.jsx("span",{className:F("inline-block h-4 w-4 rounded-full border border-border/70 shadow-[0_0_0_1px_hsl(var(--background))] shrink-0",t),style:{backgroundColor:e},"aria-hidden":"true"})}function Np({className:e}){const{theme:t,themes:n,setTheme:r}=so(),s=t.mode==="dark"?"bg-card/65 backdrop-blur-sm hover:bg-accent/70":"bg-card/92 hover:bg-accent/85",a=t.mode==="dark"?"bg-popover/95 backdrop-blur-xl shadow-[0_24px_48px_-24px_hsl(var(--foreground)/0.45)]":"bg-popover shadow-[0_20px_40px_-22px_hsl(var(--foreground)/0.22)]";return o.jsxs(Ja,{children:[o.jsx(Xa,{asChild:!0,children:o.jsx("button",{type:"button",className:F("h-8 w-8 rounded-lg border border-border/70 flex items-center justify-center text-muted-foreground hover:text-foreground hover:border-primary/45 transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",s,e),"aria-label":`Theme picker (current: ${t.label})`,title:`Theme: ${t.label}`,children:o.jsx($o,{color:t.ui.primary,className:"h-3.5 w-3.5 border-border/80"})})}),o.jsxs(no,{align:"end",className:F("w-72 border-border/70",a),children:[o.jsx(Qa,{className:"text-[10px] uppercase tracking-[0.14em] text-muted-foreground font-semibold",children:"Theme"}),o.jsx(ro,{}),o.jsx(sp,{value:t.id,onValueChange:r,children:n.map(i=>o.jsx(Za,{value:i.id,className:"pl-2 pr-2 py-2 rounded-md border border-transparent focus:bg-accent/70 data-[state=checked]:border-primary/35 data-[state=checked]:bg-primary/10 [&>span:first-child]:hidden",children:o.jsxs("div",{className:"flex w-full items-center gap-2.5",children:[o.jsx($o,{color:i.ui.primary}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"truncate text-sm font-medium",children:i.label}),o.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:i.description})]}),o.jsx("span",{className:F("ml-auto h-2 w-2 rounded-full border border-border/70",t.id===i.id?"bg-primary border-primary/50":"bg-transparent")})]})},i.id))})]})]})}class nt extends Error{constructor(t,n,r){super(t),this.status=n,this.response=r,this.name="ApiError"}}class Ep{constructor(t="/api"){le(this,"baseUrl");this.baseUrl=t}async request(t,n){const r=`${this.baseUrl}${t}`;try{const s=await fetch(r,{...n,cache:"no-store",headers:{"Content-Type":"application/json",...n==null?void 0:n.headers}});if(!s.ok){let a=`HTTP ${s.status}: ${s.statusText}`,i;try{i=await s.json(),i&&typeof i=="object"&&"error"in i&&(a=String(i.error))}catch{}throw new nt(a,s.status,i)}return await s.json()}catch(s){throw s instanceof nt?s:new nt(s instanceof Error?s.message:"Network error",0)}}async getHealth(){return this.request("/health")}async getVersion(){return this.request("/version")}async getProviders(){return this.request("/providers")}async getSessions(){return this.request("/sessions")}async getSession(t){return this.request(`/sessions/${t}`)}async updateSessionName(t,n){return this.request(`/sessions/${t}/name`,{method:"PUT",body:JSON.stringify(n)})}async createSession(t){return this.request("/sessions",{method:"POST",body:JSON.stringify(t)})}async stopSession(t){return this.request(`/sessions/${t}/stop`,{method:"POST"})}async killSession(t){return this.request(`/sessions/${t}/kill`,{method:"POST"})}async resumeSession(t){return this.request(`/sessions/${t}/resume`,{method:"POST"})}async recoverSession(t){return this.request(`/sessions/${t}/recover`,{method:"POST"})}async sendText(t,n){await this.request(`/sessions/${t}/send`,{method:"POST",body:JSON.stringify(n)})}async uploadImage(t,n,r){const s=`${this.baseUrl}/sessions/${t}/upload-image`,a=new FormData;if(a.append("image",n),r!=null&&r.onProgress)return new Promise((l,d)=>{const f=new XMLHttpRequest;f.open("POST",s,!0),f.responseType="json",f.upload.onprogress=m=>{var h;if(!m.lengthComputable)return;const p=Math.max(0,Math.min(100,Math.round(m.loaded/m.total*100)));(h=r.onProgress)==null||h.call(r,p)},f.onload=()=>{var p;if(f.status<200||f.status>=300){const h=f.response&&typeof f.response=="object"&&"error"in f.response?String(f.response.error):`HTTP ${f.status}: ${f.statusText}`;d(new nt(h,f.status));return}const m=f.response&&typeof f.response=="object"?f.response:null;if(!(m!=null&&m.path)){d(new nt("Invalid upload response payload",f.status||500));return}(p=r.onProgress)==null||p.call(r,100),l(m)},f.onerror=()=>{d(new nt("Network error during upload",f.status||0))},f.send(a)});const i=await fetch(s,{method:"POST",body:a});if(!i.ok){let l=`HTTP ${i.status}: ${i.statusText}`;try{const d=await i.json();d!=null&&d.error&&(l=String(d.error))}catch{}throw new nt(l,i.status)}return await i.json()}async transcribeAudio(t,n,r="voice.webm"){const s=`${this.baseUrl}/sessions/${t}/terminal/transcribe`,a=new FormData;a.append("audio",new File([n],r,{type:n.type}));const i=await fetch(s,{method:"POST",body:a});if(!i.ok){let l=`HTTP ${i.status}: ${i.statusText}`;try{const d=await i.json();d!=null&&d.error&&(l=String(d.error))}catch{}throw new nt(l,i.status)}return await i.json()}async sendKeys(t,n){await this.request(`/sessions/${t}/keys`,{method:"POST",body:JSON.stringify(n)})}async resizeSession(t,n,r){return this.request(`/sessions/${t}/resize`,{method:"POST",body:JSON.stringify({cols:n,rows:r})})}async getSessionOutput(t){return this.request(`/sessions/${t}/output`)}async getEvents(t,n){const r=new URLSearchParams;n!=null&&n.since&&r.append("since",String(n.since)),n!=null&&n.before&&r.append("before",String(n.before)),n!=null&&n.limit&&r.append("limit",String(n.limit)),n!=null&&n.source&&r.append("source",n.source),n!=null&&n.type&&r.append("type",n.type),n!=null&&n.order&&r.append("order",n.order);const s=r.toString(),a=`/sessions/${t}/events${s?`?${s}`:""}`;return this.request(a)}async getPolicies(){return this.request("/policies")}async getPolicy(t){return this.request(`/policies/${t}`)}async createPolicy(t){return this.request("/policies",{method:"POST",body:JSON.stringify(t)})}async updatePolicy(t,n){return this.request(`/policies/${t}`,{method:"PUT",body:JSON.stringify(n)})}async deletePolicy(t){return this.request(`/policies/${t}`,{method:"DELETE"})}async getPolicySets(){return this.request("/policy-sets")}async getPolicySet(t){return this.request(`/policy-sets/${t}`)}async createPolicySet(t){return this.request("/policy-sets",{method:"POST",body:JSON.stringify(t)})}async updatePolicySet(t,n){return this.request(`/policy-sets/${t}`,{method:"PUT",body:JSON.stringify(n)})}async deletePolicySet(t){return this.request(`/policy-sets/${t}`,{method:"DELETE"})}async addPolicyToSet(t,n){return this.request(`/policy-sets/${t}/policies`,{method:"POST",body:JSON.stringify({policyId:n})})}async removePolicyFromSet(t,n){return this.request(`/policy-sets/${t}/policies/${n}`,{method:"DELETE"})}async getSessionPolicySets(t){return this.request(`/sessions/${t}/policy-sets`)}async applyPolicySetToSession(t,n){return this.request(`/sessions/${t}/policy-sets`,{method:"POST",body:JSON.stringify({policySetId:n})})}async removePolicySetFromSession(t,n){return this.request(`/sessions/${t}/policy-sets/${n}`,{method:"DELETE"})}async getEffectivePolicies(t){return this.request(`/sessions/${t}/effective-policies`)}async getPolicyDecisions(t){const n=new URLSearchParams;t!=null&&t.sessionId&&n.append("sessionId",t.sessionId),t!=null&&t.decision&&n.append("decision",t.decision),t!=null&&t.limit&&n.append("limit",String(t.limit));const r=n.toString();return this.request(`/policy-decisions${r?`?${r}`:""}`)}async getWorkflows(){return this.request("/workflows")}async getWorkflow(t){return this.request(`/workflows/${t}`)}async createWorkflow(t){return this.request("/workflows",{method:"POST",body:JSON.stringify(t)})}async executeWorkflow(t,n){return this.request(`/workflows/${t}/execute`,{method:"POST",body:JSON.stringify({variables:n})})}async getWorkflowExecutions(t){return this.request(`/workflows/${t}/executions`)}async getWorkflowExecution(t,n){return this.request(`/workflows/${t}/executions/${n}`)}async cancelExecution(t,n){return this.request(`/workflows/${t}/executions/${n}/cancel`,{method:"POST"})}async getWorkspaces(){return this.request("/workspaces")}async createWorkspace(t){return this.request("/workspaces",{method:"POST",body:JSON.stringify(t)})}async updateWorkspace(t,n){return this.request(`/workspaces/${t}`,{method:"PUT",body:JSON.stringify(n)})}async deleteWorkspace(t){return this.request(`/workspaces/${t}`,{method:"DELETE"})}async getEnvSets(){return this.request("/env-sets")}async createEnvSet(t){return this.request("/env-sets",{method:"POST",body:JSON.stringify(t)})}async updateEnvSet(t,n){return this.request(`/env-sets/${t}`,{method:"PUT",body:JSON.stringify(n)})}async deleteEnvSet(t){return this.request(`/env-sets/${t}`,{method:"DELETE"})}async getDaemonSettings(){return this.request("/settings/daemon")}async updateDaemonSettings(t){return this.request("/settings/daemon",{method:"PUT",body:JSON.stringify(t)})}async restartDaemon(){return this.request("/settings/daemon/restart",{method:"POST"})}async getNotifications(t){const n=new URLSearchParams;t!=null&&t.sessionId&&n.append("sessionId",t.sessionId),t!=null&&t.eventType&&n.append("eventType",t.eventType),typeof(t==null?void 0:t.unreadOnly)=="boolean"&&n.append("unreadOnly",t.unreadOnly?"true":"false"),typeof(t==null?void 0:t.before)=="number"&&n.append("before",String(t.before)),typeof(t==null?void 0:t.limit)=="number"&&n.append("limit",String(t.limit));const r=n.toString();return this.request(`/notifications${r?`?${r}`:""}`)}async getNotificationCounts(){return this.request("/notifications/counts")}async markNotificationRead(t,n){return this.request(`/notifications/${t}/read`,{method:"POST",body:JSON.stringify(n?{readSource:n}:{})})}async markNotificationsRead(t){return this.request("/notifications/read",{method:"POST",body:JSON.stringify(t??{})})}async getSessionNotificationPrefs(t){return this.request(`/sessions/${t}/notifications/prefs`)}async updateSessionNotificationPrefs(t,n){return this.request(`/sessions/${t}/notifications/prefs`,{method:"PUT",body:JSON.stringify({enabled:n})})}async listPushSubscriptions(){return this.request("/notifications/push/subscriptions")}async getPushDeliveryStatus(){return this.request("/notifications/push/status")}async sendTestPushNotification(t){return this.request("/notifications/push/test",{method:"POST",body:JSON.stringify(t??{})})}async upsertPushSubscription(t){return this.request("/notifications/push/subscriptions",{method:"PUT",body:JSON.stringify(t)})}async deletePushSubscription(t){return this.request("/notifications/push/subscriptions",{method:"DELETE",body:JSON.stringify({endpoint:t})})}async validateSession(t){return this.request("/sessions/validate",{method:"POST",body:JSON.stringify(t)})}async validateGit(t){return this.request("/sessions/validate-git",{method:"POST",body:JSON.stringify(t)})}async getGitStatus(t){return this.request(`/sessions/${t}/git/status`)}async getGitLog(t,n=50){return this.request(`/sessions/${t}/git/log?limit=${n}`)}async getGitDiff(t,n){const r=new URLSearchParams;n!=null&&n.staged&&r.append("staged","true"),n!=null&&n.commit&&r.append("commit",n.commit),n!=null&&n.commitA&&r.append("commitA",n.commitA),n!=null&&n.commitB&&r.append("commitB",n.commitB),n!=null&&n.path&&r.append("path",n.path);const s=r.toString();return this.request(`/sessions/${t}/git/diff${s?`?${s}`:""}`)}async getGitFile(t,n,r){const s=new URLSearchParams({ref:n,path:r});return this.request(`/sessions/${t}/git/file?${s}`)}async getGitFileRawBlob(t,n,r){const s=new URLSearchParams({ref:n,path:r});try{const a=await fetch(`${this.baseUrl}/sessions/${t}/git/file-raw?${s}`);return a.ok?await a.blob():null}catch{return null}}async getGitBranches(t){return this.request(`/sessions/${t}/git/branches`)}async getGitDiffStat(t,n,r){const s=new URLSearchParams({ref:n});return r&&s.append("base",r),this.request(`/sessions/${t}/git/diff-stat?${s}`)}async stageFiles(t,n){return this.request(`/sessions/${t}/git/stage`,{method:"POST",body:JSON.stringify({paths:n})})}async unstageFiles(t,n){return this.request(`/sessions/${t}/git/unstage`,{method:"POST",body:JSON.stringify({paths:n})})}async getTerminalInfo(t){return this.request(`/sessions/${t}/terminal/info`)}async setTerminalMode(t,n){return this.request(`/sessions/${t}/terminal/mode`,{method:"POST",body:JSON.stringify({mode:n})})}async scrollTerminal(t,n){return this.request(`/sessions/${t}/terminal/scroll`,{method:"POST",body:JSON.stringify(n)})}async searchTerminal(t,n){return this.request(`/sessions/${t}/terminal/search`,{method:"POST",body:JSON.stringify(n)})}}const ae=new Ep,Fo={"session.turn_completed":"Turn completed","session.permission_required":"Permission required","session.input_required":"Input required"},Cp={"claude-code":"Claude Code",codex:"Codex"};function kp(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function oi(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function si(e,t){return e.toLocaleLowerCase().includes(t.toLocaleLowerCase())}function jp(e,t){return si(e,t)?e:`${t}: ${e}`}function ao(e){return e in Fo?Fo[e]:oi(e.replace(/[._]+/g," "))}function ai(e){return Cp[e]??oi(e.replace(/-/g," "))}function Pp(e){return io(e)}function io(e,t){if(typeof t=="string"&&t.trim())return t.trim();const n=e.payload;return kp(n)&&typeof n.sessionLabel=="string"&&n.sessionLabel.trim()?n.sessionLabel.trim():`#${e.sessionId.slice(0,8)}`}function vr(e,t){var r;const n=io(e,t);return e.eventType==="session.turn_completed"?`${n} wrapped up a turn and is ready for your next move.`:e.eventType==="session.permission_required"?`${n} needs a quick permission decision to continue.`:e.eventType==="session.input_required"?`${n} is waiting for your input.`:(r=e.body)!=null&&r.trim()?jp(e.body.trim(),n):`${n}: ${ao(e.eventType)}.`}function wr(e,t){const n=io(e,t),r=e.title.trim();return r.length===0?n:si(r,n)?r:`${n} · ${r}`}const co="/sounds/codepiper-soft-chime.wav",Ag=[{key:"session.turn_completed",label:"Turn completed"},{key:"session.permission_required",label:"Permission required"},{key:"session.input_required",label:"Input required"}],Ig=512*1024;function Tp(e,t){return e[t]||e.default||co}function Mg(e){return e.type.startsWith("audio/")?!0:/\.(mp3|wav|ogg|m4a|aac|webm|flac)$/i.test(e.name)}const _p="dev";function Rp(){const e="0.2.0".trim(),t=globalThis.__CODEPIPER_WEB_BUILD_ID__,n=typeof t=="string"?t.trim():"",r=e||n;return r.length>0?r:_p}function ii(){return`/sw.js?v=${encodeURIComponent(Rp())}`}function Pn(e){e.waiting&&e.waiting.postMessage({type:"SKIP_WAITING"})}function Ap(e){return e==="sessions"||e==="notifications"||/^session:[a-zA-Z0-9-]+:(events|pty)$/.test(e)}function Ip(e){return/^session:[a-zA-Z0-9-]+:pty$/.test(e)}const cr=1,Bo=!1,Uo=!1,Wo=!0,Mp=67,Op=1,Dp=1,Lp=2,Ho=10,$p=16,Vo=4,lr=new TextDecoder,Fp=new TextEncoder,Bp=3e4,dr=8192,Up=512,Wp=2*1024*1024,Hp=256*1024,Vp=8,qp=80;let ur=0;class Kp{constructor(t){le(this,"ws",null);le(this,"url");le(this,"subscribers",new Map);le(this,"subscriptionOptions",new Map);le(this,"connectionStateHandlers",new Set);le(this,"reconnectTimeout",null);le(this,"reconnectAttempts",0);le(this,"maxReconnectAttempts",10);le(this,"isIntentionallyClosed",!1);le(this,"connected",!1);le(this,"pendingInputRequests",new Map);le(this,"pendingPasteSends",new Map);le(this,"telemetryStartedAt",Date.now());le(this,"serverHelloAcknowledged",!1);le(this,"serverNegotiatedPtyPatch",!1);le(this,"serverNegotiatedPtyBinary",!1);le(this,"serverNegotiatedPtyPaste",!1);le(this,"telemetry",{connectionsOpened:0,connectionsClosed:0,reconnectSchedules:0,reconnectSuccesses:0,maxReconnectExhausted:0,messagesReceived:0,parseErrors:0,invalidMessageShape:0,invalidTopic:0,helloSent:0,helloAckReceived:0,helloAckVersionMismatch:0,subscribeSent:0,subscribeWithReplayCursorSent:0,unsubscribeSent:0,ptyInputSent:0,ptyKeySent:0,ptyPasteSent:0,ptyInputAcksReceived:0,ptyKeyAcksReceived:0,ptyPasteAcksReceived:0,ptyInputAckUnmatched:0,ptyKeyAckUnmatched:0,ptyPasteAckUnmatched:0,ptyInputErrorsReceived:0,ptyKeyErrorsReceived:0,ptyPasteErrorsReceived:0,ptyInputErrorUnmatched:0,ptyKeyErrorUnmatched:0,ptyPasteErrorUnmatched:0,ptyInputFallbackTriggered:0,ptyKeyFallbackTriggered:0,ptyPasteFallbackTriggered:0,ptyFallbackHandlerErrors:0});this.url=t}connect(){var t;if(((t=this.ws)==null?void 0:t.readyState)!==WebSocket.OPEN){this.isIntentionallyClosed=!1;try{this.ws=new WebSocket(this.url),this.ws.binaryType="arraybuffer",this.ws.onopen=()=>{console.log("[WebSocket] Connected"),this.telemetry.connectionsOpened+=1,this.serverHelloAcknowledged=!1,this.serverNegotiatedPtyPatch=!1,this.serverNegotiatedPtyBinary=!1,this.serverNegotiatedPtyPaste=!1,this.reconnectAttempts>0&&(this.telemetry.reconnectSuccesses+=1),this.reconnectAttempts=0,this.setConnectedState(!0),this.sendHello();for(const n of this.subscribers.keys())this.sendSubscribe(n,this.subscriptionOptions.get(n))},this.ws.onmessage=n=>{this.telemetry.messagesReceived+=1;try{if(typeof n.data=="string"){const s=JSON.parse(n.data);this.handleMessage(s);return}if(!(n.data instanceof ArrayBuffer)){console.error("[WebSocket] Received unsupported binary payload type");return}const r=Yp(n.data);if(!r){this.telemetry.parseErrors+=1,console.error("[WebSocket] Failed to decode binary PTY frame");return}this.handleMessage(r)}catch(r){this.telemetry.parseErrors+=1,console.error("[WebSocket] Failed to parse message:",r)}},this.ws.onerror=n=>{console.error("[WebSocket] Error:",n)},this.ws.onclose=()=>{console.log("[WebSocket] Disconnected"),this.telemetry.connectionsClosed+=1,this.setConnectedState(!1),this.isIntentionallyClosed||this.scheduleReconnect()}}catch(n){console.error("[WebSocket] Connection failed:",n),this.scheduleReconnect()}}}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts){this.telemetry.maxReconnectExhausted+=1,console.error("[WebSocket] Max reconnect attempts reached");return}const t=Math.min(1e3*2**this.reconnectAttempts,3e4);this.reconnectAttempts++,this.telemetry.reconnectSchedules+=1,console.log(`[WebSocket] Reconnecting in ${t}ms (attempt ${this.reconnectAttempts})...`),this.reconnectTimeout=setTimeout(()=>{this.connect()},t)}handleMessage(t){if(Gp(t)&&!("topic"in t)){this.handleControlMessage(t);return}if(!zp(t)){this.telemetry.invalidMessageShape+=1,console.error("[WebSocket] Invalid message payload shape");return}if(!Ap(t.topic)){this.telemetry.invalidTopic+=1,console.warn(`[WebSocket] Ignoring message for invalid topic: ${t.topic}`);return}const n=this.subscribers.get(t.topic);if(n){const{topic:r,...s}=t;for(const a of n)try{a(s)}catch(i){console.error(`[WebSocket] Error in handler for ${t.topic}:`,i)}}}handleControlMessage(t){if(t.op==="hello_ack"){this.telemetry.helloAckReceived+=1,this.serverHelloAcknowledged=!0;const n=t.version;if(typeof n=="number"&&n!==cr&&(this.telemetry.helloAckVersionMismatch+=1,console.warn(`[WebSocket] Protocol mismatch: client=${cr}, server=${n}`)),t.features&&typeof t.features=="object"){const r=t.features;this.serverNegotiatedPtyPaste=r.ptyPaste===!0}if(t.negotiated&&typeof t.negotiated=="object"){const r=t.negotiated;this.serverNegotiatedPtyPatch=r.ptyPatch===!0,this.serverNegotiatedPtyBinary=r.ptyBinary===!0,"ptyPaste"in r&&(this.serverNegotiatedPtyPaste=r.ptyPaste===!0)}return}if(t.op==="pty_input_ack"||t.op==="pty_key_ack"||t.op==="pty_paste_ack"){this.handleInputAckControlMessage(t);return}(t.op==="pty_input_error"||t.op==="pty_key_error"||t.op==="pty_paste_error")&&this.handleInputErrorControlMessage(t)}sendHello(){var t;((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN&&(this.telemetry.helloSent+=1,this.ws.send(JSON.stringify({op:"hello",version:cr,supports:{ptyPatch:Bo,ptyBinary:Uo,ptyPaste:Wo}})))}sendSubscribe(t,n){var r,s;if(((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN){const a={op:"subscribe",topic:t},i=(s=n==null?void 0:n.getReplayCursor)==null?void 0:s.call(n);this.telemetry.subscribeSent+=1,Ip(t)&&typeof i=="number"&&Number.isInteger(i)&&i>=0&&(a.sinceSeq=i,this.telemetry.subscribeWithReplayCursorSent+=1),this.ws.send(JSON.stringify(a))}}sendUnsubscribe(t){var n;((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN&&(this.telemetry.unsubscribeSent+=1,this.ws.send(JSON.stringify({op:"unsubscribe",topic:t})))}sendPtyInput(t,n,r){if(!(t&&n))return!1;const s=this.sendInputOperation("pty_input",t,{data:n},r);return s&&(this.telemetry.ptyInputSent+=1),s}sendPtyKey(t,n,r){if(!(t&&n))return!1;const s=this.sendInputOperation("pty_key",t,{key:n},r);return s&&(this.telemetry.ptyKeySent+=1),s}sendPtyPaste(t,n,r){var l;if(!(t&&n)||this.serverHelloAcknowledged&&!this.serverNegotiatedPtyPaste||((l=this.ws)==null?void 0:l.readyState)!==WebSocket.OPEN)return!1;const s=Jp(n);if(!s||s.length===0)return!1;const a=this.resolveInputRequestId({requestId:r==null?void 0:r.requestId,onDispatchError:(r==null?void 0:r.onDispatchError)??(()=>{})});if(!a)return!1;const i=(r==null?void 0:r.onDispatchError)??(()=>{});return this.registerPendingInputRequest("pty_paste",t,a,i),this.enqueuePtyPasteSend(t,a,s,i),!0}subscribe(t,n,r){var a;this.subscribers.has(t)?r&&this.subscriptionOptions.set(t,r):(this.subscribers.set(t,new Set),this.subscriptionOptions.set(t,r),this.sendSubscribe(t,r));const s=n;return(a=this.subscribers.get(t))==null||a.add(s),()=>{const i=this.subscribers.get(t);i&&(i.delete(s),i.size===0&&(this.subscribers.delete(t),this.subscriptionOptions.delete(t),this.sendUnsubscribe(t)))}}close(){this.isIntentionallyClosed=!0,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.ws&&(this.ws.close(),this.ws=null),this.setConnectedState(!1),this.serverHelloAcknowledged=!1,this.serverNegotiatedPtyPatch=!1,this.serverNegotiatedPtyBinary=!1,this.serverNegotiatedPtyPaste=!1,this.clearPendingInputRequests(),this.pendingPasteSends.clear(),this.subscribers.clear(),this.subscriptionOptions.clear()}getReadyState(){var t;return((t=this.ws)==null?void 0:t.readyState)??WebSocket.CLOSED}isConnected(){return this.connected}getTelemetrySnapshot(t=Date.now()){return{startedAt:this.telemetryStartedAt,uptimeMs:Math.max(0,t-this.telemetryStartedAt),connected:this.connected,reconnectAttempts:this.reconnectAttempts,connectionsOpened:this.telemetry.connectionsOpened,connectionsClosed:this.telemetry.connectionsClosed,reconnectSchedules:this.telemetry.reconnectSchedules,reconnectSuccesses:this.telemetry.reconnectSuccesses,maxReconnectExhausted:this.telemetry.maxReconnectExhausted,messagesReceived:this.telemetry.messagesReceived,parseErrors:this.telemetry.parseErrors,invalidMessageShape:this.telemetry.invalidMessageShape,invalidTopic:this.telemetry.invalidTopic,helloSent:this.telemetry.helloSent,helloAckReceived:this.telemetry.helloAckReceived,helloAckVersionMismatch:this.telemetry.helloAckVersionMismatch,clientAdvertisesPtyPatch:Bo,clientAdvertisesPtyBinary:Uo,clientAdvertisesPtyPaste:Wo,serverNegotiatedPtyPatch:this.serverNegotiatedPtyPatch,serverNegotiatedPtyBinary:this.serverNegotiatedPtyBinary,serverNegotiatedPtyPaste:this.serverNegotiatedPtyPaste,subscribeSent:this.telemetry.subscribeSent,subscribeWithReplayCursorSent:this.telemetry.subscribeWithReplayCursorSent,unsubscribeSent:this.telemetry.unsubscribeSent,ptyInputSent:this.telemetry.ptyInputSent,ptyKeySent:this.telemetry.ptyKeySent,ptyPasteSent:this.telemetry.ptyPasteSent,ptyInputAcksReceived:this.telemetry.ptyInputAcksReceived,ptyKeyAcksReceived:this.telemetry.ptyKeyAcksReceived,ptyPasteAcksReceived:this.telemetry.ptyPasteAcksReceived,ptyInputAckUnmatched:this.telemetry.ptyInputAckUnmatched,ptyKeyAckUnmatched:this.telemetry.ptyKeyAckUnmatched,ptyPasteAckUnmatched:this.telemetry.ptyPasteAckUnmatched,ptyInputErrorsReceived:this.telemetry.ptyInputErrorsReceived,ptyKeyErrorsReceived:this.telemetry.ptyKeyErrorsReceived,ptyPasteErrorsReceived:this.telemetry.ptyPasteErrorsReceived,ptyInputErrorUnmatched:this.telemetry.ptyInputErrorUnmatched,ptyKeyErrorUnmatched:this.telemetry.ptyKeyErrorUnmatched,ptyPasteErrorUnmatched:this.telemetry.ptyPasteErrorUnmatched,ptyInputFallbackTriggered:this.telemetry.ptyInputFallbackTriggered,ptyKeyFallbackTriggered:this.telemetry.ptyKeyFallbackTriggered,ptyPasteFallbackTriggered:this.telemetry.ptyPasteFallbackTriggered,ptyFallbackHandlerErrors:this.telemetry.ptyFallbackHandlerErrors,pendingInputRequests:this.pendingInputRequests.size,pendingPasteSessionQueues:this.pendingPasteSends.size}}getSessionInputQueueDepth(t){let n=0;for(const r of this.pendingInputRequests.values())r.sessionId===t&&(n+=1);return{pendingInputRequests:n,hasPendingPasteQueue:this.pendingPasteSends.has(t)}}onConnectionChange(t){return this.connectionStateHandlers.add(t),()=>{this.connectionStateHandlers.delete(t)}}setConnectedState(t){if(this.connected!==t){this.connected=t;for(const n of this.connectionStateHandlers)try{n(t)}catch(r){console.error("[WebSocket] Error in connection state handler:",r)}}}handleInputAckControlMessage(t){const n=t.op==="pty_key_ack"?"pty_key":t.op==="pty_paste_ack"?"pty_paste":"pty_input";if(n==="pty_key"?this.telemetry.ptyKeyAcksReceived+=1:n==="pty_paste"?this.telemetry.ptyPasteAcksReceived+=1:this.telemetry.ptyInputAcksReceived+=1,typeof t.sessionId!="string"||!t.sessionId){console.warn(`[WebSocket] Ignoring ${t.op} with invalid sessionId`);return}if(typeof t.requestId!="string"||!t.requestId){n==="pty_key"?this.telemetry.ptyKeyAckUnmatched+=1:n==="pty_paste"?this.telemetry.ptyPasteAckUnmatched+=1:this.telemetry.ptyInputAckUnmatched+=1,console.warn(`[WebSocket] Ignoring ${t.op} with invalid requestId`);return}const r=this.pendingInputRequests.get(t.requestId);if(!r||r.op!==n||r.sessionId!==t.sessionId){n==="pty_key"?this.telemetry.ptyKeyAckUnmatched+=1:n==="pty_paste"?this.telemetry.ptyPasteAckUnmatched+=1:this.telemetry.ptyInputAckUnmatched+=1,console.warn(`[WebSocket] Received unmatched ${t.op} for session ${t.sessionId}`,{requestId:t.requestId});return}this.takePendingInputRequest(t.requestId)}handleInputErrorControlMessage(t){const n=t.op==="pty_key_error"?"pty_key":t.op==="pty_paste_error"?"pty_paste":"pty_input";if(n==="pty_key"?this.telemetry.ptyKeyErrorsReceived+=1:n==="pty_paste"?this.telemetry.ptyPasteErrorsReceived+=1:this.telemetry.ptyInputErrorsReceived+=1,typeof t.sessionId!="string"||!t.sessionId){console.warn(`[WebSocket] Ignoring ${t.op} with invalid sessionId`);return}const r=typeof t.requestId=="string"&&t.requestId?t.requestId:void 0;let s=r&&this.pendingInputRequests.has(r)?this.pendingInputRequests.get(r):void 0;if(r&&s&&s.op===n&&s.sessionId===t.sessionId?this.takePendingInputRequest(r):r&&(s=void 0),s||(s=this.takeFirstPendingInputRequest(n,t.sessionId)),!s||s.op!==n||s.sessionId!==t.sessionId){n==="pty_key"?this.telemetry.ptyKeyErrorUnmatched+=1:n==="pty_paste"?this.telemetry.ptyPasteErrorUnmatched+=1:this.telemetry.ptyInputErrorUnmatched+=1,console.warn(`[WebSocket] Received unmatched ${t.op} for session ${t.sessionId}`,r?{requestId:r}:void 0);return}n==="pty_key"?this.telemetry.ptyKeyFallbackTriggered+=1:n==="pty_paste"?this.telemetry.ptyPasteFallbackTriggered+=1:this.telemetry.ptyInputFallbackTriggered+=1,Promise.resolve(s.onError()).catch(a=>{this.telemetry.ptyFallbackHandlerErrors+=1,console.error(`[WebSocket] ${t.op} fallback failed:`,a)})}sendInputOperation(t,n,r,s){var i;if(((i=this.ws)==null?void 0:i.readyState)!==WebSocket.OPEN)return!1;const a=this.resolveInputRequestId(s);a&&(s!=null&&s.onDispatchError)&&this.registerPendingInputRequest(t,n,a,s.onDispatchError);try{return this.ws.send(JSON.stringify({op:t,sessionId:n,...r,...a?{requestId:a}:{}})),!0}catch(l){return a&&this.takePendingInputRequest(a),console.error(`[WebSocket] Failed to send ${t}:`,l),!1}}resolveInputRequestId(t){const n=t==null?void 0:t.requestId;if(typeof n=="string"&&/^[a-zA-Z0-9_-]{1,128}$/.test(n))return n;if(t!=null&&t.onDispatchError)return ur=(ur+1)%Number.MAX_SAFE_INTEGER,`wr${Date.now().toString(36)}_${ur.toString(36)}`}registerPendingInputRequest(t,n,r,s){const a=this.pendingInputRequests.get(r);a&&clearTimeout(a.timeout);const i=setTimeout(()=>{this.pendingInputRequests.delete(r)},Bp);this.pendingInputRequests.set(r,{op:t,sessionId:n,onError:s,timeout:i})}takePendingInputRequest(t){const n=this.pendingInputRequests.get(t);if(n)return clearTimeout(n.timeout),this.pendingInputRequests.delete(t),n}takeFirstPendingInputRequest(t,n){for(const[r,s]of this.pendingInputRequests.entries())if(s.op===t&&s.sessionId===n)return this.takePendingInputRequest(r)}clearPendingInputRequests(){for(const t of this.pendingInputRequests.values())clearTimeout(t.timeout);this.pendingInputRequests.clear()}enqueuePtyPasteSend(t,n,r,s){const l=(this.pendingPasteSends.get(t)??Promise.resolve()).catch(()=>{}).then(async()=>{await this.sendPtyPasteChunks(t,n,r)}).catch(d=>(this.takePendingInputRequest(n),this.telemetry.ptyPasteFallbackTriggered+=1,console.error("[WebSocket] Failed to send pty_paste:",d),Promise.resolve(s()).catch(f=>{this.telemetry.ptyFallbackHandlerErrors+=1,console.error("[WebSocket] pty_paste fallback failed:",f)}))).finally(()=>{this.pendingPasteSends.get(t)===l&&this.pendingPasteSends.delete(t)});this.pendingPasteSends.set(t,l)}async sendPtyPasteChunks(t,n,r){for(let s=0;s<r.length;s+=1){const a=this.ws;if(!a||a.readyState!==WebSocket.OPEN)throw new Error("WebSocket is not connected");await this.waitForPasteBufferDrain(a),a.send(JSON.stringify({op:"pty_paste",sessionId:t,requestId:n,chunkIndex:s,chunkCount:r.length,data:r[s]})),this.telemetry.ptyPasteSent+=1}}async waitForPasteBufferDrain(t){let n=0;for(;t.readyState===WebSocket.OPEN&&t.bufferedAmount>Hp&&n<qp;)n+=1,await new Promise(r=>setTimeout(r,Vp));if(t.readyState!==WebSocket.OPEN)throw new Error("WebSocket disconnected while streaming paste")}}function zp(e){return!(e&&typeof e=="object")||Array.isArray(e)?!1:typeof e.topic=="string"}function Gp(e){return!(e&&typeof e=="object")||Array.isArray(e)?!1:typeof e.op=="string"}function Yp(e){const t=new Uint8Array(e);if(t.byteLength<Ho+Vo)return null;const n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint8(0),s=n.getUint8(1),a=n.getUint8(2);if(r!==Mp||s!==Op)return null;const i=n.getUint16(4,!0),l=n.getUint32(6,!0);let d=Ho;const f=d+i;if(f>t.byteLength)return null;const m=lr.decode(t.subarray(d,f));if(d=f,a===Dp){if(d+Vo>t.byteLength)return null;const h=n.getUint32(d,!0);d+=4;const u=d+h;if(u!==t.byteLength)return null;const x=lr.decode(t.subarray(d,u));return{topic:m,type:"pty_output",data:x,seq:l}}if(a===Lp){if(d+$p>t.byteLength)return null;const h=n.getUint32(d,!0);d+=4;const u=n.getUint32(d,!0);d+=4;const x=n.getUint32(d,!0);d+=4;const g=n.getUint32(d,!0);d+=4;const y=d+g;if(y!==t.byteLength)return null;const b=lr.decode(t.subarray(d,y));return{topic:m,type:"pty_patch",baseSeq:h,seq:l,start:u,deleteCount:x,data:b}}return null}function Jp(e){if(!e)return[];if(Fp.encode(e).byteLength>Wp||e.length>dr*Up)return null;const t=[];for(let n=0;n<e.length;n+=dr)t.push(e.slice(n,n+dr));return t}const Xp=window.location.protocol==="https:"?"wss:":"ws:",Zp=`${Xp}//${window.location.host}/ws`,at=new Kp(Zp),Sr={totalUnread:0,bySession:{}},qo={notificationsEnabled:!1,systemNotificationsEnabled:!1,notificationSoundsEnabled:!0,notificationEventDefaults:{},notificationSoundMap:{default:co}},ci=c.createContext(null);function Mt(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ko(e){return typeof e!="number"||Number.isNaN(e)||!Number.isFinite(e)?0:Math.max(0,Math.floor(e))}function zo(e){if(!Mt(e))return Sr;const t=Mt(e.bySession)?e.bySession:{},n=Object.entries(t).reduce((r,[s,a])=>{const i=Ko(a);return i>0&&(r[s]=i),r},{});return{totalUnread:Ko(e.totalUnread),bySession:n}}function Qp(e){return e.type==="notification_counts_updated"&&Mt(e.data)}function Go(e,t){return Mt(e)?typeof e.status=="number"&&e.status===t:!1}function Yo(e){return typeof e=="string"?e:typeof e=="number"&&Number.isFinite(e)?new Date(e).toISOString():e instanceof Date?e.toISOString():null}function li(){return typeof window<"u"&&window.isSecureContext&&"serviceWorker"in navigator&&"PushManager"in window}function em(){return null}function tm(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),s=new Uint8Array(new ArrayBuffer(r.length));for(let a=0;a<r.length;a+=1)s[a]=r.charCodeAt(a);return s.buffer}function Nr(e){if(!e)return null;const t=new Uint8Array(e);let n="";for(const r of t)n+=String.fromCharCode(r);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function nm(e,t){var r;const n=(r=e.options)==null?void 0:r.applicationServerKey;return n?Nr(n)===t:!0}function rm(e){const t=Nr(e.getKey("p256dh")),n=Nr(e.getKey("auth"));return t&&n?{endpoint:e.endpoint,expirationTime:e.expirationTime??null,keys:{p256dh:t,auth:n}}:null}async function om(){if(!li())return null;try{const e=await navigator.serviceWorker.getRegistration();if(e)return Pn(e),e;const t=await navigator.serviceWorker.register(ii());return Pn(t),t}catch{return null}}function sm(e){if(!Mt(e)||typeof e.id!="number"||typeof e.sessionId!="string"||typeof e.title!="string"||typeof e.eventType!="string")return null;const t=Yo(e.createdAt);return t?{id:e.id,sessionId:e.sessionId,provider:typeof e.provider=="string"?e.provider:"unknown",eventType:e.eventType,sourceEventId:typeof e.sourceEventId=="number"?e.sourceEventId:null,title:e.title,body:typeof e.body=="string"?e.body:null,payload:Mt(e.payload)?e.payload:{},createdAt:t,readAt:Yo(e.readAt),readSource:typeof e.readSource=="string"?e.readSource:null}:null}function am({children:e}){const[t,n]=c.useState(Sr),[r,s]=c.useState(qo),[a,i]=c.useState(null),[l,d]=c.useState(!0),[f,m]=c.useState(null),p=c.useCallback(async()=>{try{const g=await ae.getNotificationCounts();n(zo(g.counts)),m(null)}catch(g){if(Go(g,404)){n(Sr),m(null);return}const y=g instanceof Error?g.message:"Failed to load notifications";m(y)}},[]),h=c.useCallback(async()=>{try{const g=await ae.getDaemonSettings(),y=g.settings.notificationSoundMap??{};s({notificationsEnabled:g.settings.notificationsEnabled??!1,systemNotificationsEnabled:g.settings.systemNotificationsEnabled??!1,notificationSoundsEnabled:g.settings.notificationSoundsEnabled??!0,notificationEventDefaults:g.settings.notificationEventDefaults??{},notificationSoundMap:{default:co,...y}})}catch(g){Go(g,404)&&s(qo)}},[]),u=c.useCallback(g=>{i(y=>y&&typeof g=="number"&&y.id!==g?y:null)},[]);c.useEffect(()=>{let g=!0;d(!0),Promise.all([p(),h()]).finally(()=>{g&&d(!1)});const y=at.subscribe("notifications",v=>{if(v.type==="notification_created"){const w=sm(v.data);w&&i(w);return}Qp(v)&&n(zo(v.data))}),b=at.onConnectionChange(v=>{v&&(p(),h())});return()=>{g=!1,y(),b()}},[p,h]),c.useEffect(()=>{if(!(r.notificationsEnabled&&r.systemNotificationsEnabled)||!li()||typeof window>"u"||typeof window.Notification>"u"||window.Notification.permission!=="granted")return;let g=!1;return(async()=>{try{const v=await(async()=>{const C=em();if(C)return C;try{const I=(await ae.getPushDeliveryStatus()).status.publicKey;if(typeof I=="string"&&I.trim()!=="")return I.trim()}catch{}return null})();if(!v||g)return;const w=await om();if(!(w&&!g))return;let E=await w.pushManager.getSubscription();if(E&&!nm(E,v)){const C=E.endpoint;await ae.deletePushSubscription(C).catch(()=>{}),await E.unsubscribe().catch(()=>{}),E=null}if(E||(E=await w.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:tm(v)})),!(E&&!g))return;const S=rm(E);if(!S)return;await ae.upsertPushSubscription(S)}catch{}})(),()=>{g=!0}},[r.notificationsEnabled,r.systemNotificationsEnabled]);const x=c.useMemo(()=>({counts:t,settings:r,lastCreatedNotification:a,loading:l,error:f,refresh:p,refreshSettings:h,clearLastCreatedNotification:u}),[t,r,a,l,f,p,h,u]);return o.jsx(ci.Provider,{value:x,children:e})}function rn(){const e=c.useContext(ci);if(!e)throw new Error("useNotifications must be used within a NotificationProvider");return e}const Ct=5,Jo="(max-width: 767px)";function Er(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function im(e,t){return Er(e)&&typeof e.status=="number"&&e.status===t}function cm(e){return e.type==="notification_created"}function lm(e){return!Er(e)||typeof e.id!="number"||typeof e.sessionId!="string"||typeof e.title!="string"||typeof e.eventType!="string"||typeof e.createdAt!="string"?null:{id:e.id,sessionId:e.sessionId,provider:typeof e.provider=="string"?e.provider:"unknown",eventType:e.eventType,sourceEventId:typeof e.sourceEventId=="number"?e.sourceEventId:null,title:e.title,body:typeof e.body=="string"?e.body:null,payload:Er(e.payload)?e.payload:{},createdAt:e.createdAt,readAt:typeof e.readAt=="string"?e.readAt:null,readSource:typeof e.readSource=="string"?e.readSource:null}}function bn(e){const t=new Set,n=[];for(const r of e)t.has(r.id)||(t.add(r.id),n.push(r));return n}function dm(e,t){const n=e.filter(r=>r.id!==t.id);return n.unshift(t),bn(n)}function um(){const[e,t]=c.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(Jo).matches);return c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia(Jo),r=s=>{t(s.matches)};return t(n.matches),typeof n.addEventListener=="function"?(n.addEventListener("change",r),()=>n.removeEventListener("change",r)):(n.addListener(r),()=>n.removeListener(r))},[]),e}function fm({open:e,onClose:t}){const n=gt(),r=um(),{refresh:s}=rn(),[a,i]=c.useState(!1),[l,d]=c.useState(!1),[f,m]=c.useState(null),[p,h]=c.useState(!1),[u,x]=c.useState([]),[g,y]=c.useState(!0),[b,v]=c.useState(!1),[w,E]=c.useState(void 0),S=c.useCallback(async()=>{var _;if(e){i(!0);try{const j=await ae.getNotifications({unreadOnly:p,limit:Ct+1}),R=bn(j.notifications),A=R.length>Ct,N=A?R.slice(0,Ct):R;x(N),v(A),E(N.length>0?(_=N[N.length-1])==null?void 0:_.id:void 0),y(!0),m(null),await s()}catch(j){if(im(j,404)){x([]),y(!1),v(!1),E(void 0),m(null);return}m(j instanceof Error?j.message:"Failed to load notifications")}finally{i(!1)}}},[e,p,s]),C=c.useCallback(async()=>{var _;if(!(!(e&&b&&w!==void 0)||a||l)){d(!0);try{const j=await ae.getNotifications({unreadOnly:p,before:w,limit:Ct+1}),R=bn(j.notifications),A=R.length>Ct,N=A?R.slice(0,Ct):R;if(N.length===0){v(!1);return}x(U=>bn([...U,...N])),E((_=N[N.length-1])==null?void 0:_.id),v(A),m(null)}catch(j){m(j instanceof Error?j.message:"Failed to load more notifications")}finally{d(!1)}}},[w,b,a,l,e,p]);c.useEffect(()=>{e&&S()},[e,S]),c.useEffect(()=>{if(!e)return;const _=at.subscribe("notifications",j=>{if(j.type==="notification_read"){S();return}if(cm(j)){const R=lm(j.data);if(!(R&&!(p&&R.readAt)))return;x(A=>dm(A,R));return}j.type==="notification_counts_updated"&&s()});return()=>{_()}},[e,p,S,s]);const k=c.useMemo(()=>u.reduce((_,j)=>_+(j.readAt?0:1),0),[u]),I=c.useCallback(async _=>{if(!_.readAt)try{await ae.markNotificationRead(_.id,"click")}catch{}x(j=>j.map(R=>R.id===_.id?{...R,readAt:R.readAt??new Date().toISOString(),readSource:"click"}:R)),s(),n(`/sessions/${_.sessionId}/terminal`),t()},[n,t,s]),H=c.useCallback(async()=>{try{if((await ae.markNotificationsRead({readSource:"bulk"})).updated>0){const j=new Date().toISOString();x(R=>R.map(A=>A.readAt?A:{...A,readAt:j,readSource:"bulk"}))}s()}catch(_){m(_ instanceof Error?_.message:"Failed to mark notifications as read")}},[s]);if(!e)return null;const D=o.jsx(o.Fragment,{children:o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[o.jsxs("div",{className:"bg-gradient-to-b from-cyan-500/10 via-cyan-500/[0.02] to-transparent",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-border/80 px-3 py-2.5",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(fs,{className:"h-4 w-4 text-cyan-400"}),o.jsx("h3",{className:"text-sm font-semibold",children:"Notifications"}),k>0&&o.jsx("span",{className:"rounded-full bg-amber-500 px-1.5 py-0.5 text-[10px] font-semibold text-amber-950",children:k>99?"99+":k})]}),o.jsxs("button",{type:"button",onClick:()=>void H(),className:"inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/95 px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-accent/85 hover:text-foreground disabled:opacity-40",disabled:a||l||u.length===0||k===0,children:[o.jsx(Xc,{className:"h-3.5 w-3.5"}),"Mark all read"]})]}),o.jsx("div",{className:"border-b border-border/70 px-3 py-2.5",children:o.jsxs("div",{className:"grid grid-cols-2 items-center gap-1 rounded-lg bg-muted/25 p-1",children:[o.jsx("button",{type:"button",onClick:()=>h(!1),className:`rounded-md px-2 py-1.5 text-xs font-medium transition-colors ${p?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)]"}`,children:"All"}),o.jsx("button",{type:"button",onClick:()=>h(!0),className:`rounded-md px-2 py-1.5 text-xs font-medium transition-colors ${p?"bg-background text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)]":"text-muted-foreground hover:text-foreground"}`,children:"Unread"})]})})]}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2.5 pb-[calc(env(safe-area-inset-bottom)+0.75rem)] md:pb-2.5",children:a?o.jsxs("div",{className:"flex items-center justify-center gap-2 px-3 py-8 text-sm text-muted-foreground",children:[o.jsx(Or,{className:"h-4 w-4 animate-spin"}),o.jsx("span",{children:"Loading notifications..."})]}):g?f?o.jsx("div",{className:"px-3 py-6 text-sm text-red-400",children:f}):u.length===0?o.jsx("div",{className:"px-3 py-8 text-sm text-muted-foreground",children:p?"No unread notifications.":"No notifications yet."}):o.jsxs("ul",{className:"space-y-2",children:[u.map(_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>void I(_),className:`w-full rounded-xl border px-3 py-2.5 text-left transition-colors ${_.readAt?"border-border/65 bg-background/98 hover:bg-accent/60":"border-cyan-500/35 bg-gradient-to-r from-cyan-500/14 via-cyan-500/[0.05] to-background/95 hover:from-cyan-500/20"}`,children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm font-semibold text-foreground",children:wr(_)}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px]",children:[o.jsx("span",{className:"rounded-full border border-border/70 bg-muted/20 px-1.5 py-0.5 text-muted-foreground",children:ao(_.eventType)}),o.jsx("span",{className:"rounded-full border border-border/70 bg-muted/20 px-1.5 py-0.5 text-muted-foreground",children:ai(_.provider)})]})]}),o.jsx("span",{className:"text-[10px] text-muted-foreground",children:jn(_.createdAt)})]}),o.jsx("p",{className:"mt-1 text-xs leading-snug text-foreground/80",children:vr(_)}),o.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-[10px] text-muted-foreground",children:[o.jsx("span",{className:"rounded-md bg-muted/25 px-1.5 py-0.5 font-mono",children:Pp(_)}),!_.readAt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-border",children:"•"}),o.jsx("span",{className:"text-cyan-400",children:"Unread"})]})]})]})},_.id)),(b||l)&&o.jsx("li",{className:"pt-1 pb-2 text-center",children:o.jsx("button",{type:"button",onClick:()=>void C(),disabled:l,className:"text-xs font-medium text-cyan-400 hover:text-cyan-300 underline underline-offset-4 disabled:opacity-45 disabled:no-underline",children:l?"Loading...":"Load more"})})]}):o.jsx("div",{className:"px-3 py-6 text-sm text-muted-foreground",children:"Notification inbox is not supported by the connected daemon version."})})]})}),W=r&&typeof document<"u",T=W?"fixed inset-0 z-[260] cursor-default bg-background/60 backdrop-blur-[2.5px]":"fixed inset-0 z-[90] hidden cursor-default bg-background/60 backdrop-blur-[2.5px] md:block md:bg-transparent md:backdrop-blur-0",L=W?"notification-inbox-surface fixed inset-x-2 top-[calc(env(safe-area-inset-top)+3.25rem)] bottom-[calc(env(safe-area-inset-bottom)+5.2rem)] z-[270] flex min-h-0 flex-col overflow-hidden rounded-2xl border border-border/80 text-popover-foreground shadow-[0_26px_60px_rgba(0,0,0,0.34)]":"notification-inbox-surface relative z-[120] hidden min-h-0 flex-col overflow-hidden rounded-xl border border-border text-popover-foreground shadow-[0_20px_48px_rgba(0,0,0,0.45)] md:absolute md:inset-x-auto md:right-0 md:top-[calc(100%+0.5rem)] md:flex md:w-[24rem] md:max-h-[70vh]",$=o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button","aria-label":"Close notification inbox",className:T,onClick:t}),o.jsx("section",{role:"dialog","aria-modal":"true","aria-label":"Notification inbox",className:L,children:D})]});return r&&typeof document>"u"?null:W?Ot.createPortal($,document.body):$}function pm(e){if(!(e&&typeof e=="object"))return!1;const t=e;return typeof t.id=="string"&&typeof t.provider=="string"&&typeof t.cwd=="string"&&typeof t.status=="string"&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"}function mm(e){if(!(e&&typeof e=="object"))return!1;const t=e,n=t.type;return n==="session_deleted"?typeof t.sessionId=="string":n==="session_created"||n==="session_updated"?pm(t.session):!1}function on(){const[e,t]=c.useState([]),[n,r]=c.useState(!0),[s,a]=c.useState(null),i=c.useCallback(async()=>{try{const d=await ae.getSessions();t(d.sessions)}catch{}},[]),l=c.useCallback((d,f)=>{t(m=>m.map(p=>p.id===d?{...p,status:f}:p))},[]);return c.useEffect(()=>{let d=!0;(async()=>{try{r(!0),a(null);const p=await ae.getSessions();d&&t(p.sessions)}catch(p){d&&a(p instanceof Error?p.message:"Failed to fetch sessions")}finally{d&&r(!1)}})();const m=at.subscribe("sessions",p=>{mm(p)&&(p.type==="session_created"?t(h=>[...h,p.session]):p.type==="session_updated"?t(h=>h.map(u=>u.id===p.session.id?p.session:u)):p.type==="session_deleted"&&t(h=>h.filter(u=>u.id!==p.sessionId)))});return()=>{d=!1,m()}},[]),{sessions:e,loading:n,error:s,refresh:i,updateSessionStatus:l}}function Xo(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function hm(e){const t=e.trim();return t.length>0?t:null}function di(e){if(!Xo(e.metadata))return null;const t=e.metadata.ui;return!Xo(t)||typeof t.customName!="string"?null:hm(t.customName)}function ui(e){const t=e.replace(/[\\/]+$/,"");if(!t)return e||"session";const n=t.split(/[\\/]/).filter(Boolean);return n[n.length-1]??t}function sn(e){const t=new Map,n=new Map,r=[...e].sort((s,a)=>{const i=new Date(s.createdAt).getTime()-new Date(a.createdAt).getTime();return i!==0?i:s.id.localeCompare(a.id)});for(const s of r){const a=di(s);if(a){t.set(s.id,a);continue}const i=ui(s.cwd),l=n.get(i);l?l.push(s.id):n.set(i,[s.id])}for(const[s,a]of n){if(a.length===1){t.set(a[0],s);continue}a.forEach((i,l)=>{t.set(i,`${s} [${l+1}]`)})}return t}function Rt(e,t){return(t==null?void 0:t.get(e.id))??di(e)??ui(e.cwd)}function gm(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function xm(e){const t=e.match(/^\/sessions\/([^/]+)(?:\/([^/]+))?$/);if(!t)return null;const n=t[1],r=t[2];return r&&r!=="terminal"?null:n}function ym(){return typeof window<"u"&&window.isSecureContext&&typeof window.Notification<"u"&&window.Notification.permission==="granted"}function bm(e){return`/sessions/${encodeURIComponent(e)}/terminal`}const vm=45e3;function wm(e){return e==="session.turn_completed"?{badge:"border border-emerald-500/25 bg-emerald-500/14 text-emerald-800 dark:text-emerald-300",button:"border border-emerald-500/55 bg-emerald-600 text-white hover:bg-emerald-500 dark:bg-emerald-500 dark:text-emerald-950 dark:hover:bg-emerald-400",border:"border-emerald-500/28"}:e==="session.permission_required"?{badge:"border border-amber-500/25 bg-amber-500/14 text-amber-800 dark:text-amber-300",button:"border border-amber-500/55 bg-amber-600 text-white hover:bg-amber-500 dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400",border:"border-amber-500/32"}:{badge:"border border-cyan-500/25 bg-cyan-500/12 text-cyan-800 dark:text-cyan-300",button:"border border-cyan-500/55 bg-cyan-600 text-white hover:bg-cyan-500 dark:bg-cyan-500 dark:text-cyan-950 dark:hover:bg-cyan-400",border:"border-cyan-500/28"}}function Sm(){const{logout:e}=Mn(),{theme:t}=so(),n=gt(),r=In(),{sessions:s}=on(),{counts:a,settings:i,lastCreatedNotification:l,clearLastCreatedNotification:d}=rn(),[f,m]=c.useState(!1),[p,h]=c.useState(!1),[u,x]=c.useState(!1),[g,y]=c.useState(null),b=c.useRef(null),v=c.useRef(Date.now()),w=c.useMemo(()=>xm(r.pathname),[r.pathname]),E=c.useMemo(()=>sn(s),[s]);c.useEffect(()=>(m(at.isConnected()),at.onConnectionChange(T=>{m(T)})),[]),c.useEffect(()=>{if(!p)return;const T=L=>{L.key==="Escape"&&h(!1)};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[p]),c.useEffect(()=>{const T=()=>{v.current=Date.now()},L={passive:!0};return window.addEventListener("pointerdown",T,L),window.addEventListener("keydown",T),window.addEventListener("touchstart",T,L),window.addEventListener("focus",T),document.addEventListener("visibilitychange",T),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",T),window.removeEventListener("touchstart",T),window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",T)}},[]);const S=c.useCallback(async T=>{if(!i.notificationSoundsEnabled)return;const L=Tp(i.notificationSoundMap,T);if(L)try{const $=new Audio(L);$.volume=.55,await $.play();return}catch{}try{const $=window.AudioContext||window.webkitAudioContext;if(!$)return;b.current||(b.current=new $);const _=b.current;_.state==="suspended"&&await _.resume().catch(()=>{});const j=_.createOscillator(),R=_.createGain();j.type="sine",j.frequency.value=880,R.gain.value=1e-4,j.connect(R),R.connect(_.destination);const A=_.currentTime;R.gain.exponentialRampToValueAtTime(.035,A+.01),R.gain.exponentialRampToValueAtTime(1e-4,A+.16),j.start(A),j.stop(A+.18)}catch{}},[i.notificationSoundsEnabled,i.notificationSoundMap]),C=c.useCallback(async(T,L,$)=>{if(!(i.systemNotificationsEnabled&&ym()))return!1;const _=vr(T,$),j=wr(T,$),R=`codepiper:notification:${T.id}`,A={url:L,sessionId:T.sessionId,notificationId:T.id};try{if("serviceWorker"in navigator){const U=await navigator.serviceWorker.getRegistration();if(U)return await U.showNotification(j,{body:_,tag:R,icon:"/apple-touch-icon.png",badge:"/logo.svg",data:A}),!0}const N=new window.Notification(j,{body:_,tag:R,icon:"/apple-touch-icon.png",data:A});return N.onclick=()=>{typeof window.focus=="function"&&window.focus(),ae.markNotificationRead(T.id,"click"),n(L),N.close()},!0}catch{return!1}},[n,i.systemNotificationsEnabled]);c.useEffect(()=>{if(!g)return;const T=setTimeout(()=>{y(L=>(L==null?void 0:L.id)===g.id?null:L)},6500);return()=>{clearTimeout(T)}},[g]),c.useEffect(()=>{if(!l)return;if(i.notificationEventDefaults[l.eventType]===!1){d(l.id);return}const L=typeof document<"u"?document.visibilityState==="visible":!1,$=w===l.sessionId&&L,_=Date.now()-v.current>=vm;if($&&!_){ae.markNotificationRead(l.id,"active").catch(()=>{}),d(l.id);return}const j=bm(l.sessionId),R=E.get(l.sessionId)??null,A=L;let N=null,U=!1;return(async()=>{var V;await C(l,j,R),!U&&(A&&(gm()||(x(!0),N=setTimeout(()=>x(!1),700),typeof navigator<"u"&&"vibrate"in navigator&&((V=navigator.vibrate)==null||V.call(navigator,20))),y({id:l.id,eventType:l.eventType,eventLabel:ao(l.eventType),providerLabel:ai(l.provider),title:wr(l,R),description:vr(l,R),targetPath:j}),S(l.eventType)),d(l.id))})(),()=>{U=!0,N&&clearTimeout(N)}},[d,l,S,C,w,i.notificationEventDefaults,E]);const k=t.mode==="dark"?"bg-background/60 backdrop-blur-xl":"bg-background/92 backdrop-blur-md",I=g?wm(g.eventType):null,H=c.useCallback(()=>{g&&(ae.markNotificationRead(g.id,"click"),n(g.targetPath),y(null))},[g,n]),D=c.useCallback(()=>{y(null)},[]),W=g&&I&&typeof document<"u"?Ot.createPortal(o.jsx("div",{className:"pointer-events-none fixed z-[500] right-[max(0.5rem,calc(env(safe-area-inset-right,0px)+0.35rem))] top-[max(0.5rem,calc(env(safe-area-inset-top,0px)+0.35rem))] w-[min(21.5rem,calc(100vw-1rem))]",children:o.jsxs("article",{className:F("pointer-events-auto animate-in rounded-2xl border p-3 shadow-[0_18px_36px_rgba(2,8,23,0.34)]",t.mode==="dark"?"bg-card/96 text-card-foreground backdrop-blur-md":"bg-popover/98 text-popover-foreground",I.border),"aria-live":"polite",children:[o.jsxs("div",{className:"mb-2 flex items-start justify-between gap-2",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"truncate text-[0.93rem] font-semibold leading-5",children:g.title}),o.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[o.jsx("span",{className:F("inline-flex rounded-full px-2 py-0.5 text-[10px] font-semibold",I.badge),children:g.eventLabel}),o.jsx("span",{className:"inline-flex rounded-full border border-border/60 bg-muted/35 px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:g.providerLabel})]})]}),o.jsx("button",{type:"button",onClick:D,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground","aria-label":"Dismiss notification",children:o.jsx(Rl,{className:"h-3.5 w-3.5"})})]}),o.jsx("p",{className:"line-clamp-3 text-[0.79rem] leading-5 text-muted-foreground",children:g.description}),o.jsx("div",{className:"mt-3 flex justify-end",children:o.jsx("button",{type:"button",onClick:H,className:F("h-8 rounded-full px-4 text-[0.75rem] font-semibold tracking-[0.01em] transition-colors",I.button),children:"Open session"})})]})}),document.body):null;return o.jsxs(o.Fragment,{children:[o.jsx("header",{className:F("relative z-[80] border-b border-border pt-safe",k),children:o.jsxs("div",{className:"flex h-12 items-center justify-between px-4 md:px-6",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsxs("a",{href:"/",className:"md:hidden flex items-center gap-2",children:[o.jsx("img",{src:"/piper.svg",alt:"CodePiper",className:"h-7 w-7"}),o.jsx("span",{className:"text-sm font-semibold tracking-wide",children:"CodePiper"})]}),o.jsx("div",{className:F("hidden md:flex items-center gap-2 px-2.5 py-1 rounded-full text-[11px] font-medium transition-all",f?"bg-emerald-500/[0.1] text-emerald-700 border border-emerald-500/30 dark:bg-emerald-500/[0.08] dark:text-emerald-400 dark:border-emerald-500/20":"bg-red-500/[0.1] text-red-700 border border-red-500/30 dark:bg-red-500/[0.08] dark:text-red-400 dark:border-red-500/20"),children:f?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"relative",children:[o.jsx(Tl,{className:"h-3 w-3"}),o.jsx("div",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 rounded-full bg-emerald-400 pulse-live"})]}),o.jsx("span",{children:"Connected"})]}):o.jsxs(o.Fragment,{children:[o.jsx(jl,{className:"h-3 w-3"}),o.jsx("span",{children:"Disconnected"})]})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"md:hidden",children:o.jsx("div",{className:F("w-2 h-2 rounded-full",f?"bg-emerald-500 dark:bg-emerald-400 shadow-[0_0_6px_rgba(16,185,129,0.5)]":"bg-red-500 dark:bg-red-400 shadow-[0_0_6px_rgba(248,113,113,0.5)]")})}),o.jsxs("div",{className:"relative",children:[o.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":p,onClick:()=>h(T=>!T),className:"relative h-8 w-8 rounded-lg flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200",title:a.totalUnread>0?`${a.totalUnread} unread notification${a.totalUnread===1?"":"s"}`:"No unread notifications",children:[o.jsx(fs,{className:F("h-4 w-4",u&&"bell-wiggle")}),a.totalUnread>0&&o.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-[16px] rounded-full bg-amber-500 text-[9px] font-bold text-amber-950 flex items-center justify-center px-1 leading-none shadow-[0_0_8px_rgba(245,158,11,0.45)] pulse-live",children:a.totalUnread>99?"99+":a.totalUnread})]}),o.jsx(fm,{open:p,onClose:()=>h(!1)})]}),o.jsx(Np,{}),o.jsx("button",{type:"button",onClick:e,className:"h-8 w-8 rounded-lg flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200",title:"Sign out",children:o.jsx(gl,{className:"h-4 w-4"})})]})]})}),W]})}var Nm=e=>{switch(e){case"success":return km;case"info":return Pm;case"warning":return jm;case"error":return Tm;default:return null}},Em=Array(12).fill(0),Cm=({visible:e,className:t})=>P.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},P.createElement("div",{className:"sonner-spinner"},Em.map((n,r)=>P.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),km=P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},P.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),jm=P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},P.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Pm=P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},P.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Tm=P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},P.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),_m=P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},P.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),P.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Rm=()=>{let[e,t]=P.useState(document.hidden);return P.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Cr=1,Am=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,s=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Cr++,a=this.toasts.find(l=>l.id===s),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),a?this.toasts=this.toasts.map(l=>l.id===s?(this.publish({...l,...e,id:s,title:n}),{...l,...e,id:s,dismissible:i,title:n}):l):this.addToast({title:n,...r,dismissible:i,id:s}),s},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),s=n!==void 0,a,i=r.then(async d=>{if(a=["resolve",d],P.isValidElement(d))s=!1,this.create({id:n,type:"default",message:d});else if(Mm(d)&&!d.ok){s=!1;let f=typeof t.error=="function"?await t.error(`HTTP error! status: ${d.status}`):t.error,m=typeof t.description=="function"?await t.description(`HTTP error! status: ${d.status}`):t.description;this.create({id:n,type:"error",message:f,description:m})}else if(t.success!==void 0){s=!1;let f=typeof t.success=="function"?await t.success(d):t.success,m=typeof t.description=="function"?await t.description(d):t.description;this.create({id:n,type:"success",message:f,description:m})}}).catch(async d=>{if(a=["reject",d],t.error!==void 0){s=!1;let f=typeof t.error=="function"?await t.error(d):t.error,m=typeof t.description=="function"?await t.description(d):t.description;this.create({id:n,type:"error",message:f,description:m})}}).finally(()=>{var d;s&&(this.dismiss(n),n=void 0),(d=t.finally)==null||d.call(t)}),l=()=>new Promise((d,f)=>i.then(()=>a[0]==="reject"?f(a[1]):d(a[1])).catch(f));return typeof n!="string"&&typeof n!="number"?{unwrap:l}:Object.assign(n,{unwrap:l})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Cr++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},be=new Am,Im=(e,t)=>{let n=(t==null?void 0:t.id)||Cr++;return be.addToast({title:e,...t,id:n}),n},Mm=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",Om=Im,Dm=()=>be.toasts,Lm=()=>be.getActiveToasts(),ve=Object.assign(Om,{success:be.success,info:be.info,warning:be.warning,error:be.error,custom:be.custom,message:be.message,promise:be.promise,dismiss:be.dismiss,loading:be.loading},{getHistory:Dm,getToasts:Lm});function $m(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}$m(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
199
- `);function hn(e){return e.label!==void 0}var Fm=3,Bm="32px",Um="16px",Zo=4e3,Wm=356,Hm=14,Vm=20,qm=200;function Ie(...e){return e.filter(Boolean).join(" ")}function Km(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var zm=e=>{var t,n,r,s,a,i,l,d,f,m,p;let{invert:h,toast:u,unstyled:x,interacting:g,setHeights:y,visibleToasts:b,heights:v,index:w,toasts:E,expanded:S,removeToast:C,defaultRichColors:k,closeButton:I,style:H,cancelButtonStyle:D,actionButtonStyle:W,className:T="",descriptionClassName:L="",duration:$,position:_,gap:j,loadingIcon:R,expandByDefault:A,classNames:N,icons:U,closeButtonAriaLabel:te="Close toast",pauseWhenPageIsHidden:V}=e,[z,G]=P.useState(null),[ne,ie]=P.useState(null),[M,Z]=P.useState(!1),[X,J]=P.useState(!1),[q,Y]=P.useState(!1),[ce,de]=P.useState(!1),[$e,Pe]=P.useState(!1),[we,Te]=P.useState(0),[Se,dt]=P.useState(0),ke=P.useRef(u.duration||$||Zo),ue=P.useRef(null),pe=P.useRef(null),an=w===0,cn=w+1<=b,ge=u.type,Ze=u.dismissible!==!1,Zn=u.className||"",ln=u.descriptionClassName||"",wt=P.useMemo(()=>v.findIndex(K=>K.toastId===u.id)||0,[v,u.id]),Qn=P.useMemo(()=>{var K;return(K=u.closeButton)!=null?K:I},[u.closeButton,I]),dn=P.useMemo(()=>u.duration||$||Zo,[u.duration,$]),St=P.useRef(0),qe=P.useRef(0),Ft=P.useRef(0),Ke=P.useRef(null),[O,fe]=_.split("-"),xe=P.useMemo(()=>v.reduce((K,re,se)=>se>=wt?K:K+re.height,0),[v,wt]),ye=Rm(),Nt=u.invert||h,Qe=ge==="loading";qe.current=P.useMemo(()=>wt*j+xe,[wt,xe]),P.useEffect(()=>{ke.current=dn},[dn]),P.useEffect(()=>{Z(!0)},[]),P.useEffect(()=>{let K=pe.current;if(K){let re=K.getBoundingClientRect().height;return dt(re),y(se=>[{toastId:u.id,height:re,position:u.position},...se]),()=>y(se=>se.filter(_e=>_e.toastId!==u.id))}},[y,u.id]),P.useLayoutEffect(()=>{if(!M)return;let K=pe.current,re=K.style.height;K.style.height="auto";let se=K.getBoundingClientRect().height;K.style.height=re,dt(se),y(_e=>_e.find(Re=>Re.toastId===u.id)?_e.map(Re=>Re.toastId===u.id?{...Re,height:se}:Re):[{toastId:u.id,height:se,position:u.position},..._e])},[M,u.title,u.description,y,u.id]);let Fe=P.useCallback(()=>{J(!0),Te(qe.current),y(K=>K.filter(re=>re.toastId!==u.id)),setTimeout(()=>{C(u)},qm)},[u,C,y,qe]);P.useEffect(()=>{if(u.promise&&ge==="loading"||u.duration===1/0||u.type==="loading")return;let K;return S||g||V&&ye?(()=>{if(Ft.current<St.current){let re=new Date().getTime()-St.current;ke.current=ke.current-re}Ft.current=new Date().getTime()})():ke.current!==1/0&&(St.current=new Date().getTime(),K=setTimeout(()=>{var re;(re=u.onAutoClose)==null||re.call(u,u),Fe()},ke.current)),()=>clearTimeout(K)},[S,g,u,ge,V,ye,Fe]),P.useEffect(()=>{u.delete&&Fe()},[Fe,u.delete]);function Sc(){var K,re,se;return U!=null&&U.loading?P.createElement("div",{className:Ie(N==null?void 0:N.loader,(K=u==null?void 0:u.classNames)==null?void 0:K.loader,"sonner-loader"),"data-visible":ge==="loading"},U.loading):R?P.createElement("div",{className:Ie(N==null?void 0:N.loader,(re=u==null?void 0:u.classNames)==null?void 0:re.loader,"sonner-loader"),"data-visible":ge==="loading"},R):P.createElement(Cm,{className:Ie(N==null?void 0:N.loader,(se=u==null?void 0:u.classNames)==null?void 0:se.loader),visible:ge==="loading"})}return P.createElement("li",{tabIndex:0,ref:pe,className:Ie(T,Zn,N==null?void 0:N.toast,(t=u==null?void 0:u.classNames)==null?void 0:t.toast,N==null?void 0:N.default,N==null?void 0:N[ge],(n=u==null?void 0:u.classNames)==null?void 0:n[ge]),"data-sonner-toast":"","data-rich-colors":(r=u.richColors)!=null?r:k,"data-styled":!(u.jsx||u.unstyled||x),"data-mounted":M,"data-promise":!!u.promise,"data-swiped":$e,"data-removed":X,"data-visible":cn,"data-y-position":O,"data-x-position":fe,"data-index":w,"data-front":an,"data-swiping":q,"data-dismissible":Ze,"data-type":ge,"data-invert":Nt,"data-swipe-out":ce,"data-swipe-direction":ne,"data-expanded":!!(S||A&&M),style:{"--index":w,"--toasts-before":w,"--z-index":E.length-w,"--offset":`${X?we:qe.current}px`,"--initial-height":A?"auto":`${Se}px`,...H,...u.style},onDragEnd:()=>{Y(!1),G(null),Ke.current=null},onPointerDown:K=>{Qe||!Ze||(ue.current=new Date,Te(qe.current),K.target.setPointerCapture(K.pointerId),K.target.tagName!=="BUTTON"&&(Y(!0),Ke.current={x:K.clientX,y:K.clientY}))},onPointerUp:()=>{var K,re,se,_e;if(ce||!Ze)return;Ke.current=null;let Re=Number(((K=pe.current)==null?void 0:K.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),et=Number(((re=pe.current)==null?void 0:re.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ut=new Date().getTime()-((se=ue.current)==null?void 0:se.getTime()),Ae=z==="x"?Re:et,tt=Math.abs(Ae)/ut;if(Math.abs(Ae)>=Vm||tt>.11){Te(qe.current),(_e=u.onDismiss)==null||_e.call(u,u),ie(z==="x"?Re>0?"right":"left":et>0?"down":"up"),Fe(),de(!0),Pe(!1);return}Y(!1),G(null)},onPointerMove:K=>{var re,se,_e,Re;if(!Ke.current||!Ze||((re=window.getSelection())==null?void 0:re.toString().length)>0)return;let et=K.clientY-Ke.current.y,ut=K.clientX-Ke.current.x,Ae=(se=e.swipeDirections)!=null?se:Km(_);!z&&(Math.abs(ut)>1||Math.abs(et)>1)&&G(Math.abs(ut)>Math.abs(et)?"x":"y");let tt={x:0,y:0};z==="y"?(Ae.includes("top")||Ae.includes("bottom"))&&(Ae.includes("top")&&et<0||Ae.includes("bottom")&&et>0)&&(tt.y=et):z==="x"&&(Ae.includes("left")||Ae.includes("right"))&&(Ae.includes("left")&&ut<0||Ae.includes("right")&&ut>0)&&(tt.x=ut),(Math.abs(tt.x)>0||Math.abs(tt.y)>0)&&Pe(!0),(_e=pe.current)==null||_e.style.setProperty("--swipe-amount-x",`${tt.x}px`),(Re=pe.current)==null||Re.style.setProperty("--swipe-amount-y",`${tt.y}px`)}},Qn&&!u.jsx?P.createElement("button",{"aria-label":te,"data-disabled":Qe,"data-close-button":!0,onClick:Qe||!Ze?()=>{}:()=>{var K;Fe(),(K=u.onDismiss)==null||K.call(u,u)},className:Ie(N==null?void 0:N.closeButton,(s=u==null?void 0:u.classNames)==null?void 0:s.closeButton)},(a=U==null?void 0:U.close)!=null?a:_m):null,u.jsx||c.isValidElement(u.title)?u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title:P.createElement(P.Fragment,null,ge||u.icon||u.promise?P.createElement("div",{"data-icon":"",className:Ie(N==null?void 0:N.icon,(i=u==null?void 0:u.classNames)==null?void 0:i.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||Sc():null,u.type!=="loading"?u.icon||(U==null?void 0:U[ge])||Nm(ge):null):null,P.createElement("div",{"data-content":"",className:Ie(N==null?void 0:N.content,(l=u==null?void 0:u.classNames)==null?void 0:l.content)},P.createElement("div",{"data-title":"",className:Ie(N==null?void 0:N.title,(d=u==null?void 0:u.classNames)==null?void 0:d.title)},typeof u.title=="function"?u.title():u.title),u.description?P.createElement("div",{"data-description":"",className:Ie(L,ln,N==null?void 0:N.description,(f=u==null?void 0:u.classNames)==null?void 0:f.description)},typeof u.description=="function"?u.description():u.description):null),c.isValidElement(u.cancel)?u.cancel:u.cancel&&hn(u.cancel)?P.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||D,onClick:K=>{var re,se;hn(u.cancel)&&Ze&&((se=(re=u.cancel).onClick)==null||se.call(re,K),Fe())},className:Ie(N==null?void 0:N.cancelButton,(m=u==null?void 0:u.classNames)==null?void 0:m.cancelButton)},u.cancel.label):null,c.isValidElement(u.action)?u.action:u.action&&hn(u.action)?P.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||W,onClick:K=>{var re,se;hn(u.action)&&((se=(re=u.action).onClick)==null||se.call(re,K),!K.defaultPrevented&&Fe())},className:Ie(N==null?void 0:N.actionButton,(p=u==null?void 0:u.classNames)==null?void 0:p.actionButton)},u.action.label):null))};function Qo(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function Gm(e,t){let n={};return[e,t].forEach((r,s)=>{let a=s===1,i=a?"--mobile-offset":"--offset",l=a?Um:Bm;function d(f){["top","right","bottom","left"].forEach(m=>{n[`${i}-${m}`]=typeof f=="number"?`${f}px`:f})}typeof r=="number"||typeof r=="string"?d(r):typeof r=="object"?["top","right","bottom","left"].forEach(f=>{r[f]===void 0?n[`${i}-${f}`]=l:n[`${i}-${f}`]=typeof r[f]=="number"?`${r[f]}px`:r[f]}):d(l)}),n}var Ym=c.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:s=["altKey","KeyT"],expand:a,closeButton:i,className:l,offset:d,mobileOffset:f,theme:m="light",richColors:p,duration:h,style:u,visibleToasts:x=Fm,toastOptions:g,dir:y=Qo(),gap:b=Hm,loadingIcon:v,icons:w,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:S}=e,[C,k]=P.useState([]),I=P.useMemo(()=>Array.from(new Set([r].concat(C.filter(V=>V.position).map(V=>V.position)))),[C,r]),[H,D]=P.useState([]),[W,T]=P.useState(!1),[L,$]=P.useState(!1),[_,j]=P.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),R=P.useRef(null),A=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),N=P.useRef(null),U=P.useRef(!1),te=P.useCallback(V=>{k(z=>{var G;return(G=z.find(ne=>ne.id===V.id))!=null&&G.delete||be.dismiss(V.id),z.filter(({id:ne})=>ne!==V.id)})},[]);return P.useEffect(()=>be.subscribe(V=>{if(V.dismiss){k(z=>z.map(G=>G.id===V.id?{...G,delete:!0}:G));return}setTimeout(()=>{ls.flushSync(()=>{k(z=>{let G=z.findIndex(ne=>ne.id===V.id);return G!==-1?[...z.slice(0,G),{...z[G],...V},...z.slice(G+1)]:[V,...z]})})})}),[]),P.useEffect(()=>{if(m!=="system"){j(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?j("dark"):j("light")),typeof window>"u")return;let V=window.matchMedia("(prefers-color-scheme: dark)");try{V.addEventListener("change",({matches:z})=>{j(z?"dark":"light")})}catch{V.addListener(({matches:G})=>{try{j(G?"dark":"light")}catch(ne){console.error(ne)}})}},[m]),P.useEffect(()=>{C.length<=1&&T(!1)},[C]),P.useEffect(()=>{let V=z=>{var G,ne;s.every(ie=>z[ie]||z.code===ie)&&(T(!0),(G=R.current)==null||G.focus()),z.code==="Escape"&&(document.activeElement===R.current||(ne=R.current)!=null&&ne.contains(document.activeElement))&&T(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[s]),P.useEffect(()=>{if(R.current)return()=>{N.current&&(N.current.focus({preventScroll:!0}),N.current=null,U.current=!1)}},[R.current]),P.createElement("section",{ref:t,"aria-label":`${E} ${A}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},I.map((V,z)=>{var G;let[ne,ie]=V.split("-");return C.length?P.createElement("ol",{key:V,dir:y==="auto"?Qo():y,tabIndex:-1,ref:R,className:l,"data-sonner-toaster":!0,"data-theme":_,"data-y-position":ne,"data-lifted":W&&C.length>1&&!a,"data-x-position":ie,style:{"--front-toast-height":`${((G=H[0])==null?void 0:G.height)||0}px`,"--width":`${Wm}px`,"--gap":`${b}px`,...u,...Gm(d,f)},onBlur:M=>{U.current&&!M.currentTarget.contains(M.relatedTarget)&&(U.current=!1,N.current&&(N.current.focus({preventScroll:!0}),N.current=null))},onFocus:M=>{M.target instanceof HTMLElement&&M.target.dataset.dismissible==="false"||U.current||(U.current=!0,N.current=M.relatedTarget)},onMouseEnter:()=>T(!0),onMouseMove:()=>T(!0),onMouseLeave:()=>{L||T(!1)},onDragEnd:()=>T(!1),onPointerDown:M=>{M.target instanceof HTMLElement&&M.target.dataset.dismissible==="false"||$(!0)},onPointerUp:()=>$(!1)},C.filter(M=>!M.position&&z===0||M.position===V).map((M,Z)=>{var X,J;return P.createElement(zm,{key:M.id,icons:w,index:Z,toast:M,defaultRichColors:p,duration:(X=g==null?void 0:g.duration)!=null?X:h,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:x,closeButton:(J=g==null?void 0:g.closeButton)!=null?J:i,interacting:L,position:V,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:te,toasts:C.filter(q=>q.position==M.position),heights:H.filter(q=>q.position==M.position),setHeights:D,expandByDefault:a,gap:b,loadingIcon:v,expanded:W,pauseWhenPageIsHidden:S,swipeDirections:e.swipeDirections})})):null}))});const Jm=["terminal","git","policies","logs","events"],Xm=["terminal","git","policies"],Zm={nativeHooks:!1,supportsDangerousMode:!1,supportsModelSwitch:!1,supportsTranscriptTailing:!1,supportsTmuxAdoption:!1,policyChannel:"none",metricsChannel:"none"},kr=[{id:"claude-code",label:"Claude Code",runtime:"tmux",capabilities:{nativeHooks:!0,supportsDangerousMode:!0,supportsModelSwitch:!0,supportsTranscriptTailing:!0,supportsTmuxAdoption:!0,policyChannel:"native-hooks",metricsChannel:"transcript"},launchHints:{dangerousModeFlags:["--dangerously-skip-permissions"],resumeCommands:{resume:"claude --resume {id}",fork:"claude --resume {id} --fork-session",idPlaceholder:"claude session id"}}},{id:"codex",label:"Codex",runtime:"tmux",capabilities:{nativeHooks:!1,supportsDangerousMode:!0,supportsModelSwitch:!1,supportsTranscriptTailing:!1,supportsTmuxAdoption:!0,policyChannel:"input-preflight",metricsChannel:"pty"},launchHints:{dangerousModeFlags:["--dangerously-bypass-approvals-and-sandbox"],resumeCommands:{resume:"codex resume {id}",fork:"codex fork {id}",idPlaceholder:"019c7285-ba64-7462-bbfc-4227f3e24e88"}}}],Qm=new Map(kr.map(e=>[e.id,e]));function eh(e){const t=e.trim();return t.length===0?"Provider":t.split(/[-_]/g).filter(Boolean).map(n=>{var r;return((r=n[0])==null?void 0:r.toUpperCase())+n.slice(1)}).join(" ")}function th(e,t){const n=t==null?void 0:t.find(s=>s.id===e);if(n)return n;const r=Qm.get(e);return r||{id:e,label:eh(e),runtime:"tmux",capabilities:Zm}}function nh(e){return e.capabilities.nativeHooks?"Native hook integration, richer policy and transcript metrics.":e.capabilities.policyChannel==="input-preflight"?"Tmux-first integration with preflight policy checks (no native hooks).":"Tmux session with limited policy and analytics integration."}function rh(e){return e.nativeHooks||e.supportsTranscriptTailing}function oh(e){return rh(e)?Jm:Xm}function Og(e,t){return oh(th(e,t).capabilities)}const sh={"claude-code":{label:"Claude Code",icon:zc,className:"border-amber-500/25 bg-gradient-to-r from-amber-500/15 via-orange-500/10 to-transparent text-amber-700 dark:text-amber-300",dotClassName:"bg-amber-500/85"},codex:{label:"Codex",icon:qc,className:"border-sky-500/25 bg-gradient-to-r from-sky-500/15 via-cyan-500/10 to-transparent text-sky-700 dark:text-sky-300",dotClassName:"bg-sky-500/85"}},ah={label:"Provider",icon:sl,className:"border-slate-500/25 bg-gradient-to-r from-slate-500/15 via-zinc-500/10 to-transparent text-slate-700 dark:text-slate-300",dotClassName:"bg-slate-500/85"};function lo(e){const t=sh[e];return t||{...ah,label:e.split(/[-_]/g).filter(Boolean).map(n=>{var r;return((r=n[0])==null?void 0:r.toUpperCase())+n.slice(1)}).join(" ")}}const qt=c.forwardRef(({className:e,variant:t="default",size:n="default",...r},s)=>o.jsx("button",{className:F("inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none",{"bg-primary text-primary-foreground hover:bg-primary/90":t==="default","bg-destructive text-destructive-foreground hover:bg-destructive/90":t==="destructive","border border-input hover:bg-accent hover:text-accent-foreground":t==="outline","bg-secondary text-secondary-foreground hover:bg-secondary/80":t==="secondary","hover:bg-accent hover:text-accent-foreground":t==="ghost","underline-offset-4 hover:underline text-primary":t==="link"},{"h-10 py-2 px-4":n==="default","h-9 px-3 rounded-md":n==="sm","h-11 px-8 rounded-md":n==="lg","h-10 w-10":n==="icon"},e),ref:s,...r}));qt.displayName="Button";var Gn="Dialog",[fi]=yt(Gn),[ih,Le]=fi(Gn),pi=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:s,onOpenChange:a,modal:i=!0}=e,l=c.useRef(null),d=c.useRef(null),[f,m]=Kt({prop:r,defaultProp:s??!1,onChange:a,caller:Gn});return o.jsx(ih,{scope:t,triggerRef:l,contentRef:d,contentId:Ye(),titleId:Ye(),descriptionId:Ye(),open:f,onOpenChange:m,onOpenToggle:c.useCallback(()=>m(p=>!p),[m]),modal:i,children:n})};pi.displayName=Gn;var mi="DialogTrigger",hi=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(mi,n),a=oe(t,s.triggerRef);return o.jsx(Q.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":po(s.open),...r,ref:a,onClick:B(e.onClick,s.onOpenToggle)})});hi.displayName=mi;var uo="DialogPortal",[ch,gi]=fi(uo,{forceMount:void 0}),xi=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:s}=e,a=Le(uo,t);return o.jsx(ch,{scope:t,forceMount:n,children:c.Children.map(r,i=>o.jsx(it,{present:n||a.open,children:o.jsx(Vn,{asChild:!0,container:s,children:i})}))})};xi.displayName=uo;var Tn="DialogOverlay",yi=c.forwardRef((e,t)=>{const n=gi(Tn,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,a=Le(Tn,e.__scopeDialog);return a.modal?o.jsx(it,{present:r||a.open,children:o.jsx(dh,{...s,ref:t})}):null});yi.displayName=Tn;var lh=At("DialogOverlay.RemoveScroll"),dh=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(Tn,n);return o.jsx(Ir,{as:lh,allowPinchZoom:!0,shards:[s.contentRef],children:o.jsx(Q.div,{"data-state":po(s.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),pt="DialogContent",bi=c.forwardRef((e,t)=>{const n=gi(pt,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,a=Le(pt,e.__scopeDialog);return o.jsx(it,{present:r||a.open,children:a.modal?o.jsx(uh,{...s,ref:t}):o.jsx(fh,{...s,ref:t})})});bi.displayName=pt;var uh=c.forwardRef((e,t)=>{const n=Le(pt,e.__scopeDialog),r=c.useRef(null),s=oe(t,n.contentRef,r);return c.useEffect(()=>{const a=r.current;if(a)return zr(a)},[]),o.jsx(vi,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:B(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:B(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:B(e.onFocusOutside,a=>a.preventDefault())})}),fh=c.forwardRef((e,t)=>{const n=Le(pt,e.__scopeDialog),r=c.useRef(!1),s=c.useRef(!1);return o.jsx(vi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:a=>{var d,f;(d=e.onInteractOutside)==null||d.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=a.target;((f=n.triggerRef.current)==null?void 0:f.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),vi=c.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:a,...i}=e,l=Le(pt,n),d=c.useRef(null),f=oe(t,d);return $r(),o.jsxs(o.Fragment,{children:[o.jsx($n,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:a,children:o.jsx(Ln,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":po(l.open),...i,ref:f,onDismiss:()=>l.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(mh,{titleId:l.titleId}),o.jsx(gh,{contentRef:d,descriptionId:l.descriptionId})]})]})}),fo="DialogTitle",wi=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(fo,n);return o.jsx(Q.h2,{id:s.titleId,...r,ref:t})});wi.displayName=fo;var Si="DialogDescription",Ni=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(Si,n);return o.jsx(Q.p,{id:s.descriptionId,...r,ref:t})});Ni.displayName=Si;var Ei="DialogClose",ph=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(Ei,n);return o.jsx(Q.button,{type:"button",...r,ref:t,onClick:B(e.onClick,()=>s.onOpenChange(!1))})});ph.displayName=Ei;function po(e){return e?"open":"closed"}var Ci="DialogTitleWarning",[Dg,ki]=Ml(Ci,{contentName:pt,titleName:fo,docsSlug:"dialog"}),mh=({titleId:e})=>{const t=ki(Ci),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
198
+ */const Al=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Il=ee("zap",Al);function F(e,t,{checkForDefaultPrevented:n=!0}={}){return function(s){if(e==null||e(s),n===!1||!s.defaultPrevented)return t==null?void 0:t(s)}}function yo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dn(...e){return t=>{let n=!1;const r=e.map(s=>{const a=yo(s,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let s=0;s<r.length;s++){const a=r[s];typeof a=="function"?a():yo(e[s],null)}}}}function oe(...e){return c.useCallback(Dn(...e),e)}function Ml(e,t){const n=c.createContext(t),r=a=>{const{children:i,...l}=a,d=c.useMemo(()=>l,Object.values(l));return o.jsx(n.Provider,{value:d,children:i})};r.displayName=e+"Provider";function s(a){const i=c.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,s]}function yt(e,t=[]){let n=[];function r(a,i){const l=c.createContext(i),d=n.length;n=[...n,i];const f=p=>{var b;const{scope:h,children:u,...x}=p,g=((b=h==null?void 0:h[e])==null?void 0:b[d])||l,y=c.useMemo(()=>x,Object.values(x));return o.jsx(g.Provider,{value:y,children:u})};f.displayName=a+"Provider";function m(p,h){var g;const u=((g=h==null?void 0:h[e])==null?void 0:g[d])||l,x=c.useContext(u);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${p}\` must be used within \`${a}\``)}return[f,m]}const s=()=>{const a=n.map(i=>c.createContext(i));return function(l){const d=(l==null?void 0:l[e])||a;return c.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return s.scopeName=e,[r,Ol(s,...t)]}function Ol(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(a){const i=r.reduce((l,{useScope:d,scopeName:f})=>{const p=d(a)[`__scope${f}`];return{...l,...p}},{});return c.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var me=globalThis!=null&&globalThis.document?c.useLayoutEffect:()=>{},Dl=cs[" useInsertionEffect ".trim().toString()]||me;function Kt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[s,a,i]=Ll({defaultProp:t,onChange:n}),l=e!==void 0,d=l?e:s;{const m=c.useRef(e!==void 0);c.useEffect(()=>{const p=m.current;p!==l&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),m.current=l},[l,r])}const f=c.useCallback(m=>{var p;if(l){const h=$l(m)?m(e):m;h!==e&&((p=i.current)==null||p.call(i,h))}else a(m)},[l,e,a,i]);return[d,f]}function Ll({defaultProp:e,onChange:t}){const[n,r]=c.useState(e),s=c.useRef(n),a=c.useRef(t);return Dl(()=>{a.current=t},[t]),c.useEffect(()=>{var i;s.current!==n&&((i=a.current)==null||i.call(a,n),s.current=n)},[n,s]),[n,r,a]}function $l(e){return typeof e=="function"}function At(e){const t=Fl(e),n=c.forwardRef((r,s)=>{const{children:a,...i}=r,l=c.Children.toArray(a),d=l.find(Ul);if(d){const f=d.props.children,m=l.map(p=>p===d?c.Children.count(f)>1?c.Children.only(null):c.isValidElement(f)?f.props.children:null:p);return o.jsx(t,{...i,ref:s,children:c.isValidElement(f)?c.cloneElement(f,void 0,m):null})}return o.jsx(t,{...i,ref:s,children:a})});return n.displayName=`${e}.Slot`,n}function Fl(e){const t=c.forwardRef((n,r)=>{const{children:s,...a}=n;if(c.isValidElement(s)){const i=Hl(s),l=Wl(a,s.props);return s.type!==c.Fragment&&(l.ref=r?Dn(r,i):i),c.cloneElement(s,l)}return c.Children.count(s)>1?c.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Bl=Symbol("radix.slottable");function Ul(e){return c.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Bl}function Wl(e,t){const n={...t};for(const r in t){const s=e[r],a=t[r];/^on[A-Z]/.test(r)?s&&a?n[r]=(...l)=>{const d=a(...l);return s(...l),d}:s&&(n[r]=s):r==="style"?n[r]={...s,...a}:r==="className"&&(n[r]=[s,a].filter(Boolean).join(" "))}return{...e,...n}}function Hl(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Vl=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Q=Vl.reduce((e,t)=>{const n=At(`Primitive.${t}`),r=c.forwardRef((s,a)=>{const{asChild:i,...l}=s,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(d,{...l,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function bs(e,t){e&&Ot.flushSync(()=>e.dispatchEvent(t))}function Dr(e){const t=e+"CollectionProvider",[n,r]=yt(t),[s,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=g=>{const{scope:y,children:b}=g,v=_.useRef(null),w=_.useRef(new Map).current;return o.jsx(s,{scope:y,itemMap:w,collectionRef:v,children:b})};i.displayName=t;const l=e+"CollectionSlot",d=At(l),f=_.forwardRef((g,y)=>{const{scope:b,children:v}=g,w=a(l,b),E=oe(y,w.collectionRef);return o.jsx(d,{ref:E,children:v})});f.displayName=l;const m=e+"CollectionItemSlot",p="data-radix-collection-item",h=At(m),u=_.forwardRef((g,y)=>{const{scope:b,children:v,...w}=g,E=_.useRef(null),S=oe(y,E),C=a(m,b);return _.useEffect(()=>(C.itemMap.set(E,{ref:E,...w}),()=>void C.itemMap.delete(E))),o.jsx(h,{[p]:"",ref:S,children:v})});u.displayName=m;function x(g){const y=a(e+"CollectionConsumer",g);return _.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const w=Array.from(v.querySelectorAll(`[${p}]`));return Array.from(y.itemMap.values()).sort((C,k)=>w.indexOf(C.ref.current)-w.indexOf(k.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:f,ItemSlot:u},x,r]}var ql=c.createContext(void 0);function Lr(e){const t=c.useContext(ql);return e||t||"ltr"}function We(e){const t=c.useRef(e);return c.useEffect(()=>{t.current=e}),c.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Kl(e,t=globalThis==null?void 0:globalThis.document){const n=We(e);c.useEffect(()=>{const r=s=>{s.key==="Escape"&&n(s)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var zl="DismissableLayer",pr="dismissableLayer.update",Gl="dismissableLayer.pointerDownOutside",Yl="dismissableLayer.focusOutside",bo,vs=c.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ln=c.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...d}=e,f=c.useContext(vs),[m,p]=c.useState(null),h=(m==null?void 0:m.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,u]=c.useState({}),x=oe(t,k=>p(k)),g=Array.from(f.layers),[y]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),b=g.indexOf(y),v=m?g.indexOf(m):-1,w=f.layersWithOutsidePointerEventsDisabled.size>0,E=v>=b,S=Zl(k=>{const I=k.target,W=[...f.branches].some(B=>B.contains(I));!E||W||(s==null||s(k),i==null||i(k),k.defaultPrevented||l==null||l())},h),C=Ql(k=>{const I=k.target;[...f.branches].some(B=>B.contains(I))||(a==null||a(k),i==null||i(k),k.defaultPrevented||l==null||l())},h);return Kl(k=>{v===f.layers.size-1&&(r==null||r(k),!k.defaultPrevented&&l&&(k.preventDefault(),l()))},h),c.useEffect(()=>{if(m)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(bo=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(m)),f.layers.add(m),vo(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=bo)}},[m,h,n,f]),c.useEffect(()=>()=>{m&&(f.layers.delete(m),f.layersWithOutsidePointerEventsDisabled.delete(m),vo())},[m,f]),c.useEffect(()=>{const k=()=>u({});return document.addEventListener(pr,k),()=>document.removeEventListener(pr,k)},[]),o.jsx(Q.div,{...d,ref:x,style:{pointerEvents:w?E?"auto":"none":void 0,...e.style},onFocusCapture:F(e.onFocusCapture,C.onFocusCapture),onBlurCapture:F(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:F(e.onPointerDownCapture,S.onPointerDownCapture)})});Ln.displayName=zl;var Jl="DismissableLayerBranch",Xl=c.forwardRef((e,t)=>{const n=c.useContext(vs),r=c.useRef(null),s=oe(t,r);return c.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),o.jsx(Q.div,{...e,ref:s})});Xl.displayName=Jl;function Zl(e,t=globalThis==null?void 0:globalThis.document){const n=We(e),r=c.useRef(!1),s=c.useRef(()=>{});return c.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let d=function(){ws(Gl,n,f,{discrete:!0})};const f={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=d,t.addEventListener("click",s.current,{once:!0})):d()}else t.removeEventListener("click",s.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Ql(e,t=globalThis==null?void 0:globalThis.document){const n=We(e),r=c.useRef(!1);return c.useEffect(()=>{const s=a=>{a.target&&!r.current&&ws(Yl,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function vo(){const e=new CustomEvent(pr);document.dispatchEvent(e)}function ws(e,t,n,{discrete:r}){const s=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&s.addEventListener(e,t,{once:!0}),r?bs(s,a):s.dispatchEvent(a)}var tr=0;function $r(){c.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??wo()),document.body.insertAdjacentElement("beforeend",e[1]??wo()),tr++,()=>{tr===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),tr--}},[])}function wo(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var nr="focusScope.autoFocusOnMount",rr="focusScope.autoFocusOnUnmount",So={bubbles:!1,cancelable:!0},ed="FocusScope",$n=c.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,d]=c.useState(null),f=We(s),m=We(a),p=c.useRef(null),h=oe(t,g=>d(g)),u=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(r){let g=function(w){if(u.paused||!l)return;const E=w.target;l.contains(E)?p.current=E:rt(p.current,{select:!0})},y=function(w){if(u.paused||!l)return;const E=w.relatedTarget;E!==null&&(l.contains(E)||rt(p.current,{select:!0}))},b=function(w){if(document.activeElement===document.body)for(const S of w)S.removedNodes.length>0&&rt(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",y);const v=new MutationObserver(b);return l&&v.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",y),v.disconnect()}}},[r,l,u.paused]),c.useEffect(()=>{if(l){Eo.add(u);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(nr,So);l.addEventListener(nr,f),l.dispatchEvent(b),b.defaultPrevented||(td(ad(Ss(l)),{select:!0}),document.activeElement===g&&rt(l))}return()=>{l.removeEventListener(nr,f),setTimeout(()=>{const b=new CustomEvent(rr,So);l.addEventListener(rr,m),l.dispatchEvent(b),b.defaultPrevented||rt(g??document.body,{select:!0}),l.removeEventListener(rr,m),Eo.remove(u)},0)}}},[l,f,m,u]);const x=c.useCallback(g=>{if(!n&&!r||u.paused)return;const y=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,b=document.activeElement;if(y&&b){const v=g.currentTarget,[w,E]=nd(v);w&&E?!g.shiftKey&&b===E?(g.preventDefault(),n&&rt(w,{select:!0})):g.shiftKey&&b===w&&(g.preventDefault(),n&&rt(E,{select:!0})):b===v&&g.preventDefault()}},[n,r,u.paused]);return o.jsx(Q.div,{tabIndex:-1,...i,ref:h,onKeyDown:x})});$n.displayName=ed;function td(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(rt(r,{select:t}),document.activeElement!==n)return}function nd(e){const t=Ss(e),n=No(t,e),r=No(t.reverse(),e);return[n,r]}function Ss(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function No(e,t){for(const n of e)if(!rd(n,{upTo:t}))return n}function rd(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function od(e){return e instanceof HTMLInputElement&&"select"in e}function rt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&od(e)&&t&&e.select()}}var Eo=sd();function sd(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Co(e,t),e.unshift(t)},remove(t){var n;e=Co(e,t),(n=e[0])==null||n.resume()}}}function Co(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ad(e){return e.filter(t=>t.tagName!=="A")}var id=cs[" useId ".trim().toString()]||(()=>{}),cd=0;function Ye(e){const[t,n]=c.useState(id());return me(()=>{n(r=>r??String(cd++))},[e]),t?`radix-${t}`:""}const ld=["top","right","bottom","left"],ot=Math.min,Ee=Math.max,wn=Math.round,un=Math.floor,Ue=e=>({x:e,y:e}),dd={left:"right",right:"left",bottom:"top",top:"bottom"},ud={start:"end",end:"start"};function mr(e,t,n){return Ee(e,ot(t,n))}function Je(e,t){return typeof e=="function"?e(t):e}function Xe(e){return e.split("-")[0]}function Dt(e){return e.split("-")[1]}function Fr(e){return e==="x"?"y":"x"}function Br(e){return e==="y"?"height":"width"}const fd=new Set(["top","bottom"]);function Be(e){return fd.has(Xe(e))?"y":"x"}function Ur(e){return Fr(Be(e))}function pd(e,t,n){n===void 0&&(n=!1);const r=Dt(e),s=Ur(e),a=Br(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=Sn(i)),[i,Sn(i)]}function md(e){const t=Sn(e);return[hr(e),t,hr(t)]}function hr(e){return e.replace(/start|end/g,t=>ud[t])}const ko=["left","right"],jo=["right","left"],hd=["top","bottom"],gd=["bottom","top"];function xd(e,t,n){switch(e){case"top":case"bottom":return n?t?jo:ko:t?ko:jo;case"left":case"right":return t?hd:gd;default:return[]}}function yd(e,t,n,r){const s=Dt(e);let a=xd(Xe(e),n==="start",r);return s&&(a=a.map(i=>i+"-"+s),t&&(a=a.concat(a.map(hr)))),a}function Sn(e){return e.replace(/left|right|bottom|top/g,t=>dd[t])}function bd(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ns(e){return typeof e!="number"?bd(e):{top:e,right:e,bottom:e,left:e}}function Nn(e){const{x:t,y:n,width:r,height:s}=e;return{width:r,height:s,top:n,left:t,right:t+r,bottom:n+s,x:t,y:n}}function Po(e,t,n){let{reference:r,floating:s}=e;const a=Be(t),i=Ur(t),l=Br(i),d=Xe(t),f=a==="y",m=r.x+r.width/2-s.width/2,p=r.y+r.height/2-s.height/2,h=r[l]/2-s[l]/2;let u;switch(d){case"top":u={x:m,y:r.y-s.height};break;case"bottom":u={x:m,y:r.y+r.height};break;case"right":u={x:r.x+r.width,y:p};break;case"left":u={x:r.x-s.width,y:p};break;default:u={x:r.x,y:r.y}}switch(Dt(t)){case"start":u[i]-=h*(n&&f?-1:1);break;case"end":u[i]+=h*(n&&f?-1:1);break}return u}async function vd(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:a,rects:i,elements:l,strategy:d}=e,{boundary:f="clippingAncestors",rootBoundary:m="viewport",elementContext:p="floating",altBoundary:h=!1,padding:u=0}=Je(t,e),x=Ns(u),y=l[h?p==="floating"?"reference":"floating":p],b=Nn(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(y)))==null||n?y:y.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:f,rootBoundary:m,strategy:d})),v=p==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),E=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},S=Nn(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:w,strategy:d}):v);return{top:(b.top-S.top+x.top)/E.y,bottom:(S.bottom-b.bottom+x.bottom)/E.y,left:(b.left-S.left+x.left)/E.x,right:(S.right-b.right+x.right)/E.x}}const wd=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:a=[],platform:i}=n,l=a.filter(Boolean),d=await(i.isRTL==null?void 0:i.isRTL(t));let f=await i.getElementRects({reference:e,floating:t,strategy:s}),{x:m,y:p}=Po(f,r,d),h=r,u={},x=0;for(let y=0;y<l.length;y++){var g;const{name:b,fn:v}=l[y],{x:w,y:E,data:S,reset:C}=await v({x:m,y:p,initialPlacement:r,placement:h,strategy:s,middlewareData:u,rects:f,platform:{...i,detectOverflow:(g=i.detectOverflow)!=null?g:vd},elements:{reference:e,floating:t}});m=w??m,p=E??p,u={...u,[b]:{...u[b],...S}},C&&x<=50&&(x++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(f=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:s}):C.rects),{x:m,y:p}=Po(f,h,d)),y=-1)}return{x:m,y:p,placement:h,strategy:s,middlewareData:u}},Sd=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:a,platform:i,elements:l,middlewareData:d}=t,{element:f,padding:m=0}=Je(e,t)||{};if(f==null)return{};const p=Ns(m),h={x:n,y:r},u=Ur(s),x=Br(u),g=await i.getDimensions(f),y=u==="y",b=y?"top":"left",v=y?"bottom":"right",w=y?"clientHeight":"clientWidth",E=a.reference[x]+a.reference[u]-h[u]-a.floating[x],S=h[u]-a.reference[u],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(f));let k=C?C[w]:0;(!k||!await(i.isElement==null?void 0:i.isElement(C)))&&(k=l.floating[w]||a.floating[x]);const I=E/2-S/2,W=k/2-g[x]/2-1,B=ot(p[b],W),H=ot(p[v],W),j=B,D=k-g[x]-H,L=k/2-g[x]/2+I,T=mr(j,L,D),P=!d.arrow&&Dt(s)!=null&&L!==T&&a.reference[x]/2-(L<j?B:H)-g[x]/2<0,R=P?L<j?L-j:L-D:0;return{[u]:h[u]+R,data:{[u]:T,centerOffset:L-T-R,...P&&{alignmentOffset:R}},reset:P}}}),Nd=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:a,rects:i,initialPlacement:l,platform:d,elements:f}=t,{mainAxis:m=!0,crossAxis:p=!0,fallbackPlacements:h,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:g=!0,...y}=Je(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const b=Xe(s),v=Be(l),w=Xe(l)===l,E=await(d.isRTL==null?void 0:d.isRTL(f.floating)),S=h||(w||!g?[Sn(l)]:md(l)),C=x!=="none";!h&&C&&S.push(...yd(l,g,x,E));const k=[l,...S],I=await d.detectOverflow(t,y),W=[];let B=((r=a.flip)==null?void 0:r.overflows)||[];if(m&&W.push(I[b]),p){const L=pd(s,i,E);W.push(I[L[0]],I[L[1]])}if(B=[...B,{placement:s,overflows:W}],!W.every(L=>L<=0)){var H,j;const L=(((H=a.flip)==null?void 0:H.index)||0)+1,T=k[L];if(T&&(!(p==="alignment"?v!==Be(T):!1)||B.every(A=>Be(A.placement)===v?A.overflows[0]>0:!0)))return{data:{index:L,overflows:B},reset:{placement:T}};let P=(j=B.filter(R=>R.overflows[0]<=0).sort((R,A)=>R.overflows[1]-A.overflows[1])[0])==null?void 0:j.placement;if(!P)switch(u){case"bestFit":{var D;const R=(D=B.filter(A=>{if(C){const N=Be(A.placement);return N===v||N==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(N=>N>0).reduce((N,U)=>N+U,0)]).sort((A,N)=>A[1]-N[1])[0])==null?void 0:D[0];R&&(P=R);break}case"initialPlacement":P=l;break}if(s!==P)return{reset:{placement:P}}}return{}}}};function To(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function _o(e){return ld.some(t=>e[t]>=0)}const Ed=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:s="referenceHidden",...a}=Je(e,t);switch(s){case"referenceHidden":{const i=await r.detectOverflow(t,{...a,elementContext:"reference"}),l=To(i,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:_o(l)}}}case"escaped":{const i=await r.detectOverflow(t,{...a,altBoundary:!0}),l=To(i,n.floating);return{data:{escapedOffsets:l,escaped:_o(l)}}}default:return{}}}}},Es=new Set(["left","top"]);async function Cd(e,t){const{placement:n,platform:r,elements:s}=e,a=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=Xe(n),l=Dt(n),d=Be(n)==="y",f=Es.has(i)?-1:1,m=a&&d?-1:1,p=Je(t,e);let{mainAxis:h,crossAxis:u,alignmentAxis:x}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof x=="number"&&(u=l==="end"?x*-1:x),d?{x:u*m,y:h*f}:{x:h*f,y:u*m}}const kd=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:a,placement:i,middlewareData:l}=t,d=await Cd(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+d.x,y:a+d.y,data:{...d,placement:i}}}}},jd=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:a}=t,{mainAxis:i=!0,crossAxis:l=!1,limiter:d={fn:b=>{let{x:v,y:w}=b;return{x:v,y:w}}},...f}=Je(e,t),m={x:n,y:r},p=await a.detectOverflow(t,f),h=Be(Xe(s)),u=Fr(h);let x=m[u],g=m[h];if(i){const b=u==="y"?"top":"left",v=u==="y"?"bottom":"right",w=x+p[b],E=x-p[v];x=mr(w,x,E)}if(l){const b=h==="y"?"top":"left",v=h==="y"?"bottom":"right",w=g+p[b],E=g-p[v];g=mr(w,g,E)}const y=d.fn({...t,[u]:x,[h]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[u]:i,[h]:l}}}}}},Pd=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:s,rects:a,middlewareData:i}=t,{offset:l=0,mainAxis:d=!0,crossAxis:f=!0}=Je(e,t),m={x:n,y:r},p=Be(s),h=Fr(p);let u=m[h],x=m[p];const g=Je(l,t),y=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(d){const w=h==="y"?"height":"width",E=a.reference[h]-a.floating[w]+y.mainAxis,S=a.reference[h]+a.reference[w]-y.mainAxis;u<E?u=E:u>S&&(u=S)}if(f){var b,v;const w=h==="y"?"width":"height",E=Es.has(Xe(s)),S=a.reference[p]-a.floating[w]+(E&&((b=i.offset)==null?void 0:b[p])||0)+(E?0:y.crossAxis),C=a.reference[p]+a.reference[w]+(E?0:((v=i.offset)==null?void 0:v[p])||0)-(E?y.crossAxis:0);x<S?x=S:x>C&&(x=C)}return{[h]:u,[p]:x}}}},Td=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:s,rects:a,platform:i,elements:l}=t,{apply:d=()=>{},...f}=Je(e,t),m=await i.detectOverflow(t,f),p=Xe(s),h=Dt(s),u=Be(s)==="y",{width:x,height:g}=a.floating;let y,b;p==="top"||p==="bottom"?(y=p,b=h===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(b=p,y=h==="end"?"top":"bottom");const v=g-m.top-m.bottom,w=x-m.left-m.right,E=ot(g-m[y],v),S=ot(x-m[b],w),C=!t.middlewareData.shift;let k=E,I=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(I=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=v),C&&!h){const B=Ee(m.left,0),H=Ee(m.right,0),j=Ee(m.top,0),D=Ee(m.bottom,0);u?I=x-2*(B!==0||H!==0?B+H:Ee(m.left,m.right)):k=g-2*(j!==0||D!==0?j+D:Ee(m.top,m.bottom))}await d({...t,availableWidth:I,availableHeight:k});const W=await i.getDimensions(l.floating);return x!==W.width||g!==W.height?{reset:{rects:!0}}:{}}}};function Fn(){return typeof window<"u"}function Lt(e){return Cs(e)?(e.nodeName||"").toLowerCase():"#document"}function Ce(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ve(e){var t;return(t=(Cs(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Cs(e){return Fn()?e instanceof Node||e instanceof Ce(e).Node:!1}function Oe(e){return Fn()?e instanceof Element||e instanceof Ce(e).Element:!1}function He(e){return Fn()?e instanceof HTMLElement||e instanceof Ce(e).HTMLElement:!1}function Ro(e){return!Fn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ce(e).ShadowRoot}const _d=new Set(["inline","contents"]);function Qt(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=De(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!_d.has(s)}const Rd=new Set(["table","td","th"]);function Ad(e){return Rd.has(Lt(e))}const Id=[":popover-open",":modal"];function Bn(e){return Id.some(t=>{try{return e.matches(t)}catch{return!1}})}const Md=["transform","translate","scale","rotate","perspective"],Od=["transform","translate","scale","rotate","perspective","filter"],Dd=["paint","layout","strict","content"];function Wr(e){const t=Hr(),n=Oe(e)?De(e):e;return Md.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Od.some(r=>(n.willChange||"").includes(r))||Dd.some(r=>(n.contain||"").includes(r))}function Ld(e){let t=st(e);for(;He(t)&&!It(t);){if(Wr(t))return t;if(Bn(t))return null;t=st(t)}return null}function Hr(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const $d=new Set(["html","body","#document"]);function It(e){return $d.has(Lt(e))}function De(e){return Ce(e).getComputedStyle(e)}function Un(e){return Oe(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function st(e){if(Lt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ro(e)&&e.host||Ve(e);return Ro(t)?t.host:t}function ks(e){const t=st(e);return It(t)?e.ownerDocument?e.ownerDocument.body:e.body:He(t)&&Qt(t)?t:ks(t)}function zt(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=ks(e),a=s===((r=e.ownerDocument)==null?void 0:r.body),i=Ce(s);if(a){const l=gr(i);return t.concat(i,i.visualViewport||[],Qt(s)?s:[],l&&n?zt(l):[])}return t.concat(s,zt(s,[],n))}function gr(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function js(e){const t=De(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=He(e),a=s?e.offsetWidth:n,i=s?e.offsetHeight:r,l=wn(n)!==a||wn(r)!==i;return l&&(n=a,r=i),{width:n,height:r,$:l}}function Vr(e){return Oe(e)?e:e.contextElement}function _t(e){const t=Vr(e);if(!He(t))return Ue(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:a}=js(t);let i=(a?wn(n.width):n.width)/r,l=(a?wn(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const Fd=Ue(0);function Ps(e){const t=Ce(e);return!Hr()||!t.visualViewport?Fd:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Bd(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ce(e)?!1:t}function ft(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),a=Vr(e);let i=Ue(1);t&&(r?Oe(r)&&(i=_t(r)):i=_t(e));const l=Bd(a,n,r)?Ps(a):Ue(0);let d=(s.left+l.x)/i.x,f=(s.top+l.y)/i.y,m=s.width/i.x,p=s.height/i.y;if(a){const h=Ce(a),u=r&&Oe(r)?Ce(r):r;let x=h,g=gr(x);for(;g&&r&&u!==x;){const y=_t(g),b=g.getBoundingClientRect(),v=De(g),w=b.left+(g.clientLeft+parseFloat(v.paddingLeft))*y.x,E=b.top+(g.clientTop+parseFloat(v.paddingTop))*y.y;d*=y.x,f*=y.y,m*=y.x,p*=y.y,d+=w,f+=E,x=Ce(g),g=gr(x)}}return Nn({width:m,height:p,x:d,y:f})}function Wn(e,t){const n=Un(e).scrollLeft;return t?t.left+n:ft(Ve(e)).left+n}function Ts(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Wn(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Ud(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const a=s==="fixed",i=Ve(r),l=t?Bn(t.floating):!1;if(r===i||l&&a)return n;let d={scrollLeft:0,scrollTop:0},f=Ue(1);const m=Ue(0),p=He(r);if((p||!p&&!a)&&((Lt(r)!=="body"||Qt(i))&&(d=Un(r)),He(r))){const u=ft(r);f=_t(r),m.x=u.x+r.clientLeft,m.y=u.y+r.clientTop}const h=i&&!p&&!a?Ts(i,d):Ue(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-d.scrollLeft*f.x+m.x+h.x,y:n.y*f.y-d.scrollTop*f.y+m.y+h.y}}function Wd(e){return Array.from(e.getClientRects())}function Hd(e){const t=Ve(e),n=Un(e),r=e.ownerDocument.body,s=Ee(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Ee(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Wn(e);const l=-n.scrollTop;return De(r).direction==="rtl"&&(i+=Ee(t.clientWidth,r.clientWidth)-s),{width:s,height:a,x:i,y:l}}const Ao=25;function Vd(e,t){const n=Ce(e),r=Ve(e),s=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,l=0,d=0;if(s){a=s.width,i=s.height;const m=Hr();(!m||m&&t==="fixed")&&(l=s.offsetLeft,d=s.offsetTop)}const f=Wn(r);if(f<=0){const m=r.ownerDocument,p=m.body,h=getComputedStyle(p),u=m.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,x=Math.abs(r.clientWidth-p.clientWidth-u);x<=Ao&&(a-=x)}else f<=Ao&&(a+=f);return{width:a,height:i,x:l,y:d}}const qd=new Set(["absolute","fixed"]);function Kd(e,t){const n=ft(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,a=He(e)?_t(e):Ue(1),i=e.clientWidth*a.x,l=e.clientHeight*a.y,d=s*a.x,f=r*a.y;return{width:i,height:l,x:d,y:f}}function Io(e,t,n){let r;if(t==="viewport")r=Vd(e,n);else if(t==="document")r=Hd(Ve(e));else if(Oe(t))r=Kd(t,n);else{const s=Ps(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Nn(r)}function _s(e,t){const n=st(e);return n===t||!Oe(n)||It(n)?!1:De(n).position==="fixed"||_s(n,t)}function zd(e,t){const n=t.get(e);if(n)return n;let r=zt(e,[],!1).filter(l=>Oe(l)&&Lt(l)!=="body"),s=null;const a=De(e).position==="fixed";let i=a?st(e):e;for(;Oe(i)&&!It(i);){const l=De(i),d=Wr(i);!d&&l.position==="fixed"&&(s=null),(a?!d&&!s:!d&&l.position==="static"&&!!s&&qd.has(s.position)||Qt(i)&&!d&&_s(e,i))?r=r.filter(m=>m!==i):s=l,i=st(i)}return t.set(e,r),r}function Gd(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?Bn(t)?[]:zd(t,this._c):[].concat(n),r],l=i[0],d=i.reduce((f,m)=>{const p=Io(t,m,s);return f.top=Ee(p.top,f.top),f.right=ot(p.right,f.right),f.bottom=ot(p.bottom,f.bottom),f.left=Ee(p.left,f.left),f},Io(t,l,s));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Yd(e){const{width:t,height:n}=js(e);return{width:t,height:n}}function Jd(e,t,n){const r=He(t),s=Ve(t),a=n==="fixed",i=ft(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const d=Ue(0);function f(){d.x=Wn(s)}if(r||!r&&!a)if((Lt(t)!=="body"||Qt(s))&&(l=Un(t)),r){const u=ft(t,!0,a,t);d.x=u.x+t.clientLeft,d.y=u.y+t.clientTop}else s&&f();a&&!r&&s&&f();const m=s&&!r&&!a?Ts(s,l):Ue(0),p=i.left+l.scrollLeft-d.x-m.x,h=i.top+l.scrollTop-d.y-m.y;return{x:p,y:h,width:i.width,height:i.height}}function or(e){return De(e).position==="static"}function Mo(e,t){if(!He(e)||De(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ve(e)===n&&(n=n.ownerDocument.body),n}function Rs(e,t){const n=Ce(e);if(Bn(e))return n;if(!He(e)){let s=st(e);for(;s&&!It(s);){if(Oe(s)&&!or(s))return s;s=st(s)}return n}let r=Mo(e,t);for(;r&&Ad(r)&&or(r);)r=Mo(r,t);return r&&It(r)&&or(r)&&!Wr(r)?n:r||Ld(e)||n}const Xd=async function(e){const t=this.getOffsetParent||Rs,n=this.getDimensions,r=await n(e.floating);return{reference:Jd(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Zd(e){return De(e).direction==="rtl"}const Qd={convertOffsetParentRelativeRectToViewportRelativeRect:Ud,getDocumentElement:Ve,getClippingRect:Gd,getOffsetParent:Rs,getElementRects:Xd,getClientRects:Wd,getDimensions:Yd,getScale:_t,isElement:Oe,isRTL:Zd};function As(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function eu(e,t){let n=null,r;const s=Ve(e);function a(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function i(l,d){l===void 0&&(l=!1),d===void 0&&(d=1),a();const f=e.getBoundingClientRect(),{left:m,top:p,width:h,height:u}=f;if(l||t(),!h||!u)return;const x=un(p),g=un(s.clientWidth-(m+h)),y=un(s.clientHeight-(p+u)),b=un(m),w={rootMargin:-x+"px "+-g+"px "+-y+"px "+-b+"px",threshold:Ee(0,ot(1,d))||1};let E=!0;function S(C){const k=C[0].intersectionRatio;if(k!==d){if(!E)return i();k?i(!1,k):r=setTimeout(()=>{i(!1,1e-7)},1e3)}k===1&&!As(f,e.getBoundingClientRect())&&i(),E=!1}try{n=new IntersectionObserver(S,{...w,root:s.ownerDocument})}catch{n=new IntersectionObserver(S,w)}n.observe(e)}return i(!0),a}function tu(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,f=Vr(e),m=s||a?[...f?zt(f):[],...zt(t)]:[];m.forEach(b=>{s&&b.addEventListener("scroll",n,{passive:!0}),a&&b.addEventListener("resize",n)});const p=f&&l?eu(f,n):null;let h=-1,u=null;i&&(u=new ResizeObserver(b=>{let[v]=b;v&&v.target===f&&u&&(u.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=u)==null||w.observe(t)})),n()}),f&&!d&&u.observe(f),u.observe(t));let x,g=d?ft(e):null;d&&y();function y(){const b=ft(e);g&&!As(g,b)&&n(),g=b,x=requestAnimationFrame(y)}return n(),()=>{var b;m.forEach(v=>{s&&v.removeEventListener("scroll",n),a&&v.removeEventListener("resize",n)}),p==null||p(),(b=u)==null||b.disconnect(),u=null,d&&cancelAnimationFrame(x)}}const nu=kd,ru=jd,ou=Nd,su=Td,au=Ed,Oo=Sd,iu=Pd,cu=(e,t,n)=>{const r=new Map,s={platform:Qd,...n},a={...s.platform,_c:r};return wd(e,t,{...s,platform:a})};var lu=typeof document<"u",du=function(){},xn=lu?c.useLayoutEffect:du;function En(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!En(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const a=s[r];if(!(a==="_owner"&&e.$$typeof)&&!En(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function Is(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Do(e,t){const n=Is(e);return Math.round(t*n)/n}function sr(e){const t=c.useRef(e);return xn(()=>{t.current=e}),t}function uu(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:a,floating:i}={},transform:l=!0,whileElementsMounted:d,open:f}=e,[m,p]=c.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,u]=c.useState(r);En(h,r)||u(r);const[x,g]=c.useState(null),[y,b]=c.useState(null),v=c.useCallback(A=>{A!==C.current&&(C.current=A,g(A))},[]),w=c.useCallback(A=>{A!==k.current&&(k.current=A,b(A))},[]),E=a||x,S=i||y,C=c.useRef(null),k=c.useRef(null),I=c.useRef(m),W=d!=null,B=sr(d),H=sr(s),j=sr(f),D=c.useCallback(()=>{if(!C.current||!k.current)return;const A={placement:t,strategy:n,middleware:h};H.current&&(A.platform=H.current),cu(C.current,k.current,A).then(N=>{const U={...N,isPositioned:j.current!==!1};L.current&&!En(I.current,U)&&(I.current=U,Ot.flushSync(()=>{p(U)}))})},[h,t,n,H,j]);xn(()=>{f===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,p(A=>({...A,isPositioned:!1})))},[f]);const L=c.useRef(!1);xn(()=>(L.current=!0,()=>{L.current=!1}),[]),xn(()=>{if(E&&(C.current=E),S&&(k.current=S),E&&S){if(B.current)return B.current(E,S,D);D()}},[E,S,D,B,W]);const T=c.useMemo(()=>({reference:C,floating:k,setReference:v,setFloating:w}),[v,w]),P=c.useMemo(()=>({reference:E,floating:S}),[E,S]),R=c.useMemo(()=>{const A={position:n,left:0,top:0};if(!P.floating)return A;const N=Do(P.floating,m.x),U=Do(P.floating,m.y);return l?{...A,transform:"translate("+N+"px, "+U+"px)",...Is(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:U}},[n,l,P.floating,m.x,m.y]);return c.useMemo(()=>({...m,update:D,refs:T,elements:P,floatingStyles:R}),[m,D,T,P,R])}const fu=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:s}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Oo({element:r.current,padding:s}).fn(n):{}:r?Oo({element:r,padding:s}).fn(n):{}}}},pu=(e,t)=>({...nu(e),options:[e,t]}),mu=(e,t)=>({...ru(e),options:[e,t]}),hu=(e,t)=>({...iu(e),options:[e,t]}),gu=(e,t)=>({...ou(e),options:[e,t]}),xu=(e,t)=>({...su(e),options:[e,t]}),yu=(e,t)=>({...au(e),options:[e,t]}),bu=(e,t)=>({...fu(e),options:[e,t]});var vu="Arrow",Ms=c.forwardRef((e,t)=>{const{children:n,width:r=10,height:s=5,...a}=e;return o.jsx(Q.svg,{...a,ref:t,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ms.displayName=vu;var wu=Ms;function Su(e){const[t,n]=c.useState(void 0);return me(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const a=s[0];let i,l;if("borderBoxSize"in a){const d=a.borderBoxSize,f=Array.isArray(d)?d[0]:d;i=f.inlineSize,l=f.blockSize}else i=e.offsetWidth,l=e.offsetHeight;n({width:i,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var qr="Popper",[Os,Hn]=yt(qr),[Nu,Ds]=Os(qr),Ls=e=>{const{__scopePopper:t,children:n}=e,[r,s]=c.useState(null);return o.jsx(Nu,{scope:t,anchor:r,onAnchorChange:s,children:n})};Ls.displayName=qr;var $s="PopperAnchor",Fs=c.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,a=Ds($s,n),i=c.useRef(null),l=oe(t,i),d=c.useRef(null);return c.useEffect(()=>{const f=d.current;d.current=(r==null?void 0:r.current)||i.current,f!==d.current&&a.onAnchorChange(d.current)}),r?null:o.jsx(Q.div,{...s,ref:l})});Fs.displayName=$s;var Kr="PopperContent",[Eu,Cu]=Os(Kr),Bs=c.forwardRef((e,t)=>{var M,Z,X,J,q,Y;const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:a="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:d=!0,collisionBoundary:f=[],collisionPadding:m=0,sticky:p="partial",hideWhenDetached:h=!1,updatePositionStrategy:u="optimized",onPlaced:x,...g}=e,y=Ds(Kr,n),[b,v]=c.useState(null),w=oe(t,ce=>v(ce)),[E,S]=c.useState(null),C=Su(E),k=(C==null?void 0:C.width)??0,I=(C==null?void 0:C.height)??0,W=r+(a!=="center"?"-"+a:""),B=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},H=Array.isArray(f)?f:[f],j=H.length>0,D={padding:B,boundary:H.filter(ju),altBoundary:j},{refs:L,floatingStyles:T,placement:P,isPositioned:R,middlewareData:A}=uu({strategy:"fixed",placement:W,whileElementsMounted:(...ce)=>tu(...ce,{animationFrame:u==="always"}),elements:{reference:y.anchor},middleware:[pu({mainAxis:s+I,alignmentAxis:i}),d&&mu({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?hu():void 0,...D}),d&&gu({...D}),xu({...D,apply:({elements:ce,rects:de,availableWidth:$e,availableHeight:Pe})=>{const{width:we,height:Te}=de.reference,Se=ce.floating.style;Se.setProperty("--radix-popper-available-width",`${$e}px`),Se.setProperty("--radix-popper-available-height",`${Pe}px`),Se.setProperty("--radix-popper-anchor-width",`${we}px`),Se.setProperty("--radix-popper-anchor-height",`${Te}px`)}}),E&&bu({element:E,padding:l}),Pu({arrowWidth:k,arrowHeight:I}),h&&yu({strategy:"referenceHidden",...D})]}),[N,U]=Hs(P),te=We(x);me(()=>{R&&(te==null||te())},[R,te]);const V=(M=A.arrow)==null?void 0:M.x,z=(Z=A.arrow)==null?void 0:Z.y,G=((X=A.arrow)==null?void 0:X.centerOffset)!==0,[ne,ie]=c.useState();return me(()=>{b&&ie(window.getComputedStyle(b).zIndex)},[b]),o.jsx("div",{ref:L.setFloating,"data-radix-popper-content-wrapper":"",style:{...T,transform:R?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ne,"--radix-popper-transform-origin":[(J=A.transformOrigin)==null?void 0:J.x,(q=A.transformOrigin)==null?void 0:q.y].join(" "),...((Y=A.hide)==null?void 0:Y.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx(Eu,{scope:n,placedSide:N,onArrowChange:S,arrowX:V,arrowY:z,shouldHideArrow:G,children:o.jsx(Q.div,{"data-side":N,"data-align":U,...g,ref:w,style:{...g.style,animation:R?void 0:"none"}})})})});Bs.displayName=Kr;var Us="PopperArrow",ku={top:"bottom",right:"left",bottom:"top",left:"right"},Ws=c.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,a=Cu(Us,r),i=ku[a.placedSide];return o.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:o.jsx(wu,{...s,ref:n,style:{...s.style,display:"block"}})})});Ws.displayName=Us;function ju(e){return e!==null}var Pu=e=>({name:"transformOrigin",options:e,fn(t){var y,b,v;const{placement:n,rects:r,middlewareData:s}=t,i=((y=s.arrow)==null?void 0:y.centerOffset)!==0,l=i?0:e.arrowWidth,d=i?0:e.arrowHeight,[f,m]=Hs(n),p={start:"0%",center:"50%",end:"100%"}[m],h=(((b=s.arrow)==null?void 0:b.x)??0)+l/2,u=(((v=s.arrow)==null?void 0:v.y)??0)+d/2;let x="",g="";return f==="bottom"?(x=i?p:`${h}px`,g=`${-d}px`):f==="top"?(x=i?p:`${h}px`,g=`${r.floating.height+d}px`):f==="right"?(x=`${-d}px`,g=i?p:`${u}px`):f==="left"&&(x=`${r.floating.width+d}px`,g=i?p:`${u}px`),{data:{x,y:g}}}});function Hs(e){const[t,n="center"]=e.split("-");return[t,n]}var Vs=Ls,qs=Fs,Ks=Bs,zs=Ws,Tu="Portal",Vn=c.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[s,a]=c.useState(!1);me(()=>a(!0),[]);const i=n||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?ls.createPortal(o.jsx(Q.div,{...r,ref:t}),i):null});Vn.displayName=Tu;function _u(e,t){return c.useReducer((n,r)=>t[n][r]??n,e)}var it=e=>{const{present:t,children:n}=e,r=Ru(t),s=typeof n=="function"?n({present:r.isPresent}):c.Children.only(n),a=oe(r.ref,Au(s));return typeof n=="function"||r.isPresent?c.cloneElement(s,{ref:a}):null};it.displayName="Presence";function Ru(e){const[t,n]=c.useState(),r=c.useRef(null),s=c.useRef(e),a=c.useRef("none"),i=e?"mounted":"unmounted",[l,d]=_u(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return c.useEffect(()=>{const f=fn(r.current);a.current=l==="mounted"?f:"none"},[l]),me(()=>{const f=r.current,m=s.current;if(m!==e){const h=a.current,u=fn(f);e?d("MOUNT"):u==="none"||(f==null?void 0:f.display)==="none"?d("UNMOUNT"):d(m&&h!==u?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,d]),me(()=>{if(t){let f;const m=t.ownerDocument.defaultView??window,p=u=>{const g=fn(r.current).includes(CSS.escape(u.animationName));if(u.target===t&&g&&(d("ANIMATION_END"),!s.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",f=m.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=u=>{u.target===t&&(a.current=fn(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",p),t.addEventListener("animationend",p),()=>{m.clearTimeout(f),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",p),t.removeEventListener("animationend",p)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:c.useCallback(f=>{r.current=f?getComputedStyle(f):null,n(f)},[])}}function fn(e){return(e==null?void 0:e.animationName)||"none"}function Au(e){var r,s;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ar="rovingFocusGroup.onEntryFocus",Iu={bubbles:!1,cancelable:!0},en="RovingFocusGroup",[xr,Gs,Mu]=Dr(en),[Ou,Ys]=yt(en,[Mu]),[Du,Lu]=Ou(en),Js=c.forwardRef((e,t)=>o.jsx(xr.Provider,{scope:e.__scopeRovingFocusGroup,children:o.jsx(xr.Slot,{scope:e.__scopeRovingFocusGroup,children:o.jsx($u,{...e,ref:t})})}));Js.displayName=en;var $u=c.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:s=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:m=!1,...p}=e,h=c.useRef(null),u=oe(t,h),x=Lr(a),[g,y]=Kt({prop:i,defaultProp:l??null,onChange:d,caller:en}),[b,v]=c.useState(!1),w=We(f),E=Gs(n),S=c.useRef(!1),[C,k]=c.useState(0);return c.useEffect(()=>{const I=h.current;if(I)return I.addEventListener(ar,w),()=>I.removeEventListener(ar,w)},[w]),o.jsx(Du,{scope:n,orientation:r,dir:x,loop:s,currentTabStopId:g,onItemFocus:c.useCallback(I=>y(I),[y]),onItemShiftTab:c.useCallback(()=>v(!0),[]),onFocusableItemAdd:c.useCallback(()=>k(I=>I+1),[]),onFocusableItemRemove:c.useCallback(()=>k(I=>I-1),[]),children:o.jsx(Q.div,{tabIndex:b||C===0?-1:0,"data-orientation":r,...p,ref:u,style:{outline:"none",...e.style},onMouseDown:F(e.onMouseDown,()=>{S.current=!0}),onFocus:F(e.onFocus,I=>{const W=!S.current;if(I.target===I.currentTarget&&W&&!b){const B=new CustomEvent(ar,Iu);if(I.currentTarget.dispatchEvent(B),!B.defaultPrevented){const H=E().filter(P=>P.focusable),j=H.find(P=>P.active),D=H.find(P=>P.id===g),T=[j,D,...H].filter(Boolean).map(P=>P.ref.current);Qs(T,m)}}S.current=!1}),onBlur:F(e.onBlur,()=>v(!1))})})}),Xs="RovingFocusGroupItem",Zs=c.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:s=!1,tabStopId:a,children:i,...l}=e,d=Ye(),f=a||d,m=Lu(Xs,n),p=m.currentTabStopId===f,h=Gs(n),{onFocusableItemAdd:u,onFocusableItemRemove:x,currentTabStopId:g}=m;return c.useEffect(()=>{if(r)return u(),()=>x()},[r,u,x]),o.jsx(xr.ItemSlot,{scope:n,id:f,focusable:r,active:s,children:o.jsx(Q.span,{tabIndex:p?0:-1,"data-orientation":m.orientation,...l,ref:t,onMouseDown:F(e.onMouseDown,y=>{r?m.onItemFocus(f):y.preventDefault()}),onFocus:F(e.onFocus,()=>m.onItemFocus(f)),onKeyDown:F(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){m.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const b=Uu(y,m.orientation,m.dir);if(b!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let w=h().filter(E=>E.focusable).map(E=>E.ref.current);if(b==="last")w.reverse();else if(b==="prev"||b==="next"){b==="prev"&&w.reverse();const E=w.indexOf(y.currentTarget);w=m.loop?Wu(w,E+1):w.slice(E+1)}setTimeout(()=>Qs(w))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});Zs.displayName=Xs;var Fu={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Bu(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Uu(e,t,n){const r=Bu(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Fu[r]}function Qs(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Wu(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Hu=Js,Vu=Zs,qu=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Et=new WeakMap,pn=new WeakMap,mn={},ir=0,ea=function(e){return e&&(e.host||ea(e.parentNode))},Ku=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=ea(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},zu=function(e,t,n,r){var s=Ku(t,Array.isArray(e)?e:[e]);mn[n]||(mn[n]=new WeakMap);var a=mn[n],i=[],l=new Set,d=new Set(s),f=function(p){!p||l.has(p)||(l.add(p),f(p.parentNode))};s.forEach(f);var m=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(h){if(l.has(h))m(h);else try{var u=h.getAttribute(r),x=u!==null&&u!=="false",g=(Et.get(h)||0)+1,y=(a.get(h)||0)+1;Et.set(h,g),a.set(h,y),i.push(h),g===1&&x&&pn.set(h,!0),y===1&&h.setAttribute(n,"true"),x||h.setAttribute(r,"true")}catch(b){console.error("aria-hidden: cannot operate on ",h,b)}})};return m(t),l.clear(),ir++,function(){i.forEach(function(p){var h=Et.get(p)-1,u=a.get(p)-1;Et.set(p,h),a.set(p,u),h||(pn.has(p)||p.removeAttribute(r),pn.delete(p)),u||p.removeAttribute(n)}),ir--,ir||(Et=new WeakMap,Et=new WeakMap,pn=new WeakMap,mn={})}},zr=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),s=qu(e);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live], script"))),zu(r,s,n,"aria-hidden")):function(){return null}},yr=["Enter"," "],Gu=["ArrowDown","PageUp","Home"],ta=["ArrowUp","PageDown","End"],Yu=[...Gu,...ta],Ju={ltr:[...yr,"ArrowRight"],rtl:[...yr,"ArrowLeft"]},Xu={ltr:["ArrowLeft"],rtl:["ArrowRight"]},tn="Menu",[Gt,Zu,Qu]=Dr(tn),[bt,na]=yt(tn,[Qu,Hn,Ys]),qn=Hn(),ra=Ys(),[ef,vt]=bt(tn),[tf,nn]=bt(tn),oa=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:s,onOpenChange:a,modal:i=!0}=e,l=qn(t),[d,f]=c.useState(null),m=c.useRef(!1),p=We(a),h=Lr(s);return c.useEffect(()=>{const u=()=>{m.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>m.current=!1;return document.addEventListener("keydown",u,{capture:!0}),()=>{document.removeEventListener("keydown",u,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),o.jsx(Vs,{...l,children:o.jsx(ef,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:f,children:o.jsx(tf,{scope:t,onClose:c.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:m,dir:h,modal:i,children:r})})})};oa.displayName=tn;var nf="MenuAnchor",Gr=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,s=qn(n);return o.jsx(qs,{...s,...r,ref:t})});Gr.displayName=nf;var Yr="MenuPortal",[rf,sa]=bt(Yr,{forceMount:void 0}),aa=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:s}=e,a=vt(Yr,t);return o.jsx(rf,{scope:t,forceMount:n,children:o.jsx(it,{present:n||a.open,children:o.jsx(Vn,{asChild:!0,container:s,children:r})})})};aa.displayName=Yr;var je="MenuContent",[of,Jr]=bt(je),ia=c.forwardRef((e,t)=>{const n=sa(je,e.__scopeMenu),{forceMount:r=n.forceMount,...s}=e,a=vt(je,e.__scopeMenu),i=nn(je,e.__scopeMenu);return o.jsx(Gt.Provider,{scope:e.__scopeMenu,children:o.jsx(it,{present:r||a.open,children:o.jsx(Gt.Slot,{scope:e.__scopeMenu,children:i.modal?o.jsx(sf,{...s,ref:t}):o.jsx(af,{...s,ref:t})})})})}),sf=c.forwardRef((e,t)=>{const n=vt(je,e.__scopeMenu),r=c.useRef(null),s=oe(t,r);return c.useEffect(()=>{const a=r.current;if(a)return zr(a)},[]),o.jsx(Xr,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:F(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),af=c.forwardRef((e,t)=>{const n=vt(je,e.__scopeMenu);return o.jsx(Xr,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),cf=At("MenuContent.ScrollLock"),Xr=c.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:l,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:h,onDismiss:u,disableOutsideScroll:x,...g}=e,y=vt(je,n),b=nn(je,n),v=qn(n),w=ra(n),E=Zu(n),[S,C]=c.useState(null),k=c.useRef(null),I=oe(t,k,y.onContentChange),W=c.useRef(0),B=c.useRef(""),H=c.useRef(0),j=c.useRef(null),D=c.useRef("right"),L=c.useRef(0),T=x?Ir:c.Fragment,P=x?{as:cf,allowPinchZoom:!0}:void 0,R=N=>{var M,Z;const U=B.current+N,te=E().filter(X=>!X.disabled),V=document.activeElement,z=(M=te.find(X=>X.ref.current===V))==null?void 0:M.textValue,G=te.map(X=>X.textValue),ne=vf(G,U,z),ie=(Z=te.find(X=>X.textValue===ne))==null?void 0:Z.ref.current;(function X(J){B.current=J,window.clearTimeout(W.current),J!==""&&(W.current=window.setTimeout(()=>X(""),1e3))})(U),ie&&setTimeout(()=>ie.focus())};c.useEffect(()=>()=>window.clearTimeout(W.current),[]),$r();const A=c.useCallback(N=>{var te,V;return D.current===((te=j.current)==null?void 0:te.side)&&Sf(N,(V=j.current)==null?void 0:V.area)},[]);return o.jsx(of,{scope:n,searchRef:B,onItemEnter:c.useCallback(N=>{A(N)&&N.preventDefault()},[A]),onItemLeave:c.useCallback(N=>{var U;A(N)||((U=k.current)==null||U.focus(),C(null))},[A]),onTriggerLeave:c.useCallback(N=>{A(N)&&N.preventDefault()},[A]),pointerGraceTimerRef:H,onPointerGraceIntentChange:c.useCallback(N=>{j.current=N},[]),children:o.jsx(T,{...P,children:o.jsx($n,{asChild:!0,trapped:s,onMountAutoFocus:F(a,N=>{var U;N.preventDefault(),(U=k.current)==null||U.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:o.jsx(Ln,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:p,onInteractOutside:h,onDismiss:u,children:o.jsx(Hu,{asChild:!0,...w,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:F(d,N=>{b.isUsingKeyboardRef.current||N.preventDefault()}),preventScrollOnEntryFocus:!0,children:o.jsx(Ks,{role:"menu","aria-orientation":"vertical","data-state":Na(y.open),"data-radix-menu-content":"",dir:b.dir,...v,...g,ref:I,style:{outline:"none",...g.style},onKeyDown:F(g.onKeyDown,N=>{const te=N.target.closest("[data-radix-menu-content]")===N.currentTarget,V=N.ctrlKey||N.altKey||N.metaKey,z=N.key.length===1;te&&(N.key==="Tab"&&N.preventDefault(),!V&&z&&R(N.key));const G=k.current;if(N.target!==G||!Yu.includes(N.key))return;N.preventDefault();const ie=E().filter(M=>!M.disabled).map(M=>M.ref.current);ta.includes(N.key)&&ie.reverse(),yf(ie)}),onBlur:F(e.onBlur,N=>{N.currentTarget.contains(N.target)||(window.clearTimeout(W.current),B.current="")}),onPointerMove:F(e.onPointerMove,Yt(N=>{const U=N.target,te=L.current!==N.clientX;if(N.currentTarget.contains(U)&&te){const V=N.clientX>L.current?"right":"left";D.current=V,L.current=N.clientX}}))})})})})})})});ia.displayName=je;var lf="MenuGroup",Zr=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(Q.div,{role:"group",...r,ref:t})});Zr.displayName=lf;var df="MenuLabel",ca=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(Q.div,{...r,ref:t})});ca.displayName=df;var Cn="MenuItem",Lo="menu.itemSelect",Kn=c.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...s}=e,a=c.useRef(null),i=nn(Cn,e.__scopeMenu),l=Jr(Cn,e.__scopeMenu),d=oe(t,a),f=c.useRef(!1),m=()=>{const p=a.current;if(!n&&p){const h=new CustomEvent(Lo,{bubbles:!0,cancelable:!0});p.addEventListener(Lo,u=>r==null?void 0:r(u),{once:!0}),bs(p,h),h.defaultPrevented?f.current=!1:i.onClose()}};return o.jsx(la,{...s,ref:d,disabled:n,onClick:F(e.onClick,m),onPointerDown:p=>{var h;(h=e.onPointerDown)==null||h.call(e,p),f.current=!0},onPointerUp:F(e.onPointerUp,p=>{var h;f.current||(h=p.currentTarget)==null||h.click()}),onKeyDown:F(e.onKeyDown,p=>{const h=l.searchRef.current!=="";n||h&&p.key===" "||yr.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Kn.displayName=Cn;var la=c.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:s,...a}=e,i=Jr(Cn,n),l=ra(n),d=c.useRef(null),f=oe(t,d),[m,p]=c.useState(!1),[h,u]=c.useState("");return c.useEffect(()=>{const x=d.current;x&&u((x.textContent??"").trim())},[a.children]),o.jsx(Gt.ItemSlot,{scope:n,disabled:r,textValue:s??h,children:o.jsx(Vu,{asChild:!0,...l,focusable:!r,children:o.jsx(Q.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...a,ref:f,onPointerMove:F(e.onPointerMove,Yt(x=>{r?i.onItemLeave(x):(i.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:F(e.onPointerLeave,Yt(x=>i.onItemLeave(x))),onFocus:F(e.onFocus,()=>p(!0)),onBlur:F(e.onBlur,()=>p(!1))})})})}),uf="MenuCheckboxItem",da=c.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...s}=e;return o.jsx(ha,{scope:e.__scopeMenu,checked:n,children:o.jsx(Kn,{role:"menuitemcheckbox","aria-checked":kn(n)?"mixed":n,...s,ref:t,"data-state":eo(n),onSelect:F(s.onSelect,()=>r==null?void 0:r(kn(n)?!0:!n),{checkForDefaultPrevented:!1})})})});da.displayName=uf;var ua="MenuRadioGroup",[ff,pf]=bt(ua,{value:void 0,onValueChange:()=>{}}),fa=c.forwardRef((e,t)=>{const{value:n,onValueChange:r,...s}=e,a=We(r);return o.jsx(ff,{scope:e.__scopeMenu,value:n,onValueChange:a,children:o.jsx(Zr,{...s,ref:t})})});fa.displayName=ua;var pa="MenuRadioItem",ma=c.forwardRef((e,t)=>{const{value:n,...r}=e,s=pf(pa,e.__scopeMenu),a=n===s.value;return o.jsx(ha,{scope:e.__scopeMenu,checked:a,children:o.jsx(Kn,{role:"menuitemradio","aria-checked":a,...r,ref:t,"data-state":eo(a),onSelect:F(r.onSelect,()=>{var i;return(i=s.onValueChange)==null?void 0:i.call(s,n)},{checkForDefaultPrevented:!1})})})});ma.displayName=pa;var Qr="MenuItemIndicator",[ha,mf]=bt(Qr,{checked:!1}),ga=c.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...s}=e,a=mf(Qr,n);return o.jsx(it,{present:r||kn(a.checked)||a.checked===!0,children:o.jsx(Q.span,{...s,ref:t,"data-state":eo(a.checked)})})});ga.displayName=Qr;var hf="MenuSeparator",xa=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(Q.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});xa.displayName=hf;var gf="MenuArrow",ya=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,s=qn(n);return o.jsx(zs,{...s,...r,ref:t})});ya.displayName=gf;var xf="MenuSub",[Rg,ba]=bt(xf),Ut="MenuSubTrigger",va=c.forwardRef((e,t)=>{const n=vt(Ut,e.__scopeMenu),r=nn(Ut,e.__scopeMenu),s=ba(Ut,e.__scopeMenu),a=Jr(Ut,e.__scopeMenu),i=c.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:d}=a,f={__scopeMenu:e.__scopeMenu},m=c.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return c.useEffect(()=>m,[m]),c.useEffect(()=>{const p=l.current;return()=>{window.clearTimeout(p),d(null)}},[l,d]),o.jsx(Gr,{asChild:!0,...f,children:o.jsx(la,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":Na(n.open),...e,ref:Dn(t,s.onTriggerChange),onClick:p=>{var h;(h=e.onClick)==null||h.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:F(e.onPointerMove,Yt(p=>{a.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(a.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:F(e.onPointerLeave,Yt(p=>{var u,x;m();const h=(u=n.content)==null?void 0:u.getBoundingClientRect();if(h){const g=(x=n.content)==null?void 0:x.dataset.side,y=g==="right",b=y?-5:5,v=h[y?"left":"right"],w=h[y?"right":"left"];a.onPointerGraceIntentChange({area:[{x:p.clientX+b,y:p.clientY},{x:v,y:h.top},{x:w,y:h.top},{x:w,y:h.bottom},{x:v,y:h.bottom}],side:g}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(p),p.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:F(e.onKeyDown,p=>{var u;const h=a.searchRef.current!=="";e.disabled||h&&p.key===" "||Ju[r.dir].includes(p.key)&&(n.onOpenChange(!0),(u=n.content)==null||u.focus(),p.preventDefault())})})})});va.displayName=Ut;var wa="MenuSubContent",Sa=c.forwardRef((e,t)=>{const n=sa(je,e.__scopeMenu),{forceMount:r=n.forceMount,...s}=e,a=vt(je,e.__scopeMenu),i=nn(je,e.__scopeMenu),l=ba(wa,e.__scopeMenu),d=c.useRef(null),f=oe(t,d);return o.jsx(Gt.Provider,{scope:e.__scopeMenu,children:o.jsx(it,{present:r||a.open,children:o.jsx(Gt.Slot,{scope:e.__scopeMenu,children:o.jsx(Xr,{id:l.contentId,"aria-labelledby":l.triggerId,...s,ref:f,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{var p;i.isUsingKeyboardRef.current&&((p=d.current)==null||p.focus()),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:F(e.onFocusOutside,m=>{m.target!==l.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:F(e.onEscapeKeyDown,m=>{i.onClose(),m.preventDefault()}),onKeyDown:F(e.onKeyDown,m=>{var u;const p=m.currentTarget.contains(m.target),h=Xu[i.dir].includes(m.key);p&&h&&(a.onOpenChange(!1),(u=l.trigger)==null||u.focus(),m.preventDefault())})})})})})});Sa.displayName=wa;function Na(e){return e?"open":"closed"}function kn(e){return e==="indeterminate"}function eo(e){return kn(e)?"indeterminate":e?"checked":"unchecked"}function yf(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function bf(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function vf(e,t,n){const s=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=bf(e,Math.max(a,0));s.length===1&&(i=i.filter(f=>f!==n));const d=i.find(f=>f.toLowerCase().startsWith(s.toLowerCase()));return d!==n?d:void 0}function wf(e,t){const{x:n,y:r}=e;let s=!1;for(let a=0,i=t.length-1;a<t.length;i=a++){const l=t[a],d=t[i],f=l.x,m=l.y,p=d.x,h=d.y;m>r!=h>r&&n<(p-f)*(r-m)/(h-m)+f&&(s=!s)}return s}function Sf(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return wf(n,t)}function Yt(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Nf=oa,Ef=Gr,Cf=aa,kf=ia,jf=Zr,Pf=ca,Tf=Kn,_f=da,Rf=fa,Af=ma,If=ga,Mf=xa,Of=ya,Df=va,Lf=Sa,zn="DropdownMenu",[$f]=yt(zn,[na]),he=na(),[Ff,Ea]=$f(zn),Ca=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:s,defaultOpen:a,onOpenChange:i,modal:l=!0}=e,d=he(t),f=c.useRef(null),[m,p]=Kt({prop:s,defaultProp:a??!1,onChange:i,caller:zn});return o.jsx(Ff,{scope:t,triggerId:Ye(),triggerRef:f,contentId:Ye(),open:m,onOpenChange:p,onOpenToggle:c.useCallback(()=>p(h=>!h),[p]),modal:l,children:o.jsx(Nf,{...d,open:m,onOpenChange:p,dir:r,modal:l,children:n})})};Ca.displayName=zn;var ka="DropdownMenuTrigger",ja=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...s}=e,a=Ea(ka,n),i=he(n);return o.jsx(Ef,{asChild:!0,...i,children:o.jsx(Q.button,{type:"button",id:a.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...s,ref:Dn(t,a.triggerRef),onPointerDown:F(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(a.onOpenToggle(),a.open||l.preventDefault())}),onKeyDown:F(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&a.onOpenToggle(),l.key==="ArrowDown"&&a.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});ja.displayName=ka;var Bf="DropdownMenuPortal",Pa=e=>{const{__scopeDropdownMenu:t,...n}=e,r=he(t);return o.jsx(Cf,{...r,...n})};Pa.displayName=Bf;var Ta="DropdownMenuContent",_a=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Ea(Ta,n),a=he(n),i=c.useRef(!1);return o.jsx(kf,{id:s.contentId,"aria-labelledby":s.triggerId,...a,...r,ref:t,onCloseAutoFocus:F(e.onCloseAutoFocus,l=>{var d;i.current||(d=s.triggerRef.current)==null||d.focus(),i.current=!1,l.preventDefault()}),onInteractOutside:F(e.onInteractOutside,l=>{const d=l.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,m=d.button===2||f;(!s.modal||m)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});_a.displayName=Ta;var Uf="DropdownMenuGroup",Wf=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(jf,{...s,...r,ref:t})});Wf.displayName=Uf;var Hf="DropdownMenuLabel",Ra=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Pf,{...s,...r,ref:t})});Ra.displayName=Hf;var Vf="DropdownMenuItem",Aa=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Tf,{...s,...r,ref:t})});Aa.displayName=Vf;var qf="DropdownMenuCheckboxItem",Ia=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(_f,{...s,...r,ref:t})});Ia.displayName=qf;var Kf="DropdownMenuRadioGroup",Ma=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Rf,{...s,...r,ref:t})});Ma.displayName=Kf;var zf="DropdownMenuRadioItem",Oa=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Af,{...s,...r,ref:t})});Oa.displayName=zf;var Gf="DropdownMenuItemIndicator",Da=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(If,{...s,...r,ref:t})});Da.displayName=Gf;var Yf="DropdownMenuSeparator",La=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Mf,{...s,...r,ref:t})});La.displayName=Yf;var Jf="DropdownMenuArrow",Xf=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Of,{...s,...r,ref:t})});Xf.displayName=Jf;var Zf="DropdownMenuSubTrigger",$a=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Df,{...s,...r,ref:t})});$a.displayName=Zf;var Qf="DropdownMenuSubContent",Fa=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Lf,{...s,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Fa.displayName=Qf;var ep=Ca,tp=ja,np=Pa,Ba=_a,Ua=Ra,Wa=Aa,Ha=Ia,rp=Ma,Va=Oa,qa=Da,Ka=La,za=$a,Ga=Fa;function $(...e){return Tc(e)}const op=new Set(["RUNNING","STARTING","NEEDS_PERMISSION","NEEDS_INPUT"]);function to(e){return op.has(e.status)}function br(e){return e.status==="NEEDS_PERMISSION"||e.status==="NEEDS_INPUT"}function jn(e){const t=new Date,n=typeof e=="string"?new Date(e):e,r=Math.floor((t.getTime()-n.getTime())/1e3);return r<60?"just now":r<3600?`${Math.floor(r/60)}m ago`:r<86400?`${Math.floor(r/3600)}h ago`:r<604800?`${Math.floor(r/86400)}d ago`:n.toLocaleDateString()}function Pt(e,t){return e.length<=t?e:`${e.slice(0,t)}...`}function Ya(e){switch(e){case"RUNNING":return"green";case"STARTING":return"yellow";case"CRASHED":return"red";case"STOPPED":return"gray";case"NEEDS_PERMISSION":return"blue";case"NEEDS_INPUT":return"cyan";default:return"gray"}}const Ja=ep,Xa=tp,sp=rp,ap=c.forwardRef(({className:e,inset:t,children:n,...r},s)=>o.jsxs(za,{ref:s,className:$("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ml-auto h-4 w-4",children:o.jsx("path",{d:"M6.1584 3.13508C6.35985 2.94621 6.67627 2.95642 6.86514 3.15788L10.6151 7.15788C10.7954 7.3502 10.7954 7.64949 10.6151 7.84182L6.86514 11.8418C6.67627 12.0433 6.35985 12.0535 6.1584 11.8646C5.95694 11.6757 5.94673 11.3593 6.1356 11.1579L9.565 7.49985L6.1356 3.84182C5.94673 3.64036 5.95694 3.32394 6.1584 3.13508Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})]}));ap.displayName=za.displayName;const ip=c.forwardRef(({className:e,...t},n)=>o.jsx(Ga,{ref:n,className:$("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",e),...t}));ip.displayName=Ga.displayName;const no=c.forwardRef(({className:e,sideOffset:t=4,...n},r)=>o.jsx(np,{children:o.jsx(Ba,{ref:r,sideOffset:t,className:$("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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",e),...n})}));no.displayName=Ba.displayName;const Wt=c.forwardRef(({className:e,inset:t,...n},r)=>o.jsx(Wa,{ref:r,className:$("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));Wt.displayName=Wa.displayName;const cp=c.forwardRef(({className:e,children:t,checked:n,...r},s)=>o.jsxs(Ha,{ref:s,className:$("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(qa,{children:o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",children:o.jsx("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})})}),t]}));cp.displayName=Ha.displayName;const Za=c.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(Va,{ref:r,className:$("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(qa,{children:o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 fill-current",children:o.jsx("path",{d:"M9.875 7.5C9.875 8.81168 8.81168 9.875 7.5 9.875C6.18832 9.875 5.125 8.81168 5.125 7.5C5.125 6.18832 6.18832 5.125 7.5 5.125C8.81168 5.125 9.875 6.18832 9.875 7.5Z",fill:"currentColor"})})})}),t]}));Za.displayName=Va.displayName;const Qa=c.forwardRef(({className:e,inset:t,...n},r)=>o.jsx(Ua,{ref:r,className:$("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Qa.displayName=Ua.displayName;const ro=c.forwardRef(({className:e,...t},n)=>o.jsx(Ka,{ref:n,className:$("-mx-1 my-1 h-px bg-muted",e),...t}));ro.displayName=Ka.displayName;const ei="codepiper.theme",ti="codepiper-dark",ni="codepiper-light",oo=[{id:"codepiper-dark",label:"CodePiper Dark",description:"Default dark theme with cyan accents.",mode:"dark",themeColor:"#0e1016",monacoTheme:"vs-dark",ui:{background:"#0e1016",foreground:"#f3f4f6",card:"#161b22",cardForeground:"#f3f4f6",popover:"#161b22",popoverForeground:"#f3f4f6",primary:"#06b6d4",primaryForeground:"#0e1016",secondary:"#222a35",secondaryForeground:"#f3f4f6",muted:"#222a35",mutedForeground:"#9ca3af",accent:"#243142",accentForeground:"#f3f4f6",destructive:"#dc2626",destructiveForeground:"#f8fafc",border:"#243142",input:"#243142",ring:"#06b6d4"},terminal:{background:"#0e1016",foreground:"#d4d4e0",cursor:"#67e8f9",cursorAccent:"#0e1016",selectionBackground:"#06b6d430",selectionForeground:"#d4d4e0",black:"#3a3a4a",red:"#f87171",green:"#4ade80",yellow:"#fbbf24",blue:"#60a5fa",magenta:"#c084fc",cyan:"#22d3ee",white:"#d4d4e0",brightBlack:"#5a5a6a",brightRed:"#fca5a5",brightGreen:"#86efac",brightYellow:"#fde68a",brightBlue:"#93c5fd",brightMagenta:"#d8b4fe",brightCyan:"#67e8f9",brightWhite:"#f0f0f8"}},{id:"codepiper-light",label:"CodePiper Light",description:"Editorial light theme with crisp contrast and sapphire accents.",mode:"light",themeColor:"#f5f7fb",monacoTheme:"vs",ui:{background:"#f5f7fb",foreground:"#121826",card:"#ffffff",cardForeground:"#121826",popover:"#ffffff",popoverForeground:"#121826",primary:"#1f5bd8",primaryForeground:"#f8fbff",secondary:"#e8edf6",secondaryForeground:"#172235",muted:"#eef2f8",mutedForeground:"#57627a",accent:"#dfe8f8",accentForeground:"#122038",destructive:"#c62828",destructiveForeground:"#ffffff",border:"#cad5e4",input:"#c4d0e0",ring:"#1f5bd8"},terminal:{background:"#f7faff",foreground:"#102035",cursor:"#1c2f4a",cursorAccent:"#ffffff",selectionBackground:"#1f5bd829",selectionForeground:"#102035",black:"#1e2a3f",red:"#c62828",green:"#2e7d32",yellow:"#93610d",blue:"#1e5bd7",magenta:"#7b2cbf",cyan:"#0e7490",white:"#d6e1f0",brightBlack:"#5a6a83",brightRed:"#ef4444",brightGreen:"#22a55a",brightYellow:"#b7791f",brightBlue:"#2563eb",brightMagenta:"#9333ea",brightCyan:"#0891b2",brightWhite:"#ffffff"}},{id:"dracula",label:"Dracula",description:"Popular high-contrast purple theme.",mode:"dark",themeColor:"#282a36",monacoTheme:"vs-dark",ui:{background:"#282a36",foreground:"#f8f8f2",card:"#303442",cardForeground:"#f8f8f2",popover:"#303442",popoverForeground:"#f8f8f2",primary:"#bd93f9",primaryForeground:"#282a36",secondary:"#3b3f51",secondaryForeground:"#f8f8f2",muted:"#3b3f51",mutedForeground:"#bdc2d6",accent:"#44475a",accentForeground:"#f8f8f2",destructive:"#ff5555",destructiveForeground:"#ffffff",border:"#44475a",input:"#44475a",ring:"#8be9fd"},terminal:{background:"#282a36",foreground:"#f8f8f2",cursor:"#f8f8f2",cursorAccent:"#282a36",selectionBackground:"#44475a99",selectionForeground:"#f8f8f2",black:"#21222c",red:"#ff5555",green:"#50fa7b",yellow:"#f1fa8c",blue:"#bd93f9",magenta:"#ff79c6",cyan:"#8be9fd",white:"#f8f8f2",brightBlack:"#6272a4",brightRed:"#ff6e6e",brightGreen:"#69ff94",brightYellow:"#ffffa5",brightBlue:"#d6acff",brightMagenta:"#ff92df",brightCyan:"#a4ffff",brightWhite:"#ffffff"}},{id:"nord",label:"Nord",description:"Arctic blue palette from the Nord project.",mode:"dark",themeColor:"#2e3440",monacoTheme:"vs-dark",ui:{background:"#2e3440",foreground:"#d8dee9",card:"#3b4252",cardForeground:"#d8dee9",popover:"#3b4252",popoverForeground:"#d8dee9",primary:"#88c0d0",primaryForeground:"#2e3440",secondary:"#434c5e",secondaryForeground:"#d8dee9",muted:"#434c5e",mutedForeground:"#b7c0cf",accent:"#4c566a",accentForeground:"#eceff4",destructive:"#bf616a",destructiveForeground:"#eceff4",border:"#4c566a",input:"#4c566a",ring:"#81a1c1"},terminal:{background:"#2e3440",foreground:"#d8dee9",cursor:"#d8dee9",cursorAccent:"#2e3440",selectionBackground:"#4c566a99",selectionForeground:"#eceff4",black:"#3b4252",red:"#bf616a",green:"#a3be8c",yellow:"#ebcb8b",blue:"#81a1c1",magenta:"#b48ead",cyan:"#88c0d0",white:"#e5e9f0",brightBlack:"#4c566a",brightRed:"#bf616a",brightGreen:"#a3be8c",brightYellow:"#ebcb8b",brightBlue:"#81a1c1",brightMagenta:"#b48ead",brightCyan:"#8fbcbb",brightWhite:"#eceff4"}},{id:"gruvbox-dark",label:"Gruvbox Dark",description:"Retro contrast palette popular in Vim and terminal workflows.",mode:"dark",themeColor:"#282828",monacoTheme:"vs-dark",ui:{background:"#282828",foreground:"#ebdbb2",card:"#32302f",cardForeground:"#ebdbb2",popover:"#32302f",popoverForeground:"#ebdbb2",primary:"#fabd2f",primaryForeground:"#282828",secondary:"#3c3836",secondaryForeground:"#ebdbb2",muted:"#3c3836",mutedForeground:"#bdae93",accent:"#504945",accentForeground:"#fbf1c7",destructive:"#fb4934",destructiveForeground:"#fbf1c7",border:"#504945",input:"#504945",ring:"#d79921"},terminal:{background:"#282828",foreground:"#ebdbb2",cursor:"#ebdbb2",cursorAccent:"#282828",selectionBackground:"#50494599",selectionForeground:"#fbf1c7",black:"#282828",red:"#cc241d",green:"#98971a",yellow:"#d79921",blue:"#458588",magenta:"#b16286",cyan:"#689d6a",white:"#a89984",brightBlack:"#928374",brightRed:"#fb4934",brightGreen:"#b8bb26",brightYellow:"#fabd2f",brightBlue:"#83a598",brightMagenta:"#d3869b",brightCyan:"#8ec07c",brightWhite:"#ebdbb2"}},{id:"solarized-dark",label:"Solarized Dark",description:"Low-contrast classic palette by Ethan Schoonover.",mode:"dark",themeColor:"#002b36",monacoTheme:"vs-dark",ui:{background:"#002b36",foreground:"#839496",card:"#073642",cardForeground:"#93a1a1",popover:"#073642",popoverForeground:"#93a1a1",primary:"#268bd2",primaryForeground:"#002b36",secondary:"#0b3f4a",secondaryForeground:"#93a1a1",muted:"#0b3f4a",mutedForeground:"#657b83",accent:"#0f4754",accentForeground:"#eee8d5",destructive:"#dc322f",destructiveForeground:"#fdf6e3",border:"#0f4754",input:"#0f4754",ring:"#2aa198"},terminal:{background:"#002b36",foreground:"#839496",cursor:"#839496",cursorAccent:"#002b36",selectionBackground:"#073642cc",selectionForeground:"#93a1a1",black:"#073642",red:"#dc322f",green:"#859900",yellow:"#b58900",blue:"#268bd2",magenta:"#d33682",cyan:"#2aa198",white:"#eee8d5",brightBlack:"#002b36",brightRed:"#cb4b16",brightGreen:"#586e75",brightYellow:"#657b83",brightBlue:"#839496",brightMagenta:"#6c71c4",brightCyan:"#93a1a1",brightWhite:"#fdf6e3"}}],lp=new Map(oo.map(e=>[e.id,e]));function yn(e){if(e)return lp.get(e)}function dp(e){const t=e.trim().toLowerCase();if(/^#[0-9a-f]{6}$/.test(t))return t;if(/^#[0-9a-f]{3}$/.test(t)){const[n,r,s]=t.slice(1).split("");return`#${n}${n}${r}${r}${s}${s}`}throw new Error(`Invalid hex color: ${e}`)}function up(e){const t=dp(e),n=Number.parseInt(t.slice(1,3),16),r=Number.parseInt(t.slice(3,5),16),s=Number.parseInt(t.slice(5,7),16);return{r:n,g:r,b:s}}function fp({r:e,g:t,b:n}){const r=e/255,s=t/255,a=n/255,i=Math.max(r,s,a),l=Math.min(r,s,a),d=i-l;let f=0;d>0&&(i===r?f=(s-a)/d%6:i===s?f=(a-r)/d+2:f=(r-s)/d+4),f=Math.round(f*60),f<0&&(f+=360);const m=(i+l)/2,p=d===0?0:d/(1-Math.abs(2*m-1)),h=Math.round(p*100),u=Math.round(m*100);return`${f} ${h}% ${u}%`}function pp(e){return fp(up(e))}const mp={background:"--background",foreground:"--foreground",card:"--card",cardForeground:"--card-foreground",popover:"--popover",popoverForeground:"--popover-foreground",primary:"--primary",primaryForeground:"--primary-foreground",secondary:"--secondary",secondaryForeground:"--secondary-foreground",muted:"--muted",mutedForeground:"--muted-foreground",accent:"--accent",accentForeground:"--accent-foreground",destructive:"--destructive",destructiveForeground:"--destructive-foreground",border:"--border",input:"--input",ring:"--ring"};function hp(e){document.documentElement.style.colorScheme=e}function gp(e){const t=document.querySelector('meta[name="theme-color"]');t instanceof HTMLMetaElement&&(t.content=e)}function xp(e){const t=document.documentElement;t.dataset.theme=e.id,t.classList.toggle("dark",e.mode==="dark");for(const[n,r]of Object.entries(mp)){const s=n;t.style.setProperty(r,pp(e.ui[s]))}hp(e.mode),gp(e.themeColor)}function yp(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function bp(){const e=localStorage.getItem("theme");if(e==="dark")return ti;if(e==="light")return ni}function vp(){const e=localStorage.getItem(ei),t=yn(e);if(t)return t;const n=bp(),r=yn(n);if(r)return r;const a=yp()==="dark"?ti:ni;return yn(a)??oo[0]}function wp(e){localStorage.setItem(ei,e)}const ri=c.createContext(null);function Sp({children:e}){const[t,n]=c.useState(()=>vp());c.useEffect(()=>{xp(t),wp(t.id)},[t]);const r=c.useCallback(a=>{const i=yn(a);i&&n(i)},[]),s=c.useMemo(()=>({theme:t,themes:oo,setTheme:r}),[t,r]);return o.jsx(ri.Provider,{value:s,children:e})}function so(){const e=c.useContext(ri);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}function $o({color:e,className:t}){return o.jsx("span",{className:$("inline-block h-4 w-4 rounded-full border border-border/70 shadow-[0_0_0_1px_hsl(var(--background))] shrink-0",t),style:{backgroundColor:e},"aria-hidden":"true"})}function Np({className:e}){const{theme:t,themes:n,setTheme:r}=so(),s=t.mode==="dark"?"bg-card/65 backdrop-blur-sm hover:bg-accent/70":"bg-card/92 hover:bg-accent/85",a=t.mode==="dark"?"bg-popover/95 backdrop-blur-xl shadow-[0_24px_48px_-24px_hsl(var(--foreground)/0.45)]":"bg-popover shadow-[0_20px_40px_-22px_hsl(var(--foreground)/0.22)]";return o.jsxs(Ja,{children:[o.jsx(Xa,{asChild:!0,children:o.jsx("button",{type:"button",className:$("h-8 w-8 rounded-lg border border-border/70 flex items-center justify-center text-muted-foreground hover:text-foreground hover:border-primary/45 transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",s,e),"aria-label":`Theme picker (current: ${t.label})`,title:`Theme: ${t.label}`,children:o.jsx($o,{color:t.ui.primary,className:"h-3.5 w-3.5 border-border/80"})})}),o.jsxs(no,{align:"end",className:$("w-72 border-border/70",a),children:[o.jsx(Qa,{className:"text-[10px] uppercase tracking-[0.14em] text-muted-foreground font-semibold",children:"Theme"}),o.jsx(ro,{}),o.jsx(sp,{value:t.id,onValueChange:r,children:n.map(i=>o.jsx(Za,{value:i.id,className:"pl-2 pr-2 py-2 rounded-md border border-transparent focus:bg-accent/70 data-[state=checked]:border-primary/35 data-[state=checked]:bg-primary/10 [&>span:first-child]:hidden",children:o.jsxs("div",{className:"flex w-full items-center gap-2.5",children:[o.jsx($o,{color:i.ui.primary}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"truncate text-sm font-medium",children:i.label}),o.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:i.description})]}),o.jsx("span",{className:$("ml-auto h-2 w-2 rounded-full border border-border/70",t.id===i.id?"bg-primary border-primary/50":"bg-transparent")})]})},i.id))})]})]})}class nt extends Error{constructor(t,n,r){super(t),this.status=n,this.response=r,this.name="ApiError"}}class Ep{constructor(t="/api"){le(this,"baseUrl");this.baseUrl=t}async request(t,n){const r=`${this.baseUrl}${t}`;try{const s=await fetch(r,{...n,cache:"no-store",headers:{"Content-Type":"application/json",...n==null?void 0:n.headers}});if(!s.ok){let a=`HTTP ${s.status}: ${s.statusText}`,i;try{i=await s.json(),i&&typeof i=="object"&&"error"in i&&(a=String(i.error))}catch{}throw new nt(a,s.status,i)}return await s.json()}catch(s){throw s instanceof nt?s:new nt(s instanceof Error?s.message:"Network error",0)}}async getHealth(){return this.request("/health")}async getVersion(){return this.request("/version")}async getProviders(){return this.request("/providers")}async getSessions(){return this.request("/sessions")}async getSession(t){return this.request(`/sessions/${t}`)}async updateSessionName(t,n){return this.request(`/sessions/${t}/name`,{method:"PUT",body:JSON.stringify(n)})}async createSession(t){return this.request("/sessions",{method:"POST",body:JSON.stringify(t)})}async stopSession(t){return this.request(`/sessions/${t}/stop`,{method:"POST"})}async killSession(t){return this.request(`/sessions/${t}/kill`,{method:"POST"})}async resumeSession(t){return this.request(`/sessions/${t}/resume`,{method:"POST"})}async recoverSession(t){return this.request(`/sessions/${t}/recover`,{method:"POST"})}async sendText(t,n){await this.request(`/sessions/${t}/send`,{method:"POST",body:JSON.stringify(n)})}async uploadImage(t,n,r){const s=`${this.baseUrl}/sessions/${t}/upload-image`,a=new FormData;if(a.append("image",n),r!=null&&r.onProgress)return new Promise((l,d)=>{const f=new XMLHttpRequest;f.open("POST",s,!0),f.responseType="json",f.upload.onprogress=m=>{var h;if(!m.lengthComputable)return;const p=Math.max(0,Math.min(100,Math.round(m.loaded/m.total*100)));(h=r.onProgress)==null||h.call(r,p)},f.onload=()=>{var p;if(f.status<200||f.status>=300){const h=f.response&&typeof f.response=="object"&&"error"in f.response?String(f.response.error):`HTTP ${f.status}: ${f.statusText}`;d(new nt(h,f.status));return}const m=f.response&&typeof f.response=="object"?f.response:null;if(!(m!=null&&m.path)){d(new nt("Invalid upload response payload",f.status||500));return}(p=r.onProgress)==null||p.call(r,100),l(m)},f.onerror=()=>{d(new nt("Network error during upload",f.status||0))},f.send(a)});const i=await fetch(s,{method:"POST",body:a});if(!i.ok){let l=`HTTP ${i.status}: ${i.statusText}`;try{const d=await i.json();d!=null&&d.error&&(l=String(d.error))}catch{}throw new nt(l,i.status)}return await i.json()}async transcribeAudio(t,n,r="voice.webm"){const s=`${this.baseUrl}/sessions/${t}/terminal/transcribe`,a=new FormData;a.append("audio",new File([n],r,{type:n.type}));const i=await fetch(s,{method:"POST",body:a});if(!i.ok){let l=`HTTP ${i.status}: ${i.statusText}`;try{const d=await i.json();d!=null&&d.error&&(l=String(d.error))}catch{}throw new nt(l,i.status)}return await i.json()}async sendKeys(t,n){await this.request(`/sessions/${t}/keys`,{method:"POST",body:JSON.stringify(n)})}async resizeSession(t,n,r){return this.request(`/sessions/${t}/resize`,{method:"POST",body:JSON.stringify({cols:n,rows:r})})}async getSessionOutput(t){return this.request(`/sessions/${t}/output`)}async getEvents(t,n){const r=new URLSearchParams;n!=null&&n.since&&r.append("since",String(n.since)),n!=null&&n.before&&r.append("before",String(n.before)),n!=null&&n.limit&&r.append("limit",String(n.limit)),n!=null&&n.source&&r.append("source",n.source),n!=null&&n.type&&r.append("type",n.type),n!=null&&n.order&&r.append("order",n.order);const s=r.toString(),a=`/sessions/${t}/events${s?`?${s}`:""}`;return this.request(a)}async getPolicies(){return this.request("/policies")}async getPolicy(t){return this.request(`/policies/${t}`)}async createPolicy(t){return this.request("/policies",{method:"POST",body:JSON.stringify(t)})}async updatePolicy(t,n){return this.request(`/policies/${t}`,{method:"PUT",body:JSON.stringify(n)})}async deletePolicy(t){return this.request(`/policies/${t}`,{method:"DELETE"})}async getPolicySets(){return this.request("/policy-sets")}async getPolicySet(t){return this.request(`/policy-sets/${t}`)}async createPolicySet(t){return this.request("/policy-sets",{method:"POST",body:JSON.stringify(t)})}async updatePolicySet(t,n){return this.request(`/policy-sets/${t}`,{method:"PUT",body:JSON.stringify(n)})}async deletePolicySet(t){return this.request(`/policy-sets/${t}`,{method:"DELETE"})}async addPolicyToSet(t,n){return this.request(`/policy-sets/${t}/policies`,{method:"POST",body:JSON.stringify({policyId:n})})}async removePolicyFromSet(t,n){return this.request(`/policy-sets/${t}/policies/${n}`,{method:"DELETE"})}async getSessionPolicySets(t){return this.request(`/sessions/${t}/policy-sets`)}async applyPolicySetToSession(t,n){return this.request(`/sessions/${t}/policy-sets`,{method:"POST",body:JSON.stringify({policySetId:n})})}async removePolicySetFromSession(t,n){return this.request(`/sessions/${t}/policy-sets/${n}`,{method:"DELETE"})}async getEffectivePolicies(t){return this.request(`/sessions/${t}/effective-policies`)}async getPolicyDecisions(t){const n=new URLSearchParams;t!=null&&t.sessionId&&n.append("sessionId",t.sessionId),t!=null&&t.decision&&n.append("decision",t.decision),t!=null&&t.limit&&n.append("limit",String(t.limit));const r=n.toString();return this.request(`/policy-decisions${r?`?${r}`:""}`)}async getWorkflows(){return this.request("/workflows")}async getWorkflow(t){return this.request(`/workflows/${t}`)}async createWorkflow(t){return this.request("/workflows",{method:"POST",body:JSON.stringify(t)})}async executeWorkflow(t,n){return this.request(`/workflows/${t}/execute`,{method:"POST",body:JSON.stringify({variables:n})})}async getWorkflowExecutions(t){return this.request(`/workflows/${t}/executions`)}async getWorkflowExecution(t,n){return this.request(`/workflows/${t}/executions/${n}`)}async cancelExecution(t,n){return this.request(`/workflows/${t}/executions/${n}/cancel`,{method:"POST"})}async getWorkspaces(){return this.request("/workspaces")}async createWorkspace(t){return this.request("/workspaces",{method:"POST",body:JSON.stringify(t)})}async updateWorkspace(t,n){return this.request(`/workspaces/${t}`,{method:"PUT",body:JSON.stringify(n)})}async deleteWorkspace(t){return this.request(`/workspaces/${t}`,{method:"DELETE"})}async getEnvSets(){return this.request("/env-sets")}async createEnvSet(t){return this.request("/env-sets",{method:"POST",body:JSON.stringify(t)})}async updateEnvSet(t,n){return this.request(`/env-sets/${t}`,{method:"PUT",body:JSON.stringify(n)})}async deleteEnvSet(t){return this.request(`/env-sets/${t}`,{method:"DELETE"})}async getDaemonSettings(){return this.request("/settings/daemon")}async updateDaemonSettings(t){return this.request("/settings/daemon",{method:"PUT",body:JSON.stringify(t)})}async restartDaemon(){return this.request("/settings/daemon/restart",{method:"POST"})}async getNotifications(t){const n=new URLSearchParams;t!=null&&t.sessionId&&n.append("sessionId",t.sessionId),t!=null&&t.eventType&&n.append("eventType",t.eventType),typeof(t==null?void 0:t.unreadOnly)=="boolean"&&n.append("unreadOnly",t.unreadOnly?"true":"false"),typeof(t==null?void 0:t.before)=="number"&&n.append("before",String(t.before)),typeof(t==null?void 0:t.limit)=="number"&&n.append("limit",String(t.limit));const r=n.toString();return this.request(`/notifications${r?`?${r}`:""}`)}async getNotificationCounts(){return this.request("/notifications/counts")}async markNotificationRead(t,n){return this.request(`/notifications/${t}/read`,{method:"POST",body:JSON.stringify(n?{readSource:n}:{})})}async markNotificationsRead(t){return this.request("/notifications/read",{method:"POST",body:JSON.stringify(t??{})})}async getSessionNotificationPrefs(t){return this.request(`/sessions/${t}/notifications/prefs`)}async updateSessionNotificationPrefs(t,n){return this.request(`/sessions/${t}/notifications/prefs`,{method:"PUT",body:JSON.stringify({enabled:n})})}async listPushSubscriptions(){return this.request("/notifications/push/subscriptions")}async getPushDeliveryStatus(){return this.request("/notifications/push/status")}async sendTestPushNotification(t){return this.request("/notifications/push/test",{method:"POST",body:JSON.stringify(t??{})})}async upsertPushSubscription(t){return this.request("/notifications/push/subscriptions",{method:"PUT",body:JSON.stringify(t)})}async deletePushSubscription(t){return this.request("/notifications/push/subscriptions",{method:"DELETE",body:JSON.stringify({endpoint:t})})}async validateSession(t){return this.request("/sessions/validate",{method:"POST",body:JSON.stringify(t)})}async validateGit(t){return this.request("/sessions/validate-git",{method:"POST",body:JSON.stringify(t)})}async getGitStatus(t){return this.request(`/sessions/${t}/git/status`)}async getGitLog(t,n=50){return this.request(`/sessions/${t}/git/log?limit=${n}`)}async getGitDiff(t,n){const r=new URLSearchParams;n!=null&&n.staged&&r.append("staged","true"),n!=null&&n.commit&&r.append("commit",n.commit),n!=null&&n.commitA&&r.append("commitA",n.commitA),n!=null&&n.commitB&&r.append("commitB",n.commitB),n!=null&&n.path&&r.append("path",n.path);const s=r.toString();return this.request(`/sessions/${t}/git/diff${s?`?${s}`:""}`)}async getGitFile(t,n,r){const s=new URLSearchParams({ref:n,path:r});return this.request(`/sessions/${t}/git/file?${s}`)}async getGitFileRawBlob(t,n,r){const s=new URLSearchParams({ref:n,path:r});try{const a=await fetch(`${this.baseUrl}/sessions/${t}/git/file-raw?${s}`);return a.ok?await a.blob():null}catch{return null}}async getGitBranches(t){return this.request(`/sessions/${t}/git/branches`)}async getGitDiffStat(t,n,r){const s=new URLSearchParams({ref:n});return r&&s.append("base",r),this.request(`/sessions/${t}/git/diff-stat?${s}`)}async stageFiles(t,n){return this.request(`/sessions/${t}/git/stage`,{method:"POST",body:JSON.stringify({paths:n})})}async unstageFiles(t,n){return this.request(`/sessions/${t}/git/unstage`,{method:"POST",body:JSON.stringify({paths:n})})}async getTerminalInfo(t){return this.request(`/sessions/${t}/terminal/info`)}async setTerminalMode(t,n){return this.request(`/sessions/${t}/terminal/mode`,{method:"POST",body:JSON.stringify({mode:n})})}async scrollTerminal(t,n){return this.request(`/sessions/${t}/terminal/scroll`,{method:"POST",body:JSON.stringify(n)})}async searchTerminal(t,n){return this.request(`/sessions/${t}/terminal/search`,{method:"POST",body:JSON.stringify(n)})}}const ae=new Ep,Fo={"session.turn_completed":"Turn completed","session.permission_required":"Permission required","session.input_required":"Input required"},Cp={"claude-code":"Claude Code",codex:"Codex"};function kp(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function oi(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function si(e,t){return e.toLocaleLowerCase().includes(t.toLocaleLowerCase())}function jp(e,t){return si(e,t)?e:`${t}: ${e}`}function ao(e){return e in Fo?Fo[e]:oi(e.replace(/[._]+/g," "))}function ai(e){return Cp[e]??oi(e.replace(/-/g," "))}function Pp(e){return io(e)}function io(e,t){if(typeof t=="string"&&t.trim())return t.trim();const n=e.payload;return kp(n)&&typeof n.sessionLabel=="string"&&n.sessionLabel.trim()?n.sessionLabel.trim():`#${e.sessionId.slice(0,8)}`}function vr(e,t){var r;const n=io(e,t);return e.eventType==="session.turn_completed"?`${n} wrapped up a turn and is ready for your next move.`:e.eventType==="session.permission_required"?`${n} needs a quick permission decision to continue.`:e.eventType==="session.input_required"?`${n} is waiting for your input.`:(r=e.body)!=null&&r.trim()?jp(e.body.trim(),n):`${n}: ${ao(e.eventType)}.`}function wr(e,t){const n=io(e,t),r=e.title.trim();return r.length===0?n:si(r,n)?r:`${n} · ${r}`}const co="/sounds/codepiper-soft-chime.wav",Ag=[{key:"session.turn_completed",label:"Turn completed"},{key:"session.permission_required",label:"Permission required"},{key:"session.input_required",label:"Input required"}],Ig=512*1024;function Tp(e,t){return e[t]||e.default||co}function Mg(e){return e.type.startsWith("audio/")?!0:/\.(mp3|wav|ogg|m4a|aac|webm|flac)$/i.test(e.name)}const _p="dev";function Rp(){const e="0.2.1".trim(),t=globalThis.__CODEPIPER_WEB_BUILD_ID__,n=typeof t=="string"?t.trim():"",r=e||n;return r.length>0?r:_p}function ii(){return`/sw.js?v=${encodeURIComponent(Rp())}`}function Pn(e){e.waiting&&e.waiting.postMessage({type:"SKIP_WAITING"})}function Ap(e){return e==="sessions"||e==="notifications"||/^session:[a-zA-Z0-9-]+:(events|pty)$/.test(e)}function Ip(e){return/^session:[a-zA-Z0-9-]+:pty$/.test(e)}const cr=1,Bo=!1,Uo=!1,Wo=!0,Mp=67,Op=1,Dp=1,Lp=2,Ho=10,$p=16,Vo=4,lr=new TextDecoder,Fp=new TextEncoder,Bp=3e4,dr=8192,Up=512,Wp=2*1024*1024,Hp=256*1024,Vp=8,qp=80;let ur=0;class Kp{constructor(t){le(this,"ws",null);le(this,"url");le(this,"subscribers",new Map);le(this,"subscriptionOptions",new Map);le(this,"connectionStateHandlers",new Set);le(this,"reconnectTimeout",null);le(this,"reconnectAttempts",0);le(this,"maxReconnectAttempts",10);le(this,"isIntentionallyClosed",!1);le(this,"connected",!1);le(this,"pendingInputRequests",new Map);le(this,"pendingPasteSends",new Map);le(this,"telemetryStartedAt",Date.now());le(this,"serverHelloAcknowledged",!1);le(this,"serverNegotiatedPtyPatch",!1);le(this,"serverNegotiatedPtyBinary",!1);le(this,"serverNegotiatedPtyPaste",!1);le(this,"telemetry",{connectionsOpened:0,connectionsClosed:0,reconnectSchedules:0,reconnectSuccesses:0,maxReconnectExhausted:0,messagesReceived:0,parseErrors:0,invalidMessageShape:0,invalidTopic:0,helloSent:0,helloAckReceived:0,helloAckVersionMismatch:0,subscribeSent:0,subscribeWithReplayCursorSent:0,unsubscribeSent:0,ptyInputSent:0,ptyKeySent:0,ptyPasteSent:0,ptyInputAcksReceived:0,ptyKeyAcksReceived:0,ptyPasteAcksReceived:0,ptyInputAckUnmatched:0,ptyKeyAckUnmatched:0,ptyPasteAckUnmatched:0,ptyInputErrorsReceived:0,ptyKeyErrorsReceived:0,ptyPasteErrorsReceived:0,ptyInputErrorUnmatched:0,ptyKeyErrorUnmatched:0,ptyPasteErrorUnmatched:0,ptyInputFallbackTriggered:0,ptyKeyFallbackTriggered:0,ptyPasteFallbackTriggered:0,ptyFallbackHandlerErrors:0});this.url=t}connect(){var t;if(((t=this.ws)==null?void 0:t.readyState)!==WebSocket.OPEN){this.isIntentionallyClosed=!1;try{this.ws=new WebSocket(this.url),this.ws.binaryType="arraybuffer",this.ws.onopen=()=>{console.log("[WebSocket] Connected"),this.telemetry.connectionsOpened+=1,this.serverHelloAcknowledged=!1,this.serverNegotiatedPtyPatch=!1,this.serverNegotiatedPtyBinary=!1,this.serverNegotiatedPtyPaste=!1,this.reconnectAttempts>0&&(this.telemetry.reconnectSuccesses+=1),this.reconnectAttempts=0,this.setConnectedState(!0),this.sendHello();for(const n of this.subscribers.keys())this.sendSubscribe(n,this.subscriptionOptions.get(n))},this.ws.onmessage=n=>{this.telemetry.messagesReceived+=1;try{if(typeof n.data=="string"){const s=JSON.parse(n.data);this.handleMessage(s);return}if(!(n.data instanceof ArrayBuffer)){console.error("[WebSocket] Received unsupported binary payload type");return}const r=Yp(n.data);if(!r){this.telemetry.parseErrors+=1,console.error("[WebSocket] Failed to decode binary PTY frame");return}this.handleMessage(r)}catch(r){this.telemetry.parseErrors+=1,console.error("[WebSocket] Failed to parse message:",r)}},this.ws.onerror=n=>{console.error("[WebSocket] Error:",n)},this.ws.onclose=()=>{console.log("[WebSocket] Disconnected"),this.telemetry.connectionsClosed+=1,this.setConnectedState(!1),this.isIntentionallyClosed||this.scheduleReconnect()}}catch(n){console.error("[WebSocket] Connection failed:",n),this.scheduleReconnect()}}}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts){this.telemetry.maxReconnectExhausted+=1,console.error("[WebSocket] Max reconnect attempts reached");return}const t=Math.min(1e3*2**this.reconnectAttempts,3e4);this.reconnectAttempts++,this.telemetry.reconnectSchedules+=1,console.log(`[WebSocket] Reconnecting in ${t}ms (attempt ${this.reconnectAttempts})...`),this.reconnectTimeout=setTimeout(()=>{this.connect()},t)}handleMessage(t){if(Gp(t)&&!("topic"in t)){this.handleControlMessage(t);return}if(!zp(t)){this.telemetry.invalidMessageShape+=1,console.error("[WebSocket] Invalid message payload shape");return}if(!Ap(t.topic)){this.telemetry.invalidTopic+=1,console.warn(`[WebSocket] Ignoring message for invalid topic: ${t.topic}`);return}const n=this.subscribers.get(t.topic);if(n){const{topic:r,...s}=t;for(const a of n)try{a(s)}catch(i){console.error(`[WebSocket] Error in handler for ${t.topic}:`,i)}}}handleControlMessage(t){if(t.op==="hello_ack"){this.telemetry.helloAckReceived+=1,this.serverHelloAcknowledged=!0;const n=t.version;if(typeof n=="number"&&n!==cr&&(this.telemetry.helloAckVersionMismatch+=1,console.warn(`[WebSocket] Protocol mismatch: client=${cr}, server=${n}`)),t.features&&typeof t.features=="object"){const r=t.features;this.serverNegotiatedPtyPaste=r.ptyPaste===!0}if(t.negotiated&&typeof t.negotiated=="object"){const r=t.negotiated;this.serverNegotiatedPtyPatch=r.ptyPatch===!0,this.serverNegotiatedPtyBinary=r.ptyBinary===!0,"ptyPaste"in r&&(this.serverNegotiatedPtyPaste=r.ptyPaste===!0)}return}if(t.op==="pty_input_ack"||t.op==="pty_key_ack"||t.op==="pty_paste_ack"){this.handleInputAckControlMessage(t);return}(t.op==="pty_input_error"||t.op==="pty_key_error"||t.op==="pty_paste_error")&&this.handleInputErrorControlMessage(t)}sendHello(){var t;((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN&&(this.telemetry.helloSent+=1,this.ws.send(JSON.stringify({op:"hello",version:cr,supports:{ptyPatch:Bo,ptyBinary:Uo,ptyPaste:Wo}})))}sendSubscribe(t,n){var r,s;if(((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN){const a={op:"subscribe",topic:t},i=(s=n==null?void 0:n.getReplayCursor)==null?void 0:s.call(n);this.telemetry.subscribeSent+=1,Ip(t)&&typeof i=="number"&&Number.isInteger(i)&&i>=0&&(a.sinceSeq=i,this.telemetry.subscribeWithReplayCursorSent+=1),this.ws.send(JSON.stringify(a))}}sendUnsubscribe(t){var n;((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN&&(this.telemetry.unsubscribeSent+=1,this.ws.send(JSON.stringify({op:"unsubscribe",topic:t})))}sendPtyInput(t,n,r){if(!(t&&n))return!1;const s=this.sendInputOperation("pty_input",t,{data:n},r);return s&&(this.telemetry.ptyInputSent+=1),s}sendPtyKey(t,n,r){if(!(t&&n))return!1;const s=this.sendInputOperation("pty_key",t,{key:n},r);return s&&(this.telemetry.ptyKeySent+=1),s}sendPtyPaste(t,n,r){var l;if(!(t&&n)||this.serverHelloAcknowledged&&!this.serverNegotiatedPtyPaste||((l=this.ws)==null?void 0:l.readyState)!==WebSocket.OPEN)return!1;const s=Jp(n);if(!s||s.length===0)return!1;const a=this.resolveInputRequestId({requestId:r==null?void 0:r.requestId,onDispatchError:(r==null?void 0:r.onDispatchError)??(()=>{})});if(!a)return!1;const i=(r==null?void 0:r.onDispatchError)??(()=>{});return this.registerPendingInputRequest("pty_paste",t,a,i),this.enqueuePtyPasteSend(t,a,s,i),!0}subscribe(t,n,r){var a;this.subscribers.has(t)?r&&this.subscriptionOptions.set(t,r):(this.subscribers.set(t,new Set),this.subscriptionOptions.set(t,r),this.sendSubscribe(t,r));const s=n;return(a=this.subscribers.get(t))==null||a.add(s),()=>{const i=this.subscribers.get(t);i&&(i.delete(s),i.size===0&&(this.subscribers.delete(t),this.subscriptionOptions.delete(t),this.sendUnsubscribe(t)))}}close(){this.isIntentionallyClosed=!0,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.ws&&(this.ws.close(),this.ws=null),this.setConnectedState(!1),this.serverHelloAcknowledged=!1,this.serverNegotiatedPtyPatch=!1,this.serverNegotiatedPtyBinary=!1,this.serverNegotiatedPtyPaste=!1,this.clearPendingInputRequests(),this.pendingPasteSends.clear(),this.subscribers.clear(),this.subscriptionOptions.clear()}getReadyState(){var t;return((t=this.ws)==null?void 0:t.readyState)??WebSocket.CLOSED}isConnected(){return this.connected}getTelemetrySnapshot(t=Date.now()){return{startedAt:this.telemetryStartedAt,uptimeMs:Math.max(0,t-this.telemetryStartedAt),connected:this.connected,reconnectAttempts:this.reconnectAttempts,connectionsOpened:this.telemetry.connectionsOpened,connectionsClosed:this.telemetry.connectionsClosed,reconnectSchedules:this.telemetry.reconnectSchedules,reconnectSuccesses:this.telemetry.reconnectSuccesses,maxReconnectExhausted:this.telemetry.maxReconnectExhausted,messagesReceived:this.telemetry.messagesReceived,parseErrors:this.telemetry.parseErrors,invalidMessageShape:this.telemetry.invalidMessageShape,invalidTopic:this.telemetry.invalidTopic,helloSent:this.telemetry.helloSent,helloAckReceived:this.telemetry.helloAckReceived,helloAckVersionMismatch:this.telemetry.helloAckVersionMismatch,clientAdvertisesPtyPatch:Bo,clientAdvertisesPtyBinary:Uo,clientAdvertisesPtyPaste:Wo,serverNegotiatedPtyPatch:this.serverNegotiatedPtyPatch,serverNegotiatedPtyBinary:this.serverNegotiatedPtyBinary,serverNegotiatedPtyPaste:this.serverNegotiatedPtyPaste,subscribeSent:this.telemetry.subscribeSent,subscribeWithReplayCursorSent:this.telemetry.subscribeWithReplayCursorSent,unsubscribeSent:this.telemetry.unsubscribeSent,ptyInputSent:this.telemetry.ptyInputSent,ptyKeySent:this.telemetry.ptyKeySent,ptyPasteSent:this.telemetry.ptyPasteSent,ptyInputAcksReceived:this.telemetry.ptyInputAcksReceived,ptyKeyAcksReceived:this.telemetry.ptyKeyAcksReceived,ptyPasteAcksReceived:this.telemetry.ptyPasteAcksReceived,ptyInputAckUnmatched:this.telemetry.ptyInputAckUnmatched,ptyKeyAckUnmatched:this.telemetry.ptyKeyAckUnmatched,ptyPasteAckUnmatched:this.telemetry.ptyPasteAckUnmatched,ptyInputErrorsReceived:this.telemetry.ptyInputErrorsReceived,ptyKeyErrorsReceived:this.telemetry.ptyKeyErrorsReceived,ptyPasteErrorsReceived:this.telemetry.ptyPasteErrorsReceived,ptyInputErrorUnmatched:this.telemetry.ptyInputErrorUnmatched,ptyKeyErrorUnmatched:this.telemetry.ptyKeyErrorUnmatched,ptyPasteErrorUnmatched:this.telemetry.ptyPasteErrorUnmatched,ptyInputFallbackTriggered:this.telemetry.ptyInputFallbackTriggered,ptyKeyFallbackTriggered:this.telemetry.ptyKeyFallbackTriggered,ptyPasteFallbackTriggered:this.telemetry.ptyPasteFallbackTriggered,ptyFallbackHandlerErrors:this.telemetry.ptyFallbackHandlerErrors,pendingInputRequests:this.pendingInputRequests.size,pendingPasteSessionQueues:this.pendingPasteSends.size}}getSessionInputQueueDepth(t){let n=0;for(const r of this.pendingInputRequests.values())r.sessionId===t&&(n+=1);return{pendingInputRequests:n,hasPendingPasteQueue:this.pendingPasteSends.has(t)}}onConnectionChange(t){return this.connectionStateHandlers.add(t),()=>{this.connectionStateHandlers.delete(t)}}setConnectedState(t){if(this.connected!==t){this.connected=t;for(const n of this.connectionStateHandlers)try{n(t)}catch(r){console.error("[WebSocket] Error in connection state handler:",r)}}}handleInputAckControlMessage(t){const n=t.op==="pty_key_ack"?"pty_key":t.op==="pty_paste_ack"?"pty_paste":"pty_input";if(n==="pty_key"?this.telemetry.ptyKeyAcksReceived+=1:n==="pty_paste"?this.telemetry.ptyPasteAcksReceived+=1:this.telemetry.ptyInputAcksReceived+=1,typeof t.sessionId!="string"||!t.sessionId){console.warn(`[WebSocket] Ignoring ${t.op} with invalid sessionId`);return}if(typeof t.requestId!="string"||!t.requestId){n==="pty_key"?this.telemetry.ptyKeyAckUnmatched+=1:n==="pty_paste"?this.telemetry.ptyPasteAckUnmatched+=1:this.telemetry.ptyInputAckUnmatched+=1,console.warn(`[WebSocket] Ignoring ${t.op} with invalid requestId`);return}const r=this.pendingInputRequests.get(t.requestId);if(!r||r.op!==n||r.sessionId!==t.sessionId){n==="pty_key"?this.telemetry.ptyKeyAckUnmatched+=1:n==="pty_paste"?this.telemetry.ptyPasteAckUnmatched+=1:this.telemetry.ptyInputAckUnmatched+=1,console.warn(`[WebSocket] Received unmatched ${t.op} for session ${t.sessionId}`,{requestId:t.requestId});return}this.takePendingInputRequest(t.requestId)}handleInputErrorControlMessage(t){const n=t.op==="pty_key_error"?"pty_key":t.op==="pty_paste_error"?"pty_paste":"pty_input";if(n==="pty_key"?this.telemetry.ptyKeyErrorsReceived+=1:n==="pty_paste"?this.telemetry.ptyPasteErrorsReceived+=1:this.telemetry.ptyInputErrorsReceived+=1,typeof t.sessionId!="string"||!t.sessionId){console.warn(`[WebSocket] Ignoring ${t.op} with invalid sessionId`);return}const r=typeof t.requestId=="string"&&t.requestId?t.requestId:void 0;let s=r&&this.pendingInputRequests.has(r)?this.pendingInputRequests.get(r):void 0;if(r&&s&&s.op===n&&s.sessionId===t.sessionId?this.takePendingInputRequest(r):r&&(s=void 0),s||(s=this.takeFirstPendingInputRequest(n,t.sessionId)),!s||s.op!==n||s.sessionId!==t.sessionId){n==="pty_key"?this.telemetry.ptyKeyErrorUnmatched+=1:n==="pty_paste"?this.telemetry.ptyPasteErrorUnmatched+=1:this.telemetry.ptyInputErrorUnmatched+=1,console.warn(`[WebSocket] Received unmatched ${t.op} for session ${t.sessionId}`,r?{requestId:r}:void 0);return}n==="pty_key"?this.telemetry.ptyKeyFallbackTriggered+=1:n==="pty_paste"?this.telemetry.ptyPasteFallbackTriggered+=1:this.telemetry.ptyInputFallbackTriggered+=1,Promise.resolve(s.onError()).catch(a=>{this.telemetry.ptyFallbackHandlerErrors+=1,console.error(`[WebSocket] ${t.op} fallback failed:`,a)})}sendInputOperation(t,n,r,s){var i;if(((i=this.ws)==null?void 0:i.readyState)!==WebSocket.OPEN)return!1;const a=this.resolveInputRequestId(s);a&&(s!=null&&s.onDispatchError)&&this.registerPendingInputRequest(t,n,a,s.onDispatchError);try{return this.ws.send(JSON.stringify({op:t,sessionId:n,...r,...a?{requestId:a}:{}})),!0}catch(l){return a&&this.takePendingInputRequest(a),console.error(`[WebSocket] Failed to send ${t}:`,l),!1}}resolveInputRequestId(t){const n=t==null?void 0:t.requestId;if(typeof n=="string"&&/^[a-zA-Z0-9_-]{1,128}$/.test(n))return n;if(t!=null&&t.onDispatchError)return ur=(ur+1)%Number.MAX_SAFE_INTEGER,`wr${Date.now().toString(36)}_${ur.toString(36)}`}registerPendingInputRequest(t,n,r,s){const a=this.pendingInputRequests.get(r);a&&clearTimeout(a.timeout);const i=setTimeout(()=>{this.pendingInputRequests.delete(r)},Bp);this.pendingInputRequests.set(r,{op:t,sessionId:n,onError:s,timeout:i})}takePendingInputRequest(t){const n=this.pendingInputRequests.get(t);if(n)return clearTimeout(n.timeout),this.pendingInputRequests.delete(t),n}takeFirstPendingInputRequest(t,n){for(const[r,s]of this.pendingInputRequests.entries())if(s.op===t&&s.sessionId===n)return this.takePendingInputRequest(r)}clearPendingInputRequests(){for(const t of this.pendingInputRequests.values())clearTimeout(t.timeout);this.pendingInputRequests.clear()}enqueuePtyPasteSend(t,n,r,s){const l=(this.pendingPasteSends.get(t)??Promise.resolve()).catch(()=>{}).then(async()=>{await this.sendPtyPasteChunks(t,n,r)}).catch(d=>(this.takePendingInputRequest(n),this.telemetry.ptyPasteFallbackTriggered+=1,console.error("[WebSocket] Failed to send pty_paste:",d),Promise.resolve(s()).catch(f=>{this.telemetry.ptyFallbackHandlerErrors+=1,console.error("[WebSocket] pty_paste fallback failed:",f)}))).finally(()=>{this.pendingPasteSends.get(t)===l&&this.pendingPasteSends.delete(t)});this.pendingPasteSends.set(t,l)}async sendPtyPasteChunks(t,n,r){for(let s=0;s<r.length;s+=1){const a=this.ws;if(!a||a.readyState!==WebSocket.OPEN)throw new Error("WebSocket is not connected");await this.waitForPasteBufferDrain(a),a.send(JSON.stringify({op:"pty_paste",sessionId:t,requestId:n,chunkIndex:s,chunkCount:r.length,data:r[s]})),this.telemetry.ptyPasteSent+=1}}async waitForPasteBufferDrain(t){let n=0;for(;t.readyState===WebSocket.OPEN&&t.bufferedAmount>Hp&&n<qp;)n+=1,await new Promise(r=>setTimeout(r,Vp));if(t.readyState!==WebSocket.OPEN)throw new Error("WebSocket disconnected while streaming paste")}}function zp(e){return!(e&&typeof e=="object")||Array.isArray(e)?!1:typeof e.topic=="string"}function Gp(e){return!(e&&typeof e=="object")||Array.isArray(e)?!1:typeof e.op=="string"}function Yp(e){const t=new Uint8Array(e);if(t.byteLength<Ho+Vo)return null;const n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint8(0),s=n.getUint8(1),a=n.getUint8(2);if(r!==Mp||s!==Op)return null;const i=n.getUint16(4,!0),l=n.getUint32(6,!0);let d=Ho;const f=d+i;if(f>t.byteLength)return null;const m=lr.decode(t.subarray(d,f));if(d=f,a===Dp){if(d+Vo>t.byteLength)return null;const h=n.getUint32(d,!0);d+=4;const u=d+h;if(u!==t.byteLength)return null;const x=lr.decode(t.subarray(d,u));return{topic:m,type:"pty_output",data:x,seq:l}}if(a===Lp){if(d+$p>t.byteLength)return null;const h=n.getUint32(d,!0);d+=4;const u=n.getUint32(d,!0);d+=4;const x=n.getUint32(d,!0);d+=4;const g=n.getUint32(d,!0);d+=4;const y=d+g;if(y!==t.byteLength)return null;const b=lr.decode(t.subarray(d,y));return{topic:m,type:"pty_patch",baseSeq:h,seq:l,start:u,deleteCount:x,data:b}}return null}function Jp(e){if(!e)return[];if(Fp.encode(e).byteLength>Wp||e.length>dr*Up)return null;const t=[];for(let n=0;n<e.length;n+=dr)t.push(e.slice(n,n+dr));return t}const Xp=window.location.protocol==="https:"?"wss:":"ws:",Zp=`${Xp}//${window.location.host}/ws`,at=new Kp(Zp),Sr={totalUnread:0,bySession:{}},qo={notificationsEnabled:!1,systemNotificationsEnabled:!1,notificationSoundsEnabled:!0,notificationEventDefaults:{},notificationSoundMap:{default:co}},ci=c.createContext(null);function Mt(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ko(e){return typeof e!="number"||Number.isNaN(e)||!Number.isFinite(e)?0:Math.max(0,Math.floor(e))}function zo(e){if(!Mt(e))return Sr;const t=Mt(e.bySession)?e.bySession:{},n=Object.entries(t).reduce((r,[s,a])=>{const i=Ko(a);return i>0&&(r[s]=i),r},{});return{totalUnread:Ko(e.totalUnread),bySession:n}}function Qp(e){return e.type==="notification_counts_updated"&&Mt(e.data)}function Go(e,t){return Mt(e)?typeof e.status=="number"&&e.status===t:!1}function Yo(e){return typeof e=="string"?e:typeof e=="number"&&Number.isFinite(e)?new Date(e).toISOString():e instanceof Date?e.toISOString():null}function li(){return typeof window<"u"&&window.isSecureContext&&"serviceWorker"in navigator&&"PushManager"in window}function em(){return null}function tm(e){const t="=".repeat((4-e.length%4)%4),n=`${e}${t}`.replace(/-/g,"+").replace(/_/g,"/"),r=window.atob(n),s=new Uint8Array(new ArrayBuffer(r.length));for(let a=0;a<r.length;a+=1)s[a]=r.charCodeAt(a);return s.buffer}function Nr(e){if(!e)return null;const t=new Uint8Array(e);let n="";for(const r of t)n+=String.fromCharCode(r);return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function nm(e,t){var r;const n=(r=e.options)==null?void 0:r.applicationServerKey;return n?Nr(n)===t:!0}function rm(e){const t=Nr(e.getKey("p256dh")),n=Nr(e.getKey("auth"));return t&&n?{endpoint:e.endpoint,expirationTime:e.expirationTime??null,keys:{p256dh:t,auth:n}}:null}async function om(){if(!li())return null;try{const e=await navigator.serviceWorker.getRegistration();if(e)return Pn(e),e;const t=await navigator.serviceWorker.register(ii());return Pn(t),t}catch{return null}}function sm(e){if(!Mt(e)||typeof e.id!="number"||typeof e.sessionId!="string"||typeof e.title!="string"||typeof e.eventType!="string")return null;const t=Yo(e.createdAt);return t?{id:e.id,sessionId:e.sessionId,provider:typeof e.provider=="string"?e.provider:"unknown",eventType:e.eventType,sourceEventId:typeof e.sourceEventId=="number"?e.sourceEventId:null,title:e.title,body:typeof e.body=="string"?e.body:null,payload:Mt(e.payload)?e.payload:{},createdAt:t,readAt:Yo(e.readAt),readSource:typeof e.readSource=="string"?e.readSource:null}:null}function am({children:e}){const[t,n]=c.useState(Sr),[r,s]=c.useState(qo),[a,i]=c.useState(null),[l,d]=c.useState(!0),[f,m]=c.useState(null),p=c.useCallback(async()=>{try{const g=await ae.getNotificationCounts();n(zo(g.counts)),m(null)}catch(g){if(Go(g,404)){n(Sr),m(null);return}const y=g instanceof Error?g.message:"Failed to load notifications";m(y)}},[]),h=c.useCallback(async()=>{try{const g=await ae.getDaemonSettings(),y=g.settings.notificationSoundMap??{};s({notificationsEnabled:g.settings.notificationsEnabled??!1,systemNotificationsEnabled:g.settings.systemNotificationsEnabled??!1,notificationSoundsEnabled:g.settings.notificationSoundsEnabled??!0,notificationEventDefaults:g.settings.notificationEventDefaults??{},notificationSoundMap:{default:co,...y}})}catch(g){Go(g,404)&&s(qo)}},[]),u=c.useCallback(g=>{i(y=>y&&typeof g=="number"&&y.id!==g?y:null)},[]);c.useEffect(()=>{let g=!0;d(!0),Promise.all([p(),h()]).finally(()=>{g&&d(!1)});const y=at.subscribe("notifications",v=>{if(v.type==="notification_created"){const w=sm(v.data);w&&i(w);return}Qp(v)&&n(zo(v.data))}),b=at.onConnectionChange(v=>{v&&(p(),h())});return()=>{g=!1,y(),b()}},[p,h]),c.useEffect(()=>{if(!(r.notificationsEnabled&&r.systemNotificationsEnabled)||!li()||typeof window>"u"||typeof window.Notification>"u"||window.Notification.permission!=="granted")return;let g=!1;return(async()=>{try{const v=await(async()=>{const C=em();if(C)return C;try{const I=(await ae.getPushDeliveryStatus()).status.publicKey;if(typeof I=="string"&&I.trim()!=="")return I.trim()}catch{}return null})();if(!v||g)return;const w=await om();if(!(w&&!g))return;let E=await w.pushManager.getSubscription();if(E&&!nm(E,v)){const C=E.endpoint;await ae.deletePushSubscription(C).catch(()=>{}),await E.unsubscribe().catch(()=>{}),E=null}if(E||(E=await w.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:tm(v)})),!(E&&!g))return;const S=rm(E);if(!S)return;await ae.upsertPushSubscription(S)}catch{}})(),()=>{g=!0}},[r.notificationsEnabled,r.systemNotificationsEnabled]);const x=c.useMemo(()=>({counts:t,settings:r,lastCreatedNotification:a,loading:l,error:f,refresh:p,refreshSettings:h,clearLastCreatedNotification:u}),[t,r,a,l,f,p,h,u]);return o.jsx(ci.Provider,{value:x,children:e})}function rn(){const e=c.useContext(ci);if(!e)throw new Error("useNotifications must be used within a NotificationProvider");return e}const Ct=5,Jo="(max-width: 767px)";function Er(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function im(e,t){return Er(e)&&typeof e.status=="number"&&e.status===t}function cm(e){return e.type==="notification_created"}function lm(e){return!Er(e)||typeof e.id!="number"||typeof e.sessionId!="string"||typeof e.title!="string"||typeof e.eventType!="string"||typeof e.createdAt!="string"?null:{id:e.id,sessionId:e.sessionId,provider:typeof e.provider=="string"?e.provider:"unknown",eventType:e.eventType,sourceEventId:typeof e.sourceEventId=="number"?e.sourceEventId:null,title:e.title,body:typeof e.body=="string"?e.body:null,payload:Er(e.payload)?e.payload:{},createdAt:e.createdAt,readAt:typeof e.readAt=="string"?e.readAt:null,readSource:typeof e.readSource=="string"?e.readSource:null}}function bn(e){const t=new Set,n=[];for(const r of e)t.has(r.id)||(t.add(r.id),n.push(r));return n}function dm(e,t){const n=e.filter(r=>r.id!==t.id);return n.unshift(t),bn(n)}function um(){const[e,t]=c.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(Jo).matches);return c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia(Jo),r=s=>{t(s.matches)};return t(n.matches),typeof n.addEventListener=="function"?(n.addEventListener("change",r),()=>n.removeEventListener("change",r)):(n.addListener(r),()=>n.removeListener(r))},[]),e}function fm({open:e,onClose:t}){const n=gt(),r=um(),{refresh:s}=rn(),[a,i]=c.useState(!1),[l,d]=c.useState(!1),[f,m]=c.useState(null),[p,h]=c.useState(!1),[u,x]=c.useState([]),[g,y]=c.useState(!0),[b,v]=c.useState(!1),[w,E]=c.useState(void 0),S=c.useCallback(async()=>{var T;if(e){i(!0);try{const P=await ae.getNotifications({unreadOnly:p,limit:Ct+1}),R=bn(P.notifications),A=R.length>Ct,N=A?R.slice(0,Ct):R;x(N),v(A),E(N.length>0?(T=N[N.length-1])==null?void 0:T.id:void 0),y(!0),m(null),await s()}catch(P){if(im(P,404)){x([]),y(!1),v(!1),E(void 0),m(null);return}m(P instanceof Error?P.message:"Failed to load notifications")}finally{i(!1)}}},[e,p,s]),C=c.useCallback(async()=>{var T;if(!(!(e&&b&&w!==void 0)||a||l)){d(!0);try{const P=await ae.getNotifications({unreadOnly:p,before:w,limit:Ct+1}),R=bn(P.notifications),A=R.length>Ct,N=A?R.slice(0,Ct):R;if(N.length===0){v(!1);return}x(U=>bn([...U,...N])),E((T=N[N.length-1])==null?void 0:T.id),v(A),m(null)}catch(P){m(P instanceof Error?P.message:"Failed to load more notifications")}finally{d(!1)}}},[w,b,a,l,e,p]);c.useEffect(()=>{e&&S()},[e,S]),c.useEffect(()=>{if(!e)return;const T=at.subscribe("notifications",P=>{if(P.type==="notification_read"){S();return}if(cm(P)){const R=lm(P.data);if(!(R&&!(p&&R.readAt)))return;x(A=>dm(A,R));return}P.type==="notification_counts_updated"&&s()});return()=>{T()}},[e,p,S,s]);const k=c.useMemo(()=>u.reduce((T,P)=>T+(P.readAt?0:1),0),[u]),I=c.useCallback(async T=>{if(!T.readAt)try{await ae.markNotificationRead(T.id,"click")}catch{}x(P=>P.map(R=>R.id===T.id?{...R,readAt:R.readAt??new Date().toISOString(),readSource:"click"}:R)),s(),n(`/sessions/${T.sessionId}/terminal`),t()},[n,t,s]),W=c.useCallback(async()=>{try{if((await ae.markNotificationsRead({readSource:"bulk"})).updated>0){const P=new Date().toISOString();x(R=>R.map(A=>A.readAt?A:{...A,readAt:P,readSource:"bulk"}))}s()}catch(T){m(T instanceof Error?T.message:"Failed to mark notifications as read")}},[s]);if(!e)return null;const B=o.jsx(o.Fragment,{children:o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[o.jsxs("div",{className:"bg-gradient-to-b from-cyan-500/10 via-cyan-500/[0.02] to-transparent",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-border/80 px-3 py-2.5",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(fs,{className:"h-4 w-4 text-cyan-400"}),o.jsx("h3",{className:"text-sm font-semibold",children:"Notifications"}),k>0&&o.jsx("span",{className:"rounded-full bg-amber-500 px-1.5 py-0.5 text-[10px] font-semibold text-amber-950",children:k>99?"99+":k})]}),o.jsxs("button",{type:"button",onClick:()=>void W(),className:"inline-flex items-center gap-1 rounded-md border border-border/70 bg-background/95 px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-accent/85 hover:text-foreground disabled:opacity-40",disabled:a||l||u.length===0||k===0,children:[o.jsx(Xc,{className:"h-3.5 w-3.5"}),"Mark all read"]})]}),o.jsx("div",{className:"border-b border-border/70 px-3 py-2.5",children:o.jsxs("div",{className:"grid grid-cols-2 items-center gap-1 rounded-lg bg-muted/25 p-1",children:[o.jsx("button",{type:"button",onClick:()=>h(!1),className:`rounded-md px-2 py-1.5 text-xs font-medium transition-colors ${p?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)]"}`,children:"All"}),o.jsx("button",{type:"button",onClick:()=>h(!0),className:`rounded-md px-2 py-1.5 text-xs font-medium transition-colors ${p?"bg-background text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)]":"text-muted-foreground hover:text-foreground"}`,children:"Unread"})]})})]}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2.5 pb-[calc(env(safe-area-inset-bottom)+0.75rem)] md:pb-2.5",children:a?o.jsxs("div",{className:"flex items-center justify-center gap-2 px-3 py-8 text-sm text-muted-foreground",children:[o.jsx(Or,{className:"h-4 w-4 animate-spin"}),o.jsx("span",{children:"Loading notifications..."})]}):g?f?o.jsx("div",{className:"px-3 py-6 text-sm text-red-400",children:f}):u.length===0?o.jsx("div",{className:"px-3 py-8 text-sm text-muted-foreground",children:p?"No unread notifications.":"No notifications yet."}):o.jsxs("ul",{className:"space-y-2",children:[u.map(T=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>void I(T),className:`w-full rounded-xl border px-3 py-2.5 text-left transition-colors ${T.readAt?"border-border/65 bg-background/98 hover:bg-accent/60":"border-cyan-500/35 bg-gradient-to-r from-cyan-500/14 via-cyan-500/[0.05] to-background/95 hover:from-cyan-500/20"}`,children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm font-semibold text-foreground",children:wr(T)}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px]",children:[o.jsx("span",{className:"rounded-full border border-border/70 bg-muted/20 px-1.5 py-0.5 text-muted-foreground",children:ao(T.eventType)}),o.jsx("span",{className:"rounded-full border border-border/70 bg-muted/20 px-1.5 py-0.5 text-muted-foreground",children:ai(T.provider)})]})]}),o.jsx("span",{className:"text-[10px] text-muted-foreground",children:jn(T.createdAt)})]}),o.jsx("p",{className:"mt-1 text-xs leading-snug text-foreground/80",children:vr(T)}),o.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-[10px] text-muted-foreground",children:[o.jsx("span",{className:"rounded-md bg-muted/25 px-1.5 py-0.5 font-mono",children:Pp(T)}),!T.readAt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-border",children:"•"}),o.jsx("span",{className:"text-cyan-400",children:"Unread"})]})]})]})},T.id)),(b||l)&&o.jsx("li",{className:"pt-1 pb-2 text-center",children:o.jsx("button",{type:"button",onClick:()=>void C(),disabled:l,className:"text-xs font-medium text-cyan-400 hover:text-cyan-300 underline underline-offset-4 disabled:opacity-45 disabled:no-underline",children:l?"Loading...":"Load more"})})]}):o.jsx("div",{className:"px-3 py-6 text-sm text-muted-foreground",children:"Notification inbox is not supported by the connected daemon version."})})]})}),H=r&&typeof document<"u",j=H?"fixed inset-0 z-[260] cursor-default bg-background/60 backdrop-blur-[2.5px]":"fixed inset-0 z-[90] hidden cursor-default bg-background/60 backdrop-blur-[2.5px] md:block md:bg-transparent md:backdrop-blur-0",D=H?"notification-inbox-surface fixed inset-x-2 top-[calc(env(safe-area-inset-top)+3.25rem)] bottom-[calc(env(safe-area-inset-bottom)+5.2rem)] z-[270] flex min-h-0 flex-col overflow-hidden rounded-2xl border border-border/80 text-popover-foreground shadow-[0_26px_60px_rgba(0,0,0,0.34)]":"notification-inbox-surface relative z-[120] hidden min-h-0 flex-col overflow-hidden rounded-xl border border-border text-popover-foreground shadow-[0_20px_48px_rgba(0,0,0,0.45)] md:absolute md:inset-x-auto md:right-0 md:top-[calc(100%+0.5rem)] md:flex md:w-[24rem] md:max-h-[70vh]",L=o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button","aria-label":"Close notification inbox",className:j,onClick:t}),o.jsx("section",{role:"dialog","aria-modal":"true","aria-label":"Notification inbox",className:D,children:B})]});return r&&typeof document>"u"?null:H?Ot.createPortal(L,document.body):L}function pm(e){if(!(e&&typeof e=="object"))return!1;const t=e;return typeof t.id=="string"&&typeof t.provider=="string"&&typeof t.cwd=="string"&&typeof t.status=="string"&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"}function mm(e){if(!(e&&typeof e=="object"))return!1;const t=e,n=t.type;return n==="session_deleted"?typeof t.sessionId=="string":n==="session_created"||n==="session_updated"?pm(t.session):!1}function on(){const[e,t]=c.useState([]),[n,r]=c.useState(!0),[s,a]=c.useState(null),i=c.useCallback(async()=>{try{const d=await ae.getSessions();t(d.sessions)}catch{}},[]),l=c.useCallback((d,f)=>{t(m=>m.map(p=>p.id===d?{...p,status:f}:p))},[]);return c.useEffect(()=>{let d=!0;(async()=>{try{r(!0),a(null);const p=await ae.getSessions();d&&t(p.sessions)}catch(p){d&&a(p instanceof Error?p.message:"Failed to fetch sessions")}finally{d&&r(!1)}})();const m=at.subscribe("sessions",p=>{mm(p)&&(p.type==="session_created"?t(h=>[...h,p.session]):p.type==="session_updated"?t(h=>h.map(u=>u.id===p.session.id?p.session:u)):p.type==="session_deleted"&&t(h=>h.filter(u=>u.id!==p.sessionId)))});return()=>{d=!1,m()}},[]),{sessions:e,loading:n,error:s,refresh:i,updateSessionStatus:l}}function Xo(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function hm(e){const t=e.trim();return t.length>0?t:null}function di(e){if(!Xo(e.metadata))return null;const t=e.metadata.ui;return!Xo(t)||typeof t.customName!="string"?null:hm(t.customName)}function ui(e){const t=e.replace(/[\\/]+$/,"");if(!t)return e||"session";const n=t.split(/[\\/]/).filter(Boolean);return n[n.length-1]??t}function sn(e){const t=new Map,n=new Map,r=[...e].sort((s,a)=>{const i=new Date(s.createdAt).getTime()-new Date(a.createdAt).getTime();return i!==0?i:s.id.localeCompare(a.id)});for(const s of r){const a=di(s);if(a){t.set(s.id,a);continue}const i=ui(s.cwd),l=n.get(i);l?l.push(s.id):n.set(i,[s.id])}for(const[s,a]of n){if(a.length===1){t.set(a[0],s);continue}a.forEach((i,l)=>{t.set(i,`${s} [${l+1}]`)})}return t}function Rt(e,t){return(t==null?void 0:t.get(e.id))??di(e)??ui(e.cwd)}function gm(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function xm(e){const t=e.match(/^\/sessions\/([^/]+)(?:\/([^/]+))?$/);if(!t)return null;const n=t[1],r=t[2];return r&&r!=="terminal"?null:n}function ym(){return typeof window<"u"&&window.isSecureContext&&typeof window.Notification<"u"&&window.Notification.permission==="granted"}function bm(e){return`/sessions/${encodeURIComponent(e)}/terminal`}const vm=45e3;function wm(e){return e==="session.turn_completed"?{badge:"border border-emerald-500/25 bg-emerald-500/14 text-emerald-800 dark:text-emerald-300",button:"border border-emerald-500/55 bg-emerald-600 text-white hover:bg-emerald-500 dark:bg-emerald-500 dark:text-emerald-950 dark:hover:bg-emerald-400",border:"border-emerald-500/28"}:e==="session.permission_required"?{badge:"border border-amber-500/25 bg-amber-500/14 text-amber-800 dark:text-amber-300",button:"border border-amber-500/55 bg-amber-600 text-white hover:bg-amber-500 dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400",border:"border-amber-500/32"}:{badge:"border border-cyan-500/25 bg-cyan-500/12 text-cyan-800 dark:text-cyan-300",button:"border border-cyan-500/55 bg-cyan-600 text-white hover:bg-cyan-500 dark:bg-cyan-500 dark:text-cyan-950 dark:hover:bg-cyan-400",border:"border-cyan-500/28"}}function Sm(){const{logout:e}=Mn(),{theme:t}=so(),n=gt(),r=In(),{sessions:s}=on(),{counts:a,settings:i,lastCreatedNotification:l,clearLastCreatedNotification:d}=rn(),[f,m]=c.useState(!1),[p,h]=c.useState(!1),[u,x]=c.useState(!1),[g,y]=c.useState(null),b=c.useRef(null),v=c.useRef(Date.now()),w=c.useMemo(()=>xm(r.pathname),[r.pathname]),E=c.useMemo(()=>sn(s),[s]);c.useEffect(()=>(m(at.isConnected()),at.onConnectionChange(j=>{m(j)})),[]),c.useEffect(()=>{if(!p)return;const j=D=>{D.key==="Escape"&&h(!1)};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[p]),c.useEffect(()=>{const j=()=>{v.current=Date.now()},D={passive:!0};return window.addEventListener("pointerdown",j,D),window.addEventListener("keydown",j),window.addEventListener("touchstart",j,D),window.addEventListener("focus",j),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("pointerdown",j),window.removeEventListener("keydown",j),window.removeEventListener("touchstart",j),window.removeEventListener("focus",j),document.removeEventListener("visibilitychange",j)}},[]);const S=c.useCallback(async j=>{if(!i.notificationSoundsEnabled)return;const D=Tp(i.notificationSoundMap,j);if(D)try{const L=new Audio(D);L.volume=.55,await L.play();return}catch{}try{const L=window.AudioContext||window.webkitAudioContext;if(!L)return;b.current||(b.current=new L);const T=b.current;T.state==="suspended"&&await T.resume().catch(()=>{});const P=T.createOscillator(),R=T.createGain();P.type="sine",P.frequency.value=880,R.gain.value=1e-4,P.connect(R),R.connect(T.destination);const A=T.currentTime;R.gain.exponentialRampToValueAtTime(.035,A+.01),R.gain.exponentialRampToValueAtTime(1e-4,A+.16),P.start(A),P.stop(A+.18)}catch{}},[i.notificationSoundsEnabled,i.notificationSoundMap]),C=c.useCallback(async(j,D,L)=>{if(!(i.systemNotificationsEnabled&&ym()))return!1;const T=vr(j,L),P=wr(j,L),R=`codepiper:notification:${j.id}`,A={url:D,sessionId:j.sessionId,notificationId:j.id};try{if("serviceWorker"in navigator){const U=await navigator.serviceWorker.getRegistration();if(U)return await U.showNotification(P,{body:T,tag:R,icon:"/apple-touch-icon.png",badge:"/logo.svg",data:A}),!0}const N=new window.Notification(P,{body:T,tag:R,icon:"/apple-touch-icon.png",data:A});return N.onclick=()=>{typeof window.focus=="function"&&window.focus(),ae.markNotificationRead(j.id,"click"),n(D),N.close()},!0}catch{return!1}},[n,i.systemNotificationsEnabled]);c.useEffect(()=>{if(!g)return;const j=setTimeout(()=>{y(D=>(D==null?void 0:D.id)===g.id?null:D)},6500);return()=>{clearTimeout(j)}},[g]),c.useEffect(()=>{if(!l)return;if(i.notificationEventDefaults[l.eventType]===!1){d(l.id);return}const D=typeof document<"u"?document.visibilityState==="visible":!1,L=w===l.sessionId&&D,T=Date.now()-v.current>=vm;if(L&&!T){ae.markNotificationRead(l.id,"active").catch(()=>{}),d(l.id);return}const P=bm(l.sessionId),R=E.get(l.sessionId)??null,A=D;let N=null,U=!1;return(async()=>{var V;await C(l,P,R),!U&&(A&&(gm()||(x(!0),N=setTimeout(()=>x(!1),700),typeof navigator<"u"&&"vibrate"in navigator&&((V=navigator.vibrate)==null||V.call(navigator,20))),y({id:l.id,eventType:l.eventType,eventLabel:ao(l.eventType),providerLabel:ai(l.provider),title:wr(l,R),description:vr(l,R),targetPath:P}),S(l.eventType)),d(l.id))})(),()=>{U=!0,N&&clearTimeout(N)}},[d,l,S,C,w,i.notificationEventDefaults,E]);const k=t.mode==="dark"?"bg-background/60 backdrop-blur-xl":"bg-background/92 backdrop-blur-md",I=g?wm(g.eventType):null,W=c.useCallback(()=>{g&&(ae.markNotificationRead(g.id,"click"),n(g.targetPath),y(null))},[g,n]),B=c.useCallback(()=>{y(null)},[]),H=g&&I&&typeof document<"u"?Ot.createPortal(o.jsx("div",{className:"pointer-events-none fixed z-[500] right-[max(0.5rem,calc(env(safe-area-inset-right,0px)+0.35rem))] top-[max(0.5rem,calc(env(safe-area-inset-top,0px)+0.35rem))] w-[min(21.5rem,calc(100vw-1rem))]",children:o.jsxs("article",{className:$("pointer-events-auto animate-in rounded-2xl border p-3 shadow-[0_18px_36px_rgba(2,8,23,0.34)]",t.mode==="dark"?"bg-card/96 text-card-foreground backdrop-blur-md":"bg-popover/98 text-popover-foreground",I.border),"aria-live":"polite",children:[o.jsxs("div",{className:"mb-2 flex items-start justify-between gap-2",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"truncate text-[0.93rem] font-semibold leading-5",children:g.title}),o.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[o.jsx("span",{className:$("inline-flex rounded-full px-2 py-0.5 text-[10px] font-semibold",I.badge),children:g.eventLabel}),o.jsx("span",{className:"inline-flex rounded-full border border-border/60 bg-muted/35 px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:g.providerLabel})]})]}),o.jsx("button",{type:"button",onClick:B,className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground","aria-label":"Dismiss notification",children:o.jsx(Rl,{className:"h-3.5 w-3.5"})})]}),o.jsx("p",{className:"line-clamp-3 text-[0.79rem] leading-5 text-muted-foreground",children:g.description}),o.jsx("div",{className:"mt-3 flex justify-end",children:o.jsx("button",{type:"button",onClick:W,className:$("h-8 rounded-full px-4 text-[0.75rem] font-semibold tracking-[0.01em] transition-colors",I.button),children:"Open session"})})]})}),document.body):null;return o.jsxs(o.Fragment,{children:[o.jsx("header",{className:$("relative z-[80] border-b border-border pt-safe",k),children:o.jsxs("div",{className:"flex h-12 items-center justify-between px-4 md:px-6",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsxs("a",{href:"/",className:"md:hidden flex items-center gap-2",children:[o.jsx("img",{src:"/piper.svg",alt:"CodePiper",className:"h-7 w-7"}),o.jsx("span",{className:"text-sm font-semibold tracking-wide",children:"CodePiper"})]}),o.jsx("div",{className:$("hidden md:flex items-center gap-2 px-2.5 py-1 rounded-full text-[11px] font-medium transition-all",f?"bg-emerald-500/[0.1] text-emerald-700 border border-emerald-500/30 dark:bg-emerald-500/[0.08] dark:text-emerald-400 dark:border-emerald-500/20":"bg-red-500/[0.1] text-red-700 border border-red-500/30 dark:bg-red-500/[0.08] dark:text-red-400 dark:border-red-500/20"),children:f?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"relative",children:[o.jsx(Tl,{className:"h-3 w-3"}),o.jsx("div",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 rounded-full bg-emerald-400 pulse-live"})]}),o.jsx("span",{children:"Connected"})]}):o.jsxs(o.Fragment,{children:[o.jsx(jl,{className:"h-3 w-3"}),o.jsx("span",{children:"Disconnected"})]})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"md:hidden",children:o.jsx("div",{className:$("w-2 h-2 rounded-full",f?"bg-emerald-500 dark:bg-emerald-400 shadow-[0_0_6px_rgba(16,185,129,0.5)]":"bg-red-500 dark:bg-red-400 shadow-[0_0_6px_rgba(248,113,113,0.5)]")})}),o.jsxs("div",{className:"relative",children:[o.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":p,onClick:()=>h(j=>!j),className:"relative h-8 w-8 rounded-lg flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200",title:a.totalUnread>0?`${a.totalUnread} unread notification${a.totalUnread===1?"":"s"}`:"No unread notifications",children:[o.jsx(fs,{className:$("h-4 w-4",u&&"bell-wiggle")}),a.totalUnread>0&&o.jsx("span",{className:"absolute -top-1 -right-1 min-w-[16px] h-[16px] rounded-full bg-amber-500 text-[9px] font-bold text-amber-950 flex items-center justify-center px-1 leading-none shadow-[0_0_8px_rgba(245,158,11,0.45)] pulse-live",children:a.totalUnread>99?"99+":a.totalUnread})]}),o.jsx(fm,{open:p,onClose:()=>h(!1)})]}),o.jsx(Np,{}),o.jsx("button",{type:"button",onClick:e,className:"h-8 w-8 rounded-lg flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200",title:"Sign out",children:o.jsx(gl,{className:"h-4 w-4"})})]})]})}),H]})}var Nm=e=>{switch(e){case"success":return km;case"info":return Pm;case"warning":return jm;case"error":return Tm;default:return null}},Em=Array(12).fill(0),Cm=({visible:e,className:t})=>_.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},_.createElement("div",{className:"sonner-spinner"},Em.map((n,r)=>_.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),km=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),jm=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},_.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Pm=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Tm=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),_m=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},_.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),_.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Rm=()=>{let[e,t]=_.useState(document.hidden);return _.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},Cr=1,Am=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,s=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:Cr++,a=this.toasts.find(l=>l.id===s),i=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),a?this.toasts=this.toasts.map(l=>l.id===s?(this.publish({...l,...e,id:s,title:n}),{...l,...e,id:s,dismissible:i,title:n}):l):this.addToast({title:n,...r,dismissible:i,id:s}),s},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=e instanceof Promise?e:e(),s=n!==void 0,a,i=r.then(async d=>{if(a=["resolve",d],_.isValidElement(d))s=!1,this.create({id:n,type:"default",message:d});else if(Mm(d)&&!d.ok){s=!1;let f=typeof t.error=="function"?await t.error(`HTTP error! status: ${d.status}`):t.error,m=typeof t.description=="function"?await t.description(`HTTP error! status: ${d.status}`):t.description;this.create({id:n,type:"error",message:f,description:m})}else if(t.success!==void 0){s=!1;let f=typeof t.success=="function"?await t.success(d):t.success,m=typeof t.description=="function"?await t.description(d):t.description;this.create({id:n,type:"success",message:f,description:m})}}).catch(async d=>{if(a=["reject",d],t.error!==void 0){s=!1;let f=typeof t.error=="function"?await t.error(d):t.error,m=typeof t.description=="function"?await t.description(d):t.description;this.create({id:n,type:"error",message:f,description:m})}}).finally(()=>{var d;s&&(this.dismiss(n),n=void 0),(d=t.finally)==null||d.call(t)}),l=()=>new Promise((d,f)=>i.then(()=>a[0]==="reject"?f(a[1]):d(a[1])).catch(f));return typeof n!="string"&&typeof n!="number"?{unwrap:l}:Object.assign(n,{unwrap:l})},this.custom=(e,t)=>{let n=(t==null?void 0:t.id)||Cr++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},be=new Am,Im=(e,t)=>{let n=(t==null?void 0:t.id)||Cr++;return be.addToast({title:e,...t,id:n}),n},Mm=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",Om=Im,Dm=()=>be.toasts,Lm=()=>be.getActiveToasts(),ve=Object.assign(Om,{success:be.success,info:be.info,warning:be.warning,error:be.error,custom:be.custom,message:be.message,promise:be.promise,dismiss:be.dismiss,loading:be.loading},{getHistory:Dm,getToasts:Lm});function $m(e,{insertAt:t}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}$m(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
199
+ `);function hn(e){return e.label!==void 0}var Fm=3,Bm="32px",Um="16px",Zo=4e3,Wm=356,Hm=14,Vm=20,qm=200;function Ie(...e){return e.filter(Boolean).join(" ")}function Km(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var zm=e=>{var t,n,r,s,a,i,l,d,f,m,p;let{invert:h,toast:u,unstyled:x,interacting:g,setHeights:y,visibleToasts:b,heights:v,index:w,toasts:E,expanded:S,removeToast:C,defaultRichColors:k,closeButton:I,style:W,cancelButtonStyle:B,actionButtonStyle:H,className:j="",descriptionClassName:D="",duration:L,position:T,gap:P,loadingIcon:R,expandByDefault:A,classNames:N,icons:U,closeButtonAriaLabel:te="Close toast",pauseWhenPageIsHidden:V}=e,[z,G]=_.useState(null),[ne,ie]=_.useState(null),[M,Z]=_.useState(!1),[X,J]=_.useState(!1),[q,Y]=_.useState(!1),[ce,de]=_.useState(!1),[$e,Pe]=_.useState(!1),[we,Te]=_.useState(0),[Se,dt]=_.useState(0),ke=_.useRef(u.duration||L||Zo),ue=_.useRef(null),pe=_.useRef(null),an=w===0,cn=w+1<=b,ge=u.type,Ze=u.dismissible!==!1,Zn=u.className||"",ln=u.descriptionClassName||"",wt=_.useMemo(()=>v.findIndex(K=>K.toastId===u.id)||0,[v,u.id]),Qn=_.useMemo(()=>{var K;return(K=u.closeButton)!=null?K:I},[u.closeButton,I]),dn=_.useMemo(()=>u.duration||L||Zo,[u.duration,L]),St=_.useRef(0),qe=_.useRef(0),Ft=_.useRef(0),Ke=_.useRef(null),[O,fe]=T.split("-"),xe=_.useMemo(()=>v.reduce((K,re,se)=>se>=wt?K:K+re.height,0),[v,wt]),ye=Rm(),Nt=u.invert||h,Qe=ge==="loading";qe.current=_.useMemo(()=>wt*P+xe,[wt,xe]),_.useEffect(()=>{ke.current=dn},[dn]),_.useEffect(()=>{Z(!0)},[]),_.useEffect(()=>{let K=pe.current;if(K){let re=K.getBoundingClientRect().height;return dt(re),y(se=>[{toastId:u.id,height:re,position:u.position},...se]),()=>y(se=>se.filter(_e=>_e.toastId!==u.id))}},[y,u.id]),_.useLayoutEffect(()=>{if(!M)return;let K=pe.current,re=K.style.height;K.style.height="auto";let se=K.getBoundingClientRect().height;K.style.height=re,dt(se),y(_e=>_e.find(Re=>Re.toastId===u.id)?_e.map(Re=>Re.toastId===u.id?{...Re,height:se}:Re):[{toastId:u.id,height:se,position:u.position},..._e])},[M,u.title,u.description,y,u.id]);let Fe=_.useCallback(()=>{J(!0),Te(qe.current),y(K=>K.filter(re=>re.toastId!==u.id)),setTimeout(()=>{C(u)},qm)},[u,C,y,qe]);_.useEffect(()=>{if(u.promise&&ge==="loading"||u.duration===1/0||u.type==="loading")return;let K;return S||g||V&&ye?(()=>{if(Ft.current<St.current){let re=new Date().getTime()-St.current;ke.current=ke.current-re}Ft.current=new Date().getTime()})():ke.current!==1/0&&(St.current=new Date().getTime(),K=setTimeout(()=>{var re;(re=u.onAutoClose)==null||re.call(u,u),Fe()},ke.current)),()=>clearTimeout(K)},[S,g,u,ge,V,ye,Fe]),_.useEffect(()=>{u.delete&&Fe()},[Fe,u.delete]);function Sc(){var K,re,se;return U!=null&&U.loading?_.createElement("div",{className:Ie(N==null?void 0:N.loader,(K=u==null?void 0:u.classNames)==null?void 0:K.loader,"sonner-loader"),"data-visible":ge==="loading"},U.loading):R?_.createElement("div",{className:Ie(N==null?void 0:N.loader,(re=u==null?void 0:u.classNames)==null?void 0:re.loader,"sonner-loader"),"data-visible":ge==="loading"},R):_.createElement(Cm,{className:Ie(N==null?void 0:N.loader,(se=u==null?void 0:u.classNames)==null?void 0:se.loader),visible:ge==="loading"})}return _.createElement("li",{tabIndex:0,ref:pe,className:Ie(j,Zn,N==null?void 0:N.toast,(t=u==null?void 0:u.classNames)==null?void 0:t.toast,N==null?void 0:N.default,N==null?void 0:N[ge],(n=u==null?void 0:u.classNames)==null?void 0:n[ge]),"data-sonner-toast":"","data-rich-colors":(r=u.richColors)!=null?r:k,"data-styled":!(u.jsx||u.unstyled||x),"data-mounted":M,"data-promise":!!u.promise,"data-swiped":$e,"data-removed":X,"data-visible":cn,"data-y-position":O,"data-x-position":fe,"data-index":w,"data-front":an,"data-swiping":q,"data-dismissible":Ze,"data-type":ge,"data-invert":Nt,"data-swipe-out":ce,"data-swipe-direction":ne,"data-expanded":!!(S||A&&M),style:{"--index":w,"--toasts-before":w,"--z-index":E.length-w,"--offset":`${X?we:qe.current}px`,"--initial-height":A?"auto":`${Se}px`,...W,...u.style},onDragEnd:()=>{Y(!1),G(null),Ke.current=null},onPointerDown:K=>{Qe||!Ze||(ue.current=new Date,Te(qe.current),K.target.setPointerCapture(K.pointerId),K.target.tagName!=="BUTTON"&&(Y(!0),Ke.current={x:K.clientX,y:K.clientY}))},onPointerUp:()=>{var K,re,se,_e;if(ce||!Ze)return;Ke.current=null;let Re=Number(((K=pe.current)==null?void 0:K.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),et=Number(((re=pe.current)==null?void 0:re.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ut=new Date().getTime()-((se=ue.current)==null?void 0:se.getTime()),Ae=z==="x"?Re:et,tt=Math.abs(Ae)/ut;if(Math.abs(Ae)>=Vm||tt>.11){Te(qe.current),(_e=u.onDismiss)==null||_e.call(u,u),ie(z==="x"?Re>0?"right":"left":et>0?"down":"up"),Fe(),de(!0),Pe(!1);return}Y(!1),G(null)},onPointerMove:K=>{var re,se,_e,Re;if(!Ke.current||!Ze||((re=window.getSelection())==null?void 0:re.toString().length)>0)return;let et=K.clientY-Ke.current.y,ut=K.clientX-Ke.current.x,Ae=(se=e.swipeDirections)!=null?se:Km(T);!z&&(Math.abs(ut)>1||Math.abs(et)>1)&&G(Math.abs(ut)>Math.abs(et)?"x":"y");let tt={x:0,y:0};z==="y"?(Ae.includes("top")||Ae.includes("bottom"))&&(Ae.includes("top")&&et<0||Ae.includes("bottom")&&et>0)&&(tt.y=et):z==="x"&&(Ae.includes("left")||Ae.includes("right"))&&(Ae.includes("left")&&ut<0||Ae.includes("right")&&ut>0)&&(tt.x=ut),(Math.abs(tt.x)>0||Math.abs(tt.y)>0)&&Pe(!0),(_e=pe.current)==null||_e.style.setProperty("--swipe-amount-x",`${tt.x}px`),(Re=pe.current)==null||Re.style.setProperty("--swipe-amount-y",`${tt.y}px`)}},Qn&&!u.jsx?_.createElement("button",{"aria-label":te,"data-disabled":Qe,"data-close-button":!0,onClick:Qe||!Ze?()=>{}:()=>{var K;Fe(),(K=u.onDismiss)==null||K.call(u,u)},className:Ie(N==null?void 0:N.closeButton,(s=u==null?void 0:u.classNames)==null?void 0:s.closeButton)},(a=U==null?void 0:U.close)!=null?a:_m):null,u.jsx||c.isValidElement(u.title)?u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title:_.createElement(_.Fragment,null,ge||u.icon||u.promise?_.createElement("div",{"data-icon":"",className:Ie(N==null?void 0:N.icon,(i=u==null?void 0:u.classNames)==null?void 0:i.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||Sc():null,u.type!=="loading"?u.icon||(U==null?void 0:U[ge])||Nm(ge):null):null,_.createElement("div",{"data-content":"",className:Ie(N==null?void 0:N.content,(l=u==null?void 0:u.classNames)==null?void 0:l.content)},_.createElement("div",{"data-title":"",className:Ie(N==null?void 0:N.title,(d=u==null?void 0:u.classNames)==null?void 0:d.title)},typeof u.title=="function"?u.title():u.title),u.description?_.createElement("div",{"data-description":"",className:Ie(D,ln,N==null?void 0:N.description,(f=u==null?void 0:u.classNames)==null?void 0:f.description)},typeof u.description=="function"?u.description():u.description):null),c.isValidElement(u.cancel)?u.cancel:u.cancel&&hn(u.cancel)?_.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||B,onClick:K=>{var re,se;hn(u.cancel)&&Ze&&((se=(re=u.cancel).onClick)==null||se.call(re,K),Fe())},className:Ie(N==null?void 0:N.cancelButton,(m=u==null?void 0:u.classNames)==null?void 0:m.cancelButton)},u.cancel.label):null,c.isValidElement(u.action)?u.action:u.action&&hn(u.action)?_.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||H,onClick:K=>{var re,se;hn(u.action)&&((se=(re=u.action).onClick)==null||se.call(re,K),!K.defaultPrevented&&Fe())},className:Ie(N==null?void 0:N.actionButton,(p=u==null?void 0:u.classNames)==null?void 0:p.actionButton)},u.action.label):null))};function Qo(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function Gm(e,t){let n={};return[e,t].forEach((r,s)=>{let a=s===1,i=a?"--mobile-offset":"--offset",l=a?Um:Bm;function d(f){["top","right","bottom","left"].forEach(m=>{n[`${i}-${m}`]=typeof f=="number"?`${f}px`:f})}typeof r=="number"||typeof r=="string"?d(r):typeof r=="object"?["top","right","bottom","left"].forEach(f=>{r[f]===void 0?n[`${i}-${f}`]=l:n[`${i}-${f}`]=typeof r[f]=="number"?`${r[f]}px`:r[f]}):d(l)}),n}var Ym=c.forwardRef(function(e,t){let{invert:n,position:r="bottom-right",hotkey:s=["altKey","KeyT"],expand:a,closeButton:i,className:l,offset:d,mobileOffset:f,theme:m="light",richColors:p,duration:h,style:u,visibleToasts:x=Fm,toastOptions:g,dir:y=Qo(),gap:b=Hm,loadingIcon:v,icons:w,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:S}=e,[C,k]=_.useState([]),I=_.useMemo(()=>Array.from(new Set([r].concat(C.filter(V=>V.position).map(V=>V.position)))),[C,r]),[W,B]=_.useState([]),[H,j]=_.useState(!1),[D,L]=_.useState(!1),[T,P]=_.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),R=_.useRef(null),A=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),N=_.useRef(null),U=_.useRef(!1),te=_.useCallback(V=>{k(z=>{var G;return(G=z.find(ne=>ne.id===V.id))!=null&&G.delete||be.dismiss(V.id),z.filter(({id:ne})=>ne!==V.id)})},[]);return _.useEffect(()=>be.subscribe(V=>{if(V.dismiss){k(z=>z.map(G=>G.id===V.id?{...G,delete:!0}:G));return}setTimeout(()=>{ls.flushSync(()=>{k(z=>{let G=z.findIndex(ne=>ne.id===V.id);return G!==-1?[...z.slice(0,G),{...z[G],...V},...z.slice(G+1)]:[V,...z]})})})}),[]),_.useEffect(()=>{if(m!=="system"){P(m);return}if(m==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?P("dark"):P("light")),typeof window>"u")return;let V=window.matchMedia("(prefers-color-scheme: dark)");try{V.addEventListener("change",({matches:z})=>{P(z?"dark":"light")})}catch{V.addListener(({matches:G})=>{try{P(G?"dark":"light")}catch(ne){console.error(ne)}})}},[m]),_.useEffect(()=>{C.length<=1&&j(!1)},[C]),_.useEffect(()=>{let V=z=>{var G,ne;s.every(ie=>z[ie]||z.code===ie)&&(j(!0),(G=R.current)==null||G.focus()),z.code==="Escape"&&(document.activeElement===R.current||(ne=R.current)!=null&&ne.contains(document.activeElement))&&j(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[s]),_.useEffect(()=>{if(R.current)return()=>{N.current&&(N.current.focus({preventScroll:!0}),N.current=null,U.current=!1)}},[R.current]),_.createElement("section",{ref:t,"aria-label":`${E} ${A}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},I.map((V,z)=>{var G;let[ne,ie]=V.split("-");return C.length?_.createElement("ol",{key:V,dir:y==="auto"?Qo():y,tabIndex:-1,ref:R,className:l,"data-sonner-toaster":!0,"data-theme":T,"data-y-position":ne,"data-lifted":H&&C.length>1&&!a,"data-x-position":ie,style:{"--front-toast-height":`${((G=W[0])==null?void 0:G.height)||0}px`,"--width":`${Wm}px`,"--gap":`${b}px`,...u,...Gm(d,f)},onBlur:M=>{U.current&&!M.currentTarget.contains(M.relatedTarget)&&(U.current=!1,N.current&&(N.current.focus({preventScroll:!0}),N.current=null))},onFocus:M=>{M.target instanceof HTMLElement&&M.target.dataset.dismissible==="false"||U.current||(U.current=!0,N.current=M.relatedTarget)},onMouseEnter:()=>j(!0),onMouseMove:()=>j(!0),onMouseLeave:()=>{D||j(!1)},onDragEnd:()=>j(!1),onPointerDown:M=>{M.target instanceof HTMLElement&&M.target.dataset.dismissible==="false"||L(!0)},onPointerUp:()=>L(!1)},C.filter(M=>!M.position&&z===0||M.position===V).map((M,Z)=>{var X,J;return _.createElement(zm,{key:M.id,icons:w,index:Z,toast:M,defaultRichColors:p,duration:(X=g==null?void 0:g.duration)!=null?X:h,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:n,visibleToasts:x,closeButton:(J=g==null?void 0:g.closeButton)!=null?J:i,interacting:D,position:V,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:te,toasts:C.filter(q=>q.position==M.position),heights:W.filter(q=>q.position==M.position),setHeights:B,expandByDefault:a,gap:b,loadingIcon:v,expanded:H,pauseWhenPageIsHidden:S,swipeDirections:e.swipeDirections})})):null}))});const Jm=["terminal","git","policies","logs","events"],Xm=["terminal","git","policies"],Zm={nativeHooks:!1,supportsDangerousMode:!1,supportsModelSwitch:!1,supportsTranscriptTailing:!1,supportsTmuxAdoption:!1,policyChannel:"none",metricsChannel:"none"},kr=[{id:"claude-code",label:"Claude Code",runtime:"tmux",capabilities:{nativeHooks:!0,supportsDangerousMode:!0,supportsModelSwitch:!0,supportsTranscriptTailing:!0,supportsTmuxAdoption:!0,policyChannel:"native-hooks",metricsChannel:"transcript"},launchHints:{dangerousModeFlags:["--dangerously-skip-permissions"],resumeCommands:{resume:"claude --resume {id}",fork:"claude --resume {id} --fork-session",idPlaceholder:"claude session id"}}},{id:"codex",label:"Codex",runtime:"tmux",capabilities:{nativeHooks:!1,supportsDangerousMode:!0,supportsModelSwitch:!1,supportsTranscriptTailing:!1,supportsTmuxAdoption:!0,policyChannel:"input-preflight",metricsChannel:"pty"},launchHints:{dangerousModeFlags:["--dangerously-bypass-approvals-and-sandbox"],resumeCommands:{resume:"codex resume {id}",fork:"codex fork {id}",idPlaceholder:"019c7285-ba64-7462-bbfc-4227f3e24e88"}}}],Qm=new Map(kr.map(e=>[e.id,e]));function eh(e){const t=e.trim();return t.length===0?"Provider":t.split(/[-_]/g).filter(Boolean).map(n=>{var r;return((r=n[0])==null?void 0:r.toUpperCase())+n.slice(1)}).join(" ")}function th(e,t){const n=t==null?void 0:t.find(s=>s.id===e);if(n)return n;const r=Qm.get(e);return r||{id:e,label:eh(e),runtime:"tmux",capabilities:Zm}}function nh(e){return e.capabilities.nativeHooks?"Native hook integration, richer policy and transcript metrics.":e.capabilities.policyChannel==="input-preflight"?"Tmux-first integration with preflight policy checks (no native hooks).":"Tmux session with limited policy and analytics integration."}function rh(e){return e.nativeHooks||e.supportsTranscriptTailing}function oh(e){return rh(e)?Jm:Xm}function Og(e,t){return oh(th(e,t).capabilities)}const sh={"claude-code":{label:"Claude Code",icon:zc,className:"border-amber-500/25 bg-gradient-to-r from-amber-500/15 via-orange-500/10 to-transparent text-amber-700 dark:text-amber-300",dotClassName:"bg-amber-500/85"},codex:{label:"Codex",icon:qc,className:"border-sky-500/25 bg-gradient-to-r from-sky-500/15 via-cyan-500/10 to-transparent text-sky-700 dark:text-sky-300",dotClassName:"bg-sky-500/85"}},ah={label:"Provider",icon:sl,className:"border-slate-500/25 bg-gradient-to-r from-slate-500/15 via-zinc-500/10 to-transparent text-slate-700 dark:text-slate-300",dotClassName:"bg-slate-500/85"};function lo(e){const t=sh[e];return t||{...ah,label:e.split(/[-_]/g).filter(Boolean).map(n=>{var r;return((r=n[0])==null?void 0:r.toUpperCase())+n.slice(1)}).join(" ")}}const qt=c.forwardRef(({className:e,variant:t="default",size:n="default",...r},s)=>o.jsx("button",{className:$("inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none",{"bg-primary text-primary-foreground hover:bg-primary/90":t==="default","bg-destructive text-destructive-foreground hover:bg-destructive/90":t==="destructive","border border-input hover:bg-accent hover:text-accent-foreground":t==="outline","bg-secondary text-secondary-foreground hover:bg-secondary/80":t==="secondary","hover:bg-accent hover:text-accent-foreground":t==="ghost","underline-offset-4 hover:underline text-primary":t==="link"},{"h-10 py-2 px-4":n==="default","h-9 px-3 rounded-md":n==="sm","h-11 px-8 rounded-md":n==="lg","h-10 w-10":n==="icon"},e),ref:s,...r}));qt.displayName="Button";var Gn="Dialog",[fi]=yt(Gn),[ih,Le]=fi(Gn),pi=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:s,onOpenChange:a,modal:i=!0}=e,l=c.useRef(null),d=c.useRef(null),[f,m]=Kt({prop:r,defaultProp:s??!1,onChange:a,caller:Gn});return o.jsx(ih,{scope:t,triggerRef:l,contentRef:d,contentId:Ye(),titleId:Ye(),descriptionId:Ye(),open:f,onOpenChange:m,onOpenToggle:c.useCallback(()=>m(p=>!p),[m]),modal:i,children:n})};pi.displayName=Gn;var mi="DialogTrigger",hi=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(mi,n),a=oe(t,s.triggerRef);return o.jsx(Q.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":po(s.open),...r,ref:a,onClick:F(e.onClick,s.onOpenToggle)})});hi.displayName=mi;var uo="DialogPortal",[ch,gi]=fi(uo,{forceMount:void 0}),xi=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:s}=e,a=Le(uo,t);return o.jsx(ch,{scope:t,forceMount:n,children:c.Children.map(r,i=>o.jsx(it,{present:n||a.open,children:o.jsx(Vn,{asChild:!0,container:s,children:i})}))})};xi.displayName=uo;var Tn="DialogOverlay",yi=c.forwardRef((e,t)=>{const n=gi(Tn,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,a=Le(Tn,e.__scopeDialog);return a.modal?o.jsx(it,{present:r||a.open,children:o.jsx(dh,{...s,ref:t})}):null});yi.displayName=Tn;var lh=At("DialogOverlay.RemoveScroll"),dh=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(Tn,n);return o.jsx(Ir,{as:lh,allowPinchZoom:!0,shards:[s.contentRef],children:o.jsx(Q.div,{"data-state":po(s.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),pt="DialogContent",bi=c.forwardRef((e,t)=>{const n=gi(pt,e.__scopeDialog),{forceMount:r=n.forceMount,...s}=e,a=Le(pt,e.__scopeDialog);return o.jsx(it,{present:r||a.open,children:a.modal?o.jsx(uh,{...s,ref:t}):o.jsx(fh,{...s,ref:t})})});bi.displayName=pt;var uh=c.forwardRef((e,t)=>{const n=Le(pt,e.__scopeDialog),r=c.useRef(null),s=oe(t,n.contentRef,r);return c.useEffect(()=>{const a=r.current;if(a)return zr(a)},[]),o.jsx(vi,{...e,ref:s,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:F(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:F(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:F(e.onFocusOutside,a=>a.preventDefault())})}),fh=c.forwardRef((e,t)=>{const n=Le(pt,e.__scopeDialog),r=c.useRef(!1),s=c.useRef(!1);return o.jsx(vi,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:a=>{var d,f;(d=e.onInteractOutside)==null||d.call(e,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=a.target;((f=n.triggerRef.current)==null?void 0:f.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),vi=c.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:a,...i}=e,l=Le(pt,n),d=c.useRef(null),f=oe(t,d);return $r(),o.jsxs(o.Fragment,{children:[o.jsx($n,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:a,children:o.jsx(Ln,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":po(l.open),...i,ref:f,onDismiss:()=>l.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(mh,{titleId:l.titleId}),o.jsx(gh,{contentRef:d,descriptionId:l.descriptionId})]})]})}),fo="DialogTitle",wi=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(fo,n);return o.jsx(Q.h2,{id:s.titleId,...r,ref:t})});wi.displayName=fo;var Si="DialogDescription",Ni=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(Si,n);return o.jsx(Q.p,{id:s.descriptionId,...r,ref:t})});Ni.displayName=Si;var Ei="DialogClose",ph=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(Ei,n);return o.jsx(Q.button,{type:"button",...r,ref:t,onClick:F(e.onClick,()=>s.onOpenChange(!1))})});ph.displayName=Ei;function po(e){return e?"open":"closed"}var Ci="DialogTitleWarning",[Dg,ki]=Ml(Ci,{contentName:pt,titleName:fo,docsSlug:"dialog"}),mh=({titleId:e})=>{const t=ki(Ci),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
200
200
 
201
201
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
202
202
 
203
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return c.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},hh="DialogDescriptionWarning",gh=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ki(hh).contentName}}.`;return c.useEffect(()=>{var a;const s=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},xh=pi,yh=hi,bh=xi,ji=yi,Pi=bi,Ti=wi,_i=Ni;const vh=xh,wh=yh,Sh=bh,Ri=c.forwardRef(({className:e,...t},n)=>o.jsx(ji,{ref:n,className:F("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Ri.displayName=ji.displayName;const Ai=c.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(Sh,{children:[o.jsx(Ri,{}),o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:o.jsx(Pi,{ref:r,className:F("grid w-full max-w-lg gap-4 border bg-background p-6 shadow-lg duration-200 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 sm:rounded-lg",e),...n,children:t})})]}));Ai.displayName=Pi.displayName;const Ii=({className:e,...t})=>o.jsx("div",{className:F("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ii.displayName="DialogHeader";const Mi=({className:e,...t})=>o.jsx("div",{className:F("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Mi.displayName="DialogFooter";const Oi=c.forwardRef(({className:e,...t},n)=>o.jsx(Ti,{ref:n,className:F("text-lg font-semibold leading-none tracking-tight",e),...t}));Oi.displayName=Ti.displayName;const Di=c.forwardRef(({className:e,...t},n)=>o.jsx(_i,{ref:n,className:F("text-sm text-muted-foreground",e),...t}));Di.displayName=_i.displayName;const Tt=c.forwardRef(({className:e,type:t,...n},r)=>o.jsx("input",{type:t,className:F("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));Tt.displayName="Input";function es(e,[t,n]){return Math.min(n,Math.max(t,e))}function Nh(e){const t=c.useRef({value:e,previous:e});return c.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Li=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Eh="VisuallyHidden",Ch=c.forwardRef((e,t)=>o.jsx(Q.span,{...e,ref:t,style:{...Li,...e.style}}));Ch.displayName=Eh;var kh=[" ","Enter","ArrowUp","ArrowDown"],jh=[" ","Enter"],mt="Select",[Yn,Jn,Ph]=Dr(mt),[$t]=yt(mt,[Ph,Hn]),Xn=Hn(),[Th,ct]=$t(mt),[_h,Rh]=$t(mt),$i=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:s,onOpenChange:a,value:i,defaultValue:l,onValueChange:d,dir:f,name:m,autoComplete:p,disabled:h,required:u,form:x}=e,g=Xn(t),[y,b]=c.useState(null),[v,w]=c.useState(null),[E,S]=c.useState(!1),C=Lr(f),[k,I]=Kt({prop:r,defaultProp:s??!1,onChange:a,caller:mt}),[H,D]=Kt({prop:i,defaultProp:l,onChange:d,caller:mt}),W=c.useRef(null),T=y?x||!!y.closest("form"):!0,[L,$]=c.useState(new Set),_=Array.from(L).map(j=>j.props.value).join(";");return o.jsx(Vs,{...g,children:o.jsxs(Th,{required:u,scope:t,trigger:y,onTriggerChange:b,valueNode:v,onValueNodeChange:w,valueNodeHasChildren:E,onValueNodeHasChildrenChange:S,contentId:Ye(),value:H,onValueChange:D,open:k,onOpenChange:I,dir:C,triggerPointerDownPosRef:W,disabled:h,children:[o.jsx(Yn.Provider,{scope:t,children:o.jsx(_h,{scope:e.__scopeSelect,onNativeOptionAdd:c.useCallback(j=>{$(R=>new Set(R).add(j))},[]),onNativeOptionRemove:c.useCallback(j=>{$(R=>{const A=new Set(R);return A.delete(j),A})},[]),children:n})}),T?o.jsxs(cc,{"aria-hidden":!0,required:u,tabIndex:-1,name:m,autoComplete:p,value:H,onChange:j=>D(j.target.value),disabled:h,form:x,children:[H===void 0?o.jsx("option",{value:""}):null,Array.from(L)]},_):null]})})};$i.displayName=mt;var Fi="SelectTrigger",Bi=c.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...s}=e,a=Xn(n),i=ct(Fi,n),l=i.disabled||r,d=oe(t,i.onTriggerChange),f=Jn(n),m=c.useRef("touch"),[p,h,u]=dc(g=>{const y=f().filter(w=>!w.disabled),b=y.find(w=>w.value===i.value),v=uc(y,g,b);v!==void 0&&i.onValueChange(v.value)}),x=g=>{l||(i.onOpenChange(!0),u()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return o.jsx(qs,{asChild:!0,...a,children:o.jsx(Q.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":lc(i.value)?"":void 0,...s,ref:d,onClick:B(s.onClick,g=>{g.currentTarget.focus(),m.current!=="mouse"&&x(g)}),onPointerDown:B(s.onPointerDown,g=>{m.current=g.pointerType;const y=g.target;y.hasPointerCapture(g.pointerId)&&y.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(x(g),g.preventDefault())}),onKeyDown:B(s.onKeyDown,g=>{const y=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&h(g.key),!(y&&g.key===" ")&&kh.includes(g.key)&&(x(),g.preventDefault())})})})});Bi.displayName=Fi;var Ui="SelectValue",Wi=c.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:s,children:a,placeholder:i="",...l}=e,d=ct(Ui,n),{onValueNodeHasChildrenChange:f}=d,m=a!==void 0,p=oe(t,d.onValueNodeChange);return me(()=>{f(m)},[f,m]),o.jsx(Q.span,{...l,ref:p,style:{pointerEvents:"none"},children:lc(d.value)?o.jsx(o.Fragment,{children:i}):a})});Wi.displayName=Ui;var Ah="SelectIcon",Hi=c.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...s}=e;return o.jsx(Q.span,{"aria-hidden":!0,...s,ref:t,children:r||"▼"})});Hi.displayName=Ah;var Ih="SelectPortal",Vi=e=>o.jsx(Vn,{asChild:!0,...e});Vi.displayName=Ih;var ht="SelectContent",qi=c.forwardRef((e,t)=>{const n=ct(ht,e.__scopeSelect),[r,s]=c.useState();if(me(()=>{s(new DocumentFragment)},[]),!n.open){const a=r;return a?Ot.createPortal(o.jsx(Ki,{scope:e.__scopeSelect,children:o.jsx(Yn.Slot,{scope:e.__scopeSelect,children:o.jsx("div",{children:e.children})})}),a):null}return o.jsx(zi,{...e,ref:t})});qi.displayName=ht;var Me=10,[Ki,lt]=$t(ht),Mh="SelectContentImpl",Oh=At("SelectContent.RemoveScroll"),zi=c.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:a,onPointerDownOutside:i,side:l,sideOffset:d,align:f,alignOffset:m,arrowPadding:p,collisionBoundary:h,collisionPadding:u,sticky:x,hideWhenDetached:g,avoidCollisions:y,...b}=e,v=ct(ht,n),[w,E]=c.useState(null),[S,C]=c.useState(null),k=oe(t,M=>E(M)),[I,H]=c.useState(null),[D,W]=c.useState(null),T=Jn(n),[L,$]=c.useState(!1),_=c.useRef(!1);c.useEffect(()=>{if(w)return zr(w)},[w]),$r();const j=c.useCallback(M=>{const[Z,...X]=T().map(Y=>Y.ref.current),[J]=X.slice(-1),q=document.activeElement;for(const Y of M)if(Y===q||(Y==null||Y.scrollIntoView({block:"nearest"}),Y===Z&&S&&(S.scrollTop=0),Y===J&&S&&(S.scrollTop=S.scrollHeight),Y==null||Y.focus(),document.activeElement!==q))return},[T,S]),R=c.useCallback(()=>j([I,w]),[j,I,w]);c.useEffect(()=>{L&&R()},[L,R]);const{onOpenChange:A,triggerPointerDownPosRef:N}=v;c.useEffect(()=>{if(w){let M={x:0,y:0};const Z=J=>{var q,Y;M={x:Math.abs(Math.round(J.pageX)-(((q=N.current)==null?void 0:q.x)??0)),y:Math.abs(Math.round(J.pageY)-(((Y=N.current)==null?void 0:Y.y)??0))}},X=J=>{M.x<=10&&M.y<=10?J.preventDefault():w.contains(J.target)||A(!1),document.removeEventListener("pointermove",Z),N.current=null};return N.current!==null&&(document.addEventListener("pointermove",Z),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Z),document.removeEventListener("pointerup",X,{capture:!0})}}},[w,A,N]),c.useEffect(()=>{const M=()=>A(!1);return window.addEventListener("blur",M),window.addEventListener("resize",M),()=>{window.removeEventListener("blur",M),window.removeEventListener("resize",M)}},[A]);const[U,te]=dc(M=>{const Z=T().filter(q=>!q.disabled),X=Z.find(q=>q.ref.current===document.activeElement),J=uc(Z,M,X);J&&setTimeout(()=>J.ref.current.focus())}),V=c.useCallback((M,Z,X)=>{const J=!_.current&&!X;(v.value!==void 0&&v.value===Z||J)&&(H(M),J&&(_.current=!0))},[v.value]),z=c.useCallback(()=>w==null?void 0:w.focus(),[w]),G=c.useCallback((M,Z,X)=>{const J=!_.current&&!X;(v.value!==void 0&&v.value===Z||J)&&W(M)},[v.value]),ne=r==="popper"?jr:Gi,ie=ne===jr?{side:l,sideOffset:d,align:f,alignOffset:m,arrowPadding:p,collisionBoundary:h,collisionPadding:u,sticky:x,hideWhenDetached:g,avoidCollisions:y}:{};return o.jsx(Ki,{scope:n,content:w,viewport:S,onViewportChange:C,itemRefCallback:V,selectedItem:I,onItemLeave:z,itemTextRefCallback:G,focusSelectedItem:R,selectedItemText:D,position:r,isPositioned:L,searchRef:U,children:o.jsx(Ir,{as:Oh,allowPinchZoom:!0,children:o.jsx($n,{asChild:!0,trapped:v.open,onMountAutoFocus:M=>{M.preventDefault()},onUnmountAutoFocus:B(s,M=>{var Z;(Z=v.trigger)==null||Z.focus({preventScroll:!0}),M.preventDefault()}),children:o.jsx(Ln,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:M=>M.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:o.jsx(ne,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:M=>M.preventDefault(),...b,...ie,onPlaced:()=>$(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:B(b.onKeyDown,M=>{const Z=M.ctrlKey||M.altKey||M.metaKey;if(M.key==="Tab"&&M.preventDefault(),!Z&&M.key.length===1&&te(M.key),["ArrowUp","ArrowDown","Home","End"].includes(M.key)){let J=T().filter(q=>!q.disabled).map(q=>q.ref.current);if(["ArrowUp","End"].includes(M.key)&&(J=J.slice().reverse()),["ArrowUp","ArrowDown"].includes(M.key)){const q=M.target,Y=J.indexOf(q);J=J.slice(Y+1)}setTimeout(()=>j(J)),M.preventDefault()}})})})})})})});zi.displayName=Mh;var Dh="SelectItemAlignedPosition",Gi=c.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...s}=e,a=ct(ht,n),i=lt(ht,n),[l,d]=c.useState(null),[f,m]=c.useState(null),p=oe(t,k=>m(k)),h=Jn(n),u=c.useRef(!1),x=c.useRef(!0),{viewport:g,selectedItem:y,selectedItemText:b,focusSelectedItem:v}=i,w=c.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&f&&g&&y&&b){const k=a.trigger.getBoundingClientRect(),I=f.getBoundingClientRect(),H=a.valueNode.getBoundingClientRect(),D=b.getBoundingClientRect();if(a.dir!=="rtl"){const q=D.left-I.left,Y=H.left-q,ce=k.left-Y,de=k.width+ce,$e=Math.max(de,I.width),Pe=window.innerWidth-Me,we=es(Y,[Me,Math.max(Me,Pe-$e)]);l.style.minWidth=de+"px",l.style.left=we+"px"}else{const q=I.right-D.right,Y=window.innerWidth-H.right-q,ce=window.innerWidth-k.right-Y,de=k.width+ce,$e=Math.max(de,I.width),Pe=window.innerWidth-Me,we=es(Y,[Me,Math.max(Me,Pe-$e)]);l.style.minWidth=de+"px",l.style.right=we+"px"}const W=h(),T=window.innerHeight-Me*2,L=g.scrollHeight,$=window.getComputedStyle(f),_=parseInt($.borderTopWidth,10),j=parseInt($.paddingTop,10),R=parseInt($.borderBottomWidth,10),A=parseInt($.paddingBottom,10),N=_+j+L+A+R,U=Math.min(y.offsetHeight*5,N),te=window.getComputedStyle(g),V=parseInt(te.paddingTop,10),z=parseInt(te.paddingBottom,10),G=k.top+k.height/2-Me,ne=T-G,ie=y.offsetHeight/2,M=y.offsetTop+ie,Z=_+j+M,X=N-Z;if(Z<=G){const q=W.length>0&&y===W[W.length-1].ref.current;l.style.bottom="0px";const Y=f.clientHeight-g.offsetTop-g.offsetHeight,ce=Math.max(ne,ie+(q?z:0)+Y+R),de=Z+ce;l.style.height=de+"px"}else{const q=W.length>0&&y===W[0].ref.current;l.style.top="0px";const ce=Math.max(G,_+g.offsetTop+(q?V:0)+ie)+X;l.style.height=ce+"px",g.scrollTop=Z-G+g.offsetTop}l.style.margin=`${Me}px 0`,l.style.minHeight=U+"px",l.style.maxHeight=T+"px",r==null||r(),requestAnimationFrame(()=>u.current=!0)}},[h,a.trigger,a.valueNode,l,f,g,y,b,a.dir,r]);me(()=>w(),[w]);const[E,S]=c.useState();me(()=>{f&&S(window.getComputedStyle(f).zIndex)},[f]);const C=c.useCallback(k=>{k&&x.current===!0&&(w(),v==null||v(),x.current=!1)},[w,v]);return o.jsx($h,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:u,onScrollButtonChange:C,children:o.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:o.jsx(Q.div,{...s,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});Gi.displayName=Dh;var Lh="SelectPopperPosition",jr=c.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:s=Me,...a}=e,i=Xn(n);return o.jsx(Ks,{...i,...a,ref:t,align:r,collisionPadding:s,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});jr.displayName=Lh;var[$h,mo]=$t(ht,{}),Pr="SelectViewport",Yi=c.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...s}=e,a=lt(Pr,n),i=mo(Pr,n),l=oe(t,a.onViewportChange),d=c.useRef(0);return o.jsxs(o.Fragment,{children:[o.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),o.jsx(Yn.Slot,{scope:n,children:o.jsx(Q.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:B(s.onScroll,f=>{const m=f.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&p){const u=Math.abs(d.current-m.scrollTop);if(u>0){const x=window.innerHeight-Me*2,g=parseFloat(p.style.minHeight),y=parseFloat(p.style.height),b=Math.max(g,y);if(b<x){const v=b+u,w=Math.min(x,v),E=v-w;p.style.height=w+"px",p.style.bottom==="0px"&&(m.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}d.current=m.scrollTop})})})]})});Yi.displayName=Pr;var Ji="SelectGroup",[Fh,Bh]=$t(Ji),Uh=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Ye();return o.jsx(Fh,{scope:n,id:s,children:o.jsx(Q.div,{role:"group","aria-labelledby":s,...r,ref:t})})});Uh.displayName=Ji;var Xi="SelectLabel",Zi=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Bh(Xi,n);return o.jsx(Q.div,{id:s.id,...r,ref:t})});Zi.displayName=Xi;var _n="SelectItem",[Wh,Qi]=$t(_n),ec=c.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:s=!1,textValue:a,...i}=e,l=ct(_n,n),d=lt(_n,n),f=l.value===r,[m,p]=c.useState(a??""),[h,u]=c.useState(!1),x=oe(t,v=>{var w;return(w=d.itemRefCallback)==null?void 0:w.call(d,v,r,s)}),g=Ye(),y=c.useRef("touch"),b=()=>{s||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return o.jsx(Wh,{scope:n,value:r,disabled:s,textId:g,isSelected:f,onItemTextChange:c.useCallback(v=>{p(w=>w||((v==null?void 0:v.textContent)??"").trim())},[]),children:o.jsx(Yn.ItemSlot,{scope:n,value:r,disabled:s,textValue:m,children:o.jsx(Q.div,{role:"option","aria-labelledby":g,"data-highlighted":h?"":void 0,"aria-selected":f&&h,"data-state":f?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...i,ref:x,onFocus:B(i.onFocus,()=>u(!0)),onBlur:B(i.onBlur,()=>u(!1)),onClick:B(i.onClick,()=>{y.current!=="mouse"&&b()}),onPointerUp:B(i.onPointerUp,()=>{y.current==="mouse"&&b()}),onPointerDown:B(i.onPointerDown,v=>{y.current=v.pointerType}),onPointerMove:B(i.onPointerMove,v=>{var w;y.current=v.pointerType,s?(w=d.onItemLeave)==null||w.call(d):y.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:B(i.onPointerLeave,v=>{var w;v.currentTarget===document.activeElement&&((w=d.onItemLeave)==null||w.call(d))}),onKeyDown:B(i.onKeyDown,v=>{var E;((E=d.searchRef)==null?void 0:E.current)!==""&&v.key===" "||(jh.includes(v.key)&&b(),v.key===" "&&v.preventDefault())})})})})});ec.displayName=_n;var Ht="SelectItemText",tc=c.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:s,...a}=e,i=ct(Ht,n),l=lt(Ht,n),d=Qi(Ht,n),f=Rh(Ht,n),[m,p]=c.useState(null),h=oe(t,b=>p(b),d.onItemTextChange,b=>{var v;return(v=l.itemTextRefCallback)==null?void 0:v.call(l,b,d.value,d.disabled)}),u=m==null?void 0:m.textContent,x=c.useMemo(()=>o.jsx("option",{value:d.value,disabled:d.disabled,children:u},d.value),[d.disabled,d.value,u]),{onNativeOptionAdd:g,onNativeOptionRemove:y}=f;return me(()=>(g(x),()=>y(x)),[g,y,x]),o.jsxs(o.Fragment,{children:[o.jsx(Q.span,{id:d.textId,...a,ref:h}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Ot.createPortal(a.children,i.valueNode):null]})});tc.displayName=Ht;var nc="SelectItemIndicator",rc=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Qi(nc,n).isSelected?o.jsx(Q.span,{"aria-hidden":!0,...r,ref:t}):null});rc.displayName=nc;var Tr="SelectScrollUpButton",oc=c.forwardRef((e,t)=>{const n=lt(Tr,e.__scopeSelect),r=mo(Tr,e.__scopeSelect),[s,a]=c.useState(!1),i=oe(t,r.onScrollButtonChange);return me(()=>{if(n.viewport&&n.isPositioned){let l=function(){const f=d.scrollTop>0;a(f)};const d=n.viewport;return l(),d.addEventListener("scroll",l),()=>d.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?o.jsx(ac,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=n;l&&d&&(l.scrollTop=l.scrollTop-d.offsetHeight)}}):null});oc.displayName=Tr;var _r="SelectScrollDownButton",sc=c.forwardRef((e,t)=>{const n=lt(_r,e.__scopeSelect),r=mo(_r,e.__scopeSelect),[s,a]=c.useState(!1),i=oe(t,r.onScrollButtonChange);return me(()=>{if(n.viewport&&n.isPositioned){let l=function(){const f=d.scrollHeight-d.clientHeight,m=Math.ceil(d.scrollTop)<f;a(m)};const d=n.viewport;return l(),d.addEventListener("scroll",l),()=>d.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?o.jsx(ac,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=n;l&&d&&(l.scrollTop=l.scrollTop+d.offsetHeight)}}):null});sc.displayName=_r;var ac=c.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...s}=e,a=lt("SelectScrollButton",n),i=c.useRef(null),l=Jn(n),d=c.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return c.useEffect(()=>()=>d(),[d]),me(()=>{var m;const f=l().find(p=>p.ref.current===document.activeElement);(m=f==null?void 0:f.ref.current)==null||m.scrollIntoView({block:"nearest"})},[l]),o.jsx(Q.div,{"aria-hidden":!0,...s,ref:t,style:{flexShrink:0,...s.style},onPointerDown:B(s.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:B(s.onPointerMove,()=>{var f;(f=a.onItemLeave)==null||f.call(a),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:B(s.onPointerLeave,()=>{d()})})}),Hh="SelectSeparator",ic=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return o.jsx(Q.div,{"aria-hidden":!0,...r,ref:t})});ic.displayName=Hh;var Rr="SelectArrow",Vh=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Xn(n),a=ct(Rr,n),i=lt(Rr,n);return a.open&&i.position==="popper"?o.jsx(zs,{...s,...r,ref:t}):null});Vh.displayName=Rr;var qh="SelectBubbleInput",cc=c.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const s=c.useRef(null),a=oe(r,s),i=Nh(t);return c.useEffect(()=>{const l=s.current;if(!l)return;const d=window.HTMLSelectElement.prototype,m=Object.getOwnPropertyDescriptor(d,"value").set;if(i!==t&&m){const p=new Event("change",{bubbles:!0});m.call(l,t),l.dispatchEvent(p)}},[i,t]),o.jsx(Q.select,{...n,style:{...Li,...n.style},ref:a,defaultValue:t})});cc.displayName=qh;function lc(e){return e===""||e===void 0}function dc(e){const t=We(e),n=c.useRef(""),r=c.useRef(0),s=c.useCallback(i=>{const l=n.current+i;t(l),function d(f){n.current=f,window.clearTimeout(r.current),f!==""&&(r.current=window.setTimeout(()=>d(""),1e3))}(l)},[t]),a=c.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return c.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,s,a]}function uc(e,t,n){const s=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=Kh(e,Math.max(a,0));s.length===1&&(i=i.filter(f=>f!==n));const d=i.find(f=>f.textValue.toLowerCase().startsWith(s.toLowerCase()));return d!==n?d:void 0}function Kh(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var zh=$i,fc=Bi,Gh=Wi,Yh=Hi,Jh=Vi,pc=qi,Xh=Yi,mc=Zi,hc=ec,Zh=tc,Qh=rc,gc=oc,xc=sc,yc=ic;const Rn=zh,An=Gh,Jt=c.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(fc,{ref:r,className:F("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...n,children:[t,o.jsx(Yh,{asChild:!0,children:o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 opacity-50",children:o.jsx("path",{d:"M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.26618 11.9026 7.38064 11.95 7.49999 11.95C7.61933 11.95 7.73379 11.9026 7.81819 11.8182L10.0682 9.56819Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})})]}));Jt.displayName=fc.displayName;const bc=c.forwardRef(({className:e,...t},n)=>o.jsx(gc,{ref:n,className:F("flex cursor-default items-center justify-center py-1",e),...t,children:o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",children:o.jsx("path",{d:"M7.14645 2.14645C7.34171 1.95118 7.65829 1.95118 7.85355 2.14645L11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355C11.6583 7.04882 11.3417 7.04882 11.1464 6.85355L7.5 3.20711L3.85355 6.85355C3.65829 7.04882 3.34171 7.04882 3.14645 6.85355C2.95118 6.65829 2.95118 6.34171 3.14645 6.14645L7.14645 2.14645Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}));bc.displayName=gc.displayName;const vc=c.forwardRef(({className:e,...t},n)=>o.jsx(xc,{ref:n,className:F("flex cursor-default items-center justify-center py-1",e),...t,children:o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",children:o.jsx("path",{d:"M7.14645 12.8536C7.34171 13.0488 7.65829 13.0488 7.85355 12.8536L11.8536 8.85355C12.0488 8.65829 12.0488 8.34171 11.8536 8.14645C11.6583 7.95118 11.3417 7.95118 11.1464 8.14645L7.5 11.7929L3.85355 8.14645C3.65829 7.95118 3.34171 7.95118 3.14645 8.14645C2.95118 8.34171 2.95118 8.65829 3.14645 8.85355L7.14645 12.8536Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}));vc.displayName=xc.displayName;const Xt=c.forwardRef(({className:e,children:t,position:n="popper",...r},s)=>o.jsx(Jh,{children:o.jsxs(pc,{ref:s,className:F("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",n==="popper"&&"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:n,...r,children:[o.jsx(bc,{}),o.jsx(Xh,{className:F("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),o.jsx(vc,{})]})}));Xt.displayName=pc.displayName;const eg=c.forwardRef(({className:e,...t},n)=>o.jsx(mc,{ref:n,className:F("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));eg.displayName=mc.displayName;const Ne=c.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(hc,{ref:r,className:F("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(Qh,{children:o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",children:o.jsx("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})})}),o.jsx(Zh,{children:t})]}));Ne.displayName=hc.displayName;const tg=c.forwardRef(({className:e,...t},n)=>o.jsx(yc,{ref:n,className:F("-mx-1 my-1 h-px bg-muted",e),...t}));tg.displayName=yc.displayName;function ng(e){const t=e.trim();if(!t)return{args:[]};const n=[];let r="",s=null,a=!1;for(const i of t){if(a){r+=i,a=!1;continue}if(i==="\\"){a=!0;continue}if(s){i===s?s=null:r+=i;continue}if(i==='"'||i==="'"){s=i;continue}if(/\s/.test(i)){r.length>0&&(n.push(r),r="");continue}r+=i}return a&&(r+="\\"),s?{args:[],error:"Unclosed quote in arguments"}:(r.length>0&&n.push(r),{args:n})}function ho({onSessionCreated:e,children:t}){var Ft,Ke;const n=gt(),[r,s]=c.useState(!1),[a,i]=c.useState(!1),[l,d]=c.useState([...kr]),[f,m]=c.useState("claude-code"),[p,h]=c.useState(!1),[u,x]=c.useState("new"),[g,y]=c.useState(""),[b,v]=c.useState("resume"),[w,E]=c.useState("type"),[S,C]=c.useState(""),[k,I]=c.useState(""),[H,D]=c.useState(""),[W,T]=c.useState(!0),[L,$]=c.useState(!1),[_,j]=c.useState(!1),[R,A]=c.useState(""),[N,U]=c.useState(!1),[te,V]=c.useState(!1),[z,G]=c.useState(new Set),[ne,ie]=c.useState([]),[M,Z]=c.useState([]),[X,J]=c.useState(!1),[q,Y]=c.useState(null),[ce,de]=c.useState(null),[$e,Pe]=c.useState(!1),we=c.useRef(null),Te=c.useRef(null);c.useEffect(()=>{if(!r)return;let O=!1;return(async()=>{const[fe,xe,ye]=await Promise.allSettled([ae.getWorkspaces(),ae.getEnvSets(),ae.getProviders()]);O||(fe.status==="fulfilled"?(ie(fe.value.workspaces),fe.value.workspaces.length>0&&(E("workspace"),I(fe.value.workspaces[0].id))):ve.error("Failed to load workspaces"),xe.status==="fulfilled"?Z(xe.value.envSets):ve.error("Failed to load environment sets"),ye.status==="fulfilled"&&ye.value.providers.length>0?(d(ye.value.providers),m(Nt=>ye.value.providers.some(Fe=>Fe.id===Nt)?Nt:ye.value.providers[0].id)):d([...kr]))})(),()=>{O=!0}},[r]);const Se=l.find(O=>O.id===f),dt=(Se==null?void 0:Se.capabilities.supportsDangerousMode)===!0,ke=Se==null?void 0:Se.launchHints,ue=ke==null?void 0:ke.resumeCommands;c.useEffect(()=>{!dt&&p&&h(!1)},[p,dt]),c.useEffect(()=>{u==="resume"&&(j(!1),$(!1))},[u]);const pe=w==="workspace"?((Ft=ne.find(O=>O.id===k))==null?void 0:Ft.path)||"":S,an=c.useCallback(async O=>{if(!O){Y(null);return}J(!0);try{const fe=await ae.validateSession({cwd:O});Y(fe)}catch{Y(null)}finally{J(!1)}},[]);c.useEffect(()=>{if(we.current&&clearTimeout(we.current),!pe){Y(null);return}return we.current=setTimeout(()=>an(pe),500),()=>{we.current&&clearTimeout(we.current)}},[pe,an]);const cn=c.useCallback(async(O,fe,xe)=>{if(!(O&&fe)){de(null);return}Pe(!0);try{const ye=await ae.validateGit({cwd:O,branch:fe,createBranch:xe});de(ye)}catch{de(null)}finally{Pe(!1)}},[]);c.useEffect(()=>{if(!_){de(null);return}if(Te.current&&clearTimeout(Te.current),!R){de(null);return}return Te.current=setTimeout(()=>cn(pe,R,N),500),()=>{Te.current&&clearTimeout(Te.current)}},[R,N,pe,_,cn]);const ge=O=>{G(fe=>{const xe=new Set(fe);return xe.has(O)?xe.delete(O):xe.add(O),xe})},Ze=q&&!q.valid,Zn=u==="new"&&_&&ce&&!ce.valid,ln=u==="resume"&&g.trim().length===0,wt=pe&&!X&&!$e&&!Ze&&!Zn&&!ln,Qn=async()=>{if(!pe){ve.error("Working directory is required");return}try{const O=ng(H);if(O.error){ve.error(O.error);return}i(!0);const{session:fe}=await ae.createSession({provider:f,cwd:pe,args:O.args.length>0?O.args:void 0,dangerousMode:p,envSetIds:z.size>0?Array.from(z):void 0,providerResume:u==="resume"?{providerSessionId:g.trim(),mode:b}:void 0,worktree:u==="new"&&_&&R?{branch:R,createBranch:N}:void 0});ve.success("Session created successfully"),s(!1),dn(),e==null||e(),setTimeout(()=>n(`/sessions/${fe.id}`),300)}catch(O){ve.error(O instanceof Error?O.message:"Failed to create session")}finally{i(!1)}},dn=()=>{m("claude-code"),h(!1),x("new"),y(""),v("resume"),E("type"),C(""),I(""),D(""),T(!0),j(!1),A(""),U(!1),G(new Set),Y(null),de(null),$(!1),V(!1)},St=p?(ke==null?void 0:ke.dangerousModeFlags)??[]:[],qe=(()=>{if(u!=="resume"||!(ue!=null&&ue.resume))return;const O=g.trim()||"<provider-session-id>";return(b==="fork"?ue.fork??ue.resume:ue.resume).split("{id}").join(O)})();return o.jsxs(vh,{open:r,onOpenChange:s,children:[o.jsx(wh,{asChild:!0,children:t||o.jsxs(qt,{className:"bg-cyan-600 hover:bg-cyan-700 text-white border-0",children:[o.jsx(On,{className:"h-4 w-4 mr-1.5"}),"New Session"]})}),o.jsxs(Ai,{className:"border-border bg-popover max-w-lg max-h-[85vh] overflow-y-auto",children:[o.jsxs(Ii,{children:[o.jsx(Oi,{children:"Create New Session"}),o.jsx(Di,{className:"text-muted-foreground/60",children:"Start a new provider session in tmux."})]}),o.jsxs("div",{className:"space-y-5 py-2",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Provider *"}),o.jsx("div",{className:"grid gap-2",children:l.map(O=>{const fe=lo(O.id),xe=fe.icon,ye=f===O.id,Nt=[{label:O.capabilities.nativeHooks?"Native Hooks":"No Native Hooks",active:O.capabilities.nativeHooks},{label:O.capabilities.policyChannel==="input-preflight"?"Input Preflight Policy":"Hook Policy Channel",active:O.capabilities.policyChannel!=="none"},{label:O.capabilities.metricsChannel==="transcript"?"Transcript Metrics":O.capabilities.metricsChannel==="pty"?"PTY Metrics":"No Metrics",active:O.capabilities.metricsChannel!=="none"}];return o.jsx("button",{type:"button","aria-pressed":ye,onClick:()=>m(O.id),className:F("group rounded-xl border p-3 text-left transition-all",ye?"border-primary/45 bg-gradient-to-r from-primary/14 via-primary/6 to-transparent shadow-[0_8px_20px_rgba(0,0,0,0.12)]":"border-border/80 bg-muted/20 hover:border-border hover:bg-muted/35"),children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:F("mt-0.5 inline-flex h-8 w-8 items-center justify-center rounded-lg border",fe.className),children:o.jsx(xe,{className:"h-4 w-4"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"text-sm font-semibold text-foreground",children:O.label}),o.jsx("span",{className:"rounded-full border border-border/70 bg-background/70 px-1.5 py-0.5 text-[10px] font-mono uppercase tracking-wide text-muted-foreground",children:O.runtime}),O.capabilities.nativeHooks&&o.jsx("span",{className:"rounded-full border border-emerald-500/30 bg-emerald-500/12 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-300",children:"Recommended"})]}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:nh(O)}),o.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:Nt.map(Qe=>o.jsx("span",{className:F("rounded-full border px-1.5 py-0.5 text-[10px]",Qe.active?"border-primary/25 bg-primary/10 text-primary":"border-border/70 bg-background/60 text-muted-foreground"),children:Qe.label},`${O.id}-${Qe.label}`))})]}),o.jsx("div",{className:F("mt-1 inline-flex h-5 w-5 items-center justify-center rounded-full border transition-colors",ye?"border-primary/50 bg-primary/15 text-primary":"border-border/70 text-transparent group-hover:border-primary/25"),children:o.jsx(Mr,{className:"h-3.5 w-3.5"})})]})},O.id)})})]}),o.jsxs("div",{className:"grid gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Session Mode"}),o.jsxs("div",{className:"flex gap-1 bg-muted/40 rounded-md p-0.5",children:[o.jsx("button",{type:"button",onClick:()=>x("new"),className:`flex-1 text-xs px-2.5 py-1.5 rounded transition-all ${u==="new"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"New Session"}),o.jsx("button",{type:"button",onClick:()=>x("resume"),className:`flex-1 text-xs px-2.5 py-1.5 rounded transition-all ${u==="resume"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Resume by ID"})]}),o.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:u==="new"?"Start a new provider conversation inside a CodePiper-managed tmux session.":"Attach a new CodePiper runtime to an existing provider conversation/session ID."})]}),o.jsxs("div",{className:"grid gap-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Working Directory *"}),ne.length>0&&o.jsxs("div",{className:"flex gap-1 bg-muted/40 rounded-md p-0.5",children:[o.jsx("button",{type:"button",onClick:()=>E("type"),className:`text-[10px] px-2 py-0.5 rounded transition-all ${w==="type"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Type Path"}),o.jsx("button",{type:"button",onClick:()=>E("workspace"),className:`text-[10px] px-2 py-0.5 rounded transition-all ${w==="workspace"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Workspace"})]})]}),w==="type"?o.jsx(Tt,{placeholder:"/path/to/project",value:S,onChange:O=>C(O.target.value),className:"border-border bg-muted/30 font-mono text-sm placeholder:text-muted-foreground/30"}):o.jsxs(Rn,{value:k,onValueChange:I,children:[o.jsx(Jt,{className:"border-border bg-muted/30",children:o.jsx(An,{placeholder:"Select a workspace..."})}),o.jsx(Xt,{children:ne.map(O=>o.jsx(Ne,{value:O.id,children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ll,{className:"h-3 w-3 text-cyan-400"}),o.jsx("span",{children:O.name}),o.jsx("span",{className:"text-muted-foreground/50 text-xs font-mono ml-1",children:O.path})]})},O.id))})]}),o.jsx(rg,{validating:X,result:q})]}),u==="resume"&&o.jsxs("div",{className:"border border-cyan-500/20 rounded-lg p-3 space-y-3 bg-cyan-500/[0.04]",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Provider Session ID *"}),o.jsx(Tt,{placeholder:(ue==null?void 0:ue.idPlaceholder)??"provider session id",value:g,onChange:O=>y(O.target.value),className:"border-border bg-background/70 font-mono text-sm"}),ln&&o.jsx("span",{className:"text-[11px] text-red-400",children:"Provider session ID is required in Resume mode."})]}),o.jsxs("div",{className:"grid gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Resume Strategy"}),o.jsxs(Rn,{value:b,onValueChange:O=>v(O),children:[o.jsx(Jt,{className:"border-border bg-background/70",children:o.jsx(An,{})}),o.jsxs(Xt,{children:[o.jsx(Ne,{value:"resume",children:"Resume existing thread/session"}),o.jsx(Ne,{value:"fork",children:"Fork from that thread/session"})]})]}),o.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:ue!=null&&ue.resume?b==="fork"?ue.fork?`Uses \`${ue.fork}\`.`:`Uses \`${ue.resume}\` (provider does not expose a dedicated fork command).`:`Uses \`${ue.resume}\`.`:"Provider resume command preview unavailable for this provider."})]})]}),u==="new"&&(q==null?void 0:q.isGitRepo)&&o.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>$(!L),className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-muted/30 transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[L?o.jsx(er,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(gn,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx(ms,{className:"h-3.5 w-3.5 text-emerald-400"}),o.jsx("span",{className:"text-xs font-medium text-foreground",children:"Git Worktree"})]}),q.gitInfo&&o.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/60",children:q.gitInfo.currentBranch})]}),L&&o.jsxs("div",{className:"border-t border-border px-3 py-3 space-y-3",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:_,onChange:O=>j(O.target.checked),className:"rounded border-border"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:"Use Git Worktree (isolated branch work)"})]}),_&&o.jsxs("div",{className:"space-y-3 pl-5",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-[10px] font-medium text-muted-foreground mb-1 block",children:"Branch"}),o.jsx(Tt,{placeholder:"feature/my-branch",value:R,onChange:O=>A(O.target.value),className:"bg-background border-border font-mono text-xs h-8",list:"branch-suggestions"}),((Ke=q.gitInfo)==null?void 0:Ke.branches)&&o.jsx("datalist",{id:"branch-suggestions",children:q.gitInfo.branches.map(O=>o.jsx("option",{value:O},O))})]}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:N,onChange:O=>U(O.target.checked),className:"rounded border-border"}),o.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Create branch if it doesn't exist"})]}),o.jsx(og,{validating:$e,result:ce})]})]})]}),M.length>0&&o.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>V(!te),className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-muted/30 transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[te?o.jsx(er,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(gn,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx(fl,{className:"h-3.5 w-3.5 text-violet-400"}),o.jsx("span",{className:"text-xs font-medium text-foreground",children:"Environment Sets"})]}),z.size>0&&o.jsxs("span",{className:"text-[10px] font-mono text-violet-400/80",children:[z.size," selected"]})]}),te&&o.jsx("div",{className:"border-t border-border px-3 py-3 space-y-2",children:M.map(O=>o.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer py-1",children:[o.jsx("input",{type:"checkbox",checked:z.has(O.id),onChange:()=>ge(O.id),className:"rounded border-border"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("span",{className:"text-xs text-foreground",children:O.name}),O.description&&o.jsx("span",{className:"text-[10px] text-muted-foreground/60 ml-2",children:O.description})]})]},O.id))})]}),o.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>T(!W),className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-muted/30 transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[W?o.jsx(er,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(gn,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-xs font-medium text-foreground",children:"Advanced Options"})]}),o.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/60",children:"args + dangerous + preview"})]}),W&&o.jsxs("div",{className:"border-t border-border px-3 py-3 space-y-3",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Arguments (optional)"}),o.jsx(Tt,{placeholder:"--model opus --verbose",value:H,onChange:O=>D(O.target.value),className:"border-border bg-muted/30 font-mono text-sm placeholder:text-muted-foreground/30"}),o.jsxs("p",{className:"text-[11px] text-muted-foreground/70",children:["Supports quoted values, e.g. ",o.jsx("code",{children:'--prompt \\"hello world\\"'}),"."]})]}),o.jsxs("div",{className:"border border-amber-500/40 rounded-lg p-3 space-y-2 bg-amber-500/5",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:p,disabled:!dt,onChange:O=>h(O.target.checked),className:"rounded border-border"}),o.jsx("span",{className:"text-xs font-medium text-amber-300",children:"Dangerous Mode"})]}),o.jsx("p",{className:"text-[11px] text-muted-foreground",children:dt?"Bypasses CodePiper policy checks and enables provider-native dangerous mode flags for this session.":"This provider does not support dangerous mode."}),St.length>0&&o.jsxs("p",{className:"text-[11px] text-amber-200/90 font-mono",children:["Effective flags: ",St.join(" ")]})]}),qe&&o.jsxs("div",{className:"border border-cyan-500/25 rounded-lg p-3 bg-cyan-500/[0.06]",children:[o.jsx("p",{className:"text-[11px] text-muted-foreground mb-1",children:"Provider resume preview"}),o.jsx("p",{className:"text-[11px] font-mono text-cyan-200/90 break-all",children:qe})]})]})]})]}),o.jsxs(Mi,{children:[o.jsx(qt,{variant:"outline",onClick:()=>s(!1),disabled:a,className:"border-border",children:"Cancel"}),o.jsx(qt,{onClick:Qn,disabled:a||!wt,className:"bg-cyan-600 hover:bg-cyan-700 text-white border-0",children:a?"Creating...":"Create Session"})]})]})]})}function rg({validating:e,result:t}){return e?o.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground/60",children:[o.jsx(Or,{className:"h-3 w-3 animate-spin"}),o.jsx("span",{className:"text-[11px]",children:"Validating..."})]}):t?o.jsxs("div",{className:"space-y-1",children:[t.errors.map(n=>o.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[o.jsx(ps,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"text-[11px]",children:n})]},n)),t.warnings.map(n=>o.jsxs("div",{className:"flex items-center gap-1.5 text-amber-400",children:[o.jsx(ys,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"text-[11px]",children:n})]},n)),t.valid&&t.errors.length===0&&o.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-400",children:[o.jsx(Mr,{className:"h-3 w-3 shrink-0"}),o.jsxs("span",{className:"text-[11px]",children:["Directory valid",t.isGitRepo&&" (git repository)"]})]})]}):null}function og({validating:e,result:t}){return e?o.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground/60",children:[o.jsx(Or,{className:"h-3 w-3 animate-spin"}),o.jsx("span",{className:"text-[11px]",children:"Checking branch..."})]}):t?o.jsxs("div",{className:"space-y-1",children:[t.errors.map(n=>o.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[o.jsx(ps,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"text-[11px]",children:n})]},n)),t.warnings.map(n=>o.jsxs("div",{className:"flex items-center gap-1.5 text-amber-400",children:[o.jsx(ys,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"text-[11px]",children:n})]},n)),t.valid&&t.errors.length===0&&o.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-400",children:[o.jsx(Mr,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"text-[11px]",children:"Branch ready"})]})]}):null}const sg=[{name:"Home",href:"/",icon:hs},{name:"Sessions",href:"/sessions",icon:xt},{name:"new",href:"#new",icon:On},{name:"Policies",href:"/policies",icon:xs},{name:"More",href:"/settings",icon:gs}];function ag({keyboardOpen:e=!1}){var h;const t=gt(),n=In(),{theme:r}=so(),s=(h=n.pathname.match(/^\/sessions\/([^/]+)/))==null?void 0:h[1],{sessions:a}=on(),{counts:i}=rn(),l=c.useMemo(()=>a.filter(to).sort((u,x)=>new Date(x.createdAt).getTime()-new Date(u.createdAt).getTime()).slice(0,5),[a]),d=c.useMemo(()=>sn(a),[a]),f=l.length,m=i.totalUnread>0?i.totalUnread:f,p=r.mode==="dark"?"bg-card/95 backdrop-blur-xl":"bg-card border-border/90";return o.jsxs("nav",{className:F("md:hidden fixed bottom-0 left-0 right-0 z-40 border-t border-border pb-safe transition-transform duration-200 ease-out",p,e?"translate-y-[calc(100%+1.5rem)] opacity-0 pointer-events-none":"translate-y-0 opacity-100"),children:[l.length>0&&o.jsx("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-emerald-500/[0.03] border-b border-emerald-500/10 overflow-x-auto scrollbar-none",children:l.map(u=>{const x=Rt(u,d),g=br(u),y=s===u.id,b=i.bySession[u.id]??0;return o.jsxs("button",{type:"button",onClick:()=>t(`/sessions/${u.id}`),className:F("flex items-center gap-1.5 shrink-0 min-h-[28px] px-2.5 rounded-full border active:scale-95 transition-all",y?"bg-emerald-500/15 border-emerald-400/30 shadow-[0_0_8px_rgba(16,185,129,0.15)]":"bg-card/60 border-border/40"),children:[o.jsx(xt,{className:F("h-3 w-3 shrink-0",g?"text-amber-400 drop-shadow-[0_0_3px_rgba(251,191,36,0.6)]":"text-emerald-400 drop-shadow-[0_0_3px_rgba(16,185,129,0.5)]",g&&"pulse-live")}),b>0&&o.jsx("span",{className:"inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-amber-500 px-1 text-[9px] font-semibold leading-none text-amber-950 shadow-[0_0_8px_rgba(245,158,11,0.4)]",children:b>99?"99+":b}),o.jsx("span",{className:F("text-[10px] font-medium max-w-[72px] truncate",y?"text-emerald-300":"text-muted-foreground"),children:x})]},u.id)})}),o.jsx("div",{className:"flex items-center justify-around h-14",children:sg.map(u=>u.name==="new"?o.jsx(ho,{children:o.jsx("button",{type:"button",className:"flex items-center justify-center w-11 h-11 rounded-2xl bg-gradient-to-br from-cyan-500 to-violet-600 text-white shadow-lg shadow-cyan-500/25 active:scale-95 transition-transform",children:o.jsx(On,{className:"h-5 w-5"})})},"new-session"):o.jsx(vn,{to:u.href,end:u.href==="/",className:({isActive:x})=>F("relative flex flex-col items-center justify-center gap-0.5 w-14 h-14 transition-colors",x?"text-cyan-400":"text-muted-foreground active:text-foreground"),children:({isActive:x})=>o.jsxs(o.Fragment,{children:[x&&o.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-5 h-[2px] rounded-full bg-cyan-400 shadow-[0_0_6px_rgba(6,182,212,0.5)]"}),o.jsxs("div",{className:"relative",children:[o.jsx(u.icon,{className:"h-5 w-5"}),u.name==="Sessions"&&m>0&&o.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-[16px] rounded-full bg-cyan-500 text-[9px] font-bold text-cyan-950 flex items-center justify-center px-1 leading-none",children:m>99?"99+":m})]}),o.jsx("span",{className:"text-[10px] font-medium",children:u.name})]})},u.href))})]})}const ig=[{name:"Dashboard",href:"/",icon:hs},{name:"Sessions",href:"/sessions",icon:xt}],cg=[{name:"Analytics",href:"/analytics",icon:Yc},{name:"Workflows",href:"/workflows",icon:ms},{name:"Policies",href:"/policies",icon:xs}];function Ar({label:e}){return o.jsx("span",{className:"absolute left-full ml-2.5 px-2.5 py-1 rounded-md bg-popover border border-border text-xs font-medium text-popover-foreground whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity duration-150 z-50 shadow-lg shadow-black/20",children:e})}function ts({item:e,sessionCount:t,attentionCount:n,unreadCount:r}){const s=r>0?r:t;return o.jsx(vn,{to:e.href,end:e.href==="/",className:({isActive:a})=>F("group relative flex items-center justify-center w-10 h-10 rounded-lg transition-all duration-200",a?"text-cyan-400 bg-cyan-500/[0.12]":"text-muted-foreground hover:text-foreground hover:bg-accent/50"),children:({isActive:a})=>o.jsxs(o.Fragment,{children:[a&&o.jsx("div",{className:"absolute -left-[6px] top-1/2 -translate-y-1/2 w-[3px] h-5 rounded-r-full bg-gradient-to-b from-cyan-400 to-cyan-600 shadow-[0_0_8px_rgba(6,182,212,0.4)]"}),o.jsx(e.icon,{className:F("h-[18px] w-[18px] transition-colors",a?"text-cyan-400":"text-muted-foreground group-hover:text-foreground")}),e.href==="/sessions"&&s>0&&o.jsx("span",{className:F("absolute -top-0.5 -right-0.5 min-w-[18px] h-[18px] rounded-full flex items-center justify-center text-[10px] font-bold leading-none px-1",r>0||n>0?"bg-amber-500 text-amber-950 shadow-[0_0_8px_rgba(245,158,11,0.5)] pulse-live":"bg-cyan-500/90 text-cyan-950 shadow-[0_0_6px_rgba(6,182,212,0.4)]"),children:s>99?"99+":s}),o.jsx(Ar,{label:e.name})]})})}function lg(){var f;const e=gt(),n=(f=In().pathname.match(/^\/sessions\/([^/]+)/))==null?void 0:f[1],{sessions:r}=on(),{counts:s}=rn(),a=r.filter(br).length,i=c.useMemo(()=>r.filter(to).sort((m,p)=>new Date(p.createdAt).getTime()-new Date(m.createdAt).getTime()).slice(0,5),[r]),l=c.useMemo(()=>sn(r),[r]),d=i.length;return o.jsxs("aside",{className:"hidden md:flex w-[60px] border-r border-border bg-card flex-col items-center relative overflow-visible",children:[o.jsx("div",{className:"absolute top-0 left-0 right-0 h-32 bg-gradient-to-b from-cyan-500/[0.04] to-transparent pointer-events-none"}),o.jsx("button",{type:"button",onClick:()=>e("/"),className:"py-4 relative group cursor-pointer",title:"Dashboard",children:o.jsx("img",{src:"/piper.svg",alt:"CodePiper",className:"w-10 h-10 transition-transform group-hover:scale-110"})}),o.jsxs("div",{className:"pb-2 relative group",children:[o.jsx(ho,{children:o.jsx("button",{type:"button",className:"w-9 h-9 rounded-lg bg-cyan-500/10 text-cyan-400/70 hover:bg-cyan-500/20 hover:text-cyan-400 flex items-center justify-center transition-all duration-200 border border-cyan-500/10 hover:border-cyan-500/20",children:o.jsx(On,{className:"h-4 w-4"})})}),o.jsx(Ar,{label:"New Session"})]}),o.jsx("div",{className:"w-6 border-t border-border/60 mb-1"}),o.jsxs("nav",{className:"flex-1 flex flex-col items-center gap-0.5 py-1 relative",children:[ig.map(m=>o.jsx(ts,{item:m,sessionCount:d,attentionCount:a,unreadCount:m.href==="/sessions"?s.totalUnread:0},m.href)),i.length>0&&o.jsxs("div",{className:"flex flex-col items-center gap-0.5 py-1 my-0.5",children:[o.jsx("div",{className:"w-5 border-t border-emerald-500/20 mb-0.5"}),i.map(m=>{const p=Rt(m,l),h=br(m),u=n===m.id,x=s.bySession[m.id]??0;return o.jsxs(vn,{to:`/sessions/${m.id}`,className:F("group relative flex items-center justify-center w-10 h-8 rounded-lg transition-all duration-200",u?"bg-emerald-500/[0.12]":"hover:bg-emerald-500/10"),children:[u&&o.jsx("div",{className:"absolute -left-[6px] top-1/2 -translate-y-1/2 w-[3px] h-4 rounded-r-full bg-gradient-to-b from-emerald-400 to-emerald-600 shadow-[0_0_8px_rgba(16,185,129,0.4)]"}),o.jsx(xt,{className:F("h-4 w-4 transition-all duration-200",h?"text-amber-400 drop-shadow-[0_0_4px_rgba(251,191,36,0.6)]":"text-emerald-400 drop-shadow-[0_0_4px_rgba(16,185,129,0.5)]",h&&"pulse-live")}),x>0&&o.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[15px] h-[15px] rounded-full bg-amber-500 text-[9px] font-bold text-amber-950 flex items-center justify-center px-1 leading-none shadow-[0_0_8px_rgba(245,158,11,0.45)]",children:x>99?"99+":x}),o.jsxs("span",{className:"absolute left-full ml-2.5 px-2.5 py-1.5 rounded-md bg-popover border border-border text-xs text-popover-foreground whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity duration-150 z-50 shadow-lg shadow-black/20 max-w-[200px]",children:[o.jsx("span",{className:"font-medium text-emerald-400",children:p}),x>0&&o.jsxs("span",{className:"block text-[10px] text-amber-400 mt-0.5",children:[x," unread notification",x===1?"":"s"]}),o.jsx("span",{className:"block text-[10px] text-muted-foreground mt-0.5 truncate",children:m.cwd})]})]},m.id)}),o.jsx("div",{className:"w-5 border-t border-emerald-500/20 mt-0.5"})]}),cg.map(m=>o.jsx(ts,{item:m,sessionCount:0,attentionCount:0,unreadCount:0},m.href))]}),o.jsxs("div",{className:"flex flex-col items-center gap-1 pb-3",children:[o.jsx(vn,{to:"/settings",className:({isActive:m})=>F("group relative flex items-center justify-center w-10 h-10 rounded-lg transition-all duration-200",m?"text-cyan-400 bg-cyan-500/[0.12]":"text-muted-foreground hover:text-foreground hover:bg-accent/50"),children:({isActive:m})=>o.jsxs(o.Fragment,{children:[m&&o.jsx("div",{className:"absolute -left-[6px] top-1/2 -translate-y-1/2 w-[3px] h-5 rounded-r-full bg-gradient-to-b from-cyan-400 to-cyan-600 shadow-[0_0_8px_rgba(6,182,212,0.4)]"}),o.jsx(gs,{className:F("h-[18px] w-[18px] transition-colors",m?"text-cyan-400":"text-muted-foreground group-hover:text-foreground")}),o.jsx(Ar,{label:"Settings"})]})}),o.jsxs("div",{className:"flex flex-col items-center gap-1 pt-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-cyan-500 shadow-[0_0_6px_rgba(6,182,212,0.5)] pulse-live"}),o.jsx("span",{className:"text-[9px] text-muted-foreground/50 font-mono",children:"0.1"})]})]})]})}const dg=({...e})=>o.jsx(Ym,{className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e});function Vt({className:e,variant:t="default",...n}){return o.jsx("div",{className:F("inline-flex items-center rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{"border-cyan-500/20 bg-cyan-500/10 text-cyan-400":t==="default","border-border bg-muted/50 text-muted-foreground":t==="secondary","border-red-500/20 bg-red-500/10 text-red-400":t==="destructive","border-border text-muted-foreground":t==="outline","border-emerald-500/20 bg-emerald-500/10 text-emerald-400":t==="success","border-amber-500/20 bg-amber-500/10 text-amber-400":t==="warning"},e),...n})}function Lg(e){return e.filter(t=>t.source==="transcript"&&(t.type==="user"||t.type==="assistant"||t.type==="system")).map(t=>{var a,i;const n=typeof t.payload=="string"?JSON.parse(t.payload):t.payload;let r="";(a=n.message)!=null&&a.content?r=ns(n.message.content):n.content?r=ns(n.content):n.text&&(r=n.text);let s;return(i=n.message)!=null&&i.usage&&(s={prompt:n.message.usage.input_tokens||0,completion:n.message.usage.output_tokens||0}),{role:t.type||"system",content:r,timestamp:new Date(t.timestamp),tokens:s}}).sort((t,n)=>t.timestamp.getTime()-n.timestamp.getTime())}function ns(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>typeof t=="string"?t:t.type==="text"?t.text:t.type==="tool_use"?`[Tool: ${t.name}]`:JSON.stringify(t)).join(`
204
- `):JSON.stringify(e,null,2)}function fr(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}const ug=[{key:"active",label:"Active",icon:xt,gradient:"from-cyan-500/20 to-cyan-600/5",iconColor:"text-cyan-400",borderGlow:"shadow-[inset_0_1px_0_0_rgba(6,182,212,0.1)]"},{key:"messages",label:"Messages",icon:yl,gradient:"from-emerald-500/20 to-emerald-600/5",iconColor:"text-emerald-400",borderGlow:"shadow-[inset_0_1px_0_0_rgba(16,185,129,0.1)]"},{key:"tokens",label:"Tokens",icon:Bc,gradient:"from-violet-500/20 to-violet-600/5",iconColor:"text-violet-400",borderGlow:"shadow-[inset_0_1px_0_0_rgba(139,92,246,0.1)]"},{key:"cache",label:"Cache",icon:Il,gradient:"from-amber-500/20 to-amber-600/5",iconColor:"text-amber-400",borderGlow:"shadow-[inset_0_1px_0_0_rgba(245,158,11,0.1)]"}],rs={RUNNING:0,STARTING:1,NEEDS_PERMISSION:2,NEEDS_INPUT:3,STOPPED:4,CRASHED:5};function fg(){const e=gt(),{sessions:t}=on(),[n,r]=c.useState(null),s=c.useCallback(async()=>{try{const p=await fetch("/api/analytics/overview?range=today");p.ok&&r(await p.json())}catch{}},[]);c.useEffect(()=>{s()},[s]);const a=t.filter(to),i=c.useMemo(()=>sn(t),[t]),l=[...t].sort((p,h)=>{const u=rs[p.status]??99,x=rs[h.status]??99;return u!==x?u-x:new Date(h.createdAt).getTime()-new Date(p.createdAt).getTime()}).slice(0,5),d=p=>{switch(p){case"active":return a.length.toString();case"messages":return fr((n==null?void 0:n.totalMessages)??0);case"tokens":return fr((n==null?void 0:n.inputTokens)!=null?n.inputTokens+n.outputTokens:(n==null?void 0:n.totalTokens)??0);case"cache":return`${(n==null?void 0:n.cacheHitRate)??0}%`;default:return"0"}},f=p=>{switch(p){case"active":return`${t.length} total`;case"messages":return"User + assistant";case"tokens":return n!=null&&n.cacheReadTokens?`${fr(n.cacheReadTokens)} cached`:void 0;default:return}},m=p=>{switch(Ya(p)){case"green":return"success";case"yellow":return"warning";case"red":return"destructive";default:return"secondary"}};return o.jsx("div",{className:"p-4 md:p-8",children:o.jsxs("div",{className:"max-w-7xl mx-auto",children:[o.jsxs("div",{className:"mb-6 md:mb-8",children:[o.jsx("h1",{className:"text-2xl md:text-3xl font-bold tracking-tight",children:"Dashboard"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Monitor your active sessions and system metrics"})]}),o.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 md:gap-4 mb-6 md:mb-8",children:ug.map(p=>{const h=f(p.key);return o.jsxs("div",{className:`relative rounded-xl border border-border bg-gradient-to-b ${p.gradient} backdrop-blur-sm p-4 md:p-5 ${p.borderGlow}`,children:[o.jsxs("div",{className:"flex items-center justify-between mb-2 md:mb-3",children:[o.jsx("span",{className:"text-[10px] md:text-xs font-medium text-muted-foreground uppercase tracking-wider",children:p.label}),o.jsx(p.icon,{className:`h-3.5 w-3.5 md:h-4 md:w-4 ${p.iconColor}`})]}),o.jsx("div",{className:"text-2xl md:text-3xl font-bold tracking-tight",children:d(p.key)}),h&&o.jsx("div",{className:"text-[10px] md:text-xs text-muted-foreground mt-1",children:h})]},p.key)})}),o.jsxs("div",{className:"rounded-xl border border-border bg-card backdrop-blur-sm overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 md:px-6 py-3 md:py-4 border-b border-border",children:[o.jsx("h2",{className:"text-sm font-semibold tracking-wide",children:"Recent Sessions"}),o.jsxs("button",{type:"button",onClick:()=>e("/sessions"),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-cyan-400 transition-colors",children:["View all ",o.jsx(Wc,{className:"h-3 w-3"})]})]}),o.jsx("div",{children:l.length===0?o.jsxs("div",{className:"py-12 md:py-16 text-center",children:[o.jsx(xt,{className:"h-8 w-8 text-muted-foreground/30 mx-auto mb-3"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"No sessions yet"}),o.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1",children:"Create one from the Sessions page"})]}):o.jsx("div",{children:l.map(p=>{const h=Rt(p,i);return o.jsxs("div",{className:"flex items-center justify-between px-4 md:px-6 py-3 md:py-3.5 hover:bg-accent/50 cursor-pointer transition-colors border-b border-border/60 last:border-0 active:bg-accent/70",onClick:()=>e(`/sessions/${p.id}`),children:[o.jsxs("div",{className:"flex items-center gap-2 md:gap-3 min-w-0",children:[o.jsx(Vt,{variant:m(p.status),className:"shrink-0",children:p.status}),o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"font-mono text-sm text-foreground shrink-0",children:Pt(p.id,8)}),o.jsx("span",{className:"text-muted-foreground text-sm truncate hidden sm:inline",children:Pt(h,40)})]})]}),o.jsx("div",{className:"flex items-center gap-3 md:gap-4 shrink-0",children:o.jsx("span",{className:"text-[11px] text-muted-foreground",children:jn(p.createdAt)})})]},p.id)})})})]})]})})}function os({provider:e,compact:t=!1,className:n}){const r=lo(e),s=r.icon;return o.jsxs("span",{className:F("inline-flex items-center rounded-full border font-medium backdrop-blur-[1px] shadow-[inset_0_1px_0_rgba(255,255,255,0.22)] transition-colors dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",t?"gap-1 px-2 py-0.5 text-[10px]":"gap-1.5 px-2.5 py-1 text-[11px]",r.className,n),children:[o.jsx("span",{className:F("inline-block h-1.5 w-1.5 rounded-full",r.dotClassName)}),o.jsx("span",{className:F("inline-flex items-center justify-center rounded-full border border-current/20 bg-background/70",t?"h-4 w-4":"h-[18px] w-[18px]"),children:o.jsx(s,{className:F("shrink-0",t?"h-2.5 w-2.5":"h-3 w-3")})}),o.jsx("span",{className:F("leading-none",t?"max-w-[80px] truncate":""),children:r.label})]})}function pg({statusFilter:e,providerFilter:t,providerOptions:n,searchQuery:r,onStatusChange:s,onProviderChange:a,onSearchChange:i}){return o.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:gap-3 mb-4 md:mb-6",children:[o.jsxs("div",{className:"flex-1 relative",children:[o.jsx(Sl,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground/40"}),o.jsx(Tt,{placeholder:"Search sessions...",value:r,onChange:l=>i(l.target.value),className:"w-full pl-9 border-border bg-muted/30 placeholder:text-muted-foreground/30"})]}),o.jsxs(Rn,{value:e,onValueChange:s,children:[o.jsx(Jt,{className:"sm:w-[160px] border-border bg-muted/30 text-xs sm:text-sm",children:o.jsx(An,{placeholder:"Status"})}),o.jsxs(Xt,{children:[o.jsx(Ne,{value:"all",children:"All Statuses"}),o.jsx(Ne,{value:"RUNNING",children:"Running"}),o.jsx(Ne,{value:"STARTING",children:"Starting"}),o.jsx(Ne,{value:"STOPPED",children:"Stopped"}),o.jsx(Ne,{value:"CRASHED",children:"Crashed"}),o.jsx(Ne,{value:"NEEDS_PERMISSION",children:"Needs Permission"}),o.jsx(Ne,{value:"NEEDS_INPUT",children:"Needs Input"})]})]}),o.jsxs(Rn,{value:t,onValueChange:a,children:[o.jsx(Jt,{className:"sm:w-[170px] border-border bg-muted/30 text-xs sm:text-sm",children:o.jsx(An,{placeholder:"Provider"})}),o.jsxs(Xt,{children:[o.jsx(Ne,{value:"all",children:"All Providers"}),n.map(l=>o.jsx(Ne,{value:l.value,children:l.label},l.value))]})]})]})}function ss({session:e,onStatusChange:t}){const[n,r]=c.useState(!1),s=async()=>{try{r(!0),await ae.stopSession(e.id),t==null||t(e.id,"STOPPED"),ve.success(`Session ${e.id.slice(0,8)} stopped`)}catch(h){ve.error(h instanceof Error?h.message:"Failed to stop session")}finally{r(!1)}},a=async()=>{try{r(!0),await ae.killSession(e.id),t==null||t(e.id,"STOPPED"),ve.success(`Session ${e.id.slice(0,8)} killed`)}catch(h){ve.error(h instanceof Error?h.message:"Failed to kill session")}finally{r(!1)}},i=async()=>{try{r(!0),await ae.resumeSession(e.id),t==null||t(e.id,"RUNNING"),ve.success(`Session ${e.id.slice(0,8)} resumed`)}catch(h){ve.error(h instanceof Error?h.message:"Failed to resume session")}finally{r(!1)}},l=async()=>{try{r(!0),await ae.recoverSession(e.id),t==null||t(e.id,"RUNNING"),ve.success(`Session ${e.id.slice(0,8)} recovered`)}catch(h){ve.error(h instanceof Error?h.message:"Failed to recover session")}finally{r(!1)}},d=e.status==="RUNNING"||e.status==="STARTING",f=e.status!=="STOPPED"&&e.status!=="CRASHED",m=e.status==="STOPPED"||e.status==="CRASHED",p=e.status==="STOPPED"||e.status==="CRASHED";return o.jsxs(Ja,{children:[o.jsx(Xa,{asChild:!0,children:o.jsx(qt,{variant:"ghost",size:"sm",disabled:n,className:"h-7 w-7 p-0 hover:bg-accent",children:o.jsx(il,{className:"h-4 w-4 text-muted-foreground"})})}),o.jsxs(no,{align:"end",className:"border-border bg-popover",children:[m&&o.jsx(Wt,{onClick:i,className:"text-cyan-400 text-sm focus:text-cyan-400",children:"Resume (Provider)"}),p&&o.jsx(Wt,{onClick:l,className:"text-blue-400 text-sm focus:text-blue-400",children:"Recover (Tmux)"}),o.jsx(Wt,{onClick:s,disabled:!d,className:"text-sm",children:"Stop"}),o.jsx(ro,{className:"bg-accent"}),o.jsx(Wt,{onClick:a,disabled:!f,className:"text-red-400 text-sm focus:text-red-400",children:"Kill"})]})]})}const Bt=15;function mg(){const e=gt(),{sessions:t,loading:n,error:r,updateSessionStatus:s}=on(),{counts:a}=rn(),[i,l]=c.useState("all"),[d,f]=c.useState("all"),[m,p]=c.useState(""),[h,u]=c.useState(1),x=c.useMemo(()=>sn(t),[t]),g=c.useMemo(()=>{const S={RUNNING:0,STARTING:1,NEEDS_PERMISSION:2,NEEDS_INPUT:3,STOPPED:4,CRASHED:5};return t.filter(C=>{if(i!=="all"&&C.status!==i||d!=="all"&&C.provider!==d)return!1;if(m){const k=m.toLowerCase(),I=Rt(C,x).toLowerCase();return C.id.toLowerCase().includes(k)||I.includes(k)||C.cwd.toLowerCase().includes(k)||C.provider.toLowerCase().includes(k)}return!0}).sort((C,k)=>{const I=S[C.status]??99,H=S[k.status]??99;if(I!==H)return I-H;const D=new Date(C.createdAt).getTime();return new Date(k.createdAt).getTime()-D})},[t,i,d,m,x]),y=Math.max(1,Math.ceil(g.length/Bt)),b=Math.min(h,y),v=g.slice((b-1)*Bt,b*Bt),w=c.useMemo(()=>{const S=new Set(t.map(C=>C.provider));return Array.from(S).sort((C,k)=>C.localeCompare(k)).map(C=>({value:C,label:lo(C).label}))},[t]);c.useEffect(()=>{if(d==="all")return;w.some(C=>C.value===d)||f("all")},[d,w]);const E=S=>{switch(Ya(S)){case"green":return"success";case"yellow":return"warning";case"red":return"destructive";case"blue":case"cyan":return"default";default:return"secondary"}};return r?o.jsx("div",{className:"p-4 md:p-8 max-w-7xl mx-auto",children:o.jsxs("div",{className:"rounded-xl border border-red-500/20 bg-red-500/[0.05] p-4 text-red-400 text-sm",children:["Error loading sessions: ",r]})}):o.jsxs("div",{className:"p-4 md:p-8 max-w-7xl mx-auto",children:[o.jsxs("div",{className:"flex justify-between items-center mb-4 md:mb-6",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl md:text-3xl font-bold tracking-tight",children:"Sessions"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1 hidden sm:block",children:"Manage your interactive CLI sessions"})]}),o.jsx("div",{className:"hidden sm:block",children:o.jsx(ho,{})})]}),o.jsx(pg,{statusFilter:i,providerFilter:d,providerOptions:w,searchQuery:m,onStatusChange:S=>{l(S),u(1)},onProviderChange:S=>{f(S),u(1)},onSearchChange:S=>{p(S),u(1)}}),n?o.jsx("div",{className:"flex justify-center items-center h-64",children:o.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[o.jsx("div",{className:"w-4 h-4 border-2 border-cyan-500/30 border-t-cyan-500 rounded-full animate-spin"}),o.jsx("span",{className:"text-sm",children:"Loading sessions..."})]})}):g.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center h-64 rounded-xl border border-border bg-card/80",children:[o.jsx(xt,{className:"h-10 w-10 text-muted-foreground/20 mb-3"}),o.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"No sessions found"}),t.length===0&&o.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Create your first session to get started"})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"hidden md:block rounded-xl border border-border overflow-hidden bg-card/80 backdrop-blur-sm",children:[o.jsxs("div",{className:"grid grid-cols-[1fr_130px_110px_92px_1.3fr_100px_60px] gap-4 px-5 py-3 border-b border-border text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:[o.jsx("div",{children:"ID"}),o.jsx("div",{children:"Provider"}),o.jsx("div",{children:"Status"}),o.jsx("div",{children:"Unread"}),o.jsx("div",{children:"Session"}),o.jsx("div",{children:"Created"}),o.jsx("div",{className:"text-right",children:"Actions"})]}),v.map(S=>{const C=a.bySession[S.id]??0,k=Rt(S,x);return o.jsxs("div",{className:"grid grid-cols-[1fr_130px_110px_92px_1.3fr_100px_60px] gap-4 px-5 py-3 items-center border-b border-border/60 last:border-0 hover:bg-accent/50 cursor-pointer transition-colors",onClick:()=>e(`/sessions/${S.id}`),children:[o.jsx("div",{className:"font-mono text-sm text-foreground",children:Pt(S.id,8)}),o.jsx("div",{children:o.jsx(os,{provider:S.provider,compact:!0})}),o.jsx("div",{children:o.jsx(Vt,{variant:E(S.status),children:S.status})}),o.jsx("div",{children:C>0?o.jsx(Vt,{variant:"warning",className:"font-mono",children:C>99?"99+":C}):o.jsx("span",{className:"text-xs text-muted-foreground/35",children:"0"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-sm text-foreground truncate",children:k}),o.jsx("div",{className:"text-[11px] text-muted-foreground truncate",children:Pt(S.cwd,50)})]}),o.jsx("div",{className:"text-xs text-muted-foreground",children:jn(S.createdAt)}),o.jsx("div",{className:"text-right",onClick:I=>I.stopPropagation(),children:o.jsx(ss,{session:S,onStatusChange:s})})]},S.id)})]}),o.jsx("div",{className:"md:hidden space-y-2",children:v.map(S=>{const C=a.bySession[S.id]??0,k=Rt(S,x);return o.jsxs("div",{className:"rounded-xl border border-border bg-card/80 p-3.5 active:bg-accent/50 cursor-pointer transition-colors",onClick:()=>e(`/sessions/${S.id}`),children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(os,{provider:S.provider,compact:!0}),o.jsx(Vt,{variant:E(S.status),className:"text-[10px]",children:S.status}),C>0&&o.jsxs(Vt,{variant:"warning",className:"text-[10px] font-mono",children:[C>99?"99+":C," unread"]}),o.jsx("span",{className:"font-mono text-sm text-foreground",children:Pt(S.id,8)})]}),o.jsx("div",{onClick:I=>I.stopPropagation(),children:o.jsx(ss,{session:S,onStatusChange:s})})]}),o.jsx("div",{className:"text-sm text-foreground truncate mb-0.5",children:k}),o.jsx("div",{className:"text-xs text-muted-foreground truncate font-mono mb-1",children:Pt(S.cwd,45)}),o.jsx("div",{className:"text-[11px] text-muted-foreground/60",children:jn(S.createdAt)})]},S.id)})})]}),o.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[o.jsxs("div",{className:"text-xs text-muted-foreground",children:[(b-1)*Bt+1,"–",Math.min(b*Bt,g.length)," ","of ",g.length,g.length!==t.length&&o.jsxs("span",{className:"text-muted-foreground/40",children:[" (",t.length," total)"]})]}),y>1&&o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{type:"button",onClick:()=>u(S=>Math.max(1,S-1)),disabled:b<=1,className:"h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-accent/60 disabled:opacity-20 disabled:cursor-not-allowed transition-colors",children:o.jsx(el,{className:"h-4 w-4"})}),Array.from({length:y},(S,C)=>C+1).map(S=>o.jsx("button",{type:"button",onClick:()=>u(S),className:`h-7 min-w-[28px] px-1.5 flex items-center justify-center rounded-md text-xs font-mono transition-colors ${S===b?"bg-cyan-500/10 text-cyan-400 border border-cyan-500/20":"text-muted-foreground hover:text-foreground hover:bg-accent/60"}`,children:S},S)),o.jsx("button",{type:"button",onClick:()=>u(S=>Math.min(y,S+1)),disabled:b>=y,className:"h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-accent/60 disabled:opacity-20 disabled:cursor-not-allowed transition-colors",children:o.jsx(gn,{className:"h-4 w-4"})})]})]})]})}const hg=c.lazy(async()=>({default:(await Zt(()=>import("./AnalyticsPage-B2Jo5KhD.js"),__vite__mapDeps([0,1,2,3,4]))).AnalyticsPage})),gg=c.lazy(async()=>({default:(await Zt(()=>import("./PoliciesPage-Co0wDxU6.js"),__vite__mapDeps([5,1,6,7,8,3,4,2]))).PoliciesPage})),as=c.lazy(async()=>({default:(await Zt(()=>import("./SessionDetailPage-B02hN2vV.js"),__vite__mapDeps([9,1,3,4,10,7,11,12,8,2]))).SessionDetailPage})),xg=c.lazy(async()=>({default:(await Zt(()=>import("./SettingsPage-CsblfgAu.js"),__vite__mapDeps([13,1,10,6,8,3,4,2]))).SettingsPage})),yg=c.lazy(async()=>({default:(await Zt(()=>import("./WorkflowsPage-D6nmynEV.js"),__vite__mapDeps([14,1,3,4,2]))).WorkflowsPage}));function kt(){return o.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"Loading page..."})}function bg(e){var t;if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable||e instanceof HTMLTextAreaElement)return!0;if(e instanceof HTMLInputElement){if(e.disabled||e.readOnly)return!1;const n=((t=e.type)==null?void 0:t.toLowerCase())??"text";return!["button","checkbox","file","hidden","radio","range","reset","submit"].includes(n)}return!1}function vg(){const[e,t]=c.useState(!1);return c.useEffect(()=>{if(typeof window>"u")return;const n=window.visualViewport,r=window.matchMedia("(pointer: coarse)");let s=null,a=null;const i=()=>{const f=r.matches,m=bg(document.activeElement),p=f&&m;t(h=>h===p?h:p),document.documentElement.classList.toggle("keyboard-open",p)},l=()=>{s!==null&&cancelAnimationFrame(s),s=requestAnimationFrame(()=>{s=null,i()})},d=()=>{a&&clearTimeout(a),a=setTimeout(l,120)};return i(),n==null||n.addEventListener("resize",l),n==null||n.addEventListener("scroll",l),window.addEventListener("resize",l),window.addEventListener("orientationchange",l),window.addEventListener("focusin",l),window.addEventListener("focusout",d),()=>{s!==null&&cancelAnimationFrame(s),a&&clearTimeout(a),n==null||n.removeEventListener("resize",l),n==null||n.removeEventListener("scroll",l),window.removeEventListener("resize",l),window.removeEventListener("orientationchange",l),window.removeEventListener("focusin",l),window.removeEventListener("focusout",d)}},[]),{keyboardOpen:e}}function wg(){const e=In(),t=/^\/sessions\/[^/]+/.test(e.pathname),{keyboardOpen:n}=vg(),r=F("flex-1 overflow-auto md:pb-0",n?"pb-[max(0.5rem,env(safe-area-inset-bottom,0px))]":"pb-36");return o.jsx(Ic,{children:o.jsx(am,{children:o.jsxs("div",{className:"flex h-[100dvh] app-background noise",children:[o.jsx(lg,{}),o.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[o.jsx("div",{className:t?"hidden md:block":"",children:o.jsx(Sm,{})}),o.jsx("main",{className:r,children:o.jsxs(kc,{children:[o.jsx(ze,{path:"/",element:o.jsx(fg,{})}),o.jsx(ze,{path:"/sessions",element:o.jsx(mg,{})}),o.jsx(ze,{path:"/sessions/:id",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(as,{})})}),o.jsx(ze,{path:"/sessions/:id/:tab",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(as,{})})}),o.jsx(ze,{path:"/analytics",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(hg,{})})}),o.jsx(ze,{path:"/workflows",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(yg,{})})}),o.jsx(ze,{path:"/policies",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(gg,{})})}),o.jsx(ze,{path:"/settings",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(xg,{})})}),o.jsx(ze,{path:"*",element:o.jsx(jc,{to:"/",replace:!0})})]})})]}),o.jsx(ag,{keyboardOpen:n})]})})})}function Sg(){return c.useEffect(()=>(at.connect(),()=>{at.close()}),[]),o.jsx(Sp,{children:o.jsx(_c,{children:o.jsxs(Cc,{children:[o.jsx(wg,{}),o.jsx(dg,{})]})})})}const Ng=6e4;let is=!1;function Eg(e){const t=()=>{const n=e.installing;n&&n.addEventListener("statechange",()=>{n.state==="installed"&&navigator.serviceWorker.controller&&Pn(e)})};e.addEventListener("updatefound",t),t(),Pn(e)}function Cg(e){const t=()=>{e.update().catch(()=>{})};t(),window.setInterval(t,Ng),window.addEventListener("focus",t),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&t()})}function kg(){typeof window>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{is||(is=!0,window.location.reload())}),window.addEventListener("load",()=>{navigator.serviceWorker.register(ii()).then(e=>{Eg(e),Cg(e)}).catch(()=>{})}))}kg();const wc=document.getElementById("root");if(!wc)throw new Error("Root element not found");Pc.createRoot(wc).render(o.jsx(P.StrictMode,{children:o.jsx(Sg,{})}));export{Ya as $,Bc as A,qt as B,er as C,vh as D,on as E,rn as F,ms as G,kr as H,Tt as I,Jm as J,Og as K,Or as L,yl as M,rh as N,th as O,On as P,sn as Q,di as R,Rn as S,ys as T,Rt as U,ui as V,Pt as W,Rl as X,os as Y,Il as Z,Np as _,F as a,co as a0,Ag as a1,Tp as a2,Pn as a3,ii as a4,Mg as a5,Ig as a6,fl as a7,jt as a8,Mn as a9,gl as aa,ll as ab,gs as ac,Lr as ad,Kt as ae,Q as af,Ye as ag,Hu as ah,Vu as ai,B as aj,it as ak,yt as al,Ys as am,Jt as b,ee as c,An as d,Xt as e,fr as f,Ne as g,Vt as h,jn as i,ae as j,wh as k,Ai as l,Ii as m,Oi as n,Di as o,Mi as p,gn as q,xs as r,tg as s,so as t,ve as u,Lg as v,at as w,xt as x,Sl as y,fs as z};
203
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return c.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},hh="DialogDescriptionWarning",gh=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ki(hh).contentName}}.`;return c.useEffect(()=>{var a;const s=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},xh=pi,yh=hi,bh=xi,ji=yi,Pi=bi,Ti=wi,_i=Ni;const vh=xh,wh=yh,Sh=bh,Ri=c.forwardRef(({className:e,...t},n)=>o.jsx(ji,{ref:n,className:$("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Ri.displayName=ji.displayName;const Ai=c.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(Sh,{children:[o.jsx(Ri,{}),o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:o.jsx(Pi,{ref:r,className:$("grid w-full max-w-lg gap-4 border bg-background p-6 shadow-lg duration-200 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 sm:rounded-lg",e),...n,children:t})})]}));Ai.displayName=Pi.displayName;const Ii=({className:e,...t})=>o.jsx("div",{className:$("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ii.displayName="DialogHeader";const Mi=({className:e,...t})=>o.jsx("div",{className:$("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Mi.displayName="DialogFooter";const Oi=c.forwardRef(({className:e,...t},n)=>o.jsx(Ti,{ref:n,className:$("text-lg font-semibold leading-none tracking-tight",e),...t}));Oi.displayName=Ti.displayName;const Di=c.forwardRef(({className:e,...t},n)=>o.jsx(_i,{ref:n,className:$("text-sm text-muted-foreground",e),...t}));Di.displayName=_i.displayName;const Tt=c.forwardRef(({className:e,type:t,...n},r)=>o.jsx("input",{type:t,className:$("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));Tt.displayName="Input";function es(e,[t,n]){return Math.min(n,Math.max(t,e))}function Nh(e){const t=c.useRef({value:e,previous:e});return c.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Li=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Eh="VisuallyHidden",Ch=c.forwardRef((e,t)=>o.jsx(Q.span,{...e,ref:t,style:{...Li,...e.style}}));Ch.displayName=Eh;var kh=[" ","Enter","ArrowUp","ArrowDown"],jh=[" ","Enter"],mt="Select",[Yn,Jn,Ph]=Dr(mt),[$t]=yt(mt,[Ph,Hn]),Xn=Hn(),[Th,ct]=$t(mt),[_h,Rh]=$t(mt),$i=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:s,onOpenChange:a,value:i,defaultValue:l,onValueChange:d,dir:f,name:m,autoComplete:p,disabled:h,required:u,form:x}=e,g=Xn(t),[y,b]=c.useState(null),[v,w]=c.useState(null),[E,S]=c.useState(!1),C=Lr(f),[k,I]=Kt({prop:r,defaultProp:s??!1,onChange:a,caller:mt}),[W,B]=Kt({prop:i,defaultProp:l,onChange:d,caller:mt}),H=c.useRef(null),j=y?x||!!y.closest("form"):!0,[D,L]=c.useState(new Set),T=Array.from(D).map(P=>P.props.value).join(";");return o.jsx(Vs,{...g,children:o.jsxs(Th,{required:u,scope:t,trigger:y,onTriggerChange:b,valueNode:v,onValueNodeChange:w,valueNodeHasChildren:E,onValueNodeHasChildrenChange:S,contentId:Ye(),value:W,onValueChange:B,open:k,onOpenChange:I,dir:C,triggerPointerDownPosRef:H,disabled:h,children:[o.jsx(Yn.Provider,{scope:t,children:o.jsx(_h,{scope:e.__scopeSelect,onNativeOptionAdd:c.useCallback(P=>{L(R=>new Set(R).add(P))},[]),onNativeOptionRemove:c.useCallback(P=>{L(R=>{const A=new Set(R);return A.delete(P),A})},[]),children:n})}),j?o.jsxs(cc,{"aria-hidden":!0,required:u,tabIndex:-1,name:m,autoComplete:p,value:W,onChange:P=>B(P.target.value),disabled:h,form:x,children:[W===void 0?o.jsx("option",{value:""}):null,Array.from(D)]},T):null]})})};$i.displayName=mt;var Fi="SelectTrigger",Bi=c.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...s}=e,a=Xn(n),i=ct(Fi,n),l=i.disabled||r,d=oe(t,i.onTriggerChange),f=Jn(n),m=c.useRef("touch"),[p,h,u]=dc(g=>{const y=f().filter(w=>!w.disabled),b=y.find(w=>w.value===i.value),v=uc(y,g,b);v!==void 0&&i.onValueChange(v.value)}),x=g=>{l||(i.onOpenChange(!0),u()),g&&(i.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return o.jsx(qs,{asChild:!0,...a,children:o.jsx(Q.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":lc(i.value)?"":void 0,...s,ref:d,onClick:F(s.onClick,g=>{g.currentTarget.focus(),m.current!=="mouse"&&x(g)}),onPointerDown:F(s.onPointerDown,g=>{m.current=g.pointerType;const y=g.target;y.hasPointerCapture(g.pointerId)&&y.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(x(g),g.preventDefault())}),onKeyDown:F(s.onKeyDown,g=>{const y=p.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&h(g.key),!(y&&g.key===" ")&&kh.includes(g.key)&&(x(),g.preventDefault())})})})});Bi.displayName=Fi;var Ui="SelectValue",Wi=c.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:s,children:a,placeholder:i="",...l}=e,d=ct(Ui,n),{onValueNodeHasChildrenChange:f}=d,m=a!==void 0,p=oe(t,d.onValueNodeChange);return me(()=>{f(m)},[f,m]),o.jsx(Q.span,{...l,ref:p,style:{pointerEvents:"none"},children:lc(d.value)?o.jsx(o.Fragment,{children:i}):a})});Wi.displayName=Ui;var Ah="SelectIcon",Hi=c.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...s}=e;return o.jsx(Q.span,{"aria-hidden":!0,...s,ref:t,children:r||"▼"})});Hi.displayName=Ah;var Ih="SelectPortal",Vi=e=>o.jsx(Vn,{asChild:!0,...e});Vi.displayName=Ih;var ht="SelectContent",qi=c.forwardRef((e,t)=>{const n=ct(ht,e.__scopeSelect),[r,s]=c.useState();if(me(()=>{s(new DocumentFragment)},[]),!n.open){const a=r;return a?Ot.createPortal(o.jsx(Ki,{scope:e.__scopeSelect,children:o.jsx(Yn.Slot,{scope:e.__scopeSelect,children:o.jsx("div",{children:e.children})})}),a):null}return o.jsx(zi,{...e,ref:t})});qi.displayName=ht;var Me=10,[Ki,lt]=$t(ht),Mh="SelectContentImpl",Oh=At("SelectContent.RemoveScroll"),zi=c.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:a,onPointerDownOutside:i,side:l,sideOffset:d,align:f,alignOffset:m,arrowPadding:p,collisionBoundary:h,collisionPadding:u,sticky:x,hideWhenDetached:g,avoidCollisions:y,...b}=e,v=ct(ht,n),[w,E]=c.useState(null),[S,C]=c.useState(null),k=oe(t,M=>E(M)),[I,W]=c.useState(null),[B,H]=c.useState(null),j=Jn(n),[D,L]=c.useState(!1),T=c.useRef(!1);c.useEffect(()=>{if(w)return zr(w)},[w]),$r();const P=c.useCallback(M=>{const[Z,...X]=j().map(Y=>Y.ref.current),[J]=X.slice(-1),q=document.activeElement;for(const Y of M)if(Y===q||(Y==null||Y.scrollIntoView({block:"nearest"}),Y===Z&&S&&(S.scrollTop=0),Y===J&&S&&(S.scrollTop=S.scrollHeight),Y==null||Y.focus(),document.activeElement!==q))return},[j,S]),R=c.useCallback(()=>P([I,w]),[P,I,w]);c.useEffect(()=>{D&&R()},[D,R]);const{onOpenChange:A,triggerPointerDownPosRef:N}=v;c.useEffect(()=>{if(w){let M={x:0,y:0};const Z=J=>{var q,Y;M={x:Math.abs(Math.round(J.pageX)-(((q=N.current)==null?void 0:q.x)??0)),y:Math.abs(Math.round(J.pageY)-(((Y=N.current)==null?void 0:Y.y)??0))}},X=J=>{M.x<=10&&M.y<=10?J.preventDefault():w.contains(J.target)||A(!1),document.removeEventListener("pointermove",Z),N.current=null};return N.current!==null&&(document.addEventListener("pointermove",Z),document.addEventListener("pointerup",X,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Z),document.removeEventListener("pointerup",X,{capture:!0})}}},[w,A,N]),c.useEffect(()=>{const M=()=>A(!1);return window.addEventListener("blur",M),window.addEventListener("resize",M),()=>{window.removeEventListener("blur",M),window.removeEventListener("resize",M)}},[A]);const[U,te]=dc(M=>{const Z=j().filter(q=>!q.disabled),X=Z.find(q=>q.ref.current===document.activeElement),J=uc(Z,M,X);J&&setTimeout(()=>J.ref.current.focus())}),V=c.useCallback((M,Z,X)=>{const J=!T.current&&!X;(v.value!==void 0&&v.value===Z||J)&&(W(M),J&&(T.current=!0))},[v.value]),z=c.useCallback(()=>w==null?void 0:w.focus(),[w]),G=c.useCallback((M,Z,X)=>{const J=!T.current&&!X;(v.value!==void 0&&v.value===Z||J)&&H(M)},[v.value]),ne=r==="popper"?jr:Gi,ie=ne===jr?{side:l,sideOffset:d,align:f,alignOffset:m,arrowPadding:p,collisionBoundary:h,collisionPadding:u,sticky:x,hideWhenDetached:g,avoidCollisions:y}:{};return o.jsx(Ki,{scope:n,content:w,viewport:S,onViewportChange:C,itemRefCallback:V,selectedItem:I,onItemLeave:z,itemTextRefCallback:G,focusSelectedItem:R,selectedItemText:B,position:r,isPositioned:D,searchRef:U,children:o.jsx(Ir,{as:Oh,allowPinchZoom:!0,children:o.jsx($n,{asChild:!0,trapped:v.open,onMountAutoFocus:M=>{M.preventDefault()},onUnmountAutoFocus:F(s,M=>{var Z;(Z=v.trigger)==null||Z.focus({preventScroll:!0}),M.preventDefault()}),children:o.jsx(Ln,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:M=>M.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:o.jsx(ne,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:M=>M.preventDefault(),...b,...ie,onPlaced:()=>L(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:F(b.onKeyDown,M=>{const Z=M.ctrlKey||M.altKey||M.metaKey;if(M.key==="Tab"&&M.preventDefault(),!Z&&M.key.length===1&&te(M.key),["ArrowUp","ArrowDown","Home","End"].includes(M.key)){let J=j().filter(q=>!q.disabled).map(q=>q.ref.current);if(["ArrowUp","End"].includes(M.key)&&(J=J.slice().reverse()),["ArrowUp","ArrowDown"].includes(M.key)){const q=M.target,Y=J.indexOf(q);J=J.slice(Y+1)}setTimeout(()=>P(J)),M.preventDefault()}})})})})})})});zi.displayName=Mh;var Dh="SelectItemAlignedPosition",Gi=c.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...s}=e,a=ct(ht,n),i=lt(ht,n),[l,d]=c.useState(null),[f,m]=c.useState(null),p=oe(t,k=>m(k)),h=Jn(n),u=c.useRef(!1),x=c.useRef(!0),{viewport:g,selectedItem:y,selectedItemText:b,focusSelectedItem:v}=i,w=c.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&f&&g&&y&&b){const k=a.trigger.getBoundingClientRect(),I=f.getBoundingClientRect(),W=a.valueNode.getBoundingClientRect(),B=b.getBoundingClientRect();if(a.dir!=="rtl"){const q=B.left-I.left,Y=W.left-q,ce=k.left-Y,de=k.width+ce,$e=Math.max(de,I.width),Pe=window.innerWidth-Me,we=es(Y,[Me,Math.max(Me,Pe-$e)]);l.style.minWidth=de+"px",l.style.left=we+"px"}else{const q=I.right-B.right,Y=window.innerWidth-W.right-q,ce=window.innerWidth-k.right-Y,de=k.width+ce,$e=Math.max(de,I.width),Pe=window.innerWidth-Me,we=es(Y,[Me,Math.max(Me,Pe-$e)]);l.style.minWidth=de+"px",l.style.right=we+"px"}const H=h(),j=window.innerHeight-Me*2,D=g.scrollHeight,L=window.getComputedStyle(f),T=parseInt(L.borderTopWidth,10),P=parseInt(L.paddingTop,10),R=parseInt(L.borderBottomWidth,10),A=parseInt(L.paddingBottom,10),N=T+P+D+A+R,U=Math.min(y.offsetHeight*5,N),te=window.getComputedStyle(g),V=parseInt(te.paddingTop,10),z=parseInt(te.paddingBottom,10),G=k.top+k.height/2-Me,ne=j-G,ie=y.offsetHeight/2,M=y.offsetTop+ie,Z=T+P+M,X=N-Z;if(Z<=G){const q=H.length>0&&y===H[H.length-1].ref.current;l.style.bottom="0px";const Y=f.clientHeight-g.offsetTop-g.offsetHeight,ce=Math.max(ne,ie+(q?z:0)+Y+R),de=Z+ce;l.style.height=de+"px"}else{const q=H.length>0&&y===H[0].ref.current;l.style.top="0px";const ce=Math.max(G,T+g.offsetTop+(q?V:0)+ie)+X;l.style.height=ce+"px",g.scrollTop=Z-G+g.offsetTop}l.style.margin=`${Me}px 0`,l.style.minHeight=U+"px",l.style.maxHeight=j+"px",r==null||r(),requestAnimationFrame(()=>u.current=!0)}},[h,a.trigger,a.valueNode,l,f,g,y,b,a.dir,r]);me(()=>w(),[w]);const[E,S]=c.useState();me(()=>{f&&S(window.getComputedStyle(f).zIndex)},[f]);const C=c.useCallback(k=>{k&&x.current===!0&&(w(),v==null||v(),x.current=!1)},[w,v]);return o.jsx($h,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:u,onScrollButtonChange:C,children:o.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:E},children:o.jsx(Q.div,{...s,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});Gi.displayName=Dh;var Lh="SelectPopperPosition",jr=c.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:s=Me,...a}=e,i=Xn(n);return o.jsx(Ks,{...i,...a,ref:t,align:r,collisionPadding:s,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});jr.displayName=Lh;var[$h,mo]=$t(ht,{}),Pr="SelectViewport",Yi=c.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...s}=e,a=lt(Pr,n),i=mo(Pr,n),l=oe(t,a.onViewportChange),d=c.useRef(0);return o.jsxs(o.Fragment,{children:[o.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),o.jsx(Yn.Slot,{scope:n,children:o.jsx(Q.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:F(s.onScroll,f=>{const m=f.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&p){const u=Math.abs(d.current-m.scrollTop);if(u>0){const x=window.innerHeight-Me*2,g=parseFloat(p.style.minHeight),y=parseFloat(p.style.height),b=Math.max(g,y);if(b<x){const v=b+u,w=Math.min(x,v),E=v-w;p.style.height=w+"px",p.style.bottom==="0px"&&(m.scrollTop=E>0?E:0,p.style.justifyContent="flex-end")}}}d.current=m.scrollTop})})})]})});Yi.displayName=Pr;var Ji="SelectGroup",[Fh,Bh]=$t(Ji),Uh=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Ye();return o.jsx(Fh,{scope:n,id:s,children:o.jsx(Q.div,{role:"group","aria-labelledby":s,...r,ref:t})})});Uh.displayName=Ji;var Xi="SelectLabel",Zi=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Bh(Xi,n);return o.jsx(Q.div,{id:s.id,...r,ref:t})});Zi.displayName=Xi;var _n="SelectItem",[Wh,Qi]=$t(_n),ec=c.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:s=!1,textValue:a,...i}=e,l=ct(_n,n),d=lt(_n,n),f=l.value===r,[m,p]=c.useState(a??""),[h,u]=c.useState(!1),x=oe(t,v=>{var w;return(w=d.itemRefCallback)==null?void 0:w.call(d,v,r,s)}),g=Ye(),y=c.useRef("touch"),b=()=>{s||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return o.jsx(Wh,{scope:n,value:r,disabled:s,textId:g,isSelected:f,onItemTextChange:c.useCallback(v=>{p(w=>w||((v==null?void 0:v.textContent)??"").trim())},[]),children:o.jsx(Yn.ItemSlot,{scope:n,value:r,disabled:s,textValue:m,children:o.jsx(Q.div,{role:"option","aria-labelledby":g,"data-highlighted":h?"":void 0,"aria-selected":f&&h,"data-state":f?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...i,ref:x,onFocus:F(i.onFocus,()=>u(!0)),onBlur:F(i.onBlur,()=>u(!1)),onClick:F(i.onClick,()=>{y.current!=="mouse"&&b()}),onPointerUp:F(i.onPointerUp,()=>{y.current==="mouse"&&b()}),onPointerDown:F(i.onPointerDown,v=>{y.current=v.pointerType}),onPointerMove:F(i.onPointerMove,v=>{var w;y.current=v.pointerType,s?(w=d.onItemLeave)==null||w.call(d):y.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:F(i.onPointerLeave,v=>{var w;v.currentTarget===document.activeElement&&((w=d.onItemLeave)==null||w.call(d))}),onKeyDown:F(i.onKeyDown,v=>{var E;((E=d.searchRef)==null?void 0:E.current)!==""&&v.key===" "||(jh.includes(v.key)&&b(),v.key===" "&&v.preventDefault())})})})})});ec.displayName=_n;var Ht="SelectItemText",tc=c.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:s,...a}=e,i=ct(Ht,n),l=lt(Ht,n),d=Qi(Ht,n),f=Rh(Ht,n),[m,p]=c.useState(null),h=oe(t,b=>p(b),d.onItemTextChange,b=>{var v;return(v=l.itemTextRefCallback)==null?void 0:v.call(l,b,d.value,d.disabled)}),u=m==null?void 0:m.textContent,x=c.useMemo(()=>o.jsx("option",{value:d.value,disabled:d.disabled,children:u},d.value),[d.disabled,d.value,u]),{onNativeOptionAdd:g,onNativeOptionRemove:y}=f;return me(()=>(g(x),()=>y(x)),[g,y,x]),o.jsxs(o.Fragment,{children:[o.jsx(Q.span,{id:d.textId,...a,ref:h}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Ot.createPortal(a.children,i.valueNode):null]})});tc.displayName=Ht;var nc="SelectItemIndicator",rc=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Qi(nc,n).isSelected?o.jsx(Q.span,{"aria-hidden":!0,...r,ref:t}):null});rc.displayName=nc;var Tr="SelectScrollUpButton",oc=c.forwardRef((e,t)=>{const n=lt(Tr,e.__scopeSelect),r=mo(Tr,e.__scopeSelect),[s,a]=c.useState(!1),i=oe(t,r.onScrollButtonChange);return me(()=>{if(n.viewport&&n.isPositioned){let l=function(){const f=d.scrollTop>0;a(f)};const d=n.viewport;return l(),d.addEventListener("scroll",l),()=>d.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?o.jsx(ac,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=n;l&&d&&(l.scrollTop=l.scrollTop-d.offsetHeight)}}):null});oc.displayName=Tr;var _r="SelectScrollDownButton",sc=c.forwardRef((e,t)=>{const n=lt(_r,e.__scopeSelect),r=mo(_r,e.__scopeSelect),[s,a]=c.useState(!1),i=oe(t,r.onScrollButtonChange);return me(()=>{if(n.viewport&&n.isPositioned){let l=function(){const f=d.scrollHeight-d.clientHeight,m=Math.ceil(d.scrollTop)<f;a(m)};const d=n.viewport;return l(),d.addEventListener("scroll",l),()=>d.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),s?o.jsx(ac,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=n;l&&d&&(l.scrollTop=l.scrollTop+d.offsetHeight)}}):null});sc.displayName=_r;var ac=c.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...s}=e,a=lt("SelectScrollButton",n),i=c.useRef(null),l=Jn(n),d=c.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return c.useEffect(()=>()=>d(),[d]),me(()=>{var m;const f=l().find(p=>p.ref.current===document.activeElement);(m=f==null?void 0:f.ref.current)==null||m.scrollIntoView({block:"nearest"})},[l]),o.jsx(Q.div,{"aria-hidden":!0,...s,ref:t,style:{flexShrink:0,...s.style},onPointerDown:F(s.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:F(s.onPointerMove,()=>{var f;(f=a.onItemLeave)==null||f.call(a),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:F(s.onPointerLeave,()=>{d()})})}),Hh="SelectSeparator",ic=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return o.jsx(Q.div,{"aria-hidden":!0,...r,ref:t})});ic.displayName=Hh;var Rr="SelectArrow",Vh=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Xn(n),a=ct(Rr,n),i=lt(Rr,n);return a.open&&i.position==="popper"?o.jsx(zs,{...s,...r,ref:t}):null});Vh.displayName=Rr;var qh="SelectBubbleInput",cc=c.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const s=c.useRef(null),a=oe(r,s),i=Nh(t);return c.useEffect(()=>{const l=s.current;if(!l)return;const d=window.HTMLSelectElement.prototype,m=Object.getOwnPropertyDescriptor(d,"value").set;if(i!==t&&m){const p=new Event("change",{bubbles:!0});m.call(l,t),l.dispatchEvent(p)}},[i,t]),o.jsx(Q.select,{...n,style:{...Li,...n.style},ref:a,defaultValue:t})});cc.displayName=qh;function lc(e){return e===""||e===void 0}function dc(e){const t=We(e),n=c.useRef(""),r=c.useRef(0),s=c.useCallback(i=>{const l=n.current+i;t(l),function d(f){n.current=f,window.clearTimeout(r.current),f!==""&&(r.current=window.setTimeout(()=>d(""),1e3))}(l)},[t]),a=c.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return c.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,s,a]}function uc(e,t,n){const s=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=Kh(e,Math.max(a,0));s.length===1&&(i=i.filter(f=>f!==n));const d=i.find(f=>f.textValue.toLowerCase().startsWith(s.toLowerCase()));return d!==n?d:void 0}function Kh(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var zh=$i,fc=Bi,Gh=Wi,Yh=Hi,Jh=Vi,pc=qi,Xh=Yi,mc=Zi,hc=ec,Zh=tc,Qh=rc,gc=oc,xc=sc,yc=ic;const Rn=zh,An=Gh,Jt=c.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(fc,{ref:r,className:$("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...n,children:[t,o.jsx(Yh,{asChild:!0,children:o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 opacity-50",children:o.jsx("path",{d:"M4.93179 5.43179C4.75605 5.60753 4.75605 5.89245 4.93179 6.06819C5.10753 6.24392 5.39245 6.24392 5.56819 6.06819L7.49999 4.13638L9.43179 6.06819C9.60753 6.24392 9.89245 6.24392 10.0682 6.06819C10.2439 5.89245 10.2439 5.60753 10.0682 5.43179L7.81819 3.18179C7.73379 3.0974 7.61933 3.04999 7.49999 3.04999C7.38064 3.04999 7.26618 3.0974 7.18179 3.18179L4.93179 5.43179ZM10.0682 9.56819C10.2439 9.39245 10.2439 9.10753 10.0682 8.93179C9.89245 8.75606 9.60753 8.75606 9.43179 8.93179L7.49999 10.8636L5.56819 8.93179C5.39245 8.75606 5.10753 8.75606 4.93179 8.93179C4.75605 9.10753 4.75605 9.39245 4.93179 9.56819L7.18179 11.8182C7.26618 11.9026 7.38064 11.95 7.49999 11.95C7.61933 11.95 7.73379 11.9026 7.81819 11.8182L10.0682 9.56819Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})})]}));Jt.displayName=fc.displayName;const bc=c.forwardRef(({className:e,...t},n)=>o.jsx(gc,{ref:n,className:$("flex cursor-default items-center justify-center py-1",e),...t,children:o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",children:o.jsx("path",{d:"M7.14645 2.14645C7.34171 1.95118 7.65829 1.95118 7.85355 2.14645L11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355C11.6583 7.04882 11.3417 7.04882 11.1464 6.85355L7.5 3.20711L3.85355 6.85355C3.65829 7.04882 3.34171 7.04882 3.14645 6.85355C2.95118 6.65829 2.95118 6.34171 3.14645 6.14645L7.14645 2.14645Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}));bc.displayName=gc.displayName;const vc=c.forwardRef(({className:e,...t},n)=>o.jsx(xc,{ref:n,className:$("flex cursor-default items-center justify-center py-1",e),...t,children:o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",children:o.jsx("path",{d:"M7.14645 12.8536C7.34171 13.0488 7.65829 13.0488 7.85355 12.8536L11.8536 8.85355C12.0488 8.65829 12.0488 8.34171 11.8536 8.14645C11.6583 7.95118 11.3417 7.95118 11.1464 8.14645L7.5 11.7929L3.85355 8.14645C3.65829 7.95118 3.34171 7.95118 3.14645 8.14645C2.95118 8.34171 2.95118 8.65829 3.14645 8.85355L7.14645 12.8536Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}));vc.displayName=xc.displayName;const Xt=c.forwardRef(({className:e,children:t,position:n="popper",...r},s)=>o.jsx(Jh,{children:o.jsxs(pc,{ref:s,className:$("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",n==="popper"&&"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:n,...r,children:[o.jsx(bc,{}),o.jsx(Xh,{className:$("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),o.jsx(vc,{})]})}));Xt.displayName=pc.displayName;const eg=c.forwardRef(({className:e,...t},n)=>o.jsx(mc,{ref:n,className:$("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));eg.displayName=mc.displayName;const Ne=c.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(hc,{ref:r,className:$("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(Qh,{children:o.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",children:o.jsx("path",{d:"M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})})}),o.jsx(Zh,{children:t})]}));Ne.displayName=hc.displayName;const tg=c.forwardRef(({className:e,...t},n)=>o.jsx(yc,{ref:n,className:$("-mx-1 my-1 h-px bg-muted",e),...t}));tg.displayName=yc.displayName;function ng(e){const t=e.trim();if(!t)return{args:[]};const n=[];let r="",s=null,a=!1;for(const i of t){if(a){r+=i,a=!1;continue}if(i==="\\"){a=!0;continue}if(s){i===s?s=null:r+=i;continue}if(i==='"'||i==="'"){s=i;continue}if(/\s/.test(i)){r.length>0&&(n.push(r),r="");continue}r+=i}return a&&(r+="\\"),s?{args:[],error:"Unclosed quote in arguments"}:(r.length>0&&n.push(r),{args:n})}function ho({onSessionCreated:e,children:t}){var Ft,Ke;const n=gt(),[r,s]=c.useState(!1),[a,i]=c.useState(!1),[l,d]=c.useState([...kr]),[f,m]=c.useState("claude-code"),[p,h]=c.useState(!1),[u,x]=c.useState("new"),[g,y]=c.useState(""),[b,v]=c.useState("resume"),[w,E]=c.useState("type"),[S,C]=c.useState(""),[k,I]=c.useState(""),[W,B]=c.useState(""),[H,j]=c.useState(!0),[D,L]=c.useState(!1),[T,P]=c.useState(!1),[R,A]=c.useState(""),[N,U]=c.useState(!1),[te,V]=c.useState(!1),[z,G]=c.useState(new Set),[ne,ie]=c.useState([]),[M,Z]=c.useState([]),[X,J]=c.useState(!1),[q,Y]=c.useState(null),[ce,de]=c.useState(null),[$e,Pe]=c.useState(!1),we=c.useRef(null),Te=c.useRef(null);c.useEffect(()=>{if(!r)return;let O=!1;return(async()=>{const[fe,xe,ye]=await Promise.allSettled([ae.getWorkspaces(),ae.getEnvSets(),ae.getProviders()]);O||(fe.status==="fulfilled"?(ie(fe.value.workspaces),fe.value.workspaces.length>0&&(E("workspace"),I(fe.value.workspaces[0].id))):ve.error("Failed to load workspaces"),xe.status==="fulfilled"?Z(xe.value.envSets):ve.error("Failed to load environment sets"),ye.status==="fulfilled"&&ye.value.providers.length>0?(d(ye.value.providers),m(Nt=>ye.value.providers.some(Fe=>Fe.id===Nt)?Nt:ye.value.providers[0].id)):d([...kr]))})(),()=>{O=!0}},[r]);const Se=l.find(O=>O.id===f),dt=(Se==null?void 0:Se.capabilities.supportsDangerousMode)===!0,ke=Se==null?void 0:Se.launchHints,ue=ke==null?void 0:ke.resumeCommands;c.useEffect(()=>{!dt&&p&&h(!1)},[p,dt]),c.useEffect(()=>{u==="resume"&&(P(!1),L(!1))},[u]);const pe=w==="workspace"?((Ft=ne.find(O=>O.id===k))==null?void 0:Ft.path)||"":S,an=c.useCallback(async O=>{if(!O){Y(null);return}J(!0);try{const fe=await ae.validateSession({cwd:O});Y(fe)}catch{Y(null)}finally{J(!1)}},[]);c.useEffect(()=>{if(we.current&&clearTimeout(we.current),!pe){Y(null);return}return we.current=setTimeout(()=>an(pe),500),()=>{we.current&&clearTimeout(we.current)}},[pe,an]);const cn=c.useCallback(async(O,fe,xe)=>{if(!(O&&fe)){de(null);return}Pe(!0);try{const ye=await ae.validateGit({cwd:O,branch:fe,createBranch:xe});de(ye)}catch{de(null)}finally{Pe(!1)}},[]);c.useEffect(()=>{if(!T){de(null);return}if(Te.current&&clearTimeout(Te.current),!R){de(null);return}return Te.current=setTimeout(()=>cn(pe,R,N),500),()=>{Te.current&&clearTimeout(Te.current)}},[R,N,pe,T,cn]);const ge=O=>{G(fe=>{const xe=new Set(fe);return xe.has(O)?xe.delete(O):xe.add(O),xe})},Ze=q&&!q.valid,Zn=u==="new"&&T&&ce&&!ce.valid,ln=u==="resume"&&g.trim().length===0,wt=pe&&!X&&!$e&&!Ze&&!Zn&&!ln,Qn=async()=>{if(!pe){ve.error("Working directory is required");return}try{const O=ng(W);if(O.error){ve.error(O.error);return}i(!0);const{session:fe}=await ae.createSession({provider:f,cwd:pe,args:O.args.length>0?O.args:void 0,dangerousMode:p,envSetIds:z.size>0?Array.from(z):void 0,providerResume:u==="resume"?{providerSessionId:g.trim(),mode:b}:void 0,worktree:u==="new"&&T&&R?{branch:R,createBranch:N}:void 0});ve.success("Session created successfully"),s(!1),dn(),e==null||e(),setTimeout(()=>n(`/sessions/${fe.id}`),300)}catch(O){ve.error(O instanceof Error?O.message:"Failed to create session")}finally{i(!1)}},dn=()=>{m("claude-code"),h(!1),x("new"),y(""),v("resume"),E("type"),C(""),I(""),B(""),j(!0),P(!1),A(""),U(!1),G(new Set),Y(null),de(null),L(!1),V(!1)},St=p?(ke==null?void 0:ke.dangerousModeFlags)??[]:[],qe=(()=>{if(u!=="resume"||!(ue!=null&&ue.resume))return;const O=g.trim()||"<provider-session-id>";return(b==="fork"?ue.fork??ue.resume:ue.resume).split("{id}").join(O)})();return o.jsxs(vh,{open:r,onOpenChange:s,children:[o.jsx(wh,{asChild:!0,children:t||o.jsxs(qt,{className:"bg-cyan-600 hover:bg-cyan-700 text-white border-0",children:[o.jsx(On,{className:"h-4 w-4 mr-1.5"}),"New Session"]})}),o.jsxs(Ai,{className:"border-border bg-popover max-w-lg max-h-[85vh] overflow-y-auto",children:[o.jsxs(Ii,{children:[o.jsx(Oi,{children:"Create New Session"}),o.jsx(Di,{className:"text-muted-foreground/60",children:"Start a new provider session in tmux."})]}),o.jsxs("div",{className:"space-y-5 py-2",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Provider *"}),o.jsx("div",{className:"grid gap-2",children:l.map(O=>{const fe=lo(O.id),xe=fe.icon,ye=f===O.id,Nt=[{label:O.capabilities.nativeHooks?"Native Hooks":"No Native Hooks",active:O.capabilities.nativeHooks},{label:O.capabilities.policyChannel==="input-preflight"?"Input Preflight Policy":"Hook Policy Channel",active:O.capabilities.policyChannel!=="none"},{label:O.capabilities.metricsChannel==="transcript"?"Transcript Metrics":O.capabilities.metricsChannel==="pty"?"PTY Metrics":"No Metrics",active:O.capabilities.metricsChannel!=="none"}];return o.jsx("button",{type:"button","aria-pressed":ye,onClick:()=>m(O.id),className:$("group rounded-xl border p-3 text-left transition-all",ye?"border-primary/45 bg-gradient-to-r from-primary/14 via-primary/6 to-transparent shadow-[0_8px_20px_rgba(0,0,0,0.12)]":"border-border/80 bg-muted/20 hover:border-border hover:bg-muted/35"),children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:$("mt-0.5 inline-flex h-8 w-8 items-center justify-center rounded-lg border",fe.className),children:o.jsx(xe,{className:"h-4 w-4"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:"text-sm font-semibold text-foreground",children:O.label}),o.jsx("span",{className:"rounded-full border border-border/70 bg-background/70 px-1.5 py-0.5 text-[10px] font-mono uppercase tracking-wide text-muted-foreground",children:O.runtime}),O.capabilities.nativeHooks&&o.jsx("span",{className:"rounded-full border border-emerald-500/30 bg-emerald-500/12 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-300",children:"Recommended"})]}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:nh(O)}),o.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:Nt.map(Qe=>o.jsx("span",{className:$("rounded-full border px-1.5 py-0.5 text-[10px]",Qe.active?"border-primary/25 bg-primary/10 text-primary":"border-border/70 bg-background/60 text-muted-foreground"),children:Qe.label},`${O.id}-${Qe.label}`))})]}),o.jsx("div",{className:$("mt-1 inline-flex h-5 w-5 items-center justify-center rounded-full border transition-colors",ye?"border-primary/50 bg-primary/15 text-primary":"border-border/70 text-transparent group-hover:border-primary/25"),children:o.jsx(Mr,{className:"h-3.5 w-3.5"})})]})},O.id)})})]}),o.jsxs("div",{className:"grid gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Session Mode"}),o.jsxs("div",{className:"flex gap-1 bg-muted/40 rounded-md p-0.5",children:[o.jsx("button",{type:"button",onClick:()=>x("new"),className:`flex-1 text-xs px-2.5 py-1.5 rounded transition-all ${u==="new"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"New Session"}),o.jsx("button",{type:"button",onClick:()=>x("resume"),className:`flex-1 text-xs px-2.5 py-1.5 rounded transition-all ${u==="resume"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Resume by ID"})]}),o.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:u==="new"?"Start a new provider conversation inside a CodePiper-managed tmux session.":"Attach a new CodePiper runtime to an existing provider conversation/session ID."})]}),o.jsxs("div",{className:"grid gap-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Working Directory *"}),ne.length>0&&o.jsxs("div",{className:"flex gap-1 bg-muted/40 rounded-md p-0.5",children:[o.jsx("button",{type:"button",onClick:()=>E("type"),className:`text-[10px] px-2 py-0.5 rounded transition-all ${w==="type"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Type Path"}),o.jsx("button",{type:"button",onClick:()=>E("workspace"),className:`text-[10px] px-2 py-0.5 rounded transition-all ${w==="workspace"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Workspace"})]})]}),w==="type"?o.jsx(Tt,{placeholder:"/path/to/project",value:S,onChange:O=>C(O.target.value),className:"border-border bg-muted/30 font-mono text-sm placeholder:text-muted-foreground/30"}):o.jsxs(Rn,{value:k,onValueChange:I,children:[o.jsx(Jt,{className:"border-border bg-muted/30",children:o.jsx(An,{placeholder:"Select a workspace..."})}),o.jsx(Xt,{children:ne.map(O=>o.jsx(Ne,{value:O.id,children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(ll,{className:"h-3 w-3 text-cyan-400"}),o.jsx("span",{children:O.name}),o.jsx("span",{className:"text-muted-foreground/50 text-xs font-mono ml-1",children:O.path})]})},O.id))})]}),o.jsx(rg,{validating:X,result:q})]}),u==="resume"&&o.jsxs("div",{className:"border border-cyan-500/20 rounded-lg p-3 space-y-3 bg-cyan-500/[0.04]",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Provider Session ID *"}),o.jsx(Tt,{placeholder:(ue==null?void 0:ue.idPlaceholder)??"provider session id",value:g,onChange:O=>y(O.target.value),className:"border-border bg-background/70 font-mono text-sm"}),ln&&o.jsx("span",{className:"text-[11px] text-red-400",children:"Provider session ID is required in Resume mode."})]}),o.jsxs("div",{className:"grid gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Resume Strategy"}),o.jsxs(Rn,{value:b,onValueChange:O=>v(O),children:[o.jsx(Jt,{className:"border-border bg-background/70",children:o.jsx(An,{})}),o.jsxs(Xt,{children:[o.jsx(Ne,{value:"resume",children:"Resume existing thread/session"}),o.jsx(Ne,{value:"fork",children:"Fork from that thread/session"})]})]}),o.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:ue!=null&&ue.resume?b==="fork"?ue.fork?`Uses \`${ue.fork}\`.`:`Uses \`${ue.resume}\` (provider does not expose a dedicated fork command).`:`Uses \`${ue.resume}\`.`:"Provider resume command preview unavailable for this provider."})]})]}),u==="new"&&(q==null?void 0:q.isGitRepo)&&o.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>L(!D),className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-muted/30 transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[D?o.jsx(er,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(gn,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx(ms,{className:"h-3.5 w-3.5 text-emerald-400"}),o.jsx("span",{className:"text-xs font-medium text-foreground",children:"Git Worktree"})]}),q.gitInfo&&o.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/60",children:q.gitInfo.currentBranch})]}),D&&o.jsxs("div",{className:"border-t border-border px-3 py-3 space-y-3",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:T,onChange:O=>P(O.target.checked),className:"rounded border-border"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:"Use Git Worktree (isolated branch work)"})]}),T&&o.jsxs("div",{className:"space-y-3 pl-5",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-[10px] font-medium text-muted-foreground mb-1 block",children:"Branch"}),o.jsx(Tt,{placeholder:"feature/my-branch",value:R,onChange:O=>A(O.target.value),className:"bg-background border-border font-mono text-xs h-8",list:"branch-suggestions"}),((Ke=q.gitInfo)==null?void 0:Ke.branches)&&o.jsx("datalist",{id:"branch-suggestions",children:q.gitInfo.branches.map(O=>o.jsx("option",{value:O},O))})]}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:N,onChange:O=>U(O.target.checked),className:"rounded border-border"}),o.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Create branch if it doesn't exist"})]}),o.jsx(og,{validating:$e,result:ce})]})]})]}),M.length>0&&o.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>V(!te),className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-muted/30 transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[te?o.jsx(er,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(gn,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx(fl,{className:"h-3.5 w-3.5 text-violet-400"}),o.jsx("span",{className:"text-xs font-medium text-foreground",children:"Environment Sets"})]}),z.size>0&&o.jsxs("span",{className:"text-[10px] font-mono text-violet-400/80",children:[z.size," selected"]})]}),te&&o.jsx("div",{className:"border-t border-border px-3 py-3 space-y-2",children:M.map(O=>o.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer py-1",children:[o.jsx("input",{type:"checkbox",checked:z.has(O.id),onChange:()=>ge(O.id),className:"rounded border-border"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("span",{className:"text-xs text-foreground",children:O.name}),O.description&&o.jsx("span",{className:"text-[10px] text-muted-foreground/60 ml-2",children:O.description})]})]},O.id))})]}),o.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>j(!H),className:"w-full flex items-center justify-between px-3 py-2.5 hover:bg-muted/30 transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[H?o.jsx(er,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(gn,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-xs font-medium text-foreground",children:"Advanced Options"})]}),o.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/60",children:"args + dangerous + preview"})]}),H&&o.jsxs("div",{className:"border-t border-border px-3 py-3 space-y-3",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Arguments (optional)"}),o.jsx(Tt,{placeholder:"--model opus --verbose",value:W,onChange:O=>B(O.target.value),className:"border-border bg-muted/30 font-mono text-sm placeholder:text-muted-foreground/30"}),o.jsxs("p",{className:"text-[11px] text-muted-foreground/70",children:["Supports quoted values, e.g. ",o.jsx("code",{children:'--prompt \\"hello world\\"'}),"."]})]}),o.jsxs("div",{className:"border border-amber-500/40 rounded-lg p-3 space-y-2 bg-amber-500/5",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:p,disabled:!dt,onChange:O=>h(O.target.checked),className:"rounded border-border"}),o.jsx("span",{className:"text-xs font-medium text-amber-300",children:"Dangerous Mode"})]}),o.jsx("p",{className:"text-[11px] text-muted-foreground",children:dt?"Bypasses CodePiper policy checks and enables provider-native dangerous mode flags for this session.":"This provider does not support dangerous mode."}),St.length>0&&o.jsxs("p",{className:"text-[11px] text-amber-200/90 font-mono",children:["Effective flags: ",St.join(" ")]})]}),qe&&o.jsxs("div",{className:"border border-cyan-500/25 rounded-lg p-3 bg-cyan-500/[0.06]",children:[o.jsx("p",{className:"text-[11px] text-muted-foreground mb-1",children:"Provider resume preview"}),o.jsx("p",{className:"text-[11px] font-mono text-cyan-200/90 break-all",children:qe})]})]})]})]}),o.jsxs(Mi,{children:[o.jsx(qt,{variant:"outline",onClick:()=>s(!1),disabled:a,className:"border-border",children:"Cancel"}),o.jsx(qt,{onClick:Qn,disabled:a||!wt,className:"bg-cyan-600 hover:bg-cyan-700 text-white border-0",children:a?"Creating...":"Create Session"})]})]})]})}function rg({validating:e,result:t}){return e?o.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground/60",children:[o.jsx(Or,{className:"h-3 w-3 animate-spin"}),o.jsx("span",{className:"text-[11px]",children:"Validating..."})]}):t?o.jsxs("div",{className:"space-y-1",children:[t.errors.map(n=>o.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[o.jsx(ps,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"text-[11px]",children:n})]},n)),t.warnings.map(n=>o.jsxs("div",{className:"flex items-center gap-1.5 text-amber-400",children:[o.jsx(ys,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"text-[11px]",children:n})]},n)),t.valid&&t.errors.length===0&&o.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-400",children:[o.jsx(Mr,{className:"h-3 w-3 shrink-0"}),o.jsxs("span",{className:"text-[11px]",children:["Directory valid",t.isGitRepo&&" (git repository)"]})]})]}):null}function og({validating:e,result:t}){return e?o.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground/60",children:[o.jsx(Or,{className:"h-3 w-3 animate-spin"}),o.jsx("span",{className:"text-[11px]",children:"Checking branch..."})]}):t?o.jsxs("div",{className:"space-y-1",children:[t.errors.map(n=>o.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[o.jsx(ps,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"text-[11px]",children:n})]},n)),t.warnings.map(n=>o.jsxs("div",{className:"flex items-center gap-1.5 text-amber-400",children:[o.jsx(ys,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"text-[11px]",children:n})]},n)),t.valid&&t.errors.length===0&&o.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-400",children:[o.jsx(Mr,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"text-[11px]",children:"Branch ready"})]})]}):null}const sg=[{name:"Home",href:"/",icon:hs},{name:"Sessions",href:"/sessions",icon:xt},{name:"new",href:"#new",icon:On},{name:"Policies",href:"/policies",icon:xs},{name:"More",href:"/settings",icon:gs}];function ag({keyboardOpen:e=!1}){var h;const t=gt(),n=In(),{theme:r}=so(),s=(h=n.pathname.match(/^\/sessions\/([^/]+)/))==null?void 0:h[1],{sessions:a}=on(),{counts:i}=rn(),l=c.useMemo(()=>a.filter(to).sort((u,x)=>new Date(x.createdAt).getTime()-new Date(u.createdAt).getTime()).slice(0,5),[a]),d=c.useMemo(()=>sn(a),[a]),f=l.length,m=i.totalUnread>0?i.totalUnread:f,p=r.mode==="dark"?"bg-card/95 backdrop-blur-xl":"bg-card border-border/90";return o.jsxs("nav",{className:$("md:hidden fixed bottom-0 left-0 right-0 z-40 border-t border-border pb-safe transition-transform duration-200 ease-out",p,e?"translate-y-[calc(100%+1.5rem)] opacity-0 pointer-events-none":"translate-y-0 opacity-100"),children:[l.length>0&&o.jsx("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-emerald-500/[0.03] border-b border-emerald-500/10 overflow-x-auto scrollbar-none",children:l.map(u=>{const x=Rt(u,d),g=br(u),y=s===u.id,b=i.bySession[u.id]??0;return o.jsxs("button",{type:"button",onClick:()=>t(`/sessions/${u.id}`),className:$("flex items-center gap-1.5 shrink-0 min-h-[28px] px-2.5 rounded-full border active:scale-95 transition-all",y?"bg-emerald-500/15 border-emerald-400/30 shadow-[0_0_8px_rgba(16,185,129,0.15)]":"bg-card/60 border-border/40"),children:[o.jsx(xt,{className:$("h-3 w-3 shrink-0",g?"text-amber-400 drop-shadow-[0_0_3px_rgba(251,191,36,0.6)]":"text-emerald-400 drop-shadow-[0_0_3px_rgba(16,185,129,0.5)]",g&&"pulse-live")}),b>0&&o.jsx("span",{className:"inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-amber-500 px-1 text-[9px] font-semibold leading-none text-amber-950 shadow-[0_0_8px_rgba(245,158,11,0.4)]",children:b>99?"99+":b}),o.jsx("span",{className:$("text-[10px] font-medium max-w-[72px] truncate",y?"text-emerald-300":"text-muted-foreground"),children:x})]},u.id)})}),o.jsx("div",{className:"flex items-center justify-around h-14",children:sg.map(u=>u.name==="new"?o.jsx(ho,{children:o.jsx("button",{type:"button",className:"flex items-center justify-center w-11 h-11 rounded-2xl bg-gradient-to-br from-cyan-500 to-violet-600 text-white shadow-lg shadow-cyan-500/25 active:scale-95 transition-transform",children:o.jsx(On,{className:"h-5 w-5"})})},"new-session"):o.jsx(vn,{to:u.href,end:u.href==="/",className:({isActive:x})=>$("relative flex flex-col items-center justify-center gap-0.5 w-14 h-14 transition-colors",x?"text-cyan-400":"text-muted-foreground active:text-foreground"),children:({isActive:x})=>o.jsxs(o.Fragment,{children:[x&&o.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-5 h-[2px] rounded-full bg-cyan-400 shadow-[0_0_6px_rgba(6,182,212,0.5)]"}),o.jsxs("div",{className:"relative",children:[o.jsx(u.icon,{className:"h-5 w-5"}),u.name==="Sessions"&&m>0&&o.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-[16px] rounded-full bg-cyan-500 text-[9px] font-bold text-cyan-950 flex items-center justify-center px-1 leading-none",children:m>99?"99+":m})]}),o.jsx("span",{className:"text-[10px] font-medium",children:u.name})]})},u.href))})]})}const ig=[{name:"Dashboard",href:"/",icon:hs},{name:"Sessions",href:"/sessions",icon:xt}],cg=[{name:"Analytics",href:"/analytics",icon:Yc},{name:"Workflows",href:"/workflows",icon:ms},{name:"Policies",href:"/policies",icon:xs}];function Ar({label:e}){return o.jsx("span",{className:"absolute left-full ml-2.5 px-2.5 py-1 rounded-md bg-popover border border-border text-xs font-medium text-popover-foreground whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity duration-150 z-50 shadow-lg shadow-black/20",children:e})}function ts({item:e,sessionCount:t,attentionCount:n,unreadCount:r}){const s=r>0?r:t;return o.jsx(vn,{to:e.href,end:e.href==="/",className:({isActive:a})=>$("group relative flex items-center justify-center w-10 h-10 rounded-lg transition-all duration-200",a?"text-cyan-400 bg-cyan-500/[0.12]":"text-muted-foreground hover:text-foreground hover:bg-accent/50"),children:({isActive:a})=>o.jsxs(o.Fragment,{children:[a&&o.jsx("div",{className:"absolute -left-[6px] top-1/2 -translate-y-1/2 w-[3px] h-5 rounded-r-full bg-gradient-to-b from-cyan-400 to-cyan-600 shadow-[0_0_8px_rgba(6,182,212,0.4)]"}),o.jsx(e.icon,{className:$("h-[18px] w-[18px] transition-colors",a?"text-cyan-400":"text-muted-foreground group-hover:text-foreground")}),e.href==="/sessions"&&s>0&&o.jsx("span",{className:$("absolute -top-0.5 -right-0.5 min-w-[18px] h-[18px] rounded-full flex items-center justify-center text-[10px] font-bold leading-none px-1",r>0||n>0?"bg-amber-500 text-amber-950 shadow-[0_0_8px_rgba(245,158,11,0.5)] pulse-live":"bg-cyan-500/90 text-cyan-950 shadow-[0_0_6px_rgba(6,182,212,0.4)]"),children:s>99?"99+":s}),o.jsx(Ar,{label:e.name})]})})}function lg(){var f;const e=gt(),n=(f=In().pathname.match(/^\/sessions\/([^/]+)/))==null?void 0:f[1],{sessions:r}=on(),{counts:s}=rn(),a=r.filter(br).length,i=c.useMemo(()=>r.filter(to).sort((m,p)=>new Date(p.createdAt).getTime()-new Date(m.createdAt).getTime()).slice(0,5),[r]),l=c.useMemo(()=>sn(r),[r]),d=i.length;return o.jsxs("aside",{className:"hidden md:flex w-[60px] border-r border-border bg-card flex-col items-center relative overflow-visible",children:[o.jsx("div",{className:"absolute top-0 left-0 right-0 h-32 bg-gradient-to-b from-cyan-500/[0.04] to-transparent pointer-events-none"}),o.jsx("button",{type:"button",onClick:()=>e("/"),className:"py-4 relative group cursor-pointer",title:"Dashboard",children:o.jsx("img",{src:"/piper.svg",alt:"CodePiper",className:"w-10 h-10 transition-transform group-hover:scale-110"})}),o.jsxs("div",{className:"pb-2 relative group",children:[o.jsx(ho,{children:o.jsx("button",{type:"button",className:"w-9 h-9 rounded-lg bg-cyan-500/10 text-cyan-400/70 hover:bg-cyan-500/20 hover:text-cyan-400 flex items-center justify-center transition-all duration-200 border border-cyan-500/10 hover:border-cyan-500/20",children:o.jsx(On,{className:"h-4 w-4"})})}),o.jsx(Ar,{label:"New Session"})]}),o.jsx("div",{className:"w-6 border-t border-border/60 mb-1"}),o.jsxs("nav",{className:"flex-1 flex flex-col items-center gap-0.5 py-1 relative",children:[ig.map(m=>o.jsx(ts,{item:m,sessionCount:d,attentionCount:a,unreadCount:m.href==="/sessions"?s.totalUnread:0},m.href)),i.length>0&&o.jsxs("div",{className:"flex flex-col items-center gap-0.5 py-1 my-0.5",children:[o.jsx("div",{className:"w-5 border-t border-emerald-500/20 mb-0.5"}),i.map(m=>{const p=Rt(m,l),h=br(m),u=n===m.id,x=s.bySession[m.id]??0;return o.jsxs(vn,{to:`/sessions/${m.id}`,className:$("group relative flex items-center justify-center w-10 h-8 rounded-lg transition-all duration-200",u?"bg-emerald-500/[0.12]":"hover:bg-emerald-500/10"),children:[u&&o.jsx("div",{className:"absolute -left-[6px] top-1/2 -translate-y-1/2 w-[3px] h-4 rounded-r-full bg-gradient-to-b from-emerald-400 to-emerald-600 shadow-[0_0_8px_rgba(16,185,129,0.4)]"}),o.jsx(xt,{className:$("h-4 w-4 transition-all duration-200",h?"text-amber-400 drop-shadow-[0_0_4px_rgba(251,191,36,0.6)]":"text-emerald-400 drop-shadow-[0_0_4px_rgba(16,185,129,0.5)]",h&&"pulse-live")}),x>0&&o.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[15px] h-[15px] rounded-full bg-amber-500 text-[9px] font-bold text-amber-950 flex items-center justify-center px-1 leading-none shadow-[0_0_8px_rgba(245,158,11,0.45)]",children:x>99?"99+":x}),o.jsxs("span",{className:"absolute left-full ml-2.5 px-2.5 py-1.5 rounded-md bg-popover border border-border text-xs text-popover-foreground whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity duration-150 z-50 shadow-lg shadow-black/20 max-w-[200px]",children:[o.jsx("span",{className:"font-medium text-emerald-400",children:p}),x>0&&o.jsxs("span",{className:"block text-[10px] text-amber-400 mt-0.5",children:[x," unread notification",x===1?"":"s"]}),o.jsx("span",{className:"block text-[10px] text-muted-foreground mt-0.5 truncate",children:m.cwd})]})]},m.id)}),o.jsx("div",{className:"w-5 border-t border-emerald-500/20 mt-0.5"})]}),cg.map(m=>o.jsx(ts,{item:m,sessionCount:0,attentionCount:0,unreadCount:0},m.href))]}),o.jsxs("div",{className:"flex flex-col items-center gap-1 pb-3",children:[o.jsx(vn,{to:"/settings",className:({isActive:m})=>$("group relative flex items-center justify-center w-10 h-10 rounded-lg transition-all duration-200",m?"text-cyan-400 bg-cyan-500/[0.12]":"text-muted-foreground hover:text-foreground hover:bg-accent/50"),children:({isActive:m})=>o.jsxs(o.Fragment,{children:[m&&o.jsx("div",{className:"absolute -left-[6px] top-1/2 -translate-y-1/2 w-[3px] h-5 rounded-r-full bg-gradient-to-b from-cyan-400 to-cyan-600 shadow-[0_0_8px_rgba(6,182,212,0.4)]"}),o.jsx(gs,{className:$("h-[18px] w-[18px] transition-colors",m?"text-cyan-400":"text-muted-foreground group-hover:text-foreground")}),o.jsx(Ar,{label:"Settings"})]})}),o.jsxs("div",{className:"flex flex-col items-center gap-1 pt-1",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-cyan-500 shadow-[0_0_6px_rgba(6,182,212,0.5)] pulse-live"}),o.jsx("span",{className:"text-[9px] text-muted-foreground/50 font-mono",children:"0.1"})]})]})]})}const dg=({...e})=>o.jsx(Ym,{className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e});function Vt({className:e,variant:t="default",...n}){return o.jsx("div",{className:$("inline-flex items-center rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{"border-cyan-500/20 bg-cyan-500/10 text-cyan-400":t==="default","border-border bg-muted/50 text-muted-foreground":t==="secondary","border-red-500/20 bg-red-500/10 text-red-400":t==="destructive","border-border text-muted-foreground":t==="outline","border-emerald-500/20 bg-emerald-500/10 text-emerald-400":t==="success","border-amber-500/20 bg-amber-500/10 text-amber-400":t==="warning"},e),...n})}function Lg(e){return e.filter(t=>t.source==="transcript"&&(t.type==="user"||t.type==="assistant"||t.type==="system")).map(t=>{var a,i;const n=typeof t.payload=="string"?JSON.parse(t.payload):t.payload;let r="";(a=n.message)!=null&&a.content?r=ns(n.message.content):n.content?r=ns(n.content):n.text&&(r=n.text);let s;return(i=n.message)!=null&&i.usage&&(s={prompt:n.message.usage.input_tokens||0,completion:n.message.usage.output_tokens||0}),{role:t.type||"system",content:r,timestamp:new Date(t.timestamp),tokens:s}}).sort((t,n)=>t.timestamp.getTime()-n.timestamp.getTime())}function ns(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>typeof t=="string"?t:t.type==="text"?t.text:t.type==="tool_use"?`[Tool: ${t.name}]`:JSON.stringify(t)).join(`
204
+ `):JSON.stringify(e,null,2)}function fr(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}const ug=[{key:"active",label:"Active",icon:xt,gradient:"from-cyan-500/20 to-cyan-600/5",iconColor:"text-cyan-400",borderGlow:"shadow-[inset_0_1px_0_0_rgba(6,182,212,0.1)]"},{key:"messages",label:"Messages",icon:yl,gradient:"from-emerald-500/20 to-emerald-600/5",iconColor:"text-emerald-400",borderGlow:"shadow-[inset_0_1px_0_0_rgba(16,185,129,0.1)]"},{key:"tokens",label:"Tokens",icon:Bc,gradient:"from-violet-500/20 to-violet-600/5",iconColor:"text-violet-400",borderGlow:"shadow-[inset_0_1px_0_0_rgba(139,92,246,0.1)]"},{key:"cache",label:"Cache",icon:Il,gradient:"from-amber-500/20 to-amber-600/5",iconColor:"text-amber-400",borderGlow:"shadow-[inset_0_1px_0_0_rgba(245,158,11,0.1)]"}],rs={RUNNING:0,STARTING:1,NEEDS_PERMISSION:2,NEEDS_INPUT:3,STOPPED:4,CRASHED:5};function fg(){const e=gt(),{sessions:t}=on(),[n,r]=c.useState(null),s=c.useCallback(async()=>{try{const p=await fetch("/api/analytics/overview?range=today");p.ok&&r(await p.json())}catch{}},[]);c.useEffect(()=>{s()},[s]);const a=t.filter(to),i=c.useMemo(()=>sn(t),[t]),l=[...t].sort((p,h)=>{const u=rs[p.status]??99,x=rs[h.status]??99;return u!==x?u-x:new Date(h.createdAt).getTime()-new Date(p.createdAt).getTime()}).slice(0,5),d=p=>{switch(p){case"active":return a.length.toString();case"messages":return fr((n==null?void 0:n.totalMessages)??0);case"tokens":return fr((n==null?void 0:n.inputTokens)!=null?n.inputTokens+n.outputTokens:(n==null?void 0:n.totalTokens)??0);case"cache":return`${(n==null?void 0:n.cacheHitRate)??0}%`;default:return"0"}},f=p=>{switch(p){case"active":return`${t.length} total`;case"messages":return"User + assistant";case"tokens":return n!=null&&n.cacheReadTokens?`${fr(n.cacheReadTokens)} cached`:void 0;default:return}},m=p=>{switch(Ya(p)){case"green":return"success";case"yellow":return"warning";case"red":return"destructive";default:return"secondary"}};return o.jsx("div",{className:"p-4 md:p-8",children:o.jsxs("div",{className:"max-w-7xl mx-auto",children:[o.jsxs("div",{className:"mb-6 md:mb-8",children:[o.jsx("h1",{className:"text-2xl md:text-3xl font-bold tracking-tight",children:"Dashboard"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Monitor your active sessions and system metrics"})]}),o.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 md:gap-4 mb-6 md:mb-8",children:ug.map(p=>{const h=f(p.key);return o.jsxs("div",{className:`relative rounded-xl border border-border bg-gradient-to-b ${p.gradient} backdrop-blur-sm p-4 md:p-5 ${p.borderGlow}`,children:[o.jsxs("div",{className:"flex items-center justify-between mb-2 md:mb-3",children:[o.jsx("span",{className:"text-[10px] md:text-xs font-medium text-muted-foreground uppercase tracking-wider",children:p.label}),o.jsx(p.icon,{className:`h-3.5 w-3.5 md:h-4 md:w-4 ${p.iconColor}`})]}),o.jsx("div",{className:"text-2xl md:text-3xl font-bold tracking-tight",children:d(p.key)}),h&&o.jsx("div",{className:"text-[10px] md:text-xs text-muted-foreground mt-1",children:h})]},p.key)})}),o.jsxs("div",{className:"rounded-xl border border-border bg-card backdrop-blur-sm overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 md:px-6 py-3 md:py-4 border-b border-border",children:[o.jsx("h2",{className:"text-sm font-semibold tracking-wide",children:"Recent Sessions"}),o.jsxs("button",{type:"button",onClick:()=>e("/sessions"),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-cyan-400 transition-colors",children:["View all ",o.jsx(Wc,{className:"h-3 w-3"})]})]}),o.jsx("div",{children:l.length===0?o.jsxs("div",{className:"py-12 md:py-16 text-center",children:[o.jsx(xt,{className:"h-8 w-8 text-muted-foreground/30 mx-auto mb-3"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"No sessions yet"}),o.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1",children:"Create one from the Sessions page"})]}):o.jsx("div",{children:l.map(p=>{const h=Rt(p,i);return o.jsxs("div",{className:"flex items-center justify-between px-4 md:px-6 py-3 md:py-3.5 hover:bg-accent/50 cursor-pointer transition-colors border-b border-border/60 last:border-0 active:bg-accent/70",onClick:()=>e(`/sessions/${p.id}`),children:[o.jsxs("div",{className:"flex items-center gap-2 md:gap-3 min-w-0",children:[o.jsx(Vt,{variant:m(p.status),className:"shrink-0",children:p.status}),o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"font-mono text-sm text-foreground shrink-0",children:Pt(p.id,8)}),o.jsx("span",{className:"text-muted-foreground text-sm truncate hidden sm:inline",children:Pt(h,40)})]})]}),o.jsx("div",{className:"flex items-center gap-3 md:gap-4 shrink-0",children:o.jsx("span",{className:"text-[11px] text-muted-foreground",children:jn(p.createdAt)})})]},p.id)})})})]})]})})}function os({provider:e,compact:t=!1,className:n}){const r=lo(e),s=r.icon;return o.jsxs("span",{className:$("inline-flex items-center rounded-full border font-medium backdrop-blur-[1px] shadow-[inset_0_1px_0_rgba(255,255,255,0.22)] transition-colors dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",t?"gap-1 px-2 py-0.5 text-[10px]":"gap-1.5 px-2.5 py-1 text-[11px]",r.className,n),children:[o.jsx("span",{className:$("inline-block h-1.5 w-1.5 rounded-full",r.dotClassName)}),o.jsx("span",{className:$("inline-flex items-center justify-center rounded-full border border-current/20 bg-background/70",t?"h-4 w-4":"h-[18px] w-[18px]"),children:o.jsx(s,{className:$("shrink-0",t?"h-2.5 w-2.5":"h-3 w-3")})}),o.jsx("span",{className:$("leading-none",t?"max-w-[80px] truncate":""),children:r.label})]})}function pg({statusFilter:e,providerFilter:t,providerOptions:n,searchQuery:r,onStatusChange:s,onProviderChange:a,onSearchChange:i}){return o.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:gap-3 mb-4 md:mb-6",children:[o.jsxs("div",{className:"flex-1 relative",children:[o.jsx(Sl,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground/40"}),o.jsx(Tt,{placeholder:"Search sessions...",value:r,onChange:l=>i(l.target.value),className:"w-full pl-9 border-border bg-muted/30 placeholder:text-muted-foreground/30"})]}),o.jsxs(Rn,{value:e,onValueChange:s,children:[o.jsx(Jt,{className:"sm:w-[160px] border-border bg-muted/30 text-xs sm:text-sm",children:o.jsx(An,{placeholder:"Status"})}),o.jsxs(Xt,{children:[o.jsx(Ne,{value:"all",children:"All Statuses"}),o.jsx(Ne,{value:"RUNNING",children:"Running"}),o.jsx(Ne,{value:"STARTING",children:"Starting"}),o.jsx(Ne,{value:"STOPPED",children:"Stopped"}),o.jsx(Ne,{value:"CRASHED",children:"Crashed"}),o.jsx(Ne,{value:"NEEDS_PERMISSION",children:"Needs Permission"}),o.jsx(Ne,{value:"NEEDS_INPUT",children:"Needs Input"})]})]}),o.jsxs(Rn,{value:t,onValueChange:a,children:[o.jsx(Jt,{className:"sm:w-[170px] border-border bg-muted/30 text-xs sm:text-sm",children:o.jsx(An,{placeholder:"Provider"})}),o.jsxs(Xt,{children:[o.jsx(Ne,{value:"all",children:"All Providers"}),n.map(l=>o.jsx(Ne,{value:l.value,children:l.label},l.value))]})]})]})}function ss({session:e,onStatusChange:t}){const[n,r]=c.useState(!1),s=async()=>{try{r(!0),await ae.stopSession(e.id),t==null||t(e.id,"STOPPED"),ve.success(`Session ${e.id.slice(0,8)} stopped`)}catch(h){ve.error(h instanceof Error?h.message:"Failed to stop session")}finally{r(!1)}},a=async()=>{try{r(!0),await ae.killSession(e.id),t==null||t(e.id,"STOPPED"),ve.success(`Session ${e.id.slice(0,8)} killed`)}catch(h){ve.error(h instanceof Error?h.message:"Failed to kill session")}finally{r(!1)}},i=async()=>{try{r(!0),await ae.resumeSession(e.id),t==null||t(e.id,"RUNNING"),ve.success(`Session ${e.id.slice(0,8)} resumed`)}catch(h){ve.error(h instanceof Error?h.message:"Failed to resume session")}finally{r(!1)}},l=async()=>{try{r(!0),await ae.recoverSession(e.id),t==null||t(e.id,"RUNNING"),ve.success(`Session ${e.id.slice(0,8)} recovered`)}catch(h){ve.error(h instanceof Error?h.message:"Failed to recover session")}finally{r(!1)}},d=e.status==="RUNNING"||e.status==="STARTING",f=e.status!=="STOPPED"&&e.status!=="CRASHED",m=e.status==="STOPPED"||e.status==="CRASHED",p=e.status==="STOPPED"||e.status==="CRASHED";return o.jsxs(Ja,{children:[o.jsx(Xa,{asChild:!0,children:o.jsx(qt,{variant:"ghost",size:"sm",disabled:n,className:"h-7 w-7 p-0 hover:bg-accent",children:o.jsx(il,{className:"h-4 w-4 text-muted-foreground"})})}),o.jsxs(no,{align:"end",className:"border-border bg-popover",children:[m&&o.jsx(Wt,{onClick:i,className:"text-cyan-400 text-sm focus:text-cyan-400",children:"Resume (Provider)"}),p&&o.jsx(Wt,{onClick:l,className:"text-blue-400 text-sm focus:text-blue-400",children:"Recover (Tmux)"}),o.jsx(Wt,{onClick:s,disabled:!d,className:"text-sm",children:"Stop"}),o.jsx(ro,{className:"bg-accent"}),o.jsx(Wt,{onClick:a,disabled:!f,className:"text-red-400 text-sm focus:text-red-400",children:"Kill"})]})]})}const Bt=15;function mg(){const e=gt(),{sessions:t,loading:n,error:r,updateSessionStatus:s}=on(),{counts:a}=rn(),[i,l]=c.useState("all"),[d,f]=c.useState("all"),[m,p]=c.useState(""),[h,u]=c.useState(1),x=c.useMemo(()=>sn(t),[t]),g=c.useMemo(()=>{const S={RUNNING:0,STARTING:1,NEEDS_PERMISSION:2,NEEDS_INPUT:3,STOPPED:4,CRASHED:5};return t.filter(C=>{if(i!=="all"&&C.status!==i||d!=="all"&&C.provider!==d)return!1;if(m){const k=m.toLowerCase(),I=Rt(C,x).toLowerCase();return C.id.toLowerCase().includes(k)||I.includes(k)||C.cwd.toLowerCase().includes(k)||C.provider.toLowerCase().includes(k)}return!0}).sort((C,k)=>{const I=S[C.status]??99,W=S[k.status]??99;if(I!==W)return I-W;const B=new Date(C.createdAt).getTime();return new Date(k.createdAt).getTime()-B})},[t,i,d,m,x]),y=Math.max(1,Math.ceil(g.length/Bt)),b=Math.min(h,y),v=g.slice((b-1)*Bt,b*Bt),w=c.useMemo(()=>{const S=new Set(t.map(C=>C.provider));return Array.from(S).sort((C,k)=>C.localeCompare(k)).map(C=>({value:C,label:lo(C).label}))},[t]);c.useEffect(()=>{if(d==="all")return;w.some(C=>C.value===d)||f("all")},[d,w]);const E=S=>{switch(Ya(S)){case"green":return"success";case"yellow":return"warning";case"red":return"destructive";case"blue":case"cyan":return"default";default:return"secondary"}};return r?o.jsx("div",{className:"p-4 md:p-8 max-w-7xl mx-auto",children:o.jsxs("div",{className:"rounded-xl border border-red-500/20 bg-red-500/[0.05] p-4 text-red-400 text-sm",children:["Error loading sessions: ",r]})}):o.jsxs("div",{className:"p-4 md:p-8 max-w-7xl mx-auto",children:[o.jsxs("div",{className:"flex justify-between items-center mb-4 md:mb-6",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl md:text-3xl font-bold tracking-tight",children:"Sessions"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-1 hidden sm:block",children:"Manage your interactive CLI sessions"})]}),o.jsx("div",{className:"hidden sm:block",children:o.jsx(ho,{})})]}),o.jsx(pg,{statusFilter:i,providerFilter:d,providerOptions:w,searchQuery:m,onStatusChange:S=>{l(S),u(1)},onProviderChange:S=>{f(S),u(1)},onSearchChange:S=>{p(S),u(1)}}),n?o.jsx("div",{className:"flex justify-center items-center h-64",children:o.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[o.jsx("div",{className:"w-4 h-4 border-2 border-cyan-500/30 border-t-cyan-500 rounded-full animate-spin"}),o.jsx("span",{className:"text-sm",children:"Loading sessions..."})]})}):g.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center h-64 rounded-xl border border-border bg-card/80",children:[o.jsx(xt,{className:"h-10 w-10 text-muted-foreground/20 mb-3"}),o.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"No sessions found"}),t.length===0&&o.jsx("p",{className:"text-xs text-muted-foreground/60",children:"Create your first session to get started"})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"hidden md:block rounded-xl border border-border overflow-hidden bg-card/80 backdrop-blur-sm",children:[o.jsxs("div",{className:"grid grid-cols-[1fr_130px_110px_92px_1.3fr_100px_60px] gap-4 px-5 py-3 border-b border-border text-[11px] font-medium text-muted-foreground uppercase tracking-wider",children:[o.jsx("div",{children:"ID"}),o.jsx("div",{children:"Provider"}),o.jsx("div",{children:"Status"}),o.jsx("div",{children:"Unread"}),o.jsx("div",{children:"Session"}),o.jsx("div",{children:"Created"}),o.jsx("div",{className:"text-right",children:"Actions"})]}),v.map(S=>{const C=a.bySession[S.id]??0,k=Rt(S,x);return o.jsxs("div",{className:"grid grid-cols-[1fr_130px_110px_92px_1.3fr_100px_60px] gap-4 px-5 py-3 items-center border-b border-border/60 last:border-0 hover:bg-accent/50 cursor-pointer transition-colors",onClick:()=>e(`/sessions/${S.id}`),children:[o.jsx("div",{className:"font-mono text-sm text-foreground",children:Pt(S.id,8)}),o.jsx("div",{children:o.jsx(os,{provider:S.provider,compact:!0})}),o.jsx("div",{children:o.jsx(Vt,{variant:E(S.status),children:S.status})}),o.jsx("div",{children:C>0?o.jsx(Vt,{variant:"warning",className:"font-mono",children:C>99?"99+":C}):o.jsx("span",{className:"text-xs text-muted-foreground/35",children:"0"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-sm text-foreground truncate",children:k}),o.jsx("div",{className:"text-[11px] text-muted-foreground truncate",children:Pt(S.cwd,50)})]}),o.jsx("div",{className:"text-xs text-muted-foreground",children:jn(S.createdAt)}),o.jsx("div",{className:"text-right",onClick:I=>I.stopPropagation(),children:o.jsx(ss,{session:S,onStatusChange:s})})]},S.id)})]}),o.jsx("div",{className:"md:hidden space-y-2",children:v.map(S=>{const C=a.bySession[S.id]??0,k=Rt(S,x);return o.jsxs("div",{className:"rounded-xl border border-border bg-card/80 p-3.5 active:bg-accent/50 cursor-pointer transition-colors",onClick:()=>e(`/sessions/${S.id}`),children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(os,{provider:S.provider,compact:!0}),o.jsx(Vt,{variant:E(S.status),className:"text-[10px]",children:S.status}),C>0&&o.jsxs(Vt,{variant:"warning",className:"text-[10px] font-mono",children:[C>99?"99+":C," unread"]}),o.jsx("span",{className:"font-mono text-sm text-foreground",children:Pt(S.id,8)})]}),o.jsx("div",{onClick:I=>I.stopPropagation(),children:o.jsx(ss,{session:S,onStatusChange:s})})]}),o.jsx("div",{className:"text-sm text-foreground truncate mb-0.5",children:k}),o.jsx("div",{className:"text-xs text-muted-foreground truncate font-mono mb-1",children:Pt(S.cwd,45)}),o.jsx("div",{className:"text-[11px] text-muted-foreground/60",children:jn(S.createdAt)})]},S.id)})})]}),o.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[o.jsxs("div",{className:"text-xs text-muted-foreground",children:[(b-1)*Bt+1,"–",Math.min(b*Bt,g.length)," ","of ",g.length,g.length!==t.length&&o.jsxs("span",{className:"text-muted-foreground/40",children:[" (",t.length," total)"]})]}),y>1&&o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{type:"button",onClick:()=>u(S=>Math.max(1,S-1)),disabled:b<=1,className:"h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-accent/60 disabled:opacity-20 disabled:cursor-not-allowed transition-colors",children:o.jsx(el,{className:"h-4 w-4"})}),Array.from({length:y},(S,C)=>C+1).map(S=>o.jsx("button",{type:"button",onClick:()=>u(S),className:`h-7 min-w-[28px] px-1.5 flex items-center justify-center rounded-md text-xs font-mono transition-colors ${S===b?"bg-cyan-500/10 text-cyan-400 border border-cyan-500/20":"text-muted-foreground hover:text-foreground hover:bg-accent/60"}`,children:S},S)),o.jsx("button",{type:"button",onClick:()=>u(S=>Math.min(y,S+1)),disabled:b>=y,className:"h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-accent/60 disabled:opacity-20 disabled:cursor-not-allowed transition-colors",children:o.jsx(gn,{className:"h-4 w-4"})})]})]})]})}const hg=c.lazy(async()=>({default:(await Zt(()=>import("./AnalyticsPage-DqhM5ADr.js"),__vite__mapDeps([0,1,2,3,4]))).AnalyticsPage})),gg=c.lazy(async()=>({default:(await Zt(()=>import("./PoliciesPage-U-K61nH-.js"),__vite__mapDeps([5,1,6,7,8,3,4,2]))).PoliciesPage})),as=c.lazy(async()=>({default:(await Zt(()=>import("./SessionDetailPage-BSz5hcHE.js"),__vite__mapDeps([9,1,3,4,10,7,11,12,8,2]))).SessionDetailPage})),xg=c.lazy(async()=>({default:(await Zt(()=>import("./SettingsPage-Dlrev9PO.js"),__vite__mapDeps([13,1,10,6,8,3,4,2]))).SettingsPage})),yg=c.lazy(async()=>({default:(await Zt(()=>import("./WorkflowsPage-Chn2r8wA.js"),__vite__mapDeps([14,1,3,4,2]))).WorkflowsPage}));function kt(){return o.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"Loading page..."})}function bg(e){var t;if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable||e instanceof HTMLTextAreaElement)return!0;if(e instanceof HTMLInputElement){if(e.disabled||e.readOnly)return!1;const n=((t=e.type)==null?void 0:t.toLowerCase())??"text";return!["button","checkbox","file","hidden","radio","range","reset","submit"].includes(n)}return!1}function vg(){const[e,t]=c.useState(!1);return c.useEffect(()=>{if(typeof window>"u")return;const n=window.visualViewport,r=window.matchMedia("(pointer: coarse)");let s=null,a=null;const i=()=>{const f=r.matches,m=bg(document.activeElement),p=f&&m;t(h=>h===p?h:p),document.documentElement.classList.toggle("keyboard-open",p)},l=()=>{s!==null&&cancelAnimationFrame(s),s=requestAnimationFrame(()=>{s=null,i()})},d=()=>{a&&clearTimeout(a),a=setTimeout(l,120)};return i(),n==null||n.addEventListener("resize",l),n==null||n.addEventListener("scroll",l),window.addEventListener("resize",l),window.addEventListener("orientationchange",l),window.addEventListener("focusin",l),window.addEventListener("focusout",d),()=>{s!==null&&cancelAnimationFrame(s),a&&clearTimeout(a),n==null||n.removeEventListener("resize",l),n==null||n.removeEventListener("scroll",l),window.removeEventListener("resize",l),window.removeEventListener("orientationchange",l),window.removeEventListener("focusin",l),window.removeEventListener("focusout",d)}},[]),{keyboardOpen:e}}function wg(){const e=In(),t=/^\/sessions\/[^/]+/.test(e.pathname),{keyboardOpen:n}=vg(),r=$("flex-1 overflow-auto md:pb-0",n?"pb-[max(0.5rem,env(safe-area-inset-bottom,0px))]":"pb-36");return o.jsx(Ic,{children:o.jsx(am,{children:o.jsxs("div",{className:"flex h-[100dvh] app-background noise",children:[o.jsx(lg,{}),o.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[o.jsx("div",{className:t?"hidden md:block":"",children:o.jsx(Sm,{})}),o.jsx("main",{className:r,children:o.jsxs(kc,{children:[o.jsx(ze,{path:"/",element:o.jsx(fg,{})}),o.jsx(ze,{path:"/sessions",element:o.jsx(mg,{})}),o.jsx(ze,{path:"/sessions/:id",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(as,{})})}),o.jsx(ze,{path:"/sessions/:id/:tab",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(as,{})})}),o.jsx(ze,{path:"/analytics",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(hg,{})})}),o.jsx(ze,{path:"/workflows",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(yg,{})})}),o.jsx(ze,{path:"/policies",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(gg,{})})}),o.jsx(ze,{path:"/settings",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(xg,{})})}),o.jsx(ze,{path:"*",element:o.jsx(jc,{to:"/",replace:!0})})]})})]}),o.jsx(ag,{keyboardOpen:n})]})})})}function Sg(){return c.useEffect(()=>(at.connect(),()=>{at.close()}),[]),o.jsx(Sp,{children:o.jsx(_c,{children:o.jsxs(Cc,{children:[o.jsx(wg,{}),o.jsx(dg,{})]})})})}const Ng=6e4;let is=!1;function Eg(e){const t=()=>{const n=e.installing;n&&n.addEventListener("statechange",()=>{n.state==="installed"&&navigator.serviceWorker.controller&&Pn(e)})};e.addEventListener("updatefound",t),t(),Pn(e)}function Cg(e){const t=()=>{e.update().catch(()=>{})};t(),window.setInterval(t,Ng),window.addEventListener("focus",t),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&t()})}function kg(){typeof window>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{is||(is=!0,window.location.reload())}),window.addEventListener("load",()=>{navigator.serviceWorker.register(ii()).then(e=>{Eg(e),Cg(e)}).catch(()=>{})}))}kg();const wc=document.getElementById("root");if(!wc)throw new Error("Root element not found");Pc.createRoot(wc).render(o.jsx(_.StrictMode,{children:o.jsx(Sg,{})}));export{Ya as $,Bc as A,qt as B,er as C,vh as D,on as E,rn as F,ms as G,kr as H,Tt as I,Jm as J,Og as K,Or as L,yl as M,rh as N,th as O,On as P,sn as Q,di as R,Rn as S,ys as T,Rt as U,ui as V,Pt as W,Rl as X,os as Y,Il as Z,Np as _,$ as a,co as a0,Ag as a1,Tp as a2,Pn as a3,ii as a4,Mg as a5,Ig as a6,fl as a7,jt as a8,Mn as a9,gl as aa,ll as ab,gs as ac,Lr as ad,Kt as ae,Q as af,Ye as ag,Hu as ah,Vu as ai,F as aj,it as ak,yt as al,Ys as am,Jt as b,ee as c,An as d,Xt as e,fr as f,Ne as g,Vt as h,jn as i,ae as j,wh as k,Ai as l,Ii as m,Oi as n,Di as o,Mi as p,gn as q,xs as r,tg as s,so as t,ve as u,Lg as v,at as w,xt as x,Sl as y,fs as z};