@evandrix/claude-code-viewer 0.7.5-8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +289 -0
- package/dist/main.js +105320 -0
- package/dist/migrations/20260401113328_cute_stryfe/migration.sql +34 -0
- package/dist/migrations/20260401113328_cute_stryfe/snapshot.json +315 -0
- package/dist/migrations/20260403053302_nappy_night_thrasher/migration.sql +28 -0
- package/dist/migrations/20260403053302_nappy_night_thrasher/snapshot.json +318 -0
- package/dist/migrations/20260630164759_previous_mephisto/migration.sql +1 -0
- package/dist/migrations/20260630164759_previous_mephisto/snapshot.json +328 -0
- package/dist/static/.gitkeep +0 -0
- package/dist/static/apple-touch-icon.png +0 -0
- package/dist/static/assets/AuthProvider-CB0_NghB.js +22 -0
- package/dist/static/assets/ProtectedRoute-BbOvBhKk.js +1 -0
- package/dist/static/assets/card-D9aMzhGi.js +1 -0
- package/dist/static/assets/createLucideIcon-Dr4vJxG7.js +1 -0
- package/dist/static/assets/dist-BwsXhL7G.js +109 -0
- package/dist/static/assets/dist-DsKpSV8b.js +1 -0
- package/dist/static/assets/eye-93IqRP6X.js +1 -0
- package/dist/static/assets/index-CQL3ecGr.css +2 -0
- package/dist/static/assets/index-CYbyi5Wz.js +20 -0
- package/dist/static/assets/input-M1VOtQpS.js +1 -0
- package/dist/static/assets/label-CV_Y-Hm3.js +1 -0
- package/dist/static/assets/login-CSjM6yF4.js +1 -0
- package/dist/static/assets/markdown-parser-vendor-BdkS_k_8.js +29 -0
- package/dist/static/assets/messages-BugsdlC4.js +1 -0
- package/dist/static/assets/messages-C9GGR_pN.js +1 -0
- package/dist/static/assets/messages-CXGVSZXJ.js +1 -0
- package/dist/static/assets/projects-8k3terN9.js +1 -0
- package/dist/static/assets/refractor-vendor-BfdmH2uT.js +4 -0
- package/dist/static/assets/rolldown-runtime-S-ySWqyJ.js +1 -0
- package/dist/static/assets/routes-Bx-J7Awb.js +1 -0
- package/dist/static/assets/session-CtPZiuYb.js +1 -0
- package/dist/static/assets/session-XjI_EF5j.js +13 -0
- package/dist/static/assets/syntax-highlighter-vendor-BmNdBw1C.js +6 -0
- package/dist/static/assets/workbox-window.prod.es5-8x20nBgX.js +2 -0
- package/dist/static/assets/xterm-vendor-BrP-ENHg.css +1 -0
- package/dist/static/assets/xterm-vendor-D6WsVDeV.js +36 -0
- package/dist/static/favicon.ico +0 -0
- package/dist/static/icon-192x192.png +0 -0
- package/dist/static/icon-512x512.png +0 -0
- package/dist/static/icon-maskable-192x192.png +0 -0
- package/dist/static/icon-maskable-512x512.png +0 -0
- package/dist/static/index.html +28 -0
- package/dist/static/manifest.webmanifest +1 -0
- package/dist/static/sw.js +1 -0
- package/package.json +25 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{d as t,f as n,n as r,t as i}from"./markdown-parser-vendor-BdkS_k_8.js";import{A as a,E as o,F as s,I as c,K as l,L as u,M as d,N as f,O as p,P as m,S as h,U as g,V as _,W as v,at as y,b,d as x,f as S,h as C,i as w,it as T,j as E,k as D,m as O,n as k,o as A,p as j,r as M,u as ee,y as te,z as N}from"./AuthProvider-CB0_NghB.js";import{A as P,B as F,C as ne,D as re,E as ie,F as ae,G as oe,H as I,I as se,J as ce,K as le,L as ue,N as de,O as L,P as fe,R as pe,S as me,T as he,U as ge,V as _e,W as R,X as ve,Y as ye,Z as be,_ as xe,a as Se,b as Ce,c as we,d as Te,f as Ee,g as De,h as Oe,i as ke,j as Ae,k as je,l as Me,m as Ne,n as z,o as Pe,p as Fe,q as Ie,s as Le,u as Re,v as ze,w as Be,x as Ve,y as He,z as Ue}from"./dist-BwsXhL7G.js";import{n as B,r as V}from"./dist-DsKpSV8b.js";import{t as H}from"./createLucideIcon-Dr4vJxG7.js";import{A as We,C as Ge,D as Ke,E as qe,O as Je,S as Ye,T as Xe,_ as Ze,a as Qe,b as $e,c as et,d as tt,f as nt,g as rt,h as U,i as W,j as it,k as G,l as at,m as ot,n as st,o as ct,p as lt,r as K,s as ut,t as dt,u as ft,v as pt,w as mt,x as ht,y as gt}from"./ProtectedRoute-BbOvBhKk.js";import{t as _t}from"./eye-93IqRP6X.js";import{a as vt,d as yt,f as bt,i as xt,n as St,o as q,r as Ct,s as J,t as wt,u as Tt}from"./card-D9aMzhGi.js";import{t as Et}from"./input-M1VOtQpS.js";import{a as Dt,i as Ot,l as kt,n as At,o as jt,r as Mt,s as Nt,t as Pt,u as Ft}from"./index-CYbyi5Wz.js";import{t as Y}from"./label-CV_Y-Hm3.js";import{n as It,t as Lt}from"./xterm-vendor-D6WsVDeV.js";import{_ as Rt,a as zt,c as Bt,d as Vt,f as Ht,g as Ut,h as Wt,i as Gt,l as Kt,m as qt,n as Jt,o as Yt,p as Xt,r as Zt,s as Qt,t as $t,u as en,v as tn,y as X}from"./syntax-highlighter-vendor-BmNdBw1C.js";var nn=H(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),rn=H(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),an=H(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),on=H(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),sn=H(`bell-ring`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`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`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]),cn=H(`bot`,[[`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`}]]),ln=H(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),un=H(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),dn=H(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),fn=H(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),pn=H(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),mn=H(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),hn=H(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),gn=H(`clipboard-paste`,[[`path`,{d:`M11 14h10`,key:`1w8e9d`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v1.344`,key:`1e62lh`}],[`path`,{d:`m17 18 4-4-4-4`,key:`z2g111`}],[`path`,{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113`,key:`bjbb7m`}],[`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,key:`ublpy`}]]),_n=H(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),vn=H(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),yn=H(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),bn=H(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),xn=H(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),Sn=H(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Cn=H(`file-braces`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),wn=H(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),Tn=H(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),En=H(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Dn=H(`folder-open`,[[`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`}]]),On=H(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),kn=H(`git-branch`,[[`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`}]]),An=H(`git-compare`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]),jn=H(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),Mn=H(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Nn=H(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),Pn=H(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Fn=H(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),In=H(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),Ln=H(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),Rn=H(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),zn=H(`log-out`,[[`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`}]]),Bn=H(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),Vn=H(`message-square-plus`,[[`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`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),Hn=H(`move`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]),Un=H(`panel-bottom-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 15h18`,key:`5xshup`}],[`path`,{d:`m15 8-3 3-3-3`,key:`1oxy1z`}]]),Wn=H(`panel-bottom`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),Gn=H(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Kn=H(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),qn=H(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Jn=H(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),Yn=H(`refresh-ccw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),Xn=H(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),Zn=H(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Qn=H(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),$n=H(`settings`,[[`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`}]]),er=H(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),tr=H(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),nr=H(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),rr=H(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),ir=H(`triangle-alert`,[[`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`}]]),ar=H(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),or=class extends _{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:g(t,n.data),hasPreviousPage:v(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function sr(e,t){return c({...e,enabled:!0,suspense:!0,throwOnError:u},or,t)}var Z=e(n(),1);function cr(e,t){let n=N(t),r=n.getQueryCache();return Z.useSyncExternalStore(Z.useCallback(e=>r.subscribe(l.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var lr=e(be(),1),Q=t();function ur(e){let t=e+`CollectionProvider`,[n,r]=je(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=Z.useRef(null),a=Z.useRef(new Map).current;return(0,Q.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Ae(s),l=Z.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,Q.jsx)(c,{ref:bt(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Ae(u),p=Z.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=Z.useRef(null),s=bt(t,o),c=a(u,n);return Z.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,Q.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return Z.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var dr=Z.createContext(void 0);function fr(e){let t=Z.useContext(dr);return e||t||`ltr`}var pr=`rovingFocusGroup.onEntryFocus`,mr={bubbles:!1,cancelable:!0},hr=`RovingFocusGroup`,[gr,_r,vr]=ur(hr),[yr,br]=je(hr,[vr]),[xr,Sr]=yr(hr),Cr=Z.forwardRef((e,t)=>(0,Q.jsx)(gr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,Q.jsx)(gr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,Q.jsx)(wr,{...e,ref:t})})}));Cr.displayName=hr;var wr=Z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=Z.useRef(null),p=bt(t,f),m=fr(a),[h,g]=ie({prop:o,defaultProp:s??null,onChange:c,caller:hr}),[_,v]=Z.useState(!1),y=ne(l),b=_r(n),x=Z.useRef(!1),[S,C]=Z.useState(0);return Z.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(pr,y),()=>e.removeEventListener(pr,y)},[y]),(0,Q.jsx)(xr,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:Z.useCallback(e=>g(e),[g]),onItemShiftTab:Z.useCallback(()=>v(!0),[]),onFocusableItemAdd:Z.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:Z.useCallback(()=>C(e=>e-1),[]),children:(0,Q.jsx)(P.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:L(e.onMouseDown,()=>{x.current=!0}),onFocus:L(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(pr,mr);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Ar([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:L(e.onBlur,()=>v(!1))})})}),Tr=`RovingFocusGroupItem`,Er=Z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Be(),l=a||c,u=Sr(Tr,n),d=u.currentTabStopId===l,f=_r(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return Z.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,Q.jsx)(gr.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,Q.jsx)(P.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:L(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:L(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:L(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=kr(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?jr(n,r+1):n.slice(r+1)}setTimeout(()=>Ar(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Er.displayName=Tr;var Dr={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Or(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function kr(e,t,n){let r=Or(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Dr[r]}function Ar(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function jr(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Mr=Cr,Nr=Er;function Pr(e,[t,n]){return Math.min(n,Math.max(t,e))}var Fr=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Ir=[` `,`Enter`],Lr=`Select`,[Rr,zr,Br]=ur(Lr),[Vr,Hr]=je(Lr,[Br,$e]),Ur=$e(),[Wr,Gr]=Vr(Lr),[Kr,qr]=Vr(Lr),Jr=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=Ur(t),[g,_]=Z.useState(null),[v,y]=Z.useState(null),[b,x]=Z.useState(!1),S=fr(l),[C,w]=ie({prop:r,defaultProp:i??!1,onChange:a,caller:Lr}),[T,E]=ie({prop:o,defaultProp:s,onChange:c,caller:Lr}),D=Z.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=Z.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,Q.jsx)(gt,{...h,children:(0,Q.jsxs)(Wr,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Be(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,Q.jsx)(Rr.Provider,{scope:t,children:(0,Q.jsx)(Kr,{scope:e.__scopeSelect,onNativeOptionAdd:Z.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:Z.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,Q.jsxs)(Ui,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,Q.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};Jr.displayName=Lr;var Yr=`SelectTrigger`,Xr=Z.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Ur(n),o=Gr(Yr,n),s=o.disabled||r,c=bt(t,o.onTriggerChange),l=zr(n),u=Z.useRef(`touch`),[d,f,p]=Gi(e=>{let t=l().filter(e=>!e.disabled),n=Ki(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,Q.jsx)(rt,{asChild:!0,...a,children:(0,Q.jsx)(P.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":Wi(o.value)?``:void 0,...i,ref:c,onClick:L(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:L(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:L(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Fr.includes(e.key)&&(m(),e.preventDefault())})})})});Xr.displayName=Yr;var Zr=`SelectValue`,Qr=Z.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=Gr(Zr,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=bt(t,c.onValueNodeChange);return re(()=>{l(u)},[l,u]),(0,Q.jsx)(P.span,{...s,ref:d,style:{pointerEvents:`none`},children:Wi(c.value)?(0,Q.jsx)(Q.Fragment,{children:o}):a})});Qr.displayName=Zr;var $r=`SelectIcon`,ei=Z.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,Q.jsx)(P.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});ei.displayName=$r;var ti=`SelectPortal`,ni=e=>(0,Q.jsx)(Ce,{asChild:!0,...e});ni.displayName=ti;var ri=`SelectContent`,ii=Z.forwardRef((e,t)=>{let n=Gr(ri,e.__scopeSelect),[r,i]=Z.useState();if(re(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?lr.createPortal((0,Q.jsx)(oi,{scope:e.__scopeSelect,children:(0,Q.jsx)(Rr.Slot,{scope:e.__scopeSelect,children:(0,Q.jsx)(`div`,{children:e.children})})}),t):null}return(0,Q.jsx)(ui,{...e,ref:t})});ii.displayName=ri;var ai=10,[oi,si]=Vr(ri),ci=`SelectContentImpl`,li=Ae(`SelectContent.RemoveScroll`),ui=Z.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=Gr(ri,n),[y,b]=Z.useState(null),[x,S]=Z.useState(null),C=bt(t,e=>b(e)),[w,T]=Z.useState(null),[E,D]=Z.useState(null),O=zr(n),[k,A]=Z.useState(!1),j=Z.useRef(!1);Z.useEffect(()=>{if(y)return xe(y)},[y]),He();let M=Z.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),ee=Z.useCallback(()=>M([w,y]),[M,w,y]);Z.useEffect(()=>{k&&ee()},[k,ee]);let{onOpenChange:te,triggerPointerDownPosRef:N}=v;Z.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(N.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(N.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||te(!1),document.removeEventListener(`pointermove`,t),N.current=null};return N.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,te,N]),Z.useEffect(()=>{let e=()=>te(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[te]);let[P,F]=Gi(e=>{let t=O().filter(e=>!e.disabled),n=Ki(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),ne=Z.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),re=Z.useCallback(()=>y?.focus(),[y]),ie=Z.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),ae=r===`popper`?mi:fi,oe=ae===mi?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,Q.jsx)(oi,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:ne,selectedItem:w,onItemLeave:re,itemTextRefCallback:ie,focusSelectedItem:ee,selectedItemText:E,position:r,isPositioned:k,searchRef:P,children:(0,Q.jsx)(ze,{as:li,allowPinchZoom:!0,children:(0,Q.jsx)(Ve,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:L(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,Q.jsx)(me,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,Q.jsx)(ae,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...oe,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:L(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&F(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>M(t)),e.preventDefault()}})})})})})})});ui.displayName=ci;var di=`SelectItemAlignedPosition`,fi=Z.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=Gr(ri,n),o=si(ri,n),[s,c]=Z.useState(null),[l,u]=Z.useState(null),d=bt(t,e=>u(e)),f=zr(n),p=Z.useRef(!1),m=Z.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=Z.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-ai,d=Pr(a,[ai,Math.max(ai,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-ai,d=Pr(a,[ai,Math.max(ai,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-ai*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-ai,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${ai}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);re(()=>y(),[y]);let[b,x]=Z.useState();return re(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,Q.jsx)(hi,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:Z.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,Q.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,Q.jsx)(P.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});fi.displayName=di;var pi=`SelectPopperPosition`,mi=Z.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=ai,...a}=e,o=Ur(n);return(0,Q.jsx)(pt,{...o,...a,ref:t,align:r,collisionPadding:i,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)`}})});mi.displayName=pi;var[hi,gi]=Vr(ri,{}),_i=`SelectViewport`,vi=Z.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=si(_i,n),o=gi(_i,n),s=bt(t,a.onViewportChange),c=Z.useRef(0);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.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}),(0,Q.jsx)(Rr.Slot,{scope:n,children:(0,Q.jsx)(P.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:L(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-ai*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});vi.displayName=_i;var yi=`SelectGroup`,[bi,xi]=Vr(yi),Si=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Be();return(0,Q.jsx)(bi,{scope:n,id:i,children:(0,Q.jsx)(P.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Si.displayName=yi;var Ci=`SelectLabel`,wi=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=xi(Ci,n);return(0,Q.jsx)(P.div,{id:i.id,...r,ref:t})});wi.displayName=Ci;var Ti=`SelectItem`,[Ei,Di]=Vr(Ti),Oi=Z.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=Gr(Ti,n),c=si(Ti,n),l=s.value===r,[u,d]=Z.useState(a??``),[f,p]=Z.useState(!1),m=bt(t,e=>c.itemRefCallback?.(e,r,i)),h=Be(),g=Z.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw 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(0,Q.jsx)(Ei,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:Z.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,Q.jsx)(Rr.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,Q.jsx)(P.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:L(o.onFocus,()=>p(!0)),onBlur:L(o.onBlur,()=>p(!1)),onClick:L(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:L(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:L(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:L(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:L(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:L(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Ir.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});Oi.displayName=Ti;var ki=`SelectItemText`,Ai=Z.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=Gr(ki,n),s=si(ki,n),c=Di(ki,n),l=qr(ki,n),[u,d]=Z.useState(null),f=bt(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=Z.useMemo(()=>(0,Q.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return re(()=>(h(m),()=>g(m)),[h,g,m]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?lr.createPortal(a.children,o.valueNode):null]})});Ai.displayName=ki;var ji=`SelectItemIndicator`,Mi=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Di(ji,n).isSelected?(0,Q.jsx)(P.span,{"aria-hidden":!0,...r,ref:t}):null});Mi.displayName=ji;var Ni=`SelectScrollUpButton`,Pi=Z.forwardRef((e,t)=>{let n=si(Ni,e.__scopeSelect),r=gi(Ni,e.__scopeSelect),[i,a]=Z.useState(!1),o=bt(t,r.onScrollButtonChange);return re(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Q.jsx)(Li,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Pi.displayName=Ni;var Fi=`SelectScrollDownButton`,Ii=Z.forwardRef((e,t)=>{let n=si(Fi,e.__scopeSelect),r=gi(Fi,e.__scopeSelect),[i,a]=Z.useState(!1),o=bt(t,r.onScrollButtonChange);return re(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,Q.jsx)(Li,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});Ii.displayName=Fi;var Li=Z.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=si(`SelectScrollButton`,n),o=Z.useRef(null),s=zr(n),c=Z.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return Z.useEffect(()=>()=>c(),[c]),re(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,Q.jsx)(P.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:L(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:L(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:L(i.onPointerLeave,()=>{c()})})}),Ri=`SelectSeparator`,zi=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,Q.jsx)(P.div,{"aria-hidden":!0,...r,ref:t})});zi.displayName=Ri;var Bi=`SelectArrow`,Vi=Z.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Ur(n),a=Gr(Bi,n),o=si(Bi,n);return a.open&&o.position===`popper`?(0,Q.jsx)(Ze,{...i,...r,ref:t}):null});Vi.displayName=Bi;var Hi=`SelectBubbleInput`,Ui=Z.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=Z.useRef(null),a=bt(r,i),o=ht(t);return Z.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,Q.jsx)(P.select,{...n,style:{...Ye,...n.style},ref:a,defaultValue:t})});Ui.displayName=Hi;function Wi(e){return e===``||e===void 0}function Gi(e){let t=ne(e),n=Z.useRef(``),r=Z.useRef(0),i=Z.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=Z.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return Z.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function Ki(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=qi(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function qi(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ji=Jr,Yi=Xr,Xi=Qr,Zi=ei,Qi=ni,$i=ii,ea=vi,ta=Oi,na=Ai,ra=Mi,ia=Pi,aa=Ii,oa=`Tabs`,[sa,ca]=je(oa,[br]),la=br(),[ua,da]=sa(oa),fa=Z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=fr(s),[d,f]=ie({prop:r,onChange:i,defaultProp:a??``,caller:oa});return(0,Q.jsx)(ua,{scope:n,baseId:Be(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,Q.jsx)(P.div,{dir:u,"data-orientation":o,...l,ref:t})})});fa.displayName=oa;var pa=`TabsList`,ma=Z.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=da(pa,n),o=la(n);return(0,Q.jsx)(Mr,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,Q.jsx)(P.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});ma.displayName=pa;var ha=`TabsTrigger`,ga=Z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=da(ha,n),s=la(n),c=ya(o.baseId,r),l=ba(o.baseId,r),u=r===o.value;return(0,Q.jsx)(Nr,{asChild:!0,...s,focusable:!i,active:u,children:(0,Q.jsx)(P.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:L(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:L(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:L(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});ga.displayName=ha;var _a=`TabsContent`,va=Z.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=da(_a,n),c=ya(s.baseId,r),l=ba(s.baseId,r),u=r===s.value,d=Z.useRef(u);return Z.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,Q.jsx)(he,{present:i||u,children:({present:n})=>(0,Q.jsx)(P.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});va.displayName=_a;function ya(e,t){return`${e}-trigger-${t}`}function ba(e,t){return`${e}-content-${t}`}var xa=fa,Sa=ma,Ca=ga,wa=va,Ta=Symbol(``),Ea=e=>typeof e?.then==`function`;function Da(e=()=>{try{return window.localStorage}catch{return}},t){let n,r,i={getItem:(i,a)=>{let o=e=>{if(e||=``,n!==e){try{r=JSON.parse(e,t?.reviver)}catch{return a}n=e}return r},s=e()?.getItem(i)??null;return Ea(s)?s.then(o):o(s)},setItem:(n,r)=>e()?.setItem(n,JSON.stringify(r,t?.replacer)),removeItem:t=>e()?.removeItem(t)},a=e=>(t,n,r)=>e(t,e=>{let t;try{t=JSON.parse(e||``)}catch{t=r}n(t)}),o;try{o=e()?.subscribe}catch{}return!o&&typeof window<`u`&&typeof window.addEventListener==`function`&&window.Storage&&(o=(t,n)=>{if(!(e()instanceof window.Storage))return()=>{};let r=r=>{r.storageArea===e()&&r.key===t&&n(r.newValue)};return window.addEventListener(`storage`,r),()=>{window.removeEventListener(`storage`,r)}}),o&&(i.subscribe=a(o)),i}var Oa=Da();function ka(e,t,n=Oa,r){let i=d(r?.getOnInit?n.getItem(e,t):t);return i.onMount=r=>(r(n.getItem(e,t)),n.subscribe?.call(n,e,r,t)),d(e=>e(i),(r,a,o)=>{let s=typeof o==`function`?o(r(i)):o;return s===Ta?(a(i,t),n.removeItem(e)):Ea(s)?s.then(t=>(a(i,t),n.setItem(e,t))):(a(i,s),n.setItem(e,s))})}var Aa=d(!1),ja=ka(`rightPanelOpen`,{status:`unset`}),Ma=d(e=>{let t=e(ja);return t.status===`set`?t.value:!1},(e,t,n)=>{t(ja,{status:`set`,value:n})}),Na=ka(`rightPanelActiveTab`,`explorer`),Pa=d(28),Fa=d(!0),Ia=d(null),La=d(null),Ra=d(``),za=d({current:null}),Ba=d(!0),Va=d(20),Ha=d(!1),Ua=d(40),Wa=(e,t,n)=>Math.min(n,Math.max(t,e)),Ga=()=>({isLeftPanelOpen:D(Ba),leftPanelWidth:D(Va)}),Ka=()=>{let e=E(),t=a(Ba),n=a(Va);return{setIsLeftPanelOpen:t,toggleLeftPanel:(0,Z.useCallback)(()=>{t(!e.get(Ba))},[t,e]),setLeftPanelWidth:(0,Z.useCallback)(e=>{n(Wa(e,15,40))},[n])}},qa=()=>({isBottomPanelOpen:D(Ha),bottomPanelHeight:D(Ua)}),Ja=()=>{let e=a(Ha),t=a(Ua);return{setIsBottomPanelOpen:e,setBottomPanelHeight:(0,Z.useCallback)(e=>{t(Wa(e,15,50))},[t])}},Ya=(e,t,n)=>Math.min(n,Math.max(t,e)),Xa=e=>{try{let t=new URL(e).hostname;return[`github.com`,`www.github.com`,`gitlab.com`,`www.gitlab.com`,`twitter.com`,`x.com`,`facebook.com`,`linkedin.com`,`google.com`,`www.google.com`].some(e=>t.endsWith(e))}catch{return!1}},Za=()=>D(Ma),Qa=()=>D(Pa),$a=()=>({isOpen:Za(),activeTab:D(Na),width:Qa(),browserUrl:D(Ia),inputUrl:D(Ra)}),eo=()=>D(Fa),to=()=>({setIsTodoSectionOpen:a(Fa)}),no=()=>{let e=E(),t=a(Ma),n=a(Na),r=a(Pa),i=a(Ia),o=a(La),s=a(Ra);return{openPanel:(0,Z.useCallback)(e=>{t(!0),e&&n(e)},[t,n]),closePanel:(0,Z.useCallback)(()=>{t(!1)},[t]),togglePanel:(0,Z.useCallback)(()=>{t(!e.get(Ma))},[t,e]),setActiveTab:n,setWidth:(0,Z.useCallback)(e=>{r(Ya(e,20,80))},[r]),setInputUrl:s,setCurrentUrl:o,openBrowser:(0,Z.useCallback)(e=>{if(Xa(e)){z.warning(`This website cannot be previewed instantly.`,{description:`It blocks embedded views. Click to open in a new tab.`,action:{label:`Open Link`,onClick:()=>window.open(e,`_blank`)},duration:5e3});return}i(e),o(e),s(e),n(`browser`),t(!0)},[i,o,s,n,t]),closeBrowser:(0,Z.useCallback)(()=>{i(null),o(null),s(``)},[i,o,s]),reloadBrowser:(0,Z.useCallback)(()=>{let t=e.get(za),n=e.get(La),r=e.get(Ia),i=n??r;t.current!==null&&i!==null&&i!==``&&(t.current.src=i)},[e]),handleUrlSubmit:(0,Z.useCallback)(()=>{let t=e.get(Ra);if(t){if(Xa(t)){z.warning(`This website cannot be previewed instantly.`,{description:`It blocks embedded views. Click to open in a new tab.`,action:{label:`Open Link`,onClick:()=>window.open(t,`_blank`)},duration:5e3});return}i(t),o(t)}},[e,i,o])}},ro=1,io=.9,ao=.8,oo=.17,so=.1,co=.999,lo=.9999,uo=.99,fo=/[\\\/_+.#"@\[\(\{&]/,po=/[\\\/_+.#"@\[\(\{&]/g,mo=/[\s-]/,ho=/[\s-]/g;function go(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?ro:uo;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=go(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=ro:fo.test(e.charAt(l-1))?(d*=ao,p=e.slice(i,l-1).match(po),p&&i>0&&(d*=co**+p.length)):mo.test(e.charAt(l-1))?(d*=io,m=e.slice(i,l-1).match(ho),m&&i>0&&(d*=co**+m.length)):(d*=oo,i>0&&(d*=co**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=lo)),(d<so&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=go(e,t,n,r,l+1,a+2,o),f*so>d&&(d=f*so)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function _o(e){return e.toLowerCase().replace(ho,` `)}function vo(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,go(e,t,_o(e),_o(t),0,0,{})}var yo=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Tt(`Primitive.${t}`),r=Z.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,Q.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),bo=`[cmdk-group=""]`,xo=`[cmdk-group-items=""]`,So=`[cmdk-group-heading=""]`,Co=`[cmdk-item=""]`,wo=`${Co}:not([aria-disabled="true"])`,To=`cmdk-item-select`,Eo=`data-value`,Do=(e,t,n)=>vo(e,t,n),Oo=Z.createContext(void 0),ko=()=>Z.useContext(Oo),Ao=Z.createContext(void 0),jo=()=>Z.useContext(Ao),Mo=Z.createContext(void 0),No=Z.forwardRef((e,t)=>{let n=qo(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=qo(()=>new Set),i=qo(()=>new Map),a=qo(()=>new Map),o=qo(()=>new Set),s=Go(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Be(),y=Be(),b=Be(),x=Z.useRef(null),S=Xo();Ko(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Ko(()=>{S(6,k)},[]);let C=Z.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Z.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??Do;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(xo);t?t.appendChild(e.parentElement===t?e:e.closest(`${xo} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${xo} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${bo}[${Eo}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Eo);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(bo)?.querySelector(So))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Co}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(wo)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Eo))}function ee(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(Eo))}function te(e){let t=A()?.closest(bo),n;for(;t&&!n;)t=e>0?Uo(t,bo):Wo(t,bo),n=t?.querySelector(wo);n?C.setState(`value`,n.getAttribute(Eo)):ee(e)}let N=()=>M(j().length-1),P=e=>{e.preventDefault(),e.metaKey?N():e.altKey?te(1):ee(1)},F=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?te(-1):ee(-1)};return Z.createElement(yo.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&P(e);break;case`ArrowDown`:P(e);break;case`p`:case`k`:g&&e.ctrlKey&&F(e);break;case`ArrowUp`:F(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),N();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(To);t.dispatchEvent(e)}}}}},Z.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:$o},c),Qo(e,e=>Z.createElement(Ao.Provider,{value:C},Z.createElement(Oo.Provider,{value:w},e))))}),Po=Z.forwardRef((e,t)=>{let n=Be(),r=Z.useRef(null),i=Z.useContext(Mo),a=ko(),o=Go(e),s=o.current?.forceMount??i?.forceMount;Ko(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=Yo(n,r,[e.value,e.children,r],e.keywords),l=jo(),u=Jo(e=>e.value&&e.value===c.current),d=Jo(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);Z.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(To,f),()=>t.removeEventListener(To,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Z.createElement(yo.div,{ref:yt(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),Fo=Z.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Be(),s=Z.useRef(null),c=Z.useRef(null),l=Be(),u=ko(),d=Jo(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);Ko(()=>u.group(o),[]),Yo(o,s,[e.value,e.heading,c]);let f=Z.useMemo(()=>({id:o,forceMount:i}),[i]);return Z.createElement(yo.div,{ref:yt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&Z.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Qo(e,e=>Z.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Z.createElement(Mo.Provider,{value:f},e))))}),Io=Z.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Z.useRef(null),a=Jo(e=>!e.search);return!n&&!a?null:Z.createElement(yo.div,{ref:yt(i,t),...r,"cmdk-separator":``,role:`separator`})}),Lo=Z.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=jo(),o=Jo(e=>e.search),s=Jo(e=>e.selectedItemId),c=ko();return Z.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Z.createElement(yo.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Ro=Z.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Z.useRef(null),o=Z.useRef(null),s=Jo(e=>e.selectedItemId),c=ko();return Z.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Z.createElement(yo.div,{ref:yt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Qo(e,e=>Z.createElement(`div`,{ref:yt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),zo=Z.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Z.createElement(De,{open:n,onOpenChange:r},Z.createElement(Oe,{container:o},Z.createElement(Ne,{"cmdk-overlay":``,className:i}),Z.createElement(Fe,{"aria-label":e.label,"cmdk-dialog":``,className:a},Z.createElement(No,{ref:t,...s}))))}),Bo=Z.forwardRef((e,t)=>Jo(e=>e.filtered.count===0)?Z.createElement(yo.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Vo=Z.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Z.createElement(yo.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Qo(e,e=>Z.createElement(`div`,{"aria-hidden":!0},e)))}),Ho=Object.assign(No,{List:Ro,Item:Po,Input:Lo,Group:Fo,Separator:Io,Dialog:zo,Empty:Bo,Loading:Vo});function Uo(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Wo(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Go(e){let t=Z.useRef(e);return Ko(()=>{t.current=e}),t}var Ko=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function qo(e){let t=Z.useRef();return t.current===void 0&&(t.current=e()),t}function Jo(e){let t=jo(),n=()=>e(t.snapshot());return Z.useSyncExternalStore(t.subscribe,n,n)}function Yo(e,t,n,r=[]){let i=Z.useRef(),a=ko();return Ko(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(Eo,s),i.current=s}),i}var Xo=()=>{let[e,t]=Z.useState(),n=qo(()=>new Map);return Ko(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Zo(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Qo({asChild:e,children:t},n){return e&&Z.isValidElement(t)?Z.cloneElement(Zo(t),{ref:t.ref},n(t.props.children)):n(t)}var $o={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},es=({className:e,...t})=>(0,Q.jsx)(Ho,{"data-slot":`command`,className:J(`bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md`,e),...t}),ts=({className:e,...t})=>(0,Q.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,Q.jsx)(ce,{className:`size-4 shrink-0 opacity-50`}),(0,Q.jsx)(Ho.Input,{"data-slot":`command-input`,className:J(`placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]}),ns=({className:e,...t})=>(0,Q.jsx)(Ho.List,{"data-slot":`command-list`,className:J(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t}),rs=({...e})=>(0,Q.jsx)(Ho.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),is=({className:e,...t})=>(0,Q.jsx)(Ho.Group,{"data-slot":`command-group`,className:J(`text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium`,e),...t}),as=({className:e,...t})=>(0,Q.jsx)(Ho.Item,{"data-slot":`command-item`,className:J(`data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...t}),os=e=>e.replace(/^\/(?:home|Users)\/[^/]+/,`~`),ss=({currentProjectId:e,currentProjectPath:t})=>{let[n,r]=(0,Z.useState)(!1),i=y(),{data:a}=le({queryKey:b.queryKey,queryFn:b.queryFn}),o=a?.projects??[],s=t??(()=>{let t=o.find(t=>t.id===e);return t?t.meta.projectPath??t.claudeProjectPath:void 0})(),c=s!==void 0&&s!==``?os(s):void 0,l=t=>{r(!1),t!==e&&i({to:`/projects/$projectId/session`,params:{projectId:t}})};return(0,Q.jsxs)(et,{open:n,onOpenChange:r,children:[(0,Q.jsx)(ft,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,role:`combobox`,"aria-expanded":n,className:`flex items-center gap-1.5 h-7 text-foreground/70 font-medium truncate hover:text-foreground transition-colors rounded px-2 hover:bg-muted/50`,children:[(0,Q.jsx)(Xe,{className:`w-3.5 h-3.5 shrink-0 opacity-60`}),(0,Q.jsx)(`span`,{className:`truncate max-w-[300px] font-mono text-xs`,children:c??(0,Q.jsx)(B,{id:`project_switcher.no_project`})}),(0,Q.jsx)(dn,{className:`w-3.5 h-3.5 shrink-0 opacity-40`})]})}),(0,Q.jsx)(at,{className:`w-80 p-0 z-[53]`,align:`start`,sideOffset:8,children:(0,Q.jsxs)(es,{children:[(0,Q.jsx)(ts,{placeholder:`Search projects...`}),(0,Q.jsxs)(ns,{children:[(0,Q.jsx)(rs,{children:(0,Q.jsx)(B,{id:`project_switcher.no_results`})}),(0,Q.jsx)(is,{children:o.map(t=>{let n=t.meta.projectPath??t.claudeProjectPath,r=os(n);return(0,Q.jsxs)(as,{value:n,onSelect:()=>l(t.id),className:`gap-2`,children:[(0,Q.jsx)(We,{className:J(`w-3.5 h-3.5 shrink-0`,t.id===e?`opacity-100`:`opacity-0`)}),(0,Q.jsx)(`span`,{className:`truncate font-mono text-xs`,children:r})]},t.id)})})]})]})})]})},cs=({children:e,projectId:t,projectPath:n,currentBranch:r,sessionId:i})=>{let{isLeftPanelOpen:a}=Ga(),{setIsLeftPanelOpen:o}=Ka(),{isBottomPanelOpen:s}=qa(),{setIsBottomPanelOpen:c}=Ja(),l=Za(),{togglePanel:u}=no(),[d,f]=(0,Z.useState)(!1);return(0,Q.jsxs)(`div`,{className:`flex flex-col h-screen w-screen overflow-hidden bg-background`,children:[(0,Q.jsxs)(`header`,{className:`h-(--spacing-header-height) flex items-center justify-between px-3 bg-muted/30 border-b border-border/40 text-xs flex-shrink-0 select-none`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0 flex-1 overflow-x-auto overflow-y-hidden`,children:[(0,Q.jsx)(`div`,{className:`shrink-0`,children:(0,Q.jsx)(ss,{currentProjectId:t,currentProjectPath:n})}),r!==void 0&&r!==``&&(0,Q.jsxs)(U,{variant:`outline`,className:`h-5 text-[11px] px-2 bg-background/50 border-border/60 gap-1 shrink-0`,children:[(0,Q.jsx)(kn,{className:`w-3 h-3`}),(0,Q.jsx)(`span`,{className:`max-w-[100px] truncate`,children:r})]}),i!==void 0&&i!==``&&(0,Q.jsx)(U,{variant:`outline`,className:`h-5 text-[11px] px-2 bg-background/50 border-border/60 font-mono shrink-0 whitespace-nowrap hidden md:flex select-text cursor-text`,children:i})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>f(!0),className:`md:hidden w-11 h-11 flex items-center justify-center rounded transition-colors hover:bg-muted text-muted-foreground hover:text-foreground`,"aria-label":`Search`,children:(0,Q.jsx)(ce,{className:`w-3.5 h-3.5`})}),(0,Q.jsx)(ut,{sessionId:i}),(0,Q.jsxs)(lt,{children:[(0,Q.jsxs)(tt,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{o(!a)},className:J(`hidden md:flex w-7 h-7 items-center justify-center rounded transition-colors`,a?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`),"aria-label":`Toggle left panel`,children:(0,Q.jsx)(Gn,{className:`w-3.5 h-3.5`})})}),(0,Q.jsx)(nt,{side:`bottom`,className:`text-xs`,children:(0,Q.jsx)(B,{id:`layout.toggle_left_panel`})})]}),(0,Q.jsxs)(tt,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>c(!s),className:J(`w-11 h-11 md:w-7 md:h-7 flex items-center justify-center rounded transition-colors`,s?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`),"aria-label":`Toggle bottom panel`,children:(0,Q.jsx)(Wn,{className:`w-3.5 h-3.5`})})}),(0,Q.jsx)(nt,{side:`bottom`,className:`text-xs`,children:(0,Q.jsx)(B,{id:`layout.toggle_bottom_panel`})})]}),(0,Q.jsxs)(tt,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:u,className:J(`w-11 h-11 md:w-7 md:h-7 flex items-center justify-center rounded transition-colors`,l?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`),"aria-label":`Toggle right panel`,children:(0,Q.jsx)(Kn,{className:`w-3.5 h-3.5`})})}),(0,Q.jsx)(nt,{side:`bottom`,className:`text-xs`,children:(0,Q.jsx)(B,{id:`layout.toggle_right_panel`})})]})]})]})]}),(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:e}),(0,Q.jsx)(Se,{open:d,onOpenChange:f,projectId:t})]})},ls=({onResize:e,onResizeStart:t,onResizeEnd:n,enabled:r=!0})=>{let[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(!1),s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),l=(0,Z.useCallback)(()=>{o.current=!1,a(!1),n?.()},[n]),u=(0,Z.useCallback)(()=>{o.current=!0,a(!0),t?.()},[t]),d=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),u()},[u]),f=(0,Z.useCallback)(e=>{e.stopPropagation(),u()},[u]);return(0,Z.useEffect)(()=>{if(!r){l();return}let t=()=>{s.current===null&&(s.current=window.requestAnimationFrame(()=>{s.current=null;let t=c.current;t&&e(t)}))},n=e=>{o.current&&(e.preventDefault(),c.current={clientX:e.clientX,clientY:e.clientY},t())},i=e=>{e.preventDefault(),l()},a=()=>{l()},u=e=>{if(!o.current)return;e.preventDefault();let n=e.touches[0];n&&(c.current={clientX:n.clientX,clientY:n.clientY},t())},d=()=>{l()},f=()=>{document.hidden&&l()},p=()=>{l()};return document.addEventListener(`mousemove`,n,{passive:!1}),document.addEventListener(`mouseup`,i,{passive:!1}),document.addEventListener(`mouseleave`,a),document.addEventListener(`touchmove`,u,{passive:!1}),document.addEventListener(`touchend`,d),document.addEventListener(`touchcancel`,d),document.addEventListener(`visibilitychange`,f),window.addEventListener(`blur`,p),()=>{s.current!==null&&window.cancelAnimationFrame(s.current),document.removeEventListener(`mousemove`,n),document.removeEventListener(`mouseup`,i),document.removeEventListener(`mouseleave`,a),document.removeEventListener(`touchmove`,u),document.removeEventListener(`touchend`,d),document.removeEventListener(`touchcancel`,d),document.removeEventListener(`visibilitychange`,f),window.removeEventListener(`blur`,p)}},[r,e,l]),{isResizing:i,handleMouseDown:d,handleTouchStart:f}},us=()=>typeof window>`u`?!1:window.innerWidth<=767,ds=`(max-width: 767px)`,fs=()=>{let[e,t]=(0,Z.useState)(us);return(0,Z.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(ds),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e},ps={up:`\x1B[A`,down:`\x1B[B`,left:`\x1B[D`,right:`\x1B[C`},ms={up:`↑`,down:`↓`,left:`←`,right:`→`},hs=300,gs=15,_s=({onSendData:e})=>{let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(null),l=(0,Z.useRef)(null),u=(0,Z.useRef)(void 0),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(!1),p=(0,Z.useRef)(null),m=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>{u.current!==void 0&&clearTimeout(u.current)},[]),(0,Z.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.target;t instanceof Node&&p.current?.contains(t)!==!0&&m.current?.contains(t)!==!0&&n(!1)};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[t]);let h=(0,Z.useCallback)((e,t,n,r)=>{let i=n-e,a=r-t;return Math.sqrt(i*i+a*a)<gs?null:Math.abs(i)>Math.abs(a)?i>0?`right`:`left`:a>0?`down`:`up`},[]),g=(0,Z.useCallback)(()=>{u.current!==void 0&&(clearTimeout(u.current),u.current=void 0),d.current=!1,o(!1),i(null),l.current=null},[]),_=(0,Z.useCallback)(()=>{let e=p.current?.getBoundingClientRect();e&&c({x:e.left+e.width/2,y:e.top})},[]),v=(0,Z.useCallback)(e=>{let t=e.touches[0];t&&(l.current={x:t.clientX,y:t.clientY},i(null),u.current=setTimeout(()=>{d.current=!0,o(!0),n(!1)},hs))},[]),y=(0,Z.useCallback)(e=>{let t=e.touches[0];if(!t||!l.current)return;let n=Math.sqrt((t.clientX-l.current.x)**2+(t.clientY-l.current.y)**2);if(!d.current&&n>gs){u.current!==void 0&&(clearTimeout(u.current),u.current=void 0);return}d.current&&i(h(l.current.x,l.current.y,t.clientX,t.clientY))},[h]),b=(0,Z.useCallback)(t=>{if(d.current&&l.current){let n=t.changedTouches[0];if(n){let t=h(l.current.x,l.current.y,n.clientX,n.clientY);t&&e(ps[t])}f.current=!0}g()},[h,e,g]),x=(0,Z.useCallback)(()=>{g()},[g]),S=(0,Z.useCallback)(()=>{if(f.current){f.current=!1;return}_(),n(e=>!e)},[_]),C=(0,Z.useCallback)(e=>{e.preventDefault()},[]),w=(0,Z.useCallback)(t=>{e(ps[t])},[e]);return(0,Q.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,Q.jsx)(`button`,{ref:p,type:`button`,className:`flex items-center justify-center min-w-[32px] h-7 rounded border text-muted-foreground transition-colors flex-shrink-0 select-none ${a?`border-primary bg-primary/10`:t?`border-primary/60 bg-muted`:`border-border/60 active:bg-muted`}`,onClick:S,onContextMenu:C,onTouchStart:v,onTouchMove:y,onTouchEnd:b,onTouchCancel:x,"aria-label":`Arrow keys (tap for d-pad, long-press and drag to flick)`,children:(0,Q.jsx)(Hn,{className:`w-3.5 h-3.5`})}),a&&r!==null&&p.current&&(0,lr.createPortal)((0,Q.jsx)(`div`,{className:`fixed bg-primary text-primary-foreground text-xs font-mono px-2 py-0.5 rounded pointer-events-none whitespace-nowrap z-[9999]`,style:{left:p.current.getBoundingClientRect().left+p.current.getBoundingClientRect().width/2,top:p.current.getBoundingClientRect().top-32,transform:`translateX(-50%)`},children:ms[r]}),document.body),t&&!a&&s!==null&&(0,lr.createPortal)((0,Q.jsxs)(`div`,{ref:m,className:`fixed z-[9999]`,style:{left:s.x,top:s.y-8,transform:`translate(-50%, -100%)`},children:[(0,Q.jsxs)(`div`,{className:`bg-background border border-border rounded-lg shadow-lg p-1 grid grid-cols-3 grid-rows-3 gap-0.5 w-[84px] h-[84px]`,children:[(0,Q.jsx)(`div`,{}),(0,Q.jsx)(vs,{direction:`up`,onTap:w}),(0,Q.jsx)(`div`,{}),(0,Q.jsx)(vs,{direction:`left`,onTap:w}),(0,Q.jsx)(`div`,{}),(0,Q.jsx)(vs,{direction:`right`,onTap:w}),(0,Q.jsx)(`div`,{}),(0,Q.jsx)(vs,{direction:`down`,onTap:w}),(0,Q.jsx)(`div`,{})]}),(0,Q.jsx)(`div`,{className:`absolute top-full left-1/2 -translate-x-1/2 w-0 h-0 border-l-[6px] border-r-[6px] border-t-[6px] border-l-transparent border-r-transparent border-t-border`})]}),document.body)]})},vs=({direction:e,onTap:t})=>(0,Q.jsx)(`button`,{type:`button`,className:`flex items-center justify-center rounded bg-muted/60 text-muted-foreground active:bg-primary/20 active:text-foreground text-sm font-mono transition-colors`,onClick:n=>{n.stopPropagation(),t(e)},"aria-label":`Arrow ${e}`,children:ms[e]}),ys=`terminalSessionId`,bs=e=>{try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return;let n=t;if(n.type===`hello`&&typeof n.sessionId==`string`&&typeof n.seq==`number`)return{type:`hello`,sessionId:n.sessionId,seq:n.seq};if((n.type===`output`||n.type===`snapshot`)&&typeof n.seq==`number`&&typeof n.data==`string`)return{type:n.type,seq:n.seq,data:n.data};if(n.type===`exit`&&typeof n.code==`number`)return{type:`exit`,code:n.code};if(n.type===`pong`)return{type:`pong`}}catch{return}},xs=e=>e===void 0||e===``?ys:`${ys}:${e}`,Ss=e=>{let t=localStorage.getItem(xs(e));return t!==null&&t.length>0?t:void 0},Cs=(e,t)=>{let n=window.location.protocol===`https:`?`wss`:`ws`,r=window.location.host,i=new URLSearchParams;e!==void 0&&e!==``&&i.set(`sessionId`,e),t!==void 0&&t!==``&&i.set(`cwd`,t);let a=i.toString();return`${n}://${r}/ws/terminal${a?`?${a}`:``}`},ws=e=>{localStorage.removeItem(xs(e))},Ts=(0,Z.forwardRef)(({resetToken:e=0,cwd:t,onProcessExit:n},r)=>{let i=(0,Z.useRef)(null),a=(0,Z.useRef)(null),o=(0,Z.useRef)(null),s=(0,Z.useRef)(null),c=(0,Z.useRef)(void 0),l=(0,Z.useRef)(0),u=(0,Z.useRef)(!1),d=(0,Z.useRef)(n);d.current=n;let f=(0,Z.useRef)(void 0);return(0,Z.useImperativeHandle)(r,()=>({sendData:e=>{f.current?.({type:`input`,data:e})},sendSignal:e=>{f.current?.({type:`signal`,name:e})},scrollLines:e=>{a.current?.scrollLines(e)}})),(0,Z.useEffect)(()=>{let n=i.current;if(!n)return;e>0&&ws(t);let r=new Lt({convertEol:!0,cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas`}),p=new It;r.loadAddon(p),r.open(n);let m=()=>{p.fit(),r.rows>0&&r.refresh(0,r.rows-1)},h=()=>{u.current||(u.current=!0,requestAnimationFrame(()=>{u.current=!1,r.rows>0&&r.refresh(0,r.rows-1)}))};m(),requestAnimationFrame(()=>{m()}),a.current=r,o.current=p;let g=Ss(t);c.current=g,l.current=0;let _=new WebSocket(Cs(g,t));s.current=_;let v=e=>{_.readyState===WebSocket.OPEN&&_.send(JSON.stringify(e))};f.current=v;let y=()=>{v({type:`resize`,cols:r.cols,rows:r.rows})};_.addEventListener(`open`,()=>{v({type:`sync`,lastSeq:l.current}),m(),y()}),_.addEventListener(`message`,e=>{if(typeof e.data!=`string`)return;let n=bs(e.data);if(n){if(n.type===`hello`){c.current=n.sessionId,localStorage.setItem(xs(t),n.sessionId);return}if(n.type===`output`||n.type===`snapshot`){r.write(n.data),h(),l.current=n.seq;return}if(n.type===`exit`){r.write(`\r\n[process exited with code ${n.code}]\r\n`),d.current?.();return}}});let b=r.onData(e=>{v({type:`input`,data:e})}),x=r.onKey(({domEvent:e})=>{e.ctrlKey&&e.key.toLowerCase()===`c`&&(e.preventDefault(),e.stopPropagation(),v({type:`signal`,name:`SIGINT`}))}),S=new ResizeObserver(()=>{m(),y()});S.observe(n);let C=window.setInterval(()=>{_.readyState===WebSocket.OPEN&&_.send(JSON.stringify({type:`ping`}))},2e4),w=0,T=e=>{let t=e.touches[0];t&&(w=t.clientY)},E=e=>{e.preventDefault();let t=e.touches[0];if(!t)return;let n=w-t.clientY;w=t.clientY;let i=Math.round(n/20);i!==0&&r.scrollLines(i)};return n.addEventListener(`touchstart`,T,{passive:!0}),n.addEventListener(`touchmove`,E,{passive:!1}),()=>{f.current=void 0,n.removeEventListener(`touchstart`,T),n.removeEventListener(`touchmove`,E),window.clearInterval(C),S.disconnect(),b.dispose(),x.dispose(),_.close(),r.dispose()}},[e,t]),(0,Q.jsx)(`div`,{ref:i,className:`h-full w-full`})});Ts.displayName=`TerminalPanel`;var Es=[{label:`Esc`,type:`data`,data:`\x1B`},{label:`Tab`,type:`data`,data:` `},{label:`Ctrl+C`,type:`signal`,signal:`SIGINT`},{label:`Ctrl+U`,type:`data`,data:``}],Ds=({cwd:e})=>{let{isBottomPanelOpen:t,bottomPanelHeight:n}=qa(),{setIsBottomPanelOpen:r,setBottomPanelHeight:i}=Ja(),a=fs(),[o,s]=(0,Z.useState)(0),c=(0,Z.useRef)(void 0),l=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]);let u=(0,Z.useCallback)(()=>{c.current=setTimeout(()=>{r(!1)},1500)},[r]),{isResizing:d,handleMouseDown:f,handleTouchStart:p}=ls({onResize:(0,Z.useCallback)(e=>{i((window.innerHeight-e.clientY)/window.innerHeight*100)},[i])});(0,Z.useEffect)(()=>(d?(document.body.style.userSelect=`none`,document.body.style.cursor=`ns-resize`,document.body.style.pointerEvents=`none`):(document.body.style.userSelect=``,document.body.style.cursor=``,document.body.style.pointerEvents=``),()=>{document.body.style.userSelect=``,document.body.style.cursor=``,document.body.style.pointerEvents=``}),[d]);let m=(0,Z.useCallback)(e=>{e.type===`data`?l.current?.sendData(e.data):l.current?.sendSignal(e.signal)},[]),h=(0,Z.useCallback)(async()=>{try{let e=await navigator.clipboard.readText();e&&l.current?.sendData(e)}catch{}},[]);return t?(0,Q.jsxs)(`div`,{className:`border-t border-border/60 bg-background flex flex-col flex-shrink-0`,style:{height:`${n}%`,userSelect:d?`none`:`auto`},children:[(0,Q.jsx)(`div`,{className:`h-2 cursor-ns-resize hover:bg-primary/40 active:bg-primary transition-colors flex-shrink-0`,style:{pointerEvents:`auto`,touchAction:`none`},onMouseDown:f,onTouchStart:p}),(0,Q.jsx)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border/40 bg-muted/20 flex-shrink-0`,children:a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 overflow-x-auto flex-1 min-w-0`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(e=>e+1),className:`flex items-center justify-center min-w-[32px] h-7 rounded border border-border/60 text-muted-foreground active:bg-muted transition-colors flex-shrink-0`,"aria-label":`Start a new terminal session`,children:(0,Q.jsx)(Zn,{className:`w-3.5 h-3.5`})}),(0,Q.jsx)(`div`,{className:`w-px h-4 bg-border/60 mx-0.5 flex-shrink-0`}),(0,Q.jsx)(`button`,{type:`button`,className:`flex items-center justify-center min-w-[32px] h-7 rounded border border-border/60 text-muted-foreground active:bg-muted transition-colors flex-shrink-0`,onPointerDown:e=>{e.preventDefault(),h()},"aria-label":`Paste from clipboard`,children:(0,Q.jsx)(gn,{className:`w-3.5 h-3.5`})}),(0,Q.jsx)(_s,{onSendData:e=>l.current?.sendData(e)}),(0,Q.jsx)(`div`,{className:`w-px h-4 bg-border/60 mx-0.5 flex-shrink-0`}),Es.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`flex items-center justify-center min-w-[36px] h-7 px-1.5 rounded border border-border/60 text-[11px] font-mono text-muted-foreground active:bg-muted transition-colors flex-shrink-0`,onPointerDown:t=>{t.preventDefault(),m(e)},children:e.label},e.label))]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(!1),className:`w-7 h-7 flex items-center justify-center rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors flex-shrink-0 ml-1`,"aria-label":`Collapse terminal panel`,children:(0,Q.jsx)(Un,{className:`w-3.5 h-3.5`})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,Q.jsx)(Xn,{className:`w-3.5 h-3.5`}),(0,Q.jsx)(`span`,{children:(0,Q.jsx)(B,{id:`layout.bottom_panel.title`})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>e+1),className:`h-6 px-2 text-[11px] rounded border border-border/60 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors flex items-center gap-1`,"aria-label":`Start a new terminal session`,children:[(0,Q.jsx)(Zn,{className:`w-3 h-3`}),`New session`]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(!1),className:`w-5 h-5 flex items-center justify-center rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Collapse terminal panel`,children:(0,Q.jsx)(Un,{className:`w-3 h-3`})})]})]})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 bg-muted/5 flex`,children:[(0,Q.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Q.jsx)(Ts,{ref:l,resetToken:o,cwd:e,onProcessExit:u})}),(0,Q.jsxs)(`div`,{className:`flex flex-col w-7 flex-shrink-0 border-l border-border/30`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`flex-1 flex items-center justify-center text-muted-foreground active:bg-muted hover:bg-muted/60 transition-colors`,onPointerDown:e=>{e.preventDefault(),l.current?.scrollLines(-5)},"aria-label":`Scroll up`,children:(0,Q.jsx)(un,{className:`w-4 h-4`})}),(0,Q.jsx)(`div`,{className:`h-px bg-border/30 flex-shrink-0`}),(0,Q.jsx)(`button`,{type:`button`,className:`flex-1 flex items-center justify-center text-muted-foreground active:bg-muted hover:bg-muted/60 transition-colors`,onPointerDown:e=>{e.preventDefault(),l.current?.scrollLines(5)},"aria-label":`Scroll down`,children:(0,Q.jsx)(G,{className:`w-4 h-4`})})]})]})]}):null},Os=[{id:`explorer`,icon:Tn,label:(0,Q.jsx)(B,{id:`panel.tab.explorer`})},{id:`git`,icon:An,label:(0,Q.jsx)(B,{id:`panel.tab.git`})},{id:`review`,icon:hn,label:(0,Q.jsx)(B,{id:`panel.tab.review`})},{id:`browser`,icon:Mn,label:(0,Q.jsx)(B,{id:`panel.tab.browser`})}],ks=({gitTabContent:e,filesToolsTabContent:t,reviewTabContent:n})=>{let{isOpen:r,activeTab:i,width:o,browserUrl:s,inputUrl:c}=$a(),{closePanel:l,setActiveTab:u,setWidth:d,setInputUrl:f,setCurrentUrl:p,reloadBrowser:m,handleUrlSubmit:h}=no(),g=fs(),_=(0,Z.useRef)(null),v=a(za),y=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{v(_)},[v]),(0,Z.useEffect)(()=>{if(s===null||s===``||!r){y.current=null;return}let e=window.setInterval(()=>{try{let e=_.current?.contentWindow?.location.href;if(e===void 0||e===``||e===`about:blank`)return;e!==y.current&&(y.current=e,p(e),f(e))}catch{}},500);return()=>window.clearInterval(e)},[s,r,p,f]);let b=(0,Z.useCallback)(e=>{d((window.innerWidth-e.clientX)/window.innerWidth*100)},[d]),x=a(Aa),{isResizing:S,handleMouseDown:C}=ls({onResize:b,enabled:r&&!g});(0,Z.useEffect)(()=>(x(S),S?(document.body.style.userSelect=`none`,document.body.style.cursor=`ew-resize`,document.body.style.pointerEvents=`none`):(document.body.style.userSelect=``,document.body.style.cursor=``,document.body.style.pointerEvents=``),()=>{document.body.style.userSelect=``,document.body.style.cursor=``,document.body.style.pointerEvents=``}),[S,x]);let w=(0,Z.useCallback)(e=>{e.key===`Enter`&&h()},[h]);if(!r)return null;let T=Os.find(e=>e.id===i)?.label;return(0,Q.jsxs)(`div`,{className:J(`fixed bg-background border-border/60 shadow-2xl z-[40] flex flex-col`,g?`left-0 right-0`:`right-0 border-l`),style:{top:`var(--header-height)`,bottom:`0px`,width:g?`100%`:`${o}%`,userSelect:S?`none`:`auto`},children:[g&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border/60 bg-muted/10`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:T}),(0,Q.jsx)(`button`,{type:`button`,onClick:l,className:`w-7 h-7 flex items-center justify-center rounded-md hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Close right panel`,children:(0,Q.jsx)(Ie,{className:`w-3.5 h-3.5`})})]}),!g&&(0,Q.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-1.5 cursor-ew-resize hover:bg-primary/40 active:bg-primary transition-colors z-10`,style:{pointerEvents:`auto`},onMouseDown:C}),(0,Q.jsx)(`div`,{className:J(`flex items-center border-b border-border/60 bg-muted/20`,g?`px-2 py-2`:`px-1.5 py-1`),children:(0,Q.jsx)(lt,{children:(0,Q.jsx)(`div`,{className:J(`flex items-center`,g?`gap-1 w-full justify-between`:`gap-0.5`),children:Os.map(e=>{let t=e.icon,n=i===e.id,r=(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>u(e.id),className:J(`flex items-center justify-center rounded-md transition-all`,g?`w-16 h-10 flex-col gap-0.5`:`w-7 h-7`,n?`bg-background text-foreground shadow-sm border border-border/40`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"data-testid":`right-panel-tab-${e.id}`,children:[(0,Q.jsx)(t,{className:J(g?`w-4 h-4`:`w-3.5 h-3.5`)}),g&&(0,Q.jsx)(`span`,{className:`text-[10px] leading-none`,children:e.label})]});return g?(0,Q.jsx)(`div`,{children:r},e.id):(0,Q.jsxs)(tt,{children:[(0,Q.jsx)(ot,{asChild:!0,children:r}),(0,Q.jsx)(nt,{side:`bottom`,children:e.label})]},e.id)})})})}),(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-hidden`,children:[i===`git`&&(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e}),i===`explorer`&&(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:t}),i===`review`&&(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:n}),i===`browser`&&(0,Q.jsx)(As,{browserUrl:s,inputUrl:c,setInputUrl:f,onReload:m,onUrlKeyDown:w,iframeRef:_})]})]})},As=({browserUrl:e,inputUrl:t,setInputUrl:n,onReload:r,onUrlKeyDown:i,iframeRef:a})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1.5 border-b border-border/40 bg-muted/10`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:r,className:`p-1.5 hover:bg-muted rounded-md transition-colors text-muted-foreground hover:text-foreground`,"aria-label":`Reload`,children:(0,Q.jsx)(kt,{className:`w-3.5 h-3.5`})}),(0,Q.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),onKeyDown:i,placeholder:`Enter URL and press Enter`,className:`flex-1 px-2.5 py-1.5 bg-background border border-border/60 rounded-md text-xs text-foreground font-mono focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/50 transition-all`})]}),e!==null&&e!==``?(0,Q.jsx)(`iframe`,{ref:a,src:e,className:`flex-1 w-full h-full border-0 bg-white`,title:`Browser Preview`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox`}):(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-muted/5`,children:(0,Q.jsxs)(`div`,{className:`text-center space-y-3 px-8`,children:[(0,Q.jsx)(`div`,{className:`w-16 h-16 mx-auto rounded-2xl bg-muted/30 flex items-center justify-center`,children:(0,Q.jsx)(Mn,{className:`w-8 h-8 text-muted-foreground/50`})}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:(0,Q.jsx)(B,{id:`panel.browser.empty.title`})}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:(0,Q.jsx)(B,{id:`panel.browser.empty.description`})})]})]})})]}),js={ts:`typescript`,tsx:`tsx`,js:`javascript`,jsx:`jsx`,mjs:`javascript`,cjs:`javascript`,json:`json`,jsonc:`json`,md:`markdown`,mdx:`markdown`,py:`python`,rs:`rust`,go:`go`,html:`html`,htm:`html`,css:`css`,scss:`scss`,sass:`sass`,less:`less`,yml:`yaml`,yaml:`yaml`,toml:`toml`,xml:`xml`,sh:`bash`,bash:`bash`,zsh:`bash`,fish:`bash`,ps1:`powershell`,sql:`sql`,graphql:`graphql`,gql:`graphql`,java:`java`,kt:`kotlin`,kts:`kotlin`,scala:`scala`,rb:`ruby`,php:`php`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,cs:`csharp`,swift:`swift`,m:`objectivec`,mm:`objectivec`,r:`r`,lua:`lua`,vim:`vim`,dockerfile:`dockerfile`,makefile:`makefile`,cmake:`cmake`,tf:`hcl`,hcl:`hcl`,proto:`protobuf`,prisma:`prisma`,vue:`javascript`,svelte:`javascript`,astro:`javascript`,zig:`zig`,elm:`elm`,ex:`elixir`,exs:`elixir`,erl:`erlang`,hrl:`erlang`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,hs:`haskell`,lhs:`haskell`,ml:`ocaml`,mli:`ocaml`,fs:`fsharp`,fsx:`fsharp`,fsi:`fsharp`,pl:`perl`,pm:`perl`,nim:`nim`,d:`d`,dart:`dart`,v:`v`,sol:`solidity`,ini:`ini`,cfg:`ini`,conf:`ini`,env:`bash`,gitignore:`text`,editorconfig:`ini`,txt:`text`},Ms=e=>{let t=e.split(`/`).pop()??``,n=t.toLowerCase();if(n===`dockerfile`)return`dockerfile`;if(n===`makefile`)return`makefile`;if(n.startsWith(`.env`))return`bash`;let r=t.lastIndexOf(`.`);return r===-1||r===t.length-1?`text`:js[t.slice(r+1).toLowerCase()]??`text`},Ns=new Set([`Write`,`Edit`,`MultiEdit`]),Ps=e=>{if(!Ns.has(e.name))return[];let t=e.input;if(typeof t==`object`&&t&&`file_path`in t){let e=t.file_path;if(typeof e==`string`&&e.length>0)return[e]}return[]},Fs=e=>{let t=new Map;for(let n of e){if(n.type===`x-error`||n.type!==`assistant`)continue;let e=n.message.content;if(Array.isArray(e))for(let r of e){if(typeof r==`string`||r.type!==`tool_use`)continue;let e=Ps(r);for(let i of e)t.set(i,{filePath:i,toolName:r.name,toolUseId:r.id,timestamp:n.timestamp})}}return Array.from(t.values())},Is=e=>{if(e==null)return``;if(typeof e==`string`)return e.slice(0,80);if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e).slice(0,80);if(typeof e!=`object`)return``;let t=e;if(`file_path`in t&&typeof t.file_path==`string`)return t.file_path;if(`command`in t&&typeof t.command==`string`)return t.command.slice(0,80);if(`query`in t&&typeof t.query==`string`)return t.query.slice(0,80);if(`pattern`in t&&typeof t.pattern==`string`)return t.pattern.slice(0,80);if(`url`in t&&typeof t.url==`string`)return t.url;if(`content`in t&&typeof t.content==`string`)return t.content.slice(0,80);let n=Object.keys(t).slice(0,3);return n.length===0?`{}`:n.join(`, `)},Ls=e=>{let t=[];for(let n of e){if(n.type===`x-error`||n.type!==`assistant`)continue;let e=n.message.content;if(Array.isArray(e))for(let r of e)typeof r==`string`||r.type!==`tool_use`||t.push({id:r.id,name:r.name,timestamp:n.timestamp,inputSummary:Is(r.input)})}return t},Rs=I({subject:R(),description:R().optional()}),zs=I({taskId:R(),status:ue([`pending`,`in_progress`,`completed`]).optional(),subject:R().optional(),description:R().optional()}),Bs=new Set([`TaskCreate`,`TaskUpdate`]),Vs=e=>{let t=new Map,n=new Map,r=1;for(let i of e){if(i.type===`x-error`||i.type!==`assistant`)continue;let e=i.message.content;if(Array.isArray(e)){for(let i of e)if(!(typeof i==`string`||i.type!==`tool_use`)&&Bs.has(i.name)){if(i.name===`TaskCreate`){let e=Rs.safeParse(i.input);if(e.success){let a=String(r);r+=1;let o={id:a,subject:e.data.subject,description:e.data.description,status:`pending`};n.set(a,o),t.set(i.id,[...n.values()])}}if(i.name===`TaskUpdate`){let e=zs.safeParse(i.input);if(e.success){let r=n.get(e.data.taskId);if(r!==void 0){let t={...r,...e.data.subject===void 0?{}:{subject:e.data.subject},...e.data.description===void 0?{}:{description:e.data.description},...e.data.status===void 0?{}:{status:e.data.status}};n.set(e.data.taskId,t)}t.set(i.id,[...n.values()])}}}}}return{stateByToolUseId:t,latestTasks:n.size>0?[...n.values()]:null}},Hs=e=>!(`todos`in e)||!Array.isArray(e.todos)?!1:e.todos.every(e=>typeof e==`object`&&!!e&&`content`in e&&typeof e.content==`string`&&`status`in e&&(e.status===`pending`||e.status===`in_progress`||e.status===`completed`)),Us=(e,t)=>{let n=null;for(let t of e){if(t.type===`x-error`||t.type!==`assistant`)continue;let e=t.message.content;for(let t of e)typeof t==`string`||t.type!==`tool_use`||t.name===`TodoWrite`&&Hs(t.input)&&(n=t.input.todos)}let r=t??Vs(e),i=r.latestTasks?r.latestTasks.map(e=>({content:e.subject,status:e.status})):null;return{todoWriteItems:n,taskItems:i}},Ws=e=>{let t=Us(e);return t.todoWriteItems&&t.taskItems?[...t.todoWriteItems,...t.taskItems]:t.todoWriteItems??t.taskItems},Gs=/<(?<tag>[^>]+)>(?<content>[\s\S]*?)<\/\k<tag>>/g,Ks=I({tag:R(),content:R()});oe([I({kind:F(`command`),commandName:R(),commandArgs:R().optional(),commandMessage:R().optional()}),I({kind:F(`local-command`),stdout:R()}),I({kind:F(`text`),content:R()})]);var qs=e=>{let t=Array.from(e.matchAll(Gs)).map(e=>Ks.safeParse(e.groups)).filter(e=>e.success).map(e=>e.data);if(t.length===0)return{kind:`text`,content:e};let n=t.find(e=>e.tag===`command-name`)?.content,r=t.find(e=>e.tag===`command-args`)?.content,i=t.find(e=>e.tag===`command-message`)?.content,a=t.find(e=>e.tag===`local-command-stdout`)?.content;switch(!0){case n!==void 0:return{kind:`command`,commandName:n,commandArgs:r,commandMessage:i};case a!==void 0:return{kind:`local-command`,stdout:a};default:return{kind:`text`,content:e}}},Js=e=>{if(e<0)return`0s`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n===0&&r===0?`${(e/1e3).toFixed(1)}s`:n===0?i>0?`${r}m ${i}s`:`${r}m`:r>0?`${n}h ${r}m`:`${n}h`},Ys=(e,t)=>{let n=new Date(e),r=new Date(t);return Number.isNaN(n.getTime())||Number.isNaN(r.getTime())?null:r.getTime()-n.getTime()},Xs=(0,Z.createContext)({stateByToolUseId:new Map,latestTasks:null}),Zs=({conversations:e,children:t})=>{let n=(0,Z.useMemo)(()=>Vs(e),[e]);return(0,Q.jsx)(Xs.Provider,{value:n,children:t})},Qs=e=>(0,Z.useContext)(Xs).stateByToolUseId.get(e),$s=({language:e,code:t,syntaxTheme:n})=>{let[r,i]=(0,Z.useState)(!1),{i18n:a}=V(),o=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]);let s=async()=>{try{await navigator.clipboard.writeText(t),i(!0),z.success(a._({id:`codeBlock.copy.success`,message:`Code copied`})),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>i(!1),2e3)}catch{z.error(a._({id:`codeBlock.copy.failed`,message:`Failed to copy code`}))}};return(0,Q.jsxs)(`div`,{className:`relative my-6`,children:[(0,Q.jsxs)(`div`,{className:`group flex items-center justify-between bg-muted/30 px-4 py-2 border-b border-border rounded-t-lg`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e}),(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-foreground transition-all opacity-100 md:opacity-0 md:group-hover:opacity-100 group-focus-within:opacity-100`,onClick:()=>{s()},title:a._({id:`codeBlock.copy`,message:`Copy code`}),"aria-label":a._({id:`codeBlock.copy`,message:`Copy code`}),children:r?(0,Q.jsx)(We,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(yn,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(X,{style:n,language:e,PreTag:`div`,wrapLongLines:!0,className:`!mt-0 !rounded-t-none !rounded-b-lg !border-t-0 !border !border-border`,customStyle:{margin:0,borderTopLeftRadius:0,borderTopRightRadius:0},children:t.replace(/\n$/,``)})]})},ec=e=>{if(e===void 0||e===``)return!1;try{return new URL(e),!0}catch{return!1}},tc=({href:e,children:t})=>{let[n,r]=(0,Z.useState)(!1),{openBrowser:i}=no();return ec(e)?(0,Q.jsxs)(`span`,{className:`relative inline-block pr-8 max-w-full break-all`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[(0,Q.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:text-primary/80 underline underline-offset-4 decoration-primary/30 hover:decoration-primary/60 transition-colors break-all`,children:t}),n&&(0,Q.jsx)(`button`,{type:`button`,onClick:t=>{t.preventDefault(),t.stopPropagation(),e!==void 0&&e!==``&&i(e)},className:`absolute right-0 top-1/2 -translate-y-1/2 p-1 bg-primary text-primary-foreground rounded hover:bg-primary/90 transition-colors shadow-md z-10`,"aria-label":`Preview in browser`,children:(0,Q.jsxs)(`svg`,{className:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,role:`img`,"aria-labelledby":`preview-icon-title`,children:[(0,Q.jsx)(`title`,{id:`preview-icon-title`,children:`Preview`}),(0,Q.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`}),(0,Q.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z`})]})})]}):(0,Q.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:text-primary/80 underline underline-offset-4 decoration-primary/30 hover:decoration-primary/60 transition-colors break-all`,children:t})};X.registerLanguage(`bash`,Wt),X.registerLanguage(`sh`,Wt),X.registerLanguage(`shell`,Wt),X.registerLanguage(`c`,qt),X.registerLanguage(`cpp`,Xt),X.registerLanguage(`css`,Ht),X.registerLanguage(`diff`,Vt),X.registerLanguage(`go`,en),X.registerLanguage(`java`,Kt),X.registerLanguage(`javascript`,Bt),X.registerLanguage(`js`,Bt),X.registerLanguage(`json`,Qt),X.registerLanguage(`markdown`,Yt),X.registerLanguage(`md`,Yt),X.registerLanguage(`python`,zt),X.registerLanguage(`py`,zt),X.registerLanguage(`sql`,Gt),X.registerLanguage(`tsx`,Zt),X.registerLanguage(`typescript`,Jt),X.registerLanguage(`ts`,Jt),X.registerLanguage(`yaml`,$t),X.registerLanguage(`yml`,$t);var nc=({content:e,className:t=``})=>{let{resolvedTheme:n}=Mt(),a=n===`dark`?Rt:Ut,o=(0,Z.useMemo)(()=>({h1({children:e,...t}){return(0,Q.jsx)(`h1`,{className:`text-3xl font-bold mb-6 mt-8 pb-3 border-b border-border text-foreground`,...t,children:e})},h2({children:e,...t}){return(0,Q.jsx)(`h2`,{className:`text-2xl font-semibold mb-4 mt-8 pb-2 border-b border-border/50 text-foreground`,...t,children:e})},h3({children:e,...t}){return(0,Q.jsx)(`h3`,{className:`text-xl font-semibold mb-3 mt-6 text-foreground`,...t,children:e})},h4({children:e,...t}){return(0,Q.jsx)(`h4`,{className:`text-lg font-medium mb-2 mt-4 text-foreground`,...t,children:e})},h5({children:e,...t}){return(0,Q.jsx)(`h5`,{className:`text-base font-medium mb-2 mt-4 text-foreground`,...t,children:e})},h6({children:e,...t}){return(0,Q.jsx)(`h6`,{className:`text-sm font-medium mb-2 mt-4 text-muted-foreground`,...t,children:e})},p({children:e,...t}){return(0,Q.jsx)(`p`,{className:`mb-4 leading-7 text-foreground break-words`,...t,children:e})},ul({children:e,...t}){return(0,Q.jsx)(`ul`,{className:`mb-4 ml-6 list-disc space-y-2`,...t,children:e})},ol({children:e,...t}){return(0,Q.jsx)(`ol`,{className:`mb-4 ml-6 list-decimal space-y-2`,...t,children:e})},li({children:e,...t}){return(0,Q.jsx)(`li`,{className:`leading-7 text-foreground`,...t,children:e})},code({className:e,children:t,...n}){let r=/language-(\w+)/.exec(e??``);if(!r)return(0,Q.jsx)(`code`,{className:`inline-block max-w-full align-middle overflow-hidden rounded-md border bg-muted/70 px-2 py-1 font-mono text-sm text-foreground whitespace-break-spaces break-words [overflow-wrap:anywhere]`,...n,children:t});let i=typeof t==`string`?t:Array.isArray(t)?t.filter(e=>typeof e==`string`).join(``):``;return(0,Q.jsx)($s,{language:r[1]??``,code:i,syntaxTheme:a})},pre({children:e,...t}){return(0,Q.jsx)(`pre`,{className:`whitespace-pre-wrap break-words max-w-full overflow-x-auto`,...t,children:e})},blockquote({children:e,...t}){return(0,Q.jsx)(`blockquote`,{className:`border-l-4 border-primary/30 bg-muted/30 pl-6 pr-4 py-4 my-6 italic rounded-r-lg`,...t,children:(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:e})})},a({children:e,href:t,...n}){return(0,Q.jsx)(tc,{href:t,...n,children:e})},table({children:e,...t}){return(0,Q.jsx)(`div`,{className:`overflow-x-auto my-6 rounded-lg border border-border max-w-full`,children:(0,Q.jsx)(`table`,{className:`w-full border-collapse`,...t,children:e})})},thead({children:e,...t}){return(0,Q.jsx)(`thead`,{className:`bg-muted/50`,...t,children:e})},th({children:e,...t}){return(0,Q.jsx)(`th`,{className:`border-b border-border px-4 py-3 text-left font-semibold text-foreground`,...t,children:e})},td({children:e,...t}){return(0,Q.jsx)(`td`,{className:`border-b border-border px-4 py-3 text-foreground`,...t,children:e})},hr({...e}){return(0,Q.jsx)(`hr`,{className:`my-8 border-t border-border`,...e})},strong({children:e,...t}){return(0,Q.jsx)(`strong`,{className:`font-semibold text-foreground`,...t,children:e})},em({children:e,...t}){return(0,Q.jsx)(`em`,{className:`italic text-foreground`,...t,children:e})}}),[a]);return(0,Q.jsx)(`div`,{className:`prose prose-neutral dark:prose-invert max-w-none ${t}`,children:(0,Q.jsx)(r,{remarkPlugins:[i],components:o,children:e})})},rc=({content:e,className:t,placement:n=`user`})=>{let{i18n:r}=V(),i=async()=>{try{await navigator.clipboard.writeText(e),z.success(r._({id:`conversation.copy.success`,message:`Message copied`}))}catch(e){console.error(`Failed to copy message:`,e),z.error(r._({id:`conversation.copy.failed`,message:`Failed to copy message`}))}},a=r._({id:`conversation.copy`,message:`Copy message`});return(0,Q.jsxs)(`div`,{className:`group relative`,children:[(0,Q.jsx)(nc,{content:e,className:t}),(0,Q.jsx)(`div`,{className:J(`pointer-events-none absolute`,{"right-2 bottom-6":n===`user`,"right-0 bottom-0 translate-x-1":n===`assistant`}),children:(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`pointer-events-auto h-7 w-7 bg-background/85 opacity-100 md:opacity-0 shadow-sm transition-opacity md:group-hover:opacity-100 group-focus-within:opacity-100 backdrop-blur supports-[backdrop-filter]:bg-background/70`,onClick:()=>{i()},"aria-label":a,title:a,children:(0,Q.jsx)(yn,{className:`h-3.5 w-3.5`})})})]})},ic=({...e})=>(0,Q.jsx)(Ji,{...e}),ac=({...e})=>(0,Q.jsx)(Xi,{...e}),oc=({className:e,children:t,...n})=>(0,Q.jsxs)(Yi,{className:J(`flex h-10 w-full items-center justify-between rounded-md border 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 [&>span]:line-clamp-1`,e),...n,children:[t,(0,Q.jsx)(Zi,{asChild:!0,children:(0,Q.jsx)(G,{className:`h-4 w-4 opacity-50`})})]}),sc=({className:e,...t})=>(0,Q.jsx)(ia,{className:J(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(un,{className:`h-4 w-4`})}),cc=({className:e,...t})=>(0,Q.jsx)(aa,{className:J(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Q.jsx)(G,{className:`h-4 w-4`})}),lc=({className:e,children:t,position:n=`popper`,...r})=>(0,Q.jsx)(Qi,{children:(0,Q.jsxs)($i,{className:J(`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:[(0,Q.jsx)(sc,{}),(0,Q.jsx)(ea,{className:J(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,Q.jsx)(cc,{})]})}),$=({className:e,children:t,...n})=>(0,Q.jsxs)(ta,{className:J(`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:[(0,Q.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Q.jsx)(ra,{children:(0,Q.jsx)(We,{className:`h-4 w-4`})})}),(0,Q.jsx)(na,{children:t})]}),uc=({className:e,...t})=>(0,Q.jsx)(`div`,{"data-slot":`skeleton`,className:J(`bg-accent animate-pulse rounded-md`,e),...t}),dc=`[font-family:"Fira_Code","Fira_Mono",Menlo,Consolas,"DejaVu_Sans_Mono",monospace]`,fc=()=>{let e=(0,Z.useMemo)(()=>Array.from({length:24},(e,t)=>{let n=[45,72,60,35,80,55,40,90,65,50,30,75,85,42,68,58];return n[t%n.length]??50}),[]);return(0,Q.jsxs)(`div`,{className:`flex h-full`,children:[(0,Q.jsx)(`div`,{className:`flex flex-col items-end gap-[5px] px-3 py-4 border-r border-border/30 bg-muted/20 select-none`,children:e.map((e,t)=>(0,Q.jsx)(uc,{className:`h-[14px] w-5 rounded-sm opacity-30`},`ln-${String(t)}`))}),(0,Q.jsx)(`div`,{className:`flex-1 flex flex-col gap-[5px] px-4 py-4`,children:e.map((e,t)=>(0,Q.jsx)(uc,{className:`h-[14px] rounded-sm`,style:{width:`${String(e)}%`,opacity:.15+t%3*.1}},`code-${String(t)}`))})]})},pc=({error:e,onRetry:t})=>(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 px-8 py-12`,children:[(0,Q.jsx)(`div`,{className:`h-12 w-12 rounded-xl bg-destructive/10 flex items-center justify-center`,children:(0,Q.jsx)(Ft,{className:`h-6 w-6 text-destructive`})}),(0,Q.jsxs)(`div`,{className:`text-center space-y-1.5`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:(0,Q.jsx)(B,{id:`assistant.tool.error_loading_file`})}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-sm`,children:e.message})]}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:t,className:`gap-1.5`,children:[(0,Q.jsx)(kt,{className:`h-3 w-3`}),(0,Q.jsx)(B,{id:`assistant.tool.retry`})]})]}),mc=({filePath:e})=>{let t=e.split(`/`).filter(Boolean),n=t.pop()??e,r=t.slice(-3),i=t.length>3;return(0,Q.jsxs)(`div`,{className:J(`flex items-center gap-0.5 text-[11px] text-muted-foreground flex-wrap`,dc),children:[i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`opacity-50`,children:`...`}),(0,Q.jsx)(Je,{className:`h-2.5 w-2.5 opacity-40 flex-shrink-0`})]}),r.map((e,t)=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`opacity-60 hover:opacity-100 transition-opacity`,children:e}),(0,Q.jsx)(Je,{className:`h-2.5 w-2.5 opacity-40 flex-shrink-0`})]},`${e}-${String(t)}`)),(0,Q.jsx)(`span`,{className:`text-foreground font-medium`,children:n})]})},hc=({projectId:e,filePath:t,syntaxTheme:n})=>{let{data:r}=s(x(e,t));if(!r.success)return(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 px-8 py-12`,children:[(0,Q.jsx)(`div`,{className:`h-12 w-12 rounded-xl bg-destructive/10 flex items-center justify-center`,children:(0,Q.jsx)(Ft,{className:`h-6 w-6 text-destructive`})}),(0,Q.jsxs)(`div`,{className:`text-center space-y-1.5`,children:[(0,Q.jsxs)(`p`,{className:`text-sm font-medium text-destructive`,children:[r.error===`NOT_FOUND`&&(0,Q.jsx)(B,{id:`assistant.tool.file_not_found`}),r.error===`BINARY_FILE`&&(0,Q.jsx)(B,{id:`assistant.tool.binary_file`}),r.error===`INVALID_PATH`&&(0,Q.jsx)(B,{id:`assistant.tool.invalid_path`}),r.error===`READ_ERROR`&&(0,Q.jsx)(B,{id:`assistant.tool.read_error`})]}),r.message&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-sm`,children:r.message})]})]});let i=r.language??Ms(t),a=r.content.split(`
|
|
2
|
+
`).length;return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-1.5 border-b border-border/40 bg-muted/20 text-[10px] text-muted-foreground select-none`,children:[i&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Tn,{className:`h-3 w-3`}),i]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Nn,{className:`h-3 w-3`}),a,` lines`]}),r.truncated&&(0,Q.jsx)(U,{variant:`secondary`,className:`text-[9px] h-4 px-1.5 bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400 border-0`,children:(0,Q.jsx)(B,{id:`assistant.tool.file_truncated`})})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Q.jsx)(tn,{style:n,language:i,showLineNumbers:!0,wrapLines:!0,customStyle:{margin:0,borderRadius:0,fontSize:`0.75rem`,lineHeight:`1.5`,minHeight:`100%`},lineNumberStyle:{minWidth:`3.5em`,paddingRight:`1em`,textAlign:`right`,userSelect:`none`,opacity:.4},children:r.content})})]})},gc=class extends Z.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}render(){return this.state.error?(0,Q.jsx)(pc,{error:this.state.error,onRetry:()=>{this.setState({error:null}),this.props.onRetry()}}):this.props.children}},_c=({projectId:e,filePaths:t,children:n})=>{let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(0),{resolvedTheme:s}=Mt(),c=s===`dark`?Rt:Ut,l=t[a]??t[0],u=t.length>1,d=l?.split(`/`).pop()??``,f=(0,Z.useCallback)(e=>{i(e),e||o(0)},[]),p=(0,Z.useCallback)(async()=>{if(l!==void 0)try{await navigator.clipboard.writeText(l),z.success(`Copied file path`)}catch{z.error(`Failed to copy`)}},[l]),m=(0,Z.useCallback)(()=>{i(!1),requestAnimationFrame(()=>i(!0))},[]);return(0,Q.jsxs)(Pe,{open:r,onOpenChange:f,children:[(0,Q.jsx)(Ee,{asChild:!0,children:n??(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`h-auto py-1.5 px-3 text-xs hover:bg-blue-100 dark:hover:bg-blue-900/30 rounded-none flex items-center gap-1`,"data-testid":`file-content-button`,children:[(0,Q.jsx)(_t,{className:`h-3 w-3`}),(0,Q.jsx)(B,{id:`assistant.tool.view_file`})]})}),(0,Q.jsxs)(Le,{className:`w-[95vw] md:w-[90vw] lg:w-[85vw] max-w-[1200px] h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden`,"data-testid":`file-content-dialog`,children:[(0,Q.jsx)(Re,{className:`px-5 py-3 border-b border-border/60 bg-muted/30 flex-shrink-0`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex-shrink-0`,children:(0,Q.jsx)(`div`,{className:`h-8 w-8 rounded-md bg-primary/8 border border-primary/10 flex items-center justify-center`,children:(0,Q.jsx)(Dn,{className:`h-4 w-4 text-primary/70`})})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,Q.jsxs)(Te,{className:`text-sm font-semibold leading-tight pr-8 flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:J(`truncate`,dc),children:d}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-5 w-5 p-0 opacity-40 hover:opacity-100 flex-shrink-0`,onClick:()=>void p(),"aria-label":`Copy file path`,children:(0,Q.jsx)(yn,{className:`h-3 w-3`})})]}),(0,Q.jsx)(we,{className:`text-xs`,asChild:!0,children:(0,Q.jsx)(`div`,{children:u?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(ic,{value:String(a),onValueChange:e=>o(Number(e)),children:[(0,Q.jsx)(oc,{className:J(`h-6 text-[10px] max-w-[500px] border-border/50`,dc),"data-testid":`file-selector`,children:(0,Q.jsx)(ac,{})}),(0,Q.jsx)(lc,{children:t.map((e,t)=>(0,Q.jsx)($,{value:String(t),className:J(`text-[10px]`,dc),children:e},e))})]}),(0,Q.jsxs)(U,{variant:`outline`,className:`text-[9px] h-4 px-1.5 border-border/50 text-muted-foreground`,children:[t.length,` files`]})]}):l!==void 0&&(0,Q.jsx)(mc,{filePath:l})})})]})]})}),(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden bg-background`,children:l!==void 0&&(0,Q.jsx)(gc,{onRetry:m,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(fc,{}),children:(0,Q.jsx)(hc,{projectId:e,filePath:l,syntaxTheme:c})})},l)})]})]})},vc=e=>{let{hasLocalData:t,apiConversations:n,conversations:r,prompt:i,sessionId:a,firstConversationMeta:o}=e,s=!t&&n.length>0&&n[0]?.type===`user`,c={type:`user`,message:{role:`user`,content:i},isSidechain:!1,userType:`external`,cwd:o?.cwd??`dummy`,sessionId:a,version:o?.version??`dummy`,uuid:`dummy`,timestamp:o?.timestamp??`dummy`,parentUuid:null,isMeta:!1,toolUseResult:void 0,gitBranch:o?.gitBranch??`dummy`,isCompactSummary:!1};return[...t||s?[]:[c],...r.map(e=>({...e,isSidechain:!1}))]},yc=e=>{let t=I({type:F(`user`),message:I({content:oe([R(),pe(oe([R(),I({type:F(`text`),text:R()})]))])})}).safeParse(e);if(!t.success)return null;let n=t.data.message.content;return typeof n==`string`?n:(()=>{if(!Array.isArray(n))return null;let e=n.at(0);return e===void 0?null:typeof e==`string`?e:e.type===`text`?e.text:null})()},bc=({prompt:e,projectId:t,sessionId:n,agentId:r,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,getToolResult:s})=>{let[c,l]=(0,Z.useState)(!1),u=(0,Z.useRef)(null),d=(r===void 0?void 0:i(r))??a(e),f=d===void 0?[]:o(d.uuid),p=f.length>0,m=c&&!p&&r!==void 0,{data:h,isLoading:g,error:_,refetch:v}=le({...w(t,r??``,n),enabled:m,staleTime:0}),y=h?.conversations??[],b=p?f.map(e=>({...e,isSidechain:!1})):y,x=p?void 0:h?.agentSessionId,S=p?d?.uuid:x,C=(()=>{let t=b.at(0);return t?yc(t)??e:e.length>60?`${e.slice(0,60)}...`:e})(),E=m&&g,D=m&&_!==null,O=!E&&!D&&b.length===0&&c,k=!E&&!D&&b.length>0,A=b.find(e=>e.type===`user`||e.type===`assistant`||e.type===`system`);return(0,Q.jsxs)(Pe,{open:c,onOpenChange:l,children:[(0,Q.jsx)(Ee,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`h-auto py-1.5 px-3 text-xs hover:bg-blue-100 dark:hover:bg-blue-900/30 rounded-none flex items-center gap-1`,"data-testid":`task-modal-button`,children:[(0,Q.jsx)(_t,{className:`h-3 w-3`}),(0,Q.jsx)(B,{id:`assistant.tool.view_task_details`})]})}),(0,Q.jsxs)(Le,{className:`w-[95vw] md:w-[90vw] lg:w-[85vw] max-w-[1400px] h-[85vh] max-h-[85vh] flex flex-col p-0`,"data-testid":`task-modal`,children:[(0,Q.jsx)(Re,{className:`px-6 py-4 border-b bg-muted/30`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,Q.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,Q.jsx)(ye,{className:`h-5 w-5 text-primary`})})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(Te,{className:`text-lg font-semibold leading-tight mb-1 pr-2`,children:C.length>120?`${C.slice(0,120)}...`:C}),(0,Q.jsxs)(we,{className:`text-xs flex items-center gap-2 flex-wrap`,children:[S!=null&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(B,{id:`assistant.tool.task_id`}),`:`,` `,(0,Q.jsx)(`code`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono`,children:S.slice(0,8)})]}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`|`})]}),(0,Q.jsx)(`span`,{children:(0,Q.jsx)(B,{id:`assistant.tool.message_count`,values:{count:b.length}})})]})]})]})}),(0,Q.jsxs)(`div`,{ref:u,className:`flex-1 overflow-auto px-6 py-4`,children:[E&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Q.jsx)(T,{className:`h-8 w-8 animate-spin text-primary`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Q.jsx)(B,{id:`assistant.tool.loading_task`})})]}),D&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Q.jsx)(qe,{className:`h-8 w-8 text-destructive`}),(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:(0,Q.jsx)(B,{id:`assistant.tool.error_loading_task`})}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>{v()},children:(0,Q.jsx)(B,{id:`assistant.tool.retry`})})]}),O&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Q.jsx)(U,{variant:`secondary`,className:`text-sm`,children:(0,Q.jsx)(B,{id:`assistant.tool.no_task_data`})}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-md text-center`,children:(0,Q.jsx)(B,{id:`assistant.tool.no_task_data_description`})})]}),k&&(0,Q.jsx)(vu,{conversations:vc({hasLocalData:p,apiConversations:y,conversations:b,prompt:e,sessionId:n,firstConversationMeta:A===void 0?void 0:{cwd:A.cwd,version:A.version,timestamp:A.timestamp,gitBranch:A.gitBranch}}),getToolResult:s,projectId:t,sessionId:n,scheduledJobs:[],scrollContainerRef:u})]})]})]})},xc=({input:e})=>{let t=Object.entries(e);return t.length===0?null:(0,Q.jsx)(`span`,{children:t.map(([e,t],n)=>{let r=typeof t==`string`?t:JSON.stringify(t).replace(/^"|"$/g,``);return(0,Q.jsxs)(`span`,{children:[n>0&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`, `}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`=`]}),(0,Q.jsx)(`span`,{children:r})]},e)})})},Sc=`[font-family:"Fira_Code","Fira_Mono",Menlo,Consolas,"DejaVu_Sans_Mono",monospace]`,Cc=I({command:R(),description:R().optional()}),wc=I({stdout:R(),stderr:R(),interrupted:Ue()}),Tc=({input:e,toolUseResult:t})=>{let n=Cc.safeParse(e);if(!n.success)return null;let r=wc.safeParse(t);return(0,Q.jsxs)(`div`,{className:`${Sc} text-xs rounded bg-gray-900 dark:bg-gray-950 text-gray-100 overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-2 bg-gray-800 dark:bg-gray-900 border-b border-gray-700 flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-green-400 select-none flex-shrink-0`,children:`$`}),(0,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-all`,children:n.data.command})]}),r.success&&r.data.stdout&&(0,Q.jsx)(`div`,{className:`px-3 py-2 whitespace-pre-wrap break-words max-h-96 overflow-y-auto`,children:r.data.stdout}),r.success&&r.data.stderr&&(0,Q.jsx)(`div`,{className:`px-3 py-2 text-red-400 border-t border-gray-700 whitespace-pre-wrap break-words max-h-48 overflow-y-auto`,children:r.data.stderr}),r.success&&r.data.interrupted&&(0,Q.jsx)(`div`,{className:`px-3 py-1 text-yellow-400 border-t border-gray-700 text-xs`,children:`Process interrupted`}),!r.success&&t===void 0&&(0,Q.jsx)(`div`,{className:`px-3 py-2 text-gray-500 animate-pulse`,children:`Running...`})]})},Ec=I({label:R(),description:R(),preview:R().optional()}),Dc=I({questions:pe(I({question:R(),header:R(),options:pe(Ec),multiSelect:Ue().optional()}))}),Oc=I({content:oe([R(),pe(I({type:F(`text`),text:R()}))])}),kc=ge(R(),R()),Ac=e=>{if(e==null)return{};if(typeof e==`string`){try{let t=JSON.parse(e),n=kc.safeParse(t);if(n.success)return n.data}catch{}return{}}let t=Oc.safeParse(e);if(!t.success)return{};let{content:n}=t.data;if(typeof n==`string`)return Ac(n);for(let e of n){let t=Ac(e.text);if(Object.keys(t).length>0)return t}return{}},jc=({input:e,output:t})=>{let n=(0,Z.useMemo)(()=>Ac(t),[t]),r=Dc.safeParse(e);return r.success?(0,Q.jsx)(`div`,{className:`space-y-3`,children:r.data.questions.map(e=>{let r=n[e.question];return(0,Q.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-2 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/50 text-purple-700 dark:text-purple-300`,children:e.header}),e.multiSelect===!0&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(multiple)`})]}),(0,Q.jsx)(`p`,{className:`text-sm mt-1`,children:e.question})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-gray-800`,children:e.options.map(e=>{let t=r===e.label;return(0,Q.jsxs)(`div`,{className:`px-3 py-2 ${t?`bg-green-50 dark:bg-green-950/30 border-l-2 border-l-green-500`:``}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium ${t?`text-green-700 dark:text-green-300`:``}`,children:e.label}),t&&(0,Q.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-green-100 dark:bg-green-900/50 text-green-700 dark:text-green-300`,children:`Selected`})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description}),e.preview!==void 0&&e.preview!==``&&(0,Q.jsxs)(K,{children:[(0,Q.jsxs)(Qe,{className:`flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 mt-1 hover:underline group`,children:[`Preview`,(0,Q.jsx)(G,{className:`h-3 w-3 transition-transform group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`pre`,{className:`mt-1 text-xs bg-gray-100 dark:bg-gray-800 rounded p-2 overflow-x-auto whitespace-pre-wrap break-words`,children:e.preview})})]})]},e.label)})}),(r===void 0||r===``)&&t===void 0&&(0,Q.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground animate-pulse border-t border-gray-200 dark:border-gray-700`,children:`Waiting for answer...`})]},e.question)})}):null},Mc=ue([`added`,`deleted`,`unchanged`,`hunk`,`context`]),Nc=I({id:R(),filename:R(),lineNumber:_e(),lineType:Mc,content:R(),createdAt:_e()}),Pc=ge(R(),pe(Nc)),Fc=(e,t)=>{let n=Pc.safeParse(e);return n.success?n.data:t},Ic=(e,t,n)=>({...e,[t]:[...e[t]??[],n]}),Lc=(e,t,n)=>{let r=(e[t]??[]).filter(e=>e.id!==n);if(r.length===0){let{[t]:n,...r}=e;return r}return{...e,[t]:r}},Rc=(e,t)=>{let{[t]:n,...r}=e;return r},zc=Da(()=>localStorage),Bc=ka(`claude-code-viewer-review-comments`,{},{getItem:(e,t)=>Fc(zc.getItem(e,t),t),setItem:(e,t)=>zc.setItem(e,t),removeItem:e=>zc.removeItem(e)}),Vc=e=>{let[t,n]=p(Bc);return{comments:(0,Z.useMemo)(()=>t[e]??[],[t,e]),addComment:(0,Z.useCallback)(t=>{let r={...t,id:crypto.randomUUID(),createdAt:Date.now()};n(t=>Ic(t,e,r))},[e,n]),removeComment:(0,Z.useCallback)(t=>{n(n=>Lc(n,e,t))},[e,n]),clearComments:(0,Z.useCallback)(()=>{n(t=>Rc(t,e))},[e,n])}},Hc=(e,t,n)=>{if(e.length===0)return`## Review: ${t} vs ${n}`;let r=new Map;for(let t of e){let e=r.get(t.filename)??[];e.push(t),r.set(t.filename,e)}return`## Review: ${t} vs ${n}\n\n${[...r.keys()].sort().flatMap(e=>[...r.get(e)??[]].sort((e,t)=>e.lineNumber-t.lineNumber).map(e=>`### ${e.filename} (L${e.lineNumber})\n${e.content}`)).join(`
|
|
3
|
+
|
|
4
|
+
`)}`},Uc=({className:e,...t})=>(0,Q.jsx)(`textarea`,{"data-slot":`textarea`,className:J(`file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex min-h-[60px] w-full min-w-0 resize-none rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]`,`aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,e),...t}),Wc=e=>J({"bg-green-50 dark:bg-green-950/30":e===`added`,"bg-red-50 dark:bg-red-950/30":e===`deleted`,"bg-blue-50 dark:bg-blue-950/30":e===`hunk`,"bg-white dark:bg-gray-900":e===`unchanged`||e===`context`}),Gc=e=>J({"bg-green-50 dark:bg-green-950":e===`added`,"bg-red-50 dark:bg-red-950":e===`deleted`,"bg-blue-50 dark:bg-blue-950":e===`hunk`,"bg-white dark:bg-gray-900":e===`unchanged`||e===`context`}),Kc=e=>e.newLineNumber??e.oldLineNumber??0,qc=({reviewProps:e,line:t,onClose:n})=>{let[r,i]=(0,Z.useState)(``),{addComment:a}=Vc(e.reviewSessionId),{i18n:o}=V(),s=()=>{r.trim()!==``&&(a({filename:e.filename,lineNumber:Kc(t),lineType:t.type,content:r.trim()}),i(``),n())};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(Uc,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),s())},placeholder:o._(`review.comment.placeholder`),className:`min-h-[72px] border-0 bg-transparent px-2.5 text-[13px] leading-relaxed shadow-none ring-0 placeholder:text-muted-foreground/50 focus-visible:ring-0`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border/40 pt-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50`,children:`⌘ + Enter`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:n,className:`h-7 w-7 p-0 text-muted-foreground hover:text-foreground`,children:(0,Q.jsx)(Ie,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(q,{size:`sm`,onClick:s,disabled:r.trim()===``,className:`h-7 gap-1 rounded-full px-3 text-[11px] font-medium`,children:[(0,Q.jsx)(Qn,{className:`h-3 w-3`}),(0,Q.jsx)(B,{id:`review.comment.save`})]})]})]})]})},Jc=({comment:e,onRemove:t})=>(0,Q.jsxs)(`div`,{className:`group/comment relative rounded-md border border-border/50 bg-muted/30 px-2.5 py-2 transition-colors hover:border-border`,children:[(0,Q.jsx)(`p`,{className:`pr-5 text-[13px] leading-relaxed text-foreground/90`,children:e.content}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),className:`absolute right-1.5 top-1.5 rounded p-0.5 text-muted-foreground/40 opacity-100 md:opacity-0 transition-all hover:bg-destructive/10 hover:text-destructive md:group-hover/comment:opacity-100 group-focus-within/comment:opacity-100`,children:(0,Q.jsx)(nr,{className:`h-3 w-3`})})]}),Yc=({reviewProps:e,line:t,lineComments:n,onRemoveComment:r})=>{let[i,a]=(0,Z.useState)(!1),o=n.length>0,s=fs();return(0,Q.jsxs)(et,{open:i,onOpenChange:a,children:[(0,Q.jsx)(ft,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:J(`absolute left-0.5 top-px z-10 flex items-center rounded-sm transition-all`,o?`opacity-100`:`opacity-100 md:opacity-0 md:group-hover:opacity-100 group-focus-within:opacity-100`),children:o?(0,Q.jsx)(`span`,{className:`flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-sky-500 px-1 text-[10px] font-semibold tabular-nums text-white shadow-sm shadow-sky-500/25`,children:n.length}):(0,Q.jsx)(`span`,{className:`flex h-[18px] w-[18px] items-center justify-center rounded-sm text-muted-foreground/60 transition-colors hover:bg-primary/10 hover:text-primary`,children:(0,Q.jsx)(Vn,{className:`h-3.5 w-3.5`})})})}),(0,Q.jsxs)(at,{side:s?`bottom`:`right`,align:s?`center`:`start`,collisionPadding:8,className:J(`overflow-hidden rounded-xl border-border/50 p-0 shadow-xl shadow-black/5 dark:shadow-black/20`,s?`w-[calc(100vw-2rem)]`:`w-80`),children:[o&&(0,Q.jsx)(`div`,{className:`space-y-1.5 border-b border-border/40 bg-muted/20 p-3`,children:n.map(e=>(0,Q.jsx)(Jc,{comment:e,onRemove:r},e.id))}),(0,Q.jsx)(`div`,{className:`p-3`,children:(0,Q.jsx)(qc,{reviewProps:e,line:t,onClose:()=>a(!1)})})]})]})},Xc=({hunk:e})=>(0,Q.jsx)(`div`,{className:`w-20 shrink-0`,children:(0,Q.jsx)(`div`,{children:e.lines.map(e=>(0,Q.jsxs)(`div`,{className:J(`grid grid-cols-[2.5rem_2.5rem] border-r border-l-4`,Sc,Gc(e.type),{"border-green-200 border-l-green-400 dark:border-green-800/50":e.type===`added`,"border-red-200 border-l-red-400 dark:border-red-800/50":e.type===`deleted`,"border-blue-200 border-l-blue-400 dark:border-blue-800/50":e.type===`hunk`,"border-gray-200 border-l-transparent dark:border-gray-700":e.type===`unchanged`||e.type===`context`}),children:[(0,Q.jsx)(`div`,{className:`border-r px-1 py-0.5 text-right text-xs leading-tight tabular-nums border-gray-200 dark:border-gray-700`,children:e.type!==`added`&&e.type!==`hunk`&&e.oldLineNumber!==void 0?e.oldLineNumber:`\xA0`}),(0,Q.jsx)(`div`,{className:`px-1 py-0.5 text-right text-xs leading-tight tabular-nums`,children:e.type!==`deleted`&&e.type!==`hunk`&&e.newLineNumber!==void 0?e.newLineNumber:`\xA0`})]},`gutter-${e.oldLineNumber??``}-${e.newLineNumber??``}`))})}),Zc=({hunks:e,reviewProps:t,commentsByLine:n,onRemoveComment:r})=>(0,Q.jsx)(Q.Fragment,{children:e.map(e=>(0,Q.jsx)(`div`,{children:e.lines.map(i=>{let a=Kc(i),o=n?.get(a)??[];return(0,Q.jsx)(`div`,{"data-slot":`diff-row`,className:J(`relative min-w-full border-l-4`,Wc(i.type),{"border-green-200 border-l-green-400 dark:border-green-800/50":i.type===`added`,"border-red-200 border-l-red-400 dark:border-red-800/50":i.type===`deleted`,"border-blue-200 border-l-blue-400 dark:border-blue-800/50":i.type===`hunk`,"border-gray-100 border-l-transparent dark:border-gray-800":i.type===`unchanged`||i.type===`context`},t!==void 0&&i.type!==`hunk`&&`group`),children:(0,Q.jsxs)(`div`,{"data-slot":`diff-row-content`,className:J(`relative min-w-0 px-2 py-0.5 pl-7 text-xs leading-tight whitespace-pre`,Sc),children:[t!==void 0&&i.type!==`hunk`&&r!==void 0&&(0,Q.jsx)(Yc,{reviewProps:t,line:i,lineComments:o,onRemoveComment:r}),(0,Q.jsx)(`span`,{"data-slot":`diff-sign`,className:J(`absolute left-2 top-0.5 w-4 text-center`,{"text-green-600 dark:text-green-400":i.type===`added`,"text-red-600 dark:text-red-400":i.type===`deleted`,"font-medium text-blue-600 dark:text-blue-400":i.type===`hunk`,"text-gray-400 dark:text-gray-600":i.type===`unchanged`||i.type===`context`}),children:i.type===`added`?`+`:i.type===`deleted`?`-`:i.type===`hunk`?`@`:`\xA0`}),(0,Q.jsx)(`span`,{className:`inline-block w-max min-w-full pr-4`,children:i.content||` `})]})},`content-${e.oldStart}-${e.newStart}-${i.oldLineNumber??``}-${i.newLineNumber??``}`)})},`${e.oldStart}-${e.newStart}`))}),Qc=({hunks:e,reviewProps:t,commentsByLine:n,onRemoveComment:r})=>(0,Q.jsxs)(`div`,{className:`relative flex`,children:[(0,Q.jsx)(`div`,{className:`w-20 shrink-0`,children:e.map(e=>(0,Q.jsx)(Xc,{hunk:e},`${e.oldStart}-${e.newStart}`))}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1 overflow-x-auto`,children:(0,Q.jsx)(`div`,{className:`inline-block w-max min-w-full align-top`,children:(0,Q.jsx)(Zc,{hunks:e,reviewProps:t,commentsByLine:n,onRemoveComment:r})})})]}),$c=({fileDiff:e,isCollapsed:t,onToggleCollapse:n})=>{let r=()=>e.isNew?(0,Q.jsx)(`span`,{className:`text-green-600 dark:text-green-400`,children:`A`}):e.isDeleted?(0,Q.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:`D`}):e.isRenamed?(0,Q.jsx)(`span`,{className:`text-blue-600 dark:text-blue-400`,children:`R`}):(0,Q.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`M`}),i=async t=>{t.stopPropagation();try{await navigator.clipboard.writeText(e.filename),z.success(`ファイル名をコピーしました`)}catch(e){console.error(`Failed to copy filename:`,e),z.error(`ファイル名のコピーに失敗しました`)}};return(0,Q.jsxs)(`div`,{className:`w-full bg-gray-50 dark:bg-gray-800 px-3 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors sticky top-0 z-20`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:n,className:`w-full text-left`,"aria-expanded":!t,children:(0,Q.jsxs)(`div`,{className:`w-full flex items-center gap-2 pr-8`,children:[t?(0,Q.jsx)(Je,{className:`w-4 h-4 text-gray-500 flex-shrink-0`}):(0,Q.jsx)(G,{className:`w-4 h-4 text-gray-500 flex-shrink-0`}),(0,Q.jsx)(`div`,{className:J(`w-5 h-5 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center text-xs flex-shrink-0`,Sc),children:r()}),(0,Q.jsx)(`span`,{className:J(`text-xs font-medium text-black dark:text-white text-left truncate flex-1 min-w-0`,Sc),children:e.filename}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-500 dark:text-gray-400 flex-shrink-0`,children:[e.linesAdded>0&&(0,Q.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,e.linesAdded]}),e.linesDeleted>0&&(0,Q.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`-`,e.linesDeleted]})]})]})}),(0,Q.jsx)(q,{type:`button`,onClick:e=>{i(e)},variant:`ghost`,size:`sm`,className:`absolute right-3 top-1/2 h-5 w-5 -translate-y-1/2 p-1 hover:bg-gray-200 dark:hover:bg-gray-600`,children:(0,Q.jsx)(yn,{className:`w-3 h-3 text-gray-500 dark:text-gray-400`})}),e.isBinary&&(0,Q.jsx)(`div`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400 text-left`,children:`Binary file (content not shown)`})]})},el=(e,t)=>{let{comments:n,addComment:r,removeComment:i,clearComments:a}=Vc(e??``);return{commentsByLine:(0,Z.useMemo)(()=>{if(t===void 0)return new Map;let e=new Map;for(let r of n){if(r.filename!==t)continue;let n=e.get(r.lineNumber);n===void 0?e.set(r.lineNumber,[r]):n.push(r)}return e},[n,t]),addComment:r,removeComment:i,clearComments:a}},tl=(0,Z.memo)(({fileDiff:e,className:t,filename:n,reviewSessionId:r})=>{let[i,a]=(0,Z.useState)(!1),o=n!==void 0&&r!==void 0,{commentsByLine:s,removeComment:c}=el(r,n),l=o?{filename:n,reviewSessionId:r}:void 0,u=()=>{a(!i)};return e.isBinary?(0,Q.jsxs)(`div`,{className:J(`overflow-hidden border border-gray-200 dark:border-gray-700 rounded-lg`,t),children:[(0,Q.jsx)($c,{fileDiff:e,isCollapsed:i,onToggleCollapse:u}),!i&&(0,Q.jsx)(`div`,{className:`text-center py-8 text-gray-500 dark:text-gray-400 text-sm`,children:`Binary file cannot be displayed`})]}):(0,Q.jsxs)(`div`,{className:J(`overflow-hidden border border-gray-200 dark:border-gray-700 rounded-lg`,t),children:[(0,Q.jsx)($c,{fileDiff:e,isCollapsed:i,onToggleCollapse:u}),!i&&(0,Q.jsx)(`div`,{className:`border-t border-gray-200 dark:border-gray-700`,children:(0,Q.jsx)(Qc,{hunks:e.hunks,reviewProps:l,commentsByLine:s,onRemoveComment:c})})]})});tl.displayName=`DiffViewer`;var nl=I({content:R(),is_error:Ue().optional()}),rl=I({content:pe(oe([I({type:F(`text`),text:R()}),I({type:R()})])),is_error:Ue().optional()}),il=I({type:F(`text`),text:R()}),al=I({is_error:F(!0)}),ol=e=>{if(e==null)return{text:null,isError:!1};let t=al.safeParse(e).success,n=nl.safeParse(e);if(n.success)return{text:n.data.content,isError:t};let r=rl.safeParse(e);if(r.success){let e=[];for(let t of r.data.content){let n=il.safeParse(t);n.success&&e.push(n.data.text)}if(e.length>0)return{text:e.join(`
|
|
5
|
+
`),isError:t}}return{text:null,isError:t}},sl=200,cl=({output:e,showSuccess:t=!1})=>{let[n,r]=(0,Z.useState)(!1);if(e==null)return null;let{text:i,isError:a}=ol(e);return!a&&!t?null:a&&i!==null?i.length>sl?(0,Q.jsx)(K,{open:n,onOpenChange:r,children:(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 border-t border-red-200 dark:border-red-800/50 bg-red-50 dark:bg-red-950/30`,children:[(0,Q.jsxs)(Qe,{className:`flex items-center gap-1.5 w-full text-left`,children:[(0,Q.jsx)(Ft,{className:`w-3.5 h-3.5 flex-shrink-0 text-red-600 dark:text-red-400`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium text-red-700 dark:text-red-400`,children:`Error`}),(0,Q.jsx)(G,{className:J(`w-3 h-3 text-red-500 ml-auto transition-transform`,n&&`rotate-180`)})]}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`pre`,{className:`mt-1.5 text-xs text-red-700 dark:text-red-400 whitespace-pre-wrap break-words max-h-48 overflow-y-auto`,children:i})})]})}):(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 border-t border-red-200 dark:border-red-800/50 bg-red-50 dark:bg-red-950/30 flex items-start gap-1.5`,children:[(0,Q.jsx)(Ft,{className:`w-3.5 h-3.5 flex-shrink-0 text-red-600 dark:text-red-400 mt-0.5`}),(0,Q.jsx)(`pre`,{className:`text-xs text-red-700 dark:text-red-400 whitespace-pre-wrap break-words`,children:i})]}):a?(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 border-t border-red-200 dark:border-red-800/50 bg-red-50 dark:bg-red-950/30 flex items-center gap-1.5`,children:[(0,Q.jsx)(Ft,{className:`w-3.5 h-3.5 flex-shrink-0 text-red-600 dark:text-red-400`}),(0,Q.jsx)(`span`,{className:`text-xs text-red-700 dark:text-red-400`,children:`Error`})]}):t?(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 border-t border-gray-200 dark:border-gray-700 flex items-start gap-1.5`,children:[(0,Q.jsx)(Ke,{className:`w-3 h-3 flex-shrink-0 text-green-600 dark:text-green-500 mt-0.5`}),i===null?(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Success`}):(0,Q.jsx)(`pre`,{className:`text-xs text-muted-foreground whitespace-pre-wrap break-words max-h-24 overflow-y-auto`,children:i})]}):null},ll=I({file_path:R(),old_string:R().optional(),new_string:R().optional()}),ul=pe(I({oldStart:_e(),oldLines:_e(),newStart:_e(),newLines:_e(),lines:pe(R())})),dl=I({filePath:R(),structuredPatch:ul}),fl=e=>e.map(e=>{let t=e.oldStart,n=e.newStart,r=e.lines.map(e=>{let r=e[0],i=e.slice(1);if(r===`-`){let e={type:`deleted`,oldLineNumber:t,content:i};return t++,e}if(r===`+`){let e={type:`added`,newLineNumber:n,content:i};return n++,e}let a={type:`unchanged`,oldLineNumber:t,newLineNumber:n,content:i};return t++,n++,a});return{oldStart:e.oldStart,newStart:e.newStart,lines:r}}),pl=(e,t)=>{let n=e.split(`
|
|
6
|
+
`),r=t.split(`
|
|
7
|
+
`);return[{oldStart:1,oldLines:n.length,newStart:1,newLines:r.length,lines:[...n.map(e=>`-${e}`),...r.map(e=>`+${e}`)]}]},ml=(e,t,n)=>{let r=fl(t),i=0,a=0;for(let e of r)for(let t of e.lines)t.type===`added`&&i++,t.type===`deleted`&&a++;return(0,Q.jsxs)(`div`,{className:`overflow-hidden`,children:[(0,Q.jsx)(tl,{fileDiff:{filename:e,isNew:!1,isDeleted:!1,isRenamed:!1,isBinary:!1,hunks:r,linesAdded:i,linesDeleted:a}}),(0,Q.jsx)(cl,{output:n,showSuccess:!0})]})},hl=({input:e,output:t,toolUseResult:n})=>{let r=ll.safeParse(e);if(!r.success)return null;let i=dl.safeParse(n);if(i.success)return ml(i.data.filePath,i.data.structuredPatch,t);let{old_string:a,new_string:o}=r.data;return a!==void 0&&o!==void 0?ml(r.data.file_path,pl(a,o),t):(0,Q.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-2 bg-gray-50 dark:bg-gray-800 ${Sc} text-xs font-medium`,children:r.data.file_path}),n===void 0&&(0,Q.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground animate-pulse text-center`,children:`Applying edit...`}),(0,Q.jsx)(cl,{output:t,showSuccess:!0})]})},gl=I({file_path:R()}),_l=e=>{let t=e.split(`
|
|
8
|
+
`),n=[];for(let e of t){let t=/^\s*(\d+)\t(.*)$/.exec(e);t&&t[1]!==void 0&&t[2]!==void 0&&n.push({lineNumber:Number.parseInt(t[1],10),content:t[2]})}let r=n[0];return r?{startLine:r.lineNumber,code:n.map(e=>e.content).join(`
|
|
9
|
+
`)}:null},vl=I({content:R()}),yl=I({content:pe(I({type:F(`text`),text:R()}))}),bl=e=>{if(e==null)return null;let t=vl.safeParse(e);if(t.success)return t.data.content;let n=yl.safeParse(e);if(n.success){let e=n.data.content[0];if(e)return e.text}return null},xl=({input:e,output:t})=>{let{resolvedTheme:n}=Mt(),r=n===`dark`?Rt:Ut,i=gl.safeParse(e);if(!i.success)return null;let a=bl(t);if(a===null)return(0,Q.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-2 bg-gray-50 dark:bg-gray-800 font-mono text-xs font-medium`,children:i.data.file_path}),t===void 0&&(0,Q.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground animate-pulse text-center`,children:`Reading file...`})]});let o=_l(a);if(!o)return null;let s=Ms(i.data.file_path);return(0,Q.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 font-mono text-xs font-medium`,children:i.data.file_path}),(0,Q.jsx)(tn,{style:r,language:s,showLineNumbers:!0,startingLineNumber:o.startLine,wrapLines:!0,customStyle:{margin:0,borderRadius:0,fontSize:`0.75rem`},children:o.code})]})},Sl=I({statusChange:I({from:R(),to:R()}).optional()}),Cl=({status:e})=>{switch(e){case`completed`:return(0,Q.jsx)(Ke,{className:`w-3.5 h-3.5 flex-shrink-0 text-green-600 dark:text-green-500`});case`in_progress`:return(0,Q.jsx)(fn,{className:`w-3.5 h-3.5 flex-shrink-0 text-amber-600 dark:text-amber-500`});case`pending`:return(0,Q.jsx)(mn,{className:`w-3.5 h-3.5 flex-shrink-0 text-muted-foreground`});default:return null}},wl=({input:e,toolUseResult:t})=>{let n=Rs.safeParse(e);if(n.success)return(0,Q.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground truncate`,children:[`New Task: `,n.data.subject]});let r=zs.safeParse(e),i=Sl.safeParse(t);if(r.success){let e=i.success?i.data.statusChange:void 0;return e===void 0?(0,Q.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground truncate`,children:[`Task #`,r.data.taskId]}):(0,Q.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground truncate`,children:[`Task #`,r.data.taskId,`: `,e.from,` → `,e.to]})}return(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Tasks`})},Tl=({toolUseId:e,input:t,output:n,toolUseResult:r})=>{let i=Qs(e);if(i===void 0||i.length===0)return null;let a=i.filter(e=>e.status===`completed`).length,o=i.length,s=i.some(e=>e.status===`in_progress`);return(0,Q.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2`,children:[(0,Q.jsx)(Ln,{className:J(`w-3.5 h-3.5`,s?`text-amber-600 dark:text-amber-500`:`text-muted-foreground`)}),(0,Q.jsx)(wl,{input:t,toolUseResult:r}),(0,Q.jsxs)(`span`,{className:J(`text-[10px] px-1.5 py-0.5 rounded-full ml-auto`,a===o?`bg-green-500/20 text-green-700 dark:text-green-400`:s?`bg-amber-500/20 text-amber-700 dark:text-amber-400`:`bg-muted text-muted-foreground`),children:[a,`/`,o]})]}),(0,Q.jsx)(`div`,{className:`p-2 space-y-1 max-h-48 overflow-y-auto`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:J(`flex items-start gap-2 px-2 py-1.5 text-xs rounded-md transition-colors`,e.status===`completed`&&`text-muted-foreground`,e.status===`in_progress`&&`bg-amber-500/10`),children:[(0,Q.jsx)(Cl,{status:e.status}),(0,Q.jsx)(`span`,{className:J(`flex-1 break-words`,e.status===`completed`&&`line-through`),children:e.subject}),(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/60 flex-shrink-0`,children:[`#`,e.id]})]},`${e.id}-${e.status}`))}),(0,Q.jsx)(cl,{output:n})]})},El=I({prompt:R(),description:R().optional(),subagent_type:R().optional()}),Dl=I({totalDurationMs:_e().optional(),totalTokens:_e().optional(),totalToolUseCount:_e().optional()}),Ol=e=>{if(e<1e3)return`${e}ms`;let t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`},kl=({output:e})=>{let{text:t,isError:n}=ol(e);return t===null?null:(0,Q.jsx)(K,{children:(0,Q.jsxs)(`div`,{className:J(`border-t`,n?`border-red-200 dark:border-red-800/50`:`border-gray-200 dark:border-gray-700`),children:[(0,Q.jsxs)(Qe,{className:`flex items-center gap-1.5 w-full text-left px-3 py-1.5 bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors group`,children:[n?(0,Q.jsx)(Ft,{className:`w-3.5 h-3.5 flex-shrink-0 text-red-600 dark:text-red-400`}):null,(0,Q.jsx)(`span`,{className:J(`text-xs font-medium`,n?`text-red-700 dark:text-red-400`:`text-muted-foreground`),children:`Result`}),(0,Q.jsx)(G,{className:`w-3 h-3 ml-auto transition-transform text-muted-foreground group-data-[state=open]:rotate-180`})]}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:J(`px-3 py-2 max-h-64 overflow-y-auto`,n&&`bg-red-50/50 dark:bg-red-950/20`),children:(0,Q.jsx)(`pre`,{className:J(`text-xs whitespace-pre-wrap break-words`,n?`text-red-700 dark:text-red-400`:`text-foreground`),children:t})})})]})})},Al=({input:e,output:t,toolUseResult:n})=>{let r=El.safeParse(e);if(!r.success)return null;let i=Dl.safeParse(n),a=r.data.subagent_type!==void 0&&r.data.subagent_type!==``,o=r.data.description!==void 0&&r.data.description!==``;return(0,Q.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2 flex-wrap`,children:[a?(0,Q.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300 font-medium`,children:r.data.subagent_type}):null,o?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:r.data.description}):null]}),(0,Q.jsx)(`div`,{className:`px-3 py-2`,children:(0,Q.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap break-words font-sans leading-relaxed`,children:r.data.prompt})}),i.success&&i.data.totalDurationMs!==void 0&&(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 flex items-center gap-3 text-xs text-muted-foreground`,children:[i.data.totalDurationMs!==void 0&&(0,Q.jsx)(`span`,{children:Ol(i.data.totalDurationMs)}),i.data.totalTokens!==void 0&&(0,Q.jsxs)(`span`,{children:[i.data.totalTokens.toLocaleString(),` tokens`]}),i.data.totalToolUseCount!==void 0&&(0,Q.jsxs)(`span`,{children:[i.data.totalToolUseCount,` tool uses`]})]}),(0,Q.jsx)(kl,{output:t}),n===void 0&&(0,Q.jsx)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 text-xs text-muted-foreground animate-pulse`,children:`Running...`})]})},jl=I({todos:pe(I({content:R(),status:ue([`pending`,`in_progress`,`completed`])}))}),Ml=({status:e})=>{switch(e){case`completed`:return(0,Q.jsx)(Ke,{className:`w-3.5 h-3.5 flex-shrink-0 text-green-600 dark:text-green-500`});case`in_progress`:return(0,Q.jsx)(fn,{className:`w-3.5 h-3.5 flex-shrink-0 text-amber-600 dark:text-amber-500`});case`pending`:return(0,Q.jsx)(mn,{className:`w-3.5 h-3.5 flex-shrink-0 text-muted-foreground`});default:return null}},Nl=({input:e,output:t})=>{let n=jl.safeParse(e);if(!n.success)return null;let{todos:r}=n.data,i=r.filter(e=>e.status===`completed`).length,a=r.length,o=r.some(e=>e.status===`in_progress`);return(0,Q.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 flex items-center gap-2`,children:[(0,Q.jsx)(Ln,{className:J(`w-3.5 h-3.5`,o?`text-amber-600 dark:text-amber-500`:`text-muted-foreground`)}),(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Tasks`}),(0,Q.jsxs)(`span`,{className:J(`text-[10px] px-1.5 py-0.5 rounded-full ml-auto`,i===a?`bg-green-500/20 text-green-700 dark:text-green-400`:o?`bg-amber-500/20 text-amber-700 dark:text-amber-400`:`bg-muted text-muted-foreground`),children:[i,`/`,a]})]}),(0,Q.jsx)(`div`,{className:`p-2 space-y-1 max-h-48 overflow-y-auto`,children:r.map(e=>(0,Q.jsxs)(`div`,{className:J(`flex items-start gap-2 px-2 py-1.5 text-xs rounded-md transition-colors`,e.status===`completed`&&`text-muted-foreground`,e.status===`in_progress`&&`bg-amber-500/10`),children:[(0,Q.jsx)(Ml,{status:e.status}),(0,Q.jsx)(`span`,{className:J(`flex-1 break-words`,e.status===`completed`&&`line-through`),children:e.content})]},`${e.content}-${e.status}`))}),(0,Q.jsx)(cl,{output:t})]})},Pl=I({file_path:R(),content:R()}),Fl={Bash:Tc,Edit:hl,Read:xl,Write:({input:e,output:t})=>{let n=Pl.safeParse(e);return n.success?(0,Q.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 ${Sc} text-xs font-medium`,children:n.data.file_path}),t===void 0&&(0,Q.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground animate-pulse text-center`,children:`Writing file...`}),(0,Q.jsx)(cl,{output:t,showSuccess:!0})]}):null},Task:Al,Agent:Al,TaskCreate:Tl,TaskUpdate:Tl,TodoWrite:Nl,CCVAskUserQuestion:jc},Il=e=>Fl[e],Ll=se.object({prompt:se.string()}),Rl=new Set([`Task`,`Agent`]),zl=({content:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:s,sessionId:c,syntaxTheme:l})=>{let u=Il(e.name),[d,f]=(0,Z.useState)(u?`visual`:`raw`),p=t(e.id),m=r(e.id),h=(0,Z.useMemo)(()=>!u||d!==`visual`?null:(0,Q.jsx)(u,{toolUseId:e.id,input:e.input,output:p,toolUseResult:m}),[u,d,e.id,e.input,p,m]),g=d===`visual`&&u&&h===null?`raw`:d,_=(()=>{let r=Rl.has(e.name)?Ll.safeParse(e.input):void 0;if(r===void 0||r.success===!1)return;let l=n(e.id);return(0,Q.jsx)(bc,{prompt:r.data.prompt,projectId:s,sessionId:c,agentId:l,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,getToolResult:t})})(),v=Ps(e),y=v.length>0?(0,Q.jsx)(_c,{projectId:s,filePaths:v}):void 0;return(0,Q.jsx)(wt,{className:`border-blue-200 bg-blue-50/50 dark:border-blue-800 dark:bg-blue-950/20 mb-2 p-0 overflow-hidden`,children:(0,Q.jsxs)(K,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center min-w-0`,children:[(0,Q.jsx)(Qe,{asChild:!0,children:(0,Q.jsx)(`div`,{className:`flex-1 min-w-0 cursor-pointer hover:bg-blue-100/50 dark:hover:bg-blue-900/20 transition-all duration-200 px-3 py-1.5 group`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Q.jsx)(ar,{className:`h-4 w-4 text-blue-600 dark:text-blue-400 flex-shrink-0`}),(0,Q.jsxs)(`div`,{className:`w-full min-w-0 text-sm font-medium group-hover:text-foreground transition-colors overflow-hidden text-ellipsis whitespace-nowrap`,children:[e.name,Object.keys(e.input).length>0&&(0,Q.jsxs)(`span`,{className:`font-normal`,children:[` `,`(`,(0,Q.jsx)(xc,{input:e.input}),`)`]})]}),(0,Q.jsx)(G,{className:`h-4 w-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180 flex-shrink-0`})]})})}),(_??y)&&(0,Q.jsxs)(`div`,{className:`flex-shrink-0 border-l border-blue-200 dark:border-blue-800 flex items-center`,children:[_,y]})]}),(0,Q.jsx)(W,{children:(0,Q.jsxs)(`div`,{className:`space-y-3 py-3 px-4 border-t border-blue-200 dark:border-blue-800`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:`ID`}),(0,Q.jsx)(`code`,{className:`text-xs bg-background/50 px-2 py-1 rounded border border-blue-200 dark:border-blue-800 font-mono`,children:e.id}),u&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f(g===`raw`?`visual`:`raw`),className:`ml-auto flex items-center gap-1 px-2 py-0.5 text-xs rounded-md border transition-colors ${g===`raw`?`border-blue-300 dark:border-blue-700 bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300`:`border-gray-200 dark:border-gray-700 text-muted-foreground hover:bg-gray-100 dark:hover:bg-gray-800`}`,children:[(0,Q.jsx)(vn,{className:`h-3 w-3`}),`Raw`]})]}),g===`visual`&&h,g===`raw`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,Q.jsx)(B,{id:`assistant.tool.input_parameters`})}),(0,Q.jsx)(tn,{style:l,language:`json`,PreTag:`div`,className:`text-xs rounded`,children:JSON.stringify(e.input,null,2)})]}),p&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,Q.jsx)(B,{id:`assistant.tool.result`})}),(0,Q.jsx)(`div`,{className:`bg-background rounded border p-3`,children:typeof p.content==`string`?(0,Q.jsx)(`pre`,{className:`text-xs overflow-x-auto whitespace-pre-wrap break-words`,children:p.content}):p.content.map(e=>{if(e.type===`image`)return(0,Q.jsx)(`img`,{src:`data:${e.source.media_type};base64,${e.source.data}`,alt:`Tool Result`},e.source.data);if(e.type===`text`)return(0,Q.jsx)(`pre`,{className:`text-xs overflow-x-auto whitespace-pre-wrap break-words`,children:e.text},e.text);if(e.type===`tool_reference`)return null;throw Error(`Unexpected tool result content type`)})})]})]})]})})]})})},Bl=({content:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:s,sessionId:c})=>{let{resolvedTheme:l}=Mt(),u=l===`dark`?Rt:Ut;return e.type===`text`?(0,Q.jsx)(`div`,{className:`w-full mx-1 sm:mx-2 my-4 sm:my-6`,children:(0,Q.jsx)(rc,{content:e.text,placement:`assistant`})}):e.type===`thinking`?e.thinking===``?null:(0,Q.jsx)(wt,{className:`bg-muted/50 border-dashed gap-2 py-1 mb-2 hover:shadow-sm transition-all duration-200`,children:(0,Q.jsxs)(K,{children:[(0,Q.jsx)(Qe,{asChild:!0,children:(0,Q.jsx)(xt,{className:`cursor-pointer hover:bg-muted/80 rounded-t-lg transition-all duration-200 py-0 px-4 group`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(In,{className:`h-4 w-4 text-muted-foreground group-hover:text-yellow-600 transition-colors`}),(0,Q.jsx)(vt,{className:`text-sm font-medium group-hover:text-foreground transition-colors`,children:(0,Q.jsx)(B,{id:`assistant.thinking`})}),(0,Q.jsx)(G,{className:`h-4 w-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180`})]})})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`py-2 px-4`,children:(0,Q.jsx)(`div`,{className:`text-sm text-muted-foreground whitespace-pre-wrap font-mono`,children:e.thinking})})})]})}):e.type===`tool_use`?(0,Q.jsx)(zl,{content:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:s,sessionId:c,syntaxTheme:u}):(e.type,null)},Vl=e=>{let t=(0,Z.useMemo)(()=>e.filter(e=>e.type!==`summary`&&e.type!==`file-history-snapshot`&&e.type!==`queue-operation`&&e.type!==`progress`&&e.type!==`custom-title`&&e.type!==`ai-title`&&e.type!==`agent-name`&&e.type!==`agent-setting`&&e.type!==`pr-link`&&e.type!==`last-prompt`&&e.type!==`permission-mode`&&e.type!==`attachment`).filter(e=>e.isSidechain===!0),[e]),n=(0,Z.useMemo)(()=>new Map(t.map(e=>[e.uuid,e])),[t]),r=(0,Z.useMemo)(()=>{let e=[];for(let n of t)n.type!==`user`||n.parentUuid!==null||typeof n.message.content==`string`&&e.push([n.message.content,n]);return new Map(e)},[t]),i=(0,Z.useMemo)(()=>new Set(e.filter(e=>e.type===`assistant`).flatMap(e=>e.message.content.filter(e=>e.type===`tool_use`)).flatMap(e=>{if(!Rl.has(e.name))return[];let t=Ll.safeParse(e.input);return t.success===!1?[]:[t.data.prompt]})),[e]),a=(0,Z.useCallback)(e=>{if(e.parentUuid===null)return e;let t=n.get(e.parentUuid);return t===void 0?e:a(t)},[n]),o=(0,Z.useMemo)(()=>{let e=new Map;for(let n of t){let t=a(n);e.has(t.uuid)?e.get(t.uuid)?.push(n):e.set(t.uuid,[n])}return e},[t,a]),s=(0,Z.useCallback)(e=>e.type===`summary`||e.type===`file-history-snapshot`||e.type===`queue-operation`||e.type===`custom-title`||e.type===`ai-title`||e.type===`agent-name`||e.type===`agent-setting`||e.type===`pr-link`||e.type===`last-prompt`||e.type===`permission-mode`||e.type===`attachment`?!1:o.has(e.uuid),[o]),c=(0,Z.useCallback)(e=>o.get(e)??[],[o]),l=(0,Z.useCallback)(e=>r.get(e),[r]),u=(0,Z.useMemo)(()=>{let e=[];for(let n of t)n.type!==`user`&&n.type!==`system`&&n.type!==`assistant`||n.parentUuid!==null||n.agentId===void 0||e.push([n.agentId,n]);return new Map(e)},[t]);return{isRootSidechain:s,getSidechainConversations:c,getSidechainConversationByPrompt:l,getSidechainConversationByAgentId:(0,Z.useCallback)(e=>u.get(e),[u]),existsRelatedTaskCall:e=>i.has(e)}},Hl=e=>{if(e===void 0||e===``)return;let t=e.trim().toLowerCase().replaceAll(`_`,`-`);if(!(t.length===0||t===`*`)){if(t.startsWith(`zh`))return`zh_CN`;if(t.startsWith(`ja`)||t.startsWith(`jp`))return`ja`;if(t.startsWith(`en`))return`en`}},Ul=e=>{if(!e)return;let t;t=e.languages.length>0?e.languages:e.language?[e.language]:[];for(let e of t){let t=Hl(e);if(t)return t}},Wl=({conversation:e})=>{let t=Object.keys(e.snapshot.trackedFileBackups).length,{config:n}=fe();return(0,Q.jsxs)(K,{children:[(0,Q.jsx)(Qe,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2`,children:[(0,Q.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:[`File History Snapshot `,t>0&&`(${t} files)`]}),(0,Q.jsx)(G,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`text-xs`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Timestamp: `}),(0,Q.jsx)(`span`,{children:de(e.snapshot.timestamp,{locale:n.locale})})]}),(0,Q.jsxs)(`div`,{className:`text-xs`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Message ID: `}),(0,Q.jsx)(`span`,{className:`font-mono`,children:e.messageId})]}),(0,Q.jsxs)(`div`,{className:`text-xs`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Is Snapshot Update: `}),(0,Q.jsx)(`span`,{children:e.isSnapshotUpdate?`Yes`:`No`})]}),t>0&&(0,Q.jsxs)(`div`,{className:`text-xs`,children:[(0,Q.jsx)(`div`,{className:`text-muted-foreground mb-1`,children:`Tracked Files:`}),(0,Q.jsx)(`ul`,{className:`list-disc list-inside space-y-1`,children:Object.keys(e.snapshot.trackedFileBackups).map(e=>(0,Q.jsx)(`li`,{className:`font-mono text-xs break-all`,children:e},e))})]})]})})})]})},Gl=({children:e})=>(0,Q.jsxs)(K,{children:[(0,Q.jsx)(Qe,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2`,children:[(0,Q.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:`Meta Information`}),(0,Q.jsx)(G,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:e})})]}),Kl=e=>e===void 0?``:typeof e==`string`?e:e.map(e=>typeof e==`string`?e:e.type===`text`?e.text:e.type===`image`?`[Image]`:e.type===`document`?`[Document]`:e.type===`tool_result`?`[Tool Result]`:e).join(`
|
|
10
|
+
`),ql=({conversation:e})=>(0,Q.jsxs)(K,{children:[(0,Q.jsx)(Qe,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2`,children:[(0,Q.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:e.operation===`enqueue`?`Queue Operation: Enqueue`:`Queue Operation: Dequeue`}),(0,Q.jsx)(G,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:(0,Q.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Operation:`}),` `,e.operation]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Session ID:`}),` `,e.sessionId]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Timestamp:`}),` `,e.timestamp]}),e.operation===`enqueue`&&e.content!==void 0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Content:`}),(0,Q.jsx)(`pre`,{className:`mt-1 overflow-x-auto whitespace-pre-wrap`,children:Kl(e.content)})]})]})})})]}),Jl=({children:e})=>(0,Q.jsxs)(K,{children:[(0,Q.jsx)(Qe,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2`,children:[(0,Q.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:`Summarized`}),(0,Q.jsx)(G,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:(0,Q.jsx)(`pre`,{className:`text-xs overflow-x-auto`,children:e})})})]}),Yl=({children:e})=>(0,Q.jsxs)(K,{children:[(0,Q.jsx)(Qe,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2`,children:[(0,Q.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:`System Message`}),(0,Q.jsx)(G,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:(0,Q.jsx)(`pre`,{className:`text-xs overflow-x-auto`,children:e})})})]}),Xl=({durationMs:e})=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground mt-2 px-2`,children:[(0,Q.jsx)(_n,{className:`h-3 w-3`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(B,{id:`assistant.turn_duration`}),`: `,Js(e)]})]}),Zl=e=>e.replace(/(?<!\n)( *)\n(?!\n)/g,(e,t)=>t.length>=2?e:`
|
|
11
|
+
`),Ql=({text:e,id:t})=>{let n=qs(e);if(n.kind===`command`){let e=n.commandArgs!==void 0&&n.commandArgs!==``,r=n.commandMessage!==void 0&&n.commandMessage!==``,i=e||r;return(0,Q.jsxs)(wt,{className:`border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3`,id:t,children:[(0,Q.jsx)(xt,{className:`py-0 px-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(tr,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),(0,Q.jsx)(vt,{className:`text-sm font-medium`,children:`Claude Code Command`}),(0,Q.jsx)(U,{variant:`outline`,className:`border-green-300 text-green-700 dark:border-green-700 dark:text-green-300`,children:n.commandName})]})}),i?(0,Q.jsx)(St,{className:`py-0 px-4`,children:(0,Q.jsx)(`div`,{className:`space-y-2`,children:(0,Q.jsxs)(`div`,{children:[e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Arguments:`}),(0,Q.jsx)(`div`,{className:`bg-background rounded border p-2 mt-1`,children:(0,Q.jsx)(`code`,{className:`text-xs whitespace-pre-line break-all`,children:n.commandArgs})})]}):null,r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Message:`}),(0,Q.jsx)(`div`,{className:`bg-background rounded border p-2 mt-1`,children:(0,Q.jsx)(`code`,{className:`text-xs whitespace-pre-line break-all`,children:n.commandMessage})})]}):null]})})}):null]})}return n.kind===`local-command`?(0,Q.jsxs)(wt,{className:`border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3`,children:[(0,Q.jsx)(xt,{className:`py-0 px-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(tr,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),(0,Q.jsx)(vt,{className:`text-sm font-medium`,children:`Local Command`})]})}),(0,Q.jsx)(St,{className:`py-0 px-4`,children:(0,Q.jsx)(`pre`,{className:`text-xs overflow-x-auto whitespace-pre-wrap break-words`,children:n.stdout})})]}):(0,Q.jsx)(rc,{className:`w-full px-3 py-3 mb-5 border border-border rounded-lg bg-slate-50 dark:bg-slate-900/50`,content:Zl(n.content)})},$l=({content:e,id:t})=>typeof e==`string`?(0,Q.jsx)(Ql,{text:e,id:t}):e.type===`text`?(0,Q.jsx)(Ql,{text:e.text,id:t}):e.type===`image`?e.source.type===`base64`?(0,Q.jsx)(wt,{className:`border-purple-200 bg-purple-50/50 dark:border-purple-800 dark:bg-purple-950/20 mb-2 p-0 overflow-hidden`,id:t,children:(0,Q.jsxs)(K,{children:[(0,Q.jsx)(Qe,{asChild:!0,children:(0,Q.jsx)(`div`,{className:`cursor-pointer hover:bg-purple-100/50 dark:hover:bg-purple-900/20 transition-colors px-3 py-1.5 group`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Fn,{className:`h-4 w-4 text-purple-600 dark:text-purple-400`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:(0,Q.jsx)(B,{id:`user.content.image`})}),(0,Q.jsx)(U,{variant:`outline`,className:`border-purple-300 text-purple-700 dark:border-purple-700 dark:text-purple-300`,children:e.source.media_type}),(0,Q.jsx)(G,{className:`h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto`})]})})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`py-3 px-4 border-t border-purple-200 dark:border-purple-800`,children:(0,Q.jsx)(`div`,{className:`rounded-lg border overflow-hidden bg-background`,children:(0,Q.jsx)(`img`,{src:`data:${e.source.media_type};base64,${e.source.data}`,alt:`User uploaded content`,className:`max-w-full h-auto max-h-96 object-contain`})})})})]})}):(0,Q.jsx)(wt,{className:`border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20`,id:t,children:(0,Q.jsxs)(xt,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ft,{className:`h-4 w-4 text-red-600 dark:text-red-400`}),(0,Q.jsx)(vt,{className:`text-sm font-medium`,children:(0,Q.jsx)(B,{id:`user.content.unsupported_media`})}),(0,Q.jsx)(U,{variant:`destructive`,children:(0,Q.jsx)(B,{id:`common.error`})})]}),(0,Q.jsx)(Ct,{className:`text-xs`,children:(0,Q.jsx)(B,{id:`user.content.unsupported_media.description`})})]})}):e.type===`document`?e.source.type===`base64`&&e.source.media_type===`application/pdf`?(0,Q.jsx)(wt,{className:`border-blue-200 bg-blue-50/50 dark:border-blue-800 dark:bg-blue-950/20 mb-2 p-0 overflow-hidden`,id:t,children:(0,Q.jsxs)(K,{children:[(0,Q.jsx)(Qe,{asChild:!0,children:(0,Q.jsx)(`div`,{className:`cursor-pointer hover:bg-blue-100/50 dark:hover:bg-blue-900/20 transition-colors px-3 py-1.5 group`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Tn,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:(0,Q.jsx)(B,{id:`user.content.document.pdf`})}),(0,Q.jsx)(U,{variant:`outline`,className:`border-blue-300 text-blue-700 dark:border-blue-700 dark:text-blue-300`,children:e.source.media_type}),(0,Q.jsx)(G,{className:`h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto`})]})})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`py-3 px-4 border-t border-blue-200 dark:border-blue-800`,children:(0,Q.jsx)(`div`,{className:`rounded-lg border overflow-hidden bg-background`,children:(0,Q.jsx)(`embed`,{src:`data:${e.source.media_type};base64,${e.source.data}`,type:`application/pdf`,className:`w-full h-[600px]`})})})})]})}):e.source.type===`text`?(0,Q.jsx)(wt,{className:`border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 mb-2 p-0 overflow-hidden`,id:t,children:(0,Q.jsxs)(K,{children:[(0,Q.jsx)(Qe,{asChild:!0,children:(0,Q.jsx)(`div`,{className:`cursor-pointer hover:bg-green-100/50 dark:hover:bg-green-900/20 transition-colors px-3 py-1.5 group`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Tn,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:(0,Q.jsx)(B,{id:`user.content.document.text`})}),(0,Q.jsx)(U,{variant:`outline`,className:`border-green-300 text-green-700 dark:border-green-700 dark:text-green-300`,children:e.source.media_type}),(0,Q.jsx)(G,{className:`h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto`})]})})}),(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`py-3 px-4 border-t border-green-200 dark:border-green-800`,children:(0,Q.jsx)(`div`,{className:`rounded-lg border overflow-hidden bg-background`,children:(0,Q.jsx)(`pre`,{className:`p-4 text-sm overflow-auto max-h-96`,children:e.source.data})})})})]})}):(0,Q.jsx)(wt,{className:`border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20`,id:t,children:(0,Q.jsxs)(xt,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ft,{className:`h-4 w-4 text-red-600 dark:text-red-400`}),(0,Q.jsx)(vt,{className:`text-sm font-medium`,children:(0,Q.jsx)(B,{id:`user.content.unsupported_document`})}),(0,Q.jsx)(U,{variant:`destructive`,children:(0,Q.jsx)(B,{id:`common.error`})})]}),(0,Q.jsx)(Ct,{className:`text-xs`,children:(0,Q.jsx)(B,{id:`user.content.unsupported_document.description`})})]})}):(e.type,null),eu=e=>{let t=[];if(`subtype`in e&&e.subtype&&t.push(`[${e.subtype}]`),`level`in e&&e.level&&t.push(`Level: ${e.level}`),`content`in e&&typeof e.content==`string`&&t.push(`\n${e.content}`),e.subtype===`stop_hook_summary`&&(t.push(`Hook Count: ${e.hookCount}`),t.push(`Stop Reason: ${e.stopReason}`),t.push(`Prevented Continuation: ${e.preventedContinuation}`),t.push(`Has Output: ${e.hasOutput}`),e.hookInfos.length>0&&t.push(`Commands: ${e.hookInfos.map(e=>e.command).join(`, `)}`),e.hookErrors.length>0&&t.push(`Errors: ${JSON.stringify(e.hookErrors,null,2)}`)),e.subtype===`turn_duration`&&t.push(`Duration: ${(e.durationMs/1e3).toFixed(2)}s`),e.subtype===`compact_boundary`&&e.compactMetadata&&(t.push(`Trigger: ${e.compactMetadata.trigger}`),t.push(`Pre-Tokens: ${e.compactMetadata.preTokens}`)),e.subtype===`api_error`&&`error`in e){let n=e.error;n.status!==void 0&&t.push(`Status: ${n.status}`),n.requestID!==void 0&&n.requestID!==``&&t.push(`Request ID: ${n.requestID}`);let r=n?.error?.error?.message??n?.error?.message??(n?.error?JSON.stringify(n.error,null,2):null);r!==null&&r!==``&&t.push(`Error: ${r}`),e.retryAttempt!==void 0&&t.push(`Retry: ${e.retryAttempt}/${e.maxRetries}`),e.retryInMs!==void 0&&t.push(`Retry In: ${(e.retryInMs/1e3).toFixed(2)}s`)}return`toolUseID`in e&&e.toolUseID&&t.push(`Tool Use ID: ${e.toolUseID}`),`slug`in e&&e.slug!==void 0&&e.slug!==``&&t.push(`Slug: ${e.slug}`),t.join(`
|
|
12
|
+
`)},tu=(0,Z.memo)(({conversation:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getTurnDuration:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,getSidechainConversationByAgentId:s,projectId:c,sessionId:l,showTimestamp:u=!0})=>{let{i18n:d}=V(),f=ae.safeParse(d.locale),p=f.success?f.data:`en`;if(e.type===`summary`)return(0,Q.jsx)(Jl,{children:e.summary});if(e.type===`system`)return(0,Q.jsx)(Yl,{children:eu(e)});if(e.type===`file-history-snapshot`)return(0,Q.jsx)(Wl,{conversation:e});if(e.type===`queue-operation`)return(0,Q.jsx)(ql,{conversation:e});if(e.type===`user`){if(typeof e.message.content==`string`){let i=qs(e.message.content);if(i.kind===`local-command`){let d={type:`text`,text:i.stdout};return(0,Q.jsxs)(`div`,{className:`w-full`,children:[u&&e.timestamp&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1 px-1 select-none text-left`,children:de(e.timestamp,{locale:p,target:`datetime`})}),(0,Q.jsx)(`ul`,{className:`w-full`,children:(0,Q.jsx)(`li`,{children:(0,Q.jsx)(Bl,{content:d,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:s,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:c,sessionId:l})})})]})}}let i=typeof e.message.content==`string`?(0,Q.jsx)($l,{content:e.message.content,id:`message-${e.uuid}`}):(0,Q.jsx)(`ul`,{className:`w-full`,id:`message-${e.uuid}`,children:e.message.content.map((e,t)=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)($l,{content:e})},t))}),d=u&&e.timestamp?(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1 px-1 select-none text-right`,children:de(e.timestamp,{locale:p,target:`datetime`})}):null;return e.isMeta===!0?(0,Q.jsx)(Gl,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col w-full`,children:[d,i]})}):(0,Q.jsxs)(`div`,{className:`flex flex-col w-full`,children:[d,i]})}if(e.type===`assistant`){let d=e.message.content.filter(e=>!(e.type===`thinking`&&e.thinking===``||e.type===`tool_result`));if(d.length===0&&i(e.uuid)===void 0)return null;let f=i(e.uuid);return(0,Q.jsxs)(`div`,{className:`w-full`,children:[u&&e.timestamp&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1 px-1 select-none text-left`,children:de(e.timestamp,{locale:p,target:`datetime`})}),(0,Q.jsx)(`ul`,{className:`w-full`,children:d.map((e,i)=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(Bl,{content:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:s,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:c,sessionId:l})},i))}),f!==void 0&&(0,Q.jsx)(Xl,{durationMs:f})]})}return null}),nu=new Set([`summary`,`progress`,`queue-operation`,`file-history-snapshot`,`custom-title`,`ai-title`,`agent-name`,`agent-setting`,`attachment`]),ru=e=>{if(e.type===`user`)return`user_${e.uuid}`;if(e.type===`assistant`)return`assistant_${e.uuid}`;if(e.type===`system`)return`system_${e.uuid}`;if(e.type===`summary`)return`summary_${e.leafUuid}`;if(e.type===`file-history-snapshot`)return`file-history-snapshot_${e.messageId}`;if(e.type===`queue-operation`)return`queue-operation_${e.operation}_${e.sessionId}_${e.timestamp}`;if(e.type===`progress`)return`progress_${e.uuid}`;if(e.type===`custom-title`)return`custom-title_${e.sessionId}_${e.customTitle}`;if(e.type===`ai-title`)return`ai-title_${e.sessionId}_${e.aiTitle}`;if(e.type===`agent-name`)return`agent-name_${e.sessionId}_${e.agentName}`;if(e.type===`agent-setting`)return`agent-setting_${e.sessionId}_${e.agentSetting}`;if(e.type===`pr-link`)return`pr-link_${e.sessionId}_${e.prNumber}`;if(e.type===`last-prompt`)return`last-prompt_${e.sessionId}`;if(e.type===`permission-mode`)return`permission-mode_${e.sessionId}_${e.permissionMode}`;if(e.type===`attachment`)return`attachment_${e.uuid}`;throw Error(`Unknown conversation type`)},iu=(e,t)=>{let n=[],r=new Map,i=e=>{let t=r.get(e)??0;return r.set(e,t+1),t===0?e:`${e}_${t}`};for(let r of e){if(r.type===`x-error`){n.push({conversation:r,showTimestamp:!1,rowKey:i(`error_${r.lineNumber}`)});continue}t(r)&&n.push({conversation:r,showTimestamp:!nu.has(r.type),rowKey:i(ru(r))})}return n},au=({scheduledJobs:e})=>{let{i18n:t}=V();return e.length===0?null:(0,Q.jsx)(`div`,{className:`w-full flex justify-start mt-4`,children:(0,Q.jsx)(`div`,{className:`w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%] px-2`,children:(0,Q.jsxs)(`div`,{className:`bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800/50 rounded-lg p-4 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(ln,{className:`w-4 h-4 text-blue-600 dark:text-blue-400`}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-blue-900 dark:text-blue-100`,children:(0,Q.jsx)(B,{id:`session.scheduled_messages.title`})})]}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>{if(e.schedule.type!==`reserved`)return null;let n=new Date(e.schedule.reservedExecutionTime);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 p-3 bg-white dark:bg-gray-900 rounded border border-blue-100 dark:border-blue-900`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(U,{variant:`secondary`,className:`bg-blue-100 text-blue-900 dark:bg-blue-900 dark:text-blue-100`,children:new Intl.DateTimeFormat(t.locale,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}).format(n)}),!e.enabled&&(0,Q.jsx)(U,{variant:`outline`,className:`text-xs`,children:(0,Q.jsx)(B,{id:`session.scheduled_messages.disabled`})})]}),(0,Q.jsxs)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300 line-clamp-2`,children:[(0,Q.jsx)(B,{id:`session.scheduled_messages.message_label`}),`: `,e.message.content]})]},e.id)})})]})})})},ou=`conversation-in-page-search`,su=e=>typeof e==`object`&&!!e&&`agentId`in e&&typeof e.agentId==`string`,cu=e=>{if(typeof e==`string`)return e;let t=[];for(let n of e){if(typeof n==`string`){t.push(n);continue}n.type===`text`&&t.push(n.text)}return t.join(` `)},lu=e=>e.type===`text`?e.text:e.type===`thinking`?e.thinking:e.type===`tool_use`?e.name:``,uu=e=>e.type===`x-error`?e.line:e.type===`user`?cu(e.message.content):e.type===`assistant`?e.message.content.map(lu).join(` `):e.type===`summary`?e.summary:e.type===`system`&&`content`in e?e.content:e.type===`custom-title`?e.customTitle:e.type===`ai-title`?e.aiTitle:e.type===`last-prompt`?e.lastPrompt:``,du=()=>{let e=document.getElementById(ou);return e instanceof HTMLInputElement?e:null},fu=e=>{if(e===null)return;let t=e.querySelectorAll(`mark[data-active-search-highlight='true']`);for(let e of t){let t=e.parentNode;if(t===null)continue;let n=document.createTextNode(e.textContent??``);t.replaceChild(n,e),t.normalize()}},pu=(e,t)=>{let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;;){let e=n.nextNode();if(e===null)return null;if(!(e instanceof Text))continue;let r=e.nodeValue;if(r===null||r===``)continue;let i=r.toLowerCase().indexOf(t);if(i>=0)return{node:e,startOffset:i}}},mu=e=>{if(typeof e!=`object`||!e||!(`type`in e))return!1;let{type:t}=e;return typeof t==`string`},hu=e=>{try{let t=JSON.parse(e);return mu(t)?t.type:null}catch{return null}},gu=e=>e.split(/[-_\s]+/).filter(e=>e!==``).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),_u=({errorLine:e})=>{let t=hu(e),n=t===null?`Unknown Entry`:gu(t);return(0,Q.jsx)(`div`,{className:`w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%]`,children:(0,Q.jsxs)(wt,{className:`border-amber-200 bg-amber-50/50 dark:border-amber-800 dark:bg-amber-950/20 gap-2 py-3 mb-3`,children:[(0,Q.jsx)(xt,{className:`py-0 px-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Cn,{className:`h-4 w-4 text-amber-600 dark:text-amber-400`}),(0,Q.jsx)(vt,{className:`text-sm font-medium`,children:n})]})}),(0,Q.jsx)(St,{className:`py-0 px-4`,children:(0,Q.jsx)(`pre`,{className:`text-xs overflow-x-auto whitespace-pre-wrap break-words`,children:e})})]})})},vu=({conversations:e,getToolResult:t,projectId:n,sessionId:r,scheduledJobs:i,scrollContainerRef:a,enableInPageSearch:o=!1})=>{let{config:s}=fe(),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(0),m=(0,Z.useRef)(null),h=(0,Z.useRef)(new Map),g=(0,Z.useMemo)(()=>e.filter(e=>e.type!==`x-error`),[e]),{isRootSidechain:_,getSidechainConversations:v,getSidechainConversationByPrompt:y,getSidechainConversationByAgentId:b,existsRelatedTaskCall:x}=Vl(g),S=(0,Z.useMemo)(()=>{let e=new Map,t=e=>{if(e.type!==`user`||e.isSidechain)return!1;let t=e.message.content;if(Array.isArray(t)){let e=t[0];if(typeof e==`object`&&e&&`type`in e&&e.type===`tool_result`)return!1}return!0},n=[];for(let e=0;e<g.length;e++){let r=g[e];r!==void 0&&t(r)&&n.push(e)}for(let t=0;t<n.length;t++){let r=n[t];if(r===void 0)continue;let i=n[t+1]??g.length,a=g[r];if(a===void 0||a.type!==`user`)continue;let o=null;for(let e=r+1;e<i;e++){let t=g[e];t!==void 0&&t.type===`assistant`&&!t.isSidechain&&(o=t)}if(o!==null){let t=Ys(a.timestamp,o.timestamp);t!==null&&t>=0&&e.set(o.uuid,t)}}return e},[g]),C=(0,Z.useCallback)(e=>S.get(e),[S]),w=(0,Z.useMemo)(()=>{let e=new Map;for(let t of g){if(t.type!==`user`)continue;let n=t.message.content;if(typeof n!=`string`){for(let r of n)if(typeof r!=`string`&&r.type===`tool_result`){let n=t.toolUseResult;su(n)&&e.set(r.tool_use_id,n.agentId)}}}return e},[g]),T=(0,Z.useCallback)(e=>w.get(e),[w]),E=(0,Z.useMemo)(()=>{let e=new Map;for(let t of g){if(t.type!==`user`)continue;let n=t.message.content;if(typeof n!=`string`)for(let r of n)typeof r!=`string`&&r.type===`tool_result`&&t.toolUseResult!==void 0&&e.set(r.tool_use_id,t.toolUseResult)}return e},[g]),D=(0,Z.useCallback)(e=>E.get(e),[E]),O=(0,Z.useCallback)(e=>{if(e.type!==`user`)return!1;let t=e.message.content;return typeof t==`string`?!1:t.every(e=>typeof e!=`string`&&e.type===`tool_result`)},[]),k=(0,Z.useCallback)(e=>e.type===`x-error`?!0:!(e.type===`progress`||e.type===`custom-title`||e.type===`ai-title`||e.type===`agent-name`||e.type===`agent-setting`||e.type===`pr-link`||e.type===`last-prompt`||e.type===`permission-mode`||e.type!==`summary`&&e.type!==`file-history-snapshot`&&e.type!==`queue-operation`&&e.isSidechain||e.type===`user`&&O(e)),[O]),A=(0,Z.useMemo)(()=>iu(e,k),[e,k]),j=(0,Z.useMemo)(()=>A.map(e=>uu(e.conversation).toLowerCase()),[A]),M=(0,Z.useMemo)(()=>{if(u===``)return[];let e=[];for(let t=0;t<j.length;t++){let n=j[t];n!==void 0&&n.includes(u)&&e.push(t)}return e},[u,j]);(0,Z.useEffect)(()=>{if(!o)return;let e=s?.findHotkey??`command-f`,t=t=>{(e===`command-f`?t.metaKey&&!t.ctrlKey&&t.key.toLowerCase()===`f`:!t.metaKey&&t.ctrlKey&&t.key.toLowerCase()===`f`)&&(t.preventDefault(),l(!0)),t.key===`Escape`&&c&&l(!1)};return window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[o,c,s?.findHotkey]),(0,Z.useEffect)(()=>{p(0)},[u]),(0,Z.useEffect)(()=>{c&&requestAnimationFrame(()=>{let e=du();e!==null&&(e.focus(),e.select())})},[c]);let ee=(0,Z.useCallback)(e=>{d(e.trim().toLowerCase()),p(0)},[]);(0,Z.useEffect)(()=>{if(M.length===0)return;if(f>=M.length){p(0);return}let e=M[f];if(e===void 0)return;let t=h.current.get(e);t!==void 0&&t.scrollIntoView({behavior:`smooth`,block:`center`})},[f,M]),(0,Z.useEffect)(()=>{let e=a.current;if(e===null||(m.current!==null&&(window.cancelAnimationFrame(m.current),m.current=null),fu(e),u===``||M.length===0))return;let t=M[f];if(t===void 0)return;let n=e=>{let r=h.current.get(t);if(!(r instanceof HTMLElement)){e>0&&(m.current=window.requestAnimationFrame(()=>{n(e-1)}));return}let i=pu(r,u);if(i===null){e>0&&(m.current=window.requestAnimationFrame(()=>{n(e-1)}));return}let a=document.createElement(`mark`);a.dataset.activeSearchHighlight=`true`,a.className=`rounded bg-yellow-200 px-0.5 text-foreground dark:bg-yellow-700/70`;let o=document.createRange();o.setStart(i.node,i.startOffset),o.setEnd(i.node,i.startOffset+u.length),o.surroundContents(a),m.current=null};n(6)},[f,u,M,a]),(0,Z.useEffect)(()=>{let e=a.current;return()=>{m.current!==null&&window.cancelAnimationFrame(m.current),fu(e)}},[a]);let te=()=>{M.length!==0&&p(e=>e===0?M.length-1:e-1)},N=()=>{M.length!==0&&p(e=>(e+1)%M.length)},P=(0,Z.useCallback)((e,t)=>{t===null?h.current.delete(e):h.current.set(e,t)},[]),F=e=>{let i=A[e];if(i===void 0)return null;if(i.conversation.type===`x-error`)return(0,Q.jsx)(`div`,{className:`w-full flex justify-start`,children:(0,Q.jsx)(_u,{errorLine:i.conversation.line})});let a=i.conversation,o=a.type===`user`&&typeof a.message.content==`string`&&qs(a.message.content).kind===`local-command`;return(0,Q.jsx)(`div`,{className:`w-full flex ${a.type!==`summary`&&a.type!==`file-history-snapshot`&&a.type!==`queue-operation`&&a.type!==`progress`&&a.type!==`custom-title`&&a.type!==`ai-title`&&a.type!==`agent-name`&&a.type!==`agent-setting`&&a.type!==`pr-link`&&a.type!==`last-prompt`&&a.type!==`permission-mode`&&a.isSidechain||o||a.type===`assistant`||a.type===`system`||a.type===`summary`?`justify-start`:`justify-end`}`,children:(0,Q.jsx)(`div`,{className:`w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%]`,children:(0,Q.jsx)(tu,{conversation:a,getToolResult:t,getAgentIdForToolUse:T,getToolUseResult:D,getTurnDuration:C,isRootSidechain:_,getSidechainConversations:v,getSidechainConversationByAgentId:b,getSidechainConversationByPrompt:y,existsRelatedTaskCall:x,projectId:n,sessionId:r,showTimestamp:i.showTimestamp})})})};return(0,Q.jsxs)(Zs,{conversations:g,children:[o&&c&&(0,Q.jsx)(`div`,{className:`sticky top-2 z-20 mb-3 flex justify-end`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-background/95 px-2 py-1.5 shadow-sm backdrop-blur supports-[backdrop-filter]:bg-background/85`,children:[(0,Q.jsx)(ce,{className:`h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(Et,{id:ou,placeholder:`Find in conversation`,defaultValue:u,className:`h-8 w-56`,onKeyDown:e=>{if(e.key!==`Enter`)return;let t=e.currentTarget.value;if(t.trim().toLowerCase()===u&&M.length>0){e.shiftKey?te():N();return}ee(t)}}),(0,Q.jsx)(`span`,{className:`min-w-14 text-right text-xs text-muted-foreground`,children:M.length===0?`0/0`:`${f+1}/${M.length}`}),(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{let e=du()?.value??``;if(e.trim().toLowerCase()!==u){ee(e);return}te()},disabled:M.length===0,children:(0,Q.jsx)(un,{className:`h-4 w-4`})}),(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{let e=du()?.value??``;if(e.trim().toLowerCase()!==u){ee(e);return}N()},disabled:M.length===0,children:(0,Q.jsx)(G,{className:`h-4 w-4`})}),(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>l(!1),children:(0,Q.jsx)(Ie,{className:`h-4 w-4`})})]})}),(0,Q.jsx)(`ul`,{className:`w-full`,children:A.map((e,t)=>{let n=F(t);return n===null?null:(0,Q.jsx)(`li`,{ref:e=>P(t,e),children:n},e.rowKey)})}),(0,Q.jsx)(au,{scheduledJobs:i})]})},yu=e=>({type:`user`,message:{role:`user`,content:e.userMessage},isSidechain:!1,userType:`external`,cwd:``,sessionId:e.sessionId,version:`virtual`,uuid:`vc__${e.sessionId}__${e.sentAt}`,timestamp:e.sentAt,parentUuid:null}),bu=(e,t,n)=>!!(e.some(e=>e.type===`user`&&e.timestamp>=t)||n!==void 0&&e.length>n),xu=d(new Map),Su=f(),Cu=e=>Su.get(xu).get(e),wu=e=>{let t=Su.get(xu);if(!t.has(e))return;let n=new Map(t);n.delete(e),Su.set(xu,n)},Tu=e=>e.filter(e=>e.type!==`x-error`),Eu=(e,t)=>{let{isConnected:n}=D(jt);return s({queryKey:h(e,t).queryKey,queryFn:async()=>{let n=await h(e,t).queryFn(),r=Cu(t);if(n.session===null)return r?{session:{id:t,jsonlFilePath:``,meta:{messageCount:0,firstUserMessage:null,customTitle:null,cost:{totalUsd:0,breakdown:{inputTokensUsd:0,outputTokensUsd:0,cacheCreationUsd:0,cacheReadUsd:0},tokenUsage:{inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0}},modelName:null,prLinks:[]},conversations:[yu(r)],lastModifiedAt:r.sentAt}}:n;if(r)if(bu(Tu(n.session.conversations),r.sentAt,r.conversationCount))r.isNewSession||wu(t);else{let e=yu(r);return{...n,session:{...n.session,conversations:[...n.session.conversations,e]}}}return n},refetchInterval:n?!1:3e4,refetchIntervalInBackground:!1})},Du=(e,t)=>{let n=Eu(e,t).data?.session;if(n==null)throw Error(`Session not found`);let r=(0,Z.useMemo)(()=>{let e=n.conversations.flatMap(e=>e.type!==`user`||typeof e.message.content==`string`?[]:e.message.content.flatMap(e=>typeof e==`string`||e.type!==`tool_result`?[]:[[e.tool_use_id,e]]));return new Map(e)},[n.conversations]),i=(0,Z.useCallback)(e=>r.get(e),[r]);return{session:n,conversations:n.conversations,getToolResult:i}},Ou=({status:e})=>{switch(e){case`completed`:return(0,Q.jsx)(Ke,{className:`w-3.5 h-3.5 flex-shrink-0 text-green-600 dark:text-green-500`});case`in_progress`:return(0,Q.jsx)(fn,{className:`w-3.5 h-3.5 flex-shrink-0 text-amber-600 dark:text-amber-500`});case`pending`:return(0,Q.jsx)(mn,{className:`w-3.5 h-3.5 flex-shrink-0 text-muted-foreground`});default:return null}},ku=({todos:e})=>{let t=eo(),{setIsTodoSectionOpen:n}=to();if(!e||e.length===0)return null;let r=e.filter(e=>e.status===`completed`).length,i=e.length,a=e.some(e=>e.status===`in_progress`);return(0,Q.jsxs)(`div`,{className:`border-t border-border/40 bg-muted/5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:J(`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors`,`hover:bg-muted/30`,a&&!t&&`bg-amber-500/5`),children:[t?(0,Q.jsx)(G,{className:`w-3.5 h-3.5 text-muted-foreground`}):(0,Q.jsx)(Je,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,Q.jsx)(Ln,{className:J(`w-3.5 h-3.5`,a?`text-amber-600 dark:text-amber-500`:`text-muted-foreground`)}),(0,Q.jsx)(`span`,{className:J(`flex-1 text-left`,a?`text-amber-700 dark:text-amber-400`:`text-muted-foreground`),children:(0,Q.jsx)(B,{id:`panel.todo.collapsed_title`})}),(0,Q.jsxs)(`span`,{className:J(`text-[10px] px-1.5 py-0.5 rounded-full`,r===i?`bg-green-500/20 text-green-700 dark:text-green-400`:a?`bg-amber-500/20 text-amber-700 dark:text-amber-400`:`bg-muted text-muted-foreground`),children:[r,`/`,i]})]}),t&&(0,Q.jsx)(`div`,{className:`p-2 space-y-1 max-h-48 overflow-y-auto border-t border-border/40`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:J(`flex items-start gap-2 px-2 py-1.5 text-xs rounded-md transition-colors`,e.status===`completed`&&`text-muted-foreground`,e.status===`in_progress`&&`bg-amber-500/10`),children:[(0,Q.jsx)(Ou,{status:e.status}),(0,Q.jsx)(`span`,{className:J(`flex-1 break-words`,e.status===`completed`&&`line-through`),children:e.content})]},`${e.content}-${e.status}`))})]})},Au=e=>e.toSorted((e,t)=>e.displayPath.localeCompare(t.displayPath)),ju=(e,t)=>{if(t===void 0||t===``)return{internal:[],external:Au(e.map(e=>({...e,displayPath:e.filePath})))};let n=t.endsWith(`/`)?t:`${t}/`,r=[],i=[];for(let a of e)a.filePath.startsWith(n)?r.push({...a,displayPath:a.filePath.slice(n.length)}):a.filePath===t?r.push({...a,displayPath:`.`}):i.push({...a,displayPath:a.filePath});return{internal:Au(r),external:Au(i)}},Mu=({title:e,count:t,defaultOpen:n=!1,children:r,icon:i,stickyTop:a=0})=>{let[o,s]=(0,Z.useState)(n);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(!o),style:{top:a},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors sticky bg-background z-10 border-b border-border/40`,children:[o?(0,Q.jsx)(G,{className:`w-3.5 h-3.5`}):(0,Q.jsx)(Je,{className:`w-3.5 h-3.5`}),i,(0,Q.jsx)(`span`,{className:`flex-1 text-left`,children:e}),(0,Q.jsx)(`span`,{className:`text-[10px] bg-muted px-1.5 py-0.5 rounded-full`,children:t})]}),o&&(0,Q.jsx)(`div`,{className:`px-1 pb-2 border-b border-border/40`,children:r})]})},Nu=({filePath:e,displayPath:t,toolName:n,projectId:r,isExternal:i})=>{let a=async()=>{try{await navigator.clipboard.writeText(e),z.success(`File path copied`)}catch(e){console.error(`Failed to copy file path:`,e),z.error(`Failed to copy file path`)}};return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 text-xs font-normal hover:bg-accent rounded-md transition-colors`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[i===!0?(0,Q.jsx)(Sn,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}):(0,Q.jsx)(En,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate text-left flex-1 font-mono text-xs`,children:t}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 flex-shrink-0 bg-muted/50 px-1.5 py-0.5 rounded`,children:n})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,Q.jsx)(_c,{projectId:r,filePaths:[e],children:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,"aria-label":`Open file`,children:(0,Q.jsx)(_t,{className:`h-3.5 w-3.5 text-muted-foreground`})})}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>void a(),"aria-label":`Copy file path`,children:(0,Q.jsx)(yn,{className:`h-3.5 w-3.5 text-muted-foreground`})})]})]})},Pu=({name:e,timestamp:t,inputSummary:n})=>{let r=(0,Z.useMemo)(()=>{try{return new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}catch{return``}},[t]);return(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 px-2 py-1.5 text-xs hover:bg-muted/30 rounded-md transition-colors`,children:[(0,Q.jsx)(tr,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground mt-0.5`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r})]}),n&&(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate mt-0.5 font-mono`,children:n})]})]})},Fu=({message:e,icon:t})=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-3 text-xs text-muted-foreground`,children:[t,(0,Q.jsx)(`span`,{children:e})]}),Iu=({title:e,count:t,defaultOpen:n=!1,children:r,icon:i,stickyTop:a=0})=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{style:{top:a},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium text-muted-foreground sticky bg-background z-10 border-b border-border/40`,children:[(0,Q.jsx)(G,{className:`w-3.5 h-3.5`}),i,(0,Q.jsx)(`span`,{className:`flex-1 text-left`,children:e}),(0,Q.jsx)(`span`,{className:`text-[10px] bg-muted px-1.5 py-0.5 rounded-full`,children:t})]}),n&&(0,Q.jsx)(`div`,{className:`px-1 pb-2 border-b border-border/40`,children:r})]}),Lu=()=>void 0,Ru=({projectId:e,sessionId:t,agentId:n,title:r,isOpen:i,onOpenChange:a})=>{let o=(0,Z.useRef)(null),{data:s,isLoading:c,error:l,refetch:u}=le({...w(e,n,t),enabled:i,staleTime:0}),d=s?.conversations??[];return(0,Q.jsx)(Pe,{open:i,onOpenChange:a,children:(0,Q.jsxs)(Le,{className:`w-[95vw] md:w-[90vw] lg:w-[85vw] max-w-[1400px] h-[85vh] max-h-[85vh] flex flex-col p-0`,"data-testid":`agent-session-modal`,children:[(0,Q.jsx)(Re,{className:`px-6 py-4 border-b bg-muted/30`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,Q.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,Q.jsx)(ye,{className:`h-5 w-5 text-primary`})})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(Te,{className:`text-lg font-semibold leading-tight mb-1 pr-2`,children:r.length>120?`${r.slice(0,120)}...`:r}),(0,Q.jsxs)(we,{className:`text-xs flex items-center gap-2 flex-wrap`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`Agent:`,` `,(0,Q.jsx)(`code`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono`,children:n.slice(0,8)})]}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`|`}),(0,Q.jsx)(`span`,{children:(0,Q.jsx)(B,{id:`assistant.tool.message_count`,values:{count:d.length}})})]})]})]})}),(0,Q.jsxs)(`div`,{ref:o,className:`flex-1 overflow-auto px-6 py-4`,children:[c&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Q.jsx)(T,{className:`h-8 w-8 animate-spin text-primary`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Q.jsx)(B,{id:`assistant.tool.loading_task`})})]}),l!==null&&!c&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Q.jsx)(qe,{className:`h-8 w-8 text-destructive`}),(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,children:(0,Q.jsx)(B,{id:`assistant.tool.error_loading_task`})}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>void u(),children:(0,Q.jsx)(B,{id:`assistant.tool.retry`})})]}),!c&&l===null&&d.length===0&&(0,Q.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Q.jsx)(B,{id:`assistant.tool.no_task_data`})})}),!c&&l===null&&d.length>0&&(0,Q.jsx)(vu,{conversations:d.map(e=>({...e,isSidechain:!1})),getToolResult:Lu,projectId:e,sessionId:t,scheduledJobs:[],scrollContainerRef:o})]})]})})},zu=({agentId:e,firstMessage:t,onClick:n})=>{let r=t??`Agent ${e.slice(0,8)}`,i=r.length>80?`${r.slice(0,80)}...`:r;return(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-auto py-1.5 px-2 text-xs font-normal hover:bg-accent gap-2 rounded-md`,onClick:n,children:[(0,Q.jsx)(cn,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`truncate text-left flex-1 text-xs`,children:i}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 flex-shrink-0 bg-muted/50 px-1.5 py-0.5 rounded font-mono`,children:e.slice(0,8)})]})},Bu=()=>(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-3 border-b border-border/40 bg-muted/10`,children:(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(B,{id:`session.empty_state.description`})})}),(0,Q.jsx)(Iu,{title:(0,Q.jsx)(B,{id:`panel.files.edited_section`}),count:0,icon:(0,Q.jsx)(En,{className:`w-3.5 h-3.5`}),stickyTop:0,children:(0,Q.jsx)(Fu,{icon:(0,Q.jsx)(En,{className:`h-3.5 w-3.5`}),message:(0,Q.jsx)(B,{id:`panel.files.no_edited_files`})})}),(0,Q.jsx)(Iu,{title:(0,Q.jsx)(B,{id:`panel.files.tool_calls_section`}),count:0,icon:(0,Q.jsx)(ar,{className:`w-3.5 h-3.5`}),stickyTop:33,children:(0,Q.jsx)(Fu,{icon:(0,Q.jsx)(ar,{className:`h-3.5 w-3.5`}),message:(0,Q.jsx)(B,{id:`panel.files.no_tool_calls`})})}),(0,Q.jsx)(Iu,{title:`Agents`,count:0,icon:(0,Q.jsx)(cn,{className:`w-3.5 h-3.5`}),stickyTop:66,children:(0,Q.jsx)(Fu,{icon:(0,Q.jsx)(cn,{className:`h-3.5 w-3.5`}),message:(0,Q.jsx)(B,{id:`panel.files.no_agents`})})})]}),(0,Q.jsx)(ku,{todos:null})]}),Vu=({projectId:e,sessionId:t})=>{let{conversations:n}=Du(e,t),[r,i]=(0,Z.useState)(new Set),[a,o]=(0,Z.useState)(null),{data:s,isPending:c}=le({...M(e,t)}),l=(0,Z.useMemo)(()=>s?.agentSessions??[],[s?.agentSessions]),u=l.length>0,d=(0,Z.useMemo)(()=>a===null?``:l.find(e=>e.agentId===a)?.firstMessage??`Agent ${a.slice(0,8)}`,[a,l]),f=(0,Z.useCallback)(e=>{o(e)},[]),p=(0,Z.useCallback)(e=>{e||o(null)},[]),m=(0,Z.useMemo)(()=>Fs(n),[n]),h=(0,Z.useMemo)(()=>Ls(n),[n]),g=(0,Z.useMemo)(()=>{let e=new Set(h.map(e=>e.name));return Array.from(e).sort()},[h]),_=(0,Z.useMemo)(()=>r.size===0?h:h.filter(e=>r.has(e.name)),[h,r]),v=(0,Z.useMemo)(()=>{for(let e of n)if(`cwd`in e&&typeof e.cwd==`string`)return e.cwd},[n]),y=(0,Z.useMemo)(()=>ju(m,v),[m,v]),b=(0,Z.useMemo)(()=>Ws(n),[n]),x=y.internal.length>0||y.external.length>0,S=_.length>0,C=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[(0,Q.jsx)(Mu,{title:(0,Q.jsx)(B,{id:`panel.files.edited_section`}),count:m.length,icon:(0,Q.jsx)(En,{className:`w-3.5 h-3.5`}),stickyTop:0,children:x?(0,Q.jsxs)(Q.Fragment,{children:[y.internal.length>0&&(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:y.internal.map(t=>(0,Q.jsx)(Nu,{filePath:t.filePath,displayPath:t.displayPath,toolName:t.toolName,projectId:e},t.filePath))}),y.external.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 mt-2`,children:[(0,Q.jsx)(`div`,{className:`px-2 py-1 text-[10px] font-medium text-muted-foreground/70 uppercase tracking-wider`,children:(0,Q.jsx)(B,{id:`sidebar.edited_files.external`})}),y.external.map(t=>(0,Q.jsx)(Nu,{filePath:t.filePath,displayPath:t.displayPath,toolName:t.toolName,projectId:e,isExternal:!0},t.filePath))]})]}):(0,Q.jsx)(Fu,{icon:(0,Q.jsx)(En,{className:`h-3.5 w-3.5`}),message:(0,Q.jsx)(B,{id:`panel.files.no_edited_files`})})}),(0,Q.jsxs)(Mu,{title:(0,Q.jsx)(B,{id:`panel.files.tool_calls_section`}),count:_.length,icon:(0,Q.jsx)(ar,{className:`w-3.5 h-3.5`}),stickyTop:33,children:[h.length>0&&(0,Q.jsx)(`div`,{className:`px-2 pb-2`,children:(0,Q.jsxs)(et,{children:[(0,Q.jsx)(ft,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,className:J(`h-7 text-xs gap-1.5`,r.size>0&&`border-primary text-primary`),children:[(0,Q.jsx)(On,{className:`w-3 h-3`}),(0,Q.jsx)(B,{id:`panel.files.filter_tools`}),r.size>0&&(0,Q.jsx)(`span`,{className:`ml-1 px-1 py-0.5 bg-primary/10 rounded text-[10px]`,children:r.size})]})}),(0,Q.jsxs)(at,{align:`start`,className:`w-48 p-2`,children:[(0,Q.jsx)(`div`,{className:`space-y-1`,children:g.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 px-2 py-1 hover:bg-muted/50 rounded cursor-pointer w-full text-left`,onClick:()=>C(e),children:[(0,Q.jsx)(ct,{checked:r.has(e),onCheckedChange:()=>C(e)}),(0,Q.jsx)(`span`,{className:`text-xs`,children:e})]},e))}),r.size>0&&(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`w-full mt-2 h-7 text-xs`,onClick:()=>{i(new Set)},children:`Clear filter`})]})]})}),S?(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:_.map(e=>(0,Q.jsx)(Pu,{name:e.name,timestamp:e.timestamp,inputSummary:e.inputSummary},e.id))}):(0,Q.jsx)(Fu,{icon:(0,Q.jsx)(ar,{className:`h-3.5 w-3.5`}),message:r.size>0?(0,Q.jsx)(B,{id:`panel.files.no_filtered_tool_calls`}):(0,Q.jsx)(B,{id:`panel.files.no_tool_calls`})})]}),(0,Q.jsx)(Mu,{title:`Agents`,count:l.length,icon:(0,Q.jsx)(cn,{className:`w-3.5 h-3.5`}),stickyTop:66,children:c?(0,Q.jsx)(Fu,{icon:(0,Q.jsx)(T,{className:`h-3.5 w-3.5 animate-spin`}),message:(0,Q.jsx)(B,{id:`panel.files.loading_agents`})}):u?(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:l.map(e=>(0,Q.jsx)(zu,{agentId:e.agentId,firstMessage:e.firstMessage,onClick:()=>f(e.agentId)},e.agentId))}):(0,Q.jsx)(Fu,{icon:(0,Q.jsx)(cn,{className:`h-3.5 w-3.5`}),message:(0,Q.jsx)(B,{id:`panel.files.no_agents`})})})]}),(0,Q.jsx)(ku,{todos:b}),a!==null&&(0,Q.jsx)(Ru,{projectId:e,sessionId:t,agentId:a,title:d,isOpen:!0,onOpenChange:p})]})},Hu=xa,Uu=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(Sa,{ref:n,"data-slot":`tabs-list`,className:J(`inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground gap-1`,e),...t}));Uu.displayName=Sa.displayName;var Wu=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(Ca,{ref:n,"data-slot":`tabs-trigger`,className:J(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-sm font-medium ring-offset-background transition-all disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 gap-2 [&_svg]:size-4 [&_svg]:shrink-0`,e),...t}));Wu.displayName=Ca.displayName;var Gu=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(wa,{ref:n,"data-slot":`tabs-content`,className:J(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));Gu.displayName=wa.displayName;var Ku=e=>le({queryKey:j(e).queryKey,queryFn:j(e).queryFn,staleTime:3e4}),qu=e=>s({queryKey:j(e).queryKey,queryFn:j(e).queryFn,staleTime:3e4}),Ju=e=>s({queryKey:S(e).queryKey,queryFn:S(e).queryFn,staleTime:3e4}),Yu=(e,t,n)=>s({queryKey:O(e,t,n).queryKey,queryFn:O(e,t,n).queryFn,staleTime:3e4}),Xu=e=>{let t=N();return m({mutationFn:async t=>{let n=await o.api.projects[`:projectId`].git.checkout.$post({param:{projectId:e},json:{branchName:t}});if(!n.ok)throw Error(`Failed to checkout: ${n.statusText}`);return n.json()},onSuccess:()=>{t.invalidateQueries({queryKey:S(e).queryKey}),t.invalidateQueries({queryKey:j(e).queryKey}),t.invalidateQueries({queryKey:[`git`,`diff`,e]})}})},Zu=()=>m({mutationFn:async({projectId:e,fromRef:t,toRef:n})=>{let r=await o.api.projects[`:projectId`].git.diff.$post({param:{projectId:e},json:{fromRef:t,toRef:n}});if(!r.ok)throw Error(`Failed to get diff: ${r.statusText}`);return r.json()}}),Qu=e=>m({mutationFn:async({files:t,message:n})=>{let r=await o.api.projects[`:projectId`].git.commit.$post({param:{projectId:e},json:{files:t,message:n}});if(!r.ok)throw Error(`Failed to commit files: ${r.statusText}`);return r.json()}}),$u=e=>m({mutationFn:async()=>{let t=await o.api.projects[`:projectId`].git.push.$post({param:{projectId:e}});if(!t.ok)throw Error(`Failed to push commits: ${t.statusText}`);return t.json()}}),ed=e=>m({mutationFn:async({files:t,message:n})=>{let r=await o.api.projects[`:projectId`].git[`commit-and-push`].$post({param:{projectId:e},json:{files:t,message:n}});if(!r.ok)throw Error(`Failed to commit and push: ${r.statusText}`);return r.json()}}),td=()=>(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`flex-1 min-w-0 justify-start gap-2 h-7 px-2 text-xs font-normal`,disabled:!0,children:[(0,Q.jsx)(kn,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(T,{className:`w-3 h-3 animate-spin`}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Loading...`})]})]}),nd=({projectId:e})=>{let[t,n]=(0,Z.useState)(!1),{data:r}=qu(e),{data:i}=Ju(e),{mutate:a,isPending:o}=Xu(e),s=r?.success?r.data.currentBranch?.name??null:null,c=(0,Z.useMemo)(()=>i?.success?i.data.branches:[],[i]),l=e=>{if(e===s){n(!1);return}a(e,{onSuccess:t=>{t.success?z.success(`Switched to ${e}`):z.error(`Failed to switch branch`),n(!1)},onError:()=>{z.error(`Failed to switch branch`),n(!1)}})};return(0,Q.jsxs)(et,{open:t,onOpenChange:n,children:[(0,Q.jsx)(ft,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`flex-1 min-w-0 justify-start gap-2 h-7 px-2 text-xs font-normal`,disabled:o,children:[(0,Q.jsx)(kn,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,Q.jsx)(`span`,{className:`font-mono truncate flex-1 text-left`,children:o?(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(T,{className:`w-3 h-3 animate-spin`}),`Switching...`]}):s??`No branch`})]})}),(0,Q.jsx)(at,{className:`w-64 p-0`,align:`start`,children:(0,Q.jsxs)(es,{children:[(0,Q.jsx)(ts,{placeholder:`Search branch...`,className:`h-8`}),(0,Q.jsxs)(ns,{children:[(0,Q.jsx)(rs,{children:`No branch found.`}),(0,Q.jsx)(is,{children:c.map(e=>(0,Q.jsxs)(as,{value:e.name,onSelect:()=>l(e.name),className:`text-xs`,children:[(0,Q.jsx)(kn,{className:`w-3.5 h-3.5 mr-2 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.name}),e.name===s&&(0,Q.jsx)(We,{className:`w-3.5 h-3.5 text-primary`})]},e.name))})]})]})})]})},rd=({projectId:e,filePath:t,status:n,additions:r,deletions:i,diffHunks:a,children:o})=>{let[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`diff`),{resolvedTheme:d}=Mt(),f=d===`dark`?Rt:Ut,p=e=>{(e===`content`||e===`diff`)&&u(e)},{data:m,isLoading:h,error:g,refetch:_}=le({...x(e,t),enabled:s&&l===`content`}),v=t.split(`/`).pop()??t,y=m?.success===!0?m.language:Ms(t);return(0,Q.jsxs)(Pe,{open:s,onOpenChange:c,children:[(0,Q.jsx)(Ee,{asChild:!0,children:o}),(0,Q.jsxs)(Le,{className:`w-[95vw] md:w-[90vw] lg:w-[90vw] max-w-[1600px] h-[85vh] max-h-[85vh] flex flex-col p-0`,"data-testid":`git-file-dialog`,children:[(0,Q.jsx)(Re,{className:`px-6 py-4 border-b bg-muted/30`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,Q.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,Q.jsx)(wn,{className:`h-5 w-5 text-primary`})})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(Te,{className:`text-lg font-semibold leading-tight mb-1 pr-8 break-all`,children:v}),(0,Q.jsx)(we,{className:`text-xs flex items-center gap-2 flex-wrap`,asChild:!0,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`code`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono break-all`,children:t}),(0,Q.jsx)(U,{variant:`secondary`,className:J(`text-[10px]`,n===`added`&&`bg-green-500/20 text-green-700`,n===`deleted`&&`bg-red-500/20 text-red-700`,n===`modified`&&`bg-amber-500/20 text-amber-700`,n===`renamed`&&`bg-blue-500/20 text-blue-700`),children:n}),r>0&&(0,Q.jsxs)(`span`,{className:`text-green-600 dark:text-green-400 text-[10px]`,children:[`+`,r]}),i>0&&(0,Q.jsxs)(`span`,{className:`text-red-600 dark:text-red-400 text-[10px]`,children:[`-`,i]})]})})]})]})}),(0,Q.jsxs)(Hu,{value:l,onValueChange:p,className:`flex-1 flex flex-col overflow-hidden`,children:[(0,Q.jsxs)(Uu,{className:`mx-4 mt-2 w-fit`,children:[(0,Q.jsxs)(Wu,{value:`diff`,className:`text-xs`,children:[(0,Q.jsx)(An,{className:`w-3.5 h-3.5 mr-1`}),(0,Q.jsx)(B,{id:`panel.git.view_diff`})]}),(0,Q.jsxs)(Wu,{value:`content`,className:`text-xs`,children:[(0,Q.jsx)(_t,{className:`w-3.5 h-3.5 mr-1`}),(0,Q.jsx)(B,{id:`panel.git.view_content`})]})]}),(0,Q.jsx)(Gu,{value:`diff`,className:`flex-1 overflow-auto m-0 p-4`,children:a&&a.length>0?(0,Q.jsx)(tl,{fileDiff:{filename:t,isNew:n===`added`,isDeleted:n===`deleted`,isRenamed:n===`renamed`,isBinary:!1,hunks:a,linesAdded:r,linesDeleted:i}}):(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No diff available`})}),(0,Q.jsxs)(Gu,{value:`content`,className:`flex-1 overflow-auto m-0`,children:[h&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Q.jsx)(T,{className:`h-8 w-8 animate-spin text-primary`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Q.jsx)(B,{id:`assistant.tool.loading_file`})})]}),g!==null&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 px-6`,children:[(0,Q.jsx)(Ft,{className:`h-8 w-8 text-destructive`}),(0,Q.jsx)(`p`,{className:`text-sm text-destructive text-center`,children:(0,Q.jsx)(B,{id:`assistant.tool.error_loading_file`})}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>{_()},children:(0,Q.jsx)(B,{id:`assistant.tool.retry`})})]}),m&&!m.success&&(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 px-6`,children:[(0,Q.jsx)(Ft,{className:`h-8 w-8 text-destructive`}),(0,Q.jsxs)(`p`,{className:`text-sm text-destructive text-center`,children:[m.error===`NOT_FOUND`&&(0,Q.jsx)(B,{id:`assistant.tool.file_not_found`}),m.error===`BINARY_FILE`&&(0,Q.jsx)(B,{id:`assistant.tool.binary_file`}),m.error===`INVALID_PATH`&&(0,Q.jsx)(B,{id:`assistant.tool.invalid_path`}),m.error===`READ_ERROR`&&(0,Q.jsx)(B,{id:`assistant.tool.read_error`})]})]}),m?.success===!0&&(0,Q.jsx)(tn,{style:f,language:y,showLineNumbers:!0,wrapLines:!0,customStyle:{margin:0,borderRadius:0,fontSize:`0.75rem`,minHeight:`100%`},lineNumberStyle:{minWidth:`3em`,paddingRight:`1em`,textAlign:`right`,userSelect:`none`},children:m.content})]})]})]})]})},id=()=>(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Q.jsx)(T,{className:`w-5 h-5 animate-spin text-muted-foreground`})}),ad=({projectId:e})=>{let{i18n:t}=V(),n=(0,Z.useId)(),{data:r}=Yu(e,`HEAD`,`working`),i=N(),a=r?.success?r.data.files:[],o=a.length>0,[s,c]=(0,Z.useState)(()=>new Map),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),p=Qu(e),m=$u(e),h=ed(e),g=r?.success===!0?r.data:void 0,_=(0,Z.useMemo)(()=>{let e=new Map;if(g===void 0)return e;for(let t of g.diffs)e.set(t.file.filePath,{hunks:t.hunks});return e},[g]);(0,Z.useEffect)(()=>{g!==void 0&&g.files.length>0&&c(new Map(g.files.map(e=>[e.filePath,!0])))},[g]);let v=e=>{c(t=>{let n=new Map(t);return n.set(e,t.get(e)!==!0),n})},y=()=>{g!==void 0&&g.files.length>0&&c(new Map(g.files.map(e=>[e.filePath,!0])))},b=()=>{g!==void 0&&g.files.length>0&&c(new Map(g.files.map(e=>[e.filePath,!1])))},x=(0,Z.useCallback)(()=>{i.invalidateQueries({queryKey:[`git`,`diff`,e]})},[i,e]),S=async()=>{let e=Array.from(s.entries()).filter(([,e])=>e).map(([e])=>e);try{let t=await p.mutateAsync({files:e,message:l});t.success?(z.success(`Committed ${t.filesCommitted} files (${t.commitSha.slice(0,7)})`),u(``),x()):z.error(t.error,{description:t.details})}catch{z.error(t._(`Failed to commit`))}},C=async()=>{try{let e=await m.mutateAsync();e.success?z.success(`Pushed to ${e.remote}/${e.branch}`):z.error(e.error,{description:e.details})}catch{z.error(t._(`Failed to push`))}},w=async()=>{let e=Array.from(s.entries()).filter(([,e])=>e).map(([e])=>e);try{let n=await h.mutateAsync({files:e,message:l});n.success?(z.success(`Committed and pushed (${n.commitSha.slice(0,7)})`),u(``),x()):n.success===!1&&`commitSucceeded`in n&&n.commitSucceeded?(z.warning(`Committed (${n.commitSha?.slice(0,7)}), but push failed: ${n.error}`,{action:{label:t._(`Retry Push`),onClick:()=>{C()}}}),u(``),x()):z.error(n.error,{description:n.details})}catch{z.error(t._(`Failed to commit and push`))}},E=Array.from(s.values()).filter(Boolean).length,D=E===0||l.trim().length===0||p.isPending;return o?(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`mx-2 mt-2 mb-1 bg-gray-50 dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>f(!d),className:`w-full flex items-center justify-between p-2 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors rounded-t-lg`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-gray-700 dark:text-gray-300`,children:(0,Q.jsx)(B,{id:`diff.commit.changes`})}),d?(0,Q.jsx)(un,{className:`h-4 w-4 text-gray-600 dark:text-gray-400`}):(0,Q.jsx)(G,{className:`h-4 w-4 text-gray-600 dark:text-gray-400`})]}),d&&(0,Q.jsxs)(`div`,{className:`p-3 pt-0 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,onClick:y,disabled:p.isPending,className:`h-6 text-[10px]`,children:(0,Q.jsx)(B,{id:`diff.select.all`})}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,onClick:b,disabled:p.isPending,className:`h-6 text-[10px]`,children:(0,Q.jsx)(B,{id:`diff.deselect.all`})}),(0,Q.jsxs)(`span`,{className:`text-[10px] text-gray-600 dark:text-gray-400`,children:[E,` / `,a.length,` files`]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{htmlFor:n,className:`text-[10px] font-medium text-gray-700 dark:text-gray-300`,children:(0,Q.jsx)(B,{id:`diff.commit.message`})}),(0,Q.jsx)(Uc,{id:n,placeholder:`Enter commit message...`,value:l,onChange:e=>u(e.target.value),disabled:p.isPending,className:`resize-none text-xs min-h-[60px]`,rows:2})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,Q.jsx)(q,{onClick:()=>{S()},disabled:D,size:`sm`,className:`h-7 text-xs`,children:p.isPending?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(T,{className:`w-3 h-3 mr-1 animate-spin`}),(0,Q.jsx)(B,{id:`diff.committing`})]}):(0,Q.jsx)(B,{id:`diff.commit`})}),(0,Q.jsx)(q,{onClick:()=>{C()},disabled:m.isPending,variant:`outline`,size:`sm`,className:`h-7 text-xs`,children:m.isPending?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(T,{className:`w-3 h-3 mr-1 animate-spin`}),(0,Q.jsx)(B,{id:`diff.pushing`})]}):(0,Q.jsx)(B,{id:`diff.push`})}),(0,Q.jsx)(q,{onClick:()=>{w()},disabled:D||h.isPending,variant:`secondary`,size:`sm`,className:`h-7 text-xs`,children:h.isPending?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(T,{className:`w-3 h-3 mr-1 animate-spin`}),(0,Q.jsx)(B,{id:`diff.committing.pushing`})]}):(0,Q.jsx)(B,{id:`diff.commit.push`})})]})]})]}),(0,Q.jsx)(`div`,{className:`p-2 space-y-1`,children:a.map(t=>{let n=_.get(t.filePath);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(ct,{checked:s.get(t.filePath)??!1,onCheckedChange:()=>v(t.filePath),disabled:p.isPending,className:`h-3 w-3 flex-shrink-0`}),(0,Q.jsx)(rd,{projectId:e,filePath:t.filePath,status:t.status,additions:t.additions,deletions:t.deletions,diffHunks:n?.hunks,children:(0,Q.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-1.5 py-1.5 text-xs hover:bg-muted/30 rounded-md transition-colors text-left`,"data-testid":`git-file-button`,children:[(0,Q.jsx)(`span`,{className:J(`w-1.5 h-1.5 rounded-full flex-shrink-0`,t.status===`added`&&`bg-green-500`,t.status===`deleted`&&`bg-red-500`,t.status===`modified`&&`bg-amber-500`,t.status===`renamed`&&`bg-blue-500`)}),(0,Q.jsx)(`span`,{className:`truncate flex-1 font-mono`,children:t.filePath}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[t.additions>0&&(0,Q.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,t.additions]}),t.deletions>0&&(0,Q.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`-`,t.deletions]})]})]})})]},t.filePath)})})]}):(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,Q.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,Q.jsx)(`div`,{className:`w-12 h-12 mx-auto rounded-xl bg-muted/30 flex items-center justify-center`,children:(0,Q.jsx)(An,{className:`w-6 h-6 text-muted-foreground/50`})}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:(0,Q.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:(0,Q.jsx)(B,{id:`panel.git.empty`})})})]})})},od=({projectId:e,sessionId:t})=>{let{conversations:n}=Du(e,t);return(0,Q.jsx)(ku,{todos:(0,Z.useMemo)(()=>Ws(n),[n])})},sd=({projectId:e,sessionId:t})=>{let{session:n}=Du(e,t),r=n.meta.prLinks;return r.length===0?null:(0,Q.jsx)(`div`,{className:`border-t border-border/40`,children:(0,Q.jsxs)(`div`,{className:`px-3 py-2 bg-muted/10`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,Q.jsx)(jn,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:(0,Q.jsx)(B,{id:`panel.git.pr_links`})})]}),(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:r.map(e=>(0,Q.jsxs)(`a`,{href:e.prUrl,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-muted/50 transition-colors group text-xs`,children:[(0,Q.jsx)(jn,{className:`w-3.5 h-3.5 text-emerald-500 flex-shrink-0`}),(0,Q.jsxs)(`span`,{className:`flex-1 min-w-0 truncate text-foreground`,children:[e.prRepository,`#`,e.prNumber]}),(0,Q.jsx)(Sn,{className:`w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0`})]},`${e.prRepository}#${e.prNumber}`))})]})})},cd=({projectId:e,sessionId:t})=>{let n=N(),r=cr({predicate:t=>t.queryKey[0]===`git`&&t.queryKey.includes(e)})>0,i=(0,Z.useCallback)(()=>{n.invalidateQueries({queryKey:j(e).queryKey}),n.invalidateQueries({queryKey:S(e).queryKey}),n.invalidateQueries({queryKey:[`git`,`diff`,e]})},[n,e]);return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-border/40 px-3 py-2 bg-muted/10 flex items-center gap-1`,children:[(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(td,{}),children:(0,Q.jsx)(nd,{projectId:e})}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 flex-shrink-0`,onClick:i,disabled:r,children:(0,Q.jsx)(kt,{className:J(`w-3.5 h-3.5 text-muted-foreground`,r&&`animate-spin`)})})]}),(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(id,{}),children:(0,Q.jsx)(ad,{projectId:e})})}),t!==void 0&&t!==``&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(sd,{projectId:e,sessionId:t})}),t!==void 0&&t!==``&&(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(od,{projectId:e,sessionId:t})})]})},ld=ge(R(),R()),ud=({projectId:e,sessionId:t})=>`${e}:${t}`,dd=(e,t)=>{let n=ld.safeParse(e);return n.success?n.data:t},fd=(e,t,n)=>{if(n===``){let{[t]:n,...r}=e;return r}return{...e,[t]:n}},pd=Da(()=>localStorage),md=ka(`claude-code-viewer-chat-input-drafts`,{},{getItem:(e,t)=>dd(pd.getItem(e,t),t),setItem:(e,t)=>pd.setItem(e,t),removeItem:e=>pd.removeItem(e)}),hd=e=>{let[t,n]=p(md),r=ud(e);return[t[r]??``,(0,Z.useCallback)(e=>{n(t=>{let n=t[r]??``;return fd(t,r,typeof e==`function`?e(n):e)})},[r,n]),(0,Z.useCallback)(()=>{n(e=>fd(e,r,``))},[r,n])]},gd=({projectId:e,sessionId:t})=>{let{conversations:n}=Du(e,t);return(0,Q.jsx)(ku,{todos:(0,Z.useMemo)(()=>Ws(n),[n])})},_d=({summary:e,className:t})=>(0,Q.jsx)(`div`,{className:J(`bg-gray-50 dark:bg-gray-800 rounded-lg p-2 border border-gray-200 dark:border-gray-700`,t),children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Tn,{className:`h-4 w-4 text-gray-600 dark:text-gray-400`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[e.filesChanged,` `,(0,Q.jsx)(B,{id:`diff.files.changed`})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.insertions>0&&(0,Q.jsxs)(`span`,{className:`text-green-600 dark:text-green-400 font-medium`,children:[`+`,e.insertions]}),e.deletions>0&&(0,Q.jsxs)(`span`,{className:`text-red-600 dark:text-red-400 font-medium`,children:[`-`,e.deletions]})]})]})}),vd=({label:e,value:t,onValueChange:n,refs:r})=>{let i=(0,Z.useId)(),a=e=>{switch(e){case`branch`:return(0,Q.jsx)(kn,{className:`h-4 w-4`});case`commit`:return(0,Q.jsx)(`span`,{className:`text-xs`,children:`📝`});case`head`:return(0,Q.jsx)(kn,{className:`h-4 w-4`});case`working`:return(0,Q.jsx)(`span`,{className:`text-xs`,children:`🚧`});default:return(0,Q.jsx)(kn,{className:`h-4 w-4`})}};return(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,Q.jsxs)(ic,{value:t,onValueChange:n,children:[(0,Q.jsx)(oc,{className:`w-full h-8 text-xs`,children:(0,Q.jsx)(ac,{})}),(0,Q.jsx)(lc,{id:i,children:r.map(e=>(0,Q.jsx)($,{value:e.name,className:`text-xs`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a(e.type),(0,Q.jsx)(`span`,{children:e.displayName}),e.sha!==void 0&&e.sha!==``&&(0,Q.jsx)(`span`,{className:`text-[10px] text-gray-500 dark:text-gray-400 font-mono`,children:e.sha.substring(0,7)})]})},e.name))})]})]})},yd=({projectId:e,sessionId:t})=>{let{i18n:n}=V(),[r,i]=(0,Z.useState)(`HEAD`),[a,o]=(0,Z.useState)(`working`),{comments:s,clearComments:c}=Vc(t??``),[,l]=hd({projectId:e,sessionId:t??``}),{data:u,isLoading:d}=Ku(e),{mutate:f,data:p,isPending:m,error:h}=Zu(),g=u?.success===!0?u.data:void 0,_=p?.success===!0?p.data:void 0,v=(e,t,n)=>({name:`branch:${e}`,type:`branch`,displayName:t,sha:n}),y=(e,t)=>({name:`commit:${e}`,type:`commit`,displayName:t,sha:e}),b=g===void 0?[]:[{name:`working`,type:`working`,displayName:n._(`Uncommitted changes`)},{name:`HEAD`,type:`head`,displayName:`HEAD`,...g.head===null?{}:{sha:g.head}},...g.baseBranch===null?[]:[v(g.baseBranch.name,`${g.baseBranch.name} (base)`,g.baseBranch.commit)],...g.currentBranch===null?[]:[v(g.currentBranch.name,`${g.currentBranch.name} (current)`,g.currentBranch.commit)],...g.commits.map(e=>y(e.sha,`${e.message.substring(0,50)}${e.message.length>50?`...`:``}`))],x=(0,Z.useCallback)(()=>{r.length>0&&a.length>0&&r!==a&&f({projectId:e,fromRef:r,toRef:a})},[r,a,f,e]);return(0,Z.useEffect)(()=>{r.length>0&&a.length>0&&x()},[r,a,x]),d?(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,Q.jsx)(T,{className:`w-5 h-5 animate-spin text-muted-foreground`})}),t!==void 0&&t!==``?(0,Q.jsx)(gd,{projectId:e,sessionId:t}):(0,Q.jsx)(ku,{todos:null})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsxs)(`div`,{className:`p-3 border-b border-border/40 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1`,children:(0,Q.jsx)(vd,{label:n._(`Compare from`),value:r,onValueChange:i,refs:b.filter(e=>e.name!==`working`)})}),(0,Q.jsx)(`div`,{className:`flex-1`,children:(0,Q.jsx)(vd,{label:n._(`Compare to`),value:a,onValueChange:o,refs:b})})]}),(0,Q.jsx)(q,{onClick:x,disabled:m||r===a,size:`sm`,className:`w-full h-7 text-xs`,children:m?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(T,{className:`w-3 h-3 mr-1.5 animate-spin`}),(0,Q.jsx)(B,{id:`common.loading`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Yn,{className:`w-3 h-3 mr-1.5`}),`Refresh`]})})]}),(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[h&&(0,Q.jsx)(`div`,{className:`m-3 bg-red-50 dark:bg-red-900/10 border border-red-200 dark:border-red-800 rounded-lg p-3`,children:(0,Q.jsx)(`p`,{className:`text-red-600 dark:text-red-400 text-xs`,children:h.message})}),_===void 0&&!m&&h===null&&(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,Q.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,Q.jsx)(`div`,{className:`w-12 h-12 mx-auto rounded-xl bg-muted/30 flex items-center justify-center`,children:(0,Q.jsx)(An,{className:`w-6 h-6 text-muted-foreground/50`})}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:(0,Q.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:(0,Q.jsx)(B,{id:`panel.review.empty`})})})]})}),_!==void 0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`sticky top-0 z-30 flex items-center justify-between border-b border-border/40 bg-background/95 px-3 py-2 backdrop-blur-sm`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.length===0?n._(`review.comments.empty`):n._(`review.comments.count`,{count:s.length})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,disabled:s.length===0,onClick:()=>{c(),z.success(n._(`review.action.reset.success`))},className:`h-7 text-xs`,children:[(0,Q.jsx)(nr,{className:`w-3 h-3 mr-1`}),(0,Q.jsx)(B,{id:`review.action.reset`})]}),(0,Q.jsxs)(q,{variant:`default`,size:`sm`,disabled:s.length===0,onClick:()=>{let e=Hc(s,r,a);l(t=>t?`${t}\n\n${e}`:e),z.success(n._(`review.action.insert.success`))},className:`h-7 text-xs`,children:[(0,Q.jsx)(gn,{className:`w-3 h-3 mr-1`}),(0,Q.jsx)(B,{id:`review.action.insert`})]})]})]}),(0,Q.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Q.jsx)(_d,{summary:{filesChanged:_.files.length,insertions:_.summary.totalAdditions,deletions:_.summary.totalDeletions}}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:_.diffs.map(e=>(0,Q.jsx)(tl,{fileDiff:{filename:e.file.filePath,oldFilename:e.file.oldPath,isNew:e.file.status===`added`,isDeleted:e.file.status===`deleted`,isRenamed:e.file.status===`renamed`,isBinary:!1,hunks:e.hunks,linesAdded:e.file.additions,linesDeleted:e.file.deletions},filename:e.file.filePath,reviewSessionId:t},e.file.filePath))})]})]}),m&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Q.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,Q.jsx)(T,{className:`w-6 h-6 animate-spin mx-auto text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(B,{id:`diff.loading`})})]})})]}),t!==void 0&&t!==``?(0,Q.jsx)(gd,{projectId:e,sessionId:t}):(0,Q.jsx)(ku,{todos:null})]})},bd={sm:`w-4 h-4`,default:`w-8 h-8`,lg:`w-12 h-12`},xd={sm:`text-sm`,default:`text-base`,lg:`text-lg`},Sd=({message:e,size:t=`default`,fullScreen:n=!0,className:r})=>{let i=(0,Q.jsxs)(`div`,{className:J(`flex flex-col items-center justify-center gap-3`,r),"data-testid":`loading-indicator`,children:[(0,Q.jsx)(T,{className:J(bd[t],`animate-spin text-primary`)}),e!==void 0&&e!==``&&(0,Q.jsx)(`p`,{className:J(xd[t],`text-muted-foreground font-medium`),children:e})]});return n?(0,Q.jsx)(`div`,{className:`flex items-center justify-center w-full h-full min-h-[400px]`,children:i}):i},Cd=48,wd=200,Td=({children:e,className:t})=>{let{isLeftPanelOpen:n,leftPanelWidth:r}=Ga(),{setLeftPanelWidth:i}=Ka(),a=fs(),{isResizing:o,handleMouseDown:s}=ls({onResize:(0,Z.useCallback)(e=>{i(e.clientX/window.innerWidth*100)},[i])}),c=(0,Z.useCallback)(e=>{let t=e.shiftKey?5:1;e.key===`ArrowLeft`&&(e.preventDefault(),i(Math.max(0,r-t))),e.key===`ArrowRight`&&(e.preventDefault(),i(Math.min(50,r+t)))},[r,i]);if((0,Z.useEffect)(()=>(o?(document.body.style.userSelect=`none`,document.body.style.cursor=`ew-resize`,document.body.style.pointerEvents=`none`):(document.body.style.userSelect=``,document.body.style.cursor=``,document.body.style.pointerEvents=``),()=>{document.body.style.userSelect=``,document.body.style.cursor=``,document.body.style.pointerEvents=``}),[o]),a)return null;let l=n?`${r}%`:`${Cd}px`,u=n?`${Cd+wd}px`:`${Cd}px`;return(0,Q.jsxs)(`div`,{className:J(`relative flex-shrink-0 h-full flex overflow-hidden transition-all duration-200`,t),style:{width:l,minWidth:u,maxWidth:n?`50%`:`${Cd}px`,userSelect:o?`none`:`auto`},children:[(0,Q.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:e}),n&&(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":0,"aria-valuemax":50,"aria-valuenow":r,tabIndex:0,className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-ew-resize hover:bg-primary/40 active:bg-primary transition-colors z-10`,style:{pointerEvents:`auto`},onMouseDown:s,onKeyDown:c})]})},Ed=({startX:e,startY:t,endX:n,endY:r,threshold:i,maxVerticalRatio:a,edgeWidth:o})=>{let s=n-e,c=r-t,l=Math.abs(s);if(l<i||l>0&&Math.abs(c)/l>a)return null;let u=s>0?`right`:`left`;return u===`right`&&o!==void 0&&e>=o?null:u},Dd=e=>{let t=e.changedTouches[0];if(t)return{clientX:t.clientX,clientY:t.clientY}},Od=({onSwipe:e,threshold:t=50,maxVerticalRatio:n=.75,edgeWidth:r,enabled:i=!0})=>{let a=(0,Z.useRef)(null),o=(0,Z.useRef)(null),s=(0,Z.useRef)(e);s.current=e;let c=(0,Z.useCallback)(e=>{if(o.current?.(),o.current=null,!e||!i)return;let c=e=>{let t=Dd(e);t&&(a.current={x:t.clientX,y:t.clientY})},l=e=>{let i=a.current;if(a.current=null,!i)return;let o=Dd(e);if(!o)return;let c=Ed({startX:i.x,startY:i.y,endX:o.clientX,endY:o.clientY,threshold:t,maxVerticalRatio:n,edgeWidth:r});c&&s.current(c)},u=()=>{a.current=null};e.addEventListener(`touchstart`,c,{passive:!0}),e.addEventListener(`touchend`,l,{passive:!0}),e.addEventListener(`touchcancel`,u,{passive:!0}),o.current=()=>{e.removeEventListener(`touchstart`,c),e.removeEventListener(`touchend`,l),e.removeEventListener(`touchcancel`,u)}},[i,t,n,r]);return(0,Z.useEffect)(()=>()=>{o.current?.(),o.current=null},[]),c},kd=()=>{let e=E(),t=Pt.useNavigate(),n=Pt.useSearch(),r=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{n.leftPanel!==void 0&&(r.current=!0,e.set(Ba,n.leftPanel),r.current=!1)},[n.leftPanel,e]),(0,Z.useEffect)(()=>{let n=e.sub(Ba,()=>{if(r.current)return;let n=e.get(Ba);t({search:e=>({...e,leftPanel:n}),replace:!0})});return()=>{n()}},[e,t])},Ad=(e,t)=>e===void 0?!1:e,jd=()=>{let e=E(),t=Pt.useNavigate(),n=Pt.useSearch(),r=(0,Z.useRef)(!1),i=(0,Z.useRef)(!1),a=fs(),o=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{r.current=!0;let t=o.current?a:us();n.rightPanel===void 0?e.get(ja).status===`unset`&&e.set(Ma,Ad(void 0,t)):e.set(Ma,n.rightPanel),n.rightPanelTab!==void 0&&e.set(Na,n.rightPanelTab),o.current=!0,r.current=!1},[n.rightPanel,n.rightPanelTab,e,a]),(0,Z.useEffect)(()=>{let n=e.sub(Ma,()=>{if(r.current)return;i.current=!0;let n=e.get(Ma);t({search:e=>({...e,rightPanel:n}),replace:!0}),queueMicrotask(()=>{i.current=!1})}),a=e.sub(Na,()=>{if(r.current)return;i.current=!0;let n=e.get(Na);t({search:e=>({...e,rightPanelTab:n}),replace:!0}),queueMicrotask(()=>{i.current=!1})});return()=>{n(),a()}},[e,t])},Md=e=>sr({queryKey:te(e).queryKey,queryFn:async({pageParam:t})=>await te(e,t).queryFn(),initialPageParam:void 0,getNextPageParam:e=>e.nextCursor,refetchOnReconnect:!0}),Nd=(e,t,n)=>[...e.values()].filter(e=>e.projectId===t&&!n.has(e.sessionId)).map(e=>({id:e.sessionId,jsonlFilePath:``,lastModifiedAt:e.sentAt,createdAt:e.sentAt,meta:{messageCount:0,firstUserMessage:{kind:`text`,content:e.userMessage},customTitle:null,cost:{totalUsd:0,breakdown:{inputTokensUsd:0,outputTokensUsd:0,cacheCreationUsd:0,cacheReadUsd:0},tokenUsage:{inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0}},modelName:null,prLinks:[]}})),Pd={all:[`scheduler`],jobs:()=>[...Pd.all,`jobs`],job:e=>[...Pd.all,`job`,e]},Fd=()=>le({queryKey:Pd.jobs(),queryFn:async()=>{let e=await o.api.scheduler.jobs.$get();if(!e.ok)throw Error(`Failed to fetch scheduler jobs`);return e.json()}}),Id=()=>{let e=N();return m({mutationFn:async e=>{let t=await o.api.scheduler.jobs.$post({json:e});if(!t.ok)throw Error(`Failed to create scheduler job`);return t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:Pd.jobs()})}})},Ld=()=>{let e=N();return m({mutationFn:async({id:e,updates:t})=>{let n=await o.api.scheduler.jobs[`:id`].$patch({param:{id:e},json:t});if(!n.ok)throw n.status===404?Error(`Job not found`):Error(`Failed to update scheduler job`);return n.json()},onSuccess:t=>{e.invalidateQueries({queryKey:Pd.job(t.id)}),e.invalidateQueries({queryKey:Pd.jobs()})}})},Rd=()=>{let e=N();return m({mutationFn:async e=>{let t=await o.api.scheduler.jobs[`:id`].$delete({param:{id:e}});if(!t.ok)throw t.status===404?Error(`Job not found`):Error(`Failed to delete scheduler job`);return t.json()},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:Pd.job(n)}),e.invalidateQueries({queryKey:Pd.jobs()})}})},zd=ka(`claude-code-viewer-notification-settings`,{soundType:`none`}),Bd=d(e=>e(zd).soundType!==`none`),Vd={beep:{frequency:[800],duration:.15,type:`sine`,volume:.3},chime:{frequency:[523,659,784],duration:.4,type:`sine`,volume:.2},ping:{frequency:[1e3],duration:.1,type:`triangle`,volume:.4},pop:{frequency:[400,600],duration:.08,type:`square`,volume:.2}},Hd=e=>{if(e!==`none`)try{let t=Vd[e],n=window.AudioContext??window.webkitAudioContext;if(n===void 0)return;let r=new n;t.frequency.forEach((e,n)=>{let i=r.createOscillator(),a=r.createGain();i.connect(a),a.connect(r.destination),i.frequency.setValueAtTime(e,r.currentTime),i.type=t.type;let o=r.currentTime+n*.05;a.gain.setValueAtTime(t.volume,o),a.gain.exponentialRampToValueAtTime(.01,o+t.duration),i.start(o),i.stop(o+t.duration)})}catch(e){console.warn(`Failed to play notification sound:`,e)}},Ud=e=>({none:(0,Q.jsx)(B,{id:`notification.none`}),beep:(0,Q.jsx)(B,{id:`notification.beep`}),chime:(0,Q.jsx)(B,{id:`notification.chime`}),ping:(0,Q.jsx)(B,{id:`notification.ping`}),pop:(0,Q.jsx)(B,{id:`notification.pop`})})[e],Wd=()=>[`none`,`beep`,`chime`,`ping`,`pop`],Gd=(e,t)=>{let n=D(zd),r=D(Bd),i=D(Ot),o=a(Ot),s=(0,Z.useRef)(e),c=(0,Z.useRef)(t);c.current!==t&&(c.current=t,s.current=e),(0,Z.useEffect)(()=>{let a=s.current;if(s.current=e,a&&!e){if(i.has(t)){o(e=>{let n=new Set(e);return n.delete(t),n});return}z.success(`Task completed`),r&&Hd(n.soundType)}},[e,r,n.soundType,i,t,o])},Kd=e=>e.replace(/<local-command-caveat>[\s\S]*?<\/local-command-caveat>/g,``).trim(),qd=(e,t,n)=>e??(t?Jd(t):n),Jd=e=>{switch(e.kind){case`command`:return e.commandArgs===void 0?e.commandName:`${e.commandName} ${e.commandArgs}`;case`local-command`:return Kd(e.stdout);case`text`:return Kd(e.content);default:throw Error(`Invalid first command`)}},Yd=()=>m({mutationFn:async e=>{let t=await o.api.projects[`:projectId`].sessions[`:sessionId`].export.$get({param:{projectId:e.projectId,sessionId:e.sessionId}});if(!t.ok)throw Error(t.statusText);return await t.json()},onSuccess:(e,t)=>{let n=t.sessionId.replace(/[^a-zA-Z0-9._-]/g,`_`)||`unknown`,r=new File([e.html],`ccv-html-export-${n}.html`,{type:`text/html`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=r.name,a.rel=`noopener`,a.target=`_self`,a.style.display=`none`,document.body.appendChild(a),a.click(),setTimeout(()=>{URL.revokeObjectURL(i),a.remove()},1e3)}}),Xd=()=>{let e=D(Dt);return{sessionProcesses:e,getSessionProcess:(0,Z.useCallback)(t=>e.find(e=>e.sessionId===t),[e])}},Zd=({isPending:e=!1,onScrollToTop:t,onScrollToBottom:n})=>{let{i18n:r}=V();return(0,Q.jsx)(`div`,{className:`px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 mb-1`,children:(0,Q.jsxs)(`div`,{className:`py-0 flex items-center gap-1.5 flex-wrap`,children:[t&&(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,disabled:e,className:`h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40`,title:r._({id:`control.scroll_to_top`,message:`Scroll to Top`}),children:(0,Q.jsx)(an,{className:`w-3.5 h-3.5`})}),n&&(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:n,disabled:e,className:`h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40`,title:r._({id:`control.scroll_to_bottom`,message:`Scroll to Bottom`}),children:(0,Q.jsx)(nn,{className:`w-3.5 h-3.5`})})]})})},Qd=()=>{let e=N();return m({mutationFn:async({projectId:e,sessionId:t})=>{let n=await o.api.projects[`:projectId`].sessions[`:sessionId`].$delete({param:{projectId:e,sessionId:t}});if(!n.ok)throw n.status===404?Error(`Session not found`):Error(`Failed to delete session`);return n.json()},onSuccess:(t,{projectId:n})=>{e.invalidateQueries({queryKey:te(n).queryKey})}})},$d=({open:e,onOpenChange:t,projectId:n,sessionId:r,sessionTitle:i,onSuccess:a})=>{let{i18n:o}=V(),s=Qd();return(0,Q.jsx)(Pe,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Le,{className:`max-w-2xl max-h-[80vh] overflow-auto`,children:[(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Te,{children:(0,Q.jsx)(B,{id:`session.delete_dialog.title`})}),(0,Q.jsx)(we,{className:`break-words line-clamp-10`,children:(0,Q.jsx)(B,{id:`session.delete_dialog.description`,values:{title:i}})})]}),(0,Q.jsxs)(Me,{children:[(0,Q.jsx)(q,{variant:`outline`,onClick:()=>{t(!1)},disabled:s.isPending,children:(0,Q.jsx)(B,{id:`common.cancel`})}),(0,Q.jsx)(q,{variant:`destructive`,onClick:()=>{s.mutate({projectId:n,sessionId:r},{onSuccess:()=>{z.success(o._({id:`session.delete.success`,message:`Session deleted successfully`})),t(!1),a?.()},onError:e=>{z.error(o._({id:`session.delete.failed`,message:`Failed to delete session`}),{description:e.message})}})},disabled:s.isPending,children:s.isPending?(0,Q.jsx)(B,{id:`common.deleting`}):(0,Q.jsx)(B,{id:`common.delete`})})]})]})})},ef=e=>{if(e===`running`)return{labelId:`session.status.running`,className:`bg-green-500/10 text-green-700 dark:text-green-300 border-green-500/20`,icon:`running`};if(e===`paused`)return{labelId:`session.status.paused`,className:`bg-orange-500/10 text-orange-700 dark:text-orange-300 border-orange-500/20`,icon:`paused`}},tf=e=>e.sessionId===void 0||e.sessionId===``?(0,Q.jsx)(rf,{...e,sessionData:null,onMobileMenuOpen:e.onMobileMenuOpen}):(0,Q.jsx)(nf,{...e,sessionId:e.sessionId}),nf=e=>{let t=Du(e.projectId,e.sessionId);return(0,Q.jsx)(rf,{...e,sessionId:e.sessionId,sessionData:t,onMobileMenuOpen:e.onMobileMenuOpen})},rf=({projectId:e,sessionId:t,projectPath:n,sessionData:r,onMobileMenuOpen:i})=>{let a=y(),s=r?.conversations,c=s?.length??0,l=t!==void 0&&t!==``,u=n!==void 0&&n!==``,d=r?.getToolResult??(()=>void 0),f=l&&r!=null,{data:p}=Ku(e),h=p?.success===!0?p.data.currentBranch?.name:void 0,g=h!==void 0&&h!==``,_=Yd(),{data:v}=Fd(),{data:b}=Md(e),x=D(Dt),S=D(xu),{config:C}=fe(),w=(0,Z.useMemo)(()=>{let t=b.pages.flatMap(e=>e.sessions),n=Nd(S,e,new Set(t.map(e=>e.id)));return[...t,...n]},[b.pages,e,S]),T=(0,Z.useMemo)(()=>(s??[]).some(e=>e.type!==`user`||typeof e.message.content!=`string`?!1:qs(e.message.content).kind===`local-command`),[s]),E=(0,Z.useMemo)(()=>[...w].sort((e,t)=>{let n=x.find(t=>t.sessionId===e.id),r=x.find(e=>e.sessionId===t.id),i=n?.status,a=r?.status,o=e=>e===`running`?0:e===`paused`?1:2,s=o(i),c=o(a);if(s!==c)return s-c;let l=e.createdAt??e.lastModifiedAt,u=t.createdAt??t.lastModifiedAt,d=l?new Date(l).getTime():0;return(u?new Date(u).getTime():0)-d}),[w,x]),O=Xd(),k=(0,Z.useMemo)(()=>{if(l)return O.getSessionProcess(t)},[l,t,O]),A=k?.status===`running`&&T?`paused`:k?.status,j=ef(A);Gd(A===`running`,t??``);let M=(0,Z.useMemo)(()=>!l||v===void 0?[]:v.filter(n=>n.message.resume&&n.message.sessionId===t&&n.message.projectId===e&&n.schedule.type===`reserved`&&n.lastRunStatus===null),[v,l,e,t]),[ee,te]=(0,Z.useState)(0),[N,P]=(0,Z.useState)(!1),F=(0,Z.useRef)(null),ne=(0,Z.useRef)(null),re=(0,Z.useRef)(!0),ie=(0,Z.useRef)(!1),ae=(0,Z.useCallback)(e=>{let t=F.current;if(t!==null){if(t.scrollTo({top:t.scrollHeight,behavior:`auto`}),e<=0){ne.current=null;return}ne.current=window.requestAnimationFrame(()=>{ae(e-1)})}},[]),oe=m({mutationFn:async t=>{let n=await o.api[`claude-code`][`session-processes`][`:sessionProcessId`].abort.$post({param:{sessionProcessId:t},json:{projectId:e}});if(!n.ok)throw Error(n.statusText);return n.json()}});(0,Z.useEffect)(()=>{if(f&&A===`running`&&c!==ee){if(!re.current){te(c);return}te(c),ae(6)}},[c,f,A,ee,ae]);let I=()=>{let e=F.current;e!==null&&e.scrollTo({top:0,behavior:`auto`})},se=()=>{ne.current!==null&&(window.cancelAnimationFrame(ne.current),ne.current=null),ae(8)};(0,Z.useEffect)(()=>()=>{ne.current!==null&&window.cancelAnimationFrame(ne.current)},[]),(0,Z.useEffect)(()=>{let e=F.current;if(e===null)return;let t=()=>{re.current=e.scrollHeight-e.scrollTop-e.clientHeight<=150};return e.addEventListener(`scroll`,t,{passive:!0}),()=>{e.removeEventListener(`scroll`,t)}},[]),(0,Z.useEffect)(()=>{if(t===void 0)return;let e=S.has(t);e&&!ie.current&&ae(6),ie.current=e},[S,t,ae]),(0,Z.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`||A!==`running`||!k||oe.isPending)return;let t=document.activeElement,n=t?.tagName?.toLowerCase();n===`input`||n===`textarea`||t?.getAttribute(`contenteditable`)===`true`||oe.mutate(k.id)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[A,k,oe]);let ce=qd(r?.session.meta.customTitle??null,r?.session.meta.firstUserMessage??null,t??``),le=()=>{if(r==null||!l)return;let e=t.replace(/[^a-zA-Z0-9._-]/g,`_`)||`unknown`,n=r.conversations.map(e=>e.type===`x-error`?e.line:JSON.stringify(e)).join(`
|
|
13
|
+
`),i=new File([n],`ccv-jsonl-export-${e}.jsonl`,{type:`application/x-ndjson`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=i.name,o.rel=`noopener`,o.target=`_self`,o.style.display=`none`,document.body.appendChild(o),o.click(),setTimeout(()=>{URL.revokeObjectURL(a),o.remove()},1e3)},ue=async()=>{let e=r?.session.jsonlFilePath;if(!(e===void 0||e===``))try{await navigator.clipboard.writeText(e),z.success(`Session file path copied`)}catch(e){console.error(`Failed to copy session file path:`,e),z.error(`Failed to copy session file path`)}},L=(0,Q.jsx)(B,{id:`chat.history.title`});return f&&l&&(L=ce),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 min-w-0`,children:[(0,Q.jsx)(`header`,{className:`px-2 sm:px-3 py-1.5 sm:py-2 sticky top-0 z-10 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80 w-full flex-shrink-0 min-w-0 border-b border-border/40`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[i&&(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`flex-shrink-0 h-7 w-7 p-0 md:hidden`,onClick:i,"aria-label":`Open menu`,children:(0,Q.jsx)(Bn,{className:`w-4 h-4`})}),j&&(0,Q.jsxs)(U,{variant:`secondary`,className:J(`h-5 text-[10px] px-1.5 flex-shrink-0`,j.className),children:[j.icon===`running`?(0,Q.jsx)(Rn,{className:`w-2.5 h-2.5 mr-0.5 animate-spin`}):(0,Q.jsx)(qn,{className:`w-2.5 h-2.5 mr-0.5`}),(0,Q.jsx)(B,{id:j.labelId})]}),(0,Q.jsx)(`h1`,{className:`text-sm sm:text-base font-semibold break-all overflow-ellipsis line-clamp-1 min-w-0 text-foreground/90`,children:L})]}),f&&(0,Q.jsxs)(et,{children:[(0,Q.jsx)(ft,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`flex-shrink-0 h-7 w-7 p-0`,"aria-label":`Open session menu`,children:(0,Q.jsx)(xn,{className:`w-4 h-4`})})}),(0,Q.jsx)(at,{className:`w-80`,align:`end`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Actions`}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`justify-start`,onClick:()=>_.mutate({projectId:e,sessionId:t}),disabled:_.isPending,children:[(0,Q.jsx)(bn,{className:`w-4 h-4 mr-2 ${_.isPending?`animate-pulse`:``}`}),(0,Q.jsx)(B,{id:`session.menu.export_html`})]}),(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`justify-start`,onClick:le,children:[(0,Q.jsx)(bn,{className:`w-4 h-4 mr-2`}),(0,Q.jsx)(B,{id:`session.menu.export_jsonl`})]}),r?.session.jsonlFilePath!==void 0&&r.session.jsonlFilePath!==``&&(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`justify-start`,onClick:()=>{ue()},children:[(0,Q.jsx)(yn,{className:`w-4 h-4 mr-2`}),(0,Q.jsx)(B,{id:`session.menu.copy_session_path`})]}),(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`justify-start text-destructive hover:text-destructive`,onClick:()=>P(!0),children:[(0,Q.jsx)(rr,{className:`w-4 h-4 mr-2`}),(0,Q.jsx)(B,{id:`session.delete_dialog.title`})]})]})]}),(0,Q.jsx)(`div`,{className:`h-px bg-border/60`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`font-semibold text-sm mb-2`,children:(0,Q.jsx)(B,{id:`control.metadata`})}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[u&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(B,{id:`control.project_path`})}),(0,Q.jsx)(U,{variant:`secondary`,className:`h-7 text-xs flex items-center w-fit break-all`,children:n})]}),g&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(B,{id:`control.branch`})}),(0,Q.jsxs)(U,{variant:`secondary`,className:`h-7 text-xs flex items-center gap-1 w-fit`,children:[(0,Q.jsx)(kn,{className:`w-3 h-3`}),h]})]}),f&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(B,{id:`control.session_id`})}),(0,Q.jsx)(U,{variant:`secondary`,className:`h-7 text-xs flex items-center w-fit font-mono break-all`,children:t})]}),f&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(B,{id:`control.model`})}),(0,Q.jsx)(U,{variant:`secondary`,className:`h-7 text-xs flex items-center w-fit font-mono`,children:r.session.meta.modelName??`Unknown`})]}),f&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(B,{id:`session.cost.label`})}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(U,{variant:`secondary`,className:`h-7 text-xs flex items-center w-fit font-semibold`,children:[(0,Q.jsx)(B,{id:`session.cost.total`}),`: $`,r.session.meta.cost.totalUsd.toFixed(3)]}),(0,Q.jsxs)(`div`,{className:`text-xs space-y-1 pl-2`,children:[(0,Q.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,Q.jsx)(B,{id:`session.cost.input_tokens`}),`:`]}),(0,Q.jsxs)(`span`,{children:[`$`,r.session.meta.cost.breakdown.inputTokensUsd.toFixed(3),` `,`(`,r.session.meta.cost.tokenUsage.inputTokens.toLocaleString(),`)`]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,Q.jsx)(B,{id:`session.cost.output_tokens`}),`:`]}),(0,Q.jsxs)(`span`,{children:[`$`,r.session.meta.cost.breakdown.outputTokensUsd.toFixed(3),` `,`(`,r.session.meta.cost.tokenUsage.outputTokens.toLocaleString(),`)`]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,Q.jsx)(B,{id:`session.cost.cache_creation`}),`:`]}),(0,Q.jsxs)(`span`,{children:[`$`,r.session.meta.cost.breakdown.cacheCreationUsd.toFixed(3),` `,`(`,r.session.meta.cost.tokenUsage.cacheCreationTokens.toLocaleString(),`)`]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,Q.jsx)(B,{id:`session.cost.cache_read`}),`:`]}),(0,Q.jsxs)(`span`,{children:[`$`,r.session.meta.cost.breakdown.cacheReadUsd.toFixed(3),` `,`(`,r.session.meta.cost.tokenUsage.cacheReadTokens.toLocaleString(),`)`]})]})]})]})]})]})]})]})})]})]})}),(0,Q.jsx)(`div`,{ref:F,className:`flex-1 overflow-y-auto min-h-0 min-w-0`,"data-testid":`scrollable-content`,children:(0,Q.jsxs)(`main`,{className:`w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 relative min-w-0 pb-4`,children:[(0,Q.jsx)(vu,{conversations:f?s??[]:[],getToolResult:d,projectId:e,sessionId:t??``,scheduledJobs:M,scrollContainerRef:F,enableInPageSearch:!0}),!f&&(E.length>0?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:E.slice(0,5).map(t=>{let n=qd(t.meta.customTitle,t.meta.firstUserMessage,t.id),r=x.find(e=>e.sessionId===t.id),i=r?.status===`running`,a=r?.status===`paused`;return(0,Q.jsxs)(ve,{to:`/projects/$projectId/session`,params:{projectId:e},search:{sessionId:t.id},className:J(`block p-3 rounded-lg transition-colors border`,`border-border/40 hover:bg-muted/50 hover:border-primary/30`),children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-1 min-w-0`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium line-clamp-1 flex-1 min-w-0 break-all`,children:n}),(i||a)&&(0,Q.jsx)(U,{variant:`secondary`,className:J(`text-[10px] px-1.5 h-4 shrink-0`,i&&`bg-green-500/10 text-green-600 dark:text-green-400`,a&&`bg-yellow-500/10 text-yellow-600 dark:text-yellow-400`),children:i?(0,Q.jsx)(B,{id:`session.status.running`}):(0,Q.jsx)(B,{id:`session.status.paused`})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(ye,{className:`w-2.5 h-2.5`}),(0,Q.jsx)(`span`,{children:t.meta.messageCount})]}),(t.createdAt??t.lastModifiedAt)&&(0,Q.jsx)(`span`,{children:de(t.createdAt??t.lastModifiedAt,{locale:C.locale,target:`time`})})]})]},t.id)})}):(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,Q.jsx)(B,{id:`session.recent.empty`,message:`No sessions yet`})})),f&&A===`running`&&(0,Q.jsx)(`div`,{className:`flex justify-start items-center py-8 animate-in fade-in duration-500`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(Rn,{className:`w-8 h-8 animate-spin text-primary`}),(0,Q.jsx)(`div`,{className:`absolute inset-0 rounded-full bg-primary/20 animate-ping`})]}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground font-medium animate-pulse`,children:(0,Q.jsx)(B,{id:`session.processing`})})]})})]})}),f&&(0,Q.jsx)(`div`,{className:`w-full pt-3 pb-3`,children:(0,Q.jsx)(Zd,{onScrollToTop:I,onScrollToBottom:se})})]}),f&&(0,Q.jsx)($d,{open:N,onOpenChange:P,projectId:e,sessionId:t,sessionTitle:ce,onSuccess:()=>{a({to:`/projects/$projectId/session`,params:{projectId:e},search:{tab:`sessions`}})}})]})},af=()=>`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window,of=()=>af()?Notification.permission:`unsupported`,sf=({showLabels:e=!0,showDescriptions:t=!0,className:n=``})=>{let r=(0,Z.useId)(),[i,a]=p(zd),[o,s]=(0,Z.useState)(of),[c,l]=(0,Z.useState)(!1),u=(0,Z.useCallback)(e=>{a(t=>({...t,soundType:e}))},[a]),d=(0,Z.useCallback)(()=>{i.soundType!==`none`&&Hd(i.soundType)},[i.soundType]),f=(0,Z.useCallback)(()=>{l(!0),Nt().then(e=>{s(e)}).finally(()=>{l(!1)})},[]),m=Wd();return(0,Q.jsxs)(`div`,{className:`space-y-4 ${n}`,children:[o!==`unsupported`&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[e&&(0,Q.jsx)(`p`,{className:`text-sm font-medium leading-none`,children:(0,Q.jsx)(B,{id:`notification.push.label`})}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:o===`granted`?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,Q.jsx)(sn,{className:`w-3.5 h-3.5 text-primary`}),(0,Q.jsx)(`span`,{children:(0,Q.jsx)(B,{id:`notification.push.enabled`})})]}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:f,disabled:c,className:`gap-1.5`,children:[(0,Q.jsx)(it,{className:`w-3.5 h-3.5`}),(0,Q.jsx)(B,{id:`notification.push.enable`})]})]}):o===`denied`?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,Q.jsx)(on,{className:`w-3.5 h-3.5`}),(0,Q.jsx)(`span`,{children:(0,Q.jsx)(B,{id:`notification.push.denied`})})]}):(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:f,disabled:c,className:`gap-1.5`,children:[(0,Q.jsx)(it,{className:`w-3.5 h-3.5`}),(0,Q.jsx)(B,{id:`notification.push.enable`})]})})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[e&&(0,Q.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium leading-none`,children:`Task completion sound`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(ic,{value:i.soundType,onValueChange:u,children:[(0,Q.jsx)(oc,{id:r,className:`w-[180px]`,children:(0,Q.jsx)(ac,{placeholder:`音を選択`})}),(0,Q.jsx)(lc,{children:m.map(e=>(0,Q.jsx)($,{value:e,children:Ud(e)},e))})]}),i.soundType!==`none`&&(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:d,className:`px-3`,children:(0,Q.jsx)(B,{id:`notification.test`})})]}),t&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(B,{id:`notification.description`})})]})]})},cf=()=>{let{config:e}=fe();return e?.usageMode===`subscription`},lf=e=>e===`ctrl-k`||e===`command-k`,uf=e=>e===`ctrl-f`||e===`command-f`,df=({openingProjectId:e,showLabels:t=!0,showDescriptions:n=!0,className:r=``})=>{let[i,a]=(0,Z.useState)(``),o=(0,Z.useId)(),s=(0,Z.useId)(),c=(0,Z.useId)(),l=(0,Z.useId)(),u=(0,Z.useId)(),d=(0,Z.useId)(),f=(0,Z.useId)(),{config:p,updateConfig:m}=fe(),h=N(),{theme:g}=Mt(),{i18n:_}=V(),v=cf(),y=e=>e===`subscription`||e===`api`,x=e=>{y(e)&&m({...p,usageMode:e})},S=(0,Z.useMemo)(()=>Ul()??`en`,[]),C=()=>{m({...p,hideNoUserMessageSession:!p?.hideNoUserMessageSession},{onSuccess:async()=>{await h.refetchQueries({queryKey:b.queryKey})}})},w=()=>{m({...p,unifySameTitleSession:!p?.unifySameTitleSession},{onSuccess:async()=>{await h.refetchQueries({queryKey:te(e).queryKey})}})},T=()=>{m({...p,autoScheduleContinueOnRateLimit:!p?.autoScheduleContinueOnRateLimit})},E=[`shift-enter-send`,`enter-send`,`command-enter-send`],D=e=>{let t=E.find(t=>t===e);t!==void 0&&m({...p,enterKeyBehavior:t})},O=e=>{lf(e)&&m({...p,searchHotkey:e})},k=e=>{uf(e)&&m({...p,findHotkey:e})},A=()=>{let e=i.trim();e&&!p?.modelChoices?.includes(e)&&(m({...p,modelChoices:[...p?.modelChoices??[],e]}),a(``))},j=e=>{m({...p,modelChoices:(p?.modelChoices??[]).filter(t=>t!==e)})};return(0,Q.jsxs)(`div`,{className:`space-y-4 ${r}`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Q.jsx)(`label`,{htmlFor:s,className:`text-sm font-medium leading-none`,children:(0,Q.jsx)(B,{id:`settings.usage_mode`,message:`Usage Mode`})}),(0,Q.jsxs)(ic,{value:p?.usageMode??``,onValueChange:x,children:[(0,Q.jsx)(oc,{id:s,className:`w-full`,children:(0,Q.jsx)(ac,{placeholder:_._({id:`settings.usage_mode.select`,message:`Select usage mode`})})}),(0,Q.jsxs)(lc,{children:[(0,Q.jsx)($,{value:`subscription`,children:(0,Q.jsx)(B,{id:`settings.usage_mode.subscription`,message:`Subscription (Max, Pro, etc.)`})}),(0,Q.jsx)($,{value:`api`,children:(0,Q.jsx)(B,{id:`settings.usage_mode.api`,message:`API`})})]})]}),n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Q.jsx)(B,{id:`settings.usage_mode.description`,message:`Select how you use Claude Code. Subscription mode restricts features that require the Agent SDK.`})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Q.jsx)(ct,{id:o,checked:p?.hideNoUserMessageSession,onCheckedChange:C}),t&&(0,Q.jsx)(`label`,{htmlFor:o,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,children:(0,Q.jsx)(B,{id:`settings.session.hide_no_user_message`})})]}),n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 ml-6`,children:(0,Q.jsx)(B,{id:`settings.session.hide_no_user_message.description`})}),(0,Q.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Q.jsx)(ct,{id:`${o}-unify`,checked:p?.unifySameTitleSession,onCheckedChange:w}),t&&(0,Q.jsx)(`label`,{htmlFor:`${o}-unify`,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,children:(0,Q.jsx)(B,{id:`settings.session.unify_same_title`})})]}),n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 ml-6`,children:(0,Q.jsx)(B,{id:`settings.session.unify_same_title.description`})}),!v&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Q.jsx)(ct,{id:`${o}-auto-schedule-continue`,checked:p?.autoScheduleContinueOnRateLimit,onCheckedChange:T}),t&&(0,Q.jsx)(`label`,{htmlFor:`${o}-auto-schedule-continue`,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,children:(0,Q.jsx)(B,{id:`settings.session.auto_schedule_continue_on_rate_limit`})})]}),n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 ml-6`,children:(0,Q.jsx)(B,{id:`settings.session.auto_schedule_continue_on_rate_limit.description`})})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Q.jsx)(`label`,{htmlFor:c,className:`text-sm font-medium leading-none`,children:(0,Q.jsx)(B,{id:`settings.input.enter_key_behavior`})}),(0,Q.jsxs)(ic,{value:p?.enterKeyBehavior||`shift-enter-send`,onValueChange:D,children:[(0,Q.jsx)(oc,{id:c,className:`w-full`,children:(0,Q.jsx)(ac,{placeholder:_._(`Select enter key behavior`)})}),(0,Q.jsxs)(lc,{children:[(0,Q.jsx)($,{value:`shift-enter-send`,children:(0,Q.jsx)(B,{id:`settings.input.enter_key_behavior.shift_enter`})}),(0,Q.jsx)($,{value:`enter-send`,children:(0,Q.jsx)(B,{id:`settings.input.enter_key_behavior.enter`})}),(0,Q.jsx)($,{value:`command-enter-send`,children:(0,Q.jsx)(B,{id:`settings.input.enter_key_behavior.command_enter`})})]})]}),n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Q.jsx)(B,{id:`settings.input.enter_key_behavior.description`})})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Q.jsx)(`label`,{htmlFor:l,className:`text-sm font-medium leading-none`,children:(0,Q.jsx)(B,{id:`settings.input.search_hotkey`})}),(0,Q.jsxs)(ic,{value:p?.searchHotkey||`command-k`,onValueChange:O,children:[(0,Q.jsx)(oc,{id:l,className:`w-full`,children:(0,Q.jsx)(ac,{placeholder:_._(`Select search hotkey`)})}),(0,Q.jsxs)(lc,{children:[(0,Q.jsx)($,{value:`ctrl-k`,children:(0,Q.jsx)(B,{id:`settings.input.search_hotkey.ctrl_k`})}),(0,Q.jsx)($,{value:`command-k`,children:(0,Q.jsx)(B,{id:`settings.input.search_hotkey.command_k`})})]})]}),n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Q.jsx)(B,{id:`settings.input.search_hotkey.description`})})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Q.jsx)(`label`,{htmlFor:u,className:`text-sm font-medium leading-none`,children:(0,Q.jsx)(B,{id:`settings.input.find_hotkey`})}),(0,Q.jsxs)(ic,{value:p?.findHotkey||`command-f`,onValueChange:k,children:[(0,Q.jsx)(oc,{id:u,className:`w-full`,children:(0,Q.jsx)(ac,{placeholder:_._(`Select find hotkey`)})}),(0,Q.jsxs)(lc,{children:[(0,Q.jsx)($,{value:`ctrl-f`,children:(0,Q.jsx)(B,{id:`settings.input.find_hotkey.ctrl_f`})}),(0,Q.jsx)($,{value:`command-f`,children:(0,Q.jsx)(B,{id:`settings.input.find_hotkey.command_f`})})]})]}),n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Q.jsx)(B,{id:`settings.input.find_hotkey.description`})})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Q.jsx)(`span`,{className:`text-sm font-medium leading-none block`,children:(0,Q.jsx)(B,{id:`settings.model_choices.label`,message:`Model Choices`})}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(p?.modelChoices??[]).map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 bg-primary/10 text-primary rounded text-xs`,children:[e,(0,Q.jsx)(`button`,{type:`button`,onClick:()=>j(e),className:`hover:bg-primary/20 rounded-full p-0.5`,children:(0,Q.jsx)(Ie,{className:`w-3 h-3`})})]},e))}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(Et,{value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),A())},placeholder:_._({id:`settings.model_choices.placeholder`,message:`Add model choice...`}),className:`h-8 text-xs flex-1`}),(0,Q.jsx)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:A,disabled:!i.trim(),className:`h-8 text-xs`,children:(0,Q.jsx)(Ge,{className:`w-3 h-3`})})]}),n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Q.jsx)(B,{id:`settings.model_choices.description`,message:`Configure the model options available in the session toolbar`})})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Q.jsx)(`label`,{htmlFor:d,className:`text-sm font-medium leading-none`,children:(0,Q.jsx)(B,{id:`settings.locale`})}),(0,Q.jsxs)(ic,{value:p?.locale||S,onValueChange:e=>{m({...p,locale:e})},children:[(0,Q.jsx)(oc,{id:d,className:`w-full`,children:(0,Q.jsx)(ac,{placeholder:_._(`Select language`)})}),(0,Q.jsxs)(lc,{children:[(0,Q.jsx)($,{value:`ja`,children:(0,Q.jsx)(B,{id:`settings.locale.ja`})}),(0,Q.jsx)($,{value:`en`,children:(0,Q.jsx)(B,{id:`settings.locale.en`})}),(0,Q.jsx)($,{value:`zh_CN`,children:(0,Q.jsx)(B,{id:`settings.locale.zh_CN`})})]})]}),n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Q.jsx)(B,{id:`settings.locale.description`})})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Q.jsx)(`label`,{htmlFor:f,className:`text-sm font-medium leading-none`,children:(0,Q.jsx)(B,{id:`settings.theme`})}),(0,Q.jsxs)(ic,{value:g??`system`,onValueChange:e=>{m({...p,theme:e})},children:[(0,Q.jsx)(oc,{id:f,className:`w-full`,children:(0,Q.jsx)(ac,{placeholder:_._(`Select theme`)})}),(0,Q.jsxs)(lc,{children:[(0,Q.jsx)($,{value:`light`,children:(0,Q.jsx)(B,{id:`settings.theme.light`})}),(0,Q.jsx)($,{value:`dark`,children:(0,Q.jsx)(B,{id:`settings.theme.dark`})}),(0,Q.jsx)($,{value:`system`,children:(0,Q.jsx)(B,{id:`settings.theme.system`})})]})]}),n&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Q.jsx)(B,{id:`settings.theme.description`})})]})]})},ff=({projectId:e})=>{let t=N(),{i18n:n}=V(),{data:r,isLoading:i,error:a,isFetching:o}=le({queryKey:C(e).queryKey,queryFn:C(e).queryFn,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchInterval:!1});return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsx)(`div`,{className:`p-3 border-b border-sidebar-border`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-sidebar-foreground`,children:(0,Q.jsx)(B,{id:`mcp.title`})}),(0,Q.jsx)(q,{onClick:()=>{t.invalidateQueries({queryKey:C(e).queryKey})},variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:i||o,title:n._(`Reload MCP servers`),children:(0,Q.jsx)(kt,{className:`w-3 h-3 ${i||o?`animate-spin`:``}`})})]})}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-auto p-3`,children:[i&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,Q.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:(0,Q.jsx)(Sd,{})})}),a&&(0,Q.jsx)(`div`,{className:`text-sm text-red-500`,children:(0,Q.jsx)(B,{id:`mcp.error.load_failed`,values:{error:a.message}})}),r&&r.servers.length===0&&(0,Q.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:(0,Q.jsx)(B,{id:`mcp.no.servers`})}),r&&r.servers.length>0&&(0,Q.jsx)(`div`,{className:`space-y-3`,children:r.servers.map(e=>(0,Q.jsx)(`div`,{className:`p-3 bg-sidebar-accent/50 rounded-md border ${e.status===`failed`?`border-red-500/50 bg-red-500/10`:`border-sidebar-border`}`,children:(0,Q.jsx)(`div`,{className:`flex items-start justify-between`,children:(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`connected`&&(0,Q.jsx)(Ke,{className:`w-4 h-4 text-green-500 flex-shrink-0`}),e.status===`failed`&&(0,Q.jsx)(qe,{className:`w-4 h-4 text-red-500 flex-shrink-0`}),e.status===`unknown`&&(0,Q.jsx)(pn,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`}),(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-sidebar-foreground truncate`,children:e.name})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 font-mono break-all pl-6`,children:e.command})]})})},e.name))})]})]})},pf=(0,Z.forwardRef)(({projectId:e,inputValue:t,onCommandSelect:n,className:r},i)=>{let{i18n:a}=V(),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(-1),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),{data:f}=le({queryKey:A(e).queryKey,queryFn:A(e).queryFn,staleTime:1e3*60*5}),{shouldShowCompletion:p,filteredCommands:m}=(0,Z.useMemo)(()=>{let e=[...f?.defaultCommands??[],...f?.globalCommands??[],...f?.projectCommands??[],...f?.globalSkills??[],...f?.projectSkills??[]],n=t.startsWith(`/`),r=n?t.slice(1).toLowerCase():``;return{shouldShowCompletion:n,filteredCommands:n?e.filter(e=>e.name.toLowerCase().includes(r)||(e.description!==null&&e.description!==``?e.description.toLowerCase():``).includes(r)):[]}},[f,t]),h=p&&m.length>0;o!==h&&(s(h),l(-1));let g=(0,Z.useCallback)(e=>{let t=e.argumentHint!==null&&e.argumentHint!==``?` ${e.argumentHint}`:``;n(`/${e.name}${t} `),s(!1),l(-1)},[n]),_=(0,Z.useCallback)(e=>{if(e>=0&&d.current){let t=d.current.querySelectorAll(`button[role="option"]`)[e];t instanceof HTMLElement&&t.scrollIntoView({block:`nearest`,behavior:`smooth`})}},[]),v=(0,Z.useCallback)(e=>{if(!o||m.length===0)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),l(e=>{let t=e<m.length-1?e+1:0;return requestAnimationFrame(()=>_(t)),t}),!0;case`ArrowUp`:return e.preventDefault(),l(e=>{let t=e>0?e-1:m.length-1;return requestAnimationFrame(()=>_(t)),t}),!0;case`Enter`:case`Tab`:if(c>=0&&c<m.length){e.preventDefault();let t=m[c];return t&&g(t),!0}return!1;case`Escape`:return e.preventDefault(),s(!1),l(-1),!0;default:return!1}},[o,c,g,_,m]);return(0,Z.useEffect)(()=>{let e=e=>{u.current&&e.target instanceof Node&&!u.current.contains(e.target)&&(s(!1),l(-1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,Z.useImperativeHandle)(i,()=>({handleKeyDown:v}),[v]),!p||m.length===0?null:(0,Q.jsx)(`div`,{ref:u,className:J(`relative`,r),children:(0,Q.jsx)(K,{open:o,onOpenChange:s,children:(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{ref:d,className:`absolute z-50 w-full bg-popover border border-border rounded-lg shadow-xl overflow-hidden`,style:{height:`15rem`},role:`listbox`,"aria-label":a._(`Available commands`),children:(0,Q.jsx)(`div`,{className:`h-full overflow-y-auto`,children:m.length>0&&(0,Q.jsxs)(`div`,{className:`p-1.5`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs font-semibold text-muted-foreground/80 border-b border-border/50 mb-1 flex items-center gap-2`,role:`presentation`,children:[(0,Q.jsx)(tr,{className:`w-3.5 h-3.5`}),`Available Commands / Skills (`,m.length,`)`]}),m.map((e,t)=>(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:J(`w-full justify-start text-left font-mono text-sm h-auto min-h-9 px-3 py-2 min-w-0 transition-colors duration-150`,t===c?`bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20`:`hover:bg-accent/50`),onClick:()=>g(e),onMouseEnter:()=>l(t),role:`option`,tabIndex:-1,"aria-selected":t===c,"aria-label":`Command: /${e.name}`,title:e.description??`/${e.name}`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-0.5 min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 w-full`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground flex-shrink-0`,children:`/`}),(0,Q.jsx)(`span`,{className:`font-medium truncate`,children:e.name}),e.argumentHint!==null&&e.argumentHint!==``?(0,Q.jsx)(`span`,{className:`text-muted-foreground/60 text-xs truncate`,children:e.argumentHint}):null]}),e.description!==null&&e.description!==``?(0,Q.jsx)(`span`,{className:`text-muted-foreground/70 text-xs pl-0 truncate w-full`,children:e.description}):null]}),t===c&&(0,Q.jsx)(We,{className:`w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0`})]},e.name))]})})})})})})}),mf=(e,t,n=!0)=>le({queryKey:ee(e,t).queryKey,queryFn:ee(e,t).queryFn,enabled:n&&!!e,staleTime:1e3*60*5}),hf=e=>{let t=e.lastIndexOf(`@`);if(t===-1)return{shouldShow:!1,searchPath:``,beforeAt:``,afterAt:``};let n=e.slice(0,t),r=e.slice(t+1),i=r.split(/\s/),a=i[0]??``;return{shouldShow:!(i.length>1),searchPath:a,beforeAt:n,afterAt:r}},gf=(0,Z.forwardRef)(({projectId:e,inputValue:t,onFileSelect:n,className:r},i)=>{let{i18n:a}=V(),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(-1),u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),{shouldShow:f,searchPath:p,beforeAt:m,afterAt:h}=(0,Z.useMemo)(()=>hf(t),[t]),{basePath:g,filterTerm:_}=(0,Z.useMemo)(()=>{if(!p)return{basePath:`/`,filterTerm:``};let e=p.lastIndexOf(`/`);if(e===-1)return{basePath:`/`,filterTerm:p};let t=p.slice(0,e+1),n=p.slice(e+1);return{basePath:t===`/`?`/`:t,filterTerm:n}},[p]),{data:v,isLoading:y}=mf(e,g,f),b=(0,Z.useMemo)(()=>v?.entries?_?v.entries.filter(e=>e.name.toLowerCase().includes(_.toLowerCase())):v.entries:[],[v?.entries,_]),x=f&&!y&&b.length>0;o!==x&&(s(x),l(-1));let S=(0,Z.useCallback)((e,t=!1)=>{n(`${m}@${e.path}${h.split(/\s/).slice(1).join(` `)}`.trim()+(e.type===`directory`&&!t?`/`:` `)),(e.type===`file`||t)&&(s(!1),l(-1))},[m,h,n]),C=(0,Z.useCallback)(e=>{if(e>=0&&d.current){let t=d.current.querySelectorAll(`button[role="option"]`)[e];t instanceof HTMLElement&&t.scrollIntoView({block:`nearest`,behavior:`smooth`})}},[]),w=(0,Z.useCallback)(e=>{if(!o||b.length===0)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),l(e=>{let t=e<b.length-1?e+1:0;return requestAnimationFrame(()=>C(t)),t}),!0;case`ArrowUp`:return e.preventDefault(),l(e=>{let t=e>0?e-1:b.length-1;return requestAnimationFrame(()=>C(t)),t}),!0;case`Enter`:if(c>=0&&c<b.length){e.preventDefault();let t=b[c];return t&&S(t,!0),!0}return!1;case`Tab`:if(c>=0&&c<b.length){e.preventDefault();let t=b[c];return t&&S(t,t.type===`file`),!0}return!1;case`Escape`:return e.preventDefault(),s(!1),l(-1),!0;default:return!1}},[o,c,S,C,b]);return(0,Z.useEffect)(()=>{let e=e=>{u.current&&e.target instanceof Node&&!u.current.contains(e.target)&&(s(!1),l(-1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,Z.useImperativeHandle)(i,()=>({handleKeyDown:w}),[w]),!f||y||b.length===0?null:(0,Q.jsx)(`div`,{ref:u,className:J(`relative`,r),children:(0,Q.jsx)(K,{open:o,onOpenChange:s,children:(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{ref:d,className:`absolute z-50 w-full bg-popover border border-border rounded-lg shadow-xl overflow-hidden`,style:{height:`15rem`},role:`listbox`,"aria-label":a._(`Available files and directories`),children:(0,Q.jsx)(`div`,{className:`h-full overflow-y-auto`,children:b.length>0&&(0,Q.jsxs)(`div`,{className:`p-1.5`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs font-semibold text-muted-foreground/80 border-b border-border/50 mb-1 flex items-center gap-2`,role:`presentation`,children:[(0,Q.jsx)(En,{className:`w-3.5 h-3.5`}),`Files & Directories (`,b.length,`)`,g!==`/`&&(0,Q.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground/70`,children:[`in `,g]})]}),b.map((e,t)=>(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:J(`w-full justify-start text-left font-mono text-sm h-9 px-3 min-w-0 transition-colors duration-150`,t===c?`bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20`:`hover:bg-accent/50`),onClick:()=>S(e,e.type===`file`),onMouseEnter:()=>l(t),role:`option`,tabIndex:-1,"aria-selected":t===c,"aria-label":`${e.type}: ${e.name}`,title:e.path,children:[e.type===`directory`?(0,Q.jsx)(Xe,{className:`w-3.5 h-3.5 mr-2 text-blue-500 dark:text-blue-400 flex-shrink-0`}):(0,Q.jsx)(En,{className:`w-3.5 h-3.5 mr-2 text-gray-500 dark:text-gray-400 flex-shrink-0`}),(0,Q.jsx)(`span`,{className:`font-medium truncate min-w-0`,children:e.name}),e.type===`directory`&&(0,Q.jsx)(`span`,{className:`text-muted-foreground ml-1 flex-shrink-0`,children:`/`}),t===c&&(0,Q.jsx)(We,{className:`w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0`})]},e.path))]})})})})})})});gf.displayName=`FileCompletion`;var _f=(e,t,n)=>{let r=typeof window<`u`?window.innerHeight:800,i=r/2,a=48+36*Math.min(n,5)+12,o=t.top<i,s=r-t.top,c=t.top,l,u;o&&s>=a+20?(l=`below`,u=e.top+24):!o&&c>=a+20?(l=`above`,u=e.top-a-16):s>c?(l=`below`,u=e.top+24):(l=`above`,u=e.top-a-16);let d=(typeof window<`u`?window.innerWidth:1200)-512-16,f=Math.max(16,Math.min(e.left-16,d));return{top:u,left:f,placement:l}},vf=({projectId:e,message:t,commandCompletionRef:n,fileCompletionRef:r,handleCommandSelect:i,handleFileSelect:a,cursorPosition:o})=>{let s=(0,Z.useMemo)(()=>_f(o.relative,o.absolute,5),[o]);return(0,Q.jsxs)(`div`,{className:`absolute w-full max-w-sm sm:max-w-md lg:max-w-lg xl:max-w-xl z-50`,style:{top:s.top,left:s.left,maxWidth:typeof window<`u`?Math.min(512,window.innerWidth*.8):512},children:[(0,Q.jsx)(pf,{ref:n,projectId:e,inputValue:t,onCommandSelect:i,className:`absolute left-0 right-0 ${s.placement===`above`?`bottom-full mb-2`:`top-full mt-1`}`}),(0,Q.jsx)(gf,{ref:r,projectId:e,inputValue:t,onFileSelect:a,className:`absolute left-0 right-0 ${s.placement===`above`?`bottom-full mb-2`:`top-full mt-1`}`})]})},yf=()=>{let[e,t]=(0,Z.useState)({relative:{top:0,left:0},absolute:{top:0,left:0}}),n=(0,Z.useRef)(null),r=(0,Z.useRef)(null),i=(0,Z.useRef)(null),a=(0,Z.useRef)(null),o=(0,Z.useCallback)(()=>{let e=r.current,t=n.current;if(e===null||t===null)return;let i=e.selectionStart,a=e.value.substring(0,i),o=e.value.substring(i),s=document.createTextNode(a),c=document.createTextNode(o),l=document.createElement(`span`);l.innerHTML=` `;let u=document.createElement(`div`);u.innerHTML=``,u.append(s,l,c);let d=window.getComputedStyle(e);for(let e of[`border`,`boxSizing`,`fontFamily`,`fontSize`,`fontWeight`,`letterSpacing`,`lineHeight`,`padding`,`textDecoration`,`textIndent`,`textTransform`,`whiteSpace`,`wordSpacing`,`wordWrap`])u.style[e]=d[e];u.style.visibility=`hidden`,t.prepend(u);let f=l.getBoundingClientRect(),p=t.getBoundingClientRect();return t.removeChild(u),{relative:{top:f.top-p.top-e.scrollTop,left:f.left-p.left-e.scrollLeft},absolute:{top:f.top-e.scrollTop,left:f.left-e.scrollLeft}}},[]);return{cursorPosition:e,containerRef:n,textareaRef:r,commandCompletionRef:i,fileCompletionRef:a,getCursorPosition:o,handleChange:(0,Z.useCallback)((e,n)=>{if(e.endsWith(`@`)||e.endsWith(`/`)){let e=o();e&&t(e)}n(e)},[o]),handleKeyDown:(0,Z.useCallback)(e=>a.current?.handleKeyDown(e)===!0||i.current?.handleKeyDown(e)===!0,[]),handleCommandSelect:(0,Z.useCallback)((e,t)=>{t(e),r.current?.focus()},[]),handleFileSelect:(0,Z.useCallback)((e,t)=>{t(e),r.current?.focus()},[])}},bf=Z.forwardRef(({className:e,checked:t,onCheckedChange:n,disabled:r,...i},a)=>(0,Q.jsxs)(`label`,{className:J(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background`,r===!0&&`cursor-not-allowed opacity-50`,t===!0?`bg-primary`:`bg-input`,e),children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`sr-only`,ref:a,checked:t,onChange:e=>{n?.(e.target.checked),i.onChange?.(e)},disabled:r,...i}),(0,Q.jsx)(`span`,{className:J(`pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform`,t===!0?`translate-x-4`:`translate-x-0`)})]}));bf.displayName=`Switch`;var xf=[{value:0,labelKey:(0,Q.jsx)(B,{id:`cron_builder.sunday`})},{value:1,labelKey:(0,Q.jsx)(B,{id:`cron_builder.monday`})},{value:2,labelKey:(0,Q.jsx)(B,{id:`cron_builder.tuesday`})},{value:3,labelKey:(0,Q.jsx)(B,{id:`cron_builder.wednesday`})},{value:4,labelKey:(0,Q.jsx)(B,{id:`cron_builder.thursday`})},{value:5,labelKey:(0,Q.jsx)(B,{id:`cron_builder.friday`})},{value:6,labelKey:(0,Q.jsx)(B,{id:`cron_builder.saturday`})}],Sf=e=>{let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=t[0],r=t[1],i=t[4];if(n===void 0||n===``||r===void 0||r===``||i===void 0||i===``)return null;if(r===`*`&&n===`0`)return{mode:`hourly`,hour:0,minute:0,dayOfWeek:0};if(i===`*`&&r!==`*`){let e=Number.parseInt(r,10),t=Number.parseInt(n,10);if(!Number.isNaN(e)&&!Number.isNaN(t))return{mode:`daily`,hour:e,minute:t,dayOfWeek:0}}if(i!==`*`&&r!==`*`){let e=Number.parseInt(r,10),t=Number.parseInt(n,10),a=Number.parseInt(i,10);if(!Number.isNaN(e)&&!Number.isNaN(t)&&!Number.isNaN(a))return{mode:`weekly`,hour:e,minute:t,dayOfWeek:a}}return{mode:`custom`,hour:0,minute:0,dayOfWeek:0}},Cf=(e,t,n,r)=>{switch(e){case`hourly`:return`0 * * * *`;case`daily`:return`${n} ${t} * * *`;case`weekly`:return`${n} ${t} * * ${r}`;case`custom`:return`0 0 * * *`;default:return`0 0 * * *`}},wf=e=>{let t=e.trim().split(/\s+/);if(t.length!==5)return!1;let n=t[0],r=t[1],i=t[2],a=t[3],o=t[4];if(n===void 0||n===``||r===void 0||r===``||i===void 0||i===``||a===void 0||a===``||o===void 0||o===``)return!1;let s=(e,t,n)=>{if(e===`*`)return!0;let r=Number.parseInt(e,10);return!Number.isNaN(r)&&r>=t&&r<=n};return s(n,0,59)&&(r===`*`||s(r,0,23))&&(i===`*`||s(i,1,31))&&(a===`*`||s(a,1,12))&&(o===`*`||s(o,0,6))},Tf=e=>{let t=e.trim().split(/\s+/);if(t.length!==5)return`Invalid cron expression`;let n=t[0],r=t[1],i=t[4];if(n===void 0||n===``||r===void 0||r===``||i===void 0||i===``)return`Invalid cron expression`;if(r===`*`)return`Every hour at ${n} minute(s)`;let a=`${r.padStart(2,`0`)}:${n.padStart(2,`0`)}`;if(i===`*`)return`Every day at ${a}`;let o=Number.parseInt(i,10),s=xf.find(e=>e.value===o);return(0,Q.jsxs)(Q.Fragment,{children:[`Every `,s?s.labelKey:`unknown`,` at `,a]})},Ef=({value:e,onChange:t})=>{let n=Sf(e),[r,i]=(0,Z.useState)(n?.mode??`daily`),[a,o]=(0,Z.useState)(n?.hour??9),[s,c]=(0,Z.useState)(n?.minute??0),[l,u]=(0,Z.useState)(n?.dayOfWeek??1),[d,f]=(0,Z.useState)(e),[p,m]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{if(r===`custom`)wf(d)?(t(d),m(null)):m(`Invalid cron expression`);else{let e=Cf(r,a,s,l);t(e),f(e),m(null)}},[r,a,s,l,d,t]),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{children:(0,Q.jsx)(B,{id:`cron_builder.schedule_type`})}),(0,Q.jsxs)(ic,{value:r,onValueChange:e=>{i(e),e!==`custom`&&f(Cf(e,a,s,l))},children:[(0,Q.jsx)(oc,{children:(0,Q.jsx)(ac,{})}),(0,Q.jsxs)(lc,{children:[(0,Q.jsx)($,{value:`hourly`,children:(0,Q.jsx)(B,{id:`cron_builder.hourly`})}),(0,Q.jsx)($,{value:`daily`,children:(0,Q.jsx)(B,{id:`cron_builder.daily`})}),(0,Q.jsx)($,{value:`weekly`,children:(0,Q.jsx)(B,{id:`cron_builder.weekly`})}),(0,Q.jsx)($,{value:`custom`,children:(0,Q.jsx)(B,{id:`cron_builder.custom`})})]})]})]}),r===`daily`&&(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{children:(0,Q.jsx)(B,{id:`cron_builder.hour`})}),(0,Q.jsx)(Et,{type:`number`,min:`0`,max:`23`,value:a,onChange:e=>o(Number.parseInt(e.target.value,10))})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{children:(0,Q.jsx)(B,{id:`cron_builder.minute`})}),(0,Q.jsx)(Et,{type:`number`,min:`0`,max:`59`,value:s,onChange:e=>c(Number.parseInt(e.target.value,10))})]})]}),r===`weekly`&&(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{children:(0,Q.jsx)(B,{id:`cron_builder.day_of_week`})}),(0,Q.jsxs)(ic,{value:String(l),onValueChange:e=>u(Number.parseInt(e,10)),children:[(0,Q.jsx)(oc,{children:(0,Q.jsx)(ac,{})}),(0,Q.jsx)(lc,{children:xf.map(e=>(0,Q.jsx)($,{value:String(e.value),children:e.labelKey},e.value))})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{children:(0,Q.jsx)(B,{id:`cron_builder.hour`})}),(0,Q.jsx)(Et,{type:`number`,min:`0`,max:`23`,value:a,onChange:e=>o(Number.parseInt(e.target.value,10))})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{children:(0,Q.jsx)(B,{id:`cron_builder.minute`})}),(0,Q.jsx)(Et,{type:`number`,min:`0`,max:`59`,value:s,onChange:e=>c(Number.parseInt(e.target.value,10))})]})]})]}),r===`custom`&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{children:(0,Q.jsx)(B,{id:`cron_builder.cron_expression`})}),(0,Q.jsx)(Et,{value:d,onChange:e=>f(e.target.value),placeholder:`0 9 * * *`})]}),(0,Q.jsxs)(`div`,{className:`rounded-md border p-3 text-sm`,children:[(0,Q.jsx)(`div`,{className:`font-medium mb-1`,children:(0,Q.jsx)(B,{id:`cron_builder.preview`})}),(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:p===null?Tf(r===`custom`?d:e):(0,Q.jsx)(`span`,{className:`text-destructive`,children:p})}),(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-2`,children:[(0,Q.jsx)(B,{id:`cron_builder.expression`}),`:`,` `,(0,Q.jsx)(`code`,{children:r===`custom`?d:e})]})]})]})},Df=({open:e,onOpenChange:t,job:n,projectId:r,onSubmit:i,isSubmitting:a=!1})=>{let{_:o,i18n:s}=V(),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(`cron`),[f,p]=(0,Z.useState)(`0 9 * * *`),[m,h]=(0,Z.useState)(()=>{let e=new Date;return e.setHours(e.getHours()+1),e.toISOString().slice(0,16)}),[g,_]=(0,Z.useState)(``),[v,y]=(0,Z.useState)(!0),[b,x]=(0,Z.useState)(`skip`),S=yf();(0,Z.useEffect)(()=>{if(n){if(l(n.name),d(n.schedule.type),n.schedule.type===`cron`)p(n.schedule.expression),x(n.schedule.concurrencyPolicy);else if(n.schedule.type===`reserved`){let e=new Date(n.schedule.reservedExecutionTime);h(`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`)}_(n.message.content),y(n.enabled)}else{l(``),d(`cron`),p(`0 9 * * *`);let e=new Date;e.setHours(e.getHours()+1),h(`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`),_(``),y(!0),x(`skip`)}},[n]);let C=()=>{i({name:c,schedule:u===`cron`?{type:`cron`,expression:f,concurrencyPolicy:b}:{type:`reserved`,reservedExecutionTime:(()=>{let e=m.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/);if(!e)throw Error(`Invalid datetime format`);let t=Number(e[1]),n=Number(e[2]),r=Number(e[3]),i=Number(e[4]),a=Number(e[5]);return new Date(t,n-1,r,i,a).toISOString()})()},message:{content:g,projectId:r,sessionId:crypto.randomUUID(),resume:!1},enabled:v})},w=c.trim()!==``&&g.trim()!==``;return(0,Q.jsx)(Pe,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Le,{className:`max-w-2xl max-h-[90vh] overflow-y-auto`,children:[(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Te,{children:n?(0,Q.jsx)(B,{id:`scheduler.dialog.title.edit`}):(0,Q.jsx)(B,{id:`scheduler.dialog.title.create`})}),(0,Q.jsx)(we,{children:(0,Q.jsx)(B,{id:`scheduler.dialog.description`})})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border p-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Q.jsx)(Y,{htmlFor:`enabled`,className:`text-base font-semibold`,children:(0,Q.jsx)(B,{id:`scheduler.form.enabled`})}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Q.jsx)(B,{id:`scheduler.form.enabled.description`})})]}),(0,Q.jsx)(bf,{id:`enabled`,checked:v,onCheckedChange:y,disabled:a})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{htmlFor:`job-name`,children:(0,Q.jsx)(B,{id:`scheduler.form.name`})}),(0,Q.jsx)(Et,{id:`job-name`,value:c,onChange:e=>l(e.target.value),placeholder:o({id:`scheduler.form.name.placeholder`,message:`e.g., Daily Report`}),disabled:a})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{children:(0,Q.jsx)(B,{id:`scheduler.form.schedule_type`})}),(0,Q.jsxs)(ic,{value:u,onValueChange:e=>d(e),disabled:a,children:[(0,Q.jsx)(oc,{children:(0,Q.jsx)(ac,{})}),(0,Q.jsxs)(lc,{children:[(0,Q.jsx)($,{value:`cron`,children:(0,Q.jsx)(B,{id:`scheduler.form.schedule_type.cron`})}),(0,Q.jsx)($,{value:`reserved`,children:(0,Q.jsx)(B,{id:`scheduler.form.schedule_type.reserved`})})]})]})]}),u===`cron`?(0,Q.jsx)(Ef,{value:f,onChange:p}):(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{htmlFor:`reserved-datetime`,children:(0,Q.jsx)(B,{id:`scheduler.form.reserved_time`})}),(0,Q.jsx)(Et,{id:`reserved-datetime`,type:`datetime-local`,value:m,onChange:e=>h(e.target.value),disabled:a}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(B,{id:`scheduler.form.reserved_time.hint`})})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{htmlFor:`message-content`,children:(0,Q.jsx)(B,{id:`scheduler.form.message`})}),(0,Q.jsxs)(`div`,{className:`relative`,ref:S.containerRef,children:[(0,Q.jsx)(Uc,{ref:S.textareaRef,id:`message-content`,value:g,onChange:e=>S.handleChange(e.target.value,_),onKeyDown:e=>S.handleKeyDown(e),placeholder:s._({id:`scheduler.form.message.placeholder`,message:`Type message to send to Claude Code... (/ for commands, @ for files)`}),rows:4,disabled:a,className:`resize-none`,"aria-label":s._({id:`scheduler.form.message.aria_label`,message:`Message input with completion support (/ for commands, @ for files)`}),"aria-expanded":g.startsWith(`/`)||g.includes(`@`)}),(0,Q.jsx)(vf,{projectId:r,message:g,commandCompletionRef:S.commandCompletionRef,fileCompletionRef:S.fileCompletionRef,handleCommandSelect:e=>S.handleCommandSelect(e,_),handleFileSelect:e=>S.handleFileSelect(e,_),cursorPosition:S.cursorPosition})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Q.jsx)(B,{id:`scheduler.form.message.hint`})})]}),u===`cron`&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{children:(0,Q.jsx)(B,{id:`scheduler.form.concurrency_policy`})}),(0,Q.jsxs)(ic,{value:b,onValueChange:e=>x(e),disabled:a,children:[(0,Q.jsx)(oc,{children:(0,Q.jsx)(ac,{})}),(0,Q.jsxs)(lc,{children:[(0,Q.jsx)($,{value:`skip`,children:(0,Q.jsx)(B,{id:`scheduler.form.concurrency_policy.skip`})}),(0,Q.jsx)($,{value:`run`,children:(0,Q.jsx)(B,{id:`scheduler.form.concurrency_policy.run`})})]})]})]})]}),(0,Q.jsxs)(Me,{children:[(0,Q.jsx)(q,{variant:`outline`,onClick:()=>t(!1),disabled:a,children:(0,Q.jsx)(B,{id:`common.cancel`})}),(0,Q.jsx)(q,{onClick:C,disabled:!w||a,children:a?(0,Q.jsx)(B,{id:`common.saving`}):n?(0,Q.jsx)(B,{id:`common.update`}):(0,Q.jsx)(B,{id:`common.create`})})]})]})})},Of=({projectId:e,sessionId:t})=>{let{i18n:n}=V(),{data:r,isLoading:i,isFetching:a,error:o,refetch:s}=Fd(),c=Id(),l=Ld(),u=Rd(),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null),y=e=>{c.mutate(e,{onSuccess:()=>{z.success(n._({id:`scheduler.job.created`,message:`Job created successfully`})),f(!1)},onError:e=>{z.error(n._({id:`scheduler.job.create_failed`,message:`Failed to create job`}),{description:e.message})}})},b=e=>{p&&l.mutate({id:p.id,updates:e},{onSuccess:()=>{z.success(n._({id:`scheduler.job.updated`,message:`Job updated successfully`})),f(!1),m(null)},onError:e=>{z.error(n._({id:`scheduler.job.update_failed`,message:`Failed to update job`}),{description:e.message})}})},x=()=>{_===null||_===``||u.mutate(_,{onSuccess:()=>{z.success(n._({id:`scheduler.job.deleted`,message:`Job deleted successfully`})),g(!1),v(null)},onError:e=>{z.error(n._({id:`scheduler.job.delete_failed`,message:`Failed to delete job`}),{description:e.message})}})},S=e=>{m(e),f(!0)},C=e=>{v(e),g(!0)},w=e=>e.schedule.type===`cron`?`Cron: ${e.schedule.expression}`:e.schedule.type===`reserved`?`Reserved: ${new Date(e.schedule.reservedExecutionTime).toLocaleString()}`:`Unknown schedule type`,T=e=>e===null||e===``?`Never`:new Date(e).toLocaleString();return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Q.jsx)(`div`,{className:`p-3 border-b border-sidebar-border`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-sidebar-foreground`,children:(0,Q.jsx)(B,{id:`scheduler.title`})}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(q,{onClick:()=>{s()},variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:i||a,title:n._({id:`common.reload`,message:`Reload`}),children:(0,Q.jsx)(kt,{className:`w-3 h-3 ${i||a?`animate-spin`:``}`})}),(0,Q.jsx)(q,{onClick:()=>{m(null),f(!0)},variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,title:n._({id:`scheduler.create_job`,message:`Create Job`}),children:(0,Q.jsx)(Ge,{className:`w-3 h-3`})})]})]})}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-auto p-3`,children:[i&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,Q.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:(0,Q.jsx)(Sd,{})})}),o&&(0,Q.jsx)(`div`,{className:`text-sm text-red-500`,children:(0,Q.jsx)(B,{id:`scheduler.error.load_failed`,values:{error:o.message}})}),r&&r.length===0&&(0,Q.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:(0,Q.jsx)(B,{id:`scheduler.no_jobs`})}),r&&r.length>0&&(0,Q.jsx)(`div`,{className:`space-y-3`,children:r.map(e=>(0,Q.jsxs)(`div`,{className:`p-3 bg-sidebar-accent/50 rounded-md border border-sidebar-border`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-sidebar-foreground truncate`,children:e.name}),(0,Q.jsx)(U,{variant:e.enabled?`default`:`secondary`,className:`text-xs`,children:e.enabled?(0,Q.jsx)(B,{id:`scheduler.status.enabled`}):(0,Q.jsx)(B,{id:`scheduler.status.disabled`})})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:w(e)})]}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>S(e),children:(0,Q.jsx)(er,{className:`w-3 h-3`})}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive hover:text-destructive`,onClick:()=>C(e.id),children:(0,Q.jsx)(rr,{className:`w-3 h-3`})})]})]}),e.lastRunAt!==null&&e.lastRunAt!==``&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2 pt-2 border-t border-sidebar-border`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(B,{id:`scheduler.last_run`}),(0,Q.jsx)(`span`,{children:T(e.lastRunAt)})]}),e.lastRunStatus&&(0,Q.jsx)(U,{variant:e.lastRunStatus===`success`?`default`:`destructive`,className:`text-xs`,children:e.lastRunStatus})]})})]},e.id))})]}),(0,Q.jsx)(Df,{open:d,onOpenChange:e=>{f(e),e||m(null)},job:p,projectId:e,currentSessionId:t,onSubmit:p?b:y,isSubmitting:c.isPending||l.isPending}),(0,Q.jsx)(Pe,{open:h,onOpenChange:g,children:(0,Q.jsxs)(Le,{children:[(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Te,{children:(0,Q.jsx)(B,{id:`scheduler.delete_dialog.title`})}),(0,Q.jsx)(we,{children:(0,Q.jsx)(B,{id:`scheduler.delete_dialog.description`})})]}),(0,Q.jsxs)(Me,{children:[(0,Q.jsx)(q,{variant:`outline`,onClick:()=>{g(!1),v(null)},disabled:u.isPending,children:(0,Q.jsx)(B,{id:`common.cancel`})}),(0,Q.jsx)(q,{variant:`destructive`,onClick:x,disabled:u.isPending,children:u.isPending?(0,Q.jsx)(B,{id:`common.deleting`}):(0,Q.jsx)(B,{id:`common.delete`})})]})]})})]})},kf=({currentSessionId:e,projectId:t,onSessionSelect:n})=>{let{data:r,fetchNextPage:i,hasNextPage:a,isFetchingNextPage:o}=Md(t),s=D(Dt),c=D(xu),l=(0,Z.useMemo)(()=>{let e=r.pages.flatMap(e=>e.sessions),n=Nd(c,t,new Set(e.map(e=>e.id)));return[...e,...n]},[r.pages,t,c]);(0,Z.useEffect)(()=>{let e=new Set(r.pages.flatMap(e=>e.sessions).map(e=>e.id));for(let n of c.values())n.projectId===t&&n.isNewSession&&e.has(n.sessionId)&&wu(n.sessionId)},[r.pages,t,c]);let{config:u}=fe(),d=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{d.current?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[e]);let f=`sessions`,p=e===``,m=(0,Z.useMemo)(()=>{let e=e=>e===`running`?0:e===`paused`?1:2;return[...l].sort((t,n)=>{let r=s.find(e=>e.sessionId===t.id)?.status,i=s.find(e=>e.sessionId===n.id)?.status,a=e(r),o=e(i);if(a!==o)return a-o;let c=t.createdAt??t.lastModifiedAt,l=n.createdAt??n.lastModifiedAt,u=c?new Date(c).getTime():0;return(l?new Date(l).getTime():0)-u})},[l,s]);return(0,Q.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-sidebar-border p-4`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between mb-2`,children:(0,Q.jsx)(`h2`,{className:`font-semibold text-lg`,children:(0,Q.jsx)(B,{id:`sessions.title`})})}),(0,Q.jsxs)(`p`,{className:`text-xs text-sidebar-foreground/70`,children:[l.length,` `,(0,Q.jsx)(B,{id:`sessions.total`})]})]}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-2 space-y-0.5`,children:[(0,Q.jsx)(ve,{to:`/projects/$projectId/session`,params:{projectId:t},search:{tab:f},onClick:n,className:J(`block rounded-lg p-2.5 transition-all duration-200 border border-sidebar-border/40 bg-sidebar/30 hover:bg-blue-50/60 dark:hover:bg-blue-950/40 hover:border-blue-300/60 dark:hover:border-blue-700/60 hover:shadow-sm`,p&&`bg-blue-100 dark:bg-blue-900/50 border-blue-400 dark:border-blue-600 shadow-md ring-1 ring-blue-200/50 dark:ring-blue-700/50`),children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,Q.jsx)(Pn,{className:`w-4 h-4`})}),(0,Q.jsx)(`div`,{className:`space-y-0.5`,children:(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-sidebar-foreground`,children:(0,Q.jsx)(B,{id:`chat.history.title`})})})]})}),m.map(r=>{let i=r.id===e,a=qd(r.meta.customTitle,r.meta.firstUserMessage,r.id),o=s.find(e=>e.sessionId===r.id),c=o?.status===`running`,l=o?.status===`paused`;return(0,Q.jsx)(ve,{ref:i?d:void 0,to:`/projects/$projectId/session`,params:{projectId:t},search:{tab:f,sessionId:r.id},onClick:n,className:J(`group relative block rounded-lg p-2.5 transition-all duration-200 hover:bg-blue-50/60 dark:hover:bg-blue-950/40 hover:border-blue-300/60 dark:hover:border-blue-700/60 hover:shadow-sm border border-sidebar-border/40 bg-sidebar/30`,i&&`bg-blue-100 dark:bg-blue-900/50 border-blue-400 dark:border-blue-600 shadow-md ring-1 ring-blue-200/50 dark:ring-blue-700/50 hover:bg-blue-100 dark:hover:bg-blue-900/50 hover:border-blue-400 dark:hover:border-blue-600`),children:(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2 pr-6`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium line-clamp-2 leading-tight text-sidebar-foreground flex-1`,children:a}),(c||l)&&(0,Q.jsx)(U,{variant:c?`default`:`secondary`,className:J(`text-xs shrink-0`,c&&`bg-green-500 text-white`,l&&`bg-yellow-500 text-white`),children:c?(0,Q.jsx)(B,{id:`session.status.running`}):(0,Q.jsx)(B,{id:`session.status.paused`})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-sidebar-foreground/70 min-w-0`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(ye,{className:`w-3 h-3`}),(0,Q.jsx)(`span`,{children:r.meta.messageCount})]})}),(r.createdAt??r.lastModifiedAt)&&(0,Q.jsx)(`span`,{className:`text-xs text-sidebar-foreground/60 shrink-0`,children:de(r.createdAt??r.lastModifiedAt,{locale:u.locale,target:`time`})})]})]})},r.id)}),a===!0&&(0,Q.jsx)(`div`,{className:`p-2`,children:(0,Q.jsx)(q,{onClick:()=>{i()},disabled:o,variant:`outline`,size:`sm`,className:`w-full`,children:o?(0,Q.jsx)(B,{id:`common.loading`}):(0,Q.jsx)(B,{id:`sessions.load.more`})})})]})]})},Af=async(e,t)=>(await o.api.tasks.$get({query:{projectId:e,sessionId:t}})).json(),jf=async(e,t,n)=>(await o.api.tasks.$post({query:{projectId:e,sessionId:n},json:t})).json(),Mf=async(e,t,n,r)=>(await o.api.tasks[`:taskId`].$patch({param:{taskId:t},query:{projectId:e,sessionId:r},json:n})).json(),Nf=({status:e,onClick:t})=>(0,Q.jsxs)(`button`,{type:`button`,onClick:t,className:J(`flex items-center justify-center w-6 h-6 rounded-md shrink-0 transition-all duration-200`,`hover:scale-110 active:scale-95`,e===`completed`&&`bg-green-500/20 text-green-600 dark:text-green-400 hover:bg-green-500/30`,e===`in_progress`&&`bg-blue-500/20 text-blue-600 dark:text-blue-400 hover:bg-blue-500/30`,e===`pending`&&`bg-gray-500/10 text-gray-500 dark:text-gray-400 hover:bg-gray-500/20`,e===`failed`&&`bg-red-500/20 text-red-600 dark:text-red-400 hover:bg-red-500/30`),children:[e===`completed`&&(0,Q.jsx)(Ke,{className:`w-4 h-4`}),e===`in_progress`&&(0,Q.jsx)(_n,{className:`w-4 h-4 animate-pulse`}),e===`pending`&&(0,Q.jsx)(mn,{className:`w-4 h-4`}),e===`failed`&&(0,Q.jsx)(Ft,{className:`w-4 h-4`})]}),Pf=({task:e,onToggleStatus:t})=>{let n=e.status===`completed`,r=e.status===`in_progress`,i=e.status===`failed`;return(0,Q.jsx)(`div`,{className:J(`group relative block rounded-lg p-3 transition-all duration-200`,`border border-sidebar-border/40 bg-sidebar/30`,`hover:bg-blue-50/60 dark:hover:bg-blue-950/40`,`hover:border-blue-300/60 dark:hover:border-blue-700/60`,`hover:shadow-sm`,r&&`bg-blue-50/80 dark:bg-blue-950/50 border-blue-400/60 dark:border-blue-600/60`,n&&`opacity-60 bg-sidebar/20`,i&&`border-red-400/60 bg-red-50/30 dark:bg-red-950/30 dark:border-red-700/60`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(Nf,{status:e.status,onClick:()=>t(e)}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:J(`text-sm font-medium leading-tight line-clamp-1`,n&&`line-through text-sidebar-foreground/60`),children:e.subject}),(0,Q.jsxs)(`span`,{className:`text-[10px] font-mono text-sidebar-foreground/50 shrink-0`,children:[`#`,e.id]})]}),e.description!==void 0&&e.description!==``&&(0,Q.jsx)(`p`,{className:`text-xs text-sidebar-foreground/60 line-clamp-2 leading-relaxed`,children:e.description}),e.blockedBy&&e.blockedBy.length>0&&e.status!==`completed`&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:e.blockedBy.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 border border-amber-200 dark:border-amber-800/50`,children:[(0,Q.jsx)(ir,{className:`w-2.5 h-2.5`}),`#`,e]},e))})]})]})})},Ff=()=>(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 px-4 text-center`,children:[(0,Q.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-sidebar-accent/50 flex items-center justify-center mb-4`,children:(0,Q.jsx)(Ln,{className:`w-6 h-6 text-sidebar-foreground/40`})}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-sidebar-foreground/70`,children:`No tasks yet`}),(0,Q.jsx)(`p`,{className:`text-xs text-sidebar-foreground/50 mt-1`,children:`Tasks will appear here when created`})]}),If=()=>(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sidebar-foreground/60`,children:[(0,Q.jsx)(T,{className:`w-4 h-4 animate-spin`}),(0,Q.jsx)(`span`,{className:`text-sm`,children:`Loading tasks...`})]})}),Lf=()=>(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 px-4 text-center`,children:[(0,Q.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center mb-4`,children:(0,Q.jsx)(Ft,{className:`w-6 h-6 text-red-500`})}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-red-600 dark:text-red-400`,children:`Failed to load tasks`}),(0,Q.jsx)(`p`,{className:`text-xs text-sidebar-foreground/50 mt-1`,children:`Please try again later`})]}),Rf=({projectId:e,sessionId:t})=>{let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),c=N(),{data:l,isLoading:u,error:d}=le({queryKey:[`tasks`,e,t],queryFn:()=>Af(e,t),refetchInterval:5e3}),f=m({mutationFn:n=>jf(e,n,t),onSuccess:()=>{c.invalidateQueries({queryKey:[`tasks`,e,t]}),r(!1),a(``),s(``),z.success(`Task created`)},onError:()=>z.error(`Failed to create task`)}),p=m({mutationFn:n=>Mf(e,n.taskId,n.update,t),onSuccess:()=>{c.invalidateQueries({queryKey:[`tasks`,e,t]})},onError:()=>z.error(`Failed to update task`)}),h=e=>{let t=`pending`;e.status===`pending`?t=`in_progress`:e.status===`in_progress`?t=`completed`:(e.status===`completed`||e.status===`failed`)&&(t=`pending`),p.mutate({taskId:e.id,update:{status:t}})},g=e=>{e.preventDefault(),i.trim().length!==0&&f.mutate({subject:i,description:o})},_=l?.length??0;return(0,Q.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-sidebar-border p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-lg`,children:`Tasks`}),(0,Q.jsxs)(Pe,{open:n,onOpenChange:r,children:[(0,Q.jsx)(Ee,{asChild:!0,children:(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,className:`h-8 w-8 p-0 rounded-full hover:bg-primary/10 hover:text-primary transition-colors`,children:(0,Q.jsx)(Ge,{className:`w-4 h-4`})})}),(0,Q.jsxs)(Le,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Te,{children:`Create New Task`}),(0,Q.jsx)(we,{children:`Add a new task to track your progress.`})]}),(0,Q.jsxs)(`form`,{onSubmit:g,className:`space-y-4 mt-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{htmlFor:`subject`,children:`Title`}),(0,Q.jsx)(Et,{id:`subject`,value:i,onChange:e=>a(e.target.value),placeholder:`e.g. Implement login flow`,className:`focus-visible:ring-primary/30`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(Y,{htmlFor:`description`,children:`Description`}),(0,Q.jsx)(Uc,{id:`description`,value:o,onChange:e=>s(e.target.value),placeholder:`Optional details about the task...`,className:`focus-visible:ring-primary/30 min-h-[80px]`})]}),(0,Q.jsx)(Me,{children:(0,Q.jsx)(q,{type:`submit`,disabled:f.isPending||i.trim().length===0,className:`w-full sm:w-auto`,children:f.isPending?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(T,{className:`w-4 h-4 mr-2 animate-spin`}),`Creating...`]}):`Create Task`})})]})]})]})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-sidebar-foreground/70`,children:[_,` `,_===1?`task`:`tasks`]})]}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-2 space-y-2`,children:[u&&(0,Q.jsx)(If,{}),d&&(0,Q.jsx)(Lf,{}),!u&&!d&&_===0&&(0,Q.jsx)(Ff,{}),!u&&!d&&l?.map(e=>(0,Q.jsx)(Pf,{task:e,onToggleStatus:h},e.id))]})]})},zf=({currentSessionId:e,projectId:t,isOpen:n,onClose:r,initialTab:i=`sessions`})=>{let{i18n:a}=V(),o=y(),s=cf(),[c,l]=(0,Z.useState)(i),u=c,d=(0,Z.useMemo)(()=>s?At.options.filter(e=>e!==`scheduler`):At.options,[s]);(0,Z.useEffect)(()=>{c===`scheduler`&&s&&l(`sessions`)},[c,s]);let f={sessions:a._({id:`sidebar.tab.sessions`}),mcp:a._({id:`sidebar.tab.mcp`}),tasks:a._({id:`sidebar.tab.tasks`}),scheduler:a._({id:`sidebar.tab.scheduler`}),settings:a._({id:`sidebar.tab.settings`}),"system-info":a._({id:`sidebar.tab.system_info`})};(0,Z.useEffect)(()=>{l(i)},[i]),(0,Z.useEffect)(()=>{if(!n)return;document.body.style.overflow=`hidden`;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=``}},[n,r]);let p=Od({onSwipe:e=>{e===`left`&&r()},enabled:n});return(0,Q.jsxs)(`div`,{ref:p,className:J(`fixed inset-y-0 left-0 w-[75vw] z-50 bg-sidebar text-sidebar-foreground flex flex-col shadow-xl md:hidden`,`transition-transform duration-300 ease-out`,n?`translate-x-0`:`-translate-x-full`),children:[(0,Q.jsxs)(`div`,{className:`h-(--spacing-header-height) flex items-center gap-2 px-3 border-b border-sidebar-border bg-sidebar/80 backdrop-blur-sm flex-shrink-0`,children:[(0,Q.jsxs)(ic,{value:c,onValueChange:e=>{if(e===`projects`){o({to:`/projects`}),r();return}let t=At.safeParse(e);t.success&&l(t.data)},children:[(0,Q.jsx)(oc,{className:`flex-1 h-7 text-xs`,children:(0,Q.jsx)(ac,{})}),(0,Q.jsxs)(lc,{children:[(0,Q.jsx)($,{value:`projects`,className:`text-xs`,children:a._({id:`sidebar.tab.projects`,message:`Projects`})}),d.map(e=>(0,Q.jsx)($,{value:e,className:`text-xs`,children:f[e]},e))]})]}),(0,Q.jsx)(ve,{to:`/projects/$projectId/session`,params:{projectId:t},search:{tab:u},onClick:r,className:`flex-shrink-0`,children:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 hover:bg-sidebar-accent/50`,"aria-label":a._(`New chat`),children:(0,Q.jsx)(Ge,{className:`w-3.5 h-3.5`})})}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,className:`h-7 w-7 p-0 hover:bg-sidebar-accent/50 flex-shrink-0`,"aria-label":a._(`Close sidebar`),children:(0,Q.jsx)(Ie,{className:`w-3.5 h-3.5`})})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(()=>{switch(c){case`sessions`:return(0,Q.jsx)(kf,{currentSessionId:e,projectId:t,onSessionSelect:r});case`mcp`:return(0,Q.jsx)(ff,{projectId:t});case`tasks`:return(0,Q.jsx)(Rf,{projectId:t,sessionId:e});case`scheduler`:return(0,Q.jsx)(Of,{projectId:t,sessionId:e});case`settings`:return(0,Q.jsx)(`div`,{className:`h-full flex flex-col`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4`,children:(0,Q.jsx)(`div`,{className:`text-sm text-sidebar-foreground/70`,children:(0,Q.jsx)(B,{id:`settings.loading`})})}),children:(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,Q.jsx)(B,{id:`settings.session.display`})}),(0,Q.jsx)(df,{openingProjectId:t})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,Q.jsx)(B,{id:`settings.notifications`})}),(0,Q.jsx)(sf,{})]})]})})});case`system-info`:return(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4`,children:(0,Q.jsx)(`div`,{className:`text-sm text-sidebar-foreground/70`,children:`Loading...`})}),children:(0,Q.jsx)(st,{})});default:return null}})()})]})},Bf=({projectId:e,className:t,additionalTabs:n=[],defaultActiveTab:r,headerButton:i,fillWidth:a=!1,isContentHidden:o=!1,onToggle:s,onMobileTabClick:c})=>{let{openSearch:l}=ke(),{authEnabled:u,logout:d}=k(),f=y(),p=async()=>{await d(),f({to:`/login`})},m={id:`settings`,icon:$n,title:(0,Q.jsx)(B,{id:`settings.tab.title`}),content:(0,Q.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-sidebar-border p-4`,children:[(0,Q.jsx)(`h2`,{className:`font-semibold text-lg`,children:(0,Q.jsx)(B,{id:`settings.title`})}),(0,Q.jsx)(`p`,{className:`text-xs text-sidebar-foreground/70`,children:(0,Q.jsx)(B,{id:`settings.description`})})]}),(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4`,children:(0,Q.jsx)(`div`,{className:`text-sm text-sidebar-foreground/70`,children:(0,Q.jsx)(B,{id:`settings.loading`})})}),children:(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,Q.jsx)(B,{id:`settings.section.session_display`})}),(0,Q.jsx)(df,{openingProjectId:e??``})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,Q.jsx)(B,{id:`settings.section.notifications`})}),(0,Q.jsx)(sf,{})]})]})})]})},h={id:`system-info`,icon:mt,title:(0,Q.jsx)(B,{id:`settings.section.system_info`}),content:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Sd,{}),children:(0,Q.jsx)(st,{})})},g=[...n,m,h],[_,v]=(0,Z.useState)(r??g[0]?.id??`settings`),b=e=>{if(c){v(e),c(e);return}o?(v(e),s?.()):_===e?s?.():v(e)},x=g.find(e=>e.id===_)?.content,S=!o;return(0,Q.jsxs)(`div`,{className:J(`h-full border-r border-sidebar-border transition-all duration-300 ease-in-out flex bg-sidebar text-sidebar-foreground`,S?a?`w-full`:`w-80 lg:w-80`:`w-(--spacing-sidebar-icon-menu-mobile) md:w-(--spacing-sidebar-icon-menu)`,t),children:[(0,Q.jsx)(`div`,{className:`w-(--spacing-sidebar-icon-menu-mobile) md:w-(--spacing-sidebar-icon-menu) flex flex-col border-r border-sidebar-border bg-sidebar/50`,children:(0,Q.jsxs)(lt,{children:[i!==void 0&&(0,Q.jsx)(`div`,{className:`border-b border-sidebar-border`,children:i}),(0,Q.jsx)(`div`,{className:`p-1.5 md:p-2 border-b border-sidebar-border`,children:(0,Q.jsxs)(tt,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:l,className:J(`w-7 h-7 md:w-8 md:h-8 flex items-center justify-center rounded-md transition-colors`,`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,`text-sidebar-foreground/70`),"data-testid":`search-button`,children:(0,Q.jsx)(ce,{className:`w-4 h-4`})})}),(0,Q.jsx)(nt,{side:`right`,children:(0,Q.jsxs)(`p`,{children:[`Search `,(0,Q.jsx)(`kbd`,{className:`ml-1 text-xs opacity-60`,children:`⌘K`})]})})]})}),(0,Q.jsx)(`div`,{className:`flex-1 flex flex-col p-1.5 md:p-2 space-y-0.5 md:space-y-1`,children:g.map(e=>{let t=e.icon;return(0,Q.jsxs)(tt,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>b(e.id),className:J(`w-7 h-7 md:w-8 md:h-8 flex items-center justify-center rounded-md transition-colors`,`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,_===e.id&&S?`bg-sidebar-accent text-sidebar-accent-foreground shadow-sm`:`text-sidebar-foreground/70`),"data-testid":`${e.id}-tab-button`,children:(0,Q.jsx)(t,{className:`w-4 h-4`})})}),(0,Q.jsx)(nt,{side:`right`,children:(0,Q.jsx)(`p`,{children:e.title})})]},e.id)})}),u&&(0,Q.jsx)(`div`,{className:`p-1.5 md:p-2 border-t border-sidebar-border`,children:(0,Q.jsxs)(tt,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void p(),className:J(`w-7 h-7 md:w-8 md:h-8 flex items-center justify-center rounded-md transition-colors`,`hover:bg-destructive/10 hover:text-destructive`,`text-sidebar-foreground/70`),"data-testid":`logout-button`,children:(0,Q.jsx)(zn,{className:`w-4 h-4`})})}),(0,Q.jsx)(nt,{side:`right`,children:(0,Q.jsx)(`p`,{children:`Logout`})})]})})]})}),S&&(0,Q.jsx)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:x})]})},Vf=({currentSessionId:e,projectId:t,className:n,initialTab:r})=>{let{isLeftPanelOpen:i}=Ga(),{toggleLeftPanel:a}=Ka(),o=cf(),s=e??``,c=(0,Z.useMemo)(()=>[{id:`sessions`,icon:ye,title:(0,Q.jsx)(B,{id:`sidebar.show.session.list`}),content:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Sd,{}),children:(0,Q.jsx)(kf,{currentSessionId:s,projectId:t})})},{id:`mcp`,icon:Jn,title:(0,Q.jsx)(B,{id:`sidebar.show.mcp.settings`}),content:(0,Q.jsx)(ff,{projectId:t})},{id:`tasks`,icon:Ln,title:(0,Q.jsx)(B,{id:`sidebar.show.task.list`}),content:(0,Q.jsx)(Rf,{projectId:t,sessionId:s})},...o?[]:[{id:`scheduler`,icon:ln,title:(0,Q.jsx)(B,{id:`sidebar.show.scheduler.jobs`}),content:(0,Q.jsx)(Of,{projectId:t,sessionId:s})}]],[s,t,o]);return(0,Q.jsx)(`div`,{className:J(`hidden md:flex h-full w-full`,n),children:(0,Q.jsx)(Bf,{projectId:t,additionalTabs:c,defaultActiveTab:r,headerButton:(0,Q.jsx)(lt,{children:(0,Q.jsxs)(tt,{children:[(0,Q.jsx)(ot,{asChild:!0,children:(0,Q.jsx)(ve,{to:`/projects`,className:`w-(--spacing-sidebar-icon-menu) h-(--spacing-sidebar-icon-menu) flex items-center justify-center hover:bg-sidebar-accent transition-colors`,children:(0,Q.jsx)(rn,{className:`w-4 h-4 text-sidebar-foreground/70`})})}),(0,Q.jsx)(nt,{side:`right`,children:(0,Q.jsx)(`p`,{children:(0,Q.jsx)(B,{id:`sidebar.back.to.projects`})})})]})}),fillWidth:!0,isContentHidden:!i,onToggle:a})})},Hf=({projectId:e,sessionId:t,tab:n})=>(kd(),jd(),(0,Q.jsx)(cs,{projectId:e,sessionId:t,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Sd,{}),children:(0,Q.jsx)(Uf,{projectId:e,sessionId:t,tab:n})})})),Uf=({projectId:e,sessionId:t,tab:n})=>{let[r,i]=(0,Z.useState)(!1),a=fs(),o=Od({onSwipe:e=>{e===`right`&&!r&&i(!0)},edgeWidth:30,enabled:a}),s=Za(),c=Qa(),l=D(Aa),{data:u}=Md(e),d=u.pages[0]?.project,f=d?.meta.projectPath??d?.claudeProjectPath,p=d?.meta.projectName??`Untitled Project`,m=p?`${p} - Claude Code Viewer`:`Claude Code Viewer`,h=s&&!a?`${c}%`:`0`,g=(0,Z.useCallback)(()=>{i(!0)},[]),_=(0,Z.useCallback)(()=>{i(!1)},[]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`title`,{children:m}),a&&(0,Q.jsx)(zf,{currentSessionId:t??``,projectId:e,isOpen:r,onClose:_,initialTab:n}),a&&r&&(0,Q.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-black/30 md:hidden`,onClick:_,"aria-label":`Close sidebar`}),(0,Q.jsxs)(`div`,{ref:o,className:J(`flex h-full overflow-hidden`,a&&`transition-transform duration-300 ease-out`),style:a&&r?{transform:`translateX(75vw)`}:void 0,children:[(0,Q.jsx)(Td,{children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Sd,{}),children:(0,Q.jsx)(Vf,{currentSessionId:t,projectId:e,initialTab:n})})}),(0,Q.jsxs)(`div`,{className:J(`flex flex-col flex-1 min-w-0`,!l&&`transition-all duration-200`),style:{marginRight:h},children:[(0,Q.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Sd,{}),children:(0,Q.jsx)(tf,{projectId:e,sessionId:t,projectPath:f,projectName:p,onMobileMenuOpen:a?g:void 0})})}),(0,Q.jsx)(Ds,{cwd:f})]}),(0,Q.jsx)(ks,{projectId:e,sessionId:t,gitTabContent:(0,Q.jsx)(cd,{projectId:e,sessionId:t}),filesToolsTabContent:t!==void 0&&t!==``?(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Sd,{}),children:(0,Q.jsx)(Vu,{projectId:e,sessionId:t})}):(0,Q.jsx)(Bu,{}),reviewTabContent:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(Sd,{}),children:(0,Q.jsx)(yd,{projectId:e,sessionId:t})})})]})]})},Wf=()=>{let e=Pt.useParams(),{sessionId:t,tab:n}=Pt.useSearch();return(0,Q.jsx)(dt,{children:(0,Q.jsx)(Hf,{projectId:e.projectId,sessionId:t,tab:n})})};export{Wf as component};
|