@kimuson/claude-code-viewer 0.7.0 → 0.7.2
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 +22 -0
- package/dist/main.js +1708 -1401
- package/dist/main.js.map +4 -4
- package/dist/migrations/20260403053302_nappy_night_thrasher/migration.sql +28 -0
- package/dist/migrations/20260403053302_nappy_night_thrasher/snapshot.json +318 -0
- package/dist/static/assets/{AuthProvider-BKc7q7ka.js → AuthProvider-Ds-c4CWc.js} +1 -1
- package/dist/static/assets/{ProtectedRoute-Clw5r4X-.js → ProtectedRoute-BTfjJdM-.js} +1 -1
- package/dist/static/assets/{dist-DiGJ7VFi.js → dist-Cartj9I0.js} +3 -3
- package/dist/static/assets/index-BD93fXJt.js +20 -0
- package/dist/static/assets/index-DNPVlDui.css +2 -0
- package/dist/static/assets/{login-pLhQHKNI.js → login-CKSjZM5v.js} +1 -1
- package/dist/static/assets/messages-BIF6nUZW.js +1 -0
- package/dist/static/assets/messages-BLphVEYK.js +1 -0
- package/dist/static/assets/messages-CuPsU53l.js +1 -0
- package/dist/static/assets/{projects-BVPr5gWf.js → projects-DH0K12HM.js} +1 -1
- package/dist/static/assets/routes-CzLZwWu9.js +1 -0
- package/dist/static/assets/session-CvxVXyyO.js +1 -0
- package/dist/static/assets/session-TzwkQ1Zv.js +12 -0
- package/dist/static/index.html +4 -4
- package/dist/static/sw.js +1 -1
- package/package.json +3 -1
- package/dist/static/assets/index-26yPYMZp.css +0 -2
- package/dist/static/assets/index-BO-D9mWo.js +0 -20
- package/dist/static/assets/messages-Cq0t_Ljz.js +0 -1
- package/dist/static/assets/messages-DJ70MfCl.js +0 -1
- package/dist/static/assets/messages-DRdgpO3i.js +0 -1
- package/dist/static/assets/routes-9aZugTrf.js +0 -1
- package/dist/static/assets/session-BkAg5Fs5.js +0 -1
- package/dist/static/assets/session-D-iyWO70.js +0 -8
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{d as t,f as n,n as r,t as i}from"./markdown-parser-vendor-D9j1a-bm.js";import{A as a,B as o,C as s,D as c,F as l,G as u,H as d,I as f,L as p,M as m,N as h,P as g,R as _,b as v,ct as y,d as b,f as x,g as S,h as C,i as w,j as T,k as E,m as D,n as O,o as k,p as A,r as j,st as M,u as ee,v as N,x as te,y as ne}from"./AuthProvider-Ds-c4CWc.js";import{$ as re,A as P,B as ie,C as ae,D as oe,E as se,F as ce,G as le,H as F,I as ue,J as de,K as fe,L as pe,N as me,O as I,P as he,Q as ge,R as _e,S as ve,T as ye,U as be,V as xe,W as L,X as Se,Y as Ce,Z as we,_ as Te,a as Ee,b as De,c as Oe,d as ke,et as Ae,f as je,g as Me,h as Ne,i as Pe,j as Fe,k as Ie,l as Le,m as Re,n as R,o as ze,p as Be,q as Ve,s as He,u as Ue,v as We,w as Ge,x as Ke,y as qe,z as Je}from"./dist-Cartj9I0.js";import{n as z,r as B}from"./dist-CG2L4mx5.js";import{t as V}from"./createLucideIcon-BL_meogc.js";import{A as H,C as Ye,D as Xe,E as Ze,M as Qe,O as $e,S as et,T as tt,_ as nt,a as rt,b as it,c as at,d as ot,f as st,g as U,h as ct,i as lt,j as ut,k as dt,l as ft,m as pt,n as mt,o as ht,p as gt,r as _t,s as vt,t as yt,u as bt,v as xt,w as St,x as Ct,y as wt}from"./ProtectedRoute-BTfjJdM-.js";import{t as Tt}from"./eye-SsvAY8oF.js";import{a as Et,d as Dt,f as Ot,i as kt,n as At,o as W,r as jt,s as G,t as Mt,u as Nt}from"./card-DGrqtTaC.js";import{t as Pt}from"./input-B_6IT1CP.js";import{a as Ft,c as It,d as Lt,f as Rt,g as zt,h as Bt,i as Vt,l as Ht,n as Ut,o as Wt,p as Gt,r as Kt,s as qt,t as Jt,u as Yt}from"./index-BD93fXJt.js";import{t as K}from"./label-Cw6sZ5kQ.js";import{n as Xt,t as Zt}from"./xterm-vendor-DRG2K165.js";import{_ as Qt,a as $t,c as en,d as tn,f as nn,g as rn,h as an,i as on,l as sn,m as cn,n as ln,o as un,p as dn,r as fn,s as pn,t as mn,u as hn,v as gn,y as q}from"./syntax-highlighter-vendor-CwGXx8v4.js";var _n=V(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),vn=V(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),yn=V(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),bn=V(`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`}]]),xn=V(`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`}]]),Sn=V(`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`}]]),Cn=V(`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`}]]),wn=V(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Tn=V(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),En=V(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Dn=V(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),On=V(`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`}]]),kn=V(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),An=V(`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`}]]),jn=V(`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`}]]),Mn=V(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Nn=V(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Pn=V(`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`}]]),Fn=V(`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`}]]),In=V(`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`}]]),Ln=V(`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`}]]),Rn=V(`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`}]]),zn=V(`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`}]]),Bn=V(`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`}]]),Vn=V(`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`}]]),Hn=V(`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`}]]),Un=V(`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`}]]),Wn=V(`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`}]]),Gn=V(`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`}]]),Kn=V(`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`}]]),qn=V(`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`}]]),Jn=V(`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`}]]),Yn=V(`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`}]]),Xn=V(`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`}]]),Zn=V(`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`}]]),Qn=V(`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`}]]),$n=V(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),er=V(`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`}]]),tr=V(`message-square-text`,[[`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:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),nr=V(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),rr=V(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),ir=V(`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`}]]),ar=V(`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`}]]),or=V(`panel-bottom`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),sr=V(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),cr=V(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),lr=V(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),ur=V(`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`}]]),dr=V(`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`}]]),fr=V(`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`}]]),pr=V(`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`}]]),mr=V(`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`}]]),hr=V(`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`}]]),gr=V(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),_r=V(`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`}]]),vr=V(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),yr=V(`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`}]]),br=V(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),xr=V(`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`}]]),Sr=V(`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`}]]),Cr=V(`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`}]]),wr=V(`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`}]]),Tr=class extends d{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Gt()})}getOptimisticResult(e){return e.behavior=Gt(),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:Lt(t,n.data),hasPreviousPage:Rt(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}};function Er(e,t){return p({...e,enabled:!0,suspense:!0,throwOnError:_},Tr,t)}var J=e(n(),1);function Dr(e,t){let n=o(t),r=n.getQueryCache();return J.useSyncExternalStore(J.useCallback(e=>r.subscribe(u.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var Or=e(Ae(),1),Y=t();function kr(e){let t=e+`CollectionProvider`,[n,r]=Ie(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=J.useRef(null),a=J.useRef(new Map).current;return(0,Y.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Fe(s),l=J.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,Y.jsx)(c,{ref:Ot(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Fe(u),p=J.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=J.useRef(null),s=Ot(t,o),c=a(u,n);return J.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,Y.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return J.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 Ar=J.createContext(void 0);function jr(e){let t=J.useContext(Ar);return e||t||`ltr`}var Mr=`rovingFocusGroup.onEntryFocus`,Nr={bubbles:!1,cancelable:!0},Pr=`RovingFocusGroup`,[Fr,Ir,Lr]=kr(Pr),[Rr,zr]=Ie(Pr,[Lr]),[Br,Vr]=Rr(Pr),Hr=J.forwardRef((e,t)=>(0,Y.jsx)(Fr.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,Y.jsx)(Fr.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,Y.jsx)(Ur,{...e,ref:t})})}));Hr.displayName=Pr;var Ur=J.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=J.useRef(null),p=Ot(t,f),m=jr(a),[h,g]=se({prop:o,defaultProp:s??null,onChange:c,caller:Pr}),[_,v]=J.useState(!1),y=ae(l),b=Ir(n),x=J.useRef(!1),[S,C]=J.useState(0);return J.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Mr,y),()=>e.removeEventListener(Mr,y)},[y]),(0,Y.jsx)(Br,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:J.useCallback(e=>g(e),[g]),onItemShiftTab:J.useCallback(()=>v(!0),[]),onFocusableItemAdd:J.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:J.useCallback(()=>C(e=>e-1),[]),children:(0,Y.jsx)(P.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:I(e.onMouseDown,()=>{x.current=!0}),onFocus:I(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Mr,Nr);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Yr([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:I(e.onBlur,()=>v(!1))})})}),Wr=`RovingFocusGroupItem`,Gr=J.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Ge(),l=a||c,u=Vr(Wr,n),d=u.currentTabStopId===l,f=Ir(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return J.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,Y.jsx)(Fr.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,Y.jsx)(P.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:I(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:I(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:I(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Jr(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?Xr(n,r+1):n.slice(r+1)}setTimeout(()=>Yr(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Gr.displayName=Wr;var Kr={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function qr(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Jr(e,t,n){let r=qr(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Kr[r]}function Yr(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Xr(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Zr=Hr,Qr=Gr;function $r(e,[t,n]){return Math.min(n,Math.max(t,e))}var ei=[` `,`Enter`,`ArrowUp`,`ArrowDown`],ti=[` `,`Enter`],ni=`Select`,[ri,ii,ai]=kr(ni),[oi,si]=Ie(ni,[ai,Ct]),ci=Ct(),[li,ui]=oi(ni),[di,fi]=oi(ni),pi=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=ci(t),[g,_]=J.useState(null),[v,y]=J.useState(null),[b,x]=J.useState(!1),S=jr(l),[C,w]=se({prop:r,defaultProp:i??!1,onChange:a,caller:ni}),[T,E]=se({prop:o,defaultProp:s,onChange:c,caller:ni}),D=J.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=J.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,Y.jsx)(it,{...h,children:(0,Y.jsxs)(li,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:Ge(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,Y.jsx)(ri.Provider,{scope:t,children:(0,Y.jsx)(di,{scope:e.__scopeSelect,onNativeOptionAdd:J.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:J.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,Y.jsxs)(ca,{"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,Y.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};pi.displayName=ni;var mi=`SelectTrigger`,hi=J.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=ci(n),o=ui(mi,n),s=o.disabled||r,c=Ot(t,o.onTriggerChange),l=ii(n),u=J.useRef(`touch`),[d,f,p]=ua(e=>{let t=l().filter(e=>!e.disabled),n=da(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,Y.jsx)(nt,{asChild:!0,...a,children:(0,Y.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":la(o.value)?``:void 0,...i,ref:c,onClick:I(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:I(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:I(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&ei.includes(e.key)&&(m(),e.preventDefault())})})})});hi.displayName=mi;var gi=`SelectValue`,_i=J.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=ui(gi,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Ot(t,c.onValueNodeChange);return oe(()=>{l(u)},[l,u]),(0,Y.jsx)(P.span,{...s,ref:d,style:{pointerEvents:`none`},children:la(c.value)?(0,Y.jsx)(Y.Fragment,{children:o}):a})});_i.displayName=gi;var vi=`SelectIcon`,yi=J.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,Y.jsx)(P.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});yi.displayName=vi;var bi=`SelectPortal`,xi=e=>(0,Y.jsx)(De,{asChild:!0,...e});xi.displayName=bi;var Si=`SelectContent`,Ci=J.forwardRef((e,t)=>{let n=ui(Si,e.__scopeSelect),[r,i]=J.useState();if(oe(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Or.createPortal((0,Y.jsx)(Ti,{scope:e.__scopeSelect,children:(0,Y.jsx)(ri.Slot,{scope:e.__scopeSelect,children:(0,Y.jsx)(`div`,{children:e.children})})}),t):null}return(0,Y.jsx)(ki,{...e,ref:t})});Ci.displayName=Si;var wi=10,[Ti,Ei]=oi(Si),Di=`SelectContentImpl`,Oi=Fe(`SelectContent.RemoveScroll`),ki=J.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=ui(Si,n),[y,b]=J.useState(null),[x,S]=J.useState(null),C=Ot(t,e=>b(e)),[w,T]=J.useState(null),[E,D]=J.useState(null),O=ii(n),[k,A]=J.useState(!1),j=J.useRef(!1);J.useEffect(()=>{if(y)return Te(y)},[y]),qe();let M=J.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=J.useCallback(()=>M([w,y]),[M,w,y]);J.useEffect(()=>{k&&ee()},[k,ee]);let{onOpenChange:N,triggerPointerDownPosRef:te}=v;J.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(te.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(te.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||N(!1),document.removeEventListener(`pointermove`,t),te.current=null};return te.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,N,te]),J.useEffect(()=>{let e=()=>N(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[N]);let[ne,re]=ua(e=>{let t=O().filter(e=>!e.disabled),n=da(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),P=J.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]),ie=J.useCallback(()=>y?.focus(),[y]),ae=J.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),oe=r===`popper`?Ni:ji,se=oe===Ni?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,Y.jsx)(Ti,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:P,selectedItem:w,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:ee,selectedItemText:E,position:r,isPositioned:k,searchRef:ne,children:(0,Y.jsx)(We,{as:Oi,allowPinchZoom:!0,children:(0,Y.jsx)(Ke,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:I(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,Y.jsx)(ve,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,Y.jsx)(oe,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...se,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:I(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&re(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()}})})})})})})});ki.displayName=Di;var Ai=`SelectItemAlignedPosition`,ji=J.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=ui(Si,n),o=Ei(Si,n),[s,c]=J.useState(null),[l,u]=J.useState(null),d=Ot(t,e=>u(e)),f=ii(n),p=J.useRef(!1),m=J.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=J.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-wi,d=$r(a,[wi,Math.max(wi,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-wi,d=$r(a,[wi,Math.max(wi,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-wi*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-wi,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=`${wi}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]);oe(()=>y(),[y]);let[b,x]=J.useState();return oe(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,Y.jsx)(Pi,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:J.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,Y.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,Y.jsx)(P.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});ji.displayName=Ai;var Mi=`SelectPopperPosition`,Ni=J.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=wi,...a}=e,o=ci(n);return(0,Y.jsx)(wt,{...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)`}})});Ni.displayName=Mi;var[Pi,Fi]=oi(Si,{}),Ii=`SelectViewport`,Li=J.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=Ei(Ii,n),o=Fi(Ii,n),s=Ot(t,a.onViewportChange),c=J.useRef(0);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(ri.Slot,{scope:n,children:(0,Y.jsx)(P.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:I(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-wi*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})})})]})});Li.displayName=Ii;var Ri=`SelectGroup`,[zi,Bi]=oi(Ri),Vi=J.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Ge();return(0,Y.jsx)(zi,{scope:n,id:i,children:(0,Y.jsx)(P.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Vi.displayName=Ri;var Hi=`SelectLabel`,Ui=J.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Bi(Hi,n);return(0,Y.jsx)(P.div,{id:i.id,...r,ref:t})});Ui.displayName=Hi;var Wi=`SelectItem`,[Gi,Ki]=oi(Wi),qi=J.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=ui(Wi,n),c=Ei(Wi,n),l=s.value===r,[u,d]=J.useState(a??``),[f,p]=J.useState(!1),m=Ot(t,e=>c.itemRefCallback?.(e,r,i)),h=Ge(),g=J.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,Y.jsx)(Gi,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:J.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,Y.jsx)(ri.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,Y.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:I(o.onFocus,()=>p(!0)),onBlur:I(o.onBlur,()=>p(!1)),onClick:I(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:I(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:I(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:I(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:I(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:I(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(ti.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});qi.displayName=Wi;var Ji=`SelectItemText`,Yi=J.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=ui(Ji,n),s=Ei(Ji,n),c=Ki(Ji,n),l=fi(Ji,n),[u,d]=J.useState(null),f=Ot(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=J.useMemo(()=>(0,Y.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return oe(()=>(h(m),()=>g(m)),[h,g,m]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(P.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Or.createPortal(a.children,o.valueNode):null]})});Yi.displayName=Ji;var Xi=`SelectItemIndicator`,Zi=J.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Ki(Xi,n).isSelected?(0,Y.jsx)(P.span,{"aria-hidden":!0,...r,ref:t}):null});Zi.displayName=Xi;var Qi=`SelectScrollUpButton`,$i=J.forwardRef((e,t)=>{let n=Ei(Qi,e.__scopeSelect),r=Fi(Qi,e.__scopeSelect),[i,a]=J.useState(!1),o=Ot(t,r.onScrollButtonChange);return oe(()=>{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,Y.jsx)(na,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});$i.displayName=Qi;var ea=`SelectScrollDownButton`,ta=J.forwardRef((e,t)=>{let n=Ei(ea,e.__scopeSelect),r=Fi(ea,e.__scopeSelect),[i,a]=J.useState(!1),o=Ot(t,r.onScrollButtonChange);return oe(()=>{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,Y.jsx)(na,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});ta.displayName=ea;var na=J.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Ei(`SelectScrollButton`,n),o=J.useRef(null),s=ii(n),c=J.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return J.useEffect(()=>()=>c(),[c]),oe(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,Y.jsx)(P.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:I(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:I(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:I(i.onPointerLeave,()=>{c()})})}),ra=`SelectSeparator`,ia=J.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,Y.jsx)(P.div,{"aria-hidden":!0,...r,ref:t})});ia.displayName=ra;var aa=`SelectArrow`,oa=J.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=ci(n),a=ui(aa,n),o=Ei(aa,n);return a.open&&o.position===`popper`?(0,Y.jsx)(xt,{...i,...r,ref:t}):null});oa.displayName=aa;var sa=`SelectBubbleInput`,ca=J.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=J.useRef(null),a=Ot(r,i),o=et(t);return J.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,Y.jsx)(P.select,{...n,style:{...Ye,...n.style},ref:a,defaultValue:t})});ca.displayName=sa;function la(e){return e===``||e===void 0}function ua(e){let t=ae(e),n=J.useRef(``),r=J.useRef(0),i=J.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=J.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return J.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function da(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=fa(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 fa(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var pa=pi,ma=hi,ha=_i,ga=yi,_a=xi,va=Ci,ya=Li,ba=qi,xa=Yi,Sa=Zi,Ca=$i,wa=ta,Ta=`Tabs`,[Ea,Da]=Ie(Ta,[zr]),Oa=zr(),[ka,Aa]=Ea(Ta),ja=J.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=jr(s),[d,f]=se({prop:r,onChange:i,defaultProp:a??``,caller:Ta});return(0,Y.jsx)(ka,{scope:n,baseId:Ge(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,Y.jsx)(P.div,{dir:u,"data-orientation":o,...l,ref:t})})});ja.displayName=Ta;var Ma=`TabsList`,Na=J.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Aa(Ma,n),o=Oa(n);return(0,Y.jsx)(Zr,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,Y.jsx)(P.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Na.displayName=Ma;var Pa=`TabsTrigger`,Fa=J.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Aa(Pa,n),s=Oa(n),c=Ra(o.baseId,r),l=za(o.baseId,r),u=r===o.value;return(0,Y.jsx)(Qr,{asChild:!0,...s,focusable:!i,active:u,children:(0,Y.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:I(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:I(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:I(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Fa.displayName=Pa;var Ia=`TabsContent`,La=J.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Aa(Ia,n),c=Ra(s.baseId,r),l=za(s.baseId,r),u=r===s.value,d=J.useRef(u);return J.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,Y.jsx)(ye,{present:i||u,children:({present:n})=>(0,Y.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})})});La.displayName=Ia;function Ra(e,t){return`${e}-trigger-${t}`}function za(e,t){return`${e}-content-${t}`}var Ba=ja,Va=Na,Ha=Fa,Ua=La,Wa=h(!1),Ga=h(!1),Ka=h(`explorer`),qa=h(28),Ja=h(!0),Ya=h(null),Xa=h(null),Za=h(``),Qa=h({current:null}),$a=h(!1),eo=h(20),to=h(!1),no=h(40),ro=(e,t,n)=>Math.min(n,Math.max(t,e)),io=()=>({isLeftPanelOpen:a($a),leftPanelWidth:a(eo)}),ao=()=>{let e=m(),t=T($a),n=T(eo);return{setIsLeftPanelOpen:t,toggleLeftPanel:(0,J.useCallback)(()=>{t(!e.get($a))},[t,e]),setLeftPanelWidth:(0,J.useCallback)(e=>{n(ro(e,15,40))},[n])}},oo=()=>({isBottomPanelOpen:a(to),bottomPanelHeight:a(no)}),so=()=>{let e=T(to),t=T(no);return{setIsBottomPanelOpen:e,setBottomPanelHeight:(0,J.useCallback)(e=>{t(ro(e,15,50))},[t])}},co=(e,t,n)=>Math.min(n,Math.max(t,e)),lo=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}},uo=()=>a(Ga),fo=()=>a(qa),po=()=>({isOpen:uo(),activeTab:a(Ka),width:fo(),browserUrl:a(Ya),inputUrl:a(Za)}),mo=()=>a(Ja),ho=()=>({setIsTodoSectionOpen:T(Ja)}),go=()=>{let e=m(),t=T(Ga),n=T(Ka),r=T(qa),i=T(Ya),a=T(Xa),o=T(Za);return{openPanel:(0,J.useCallback)(e=>{t(!0),e&&n(e)},[t,n]),closePanel:(0,J.useCallback)(()=>{t(!1)},[t]),togglePanel:(0,J.useCallback)(()=>{t(!e.get(Ga))},[t,e]),setActiveTab:n,setWidth:(0,J.useCallback)(e=>{r(co(e,20,80))},[r]),setInputUrl:o,setCurrentUrl:a,openBrowser:(0,J.useCallback)(e=>{if(lo(e)){R.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),a(e),o(e),n(`browser`),t(!0)},[i,a,o,n,t]),closeBrowser:(0,J.useCallback)(()=>{i(null),a(null),o(``)},[i,a,o]),reloadBrowser:(0,J.useCallback)(()=>{let t=e.get(Qa),n=e.get(Xa),r=e.get(Ya),i=n??r;t.current!==null&&i!==null&&i!==``&&(t.current.src=i)},[e]),handleUrlSubmit:(0,J.useCallback)(()=>{let t=e.get(Za);if(t){if(lo(t)){R.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),a(t)}},[e,i,a])}},_o=1,vo=.9,yo=.8,bo=.17,xo=.1,So=.999,Co=.9999,wo=.99,To=/[\\\/_+.#"@\[\(\{&]/,Eo=/[\\\/_+.#"@\[\(\{&]/g,Do=/[\s-]/,Oo=/[\s-]/g;function ko(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?_o:wo;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=ko(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=_o:To.test(e.charAt(l-1))?(d*=yo,p=e.slice(i,l-1).match(Eo),p&&i>0&&(d*=So**+p.length)):Do.test(e.charAt(l-1))?(d*=vo,m=e.slice(i,l-1).match(Oo),m&&i>0&&(d*=So**+m.length)):(d*=bo,i>0&&(d*=So**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Co)),(d<xo&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=ko(e,t,n,r,l+1,a+2,o),f*xo>d&&(d=f*xo)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Ao(e){return e.toLowerCase().replace(Oo,` `)}function jo(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,ko(e,t,Ao(e),Ao(t),0,0,{})}var Mo=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Nt(`Primitive.${t}`),r=J.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,Y.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),No=`[cmdk-group=""]`,Po=`[cmdk-group-items=""]`,Fo=`[cmdk-group-heading=""]`,Io=`[cmdk-item=""]`,Lo=`${Io}:not([aria-disabled="true"])`,Ro=`cmdk-item-select`,zo=`data-value`,Bo=(e,t,n)=>jo(e,t,n),Vo=J.createContext(void 0),Ho=()=>J.useContext(Vo),Uo=J.createContext(void 0),Wo=()=>J.useContext(Uo),Go=J.createContext(void 0),Ko=J.forwardRef((e,t)=>{let n=os(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=os(()=>new Set),i=os(()=>new Map),a=os(()=>new Map),o=os(()=>new Set),s=is(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Ge(),y=Ge(),b=Ge(),x=J.useRef(null),S=ls();as(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),as(()=>{S(6,k)},[]);let C=J.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=J.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??Bo;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(Po);t?t.appendChild(e.parentElement===t?e:e.closest(`${Po} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Po} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${No}[${zo}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(zo);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(No)?.querySelector(Fo))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Io}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Lo)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(zo))}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(zo))}function N(e){let t=A()?.closest(No),n;for(;t&&!n;)t=e>0?ns(t,No):rs(t,No),n=t?.querySelector(Lo);n?C.setState(`value`,n.getAttribute(zo)):ee(e)}let te=()=>M(j().length-1),ne=e=>{e.preventDefault(),e.metaKey?te():e.altKey?N(1):ee(1)},re=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?N(-1):ee(-1)};return J.createElement(Mo.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&&ne(e);break;case`ArrowDown`:ne(e);break;case`p`:case`k`:g&&e.ctrlKey&&re(e);break;case`ArrowUp`:re(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),te();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(Ro);t.dispatchEvent(e)}}}}},J.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:fs},c),ds(e,e=>J.createElement(Uo.Provider,{value:C},J.createElement(Vo.Provider,{value:w},e))))}),qo=J.forwardRef((e,t)=>{let n=Ge(),r=J.useRef(null),i=J.useContext(Go),a=Ho(),o=is(e),s=o.current?.forceMount??i?.forceMount;as(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=cs(n,r,[e.value,e.children,r],e.keywords),l=Wo(),u=ss(e=>e.value&&e.value===c.current),d=ss(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);J.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Ro,f),()=>t.removeEventListener(Ro,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 J.createElement(Mo.div,{ref:Dt(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)}),Jo=J.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Ge(),s=J.useRef(null),c=J.useRef(null),l=Ge(),u=Ho(),d=ss(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);as(()=>u.group(o),[]),cs(o,s,[e.value,e.heading,c]);let f=J.useMemo(()=>({id:o,forceMount:i}),[i]);return J.createElement(Mo.div,{ref:Dt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&J.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),ds(e,e=>J.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},J.createElement(Go.Provider,{value:f},e))))}),Yo=J.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=J.useRef(null),a=ss(e=>!e.search);return!n&&!a?null:J.createElement(Mo.div,{ref:Dt(i,t),...r,"cmdk-separator":``,role:`separator`})}),Xo=J.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=Wo(),o=ss(e=>e.search),s=ss(e=>e.selectedItemId),c=Ho();return J.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),J.createElement(Mo.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)}})}),Zo=J.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=J.useRef(null),o=J.useRef(null),s=ss(e=>e.selectedItemId),c=Ho();return J.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)}}},[]),J.createElement(Mo.div,{ref:Dt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},ds(e,e=>J.createElement(`div`,{ref:Dt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Qo=J.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return J.createElement(Me,{open:n,onOpenChange:r},J.createElement(Ne,{container:o},J.createElement(Re,{"cmdk-overlay":``,className:i}),J.createElement(Be,{"aria-label":e.label,"cmdk-dialog":``,className:a},J.createElement(Ko,{ref:t,...s}))))}),$o=J.forwardRef((e,t)=>ss(e=>e.filtered.count===0)?J.createElement(Mo.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),es=J.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return J.createElement(Mo.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},ds(e,e=>J.createElement(`div`,{"aria-hidden":!0},e)))}),ts=Object.assign(Ko,{List:Zo,Item:qo,Input:Xo,Group:Jo,Separator:Yo,Dialog:Qo,Empty:$o,Loading:es});function ns(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function rs(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function is(e){let t=J.useRef(e);return as(()=>{t.current=e}),t}var as=typeof window>`u`?J.useEffect:J.useLayoutEffect;function os(e){let t=J.useRef();return t.current===void 0&&(t.current=e()),t}function ss(e){let t=Wo(),n=()=>e(t.snapshot());return J.useSyncExternalStore(t.subscribe,n,n)}function cs(e,t,n,r=[]){let i=J.useRef(),a=Ho();return as(()=>{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(zo,s),i.current=s}),i}var ls=()=>{let[e,t]=J.useState(),n=os(()=>new Map);return as(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function us(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function ds({asChild:e,children:t},n){return e&&J.isValidElement(t)?J.cloneElement(us(t),{ref:t.ref},n(t.props.children)):n(t)}var fs={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},ps=({className:e,...t})=>(0,Y.jsx)(ts,{"data-slot":`command`,className:G(`bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md`,e),...t}),ms=({className:e,...t})=>(0,Y.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,Y.jsx)(we,{className:`size-4 shrink-0 opacity-50`}),(0,Y.jsx)(ts.Input,{"data-slot":`command-input`,className:G(`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})]}),hs=({className:e,...t})=>(0,Y.jsx)(ts.List,{"data-slot":`command-list`,className:G(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t}),gs=({...e})=>(0,Y.jsx)(ts.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e}),_s=({className:e,...t})=>(0,Y.jsx)(ts.Group,{"data-slot":`command-group`,className:G(`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}),vs=({className:e,...t})=>(0,Y.jsx)(ts.Item,{"data-slot":`command-item`,className:G(`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}),ys=e=>e.replace(/^\/(?:home|Users)\/[^/]+/,`~`),bs=({currentProjectId:e,currentProjectPath:t})=>{let[n,r]=(0,J.useState)(!1),i=y(),{data:a}=Ce({queryKey:te.queryKey,queryFn:te.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!==``?ys(s):void 0,l=t=>{r(!1),t!==e&&i({to:`/projects/$projectId/session`,params:{projectId:t}})};return(0,Y.jsxs)(ft,{open:n,onOpenChange:r,children:[(0,Y.jsx)(ot,{asChild:!0,children:(0,Y.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,Y.jsx)(Ze,{className:`w-3.5 h-3.5 shrink-0 opacity-60`}),(0,Y.jsx)(`span`,{className:`truncate max-w-[300px] font-mono text-xs`,children:c??(0,Y.jsx)(z,{id:`project_switcher.no_project`})}),(0,Y.jsx)(En,{className:`w-3.5 h-3.5 shrink-0 opacity-40`})]})}),(0,Y.jsx)(bt,{className:`w-80 p-0 z-[53]`,align:`start`,sideOffset:8,children:(0,Y.jsxs)(ps,{children:[(0,Y.jsx)(ms,{placeholder:`Search projects...`}),(0,Y.jsxs)(hs,{children:[(0,Y.jsx)(gs,{children:(0,Y.jsx)(z,{id:`project_switcher.no_results`})}),(0,Y.jsx)(_s,{children:o.map(t=>{let n=t.meta.projectPath??t.claudeProjectPath,r=ys(n);return(0,Y.jsxs)(vs,{value:n,onSelect:()=>l(t.id),className:`gap-2`,children:[(0,Y.jsx)(ut,{className:G(`w-3.5 h-3.5 shrink-0`,t.id===e?`opacity-100`:`opacity-0`)}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-xs`,children:r})]},t.id)})})]})]})})]})},xs=({children:e,projectId:t,projectPath:n,currentBranch:r,sessionId:i})=>{let{isLeftPanelOpen:a}=io(),{setIsLeftPanelOpen:o}=ao(),{isBottomPanelOpen:s}=oo(),{setIsBottomPanelOpen:c}=so(),l=uo(),{togglePanel:u}=go(),[d,f]=(0,J.useState)(!1);return(0,Y.jsxs)(`div`,{className:`flex flex-col h-screen w-screen overflow-hidden bg-background`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0 flex-1 overflow-x-auto overflow-y-hidden`,children:[(0,Y.jsx)(`div`,{className:`shrink-0`,children:(0,Y.jsx)(bs,{currentProjectId:t,currentProjectPath:n})}),r!==void 0&&r!==``&&(0,Y.jsxs)(U,{variant:`outline`,className:`h-5 text-[11px] px-2 bg-background/50 border-border/60 gap-1 shrink-0`,children:[(0,Y.jsx)(Un,{className:`w-3 h-3`}),(0,Y.jsx)(`span`,{className:`max-w-[100px] truncate`,children:r})]}),i!==void 0&&i!==``&&(0,Y.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`,children:i})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,Y.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,Y.jsx)(we,{className:`w-3.5 h-3.5`})}),(0,Y.jsx)(at,{sessionId:i}),(0,Y.jsxs)(pt,{children:[(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{o(!a)},className:G(`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,Y.jsx)(sr,{className:`w-3.5 h-3.5`})})}),(0,Y.jsx)(gt,{side:`bottom`,className:`text-xs`,children:(0,Y.jsx)(z,{id:`layout.toggle_left_panel`})})]}),(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,onClick:()=>c(!s),className:G(`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,Y.jsx)(or,{className:`w-3.5 h-3.5`})})}),(0,Y.jsx)(gt,{side:`bottom`,className:`text-xs`,children:(0,Y.jsx)(z,{id:`layout.toggle_bottom_panel`})})]}),(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,onClick:u,className:G(`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,Y.jsx)(cr,{className:`w-3.5 h-3.5`})})}),(0,Y.jsx)(gt,{side:`bottom`,className:`text-xs`,children:(0,Y.jsx)(z,{id:`layout.toggle_right_panel`})})]})]})]})]}),(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:e}),(0,Y.jsx)(Ee,{open:d,onOpenChange:f,projectId:t})]})},Ss=({onResize:e,onResizeStart:t,onResizeEnd:n,enabled:r=!0})=>{let[i,a]=(0,J.useState)(!1),o=(0,J.useRef)(!1),s=(0,J.useRef)(null),c=(0,J.useRef)(null),l=(0,J.useCallback)(()=>{o.current=!1,a(!1),n?.()},[n]),u=(0,J.useCallback)(()=>{o.current=!0,a(!0),t?.()},[t]),d=(0,J.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),u()},[u]),f=(0,J.useCallback)(e=>{e.stopPropagation(),u()},[u]);return(0,J.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}},Cs=()=>typeof window>`u`?!1:window.innerWidth<=767,ws=`(max-width: 767px)`,Ts=()=>{let[e,t]=(0,J.useState)(Cs);return(0,J.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(ws),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e},Es={up:`\x1B[A`,down:`\x1B[B`,left:`\x1B[D`,right:`\x1B[C`},Ds={up:`↑`,down:`↓`,left:`←`,right:`→`},Os=300,ks=15,As=({onSendData:e})=>{let[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),l=(0,J.useRef)(null),u=(0,J.useRef)(void 0),d=(0,J.useRef)(!1),f=(0,J.useRef)(!1),p=(0,J.useRef)(null),m=(0,J.useRef)(null);(0,J.useEffect)(()=>()=>{u.current!==void 0&&clearTimeout(u.current)},[]),(0,J.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,J.useCallback)((e,t,n,r)=>{let i=n-e,a=r-t;return Math.sqrt(i*i+a*a)<ks?null:Math.abs(i)>Math.abs(a)?i>0?`right`:`left`:a>0?`down`:`up`},[]),g=(0,J.useCallback)(()=>{u.current!==void 0&&(clearTimeout(u.current),u.current=void 0),d.current=!1,o(!1),i(null),l.current=null},[]),_=(0,J.useCallback)(()=>{let e=p.current?.getBoundingClientRect();e&&c({x:e.left+e.width/2,y:e.top})},[]),v=(0,J.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)},Os))},[]),y=(0,J.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>ks){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,J.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(Es[t])}f.current=!0}g()},[h,e,g]),x=(0,J.useCallback)(()=>{g()},[g]),S=(0,J.useCallback)(()=>{if(f.current){f.current=!1;return}_(),n(e=>!e)},[_]),C=(0,J.useCallback)(e=>{e.preventDefault()},[]),w=(0,J.useCallback)(t=>{e(Es[t])},[e]);return(0,Y.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,Y.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,Y.jsx)(ir,{className:`w-3.5 h-3.5`})}),a&&r!==null&&p.current&&(0,Or.createPortal)((0,Y.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:Ds[r]}),document.body),t&&!a&&s!==null&&(0,Or.createPortal)((0,Y.jsxs)(`div`,{ref:m,className:`fixed z-[9999]`,style:{left:s.x,top:s.y-8,transform:`translate(-50%, -100%)`},children:[(0,Y.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,Y.jsx)(`div`,{}),(0,Y.jsx)(js,{direction:`up`,onTap:w}),(0,Y.jsx)(`div`,{}),(0,Y.jsx)(js,{direction:`left`,onTap:w}),(0,Y.jsx)(`div`,{}),(0,Y.jsx)(js,{direction:`right`,onTap:w}),(0,Y.jsx)(`div`,{}),(0,Y.jsx)(js,{direction:`down`,onTap:w}),(0,Y.jsx)(`div`,{})]}),(0,Y.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)]})},js=({direction:e,onTap:t})=>(0,Y.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:Ds[e]}),Ms=`terminalSessionId`,Ns=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}},Ps=e=>e===void 0||e===``?Ms:`${Ms}:${e}`,Fs=e=>{let t=localStorage.getItem(Ps(e));return t!==null&&t.length>0?t:void 0},Is=(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}`:``}`},Ls=e=>{localStorage.removeItem(Ps(e))},Rs=(0,J.forwardRef)(({resetToken:e=0,cwd:t,onProcessExit:n},r)=>{let i=(0,J.useRef)(null),a=(0,J.useRef)(null),o=(0,J.useRef)(null),s=(0,J.useRef)(null),c=(0,J.useRef)(void 0),l=(0,J.useRef)(0),u=(0,J.useRef)(!1),d=(0,J.useRef)(n);d.current=n;let f=(0,J.useRef)(void 0);return(0,J.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,J.useEffect)(()=>{let n=i.current;if(!n)return;e>0&&Ls(t);let r=new Zt({convertEol:!0,cursorBlink:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas`}),p=new Xt;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=Fs(t);c.current=g,l.current=0;let _=new WebSocket(Is(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=Ns(e.data);if(n){if(n.type===`hello`){c.current=n.sessionId,localStorage.setItem(Ps(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,Y.jsx)(`div`,{ref:i,className:`h-full w-full`})});Rs.displayName=`TerminalPanel`;var zs=[{label:`Esc`,type:`data`,data:`\x1B`},{label:`Tab`,type:`data`,data:` `},{label:`Ctrl+C`,type:`signal`,signal:`SIGINT`},{label:`Ctrl+U`,type:`data`,data:``}],Bs=({cwd:e})=>{let{isBottomPanelOpen:t,bottomPanelHeight:n}=oo(),{setIsBottomPanelOpen:r,setBottomPanelHeight:i}=so(),a=Ts(),[o,s]=(0,J.useState)(0),c=(0,J.useRef)(void 0),l=(0,J.useRef)(null);(0,J.useEffect)(()=>()=>{c.current&&clearTimeout(c.current)},[]);let u=(0,J.useCallback)(()=>{c.current=setTimeout(()=>{r(!1)},1500)},[r]),{isResizing:d,handleMouseDown:f,handleTouchStart:p}=Ss({onResize:(0,J.useCallback)(e=>{i((window.innerHeight-e.clientY)/window.innerHeight*100)},[i])});(0,J.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,J.useCallback)(e=>{e.type===`data`?l.current?.sendData(e.data):l.current?.sendSignal(e.signal)},[]),h=(0,J.useCallback)(async()=>{try{let e=await navigator.clipboard.readText();e&&l.current?.sendData(e)}catch{}},[]);return t?(0,Y.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,Y.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,Y.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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 overflow-x-auto flex-1 min-w-0`,children:[(0,Y.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,Y.jsx)(mr,{className:`w-3.5 h-3.5`})}),(0,Y.jsx)(`div`,{className:`w-px h-4 bg-border/60 mx-0.5 flex-shrink-0`}),(0,Y.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,Y.jsx)(jn,{className:`w-3.5 h-3.5`})}),(0,Y.jsx)(As,{onSendData:e=>l.current?.sendData(e)}),(0,Y.jsx)(`div`,{className:`w-px h-4 bg-border/60 mx-0.5 flex-shrink-0`}),zs.map(e=>(0,Y.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,Y.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,Y.jsx)(ar,{className:`w-3.5 h-3.5`})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,Y.jsx)(pr,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(`span`,{children:(0,Y.jsx)(z,{id:`layout.bottom_panel.title`})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.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,Y.jsx)(mr,{className:`w-3 h-3`}),`New session`]}),(0,Y.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,Y.jsx)(ar,{className:`w-3 h-3`})})]})]})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-h-0 bg-muted/5 flex`,children:[(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(Rs,{ref:l,resetToken:o,cwd:e,onProcessExit:u})}),(0,Y.jsxs)(`div`,{className:`flex flex-col w-7 flex-shrink-0 border-l border-border/30`,children:[(0,Y.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,Y.jsx)(Tn,{className:`w-4 h-4`})}),(0,Y.jsx)(`div`,{className:`h-px bg-border/30 flex-shrink-0`}),(0,Y.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,Y.jsx)(H,{className:`w-4 h-4`})})]})]})]}):null},Vs=[{id:`explorer`,icon:zn,label:(0,Y.jsx)(z,{id:`panel.tab.explorer`})},{id:`git`,icon:Wn,label:(0,Y.jsx)(z,{id:`panel.tab.git`})},{id:`review`,icon:An,label:(0,Y.jsx)(z,{id:`panel.tab.review`})},{id:`browser`,icon:Kn,label:(0,Y.jsx)(z,{id:`panel.tab.browser`})}],Hs=({gitTabContent:e,filesToolsTabContent:t,reviewTabContent:n})=>{let{isOpen:r,activeTab:i,width:a,browserUrl:o,inputUrl:s}=po(),{closePanel:c,setActiveTab:l,setWidth:u,setInputUrl:d,setCurrentUrl:f,reloadBrowser:p,handleUrlSubmit:m}=go(),h=Ts(),g=(0,J.useRef)(null),_=T(Qa),v=(0,J.useRef)(null);(0,J.useEffect)(()=>{_(g)},[_]),(0,J.useEffect)(()=>{if(o===null||o===``||!r){v.current=null;return}let e=window.setInterval(()=>{try{let e=g.current?.contentWindow?.location.href;if(e===void 0||e===``||e===`about:blank`)return;e!==v.current&&(v.current=e,f(e),d(e))}catch{}},500);return()=>window.clearInterval(e)},[o,r,f,d]);let y=(0,J.useCallback)(e=>{u((window.innerWidth-e.clientX)/window.innerWidth*100)},[u]),b=T(Wa),{isResizing:x,handleMouseDown:S}=Ss({onResize:y,enabled:r&&!h});(0,J.useEffect)(()=>(b(x),x?(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=``}),[x,b]);let C=(0,J.useCallback)(e=>{e.key===`Enter`&&m()},[m]);if(!r)return null;let w=Vs.find(e=>e.id===i)?.label;return(0,Y.jsxs)(`div`,{className:G(`fixed bg-background border-border/60 shadow-2xl z-[40] flex flex-col`,h?`left-0 right-0`:`right-0 border-l`),style:{top:`var(--header-height)`,bottom:`0px`,width:h?`100%`:`${a}%`,userSelect:x?`none`:`auto`},children:[h&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border/60 bg-muted/10`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:w}),(0,Y.jsx)(`button`,{type:`button`,onClick:c,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,Y.jsx)(Se,{className:`w-3.5 h-3.5`})})]}),!h&&(0,Y.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:S}),(0,Y.jsx)(`div`,{className:G(`flex items-center border-b border-border/60 bg-muted/20`,h?`px-2 py-2`:`px-1.5 py-1`),children:(0,Y.jsx)(pt,{children:(0,Y.jsx)(`div`,{className:G(`flex items-center`,h?`gap-1 w-full justify-between`:`gap-0.5`),children:Vs.map(e=>{let t=e.icon,n=i===e.id,r=(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>l(e.id),className:G(`flex items-center justify-center rounded-md transition-all`,h?`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,Y.jsx)(t,{className:G(h?`w-4 h-4`:`w-3.5 h-3.5`)}),h&&(0,Y.jsx)(`span`,{className:`text-[10px] leading-none`,children:e.label})]});return h?(0,Y.jsx)(`div`,{children:r},e.id):(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:r}),(0,Y.jsx)(gt,{side:`bottom`,children:e.label})]},e.id)})})})}),(0,Y.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-hidden`,children:[i===`git`&&(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e}),i===`explorer`&&(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto`,children:t}),i===`review`&&(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto`,children:n}),i===`browser`&&(0,Y.jsx)(Us,{browserUrl:o,inputUrl:s,setInputUrl:d,onReload:p,onUrlKeyDown:C,iframeRef:g})]})]})},Us=({browserUrl:e,inputUrl:t,setInputUrl:n,onReload:r,onUrlKeyDown:i,iframeRef:a})=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1.5 border-b border-border/40 bg-muted/10`,children:[(0,Y.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,Y.jsx)(Bt,{className:`w-3.5 h-3.5`})}),(0,Y.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,Y.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,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-muted/5`,children:(0,Y.jsxs)(`div`,{className:`text-center space-y-3 px-8`,children:[(0,Y.jsx)(`div`,{className:`w-16 h-16 mx-auto rounded-2xl bg-muted/30 flex items-center justify-center`,children:(0,Y.jsx)(Kn,{className:`w-8 h-8 text-muted-foreground/50`})}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:(0,Y.jsx)(z,{id:`panel.browser.empty.title`})}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:(0,Y.jsx)(z,{id:`panel.browser.empty.description`})})]})]})})]}),Ws={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`},Gs=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`:Ws[t.slice(r+1).toLowerCase()]??`text`},Ks=new Set([`Write`,`Edit`,`MultiEdit`]),qs=e=>{if(!Ks.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[]},Js=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=qs(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())},Ys=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(`, `)},Xs=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:Ys(r.input)})}return t},Zs=F({subject:L(),description:L().optional()}),Qs=F({taskId:L(),status:pe([`pending`,`in_progress`,`completed`]).optional(),subject:L().optional(),description:L().optional()}),$s=new Set([`TaskCreate`,`TaskUpdate`]),ec=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`)&&$s.has(i.name)){if(i.name===`TaskCreate`){let e=Zs.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=Qs.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}},tc=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`)),nc=(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`&&tc(t.input)&&(n=t.input.todos)}let r=t??ec(e),i=r.latestTasks?r.latestTasks.map(e=>({content:e.subject,status:e.status})):null;return{todoWriteItems:n,taskItems:i}},rc=e=>{let t=nc(e);return t.todoWriteItems&&t.taskItems?[...t.todoWriteItems,...t.taskItems]:t.todoWriteItems??t.taskItems},ic=/<(?<tag>[^>]+)>(?<content>[\s\S]*?)<\/\k<tag>>/g,ac=F({tag:L(),content:L()});le([F({kind:ie(`command`),commandName:L(),commandArgs:L().optional(),commandMessage:L().optional()}),F({kind:ie(`local-command`),stdout:L()}),F({kind:ie(`text`),content:L()})]);var oc=e=>{let t=Array.from(e.matchAll(ic)).map(e=>ac.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}}},sc=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`},cc=(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()},lc=(0,J.createContext)({stateByToolUseId:new Map,latestTasks:null}),uc=({conversations:e,children:t})=>{let n=(0,J.useMemo)(()=>ec(e),[e]);return(0,Y.jsx)(lc.Provider,{value:n,children:t})},dc=e=>(0,J.useContext)(lc).stateByToolUseId.get(e),fc=e=>{if(e===void 0||e===``)return!1;try{return new URL(e),!0}catch{return!1}},pc=({href:e,children:t})=>{let[n,r]=(0,J.useState)(!1),{openBrowser:i}=go();return fc(e)?(0,Y.jsxs)(`span`,{className:`relative inline-block pr-8 max-w-full break-all`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[(0,Y.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,Y.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,Y.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,Y.jsx)(`title`,{id:`preview-icon-title`,children:`Preview`}),(0,Y.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`}),(0,Y.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,Y.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})};q.registerLanguage(`bash`,an),q.registerLanguage(`sh`,an),q.registerLanguage(`shell`,an),q.registerLanguage(`c`,cn),q.registerLanguage(`cpp`,dn),q.registerLanguage(`css`,nn),q.registerLanguage(`diff`,tn),q.registerLanguage(`go`,hn),q.registerLanguage(`java`,sn),q.registerLanguage(`javascript`,en),q.registerLanguage(`js`,en),q.registerLanguage(`json`,pn),q.registerLanguage(`markdown`,un),q.registerLanguage(`md`,un),q.registerLanguage(`python`,$t),q.registerLanguage(`py`,$t),q.registerLanguage(`sql`,on),q.registerLanguage(`tsx`,fn),q.registerLanguage(`typescript`,ln),q.registerLanguage(`ts`,ln),q.registerLanguage(`yaml`,mn),q.registerLanguage(`yml`,mn);var mc=({content:e,className:t=``})=>{let{resolvedTheme:n}=Kt(),a=n===`dark`?Qt:rn,o=(0,J.useMemo)(()=>({h1({children:e,...t}){return(0,Y.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,Y.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,Y.jsx)(`h3`,{className:`text-xl font-semibold mb-3 mt-6 text-foreground`,...t,children:e})},h4({children:e,...t}){return(0,Y.jsx)(`h4`,{className:`text-lg font-medium mb-2 mt-4 text-foreground`,...t,children:e})},h5({children:e,...t}){return(0,Y.jsx)(`h5`,{className:`text-base font-medium mb-2 mt-4 text-foreground`,...t,children:e})},h6({children:e,...t}){return(0,Y.jsx)(`h6`,{className:`text-sm font-medium mb-2 mt-4 text-muted-foreground`,...t,children:e})},p({children:e,...t}){return(0,Y.jsx)(`p`,{className:`mb-4 leading-7 text-foreground break-all`,...t,children:e})},ul({children:e,...t}){return(0,Y.jsx)(`ul`,{className:`mb-4 ml-6 list-disc space-y-2`,...t,children:e})},ol({children:e,...t}){return(0,Y.jsx)(`ol`,{className:`mb-4 ml-6 list-decimal space-y-2`,...t,children:e})},li({children:e,...t}){return(0,Y.jsx)(`li`,{className:`leading-7 text-foreground`,...t,children:e})},code({className:e,children:t,...n}){let r=/language-(\w+)/.exec(e??``);return r?(()=>{let e=typeof t==`string`?t:Array.isArray(t)?t.filter(e=>typeof e==`string`).join(``):``;return(0,Y.jsxs)(`div`,{className:`relative my-6`,children:[(0,Y.jsx)(`div`,{className:`flex items-center justify-between bg-muted/30 px-4 py-2 border-b border-border rounded-t-lg`,children:(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:r[1]})}),(0,Y.jsx)(q,{style:a,language:r[1],PreTag:`div`,className:`!mt-0 !rounded-t-none !rounded-b-lg !border-t-0 !border !border-border`,customStyle:{margin:0,borderTopLeftRadius:0,borderTopRightRadius:0},children:e.replace(/\n$/,``)})]})})():(0,Y.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})},pre({children:e,...t}){return(0,Y.jsx)(`pre`,{...t,children:e})},blockquote({children:e,...t}){return(0,Y.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,Y.jsx)(`div`,{className:`text-muted-foreground`,children:e})})},a({children:e,href:t,...n}){return(0,Y.jsx)(pc,{href:t,...n,children:e})},table({children:e,...t}){return(0,Y.jsx)(`div`,{className:`overflow-x-auto my-6 rounded-lg border border-border max-w-full`,children:(0,Y.jsx)(`table`,{className:`w-full border-collapse`,...t,children:e})})},thead({children:e,...t}){return(0,Y.jsx)(`thead`,{className:`bg-muted/50`,...t,children:e})},th({children:e,...t}){return(0,Y.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,Y.jsx)(`td`,{className:`border-b border-border px-4 py-3 text-foreground`,...t,children:e})},hr({...e}){return(0,Y.jsx)(`hr`,{className:`my-8 border-t border-border`,...e})},strong({children:e,...t}){return(0,Y.jsx)(`strong`,{className:`font-semibold text-foreground`,...t,children:e})},em({children:e,...t}){return(0,Y.jsx)(`em`,{className:`italic text-foreground`,...t,children:e})}}),[a]);return(0,Y.jsx)(`div`,{className:`prose prose-neutral dark:prose-invert max-w-none ${t}`,children:(0,Y.jsx)(r,{remarkPlugins:[i],components:o,children:e})})},hc=({content:e,className:t,placement:n=`user`})=>{let{i18n:r}=B(),i=async()=>{try{await navigator.clipboard.writeText(e),R.success(r._({id:`conversation.copy.success`,message:`Message copied`}))}catch(e){console.error(`Failed to copy message:`,e),R.error(r._({id:`conversation.copy.failed`,message:`Failed to copy message`}))}},a=r._({id:`conversation.copy`,message:`Copy message`});return(0,Y.jsxs)(`div`,{className:`group relative`,children:[(0,Y.jsx)(mc,{content:e,className:t}),(0,Y.jsx)(`div`,{className:G(`pointer-events-none absolute`,{"right-2 bottom-6":n===`user`,"right-0 bottom-0 translate-x-1":n===`assistant`}),children:(0,Y.jsx)(W,{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,Y.jsx)(Pn,{className:`h-3.5 w-3.5`})})})]})},gc=({...e})=>(0,Y.jsx)(pa,{...e}),_c=({...e})=>(0,Y.jsx)(ha,{...e}),vc=({className:e,children:t,...n})=>(0,Y.jsxs)(ma,{className:G(`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,Y.jsx)(ga,{asChild:!0,children:(0,Y.jsx)(H,{className:`h-4 w-4 opacity-50`})})]}),yc=({className:e,...t})=>(0,Y.jsx)(Ca,{className:G(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Y.jsx)(Tn,{className:`h-4 w-4`})}),bc=({className:e,...t})=>(0,Y.jsx)(wa,{className:G(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,Y.jsx)(H,{className:`h-4 w-4`})}),xc=({className:e,children:t,position:n=`popper`,...r})=>(0,Y.jsx)(_a,{children:(0,Y.jsxs)(va,{className:G(`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,Y.jsx)(yc,{}),(0,Y.jsx)(ya,{className:G(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,Y.jsx)(bc,{})]})}),X=({className:e,children:t,...n})=>(0,Y.jsxs)(ba,{className:G(`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,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(Sa,{children:(0,Y.jsx)(ut,{className:`h-4 w-4`})})}),(0,Y.jsx)(xa,{children:t})]}),Sc=({className:e,...t})=>(0,Y.jsx)(`div`,{"data-slot":`skeleton`,className:G(`bg-accent animate-pulse rounded-md`,e),...t}),Cc=`[font-family:"Fira_Code","Fira_Mono",Menlo,Consolas,"DejaVu_Sans_Mono",monospace]`,wc=()=>{let e=(0,J.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,Y.jsxs)(`div`,{className:`flex h-full`,children:[(0,Y.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,Y.jsx)(Sc,{className:`h-[14px] w-5 rounded-sm opacity-30`},`ln-${String(t)}`))}),(0,Y.jsx)(`div`,{className:`flex-1 flex flex-col gap-[5px] px-4 py-4`,children:e.map((e,t)=>(0,Y.jsx)(Sc,{className:`h-[14px] rounded-sm`,style:{width:`${String(e)}%`,opacity:.15+t%3*.1}},`code-${String(t)}`))})]})},Tc=({error:e,onRetry:t})=>(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 px-8 py-12`,children:[(0,Y.jsx)(`div`,{className:`h-12 w-12 rounded-xl bg-destructive/10 flex items-center justify-center`,children:(0,Y.jsx)(zt,{className:`h-6 w-6 text-destructive`})}),(0,Y.jsxs)(`div`,{className:`text-center space-y-1.5`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:(0,Y.jsx)(z,{id:`assistant.tool.error_loading_file`})}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-sm`,children:e.message})]}),(0,Y.jsxs)(W,{variant:`outline`,size:`sm`,onClick:t,className:`gap-1.5`,children:[(0,Y.jsx)(Bt,{className:`h-3 w-3`}),(0,Y.jsx)(z,{id:`assistant.tool.retry`})]})]}),Ec=({filePath:e})=>{let t=e.split(`/`).filter(Boolean),n=t.pop()??e,r=t.slice(-3),i=t.length>3;return(0,Y.jsxs)(`div`,{className:G(`flex items-center gap-0.5 text-[11px] text-muted-foreground flex-wrap`,Cc),children:[i&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`opacity-50`,children:`...`}),(0,Y.jsx)(dt,{className:`h-2.5 w-2.5 opacity-40 flex-shrink-0`})]}),r.map((e,t)=>(0,Y.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`opacity-60 hover:opacity-100 transition-opacity`,children:e}),(0,Y.jsx)(dt,{className:`h-2.5 w-2.5 opacity-40 flex-shrink-0`})]},`${e}-${String(t)}`)),(0,Y.jsx)(`span`,{className:`text-foreground font-medium`,children:n})]})},Dc=({projectId:e,filePath:t,syntaxTheme:n})=>{let{data:r}=f(b(e,t));if(!r.success)return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 px-8 py-12`,children:[(0,Y.jsx)(`div`,{className:`h-12 w-12 rounded-xl bg-destructive/10 flex items-center justify-center`,children:(0,Y.jsx)(zt,{className:`h-6 w-6 text-destructive`})}),(0,Y.jsxs)(`div`,{className:`text-center space-y-1.5`,children:[(0,Y.jsxs)(`p`,{className:`text-sm font-medium text-destructive`,children:[r.error===`NOT_FOUND`&&(0,Y.jsx)(z,{id:`assistant.tool.file_not_found`}),r.error===`BINARY_FILE`&&(0,Y.jsx)(z,{id:`assistant.tool.binary_file`}),r.error===`INVALID_PATH`&&(0,Y.jsx)(z,{id:`assistant.tool.invalid_path`}),r.error===`READ_ERROR`&&(0,Y.jsx)(z,{id:`assistant.tool.read_error`})]}),r.message&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-sm`,children:r.message})]})]});let i=r.language??Gs(t),a=r.content.split(`
|
|
2
|
+
`).length;return(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Y.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,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(zn,{className:`h-3 w-3`}),i]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(qn,{className:`h-3 w-3`}),a,` lines`]}),r.truncated&&(0,Y.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,Y.jsx)(z,{id:`assistant.tool.file_truncated`})})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Y.jsx)(gn,{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})})]})},Oc=class extends J.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,Y.jsx)(Tc,{error:this.state.error,onRetry:()=>{this.setState({error:null}),this.props.onRetry()}}):this.props.children}},kc=({projectId:e,filePaths:t,children:n})=>{let[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(0),{resolvedTheme:s}=Kt(),c=s===`dark`?Qt:rn,l=t[a]??t[0],u=t.length>1,d=l?.split(`/`).pop()??``,f=(0,J.useCallback)(e=>{i(e),e||o(0)},[]),p=(0,J.useCallback)(async()=>{if(l!==void 0)try{await navigator.clipboard.writeText(l),R.success(`Copied file path`)}catch{R.error(`Failed to copy`)}},[l]),m=(0,J.useCallback)(()=>{i(!1),requestAnimationFrame(()=>i(!0))},[]);return(0,Y.jsxs)(ze,{open:r,onOpenChange:f,children:[(0,Y.jsx)(je,{asChild:!0,children:n??(0,Y.jsxs)(W,{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,Y.jsx)(Tt,{className:`h-3 w-3`}),(0,Y.jsx)(z,{id:`assistant.tool.view_file`})]})}),(0,Y.jsxs)(He,{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,Y.jsx)(Ue,{className:`px-5 py-3 border-b border-border/60 bg-muted/30 flex-shrink-0`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex-shrink-0`,children:(0,Y.jsx)(`div`,{className:`h-8 w-8 rounded-md bg-primary/8 border border-primary/10 flex items-center justify-center`,children:(0,Y.jsx)(Vn,{className:`h-4 w-4 text-primary/70`})})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,Y.jsxs)(ke,{className:`text-sm font-semibold leading-tight pr-8 flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:G(`truncate`,Cc),children:d}),(0,Y.jsx)(W,{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,Y.jsx)(Pn,{className:`h-3 w-3`})})]}),(0,Y.jsx)(Oe,{className:`text-xs`,asChild:!0,children:(0,Y.jsx)(`div`,{children:u?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(gc,{value:String(a),onValueChange:e=>o(Number(e)),children:[(0,Y.jsx)(vc,{className:G(`h-6 text-[10px] max-w-[500px] border-border/50`,Cc),"data-testid":`file-selector`,children:(0,Y.jsx)(_c,{})}),(0,Y.jsx)(xc,{children:t.map((e,t)=>(0,Y.jsx)(X,{value:String(t),className:G(`text-[10px]`,Cc),children:e},e))})]}),(0,Y.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,Y.jsx)(Ec,{filePath:l})})})]})]})}),(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden bg-background`,children:l!==void 0&&(0,Y.jsx)(Oc,{onRetry:m,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(wc,{}),children:(0,Y.jsx)(Dc,{projectId:e,filePath:l,syntaxTheme:c})})},l)})]})]})},Ac=e=>{let t=F({type:ie(`user`),message:F({content:le([L(),_e(le([L(),F({type:ie(`text`),text:L()})]))])})}).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})()},jc=({prompt:e,projectId:t,sessionId:n,agentId:r,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,getToolResult:s})=>{let[c,l]=(0,J.useState)(!1),u=(0,J.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}=Ce({...w(t,r??``,n),enabled:m,staleTime:0}),y=p?f.map(e=>({...e,isSidechain:!1})):h?.conversations??[],b=p?void 0:h?.agentSessionId,x=p?d?.uuid:b,S=(()=>{let t=y.at(0);return t?Ac(t)??e:e.length>60?`${e.slice(0,60)}...`:e})(),C=m&&g,T=m&&_!==null,E=!C&&!T&&y.length===0&&c,D=!C&&!T&&y.length>0,O=y.find(e=>e.type===`user`||e.type===`assistant`||e.type===`system`);return(0,Y.jsxs)(ze,{open:c,onOpenChange:l,children:[(0,Y.jsx)(je,{asChild:!0,children:(0,Y.jsxs)(W,{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,Y.jsx)(Tt,{className:`h-3 w-3`}),(0,Y.jsx)(z,{id:`assistant.tool.view_task_details`})]})}),(0,Y.jsxs)(He,{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,Y.jsx)(Ue,{className:`px-6 py-4 border-b bg-muted/30`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,Y.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,Y.jsx)(ge,{className:`h-5 w-5 text-primary`})})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(ke,{className:`text-lg font-semibold leading-tight mb-1 pr-2`,children:S.length>120?`${S.slice(0,120)}...`:S}),(0,Y.jsxs)(Oe,{className:`text-xs flex items-center gap-2 flex-wrap`,children:[x!=null&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(z,{id:`assistant.tool.task_id`}),`:`,` `,(0,Y.jsx)(`code`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono`,children:x.slice(0,8)})]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`|`})]}),(0,Y.jsx)(`span`,{children:(0,Y.jsx)(z,{id:`assistant.tool.message_count`,values:{count:y.length}})})]})]})]})}),(0,Y.jsxs)(`div`,{ref:u,className:`flex-1 overflow-auto px-6 py-4`,children:[C&&(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Y.jsx)(M,{className:`h-8 w-8 animate-spin text-primary`}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Y.jsx)(z,{id:`assistant.tool.loading_task`})})]}),T&&(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Y.jsx)(Xe,{className:`h-8 w-8 text-destructive`}),(0,Y.jsx)(`p`,{className:`text-sm text-destructive`,children:(0,Y.jsx)(z,{id:`assistant.tool.error_loading_task`})}),(0,Y.jsx)(W,{variant:`outline`,size:`sm`,onClick:()=>{v()},children:(0,Y.jsx)(z,{id:`assistant.tool.retry`})})]}),E&&(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Y.jsx)(U,{variant:`secondary`,className:`text-sm`,children:(0,Y.jsx)(z,{id:`assistant.tool.no_task_data`})}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-md text-center`,children:(0,Y.jsx)(z,{id:`assistant.tool.no_task_data_description`})})]}),D&&(0,Y.jsx)(Au,{conversations:[...p?[]:[{type:`user`,message:{role:`user`,content:e},isSidechain:!1,userType:`external`,cwd:O?.cwd??`dummy`,sessionId:n,version:O?.version??`dummy`,uuid:`dummy`,timestamp:O?.timestamp??`dummy`,parentUuid:null,isMeta:!1,toolUseResult:void 0,gitBranch:O?.gitBranch??`dummy`,isCompactSummary:!1}],...y.map(e=>({...e,isSidechain:!1}))],getToolResult:s,projectId:t,sessionId:n,scheduledJobs:[],scrollContainerRef:u})]})]})]})},Mc=({input:e})=>{let t=Object.entries(e);return t.length===0?null:(0,Y.jsx)(`span`,{children:t.map(([e,t],n)=>{let r=typeof t==`string`?t:JSON.stringify(t).replace(/^"|"$/g,``);return(0,Y.jsxs)(`span`,{children:[n>0&&(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`, `}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,`=`]}),(0,Y.jsx)(`span`,{children:r})]},e)})})},Nc=`[font-family:"Fira_Code","Fira_Mono",Menlo,Consolas,"DejaVu_Sans_Mono",monospace]`,Pc=F({command:L(),description:L().optional()}),Fc=F({stdout:L(),stderr:L(),interrupted:Je()}),Ic=({input:e,toolUseResult:t})=>{let n=Pc.safeParse(e);if(!n.success)return null;let r=Fc.safeParse(t);return(0,Y.jsxs)(`div`,{className:`${Nc} text-xs rounded bg-gray-900 dark:bg-gray-950 text-gray-100 overflow-hidden`,children:[(0,Y.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,Y.jsx)(`span`,{className:`text-green-400 select-none flex-shrink-0`,children:`$`}),(0,Y.jsx)(`span`,{className:`whitespace-pre-wrap break-all`,children:n.data.command})]}),r.success&&r.data.stdout&&(0,Y.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,Y.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,Y.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,Y.jsx)(`div`,{className:`px-3 py-2 text-gray-500 animate-pulse`,children:`Running...`})]})},Lc=F({label:L(),description:L(),preview:L().optional()}),Rc=F({questions:_e(F({question:L(),header:L(),options:_e(Lc),multiSelect:Je().optional()}))}),zc=F({content:le([L(),_e(F({type:ie(`text`),text:L()}))])}),Bc=be(L(),L()),Vc=e=>{if(e==null)return{};if(typeof e==`string`){try{let t=JSON.parse(e),n=Bc.safeParse(t);if(n.success)return n.data}catch{}return{}}let t=zc.safeParse(e);if(!t.success)return{};let{content:n}=t.data;if(typeof n==`string`)return Vc(n);for(let e of n){let t=Vc(e.text);if(Object.keys(t).length>0)return t}return{}},Hc=({input:e,output:t})=>{let n=(0,J.useMemo)(()=>Vc(t),[t]),r=Rc.safeParse(e);return r.success?(0,Y.jsx)(`div`,{className:`space-y-3`,children:r.data.questions.map(e=>{let r=n[e.question];return(0,Y.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.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,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`(multiple)`})]}),(0,Y.jsx)(`p`,{className:`text-sm mt-1`,children:e.question})]}),(0,Y.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-gray-800`,children:e.options.map(e=>{let t=r===e.label;return(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium ${t?`text-green-700 dark:text-green-300`:``}`,children:e.label}),t&&(0,Y.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,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description}),e.preview!==void 0&&e.preview!==``&&(0,Y.jsxs)(lt,{children:[(0,Y.jsxs)(ht,{className:`flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 mt-1 hover:underline group`,children:[`Preview`,(0,Y.jsx)(H,{className:`h-3 w-3 transition-transform group-data-[state=open]:rotate-180`})]}),(0,Y.jsx)(rt,{children:(0,Y.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,Y.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},Uc=Symbol(``),Wc=e=>typeof e?.then==`function`;function Gc(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 Wc(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 Kc=Gc();function qc(e,t,n=Kc,r){let i=h(r?.getOnInit?n.getItem(e,t):t);return i.onMount=r=>(r(n.getItem(e,t)),n.subscribe?.call(n,e,r,t)),h(e=>e(i),(r,a,o)=>{let s=typeof o==`function`?o(r(i)):o;return s===Uc?(a(i,t),n.removeItem(e)):Wc(s)?s.then(t=>(a(i,t),n.setItem(e,t))):(a(i,s),n.setItem(e,s))})}var Jc=pe([`added`,`deleted`,`unchanged`,`hunk`,`context`]),Yc=F({id:L(),filename:L(),lineNumber:xe(),lineType:Jc,content:L(),createdAt:xe()}),Xc=be(L(),_e(Yc)),Zc=(e,t)=>{let n=Xc.safeParse(e);return n.success?n.data:t},Qc=(e,t,n)=>({...e,[t]:[...e[t]??[],n]}),$c=(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}},el=(e,t)=>{let{[t]:n,...r}=e;return r},tl=Gc(()=>localStorage),nl=qc(`claude-code-viewer-review-comments`,{},{getItem:(e,t)=>Zc(tl.getItem(e,t),t),setItem:(e,t)=>tl.setItem(e,t),removeItem:e=>tl.removeItem(e)}),rl=e=>{let[t,n]=E(nl);return{comments:(0,J.useMemo)(()=>t[e]??[],[t,e]),addComment:(0,J.useCallback)(t=>{let r={...t,id:crypto.randomUUID(),createdAt:Date.now()};n(t=>Qc(t,e,r))},[e,n]),removeComment:(0,J.useCallback)(t=>{n(n=>$c(n,e,t))},[e,n]),clearComments:(0,J.useCallback)(()=>{n(t=>el(t,e))},[e,n])}},il=(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
|
+
`)}`},al=({className:e,...t})=>(0,Y.jsx)(`textarea`,{"data-slot":`textarea`,className:G(`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}),ol=e=>G({"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`}),sl=e=>G({"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`}),cl=e=>e.newLineNumber??e.oldLineNumber??0,ll=({reviewProps:e,line:t,onClose:n})=>{let[r,i]=(0,J.useState)(``),{addComment:a}=rl(e.reviewSessionId),{i18n:o}=B(),s=()=>{r.trim()!==``&&(a({filename:e.filename,lineNumber:cl(t),lineType:t.type,content:r.trim()}),i(``),n())};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(al,{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,Y.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border/40 pt-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50`,children:`⌘ + Enter`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,onClick:n,className:`h-7 w-7 p-0 text-muted-foreground hover:text-foreground`,children:(0,Y.jsx)(Se,{className:`h-3.5 w-3.5`})}),(0,Y.jsxs)(W,{size:`sm`,onClick:s,disabled:r.trim()===``,className:`h-7 gap-1 rounded-full px-3 text-[11px] font-medium`,children:[(0,Y.jsx)(hr,{className:`h-3 w-3`}),(0,Y.jsx)(z,{id:`review.comment.save`})]})]})]})]})},ul=({comment:e,onRemove:t})=>(0,Y.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,Y.jsx)(`p`,{className:`pr-5 text-[13px] leading-relaxed text-foreground/90`,children:e.content}),(0,Y.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-0 transition-all hover:bg-destructive/10 hover:text-destructive group-hover/comment:opacity-100`,children:(0,Y.jsx)(xr,{className:`h-3 w-3`})})]}),dl=({reviewProps:e,line:t,lineComments:n,onRemoveComment:r})=>{let[i,a]=(0,J.useState)(!1),o=n.length>0;return(0,Y.jsxs)(ft,{open:i,onOpenChange:a,children:[(0,Y.jsx)(ot,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,className:G(`absolute left-0.5 top-px z-10 flex items-center rounded-sm transition-all`,o?`opacity-100`:`opacity-0 group-hover:opacity-100`),children:o?(0,Y.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,Y.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,Y.jsx)(er,{className:`h-3.5 w-3.5`})})})}),(0,Y.jsxs)(bt,{side:`right`,align:`start`,className:`w-80 overflow-hidden rounded-xl border-border/50 p-0 shadow-xl shadow-black/5 dark:shadow-black/20`,children:[o&&(0,Y.jsx)(`div`,{className:`space-y-1.5 border-b border-border/40 bg-muted/20 p-3`,children:n.map(e=>(0,Y.jsx)(ul,{comment:e,onRemove:r},e.id))}),(0,Y.jsx)(`div`,{className:`p-3`,children:(0,Y.jsx)(ll,{reviewProps:e,line:t,onClose:()=>a(!1)})})]})]})},fl=({hunk:e})=>(0,Y.jsx)(`div`,{className:`w-20 shrink-0`,children:(0,Y.jsx)(`div`,{children:e.lines.map(e=>(0,Y.jsxs)(`div`,{className:G(`grid grid-cols-[2.5rem_2.5rem] border-r border-l-4`,Nc,sl(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,Y.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,Y.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??``}`))})}),pl=({hunks:e,reviewProps:t,commentsByLine:n,onRemoveComment:r})=>(0,Y.jsx)(Y.Fragment,{children:e.map(e=>(0,Y.jsx)(`div`,{children:e.lines.map(i=>{let a=cl(i),o=n?.get(a)??[];return(0,Y.jsx)(`div`,{"data-slot":`diff-row`,className:G(`relative min-w-full border-l-4`,ol(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,Y.jsxs)(`div`,{"data-slot":`diff-row-content`,className:G(`relative min-w-0 px-2 py-0.5 pl-7 text-xs leading-tight whitespace-pre`,Nc),children:[t!==void 0&&i.type!==`hunk`&&r!==void 0&&(0,Y.jsx)(dl,{reviewProps:t,line:i,lineComments:o,onRemoveComment:r}),(0,Y.jsx)(`span`,{"data-slot":`diff-sign`,className:G(`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,Y.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}`))}),ml=({hunks:e,reviewProps:t,commentsByLine:n,onRemoveComment:r})=>(0,Y.jsxs)(`div`,{className:`relative flex`,children:[(0,Y.jsx)(`div`,{className:`w-20 shrink-0`,children:e.map(e=>(0,Y.jsx)(fl,{hunk:e},`${e.oldStart}-${e.newStart}`))}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1 overflow-x-auto`,children:(0,Y.jsx)(`div`,{className:`inline-block w-max min-w-full align-top`,children:(0,Y.jsx)(pl,{hunks:e,reviewProps:t,commentsByLine:n,onRemoveComment:r})})})]}),hl=({fileDiff:e,isCollapsed:t,onToggleCollapse:n})=>{let r=()=>e.isNew?(0,Y.jsx)(`span`,{className:`text-green-600 dark:text-green-400`,children:`A`}):e.isDeleted?(0,Y.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:`D`}):e.isRenamed?(0,Y.jsx)(`span`,{className:`text-blue-600 dark:text-blue-400`,children:`R`}):(0,Y.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`M`}),i=async t=>{t.stopPropagation();try{await navigator.clipboard.writeText(e.filename),R.success(`ファイル名をコピーしました`)}catch(e){console.error(`Failed to copy filename:`,e),R.error(`ファイル名のコピーに失敗しました`)}};return(0,Y.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,Y.jsx)(`button`,{type:`button`,onClick:n,className:`w-full text-left`,"aria-expanded":!t,children:(0,Y.jsxs)(`div`,{className:`w-full flex items-center gap-2 pr-8`,children:[t?(0,Y.jsx)(dt,{className:`w-4 h-4 text-gray-500 flex-shrink-0`}):(0,Y.jsx)(H,{className:`w-4 h-4 text-gray-500 flex-shrink-0`}),(0,Y.jsx)(`div`,{className:G(`w-5 h-5 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center text-xs flex-shrink-0`,Nc),children:r()}),(0,Y.jsx)(`span`,{className:G(`text-xs font-medium text-black dark:text-white text-left truncate flex-1 min-w-0`,Nc),children:e.filename}),(0,Y.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,Y.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,e.linesAdded]}),e.linesDeleted>0&&(0,Y.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`-`,e.linesDeleted]})]})]})}),(0,Y.jsx)(W,{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,Y.jsx)(Pn,{className:`w-3 h-3 text-gray-500 dark:text-gray-400`})}),e.isBinary&&(0,Y.jsx)(`div`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400 text-left`,children:`Binary file (content not shown)`})]})},gl=(e,t)=>{let{comments:n,addComment:r,removeComment:i,clearComments:a}=rl(e??``);return{commentsByLine:(0,J.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}},_l=(0,J.memo)(({fileDiff:e,className:t,filename:n,reviewSessionId:r})=>{let[i,a]=(0,J.useState)(!1),o=n!==void 0&&r!==void 0,{commentsByLine:s,removeComment:c}=gl(r,n),l=o?{filename:n,reviewSessionId:r}:void 0,u=()=>{a(!i)};return e.isBinary?(0,Y.jsxs)(`div`,{className:G(`overflow-hidden border border-gray-200 dark:border-gray-700 rounded-lg`,t),children:[(0,Y.jsx)(hl,{fileDiff:e,isCollapsed:i,onToggleCollapse:u}),!i&&(0,Y.jsx)(`div`,{className:`text-center py-8 text-gray-500 dark:text-gray-400 text-sm`,children:`Binary file cannot be displayed`})]}):(0,Y.jsxs)(`div`,{className:G(`overflow-hidden border border-gray-200 dark:border-gray-700 rounded-lg`,t),children:[(0,Y.jsx)(hl,{fileDiff:e,isCollapsed:i,onToggleCollapse:u}),!i&&(0,Y.jsx)(`div`,{className:`border-t border-gray-200 dark:border-gray-700`,children:(0,Y.jsx)(ml,{hunks:e.hunks,reviewProps:l,commentsByLine:s,onRemoveComment:c})})]})});_l.displayName=`DiffViewer`;var vl=F({content:L(),is_error:Je().optional()}),yl=F({content:_e(le([F({type:ie(`text`),text:L()}),F({type:L()})])),is_error:Je().optional()}),bl=F({type:ie(`text`),text:L()}),xl=F({is_error:ie(!0)}),Sl=e=>{if(e==null)return{text:null,isError:!1};let t=xl.safeParse(e).success,n=vl.safeParse(e);if(n.success)return{text:n.data.content,isError:t};let r=yl.safeParse(e);if(r.success){let e=[];for(let t of r.data.content){let n=bl.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}},Cl=200,wl=({output:e,showSuccess:t=!1})=>{let[n,r]=(0,J.useState)(!1);if(e==null)return null;let{text:i,isError:a}=Sl(e);return!a&&!t?null:a&&i!==null?i.length>Cl?(0,Y.jsx)(lt,{open:n,onOpenChange:r,children:(0,Y.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,Y.jsxs)(ht,{className:`flex items-center gap-1.5 w-full text-left`,children:[(0,Y.jsx)(zt,{className:`w-3.5 h-3.5 flex-shrink-0 text-red-600 dark:text-red-400`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium text-red-700 dark:text-red-400`,children:`Error`}),(0,Y.jsx)(H,{className:G(`w-3 h-3 text-red-500 ml-auto transition-transform`,n&&`rotate-180`)})]}),(0,Y.jsx)(rt,{children:(0,Y.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,Y.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,Y.jsx)(zt,{className:`w-3.5 h-3.5 flex-shrink-0 text-red-600 dark:text-red-400 mt-0.5`}),(0,Y.jsx)(`pre`,{className:`text-xs text-red-700 dark:text-red-400 whitespace-pre-wrap break-words`,children:i})]}):a?(0,Y.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,Y.jsx)(zt,{className:`w-3.5 h-3.5 flex-shrink-0 text-red-600 dark:text-red-400`}),(0,Y.jsx)(`span`,{className:`text-xs text-red-700 dark:text-red-400`,children:`Error`})]}):t?(0,Y.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,Y.jsx)($e,{className:`w-3 h-3 flex-shrink-0 text-green-600 dark:text-green-500 mt-0.5`}),i===null?(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Success`}):(0,Y.jsx)(`pre`,{className:`text-xs text-muted-foreground whitespace-pre-wrap break-words max-h-24 overflow-y-auto`,children:i})]}):null},Tl=F({file_path:L(),old_string:L().optional(),new_string:L().optional()}),El=_e(F({oldStart:xe(),oldLines:xe(),newStart:xe(),newLines:xe(),lines:_e(L())})),Dl=F({filePath:L(),structuredPatch:El}),Ol=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}}),kl=(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}`)]}]},Al=(e,t,n)=>{let r=Ol(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,Y.jsxs)(`div`,{className:`overflow-hidden`,children:[(0,Y.jsx)(_l,{fileDiff:{filename:e,isNew:!1,isDeleted:!1,isRenamed:!1,isBinary:!1,hunks:r,linesAdded:i,linesDeleted:a}}),(0,Y.jsx)(wl,{output:n,showSuccess:!0})]})},jl=({input:e,output:t,toolUseResult:n})=>{let r=Tl.safeParse(e);if(!r.success)return null;let i=Dl.safeParse(n);if(i.success)return Al(i.data.filePath,i.data.structuredPatch,t);let{old_string:a,new_string:o}=r.data;return a!==void 0&&o!==void 0?Al(r.data.file_path,kl(a,o),t):(0,Y.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Y.jsx)(`div`,{className:`px-3 py-2 bg-gray-50 dark:bg-gray-800 ${Nc} text-xs font-medium`,children:r.data.file_path}),n===void 0&&(0,Y.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground animate-pulse text-center`,children:`Applying edit...`}),(0,Y.jsx)(wl,{output:t,showSuccess:!0})]})},Ml=F({file_path:L()}),Nl=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},Pl=F({content:L()}),Fl=F({content:_e(F({type:ie(`text`),text:L()}))}),Il=e=>{if(e==null)return null;let t=Pl.safeParse(e);if(t.success)return t.data.content;let n=Fl.safeParse(e);if(n.success){let e=n.data.content[0];if(e)return e.text}return null},Ll=({input:e,output:t})=>{let{resolvedTheme:n}=Kt(),r=n===`dark`?Qt:rn,i=Ml.safeParse(e);if(!i.success)return null;let a=Il(t);if(a===null)return(0,Y.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700`,children:[(0,Y.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,Y.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground animate-pulse text-center`,children:`Reading file...`})]});let o=Nl(a);if(!o)return null;let s=Gs(i.data.file_path);return(0,Y.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Y.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,Y.jsx)(gn,{style:r,language:s,showLineNumbers:!0,startingLineNumber:o.startLine,wrapLines:!0,customStyle:{margin:0,borderRadius:0,fontSize:`0.75rem`},children:o.code})]})},Rl=F({statusChange:F({from:L(),to:L()}).optional()}),zl=({status:e})=>{switch(e){case`completed`:return(0,Y.jsx)($e,{className:`w-3.5 h-3.5 flex-shrink-0 text-green-600 dark:text-green-500`});case`in_progress`:return(0,Y.jsx)(Dn,{className:`w-3.5 h-3.5 flex-shrink-0 text-amber-600 dark:text-amber-500`});case`pending`:return(0,Y.jsx)(kn,{className:`w-3.5 h-3.5 flex-shrink-0 text-muted-foreground`});default:return null}},Bl=({input:e,toolUseResult:t})=>{let n=Zs.safeParse(e);if(n.success)return(0,Y.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground truncate`,children:[`New Task: `,n.data.subject]});let r=Qs.safeParse(e),i=Rl.safeParse(t);if(r.success){let e=i.success?i.data.statusChange:void 0;return e===void 0?(0,Y.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground truncate`,children:[`Task #`,r.data.taskId]}):(0,Y.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground truncate`,children:[`Task #`,r.data.taskId,`: `,e.from,` → `,e.to]})}return(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Tasks`})},Vl=({toolUseId:e,input:t,output:n,toolUseResult:r})=>{let i=dc(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,Y.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Y.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,Y.jsx)(Xn,{className:G(`w-3.5 h-3.5`,s?`text-amber-600 dark:text-amber-500`:`text-muted-foreground`)}),(0,Y.jsx)(Bl,{input:t,toolUseResult:r}),(0,Y.jsxs)(`span`,{className:G(`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,Y.jsx)(`div`,{className:`p-2 space-y-1 max-h-48 overflow-y-auto`,children:i.map(e=>(0,Y.jsxs)(`div`,{className:G(`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,Y.jsx)(zl,{status:e.status}),(0,Y.jsx)(`span`,{className:G(`flex-1 break-words`,e.status===`completed`&&`line-through`),children:e.subject}),(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/60 flex-shrink-0`,children:[`#`,e.id]})]},`${e.id}-${e.status}`))}),(0,Y.jsx)(wl,{output:n})]})},Hl=F({prompt:L(),description:L().optional(),subagent_type:L().optional()}),Ul=F({totalDurationMs:xe().optional(),totalTokens:xe().optional(),totalToolUseCount:xe().optional()}),Wl=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`},Gl=({output:e})=>{let{text:t,isError:n}=Sl(e);return t===null?null:(0,Y.jsx)(lt,{children:(0,Y.jsxs)(`div`,{className:G(`border-t`,n?`border-red-200 dark:border-red-800/50`:`border-gray-200 dark:border-gray-700`),children:[(0,Y.jsxs)(ht,{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,Y.jsx)(zt,{className:`w-3.5 h-3.5 flex-shrink-0 text-red-600 dark:text-red-400`}):null,(0,Y.jsx)(`span`,{className:G(`text-xs font-medium`,n?`text-red-700 dark:text-red-400`:`text-muted-foreground`),children:`Result`}),(0,Y.jsx)(H,{className:`w-3 h-3 ml-auto transition-transform text-muted-foreground group-data-[state=open]:rotate-180`})]}),(0,Y.jsx)(rt,{children:(0,Y.jsx)(`div`,{className:G(`px-3 py-2 max-h-64 overflow-y-auto`,n&&`bg-red-50/50 dark:bg-red-950/20`),children:(0,Y.jsx)(`pre`,{className:G(`text-xs whitespace-pre-wrap break-words`,n?`text-red-700 dark:text-red-400`:`text-foreground`),children:t})})})]})})},Kl=({input:e,output:t,toolUseResult:n})=>{let r=Hl.safeParse(e);if(!r.success)return null;let i=Ul.safeParse(n),a=r.data.subagent_type!==void 0&&r.data.subagent_type!==``,o=r.data.description!==void 0&&r.data.description!==``;return(0,Y.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Y.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,Y.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,Y.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:r.data.description}):null]}),(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.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,Y.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,Y.jsx)(`span`,{children:Wl(i.data.totalDurationMs)}),i.data.totalTokens!==void 0&&(0,Y.jsxs)(`span`,{children:[i.data.totalTokens.toLocaleString(),` tokens`]}),i.data.totalToolUseCount!==void 0&&(0,Y.jsxs)(`span`,{children:[i.data.totalToolUseCount,` tool uses`]})]}),(0,Y.jsx)(Gl,{output:t}),n===void 0&&(0,Y.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...`})]})},ql=F({todos:_e(F({content:L(),status:pe([`pending`,`in_progress`,`completed`])}))}),Jl=({status:e})=>{switch(e){case`completed`:return(0,Y.jsx)($e,{className:`w-3.5 h-3.5 flex-shrink-0 text-green-600 dark:text-green-500`});case`in_progress`:return(0,Y.jsx)(Dn,{className:`w-3.5 h-3.5 flex-shrink-0 text-amber-600 dark:text-amber-500`});case`pending`:return(0,Y.jsx)(kn,{className:`w-3.5 h-3.5 flex-shrink-0 text-muted-foreground`});default:return null}},Yl=({input:e,output:t})=>{let n=ql.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,Y.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Y.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,Y.jsx)(Xn,{className:G(`w-3.5 h-3.5`,o?`text-amber-600 dark:text-amber-500`:`text-muted-foreground`)}),(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Tasks`}),(0,Y.jsxs)(`span`,{className:G(`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,Y.jsx)(`div`,{className:`p-2 space-y-1 max-h-48 overflow-y-auto`,children:r.map(e=>(0,Y.jsxs)(`div`,{className:G(`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,Y.jsx)(Jl,{status:e.status}),(0,Y.jsx)(`span`,{className:G(`flex-1 break-words`,e.status===`completed`&&`line-through`),children:e.content})]},`${e.content}-${e.status}`))}),(0,Y.jsx)(wl,{output:t})]})},Xl=F({file_path:L(),content:L()}),Zl={Bash:Ic,Edit:jl,Read:Ll,Write:({input:e,output:t})=>{let n=Xl.safeParse(e);return n.success?(0,Y.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,Y.jsx)(`div`,{className:`px-3 py-1.5 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 ${Nc} text-xs font-medium`,children:n.data.file_path}),t===void 0&&(0,Y.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground animate-pulse text-center`,children:`Writing file...`}),(0,Y.jsx)(wl,{output:t,showSuccess:!0})]}):null},Task:Kl,Agent:Kl,TaskCreate:Vl,TaskUpdate:Vl,TodoWrite:Yl,CCVAskUserQuestion:Hc},Ql=e=>Zl[e],$l=ue.object({prompt:ue.string()}),eu=new Set([`Task`,`Agent`]),tu=({content:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:s,sessionId:c,syntaxTheme:l})=>{let u=Ql(e.name),[d,f]=(0,J.useState)(u?`visual`:`raw`),p=t(e.id),m=r(e.id),h=(0,J.useMemo)(()=>!u||d!==`visual`?null:(0,Y.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=eu.has(e.name)?$l.safeParse(e.input):void 0;if(r===void 0||r.success===!1)return;let l=n(e.id);return(0,Y.jsx)(jc,{prompt:r.data.prompt,projectId:s,sessionId:c,agentId:l,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,getToolResult:t})})(),v=qs(e),y=v.length>0?(0,Y.jsx)(kc,{projectId:s,filePaths:v}):void 0;return(0,Y.jsx)(Mt,{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,Y.jsxs)(lt,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center min-w-0`,children:[(0,Y.jsx)(ht,{asChild:!0,children:(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(wr,{className:`h-4 w-4 text-blue-600 dark:text-blue-400 flex-shrink-0`}),(0,Y.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,Y.jsxs)(`span`,{className:`font-normal`,children:[` `,`(`,(0,Y.jsx)(Mc,{input:e.input}),`)`]})]}),(0,Y.jsx)(H,{className:`h-4 w-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180 flex-shrink-0`})]})})}),(_??y)&&(0,Y.jsxs)(`div`,{className:`flex-shrink-0 border-l border-blue-200 dark:border-blue-800 flex items-center`,children:[_,y]})]}),(0,Y.jsx)(rt,{children:(0,Y.jsxs)(`div`,{className:`space-y-3 py-3 px-4 border-t border-blue-200 dark:border-blue-800`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:`ID`}),(0,Y.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,Y.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,Y.jsx)(Nn,{className:`h-3 w-3`}),`Raw`]})]}),g===`visual`&&h,g===`raw`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,Y.jsx)(z,{id:`assistant.tool.input_parameters`})}),(0,Y.jsx)(gn,{style:l,language:`json`,PreTag:`div`,className:`text-xs rounded`,children:JSON.stringify(e.input,null,2)})]}),p&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:(0,Y.jsx)(z,{id:`assistant.tool.result`})}),(0,Y.jsx)(`div`,{className:`bg-background rounded border p-3`,children:typeof p.content==`string`?(0,Y.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,Y.jsx)(`img`,{src:`data:${e.source.media_type};base64,${e.source.data}`,alt:`Tool Result`},e.source.data);if(e.type===`text`)return(0,Y.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`)})})]})]})]})})]})})},nu=({content:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:s,sessionId:c})=>{let{resolvedTheme:l}=Kt(),u=l===`dark`?Qt:rn;return e.type===`text`?(0,Y.jsx)(`div`,{className:`w-full mx-1 sm:mx-2 my-4 sm:my-6`,children:(0,Y.jsx)(hc,{content:e.text,placement:`assistant`})}):e.type===`thinking`?e.thinking===``?null:(0,Y.jsx)(Mt,{className:`bg-muted/50 border-dashed gap-2 py-1 mb-2 hover:shadow-sm transition-all duration-200`,children:(0,Y.jsxs)(lt,{children:[(0,Y.jsx)(ht,{asChild:!0,children:(0,Y.jsx)(kt,{className:`cursor-pointer hover:bg-muted/80 rounded-t-lg transition-all duration-200 py-0 px-4 group`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Yn,{className:`h-4 w-4 text-muted-foreground group-hover:text-yellow-600 transition-colors`}),(0,Y.jsx)(Et,{className:`text-sm font-medium group-hover:text-foreground transition-colors`,children:(0,Y.jsx)(z,{id:`assistant.thinking`})}),(0,Y.jsx)(H,{className:`h-4 w-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180`})]})})}),(0,Y.jsx)(rt,{children:(0,Y.jsx)(`div`,{className:`py-2 px-4`,children:(0,Y.jsx)(`div`,{className:`text-sm text-muted-foreground whitespace-pre-wrap font-mono`,children:e.thinking})})})]})}):e.type===`tool_use`?(0,Y.jsx)(tu,{content:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:i,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:s,sessionId:c,syntaxTheme:u}):(e.type,null)},ru=e=>{let t=(0,J.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!==`agent-name`&&e.type!==`agent-setting`&&e.type!==`pr-link`&&e.type!==`last-prompt`&&e.type!==`permission-mode`).filter(e=>e.isSidechain===!0),[e]),n=(0,J.useMemo)(()=>new Map(t.map(e=>[e.uuid,e])),[t]),r=(0,J.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,J.useMemo)(()=>new Set(e.filter(e=>e.type===`assistant`).flatMap(e=>e.message.content.filter(e=>e.type===`tool_use`)).flatMap(e=>{if(!eu.has(e.name))return[];let t=$l.safeParse(e.input);return t.success===!1?[]:[t.data.prompt]})),[e]),a=(0,J.useCallback)(e=>{if(e.parentUuid===null)return e;let t=n.get(e.parentUuid);return t===void 0?e:a(t)},[n]),o=(0,J.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,J.useCallback)(e=>e.type===`summary`||e.type===`file-history-snapshot`||e.type===`queue-operation`||e.type===`custom-title`||e.type===`agent-name`||e.type===`agent-setting`||e.type===`pr-link`||e.type===`last-prompt`||e.type===`permission-mode`?!1:o.has(e.uuid),[o]),c=(0,J.useCallback)(e=>o.get(e)??[],[o]),l=(0,J.useCallback)(e=>r.get(e),[r]),u=(0,J.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,J.useCallback)(e=>u.get(e),[u]),existsRelatedTaskCall:e=>i.has(e)}},iu=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`}},au=e=>{if(!e)return;let t;t=e.languages.length>0?e.languages:e.language?[e.language]:[];for(let e of t){let t=iu(e);if(t)return t}},ou=({conversation:e})=>{let t=Object.keys(e.snapshot.trackedFileBackups).length,{config:n}=he();return(0,Y.jsxs)(lt,{children:[(0,Y.jsx)(ht,{asChild:!0,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2`,children:[(0,Y.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:[`File History Snapshot `,t>0&&`(${t} files)`]}),(0,Y.jsx)(H,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Y.jsx)(rt,{children:(0,Y.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`text-xs`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Timestamp: `}),(0,Y.jsx)(`span`,{children:me(e.snapshot.timestamp,{locale:n.locale})})]}),(0,Y.jsxs)(`div`,{className:`text-xs`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Message ID: `}),(0,Y.jsx)(`span`,{className:`font-mono`,children:e.messageId})]}),(0,Y.jsxs)(`div`,{className:`text-xs`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Is Snapshot Update: `}),(0,Y.jsx)(`span`,{children:e.isSnapshotUpdate?`Yes`:`No`})]}),t>0&&(0,Y.jsxs)(`div`,{className:`text-xs`,children:[(0,Y.jsx)(`div`,{className:`text-muted-foreground mb-1`,children:`Tracked Files:`}),(0,Y.jsx)(`ul`,{className:`list-disc list-inside space-y-1`,children:Object.keys(e.snapshot.trackedFileBackups).map(e=>(0,Y.jsx)(`li`,{className:`font-mono text-xs break-all`,children:e},e))})]})]})})})]})},su=({children:e})=>(0,Y.jsxs)(lt,{children:[(0,Y.jsx)(ht,{asChild:!0,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2`,children:[(0,Y.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:`Meta Information`}),(0,Y.jsx)(H,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Y.jsx)(rt,{children:(0,Y.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:e})})]}),cu=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
|
+
`),lu=({conversation:e})=>(0,Y.jsxs)(lt,{children:[(0,Y.jsx)(ht,{asChild:!0,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2`,children:[(0,Y.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:e.operation===`enqueue`?`Queue Operation: Enqueue`:`Queue Operation: Dequeue`}),(0,Y.jsx)(H,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Y.jsx)(rt,{children:(0,Y.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:(0,Y.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Operation:`}),` `,e.operation]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Session ID:`}),` `,e.sessionId]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Timestamp:`}),` `,e.timestamp]}),e.operation===`enqueue`&&e.content!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Content:`}),(0,Y.jsx)(`pre`,{className:`mt-1 overflow-x-auto whitespace-pre-wrap`,children:cu(e.content)})]})]})})})]}),uu=({children:e})=>(0,Y.jsxs)(lt,{children:[(0,Y.jsx)(ht,{asChild:!0,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2`,children:[(0,Y.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:`Summarized`}),(0,Y.jsx)(H,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Y.jsx)(rt,{children:(0,Y.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:(0,Y.jsx)(`pre`,{className:`text-xs overflow-x-auto`,children:e})})})]}),du=({children:e})=>(0,Y.jsxs)(lt,{children:[(0,Y.jsx)(ht,{asChild:!0,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2`,children:[(0,Y.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground`,children:`System Message`}),(0,Y.jsx)(H,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Y.jsx)(rt,{children:(0,Y.jsx)(`div`,{className:`bg-background rounded border p-3 mt-2`,children:(0,Y.jsx)(`pre`,{className:`text-xs overflow-x-auto`,children:e})})})]}),fu=({durationMs:e})=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground mt-2 px-2`,children:[(0,Y.jsx)(Mn,{className:`h-3 w-3`}),(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(z,{id:`assistant.turn_duration`}),`: `,sc(e)]})]}),pu=({text:e,id:t})=>{let n=oc(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,Y.jsxs)(Mt,{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,Y.jsx)(kt,{className:`py-0 px-4`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(br,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),(0,Y.jsx)(Et,{className:`text-sm font-medium`,children:`Claude Code Command`}),(0,Y.jsx)(U,{variant:`outline`,className:`border-green-300 text-green-700 dark:border-green-700 dark:text-green-300`,children:n.commandName})]})}),i?(0,Y.jsx)(At,{className:`py-0 px-4`,children:(0,Y.jsx)(`div`,{className:`space-y-2`,children:(0,Y.jsxs)(`div`,{children:[e?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Arguments:`}),(0,Y.jsx)(`div`,{className:`bg-background rounded border p-2 mt-1`,children:(0,Y.jsx)(`code`,{className:`text-xs whitespace-pre-line break-all`,children:n.commandArgs})})]}):null,r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Message:`}),(0,Y.jsx)(`div`,{className:`bg-background rounded border p-2 mt-1`,children:(0,Y.jsx)(`code`,{className:`text-xs whitespace-pre-line break-all`,children:n.commandMessage})})]}):null]})})}):null]})}return n.kind===`local-command`?(0,Y.jsxs)(Mt,{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,Y.jsx)(kt,{className:`py-0 px-4`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(br,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),(0,Y.jsx)(Et,{className:`text-sm font-medium`,children:`Local Command`})]})}),(0,Y.jsx)(At,{className:`py-0 px-4`,children:(0,Y.jsx)(`pre`,{className:`text-xs overflow-x-auto whitespace-pre-wrap break-words`,children:n.stdout})})]}):(0,Y.jsx)(hc,{className:`w-full px-3 py-3 mb-5 border border-border rounded-lg bg-slate-50 dark:bg-slate-900/50`,content:n.content})},mu=({content:e,id:t})=>typeof e==`string`?(0,Y.jsx)(pu,{text:e,id:t}):e.type===`text`?(0,Y.jsx)(pu,{text:e.text,id:t}):e.type===`image`?e.source.type===`base64`?(0,Y.jsx)(Mt,{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,Y.jsxs)(lt,{children:[(0,Y.jsx)(ht,{asChild:!0,children:(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Jn,{className:`h-4 w-4 text-purple-600 dark:text-purple-400`}),(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:(0,Y.jsx)(z,{id:`user.content.image`})}),(0,Y.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,Y.jsx)(H,{className:`h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto`})]})})}),(0,Y.jsx)(rt,{children:(0,Y.jsx)(`div`,{className:`py-3 px-4 border-t border-purple-200 dark:border-purple-800`,children:(0,Y.jsx)(`div`,{className:`rounded-lg border overflow-hidden bg-background`,children:(0,Y.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,Y.jsx)(Mt,{className:`border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20`,id:t,children:(0,Y.jsxs)(kt,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(zt,{className:`h-4 w-4 text-red-600 dark:text-red-400`}),(0,Y.jsx)(Et,{className:`text-sm font-medium`,children:(0,Y.jsx)(z,{id:`user.content.unsupported_media`})}),(0,Y.jsx)(U,{variant:`destructive`,children:(0,Y.jsx)(z,{id:`common.error`})})]}),(0,Y.jsx)(jt,{className:`text-xs`,children:(0,Y.jsx)(z,{id:`user.content.unsupported_media.description`})})]})}):e.type===`document`?e.source.type===`base64`&&e.source.media_type===`application/pdf`?(0,Y.jsx)(Mt,{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,Y.jsxs)(lt,{children:[(0,Y.jsx)(ht,{asChild:!0,children:(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(zn,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:(0,Y.jsx)(z,{id:`user.content.document.pdf`})}),(0,Y.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,Y.jsx)(H,{className:`h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto`})]})})}),(0,Y.jsx)(rt,{children:(0,Y.jsx)(`div`,{className:`py-3 px-4 border-t border-blue-200 dark:border-blue-800`,children:(0,Y.jsx)(`div`,{className:`rounded-lg border overflow-hidden bg-background`,children:(0,Y.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,Y.jsx)(Mt,{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,Y.jsxs)(lt,{children:[(0,Y.jsx)(ht,{asChild:!0,children:(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(zn,{className:`h-4 w-4 text-green-600 dark:text-green-400`}),(0,Y.jsx)(`span`,{className:`text-sm font-medium`,children:(0,Y.jsx)(z,{id:`user.content.document.text`})}),(0,Y.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,Y.jsx)(H,{className:`h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto`})]})})}),(0,Y.jsx)(rt,{children:(0,Y.jsx)(`div`,{className:`py-3 px-4 border-t border-green-200 dark:border-green-800`,children:(0,Y.jsx)(`div`,{className:`rounded-lg border overflow-hidden bg-background`,children:(0,Y.jsx)(`pre`,{className:`p-4 text-sm overflow-auto max-h-96`,children:e.source.data})})})})]})}):(0,Y.jsx)(Mt,{className:`border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20`,id:t,children:(0,Y.jsxs)(kt,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(zt,{className:`h-4 w-4 text-red-600 dark:text-red-400`}),(0,Y.jsx)(Et,{className:`text-sm font-medium`,children:(0,Y.jsx)(z,{id:`user.content.unsupported_document`})}),(0,Y.jsx)(U,{variant:`destructive`,children:(0,Y.jsx)(z,{id:`common.error`})})]}),(0,Y.jsx)(jt,{className:`text-xs`,children:(0,Y.jsx)(z,{id:`user.content.unsupported_document.description`})})]})}):(e.type,null),hu=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(`
|
|
11
|
+
`)},gu=(0,J.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}=B(),f=ce.safeParse(d.locale),p=f.success?f.data:`en`;if(e.type===`summary`)return(0,Y.jsx)(uu,{children:e.summary});if(e.type===`system`)return(0,Y.jsx)(du,{children:hu(e)});if(e.type===`file-history-snapshot`)return(0,Y.jsx)(ou,{conversation:e});if(e.type===`queue-operation`)return(0,Y.jsx)(lu,{conversation:e});if(e.type===`user`){if(typeof e.message.content==`string`){let i=oc(e.message.content);if(i.kind===`local-command`){let d={type:`text`,text:i.stdout};return(0,Y.jsxs)(`div`,{className:`w-full`,children:[u&&e.timestamp&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1 px-1 select-none text-left`,children:me(e.timestamp,{locale:p,target:`datetime`})}),(0,Y.jsx)(`ul`,{className:`w-full`,children:(0,Y.jsx)(`li`,{children:(0,Y.jsx)(nu,{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,Y.jsx)(mu,{content:e.message.content,id:`message-${e.uuid}`}):(0,Y.jsx)(`ul`,{className:`w-full`,id:`message-${e.uuid}`,children:e.message.content.map((e,t)=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(mu,{content:e})},t))}),d=u&&e.timestamp?(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1 px-1 select-none text-right`,children:me(e.timestamp,{locale:p,target:`datetime`})}):null;return e.isMeta===!0?(0,Y.jsx)(su,{children:(0,Y.jsxs)(`div`,{className:`flex flex-col w-full`,children:[d,i]})}):(0,Y.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,Y.jsxs)(`div`,{className:`w-full`,children:[u&&e.timestamp&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1 px-1 select-none text-left`,children:me(e.timestamp,{locale:p,target:`datetime`})}),(0,Y.jsx)(`ul`,{className:`w-full`,children:d.map((e,i)=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(nu,{content:e,getToolResult:t,getAgentIdForToolUse:n,getToolUseResult:r,getSidechainConversationByAgentId:s,getSidechainConversationByPrompt:a,getSidechainConversations:o,projectId:c,sessionId:l})},i))}),f!==void 0&&(0,Y.jsx)(fu,{durationMs:f})]})}return null}),_u=new Set([`summary`,`progress`,`queue-operation`,`file-history-snapshot`,`custom-title`,`agent-name`,`agent-setting`]),vu=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===`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}`;throw Error(`Unknown conversation type`)},yu=(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:!_u.has(r.type),rowKey:i(vu(r))})}return n},bu=({scheduledJobs:e})=>{let{i18n:t}=B();return e.length===0?null:(0,Y.jsx)(`div`,{className:`w-full flex justify-start mt-4`,children:(0,Y.jsx)(`div`,{className:`w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%] px-2`,children:(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Cn,{className:`w-4 h-4 text-blue-600 dark:text-blue-400`}),(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-blue-900 dark:text-blue-100`,children:(0,Y.jsx)(z,{id:`session.scheduled_messages.title`})})]}),(0,Y.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,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(U,{variant:`secondary`,className:`bg-blue-100 text-blue-900 dark:bg-blue-900 dark:text-blue-100`,children:t.date(n,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}),!e.enabled&&(0,Y.jsx)(U,{variant:`outline`,className:`text-xs`,children:(0,Y.jsx)(z,{id:`session.scheduled_messages.disabled`})})]}),(0,Y.jsxs)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300 line-clamp-2`,children:[(0,Y.jsx)(z,{id:`session.scheduled_messages.message_label`}),`: `,e.message.content]})]},e.id)})})]})})})},xu=`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(` `)},wu=e=>e.type===`text`?e.text:e.type===`thinking`?e.thinking:e.type===`tool_use`?e.name:``,Tu=e=>e.type===`x-error`?e.line:e.type===`user`?Cu(e.message.content):e.type===`assistant`?e.message.content.map(wu).join(` `):e.type===`summary`?e.summary:e.type===`system`&&`content`in e?e.content:e.type===`custom-title`?e.customTitle:e.type===`last-prompt`?e.lastPrompt:``,Eu=()=>{let e=document.getElementById(xu);return e instanceof HTMLInputElement?e:null},Du=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()}},Ou=(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}}},ku=({errorLine:e})=>(0,Y.jsx)(`div`,{className:`w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%] px-2`,children:(0,Y.jsxs)(lt,{children:[(0,Y.jsx)(ht,{asChild:!0,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 border-l-2 border-red-400`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Cr,{className:`h-3 w-3 text-red-500`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium text-red-600`,children:(0,Y.jsx)(z,{id:`conversation.error.schema`})})]}),(0,Y.jsx)(H,{className:`h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]})}),(0,Y.jsx)(rt,{children:(0,Y.jsx)(`div`,{className:`bg-background rounded border border-red-200 p-3 mt-2`,children:(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(It,{variant:`destructive`,className:`border-red-200 bg-red-50`,children:[(0,Y.jsx)(Cr,{className:`h-4 w-4`}),(0,Y.jsx)(Yt,{className:`text-red-800`,children:(0,Y.jsx)(z,{id:`conversation.error.schema_validation`})}),(0,Y.jsxs)(Ht,{className:`text-red-700`,children:[(0,Y.jsx)(z,{id:`conversation.error.schema_validation.description`}),` `,(0,Y.jsxs)(`a`,{href:`https://github.com/d-kimuson/claude-code-viewer/issues`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-red-600 hover:text-red-800 underline underline-offset-4`,children:[(0,Y.jsx)(z,{id:`conversation.error.report_issue`}),(0,Y.jsx)(Ln,{className:`h-3 w-3`})]})]})]}),(0,Y.jsxs)(`div`,{className:`bg-gray-50 border rounded px-3 py-2`,children:[(0,Y.jsx)(`h5`,{className:`text-xs font-medium text-gray-700 mb-2`,children:(0,Y.jsx)(z,{id:`conversation.error.raw_content`})}),(0,Y.jsx)(`pre`,{className:`text-xs overflow-x-auto whitespace-pre-wrap break-all font-mono text-gray-800`,children:e})]})]})})})]})}),Au=({conversations:e,getToolResult:t,projectId:n,sessionId:r,scheduledJobs:i,scrollContainerRef:a,enableInPageSearch:o=!1})=>{let{config:s}=he(),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(0),m=(0,J.useRef)(null),h=(0,J.useRef)(new Map),g=(0,J.useMemo)(()=>e.filter(e=>e.type!==`x-error`),[e]),{isRootSidechain:_,getSidechainConversations:v,getSidechainConversationByPrompt:y,getSidechainConversationByAgentId:b,existsRelatedTaskCall:x}=ru(g),S=(0,J.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=cc(a.timestamp,o.timestamp);t!==null&&t>=0&&e.set(o.uuid,t)}}return e},[g]),C=(0,J.useCallback)(e=>S.get(e),[S]),w=(0,J.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,J.useCallback)(e=>w.get(e),[w]),E=(0,J.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,J.useCallback)(e=>E.get(e),[E]),O=(0,J.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,J.useCallback)(e=>e.type===`x-error`?!0:!(e.type===`progress`||e.type===`custom-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,J.useMemo)(()=>yu(e,k),[e,k]),j=(0,J.useMemo)(()=>A.map(e=>Tu(e.conversation).toLowerCase()),[A]),M=(0,J.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,J.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,J.useEffect)(()=>{p(0)},[u]),(0,J.useEffect)(()=>{c&&requestAnimationFrame(()=>{let e=Eu();e!==null&&(e.focus(),e.select())})},[c]);let ee=(0,J.useCallback)(e=>{d(e.trim().toLowerCase()),p(0)},[]);(0,J.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,J.useEffect)(()=>{let e=a.current;if(e===null||(m.current!==null&&(window.cancelAnimationFrame(m.current),m.current=null),Du(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=Ou(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,J.useEffect)(()=>{let e=a.current;return()=>{m.current!==null&&window.cancelAnimationFrame(m.current),Du(e)}},[a]);let N=()=>{M.length!==0&&p(e=>e===0?M.length-1:e-1)},te=()=>{M.length!==0&&p(e=>(e+1)%M.length)},ne=(0,J.useCallback)((e,t)=>{t===null?h.current.delete(e):h.current.set(e,t)},[]),re=e=>{let i=A[e];if(i===void 0)return null;if(i.conversation.type===`x-error`)return(0,Y.jsx)(`div`,{className:`w-full flex justify-start`,children:(0,Y.jsx)(ku,{errorLine:i.conversation.line})});let a=i.conversation,o=a.type===`user`&&typeof a.message.content==`string`&&oc(a.message.content).kind===`local-command`;return(0,Y.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!==`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,Y.jsx)(`div`,{className:`w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%]`,children:(0,Y.jsx)(gu,{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,Y.jsxs)(uc,{conversations:g,children:[o&&c&&(0,Y.jsx)(`div`,{className:`sticky top-2 z-20 mb-3 flex justify-end`,children:(0,Y.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,Y.jsx)(we,{className:`h-4 w-4 text-muted-foreground`}),(0,Y.jsx)(Pt,{id:xu,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?N():te();return}ee(t)}}),(0,Y.jsx)(`span`,{className:`min-w-14 text-right text-xs text-muted-foreground`,children:M.length===0?`0/0`:`${f+1}/${M.length}`}),(0,Y.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{let e=Eu()?.value??``;if(e.trim().toLowerCase()!==u){ee(e);return}N()},disabled:M.length===0,children:(0,Y.jsx)(Tn,{className:`h-4 w-4`})}),(0,Y.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{let e=Eu()?.value??``;if(e.trim().toLowerCase()!==u){ee(e);return}te()},disabled:M.length===0,children:(0,Y.jsx)(H,{className:`h-4 w-4`})}),(0,Y.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>l(!1),children:(0,Y.jsx)(Se,{className:`h-4 w-4`})})]})}),(0,Y.jsx)(`ul`,{className:`w-full`,children:A.map((e,t)=>{let n=re(t);return n===null?null:(0,Y.jsx)(`li`,{ref:e=>ne(t,e),children:n},e.rowKey)})}),(0,Y.jsx)(bu,{scheduledJobs:i})]})},ju=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}),Mu=(e,t)=>e.some(e=>e.type===`user`&&e.timestamp>=t),Nu=h(new Map),Pu=g(),Fu=e=>{let t=Pu.get(Nu),n=new Map(t);n.set(e.sessionId,e),Pu.set(Nu,n)},Iu=e=>Pu.get(Nu).get(e),Lu=e=>{let t=Pu.get(Nu);if(!t.has(e))return;let n=new Map(t);n.delete(e),Pu.set(Nu,n)},Ru=e=>e.filter(e=>e.type!==`x-error`),zu=(e,t)=>{let{isConnected:n}=a(Wt);return f({queryKey:s(e,t).queryKey,queryFn:async()=>{let n=await s(e,t).queryFn(),r=Iu(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:[ju(r)],lastModifiedAt:r.sentAt}}:n;if(r)if(Mu(Ru(n.session.conversations),r.sentAt))r.isNewSession||Lu(t);else{let e=ju(r);return{...n,session:{...n.session,conversations:[...n.session.conversations,e]}}}return n},refetchInterval:n?!1:3e4,refetchIntervalInBackground:!1})},Bu=(e,t)=>{let n=zu(e,t).data?.session;if(n==null)throw Error(`Session not found`);let r=(0,J.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,J.useCallback)(e=>r.get(e),[r]);return{session:n,conversations:n.conversations,getToolResult:i}},Vu=({status:e})=>{switch(e){case`completed`:return(0,Y.jsx)($e,{className:`w-3.5 h-3.5 flex-shrink-0 text-green-600 dark:text-green-500`});case`in_progress`:return(0,Y.jsx)(Dn,{className:`w-3.5 h-3.5 flex-shrink-0 text-amber-600 dark:text-amber-500`});case`pending`:return(0,Y.jsx)(kn,{className:`w-3.5 h-3.5 flex-shrink-0 text-muted-foreground`});default:return null}},Hu=({todos:e})=>{let t=mo(),{setIsTodoSectionOpen:n}=ho();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,Y.jsxs)(`div`,{className:`border-t border-border/40 bg-muted/5`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:G(`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,Y.jsx)(H,{className:`w-3.5 h-3.5 text-muted-foreground`}):(0,Y.jsx)(dt,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,Y.jsx)(Xn,{className:G(`w-3.5 h-3.5`,a?`text-amber-600 dark:text-amber-500`:`text-muted-foreground`)}),(0,Y.jsx)(`span`,{className:G(`flex-1 text-left`,a?`text-amber-700 dark:text-amber-400`:`text-muted-foreground`),children:(0,Y.jsx)(z,{id:`panel.todo.collapsed_title`})}),(0,Y.jsxs)(`span`,{className:G(`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,Y.jsx)(`div`,{className:`p-2 space-y-1 max-h-48 overflow-y-auto border-t border-border/40`,children:e.map(e=>(0,Y.jsxs)(`div`,{className:G(`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,Y.jsx)(Vu,{status:e.status}),(0,Y.jsx)(`span`,{className:G(`flex-1 break-words`,e.status===`completed`&&`line-through`),children:e.content})]},`${e.content}-${e.status}`))})]})},Uu=e=>e.toSorted((e,t)=>e.displayPath.localeCompare(t.displayPath)),Wu=(e,t)=>{if(t===void 0||t===``)return{internal:[],external:Uu(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:Uu(r),external:Uu(i)}},Gu=({title:e,count:t,defaultOpen:n=!1,children:r,icon:i,stickyTop:a=0})=>{let[o,s]=(0,J.useState)(n);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(H,{className:`w-3.5 h-3.5`}):(0,Y.jsx)(dt,{className:`w-3.5 h-3.5`}),i,(0,Y.jsx)(`span`,{className:`flex-1 text-left`,children:e}),(0,Y.jsx)(`span`,{className:`text-[10px] bg-muted px-1.5 py-0.5 rounded-full`,children:t})]}),o&&(0,Y.jsx)(`div`,{className:`px-1 pb-2 border-b border-border/40`,children:r})]})},Ku=({filePath:e,displayPath:t,toolName:n,projectId:r,isExternal:i})=>{let a=async()=>{try{await navigator.clipboard.writeText(e),R.success(`File path copied`)}catch(e){console.error(`Failed to copy file path:`,e),R.error(`Failed to copy file path`)}};return(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[i===!0?(0,Y.jsx)(Ln,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}):(0,Y.jsx)(Bn,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate text-left flex-1 font-mono text-xs`,children:t}),(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,Y.jsx)(kc,{projectId:r,filePaths:[e],children:(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,"aria-label":`Open file`,children:(0,Y.jsx)(Tt,{className:`h-3.5 w-3.5 text-muted-foreground`})})}),(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>void a(),"aria-label":`Copy file path`,children:(0,Y.jsx)(Pn,{className:`h-3.5 w-3.5 text-muted-foreground`})})]})]})},qu=({name:e,timestamp:t,inputSummary:n})=>{let r=(0,J.useMemo)(()=>{try{return new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}catch{return``}},[t]);return(0,Y.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,Y.jsx)(br,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground mt-0.5`}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:e}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r})]}),n&&(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate mt-0.5 font-mono`,children:n})]})]})},Ju=({message:e,icon:t})=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-3 text-xs text-muted-foreground`,children:[t,(0,Y.jsx)(`span`,{children:e})]}),Yu=({title:e,count:t,defaultOpen:n=!1,children:r,icon:i,stickyTop:a=0})=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(H,{className:`w-3.5 h-3.5`}),i,(0,Y.jsx)(`span`,{className:`flex-1 text-left`,children:e}),(0,Y.jsx)(`span`,{className:`text-[10px] bg-muted px-1.5 py-0.5 rounded-full`,children:t})]}),n&&(0,Y.jsx)(`div`,{className:`px-1 pb-2 border-b border-border/40`,children:r})]}),Xu=()=>void 0,Zu=({projectId:e,sessionId:t,agentId:n,title:r,isOpen:i,onOpenChange:a})=>{let o=(0,J.useRef)(null),{data:s,isLoading:c,error:l,refetch:u}=Ce({...w(e,n,t),enabled:i,staleTime:0}),d=s?.conversations??[];return(0,Y.jsx)(ze,{open:i,onOpenChange:a,children:(0,Y.jsxs)(He,{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,Y.jsx)(Ue,{className:`px-6 py-4 border-b bg-muted/30`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,Y.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,Y.jsx)(ge,{className:`h-5 w-5 text-primary`})})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(ke,{className:`text-lg font-semibold leading-tight mb-1 pr-2`,children:r.length>120?`${r.slice(0,120)}...`:r}),(0,Y.jsxs)(Oe,{className:`text-xs flex items-center gap-2 flex-wrap`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`Agent:`,` `,(0,Y.jsx)(`code`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono`,children:n.slice(0,8)})]}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`|`}),(0,Y.jsx)(`span`,{children:(0,Y.jsx)(z,{id:`assistant.tool.message_count`,values:{count:d.length}})})]})]})]})}),(0,Y.jsxs)(`div`,{ref:o,className:`flex-1 overflow-auto px-6 py-4`,children:[c&&(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Y.jsx)(M,{className:`h-8 w-8 animate-spin text-primary`}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Y.jsx)(z,{id:`assistant.tool.loading_task`})})]}),l!==null&&!c&&(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Y.jsx)(Xe,{className:`h-8 w-8 text-destructive`}),(0,Y.jsx)(`p`,{className:`text-sm text-destructive`,children:(0,Y.jsx)(z,{id:`assistant.tool.error_loading_task`})}),(0,Y.jsx)(W,{variant:`outline`,size:`sm`,onClick:()=>void u(),children:(0,Y.jsx)(z,{id:`assistant.tool.retry`})})]}),!c&&l===null&&d.length===0&&(0,Y.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Y.jsx)(z,{id:`assistant.tool.no_task_data`})})}),!c&&l===null&&d.length>0&&(0,Y.jsx)(Au,{conversations:d.map(e=>({...e,isSidechain:!1})),getToolResult:Xu,projectId:e,sessionId:t,scheduledJobs:[],scrollContainerRef:o})]})]})})},Qu=({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,Y.jsxs)(W,{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,Y.jsx)(Sn,{className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`truncate text-left flex-1 text-xs`,children:i}),(0,Y.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)})]})},$u=()=>(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[(0,Y.jsx)(`div`,{className:`px-3 py-3 border-b border-border/40 bg-muted/10`,children:(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Y.jsx)(z,{id:`session.empty_state.description`})})}),(0,Y.jsx)(Yu,{title:(0,Y.jsx)(z,{id:`panel.files.edited_section`}),count:0,icon:(0,Y.jsx)(Bn,{className:`w-3.5 h-3.5`}),stickyTop:0,children:(0,Y.jsx)(Ju,{icon:(0,Y.jsx)(Bn,{className:`h-3.5 w-3.5`}),message:(0,Y.jsx)(z,{id:`panel.files.no_edited_files`})})}),(0,Y.jsx)(Yu,{title:(0,Y.jsx)(z,{id:`panel.files.tool_calls_section`}),count:0,icon:(0,Y.jsx)(wr,{className:`w-3.5 h-3.5`}),stickyTop:33,children:(0,Y.jsx)(Ju,{icon:(0,Y.jsx)(wr,{className:`h-3.5 w-3.5`}),message:(0,Y.jsx)(z,{id:`panel.files.no_tool_calls`})})}),(0,Y.jsx)(Yu,{title:`Agents`,count:0,icon:(0,Y.jsx)(Sn,{className:`w-3.5 h-3.5`}),stickyTop:66,children:(0,Y.jsx)(Ju,{icon:(0,Y.jsx)(Sn,{className:`h-3.5 w-3.5`}),message:(0,Y.jsx)(z,{id:`panel.files.no_agents`})})})]}),(0,Y.jsx)(Hu,{todos:null})]}),ed=({projectId:e,sessionId:t})=>{let{conversations:n}=Bu(e,t),[r,i]=(0,J.useState)(new Set),[a,o]=(0,J.useState)(null),{data:s,isPending:c}=Ce({...j(e,t)}),l=(0,J.useMemo)(()=>s?.agentSessions??[],[s?.agentSessions]),u=l.length>0,d=(0,J.useMemo)(()=>a===null?``:l.find(e=>e.agentId===a)?.firstMessage??`Agent ${a.slice(0,8)}`,[a,l]),f=(0,J.useCallback)(e=>{o(e)},[]),p=(0,J.useCallback)(e=>{e||o(null)},[]),m=(0,J.useMemo)(()=>Js(n),[n]),h=(0,J.useMemo)(()=>Xs(n),[n]),g=(0,J.useMemo)(()=>{let e=new Set(h.map(e=>e.name));return Array.from(e).sort()},[h]),_=(0,J.useMemo)(()=>r.size===0?h:h.filter(e=>r.has(e.name)),[h,r]),v=(0,J.useMemo)(()=>{for(let e of n)if(`cwd`in e&&typeof e.cwd==`string`)return e.cwd},[n]),y=(0,J.useMemo)(()=>Wu(m,v),[m,v]),b=(0,J.useMemo)(()=>rc(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,Y.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[(0,Y.jsx)(Gu,{title:(0,Y.jsx)(z,{id:`panel.files.edited_section`}),count:m.length,icon:(0,Y.jsx)(Bn,{className:`w-3.5 h-3.5`}),stickyTop:0,children:x?(0,Y.jsxs)(Y.Fragment,{children:[y.internal.length>0&&(0,Y.jsx)(`div`,{className:`space-y-0.5`,children:y.internal.map(t=>(0,Y.jsx)(Ku,{filePath:t.filePath,displayPath:t.displayPath,toolName:t.toolName,projectId:e},t.filePath))}),y.external.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-0.5 mt-2`,children:[(0,Y.jsx)(`div`,{className:`px-2 py-1 text-[10px] font-medium text-muted-foreground/70 uppercase tracking-wider`,children:(0,Y.jsx)(z,{id:`sidebar.edited_files.external`})}),y.external.map(t=>(0,Y.jsx)(Ku,{filePath:t.filePath,displayPath:t.displayPath,toolName:t.toolName,projectId:e,isExternal:!0},t.filePath))]})]}):(0,Y.jsx)(Ju,{icon:(0,Y.jsx)(Bn,{className:`h-3.5 w-3.5`}),message:(0,Y.jsx)(z,{id:`panel.files.no_edited_files`})})}),(0,Y.jsxs)(Gu,{title:(0,Y.jsx)(z,{id:`panel.files.tool_calls_section`}),count:_.length,icon:(0,Y.jsx)(wr,{className:`w-3.5 h-3.5`}),stickyTop:33,children:[h.length>0&&(0,Y.jsx)(`div`,{className:`px-2 pb-2`,children:(0,Y.jsxs)(ft,{children:[(0,Y.jsx)(ot,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`outline`,size:`sm`,className:G(`h-7 text-xs gap-1.5`,r.size>0&&`border-primary text-primary`),children:[(0,Y.jsx)(Hn,{className:`w-3 h-3`}),(0,Y.jsx)(z,{id:`panel.files.filter_tools`}),r.size>0&&(0,Y.jsx)(`span`,{className:`ml-1 px-1 py-0.5 bg-primary/10 rounded text-[10px]`,children:r.size})]})}),(0,Y.jsxs)(bt,{align:`start`,className:`w-48 p-2`,children:[(0,Y.jsx)(`div`,{className:`space-y-1`,children:g.map(e=>(0,Y.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,Y.jsx)(vt,{checked:r.has(e),onCheckedChange:()=>C(e)}),(0,Y.jsx)(`span`,{className:`text-xs`,children:e})]},e))}),r.size>0&&(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,className:`w-full mt-2 h-7 text-xs`,onClick:()=>{i(new Set)},children:`Clear filter`})]})]})}),S?(0,Y.jsx)(`div`,{className:`space-y-0.5`,children:_.map(e=>(0,Y.jsx)(qu,{name:e.name,timestamp:e.timestamp,inputSummary:e.inputSummary},e.id))}):(0,Y.jsx)(Ju,{icon:(0,Y.jsx)(wr,{className:`h-3.5 w-3.5`}),message:r.size>0?(0,Y.jsx)(z,{id:`panel.files.no_filtered_tool_calls`}):(0,Y.jsx)(z,{id:`panel.files.no_tool_calls`})})]}),(0,Y.jsx)(Gu,{title:`Agents`,count:l.length,icon:(0,Y.jsx)(Sn,{className:`w-3.5 h-3.5`}),stickyTop:66,children:c?(0,Y.jsx)(Ju,{icon:(0,Y.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}),message:(0,Y.jsx)(z,{id:`panel.files.loading_agents`})}):u?(0,Y.jsx)(`div`,{className:`space-y-0.5`,children:l.map(e=>(0,Y.jsx)(Qu,{agentId:e.agentId,firstMessage:e.firstMessage,onClick:()=>f(e.agentId)},e.agentId))}):(0,Y.jsx)(Ju,{icon:(0,Y.jsx)(Sn,{className:`h-3.5 w-3.5`}),message:(0,Y.jsx)(z,{id:`panel.files.no_agents`})})})]}),(0,Y.jsx)(Hu,{todos:b}),a!==null&&(0,Y.jsx)(Zu,{projectId:e,sessionId:t,agentId:a,title:d,isOpen:!0,onOpenChange:p})]})},td=Ba,nd=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(Va,{ref:n,"data-slot":`tabs-list`,className:G(`inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground gap-1`,e),...t}));nd.displayName=Va.displayName;var rd=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(Ha,{ref:n,"data-slot":`tabs-trigger`,className:G(`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}));rd.displayName=Ha.displayName;var id=J.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(Ua,{ref:n,"data-slot":`tabs-content`,className:G(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));id.displayName=Ua.displayName;var ad=e=>Ce({queryKey:D(e).queryKey,queryFn:D(e).queryFn,staleTime:3e4}),od=e=>f({queryKey:D(e).queryKey,queryFn:D(e).queryFn,staleTime:3e4}),sd=e=>f({queryKey:A(e).queryKey,queryFn:A(e).queryFn,staleTime:3e4}),cd=(e,t,n)=>f({queryKey:C(e,t,n).queryKey,queryFn:C(e,t,n).queryFn,staleTime:3e4}),ld=e=>{let t=o();return l({mutationFn:async t=>{let n=await c.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:A(e).queryKey}),t.invalidateQueries({queryKey:D(e).queryKey}),t.invalidateQueries({queryKey:[`git`,`diff`,e]})}})},ud=()=>l({mutationFn:async({projectId:e,fromRef:t,toRef:n})=>{let r=await c.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()}}),dd=e=>l({mutationFn:async({files:t,message:n})=>{let r=await c.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()}}),fd=e=>l({mutationFn:async()=>{let t=await c.api.projects[`:projectId`].git.push.$post({param:{projectId:e}});if(!t.ok)throw Error(`Failed to push commits: ${t.statusText}`);return t.json()}}),pd=e=>l({mutationFn:async({files:t,message:n})=>{let r=await c.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()}}),md=()=>(0,Y.jsxs)(W,{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,Y.jsx)(Un,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(M,{className:`w-3 h-3 animate-spin`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`Loading...`})]})]}),hd=({projectId:e})=>{let[t,n]=(0,J.useState)(!1),{data:r}=od(e),{data:i}=sd(e),{mutate:a,isPending:o}=ld(e),s=r?.success?r.data.currentBranch?.name??null:null,c=(0,J.useMemo)(()=>i?.success?i.data.branches:[],[i]),l=e=>{if(e===s){n(!1);return}a(e,{onSuccess:t=>{t.success?R.success(`Switched to ${e}`):R.error(`Failed to switch branch`),n(!1)},onError:()=>{R.error(`Failed to switch branch`),n(!1)}})};return(0,Y.jsxs)(ft,{open:t,onOpenChange:n,children:[(0,Y.jsx)(ot,{asChild:!0,children:(0,Y.jsxs)(W,{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,Y.jsx)(Un,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,Y.jsx)(`span`,{className:`font-mono truncate flex-1 text-left`,children:o?(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(M,{className:`w-3 h-3 animate-spin`}),`Switching...`]}):s??`No branch`})]})}),(0,Y.jsx)(bt,{className:`w-64 p-0`,align:`start`,children:(0,Y.jsxs)(ps,{children:[(0,Y.jsx)(ms,{placeholder:`Search branch...`,className:`h-8`}),(0,Y.jsxs)(hs,{children:[(0,Y.jsx)(gs,{children:`No branch found.`}),(0,Y.jsx)(_s,{children:c.map(e=>(0,Y.jsxs)(vs,{value:e.name,onSelect:()=>l(e.name),className:`text-xs`,children:[(0,Y.jsx)(Un,{className:`w-3.5 h-3.5 mr-2 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.name}),e.name===s&&(0,Y.jsx)(ut,{className:`w-3.5 h-3.5 text-primary`})]},e.name))})]})]})})]})},gd=({projectId:e,filePath:t,status:n,additions:r,deletions:i,diffHunks:a,children:o})=>{let[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(`diff`),{resolvedTheme:d}=Kt(),f=d===`dark`?Qt:rn,p=e=>{(e===`content`||e===`diff`)&&u(e)},{data:m,isLoading:h,error:g,refetch:_}=Ce({...b(e,t),enabled:s&&l===`content`}),v=t.split(`/`).pop()??t,y=m?.success===!0?m.language:Gs(t);return(0,Y.jsxs)(ze,{open:s,onOpenChange:c,children:[(0,Y.jsx)(je,{asChild:!0,children:o}),(0,Y.jsxs)(He,{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,Y.jsx)(Ue,{className:`px-6 py-4 border-b bg-muted/30`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,Y.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center`,children:(0,Y.jsx)(Rn,{className:`h-5 w-5 text-primary`})})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(ke,{className:`text-lg font-semibold leading-tight mb-1 pr-8 break-all`,children:v}),(0,Y.jsx)(Oe,{className:`text-xs flex items-center gap-2 flex-wrap`,asChild:!0,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`code`,{className:`px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono break-all`,children:t}),(0,Y.jsx)(U,{variant:`secondary`,className:G(`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,Y.jsxs)(`span`,{className:`text-green-600 dark:text-green-400 text-[10px]`,children:[`+`,r]}),i>0&&(0,Y.jsxs)(`span`,{className:`text-red-600 dark:text-red-400 text-[10px]`,children:[`-`,i]})]})})]})]})}),(0,Y.jsxs)(td,{value:l,onValueChange:p,className:`flex-1 flex flex-col overflow-hidden`,children:[(0,Y.jsxs)(nd,{className:`mx-4 mt-2 w-fit`,children:[(0,Y.jsxs)(rd,{value:`diff`,className:`text-xs`,children:[(0,Y.jsx)(Wn,{className:`w-3.5 h-3.5 mr-1`}),(0,Y.jsx)(z,{id:`panel.git.view_diff`})]}),(0,Y.jsxs)(rd,{value:`content`,className:`text-xs`,children:[(0,Y.jsx)(Tt,{className:`w-3.5 h-3.5 mr-1`}),(0,Y.jsx)(z,{id:`panel.git.view_content`})]})]}),(0,Y.jsx)(id,{value:`diff`,className:`flex-1 overflow-auto m-0 p-4`,children:a&&a.length>0?(0,Y.jsx)(_l,{fileDiff:{filename:t,isNew:n===`added`,isDeleted:n===`deleted`,isRenamed:n===`renamed`,isBinary:!1,hunks:a,linesAdded:r,linesDeleted:i}}):(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:`No diff available`})}),(0,Y.jsxs)(id,{value:`content`,className:`flex-1 overflow-auto m-0`,children:[h&&(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4`,children:[(0,Y.jsx)(M,{className:`h-8 w-8 animate-spin text-primary`}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Y.jsx)(z,{id:`assistant.tool.loading_file`})})]}),g!==null&&(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 px-6`,children:[(0,Y.jsx)(zt,{className:`h-8 w-8 text-destructive`}),(0,Y.jsx)(`p`,{className:`text-sm text-destructive text-center`,children:(0,Y.jsx)(z,{id:`assistant.tool.error_loading_file`})}),(0,Y.jsx)(W,{variant:`outline`,size:`sm`,onClick:()=>{_()},children:(0,Y.jsx)(z,{id:`assistant.tool.retry`})})]}),m&&!m.success&&(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 px-6`,children:[(0,Y.jsx)(zt,{className:`h-8 w-8 text-destructive`}),(0,Y.jsxs)(`p`,{className:`text-sm text-destructive text-center`,children:[m.error===`NOT_FOUND`&&(0,Y.jsx)(z,{id:`assistant.tool.file_not_found`}),m.error===`BINARY_FILE`&&(0,Y.jsx)(z,{id:`assistant.tool.binary_file`}),m.error===`INVALID_PATH`&&(0,Y.jsx)(z,{id:`assistant.tool.invalid_path`}),m.error===`READ_ERROR`&&(0,Y.jsx)(z,{id:`assistant.tool.read_error`})]})]}),m?.success===!0&&(0,Y.jsx)(gn,{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})]})]})]})]})},_d=()=>(0,Y.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Y.jsx)(M,{className:`w-5 h-5 animate-spin text-muted-foreground`})}),vd=({projectId:e})=>{let{i18n:t}=B(),n=(0,J.useId)(),{data:r}=cd(e,`HEAD`,`working`),i=o(),a=r?.success?r.data.files:[],s=a.length>0,[c,l]=(0,J.useState)(()=>new Map),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(!1),m=dd(e),h=fd(e),g=pd(e),_=r?.success===!0?r.data:void 0,v=(0,J.useMemo)(()=>{let e=new Map;if(_===void 0)return e;for(let t of _.diffs)e.set(t.file.filePath,{hunks:t.hunks});return e},[_]);(0,J.useEffect)(()=>{_!==void 0&&_.files.length>0&&l(new Map(_.files.map(e=>[e.filePath,!0])))},[_]);let y=e=>{l(t=>{let n=new Map(t);return n.set(e,t.get(e)!==!0),n})},b=()=>{_!==void 0&&_.files.length>0&&l(new Map(_.files.map(e=>[e.filePath,!0])))},x=()=>{_!==void 0&&_.files.length>0&&l(new Map(_.files.map(e=>[e.filePath,!1])))},S=(0,J.useCallback)(()=>{i.invalidateQueries({queryKey:[`git`,`diff`,e]})},[i,e]),C=async()=>{let e=Array.from(c.entries()).filter(([,e])=>e).map(([e])=>e);try{let t=await m.mutateAsync({files:e,message:u});t.success?(R.success(`Committed ${t.filesCommitted} files (${t.commitSha.slice(0,7)})`),d(``),S()):R.error(t.error,{description:t.details})}catch{R.error(t._(`Failed to commit`))}},w=async()=>{try{let e=await h.mutateAsync();e.success?R.success(`Pushed to ${e.remote}/${e.branch}`):R.error(e.error,{description:e.details})}catch{R.error(t._(`Failed to push`))}},T=async()=>{let e=Array.from(c.entries()).filter(([,e])=>e).map(([e])=>e);try{let n=await g.mutateAsync({files:e,message:u});n.success?(R.success(`Committed and pushed (${n.commitSha.slice(0,7)})`),d(``),S()):n.success===!1&&`commitSucceeded`in n&&n.commitSucceeded?(R.warning(`Committed (${n.commitSha?.slice(0,7)}), but push failed: ${n.error}`,{action:{label:t._(`Retry Push`),onClick:()=>{w()}}}),d(``),S()):R.error(n.error,{description:n.details})}catch{R.error(t._(`Failed to commit and push`))}},E=Array.from(c.values()).filter(Boolean).length,D=E===0||u.trim().length===0||m.isPending;return s?(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.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,Y.jsxs)(`button`,{type:`button`,onClick:()=>p(!f),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,Y.jsx)(`span`,{className:`text-xs font-medium text-gray-700 dark:text-gray-300`,children:(0,Y.jsx)(z,{id:`diff.commit.changes`})}),f?(0,Y.jsx)(Tn,{className:`h-4 w-4 text-gray-600 dark:text-gray-400`}):(0,Y.jsx)(H,{className:`h-4 w-4 text-gray-600 dark:text-gray-400`})]}),f&&(0,Y.jsxs)(`div`,{className:`p-3 pt-0 space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:b,disabled:m.isPending,className:`h-6 text-[10px]`,children:(0,Y.jsx)(z,{id:`diff.select.all`})}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,onClick:x,disabled:m.isPending,className:`h-6 text-[10px]`,children:(0,Y.jsx)(z,{id:`diff.deselect.all`})}),(0,Y.jsxs)(`span`,{className:`text-[10px] text-gray-600 dark:text-gray-400`,children:[E,` / `,a.length,` files`]})]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`label`,{htmlFor:n,className:`text-[10px] font-medium text-gray-700 dark:text-gray-300`,children:(0,Y.jsx)(z,{id:`diff.commit.message`})}),(0,Y.jsx)(al,{id:n,placeholder:`Enter commit message...`,value:u,onChange:e=>d(e.target.value),disabled:m.isPending,className:`resize-none text-xs min-h-[60px]`,rows:2})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,Y.jsx)(W,{onClick:()=>{C()},disabled:D,size:`sm`,className:`h-7 text-xs`,children:m.isPending?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(M,{className:`w-3 h-3 mr-1 animate-spin`}),(0,Y.jsx)(z,{id:`diff.committing`})]}):(0,Y.jsx)(z,{id:`diff.commit`})}),(0,Y.jsx)(W,{onClick:()=>{w()},disabled:h.isPending,variant:`outline`,size:`sm`,className:`h-7 text-xs`,children:h.isPending?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(M,{className:`w-3 h-3 mr-1 animate-spin`}),(0,Y.jsx)(z,{id:`diff.pushing`})]}):(0,Y.jsx)(z,{id:`diff.push`})}),(0,Y.jsx)(W,{onClick:()=>{T()},disabled:D||g.isPending,variant:`secondary`,size:`sm`,className:`h-7 text-xs`,children:g.isPending?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(M,{className:`w-3 h-3 mr-1 animate-spin`}),(0,Y.jsx)(z,{id:`diff.committing.pushing`})]}):(0,Y.jsx)(z,{id:`diff.commit.push`})})]})]})]}),(0,Y.jsx)(`div`,{className:`p-2 space-y-1`,children:a.map(t=>{let n=v.get(t.filePath);return(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(vt,{checked:c.get(t.filePath)??!1,onCheckedChange:()=>y(t.filePath),disabled:m.isPending,className:`h-3 w-3 flex-shrink-0`}),(0,Y.jsx)(gd,{projectId:e,filePath:t.filePath,status:t.status,additions:t.additions,deletions:t.deletions,diffHunks:n?.hunks,children:(0,Y.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,Y.jsx)(`span`,{className:G(`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,Y.jsx)(`span`,{className:`truncate flex-1 font-mono`,children:t.filePath}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[t.additions>0&&(0,Y.jsxs)(`span`,{className:`text-green-600 dark:text-green-400`,children:[`+`,t.additions]}),t.deletions>0&&(0,Y.jsxs)(`span`,{className:`text-red-600 dark:text-red-400`,children:[`-`,t.deletions]})]})]})})]},t.filePath)})})]}):(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,Y.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,Y.jsx)(`div`,{className:`w-12 h-12 mx-auto rounded-xl bg-muted/30 flex items-center justify-center`,children:(0,Y.jsx)(Wn,{className:`w-6 h-6 text-muted-foreground/50`})}),(0,Y.jsx)(`div`,{className:`space-y-1`,children:(0,Y.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:(0,Y.jsx)(z,{id:`panel.git.empty`})})})]})})},yd=({projectId:e,sessionId:t})=>{let{conversations:n}=Bu(e,t);return(0,Y.jsx)(Hu,{todos:(0,J.useMemo)(()=>rc(n),[n])})},bd=({projectId:e,sessionId:t})=>{let{session:n}=Bu(e,t),r=n.meta.prLinks;return r.length===0?null:(0,Y.jsx)(`div`,{className:`border-t border-border/40`,children:(0,Y.jsxs)(`div`,{className:`px-3 py-2 bg-muted/10`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-2`,children:[(0,Y.jsx)(Gn,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:(0,Y.jsx)(z,{id:`panel.git.pr_links`})})]}),(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:r.map(e=>(0,Y.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,Y.jsx)(Gn,{className:`w-3.5 h-3.5 text-emerald-500 flex-shrink-0`}),(0,Y.jsxs)(`span`,{className:`flex-1 min-w-0 truncate text-foreground`,children:[e.prRepository,`#`,e.prNumber]}),(0,Y.jsx)(Ln,{className:`w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0`})]},`${e.prRepository}#${e.prNumber}`))})]})})},xd=({projectId:e,sessionId:t})=>{let n=o(),r=Dr({predicate:t=>t.queryKey[0]===`git`&&t.queryKey.includes(e)})>0,i=(0,J.useCallback)(()=>{n.invalidateQueries({queryKey:D(e).queryKey}),n.invalidateQueries({queryKey:A(e).queryKey}),n.invalidateQueries({queryKey:[`git`,`diff`,e]})},[n,e]);return(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Y.jsxs)(`div`,{className:`border-b border-border/40 px-3 py-2 bg-muted/10 flex items-center gap-1`,children:[(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(md,{}),children:(0,Y.jsx)(hd,{projectId:e})}),(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 flex-shrink-0`,onClick:i,disabled:r,children:(0,Y.jsx)(Bt,{className:G(`w-3.5 h-3.5 text-muted-foreground`,r&&`animate-spin`)})})]}),(0,Y.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(_d,{}),children:(0,Y.jsx)(vd,{projectId:e})})}),t!==void 0&&t!==``&&(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(bd,{projectId:e,sessionId:t})}),t!==void 0&&t!==``&&(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(yd,{projectId:e,sessionId:t})})]})},Sd=be(L(),L()),Cd=({projectId:e,sessionId:t})=>`${e}:${t}`,wd=(e,t)=>{let n=Sd.safeParse(e);return n.success?n.data:t},Td=(e,t,n)=>{if(n===``){let{[t]:n,...r}=e;return r}return{...e,[t]:n}},Ed=Gc(()=>localStorage),Dd=qc(`claude-code-viewer-chat-input-drafts`,{},{getItem:(e,t)=>wd(Ed.getItem(e,t),t),setItem:(e,t)=>Ed.setItem(e,t),removeItem:e=>Ed.removeItem(e)}),Od=e=>{let[t,n]=E(Dd),r=Cd(e);return[t[r]??``,(0,J.useCallback)(e=>{n(t=>{let n=t[r]??``;return Td(t,r,typeof e==`function`?e(n):e)})},[r,n]),(0,J.useCallback)(()=>{n(e=>Td(e,r,``))},[r,n])]},kd=({projectId:e,sessionId:t})=>{let{conversations:n}=Bu(e,t);return(0,Y.jsx)(Hu,{todos:(0,J.useMemo)(()=>rc(n),[n])})},Ad=({summary:e,className:t})=>(0,Y.jsx)(`div`,{className:G(`bg-gray-50 dark:bg-gray-800 rounded-lg p-2 border border-gray-200 dark:border-gray-700`,t),children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(zn,{className:`h-4 w-4 text-gray-600 dark:text-gray-400`}),(0,Y.jsxs)(`span`,{className:`font-medium`,children:[e.filesChanged,` `,(0,Y.jsx)(z,{id:`diff.files.changed`})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.insertions>0&&(0,Y.jsxs)(`span`,{className:`text-green-600 dark:text-green-400 font-medium`,children:[`+`,e.insertions]}),e.deletions>0&&(0,Y.jsxs)(`span`,{className:`text-red-600 dark:text-red-400 font-medium`,children:[`-`,e.deletions]})]})]})}),jd=({label:e,value:t,onValueChange:n,refs:r})=>{let i=(0,J.useId)(),a=e=>{switch(e){case`branch`:return(0,Y.jsx)(Un,{className:`h-4 w-4`});case`commit`:return(0,Y.jsx)(`span`,{className:`text-xs`,children:`📝`});case`head`:return(0,Y.jsx)(Un,{className:`h-4 w-4`});case`working`:return(0,Y.jsx)(`span`,{className:`text-xs`,children:`🚧`});default:return(0,Y.jsx)(Un,{className:`h-4 w-4`})}};return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,Y.jsxs)(gc,{value:t,onValueChange:n,children:[(0,Y.jsx)(vc,{className:`w-full h-8 text-xs`,children:(0,Y.jsx)(_c,{})}),(0,Y.jsx)(xc,{id:i,children:r.map(e=>(0,Y.jsx)(X,{value:e.name,className:`text-xs`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a(e.type),(0,Y.jsx)(`span`,{children:e.displayName}),e.sha!==void 0&&e.sha!==``&&(0,Y.jsx)(`span`,{className:`text-[10px] text-gray-500 dark:text-gray-400 font-mono`,children:e.sha.substring(0,7)})]})},e.name))})]})]})},Md=({projectId:e,sessionId:t})=>{let{i18n:n}=B(),[r,i]=(0,J.useState)(`HEAD`),[a,o]=(0,J.useState)(`working`),{comments:s,clearComments:c}=rl(t??``),[,l]=Od({projectId:e,sessionId:t??``}),{data:u,isLoading:d}=ad(e),{mutate:f,data:p,isPending:m,error:h}=ud(),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,J.useCallback)(()=>{r.length>0&&a.length>0&&r!==a&&f({projectId:e,fromRef:r,toRef:a})},[r,a,f,e]);return(0,J.useEffect)(()=>{r.length>0&&a.length>0&&x()},[r,a,x]),d?(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,Y.jsx)(M,{className:`w-5 h-5 animate-spin text-muted-foreground`})}),t!==void 0&&t!==``?(0,Y.jsx)(kd,{projectId:e,sessionId:t}):(0,Y.jsx)(Hu,{todos:null})]}):(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Y.jsxs)(`div`,{className:`p-3 border-b border-border/40 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`div`,{className:`flex-1`,children:(0,Y.jsx)(jd,{label:n._(`Compare from`),value:r,onValueChange:i,refs:b.filter(e=>e.name!==`working`)})}),(0,Y.jsx)(`div`,{className:`flex-1`,children:(0,Y.jsx)(jd,{label:n._(`Compare to`),value:a,onValueChange:o,refs:b})})]}),(0,Y.jsx)(W,{onClick:x,disabled:m||r===a,size:`sm`,className:`w-full h-7 text-xs`,children:m?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(M,{className:`w-3 h-3 mr-1.5 animate-spin`}),(0,Y.jsx)(z,{id:`common.loading`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(fr,{className:`w-3 h-3 mr-1.5`}),`Refresh`]})})]}),(0,Y.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[h&&(0,Y.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,Y.jsx)(`p`,{className:`text-red-600 dark:text-red-400 text-xs`,children:h.message})}),_===void 0&&!m&&h===null&&(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,Y.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,Y.jsx)(`div`,{className:`w-12 h-12 mx-auto rounded-xl bg-muted/30 flex items-center justify-center`,children:(0,Y.jsx)(Wn,{className:`w-6 h-6 text-muted-foreground/50`})}),(0,Y.jsx)(`div`,{className:`space-y-1`,children:(0,Y.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:(0,Y.jsx)(z,{id:`panel.review.empty`})})})]})}),_!==void 0&&(0,Y.jsxs)(`div`,{children:[(0,Y.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,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.length===0?n._(`review.comments.empty`):n._(`review.comments.count`,{count:s.length})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,disabled:s.length===0,onClick:()=>{c(),R.success(n._(`review.action.reset.success`))},className:`h-7 text-xs`,children:[(0,Y.jsx)(xr,{className:`w-3 h-3 mr-1`}),(0,Y.jsx)(z,{id:`review.action.reset`})]}),(0,Y.jsxs)(W,{variant:`default`,size:`sm`,disabled:s.length===0,onClick:()=>{let e=il(s,r,a);l(t=>t?`${t}\n\n${e}`:e),R.success(n._(`review.action.insert.success`))},className:`h-7 text-xs`,children:[(0,Y.jsx)(jn,{className:`w-3 h-3 mr-1`}),(0,Y.jsx)(z,{id:`review.action.insert`})]})]})]}),(0,Y.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,Y.jsx)(Ad,{summary:{filesChanged:_.files.length,insertions:_.summary.totalAdditions,deletions:_.summary.totalDeletions}}),(0,Y.jsx)(`div`,{className:`space-y-2`,children:_.diffs.map(e=>(0,Y.jsx)(_l,{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,Y.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Y.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,Y.jsx)(M,{className:`w-6 h-6 animate-spin mx-auto text-muted-foreground`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Y.jsx)(z,{id:`diff.loading`})})]})})]}),t!==void 0&&t!==``?(0,Y.jsx)(kd,{projectId:e,sessionId:t}):(0,Y.jsx)(Hu,{todos:null})]})},Nd={sm:`w-4 h-4`,default:`w-8 h-8`,lg:`w-12 h-12`},Pd={sm:`text-sm`,default:`text-base`,lg:`text-lg`},Fd=({message:e,size:t=`default`,fullScreen:n=!0,className:r})=>{let i=(0,Y.jsxs)(`div`,{className:G(`flex flex-col items-center justify-center gap-3`,r),"data-testid":`loading-indicator`,children:[(0,Y.jsx)(M,{className:G(Nd[t],`animate-spin text-primary`)}),e!==void 0&&e!==``&&(0,Y.jsx)(`p`,{className:G(Pd[t],`text-muted-foreground font-medium`),children:e})]});return n?(0,Y.jsx)(`div`,{className:`flex items-center justify-center w-full h-full min-h-[400px]`,children:i}):i},Id=48,Ld=200,Rd=({children:e,className:t})=>{let{isLeftPanelOpen:n,leftPanelWidth:r}=io(),{setLeftPanelWidth:i}=ao(),a=Ts(),{isResizing:o,handleMouseDown:s}=Ss({onResize:(0,J.useCallback)(e=>{i(e.clientX/window.innerWidth*100)},[i])});if((0,J.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 c=n?`${r}%`:`${Id}px`,l=n?`${Id+Ld}px`:`${Id}px`;return(0,Y.jsxs)(`div`,{className:G(`relative flex-shrink-0 h-full flex overflow-hidden transition-all duration-200`,t),style:{width:c,minWidth:l,maxWidth:n?`50%`:`${Id}px`,userSelect:o?`none`:`auto`},children:[(0,Y.jsx)(`div`,{className:`w-full h-full overflow-hidden`,children:e}),n&&(0,Y.jsx)(`div`,{role:`separator`,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})]})},zd=({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},Bd=e=>{let t=e.changedTouches[0];if(t)return{clientX:t.clientX,clientY:t.clientY}},Vd=({onSwipe:e,threshold:t=50,maxVerticalRatio:n=.75,edgeWidth:r,enabled:i=!0})=>{let a=(0,J.useRef)(null),o=(0,J.useRef)(null),s=(0,J.useRef)(e);s.current=e;let c=(0,J.useCallback)(e=>{if(o.current?.(),o.current=null,!e||!i)return;let c=e=>{let t=Bd(e);t&&(a.current={x:t.clientX,y:t.clientY})},l=e=>{let i=a.current;if(a.current=null,!i)return;let o=Bd(e);if(!o)return;let c=zd({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,J.useEffect)(()=>()=>{o.current?.(),o.current=null},[]),c},Hd=(e,t)=>e===void 0?!t:e,Ud=()=>{let e=m(),t=Jt.useNavigate(),n=Jt.useSearch(),r=(0,J.useRef)(!1),i=(0,J.useRef)(!1),a=Ts(),o=(0,J.useRef)(!1);(0,J.useEffect)(()=>{r.current=!0;let t=o.current?a:Cs(),i=Hd(n.rightPanel,t);e.set(Ga,i),e.set(Ka,n.rightPanelTab),o.current=!0,r.current=!1},[n.rightPanel,n.rightPanelTab,e,a]),(0,J.useEffect)(()=>{let n=e.sub(Ga,()=>{if(r.current)return;i.current=!0;let n=e.get(Ga);t({search:e=>({...e,rightPanel:n}),replace:!0}),queueMicrotask(()=>{i.current=!1})}),a=e.sub(Ka,()=>{if(r.current)return;i.current=!0;let n=e.get(Ka);t({search:e=>({...e,rightPanelTab:n}),replace:!0}),queueMicrotask(()=>{i.current=!1})});return()=>{n(),a()}},[e,t])},Wd=e=>Er({queryKey:v(e).queryKey,queryFn:async({pageParam:t})=>await v(e,t).queryFn(),initialPageParam:void 0,getNextPageParam:e=>e.nextCursor,refetchOnReconnect:!0});F({model:L().optional(),effort:pe([`low`,`medium`,`high`,`max`]).optional(),permissionMode:pe([`acceptEdits`,`bypassPermissions`,`default`,`plan`]).optional(),useSystemPromptPreset:Je().optional()});var Gd=qc(`claude-code-viewer-session-options`,{}),Kd=e=>{let[t,n]=E(Gd);return[(0,J.useMemo)(()=>t[e]??{},[t,e]),(0,J.useCallback)(t=>{n(n=>({...n,[e]:t}))},[n,e])]},qd=(e,t,n)=>[...e.values()].filter(e=>e.projectId===t&&!n.has(e.sessionId)).map(e=>({id:e.sessionId,jsonlFilePath:``,lastModifiedAt: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:[]}})),Jd=F({mode:pe([`preset`,`none`]),append:L().optional()}),Yd=F({allowedDomains:L().optional(),allowLocalBinding:Je().optional()}),Xd=F({enabled:Je().optional(),autoAllowBashIfSandboxed:Je().optional(),allowUnsandboxedCommands:Je().optional(),network:Yd.optional()}),Zd=F({model:L().optional(),disallowedTools:_e(L()).optional(),systemPrompt:Jd.optional(),env:be(L(),L().optional()).optional(),sandbox:Xd.optional(),settingSources:_e(pe([`user`,`project`,`local`])).optional(),maxTurns:xe().int().positive().optional(),maxThinkingTokens:xe().int().positive().optional(),maxBudgetUsd:xe().nonnegative().optional(),effort:pe([`low`,`medium`,`high`,`max`]).optional(),permissionMode:pe([`acceptEdits`,`bypassPermissions`,`default`,`plan`]).optional()}),Qd=[`user`,`project`,`local`],$d=()=>({settingSources:[...Qd],permissionMode:`default`,systemPrompt:{type:`preset`,preset:`claude_code`}}),ef=e=>{let t=e=>e===void 0?!1:Array.isArray(e)?e.length>0:typeof e==`object`&&e?Object.keys(e).length>0:!0,n=e=>{if(e===void 0||e===``)return;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return t.length>0?t:void 0},r=e=>{if(e===void 0)return;let r=n(e.allowedDomains),i=e.allowLocalBinding,a={...r===void 0?{}:{allowedDomains:r},...i===void 0?{}:{allowLocalBinding:i}};return t(a)?a:void 0},i=e=>{if(e===void 0)return;let n=r(e.network),i={...e.enabled===void 0?{}:{enabled:e.enabled},...e.autoAllowBashIfSandboxed===void 0?{}:{autoAllowBashIfSandboxed:e.autoAllowBashIfSandboxed},...e.allowUnsandboxedCommands===void 0?{}:{allowUnsandboxedCommands:e.allowUnsandboxedCommands},...n===void 0?{}:{network:n}};return t(i)?i:void 0},a=e=>{if(e!==void 0){if(e.mode===`none`)return``;if(!(e.append===void 0||e.append===``))return{type:`preset`,preset:`claude_code`,append:e.append}}};if(!Object.values(e).some(e=>t(e)))return;let o=a(e.systemPrompt),s=i(e.sandbox),c=e.env!==void 0&&t(e.env)?e.env:void 0,l={...e.model!==void 0&&e.model!==``?{model:e.model}:{},...e.disallowedTools!==void 0&&e.disallowedTools.length>0?{disallowedTools:e.disallowedTools}:{},...o===void 0?{}:{systemPrompt:o},...c===void 0?{}:{env:c},...s===void 0?{}:{sandbox:s},...e.settingSources===void 0?{}:{settingSources:e.settingSources},...e.maxTurns===void 0?{}:{maxTurns:e.maxTurns},...e.maxThinkingTokens===void 0?{}:{maxThinkingTokens:e.maxThinkingTokens},...e.maxBudgetUsd===void 0?{}:{maxBudgetUsd:e.maxBudgetUsd},...e.effort===void 0?{}:{effort:e.effort},...e.permissionMode===void 0?{}:{permissionMode:e.permissionMode}};return t(l)?l:void 0},tf=e=>{if(!e)return{systemPrompt:{mode:`preset`},settingSources:[...Qd]};let t={settingSources:[...Qd]};if(e.model!==void 0&&e.model!==``&&(t.model=e.model),e.disallowedTools!==void 0&&(t.disallowedTools=e.disallowedTools),e.systemPrompt===void 0?t.systemPrompt={mode:`preset`}:typeof e.systemPrompt==`string`?t.systemPrompt={mode:`none`}:t.systemPrompt={mode:`preset`,append:e.systemPrompt.append},e.env!==void 0&&(t.env=e.env),e.sandbox!==void 0){let n={};if(e.sandbox.enabled!==void 0&&(n.enabled=e.sandbox.enabled),e.sandbox.autoAllowBashIfSandboxed!==void 0&&(n.autoAllowBashIfSandboxed=e.sandbox.autoAllowBashIfSandboxed),e.sandbox.allowUnsandboxedCommands!==void 0&&(n.allowUnsandboxedCommands=e.sandbox.allowUnsandboxedCommands),e.sandbox.network!==void 0){let t={};e.sandbox.network.allowedDomains!==void 0&&e.sandbox.network.allowedDomains.length>0&&(t.allowedDomains=e.sandbox.network.allowedDomains.join(`, `)),e.sandbox.network.allowLocalBinding!==void 0&&(t.allowLocalBinding=e.sandbox.network.allowLocalBinding),n.network=t}t.sandbox=n}return e.settingSources!==void 0&&(t.settingSources=e.settingSources),e.maxTurns!==void 0&&(t.maxTurns=e.maxTurns),e.maxThinkingTokens!==void 0&&(t.maxThinkingTokens=e.maxThinkingTokens),e.maxBudgetUsd!==void 0&&(t.maxBudgetUsd=e.maxBudgetUsd),e.effort!==void 0&&(t.effort=e.effort),e.permissionMode!==void 0&&(t.permissionMode=e.permissionMode),t},nf=e=>e.split(`/`).at(-1)??e,rf=e=>{switch(e[0]?.toLowerCase()??``){case`commit`:return`コミットしようとしています`;case`push`:return`プッシュしようとしています`;case`pull`:return`プルしようとしています`;case`clone`:return`リポジトリをクローンしようとしています`;case`checkout`:case`switch`:return`ブランチを切り替えようとしています`;case`branch`:return`ブランチを操作しようとしています`;case`merge`:return`マージしようとしています`;case`rebase`:return`リベースしようとしています`;case`add`:return`変更をステージしようとしています`;case`status`:return`git の状態を確認しようとしています`;case`log`:return`git ログを確認しようとしています`;case`diff`:return`差分を確認しようとしています`;case`reset`:return`変更をリセットしようとしています`;case`stash`:return`変更を一時保存しようとしています`;case`fetch`:return`リモートの情報を取得しようとしています`;default:return`git を操作しようとしています`}},af=e=>{switch(e[0]?.toLowerCase()??``){case`install`:case`add`:case`i`:return`パッケージをインストールしようとしています`;case`uninstall`:case`remove`:case`rm`:return`パッケージを削除しようとしています`;case`update`:case`upgrade`:return`パッケージを更新しようとしています`;case`run`:return e[1]===void 0?`スクリプトを実行しようとしています`:`${e[1]} スクリプトを実行しようとしています`;case`build`:return`ビルドしようとしています`;case`test`:return`テストを実行しようとしています`;case`lint`:return`Lint を実行しようとしています`;default:return`パッケージを管理しようとしています`}},of=e=>{let t=(e.split(/\s*(?:&&|\|\||;)\s*/)[0]?.trim()??e).trim().split(/\s+/),n=0;for(;n<t.length;){let e=t[n]??``;if(e===`sudo`||e===`env`||e.includes(`=`))n++;else break}let r=t[n]?.toLowerCase()??``,i=t.slice(n+1).filter(e=>!e.startsWith(`-`)),a=i[0];switch(r){case`rm`:case`rmdir`:return a===void 0?`ファイルを削除しようとしています`:`${a} を削除しようとしています`;case`ls`:return a===void 0?`フォルダを確認しようとしています`:`${a} フォルダを確認しようとしています`;case`mkdir`:return a===void 0?`フォルダを作成しようとしています`:`${a} フォルダを作成しようとしています`;case`cp`:return`ファイルをコピーしようとしています`;case`mv`:return`ファイルを移動しようとしています`;case`cat`:return a===void 0?`ファイルを確認しようとしています`:`${a} を確認しようとしています`;case`touch`:return a===void 0?`ファイルを作成しようとしています`:`${a} を作成しようとしています`;case`find`:return`ファイルを検索しようとしています`;case`grep`:case`rg`:return`ファイル内を検索しようとしています`;case`git`:return rf(i);case`npm`:case`pnpm`:case`yarn`:case`bun`:return af(i);case`curl`:case`wget`:return`ファイルをダウンロードしようとしています`;case`chmod`:case`chown`:return`ファイルの権限を変更しようとしています`;case`kill`:case`killall`:case`pkill`:return`プロセスを終了しようとしています`;case`ps`:return`プロセスを確認しようとしています`;case`docker`:return`Docker を操作しようとしています`;case`ssh`:return`リモートサーバーに接続しようとしています`;case`make`:return`ビルドしようとしています`;case`python`:case`python3`:return`Python スクリプトを実行しようとしています`;case`node`:case`npx`:case`tsx`:case`ts-node`:return`スクリプトを実行しようとしています`;case`echo`:return`テキストを出力しようとしています`;case`cd`:return a===void 0?`ディレクトリを移動しようとしています`:`${a} に移動しようとしています`;case`tar`:case`zip`:case`unzip`:case`gzip`:return`アーカイブを操作しようとしています`;case`open`:return a===void 0?`ファイルを開こうとしています`:`${a} を開こうとしています`;default:return`コマンドを実行しようとしています`}},sf=(e,t)=>{switch(e.toLowerCase()){case`read`:return typeof t.file_path==`string`?`${nf(t.file_path)} を読もうとしています`:`ファイルを読もうとしています`;case`write`:return typeof t.file_path==`string`?`${nf(t.file_path)} を書き込もうとしています`:`ファイルを書き込もうとしています`;case`edit`:case`multiedit`:return typeof t.file_path==`string`?`${nf(t.file_path)} を編集しようとしています`:`ファイルを編集しようとしています`;case`bash`:return typeof t.command==`string`?of(t.command):`コマンドを実行しようとしています`;case`glob`:return typeof t.pattern==`string`?`${t.pattern} に一致するファイルを検索しようとしています`:`ファイルを検索しようとしています`;case`grep`:return typeof t.pattern==`string`?`「${t.pattern}」をファイル内で検索しようとしています`:`ファイル内を検索しようとしています`;case`ls`:return typeof t.path==`string`?`${t.path} フォルダを確認しようとしています`:`フォルダを確認しようとしています`;case`webfetch`:return`Web ページを取得しようとしています`;case`websearch`:return typeof t.query==`string`?`「${t.query}」を検索しようとしています`:`Web を検索しようとしています`;case`notebookread`:return typeof t.notebook_path==`string`?`${nf(t.notebook_path)} を読もうとしています`:`ノートブックを読もうとしています`;case`notebookedit`:return typeof t.notebook_path==`string`?`${nf(t.notebook_path)} を編集しようとしています`:`ノートブックを編集しようとしています`;case`todowrite`:return`タスクリストを更新しようとしています`;case`agent`:return typeof t.description==`string`?`サブエージェント(${t.description})を起動しようとしています`:`サブエージェントを起動しようとしています`;default:if(e.toLowerCase().startsWith(`mcp__`)){let t=e.split(`__`);return`${t[1]??``} の ${t.slice(2).join(`__`)} を実行しようとしています`}return`${e} を実行しようとしています`}},cf=e=>typeof e==`string`?e:e==null?String(e):JSON.stringify(e,null,2),lf=({permissionRequest:e})=>{let t=Ql(e.toolName);if(t!==void 0)return(0,Y.jsx)(`div`,{className:`rounded-lg border border-border/60 overflow-hidden max-h-64 overflow-y-auto`,children:(0,Y.jsx)(t,{toolUseId:``,input:e.toolInput,output:void 0,toolUseResult:void 0})});let n=Object.entries(e.toolInput);return n.length===0?null:(0,Y.jsx)(`div`,{className:`rounded-lg border border-border/60 overflow-hidden max-h-48 overflow-y-auto`,children:(0,Y.jsx)(`div`,{className:`px-3.5 py-2.5 space-y-2`,children:n.map(([e,t])=>(0,Y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-semibold text-muted-foreground uppercase tracking-wider`,children:e}),(0,Y.jsx)(`pre`,{className:`text-xs font-mono whitespace-pre-wrap break-words leading-relaxed text-foreground/80 bg-muted/60 rounded-md border border-border/40 px-2.5 py-1.5 max-h-32 overflow-y-auto`,children:cf(t)})]},e))})})},uf=({permissionRequest:e,onResponse:t})=>{let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(null),{config:o}=he(),s=Ce({...x(e?.toolName??``,e?.toolInput??{},e?.projectId??``),enabled:e!==null});if(!e)return null;let c=s.data!==void 0&&`rule`in s.data?s.data.rule??``:``,l=i??c,u=i!==null,d=async n=>{r(!0);try{await t({permissionRequestId:e.id,decision:n})}finally{r(!1)}},f=async n=>{r(!0);try{await t({permissionRequestId:e.id,decision:`always_allow`,alwaysAllowRule:l,alwaysAllowScope:n})}finally{r(!1)}};return(0,Y.jsx)(`div`,{className:`mx-4 sm:mx-6 md:mx-8 lg:mx-12 xl:mx-16 mb-3 animate-in fade-in slide-in-from-bottom-2 duration-300`,children:(0,Y.jsxs)(`div`,{className:`rounded-xl border border-orange-500/25 bg-card shadow-sm overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-border/60 bg-orange-500/[0.04]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Y.jsx)(`div`,{className:`flex items-center justify-center size-6 rounded-md bg-orange-500/10 text-orange-600 dark:text-orange-400`,children:(0,Y.jsx)(vr,{className:`size-3.5`})}),(0,Y.jsx)(`span`,{className:`text-sm font-semibold`,children:`Permission Request`})]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:me(e.timestamp,{locale:o.locale,target:`time`})})]}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5 ml-[2.125rem]`,children:sf(e.toolName,e.toolInput)})]}),(0,Y.jsxs)(`div`,{className:`p-4 space-y-3`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Y.jsx)(U,{variant:`secondary`,className:`font-mono text-xs tracking-tight`,children:e.toolName})}),(0,Y.jsx)(lf,{permissionRequest:e}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:`Always Allow Rule:`}),s.isLoading?(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Y.jsx)(M,{className:`size-3 animate-spin`}),`Generating...`]}):(0,Y.jsx)(Pt,{value:l,onChange:e=>a(e.target.value),className:`font-mono text-xs h-7 flex-1`,placeholder:`Permission rule...`}),u&&(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>a(null),className:`h-7 w-7 p-0 text-muted-foreground hover:text-foreground shrink-0`,title:`Reset to generated rule`,children:(0,Y.jsx)(mr,{className:`size-3.5`})})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2.5 justify-end pt-1`,children:[(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,onClick:()=>void d(`deny`),disabled:n,className:`min-w-[4.5rem] gap-1.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10`,children:[(0,Y.jsx)(Se,{className:`size-3.5`}),`Deny`]}),(0,Y.jsxs)(W,{size:`sm`,onClick:()=>void d(`allow`),disabled:n||u,className:`min-w-[4.5rem] gap-1.5`,children:[(0,Y.jsx)(ut,{className:`size-3.5`}),`Allow`]}),(0,Y.jsxs)(W,{variant:`outline`,size:`sm`,onClick:()=>void f(`session`),disabled:n||s.isLoading||l===``,className:`min-w-[5.5rem] gap-1.5`,children:[(0,Y.jsx)(ut,{className:`size-3.5`}),`Session`]}),(0,Y.jsxs)(W,{variant:`outline`,size:`sm`,onClick:()=>void f(`project`),disabled:n||s.isLoading||l===``,className:`min-w-[5.5rem] gap-1.5`,children:[(0,Y.jsx)(ut,{className:`size-3.5`}),`Project`]})]})]})]})})},df=`__other__`,ff=({current:e,total:t})=>(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5`,children:Array.from({length:t},(t,n)=>(0,Y.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Step ${String(n+1)}`,className:G(`size-2 rounded-full transition-all duration-300`,n===e?`bg-primary scale-125`:n<e?`bg-primary/40`:`bg-muted-foreground/25`)},`step-${String(n)}`))}),pf=({questionRequest:e,onResponse:t})=>{let[n,r]=(0,J.useState)(0),[i,a]=(0,J.useState)({}),[o,s]=(0,J.useState)({}),[c,l]=(0,J.useState)({}),[u,d]=(0,J.useState)({}),[f,p]=(0,J.useState)(!1),m=(0,J.useRef)(null);if(!e)return null;let h=e.questions,g=h.length,_=h[n];if(!_)return null;let v=_.question,y=c[v]??new Set,b=u[v]??``,x=(e,t)=>{let n=e.question,r=new Set;t===df?(r.add(df),requestAnimationFrame(()=>m.current?.focus())):r.add(t),l(e=>({...e,[n]:r}));let i=e.options.find(e=>e.label===t);i?.preview!==void 0&&i.preview!==``?s(e=>({...e,[n]:{...e[n],preview:i.preview}})):s(e=>{let t=e[n];if(!t)return e;let{preview:r,...i}=t;return{...e,[n]:i}})},S=(e,t)=>{let n=e.question,r=new Set(c[n]??new Set);t===df?r.has(df)?r.delete(df):(r.add(df),requestAnimationFrame(()=>m.current?.focus())):r.has(t)?r.delete(t):r.add(t),l(e=>({...e,[n]:r}))},C=(e,t)=>{let n=e.question;d(e=>({...e,[n]:t}))},w=e=>{let t=e.question,n=c[t]??new Set,r=u[t]??``,i=[];for(let e of n)e===df?r.trim()&&i.push(r.trim()):i.push(e);return i.join(`, `)},T=()=>{let e=c[v]??new Set;return!(e.size===0||e.has(df)&&!(u[v]??``).trim())},E=()=>{if(n>0){let e=w(_);a(t=>({...t,[v]:e})),r(e=>e-1)}},D=()=>{let e=w(_);a(t=>({...t,[v]:e})),n<g-1&&r(e=>e+1)},O=async()=>{p(!0);let n={...i};n[v]=w(_);let c={questionRequestId:e.id,answers:n,annotations:o};try{await t(c)}finally{p(!1),r(0),a({}),s({}),l({}),d({})}},k=n===g-1,A=T(),j=n===0,M=e=>y.has(e),ee=_.options.find(e=>y.has(e.label)&&e.preview!==void 0&&e.preview!==``)?.preview,N=M(df);return(0,Y.jsx)(`div`,{className:`mx-4 sm:mx-6 md:mx-8 lg:mx-12 xl:mx-16 mb-3 animate-in fade-in slide-in-from-bottom-2 duration-300`,children:(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border bg-card shadow-sm overflow-hidden`,children:[(0,Y.jsx)(`div`,{className:`px-4 py-2.5 border-b border-border/60 bg-muted/30`,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Y.jsx)(`div`,{className:`flex items-center justify-center size-6 rounded-md bg-primary/10 text-primary`,children:(0,Y.jsx)(tr,{className:`size-3.5`})}),(0,Y.jsx)(U,{variant:`outline`,className:`text-[11px] font-medium tracking-wide uppercase`,children:_.header})]}),g>1&&(0,Y.jsx)(ff,{current:n,total:g})]})}),(0,Y.jsxs)(`div`,{className:`p-4 space-y-3.5`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium leading-relaxed`,children:_.question}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[_.options.map(e=>{let t=M(e.label);return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>_.multiSelect?S(_,e.label):x(_,e.label),className:G(`w-full text-left rounded-lg border px-3.5 py-2.5 transition-all duration-200`,`hover:shadow-sm`,t?`border-primary/60 bg-primary/[0.04] shadow-sm ring-1 ring-primary/20`:`border-border/60 hover:border-border hover:bg-muted/40`),children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_.multiSelect?(0,Y.jsx)(vt,{checked:t,className:`mt-0.5`,tabIndex:-1}):(0,Y.jsx)(`div`,{className:G(`mt-0.5 size-4 shrink-0 rounded-full border-2 transition-all duration-200 flex items-center justify-center`,t?`border-primary bg-primary`:`border-muted-foreground/30`),children:t&&(0,Y.jsx)(`div`,{className:`size-1.5 rounded-full bg-primary-foreground`})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(K,{className:`text-sm font-medium cursor-pointer leading-tight`,children:e.label}),e.description&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 leading-relaxed`,children:e.description})]})]})},e.label)}),(0,Y.jsxs)(`div`,{className:G(`rounded-lg border transition-all duration-200`,N?`border-primary/60 bg-primary/[0.04] shadow-sm ring-1 ring-primary/20`:`border-border/60 hover:border-border hover:bg-muted/40`),children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>_.multiSelect?S(_,df):x(_,df),className:`w-full text-left px-3.5 py-2.5`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_.multiSelect?(0,Y.jsx)(vt,{checked:N,className:`mt-0.5`,tabIndex:-1}):(0,Y.jsx)(`div`,{className:G(`mt-0.5 size-4 shrink-0 rounded-full border-2 transition-all duration-200 flex items-center justify-center`,N?`border-primary bg-primary`:`border-muted-foreground/30`),children:N&&(0,Y.jsx)(`div`,{className:`size-1.5 rounded-full bg-primary-foreground`})}),(0,Y.jsx)(K,{className:`text-sm font-medium cursor-pointer leading-tight`,children:`Other`})]})}),(0,Y.jsx)(`div`,{className:G(`grid transition-all duration-250 ease-out`,N?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`),children:(0,Y.jsx)(`div`,{className:`overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`px-3.5 pb-3 pt-1`,children:(0,Y.jsx)(al,{ref:m,placeholder:`Type your response here...`,value:b,onChange:e=>C(_,e.target.value),className:`min-h-[68px] text-sm resize-none`,rows:2})})})})]})]}),ee!==void 0&&ee!==``&&(0,Y.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-muted/30 overflow-hidden animate-in fade-in duration-200`,children:[(0,Y.jsx)(`div`,{className:`px-3 py-1.5 border-b border-border/40 bg-muted/40`,children:(0,Y.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Preview`})}),(0,Y.jsx)(`div`,{className:`p-3`,children:(0,Y.jsx)(`pre`,{className:`text-xs font-mono whitespace-pre-wrap break-words max-h-32 overflow-y-auto leading-relaxed text-foreground/80`,children:ee})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,children:[(0,Y.jsx)(`div`,{children:g>1&&!j&&(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,onClick:E,className:`gap-1 text-muted-foreground hover:text-foreground`,children:[(0,Y.jsx)(wn,{className:`size-3.5`}),`Back`]})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!A&&N&&!b.trim()&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,Y.jsx)(zt,{className:`size-3`}),`Enter a response`]}),k?(0,Y.jsxs)(W,{size:`sm`,onClick:()=>void O(),disabled:!A||f,className:`gap-1.5 min-w-[5.5rem]`,children:[(0,Y.jsx)(gr,{className:`size-3.5`}),`Submit`]}):(0,Y.jsxs)(W,{size:`sm`,onClick:D,disabled:!A,className:`gap-1 min-w-[5rem]`,children:[`Next`,(0,Y.jsx)(dt,{className:`size-3.5`})]})]})]})]})]})})},mf=({permissionRequest:e,questionRequest:t,onPermissionResponse:n,onQuestionResponse:r})=>t?(0,Y.jsx)(pf,{questionRequest:t,onResponse:r}):e?(0,Y.jsx)(uf,{permissionRequest:e,onResponse:n}):null,hf=e=>{let t=o(),{data:n}=Ce({...N,enabled:e!==void 0});return{currentPermissionRequest:(n?.permissionRequests??[]).find(t=>t.sessionId===e)??null,onPermissionResponse:(0,J.useCallback)(async n=>{try{if(!(await c.api[`claude-code`][`permission-response`].$post({json:n})).ok)throw Error(`Failed to send permission response`);e!==void 0&&e!==``&&await c.api.notifications[`:sessionId`].consume.$post({param:{sessionId:e},json:{types:[`permission_requested`]}}),await t.invalidateQueries({queryKey:N.queryKey})}catch(e){console.error(`Error sending permission response:`,e),R.error(`Failed to send permission response`)}},[e,t])}},gf=e=>{let t=o(),{data:n}=Ce({...ne,enabled:e!==void 0});return{currentQuestionRequest:(n?.questionRequests??[]).find(t=>t.sessionId===e)??null,onQuestionResponse:(0,J.useCallback)(async n=>{try{if(!(await c.api[`claude-code`][`question-response`].$post({json:n})).ok)throw Error(`Failed to send question response`);e!==void 0&&e!==``&&await c.api.notifications[`:sessionId`].consume.$post({param:{sessionId:e},json:{types:[`question_asked`]}}),await t.invalidateQueries({queryKey:ne.queryKey})}catch(e){console.error(`Error sending question response:`,e),R.error(`Failed to send question response`)}},[e,t])}},_f={all:[`scheduler`],jobs:()=>[..._f.all,`jobs`],job:e=>[..._f.all,`job`,e]},vf=()=>Ce({queryKey:_f.jobs(),queryFn:async()=>{let e=await c.api.scheduler.jobs.$get();if(!e.ok)throw Error(`Failed to fetch scheduler jobs`);return e.json()}}),yf=()=>{let e=o();return l({mutationFn:async e=>{let t=await c.api.scheduler.jobs.$post({json:e});if(!t.ok)throw Error(`Failed to create scheduler job`);return t.json()},onSuccess:()=>{e.invalidateQueries({queryKey:_f.jobs()})}})},bf=()=>{let e=o();return l({mutationFn:async({id:e,updates:t})=>{let n=await c.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:_f.job(t.id)}),e.invalidateQueries({queryKey:_f.jobs()})}})},xf=()=>{let e=o();return l({mutationFn:async e=>{let t=await c.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:_f.job(n)}),e.invalidateQueries({queryKey:_f.jobs()})}})},Sf=qc(`claude-code-viewer-notification-settings`,{soundType:`none`}),Cf=h(e=>e(Sf).soundType!==`none`),wf={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}},Tf=e=>{if(e!==`none`)try{let t=wf[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)}},Ef=e=>({none:(0,Y.jsx)(z,{id:`notification.none`}),beep:(0,Y.jsx)(z,{id:`notification.beep`}),chime:(0,Y.jsx)(z,{id:`notification.chime`}),ping:(0,Y.jsx)(z,{id:`notification.ping`}),pop:(0,Y.jsx)(z,{id:`notification.pop`})})[e],Df=()=>[`none`,`beep`,`chime`,`ping`,`pop`],Of=(e,t)=>{let n=a(Sf),r=a(Cf),i=a(Vt),o=T(Vt),s=(0,J.useRef)(e),c=(0,J.useRef)(t);c.current!==t&&(c.current=t,s.current=e),(0,J.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}R.success(`Task completed`),r&&Tf(n.soundType)}},[e,r,n.soundType,i,t,o])},kf=e=>e.replace(/<local-command-caveat>[\s\S]*?<\/local-command-caveat>/g,``).trim(),Af=(e,t,n)=>e??(t?jf(t):n),jf=e=>{switch(e.kind){case`command`:return e.commandArgs===void 0?e.commandName:`${e.commandName} ${e.commandArgs}`;case`local-command`:return kf(e.stdout);case`text`:return kf(e.content);default:throw Error(`Invalid first command`)}},Mf=()=>l({mutationFn:async e=>{let t=await c.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)}}),Nf=()=>{let e=a(Ft);return{sessionProcesses:e,getSessionProcess:(0,J.useCallback)(t=>e.find(e=>e.sessionId===t),[e])}},Pf=`__none__`,Ff=({projectId:e,isPending:t=!1,onScrollToTop:n,onScrollToBottom:r,sessionProcess:i,abortTask:a,isNewChat:o=!1,enableCCOptions:s=!1,ccOptions:c,onCCOptionsChange:l})=>{let{i18n:u}=B(),d=(0,J.useId)(),f=y({from:`/projects/$projectId/session`}),{isFlagEnabled:p}=_t(),m=p(`tool-approval`),{data:h}=Ce({...k(e),staleTime:1e3*60*5}),g=(0,J.useMemo)(()=>{let e=h?.globalAgents??[],t=h?.projectAgents??[];return[...e,...t]},[h?.globalAgents,h?.projectAgents]),_=()=>{f({to:`/projects/$projectId/session`,params:{projectId:e},search:{sessionId:void 0}})};return(0,Y.jsx)(`div`,{className:`px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 mb-1`,children:(0,Y.jsxs)(`div`,{className:`py-0 flex items-center gap-1.5 flex-wrap`,children:[(0,Y.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,disabled:t||o,className:`h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40`,"data-testid":`start-new-chat-button`,onClick:_,title:u._({id:`control.new_chat`,message:`New Chat`}),children:[(0,Y.jsx)(St,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:(0,Y.jsx)(z,{id:`control.new`})})]}),n&&(0,Y.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:n,disabled:t,className:`h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40`,title:u._({id:`control.scroll_to_top`,message:`Scroll to Top`}),children:(0,Y.jsx)(yn,{className:`w-3.5 h-3.5`})}),r&&(0,Y.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,disabled:t,className:`h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40`,title:u._({id:`control.scroll_to_bottom`,message:`Scroll to Bottom`}),children:(0,Y.jsx)(_n,{className:`w-3.5 h-3.5`})}),i&&a&&(0,Y.jsxs)(W,{type:`button`,variant:`destructive`,size:`sm`,onClick:()=>{a.mutate(i.id)},disabled:a.isPending||t,className:`h-7 px-2 gap-1.5 text-xs rounded-lg`,children:[a.isPending?(0,Y.jsx)(Zn,{className:`w-3.5 h-3.5 animate-spin`}):(0,Y.jsx)(Se,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(`span`,{children:(0,Y.jsx)(z,{id:`session.conversation.abort`})})]}),s&&l&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(`span`,{children:(0,Y.jsxs)(gc,{value:c?.permissionMode??`default`,onValueChange:e=>l({...c,permissionMode:e}),disabled:t||!m,children:[(0,Y.jsx)(vc,{className:`h-7 w-auto min-w-[80px] text-[11px] font-medium bg-background/50 border-border/30 shadow-none hover:bg-background hover:border-border/50 transition-all duration-200 gap-1 px-2`,children:(0,Y.jsx)(_c,{})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`default`,children:(0,Y.jsx)(z,{id:`chat.toolbar.permission_mode.default`,message:`Default`})}),(0,Y.jsx)(X,{value:`acceptEdits`,children:(0,Y.jsx)(z,{id:`chat.toolbar.permission_mode.accept_edits`,message:`Accept Edits`})}),(0,Y.jsx)(X,{value:`bypassPermissions`,children:(0,Y.jsx)(z,{id:`chat.toolbar.permission_mode.bypass`,message:`Bypass`})}),(0,Y.jsx)(X,{value:`plan`,children:(0,Y.jsx)(z,{id:`chat.toolbar.permission_mode.plan`,message:`Plan`})})]})]})})}),(0,Y.jsx)(gt,{children:(0,Y.jsx)(z,{id:`chat.toolbar.permission_mode.tooltip`,message:`Select permission mode`})})]}),(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsxs)(`label`,{htmlFor:d,className:`flex items-center gap-1.5 cursor-pointer h-7 px-2 rounded-lg text-[11px] font-medium text-muted-foreground hover:bg-background/80 hover:text-foreground transition-all duration-200`,children:[(0,Y.jsx)(vt,{id:d,checked:c?.systemPrompt!==void 0&&c?.systemPrompt!==``,onCheckedChange:e=>{l({...c,systemPrompt:e===!0?{type:`preset`,preset:`claude_code`}:``})},disabled:t,className:`h-3.5 w-3.5`}),(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:`Claude Code`})]})}),(0,Y.jsx)(gt,{children:(0,Y.jsx)(z,{id:`chat.toolbar.system_prompt.tooltip`,message:`Include default Claude Code prompt`})})]}),g.length>0&&(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(`span`,{children:(0,Y.jsxs)(gc,{value:c?.agent??Pf,onValueChange:e=>l({...c,agent:e===Pf?void 0:e}),disabled:t,children:[(0,Y.jsx)(vc,{className:`h-7 w-auto min-w-[80px] text-[11px] font-medium bg-background/50 border-border/30 shadow-none hover:bg-background hover:border-border/50 transition-all duration-200 gap-1 px-2`,children:(0,Y.jsx)(_c,{placeholder:u._({id:`chat.toolbar.agent.none`,message:`No Agent`})})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:Pf,children:(0,Y.jsx)(z,{id:`chat.toolbar.agent.none`,message:`No Agent`})}),g.map(e=>(0,Y.jsxs)(ba,{value:e.name,className:`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,children:[(0,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(Sa,{children:(0,Y.jsx)(ut,{className:`h-4 w-4`})})}),(0,Y.jsx)(xa,{children:e.name}),e.description!==null&&(0,Y.jsxs)(`span`,{className:`ml-1.5 text-muted-foreground truncate max-w-[200px]`,children:[`— `,e.description]})]},e.name))]})]})})}),(0,Y.jsx)(gt,{children:(0,Y.jsx)(z,{id:`chat.toolbar.agent.tooltip`,message:`Select agent`})})]})]})]})})},If=e=>`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\$/g,`\\$`).replace(/`/g,"\\`")}"`,Lf=({text:e,sessionId:t,ccOptions:n})=>{let r=[`claude`];return t!==void 0&&t!==``&&r.push(`--resume`,If(t)),n!==void 0&&(n.model!==void 0&&n.model!==``&&r.push(`--model`,If(n.model)),n.permissionMode!==void 0&&n.permissionMode!==`default`&&r.push(`--permission-mode`,If(n.permissionMode)),n.maxTurns!==void 0&&r.push(`--max-turns`,String(n.maxTurns)),n.disallowedTools!==void 0&&n.disallowedTools.length>0&&r.push(`--disallowedTools`,If(n.disallowedTools.join(`,`))),typeof n.systemPrompt==`string`&&r.push(`--system-prompt`,If(n.systemPrompt)),n.agent!==void 0&&n.agent!==``&&r.push(`--agent`,If(n.agent))),r.push(If(e)),r.join(` `)},Rf=()=>{if(!(typeof window>`u`))return window.SpeechRecognition??window.webkitSpeechRecognition},zf=4,Bf=[0,0,0,0],Vf=({onTranscript:e,onInterimTranscript:t})=>{let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(Bf),o=(0,J.useRef)(null),s=(0,J.useRef)(null),c=(0,J.useRef)(null),l=(0,J.useRef)(null),u=(0,J.useRef)(null),d=(0,J.useRef)(e);d.current=e;let f=(0,J.useRef)(t);f.current=t;let p=Rf()!==void 0,m=(0,J.useCallback)(()=>{if(u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),s.current&&=(s.current.close().catch(()=>{}),null),c.current=null,l.current){for(let e of l.current.getTracks())e.stop();l.current=null}a(Bf)},[]),h=(0,J.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});l.current=e;let t=new AudioContext;s.current=t;let n=t.createMediaStreamSource(e),r=t.createAnalyser();r.fftSize=64,n.connect(r),c.current=r;let i=new Uint8Array(r.frequencyBinCount),o=()=>{let e=c.current;if(!e)return;e.getByteFrequencyData(i);let t=i.length,n=Math.floor(t/zf),r=[];for(let e=0;e<zf;e++){let a=e*n,o=Math.min(a+n,t),s=0;for(let e=a;e<o;e++)s+=i[e]??0;let c=o>a?s/(o-a):0;r.push(c/255)}a(r),u.current=requestAnimationFrame(o)};return u.current=requestAnimationFrame(o),!0}catch{return!1}},[]),g=(0,J.useCallback)(()=>{let e=o.current;e&&(o.current=null,e.stop()),m(),r(!1)},[m]),_=(0,J.useCallback)(()=>{let e=Rf();if(!e)return;let t=new e;t.continuous=!0,t.interimResults=!0,t.lang=navigator.language,t.onresult=e=>{let t=``,n=``;for(let r=e.resultIndex;r<e.results.length;r++){let i=e.results[r];if(!i)continue;let a=i[0];a&&(i.isFinal?t+=a.transcript:n+=a.transcript)}t&&d.current(t),n&&f.current?.(n)},t.onerror=()=>{g()},t.onend=()=>{o.current===t&&(o.current=null,m(),r(!1))},o.current=t,r(!0);try{t.start()}catch{g();return}h().then(()=>{o.current!==t&&m()})},[h,g,m]),v=(0,J.useCallback)(()=>{n?g():_()},[n,_,g]);return(0,J.useEffect)(()=>()=>{if(o.current&&=(o.current.stop(),null),u.current!==null&&cancelAnimationFrame(u.current),s.current&&s.current.close().catch(()=>{}),l.current)for(let e of l.current.getTracks())e.stop()},[]),{isSupported:p,isListening:n,audioLevels:i,toggle:v}},Hf=e=>e.type===`checkbox`,Uf=e=>e instanceof Date,Wf=e=>e==null,Gf=e=>typeof e==`object`,Kf=e=>!Wf(e)&&!Array.isArray(e)&&Gf(e)&&!Uf(e),qf=e=>Kf(e)&&e.target?Hf(e.target)?e.target.checked:e.target.value:e,Jf=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,Yf=(e,t)=>e.has(Jf(t)),Xf=e=>{let t=e.constructor&&e.constructor.prototype;return Kf(t)&&t.hasOwnProperty(`isPrototypeOf`)},Zf=typeof window<`u`&&window.HTMLElement!==void 0&&typeof document<`u`;function Qf(e){if(e instanceof Date)return new Date(e);let t=typeof FileList<`u`&&e instanceof FileList;if(Zf&&(e instanceof Blob||t))return e;let n=Array.isArray(e);if(!n&&!(Kf(e)&&Xf(e)))return e;let r=n?[]:Object.create(Object.getPrototypeOf(e));for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=Qf(e[t]));return r}var $f=e=>/^\w*$/.test(e),Z=e=>e===void 0,ep=e=>Array.isArray(e)?e.filter(Boolean):[],tp=e=>ep(e.replace(/["|']|\]/g,``).split(/\.|\[/)),Q=(e,t,n)=>{if(!t||!Kf(e))return n;let r=($f(t)?[t]:tp(t)).reduce((e,t)=>Wf(e)?e:e[t],e);return Z(r)||r===e?Z(e[t])?n:e[t]:r},np=e=>typeof e==`boolean`,rp=e=>typeof e==`function`,$=(e,t,n)=>{let r=-1,i=$f(t)?[t]:tp(t),a=i.length,o=a-1;for(;++r<a;){let t=i[r],a=n;if(r!==o){let n=e[t];a=Kf(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if(t===`__proto__`||t===`constructor`||t===`prototype`)return;e[t]=a,e=e[t]}},ip={BLUR:`blur`,FOCUS_OUT:`focusout`,CHANGE:`change`,SUBMIT:`submit`,TRIGGER:`trigger`,VALID:`valid`},ap={onBlur:`onBlur`,onChange:`onChange`,onSubmit:`onSubmit`,onTouched:`onTouched`,all:`all`},op={max:`max`,min:`min`,maxLength:`maxLength`,minLength:`minLength`,pattern:`pattern`,required:`required`,validate:`validate`},sp=`form`,cp=`root`,lp=J.createContext(null);lp.displayName=`HookFormControlContext`;var up=(e,t,n,r=!0)=>{let i={defaultValues:t._defaultValues};for(let a in e)Object.defineProperty(i,a,{get:()=>{let i=a;return t._proxyFormState[i]!==ap.all&&(t._proxyFormState[i]=!r||ap.all),n&&(n[i]=!0),e[i]}});return i},dp=typeof window<`u`?J.useLayoutEffect:J.useEffect,fp=e=>typeof e==`string`,pp=(e,t,n,r,i)=>fp(e)?(r&&t.watch.add(e),Q(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),Q(n,e))):(r&&(t.watchAll=!0),n),mp=e=>Wf(e)||!Gf(e);function hp(e,t,n=new WeakSet){if(mp(e)||mp(t))return Object.is(e,t);if(Uf(e)&&Uf(t))return Object.is(e.getTime(),t.getTime());let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(let a of r){let r=e[a];if(!i.includes(a))return!1;if(a!==`ref`){let e=t[a];if(Uf(r)&&Uf(e)||Kf(r)&&Kf(e)||Array.isArray(r)&&Array.isArray(e)?!hp(r,e,n):!Object.is(r,e))return!1}}return!0}var gp=J.createContext(null);gp.displayName=`HookFormContext`;var _p=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},vp=e=>Array.isArray(e)?e:[e],yp=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}};function bp(e,t){let n={};for(let r in e)if(e.hasOwnProperty(r)){let i=e[r],a=t[r];if(i&&Kf(i)&&a){let e=bp(i,a);Kf(e)&&(n[r]=e)}else e[r]&&(n[r]=a)}return n}var xp=e=>Kf(e)&&!Object.keys(e).length,Sp=e=>e.type===`file`,Cp=e=>{if(!Zf)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},wp=e=>e.type===`select-multiple`,Tp=e=>e.type===`radio`,Ep=e=>Tp(e)||Hf(e),Dp=e=>Cp(e)&&e.isConnected;function Op(e,t){let n=t.slice(0,-1).length,r=0;for(;r<n;)e=Z(e)?r++:e[t[r++]];return e}function kp(e){for(let t in e)if(e.hasOwnProperty(t)&&!Z(e[t]))return!1;return!0}function Ap(e,t){let n=Array.isArray(t)?t:$f(t)?[t]:tp(t),r=n.length===1?e:Op(e,n),i=n.length-1,a=n[i];return r&&delete r[a],i!==0&&(Kf(r)&&xp(r)||Array.isArray(r)&&kp(r))&&Ap(e,n.slice(0,-1)),e}var jp=e=>{for(let t in e)if(rp(e[t]))return!0;return!1};function Mp(e){return Array.isArray(e)||Kf(e)&&!jp(e)}function Np(e,t={}){for(let n in e){let r=e[n];Mp(r)?(t[n]=Array.isArray(r)?[]:{},Np(r,t[n])):Z(r)||(t[n]=!0)}return t}function Pp(e,t,n){n||=Np(t);for(let r in e){let i=e[r];if(Mp(i))Z(t)||mp(n[r])?n[r]=Np(i,Array.isArray(i)?[]:{}):Pp(i,Wf(t)?{}:t[r],n[r]);else{let e=t[r];n[r]=!hp(i,e)}}return n}var Fp={value:!1,isValid:!1},Ip={value:!0,isValid:!0},Lp=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Z(e[0].attributes.value)?Z(e[0].value)||e[0].value===``?Ip:{value:e[0].value,isValid:!0}:Ip:Fp}return Fp},Rp=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Z(e)?e:t?e===``?NaN:e&&+e:n&&fp(e)?new Date(e):r?r(e):e,zp={isValid:!1,value:null},Bp=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,zp):zp;function Vp(e){let t=e.ref;return Sp(t)?t.files:Tp(t)?Bp(e.refs).value:wp(t)?[...t.selectedOptions].map(({value:e})=>e):Hf(t)?Lp(e.refs).value:Rp(Z(t.value)?e.ref.value:t.value,e)}var Hp=(e,t,n,r)=>{let i={};for(let n of e){let e=Q(t,n);e&&$(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Up=e=>e instanceof RegExp,Wp=e=>Z(e)?e:Up(e)?e.source:Kf(e)?Up(e.value)?e.value.source:e.value:e,Gp=e=>({isOnSubmit:!e||e===ap.onSubmit,isOnBlur:e===ap.onBlur,isOnChange:e===ap.onChange,isOnAll:e===ap.all,isOnTouch:e===ap.onTouched}),Kp=`AsyncFunction`,qp=e=>!!e&&!!e.validate&&!!(rp(e.validate)&&e.validate.constructor.name===Kp||Kf(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===Kp)),Jp=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Yp=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))),Xp=(e,t,n,r)=>{for(let i of n||Object.keys(e)){let n=Q(e,i);if(n){let{_f:e,...a}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r||e.ref&&t(e.ref,e.name)&&!r)return!0;if(Xp(a,t))break}else if(Kf(a)&&Xp(a,t))break}}};function Zp(e,t,n){let r=Q(e,n);if(r||$f(n))return{error:r,name:n};let i=n.split(`.`);for(;i.length;){let r=i.join(`.`),a=Q(t,r),o=Q(e,r);if(a&&!Array.isArray(a)&&n!==r)return{name:n};if(o&&o.type)return{name:r,error:o};if(o&&o.root&&o.root.type)return{name:`${r}.root`,error:o.root};i.pop()}return{name:n}}var Qp=(e,t,n,r)=>{n(e);let{name:i,...a}=e;return xp(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(e=>t[e]===(!r||ap.all))},$p=(e,t,n)=>!e||!t||e===t||vp(e).some(e=>e&&(n?e===t:e.startsWith(t)||t.startsWith(e))),em=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,tm=(e,t)=>!ep(Q(e,t)).length&&Ap(e,t),nm=(e,t,n)=>{let r=vp(Q(e,n));return $(r,cp,t[n]),$(e,n,r),e};function rm(e,t,n=`validate`){if(fp(e)||Array.isArray(e)&&e.every(fp)||np(e)&&!e)return{type:n,message:fp(e)?e:``,ref:t}}var im=e=>Kf(e)&&!Up(e)?e:{value:e,message:``},am=async(e,t,n,r,i,a)=>{let{ref:o,refs:s,required:c,maxLength:l,minLength:u,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:_}=e._f,v=Q(n,h);if(!_||t.has(h))return{};let y=s?s[0]:o,b=e=>{i&&y.reportValidity&&(y.setCustomValidity(np(e)?``:e||``),y.reportValidity())},x={},S=Tp(o),C=Hf(o),w=S||C,T=(g||Sp(o))&&Z(o.value)&&Z(v)||Cp(o)&&o.value===``||v===``||Array.isArray(v)&&!v.length,E=_p.bind(null,h,r,x),D=(e,t,n,r=op.maxLength,i=op.minLength)=>{let a=e?t:n;x[h]={type:e?r:i,message:a,ref:o,...E(e?r:i,a)}};if(a?!Array.isArray(v)||!v.length:c&&(!w&&(T||Wf(v))||np(v)&&!v||C&&!Lp(s).isValid||S&&!Bp(s).isValid)){let{value:e,message:t}=fp(c)?{value:!!c,message:c}:im(c);if(e&&(x[h]={type:op.required,message:t,ref:y,...E(op.required,t)},!r))return b(t),x}if(!T&&(!Wf(d)||!Wf(f))){let e,t,n=im(f),i=im(d);if(!Wf(v)&&!isNaN(v)){let r=o.valueAsNumber||v&&+v;Wf(n.value)||(e=r>n.value),Wf(i.value)||(t=r<i.value)}else{let r=o.valueAsDate||new Date(v),a=e=>new Date(new Date().toDateString()+` `+e),s=o.type==`time`,c=o.type==`week`;fp(n.value)&&v&&(e=s?a(v)>a(n.value):c?v>n.value:r>new Date(n.value)),fp(i.value)&&v&&(t=s?a(v)<a(i.value):c?v<i.value:r<new Date(i.value))}if((e||t)&&(D(!!e,n.message,i.message,op.max,op.min),!r))return b(x[h].message),x}if((l||u)&&!T&&(fp(v)||a&&Array.isArray(v))){let e=im(l),t=im(u),n=!Wf(e.value)&&v.length>+e.value,i=!Wf(t.value)&&v.length<+t.value;if((n||i)&&(D(n,e.message,t.message),!r))return b(x[h].message),x}if(p&&!T&&fp(v)){let{value:e,message:t}=im(p);if(Up(e)&&!v.match(e)&&(x[h]={type:op.pattern,message:t,ref:o,...E(op.pattern,t)},!r))return b(t),x}if(m){if(rp(m)){let e=rm(await m(v,n),y);if(e&&(x[h]={...e,...E(op.validate,e.message)},!r))return b(e.message),x}else if(Kf(m)){let e={};for(let t in m){if(!xp(e)&&!r)break;let i=rm(await m[t](v,n),y,t);i&&(e={...i,...E(t,i.message)},b(i.message),r&&(x[h]=e))}if(!xp(e)&&(x[h]={ref:y,...e},!r))return x}}return b(!0),x},om={mode:ap.onSubmit,reValidateMode:ap.onChange,shouldFocusError:!0};function sm(e={}){let t={...om,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:rp(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=(Kf(t.defaultValues)||Kf(t.values))&&Qf(t.defaultValues||t.values)||{},a=t.shouldUnregister?{}:Qf(i),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,l=0,u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...u},f={...d},p={array:yp(),state:yp()},m=t.criteriaMode===ap.all,h=e=>t=>{clearTimeout(l),l=setTimeout(e,t)},g=async e=>{if(!o.keepIsValid&&!t.disabled&&(d.isValid||f.isValid||e)){let e;t.resolver?(e=xp((await w()).errors),_()):e=await D({fields:r,onlyCheckValid:!0,eventType:ip.VALID}),e!==n.isValid&&p.state.next({isValid:e})}},_=(e,r)=>{!t.disabled&&(d.isValidating||d.validatingFields||f.isValidating||f.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(r?$(n.validatingFields,e,r):Ap(n.validatingFields,e))}),p.state.next({validatingFields:n.validatingFields,isValidating:!xp(n.validatingFields)}))},v=(e,s=[],c,l,u=!0,m=!0)=>{if(l&&c&&!t.disabled){if(o.action=!0,m&&Array.isArray(Q(r,e))){let t=c(Q(r,e),l.argA,l.argB);u&&$(r,e,t)}if(m&&Array.isArray(Q(n.errors,e))){let t=c(Q(n.errors,e),l.argA,l.argB);u&&$(n.errors,e,t),tm(n.errors,e)}if((d.touchedFields||f.touchedFields)&&m&&Array.isArray(Q(n.touchedFields,e))){let t=c(Q(n.touchedFields,e),l.argA,l.argB);u&&$(n.touchedFields,e,t)}if(d.dirtyFields||f.dirtyFields){let t=Pp(i,a),r=Jf(e);$(n.dirtyFields,r,Q(t,r))}p.state.next({name:e,isDirty:k(e,s),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else $(a,e,s)},y=(e,t)=>{$(n.errors,e,t),p.state.next({errors:n.errors})},b=e=>{n.errors=e,p.state.next({errors:n.errors,isValid:!1})},x=(e,t,n,s)=>{let c=Q(r,e);if(c){let r=Q(a,e,Z(n)?Q(i,e):n);Z(r)||s&&s.defaultChecked||t?$(a,e,t?r:Vp(c._f)):M(e,r),o.mount&&!o.action&&g()}},S=(e,r,a,o,s)=>{let c=!1,l=!1,u={name:e};if(!t.disabled){if(!a||o){(d.isDirty||f.isDirty)&&(l=n.isDirty,n.isDirty=u.isDirty=k(),c=l!==u.isDirty);let t=hp(Q(i,e),r);l=!!Q(n.dirtyFields,e),t?Ap(n.dirtyFields,e):$(n.dirtyFields,e,!0),u.dirtyFields=n.dirtyFields,c||=(d.dirtyFields||f.dirtyFields)&&l!==!t}if(a){let t=Q(n.touchedFields,e);t||($(n.touchedFields,e,a),u.touchedFields=n.touchedFields,c||=(d.touchedFields||f.touchedFields)&&t!==a)}c&&s&&p.state.next(u)}return c?u:{}},C=(e,r,i,a)=>{let o=Q(n.errors,e),s=(d.isValid||f.isValid)&&np(r)&&n.isValid!==r;if(t.delayError&&i?(c=h(()=>y(e,i)),c(t.delayError)):(clearTimeout(l),c=null,i?$(n.errors,e,i):Ap(n.errors,e)),(i?!hp(o,i):o)||!xp(a)||s){let t={...a,...s&&np(r)?{isValid:r}:{},errors:n.errors,name:e};n={...n,...t},p.state.next(t)}},w=async e=>(_(e,!0),await t.resolver(a,t.context,Hp(e||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),T=async e=>{let{errors:t}=await w(e);if(_(e),e)for(let r of e){let e=Q(t,r);e?$(n.errors,r,e):Ap(n.errors,r)}else n.errors=t;return t},E=async({name:t,eventType:r})=>{if(e.validate){let i=await e.validate({formValues:a,formState:n,name:t,eventType:r});if(Kf(i))for(let e in i)i[e]&&oe(`${sp}.${e}`,{message:fp(i.message)?i.message:``,type:op.validate});else fp(i)||!i?oe(sp,{message:i||``,type:op.validate}):ae(sp);return i}return!0},D=async({fields:r,onlyCheckValid:i,name:o,eventType:c,context:l={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(l.runRootValidation=!0,!await E({name:o,eventType:c})&&(l.valid=!1,i)))return l.valid;for(let o in r){let u=r[o];if(u){let{_f:r,...f}=u;if(r){let o=s.array.has(r.name),c=u._f&&qp(u._f);c&&d.validatingFields&&_([r.name],!0);let f=await am(u,s.disabled,a,m,t.shouldUseNativeValidation&&!i,o);if(c&&d.validatingFields&&_([r.name]),f[r.name]&&(l.valid=!1,i)||(!i&&(Q(f,r.name)?o?nm(n.errors,f,r.name):$(n.errors,r.name,f[r.name]):Ap(n.errors,r.name)),e.shouldUseNativeValidation&&f[r.name]))break}!xp(f)&&await D({context:l,onlyCheckValid:i,fields:f,name:o,eventType:c})}}return l.valid},O=()=>{for(let e of s.unMount){let t=Q(r,e);t&&(t._f.refs?t._f.refs.every(e=>!Dp(e)):!Dp(t._f.ref))&&F(e)}s.unMount=new Set},k=(e,n)=>!t.disabled&&(e&&n&&$(a,e,n),!hp(P(),i)),A=(e,t,n)=>pp(e,s,{...o.mount?a:Z(t)?i:fp(e)?{[e]:t}:t},n,t),j=e=>ep(Q(o.mount?a:i,e,t.shouldUnregister?Q(i,e,[]):[])),M=(e,t,n={})=>{let i=Q(r,e),o=t;if(i){let n=i._f;n&&(!n.disabled&&$(a,e,Rp(t,n)),o=Cp(n.ref)&&Wf(t)?``:t,wp(n.ref)?[...n.ref.options].forEach(e=>e.selected=o.includes(e.value)):n.refs?Hf(n.ref)?n.refs.forEach(e=>{(!e.defaultChecked||!e.disabled)&&(Array.isArray(o)?e.checked=!!o.find(t=>t===e.value):e.checked=o===e.value||!!o)}):n.refs.forEach(e=>e.checked=e.value===o):Sp(n.ref)?n.ref.value=``:(n.ref.value=o,n.ref.type||p.state.next({name:e,values:Qf(a)})))}(n.shouldDirty||n.shouldTouch)&&S(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&re(e)},ee=(e,t,n)=>{for(let i in t){if(!t.hasOwnProperty(i))return;let a=t[i],o=e+`.`+i,c=Q(r,o);(s.array.has(e)||Kf(a)||c&&!c._f)&&!Uf(a)?ee(o,a,n):M(o,a,n)}},N=(e,t,c={})=>{let l=Q(r,e),u=s.array.has(e),m=Qf(t);$(a,e,m),u?(p.array.next({name:e,values:Qf(a)}),(d.isDirty||d.dirtyFields||f.isDirty||f.dirtyFields)&&c.shouldDirty&&p.state.next({name:e,dirtyFields:Pp(i,a),isDirty:k(e,m)})):l&&!l._f&&!Wf(m)?ee(e,m,c):M(e,m,c),Yp(e,s)?p.state.next({...n,name:e,values:Qf(a)}):p.state.next({name:o.mount?e:void 0,values:Qf(a)})},te=async i=>{o.mount=!0;let l=i.target,u=l.name,h=!0,v=Q(r,u),y=e=>{h=Number.isNaN(e)||Uf(e)&&isNaN(e.getTime())||hp(e,Q(a,u,e))},b=Gp(t.mode),x=Gp(t.reValidateMode);if(v){let o,T,O=l.type?Vp(v._f):qf(i),k=i.type===ip.BLUR||i.type===ip.FOCUS_OUT,A=!Jp(v._f)&&!e.validate&&!t.resolver&&!Q(n.errors,u)&&!v._f.deps||em(k,Q(n.touchedFields,u),n.isSubmitted,x,b),j=Yp(u,s,k);$(a,u,O),k?(!l||!l.readOnly)&&(v._f.onBlur&&v._f.onBlur(i),c&&c(0)):v._f.onChange&&v._f.onChange(i);let M=S(u,O,k),ee=!xp(M)||j;if(!k&&p.state.next({name:u,type:i.type,values:Qf(a)}),A)return(d.isValid||f.isValid)&&(t.mode===`onBlur`?k&&g():k||g()),ee&&p.state.next({name:u,...j?{}:M});if(!t.resolver&&e.validate&&await E({name:u,eventType:i.type}),!k&&j&&p.state.next({...n}),t.resolver){let{errors:e}=await w([u]);if(_([u]),y(O),h){let t=Zp(n.errors,r,u),i=Zp(e,r,t.name||u);o=i.error,u=i.name,T=xp(e)}}else _([u],!0),o=(await am(v,s.disabled,a,m,t.shouldUseNativeValidation))[u],_([u]),y(O),h&&(o?T=!1:(d.isValid||f.isValid)&&(T=await D({fields:r,onlyCheckValid:!0,name:u,eventType:i.type})));h&&(v._f.deps&&(!Array.isArray(v._f.deps)||v._f.deps.length>0)&&re(v._f.deps),C(u,T,o,M))}},ne=(e,t)=>{if(Q(n.errors,t)&&e.focus)return e.focus(),1},re=async(e,i={})=>{let a,o,c=vp(e);if(t.resolver){let t=await T(Z(e)?e:c);a=xp(t),o=e?!c.some(e=>Q(t,e)):a}else e?(o=(await Promise.all(c.map(async e=>{let t=Q(r,e);return await D({fields:t&&t._f?{[e]:t}:t,eventType:ip.TRIGGER})}))).every(Boolean),!(!o&&!n.isValid)&&g()):o=a=await D({fields:r,name:e,eventType:ip.TRIGGER});return p.state.next({...!fp(e)||(d.isValid||f.isValid)&&a!==n.isValid?{}:{name:e},...t.resolver||!e?{isValid:a}:{},errors:n.errors}),i.shouldFocus&&!o&&Xp(r,ne,e?c:s.mount),o},P=(e,t)=>{let r={...o.mount?a:i};return t&&(r=bp(t.dirtyFields?n.dirtyFields:n.touchedFields,r)),Z(e)?r:fp(e)?Q(r,e):e.map(e=>Q(r,e))},ie=(e,t)=>({invalid:!!Q((t||n).errors,e),isDirty:!!Q((t||n).dirtyFields,e),error:Q((t||n).errors,e),isValidating:!!Q(n.validatingFields,e),isTouched:!!Q((t||n).touchedFields,e)}),ae=e=>{let t=e?vp(e):void 0;t?.forEach(e=>Ap(n.errors,e)),t?t.forEach(e=>{p.state.next({name:e,errors:n.errors})}):p.state.next({errors:{}})},oe=(e,t,i)=>{let a=(Q(r,e,{_f:{}})._f||{}).ref,{ref:o,message:s,type:c,...l}=Q(n.errors,e)||{};$(n.errors,e,{...l,...t,ref:a}),p.state.next({name:e,errors:n.errors,isValid:!1}),i&&i.shouldFocus&&a&&a.focus&&a.focus()},se=(e,t)=>rp(e)?p.state.subscribe({next:n=>`values`in n&&e(A(void 0,t),n)}):A(e,t,!0),ce=e=>p.state.subscribe({next:t=>{$p(e.name,t.name,e.exact)&&Qp(t,e.formState||d,ve,e.reRenderRoot)&&e.callback({values:{...a},...n,...t,defaultValues:i})}}).unsubscribe,le=e=>(o.mount=!0,f={...f,...e.formState},ce({...e,formState:{...u,...e.formState}})),F=(e,o={})=>{for(let c of e?vp(e):s.mount)s.mount.delete(c),s.array.delete(c),o.keepValue||(Ap(r,c),Ap(a,c)),!o.keepError&&Ap(n.errors,c),!o.keepDirty&&Ap(n.dirtyFields,c),!o.keepTouched&&Ap(n.touchedFields,c),!o.keepIsValidating&&Ap(n.validatingFields,c),!t.shouldUnregister&&!o.keepDefaultValue&&Ap(i,c);p.state.next({values:Qf(a)}),p.state.next({...n,...o.keepDirty?{isDirty:k()}:{}}),!o.keepIsValid&&g()},ue=({disabled:e,name:t})=>{if(np(e)&&o.mount||e||s.disabled.has(t)){let n=s.disabled.has(t)!==!!e;e?s.disabled.add(t):s.disabled.delete(t),n&&o.mount&&!o.action&&g()}},de=(e,n={})=>{let a=Q(r,e),c=np(n.disabled)||np(t.disabled);return $(r,e,{...a||{},_f:{...a&&a._f?a._f:{ref:{name:e}},name:e,mount:!0,...n}}),s.mount.add(e),a?ue({disabled:np(n.disabled)?n.disabled:t.disabled,name:e}):x(e,!0,n.value),{...c?{disabled:n.disabled||t.disabled}:{},...t.progressive?{required:!!n.required,min:Wp(n.min),max:Wp(n.max),minLength:Wp(n.minLength),maxLength:Wp(n.maxLength),pattern:Wp(n.pattern)}:{},name:e,onChange:te,onBlur:te,ref:c=>{if(c){de(e,n),a=Q(r,e);let t=Z(c.value)&&c.querySelectorAll&&c.querySelectorAll(`input,select,textarea`)[0]||c,o=Ep(t),s=a._f.refs||[];if(o?s.find(e=>e===t):t===a._f.ref)return;$(r,e,{_f:{...a._f,...o?{refs:[...s.filter(Dp),t,...Array.isArray(Q(i,e))?[{}]:[]],ref:{type:t.type,name:e}}:{ref:t}}}),x(e,!1,void 0,t)}else a=Q(r,e,{}),a._f&&(a._f.mount=!1),(t.shouldUnregister||n.shouldUnregister)&&!(Yf(s.array,e)&&o.action)&&s.unMount.add(e)}}},fe=()=>t.shouldFocusError&&Xp(r,ne,s.mount),pe=e=>{np(e)&&(p.state.next({disabled:e}),Xp(r,(t,n)=>{let i=Q(r,n);i&&(t.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach(t=>{t.disabled=i._f.disabled||e}))},0,!1))},me=(e,i)=>async o=>{let c;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let l=Qf(a);if(p.state.next({isSubmitting:!0}),t.resolver){let{errors:e,values:t}=await w();_(),n.errors=e,l=Qf(t)}else await D({fields:r,eventType:ip.SUBMIT});if(s.disabled.size)for(let e of s.disabled)Ap(l,e);if(Ap(n.errors,cp),xp(n.errors)){p.state.next({errors:{}});try{await e(l,o)}catch(e){c=e}}else i&&await i({...n.errors},o),fe(),setTimeout(fe);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:xp(n.errors)&&!c,submitCount:n.submitCount+1,errors:n.errors}),c)throw c},I=(e,t={})=>{Q(r,e)&&(Z(t.defaultValue)?N(e,Qf(Q(i,e))):(N(e,t.defaultValue),$(i,e,Qf(t.defaultValue))),t.keepTouched||Ap(n.touchedFields,e),t.keepDirty||(Ap(n.dirtyFields,e),n.isDirty=t.defaultValue?k(e,Qf(Q(i,e))):k()),t.keepError||(Ap(n.errors,e),d.isValid&&g()),p.state.next({...n}))},he=(e,c={})=>{let l=e?Qf(e):i,u=Qf(l),f=xp(e),m=f?i:u;if(c.keepDefaultValues||(i=l),!c.keepValues){if(c.keepDirtyValues){let e=new Set([...s.mount,...Object.keys(Pp(i,a))]);for(let t of Array.from(e)){let e=Q(n.dirtyFields,t),r=Q(a,t),i=Q(m,t);e&&!Z(r)?$(m,t,r):!e&&!Z(i)&&N(t,i)}}else{if(Zf&&Z(e))for(let e of s.mount){let t=Q(r,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(Cp(e)){let t=e.closest(`form`);if(t){t.reset();break}}}}if(c.keepFieldsRef)for(let e of s.mount)N(e,Q(m,e));else r={}}a=t.shouldUnregister?c.keepDefaultValues?Qf(i):{}:Qf(m),p.array.next({values:{...m}}),p.state.next({values:{...m}})}s={mount:c.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:``},o.mount=!d.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!t.shouldUnregister&&!xp(m),o.watch=!!t.shouldUnregister,o.keepIsValid=!!c.keepIsValid,o.action=!1,c.keepErrors||(n.errors={}),p.state.next({submitCount:c.keepSubmitCount?n.submitCount:0,isDirty:f?!1:c.keepDirty?n.isDirty:!!(c.keepDefaultValues&&!hp(e,i)),isSubmitted:c.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:f?{}:c.keepDirtyValues?c.keepDefaultValues&&a?Pp(i,a):n.dirtyFields:c.keepDefaultValues&&e?Pp(i,e):c.keepDirty?n.dirtyFields:{},touchedFields:c.keepTouched?n.touchedFields:{},errors:c.keepErrors?n.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:i})},ge=(e,n)=>he(rp(e)?e(a):e,{...t.resetOptions,...n}),_e=(e,t={})=>{let n=Q(r,e),i=n&&n._f;if(i){let e=i.refs?i.refs[0]:i.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&rp(e.select)&&e.select()})}},ve=e=>{n={...n,...e}},ye={control:{register:de,unregister:F,getFieldState:ie,handleSubmit:me,setError:oe,_subscribe:ce,_runSchema:w,_updateIsValidating:_,_focusError:fe,_getWatch:A,_getDirty:k,_setValid:g,_setFieldArray:v,_setDisabledField:ue,_setErrors:b,_getFieldArray:j,_reset:he,_resetDefaultValues:()=>rp(t.defaultValues)&&t.defaultValues().then(e=>{ge(e,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:O,_disableForm:pe,_subjects:p,_proxyFormState:d,get _fields(){return r},get _formValues(){return a},get _state(){return o},set _state(e){o=e},get _defaultValues(){return i},get _names(){return s},set _names(e){s=e},get _formState(){return n},get _options(){return t},set _options(e){t={...t,...e}}},subscribe:le,trigger:re,register:de,handleSubmit:me,watch:se,setValue:N,getValues:P,reset:ge,resetField:I,clearErrors:ae,unregister:F,setError:oe,setFocus:_e,getFieldState:ie};return{...ye,formControl:ye}}function cm(e={}){let t=J.useRef(void 0),n=J.useRef(void 0),[r,i]=J.useState({isDirty:!1,isValidating:!1,isLoading:rp(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:rp(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!rp(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{let{formControl:n,...i}=sm(e);t.current={...i,formState:r}}let a=t.current.control;return a._options=e,dp(()=>{let e=a._subscribe({formState:a._proxyFormState,callback:()=>i({...a._formState}),reRenderRoot:!0});return i(e=>({...e,isReady:!0})),a._formState.isReady=!0,e},[a]),J.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),J.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),J.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),J.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),J.useEffect(()=>{if(a._proxyFormState.isDirty){let e=a._getDirty();e!==r.isDirty&&a._subjects.state.next({isDirty:e})}},[a,r.isDirty]),J.useEffect(()=>{e.values&&!hp(e.values,n.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),a._options.resetOptions?.keepIsValid||a._setValid(),n.current=e.values,i(e=>({...e}))):a._resetDefaultValues()},[a,e.values]),J.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=J.useMemo(()=>up(r,a),[a,r]),t.current}var lm=(e,t,n)=>{if(e&&`reportValidity`in e){let r=Q(n,t);e.setCustomValidity(r&&r.message||``),e.reportValidity()}},um=(e,t)=>{for(let n in t.fields){let r=t.fields[n];r&&r.ref&&`reportValidity`in r.ref?lm(r.ref,n,e):r&&r.refs&&r.refs.forEach(t=>lm(t,n,e))}},dm=(e,t)=>{t.shouldUseNativeValidation&&um(e,t);let n={};for(let r in e){let i=Q(t.fields,r),a=Object.assign(e[r]||{},{ref:i&&i.ref});if(fm(t.names||Object.keys(e),r)){let e=Object.assign({},Q(n,r));$(e,`root`,a),$(n,r,e)}else $(n,r,a)}return n},fm=(e,t)=>{let n=pm(t);return e.some(e=>pm(e).match(`^${n}\\.\\d+`))};function pm(e){return e.replace(/\]|\[/g,``)}function mm(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}function hm(e,t){for(var n={};e.length;){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o])if(`unionErrors`in r){var s=r.unionErrors[0].errors[0];n[o]={message:s.message,type:s.code}}else n[o]={message:a,type:i};if(`unionErrors`in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=_p(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()}return n}function gm(e,t){for(var n={};e.length;){var r=e[0],i=r.code,a=r.message,o=r.path.join(`.`);if(!n[o])if(r.code===`invalid_union`&&r.errors.length>0){var s=r.errors[0][0];n[o]={message:s.message,type:s.code}}else n[o]={message:a,type:i};if(r.code===`invalid_union`&&r.errors.forEach(function(t){return t.forEach(function(t){return e.push(t)})}),t){var c=n[o].types,l=c&&c[r.code];n[o]=_p(o,t,n,i,l?[].concat(l,r.message):r.message)}e.shift()}return n}function _m(e,t,n){if(n===void 0&&(n={}),function(e){return`_def`in e&&typeof e._def==`object`&&`typeName`in e._def}(e))return function(r,i,a){try{return Promise.resolve(mm(function(){return Promise.resolve(e[n.mode===`sync`?`parse`:`parseAsync`](r,t)).then(function(e){return a.shouldUseNativeValidation&&um({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return Array.isArray(e?.issues)}(e))return{values:{},errors:dm(hm(e.errors,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};if(function(e){return`_zod`in e&&typeof e._zod==`object`}(e))return function(r,i,a){try{return Promise.resolve(mm(function(){return Promise.resolve((n.mode===`sync`?fe:Ve)(e,r,t)).then(function(e){return a.shouldUseNativeValidation&&um({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return e instanceof de}(e))return{values:{},errors:dm(gm(e.issues,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};throw Error(`Invalid input: not a Zod schema`)}var vm=J.forwardRef(({className:e,checked:t,onCheckedChange:n,disabled:r,...i},a)=>(0,Y.jsxs)(`label`,{className:G(`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,Y.jsx)(`input`,{type:`checkbox`,className:`sr-only`,ref:a,checked:t,onChange:e=>{n?.(e.target.checked),i.onChange?.(e)},disabled:r,...i}),(0,Y.jsx)(`span`,{className:G(`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`)})]}));vm.displayName=`Switch`;var ym=[`Bash`,`Read`,`Write`,`Edit`,`Glob`,`Grep`,`WebFetch`,`WebSearch`,`Task`,`TodoRead`,`TodoWrite`,`NotebookEdit`,`AskUserQuestion`],bm=e=>e===void 0?`undefined`:e===null?`null`:typeof e==`object`?Array.isArray(e)?`[${e.map(bm).join(`,`)}]`:`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${bm(t)}`).join(`,`)}}`:JSON.stringify(e),xm=({value:e,onChange:t,disabled:n})=>{let{i18n:r}=B(),i=Object.entries(e),a=()=>{t({...e,"":``})},o=n=>{let r={...e};delete r[n],t(r)},s=(n,r)=>{let i={};for(let[t,a]of Object.entries(e))t===n?i[r]=a:i[t]=a;t(i)},c=(n,r)=>{t({...e,[n]:r})};return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[i.map(([e,t])=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Pt,{value:e,onChange:t=>s(e,t.target.value),placeholder:r._(`Key`),disabled:n,className:`h-8 text-xs flex-1`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`=`}),(0,Y.jsx)(Pt,{value:t??``,onChange:t=>c(e,t.target.value),placeholder:r._(`Value`),disabled:n,className:`h-8 text-xs flex-1`}),(0,Y.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>o(e),disabled:n,className:`h-8 w-8 p-0`,children:(0,Y.jsx)(Sr,{className:`w-3 h-3`})})]},`env-${e}`)),(0,Y.jsxs)(W,{type:`button`,variant:`outline`,size:`sm`,onClick:a,disabled:n,className:`h-7 text-xs`,children:[(0,Y.jsx)(St,{className:`w-3 h-3 mr-1`}),(0,Y.jsx)(z,{id:`settings.env.add`})]})]})},Sm=({value:e,onChange:t,disabled:n})=>{let{i18n:r}=B(),[i,a]=(0,J.useState)(``),o=n=>{e.includes(n)?t(e.filter(e=>e!==n)):t([...e,n])},s=()=>{let n=i.trim();n&&!e.includes(n)&&(t([...e,n]),a(``))};return(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>(0,Y.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,Y.jsx)(`button`,{type:`button`,onClick:()=>o(e),disabled:n,className:`hover:bg-primary/20 rounded-full p-0.5`,children:(0,Y.jsx)(Se,{className:`w-3 h-3`})})]},e))}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:ym.filter(t=>!e.includes(t)).map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>o(e),disabled:n,className:`px-2 py-0.5 text-xs rounded border border-border hover:bg-muted transition-colors`,children:e},e))}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Pt,{value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())},placeholder:r._(`Custom tool name...`),disabled:n,className:`h-8 text-xs flex-1`}),(0,Y.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,onClick:s,disabled:n??!i.trim(),className:`h-8 text-xs`,children:(0,Y.jsx)(St,{className:`w-3 h-3`})})]})]})},Cm=({value:e,onChange:t,disabled:n=!1})=>{let{i18n:r}=B(),i=(0,J.useId)(),a=(0,J.useId)(),o=(0,J.useId)(),{register:s,watch:c,setValue:l,formState:{errors:u}}=cm({resolver:_m(Zd),defaultValues:tf(e)}),d=c(),f=(0,J.useMemo)(()=>ef(d),[d]),p=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let e=bm(f);e!==p.current&&(p.current=e,t(f))},[f,t]),(0,Y.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,Y.jsx)(vt,{checked:d.systemPrompt?.mode!==`none`,onCheckedChange:e=>l(`systemPrompt`,{...d.systemPrompt,mode:e===!0?`preset`:`none`}),disabled:n}),(0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:(0,Y.jsx)(z,{id:`settings.systemPrompt.includeDefault`,message:`Include Claude Code system prompt`})})]})}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(K,{className:`text-xs font-medium`,children:(0,Y.jsx)(z,{id:`settings.disallowedTools.label`})}),(0,Y.jsx)(Sm,{value:d.disallowedTools??[],onChange:e=>l(`disallowedTools`,e),disabled:n}),u.disallowedTools?.message!==void 0&&u.disallowedTools.message!==``&&(0,Y.jsx)(`p`,{className:`text-xs text-red-500`,children:u.disallowedTools.message})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(K,{className:`text-xs font-medium`,children:(0,Y.jsx)(z,{id:`settings.env.label`,message:`Environment Variables`})}),(0,Y.jsx)(xm,{value:d.env??{},onChange:e=>l(`env`,e),disabled:n}),u.env?.root?.message!==void 0&&u.env.root.message!==``&&(0,Y.jsx)(`p`,{className:`text-xs text-red-500`,children:u.env.root.message})]}),(0,Y.jsxs)(`div`,{className:`space-y-2 p-3 bg-muted/30 rounded-md`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(K,{className:`text-xs font-medium`,children:(0,Y.jsx)(z,{id:`settings.sandbox.label`,message:`Sandbox`})}),(0,Y.jsx)(vm,{checked:d.sandbox?.enabled??!1,onCheckedChange:e=>l(`sandbox`,{...d.sandbox,enabled:e}),disabled:n})]}),d.sandbox?.enabled===!0&&(0,Y.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-border/50`,children:[(0,Y.jsxs)(`label`,{htmlFor:i,className:`flex items-center gap-2 cursor-pointer`,children:[(0,Y.jsx)(vt,{id:i,checked:d.sandbox?.autoAllowBashIfSandboxed??!1,onCheckedChange:e=>l(`sandbox`,{...d.sandbox,autoAllowBashIfSandboxed:e===!0}),disabled:n}),(0,Y.jsx)(`span`,{className:`text-xs`,children:(0,Y.jsx)(z,{id:`settings.sandbox.autoAllowBash`,message:`Auto-allow Bash if sandboxed`})})]}),(0,Y.jsxs)(`label`,{htmlFor:a,className:`flex items-center gap-2 cursor-pointer`,children:[(0,Y.jsx)(vt,{id:a,checked:d.sandbox?.allowUnsandboxedCommands??!1,onCheckedChange:e=>l(`sandbox`,{...d.sandbox,allowUnsandboxedCommands:e===!0}),disabled:n}),(0,Y.jsx)(`span`,{className:`text-xs`,children:(0,Y.jsx)(z,{id:`settings.sandbox.allowUnsandboxedCommands`,message:`Allow unsandboxed commands`})})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{className:`text-xs font-medium`,children:(0,Y.jsx)(z,{id:`settings.sandbox.network.label`,message:`Network Settings`})}),(0,Y.jsxs)(`label`,{htmlFor:o,className:`flex items-center gap-2 cursor-pointer`,children:[(0,Y.jsx)(vt,{id:o,checked:d.sandbox?.network?.allowLocalBinding??!1,onCheckedChange:e=>l(`sandbox`,{...d.sandbox,network:{...d.sandbox?.network,allowLocalBinding:e===!0}}),disabled:n}),(0,Y.jsx)(`span`,{className:`text-xs`,children:(0,Y.jsx)(z,{id:`settings.sandbox.network.allowLocalBinding`,message:`Allow local binding`})})]}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(K,{className:`text-xs text-muted-foreground`,children:(0,Y.jsx)(z,{id:`settings.sandbox.network.allowedDomains`,message:`Allowed Domains (comma-separated)`})}),(0,Y.jsx)(Pt,{value:d.sandbox?.network?.allowedDomains??``,onChange:e=>{l(`sandbox`,{...d.sandbox,network:{...d.sandbox?.network,allowedDomains:e.target.value||void 0}})},placeholder:r._(`e.g., api.example.com, cdn.example.com`),disabled:n,className:`h-8 text-xs`})]})]})]}),u.sandbox?.message!==void 0&&u.sandbox.message!==``&&(0,Y.jsx)(`p`,{className:`text-xs text-red-500`,children:u.sandbox.message})]}),(0,Y.jsxs)(`details`,{className:`group`,children:[(0,Y.jsx)(`summary`,{className:`text-xs font-medium text-muted-foreground cursor-pointer hover:text-foreground transition-colors`,children:(0,Y.jsx)(z,{id:`settings.advanced`,message:`Advanced Settings`})}),(0,Y.jsxs)(`div`,{className:`mt-3 space-y-4 pl-2 border-l-2 border-border/50`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(K,{className:`text-xs font-medium`,children:(0,Y.jsx)(z,{id:`settings.settingSources.label`,message:`Setting Sources`})}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`user`,`project`,`local`].map(e=>{let t=d.settingSources??[`user`,`project`,`local`];return(0,Y.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer`,children:[(0,Y.jsx)(vt,{checked:t.includes(e),onCheckedChange:n=>{n===!0?l(`settingSources`,[...t,e]):l(`settingSources`,t.filter(t=>t!==e))},disabled:n}),(0,Y.jsx)(`span`,{className:`text-xs`,children:e})]},e)})}),u.settingSources?.message!==void 0&&u.settingSources.message!==``&&(0,Y.jsx)(`p`,{className:`text-xs text-red-500`,children:u.settingSources.message})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(K,{htmlFor:`maxTurns`,className:`text-xs font-medium`,children:(0,Y.jsx)(z,{id:`settings.maxTurns.label`,message:`Max Turns`})}),(0,Y.jsx)(Pt,{id:`maxTurns`,type:`number`,min:1,...s(`maxTurns`,{setValueAs:e=>e===``?void 0:Number(e)}),placeholder:r._(`e.g., 10`),disabled:n,className:`h-8 text-xs`}),u.maxTurns?.message!==void 0&&u.maxTurns.message!==``&&(0,Y.jsx)(`p`,{className:`text-xs text-red-500`,children:u.maxTurns.message})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(K,{htmlFor:`maxThinkingTokens`,className:`text-xs font-medium`,children:(0,Y.jsx)(z,{id:`settings.maxThinkingTokens.label`,message:`Max Thinking Tokens`})}),(0,Y.jsx)(Pt,{id:`maxThinkingTokens`,type:`number`,min:1,...s(`maxThinkingTokens`,{setValueAs:e=>e===``?void 0:Number(e)}),placeholder:r._(`e.g., 10000`),disabled:n,className:`h-8 text-xs`}),u.maxThinkingTokens?.message!==void 0&&u.maxThinkingTokens.message!==``?(0,Y.jsx)(`p`,{className:`text-xs text-red-500`,children:u.maxThinkingTokens.message}):null]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(K,{htmlFor:`maxBudgetUsd`,className:`text-xs font-medium`,children:(0,Y.jsx)(z,{id:`settings.maxBudgetUsd.label`,message:`Max Budget (USD)`})}),(0,Y.jsx)(Pt,{id:`maxBudgetUsd`,type:`number`,min:0,step:.01,...s(`maxBudgetUsd`,{setValueAs:e=>e===``?void 0:Number(e)}),placeholder:r._(`e.g., 1.00`),disabled:n,className:`h-8 text-xs`}),u.maxBudgetUsd?.message!==void 0&&u.maxBudgetUsd.message!==``&&(0,Y.jsx)(`p`,{className:`text-xs text-red-500`,children:u.maxBudgetUsd.message})]})]})]})]})},wm=({value:e,onChange:t,disabled:n})=>{let[r,i]=(0,J.useState)(!1);return(0,Y.jsxs)(ft,{open:r,onOpenChange:i,children:[(0,Y.jsx)(ot,{asChild:!0,children:(0,Y.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,disabled:n,className:`px-2 hover:bg-background/80 hover:text-foreground text-muted-foreground transition-all duration-200 h-8 rounded-lg`,children:(0,Y.jsx)(_r,{className:`w-4 h-4`})})}),(0,Y.jsx)(bt,{className:`w-[calc(100vw-2rem)] sm:w-80 max-h-[70vh] overflow-y-auto z-[60]`,align:`end`,side:`top`,collisionPadding:16,children:(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`h4`,{className:`font-medium text-sm`,children:(0,Y.jsx)(z,{id:`settings.title`,message:`Claude Code Settings`})}),(0,Y.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>i(!1),className:`h-6 w-6 p-0`,children:(0,Y.jsx)(Se,{className:`w-4 h-4`})})]}),(0,Y.jsx)(Cm,{value:e,onChange:t,disabled:n})]})})]})},Tm=e=>{if(e.startsWith(`/`)&&!e.includes(` `))return!0;let t=e.lastIndexOf(`@`);return t===-1?!1:!e.slice(t+1).includes(` `)},Em=pe([`image/png`,`image/jpeg`,`image/gif`,`image/webp`]),Dm=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`text`,Om=e=>{if(e===null)return[];let t=Array.from(e.items).flatMap(e=>{if(e.kind!==`file`||!e.type.startsWith(`image/`))return[];let t=e.getAsFile();return t===null?[]:[t]});return t.length>0?t:Array.from(e.files).filter(e=>e.type.startsWith(`image/`))},km=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;if(typeof e==`string`){let n=e.split(`,`)[1];t(n??``)}else n(Error(`Failed to read file as base64`))},r.onerror=()=>{n(Error(`Failed to read file`))},r.readAsDataURL(e)}),Am=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;typeof e==`string`?t(e):n(Error(`Failed to read file as text`))},r.onerror=()=>{n(Error(`Failed to read file`))},r.readAsText(e)}),jm=async e=>{let t=Dm(e.type);if(t===`text`)return{type:`text`,content:await Am(e)};let n=await km(e);if(t===`image`){let t=Em.safeParse(e.type);return t.success?{type:`image`,block:{type:`image`,source:{type:`base64`,media_type:t.data,data:n}}}:null}return{type:`document`,block:{type:`document`,source:{type:`base64`,media_type:`application/pdf`,data:n}}}},Mm=(0,J.forwardRef)(({projectId:e,inputValue:t,onCommandSelect:n,className:r},i)=>{let{i18n:a}=B(),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(-1),u=(0,J.useRef)(null),d=(0,J.useRef)(null),{data:f}=Ce({queryKey:k(e).queryKey,queryFn:k(e).queryFn,staleTime:1e3*60*5}),{shouldShowCompletion:p,filteredCommands:m}=(0,J.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,J.useCallback)(e=>{let t=e.argumentHint!==null&&e.argumentHint!==``?` ${e.argumentHint}`:``;n(`/${e.name}${t} `),s(!1),l(-1)},[n]),_=(0,J.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,J.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,J.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,J.useImperativeHandle)(i,()=>({handleKeyDown:v}),[v]),!p||m.length===0?null:(0,Y.jsx)(`div`,{ref:u,className:G(`relative`,r),children:(0,Y.jsx)(lt,{open:o,onOpenChange:s,children:(0,Y.jsx)(rt,{children:(0,Y.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,Y.jsx)(`div`,{className:`h-full overflow-y-auto`,children:m.length>0&&(0,Y.jsxs)(`div`,{className:`p-1.5`,children:[(0,Y.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,Y.jsx)(br,{className:`w-3.5 h-3.5`}),`Available Commands / Skills (`,m.length,`)`]}),m.map((e,t)=>(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:G(`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`,"aria-selected":t===c,"aria-label":`Command: /${e.name}`,title:e.description??`/${e.name}`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col items-start gap-0.5 min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 w-full`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground flex-shrink-0`,children:`/`}),(0,Y.jsx)(`span`,{className:`font-medium truncate`,children:e.name}),e.argumentHint!==null&&e.argumentHint!==``?(0,Y.jsx)(`span`,{className:`text-muted-foreground/60 text-xs truncate`,children:e.argumentHint}):null]}),e.description!==null&&e.description!==``?(0,Y.jsx)(`span`,{className:`text-muted-foreground/70 text-xs pl-0 truncate w-full`,children:e.description}):null]}),t===c&&(0,Y.jsx)(ut,{className:`w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0`})]},e.name))]})})})})})})}),Nm=(e,t,n=!0)=>Ce({queryKey:ee(e,t).queryKey,queryFn:ee(e,t).queryFn,enabled:n&&!!e,staleTime:1e3*60*5}),Pm=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}},Fm=(0,J.forwardRef)(({projectId:e,inputValue:t,onFileSelect:n,className:r},i)=>{let{i18n:a}=B(),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(-1),u=(0,J.useRef)(null),d=(0,J.useRef)(null),{shouldShow:f,searchPath:p,beforeAt:m,afterAt:h}=(0,J.useMemo)(()=>Pm(t),[t]),{basePath:g,filterTerm:_}=(0,J.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}=Nm(e,g,f),b=(0,J.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,J.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,J.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,J.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,J.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,J.useImperativeHandle)(i,()=>({handleKeyDown:w}),[w]),!f||y||b.length===0?null:(0,Y.jsx)(`div`,{ref:u,className:G(`relative`,r),children:(0,Y.jsx)(lt,{open:o,onOpenChange:s,children:(0,Y.jsx)(rt,{children:(0,Y.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,Y.jsx)(`div`,{className:`h-full overflow-y-auto`,children:b.length>0&&(0,Y.jsxs)(`div`,{className:`p-1.5`,children:[(0,Y.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,Y.jsx)(Bn,{className:`w-3.5 h-3.5`}),`Files & Directories (`,b.length,`)`,g!==`/`&&(0,Y.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground/70`,children:[`in `,g]})]}),b.map((e,t)=>(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:G(`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`,"aria-selected":t===c,"aria-label":`${e.type}: ${e.name}`,title:e.path,children:[e.type===`directory`?(0,Y.jsx)(Ze,{className:`w-3.5 h-3.5 mr-2 text-blue-500 dark:text-blue-400 flex-shrink-0`}):(0,Y.jsx)(Bn,{className:`w-3.5 h-3.5 mr-2 text-gray-500 dark:text-gray-400 flex-shrink-0`}),(0,Y.jsx)(`span`,{className:`font-medium truncate min-w-0`,children:e.name}),e.type===`directory`&&(0,Y.jsx)(`span`,{className:`text-muted-foreground ml-1 flex-shrink-0`,children:`/`}),t===c&&(0,Y.jsx)(ut,{className:`w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0`})]},e.path))]})})})})})})});Fm.displayName=`FileCompletion`;var Im=(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}},Lm=({projectId:e,message:t,commandCompletionRef:n,fileCompletionRef:r,handleCommandSelect:i,handleFileSelect:a,cursorPosition:o})=>{let s=(0,J.useMemo)(()=>Im(o.relative,o.absolute,5),[o]);return(0,Y.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,Y.jsx)(Mm,{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,Y.jsx)(Fm,{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`}`})]})},Rm=({projectId:e,onSubmit:t,isPending:n,error:r,placeholder:i,buttonText:a,minHeight:o=`min-h-[64px]`,containerClassName:s=``,disabled:c=!1,sendDisabled:l=!1,buttonSize:u=`lg`,enableScheduledSend:d=!1,baseSessionId:f=null,enableCCOptions:p=!1,ccOptions:m,onCCOptionsChange:h,copyCommandMode:g=!1})=>{let _=(e=>{let t=e.match(/(\d+)px/);if(t?.[1]!==void 0){let e=parseInt(t[1],10);if(!Number.isNaN(e))return e}return 48})(o),{i18n:v}=B(),[y,b,x]=Od({projectId:e,sessionId:f??`new-session`}),[S,C]=(0,J.useState)([]),[w,T]=(0,J.useState)({relative:{top:0,left:0},absolute:{top:0,left:0}}),[E,D]=(0,J.useState)(`immediate`),[O,k]=(0,J.useState)(()=>{let e=new Date;return e.setHours(e.getHours()+1),`${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`)}`}),A=(0,J.useRef)(null),j=(0,J.useRef)(null),M=(0,J.useRef)(null),ee=(0,J.useRef)(null),N=(0,J.useRef)(null),{config:te}=he(),ne=yf(),{isSupported:re,isListening:P,audioLevels:ie,toggle:ae}=Vf({onTranscript:(0,J.useCallback)(e=>{b(t=>t+e)},[b])});(0,J.useEffect)(()=>{let e=j.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight;e.style.height=`${Math.max(_,Math.min(t,200))}px`},[y,_]),(0,J.useEffect)(()=>{let e=j.current;e&&(e.style.height=`${_}px`)},[_]);let oe=e=>{if(e.length===0)return;let t=e.map(e=>({file:e,id:`${e.name}-${Date.now()}-${Math.random()}`}));C(e=>[...e,...t])},se=async()=>{if(!y.trim()||c||l)return;let e=Lf({text:y,sessionId:f??void 0,ccOptions:m});try{let t=new Blob([e],{type:`text/plain;charset=utf-8`});await navigator.clipboard.write([new ClipboardItem({"text/plain":t})]),R.success(v._({id:`chat.copy_command.success`,message:`Command copied to clipboard`}))}catch{R.error(v._({id:`chat.copy_command.failed`,message:`Failed to copy command`}))}},ce=async()=>{if(g){await se();return}if(!y.trim()&&S.length===0||n||c||l)return;let r=[],i=[];for(let{file:e}of S){let t=await jm(e);t!==null&&(t.type===`text`?i.push({type:`document`,source:{type:`text`,media_type:`text/plain`,data:t.content}}):t.type===`image`?r.push(t.block):t.type===`document`&&i.push(t.block))}if(d&&E===`scheduled`){let t=O.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/);if(!t)throw Error(`Invalid datetime format`);let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=Number(t[4]),o=Number(t[5]),s=new Date(n,r-1,i,a,o);try{await ne.mutateAsync({name:`Scheduled message at ${O}`,schedule:{type:`reserved`,reservedExecutionTime:s.toISOString()},message:{content:y,projectId:e,sessionId:f!==null&&f!==``?f:crypto.randomUUID(),resume:f!==null&&f!==``},enabled:!0}),R.success(v._({id:`chat.scheduled_send.success`,message:`Message scheduled successfully`}),{description:v._({id:`chat.scheduled_send.success_description`,message:`You can view and manage it in the Scheduler tab`})}),x(),C([])}catch(e){R.error(v._({id:`chat.scheduled_send.failed`,message:`Failed to schedule message`}),{description:e instanceof Error?e.message:void 0})}}else t!==void 0&&await t({text:y,images:r.length>0?r:void 0,documents:i.length>0?i:void 0,ccOptions:m}),x(),C([])},le=e=>{let t=e.target.files;t&&(oe(Array.from(t)),M.current&&(M.current.value=``))},F=e=>{let t=Om(e.clipboardData);t.length!==0&&(e.preventDefault(),oe(t))},ue=e=>{C(t=>t.filter(t=>t.id!==e))},de=e=>{if(N.current?.handleKeyDown(e)!==!0&&ee.current?.handleKeyDown(e)!==!0&&e.key===`Enter`&&!e.nativeEvent.isComposing){let t=te?.enterKeyBehavior;(t===`enter-send`&&!e.shiftKey&&!e.metaKey||t===`shift-enter-send`&&e.shiftKey&&!e.metaKey||t===`command-enter-send`&&e.metaKey&&!e.shiftKey)&&(e.preventDefault(),ce())}},fe=(0,J.useCallback)(()=>{let e=j.current,t=A.current;if(e===null||t===null)return;let n=e.selectionStart,r=e.value.substring(0,n),i=e.value.substring(n),a=document.createTextNode(r),o=document.createTextNode(i),s=document.createElement(`span`);s.innerHTML=` `;let c=document.createElement(`div`);c.innerHTML=``,c.append(a,s,o);let l=window.getComputedStyle(e);for(let e of[`border`,`boxSizing`,`fontFamily`,`fontSize`,`fontWeight`,`letterSpacing`,`lineHeight`,`padding`,`textDecoration`,`textIndent`,`textTransform`,`whiteSpace`,`wordSpacing`,`wordWrap`])c.style[e]=l[e];c.style.visibility=`hidden`,t.prepend(c);let u=s.getBoundingClientRect(),d=t.getBoundingClientRect();return t.removeChild(c),{relative:{top:u.top-d.top-e.scrollTop,left:u.left-d.left-e.scrollLeft},absolute:{top:u.top-e.scrollTop,left:u.left-e.scrollLeft}}},[]),pe=e=>{b(e),j.current?.focus()},me=e=>{b(e),j.current?.focus()};return(0,Y.jsxs)(`div`,{className:s,children:[r&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-3 text-sm text-red-600 dark:text-red-400 bg-gradient-to-r from-red-50 to-red-100/50 dark:from-red-950/30 dark:to-red-900/20 border border-red-200/50 dark:border-red-800/50 rounded-xl mb-4 animate-in fade-in slide-in-from-top-2 duration-300 shadow-sm`,children:[(0,Y.jsx)(zt,{className:`w-4 h-4 shrink-0 mt-0.5`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:(0,Y.jsx)(z,{id:`chat.error.send_failed`})})]}),(0,Y.jsxs)(`div`,{className:`relative group`,children:[(0,Y.jsx)(`div`,{className:`absolute -inset-0.5 bg-gradient-to-r from-blue-500/20 via-purple-500/20 to-pink-500/20 rounded-2xl blur opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity duration-500 will-change-opacity`,"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{className:`relative bg-background border border-border/40 rounded-2xl shadow-lg hover:shadow-xl transition-all duration-300 overflow-hidden ring-0 group-focus-within:ring-1 group-focus-within:ring-primary/20 group-focus-within:border-primary/20`,children:[(0,Y.jsx)(`div`,{className:`relative`,ref:A,children:(0,Y.jsx)(al,{ref:j,value:y,onChange:e=>{if(e.target.value.endsWith(`@`)||e.target.value.endsWith(`/`)){let e=fe();e&&T(e)}b(e.target.value)},onKeyDown:de,onPaste:F,placeholder:i,className:`resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent px-5 py-4 text-base transition-all duration-200 placeholder:text-muted-foreground/50 overflow-y-auto leading-relaxed antialiased font-normal`,style:{minHeight:`${_}px`},disabled:n||c,"aria-label":v._(`Message input with completion support`),"aria-expanded":Tm(y)})}),S.length>0&&(0,Y.jsx)(`div`,{className:`px-5 py-3 flex flex-wrap gap-2 border-t border-border/40 bg-muted/10 animate-in fade-in slide-in-from-top-1 duration-200`,children:S.map(({file:e,id:t})=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-background border border-border/50 shadow-sm rounded-lg text-sm text-foreground/80 hover:text-foreground hover:border-foreground/20 transition-all duration-200`,children:[(0,Y.jsx)(`span`,{className:`truncate max-w-[200px] font-medium`,children:e.name}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>ue(t),className:`text-muted-foreground hover:text-red-500 transition-colors bg-transparent rounded-full p-0.5 hover:bg-muted`,disabled:n,children:(0,Y.jsx)(Se,{className:`w-3.5 h-3.5`})})]},t))}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 px-2 py-1 bg-muted/10 border-t border-border/30 backdrop-blur-sm`,children:[d&&E===`scheduled`&&(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-stretch sm:items-center gap-2 pt-1 animate-in fade-in duration-200`,children:[(0,Y.jsx)(K,{htmlFor:`send-mode-mobile`,className:`text-xs sr-only`,children:(0,Y.jsx)(z,{id:`chat.send_mode.label`})}),(0,Y.jsxs)(gc,{value:E,onValueChange:e=>D(e),disabled:n||c,children:[(0,Y.jsx)(vc,{id:`send-mode-mobile`,className:`h-8 w-full sm:w-[140px] text-xs bg-background/50 border-border/50 shadow-sm focus:ring-primary/20`,children:(0,Y.jsx)(_c,{})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`immediate`,children:(0,Y.jsx)(z,{id:`chat.send_mode.immediate`})}),(0,Y.jsx)(X,{value:`scheduled`,children:(0,Y.jsx)(z,{id:`chat.send_mode.scheduled`})})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-1`,children:[(0,Y.jsx)(K,{htmlFor:`scheduled-time`,className:`text-xs sr-only`,children:(0,Y.jsx)(z,{id:`chat.send_mode.scheduled_time`})}),(0,Y.jsx)(Pt,{id:`scheduled-time`,type:`datetime-local`,value:O,onChange:e=>k(e.target.value),disabled:n||c,className:`h-8 w-full sm:w-[180px] text-xs bg-background/50 border-border/50 shadow-sm focus:ring-primary/20`})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5 text-muted-foreground/70 flex-1 min-w-0 flex-wrap`,children:[(0,Y.jsx)(`input`,{ref:M,type:`file`,multiple:!0,onChange:le,className:`hidden`}),(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>M.current?.click(),disabled:n||c,className:`px-1.5 hover:bg-background/80 hover:text-foreground text-muted-foreground transition-all duration-200 h-7 rounded-lg`,children:(0,Y.jsx)(lr,{className:`w-3.5 h-3.5`})})}),(0,Y.jsx)(gt,{children:(0,Y.jsx)(z,{id:`chat.attach_file`})})]}),p&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(`span`,{children:(0,Y.jsxs)(gc,{value:m?.model??`default`,onValueChange:e=>h?.({...m,model:e===`default`?void 0:e}),disabled:n||c,children:[(0,Y.jsx)(vc,{className:`h-7 w-auto min-w-[80px] text-[11px] font-medium bg-background/50 border-border/30 shadow-none hover:bg-background hover:border-border/50 transition-all duration-200 gap-1 px-2`,children:(0,Y.jsx)(_c,{})}),(0,Y.jsx)(xc,{children:(te?.modelChoices??[`default`]).map(e=>(0,Y.jsx)(X,{value:e,children:e},e))})]})})}),(0,Y.jsx)(gt,{children:(0,Y.jsx)(z,{id:`chat.toolbar.model.tooltip`,message:`Select model`})})]}),(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(`span`,{children:(0,Y.jsxs)(gc,{value:m?.effort??`auto`,onValueChange:e=>h?.({...m,effort:e===`auto`?void 0:e}),disabled:n||c,children:[(0,Y.jsx)(vc,{className:`h-7 w-auto min-w-[70px] text-[11px] font-medium bg-background/50 border-border/30 shadow-none hover:bg-background hover:border-border/50 transition-all duration-200 gap-1 px-2`,children:(0,Y.jsx)(_c,{})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`auto`,children:`Auto`}),(0,Y.jsx)(X,{value:`low`,children:`Low`}),(0,Y.jsx)(X,{value:`medium`,children:`Medium`}),(0,Y.jsx)(X,{value:`high`,children:`High`}),(0,Y.jsx)(X,{value:`max`,children:`Max`})]})]})})}),(0,Y.jsx)(gt,{children:(0,Y.jsx)(z,{id:`chat.toolbar.effort.tooltip`,message:`Select reasoning effort`})})]})]}),p&&h&&(0,Y.jsx)(wm,{value:m,onChange:h,disabled:n||c})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[d&&E===`immediate`&&(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>D(`scheduled`),disabled:n||c,className:`h-9 px-2`,children:(0,Y.jsx)(Cn,{className:`w-4 h-4`})})}),(0,Y.jsx)(gt,{children:(0,Y.jsx)(z,{id:`chat.send_mode.scheduled`})})]}),re&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[P&&(0,Y.jsx)(`div`,{className:`flex items-center gap-px h-4 px-0.5`,children:[`a`,`b`,`c`,`d`].map((e,t)=>(0,Y.jsx)(`div`,{className:`w-0.5 rounded-full bg-red-500 transition-all duration-75 ease-out`,style:{height:`${Math.max(3,(ie[t]??0)*16)}px`}},e))}),(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:ae,disabled:n||c,className:`px-1.5 hover:bg-background/80 hover:text-foreground transition-all duration-200 h-7 rounded-lg ${P?`text-red-500`:`text-muted-foreground`}`,children:P?(0,Y.jsx)(nr,{className:`w-3.5 h-3.5`}):(0,Y.jsx)(rr,{className:`w-3.5 h-3.5`})})}),(0,Y.jsx)(gt,{children:(0,Y.jsx)(z,{id:`chat.voice_input`,message:`Voice input`})})]})]}),(0,Y.jsx)(W,{onClick:()=>{ce()},disabled:(g?!y.trim():!y.trim()&&S.length===0)||n||c||l,size:u,className:`gap-2 px-3 h-9 transition-all duration-300 shadow-md hover:shadow-lg hover:scale-[1.02] active:scale-[0.98] bg-gradient-to-r from-blue-600 via-indigo-600 to-purple-600 hover:from-blue-500 hover:via-indigo-500 hover:to-purple-500 disabled:from-muted disabled:to-muted disabled:shadow-none bg-[length:200%_auto] hover:bg-[position:right_center]`,children:n?(0,Y.jsx)(Zn,{className:`w-4 h-4 animate-spin`}):g?(0,Y.jsx)(Pn,{className:`w-4 h-4`}):(0,Y.jsx)(gr,{className:`w-4 h-4`})})]})]})]})]}),(0,Y.jsx)(Lm,{projectId:e,message:y,commandCompletionRef:ee,fileCompletionRef:N,handleCommandSelect:pe,handleFileSelect:me,cursorPosition:w})]})]})},zm=(e,t)=>{let n=y({from:`/projects/$projectId/session`}),r=o();return l({mutationFn:async i=>{let{ccOptions:a,...o}=i.input,l=i.baseSessionId,u=l!==void 0&&l!==``,d=u?l:crypto.randomUUID();Fu({sessionId:d,projectId:e,userMessage:o.text,sentAt:new Date().toISOString(),isNewSession:!u}),r.invalidateQueries({queryKey:s(e,d).queryKey}),n({to:`/projects/$projectId/session`,params:{projectId:e},search:{sessionId:d}}),t?.();try{let t=await c.api[`claude-code`][`session-processes`].$post({json:{projectId:e,sessionId:d,resume:u,input:o,ccOptions:a}},{init:{signal:AbortSignal.timeout(10*1e3)}});if(!t.ok)throw Error(t.statusText);return await t.json()}catch(e){throw Lu(d),e}}})},Bm=(e,t)=>{let n=o();return l({mutationFn:async r=>{Fu({sessionId:t,projectId:e,userMessage:r.input.text,sentAt:new Date().toISOString(),isNewSession:!1}),n.invalidateQueries({queryKey:s(e,t).queryKey});try{let n=await c.api[`claude-code`][`session-processes`][`:sessionProcessId`].continue.$post({param:{sessionProcessId:r.sessionProcessId},json:{projectId:e,baseSessionId:t,input:r.input}},{init:{signal:AbortSignal.timeout(10*1e3)}});if(!n.ok)throw Error(n.statusText);return await n.json()}catch(e){throw Lu(t),e}}})},Vm=()=>{let[e,t]=(0,J.useState)({relative:{top:0,left:0},absolute:{top:0,left:0}}),n=(0,J.useRef)(null),r=(0,J.useRef)(null),i=(0,J.useRef)(null),a=(0,J.useRef)(null),o=(0,J.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,J.useCallback)((e,n)=>{if(e.endsWith(`@`)||e.endsWith(`/`)){let e=o();e&&t(e)}n(e)},[o]),handleKeyDown:(0,J.useCallback)(e=>a.current?.handleKeyDown(e)===!0||i.current?.handleKeyDown(e)===!0,[]),handleCommandSelect:(0,J.useCallback)((e,t)=>{t(e),r.current?.focus()},[]),handleFileSelect:(0,J.useCallback)((e,t)=>{t(e),r.current?.focus()},[])}},Hm=({projectId:e,sessionId:t,sessionProcessId:n,sessionProcessStatus:r})=>{let{i18n:i}=B(),a=Bm(e,t),{config:o}=he(),s=async e=>{await a.mutateAsync({input:e,sessionProcessId:n})},c=()=>{let e=o?.enterKeyBehavior;return e===`enter-send`?i._({id:`chat.placeholder.continue.enter`,message:`Type your message... (Start with / for commands, @ for files, Enter to send)`}):e===`command-enter-send`?i._({id:`chat.placeholder.continue.command_enter`,message:`Type your message... (Start with / for commands, @ for files, Command+Enter to send)`}):i._({id:`chat.placeholder.continue.shift_enter`,message:`Type your message... (Start with / for commands, @ for files, Shift+Enter to send)`})},l=r===`running`;return(0,Y.jsx)(`div`,{className:`w-full px-4 pb-3`,children:(0,Y.jsx)(Rm,{projectId:e,onSubmit:s,isPending:a.isPending,error:a.error,placeholder:l?(()=>{let e=o?.enterKeyBehavior;return e===`enter-send`?i._({id:`chat.placeholder.running.enter`,message:`Claude is running… type your next message and send when ready (Enter to send)`}):e===`command-enter-send`?i._({id:`chat.placeholder.running.command_enter`,message:`Claude is running… type your next message and send when ready (Command+Enter to send)`}):i._({id:`chat.placeholder.running.shift_enter`,message:`Claude is running… type your next message and send when ready (Shift+Enter to send)`})})():c(),buttonText:(0,Y.jsx)(z,{id:`chat.send`}),containerClassName:``,buttonSize:`default`,enableScheduledSend:!l,baseSessionId:t,sendDisabled:l})})},Um=()=>{let{config:e}=he();return e?.usageMode===`subscription`},Wm=({projectId:e,sessionId:t,ccOptions:n,onCCOptionsChange:r})=>{let{i18n:i}=B(),a=Um(),o=zm(e),{config:s}=he(),c=async e=>{await o.mutateAsync({input:e,baseSessionId:t})},l=()=>{let e=s?.enterKeyBehavior;return e===`enter-send`?i._({id:`chat.placeholder.resume.enter`,message:`Type your message... (Start with / for commands, @ for files, Enter to send)`}):e===`command-enter-send`?i._({id:`chat.placeholder.resume.command_enter`,message:`Type your message... (Start with / for commands, @ for files, Command+Enter to send)`}):i._({id:`chat.placeholder.resume.shift_enter`,message:`Type your message... (Start with / for commands, @ for files, Shift+Enter to send)`})},u=(0,Y.jsx)(z,{id:`chat.resume`});return(0,Y.jsx)(`div`,{className:`w-full px-4 pb-3`,children:(0,Y.jsx)(Rm,{projectId:e,onSubmit:c,isPending:o.isPending,error:o.error,placeholder:l(),buttonText:u,containerClassName:``,buttonSize:`default`,enableScheduledSend:!a,baseSessionId:t,enableCCOptions:!0,ccOptions:n,onCCOptionsChange:r,copyCommandMode:a})})},Gm=({projectId:e,ccOptions:t,onCCOptionsChange:n})=>{let{i18n:r}=B(),i=Um(),a=zm(e),{config:o}=he();return(0,Y.jsx)(`div`,{className:`w-full px-4 pb-3`,children:(0,Y.jsx)(Rm,{projectId:e,onSubmit:async e=>{await a.mutateAsync({input:e})},isPending:a.isPending,error:a.error,placeholder:(()=>{let e=o?.enterKeyBehavior;return e===`enter-send`?r._({id:`chat.placeholder.continue.enter`,message:`Type your message... (Start with / for commands, @ for files, Enter to send)`}):e===`command-enter-send`?r._({id:`chat.placeholder.continue.command_enter`,message:`Type your message... (Start with / for commands, @ for files, Command+Enter to send)`}):r._({id:`chat.placeholder.continue.shift_enter`,message:`Type your message... (Start with / for commands, @ for files, Shift+Enter to send)`})})(),buttonText:(0,Y.jsx)(z,{id:`chat.button.start`}),containerClassName:``,buttonSize:`default`,enableScheduledSend:!i,enableCCOptions:!0,ccOptions:t,onCCOptionsChange:n,copyCommandMode:i})})},Km=()=>{let e=o();return l({mutationFn:async({projectId:e,sessionId:t})=>{let n=await c.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:v(n).queryKey})}})},qm=({open:e,onOpenChange:t,projectId:n,sessionId:r,sessionTitle:i,onSuccess:a})=>{let{i18n:o}=B(),s=Km();return(0,Y.jsx)(ze,{open:e,onOpenChange:t,children:(0,Y.jsxs)(He,{className:`max-w-2xl max-h-[80vh] overflow-auto`,children:[(0,Y.jsxs)(Ue,{children:[(0,Y.jsx)(ke,{children:(0,Y.jsx)(z,{id:`session.delete_dialog.title`})}),(0,Y.jsx)(Oe,{className:`break-words line-clamp-10`,children:(0,Y.jsx)(z,{id:`session.delete_dialog.description`,values:{title:i}})})]}),(0,Y.jsxs)(Le,{children:[(0,Y.jsx)(W,{variant:`outline`,onClick:()=>{t(!1)},disabled:s.isPending,children:(0,Y.jsx)(z,{id:`common.cancel`})}),(0,Y.jsx)(W,{variant:`destructive`,onClick:()=>{s.mutate({projectId:n,sessionId:r},{onSuccess:()=>{R.success(o._({id:`session.delete.success`,message:`Session deleted successfully`})),t(!1),a?.()},onError:e=>{R.error(o._({id:`session.delete.failed`,message:`Failed to delete session`}),{description:e.message})}})},disabled:s.isPending,children:s.isPending?(0,Y.jsx)(z,{id:`common.deleting`}):(0,Y.jsx)(z,{id:`common.delete`})})]})]})})},Jm=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`}},Ym=e=>e.sessionId===void 0||e.sessionId===``?(0,Y.jsx)(Zm,{...e,sessionData:null,onMobileMenuOpen:e.onMobileMenuOpen}):(0,Y.jsx)(Xm,{...e,sessionId:e.sessionId}),Xm=e=>{let t=Bu(e.projectId,e.sessionId);return(0,Y.jsx)(Zm,{...e,sessionId:e.sessionId,sessionData:t,onMobileMenuOpen:e.onMobileMenuOpen})},Zm=({projectId:e,sessionId:t,projectPath:n,projectName:r,sessionData:i,onMobileMenuOpen:o})=>{let s=y(),u=i?.conversations,d=u?.length??0,f=t!==void 0&&t!==``,p=n!==void 0&&n!==``,m=i?.getToolResult??(()=>void 0),h=f&&i!=null,{currentPermissionRequest:g,onPermissionResponse:_}=hf(t),{currentQuestionRequest:v,onQuestionResponse:b}=gf(t),{data:x}=ad(e),S=x?.success===!0?x.data.currentBranch?.name:void 0,C=S!==void 0&&S!==``,w=Mf(),{data:T}=vf(),{data:E}=Wd(e),D=a(Ft),O=a(Nu),{config:k}=he(),[A,j]=Kd(e),[M,ee]=(0,J.useState)(()=>({...$d(),...A.model!==void 0&&A.model!==``?{model:A.model}:{},...A.effort===void 0?{}:{effort:A.effort},...A.permissionMode===void 0?{}:{permissionMode:A.permissionMode},...A.useSystemPromptPreset===!1?{systemPrompt:``}:{}})),N=(0,J.useCallback)(e=>{ee(e),j({model:e?.model,effort:e?.effort,permissionMode:e?.permissionMode,useSystemPromptPreset:e?.systemPrompt!==void 0&&e?.systemPrompt!==``})},[j]),te=(0,J.useMemo)(()=>{let t=E.pages.flatMap(e=>e.sessions),n=qd(O,e,new Set(t.map(e=>e.id)));return[...t,...n]},[E.pages,e,O]),ne=(0,J.useMemo)(()=>(u??[]).some(e=>e.type!==`user`||typeof e.message.content!=`string`?!1:oc(e.message.content).kind===`local-command`),[u]),P=(0,J.useMemo)(()=>[...te].sort((e,t)=>{let n=D.find(t=>t.sessionId===e.id),r=D.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.lastModifiedAt?new Date(e.lastModifiedAt).getTime():0;return(t.lastModifiedAt?new Date(t.lastModifiedAt).getTime():0)-l}),[te,D]),ie=Nf(),ae=(0,J.useMemo)(()=>{if(f)return ie.getSessionProcess(t)},[f,t,ie]),oe=!ae,se=ae?.status===`running`&&ne?`paused`:ae?.status,ce=Jm(se);Of(se===`running`,t??``);let le=(0,J.useMemo)(()=>!f||T===void 0?[]:T.filter(n=>n.message.resume&&n.message.sessionId===t&&n.message.projectId===e&&n.schedule.type===`reserved`&&n.lastRunStatus===null),[T,f,e,t]),[F,ue]=(0,J.useState)(0),[de,fe]=(0,J.useState)(!1),pe=(0,J.useRef)(null),I=(0,J.useRef)(null),_e=(0,J.useRef)(!0),ve=(0,J.useRef)(!1),ye=(0,J.useCallback)(e=>{let t=pe.current;if(t!==null){if(t.scrollTo({top:t.scrollHeight,behavior:`auto`}),e<=0){I.current=null;return}I.current=window.requestAnimationFrame(()=>{ye(e-1)})}},[]),be=l({mutationFn:async t=>{let n=await c.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,J.useEffect)(()=>{if(h&&se===`running`&&d!==F){if(!_e.current){ue(d);return}ue(d),ye(6)}},[d,h,se,F,ye]);let xe=()=>{let e=pe.current;e!==null&&e.scrollTo({top:0,behavior:`auto`})},L=()=>{I.current!==null&&(window.cancelAnimationFrame(I.current),I.current=null),ye(8)};(0,J.useEffect)(()=>()=>{I.current!==null&&window.cancelAnimationFrame(I.current)},[]),(0,J.useEffect)(()=>{let e=pe.current;if(e===null)return;let t=()=>{_e.current=e.scrollHeight-e.scrollTop-e.clientHeight<=150};return e.addEventListener(`scroll`,t,{passive:!0}),()=>{e.removeEventListener(`scroll`,t)}},[]),(0,J.useEffect)(()=>{if(t===void 0)return;let e=O.has(t);e&&!ve.current&&ye(6),ve.current=e},[O,t,ye]);let Se=Af(i?.session.meta.customTitle??null,i?.session.meta.firstUserMessage??null,t??``),Ce=()=>{if(i==null||!f)return;let e=t.replace(/[^a-zA-Z0-9._-]/g,`_`)||`unknown`,n=i.conversations.map(e=>e.type===`x-error`?e.line:JSON.stringify(e)).join(`
|
|
12
|
+
`),r=new File([n],`ccv-jsonl-export-${e}.jsonl`,{type:`application/x-ndjson`}),a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=r.name,o.rel=`noopener`,o.target=`_self`,o.style.display=`none`,document.body.appendChild(o),o.click(),setTimeout(()=>{URL.revokeObjectURL(a),o.remove()},1e3)},we=async()=>{let e=i?.session.jsonlFilePath;if(!(e===void 0||e===``))try{await navigator.clipboard.writeText(e),R.success(`Session file path copied`)}catch(e){console.error(`Failed to copy session file path:`,e),R.error(`Failed to copy session file path`)}},Te=r??e;return h?f&&(Te=Se):Te=(0,Y.jsx)(z,{id:`chat.modal.title`}),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 min-w-0`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[o&&(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,className:`flex-shrink-0 h-7 w-7 p-0 md:hidden`,onClick:o,"aria-label":`Open menu`,children:(0,Y.jsx)($n,{className:`w-4 h-4`})}),ce&&(0,Y.jsxs)(U,{variant:`secondary`,className:G(`h-5 text-[10px] px-1.5 flex-shrink-0`,ce.className),children:[ce.icon===`running`?(0,Y.jsx)(Zn,{className:`w-2.5 h-2.5 mr-0.5 animate-spin`}):(0,Y.jsx)(ur,{className:`w-2.5 h-2.5 mr-0.5`}),(0,Y.jsx)(z,{id:ce.labelId})]}),(0,Y.jsx)(`h1`,{className:`text-sm sm:text-base font-semibold break-all overflow-ellipsis line-clamp-1 min-w-0 text-foreground/90`,children:Te})]}),h&&(0,Y.jsxs)(ft,{children:[(0,Y.jsx)(ot,{asChild:!0,children:(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,className:`flex-shrink-0 h-7 w-7 p-0`,"aria-label":`Open session menu`,children:(0,Y.jsx)(In,{className:`w-4 h-4`})})}),(0,Y.jsx)(bt,{className:`w-80`,align:`end`,children:(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wide`,children:`Actions`}),(0,Y.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`justify-start`,onClick:()=>w.mutate({projectId:e,sessionId:t}),disabled:w.isPending,children:[(0,Y.jsx)(Fn,{className:`w-4 h-4 mr-2 ${w.isPending?`animate-pulse`:``}`}),(0,Y.jsx)(z,{id:`session.menu.export_html`})]}),(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`justify-start`,onClick:Ce,children:[(0,Y.jsx)(Fn,{className:`w-4 h-4 mr-2`}),(0,Y.jsx)(z,{id:`session.menu.export_jsonl`})]}),i?.session.jsonlFilePath!==void 0&&i.session.jsonlFilePath!==``&&(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`justify-start`,onClick:()=>{we()},children:[(0,Y.jsx)(Pn,{className:`w-4 h-4 mr-2`}),(0,Y.jsx)(z,{id:`session.menu.copy_session_path`})]}),(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`justify-start text-destructive hover:text-destructive`,onClick:()=>fe(!0),children:[(0,Y.jsx)(Sr,{className:`w-4 h-4 mr-2`}),(0,Y.jsx)(z,{id:`session.delete_dialog.title`})]})]})]}),(0,Y.jsx)(`div`,{className:`h-px bg-border/60`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`font-semibold text-sm mb-2`,children:(0,Y.jsx)(z,{id:`control.metadata`})}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[p&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Y.jsx)(z,{id:`control.project_path`})}),(0,Y.jsx)(U,{variant:`secondary`,className:`h-7 text-xs flex items-center w-fit break-all`,children:n})]}),C&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Y.jsx)(z,{id:`control.branch`})}),(0,Y.jsxs)(U,{variant:`secondary`,className:`h-7 text-xs flex items-center gap-1 w-fit`,children:[(0,Y.jsx)(Un,{className:`w-3 h-3`}),S]})]}),h&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Y.jsx)(z,{id:`control.session_id`})}),(0,Y.jsx)(U,{variant:`secondary`,className:`h-7 text-xs flex items-center w-fit font-mono break-all`,children:t})]}),h&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Y.jsx)(z,{id:`control.model`})}),(0,Y.jsx)(U,{variant:`secondary`,className:`h-7 text-xs flex items-center w-fit font-mono`,children:i.session.meta.modelName??`Unknown`})]}),h&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:(0,Y.jsx)(z,{id:`session.cost.label`})}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(U,{variant:`secondary`,className:`h-7 text-xs flex items-center w-fit font-semibold`,children:[(0,Y.jsx)(z,{id:`session.cost.total`}),`: $`,i.session.meta.cost.totalUsd.toFixed(3)]}),(0,Y.jsxs)(`div`,{className:`text-xs space-y-1 pl-2`,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,Y.jsx)(z,{id:`session.cost.input_tokens`}),`:`]}),(0,Y.jsxs)(`span`,{children:[`$`,i.session.meta.cost.breakdown.inputTokensUsd.toFixed(3),` `,`(`,i.session.meta.cost.tokenUsage.inputTokens.toLocaleString(),`)`]})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,Y.jsx)(z,{id:`session.cost.output_tokens`}),`:`]}),(0,Y.jsxs)(`span`,{children:[`$`,i.session.meta.cost.breakdown.outputTokensUsd.toFixed(3),` `,`(`,i.session.meta.cost.tokenUsage.outputTokens.toLocaleString(),`)`]})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,Y.jsx)(z,{id:`session.cost.cache_creation`}),`:`]}),(0,Y.jsxs)(`span`,{children:[`$`,i.session.meta.cost.breakdown.cacheCreationUsd.toFixed(3),` `,`(`,i.session.meta.cost.tokenUsage.cacheCreationTokens.toLocaleString(),`)`]})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,Y.jsx)(z,{id:`session.cost.cache_read`}),`:`]}),(0,Y.jsxs)(`span`,{children:[`$`,i.session.meta.cost.breakdown.cacheReadUsd.toFixed(3),` `,`(`,i.session.meta.cost.tokenUsage.cacheReadTokens.toLocaleString(),`)`]})]})]})]})]})]})]})]})})]})]})}),(0,Y.jsx)(`div`,{ref:pe,className:`flex-1 overflow-y-auto min-h-0 min-w-0`,"data-testid":`scrollable-content`,children:(0,Y.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,Y.jsx)(Au,{conversations:h?u??[]:[],getToolResult:m,projectId:e,sessionId:t??``,scheduledJobs:le,scrollContainerRef:pe,enableInPageSearch:!0}),!h&&(0,Y.jsxs)(`div`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-muted-foreground/40 bg-muted/30 p-8 text-center space-y-3`,children:[(0,Y.jsx)(`div`,{className:`mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-background shadow-sm`,children:(0,Y.jsx)(ge,{className:`w-5 h-5 text-muted-foreground`})}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`p`,{className:`text-base font-semibold`,children:(0,Y.jsx)(z,{id:`chat.modal.title`})}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:(0,Y.jsx)(z,{id:`session.empty_state.description`})})]})]}),P.length>0&&(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold text-muted-foreground`,children:(0,Y.jsx)(z,{id:`chat.history.title`})}),(0,Y.jsx)(`div`,{className:`grid gap-2`,children:P.slice(0,3).map(t=>{let n=Af(t.meta.customTitle,t.meta.firstUserMessage,t.id),r=D.find(e=>e.sessionId===t.id),i=r?.status===`running`,a=r?.status===`paused`;return(0,Y.jsxs)(re,{to:`/projects/$projectId/session`,params:{projectId:e},search:{sessionId:t.id},className:G(`block p-3 rounded-lg transition-colors border`,`border-border/40 hover:bg-muted/50 hover:border-primary/30`),children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-1 min-w-0`,children:[(0,Y.jsx)(`h4`,{className:`text-sm font-medium line-clamp-1 flex-1 min-w-0 break-all`,children:n}),(i||a)&&(0,Y.jsx)(U,{variant:`secondary`,className:G(`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,Y.jsx)(z,{id:`session.status.running`}):(0,Y.jsx)(z,{id:`session.status.paused`})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(ge,{className:`w-2.5 h-2.5`}),(0,Y.jsx)(`span`,{children:t.meta.messageCount})]}),t.lastModifiedAt&&(0,Y.jsx)(`span`,{children:me(t.lastModifiedAt,{locale:k.locale,target:`time`})})]})]},t.id)})})]})]}),h&&se===`running`&&(0,Y.jsx)(`div`,{className:`flex justify-start items-center py-8 animate-in fade-in duration-500`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(Zn,{className:`w-8 h-8 animate-spin text-primary`}),(0,Y.jsx)(`div`,{className:`absolute inset-0 rounded-full bg-primary/20 animate-ping`})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground font-medium animate-pulse`,children:(0,Y.jsx)(z,{id:`session.processing`})})]})})]})}),(0,Y.jsx)(mf,{permissionRequest:g,questionRequest:v,onPermissionResponse:_,onQuestionResponse:b}),(0,Y.jsx)(`div`,{className:`w-full pt-3`,children:(0,Y.jsx)(Ff,{projectId:e,onScrollToTop:xe,onScrollToBottom:L,sessionProcess:ae,abortTask:be,isNewChat:!h,enableCCOptions:oe,ccOptions:M,onCCOptionsChange:N})}),(0,Y.jsx)(`div`,{className:`flex-shrink-0 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60`,children:h&&ae?(0,Y.jsx)(Hm,{projectId:e,sessionId:t,sessionProcessId:ae.id,sessionProcessStatus:se}):h?(0,Y.jsx)(Wm,{projectId:e,sessionId:t,ccOptions:M,onCCOptionsChange:N}):(0,Y.jsx)(Gm,{projectId:e,ccOptions:M,onCCOptionsChange:N})})]}),h&&(0,Y.jsx)(qm,{open:de,onOpenChange:fe,projectId:e,sessionId:t,sessionTitle:Se,onSuccess:()=>{s({to:`/projects/$projectId/session`,params:{projectId:e},search:{tab:`sessions`}})}})]})},Qm=()=>`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window,$m=()=>Qm()?Notification.permission:`unsupported`,eh=({showLabels:e=!0,showDescriptions:t=!0,className:n=``})=>{let r=(0,J.useId)(),[i,a]=E(Sf),[o,s]=(0,J.useState)($m),[c,l]=(0,J.useState)(!1),u=(0,J.useCallback)(e=>{a(t=>({...t,soundType:e}))},[a]),d=(0,J.useCallback)(()=>{i.soundType!==`none`&&Tf(i.soundType)},[i.soundType]),f=(0,J.useCallback)(()=>{l(!0),qt().then(e=>{s(e)}).finally(()=>{l(!1)})},[]),p=Df();return(0,Y.jsxs)(`div`,{className:`space-y-4 ${n}`,children:[o!==`unsupported`&&(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[e&&(0,Y.jsx)(`p`,{className:`text-sm font-medium leading-none`,children:(0,Y.jsx)(z,{id:`notification.push.label`})}),(0,Y.jsx)(`div`,{className:`flex items-center gap-2`,children:o===`granted`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,Y.jsx)(xn,{className:`w-3.5 h-3.5 text-primary`}),(0,Y.jsx)(`span`,{children:(0,Y.jsx)(z,{id:`notification.push.enabled`})})]}),(0,Y.jsxs)(W,{variant:`outline`,size:`sm`,onClick:f,disabled:c,className:`gap-1.5`,children:[(0,Y.jsx)(Qe,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(z,{id:`notification.push.enable`})]})]}):o===`denied`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,Y.jsx)(bn,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(`span`,{children:(0,Y.jsx)(z,{id:`notification.push.denied`})})]}):(0,Y.jsxs)(W,{variant:`outline`,size:`sm`,onClick:f,disabled:c,className:`gap-1.5`,children:[(0,Y.jsx)(Qe,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(z,{id:`notification.push.enable`})]})})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[e&&(0,Y.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium leading-none`,children:`Task completion sound`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(gc,{value:i.soundType,onValueChange:u,children:[(0,Y.jsx)(vc,{id:r,className:`w-[180px]`,children:(0,Y.jsx)(_c,{placeholder:`音を選択`})}),(0,Y.jsx)(xc,{children:p.map(e=>(0,Y.jsx)(X,{value:e,children:Ef(e)},e))})]}),i.soundType!==`none`&&(0,Y.jsx)(W,{variant:`outline`,size:`sm`,onClick:d,className:`px-3`,children:(0,Y.jsx)(z,{id:`notification.test`})})]}),t&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Y.jsx)(z,{id:`notification.description`})})]})]})},th=e=>e===`ctrl-k`||e===`command-k`,nh=e=>e===`ctrl-f`||e===`command-f`,rh=({openingProjectId:e,showLabels:t=!0,showDescriptions:n=!0,className:r=``})=>{let[i,a]=(0,J.useState)(``),s=(0,J.useId)(),c=(0,J.useId)(),l=(0,J.useId)(),u=(0,J.useId)(),d=(0,J.useId)(),f=(0,J.useId)(),p=(0,J.useId)(),{config:m,updateConfig:h}=he(),g=o(),{theme:_}=Kt(),{i18n:y}=B(),b=Um(),x=e=>e===`subscription`||e===`api`,S=e=>{x(e)&&h({...m,usageMode:e})},C=(0,J.useMemo)(()=>au()??`en`,[]),w=()=>{h({...m,hideNoUserMessageSession:!m?.hideNoUserMessageSession},{onSuccess:async()=>{await g.refetchQueries({queryKey:te.queryKey})}})},T=()=>{h({...m,unifySameTitleSession:!m?.unifySameTitleSession},{onSuccess:async()=>{await g.refetchQueries({queryKey:v(e).queryKey})}})},E=()=>{h({...m,autoScheduleContinueOnRateLimit:!m?.autoScheduleContinueOnRateLimit})},D=[`shift-enter-send`,`enter-send`,`command-enter-send`],O=e=>{let t=D.find(t=>t===e);t!==void 0&&h({...m,enterKeyBehavior:t})},k=e=>{th(e)&&h({...m,searchHotkey:e})},A=e=>{nh(e)&&h({...m,findHotkey:e})},j=()=>{let e=i.trim();e&&!m?.modelChoices?.includes(e)&&(h({...m,modelChoices:[...m?.modelChoices??[],e]}),a(``))},M=e=>{h({...m,modelChoices:(m?.modelChoices??[]).filter(t=>t!==e)})};return(0,Y.jsxs)(`div`,{className:`space-y-4 ${r}`,children:[(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Y.jsx)(`label`,{htmlFor:c,className:`text-sm font-medium leading-none`,children:(0,Y.jsx)(z,{id:`settings.usage_mode`,message:`Usage Mode`})}),(0,Y.jsxs)(gc,{value:m?.usageMode??``,onValueChange:S,children:[(0,Y.jsx)(vc,{id:c,className:`w-full`,children:(0,Y.jsx)(_c,{placeholder:y._({id:`settings.usage_mode.select`,message:`Select usage mode`})})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`subscription`,children:(0,Y.jsx)(z,{id:`settings.usage_mode.subscription`,message:`Subscription (Max, Pro, etc.)`})}),(0,Y.jsx)(X,{value:`api`,children:(0,Y.jsx)(z,{id:`settings.usage_mode.api`,message:`API`})})]})]}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Y.jsx)(z,{id:`settings.usage_mode.description`,message:`Select how you use Claude Code. Subscription mode restricts features that require the Agent SDK.`})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Y.jsx)(vt,{id:s,checked:m?.hideNoUserMessageSession,onCheckedChange:w}),t&&(0,Y.jsx)(`label`,{htmlFor:s,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,children:(0,Y.jsx)(z,{id:`settings.session.hide_no_user_message`})})]}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 ml-6`,children:(0,Y.jsx)(z,{id:`settings.session.hide_no_user_message.description`})}),(0,Y.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Y.jsx)(vt,{id:`${s}-unify`,checked:m?.unifySameTitleSession,onCheckedChange:T}),t&&(0,Y.jsx)(`label`,{htmlFor:`${s}-unify`,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,children:(0,Y.jsx)(z,{id:`settings.session.unify_same_title`})})]}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 ml-6`,children:(0,Y.jsx)(z,{id:`settings.session.unify_same_title.description`})}),!b&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Y.jsx)(vt,{id:`${s}-auto-schedule-continue`,checked:m?.autoScheduleContinueOnRateLimit,onCheckedChange:E}),t&&(0,Y.jsx)(`label`,{htmlFor:`${s}-auto-schedule-continue`,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`,children:(0,Y.jsx)(z,{id:`settings.session.auto_schedule_continue_on_rate_limit`})})]}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 ml-6`,children:(0,Y.jsx)(z,{id:`settings.session.auto_schedule_continue_on_rate_limit.description`})})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Y.jsx)(`label`,{htmlFor:l,className:`text-sm font-medium leading-none`,children:(0,Y.jsx)(z,{id:`settings.input.enter_key_behavior`})}),(0,Y.jsxs)(gc,{value:m?.enterKeyBehavior||`shift-enter-send`,onValueChange:O,children:[(0,Y.jsx)(vc,{id:l,className:`w-full`,children:(0,Y.jsx)(_c,{placeholder:y._(`Select enter key behavior`)})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`shift-enter-send`,children:(0,Y.jsx)(z,{id:`settings.input.enter_key_behavior.shift_enter`})}),(0,Y.jsx)(X,{value:`enter-send`,children:(0,Y.jsx)(z,{id:`settings.input.enter_key_behavior.enter`})}),(0,Y.jsx)(X,{value:`command-enter-send`,children:(0,Y.jsx)(z,{id:`settings.input.enter_key_behavior.command_enter`})})]})]}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Y.jsx)(z,{id:`settings.input.enter_key_behavior.description`})})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Y.jsx)(`label`,{htmlFor:u,className:`text-sm font-medium leading-none`,children:(0,Y.jsx)(z,{id:`settings.input.search_hotkey`})}),(0,Y.jsxs)(gc,{value:m?.searchHotkey||`command-k`,onValueChange:k,children:[(0,Y.jsx)(vc,{id:u,className:`w-full`,children:(0,Y.jsx)(_c,{placeholder:y._(`Select search hotkey`)})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`ctrl-k`,children:(0,Y.jsx)(z,{id:`settings.input.search_hotkey.ctrl_k`})}),(0,Y.jsx)(X,{value:`command-k`,children:(0,Y.jsx)(z,{id:`settings.input.search_hotkey.command_k`})})]})]}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Y.jsx)(z,{id:`settings.input.search_hotkey.description`})})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Y.jsx)(`label`,{htmlFor:d,className:`text-sm font-medium leading-none`,children:(0,Y.jsx)(z,{id:`settings.input.find_hotkey`})}),(0,Y.jsxs)(gc,{value:m?.findHotkey||`command-f`,onValueChange:A,children:[(0,Y.jsx)(vc,{id:d,className:`w-full`,children:(0,Y.jsx)(_c,{placeholder:y._(`Select find hotkey`)})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`ctrl-f`,children:(0,Y.jsx)(z,{id:`settings.input.find_hotkey.ctrl_f`})}),(0,Y.jsx)(X,{value:`command-f`,children:(0,Y.jsx)(z,{id:`settings.input.find_hotkey.command_f`})})]})]}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Y.jsx)(z,{id:`settings.input.find_hotkey.description`})})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Y.jsx)(`span`,{className:`text-sm font-medium leading-none block`,children:(0,Y.jsx)(z,{id:`settings.model_choices.label`,message:`Model Choices`})}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(m?.modelChoices??[]).map(e=>(0,Y.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,Y.jsx)(`button`,{type:`button`,onClick:()=>M(e),className:`hover:bg-primary/20 rounded-full p-0.5`,children:(0,Y.jsx)(Se,{className:`w-3 h-3`})})]},e))}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Pt,{value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),j())},placeholder:y._({id:`settings.model_choices.placeholder`,message:`Add model choice...`}),className:`h-8 text-xs flex-1`}),(0,Y.jsx)(W,{type:`button`,variant:`outline`,size:`sm`,onClick:j,disabled:!i.trim(),className:`h-8 text-xs`,children:(0,Y.jsx)(St,{className:`w-3 h-3`})})]}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Y.jsx)(z,{id:`settings.model_choices.description`,message:`Configure the model options available in the session toolbar`})})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Y.jsx)(`label`,{htmlFor:f,className:`text-sm font-medium leading-none`,children:(0,Y.jsx)(z,{id:`settings.locale`})}),(0,Y.jsxs)(gc,{value:m?.locale||C,onValueChange:e=>{h({...m,locale:e})},children:[(0,Y.jsx)(vc,{id:f,className:`w-full`,children:(0,Y.jsx)(_c,{placeholder:y._(`Select language`)})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`ja`,children:(0,Y.jsx)(z,{id:`settings.locale.ja`})}),(0,Y.jsx)(X,{value:`en`,children:(0,Y.jsx)(z,{id:`settings.locale.en`})}),(0,Y.jsx)(X,{value:`zh_CN`,children:(0,Y.jsx)(z,{id:`settings.locale.zh_CN`})})]})]}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Y.jsx)(z,{id:`settings.locale.description`})})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[t&&(0,Y.jsx)(`label`,{htmlFor:p,className:`text-sm font-medium leading-none`,children:(0,Y.jsx)(z,{id:`settings.theme`})}),(0,Y.jsxs)(gc,{value:_??`system`,onValueChange:e=>{h({...m,theme:e})},children:[(0,Y.jsx)(vc,{id:p,className:`w-full`,children:(0,Y.jsx)(_c,{placeholder:y._(`Select theme`)})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`light`,children:(0,Y.jsx)(z,{id:`settings.theme.light`})}),(0,Y.jsx)(X,{value:`dark`,children:(0,Y.jsx)(z,{id:`settings.theme.dark`})}),(0,Y.jsx)(X,{value:`system`,children:(0,Y.jsx)(z,{id:`settings.theme.system`})})]})]}),n&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:(0,Y.jsx)(z,{id:`settings.theme.description`})})]})]})},ih=({projectId:e})=>{let t=o(),{i18n:n}=B(),{data:r,isLoading:i,error:a,isFetching:s}=Ce({queryKey:S(e).queryKey,queryFn:S(e).queryFn,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchInterval:!1});return(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Y.jsx)(`div`,{className:`p-3 border-b border-sidebar-border`,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-sidebar-foreground`,children:(0,Y.jsx)(z,{id:`mcp.title`})}),(0,Y.jsx)(W,{onClick:()=>{t.invalidateQueries({queryKey:S(e).queryKey})},variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:i||s,title:n._(`Reload MCP servers`),children:(0,Y.jsx)(Bt,{className:`w-3 h-3 ${i||s?`animate-spin`:``}`})})]})}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-auto p-3`,children:[i&&(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,Y.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:(0,Y.jsx)(Fd,{})})}),a&&(0,Y.jsx)(`div`,{className:`text-sm text-red-500`,children:(0,Y.jsx)(z,{id:`mcp.error.load_failed`,values:{error:a.message}})}),r&&r.servers.length===0&&(0,Y.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:(0,Y.jsx)(z,{id:`mcp.no.servers`})}),r&&r.servers.length>0&&(0,Y.jsx)(`div`,{className:`space-y-3`,children:r.servers.map(e=>(0,Y.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,Y.jsx)(`div`,{className:`flex items-start justify-between`,children:(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.status===`connected`&&(0,Y.jsx)($e,{className:`w-4 h-4 text-green-500 flex-shrink-0`}),e.status===`failed`&&(0,Y.jsx)(Xe,{className:`w-4 h-4 text-red-500 flex-shrink-0`}),e.status===`unknown`&&(0,Y.jsx)(On,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`}),(0,Y.jsx)(`h3`,{className:`text-sm font-medium text-sidebar-foreground truncate`,children:e.name})]}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 font-mono break-all pl-6`,children:e.command})]})})},e.name))})]})]})},ah=[{value:0,labelKey:(0,Y.jsx)(z,{id:`cron_builder.sunday`})},{value:1,labelKey:(0,Y.jsx)(z,{id:`cron_builder.monday`})},{value:2,labelKey:(0,Y.jsx)(z,{id:`cron_builder.tuesday`})},{value:3,labelKey:(0,Y.jsx)(z,{id:`cron_builder.wednesday`})},{value:4,labelKey:(0,Y.jsx)(z,{id:`cron_builder.thursday`})},{value:5,labelKey:(0,Y.jsx)(z,{id:`cron_builder.friday`})},{value:6,labelKey:(0,Y.jsx)(z,{id:`cron_builder.saturday`})}],oh=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}},sh=(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 * * *`}},ch=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))},lh=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=ah.find(e=>e.value===o);return(0,Y.jsxs)(Y.Fragment,{children:[`Every `,s?s.labelKey:`unknown`,` at `,a]})},uh=({value:e,onChange:t})=>{let n=oh(e),[r,i]=(0,J.useState)(n?.mode??`daily`),[a,o]=(0,J.useState)(n?.hour??9),[s,c]=(0,J.useState)(n?.minute??0),[l,u]=(0,J.useState)(n?.dayOfWeek??1),[d,f]=(0,J.useState)(e),[p,m]=(0,J.useState)(null);return(0,J.useEffect)(()=>{if(r===`custom`)ch(d)?(t(d),m(null)):m(`Invalid cron expression`);else{let e=sh(r,a,s,l);t(e),f(e),m(null)}},[r,a,s,l,d,t]),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{children:(0,Y.jsx)(z,{id:`cron_builder.schedule_type`})}),(0,Y.jsxs)(gc,{value:r,onValueChange:e=>{i(e),e!==`custom`&&f(sh(e,a,s,l))},children:[(0,Y.jsx)(vc,{children:(0,Y.jsx)(_c,{})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`hourly`,children:(0,Y.jsx)(z,{id:`cron_builder.hourly`})}),(0,Y.jsx)(X,{value:`daily`,children:(0,Y.jsx)(z,{id:`cron_builder.daily`})}),(0,Y.jsx)(X,{value:`weekly`,children:(0,Y.jsx)(z,{id:`cron_builder.weekly`})}),(0,Y.jsx)(X,{value:`custom`,children:(0,Y.jsx)(z,{id:`cron_builder.custom`})})]})]})]}),r===`daily`&&(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{children:(0,Y.jsx)(z,{id:`cron_builder.hour`})}),(0,Y.jsx)(Pt,{type:`number`,min:`0`,max:`23`,value:a,onChange:e=>o(Number.parseInt(e.target.value,10))})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{children:(0,Y.jsx)(z,{id:`cron_builder.minute`})}),(0,Y.jsx)(Pt,{type:`number`,min:`0`,max:`59`,value:s,onChange:e=>c(Number.parseInt(e.target.value,10))})]})]}),r===`weekly`&&(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{children:(0,Y.jsx)(z,{id:`cron_builder.day_of_week`})}),(0,Y.jsxs)(gc,{value:String(l),onValueChange:e=>u(Number.parseInt(e,10)),children:[(0,Y.jsx)(vc,{children:(0,Y.jsx)(_c,{})}),(0,Y.jsx)(xc,{children:ah.map(e=>(0,Y.jsx)(X,{value:String(e.value),children:e.labelKey},e.value))})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{children:(0,Y.jsx)(z,{id:`cron_builder.hour`})}),(0,Y.jsx)(Pt,{type:`number`,min:`0`,max:`23`,value:a,onChange:e=>o(Number.parseInt(e.target.value,10))})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{children:(0,Y.jsx)(z,{id:`cron_builder.minute`})}),(0,Y.jsx)(Pt,{type:`number`,min:`0`,max:`59`,value:s,onChange:e=>c(Number.parseInt(e.target.value,10))})]})]})]}),r===`custom`&&(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{children:(0,Y.jsx)(z,{id:`cron_builder.cron_expression`})}),(0,Y.jsx)(Pt,{value:d,onChange:e=>f(e.target.value),placeholder:`0 9 * * *`})]}),(0,Y.jsxs)(`div`,{className:`rounded-md border p-3 text-sm`,children:[(0,Y.jsx)(`div`,{className:`font-medium mb-1`,children:(0,Y.jsx)(z,{id:`cron_builder.preview`})}),(0,Y.jsx)(`div`,{className:`text-muted-foreground`,children:p===null?lh(r===`custom`?d:e):(0,Y.jsx)(`span`,{className:`text-destructive`,children:p})}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-2`,children:[(0,Y.jsx)(z,{id:`cron_builder.expression`}),`:`,` `,(0,Y.jsx)(`code`,{children:r===`custom`?d:e})]})]})]})},dh=({open:e,onOpenChange:t,job:n,projectId:r,onSubmit:i,isSubmitting:a=!1})=>{let{_:o,i18n:s}=B(),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(`cron`),[f,p]=(0,J.useState)(`0 9 * * *`),[m,h]=(0,J.useState)(()=>{let e=new Date;return e.setHours(e.getHours()+1),e.toISOString().slice(0,16)}),[g,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(!0),[b,x]=(0,J.useState)(`skip`),S=Vm();(0,J.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,Y.jsx)(ze,{open:e,onOpenChange:t,children:(0,Y.jsxs)(He,{className:`max-w-2xl max-h-[90vh] overflow-y-auto`,children:[(0,Y.jsxs)(Ue,{children:[(0,Y.jsx)(ke,{children:n?(0,Y.jsx)(z,{id:`scheduler.dialog.title.edit`}):(0,Y.jsx)(z,{id:`scheduler.dialog.title.create`})}),(0,Y.jsx)(Oe,{children:(0,Y.jsx)(z,{id:`scheduler.dialog.description`})})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border p-4`,children:[(0,Y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Y.jsx)(K,{htmlFor:`enabled`,className:`text-base font-semibold`,children:(0,Y.jsx)(z,{id:`scheduler.form.enabled`})}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:(0,Y.jsx)(z,{id:`scheduler.form.enabled.description`})})]}),(0,Y.jsx)(vm,{id:`enabled`,checked:v,onCheckedChange:y,disabled:a})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{htmlFor:`job-name`,children:(0,Y.jsx)(z,{id:`scheduler.form.name`})}),(0,Y.jsx)(Pt,{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,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{children:(0,Y.jsx)(z,{id:`scheduler.form.schedule_type`})}),(0,Y.jsxs)(gc,{value:u,onValueChange:e=>d(e),disabled:a,children:[(0,Y.jsx)(vc,{children:(0,Y.jsx)(_c,{})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`cron`,children:(0,Y.jsx)(z,{id:`scheduler.form.schedule_type.cron`})}),(0,Y.jsx)(X,{value:`reserved`,children:(0,Y.jsx)(z,{id:`scheduler.form.schedule_type.reserved`})})]})]})]}),u===`cron`?(0,Y.jsx)(uh,{value:f,onChange:p}):(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{htmlFor:`reserved-datetime`,children:(0,Y.jsx)(z,{id:`scheduler.form.reserved_time`})}),(0,Y.jsx)(Pt,{id:`reserved-datetime`,type:`datetime-local`,value:m,onChange:e=>h(e.target.value),disabled:a}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Y.jsx)(z,{id:`scheduler.form.reserved_time.hint`})})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{htmlFor:`message-content`,children:(0,Y.jsx)(z,{id:`scheduler.form.message`})}),(0,Y.jsxs)(`div`,{className:`relative`,ref:S.containerRef,children:[(0,Y.jsx)(al,{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,Y.jsx)(Lm,{projectId:r,message:g,commandCompletionRef:S.commandCompletionRef,fileCompletionRef:S.fileCompletionRef,handleCommandSelect:e=>S.handleCommandSelect(e,_),handleFileSelect:e=>S.handleFileSelect(e,_),cursorPosition:S.cursorPosition})]}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,Y.jsx)(z,{id:`scheduler.form.message.hint`})})]}),u===`cron`&&(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{children:(0,Y.jsx)(z,{id:`scheduler.form.concurrency_policy`})}),(0,Y.jsxs)(gc,{value:b,onValueChange:e=>x(e),disabled:a,children:[(0,Y.jsx)(vc,{children:(0,Y.jsx)(_c,{})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`skip`,children:(0,Y.jsx)(z,{id:`scheduler.form.concurrency_policy.skip`})}),(0,Y.jsx)(X,{value:`run`,children:(0,Y.jsx)(z,{id:`scheduler.form.concurrency_policy.run`})})]})]})]})]}),(0,Y.jsxs)(Le,{children:[(0,Y.jsx)(W,{variant:`outline`,onClick:()=>t(!1),disabled:a,children:(0,Y.jsx)(z,{id:`common.cancel`})}),(0,Y.jsx)(W,{onClick:C,disabled:!w||a,children:a?(0,Y.jsx)(z,{id:`common.saving`}):n?(0,Y.jsx)(z,{id:`common.update`}):(0,Y.jsx)(z,{id:`common.create`})})]})]})})},fh=({projectId:e,sessionId:t})=>{let{i18n:n}=B(),{data:r,isLoading:i,isFetching:a,error:o,refetch:s}=vf(),c=yf(),l=bf(),u=xf(),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(null),y=e=>{c.mutate(e,{onSuccess:()=>{R.success(n._({id:`scheduler.job.created`,message:`Job created successfully`})),f(!1)},onError:e=>{R.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:()=>{R.success(n._({id:`scheduler.job.updated`,message:`Job updated successfully`})),f(!1),m(null)},onError:e=>{R.error(n._({id:`scheduler.job.update_failed`,message:`Failed to update job`}),{description:e.message})}})},x=()=>{_===null||_===``||u.mutate(_,{onSuccess:()=>{R.success(n._({id:`scheduler.job.deleted`,message:`Job deleted successfully`})),g(!1),v(null)},onError:e=>{R.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,Y.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,Y.jsx)(`div`,{className:`p-3 border-b border-sidebar-border`,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-sidebar-foreground`,children:(0,Y.jsx)(z,{id:`scheduler.title`})}),(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Y.jsx)(W,{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,Y.jsx)(Bt,{className:`w-3 h-3 ${i||a?`animate-spin`:``}`})}),(0,Y.jsx)(W,{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,Y.jsx)(St,{className:`w-3 h-3`})})]})]})}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-auto p-3`,children:[i&&(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,Y.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:(0,Y.jsx)(Fd,{})})}),o&&(0,Y.jsx)(`div`,{className:`text-sm text-red-500`,children:(0,Y.jsx)(z,{id:`scheduler.error.load_failed`,values:{error:o.message}})}),r&&r.length===0&&(0,Y.jsx)(`div`,{className:`text-sm text-muted-foreground text-center py-8`,children:(0,Y.jsx)(z,{id:`scheduler.no_jobs`})}),r&&r.length>0&&(0,Y.jsx)(`div`,{className:`space-y-3`,children:r.map(e=>(0,Y.jsxs)(`div`,{className:`p-3 bg-sidebar-accent/50 rounded-md border border-sidebar-border`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-medium text-sidebar-foreground truncate`,children:e.name}),(0,Y.jsx)(U,{variant:e.enabled?`default`:`secondary`,className:`text-xs`,children:e.enabled?(0,Y.jsx)(z,{id:`scheduler.status.enabled`}):(0,Y.jsx)(z,{id:`scheduler.status.disabled`})})]}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:w(e)})]}),(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>S(e),children:(0,Y.jsx)(yr,{className:`w-3 h-3`})}),(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive hover:text-destructive`,onClick:()=>C(e.id),children:(0,Y.jsx)(Sr,{className:`w-3 h-3`})})]})]}),e.lastRunAt!==null&&e.lastRunAt!==``&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2 pt-2 border-t border-sidebar-border`,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(z,{id:`scheduler.last_run`}),(0,Y.jsx)(`span`,{children:T(e.lastRunAt)})]}),e.lastRunStatus&&(0,Y.jsx)(U,{variant:e.lastRunStatus===`success`?`default`:`destructive`,className:`text-xs`,children:e.lastRunStatus})]})})]},e.id))})]}),(0,Y.jsx)(dh,{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,Y.jsx)(ze,{open:h,onOpenChange:g,children:(0,Y.jsxs)(He,{children:[(0,Y.jsxs)(Ue,{children:[(0,Y.jsx)(ke,{children:(0,Y.jsx)(z,{id:`scheduler.delete_dialog.title`})}),(0,Y.jsx)(Oe,{children:(0,Y.jsx)(z,{id:`scheduler.delete_dialog.description`})})]}),(0,Y.jsxs)(Le,{children:[(0,Y.jsx)(W,{variant:`outline`,onClick:()=>{g(!1),v(null)},disabled:u.isPending,children:(0,Y.jsx)(z,{id:`common.cancel`})}),(0,Y.jsx)(W,{variant:`destructive`,onClick:x,disabled:u.isPending,children:u.isPending?(0,Y.jsx)(z,{id:`common.deleting`}):(0,Y.jsx)(z,{id:`common.delete`})})]})]})})]})},ph=({currentSessionId:e,projectId:t,onSessionSelect:n})=>{let{data:r,fetchNextPage:i,hasNextPage:o,isFetchingNextPage:s}=Wd(t),c=a(Ft),l=a(Nu),u=(0,J.useMemo)(()=>{let e=r.pages.flatMap(e=>e.sessions),n=qd(l,t,new Set(e.map(e=>e.id)));return[...e,...n]},[r.pages,t,l]);(0,J.useEffect)(()=>{let e=new Set(r.pages.flatMap(e=>e.sessions).map(e=>e.id));for(let n of l.values())n.projectId===t&&n.isNewSession&&e.has(n.sessionId)&&Lu(n.sessionId)},[r.pages,t,l]);let{config:d}=he(),f=(0,J.useRef)(null);(0,J.useEffect)(()=>{f.current?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[e]);let p=`sessions`,m=e===``,h=(0,J.useMemo)(()=>{let e=e=>e===`running`?0:e===`paused`?1:2;return[...u].sort((t,n)=>{let r=c.find(e=>e.sessionId===t.id)?.status,i=c.find(e=>e.sessionId===n.id)?.status,a=e(r),o=e(i);if(a!==o)return a-o;let s=t.lastModifiedAt?new Date(t.lastModifiedAt).getTime():0;return(n.lastModifiedAt?new Date(n.lastModifiedAt).getTime():0)-s})},[u,c]);return(0,Y.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`border-b border-sidebar-border p-4`,children:[(0,Y.jsx)(`div`,{className:`flex items-center justify-between mb-2`,children:(0,Y.jsx)(`h2`,{className:`font-semibold text-lg`,children:(0,Y.jsx)(z,{id:`sessions.title`})})}),(0,Y.jsxs)(`p`,{className:`text-xs text-sidebar-foreground/70`,children:[u.length,` `,(0,Y.jsx)(z,{id:`sessions.total`})]})]}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-2 space-y-0.5`,children:[(0,Y.jsx)(re,{to:`/projects/$projectId/session`,params:{projectId:t},search:{tab:p},onClick:n,className:G(`block rounded-lg p-2.5 transition-all duration-200 border-2 border-dashed border-sidebar-border/60 hover:border-blue-400/80 hover:bg-blue-50/50 dark:hover:bg-blue-950/40 bg-sidebar/10`,m&&`bg-blue-100 dark:bg-blue-900/40 border-blue-400 dark:border-blue-500 shadow-sm`),children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,Y.jsx)(St,{className:`w-4 h-4`})}),(0,Y.jsx)(`div`,{className:`space-y-0.5`,children:(0,Y.jsx)(`p`,{className:`text-sm font-semibold text-sidebar-foreground`,children:(0,Y.jsx)(z,{id:`chat.modal.title`})})})]})}),h.map(r=>{let i=r.id===e,a=Af(r.meta.customTitle,r.meta.firstUserMessage,r.id),o=c.find(e=>e.sessionId===r.id),s=o?.status===`running`,l=o?.status===`paused`;return(0,Y.jsx)(re,{ref:i?f:void 0,to:`/projects/$projectId/session`,params:{projectId:t},search:{tab:p,sessionId:r.id},onClick:n,className:G(`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,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2 pr-6`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-medium line-clamp-2 leading-tight text-sidebar-foreground flex-1`,children:a}),(s||l)&&(0,Y.jsx)(U,{variant:s?`default`:`secondary`,className:G(`text-xs shrink-0`,s&&`bg-green-500 text-white`,l&&`bg-yellow-500 text-white`),children:s?(0,Y.jsx)(z,{id:`session.status.running`}):(0,Y.jsx)(z,{id:`session.status.paused`})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-sidebar-foreground/70 min-w-0`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(ge,{className:`w-3 h-3`}),(0,Y.jsx)(`span`,{children:r.meta.messageCount})]})}),r.lastModifiedAt&&(0,Y.jsx)(`span`,{className:`text-xs text-sidebar-foreground/60 shrink-0`,children:me(r.lastModifiedAt,{locale:d.locale,target:`time`})})]})]})},r.id)}),o===!0&&(0,Y.jsx)(`div`,{className:`p-2`,children:(0,Y.jsx)(W,{onClick:()=>{i()},disabled:s,variant:`outline`,size:`sm`,className:`w-full`,children:s?(0,Y.jsx)(z,{id:`common.loading`}):(0,Y.jsx)(z,{id:`sessions.load.more`})})})]})]})},mh=async(e,t)=>(await c.api.tasks.$get({query:{projectId:e,sessionId:t}})).json(),hh=async(e,t,n)=>(await c.api.tasks.$post({query:{projectId:e,sessionId:n},json:t})).json(),gh=async(e,t,n,r)=>(await c.api.tasks[`:taskId`].$patch({param:{taskId:t},query:{projectId:e,sessionId:r},json:n})).json(),_h=({status:e,onClick:t})=>(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:G(`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,Y.jsx)($e,{className:`w-4 h-4`}),e===`in_progress`&&(0,Y.jsx)(Mn,{className:`w-4 h-4 animate-pulse`}),e===`pending`&&(0,Y.jsx)(kn,{className:`w-4 h-4`}),e===`failed`&&(0,Y.jsx)(zt,{className:`w-4 h-4`})]}),vh=({task:e,onToggleStatus:t})=>{let n=e.status===`completed`,r=e.status===`in_progress`,i=e.status===`failed`;return(0,Y.jsx)(`div`,{className:G(`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,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.jsx)(_h,{status:e.status,onClick:()=>t(e)}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:G(`text-sm font-medium leading-tight line-clamp-1`,n&&`line-through text-sidebar-foreground/60`),children:e.subject}),(0,Y.jsxs)(`span`,{className:`text-[10px] font-mono text-sidebar-foreground/50 shrink-0`,children:[`#`,e.id]})]}),e.description!==void 0&&e.description!==``&&(0,Y.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,Y.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:e.blockedBy.map(e=>(0,Y.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,Y.jsx)(Cr,{className:`w-2.5 h-2.5`}),`#`,e]},e))})]})]})})},yh=()=>(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 px-4 text-center`,children:[(0,Y.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-sidebar-accent/50 flex items-center justify-center mb-4`,children:(0,Y.jsx)(Xn,{className:`w-6 h-6 text-sidebar-foreground/40`})}),(0,Y.jsx)(`p`,{className:`text-sm font-medium text-sidebar-foreground/70`,children:`No tasks yet`}),(0,Y.jsx)(`p`,{className:`text-xs text-sidebar-foreground/50 mt-1`,children:`Tasks will appear here when created`})]}),bh=()=>(0,Y.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sidebar-foreground/60`,children:[(0,Y.jsx)(M,{className:`w-4 h-4 animate-spin`}),(0,Y.jsx)(`span`,{className:`text-sm`,children:`Loading tasks...`})]})}),xh=()=>(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 px-4 text-center`,children:[(0,Y.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,Y.jsx)(zt,{className:`w-6 h-6 text-red-500`})}),(0,Y.jsx)(`p`,{className:`text-sm font-medium text-red-600 dark:text-red-400`,children:`Failed to load tasks`}),(0,Y.jsx)(`p`,{className:`text-xs text-sidebar-foreground/50 mt-1`,children:`Please try again later`})]}),Sh=({projectId:e,sessionId:t})=>{let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),u=o(),{data:d,isLoading:f,error:p}=Ce({queryKey:[`tasks`,e,t],queryFn:()=>mh(e,t),refetchInterval:5e3}),m=l({mutationFn:n=>hh(e,n,t),onSuccess:()=>{u.invalidateQueries({queryKey:[`tasks`,e,t]}),r(!1),a(``),c(``),R.success(`Task created`)},onError:()=>R.error(`Failed to create task`)}),h=l({mutationFn:n=>gh(e,n.taskId,n.update,t),onSuccess:()=>{u.invalidateQueries({queryKey:[`tasks`,e,t]})},onError:()=>R.error(`Failed to update task`)}),g=e=>{let t=`pending`;e.status===`pending`?t=`in_progress`:e.status===`in_progress`?t=`completed`:(e.status===`completed`||e.status===`failed`)&&(t=`pending`),h.mutate({taskId:e.id,update:{status:t}})},_=e=>{e.preventDefault(),i.trim().length!==0&&m.mutate({subject:i,description:s})},v=d?.length??0;return(0,Y.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`border-b border-sidebar-border p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h2`,{className:`font-semibold text-lg`,children:`Tasks`}),(0,Y.jsxs)(ze,{open:n,onOpenChange:r,children:[(0,Y.jsx)(je,{asChild:!0,children:(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,className:`h-8 w-8 p-0 rounded-full hover:bg-primary/10 hover:text-primary transition-colors`,children:(0,Y.jsx)(St,{className:`w-4 h-4`})})}),(0,Y.jsxs)(He,{className:`sm:max-w-md`,children:[(0,Y.jsxs)(Ue,{children:[(0,Y.jsx)(ke,{children:`Create New Task`}),(0,Y.jsx)(Oe,{children:`Add a new task to track your progress.`})]}),(0,Y.jsxs)(`form`,{onSubmit:_,className:`space-y-4 mt-2`,children:[(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{htmlFor:`subject`,children:`Title`}),(0,Y.jsx)(Pt,{id:`subject`,value:i,onChange:e=>a(e.target.value),placeholder:`e.g. Implement login flow`,className:`focus-visible:ring-primary/30`})]}),(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(K,{htmlFor:`description`,children:`Description`}),(0,Y.jsx)(al,{id:`description`,value:s,onChange:e=>c(e.target.value),placeholder:`Optional details about the task...`,className:`focus-visible:ring-primary/30 min-h-[80px]`})]}),(0,Y.jsx)(Le,{children:(0,Y.jsx)(W,{type:`submit`,disabled:m.isPending||i.trim().length===0,className:`w-full sm:w-auto`,children:m.isPending?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(M,{className:`w-4 h-4 mr-2 animate-spin`}),`Creating...`]}):`Create Task`})})]})]})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-sidebar-foreground/70`,children:[v,` `,v===1?`task`:`tasks`]})]}),(0,Y.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-2 space-y-2`,children:[f&&(0,Y.jsx)(bh,{}),p&&(0,Y.jsx)(xh,{}),!f&&!p&&v===0&&(0,Y.jsx)(yh,{}),!f&&!p&&d?.map(e=>(0,Y.jsx)(vh,{task:e,onToggleStatus:g},e.id))]})]})},Ch=({currentSessionId:e,projectId:t,isOpen:n,onClose:r,initialTab:i=`sessions`})=>{let{i18n:a}=B(),o=y(),s=Um(),[c,l]=(0,J.useState)(i),u=c,d=(0,J.useMemo)(()=>s?Ut.options.filter(e=>e!==`scheduler`):Ut.options,[s]);(0,J.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,J.useEffect)(()=>{l(i)},[i]),(0,J.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=Vd({onSwipe:e=>{e===`left`&&r()},enabled:n}),m=e=>{if(e===`projects`){o({to:`/projects`}),r();return}let t=Ut.safeParse(e);t.success&&l(t.data)},h=()=>{switch(c){case`sessions`:return(0,Y.jsx)(ph,{currentSessionId:e,projectId:t,onSessionSelect:r});case`mcp`:return(0,Y.jsx)(ih,{projectId:t});case`tasks`:return(0,Y.jsx)(Sh,{projectId:t,sessionId:e});case`scheduler`:return(0,Y.jsx)(fh,{projectId:t,sessionId:e});case`settings`:return(0,Y.jsx)(`div`,{className:`h-full flex flex-col`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4`,children:(0,Y.jsx)(`div`,{className:`text-sm text-sidebar-foreground/70`,children:(0,Y.jsx)(z,{id:`settings.loading`})})}),children:(0,Y.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,Y.jsx)(z,{id:`settings.session.display`})}),(0,Y.jsx)(rh,{openingProjectId:t})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,Y.jsx)(z,{id:`settings.notifications`})}),(0,Y.jsx)(eh,{})]})]})})});case`system-info`:return(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4`,children:(0,Y.jsx)(`div`,{className:`text-sm text-sidebar-foreground/70`,children:`Loading...`})}),children:(0,Y.jsx)(mt,{})});default:return null}};return(0,Y.jsxs)(`div`,{ref:p,className:G(`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,Y.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,Y.jsxs)(gc,{value:c,onValueChange:m,children:[(0,Y.jsx)(vc,{className:`flex-1 h-7 text-xs`,children:(0,Y.jsx)(_c,{})}),(0,Y.jsxs)(xc,{children:[(0,Y.jsx)(X,{value:`projects`,className:`text-xs`,children:a._({id:`sidebar.tab.projects`,message:`Projects`})}),d.map(e=>(0,Y.jsx)(X,{value:e,className:`text-xs`,children:f[e]},e))]})]}),(0,Y.jsx)(re,{to:`/projects/$projectId/session`,params:{projectId:t},search:{tab:u},onClick:r,className:`flex-shrink-0`,children:(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 hover:bg-sidebar-accent/50`,"aria-label":a._(`New chat`),children:(0,Y.jsx)(St,{className:`w-3.5 h-3.5`})})}),(0,Y.jsx)(W,{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,Y.jsx)(Se,{className:`w-3.5 h-3.5`})})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:h()})]})},wh=({projectId:e,className:t,additionalTabs:n=[],defaultActiveTab:r,headerButton:i,fillWidth:a=!1,isContentHidden:o=!1,onToggle:s,onMobileTabClick:c})=>{let{openSearch:l}=Pe(),{authEnabled:u,logout:d}=O(),f=y(),p=async()=>{await d(),f({to:`/login`})},m={id:`settings`,icon:_r,title:(0,Y.jsx)(z,{id:`settings.tab.title`}),content:(0,Y.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`border-b border-sidebar-border p-4`,children:[(0,Y.jsx)(`h2`,{className:`font-semibold text-lg`,children:(0,Y.jsx)(z,{id:`settings.title`})}),(0,Y.jsx)(`p`,{className:`text-xs text-sidebar-foreground/70`,children:(0,Y.jsx)(z,{id:`settings.description`})})]}),(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-4`,children:(0,Y.jsx)(`div`,{className:`text-sm text-sidebar-foreground/70`,children:(0,Y.jsx)(z,{id:`settings.loading`})})}),children:(0,Y.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,Y.jsx)(z,{id:`settings.section.session_display`})}),(0,Y.jsx)(rh,{openingProjectId:e??``})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h3`,{className:`font-medium text-sm text-sidebar-foreground`,children:(0,Y.jsx)(z,{id:`settings.section.notifications`})}),(0,Y.jsx)(eh,{})]})]})})]})},h={id:`system-info`,icon:tt,title:(0,Y.jsx)(z,{id:`settings.section.system_info`}),content:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Fd,{}),children:(0,Y.jsx)(mt,{})})},g=[...n,m,h],[_,v]=(0,J.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,Y.jsxs)(`div`,{className:G(`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,Y.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,Y.jsxs)(pt,{children:[i!==void 0&&(0,Y.jsx)(`div`,{className:`border-b border-sidebar-border`,children:i}),(0,Y.jsx)(`div`,{className:`p-1.5 md:p-2 border-b border-sidebar-border`,children:(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,onClick:l,className:G(`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,Y.jsx)(we,{className:`w-4 h-4`})})}),(0,Y.jsx)(gt,{side:`right`,children:(0,Y.jsxs)(`p`,{children:[`Search `,(0,Y.jsx)(`kbd`,{className:`ml-1 text-xs opacity-60`,children:`⌘K`})]})})]})}),(0,Y.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,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,onClick:()=>b(e.id),className:G(`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,Y.jsx)(t,{className:`w-4 h-4`})})}),(0,Y.jsx)(gt,{side:`right`,children:(0,Y.jsx)(`p`,{children:e.title})})]},e.id)})}),u&&(0,Y.jsx)(`div`,{className:`p-1.5 md:p-2 border-t border-sidebar-border`,children:(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,onClick:()=>void p(),className:G(`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,Y.jsx)(Qn,{className:`w-4 h-4`})})}),(0,Y.jsx)(gt,{side:`right`,children:(0,Y.jsx)(`p`,{children:`Logout`})})]})})]})}),S&&(0,Y.jsx)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:x})]})},Th=({currentSessionId:e,projectId:t,className:n,initialTab:r})=>{let{isLeftPanelOpen:i}=io(),{toggleLeftPanel:a}=ao(),o=Um(),s=e??``,c=(0,J.useMemo)(()=>[{id:`sessions`,icon:ge,title:(0,Y.jsx)(z,{id:`sidebar.show.session.list`}),content:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Fd,{}),children:(0,Y.jsx)(ph,{currentSessionId:s,projectId:t})})},{id:`mcp`,icon:dr,title:(0,Y.jsx)(z,{id:`sidebar.show.mcp.settings`}),content:(0,Y.jsx)(ih,{projectId:t})},{id:`tasks`,icon:Xn,title:(0,Y.jsx)(z,{id:`sidebar.show.task.list`}),content:(0,Y.jsx)(Sh,{projectId:t,sessionId:s})},...o?[]:[{id:`scheduler`,icon:Cn,title:(0,Y.jsx)(z,{id:`sidebar.show.scheduler.jobs`}),content:(0,Y.jsx)(fh,{projectId:t,sessionId:s})}]],[s,t,o]);return(0,Y.jsx)(`div`,{className:G(`hidden md:flex h-full w-full`,n),children:(0,Y.jsx)(wh,{projectId:t,additionalTabs:c,defaultActiveTab:r,headerButton:(0,Y.jsx)(pt,{children:(0,Y.jsxs)(st,{children:[(0,Y.jsx)(ct,{asChild:!0,children:(0,Y.jsx)(re,{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,Y.jsx)(vn,{className:`w-4 h-4 text-sidebar-foreground/70`})})}),(0,Y.jsx)(gt,{side:`right`,children:(0,Y.jsx)(`p`,{children:(0,Y.jsx)(z,{id:`sidebar.back.to.projects`})})})]})}),fillWidth:!0,isContentHidden:!i,onToggle:a})})},Eh=({projectId:e,sessionId:t,tab:n})=>(Ud(),(0,Y.jsx)(xs,{projectId:e,sessionId:t,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Fd,{}),children:(0,Y.jsx)(Dh,{projectId:e,sessionId:t,tab:n})})})),Dh=({projectId:e,sessionId:t,tab:n})=>{let[r,i]=(0,J.useState)(!1),o=Ts(),s=Vd({onSwipe:e=>{e===`right`&&!r&&i(!0)},edgeWidth:30,enabled:o}),c=uo(),l=fo(),u=a(Wa),{data:d}=Wd(e),f=d.pages[0]?.project,p=f?.meta.projectPath??f?.claudeProjectPath,m=f?.meta.projectName??`Untitled Project`,h=m?`${m} - Claude Code Viewer`:`Claude Code Viewer`,g=c&&!o?`${l}%`:`0`,_=(0,J.useCallback)(()=>{i(!0)},[]),v=(0,J.useCallback)(()=>{i(!1)},[]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`title`,{children:h}),o&&(0,Y.jsx)(Ch,{currentSessionId:t??``,projectId:e,isOpen:r,onClose:v,initialTab:n}),o&&r&&(0,Y.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-black/30 md:hidden`,onClick:v,"aria-label":`Close sidebar`}),(0,Y.jsxs)(`div`,{ref:s,className:G(`flex h-full overflow-hidden`,o&&`transition-transform duration-300 ease-out`),style:o&&r?{transform:`translateX(75vw)`}:void 0,children:[(0,Y.jsx)(Rd,{children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Fd,{}),children:(0,Y.jsx)(Th,{currentSessionId:t,projectId:e,initialTab:n})})}),(0,Y.jsxs)(`div`,{className:G(`flex flex-col flex-1 min-w-0`,!u&&`transition-all duration-200`),style:{marginRight:g},children:[(0,Y.jsx)(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Fd,{}),children:(0,Y.jsx)(Ym,{projectId:e,sessionId:t,projectPath:p,projectName:m,onMobileMenuOpen:o?_:void 0})})}),(0,Y.jsx)(Bs,{cwd:p})]}),(0,Y.jsx)(Hs,{projectId:e,sessionId:t,gitTabContent:(0,Y.jsx)(xd,{projectId:e,sessionId:t}),filesToolsTabContent:t!==void 0&&t!==``?(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Fd,{}),children:(0,Y.jsx)(ed,{projectId:e,sessionId:t})}):(0,Y.jsx)($u,{}),reviewTabContent:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(Fd,{}),children:(0,Y.jsx)(Md,{projectId:e,sessionId:t})})})]})]})},Oh=()=>{let e=Jt.useParams(),{sessionId:t,tab:n}=Jt.useSearch();return(0,Y.jsx)(yt,{children:(0,Y.jsx)(Eh,{projectId:e.projectId,sessionId:t,tab:n})})};export{Oh as component};
|