codepiper 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/.env.example +28 -0
  2. package/CHANGELOG.md +10 -0
  3. package/LEGAL_NOTICE.md +39 -0
  4. package/LICENSE +21 -0
  5. package/README.md +524 -0
  6. package/package.json +90 -0
  7. package/packages/cli/package.json +13 -0
  8. package/packages/cli/src/commands/analytics.ts +157 -0
  9. package/packages/cli/src/commands/attach.ts +299 -0
  10. package/packages/cli/src/commands/audit.ts +50 -0
  11. package/packages/cli/src/commands/auth.ts +261 -0
  12. package/packages/cli/src/commands/daemon.ts +162 -0
  13. package/packages/cli/src/commands/doctor.ts +303 -0
  14. package/packages/cli/src/commands/env-set.ts +162 -0
  15. package/packages/cli/src/commands/hook-forward.ts +268 -0
  16. package/packages/cli/src/commands/keys.ts +77 -0
  17. package/packages/cli/src/commands/kill.ts +19 -0
  18. package/packages/cli/src/commands/logs.ts +419 -0
  19. package/packages/cli/src/commands/model.ts +172 -0
  20. package/packages/cli/src/commands/policy-set.ts +185 -0
  21. package/packages/cli/src/commands/policy.ts +227 -0
  22. package/packages/cli/src/commands/providers.ts +114 -0
  23. package/packages/cli/src/commands/resize.ts +34 -0
  24. package/packages/cli/src/commands/send.ts +184 -0
  25. package/packages/cli/src/commands/sessions.ts +202 -0
  26. package/packages/cli/src/commands/slash.ts +92 -0
  27. package/packages/cli/src/commands/start.ts +243 -0
  28. package/packages/cli/src/commands/stop.ts +19 -0
  29. package/packages/cli/src/commands/tail.ts +137 -0
  30. package/packages/cli/src/commands/workflow.ts +786 -0
  31. package/packages/cli/src/commands/workspace.ts +127 -0
  32. package/packages/cli/src/lib/api.ts +78 -0
  33. package/packages/cli/src/lib/args.ts +72 -0
  34. package/packages/cli/src/lib/format.ts +93 -0
  35. package/packages/cli/src/main.ts +563 -0
  36. package/packages/core/package.json +7 -0
  37. package/packages/core/src/config.ts +30 -0
  38. package/packages/core/src/errors.ts +38 -0
  39. package/packages/core/src/eventBus.ts +56 -0
  40. package/packages/core/src/eventBusAdapter.ts +143 -0
  41. package/packages/core/src/index.ts +10 -0
  42. package/packages/core/src/sqliteEventBus.ts +336 -0
  43. package/packages/core/src/types.ts +63 -0
  44. package/packages/daemon/package.json +11 -0
  45. package/packages/daemon/src/api/analyticsRoutes.ts +343 -0
  46. package/packages/daemon/src/api/authRoutes.ts +344 -0
  47. package/packages/daemon/src/api/bodyLimit.ts +133 -0
  48. package/packages/daemon/src/api/envSetRoutes.ts +170 -0
  49. package/packages/daemon/src/api/gitRoutes.ts +409 -0
  50. package/packages/daemon/src/api/hooks.ts +588 -0
  51. package/packages/daemon/src/api/inputPolicy.ts +249 -0
  52. package/packages/daemon/src/api/notificationRoutes.ts +532 -0
  53. package/packages/daemon/src/api/policyRoutes.ts +234 -0
  54. package/packages/daemon/src/api/policySetRoutes.ts +445 -0
  55. package/packages/daemon/src/api/routeUtils.ts +28 -0
  56. package/packages/daemon/src/api/routes.ts +1004 -0
  57. package/packages/daemon/src/api/server.ts +1388 -0
  58. package/packages/daemon/src/api/settingsRoutes.ts +367 -0
  59. package/packages/daemon/src/api/sqliteErrors.ts +47 -0
  60. package/packages/daemon/src/api/stt.ts +143 -0
  61. package/packages/daemon/src/api/terminalRoutes.ts +200 -0
  62. package/packages/daemon/src/api/validation.ts +287 -0
  63. package/packages/daemon/src/api/validationRoutes.ts +174 -0
  64. package/packages/daemon/src/api/workflowRoutes.ts +567 -0
  65. package/packages/daemon/src/api/workspaceRoutes.ts +151 -0
  66. package/packages/daemon/src/api/ws.ts +1588 -0
  67. package/packages/daemon/src/auth/apiRateLimiter.ts +73 -0
  68. package/packages/daemon/src/auth/authMiddleware.ts +305 -0
  69. package/packages/daemon/src/auth/authService.ts +496 -0
  70. package/packages/daemon/src/auth/rateLimiter.ts +137 -0
  71. package/packages/daemon/src/config/pricing.ts +79 -0
  72. package/packages/daemon/src/crypto/encryption.ts +196 -0
  73. package/packages/daemon/src/db/db.ts +2745 -0
  74. package/packages/daemon/src/db/index.ts +16 -0
  75. package/packages/daemon/src/db/migrations.ts +182 -0
  76. package/packages/daemon/src/db/policyDb.ts +349 -0
  77. package/packages/daemon/src/db/schema.sql +408 -0
  78. package/packages/daemon/src/db/workflowDb.ts +464 -0
  79. package/packages/daemon/src/git/gitUtils.ts +544 -0
  80. package/packages/daemon/src/index.ts +6 -0
  81. package/packages/daemon/src/main.ts +525 -0
  82. package/packages/daemon/src/notifications/pushNotifier.ts +369 -0
  83. package/packages/daemon/src/providers/codexAppServerScaffold.ts +49 -0
  84. package/packages/daemon/src/providers/registry.ts +111 -0
  85. package/packages/daemon/src/providers/types.ts +82 -0
  86. package/packages/daemon/src/sessions/auditLogger.ts +103 -0
  87. package/packages/daemon/src/sessions/policyEngine.ts +165 -0
  88. package/packages/daemon/src/sessions/policyMatcher.ts +114 -0
  89. package/packages/daemon/src/sessions/policyTypes.ts +94 -0
  90. package/packages/daemon/src/sessions/ptyProcess.ts +141 -0
  91. package/packages/daemon/src/sessions/sessionManager.ts +1770 -0
  92. package/packages/daemon/src/sessions/tmuxSession.ts +1073 -0
  93. package/packages/daemon/src/sessions/transcriptManager.ts +110 -0
  94. package/packages/daemon/src/sessions/transcriptParser.ts +149 -0
  95. package/packages/daemon/src/sessions/transcriptTailer.ts +214 -0
  96. package/packages/daemon/src/tracking/tokenTracker.ts +168 -0
  97. package/packages/daemon/src/workflows/contextManager.ts +83 -0
  98. package/packages/daemon/src/workflows/index.ts +31 -0
  99. package/packages/daemon/src/workflows/resultExtractor.ts +118 -0
  100. package/packages/daemon/src/workflows/waitConditionPoller.ts +131 -0
  101. package/packages/daemon/src/workflows/workflowParser.ts +217 -0
  102. package/packages/daemon/src/workflows/workflowRunner.ts +969 -0
  103. package/packages/daemon/src/workflows/workflowTypes.ts +188 -0
  104. package/packages/daemon/src/workflows/workflowValidator.ts +533 -0
  105. package/packages/providers/claude-code/package.json +11 -0
  106. package/packages/providers/claude-code/src/index.ts +7 -0
  107. package/packages/providers/claude-code/src/overlaySettings.ts +198 -0
  108. package/packages/providers/claude-code/src/provider.ts +311 -0
  109. package/packages/web/dist/android-chrome-192x192.png +0 -0
  110. package/packages/web/dist/android-chrome-512x512.png +0 -0
  111. package/packages/web/dist/apple-touch-icon.png +0 -0
  112. package/packages/web/dist/assets/AnalyticsPage-BIopKWRf.js +17 -0
  113. package/packages/web/dist/assets/PoliciesPage-CjdLN3dl.js +11 -0
  114. package/packages/web/dist/assets/SessionDetailPage-BtSA0V0M.js +179 -0
  115. package/packages/web/dist/assets/SettingsPage-Dbbz4Ca5.js +37 -0
  116. package/packages/web/dist/assets/WorkflowsPage-Dv6f3GgU.js +1 -0
  117. package/packages/web/dist/assets/chart-vendor-DlOHLaCG.js +49 -0
  118. package/packages/web/dist/assets/codicon-ngg6Pgfi.ttf +0 -0
  119. package/packages/web/dist/assets/css.worker-BvV5MPou.js +93 -0
  120. package/packages/web/dist/assets/editor.worker-CKy7Pnvo.js +26 -0
  121. package/packages/web/dist/assets/html.worker-BLJhxQJQ.js +470 -0
  122. package/packages/web/dist/assets/index-BbdhRfr2.css +1 -0
  123. package/packages/web/dist/assets/index-hgphORiw.js +204 -0
  124. package/packages/web/dist/assets/json.worker-usMZ-FED.js +58 -0
  125. package/packages/web/dist/assets/monaco-core-B_19GPAS.css +1 -0
  126. package/packages/web/dist/assets/monaco-core-DQ5Mk8AK.js +1234 -0
  127. package/packages/web/dist/assets/monaco-react-DfZNWvtW.js +11 -0
  128. package/packages/web/dist/assets/monacoSetup-DvBj52bT.js +1 -0
  129. package/packages/web/dist/assets/pencil-Dbczxz59.js +11 -0
  130. package/packages/web/dist/assets/react-vendor-B5MgMUHH.js +136 -0
  131. package/packages/web/dist/assets/refresh-cw-B0MGsYPL.js +6 -0
  132. package/packages/web/dist/assets/tabs-C8LsWiR5.js +1 -0
  133. package/packages/web/dist/assets/terminal-vendor-Cs8KPbV3.js +9 -0
  134. package/packages/web/dist/assets/terminal-vendor-LcAfv9l9.css +32 -0
  135. package/packages/web/dist/assets/trash-2-Btlg0d4l.js +6 -0
  136. package/packages/web/dist/assets/ts.worker-DGHjMaqB.js +67731 -0
  137. package/packages/web/dist/favicon.ico +0 -0
  138. package/packages/web/dist/icon.svg +1 -0
  139. package/packages/web/dist/index.html +29 -0
  140. package/packages/web/dist/manifest.json +29 -0
  141. package/packages/web/dist/og-image.png +0 -0
  142. package/packages/web/dist/originals/android-chrome-192x192.png +0 -0
  143. package/packages/web/dist/originals/android-chrome-512x512.png +0 -0
  144. package/packages/web/dist/originals/apple-touch-icon.png +0 -0
  145. package/packages/web/dist/originals/favicon.ico +0 -0
  146. package/packages/web/dist/piper.svg +1 -0
  147. package/packages/web/dist/sounds/codepiper-soft-chime.wav +0 -0
  148. package/packages/web/dist/sw.js +257 -0
  149. package/scripts/postinstall-link-workspaces.mjs +58 -0
@@ -0,0 +1,204 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AnalyticsPage-BIopKWRf.js","assets/react-vendor-B5MgMUHH.js","assets/chart-vendor-DlOHLaCG.js","assets/monaco-core-DQ5Mk8AK.js","assets/monaco-core-B_19GPAS.css","assets/PoliciesPage-CjdLN3dl.js","assets/trash-2-Btlg0d4l.js","assets/pencil-Dbczxz59.js","assets/tabs-C8LsWiR5.js","assets/SessionDetailPage-BtSA0V0M.js","assets/refresh-cw-B0MGsYPL.js","assets/terminal-vendor-Cs8KPbV3.js","assets/terminal-vendor-LcAfv9l9.css","assets/SettingsPage-Dbbz4Ca5.js","assets/WorkflowsPage-Dv6f3GgU.js"])))=>i.map(i=>d[i]);
2
+ var Sc=Object.defineProperty;var Nc=(e,t,n)=>t in e?Sc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var le=(e,t,n)=>Nc(e,typeof t!="symbol"?t+"":t,n);import{r as c,j as o,R as is,a as Ot,W as P,v as cs,c as Ir,u as gt,d as In,N as vn,B as Ec,e as Cc,f as ze,h as kc,i as jc}from"./react-vendor-B5MgMUHH.js";import{_ as Zt}from"./monaco-core-DQ5Mk8AK.js";import{c as Pc}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=await fetch(`/api${e}`,{...t,headers:{"Content-Type":"application/json",...t==null?void 0:t.headers}});if(!n.ok){const r=await n.json().catch(()=>({})),s=new Error(r.error||`HTTP ${n.status}`);throw s.status=n.status,s.code=r.code,s.mfaRequired=r.mfaRequired,s.mfaSetupRequired=r.mfaSetupRequired,s.setupRequired=r.setupRequired,s.retryAfter=r.retryAfter,s}return n.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"}),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"})},ls=c.createContext(null);function Tc({children:e}){const[t,n]=c.useState(!0),[r,s]=c.useState({setupRequired:!1,mfaEnabled:!1,mfaSetupRequired:!1,authenticated:!1}),a=c.useCallback(async()=>{try{const m=await jt.getStatus();s(m)}catch{s({setupRequired:!1,mfaEnabled:!1,mfaSetupRequired:!1,authenticated:!1})}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,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,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,login:i,setup:l,logout:d,checkAuth:a}),[r,t,i,l,d,a]);return o.jsx(ls.Provider,{value:f,children:e})}function Mn(){const e=c.useContext(ls);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function _c(){const{login:e,mfaEnabled:t}=Mn(),[n,r]=c.useState(""),[s,a]=c.useState(""),[i,l]=c.useState(!1),[d,f]=c.useState(""),[m,p]=c.useState(!1),h=async u=>{u.preventDefault(),f(""),p(!0);try{const x=await e(n,s||void 0);x.mfaRequired&&(l(!0),a("")),x.mfaSetupRequired&&f("MFA setup is required before first sign-in. Continue in setup.")}catch(x){x.status===429?f(`Too many attempts. Try again in ${x.retryAfter||60} seconds.`):f(x.message||"Login failed")}finally{p(!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"})]}),o.jsxs("form",{onSubmit:h,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:n,onChange:u=>r(u.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})]}),(i||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:s,onChange:u=>a(u.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:i}),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"})]}),d&&o.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:d}),o.jsx("button",{type:"submit",disabled:m||!n,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:m?"Signing in...":"Sign in"})]})]})})}function Rc(){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);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 W=await jt.mfaSetup();D||h({qrDataUrl:W.qrDataUrl,secret:W.secret})}catch(W){D||v(W.message||"Failed to start MFA setup")}finally{D||C(!1)}})(),()=>{D=!0}},[r,p,S,b]);const k=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(U){y(U.message||"Setup failed")}finally{E(!1)}},A=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"}),r==="password"?o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Step 1 of 2: Create your admin password"}):r==="mfa"?o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Step 2 of 2: MFA is required before first sign-in"}):o.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Save your recovery codes, then continue"})]}),r==="password"&&o.jsxs("form",{onSubmit:k,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..."}),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."}),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.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:A,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(`
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 Ac({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(Rc,{}):t?o.jsx(o.Fragment,{children:e}):o.jsx(_c,{})}/**
4
+ * @license lucide-react v0.564.0 - ISC
5
+ *
6
+ * This source code is licensed under the ISC license.
7
+ * See the LICENSE file in the root directory of this source tree.
8
+ */const ds=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();/**
9
+ * @license lucide-react v0.564.0 - ISC
10
+ *
11
+ * This source code is licensed under the ISC license.
12
+ * See the LICENSE file in the root directory of this source tree.
13
+ */const Ic=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
14
+ * @license lucide-react v0.564.0 - ISC
15
+ *
16
+ * This source code is licensed under the ISC license.
17
+ * See the LICENSE file in the root directory of this source tree.
18
+ */const Mc=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase());/**
19
+ * @license lucide-react v0.564.0 - ISC
20
+ *
21
+ * This source code is licensed under the ISC license.
22
+ * See the LICENSE file in the root directory of this source tree.
23
+ */const go=e=>{const t=Mc(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
24
+ * @license lucide-react v0.564.0 - ISC
25
+ *
26
+ * This source code is licensed under the ISC license.
27
+ * See the LICENSE file in the root directory of this source tree.
28
+ */var Oc={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
29
+ * @license lucide-react v0.564.0 - ISC
30
+ *
31
+ * This source code is licensed under the ISC license.
32
+ * See the LICENSE file in the root directory of this source tree.
33
+ */const Dc=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
34
+ * @license lucide-react v0.564.0 - ISC
35
+ *
36
+ * This source code is licensed under the ISC license.
37
+ * See the LICENSE file in the root directory of this source tree.
38
+ */const Lc=c.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},d)=>c.createElement("svg",{ref:d,...Oc,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:ds("lucide",s),...!a&&!Dc(l)&&{"aria-hidden":"true"},...l},[...i.map(([f,m])=>c.createElement(f,m)),...Array.isArray(a)?a:[a]]));/**
39
+ * @license lucide-react v0.564.0 - ISC
40
+ *
41
+ * This source code is licensed under the ISC license.
42
+ * See the LICENSE file in the root directory of this source tree.
43
+ */const ee=(e,t)=>{const n=c.forwardRef(({className:r,...s},a)=>c.createElement(Lc,{ref:a,iconNode:t,className:ds(`lucide-${Ic(go(e))}`,`lucide-${e}`,r),...s}));return n.displayName=go(e),n};/**
44
+ * @license lucide-react v0.564.0 - ISC
45
+ *
46
+ * This source code is licensed under the ISC license.
47
+ * See the LICENSE file in the root directory of this source tree.
48
+ */const $c=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Fc=ee("activity",$c);/**
49
+ * @license lucide-react v0.564.0 - ISC
50
+ *
51
+ * This source code is licensed under the ISC license.
52
+ * See the LICENSE file in the root directory of this source tree.
53
+ */const Bc=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],Uc=ee("arrow-up-right",Bc);/**
54
+ * @license lucide-react v0.564.0 - ISC
55
+ *
56
+ * This source code is licensed under the ISC license.
57
+ * See the LICENSE file in the root directory of this source tree.
58
+ */const Wc=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],us=ee("bell",Wc);/**
59
+ * @license lucide-react v0.564.0 - ISC
60
+ *
61
+ * This source code is licensed under the ISC license.
62
+ * See the LICENSE file in the root directory of this source tree.
63
+ */const Hc=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Vc=ee("bot",Hc);/**
64
+ * @license lucide-react v0.564.0 - ISC
65
+ *
66
+ * This source code is licensed under the ISC license.
67
+ * See the LICENSE file in the root directory of this source tree.
68
+ */const qc=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],Kc=ee("brain-circuit",qc);/**
69
+ * @license lucide-react v0.564.0 - ISC
70
+ *
71
+ * This source code is licensed under the ISC license.
72
+ * See the LICENSE file in the root directory of this source tree.
73
+ */const zc=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Gc=ee("chart-column",zc);/**
74
+ * @license lucide-react v0.564.0 - ISC
75
+ *
76
+ * This source code is licensed under the ISC license.
77
+ * See the LICENSE file in the root directory of this source tree.
78
+ */const Yc=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],Jc=ee("check-check",Yc);/**
79
+ * @license lucide-react v0.564.0 - ISC
80
+ *
81
+ * This source code is licensed under the ISC license.
82
+ * See the LICENSE file in the root directory of this source tree.
83
+ */const Xc=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],er=ee("chevron-down",Xc);/**
84
+ * @license lucide-react v0.564.0 - ISC
85
+ *
86
+ * This source code is licensed under the ISC license.
87
+ * See the LICENSE file in the root directory of this source tree.
88
+ */const Zc=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Qc=ee("chevron-left",Zc);/**
89
+ * @license lucide-react v0.564.0 - ISC
90
+ *
91
+ * This source code is licensed under the ISC license.
92
+ * See the LICENSE file in the root directory of this source tree.
93
+ */const el=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],gn=ee("chevron-right",el);/**
94
+ * @license lucide-react v0.564.0 - ISC
95
+ *
96
+ * This source code is licensed under the ISC license.
97
+ * See the LICENSE file in the root directory of this source tree.
98
+ */const tl=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],fs=ee("circle-alert",tl);/**
99
+ * @license lucide-react v0.564.0 - ISC
100
+ *
101
+ * This source code is licensed under the ISC license.
102
+ * See the LICENSE file in the root directory of this source tree.
103
+ */const nl=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Mr=ee("circle-check",nl);/**
104
+ * @license lucide-react v0.564.0 - ISC
105
+ *
106
+ * This source code is licensed under the ISC license.
107
+ * See the LICENSE file in the root directory of this source tree.
108
+ */const rl=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],ol=ee("cpu",rl);/**
109
+ * @license lucide-react v0.564.0 - ISC
110
+ *
111
+ * This source code is licensed under the ISC license.
112
+ * See the LICENSE file in the root directory of this source tree.
113
+ */const sl=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],al=ee("ellipsis",sl);/**
114
+ * @license lucide-react v0.564.0 - ISC
115
+ *
116
+ * This source code is licensed under the ISC license.
117
+ * See the LICENSE file in the root directory of this source tree.
118
+ */const il=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],cl=ee("folder-open",il);/**
119
+ * @license lucide-react v0.564.0 - ISC
120
+ *
121
+ * This source code is licensed under the ISC license.
122
+ * See the LICENSE file in the root directory of this source tree.
123
+ */const ll=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],ps=ee("git-branch",ll);/**
124
+ * @license lucide-react v0.564.0 - ISC
125
+ *
126
+ * This source code is licensed under the ISC license.
127
+ * See the LICENSE file in the root directory of this source tree.
128
+ */const dl=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],ul=ee("key-round",dl);/**
129
+ * @license lucide-react v0.564.0 - ISC
130
+ *
131
+ * This source code is licensed under the ISC license.
132
+ * See the LICENSE file in the root directory of this source tree.
133
+ */const fl=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],ms=ee("layout-dashboard",fl);/**
134
+ * @license lucide-react v0.564.0 - ISC
135
+ *
136
+ * This source code is licensed under the ISC license.
137
+ * See the LICENSE file in the root directory of this source tree.
138
+ */const pl=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Or=ee("loader-circle",pl);/**
139
+ * @license lucide-react v0.564.0 - ISC
140
+ *
141
+ * This source code is licensed under the ISC license.
142
+ * See the LICENSE file in the root directory of this source tree.
143
+ */const ml=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],hl=ee("log-out",ml);/**
144
+ * @license lucide-react v0.564.0 - ISC
145
+ *
146
+ * This source code is licensed under the ISC license.
147
+ * See the LICENSE file in the root directory of this source tree.
148
+ */const gl=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],xl=ee("message-square",gl);/**
149
+ * @license lucide-react v0.564.0 - ISC
150
+ *
151
+ * This source code is licensed under the ISC license.
152
+ * See the LICENSE file in the root directory of this source tree.
153
+ */const yl=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],xt=ee("monitor",yl);/**
154
+ * @license lucide-react v0.564.0 - ISC
155
+ *
156
+ * This source code is licensed under the ISC license.
157
+ * See the LICENSE file in the root directory of this source tree.
158
+ */const bl=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],On=ee("plus",bl);/**
159
+ * @license lucide-react v0.564.0 - ISC
160
+ *
161
+ * This source code is licensed under the ISC license.
162
+ * See the LICENSE file in the root directory of this source tree.
163
+ */const vl=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],wl=ee("search",vl);/**
164
+ * @license lucide-react v0.564.0 - ISC
165
+ *
166
+ * This source code is licensed under the ISC license.
167
+ * See the LICENSE file in the root directory of this source tree.
168
+ */const Sl=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],hs=ee("settings",Sl);/**
169
+ * @license lucide-react v0.564.0 - ISC
170
+ *
171
+ * This source code is licensed under the ISC license.
172
+ * See the LICENSE file in the root directory of this source tree.
173
+ */const Nl=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],gs=ee("shield",Nl);/**
174
+ * @license lucide-react v0.564.0 - ISC
175
+ *
176
+ * This source code is licensed under the ISC license.
177
+ * See the LICENSE file in the root directory of this source tree.
178
+ */const El=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],xs=ee("triangle-alert",El);/**
179
+ * @license lucide-react v0.564.0 - ISC
180
+ *
181
+ * This source code is licensed under the ISC license.
182
+ * See the LICENSE file in the root directory of this source tree.
183
+ */const Cl=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],kl=ee("wifi-off",Cl);/**
184
+ * @license lucide-react v0.564.0 - ISC
185
+ *
186
+ * This source code is licensed under the ISC license.
187
+ * See the LICENSE file in the root directory of this source tree.
188
+ */const jl=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Pl=ee("wifi",jl);/**
189
+ * @license lucide-react v0.564.0 - ISC
190
+ *
191
+ * This source code is licensed under the ISC license.
192
+ * See the LICENSE file in the root directory of this source tree.
193
+ */const Tl=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],_l=ee("x",Tl);/**
194
+ * @license lucide-react v0.564.0 - ISC
195
+ *
196
+ * This source code is licensed under the ISC license.
197
+ * See the LICENSE file in the root directory of this source tree.
198
+ */const Rl=[["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"}]],Al=ee("zap",Rl);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 xo(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=xo(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():xo(e[s],null)}}}}function oe(...e){return c.useCallback(Dn(...e),e)}function Il(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,Ml(s,...t)]}function Ml(...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:()=>{},Ol=is[" useInsertionEffect ".trim().toString()]||me;function Kt({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[s,a,i]=Dl({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=Ll(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 Dl({defaultProp:e,onChange:t}){const[n,r]=c.useState(e),s=c.useRef(n),a=c.useRef(t);return Ol(()=>{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 Ll(e){return typeof e=="function"}function At(e){const t=$l(e),n=c.forwardRef((r,s)=>{const{children:a,...i}=r,l=c.Children.toArray(a),d=l.find(Bl);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 $l(e){const t=c.forwardRef((n,r)=>{const{children:s,...a}=n;if(c.isValidElement(s)){const i=Wl(s),l=Ul(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 Fl=Symbol("radix.slottable");function Bl(e){return c.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Fl}function Ul(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 Wl(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 Hl=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Q=Hl.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 ys(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 Vl=c.createContext(void 0);function Lr(e){const t=c.useContext(Vl);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 ql(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 Kl="DismissableLayer",pr="dismissableLayer.update",zl="dismissableLayer.pointerDownOutside",Gl="dismissableLayer.focusOutside",yo,bs=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(bs),[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=Xl(k=>{const A=k.target,D=[...f.branches].some(U=>U.contains(A));!E||D||(s==null||s(k),i==null||i(k),k.defaultPrevented||l==null||l())},h),C=Zl(k=>{const A=k.target;[...f.branches].some(U=>U.contains(A))||(a==null||a(k),i==null||i(k),k.defaultPrevented||l==null||l())},h);return ql(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&&(yo=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(m)),f.layers.add(m),bo(),()=>{n&&f.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=yo)}},[m,h,n,f]),c.useEffect(()=>()=>{m&&(f.layers.delete(m),f.layersWithOutsidePointerEventsDisabled.delete(m),bo())},[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=Kl;var Yl="DismissableLayerBranch",Jl=c.forwardRef((e,t)=>{const n=c.useContext(bs),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})});Jl.displayName=Yl;function Xl(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(){vs(zl,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 Zl(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&&vs(Gl,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 bo(){const e=new CustomEvent(pr);document.dispatchEvent(e)}function vs(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?ys(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]??vo()),document.body.insertAdjacentElement("beforeend",e[1]??vo()),tr++,()=>{tr===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),tr--}},[])}function vo(){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",wo={bubbles:!1,cancelable:!0},Ql="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){No.add(u);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(nr,wo);l.addEventListener(nr,f),l.dispatchEvent(b),b.defaultPrevented||(ed(sd(ws(l)),{select:!0}),document.activeElement===g&&rt(l))}return()=>{l.removeEventListener(nr,f),setTimeout(()=>{const b=new CustomEvent(rr,wo);l.addEventListener(rr,m),l.dispatchEvent(b),b.defaultPrevented||rt(g??document.body,{select:!0}),l.removeEventListener(rr,m),No.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]=td(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=Ql;function ed(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(rt(r,{select:t}),document.activeElement!==n)return}function td(e){const t=ws(e),n=So(t,e),r=So(t.reverse(),e);return[n,r]}function ws(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 So(e,t){for(const n of e)if(!nd(n,{upTo:t}))return n}function nd(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 rd(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&&rd(e)&&t&&e.select()}}var No=od();function od(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Eo(e,t),e.unshift(t)},remove(t){var n;e=Eo(e,t),(n=e[0])==null||n.resume()}}}function Eo(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function sd(e){return e.filter(t=>t.tagName!=="A")}var ad=is[" useId ".trim().toString()]||(()=>{}),id=0;function Ye(e){const[t,n]=c.useState(ad());return me(()=>{n(r=>r??String(id++))},[e]),t?`radix-${t}`:""}const cd=["top","right","bottom","left"],ot=Math.min,Ee=Math.max,wn=Math.round,un=Math.floor,Ue=e=>({x:e,y:e}),ld={left:"right",right:"left",bottom:"top",top:"bottom"},dd={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 ud=new Set(["top","bottom"]);function Be(e){return ud.has(Xe(e))?"y":"x"}function Ur(e){return Fr(Be(e))}function fd(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 pd(e){const t=Sn(e);return[hr(e),t,hr(t)]}function hr(e){return e.replace(/start|end/g,t=>dd[t])}const Co=["left","right"],ko=["right","left"],md=["top","bottom"],hd=["bottom","top"];function gd(e,t,n){switch(e){case"top":case"bottom":return n?t?ko:Co:t?Co:ko;case"left":case"right":return t?md:hd;default:return[]}}function xd(e,t,n,r){const s=Dt(e);let a=gd(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=>ld[t])}function yd(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ss(e){return typeof e!="number"?yd(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 jo(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 bd(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=Ss(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 vd=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}=jo(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:bd},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}=jo(f,h,d)),y=-1)}return{x:m,y:p,placement:h,strategy:s,middlewareData:u}},wd=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=Ss(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 A=E/2-S/2,D=k/2-g[x]/2-1,U=ot(p[b],D),W=ot(p[v],D),M=U,L=k-g[x]-W,$=k/2-g[x]/2+A,T=mr(M,$,L),j=!d.arrow&&Dt(s)!=null&&$!==T&&a.reference[x]/2-($<M?U:W)-g[x]/2<0,_=j?$<M?$-M:$-L:0;return{[u]:h[u]+_,data:{[u]:T,centerOffset:$-T-_,...j&&{alignmentOffset:_}},reset:j}}}),Sd=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)]:pd(l)),C=x!=="none";!h&&C&&S.push(...xd(l,g,x,E));const k=[l,...S],A=await d.detectOverflow(t,y),D=[];let U=((r=a.flip)==null?void 0:r.overflows)||[];if(m&&D.push(A[b]),p){const $=fd(s,i,E);D.push(A[$[0]],A[$[1]])}if(U=[...U,{placement:s,overflows:D}],!D.every($=>$<=0)){var W,M;const $=(((W=a.flip)==null?void 0:W.index)||0)+1,T=k[$];if(T&&(!(p==="alignment"?v!==Be(T):!1)||U.every(R=>Be(R.placement)===v?R.overflows[0]>0:!0)))return{data:{index:$,overflows:U},reset:{placement:T}};let j=(M=U.filter(_=>_.overflows[0]<=0).sort((_,R)=>_.overflows[1]-R.overflows[1])[0])==null?void 0:M.placement;if(!j)switch(u){case"bestFit":{var L;const _=(L=U.filter(R=>{if(C){const N=Be(R.placement);return N===v||N==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(N=>N>0).reduce((N,H)=>N+H,0)]).sort((R,N)=>R[1]-N[1])[0])==null?void 0:L[0];_&&(j=_);break}case"initialPlacement":j=l;break}if(s!==j)return{reset:{placement:j}}}return{}}}};function Po(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function To(e){return cd.some(t=>e[t]>=0)}const Nd=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=Po(i,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:To(l)}}}case"escaped":{const i=await r.detectOverflow(t,{...a,altBoundary:!0}),l=Po(i,n.floating);return{data:{escapedOffsets:l,escaped:To(l)}}}default:return{}}}}},Ns=new Set(["left","top"]);async function Ed(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=Ns.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 Cd=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 Ed(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}}}}},kd=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}}}}}},jd=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=Ns.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}}}},Pd=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,A=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=v),C&&!h){const U=Ee(m.left,0),W=Ee(m.right,0),M=Ee(m.top,0),L=Ee(m.bottom,0);u?A=x-2*(U!==0||W!==0?U+W:Ee(m.left,m.right)):k=g-2*(M!==0||L!==0?M+L:Ee(m.top,m.bottom))}await d({...t,availableWidth:A,availableHeight:k});const D=await i.getDimensions(l.floating);return x!==D.width||g!==D.height?{reset:{rects:!0}}:{}}}};function Fn(){return typeof window<"u"}function Lt(e){return Es(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=(Es(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Es(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 _o(e){return!Fn()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ce(e).ShadowRoot}const Td=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)&&!Td.has(s)}const _d=new Set(["table","td","th"]);function Rd(e){return _d.has(Lt(e))}const Ad=[":popover-open",":modal"];function Bn(e){return Ad.some(t=>{try{return e.matches(t)}catch{return!1}})}const Id=["transform","translate","scale","rotate","perspective"],Md=["transform","translate","scale","rotate","perspective","filter"],Od=["paint","layout","strict","content"];function Wr(e){const t=Hr(),n=Oe(e)?De(e):e;return Id.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)||Md.some(r=>(n.willChange||"").includes(r))||Od.some(r=>(n.contain||"").includes(r))}function Dd(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 Ld=new Set(["html","body","#document"]);function It(e){return Ld.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||_o(e)&&e.host||Ve(e);return _o(t)?t.host:t}function Cs(e){const t=st(e);return It(t)?e.ownerDocument?e.ownerDocument.body:e.body:He(t)&&Qt(t)?t:Cs(t)}function zt(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=Cs(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 ks(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}=ks(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 $d=Ue(0);function js(e){const t=Ce(e);return!Hr()||!t.visualViewport?$d:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Fd(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=Fd(a,n,r)?js(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 Ps(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 Bd(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?Ps(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 Ud(e){return Array.from(e.getClientRects())}function Wd(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 Ro=25;function Hd(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<=Ro&&(a-=x)}else f<=Ro&&(a+=f);return{width:a,height:i,x:l,y:d}}const Vd=new Set(["absolute","fixed"]);function qd(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 Ao(e,t,n){let r;if(t==="viewport")r=Hd(e,n);else if(t==="document")r=Wd(Ve(e));else if(Oe(t))r=qd(t,n);else{const s=js(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Nn(r)}function Ts(e,t){const n=st(e);return n===t||!Oe(n)||It(n)?!1:De(n).position==="fixed"||Ts(n,t)}function Kd(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&&Vd.has(s.position)||Qt(i)&&!d&&Ts(e,i))?r=r.filter(m=>m!==i):s=l,i=st(i)}return t.set(e,r),r}function zd(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const i=[...n==="clippingAncestors"?Bn(t)?[]:Kd(t,this._c):[].concat(n),r],l=i[0],d=i.reduce((f,m)=>{const p=Ao(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},Ao(t,l,s));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Gd(e){const{width:t,height:n}=ks(e);return{width:t,height:n}}function Yd(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?Ps(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 Io(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 _s(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=Io(e,t);for(;r&&Rd(r)&&or(r);)r=Io(r,t);return r&&It(r)&&or(r)&&!Wr(r)?n:r||Dd(e)||n}const Jd=async function(e){const t=this.getOffsetParent||_s,n=this.getDimensions,r=await n(e.floating);return{reference:Yd(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xd(e){return De(e).direction==="rtl"}const Zd={convertOffsetParentRelativeRectToViewportRelativeRect:Bd,getDocumentElement:Ve,getClippingRect:zd,getOffsetParent:_s,getElementRects:Jd,getClientRects:Ud,getDimensions:Gd,getScale:_t,isElement:Oe,isRTL:Xd};function Rs(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Qd(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&&!Rs(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 eu(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?Qd(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&&!Rs(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 tu=Cd,nu=kd,ru=Sd,ou=Pd,su=Nd,Mo=wd,au=jd,iu=(e,t,n)=>{const r=new Map,s={platform:Zd,...n},a={...s.platform,_c:r};return vd(e,t,{...s,platform:a})};var cu=typeof document<"u",lu=function(){},xn=cu?c.useLayoutEffect:lu;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 As(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Oo(e,t){const n=As(e);return Math.round(t*n)/n}function sr(e){const t=c.useRef(e);return xn(()=>{t.current=e}),t}function du(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(R=>{R!==C.current&&(C.current=R,g(R))},[]),w=c.useCallback(R=>{R!==k.current&&(k.current=R,b(R))},[]),E=a||x,S=i||y,C=c.useRef(null),k=c.useRef(null),A=c.useRef(m),D=d!=null,U=sr(d),W=sr(s),M=sr(f),L=c.useCallback(()=>{if(!C.current||!k.current)return;const R={placement:t,strategy:n,middleware:h};W.current&&(R.platform=W.current),iu(C.current,k.current,R).then(N=>{const H={...N,isPositioned:M.current!==!1};$.current&&!En(A.current,H)&&(A.current=H,Ot.flushSync(()=>{p(H)}))})},[h,t,n,W,M]);xn(()=>{f===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,p(R=>({...R,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(U.current)return U.current(E,S,L);L()}},[E,S,L,U,D]);const T=c.useMemo(()=>({reference:C,floating:k,setReference:v,setFloating:w}),[v,w]),j=c.useMemo(()=>({reference:E,floating:S}),[E,S]),_=c.useMemo(()=>{const R={position:n,left:0,top:0};if(!j.floating)return R;const N=Oo(j.floating,m.x),H=Oo(j.floating,m.y);return l?{...R,transform:"translate("+N+"px, "+H+"px)",...As(j.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:H}},[n,l,j.floating,m.x,m.y]);return c.useMemo(()=>({...m,update:L,refs:T,elements:j,floatingStyles:_}),[m,L,T,j,_])}const uu=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?Mo({element:r.current,padding:s}).fn(n):{}:r?Mo({element:r,padding:s}).fn(n):{}}}},fu=(e,t)=>({...tu(e),options:[e,t]}),pu=(e,t)=>({...nu(e),options:[e,t]}),mu=(e,t)=>({...au(e),options:[e,t]}),hu=(e,t)=>({...ru(e),options:[e,t]}),gu=(e,t)=>({...ou(e),options:[e,t]}),xu=(e,t)=>({...su(e),options:[e,t]}),yu=(e,t)=>({...uu(e),options:[e,t]});var bu="Arrow",Is=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"})})});Is.displayName=bu;var vu=Is;function wu(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",[Ms,Hn]=yt(qr),[Su,Os]=Ms(qr),Ds=e=>{const{__scopePopper:t,children:n}=e,[r,s]=c.useState(null);return o.jsx(Su,{scope:t,anchor:r,onAnchorChange:s,children:n})};Ds.displayName=qr;var Ls="PopperAnchor",$s=c.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,a=Os(Ls,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})});$s.displayName=Ls;var Kr="PopperContent",[Nu,Eu]=Ms(Kr),Fs=c.forwardRef((e,t)=>{var I,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=Os(Kr,n),[b,v]=c.useState(null),w=oe(t,ce=>v(ce)),[E,S]=c.useState(null),C=wu(E),k=(C==null?void 0:C.width)??0,A=(C==null?void 0:C.height)??0,D=r+(a!=="center"?"-"+a:""),U=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},W=Array.isArray(f)?f:[f],M=W.length>0,L={padding:U,boundary:W.filter(ku),altBoundary:M},{refs:$,floatingStyles:T,placement:j,isPositioned:_,middlewareData:R}=du({strategy:"fixed",placement:D,whileElementsMounted:(...ce)=>eu(...ce,{animationFrame:u==="always"}),elements:{reference:y.anchor},middleware:[fu({mainAxis:s+A,alignmentAxis:i}),d&&pu({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?mu():void 0,...L}),d&&hu({...L}),gu({...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&&yu({element:E,padding:l}),ju({arrowWidth:k,arrowHeight:A}),h&&xu({strategy:"referenceHidden",...L})]}),[N,H]=Ws(j),te=We(x);me(()=>{_&&(te==null||te())},[_,te]);const V=(I=R.arrow)==null?void 0:I.x,z=(Z=R.arrow)==null?void 0:Z.y,G=((X=R.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:{...T,transform:_?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ne,"--radix-popper-transform-origin":[(J=R.transformOrigin)==null?void 0:J.x,(q=R.transformOrigin)==null?void 0:q.y].join(" "),...((Y=R.hide)==null?void 0:Y.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx(Nu,{scope:n,placedSide:N,onArrowChange:S,arrowX:V,arrowY:z,shouldHideArrow:G,children:o.jsx(Q.div,{"data-side":N,"data-align":H,...g,ref:w,style:{...g.style,animation:_?void 0:"none"}})})})});Fs.displayName=Kr;var Bs="PopperArrow",Cu={top:"bottom",right:"left",bottom:"top",left:"right"},Us=c.forwardRef(function(t,n){const{__scopePopper:r,...s}=t,a=Eu(Bs,r),i=Cu[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(vu,{...s,ref:n,style:{...s.style,display:"block"}})})});Us.displayName=Bs;function ku(e){return e!==null}var ju=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]=Ws(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 Ws(e){const[t,n="center"]=e.split("-");return[t,n]}var Hs=Ds,Vs=$s,qs=Fs,Ks=Us,Pu="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?cs.createPortal(o.jsx(Q.div,{...r,ref:t}),i):null});Vn.displayName=Pu;function Tu(e,t){return c.useReducer((n,r)=>t[n][r]??n,e)}var it=e=>{const{present:t,children:n}=e,r=_u(t),s=typeof n=="function"?n({present:r.isPresent}):c.Children.only(n),a=oe(r.ref,Ru(s));return typeof n=="function"||r.isPresent?c.cloneElement(s,{ref:a}):null};it.displayName="Presence";function _u(e){const[t,n]=c.useState(),r=c.useRef(null),s=c.useRef(e),a=c.useRef("none"),i=e?"mounted":"unmounted",[l,d]=Tu(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 Ru(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",Au={bubbles:!1,cancelable:!0},en="RovingFocusGroup",[xr,zs,Iu]=Dr(en),[Mu,Gs]=yt(en,[Iu]),[Ou,Du]=Mu(en),Ys=c.forwardRef((e,t)=>o.jsx(xr.Provider,{scope:e.__scopeRovingFocusGroup,children:o.jsx(xr.Slot,{scope:e.__scopeRovingFocusGroup,children:o.jsx(Lu,{...e,ref:t})})}));Ys.displayName=en;var Lu=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=zs(n),S=c.useRef(!1),[C,k]=c.useState(0);return c.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(ar,w),()=>A.removeEventListener(ar,w)},[w]),o.jsx(Ou,{scope:n,orientation:r,dir:x,loop:s,currentTabStopId:g,onItemFocus:c.useCallback(A=>y(A),[y]),onItemShiftTab:c.useCallback(()=>v(!0),[]),onFocusableItemAdd:c.useCallback(()=>k(A=>A+1),[]),onFocusableItemRemove:c.useCallback(()=>k(A=>A-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,A=>{const D=!S.current;if(A.target===A.currentTarget&&D&&!b){const U=new CustomEvent(ar,Au);if(A.currentTarget.dispatchEvent(U),!U.defaultPrevented){const W=E().filter(j=>j.focusable),M=W.find(j=>j.active),L=W.find(j=>j.id===g),T=[M,L,...W].filter(Boolean).map(j=>j.ref.current);Zs(T,m)}}S.current=!1}),onBlur:B(e.onBlur,()=>v(!1))})})}),Js="RovingFocusGroupItem",Xs=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=Du(Js,n),p=m.currentTabStopId===f,h=zs(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=Bu(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?Uu(w,E+1):w.slice(E+1)}setTimeout(()=>Zs(w))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:g!=null}):i})})});Xs.displayName=Js;var $u={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Fu(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Bu(e,t,n){const r=Fu(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return $u[r]}function Zs(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Uu(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Wu=Ys,Hu=Xs,Vu=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,Qs=function(e){return e&&(e.host||Qs(e.parentNode))},qu=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Qs(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})},Ku=function(e,t,n,r){var s=qu(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=Vu(e);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live], script"))),Ku(r,s,n,"aria-hidden")):function(){return null}},yr=["Enter"," "],zu=["ArrowDown","PageUp","Home"],ea=["ArrowUp","PageDown","End"],Gu=[...zu,...ea],Yu={ltr:[...yr,"ArrowRight"],rtl:[...yr,"ArrowLeft"]},Ju={ltr:["ArrowLeft"],rtl:["ArrowRight"]},tn="Menu",[Gt,Xu,Zu]=Dr(tn),[bt,ta]=yt(tn,[Zu,Hn,Gs]),qn=Hn(),na=Gs(),[Qu,vt]=bt(tn),[ef,nn]=bt(tn),ra=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(Hs,{...l,children:o.jsx(Qu,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:f,children:o.jsx(ef,{scope:t,onClose:c.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:m,dir:h,modal:i,children:r})})})};ra.displayName=tn;var tf="MenuAnchor",Gr=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,s=qn(n);return o.jsx(Vs,{...s,...r,ref:t})});Gr.displayName=tf;var Yr="MenuPortal",[nf,oa]=bt(Yr,{forceMount:void 0}),sa=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:s}=e,a=vt(Yr,t);return o.jsx(nf,{scope:t,forceMount:n,children:o.jsx(it,{present:n||a.open,children:o.jsx(Vn,{asChild:!0,container:s,children:r})})})};sa.displayName=Yr;var je="MenuContent",[rf,Jr]=bt(je),aa=c.forwardRef((e,t)=>{const n=oa(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(of,{...s,ref:t}):o.jsx(sf,{...s,ref:t})})})})}),of=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)})}),sf=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)})}),af=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=na(n),E=Xu(n),[S,C]=c.useState(null),k=c.useRef(null),A=oe(t,k,y.onContentChange),D=c.useRef(0),U=c.useRef(""),W=c.useRef(0),M=c.useRef(null),L=c.useRef("right"),$=c.useRef(0),T=x?Ir:c.Fragment,j=x?{as:af,allowPinchZoom:!0}:void 0,_=N=>{var I,Z;const H=U.current+N,te=E().filter(X=>!X.disabled),V=document.activeElement,z=(I=te.find(X=>X.ref.current===V))==null?void 0:I.textValue,G=te.map(X=>X.textValue),ne=bf(G,H,z),ie=(Z=te.find(X=>X.textValue===ne))==null?void 0:Z.ref.current;(function X(J){U.current=J,window.clearTimeout(D.current),J!==""&&(D.current=window.setTimeout(()=>X(""),1e3))})(H),ie&&setTimeout(()=>ie.focus())};c.useEffect(()=>()=>window.clearTimeout(D.current),[]),$r();const R=c.useCallback(N=>{var te,V;return L.current===((te=M.current)==null?void 0:te.side)&&wf(N,(V=M.current)==null?void 0:V.area)},[]);return o.jsx(rf,{scope:n,searchRef:U,onItemEnter:c.useCallback(N=>{R(N)&&N.preventDefault()},[R]),onItemLeave:c.useCallback(N=>{var H;R(N)||((H=k.current)==null||H.focus(),C(null))},[R]),onTriggerLeave:c.useCallback(N=>{R(N)&&N.preventDefault()},[R]),pointerGraceTimerRef:W,onPointerGraceIntentChange:c.useCallback(N=>{M.current=N},[]),children:o.jsx(T,{...j,children:o.jsx($n,{asChild:!0,trapped:s,onMountAutoFocus:B(a,N=>{var H;N.preventDefault(),(H=k.current)==null||H.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(Wu,{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(qs,{role:"menu","aria-orientation":"vertical","data-state":Sa(y.open),"data-radix-menu-content":"",dir:b.dir,...v,...g,ref:A,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&&_(N.key));const G=k.current;if(N.target!==G||!Gu.includes(N.key))return;N.preventDefault();const ie=E().filter(I=>!I.disabled).map(I=>I.ref.current);ea.includes(N.key)&&ie.reverse(),xf(ie)}),onBlur:B(e.onBlur,N=>{N.currentTarget.contains(N.target)||(window.clearTimeout(D.current),U.current="")}),onPointerMove:B(e.onPointerMove,Yt(N=>{const H=N.target,te=$.current!==N.clientX;if(N.currentTarget.contains(H)&&te){const V=N.clientX>$.current?"right":"left";L.current=V,$.current=N.clientX}}))})})})})})})});aa.displayName=je;var cf="MenuGroup",Zr=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(Q.div,{role:"group",...r,ref:t})});Zr.displayName=cf;var lf="MenuLabel",ia=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(Q.div,{...r,ref:t})});ia.displayName=lf;var Cn="MenuItem",Do="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(Do,{bubbles:!0,cancelable:!0});p.addEventListener(Do,u=>r==null?void 0:r(u),{once:!0}),ys(p,h),h.defaultPrevented?f.current=!1:i.onClose()}};return o.jsx(ca,{...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 ca=c.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:s,...a}=e,i=Jr(Cn,n),l=na(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(Hu,{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))})})})}),df="MenuCheckboxItem",la=c.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...s}=e;return o.jsx(ma,{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})})})});la.displayName=df;var da="MenuRadioGroup",[uf,ff]=bt(da,{value:void 0,onValueChange:()=>{}}),ua=c.forwardRef((e,t)=>{const{value:n,onValueChange:r,...s}=e,a=We(r);return o.jsx(uf,{scope:e.__scopeMenu,value:n,onValueChange:a,children:o.jsx(Zr,{...s,ref:t})})});ua.displayName=da;var fa="MenuRadioItem",pa=c.forwardRef((e,t)=>{const{value:n,...r}=e,s=ff(fa,e.__scopeMenu),a=n===s.value;return o.jsx(ma,{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})})})});pa.displayName=fa;var Qr="MenuItemIndicator",[ma,pf]=bt(Qr,{checked:!1}),ha=c.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...s}=e,a=pf(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)})})});ha.displayName=Qr;var mf="MenuSeparator",ga=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return o.jsx(Q.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});ga.displayName=mf;var hf="MenuArrow",xa=c.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,s=qn(n);return o.jsx(Ks,{...s,...r,ref:t})});xa.displayName=hf;var gf="MenuSub",[_g,ya]=bt(gf),Ut="MenuSubTrigger",ba=c.forwardRef((e,t)=>{const n=vt(Ut,e.__scopeMenu),r=nn(Ut,e.__scopeMenu),s=ya(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(ca,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":s.contentId,"data-state":Sa(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===" "||Yu[r.dir].includes(p.key)&&(n.onOpenChange(!0),(u=n.content)==null||u.focus(),p.preventDefault())})})})});ba.displayName=Ut;var va="MenuSubContent",wa=c.forwardRef((e,t)=>{const n=oa(je,e.__scopeMenu),{forceMount:r=n.forceMount,...s}=e,a=vt(je,e.__scopeMenu),i=nn(je,e.__scopeMenu),l=ya(va,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=Ju[i.dir].includes(m.key);p&&h&&(a.onOpenChange(!1),(u=l.trigger)==null||u.focus(),m.preventDefault())})})})})})});wa.displayName=va;function Sa(e){return e?"open":"closed"}function kn(e){return e==="indeterminate"}function eo(e){return kn(e)?"indeterminate":e?"checked":"unchecked"}function xf(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function yf(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function bf(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=yf(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 vf(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 wf(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return vf(n,t)}function Yt(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Sf=ra,Nf=Gr,Ef=sa,Cf=aa,kf=Zr,jf=ia,Pf=Kn,Tf=la,_f=ua,Rf=pa,Af=ha,If=ga,Mf=xa,Of=ba,Df=wa,zn="DropdownMenu",[Lf]=yt(zn,[ta]),he=ta(),[$f,Na]=Lf(zn),Ea=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($f,{scope:t,triggerId:Ye(),triggerRef:f,contentId:Ye(),open:m,onOpenChange:p,onOpenToggle:c.useCallback(()=>p(h=>!h),[p]),modal:l,children:o.jsx(Sf,{...d,open:m,onOpenChange:p,dir:r,modal:l,children:n})})};Ea.displayName=zn;var Ca="DropdownMenuTrigger",ka=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...s}=e,a=Na(Ca,n),i=he(n);return o.jsx(Nf,{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())})})})});ka.displayName=Ca;var Ff="DropdownMenuPortal",ja=e=>{const{__scopeDropdownMenu:t,...n}=e,r=he(t);return o.jsx(Ef,{...r,...n})};ja.displayName=Ff;var Pa="DropdownMenuContent",Ta=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=Na(Pa,n),a=he(n),i=c.useRef(!1);return o.jsx(Cf,{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)"}})});Ta.displayName=Pa;var Bf="DropdownMenuGroup",Uf=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(kf,{...s,...r,ref:t})});Uf.displayName=Bf;var Wf="DropdownMenuLabel",_a=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(jf,{...s,...r,ref:t})});_a.displayName=Wf;var Hf="DropdownMenuItem",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="DropdownMenuCheckboxItem",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="DropdownMenuRadioGroup",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="DropdownMenuRadioItem",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="DropdownMenuItemIndicator",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="DropdownMenuSeparator",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="DropdownMenuArrow",Jf=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Mf,{...s,...r,ref:t})});Jf.displayName=Yf;var Xf="DropdownMenuSubTrigger",La=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Of,{...s,...r,ref:t})});La.displayName=Xf;var Zf="DropdownMenuSubContent",$a=c.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,s=he(n);return o.jsx(Df,{...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)"}})});$a.displayName=Zf;var Qf=Ea,ep=ka,tp=ja,Fa=Ta,Ba=_a,Ua=Ra,Wa=Aa,np=Ia,Ha=Ma,Va=Oa,qa=Da,Ka=La,za=$a;function F(...e){return Pc(e)}const rp=new Set(["RUNNING","STARTING","NEEDS_PERMISSION","NEEDS_INPUT"]);function to(e){return rp.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 Ga(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 Ya=Qf,Ja=ep,op=np,sp=c.forwardRef(({className:e,inset:t,children:n,...r},s)=>o.jsxs(Ka,{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"})})]}));sp.displayName=Ka.displayName;const ap=c.forwardRef(({className:e,...t},n)=>o.jsx(za,{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}));ap.displayName=za.displayName;const no=c.forwardRef(({className:e,sideOffset:t=4,...n},r)=>o.jsx(tp,{children:o.jsx(Fa,{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=Fa.displayName;const Wt=c.forwardRef(({className:e,inset:t,...n},r)=>o.jsx(Ua,{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=Ua.displayName;const ip=c.forwardRef(({className:e,children:t,checked:n,...r},s)=>o.jsxs(Wa,{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(Va,{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]}));ip.displayName=Wa.displayName;const Xa=c.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(Ha,{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(Va,{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]}));Xa.displayName=Ha.displayName;const Za=c.forwardRef(({className:e,inset:t,...n},r)=>o.jsx(Ba,{ref:r,className:F("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Za.displayName=Ba.displayName;const ro=c.forwardRef(({className:e,...t},n)=>o.jsx(qa,{ref:n,className:F("-mx-1 my-1 h-px bg-muted",e),...t}));ro.displayName=qa.displayName;const Qa="codepiper.theme",ei="codepiper-dark",ti="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"}}],cp=new Map(oo.map(e=>[e.id,e]));function yn(e){if(e)return cp.get(e)}function lp(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 dp(e){const t=lp(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 up({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 fp(e){return up(dp(e))}const pp={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 mp(e){document.documentElement.style.colorScheme=e}function hp(e){const t=document.querySelector('meta[name="theme-color"]');t instanceof HTMLMetaElement&&(t.content=e)}function gp(e){const t=document.documentElement;t.dataset.theme=e.id,t.classList.toggle("dark",e.mode==="dark");for(const[n,r]of Object.entries(pp)){const s=n;t.style.setProperty(r,fp(e.ui[s]))}mp(e.mode),hp(e.themeColor)}function xp(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function yp(){const e=localStorage.getItem("theme");if(e==="dark")return ei;if(e==="light")return ti}function bp(){const e=localStorage.getItem(Qa),t=yn(e);if(t)return t;const n=yp(),r=yn(n);if(r)return r;const a=xp()==="dark"?ei:ti;return yn(a)??oo[0]}function vp(e){localStorage.setItem(Qa,e)}const ni=c.createContext(null);function wp({children:e}){const[t,n]=c.useState(()=>bp());c.useEffect(()=>{gp(t),vp(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(ni.Provider,{value:s,children:e})}function so(){const e=c.useContext(ni);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}function Lo({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 Sp({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(Ya,{children:[o.jsx(Ja,{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(Lo,{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(Za,{className:"text-[10px] uppercase tracking-[0.14em] text-muted-foreground font-semibold",children:"Theme"}),o.jsx(ro,{}),o.jsx(op,{value:t.id,onValueChange:r,children:n.map(i=>o.jsx(Xa,{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(Lo,{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 Np{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 Np,$o={"session.turn_completed":"Turn completed","session.permission_required":"Permission required","session.input_required":"Input required"},Ep={"claude-code":"Claude Code",codex:"Codex"};function Cp(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function ri(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function oi(e,t){return e.toLocaleLowerCase().includes(t.toLocaleLowerCase())}function kp(e,t){return oi(e,t)?e:`${t}: ${e}`}function ao(e){return e in $o?$o[e]:ri(e.replace(/[._]+/g," "))}function si(e){return Ep[e]??ri(e.replace(/-/g," "))}function jp(e){return io(e)}function io(e,t){if(typeof t=="string"&&t.trim())return t.trim();const n=e.payload;return Cp(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()?kp(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:oi(r,n)?r:`${n} · ${r}`}const co="/sounds/codepiper-soft-chime.wav",Rg=[{key:"session.turn_completed",label:"Turn completed"},{key:"session.permission_required",label:"Permission required"},{key:"session.input_required",label:"Input required"}],Ag=512*1024;function Pp(e,t){return e[t]||e.default||co}function Ig(e){return e.type.startsWith("audio/")?!0:/\.(mp3|wav|ogg|m4a|aac|webm|flac)$/i.test(e.name)}const Tp="dev";function _p(){const e="0.1.0".trim(),t=globalThis.__CODEPIPER_WEB_BUILD_ID__,n=typeof t=="string"?t.trim():"",r=e||n;return r.length>0?r:Tp}function ai(){return`/sw.js?v=${encodeURIComponent(_p())}`}function Pn(e){e.waiting&&e.waiting.postMessage({type:"SKIP_WAITING"})}function Rp(e){return e==="sessions"||e==="notifications"||/^session:[a-zA-Z0-9-]+:(events|pty)$/.test(e)}function Ap(e){return/^session:[a-zA-Z0-9-]+:pty$/.test(e)}const cr=1,Fo=!1,Bo=!1,Uo=!0,Ip=67,Mp=1,Op=1,Dp=2,Wo=10,Lp=16,Ho=4,lr=new TextDecoder,$p=new TextEncoder,Fp=3e4,dr=8192,Bp=512,Up=2*1024*1024,Wp=256*1024,Hp=8,Vp=80;let ur=0;class qp{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=Gp(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(zp(t)&&!("topic"in t)){this.handleControlMessage(t);return}if(!Kp(t)){this.telemetry.invalidMessageShape+=1,console.error("[WebSocket] Invalid message payload shape");return}if(!Rp(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:Fo,ptyBinary:Bo,ptyPaste:Uo}})))}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,Ap(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=Yp(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:Fo,clientAdvertisesPtyBinary:Bo,clientAdvertisesPtyPaste:Uo,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)},Fp);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>Wp&&n<Vp;)n+=1,await new Promise(r=>setTimeout(r,Hp));if(t.readyState!==WebSocket.OPEN)throw new Error("WebSocket disconnected while streaming paste")}}function Kp(e){return!(e&&typeof e=="object")||Array.isArray(e)?!1:typeof e.topic=="string"}function zp(e){return!(e&&typeof e=="object")||Array.isArray(e)?!1:typeof e.op=="string"}function Gp(e){const t=new Uint8Array(e);if(t.byteLength<Wo+Ho)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!==Ip||s!==Mp)return null;const i=n.getUint16(4,!0),l=n.getUint32(6,!0);let d=Wo;const f=d+i;if(f>t.byteLength)return null;const m=lr.decode(t.subarray(d,f));if(d=f,a===Op){if(d+Ho>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===Dp){if(d+Lp>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 Yp(e){if(!e)return[];if($p.encode(e).byteLength>Up||e.length>dr*Bp)return null;const t=[];for(let n=0;n<e.length;n+=dr)t.push(e.slice(n,n+dr));return t}const Jp=window.location.protocol==="https:"?"wss:":"ws:",Xp=`${Jp}//${window.location.host}/ws`,at=new qp(Xp),Sr={totalUnread:0,bySession:{}},Vo={notificationsEnabled:!1,systemNotificationsEnabled:!1,notificationSoundsEnabled:!0,notificationEventDefaults:{},notificationSoundMap:{default:co}},ii=c.createContext(null);function Mt(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function qo(e){return typeof e!="number"||Number.isNaN(e)||!Number.isFinite(e)?0:Math.max(0,Math.floor(e))}function Ko(e){if(!Mt(e))return Sr;const t=Mt(e.bySession)?e.bySession:{},n=Object.entries(t).reduce((r,[s,a])=>{const i=qo(a);return i>0&&(r[s]=i),r},{});return{totalUnread:qo(e.totalUnread),bySession:n}}function Zp(e){return e.type==="notification_counts_updated"&&Mt(e.data)}function zo(e,t){return Mt(e)?typeof e.status=="number"&&e.status===t:!1}function Go(e){return typeof e=="string"?e:typeof e=="number"&&Number.isFinite(e)?new Date(e).toISOString():e instanceof Date?e.toISOString():null}function ci(){return typeof window<"u"&&window.isSecureContext&&"serviceWorker"in navigator&&"PushManager"in window}function Qp(){const e="BCIemzlq0T3JcsJV-fuX4hcQ8FCTA9aL6U1huib00SljUW8Rba1--2uY96xUZbpLt-XkFForwp7CjiHumANPKnc";return e.trim()===""?null:e.trim()}function em(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 tm(e,t){var r;const n=(r=e.options)==null?void 0:r.applicationServerKey;return n?Nr(n)===t:!0}function nm(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 rm(){if(!ci())return null;try{const e=await navigator.serviceWorker.getRegistration();if(e)return Pn(e),e;const t=await navigator.serviceWorker.register(ai());return Pn(t),t}catch{return null}}function om(e){if(!Mt(e)||typeof e.id!="number"||typeof e.sessionId!="string"||typeof e.title!="string"||typeof e.eventType!="string")return null;const t=Go(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:Go(e.readAt),readSource:typeof e.readSource=="string"?e.readSource:null}:null}function sm({children:e}){const[t,n]=c.useState(Sr),[r,s]=c.useState(Vo),[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(Ko(g.counts)),m(null)}catch(g){if(zo(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){zo(g,404)&&s(Vo)}},[]),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=om(v.data);w&&i(w);return}Zp(v)&&n(Ko(v.data))}),b=at.onConnectionChange(v=>{v&&(p(),h())});return()=>{g=!1,y(),b()}},[p,h]),c.useEffect(()=>{if(!(r.notificationsEnabled&&r.systemNotificationsEnabled)||!ci()||typeof window>"u"||typeof window.Notification>"u"||window.Notification.permission!=="granted")return;let g=!1;return(async()=>{try{const v=await(async()=>{const C=Qp();if(C)return C;try{const A=(await ae.getPushDeliveryStatus()).status.publicKey;if(typeof A=="string"&&A.trim()!=="")return A.trim()}catch{}return null})();if(!v||g)return;const w=await rm();if(!(w&&!g))return;let E=await w.pushManager.getSubscription();if(E&&!tm(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:em(v)})),!(E&&!g))return;const S=nm(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(ii.Provider,{value:x,children:e})}function rn(){const e=c.useContext(ii);if(!e)throw new Error("useNotifications must be used within a NotificationProvider");return e}const Ct=5,Yo="(max-width: 767px)";function Er(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function am(e,t){return Er(e)&&typeof e.status=="number"&&e.status===t}function im(e){return e.type==="notification_created"}function cm(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 lm(e,t){const n=e.filter(r=>r.id!==t.id);return n.unshift(t),bn(n)}function dm(){const[e,t]=c.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(Yo).matches);return c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia(Yo),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 um({open:e,onClose:t}){const n=gt(),r=dm(),{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 j=await ae.getNotifications({unreadOnly:p,limit:Ct+1}),_=bn(j.notifications),R=_.length>Ct,N=R?_.slice(0,Ct):_;x(N),v(R),E(N.length>0?(T=N[N.length-1])==null?void 0:T.id:void 0),y(!0),m(null),await s()}catch(j){if(am(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 T;if(!(!(e&&b&&w!==void 0)||a||l)){d(!0);try{const j=await ae.getNotifications({unreadOnly:p,before:w,limit:Ct+1}),_=bn(j.notifications),R=_.length>Ct,N=R?_.slice(0,Ct):_;if(N.length===0){v(!1);return}x(H=>bn([...H,...N])),E((T=N[N.length-1])==null?void 0:T.id),v(R),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 T=at.subscribe("notifications",j=>{if(j.type==="notification_read"){S();return}if(im(j)){const _=cm(j.data);if(!(_&&!(p&&_.readAt)))return;x(R=>lm(R,_));return}j.type==="notification_counts_updated"&&s()});return()=>{T()}},[e,p,S,s]);const k=c.useMemo(()=>u.reduce((T,j)=>T+(j.readAt?0:1),0),[u]),A=c.useCallback(async T=>{if(!T.readAt)try{await ae.markNotificationRead(T.id,"click")}catch{}x(j=>j.map(_=>_.id===T.id?{..._,readAt:_.readAt??new Date().toISOString(),readSource:"click"}:_)),s(),n(`/sessions/${T.sessionId}/terminal`),t()},[n,t,s]),D=c.useCallback(async()=>{try{if((await ae.markNotificationsRead({readSource:"bulk"})).updated>0){const j=new Date().toISOString();x(_=>_.map(R=>R.readAt?R:{...R,readAt:j,readSource:"bulk"}))}s()}catch(T){m(T instanceof Error?T.message:"Failed to mark notifications as read")}},[s]);if(!e)return null;const U=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(us,{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 D(),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(Jc,{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 A(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:si(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:jp(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."})})]})}),W=r&&typeof document<"u",M=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:M,onClick:t}),o.jsx("section",{role:"dialog","aria-modal":"true","aria-label":"Notification inbox",className:L,children:U})]});return r&&typeof document>"u"?null:W?Ot.createPortal($,document.body):$}function fm(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 pm(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"?fm(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=>{pm(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 Jo(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function mm(e){const t=e.trim();return t.length>0?t:null}function li(e){if(!Jo(e.metadata))return null;const t=e.metadata.ui;return!Jo(t)||typeof t.customName!="string"?null:mm(t.customName)}function di(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=li(s);if(a){t.set(s.id,a);continue}const i=di(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))??li(e)??di(e.cwd)}function hm(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function gm(e){const t=e.match(/^\/sessions\/([^/]+)(?:\/([^/]+))?$/);if(!t)return null;const n=t[1],r=t[2];return r&&r!=="terminal"?null:n}function xm(){return typeof window<"u"&&window.isSecureContext&&typeof window.Notification<"u"&&window.Notification.permission==="granted"}function ym(e){return`/sessions/${encodeURIComponent(e)}/terminal`}const bm=45e3;function vm(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 wm(){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(()=>gm(r.pathname),[r.pathname]),E=c.useMemo(()=>sn(s),[s]);c.useEffect(()=>(m(at.isConnected()),at.onConnectionChange(M=>{m(M)})),[]),c.useEffect(()=>{if(!p)return;const M=L=>{L.key==="Escape"&&h(!1)};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[p]),c.useEffect(()=>{const M=()=>{v.current=Date.now()},L={passive:!0};return window.addEventListener("pointerdown",M,L),window.addEventListener("keydown",M),window.addEventListener("touchstart",M,L),window.addEventListener("focus",M),document.addEventListener("visibilitychange",M),()=>{window.removeEventListener("pointerdown",M),window.removeEventListener("keydown",M),window.removeEventListener("touchstart",M),window.removeEventListener("focus",M),document.removeEventListener("visibilitychange",M)}},[]);const S=c.useCallback(async M=>{if(!i.notificationSoundsEnabled)return;const L=Pp(i.notificationSoundMap,M);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 T=b.current;T.state==="suspended"&&await T.resume().catch(()=>{});const j=T.createOscillator(),_=T.createGain();j.type="sine",j.frequency.value=880,_.gain.value=1e-4,j.connect(_),_.connect(T.destination);const R=T.currentTime;_.gain.exponentialRampToValueAtTime(.035,R+.01),_.gain.exponentialRampToValueAtTime(1e-4,R+.16),j.start(R),j.stop(R+.18)}catch{}},[i.notificationSoundsEnabled,i.notificationSoundMap]),C=c.useCallback(async(M,L,$)=>{if(!(i.systemNotificationsEnabled&&xm()))return!1;const T=vr(M,$),j=wr(M,$),_=`codepiper:notification:${M.id}`,R={url:L,sessionId:M.sessionId,notificationId:M.id};try{if("serviceWorker"in navigator){const H=await navigator.serviceWorker.getRegistration();if(H)return await H.showNotification(j,{body:T,tag:_,icon:"/apple-touch-icon.png",badge:"/logo.svg",data:R}),!0}const N=new window.Notification(j,{body:T,tag:_,icon:"/apple-touch-icon.png",data:R});return N.onclick=()=>{typeof window.focus=="function"&&window.focus(),ae.markNotificationRead(M.id,"click"),n(L),N.close()},!0}catch{return!1}},[n,i.systemNotificationsEnabled]);c.useEffect(()=>{if(!g)return;const M=setTimeout(()=>{y(L=>(L==null?void 0:L.id)===g.id?null:L)},6500);return()=>{clearTimeout(M)}},[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,T=Date.now()-v.current>=bm;if($&&!T){ae.markNotificationRead(l.id,"active").catch(()=>{}),d(l.id);return}const j=ym(l.sessionId),_=E.get(l.sessionId)??null,R=L;let N=null,H=!1;return(async()=>{var V;await C(l,j,_),!H&&(R&&(hm()||(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:si(l.provider),title:wr(l,_),description:vr(l,_),targetPath:j}),S(l.eventType)),d(l.id))})(),()=>{H=!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",A=g?vm(g.eventType):null,D=c.useCallback(()=>{g&&(ae.markNotificationRead(g.id,"click"),n(g.targetPath),y(null))},[g,n]),U=c.useCallback(()=>{y(null)},[]),W=g&&A&&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",A.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",A.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:U,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(_l,{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:D,className:F("h-8 rounded-full px-4 text-[0.75rem] font-semibold tracking-[0.01em] transition-colors",A.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(Pl,{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(kl,{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(M=>!M),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(us,{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(um,{open:p,onClose:()=>h(!1)})]}),o.jsx(Sp,{}),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(hl,{className:"h-4 w-4"})})]})]})}),W]})}var Sm=e=>{switch(e){case"success":return Cm;case"info":return jm;case"warning":return km;case"error":return Pm;default:return null}},Nm=Array(12).fill(0),Em=({visible:e,className:t})=>P.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},P.createElement("div",{className:"sonner-spinner"},Nm.map((n,r)=>P.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),Cm=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"})),km=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"})),jm=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"})),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-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"})),Tm=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"})),_m=()=>{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,Rm=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(Im(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 Rm,Am=(e,t)=>{let n=(t==null?void 0:t.id)||Cr++;return be.addToast({title:e,...t,id:n}),n},Im=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",Mm=Am,Om=()=>be.toasts,Dm=()=>be.getActiveToasts(),ve=Object.assign(Mm,{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:Om,getToasts:Dm});function Lm(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))}Lm(`: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 $m=3,Fm="32px",Bm="16px",Xo=4e3,Um=356,Wm=14,Hm=20,Vm=200;function Ie(...e){return e.filter(Boolean).join(" ")}function qm(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var Km=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:A,style:D,cancelButtonStyle:U,actionButtonStyle:W,className:M="",descriptionClassName:L="",duration:$,position:T,gap:j,loadingIcon:_,expandByDefault:R,classNames:N,icons:H,closeButtonAriaLabel:te="Close toast",pauseWhenPageIsHidden:V}=e,[z,G]=P.useState(null),[ne,ie]=P.useState(null),[I,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||$||Xo),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:A},[u.closeButton,A]),dn=P.useMemo(()=>u.duration||$||Xo,[u.duration,$]),St=P.useRef(0),qe=P.useRef(0),Ft=P.useRef(0),Ke=P.useRef(null),[O,fe]=T.split("-"),xe=P.useMemo(()=>v.reduce((K,re,se)=>se>=wt?K:K+re.height,0),[v,wt]),ye=_m(),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(!I)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])},[I,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)},Vm)},[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 wc(){var K,re,se;return H!=null&&H.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"},H.loading):_?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"},_):P.createElement(Em,{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(M,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":I,"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||R&&I),style:{"--index":w,"--toasts-before":w,"--z-index":E.length-w,"--offset":`${X?we:qe.current}px`,"--initial-height":R?"auto":`${Se}px`,...D,...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)>=Hm||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:qm(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?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=H==null?void 0:H.close)!=null?a:Tm):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||wc():null,u.type!=="loading"?u.icon||(H==null?void 0:H[ge])||Sm(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||U,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 Zo(){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 zm(e,t){let n={};return[e,t].forEach((r,s)=>{let a=s===1,i=a?"--mobile-offset":"--offset",l=a?Bm:Fm;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 Gm=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=$m,toastOptions:g,dir:y=Zo(),gap:b=Wm,loadingIcon:v,icons:w,containerAriaLabel:E="Notifications",pauseWhenPageIsHidden:S}=e,[C,k]=P.useState([]),A=P.useMemo(()=>Array.from(new Set([r].concat(C.filter(V=>V.position).map(V=>V.position)))),[C,r]),[D,U]=P.useState([]),[W,M]=P.useState(!1),[L,$]=P.useState(!1),[T,j]=P.useState(m!=="system"?m:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),_=P.useRef(null),R=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),N=P.useRef(null),H=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(()=>{cs.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&&M(!1)},[C]),P.useEffect(()=>{let V=z=>{var G,ne;s.every(ie=>z[ie]||z.code===ie)&&(M(!0),(G=_.current)==null||G.focus()),z.code==="Escape"&&(document.activeElement===_.current||(ne=_.current)!=null&&ne.contains(document.activeElement))&&M(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[s]),P.useEffect(()=>{if(_.current)return()=>{N.current&&(N.current.focus({preventScroll:!0}),N.current=null,H.current=!1)}},[_.current]),P.createElement("section",{ref:t,"aria-label":`${E} ${R}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((V,z)=>{var G;let[ne,ie]=V.split("-");return C.length?P.createElement("ol",{key:V,dir:y==="auto"?Zo():y,tabIndex:-1,ref:_,className:l,"data-sonner-toaster":!0,"data-theme":T,"data-y-position":ne,"data-lifted":W&&C.length>1&&!a,"data-x-position":ie,style:{"--front-toast-height":`${((G=D[0])==null?void 0:G.height)||0}px`,"--width":`${Um}px`,"--gap":`${b}px`,...u,...zm(d,f)},onBlur:I=>{H.current&&!I.currentTarget.contains(I.relatedTarget)&&(H.current=!1,N.current&&(N.current.focus({preventScroll:!0}),N.current=null))},onFocus:I=>{I.target instanceof HTMLElement&&I.target.dataset.dismissible==="false"||H.current||(H.current=!0,N.current=I.relatedTarget)},onMouseEnter:()=>M(!0),onMouseMove:()=>M(!0),onMouseLeave:()=>{L||M(!1)},onDragEnd:()=>M(!1),onPointerDown:I=>{I.target instanceof HTMLElement&&I.target.dataset.dismissible==="false"||$(!0)},onPointerUp:()=>$(!1)},C.filter(I=>!I.position&&z===0||I.position===V).map((I,Z)=>{var X,J;return P.createElement(Km,{key:I.id,icons:w,index:Z,toast:I,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==I.position),heights:D.filter(q=>q.position==I.position),setHeights:U,expandByDefault:a,gap:b,loadingIcon:v,expanded:W,pauseWhenPageIsHidden:S,swipeDirections:e.swipeDirections})})):null}))});const Ym=["terminal","git","policies","logs","events"],Jm=["terminal","git","policies"],Xm={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"}}}],Zm=new Map(kr.map(e=>[e.id,e]));function Qm(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 eh(e,t){const n=t==null?void 0:t.find(s=>s.id===e);if(n)return n;const r=Zm.get(e);return r||{id:e,label:Qm(e),runtime:"tmux",capabilities:Xm}}function th(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 nh(e){return e.nativeHooks||e.supportsTranscriptTailing}function rh(e){return nh(e)?Ym:Jm}function Mg(e,t){return rh(eh(e,t).capabilities)}const oh={"claude-code":{label:"Claude Code",icon:Kc,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:Vc,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"}},sh={label:"Provider",icon:ol,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=oh[e];return t||{...sh,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",[ui]=yt(Gn),[ah,Le]=ui(Gn),fi=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(ah,{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})};fi.displayName=Gn;var pi="DialogTrigger",mi=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(pi,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)})});mi.displayName=pi;var uo="DialogPortal",[ih,hi]=ui(uo,{forceMount:void 0}),gi=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:s}=e,a=Le(uo,t);return o.jsx(ih,{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})}))})};gi.displayName=uo;var Tn="DialogOverlay",xi=c.forwardRef((e,t)=>{const n=hi(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(lh,{...s,ref:t})}):null});xi.displayName=Tn;var ch=At("DialogOverlay.RemoveScroll"),lh=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(Tn,n);return o.jsx(Ir,{as:ch,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",yi=c.forwardRef((e,t)=>{const n=hi(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(dh,{...s,ref:t}):o.jsx(uh,{...s,ref:t})})});yi.displayName=pt;var dh=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(bi,{...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())})}),uh=c.forwardRef((e,t)=>{const n=Le(pt,e.__scopeDialog),r=c.useRef(!1),s=c.useRef(!1);return o.jsx(bi,{...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()}})}),bi=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(ph,{titleId:l.titleId}),o.jsx(hh,{contentRef:d,descriptionId:l.descriptionId})]})]})}),fo="DialogTitle",vi=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(fo,n);return o.jsx(Q.h2,{id:s.titleId,...r,ref:t})});vi.displayName=fo;var wi="DialogDescription",Si=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(wi,n);return o.jsx(Q.p,{id:s.descriptionId,...r,ref:t})});Si.displayName=wi;var Ni="DialogClose",fh=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,s=Le(Ni,n);return o.jsx(Q.button,{type:"button",...r,ref:t,onClick:B(e.onClick,()=>s.onOpenChange(!1))})});fh.displayName=Ni;function po(e){return e?"open":"closed"}var Ei="DialogTitleWarning",[Og,Ci]=Il(Ei,{contentName:pt,titleName:fo,docsSlug:"dialog"}),ph=({titleId:e})=>{const t=Ci(Ei),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
200
+
201
+ If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
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},mh="DialogDescriptionWarning",hh=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ci(mh).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},gh=fi,xh=mi,yh=gi,ki=xi,ji=yi,Pi=vi,Ti=Si;const bh=gh,vh=xh,wh=yh,_i=c.forwardRef(({className:e,...t},n)=>o.jsx(ki,{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}));_i.displayName=ki.displayName;const Ri=c.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(wh,{children:[o.jsx(_i,{}),o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:o.jsx(ji,{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})})]}));Ri.displayName=ji.displayName;const Ai=({className:e,...t})=>o.jsx("div",{className:F("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Ai.displayName="DialogHeader";const Ii=({className:e,...t})=>o.jsx("div",{className:F("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ii.displayName="DialogFooter";const Mi=c.forwardRef(({className:e,...t},n)=>o.jsx(Pi,{ref:n,className:F("text-lg font-semibold leading-none tracking-tight",e),...t}));Mi.displayName=Pi.displayName;const Oi=c.forwardRef(({className:e,...t},n)=>o.jsx(Ti,{ref:n,className:F("text-sm text-muted-foreground",e),...t}));Oi.displayName=Ti.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 Qo(e,[t,n]){return Math.min(n,Math.max(t,e))}function Sh(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 Di=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"}),Nh="VisuallyHidden",Eh=c.forwardRef((e,t)=>o.jsx(Q.span,{...e,ref:t,style:{...Di,...e.style}}));Eh.displayName=Nh;var Ch=[" ","Enter","ArrowUp","ArrowDown"],kh=[" ","Enter"],mt="Select",[Yn,Jn,jh]=Dr(mt),[$t]=yt(mt,[jh,Hn]),Xn=Hn(),[Ph,ct]=$t(mt),[Th,_h]=$t(mt),Li=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,A]=Kt({prop:r,defaultProp:s??!1,onChange:a,caller:mt}),[D,U]=Kt({prop:i,defaultProp:l,onChange:d,caller:mt}),W=c.useRef(null),M=y?x||!!y.closest("form"):!0,[L,$]=c.useState(new Set),T=Array.from(L).map(j=>j.props.value).join(";");return o.jsx(Hs,{...g,children:o.jsxs(Ph,{required:u,scope:t,trigger:y,onTriggerChange:b,valueNode:v,onValueNodeChange:w,valueNodeHasChildren:E,onValueNodeHasChildrenChange:S,contentId:Ye(),value:D,onValueChange:U,open:k,onOpenChange:A,dir:C,triggerPointerDownPosRef:W,disabled:h,children:[o.jsx(Yn.Provider,{scope:t,children:o.jsx(Th,{scope:e.__scopeSelect,onNativeOptionAdd:c.useCallback(j=>{$(_=>new Set(_).add(j))},[]),onNativeOptionRemove:c.useCallback(j=>{$(_=>{const R=new Set(_);return R.delete(j),R})},[]),children:n})}),M?o.jsxs(ic,{"aria-hidden":!0,required:u,tabIndex:-1,name:m,autoComplete:p,value:D,onChange:j=>U(j.target.value),disabled:h,form:x,children:[D===void 0?o.jsx("option",{value:""}):null,Array.from(L)]},T):null]})})};Li.displayName=mt;var $i="SelectTrigger",Fi=c.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...s}=e,a=Xn(n),i=ct($i,n),l=i.disabled||r,d=oe(t,i.onTriggerChange),f=Jn(n),m=c.useRef("touch"),[p,h,u]=lc(g=>{const y=f().filter(w=>!w.disabled),b=y.find(w=>w.value===i.value),v=dc(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(Vs,{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":cc(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===" ")&&Ch.includes(g.key)&&(x(),g.preventDefault())})})})});Fi.displayName=$i;var Bi="SelectValue",Ui=c.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:s,children:a,placeholder:i="",...l}=e,d=ct(Bi,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:cc(d.value)?o.jsx(o.Fragment,{children:i}):a})});Ui.displayName=Bi;var Rh="SelectIcon",Wi=c.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...s}=e;return o.jsx(Q.span,{"aria-hidden":!0,...s,ref:t,children:r||"▼"})});Wi.displayName=Rh;var Ah="SelectPortal",Hi=e=>o.jsx(Vn,{asChild:!0,...e});Hi.displayName=Ah;var ht="SelectContent",Vi=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(qi,{scope:e.__scopeSelect,children:o.jsx(Yn.Slot,{scope:e.__scopeSelect,children:o.jsx("div",{children:e.children})})}),a):null}return o.jsx(Ki,{...e,ref:t})});Vi.displayName=ht;var Me=10,[qi,lt]=$t(ht),Ih="SelectContentImpl",Mh=At("SelectContent.RemoveScroll"),Ki=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,I=>E(I)),[A,D]=c.useState(null),[U,W]=c.useState(null),M=Jn(n),[L,$]=c.useState(!1),T=c.useRef(!1);c.useEffect(()=>{if(w)return zr(w)},[w]),$r();const j=c.useCallback(I=>{const[Z,...X]=M().map(Y=>Y.ref.current),[J]=X.slice(-1),q=document.activeElement;for(const Y of I)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},[M,S]),_=c.useCallback(()=>j([A,w]),[j,A,w]);c.useEffect(()=>{L&&_()},[L,_]);const{onOpenChange:R,triggerPointerDownPosRef:N}=v;c.useEffect(()=>{if(w){let I={x:0,y:0};const Z=J=>{var q,Y;I={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=>{I.x<=10&&I.y<=10?J.preventDefault():w.contains(J.target)||R(!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,R,N]),c.useEffect(()=>{const I=()=>R(!1);return window.addEventListener("blur",I),window.addEventListener("resize",I),()=>{window.removeEventListener("blur",I),window.removeEventListener("resize",I)}},[R]);const[H,te]=lc(I=>{const Z=M().filter(q=>!q.disabled),X=Z.find(q=>q.ref.current===document.activeElement),J=dc(Z,I,X);J&&setTimeout(()=>J.ref.current.focus())}),V=c.useCallback((I,Z,X)=>{const J=!T.current&&!X;(v.value!==void 0&&v.value===Z||J)&&(D(I),J&&(T.current=!0))},[v.value]),z=c.useCallback(()=>w==null?void 0:w.focus(),[w]),G=c.useCallback((I,Z,X)=>{const J=!T.current&&!X;(v.value!==void 0&&v.value===Z||J)&&W(I)},[v.value]),ne=r==="popper"?jr:zi,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(qi,{scope:n,content:w,viewport:S,onViewportChange:C,itemRefCallback:V,selectedItem:A,onItemLeave:z,itemTextRefCallback:G,focusSelectedItem:_,selectedItemText:U,position:r,isPositioned:L,searchRef:H,children:o.jsx(Ir,{as:Mh,allowPinchZoom:!0,children:o.jsx($n,{asChild:!0,trapped:v.open,onMountAutoFocus:I=>{I.preventDefault()},onUnmountAutoFocus:B(s,I=>{var Z;(Z=v.trigger)==null||Z.focus({preventScroll:!0}),I.preventDefault()}),children:o.jsx(Ln,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:I=>I.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:o.jsx(ne,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:I=>I.preventDefault(),...b,...ie,onPlaced:()=>$(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:B(b.onKeyDown,I=>{const Z=I.ctrlKey||I.altKey||I.metaKey;if(I.key==="Tab"&&I.preventDefault(),!Z&&I.key.length===1&&te(I.key),["ArrowUp","ArrowDown","Home","End"].includes(I.key)){let J=M().filter(q=>!q.disabled).map(q=>q.ref.current);if(["ArrowUp","End"].includes(I.key)&&(J=J.slice().reverse()),["ArrowUp","ArrowDown"].includes(I.key)){const q=I.target,Y=J.indexOf(q);J=J.slice(Y+1)}setTimeout(()=>j(J)),I.preventDefault()}})})})})})})});Ki.displayName=Ih;var Oh="SelectItemAlignedPosition",zi=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(),A=f.getBoundingClientRect(),D=a.valueNode.getBoundingClientRect(),U=b.getBoundingClientRect();if(a.dir!=="rtl"){const q=U.left-A.left,Y=D.left-q,ce=k.left-Y,de=k.width+ce,$e=Math.max(de,A.width),Pe=window.innerWidth-Me,we=Qo(Y,[Me,Math.max(Me,Pe-$e)]);l.style.minWidth=de+"px",l.style.left=we+"px"}else{const q=A.right-U.right,Y=window.innerWidth-D.right-q,ce=window.innerWidth-k.right-Y,de=k.width+ce,$e=Math.max(de,A.width),Pe=window.innerWidth-Me,we=Qo(Y,[Me,Math.max(Me,Pe-$e)]);l.style.minWidth=de+"px",l.style.right=we+"px"}const W=h(),M=window.innerHeight-Me*2,L=g.scrollHeight,$=window.getComputedStyle(f),T=parseInt($.borderTopWidth,10),j=parseInt($.paddingTop,10),_=parseInt($.borderBottomWidth,10),R=parseInt($.paddingBottom,10),N=T+j+L+R+_,H=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=M-G,ie=y.offsetHeight/2,I=y.offsetTop+ie,Z=T+j+I,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+_),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,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=H+"px",l.style.maxHeight=M+"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(Lh,{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}})})})});zi.displayName=Oh;var Dh="SelectPopperPosition",jr=c.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:s=Me,...a}=e,i=Xn(n);return o.jsx(qs,{...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=Dh;var[Lh,mo]=$t(ht,{}),Pr="SelectViewport",Gi=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})})})]})});Gi.displayName=Pr;var Yi="SelectGroup",[$h,Fh]=$t(Yi),Bh=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Ye();return o.jsx($h,{scope:n,id:s,children:o.jsx(Q.div,{role:"group","aria-labelledby":s,...r,ref:t})})});Bh.displayName=Yi;var Ji="SelectLabel",Xi=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,s=Fh(Ji,n);return o.jsx(Q.div,{id:s.id,...r,ref:t})});Xi.displayName=Ji;var _n="SelectItem",[Uh,Zi]=$t(_n),Qi=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(Uh,{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===" "||(kh.includes(v.key)&&b(),v.key===" "&&v.preventDefault())})})})})});Qi.displayName=_n;var Ht="SelectItemText",ec=c.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:s,...a}=e,i=ct(Ht,n),l=lt(Ht,n),d=Zi(Ht,n),f=_h(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]})});ec.displayName=Ht;var tc="SelectItemIndicator",nc=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Zi(tc,n).isSelected?o.jsx(Q.span,{"aria-hidden":!0,...r,ref:t}):null});nc.displayName=tc;var Tr="SelectScrollUpButton",rc=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(sc,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=n;l&&d&&(l.scrollTop=l.scrollTop-d.offsetHeight)}}):null});rc.displayName=Tr;var _r="SelectScrollDownButton",oc=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(sc,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=n;l&&d&&(l.scrollTop=l.scrollTop+d.offsetHeight)}}):null});oc.displayName=_r;var sc=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()})})}),Wh="SelectSeparator",ac=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return o.jsx(Q.div,{"aria-hidden":!0,...r,ref:t})});ac.displayName=Wh;var Rr="SelectArrow",Hh=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(Ks,{...s,...r,ref:t}):null});Hh.displayName=Rr;var Vh="SelectBubbleInput",ic=c.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const s=c.useRef(null),a=oe(r,s),i=Sh(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:{...Di,...n.style},ref:a,defaultValue:t})});ic.displayName=Vh;function cc(e){return e===""||e===void 0}function lc(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 dc(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=qh(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 qh(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Kh=Li,uc=Fi,zh=Ui,Gh=Wi,Yh=Hi,fc=Vi,Jh=Gi,pc=Xi,mc=Qi,Xh=ec,Zh=nc,hc=rc,gc=oc,xc=ac;const Rn=Kh,An=zh,Jt=c.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(uc,{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(Gh,{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=uc.displayName;const yc=c.forwardRef(({className:e,...t},n)=>o.jsx(hc,{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"})})}));yc.displayName=hc.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 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"})})}));bc.displayName=gc.displayName;const Xt=c.forwardRef(({className:e,children:t,position:n="popper",...r},s)=>o.jsx(Yh,{children:o.jsxs(fc,{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(yc,{}),o.jsx(Jh,{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(bc,{})]})}));Xt.displayName=fc.displayName;const Qh=c.forwardRef(({className:e,...t},n)=>o.jsx(pc,{ref:n,className:F("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Qh.displayName=pc.displayName;const Ne=c.forwardRef(({className:e,children:t,...n},r)=>o.jsxs(mc,{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(Zh,{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(Xh,{children:t})]}));Ne.displayName=mc.displayName;const eg=c.forwardRef(({className:e,...t},n)=>o.jsx(xc,{ref:n,className:F("-mx-1 my-1 h-px bg-muted",e),...t}));eg.displayName=xc.displayName;function tg(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,A]=c.useState(""),[D,U]=c.useState(""),[W,M]=c.useState(!0),[L,$]=c.useState(!1),[T,j]=c.useState(!1),[_,R]=c.useState(""),[N,H]=c.useState(!1),[te,V]=c.useState(!1),[z,G]=c.useState(new Set),[ne,ie]=c.useState([]),[I,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"),A(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(!T){de(null);return}if(Te.current&&clearTimeout(Te.current),!_){de(null);return}return Te.current=setTimeout(()=>cn(pe,_,N),500),()=>{Te.current&&clearTimeout(Te.current)}},[_,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=tg(D);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&&_?{branch:_,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(""),A(""),U(""),M(!0),j(!1),R(""),H(!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(bh,{open:r,onOpenChange:s,children:[o.jsx(vh,{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(Ri,{className:"border-border bg-popover max-w-lg max-h-[85vh] overflow-y-auto",children:[o.jsxs(Ai,{children:[o.jsx(Mi,{children:"Create New Session"}),o.jsx(Oi,{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:th(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:A,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(cl,{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(ng,{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(ps,{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:T,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)"})]}),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:_,onChange:O=>R(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=>H(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(rg,{validating:$e,result:ce})]})]})]}),I.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(ul,{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:I.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:()=>M(!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:D,onChange:O=>U(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(Ii,{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 ng({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(fs,{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(xs,{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 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:"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(fs,{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(xs,{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 og=[{name:"Home",href:"/",icon:ms},{name:"Sessions",href:"/sessions",icon:xt},{name:"new",href:"#new",icon:On},{name:"Policies",href:"/policies",icon:gs},{name:"More",href:"/settings",icon:hs}];function sg({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:og.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 ag=[{name:"Dashboard",href:"/",icon:ms},{name:"Sessions",href:"/sessions",icon:xt}],ig=[{name:"Analytics",href:"/analytics",icon:Gc},{name:"Workflows",href:"/workflows",icon:ps},{name:"Policies",href:"/policies",icon:gs}];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 es({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 cg(){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:[ag.map(m=>o.jsx(es,{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"})]}),ig.map(m=>o.jsx(es,{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(hs,{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 lg=({...e})=>o.jsx(Gm,{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 Dg(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=ts(n.message.content):n.content?r=ts(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 ts(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 dg=[{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:xl,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:Fc,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:Al,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)]"}],ns={RUNNING:0,STARTING:1,NEEDS_PERMISSION:2,NEEDS_INPUT:3,STOPPED:4,CRASHED:5};function ug(){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=ns[p.status]??99,x=ns[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(Ga(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:dg.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(Uc,{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 rs({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 fg({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(wl,{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 os({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(Ya,{children:[o.jsx(Ja,{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(al,{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 pg(){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(),A=Rt(C,x).toLowerCase();return C.id.toLowerCase().includes(k)||A.includes(k)||C.cwd.toLowerCase().includes(k)||C.provider.toLowerCase().includes(k)}return!0}).sort((C,k)=>{const A=S[C.status]??99,D=S[k.status]??99;if(A!==D)return A-D;const U=new Date(C.createdAt).getTime();return new Date(k.createdAt).getTime()-U})},[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(Ga(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(fg,{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(rs,{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:A=>A.stopPropagation(),children:o.jsx(os,{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(rs,{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:A=>A.stopPropagation(),children:o.jsx(os,{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(Qc,{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 mg=c.lazy(async()=>({default:(await Zt(()=>import("./AnalyticsPage-BIopKWRf.js"),__vite__mapDeps([0,1,2,3,4]))).AnalyticsPage})),hg=c.lazy(async()=>({default:(await Zt(()=>import("./PoliciesPage-CjdLN3dl.js"),__vite__mapDeps([5,1,6,7,8,3,4,2]))).PoliciesPage})),ss=c.lazy(async()=>({default:(await Zt(()=>import("./SessionDetailPage-BtSA0V0M.js"),__vite__mapDeps([9,1,3,4,10,7,11,12,8,2]))).SessionDetailPage})),gg=c.lazy(async()=>({default:(await Zt(()=>import("./SettingsPage-Dbbz4Ca5.js"),__vite__mapDeps([13,1,10,6,8,3,4,2]))).SettingsPage})),xg=c.lazy(async()=>({default:(await Zt(()=>import("./WorkflowsPage-Dv6f3GgU.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 yg(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 bg(){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=yg(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 vg(){const e=In(),t=/^\/sessions\/[^/]+/.test(e.pathname),{keyboardOpen:n}=bg(),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(Ac,{children:o.jsx(sm,{children:o.jsxs("div",{className:"flex h-[100dvh] app-background noise",children:[o.jsx(cg,{}),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(wm,{})}),o.jsx("main",{className:r,children:o.jsxs(Cc,{children:[o.jsx(ze,{path:"/",element:o.jsx(ug,{})}),o.jsx(ze,{path:"/sessions",element:o.jsx(pg,{})}),o.jsx(ze,{path:"/sessions/:id",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(ss,{})})}),o.jsx(ze,{path:"/sessions/:id/:tab",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(ss,{})})}),o.jsx(ze,{path:"/analytics",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(mg,{})})}),o.jsx(ze,{path:"/workflows",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(xg,{})})}),o.jsx(ze,{path:"/policies",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(hg,{})})}),o.jsx(ze,{path:"/settings",element:o.jsx(c.Suspense,{fallback:o.jsx(kt,{}),children:o.jsx(gg,{})})}),o.jsx(ze,{path:"*",element:o.jsx(kc,{to:"/",replace:!0})})]})})]}),o.jsx(sg,{keyboardOpen:n})]})})})}function wg(){return c.useEffect(()=>(at.connect(),()=>{at.close()}),[]),o.jsx(wp,{children:o.jsx(Tc,{children:o.jsxs(Ec,{children:[o.jsx(vg,{}),o.jsx(lg,{})]})})})}const Sg=6e4;let as=!1;function Ng(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 Eg(e){const t=()=>{e.update().catch(()=>{})};t(),window.setInterval(t,Sg),window.addEventListener("focus",t),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&t()})}function Cg(){typeof window>"u"||!("serviceWorker"in navigator)||(navigator.serviceWorker.addEventListener("controllerchange",()=>{as||(as=!0,window.location.reload())}),window.addEventListener("load",()=>{navigator.serviceWorker.register(ai()).then(e=>{Ng(e),Eg(e)}).catch(()=>{})}))}Cg();const vc=document.getElementById("root");if(!vc)throw new Error("Root element not found");jc.createRoot(vc).render(o.jsx(P.StrictMode,{children:o.jsx(wg,{})}));export{Ga as $,Fc as A,qt as B,er as C,bh as D,on as E,rn as F,ps as G,kr as H,Tt as I,Ym as J,Mg as K,Or as L,xl as M,nh as N,eh as O,On as P,sn as Q,li as R,Rn as S,xs as T,Rt as U,di as V,Pt as W,_l as X,rs as Y,Al as Z,Sp as _,F as a,co as a0,Rg as a1,Pp as a2,Pn as a3,ai as a4,Ig as a5,Ag as a6,ul as a7,jt as a8,Mn as a9,hl as aa,cl as ab,hs as ac,Lr as ad,Kt as ae,Q as af,Ye as ag,Wu as ah,Hu as ai,B as aj,it as ak,yt as al,Gs 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,vh as k,Ri as l,Ai as m,Mi as n,Oi as o,Ii as p,gn as q,gs as r,eg as s,so as t,ve as u,Dg as v,at as w,xt as x,wl as y,us as z};