@kimuson/claude-code-viewer 0.4.9 → 0.4.10
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/dist/main.js +18 -22
- package/dist/main.js.map +2 -2
- package/dist/static/assets/{ProtectedRoute-DZMKEulP.js → ProtectedRoute-CdwJtygx.js} +1 -1
- package/dist/static/assets/{eye-DJLA18Vn.js → eye-vRHkOT2Y.js} +1 -1
- package/dist/static/assets/{index-vwZSVRGy.js → index-BENMSEhP.js} +1 -1
- package/dist/static/assets/{index-Ci8QWeAx.js → index-CKGQ--tS.js} +1 -1
- package/dist/static/assets/{index-BGKS2Bbu.js → index-DnV70LdM.js} +3 -3
- package/dist/static/assets/{label-Mpn74N-5.js → label-CMEANyku.js} +1 -1
- package/dist/static/assets/{login-OzgY3CHO.js → login-CWyt9fyL.js} +1 -1
- package/dist/static/assets/{session-CgidTvX7.js → session-40GpSLiu.js} +2 -2
- package/dist/static/assets/{session-CZ9W8T6v.js → session-h5mv6_Wi.js} +1 -1
- package/dist/static/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as se,Q as wS,y as cc,z as _S,A as NS,E as IS,F as TS,G as F,H as K,J as Eu,K as AS,$ as cb,M as RS,O as CS,P as OS,R as DS,S as LS,U as $S,V as jS,W as MS,X as PS,Y as US,Z as FS,_ as BS,a0 as zS,a1 as qS,a2 as GS,a3 as HS,a4 as VS,a5 as WS,a6 as KS,a7 as YS,a8 as ZS,a9 as XS,aa as JS,ab as QS,ac as eE,ad as tE,ae as nE,af as rE,ag as aE,ah as iE,ai as oE,aj as sE,ak as lE,al as uE,am as cE,an as dE,ao as pE,ap as mE,aq as gE,ar as fE,as as hE,at as bE,au as yE,av as vE,aw as SE,ax as EE,ay as xE,az as kE,aA as wE,aB as _E,aC as NE,aD as IE,aE as TE,aF as AE,aG as RE,aH as CE,aI as OE,aJ as DE,aK as LE,aL as $E,aM as jE,aN as ME,aO as PE,aP as UE,aQ as FE,aR as BE,aS as zE,aT as qE,aU as GE,aV as HE,aW as VE,aX as WE,aY as KE,aZ as YE,a_ as ZE,a$ as XE,b0 as JE,b1 as QE,b2 as ex,b3 as tx,b4 as nx,b5 as rx,b6 as ax,b7 as ix,b8 as ox,b9 as sx,ba as lx,bb as ux,bc as cx,bd as dx,be as px,bf as mx,bg as gx,bh as fx,bi as hx,bj as bx,bk as yx,bl as db,bm as vx,bn as pb,bo as mb,bp as Sx,bq as gb,br as fb,bs as Ex,bt as xx,bu as kx,bv as wx,bw as _x,bx as Nx,by as Ix,bz as Tx,bA as Ax,bB as Rx,bC as hb,bD as bb,bE as yb,bF as vb,bG as Sb,bH as Cx,bI as Ox,bJ as Dx,bK as Lx,bL as $x,bM as jx,bN as Mx,bO as Px,bP as Ux,bQ as Fx,bR as Bx,bS as zx,bT as qx,bU as Eb,bV as Gx,bW as Hx,bX as Vx,bY as Wx,bZ as xb,b_ as Ql,b$ as Kx,c0 as kb,c1 as Yx,c2 as Zx,c3 as Xx,c4 as Jx,c5 as Qx,c6 as ek,c7 as tk,c8 as nk,c9 as rk,ca as ak,cb as ik,cc as ok,cd as sk,ce as wb,cf as lk,cg as _b,ch as Nb,ci as eu,cj as uk,ck,cl as Ib,cm as Tb,cn as Ab,co as Rb,cp as Cb,cq as Ob,cr as dk,cs as pk,ct as mk,cu as Db,cv as gk,cw as Lb,cx as fk,cy as $b,cz as jb,cA as hk,cB as bk,cC as yk,cD as vk,cE as Mb,cF as Sk,cG as Ek,cH as xk,cI as Pb,cJ as kk,cK as Ub,cL as wk,cM as _k,cN as Nk,cO as Fb,cP as Ik,cQ as Tk,cR as Ak,cS as Rk,cT as Ck,cU as Ok,cV as Dk,cW as Bb,cX as zb,cY as qb,cZ as Lk,c_ as $k,c$ as jk,d0 as Mk,d1 as Pk,d2 as Uk,d3 as Fk,d4 as Gb,d5 as Hb,d6 as Bk,d7 as Vb,d8 as zk,d9 as qk,da as Gk,db as Hk,dc as Vk,dd as Wk,de as Kk,df as Wb,dg as Yk,dh as Zk,di as Xk,dj as Jk,dk as Qk,dl as ew,dm as tw,dn as Kb,dp as un,dq as nw,dr as rw,ds as aw,dt as iw,du as ow,dv as Yb,dw as Zb,dx as sw,dy as lw,dz as uw,dA as cw,dB as dw,dC as pw,dD as mw,dE as Xb,dF as Jb,dG as Qb,dH as gw,dI as fw,dJ as hw,dK as bw,dL as yw,dM as vw,dN as Sw,dO as ey,dP as ty,dQ as Ew,dR as ny,dS as ry,dT as ay,dU as iy,dV as oy,dW as xw,dX as kw,dY as ww,dZ as _w,d_ as Nw,d$ as Iw,e0 as Tw,e1 as Aw,e2 as Rw,e3 as Cw,e4 as Ow,e5 as Dw,e6 as Lw,e7 as $w,e8 as jw,e9 as Mw,ea as Pw,eb as Uw,ec as Fw,ed as Bw,ee as zw,ef as qw,eg as Gw,eh as Hw,ei as Vw,ej as Ww,ek as Kw,el as Yw,em as Zw,en as Xw,eo as Jw,ep as Qw,eq as e_,er as t_,es as n_,et as r_,eu as a_,ev as i_,ew as o_,ex as s_,ey as l_,ez as u_,eA as c_,eB as d_,eC as p_,eD as m_,eE as g_,eF as f_,eG as h_,eH as b_,eI as y_,eJ as v_,eK as S_,eL as E_,eM as x_,eN as k_,eO as w_,eP as __,eQ as N_,eR as I_,eS as T_,eT as A_,eU as R_,eV as C_,eW as O_,eX as D_,eY as L_,eZ as $_,e_ as j_,e$ as dc,f0 as M_,f1 as tu,f2 as P_,f3 as U_,f4 as F_,f5 as B_,f6 as z_,f7 as q_,f8 as G_,f9 as H_,fa as V_,fb as W_,fc as K_,fd as Y_,fe as Z_,ff as X_,fg as J_,fh as Q_,fi as eN,fj as tN,fk as nN,fl as rN,fm as aN,fn as iN,fo as Nn,fp as oN,fq as sN,fr as lN,fs as uN,ft as cN,fu as dN,fv as pN,fw as mN,fx as gN,fy as fN,fz as hN,fA as bN,fB as yN,fC as vN,fD as SN,fE as EN,fF as xN,fG as kN,fH as wN,fI as _N,fJ as NN,fK as ct,fL as IN,fM as TN,fN as AN,fO as RN,fP as CN,fQ as ON,fR as DN,fS as LN,fT as $N,fU as jN,fV as MN,fW as PN,fX as UN,fY as Je,fZ as FN,f_ as BN,f$ as zN,g0 as qN,g1 as GN,g2 as HN,g3 as VN,g4 as WN,g5 as KN,g6 as YN,g7 as ZN,g8 as XN,g9 as JN,ga as QN,gb as eI,gc as tI,gd as nI,ge as rI,gf as aI,gg as He,gh as iI,gi as oI,gj as sI,gk as lI,gl as uI,gm as cI,gn as dI,go as pI,gp as mI,gq as gI,gr as fI,gs as hI,gt as xu,gu as bI,gv as yI,gw as vI,gx as SI,gy as EI,gz as xI,gA as kI,gB as wI,gC as pc,k as Pt,m as et,n as ze,gD as mc,r as O,h as kt,j as s,D as cn,q as dn,s as jn,v as Mn,w as Pn,B as re,gE as _I,gF as NI,gG as II,gH as sy,gI as ly,gJ as Jt,gK as uy,gL as TI,gM as AI,gN as RI,gO as CI,gP as OI,gQ as DI,gR as LI,gS as ce,gT as $I,t as de,gU as In,g as jI,gV as gc,gW as cy,gX as ft,gY as Tn,gZ as ku,g_ as dy,o as MI,T as R,g$ as pn,L as Tt,h0 as PI,C as ut,b as nn,d as rn,f as fc,h1 as nu,e as hc,h2 as UI,h3 as FI,h4 as BI,h5 as Ke,a as py,h6 as wu,h7 as Un,h8 as bc,h9 as yc,I as ht,ha as my,hb as Xn,hc as zI,i as An,hd as qI,x as gy,he as vc,hf as GI}from"./index-
|
|
1
|
+
import{c as se,Q as wS,y as cc,z as _S,A as NS,E as IS,F as TS,G as F,H as K,J as Eu,K as AS,$ as cb,M as RS,O as CS,P as OS,R as DS,S as LS,U as $S,V as jS,W as MS,X as PS,Y as US,Z as FS,_ as BS,a0 as zS,a1 as qS,a2 as GS,a3 as HS,a4 as VS,a5 as WS,a6 as KS,a7 as YS,a8 as ZS,a9 as XS,aa as JS,ab as QS,ac as eE,ad as tE,ae as nE,af as rE,ag as aE,ah as iE,ai as oE,aj as sE,ak as lE,al as uE,am as cE,an as dE,ao as pE,ap as mE,aq as gE,ar as fE,as as hE,at as bE,au as yE,av as vE,aw as SE,ax as EE,ay as xE,az as kE,aA as wE,aB as _E,aC as NE,aD as IE,aE as TE,aF as AE,aG as RE,aH as CE,aI as OE,aJ as DE,aK as LE,aL as $E,aM as jE,aN as ME,aO as PE,aP as UE,aQ as FE,aR as BE,aS as zE,aT as qE,aU as GE,aV as HE,aW as VE,aX as WE,aY as KE,aZ as YE,a_ as ZE,a$ as XE,b0 as JE,b1 as QE,b2 as ex,b3 as tx,b4 as nx,b5 as rx,b6 as ax,b7 as ix,b8 as ox,b9 as sx,ba as lx,bb as ux,bc as cx,bd as dx,be as px,bf as mx,bg as gx,bh as fx,bi as hx,bj as bx,bk as yx,bl as db,bm as vx,bn as pb,bo as mb,bp as Sx,bq as gb,br as fb,bs as Ex,bt as xx,bu as kx,bv as wx,bw as _x,bx as Nx,by as Ix,bz as Tx,bA as Ax,bB as Rx,bC as hb,bD as bb,bE as yb,bF as vb,bG as Sb,bH as Cx,bI as Ox,bJ as Dx,bK as Lx,bL as $x,bM as jx,bN as Mx,bO as Px,bP as Ux,bQ as Fx,bR as Bx,bS as zx,bT as qx,bU as Eb,bV as Gx,bW as Hx,bX as Vx,bY as Wx,bZ as xb,b_ as Ql,b$ as Kx,c0 as kb,c1 as Yx,c2 as Zx,c3 as Xx,c4 as Jx,c5 as Qx,c6 as ek,c7 as tk,c8 as nk,c9 as rk,ca as ak,cb as ik,cc as ok,cd as sk,ce as wb,cf as lk,cg as _b,ch as Nb,ci as eu,cj as uk,ck,cl as Ib,cm as Tb,cn as Ab,co as Rb,cp as Cb,cq as Ob,cr as dk,cs as pk,ct as mk,cu as Db,cv as gk,cw as Lb,cx as fk,cy as $b,cz as jb,cA as hk,cB as bk,cC as yk,cD as vk,cE as Mb,cF as Sk,cG as Ek,cH as xk,cI as Pb,cJ as kk,cK as Ub,cL as wk,cM as _k,cN as Nk,cO as Fb,cP as Ik,cQ as Tk,cR as Ak,cS as Rk,cT as Ck,cU as Ok,cV as Dk,cW as Bb,cX as zb,cY as qb,cZ as Lk,c_ as $k,c$ as jk,d0 as Mk,d1 as Pk,d2 as Uk,d3 as Fk,d4 as Gb,d5 as Hb,d6 as Bk,d7 as Vb,d8 as zk,d9 as qk,da as Gk,db as Hk,dc as Vk,dd as Wk,de as Kk,df as Wb,dg as Yk,dh as Zk,di as Xk,dj as Jk,dk as Qk,dl as ew,dm as tw,dn as Kb,dp as un,dq as nw,dr as rw,ds as aw,dt as iw,du as ow,dv as Yb,dw as Zb,dx as sw,dy as lw,dz as uw,dA as cw,dB as dw,dC as pw,dD as mw,dE as Xb,dF as Jb,dG as Qb,dH as gw,dI as fw,dJ as hw,dK as bw,dL as yw,dM as vw,dN as Sw,dO as ey,dP as ty,dQ as Ew,dR as ny,dS as ry,dT as ay,dU as iy,dV as oy,dW as xw,dX as kw,dY as ww,dZ as _w,d_ as Nw,d$ as Iw,e0 as Tw,e1 as Aw,e2 as Rw,e3 as Cw,e4 as Ow,e5 as Dw,e6 as Lw,e7 as $w,e8 as jw,e9 as Mw,ea as Pw,eb as Uw,ec as Fw,ed as Bw,ee as zw,ef as qw,eg as Gw,eh as Hw,ei as Vw,ej as Ww,ek as Kw,el as Yw,em as Zw,en as Xw,eo as Jw,ep as Qw,eq as e_,er as t_,es as n_,et as r_,eu as a_,ev as i_,ew as o_,ex as s_,ey as l_,ez as u_,eA as c_,eB as d_,eC as p_,eD as m_,eE as g_,eF as f_,eG as h_,eH as b_,eI as y_,eJ as v_,eK as S_,eL as E_,eM as x_,eN as k_,eO as w_,eP as __,eQ as N_,eR as I_,eS as T_,eT as A_,eU as R_,eV as C_,eW as O_,eX as D_,eY as L_,eZ as $_,e_ as j_,e$ as dc,f0 as M_,f1 as tu,f2 as P_,f3 as U_,f4 as F_,f5 as B_,f6 as z_,f7 as q_,f8 as G_,f9 as H_,fa as V_,fb as W_,fc as K_,fd as Y_,fe as Z_,ff as X_,fg as J_,fh as Q_,fi as eN,fj as tN,fk as nN,fl as rN,fm as aN,fn as iN,fo as Nn,fp as oN,fq as sN,fr as lN,fs as uN,ft as cN,fu as dN,fv as pN,fw as mN,fx as gN,fy as fN,fz as hN,fA as bN,fB as yN,fC as vN,fD as SN,fE as EN,fF as xN,fG as kN,fH as wN,fI as _N,fJ as NN,fK as ct,fL as IN,fM as TN,fN as AN,fO as RN,fP as CN,fQ as ON,fR as DN,fS as LN,fT as $N,fU as jN,fV as MN,fW as PN,fX as UN,fY as Je,fZ as FN,f_ as BN,f$ as zN,g0 as qN,g1 as GN,g2 as HN,g3 as VN,g4 as WN,g5 as KN,g6 as YN,g7 as ZN,g8 as XN,g9 as JN,ga as QN,gb as eI,gc as tI,gd as nI,ge as rI,gf as aI,gg as He,gh as iI,gi as oI,gj as sI,gk as lI,gl as uI,gm as cI,gn as dI,go as pI,gp as mI,gq as gI,gr as fI,gs as hI,gt as xu,gu as bI,gv as yI,gw as vI,gx as SI,gy as EI,gz as xI,gA as kI,gB as wI,gC as pc,k as Pt,m as et,n as ze,gD as mc,r as O,h as kt,j as s,D as cn,q as dn,s as jn,v as Mn,w as Pn,B as re,gE as _I,gF as NI,gG as II,gH as sy,gI as ly,gJ as Jt,gK as uy,gL as TI,gM as AI,gN as RI,gO as CI,gP as OI,gQ as DI,gR as LI,gS as ce,gT as $I,t as de,gU as In,g as jI,gV as gc,gW as cy,gX as ft,gY as Tn,gZ as ku,g_ as dy,o as MI,T as R,g$ as pn,L as Tt,h0 as PI,C as ut,b as nn,d as rn,f as fc,h1 as nu,e as hc,h2 as UI,h3 as FI,h4 as BI,h5 as Ke,a as py,h6 as wu,h7 as Un,h8 as bc,h9 as yc,I as ht,ha as my,hb as Xn,hc as zI,i as An,hd as qI,x as gy,he as vc,hf as GI}from"./index-DnV70LdM.js";import{B as pe,f as _u,c as Le,d as We,e as $e,a as fy,g as je,h as hy,R as HI,A as by,i as VI,j as WI,n as KI,s as YI,p as ZI,k as XI,l as JI,C as QI,S as Ot,m as Dt,o as Lt,q as $t,r as Ve,P as Nu,t as yy,F as eT,T as Ye,u as Ze,v as Xe,I as vy,L as an,w as Sy,x as tT,y as nT,z as rT,N as aT,G as iT,b as oT}from"./ProtectedRoute-CdwJtygx.js";import{E as sT}from"./eye-vRHkOT2Y.js";import{L as Ie}from"./label-CMEANyku.js";/**
|
|
2
2
|
* @license lucide-react v0.548.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -179,4 +179,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
179
179
|
`,...i.current()});return/^[\t ]/.test(c)&&(c=ln(c.charCodeAt(0))+c.slice(1)),c=c?o+" "+c:o,r.options.closeAtx&&(c+=" "+o),u(),l(),c}Vv.peek=kB;function Vv(e){return e.value||""}function kB(){return"<"}Wv.peek=wB;function Wv(e,n,r,a){const t=nc(r),i=t==='"'?"Quote":"Apostrophe",o=r.enter("image");let l=r.enter("label");const u=r.createTracker(a);let c=u.move("![");return c+=u.move(r.safe(e.alt,{before:c,after:"]",...u.current()})),c+=u.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=r.enter("destinationLiteral"),c+=u.move("<"),c+=u.move(r.safe(e.url,{before:c,after:">",...u.current()})),c+=u.move(">")):(l=r.enter("destinationRaw"),c+=u.move(r.safe(e.url,{before:c,after:e.title?" ":")",...u.current()}))),l(),e.title&&(l=r.enter(`title${i}`),c+=u.move(" "+t),c+=u.move(r.safe(e.title,{before:c,after:t,...u.current()})),c+=u.move(t),l()),c+=u.move(")"),o(),c}function wB(){return"!"}Kv.peek=_B;function Kv(e,n,r,a){const t=e.referenceType,i=r.enter("imageReference");let o=r.enter("label");const l=r.createTracker(a);let u=l.move("![");const c=r.safe(e.alt,{before:u,after:"]",...l.current()});u+=l.move(c+"]["),o();const p=r.stack;r.stack=[],o=r.enter("reference");const d=r.safe(r.associationId(e),{before:u,after:"]",...l.current()});return o(),r.stack=p,i(),t==="full"||!c||c!==d?u+=l.move(d+"]"):t==="shortcut"?u=u.slice(0,-1):u+=l.move("]"),u}function _B(){return"!"}Yv.peek=NB;function Yv(e,n,r){let a=e.value||"",t="`",i=-1;for(;new RegExp("(^|[^`])"+t+"([^`]|$)").test(a);)t+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++i<r.unsafe.length;){const o=r.unsafe[i],l=r.compilePattern(o);let u;if(o.atBreak)for(;u=l.exec(a);){let c=u.index;a.charCodeAt(c)===10&&a.charCodeAt(c-1)===13&&c--,a=a.slice(0,c)+" "+a.slice(u.index+1)}}return t+a+t}function NB(){return"`"}function Zv(e,n){const r=Wu(e);return!!(!n.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(r===e.url||"mailto:"+r===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Xv.peek=IB;function Xv(e,n,r,a){const t=nc(r),i=t==='"'?"Quote":"Apostrophe",o=r.createTracker(a);let l,u;if(Zv(e,r)){const p=r.stack;r.stack=[],l=r.enter("autolink");let d=o.move("<");return d+=o.move(r.containerPhrasing(e,{before:d,after:">",...o.current()})),d+=o.move(">"),l(),r.stack=p,d}l=r.enter("link"),u=r.enter("label");let c=o.move("[");return c+=o.move(r.containerPhrasing(e,{before:c,after:"](",...o.current()})),c+=o.move("]("),u(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(u=r.enter("destinationLiteral"),c+=o.move("<"),c+=o.move(r.safe(e.url,{before:c,after:">",...o.current()})),c+=o.move(">")):(u=r.enter("destinationRaw"),c+=o.move(r.safe(e.url,{before:c,after:e.title?" ":")",...o.current()}))),u(),e.title&&(u=r.enter(`title${i}`),c+=o.move(" "+t),c+=o.move(r.safe(e.title,{before:c,after:t,...o.current()})),c+=o.move(t),u()),c+=o.move(")"),l(),c}function IB(e,n,r){return Zv(e,r)?"<":"["}Jv.peek=TB;function Jv(e,n,r,a){const t=e.referenceType,i=r.enter("linkReference");let o=r.enter("label");const l=r.createTracker(a);let u=l.move("[");const c=r.containerPhrasing(e,{before:u,after:"]",...l.current()});u+=l.move(c+"]["),o();const p=r.stack;r.stack=[],o=r.enter("reference");const d=r.safe(r.associationId(e),{before:u,after:"]",...l.current()});return o(),r.stack=p,i(),t==="full"||!c||c!==d?u+=l.move(d+"]"):t==="shortcut"?u=u.slice(0,-1):u+=l.move("]"),u}function TB(){return"["}function rc(e){const n=e.options.bullet||"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bullet`, expected `*`, `+`, or `-`");return n}function AB(e){const n=rc(e),r=e.options.bulletOther;if(!r)return n==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+r+"`) to be different");return r}function RB(e){const n=e.options.bulletOrdered||".";if(n!=="."&&n!==")")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOrdered`, expected `.` or `)`");return n}function Qv(e){const n=e.options.rule||"*";if(n!=="*"&&n!=="-"&&n!=="_")throw new Error("Cannot serialize rules with `"+n+"` for `options.rule`, expected `*`, `-`, or `_`");return n}function CB(e,n,r,a){const t=r.enter("list"),i=r.bulletCurrent;let o=e.ordered?RB(r):rc(r);const l=e.ordered?o==="."?")":".":AB(r);let u=n&&r.bulletLastUsed?o===r.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&p&&(!p.children||!p.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(u=!0),Qv(r)===o&&p){let d=-1;for(;++d<e.children.length;){const g=e.children[d];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){u=!0;break}}}}u&&(o=l),r.bulletCurrent=o;const c=r.containerFlow(e,a);return r.bulletLastUsed=o,r.bulletCurrent=i,t(),c}function OB(e){const n=e.options.listItemIndent||"one";if(n!=="tab"&&n!=="one"&&n!=="mixed")throw new Error("Cannot serialize items with `"+n+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return n}function DB(e,n,r,a){const t=OB(r);let i=r.bulletCurrent||rc(r);n&&n.type==="list"&&n.ordered&&(i=(typeof n.start=="number"&&n.start>-1?n.start:1)+(r.options.incrementListMarker===!1?0:n.children.indexOf(e))+i);let o=i.length+1;(t==="tab"||t==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(o=Math.ceil(o/4)*4);const l=r.createTracker(a);l.move(i+" ".repeat(o-i.length)),l.shift(o);const u=r.enter("listItem"),c=r.indentLines(r.containerFlow(e,l.current()),p);return u(),c;function p(d,g,m){return g?(m?"":" ".repeat(o))+d:(m?i:i+" ".repeat(o-i.length))+d}}function LB(e,n,r,a){const t=r.enter("paragraph"),i=r.enter("phrasing"),o=r.containerPhrasing(e,a);return i(),t(),o}const $B=Kn(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function jB(e,n,r,a){return(e.children.some(function(o){return $B(o)})?r.containerPhrasing:r.containerFlow).call(r,e,a)}function MB(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}eS.peek=PB;function eS(e,n,r,a){const t=MB(r),i=r.enter("strong"),o=r.createTracker(a),l=o.move(t+t);let u=o.move(r.containerPhrasing(e,{after:t,before:l,...o.current()}));const c=u.charCodeAt(0),p=$n(a.before.charCodeAt(a.before.length-1),c,t);p.inside&&(u=ln(c)+u.slice(1));const d=u.charCodeAt(u.length-1),g=$n(a.after.charCodeAt(0),d,t);g.inside&&(u=u.slice(0,-1)+ln(d));const m=o.move(t+t);return i(),r.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},l+u+m}function PB(e,n,r){return r.options.strong||"*"}function UB(e,n,r,a){return r.safe(e.value,a)}function FB(e){const n=e.options.ruleRepetition||3;if(n<3)throw new Error("Cannot serialize rules with repetition `"+n+"` for `options.ruleRepetition`, expected `3` or more");return n}function BB(e,n,r){const a=(Qv(r)+(r.options.ruleSpaces?" ":"")).repeat(FB(r));return r.options.ruleSpaces?a.slice(0,-1):a}const tS={blockquote:cB,break:eb,code:hB,definition:yB,emphasis:Hv,hardBreak:eb,heading:xB,html:Vv,image:Wv,imageReference:Kv,inlineCode:Yv,link:Xv,linkReference:Jv,list:CB,listItem:DB,paragraph:LB,root:jB,strong:eS,text:UB,thematicBreak:BB};function zB(){return{enter:{table:qB,tableData:tb,tableHeader:tb,tableRow:HB},exit:{codeText:VB,table:GB,tableData:Jl,tableHeader:Jl,tableRow:Jl}}}function qB(e){const n=e._align;this.enter({type:"table",align:n.map(function(r){return r==="none"?null:r}),children:[]},e),this.data.inTable=!0}function GB(e){this.exit(e),this.data.inTable=void 0}function HB(e){this.enter({type:"tableRow",children:[]},e)}function Jl(e){this.exit(e)}function tb(e){this.enter({type:"tableCell",children:[]},e)}function VB(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,WB));const r=this.stack[this.stack.length-1];r.type,r.value=n,this.exit(e)}function WB(e,n){return n==="|"?n:e}function KB(e){const n=e||{},r=n.tableCellPadding,a=n.tablePipeAlign,t=n.stringLength,i=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
180
180
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:o,tableCell:u,tableRow:l}};function o(m,f,h,v){return c(p(m,h,v),m.align)}function l(m,f,h,v){const S=d(m,h,v),E=c([S]);return E.slice(0,E.indexOf(`
|
|
181
181
|
`))}function u(m,f,h,v){const S=h.enter("tableCell"),E=h.enter("phrasing"),y=h.containerPhrasing(m,{...v,before:i,after:i});return E(),S(),y}function c(m,f){return lB(m,{align:f,alignDelimiters:a,padding:r,stringLength:t})}function p(m,f,h){const v=m.children;let S=-1;const E=[],y=f.enter("table");for(;++S<v.length;)E[S]=d(v[S],f,h);return y(),E}function d(m,f,h){const v=m.children;let S=-1;const E=[],y=f.enter("tableRow");for(;++S<v.length;)E[S]=u(v[S],m,f,h);return y(),E}function g(m,f,h){let v=tS.inlineCode(m,f,h);return h.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function YB(){return{exit:{taskListCheckValueChecked:nb,taskListCheckValueUnchecked:nb,paragraph:XB}}}function ZB(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:JB}}}function nb(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function XB(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const a=r.children[0];if(a&&a.type==="text"){const t=n.children;let i=-1,o;for(;++i<t.length;){const l=t[i];if(l.type==="paragraph"){o=l;break}}o===r&&(a.value=a.value.slice(1),a.value.length===0?r.children.shift():r.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,r.position.start=Object.assign({},a.position.start)))}}this.exit(e)}function JB(e,n,r,a){const t=e.children[0],i=typeof e.checked=="boolean"&&t&&t.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",l=r.createTracker(a);i&&l.move(o);let u=tS.listItem(e,n,r,{...a,...l.current()});return i&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),u;function c(p){return p+o}}function QB(){return[C2(),J2(),nB(),zB(),YB()]}function e4(e){return{extensions:[O2(),Q2(e),rB(),KB(e),ZB()]}}const t4={tokenize:s4,partial:!0},nS={tokenize:l4,partial:!0},rS={tokenize:u4,partial:!0},aS={tokenize:c4,partial:!0},n4={tokenize:d4,partial:!0},iS={name:"wwwAutolink",tokenize:i4,previous:sS},oS={name:"protocolAutolink",tokenize:o4,previous:lS},dt={name:"emailAutolink",tokenize:a4,previous:uS},at={};function r4(){return{text:at}}let Et=48;for(;Et<123;)at[Et]=dt,Et++,Et===58?Et=65:Et===91&&(Et=97);at[43]=dt;at[45]=dt;at[46]=dt;at[95]=dt;at[72]=[dt,oS];at[104]=[dt,oS];at[87]=[dt,iS];at[119]=[dt,iS];function a4(e,n,r){const a=this;let t,i;return o;function o(d){return!Su(d)||!uS.call(a,a.previous)||ac(a.events)?r(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(d))}function l(d){return Su(d)?(e.consume(d),l):d===64?(e.consume(d),u):r(d)}function u(d){return d===46?e.check(n4,p,c)(d):d===45||d===95||ve(d)?(i=!0,e.consume(d),u):p(d)}function c(d){return e.consume(d),t=!0,u}function p(d){return i&&t&&Te(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(d)):r(d)}}function i4(e,n,r){const a=this;return t;function t(o){return o!==87&&o!==119||!sS.call(a,a.previous)||ac(a.events)?r(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(t4,e.attempt(nS,e.attempt(rS,i),r),r)(o))}function i(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(o)}}function o4(e,n,r){const a=this;let t="",i=!1;return o;function o(d){return(d===72||d===104)&&lS.call(a,a.previous)&&!ac(a.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),t+=String.fromCodePoint(d),e.consume(d),l):r(d)}function l(d){if(Te(d)&&t.length<5)return t+=String.fromCodePoint(d),e.consume(d),l;if(d===58){const g=t.toLowerCase();if(g==="http"||g==="https")return e.consume(d),u}return r(d)}function u(d){return d===47?(e.consume(d),i?c:(i=!0,u)):r(d)}function c(d){return d===null||On(d)||oe(d)||xt(d)||Hn(d)?r(d):e.attempt(nS,e.attempt(rS,p),r)(d)}function p(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(d)}}function s4(e,n,r){let a=0;return t;function t(o){return(o===87||o===119)&&a<3?(a++,e.consume(o),t):o===46&&a===3?(e.consume(o),i):r(o)}function i(o){return o===null?r(o):n(o)}}function l4(e,n,r){let a,t,i;return o;function o(c){return c===46||c===95?e.check(aS,u,l)(c):c===null||oe(c)||xt(c)||c!==45&&Hn(c)?u(c):(i=!0,e.consume(c),o)}function l(c){return c===95?a=!0:(t=a,a=void 0),e.consume(c),o}function u(c){return t||a||!i?r(c):n(c)}}function u4(e,n){let r=0,a=0;return t;function t(o){return o===40?(r++,e.consume(o),t):o===41&&a<r?i(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(aS,n,i)(o):o===null||oe(o)||xt(o)?n(o):(e.consume(o),t)}function i(o){return o===41&&a++,e.consume(o),t}}function c4(e,n,r){return a;function a(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),a):l===38?(e.consume(l),i):l===93?(e.consume(l),t):l===60||l===null||oe(l)||xt(l)?n(l):r(l)}function t(l){return l===null||l===40||l===91||oe(l)||xt(l)?n(l):a(l)}function i(l){return Te(l)?o(l):r(l)}function o(l){return l===59?(e.consume(l),a):Te(l)?(e.consume(l),o):r(l)}}function d4(e,n,r){return a;function a(i){return e.consume(i),t}function t(i){return ve(i)?r(i):n(i)}}function sS(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||oe(e)}function lS(e){return!Te(e)}function uS(e){return!(e===47||Su(e))}function Su(e){return e===43||e===45||e===46||e===95||ve(e)}function ac(e){let n=e.length,r=!1;for(;n--;){const a=e[n][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){r=!0;break}if(a._gfmAutolinkLiteralWalkedInto){r=!1;break}}return e.length>0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const p4={tokenize:S4,partial:!0};function m4(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:b4,continuation:{tokenize:y4},exit:v4}},text:{91:{name:"gfmFootnoteCall",tokenize:h4},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:g4,resolveTo:f4}}}}function g4(e,n,r){const a=this;let t=a.events.length;const i=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let o;for(;t--;){const u=a.events[t][1];if(u.type==="labelImage"){o=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return l;function l(u){if(!o||!o._balanced)return r(u);const c=Qe(a.sliceSerialize({start:o.end,end:a.now()}));return c.codePointAt(0)!==94||!i.includes(c.slice(1))?r(u):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),n(u))}}function f4(e,n){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},t={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};t.end.column++,t.end.offset++,t.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},t.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},l=[e[r+1],e[r+2],["enter",a,n],e[r+3],e[r+4],["enter",t,n],["exit",t,n],["enter",i,n],["enter",o,n],["exit",o,n],["exit",i,n],e[e.length-2],e[e.length-1],["exit",a,n]];return e.splice(r,e.length-r+1,...l),e}function h4(e,n,r){const a=this,t=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let i=0,o;return l;function l(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),u}function u(d){return d!==94?r(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(i>999||d===93&&!o||d===null||d===91||oe(d))return r(d);if(d===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return t.includes(Qe(a.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):r(d)}return oe(d)||(o=!0),i++,e.consume(d),d===92?p:c}function p(d){return d===91||d===92||d===93?(e.consume(d),i++,c):c(d)}}function b4(e,n,r){const a=this,t=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let i,o=0,l;return u;function u(f){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(f),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(f){return f===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(f),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):r(f)}function p(f){if(o>999||f===93&&!l||f===null||f===91||oe(f))return r(f);if(f===93){e.exit("chunkString");const h=e.exit("gfmFootnoteDefinitionLabelString");return i=Qe(a.sliceSerialize(h)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(f),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return oe(f)||(l=!0),o++,e.consume(f),f===92?d:p}function d(f){return f===91||f===92||f===93?(e.consume(f),o++,p):p(f)}function g(f){return f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),t.includes(i)||t.push(i),ae(e,m,"gfmFootnoteDefinitionWhitespace")):r(f)}function m(f){return n(f)}}function y4(e,n,r){return e.check(hn,n,e.attempt(p4,n,r))}function v4(e){e.exit("gfmFootnoteDefinition")}function S4(e,n,r){const a=this;return ae(e,t,"gfmFootnoteDefinitionIndent",5);function t(i){const o=a.events[a.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?n(i):r(i)}}function E4(e){let r=(e||{}).singleTilde;const a={name:"strikethrough",tokenize:i,resolveAll:t};return r==null&&(r=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function t(o,l){let u=-1;for(;++u<o.length;)if(o[u][0]==="enter"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._close){let c=u;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[u][1].end.offset-o[u][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[u][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[u][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[u][1].start)},g=[["enter",p,l],["enter",o[c][1],l],["exit",o[c][1],l],["enter",d,l]],m=l.parser.constructs.insideSpan.null;m&&Be(g,g.length,0,Vn(m,o.slice(c+1,u),l)),Be(g,g.length,0,[["exit",d,l],["enter",o[u][1],l],["exit",o[u][1],l],["exit",p,l]]),Be(o,c-1,u-c+3,g),u=c+g.length-2;break}}for(u=-1;++u<o.length;)o[u][1].type==="strikethroughSequenceTemporary"&&(o[u][1].type="data");return o}function i(o,l,u){const c=this.previous,p=this.events;let d=0;return g;function g(f){return c===126&&p[p.length-1][1].type!=="characterEscape"?u(f):(o.enter("strikethroughSequenceTemporary"),m(f))}function m(f){const h=Mt(c);if(f===126)return d>1?u(f):(o.consume(f),d++,m);if(d<2&&!r)return u(f);const v=o.exit("strikethroughSequenceTemporary"),S=Mt(f);return v._open=!S||S===2&&!!h,v._close=!h||h===2&&!!S,l(f)}}}class x4{constructor(){this.map=[]}add(n,r,a){k4(this,n,r,a)}consume(n){if(this.map.sort(function(i,o){return i[0]-o[0]}),this.map.length===0)return;let r=this.map.length;const a=[];for(;r>0;)r-=1,a.push(n.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),n.length=this.map[r][0];a.push(n.slice()),n.length=0;let t=a.pop();for(;t;){for(const i of t)n.push(i);t=a.pop()}this.map.length=0}}function k4(e,n,r,a){let t=0;if(!(r===0&&a.length===0)){for(;t<e.map.length;){if(e.map[t][0]===n){e.map[t][1]+=r,e.map[t][2].push(...a);return}t+=1}e.map.push([n,r,a])}}function w4(e,n){let r=!1;const a=[];for(;n<e.length;){const t=e[n];if(r){if(t[0]==="enter")t[1].type==="tableContent"&&a.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(t[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const i=a.length-1;a[i]=a[i]==="left"?"center":"right"}}else if(t[1].type==="tableDelimiterRow")break}else t[0]==="enter"&&t[1].type==="tableDelimiterRow"&&(r=!0);n+=1}return a}function _4(){return{flow:{null:{name:"table",tokenize:N4,resolveAll:I4}}}}function N4(e,n,r){const a=this;let t=0,i=0,o;return l;function l(k){let A=a.events.length-1;for(;A>-1;){const P=a.events[A][1].type;if(P==="lineEnding"||P==="linePrefix")A--;else break}const j=A>-1?a.events[A][1].type:null,$=j==="tableHead"||j==="tableRow"?b:u;return $===b&&a.parser.lazy[a.now().line]?r(k):$(k)}function u(k){return e.enter("tableHead"),e.enter("tableRow"),c(k)}function c(k){return k===124||(o=!0,i+=1),p(k)}function p(k){return k===null?r(k):V(k)?i>1?(i=0,a.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),m):r(k):ne(k)?ae(e,p,"whitespace")(k):(i+=1,o&&(o=!1,t+=1),k===124?(e.enter("tableCellDivider"),e.consume(k),e.exit("tableCellDivider"),o=!0,p):(e.enter("data"),d(k)))}function d(k){return k===null||k===124||oe(k)?(e.exit("data"),p(k)):(e.consume(k),k===92?g:d)}function g(k){return k===92||k===124?(e.consume(k),d):d(k)}function m(k){return a.interrupt=!1,a.parser.lazy[a.now().line]?r(k):(e.enter("tableDelimiterRow"),o=!1,ne(k)?ae(e,f,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):f(k))}function f(k){return k===45||k===58?v(k):k===124?(o=!0,e.enter("tableCellDivider"),e.consume(k),e.exit("tableCellDivider"),h):I(k)}function h(k){return ne(k)?ae(e,v,"whitespace")(k):v(k)}function v(k){return k===58?(i+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(k),e.exit("tableDelimiterMarker"),S):k===45?(i+=1,S(k)):k===null||V(k)?w(k):I(k)}function S(k){return k===45?(e.enter("tableDelimiterFiller"),E(k)):I(k)}function E(k){return k===45?(e.consume(k),E):k===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(k),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(k))}function y(k){return ne(k)?ae(e,w,"whitespace")(k):w(k)}function w(k){return k===124?f(k):k===null||V(k)?!o||t!==i?I(k):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(k)):I(k)}function I(k){return r(k)}function b(k){return e.enter("tableRow"),T(k)}function T(k){return k===124?(e.enter("tableCellDivider"),e.consume(k),e.exit("tableCellDivider"),T):k===null||V(k)?(e.exit("tableRow"),n(k)):ne(k)?ae(e,T,"whitespace")(k):(e.enter("data"),D(k))}function D(k){return k===null||k===124||oe(k)?(e.exit("data"),T(k)):(e.consume(k),k===92?_:D)}function _(k){return k===92||k===124?(e.consume(k),D):D(k)}}function I4(e,n){let r=-1,a=!0,t=0,i=[0,0,0,0],o=[0,0,0,0],l=!1,u=0,c,p,d;const g=new x4;for(;++r<e.length;){const m=e[r],f=m[1];m[0]==="enter"?f.type==="tableHead"?(l=!1,u!==0&&(rb(g,n,u,c,p),p=void 0,u=0),c={type:"table",start:Object.assign({},f.start),end:Object.assign({},f.end)},g.add(r,0,[["enter",c,n]])):f.type==="tableRow"||f.type==="tableDelimiterRow"?(a=!0,d=void 0,i=[0,0,0,0],o=[0,r+1,0,0],l&&(l=!1,p={type:"tableBody",start:Object.assign({},f.start),end:Object.assign({},f.end)},g.add(r,0,[["enter",p,n]])),t=f.type==="tableDelimiterRow"?2:p?3:1):t&&(f.type==="data"||f.type==="tableDelimiterMarker"||f.type==="tableDelimiterFiller")?(a=!1,o[2]===0&&(i[1]!==0&&(o[0]=o[1],d=kn(g,n,i,t,void 0,d),i=[0,0,0,0]),o[2]=r)):f.type==="tableCellDivider"&&(a?a=!1:(i[1]!==0&&(o[0]=o[1],d=kn(g,n,i,t,void 0,d)),i=o,o=[i[1],r,0,0])):f.type==="tableHead"?(l=!0,u=r):f.type==="tableRow"||f.type==="tableDelimiterRow"?(u=r,i[1]!==0?(o[0]=o[1],d=kn(g,n,i,t,r,d)):o[1]!==0&&(d=kn(g,n,o,t,r,d)),t=0):t&&(f.type==="data"||f.type==="tableDelimiterMarker"||f.type==="tableDelimiterFiller")&&(o[3]=r)}for(u!==0&&rb(g,n,u,c,p),g.consume(n.events),r=-1;++r<n.events.length;){const m=n.events[r];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=w4(n.events,r))}return e}function kn(e,n,r,a,t,i){const o=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",l="tableContent";r[0]!==0&&(i.end=Object.assign({},At(n.events,r[0])),e.add(r[0],0,[["exit",i,n]]));const u=At(n.events,r[1]);if(i={type:o,start:Object.assign({},u),end:Object.assign({},u)},e.add(r[1],0,[["enter",i,n]]),r[2]!==0){const c=At(n.events,r[2]),p=At(n.events,r[3]),d={type:l,start:Object.assign({},c),end:Object.assign({},p)};if(e.add(r[2],0,[["enter",d,n]]),a!==2){const g=n.events[r[2]],m=n.events[r[3]];if(g[1].end=Object.assign({},m[1].end),g[1].type="chunkText",g[1].contentType="text",r[3]>r[2]+1){const f=r[2]+1,h=r[3]-r[2]-1;e.add(f,h,[])}}e.add(r[3]+1,0,[["exit",d,n]])}return t!==void 0&&(i.end=Object.assign({},At(n.events,t)),e.add(t,0,[["exit",i,n]]),i=void 0),i}function rb(e,n,r,a,t){const i=[],o=At(n.events,r);t&&(t.end=Object.assign({},o),i.push(["exit",t,n])),a.end=Object.assign({},o),i.push(["exit",a,n]),e.add(r+1,0,i)}function At(e,n){const r=e[n],a=r[0]==="enter"?"start":"end";return r[1][a]}const T4={name:"tasklistCheck",tokenize:R4};function A4(){return{text:{91:T4}}}function R4(e,n,r){const a=this;return t;function t(u){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?r(u):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),i)}function i(u){return oe(u)?(e.enter("taskListCheckValueUnchecked"),e.consume(u),e.exit("taskListCheckValueUnchecked"),o):u===88||u===120?(e.enter("taskListCheckValueChecked"),e.consume(u),e.exit("taskListCheckValueChecked"),o):r(u)}function o(u){return u===93?(e.enter("taskListCheckMarker"),e.consume(u),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):r(u)}function l(u){return V(u)?n(u):ne(u)?e.check({tokenize:C4},n,r)(u):r(u)}}function C4(e,n,r){return ae(e,a,"whitespace");function a(t){return t===null?r(t):n(t)}}function O4(e){return Sv([r4(),m4(),E4(e),_4(),A4()])}const D4={};function L4(e){const n=this,r=e||D4,a=n.data(),t=a.micromarkExtensions||(a.micromarkExtensions=[]),i=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),o=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);t.push(O4(r)),i.push(QB()),o.push(e4(r))}const cS=({content:e,className:n=""})=>{const{resolvedTheme:r}=dy(),a=r==="dark"?av:iv;return s.jsx("div",{className:`prose prose-neutral dark:prose-invert max-w-none ${n}`,children:s.jsx(E2,{remarkPlugins:[L4],components:{h1({children:t,...i}){return s.jsx("h1",{className:"text-3xl font-bold mb-6 mt-8 pb-3 border-b border-border text-foreground",...i,children:t})},h2({children:t,...i}){return s.jsx("h2",{className:"text-2xl font-semibold mb-4 mt-8 pb-2 border-b border-border/50 text-foreground",...i,children:t})},h3({children:t,...i}){return s.jsx("h3",{className:"text-xl font-semibold mb-3 mt-6 text-foreground",...i,children:t})},h4({children:t,...i}){return s.jsx("h4",{className:"text-lg font-medium mb-2 mt-4 text-foreground",...i,children:t})},h5({children:t,...i}){return s.jsx("h5",{className:"text-base font-medium mb-2 mt-4 text-foreground",...i,children:t})},h6({children:t,...i}){return s.jsx("h6",{className:"text-sm font-medium mb-2 mt-4 text-muted-foreground",...i,children:t})},p({children:t,...i}){return s.jsx("p",{className:"mb-4 leading-7 text-foreground break-all",...i,children:t})},ul({children:t,...i}){return s.jsx("ul",{className:"mb-4 ml-6 list-disc space-y-2",...i,children:t})},ol({children:t,...i}){return s.jsx("ol",{className:"mb-4 ml-6 list-decimal space-y-2",...i,children:t})},li({children:t,...i}){return s.jsx("li",{className:"leading-7 text-foreground",...i,children:t})},code({className:t,children:i,...o}){const l=/language-(\w+)/.exec(t||"");return l?s.jsxs("div",{className:"relative my-6",children:[s.jsx("div",{className:"flex items-center justify-between bg-muted/30 px-4 py-2 border-b border-border rounded-t-lg",children:s.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:l[1]})}),s.jsx(Fu,{style:a,language:l[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:String(i).replace(/\n$/,"")})]}):s.jsx("code",{className:"bg-muted/70 px-2 py-1 rounded-md text-sm font-mono text-foreground border break-all",...o,children:i})},pre({children:t,...i}){return s.jsx("pre",{...i,children:t})},blockquote({children:t,...i}){return s.jsx("blockquote",{className:"border-l-4 border-primary/30 bg-muted/30 pl-6 pr-4 py-4 my-6 italic rounded-r-lg",...i,children:s.jsx("div",{className:"text-muted-foreground",children:t})})},a({children:t,href:i,...o}){return s.jsx("a",{href:i,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",...o,children:t})},table({children:t,...i}){return s.jsx("div",{className:"overflow-x-auto my-6 rounded-lg border border-border max-w-full",children:s.jsx("table",{className:"w-full border-collapse",...i,children:t})})},thead({children:t,...i}){return s.jsx("thead",{className:"bg-muted/50",...i,children:t})},th({children:t,...i}){return s.jsx("th",{className:"border-b border-border px-4 py-3 text-left font-semibold text-foreground",...i,children:t})},td({children:t,...i}){return s.jsx("td",{className:"border-b border-border px-4 py-3 text-foreground",...i,children:t})},hr({...t}){return s.jsx("hr",{className:"my-8 border-t border-border",...t})},strong({children:t,...i}){return s.jsx("strong",{className:"font-semibold text-foreground",...i,children:t})},em({children:t,...i}){return s.jsx("em",{className:"italic text-foreground",...i,children:t})}},children:e})})},$4=e=>e.type!=="user"?null:typeof e.message.content=="string"?e.message.content:(()=>{const r=e.message.content.at(0);return r===void 0?null:typeof r=="string"?r:r.type==="text"?r.text:null})(),j4=({prompt:e,projectId:n,sessionId:r,agentId:a,getSidechainConversationByPrompt:t,getSidechainConversations:i,getToolResult:o})=>{const[l,u]=O.useState(!1),c=t(e),p=c!==void 0?i(c.uuid):[],d=p.length>0,g=l&&!d&&a!==void 0,{data:m,isLoading:f,error:h,refetch:v}=Pt({...PI(n,a??""),enabled:g,staleTime:0}),S=d?p.map(k=>({...k,isSidechain:!1})):m?.conversations??[],E=d?void 0:m?.agentSessionId,y=d?c?.uuid:E,w=(()=>{const k=S.at(0);return k?$4(k)??e:e.length>60?`${e.slice(0,60)}...`:e})(),I=g&&f,b=g&&h!==null,T=!I&&!b&&S.length===0&&l,D=!I&&!b&&S.length>0,_=O.useMemo(()=>S.find(k=>k.type==="user"||k.type==="assistant"||k.type==="system"),[S]);return s.jsxs(cn,{open:l,onOpenChange:u,children:[s.jsx(MI,{asChild:!0,children:s.jsxs(re,{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:[s.jsx(sT,{className:"h-3 w-3"}),s.jsx(R,{id:"assistant.tool.view_task_details"})]})}),s.jsxs(dn,{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:[s.jsx(jn,{className:"px-6 py-4 border-b bg-muted/30",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"flex-shrink-0 mt-1",children:s.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center",children:s.jsx(pn,{className:"h-5 w-5 text-primary"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx(Mn,{className:"text-lg font-semibold leading-tight mb-1",children:w.length>120?`${w.slice(0,120)}...`:w}),s.jsxs(Pn,{className:"text-xs flex items-center gap-2 flex-wrap",children:[y!=null&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(R,{id:"assistant.tool.task_id"}),":"," ",s.jsx("code",{className:"px-1.5 py-0.5 bg-muted rounded text-[10px] font-mono",children:y.slice(0,8)})]}),s.jsx("span",{className:"text-muted-foreground",children:"|"})]}),s.jsx("span",{children:s.jsx(R,{id:"assistant.tool.message_count",values:{count:S.length}})})]})]})]})}),s.jsxs("div",{className:"flex-1 overflow-auto px-6 py-4",children:[I&&s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[s.jsx(Tt,{className:"h-8 w-8 animate-spin text-primary"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:s.jsx(R,{id:"assistant.tool.loading_task"})})]}),b&&s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[s.jsx(XI,{className:"h-8 w-8 text-destructive"}),s.jsx("p",{className:"text-sm text-destructive",children:s.jsx(R,{id:"assistant.tool.error_loading_task"})}),s.jsx(re,{variant:"outline",size:"sm",onClick:()=>v(),children:s.jsx(R,{id:"assistant.tool.retry"})})]}),T&&s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[s.jsx(pe,{variant:"secondary",className:"text-sm",children:s.jsx(R,{id:"assistant.tool.no_task_data"})}),s.jsx("p",{className:"text-xs text-muted-foreground max-w-md text-center",children:s.jsx(R,{id:"assistant.tool.no_task_data_description"})})]}),D&&s.jsx(pS,{conversations:[...d?[]:[{type:"user",message:{role:"user",content:e},isSidechain:!1,userType:"external",cwd:_?.cwd??"dummy",sessionId:r,version:_?.version??"dummy",uuid:"dummy",timestamp:_?.timestamp??"dummy",parentUuid:null,isMeta:!1,toolUseResult:void 0,gitBranch:_?.gitBranch??"dummy",isCompactSummary:!1}],...S.map(k=>({...k,isSidechain:!1}))],getToolResult:o,projectId:n,sessionId:r})]})]})]})},M4=({input:e})=>{const n=Object.entries(e);return n.length===0?null:s.jsx("span",{children:n.map(([r,a],t)=>{const i=typeof a=="string"?a:JSON.stringify(a).replace(/^"|"$/g,"");return s.jsxs("span",{children:[t>0&&s.jsx("span",{className:"text-muted-foreground",children:", "}),s.jsxs("span",{className:"text-muted-foreground",children:[r,"="]}),s.jsx("span",{children:i})]},r)})})},dS=_c.object({prompt:_c.string()}),P4=({content:e,getToolResult:n,getAgentIdForToolUse:r,getSidechainConversationByPrompt:a,getSidechainConversations:t,projectId:i,sessionId:o})=>{const{resolvedTheme:l}=dy(),u=l==="dark"?av:iv;if(e.type==="text")return s.jsx("div",{className:"w-full mx-1 sm:mx-2 my-4 sm:my-6",children:s.jsx(cS,{content:e.text})});if(e.type==="thinking")return s.jsx(ut,{className:"bg-muted/50 border-dashed gap-2 py-3 mb-2 hover:shadow-sm transition-all duration-200",children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsx(nn,{className:"cursor-pointer hover:bg-muted/80 rounded-t-lg transition-all duration-200 py-0 px-4 group",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(RT,{className:"h-4 w-4 text-muted-foreground group-hover:text-yellow-600 transition-colors"}),s.jsx(rn,{className:"text-sm font-medium group-hover:text-foreground transition-colors",children:s.jsx(R,{id:"assistant.thinking"})}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-2 px-4",children:s.jsx("div",{className:"text-sm text-muted-foreground whitespace-pre-wrap font-mono",children:e.thinking})})})]})});if(e.type==="tool_use"){const c=n(e.id),p=(()=>{const d=e.name==="Task"?dS.safeParse(e.input):void 0;if(d===void 0||d.success===!1)return;const g=r(e.id);return s.jsx(j4,{prompt:d.data.prompt,projectId:i,sessionId:o,agentId:g,getSidechainConversationByPrompt:a,getSidechainConversations:t,getToolResult:n})})();return s.jsx(ut,{className:"border-blue-200 bg-blue-50/50 dark:border-blue-800 dark:bg-blue-950/20 mb-2 p-0 overflow-hidden",children:s.jsxs(Le,{children:[s.jsxs("div",{className:"flex items-center min-w-0",children:[s.jsx(We,{asChild:!0,children:s.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:s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(JT,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 flex-shrink-0"}),s.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&&s.jsxs("span",{className:"font-normal",children:[" ","(",s.jsx(M4,{input:e.input}),")"]})]}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform duration-200 group-data-[state=open]:rotate-180 flex-shrink-0"})]})})}),p&&s.jsx("div",{className:"flex-shrink-0 border-l border-blue-200 dark:border-blue-800 flex items-center",children:p})]}),s.jsx(je,{children:s.jsxs("div",{className:"space-y-3 py-3 px-4 border-t border-blue-200 dark:border-blue-800",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-1",children:s.jsx(R,{id:"assistant.tool.tool_id"})}),s.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})]}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-2",children:s.jsx(R,{id:"assistant.tool.input_parameters"})}),s.jsx(Fu,{style:u,language:"json",PreTag:"div",className:"text-xs rounded",children:JSON.stringify(e.input,null,2)})]}),c&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground mb-2",children:s.jsx(R,{id:"assistant.tool.result"})}),s.jsx("div",{className:"bg-background rounded border p-3",children:typeof c.content=="string"?s.jsx("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words",children:c.content}):c.content.map(d=>{if(d.type==="image")return s.jsx("img",{src:`data:${d.source.media_type};base64,${d.source.data}`,alt:"Tool Result"},d.source.data);if(d.type==="text")return s.jsx("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words",children:d.text},d.text);throw new Error("Unexpected tool result content type")})})]})]})})]})})}return e.type==="tool_result",null},U4=e=>{const n=e.filter(d=>d.type!=="summary"&&d.type!=="file-history-snapshot"&&d.type!=="queue-operation").filter(d=>d.isSidechain===!0),r=O.useMemo(()=>new Map(n.map(d=>[d.uuid,d])),[n]),a=O.useMemo(()=>new Map(n.filter(d=>d.type==="user").filter(d=>d.parentUuid===null&&typeof d.message.content=="string").map(d=>[d.message.content,d])),[n]),t=O.useMemo(()=>new Set(e.filter(d=>d.type==="assistant").flatMap(d=>[...d.message.content.filter(g=>g.type==="tool_use")]).flatMap(d=>{if(d.name!=="Task")return[];const g=dS.safeParse(d.input);return g.success===!1?[]:[g.data.prompt]})),[e]),i=O.useCallback(d=>{if(d.parentUuid===null)return d;const g=r.get(d.parentUuid);return g===void 0?d:i(g)},[r]),o=O.useMemo(()=>{const d=new Map;for(const g of n){const m=i(g);d.has(m.uuid)?d.get(m.uuid)?.push(g):d.set(m.uuid,[g])}return d},[n,i]),l=O.useCallback(d=>d.type==="summary"||d.type==="file-history-snapshot"||d.type==="queue-operation"?!1:o.has(d.uuid),[o]),u=O.useCallback(d=>o.get(d)??[],[o]),c=O.useCallback(d=>a.get(d),[a]);return{isRootSidechain:l,getSidechainConversations:u,getSidechainConversationByPrompt:c,existsRelatedTaskCall:d=>t.has(d)}},F4=({conversation:e})=>{const n=Object.keys(e.snapshot.trackedFileBackups).length,{config:r}=kt();return s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2",children:[s.jsxs("h4",{className:"text-xs font-medium text-muted-foreground",children:["File History Snapshot ",n>0&&`(${n} files)`]}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"text-xs",children:[s.jsx("span",{className:"text-muted-foreground",children:"Timestamp: "}),s.jsx("span",{children:_u(e.snapshot.timestamp,{locale:r.locale})})]}),s.jsxs("div",{className:"text-xs",children:[s.jsx("span",{className:"text-muted-foreground",children:"Message ID: "}),s.jsx("span",{className:"font-mono",children:e.messageId})]}),s.jsxs("div",{className:"text-xs",children:[s.jsxs("span",{className:"text-muted-foreground",children:["Is Snapshot Update:"," "]}),s.jsx("span",{children:e.isSnapshotUpdate?"Yes":"No"})]}),n>0&&s.jsxs("div",{className:"text-xs",children:[s.jsx("div",{className:"text-muted-foreground mb-1",children:"Tracked Files:"}),s.jsx("ul",{className:"list-disc list-inside space-y-1",children:Object.keys(e.snapshot.trackedFileBackups).map(a=>s.jsx("li",{className:"font-mono text-xs break-all",children:a},a))})]})]})})})]})},B4=({children:e})=>s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:"Meta Information"}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:e})})]}),z4=e=>typeof e=="string"?e:e.map(n=>typeof n=="string"?n:n.type==="text"?n.text:n.type==="image"?"[Image]":n.type==="document"?"[Document]":n.type==="tool_result"?"[Tool Result]":n).join(`
|
|
182
|
-
`),q4=({conversation:e})=>{const n=e.operation==="enqueue"?"Queue Operation: Enqueue":"Queue Operation: Dequeue";return s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:n}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Operation:"})," ",e.operation]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Session ID:"})," ",e.sessionId]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Timestamp:"})," ",e.timestamp]}),e.operation==="enqueue"&&s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Content:"}),s.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap",children:z4(e.content)})]})]})})})]})},G4=({children:e})=>s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:"Summarized"}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsx("pre",{className:"text-xs overflow-x-auto",children:e})})})]}),H4=({children:e})=>s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:"System Message"}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsx("pre",{className:"text-xs overflow-x-auto",children:e})})})]}),V4=/<(?<tag>[^>]+)>(?<content>\s*[^<]*?\s*)<\/\k<tag>>/g,W4=Je({tag:He(),content:He()});xu([Je({kind:ct("command"),commandName:He(),commandArgs:He().optional(),commandMessage:He().optional()}),Je({kind:ct("local-command"),stdout:He()}),Je({kind:ct("text"),content:He()})]);const K4=e=>{const n=Array.from(e.matchAll(V4)).map(o=>W4.safeParse(o.groups)).filter(o=>o.success).map(o=>o.data);if(n.length===0)return{kind:"text",content:e};const r=n.find(o=>o.tag==="command-name")?.content,a=n.find(o=>o.tag==="command-args")?.content,t=n.find(o=>o.tag==="command-message")?.content,i=n.find(o=>o.tag==="local-command-stdout")?.content;switch(!0){case r!==void 0:return{kind:"command",commandName:r,commandArgs:a,commandMessage:t};case i!==void 0:return{kind:"local-command",stdout:i};default:return{kind:"text",content:e}}},ab=({text:e,id:n})=>{const r=K4(e);return r.kind==="command"?s.jsxs(ut,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3",id:n,children:[s.jsx(nn,{className:"py-0 px-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(au,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),s.jsx(rn,{className:"text-sm font-medium",children:"Claude Code Command"}),s.jsx(pe,{variant:"outline",className:"border-green-300 text-green-700 dark:border-green-700 dark:text-green-300",children:r.commandName})]})}),r.commandArgs||r.commandMessage?s.jsx(fc,{className:"py-0 px-4",children:s.jsx("div",{className:"space-y-2",children:s.jsxs("div",{children:[r.commandArgs&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Arguments:"}),s.jsx("div",{className:"bg-background rounded border p-2 mt-1",children:s.jsx("code",{className:"text-xs whitespace-pre-line break-all",children:r.commandArgs})})]}),r.commandMessage&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Message:"}),s.jsx("div",{className:"bg-background rounded border p-2 mt-1",children:s.jsx("code",{className:"text-xs whitespace-pre-line break-all",children:r.commandMessage})})]})]})})}):null]}):r.kind==="local-command"?s.jsxs(ut,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3",children:[s.jsx(nn,{className:"py-0 px-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(au,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),s.jsx(rn,{className:"text-sm font-medium",children:"Local Command"})]})}),s.jsx(fc,{className:"py-0 px-4",children:s.jsx("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words",children:r.stdout})})]}):s.jsx(cS,{className:"w-full px-3 py-3 mb-5 border border-border rounded-lg bg-slate-50 dark:bg-slate-900/50",content:r.content})},ib=({content:e,id:n})=>typeof e=="string"?s.jsx(ab,{text:e,id:n}):e.type==="text"?s.jsx(ab,{text:e.text,id:n}):e.type==="image"?e.source.type==="base64"?s.jsx(ut,{className:"border-purple-200 bg-purple-50/50 dark:border-purple-800 dark:bg-purple-950/20 mb-2 p-0 overflow-hidden",id:n,children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.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:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(TT,{className:"h-4 w-4 text-purple-600 dark:text-purple-400"}),s.jsx("span",{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.image"})}),s.jsx(pe,{variant:"outline",className:"border-purple-300 text-purple-700 dark:border-purple-700 dark:text-purple-300",children:e.source.media_type}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-3 px-4 border-t border-purple-200 dark:border-purple-800",children:s.jsx("div",{className:"rounded-lg border overflow-hidden bg-background",children:s.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"})})})})]})}):s.jsx(ut,{className:"border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20",id:n,children:s.jsxs(nn,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nu,{className:"h-4 w-4 text-red-600 dark:text-red-400"}),s.jsx(rn,{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.unsupported_media"})}),s.jsx(pe,{variant:"destructive",children:s.jsx(R,{id:"common.error"})})]}),s.jsx(hc,{className:"text-xs",children:s.jsx(R,{id:"user.content.unsupported_media.description"})})]})}):e.type==="document"?e.source.type==="base64"&&e.source.media_type==="application/pdf"?s.jsx(ut,{className:"border-blue-200 bg-blue-50/50 dark:border-blue-800 dark:bg-blue-950/20 mb-2 p-0 overflow-hidden",id:n,children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.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:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ru,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),s.jsx("span",{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.document.pdf"})}),s.jsx(pe,{variant:"outline",className:"border-blue-300 text-blue-700 dark:border-blue-700 dark:text-blue-300",children:e.source.media_type}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-3 px-4 border-t border-blue-200 dark:border-blue-800",children:s.jsx("div",{className:"rounded-lg border overflow-hidden bg-background",children:s.jsx("embed",{src:`data:${e.source.media_type};base64,${e.source.data}`,type:"application/pdf",className:"w-full h-[600px]"})})})})]})}):e.source.type==="text"?s.jsx(ut,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 mb-2 p-0 overflow-hidden",id:n,children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.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:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ru,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),s.jsx("span",{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.document.text"})}),s.jsx(pe,{variant:"outline",className:"border-green-300 text-green-700 dark:border-green-700 dark:text-green-300",children:e.source.media_type}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-3 px-4 border-t border-green-200 dark:border-green-800",children:s.jsx("div",{className:"rounded-lg border overflow-hidden bg-background",children:s.jsx("pre",{className:"p-4 text-sm overflow-auto max-h-96",children:e.source.data})})})})]})}):s.jsx(ut,{className:"border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20",id:n,children:s.jsxs(nn,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nu,{className:"h-4 w-4 text-red-600 dark:text-red-400"}),s.jsx(rn,{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.unsupported_document"})}),s.jsx(pe,{variant:"destructive",children:s.jsx(R,{id:"common.error"})})]}),s.jsx(hc,{className:"text-xs",children:s.jsx(R,{id:"user.content.unsupported_document.description"})})]})}):(e.type==="tool_result",null),Y4=({conversation:e,getToolResult:n,getAgentIdForToolUse:r,getSidechainConversationByPrompt:a,getSidechainConversations:t,projectId:i,sessionId:o})=>{if(e.type==="summary")return s.jsx(G4,{children:e.summary});if(e.type==="system")return s.jsx(H4,{children:e.content});if(e.type==="file-history-snapshot")return s.jsx(F4,{conversation:e});if(e.type==="queue-operation")return s.jsx(q4,{conversation:e});if(e.type==="user"){const l=typeof e.message.content=="string"?s.jsx(ib,{content:e.message.content,id:`message-${e.uuid}`}):s.jsx("ul",{className:"w-full",id:`message-${e.uuid}`,children:e.message.content.map(u=>s.jsx("li",{children:s.jsx(ib,{content:u})},u.toString()))});return e.isMeta===!0?s.jsx(B4,{children:l}):l}return e.type==="assistant"?s.jsx("ul",{className:"w-full",children:e.message.content.map(l=>s.jsx("li",{children:s.jsx(P4,{content:l,getToolResult:n,getAgentIdForToolUse:r,getSidechainConversationByPrompt:a,getSidechainConversations:t,projectId:i,sessionId:o})},l.toString()))}):null},Z4=e=>typeof e=="object"&&e!==null&&"agentId"in e&&typeof e.agentId=="string",ob=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}`;throw new Error(`Unknown conversation type: ${e}`)},X4=({errorLine:e})=>s.jsx("li",{className:"w-full flex justify-start",children:s.jsx("div",{className:"w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%] px-2",children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.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:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ec,{className:"h-3 w-3 text-red-500"}),s.jsx("span",{className:"text-xs font-medium text-red-600",children:s.jsx(R,{id:"conversation.error.schema"})})]}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border border-red-200 p-3 mt-2",children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs(UI,{variant:"destructive",className:"border-red-200 bg-red-50",children:[s.jsx(Ec,{className:"h-4 w-4"}),s.jsx(FI,{className:"text-red-800",children:s.jsx(R,{id:"conversation.error.schema_validation"})}),s.jsxs(BI,{className:"text-red-700",children:[s.jsx(R,{id:"conversation.error.schema_validation.description"})," ",s.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:[s.jsx(R,{id:"conversation.error.report_issue"}),s.jsx(ET,{className:"h-3 w-3"})]})]})]}),s.jsxs("div",{className:"bg-gray-50 border rounded px-3 py-2",children:[s.jsx("h5",{className:"text-xs font-medium text-gray-700 mb-2",children:s.jsx(R,{id:"conversation.error.raw_content"})}),s.jsx("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-all font-mono text-gray-800",children:e})]})]})})})]})})}),pS=({conversations:e,getToolResult:n,projectId:r,sessionId:a})=>{const t=O.useMemo(()=>e.filter(g=>g.type!=="x-error"),[e]),{isRootSidechain:i,getSidechainConversations:o,getSidechainConversationByPrompt:l,existsRelatedTaskCall:u}=U4(t),c=t.length===11;c&&console.log("validConversations",t);const p=O.useMemo(()=>{const g=new Map;for(const m of t){if(m.type!=="user")continue;const f=m.message.content;if(typeof f!="string"){for(const h of f)if(typeof h!="string"&&h.type==="tool_result"){const v=m.toolUseResult;Z4(v)&&g.set(h.tool_use_id,v.agentId)}}}return g},[t]),d=O.useCallback(g=>p.get(g),[p]);return s.jsx("ul",{children:e.flatMap(g=>{if(g.type==="x-error")return s.jsx(X4,{errorLine:g.line},`error_${g.line}`);c&&console.log("conversation",g);const m=s.jsx(Y4,{conversation:g,getToolResult:n,getAgentIdForToolUse:d,isRootSidechain:i,getSidechainConversations:o,getSidechainConversationByPrompt:l,existsRelatedTaskCall:u,projectId:r,sessionId:a},ob(g)),f=g.type!=="summary"&&g.type!=="file-history-snapshot"&&g.type!=="queue-operation"&&g.isSidechain;return[s.jsx("li",{className:`w-full flex ${f||g.type==="assistant"||g.type==="system"||g.type==="summary"?"justify-start":"justify-end"} animate-in fade-in slide-in-from-bottom-2 duration-300`,children:s.jsx("div",{className:"w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%]",children:m})},ob(g))]})})};function ic({className:e,...n}){return s.jsx("textarea",{"data-slot":"textarea",className:ce("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),...n})}const J4=({hunk:e})=>s.jsxs("div",{className:"relative flex overflow-x-auto",children:[s.jsxs("div",{className:"flex-shrink-0 sticky left-0 z-10 bg-white dark:bg-gray-900",children:[s.jsx("div",{className:"float-left w-10 bg-gray-50 dark:bg-gray-800/50 border-r border-gray-200 dark:border-gray-700",children:e.lines.map((n,r)=>s.jsx("div",{className:"px-1 py-0.5 text-xs text-gray-400 dark:text-gray-600 font-mono text-right leading-tight",children:n.type!=="added"&&n.type!=="hunk"&&n.oldLineNumber?n.oldLineNumber:" "},`old-${n.oldLineNumber}-${r}`))}),s.jsx("div",{className:"float-left w-10 bg-gray-50 dark:bg-gray-800/50 border-r border-gray-200 dark:border-gray-700",children:e.lines.map((n,r)=>s.jsx("div",{className:"px-1 py-0.5 text-xs text-gray-400 dark:text-gray-600 font-mono text-right leading-tight",children:n.type!=="deleted"&&n.type!=="hunk"&&n.newLineNumber?n.newLineNumber:" "},`new-${n.newLineNumber}-${r}`))})]}),s.jsx("div",{className:"flex-1 min-w-0",children:e.lines.map((n,r)=>s.jsx("div",{className:ce("flex border-l-4",{"bg-green-50 dark:bg-green-950/30 border-green-200 dark:border-green-800/50 border-l-green-400":n.type==="added","bg-red-50 dark:bg-red-950/30 border-red-200 dark:border-red-800/50 border-l-red-400":n.type==="deleted","bg-blue-50 dark:bg-blue-950/30 border-blue-200 dark:border-blue-800/50 border-l-blue-400":n.type==="hunk","bg-white dark:bg-gray-900 border-gray-100 dark:border-gray-800 border-l-transparent":n.type==="unchanged"}),children:s.jsx("div",{className:"flex-1 px-2 py-0.5",children:s.jsxs("span",{className:"font-mono text-xs whitespace-pre block leading-tight",children:[s.jsx("span",{className:ce({"text-green-600 dark:text-green-400":n.type==="added","text-red-600 dark:text-red-400":n.type==="deleted","text-blue-600 dark:text-blue-400 font-medium":n.type==="hunk","text-gray-400 dark:text-gray-600":n.type==="unchanged"}),children:n.type==="added"?"+":n.type==="deleted"?"-":n.type==="hunk"?"":" "}),n.content||" "]})})},`content-${n.content}-${n.oldLineNumber}-${n.newLineNumber}-${r}`))})]}),sb=({fileDiff:e,isCollapsed:n,onToggleCollapse:r})=>{const a=()=>e.isNew?s.jsx("span",{className:"text-green-600 dark:text-green-400",children:"A"}):e.isDeleted?s.jsx("span",{className:"text-red-600 dark:text-red-400",children:"D"}):e.isRenamed?s.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"R"}):s.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"M"}),t=async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e.filename),de.success("ファイル名をコピーしました")}catch(o){console.error("Failed to copy filename:",o),de.error("ファイル名のコピーに失敗しました")}};return s.jsxs(re,{onClick:r,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:[s.jsxs("div",{className:"w-full flex items-center gap-2",children:[n?s.jsx(fy,{className:"w-4 h-4 text-gray-500 flex-shrink-0"}):s.jsx($e,{className:"w-4 h-4 text-gray-500 flex-shrink-0"}),s.jsx("div",{className:"w-5 h-5 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center text-xs font-mono flex-shrink-0",children:a()}),s.jsx("span",{className:"font-mono text-xs font-medium text-black dark:text-white text-left truncate flex-1 min-w-0",children:e.filename}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:[e.linesAdded>0&&s.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.linesAdded]}),e.linesDeleted>0&&s.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["-",e.linesDeleted]})]}),s.jsx(re,{onClick:t,variant:"ghost",size:"sm",className:"flex-shrink-0 p-1 h-5 w-5 hover:bg-gray-200 dark:hover:bg-gray-600",children:s.jsx(xy,{className:"w-3 h-3 text-gray-500 dark:text-gray-400"})})]}),e.isBinary&&s.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400 text-left",children:"Binary file (content not shown)"})]})},Q4=({fileDiff:e,className:n})=>{const[r,a]=O.useState(!1),t=()=>{a(!r)};return e.isBinary?s.jsxs("div",{className:ce("border border-gray-200 dark:border-gray-700 rounded-lg",n),children:[s.jsx(sb,{fileDiff:e,isCollapsed:r,onToggleCollapse:t}),!r&&s.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400 text-sm",children:"Binary file cannot be displayed"})]}):s.jsxs("div",{className:ce("border border-gray-200 dark:border-gray-700 rounded-lg",n),children:[s.jsx(sb,{fileDiff:e,isCollapsed:r,onToggleCollapse:t}),!r&&s.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700",children:e.hunks.map((i,o)=>s.jsx(J4,{hunk:i},`${i.oldStart}-${i.newStart}-${o}`))})]})},ez=({summary:e,className:n})=>s.jsx("div",{className:ce("bg-gray-50 dark:bg-gray-800 rounded-lg p-2 border border-gray-200 dark:border-gray-700",n),children:s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(ru,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),s.jsxs("span",{className:"font-medium",children:[s.jsxs("span",{className:"hidden sm:inline",children:[e.filesChanged," ",s.jsx(R,{id:"diff.files.changed"})]}),s.jsxs("span",{className:"sm:hidden",children:[e.filesChanged," ",s.jsx(R,{id:"diff.files"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[e.insertions>0&&s.jsxs("span",{className:"text-green-600 dark:text-green-400 font-medium",children:["+",e.insertions]}),e.deletions>0&&s.jsxs("span",{className:"text-red-600 dark:text-red-400 font-medium",children:["-",e.deletions]})]})]})}),lb=({label:e,value:n,onValueChange:r,refs:a})=>{const t=O.useId(),i=o=>{switch(o){case"branch":return s.jsx(Rn,{className:"h-4 w-4"});case"commit":return s.jsx("span",{className:"text-xs",children:"📝"});case"working":return s.jsx("span",{className:"text-xs",children:"🚧"});default:return s.jsx(Rn,{className:"h-4 w-4"})}};return s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:t,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:e}),s.jsxs(Ot,{value:n,onValueChange:r,children:[s.jsx(Dt,{className:"w-full sm:w-80",children:s.jsx(Lt,{})}),s.jsx($t,{id:t,children:a.map(o=>s.jsx(Ve,{value:o.name,children:s.jsxs("div",{className:"flex items-center gap-2",children:[i(o.type),s.jsx("span",{children:o.displayName}),o.sha&&s.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:o.sha.substring(0,7)})]})},o.name))})]})]})},tz=({isOpen:e,onOpenChange:n,projectId:r,defaultCompareFrom:a="HEAD",defaultCompareTo:t="working",revisionsData:i})=>{const{i18n:o}=Ke(),l=O.useId(),[u,c]=O.useState(a),[p,d]=O.useState(t),[g,m]=O.useState(new Map),[f,h]=O.useState(""),[v,S]=O.useState(!1),{data:E,isLoading:y}=Tu(r),w=i??E,{mutate:I,data:b,isPending:T,error:D}=eC(),_=tC(r),k=nC(r),A=rC(r),j=w?.success&&w.data?[{name:"working",type:"working",displayName:o._("Uncommitted changes")},{name:"HEAD",type:"commit",displayName:"HEAD"},...w.data.baseBranch?[{name:`branch:${w.data.baseBranch.name}`,type:"branch",displayName:`${w.data.baseBranch.name} (base)`,sha:w.data.baseBranch.commit}]:[],...w.data.currentBranch?[{name:`branch:${w.data.currentBranch.name}`,type:"branch",displayName:`${w.data.currentBranch.name} (current)`,sha:w.data.currentBranch.commit}]:[],...w.data.commits.map(x=>({name:`commit:${x.sha}`,type:"commit",displayName:`${x.message.substring(0,50)}${x.message.length>50?"...":""}`,sha:x.sha}))]:[],$=O.useCallback(()=>{u&&p&&u!==p&&I({projectId:r,fromRef:u,toRef:p})},[u,p,I,r]);O.useEffect(()=>{if(b?.success&&b.data.files.length>0){const x=new Map(b.data.files.map(C=>[C.filePath,!0]));m(x)}},[b]),O.useEffect(()=>{e&&u&&p&&$()},[e,u,p,$]);const P=()=>{$()},z=x=>{m(C=>{const B=new Map(C),H=!C.get(x);return B.set(x,H),B})},ee=()=>{b?.success&&b.data.files.length>0&&m(new Map(b.data.files.map(x=>[x.filePath,!0])))},X=()=>{b?.success&&b.data.files.length>0&&m(new Map(b.data.files.map(x=>[x.filePath,!1])))},G=async()=>{const x=Array.from(g.entries()).filter(([C,B])=>B).map(([C])=>C);console.log("[DiffModal.handleCommit] Selected files state:",g),console.log("[DiffModal.handleCommit] Filtered selected files:",x),console.log("[DiffModal.handleCommit] Total files:",b?.success?b.data.files.length:0);try{const C=await _.mutateAsync({files:x,message:f});console.log("[DiffModal.handleCommit] Commit result:",C),C.success?(de.success(`Committed ${C.filesCommitted} files (${C.commitSha.slice(0,7)})`),h(""),$()):de.error(C.error,{description:C.details})}catch(C){console.error("[DiffModal.handleCommit] Error:",C),de.error(o._("Failed to commit"))}},te=async()=>{try{const x=await k.mutateAsync();console.log("[DiffModal.handlePush] Push result:",x),x.success?de.success(`Pushed to ${x.remote}/${x.branch}`):de.error(x.error,{description:x.details})}catch(x){console.error("[DiffModal.handlePush] Error:",x),de.error(o._("Failed to push"))}},N=async()=>{const x=Array.from(g.entries()).filter(([C,B])=>B).map(([C])=>C);console.log("[DiffModal.handleCommitAndPush] Selected files:",x);try{const C=await A.mutateAsync({files:x,message:f});console.log("[DiffModal.handleCommitAndPush] Result:",C),C.success?(de.success(`Committed and pushed (${C.commitSha.slice(0,7)})`),h(""),$()):C.success===!1&&"commitSucceeded"in C&&C.commitSucceeded?(de.warning(`Committed (${C.commitSha?.slice(0,7)}), but push failed: ${C.error}`,{action:{label:o._("Retry Push"),onClick:te}}),h(""),$()):de.error(C.error,{description:C.details})}catch(C){console.error("[DiffModal.handleCommitAndPush] Error:",C),de.error(o._("Failed to commit and push"))}},Y=Array.from(g.values()).filter(Boolean).length,Z=Y===0||f.trim().length===0||_.isPending;return s.jsx(cn,{open:e,onOpenChange:n,children:s.jsxs(dn,{className:"max-w-7xl w-[95vw] h-[90vh] overflow-hidden flex flex-col px-2 md:px-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:items-end",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 flex-1",children:[s.jsx(lb,{label:o._("Compare from"),value:u,onValueChange:c,refs:j.filter(x=>x.name!=="working")}),s.jsx(lb,{label:o._("Compare to"),value:p,onValueChange:d,refs:j})]}),s.jsx(re,{onClick:P,disabled:T||y||u===p,className:"sm:self-end w-full sm:w-auto",children:T?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"common.loading"})]}):s.jsx(FT,{className:"w-4 h-4"})})]}),D&&s.jsx("div",{className:"bg-red-50 dark:bg-red-900/10 border border-red-200 dark:border-red-800 rounded-lg p-4",children:s.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm",children:D.message})}),b?.success&&s.jsxs("div",{className:"flex-1 overflow-auto",children:[s.jsx(ez,{summary:{filesChanged:b.data.files.length,insertions:b.data.summary.totalAdditions,deletions:b.data.summary.totalDeletions,files:b.data.diffs.map(x=>({filename:x.file.filePath,oldFilename:x.file.oldPath,isNew:x.file.status==="added",isDeleted:x.file.status==="deleted",isRenamed:x.file.status==="renamed",isBinary:!1,hunks:x.hunks,linesAdded:x.file.additions,linesDeleted:x.file.deletions}))},className:"mb-3"}),p==="working"&&s.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg mb-4 border border-gray-200 dark:border-gray-700",children:[s.jsxs("button",{type:"button",onClick:()=>S(!v),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:[s.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:s.jsx(R,{id:"diff.commit.changes"})}),v?s.jsx(JI,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):s.jsx($e,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"})]}),v&&s.jsxs("div",{className:"p-4 pt-0 space-y-3",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(re,{size:"sm",variant:"ghost",onClick:ee,disabled:_.isPending,children:s.jsx(R,{id:"diff.select.all"})}),s.jsx(re,{size:"sm",variant:"ghost",onClick:X,disabled:_.isPending,children:s.jsx(R,{id:"diff.deselect.all"})}),s.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:[Y," / ",b.data.files.length," files selected"]})]})}),s.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded p-2",children:b.data.files.map(x=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(QI,{id:`file-${x.filePath}`,checked:g.get(x.filePath)??!1,onCheckedChange:()=>z(x.filePath),disabled:_.isPending}),s.jsx("label",{htmlFor:`file-${x.filePath}`,className:"text-sm font-mono cursor-pointer flex-1",children:x.filePath})]},x.filePath))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:l,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:s.jsx(R,{id:"diff.commit.message"})}),s.jsx(ic,{id:l,placeholder:"Enter commit message...",value:f,onChange:x=>h(x.target.value),disabled:_.isPending,className:"resize-none",rows:3})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(re,{onClick:G,disabled:Z,className:"w-full sm:w-auto",children:_.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"diff.committing"})]}):s.jsx(R,{id:"diff.commit"})}),s.jsx(re,{onClick:te,disabled:k.isPending,variant:"outline",className:"w-full sm:w-auto",children:k.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"diff.pushing"})]}):s.jsx(R,{id:"diff.push"})}),s.jsx(re,{onClick:N,disabled:Z||A.isPending,variant:"secondary",className:"w-full sm:w-auto",children:A.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"diff.committing.pushing"})]}):s.jsx(R,{id:"diff.commit.push"})}),Z&&!_.isPending&&!A.isPending&&s.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:Y===0?s.jsx(R,{id:"diff.select.file"}):s.jsx(R,{id:"diff.enter.message"})})]})]})]}),s.jsx("div",{className:"space-y-3",children:b.data.diffs.map(x=>s.jsx(Q4,{fileDiff:{filename:x.file.filePath,oldFilename:x.file.oldPath,isNew:x.file.status==="added",isDeleted:x.file.status==="deleted",isRenamed:x.file.status==="renamed",isBinary:!1,hunks:x.hunks,linesAdded:x.file.additions,linesDeleted:x.file.deletions}},x.file.filePath))})]}),T&&s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center space-y-2",children:[s.jsx(Tt,{className:"w-8 h-8 animate-spin mx-auto"}),s.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s.jsx(R,{id:"diff.loading"})})]})})]})})},nz=({projectId:e,isPending:n=!1,onScrollToTop:r,onScrollToBottom:a,onOpenDiffModal:t,sessionProcess:i,abortTask:o,isNewChat:l=!1})=>{const{i18n:u}=Ke(),c=py(),p=()=>{c({to:"/projects/$projectId/session",params:{projectId:e},search:d=>{const{sessionId:g,...m}=d;return m}})};return s.jsx("div",{className:"px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 mb-1",children:s.jsxs("div",{className:"py-0 flex items-center gap-1.5 flex-wrap",children:[t&&s.jsxs(re,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:n,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",title:u._({id:"control.open_git_dialog",message:"Open Git Dialog"}),children:[s.jsx(NT,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:s.jsx(R,{id:"control.git"})})]}),s.jsxs(re,{type:"button",variant:"ghost",size:"sm",disabled:n||l,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",onClick:p,title:u._({id:"control.new_chat",message:"New Chat"}),children:[s.jsx(Nu,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:s.jsx(R,{id:"control.new"})})]}),r&&s.jsx(re,{type:"button",variant:"ghost",size:"sm",onClick:r,disabled:n,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:s.jsx(pT,{className:"w-3.5 h-3.5"})}),a&&s.jsx(re,{type:"button",variant:"ghost",size:"sm",onClick:a,disabled:n,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:s.jsx(uT,{className:"w-3.5 h-3.5"})}),i&&o&&s.jsxs(re,{type:"button",variant:"destructive",size:"sm",onClick:()=>{o.mutate(i.id)},disabled:o.isPending||n,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",children:[o.isPending?s.jsx(Cn,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(wu,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:s.jsx(R,{id:"session.conversation.abort"})})]})]})})},yt={all:["scheduler"],jobs:()=>[...yt.all,"jobs"],job:e=>[...yt.all,"job",e]},rz=()=>Pt({queryKey:yt.jobs(),queryFn:async()=>{const e=await ze.api.scheduler.jobs.$get();if(!e.ok)throw new Error("Failed to fetch scheduler jobs");return e.json()}}),mS=()=>{const e=Un();return et({mutationFn:async n=>{const r=await ze.api.scheduler.jobs.$post({json:n});if(!r.ok)throw new Error("Failed to create scheduler job");return r.json()},onSuccess:()=>{e.invalidateQueries({queryKey:yt.jobs()})}})},az=()=>{const e=Un();return et({mutationFn:async({id:n,updates:r})=>{const a=await ze.api.scheduler.jobs[":id"].$patch({param:{id:n},json:r});if(!a.ok)throw a.status===404?new Error("Job not found"):new Error("Failed to update scheduler job");return a.json()},onSuccess:n=>{e.invalidateQueries({queryKey:yt.job(n.id)}),e.invalidateQueries({queryKey:yt.jobs()})}})},iz=()=>{const e=Un();return et({mutationFn:async n=>{const r=await ze.api.scheduler.jobs[":id"].$delete({param:{id:n}});if(!r.ok)throw r.status===404?new Error("Job not found"):new Error("Failed to delete scheduler job");return r.json()},onSuccess:(n,r)=>{e.invalidateQueries({queryKey:yt.job(r)}),e.invalidateQueries({queryKey:yt.jobs()})}})},gS=Nn(["image/png","image/jpeg","image/gif","image/webp"]),oz=Je({type:ct("image"),source:Je({type:ct("base64"),media_type:gS,data:He()})}),sz=Je({type:ct("document"),source:xu([Je({type:ct("text"),media_type:Nn(["text/plain"]),data:He()}),Je({type:ct("base64"),media_type:Nn(["application/pdf"]),data:He()})])});Je({text:He().min(1),images:tu(oz).optional(),documents:tu(sz).optional()});const lz=e=>e.startsWith("image/")?"image":e==="application/pdf"?"pdf":"text",uz=e=>new Promise((n,r)=>{const a=new FileReader;a.onload=()=>{const t=a.result;if(typeof t=="string"){const i=t.split(",")[1];n(i??"")}else r(new Error("Failed to read file as base64"))},a.onerror=()=>{r(new Error("Failed to read file"))},a.readAsDataURL(e)}),cz=e=>new Promise((n,r)=>{const a=new FileReader;a.onload=()=>{const t=a.result;typeof t=="string"?n(t):r(new Error("Failed to read file as text"))},a.onerror=()=>{r(new Error("Failed to read file"))},a.readAsText(e)}),dz=async e=>{const n=lz(e.type);if(n==="text")return{type:"text",content:await cz(e)};const r=await uz(e);if(n==="image"){const a=gS.safeParse(e.type);return a.success?{type:"image",block:{type:"image",source:{type:"base64",media_type:a.data,data:r}}}:null}return{type:"document",block:{type:"document",source:{type:"base64",media_type:"application/pdf",data:r}}}},pz=O.forwardRef(({projectId:e,inputValue:n,onCommandSelect:r,className:a},t)=>{const{i18n:i}=Ke(),[o,l]=O.useState(!1),[u,c]=O.useState(-1),p=O.useRef(null),d=O.useRef(null),{data:g}=Pt({queryKey:bc(e).queryKey,queryFn:bc(e).queryFn,staleTime:1e3*60*5}),{shouldShowCompletion:m,filteredCommands:f}=O.useMemo(()=>{const y=[...g?.defaultCommands||[],...g?.globalCommands||[],...g?.projectCommands||[]],w=n.startsWith("/"),I=w?n.slice(1).toLowerCase():"",b=w?y.filter(T=>T.toLowerCase().includes(I)):[];return{shouldShowCompletion:w,filteredCommands:b}},[g,n]),h=m&&f.length>0;o!==h&&(l(h),c(-1));const v=O.useCallback(y=>{r(`/${y} `),l(!1),c(-1)},[r]),S=O.useCallback(y=>{if(y>=0&&d.current){const I=d.current.querySelectorAll('button[role="option"]')[y];I&&I.scrollIntoView({block:"nearest",behavior:"smooth"})}},[]),E=O.useCallback(y=>{if(!o||f.length===0)return!1;switch(y.key){case"ArrowDown":return y.preventDefault(),c(w=>{const I=w<f.length-1?w+1:0;return requestAnimationFrame(()=>S(I)),I}),!0;case"ArrowUp":return y.preventDefault(),c(w=>{const I=w>0?w-1:f.length-1;return requestAnimationFrame(()=>S(I)),I}),!0;case"Enter":case"Tab":if(u>=0&&u<f.length){y.preventDefault();const w=f[u];return w&&v(w),!0}break;case"Escape":return y.preventDefault(),l(!1),c(-1),!0}return!1},[o,f.length,u,v,S,f]);return O.useEffect(()=>{const y=w=>{p.current&&!p.current.contains(w.target)&&(l(!1),c(-1))};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]),O.useImperativeHandle(t,()=>({handleKeyDown:E}),[E]),!m||f.length===0?null:s.jsx("div",{ref:p,className:ce("relative",a),children:s.jsx(Le,{open:o,onOpenChange:l,children:s.jsx(je,{children:s.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":i._("Available commands"),children:s.jsx("div",{className:"h-full overflow-y-auto",children:f.length>0&&s.jsxs("div",{className:"p-1.5",children:[s.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:[s.jsx(au,{className:"w-3.5 h-3.5"}),"Available Commands (",f.length,")"]}),f.map((y,w)=>s.jsxs(re,{variant:"ghost",size:"sm",className:ce("w-full justify-start text-left font-mono text-sm h-9 px-3 min-w-0 transition-colors duration-150",w===u?"bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20":"hover:bg-accent/50"),onClick:()=>v(y),onMouseEnter:()=>c(w),role:"option","aria-selected":w===u,"aria-label":`Command: /${y}`,title:`/${y}`,children:[s.jsx("span",{className:"text-muted-foreground mr-1.5 flex-shrink-0",children:"/"}),s.jsx("span",{className:"font-medium truncate min-w-0",children:y}),w===u&&s.jsx(yy,{className:"w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0"})]},y))]})})})})})})}),mz=(e,n,r=!0)=>Pt({queryKey:yc(e,n).queryKey,queryFn:yc(e,n).queryFn,enabled:r&&!!e,staleTime:1e3*60*5}),gz=e=>{const n=e.lastIndexOf("@");if(n===-1)return{shouldShow:!1,searchPath:"",beforeAt:"",afterAt:""};const r=e.slice(0,n),a=e.slice(n+1),t=a.split(/\s/),i=t[0]||"";return{shouldShow:!(t.length>1),searchPath:i,beforeAt:r,afterAt:a}},fS=O.forwardRef(({projectId:e,inputValue:n,onFileSelect:r,className:a},t)=>{const{i18n:i}=Ke(),[o,l]=O.useState(!1),[u,c]=O.useState(-1),p=O.useRef(null),d=O.useRef(null),{shouldShow:g,searchPath:m,beforeAt:f,afterAt:h}=O.useMemo(()=>gz(n),[n]),{basePath:v,filterTerm:S}=O.useMemo(()=>{if(!m)return{basePath:"/",filterTerm:""};const _=m.lastIndexOf("/");if(_===-1)return{basePath:"/",filterTerm:m};const k=m.slice(0,_+1),A=m.slice(_+1);return{basePath:k==="/"?"/":k,filterTerm:A}},[m]),{data:E,isLoading:y}=mz(e,v,g),w=O.useMemo(()=>E?.entries?S?E.entries.filter(_=>_.name.toLowerCase().includes(S.toLowerCase())):E.entries:[],[E?.entries,S]),I=g&&!y&&w.length>0;o!==I&&(l(I),c(-1));const b=O.useCallback((_,k=!1)=>{const A=_.path,j=h.split(/\s/).slice(1).join(" "),$=`${f}@${A}${j}`.trim()+(_.type==="directory"&&!k?"/":" ");r($),(_.type==="file"||k)&&(l(!1),c(-1))},[f,h,r]),T=O.useCallback(_=>{if(_>=0&&d.current){const A=d.current.querySelectorAll('button[role="option"]')[_];A&&A.scrollIntoView({block:"nearest",behavior:"smooth"})}},[]),D=O.useCallback(_=>{if(!o||w.length===0)return!1;switch(_.key){case"ArrowDown":return _.preventDefault(),c(k=>{const A=k<w.length-1?k+1:0;return requestAnimationFrame(()=>T(A)),A}),!0;case"ArrowUp":return _.preventDefault(),c(k=>{const A=k>0?k-1:w.length-1;return requestAnimationFrame(()=>T(A)),A}),!0;case"Enter":if(u>=0&&u<w.length){_.preventDefault();const k=w[u];return k&&b(k,!0),!0}break;case"Tab":if(u>=0&&u<w.length){_.preventDefault();const k=w[u];return k&&b(k,k.type==="file"),!0}break;case"Escape":return _.preventDefault(),l(!1),c(-1),!0}return!1},[o,w.length,u,b,T,w]);return O.useEffect(()=>{const _=k=>{p.current&&!p.current.contains(k.target)&&(l(!1),c(-1))};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[]),O.useImperativeHandle(t,()=>({handleKeyDown:D}),[D]),!g||y||w.length===0?null:s.jsx("div",{ref:p,className:ce("relative",a),children:s.jsx(Le,{open:o,onOpenChange:l,children:s.jsx(je,{children:s.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":i._("Available files and directories"),children:s.jsx("div",{className:"h-full overflow-y-auto",children:w.length>0&&s.jsxs("div",{className:"p-1.5",children:[s.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:[s.jsx(Sc,{className:"w-3.5 h-3.5"}),"Files & Directories (",w.length,")",v!=="/"&&s.jsxs("span",{className:"text-xs font-mono text-muted-foreground/70",children:["in ",v]})]}),w.map((_,k)=>s.jsxs(re,{variant:"ghost",size:"sm",className:ce("w-full justify-start text-left font-mono text-sm h-9 px-3 min-w-0 transition-colors duration-150",k===u?"bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20":"hover:bg-accent/50"),onClick:()=>b(_,_.type==="file"),onMouseEnter:()=>c(k),role:"option","aria-selected":k===u,"aria-label":`${_.type}: ${_.name}`,title:_.path,children:[_.type==="directory"?s.jsx(eT,{className:"w-3.5 h-3.5 mr-2 text-blue-500 dark:text-blue-400 flex-shrink-0"}):s.jsx(Sc,{className:"w-3.5 h-3.5 mr-2 text-gray-500 dark:text-gray-400 flex-shrink-0"}),s.jsx("span",{className:"font-medium truncate min-w-0",children:_.name}),_.type==="directory"&&s.jsx("span",{className:"text-muted-foreground ml-1 flex-shrink-0",children:"/"}),k===u&&s.jsx(yy,{className:"w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0"})]},_.path))]})})})})})})});fS.displayName="FileCompletion";const fz=(e,n,r)=>{const a=typeof window<"u"?window.innerHeight:800,t=a/2,i=48,o=36,l=12,c=Math.min(r,5),p=i+o*c+l,d=n.top<t,g=a-n.top,m=n.top;let f,h;d&&g>=p+20?(f="below",h=e.top+24):!d&&m>=p+20?(f="above",h=e.top-p-16):g>m?(f="below",h=e.top+24):(f="above",h=e.top-p-16);const E=(typeof window<"u"?window.innerWidth:1200)-512-16,y=Math.max(16,Math.min(e.left-16,E));return{top:h,left:y,placement:f}},hS=({projectId:e,message:n,commandCompletionRef:r,fileCompletionRef:a,handleCommandSelect:t,handleFileSelect:i,cursorPosition:o})=>{const l=O.useMemo(()=>fz(o.relative,o.absolute,5),[o]);return s.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:l.top,left:l.left,maxWidth:typeof window<"u"?Math.min(512,window.innerWidth*.8):512},children:[s.jsx(pz,{ref:r,projectId:e,inputValue:n,onCommandSelect:t,className:`absolute left-0 right-0 ${l.placement==="above"?"bottom-full mb-2":"top-full mt-1"}`}),s.jsx(fS,{ref:a,projectId:e,inputValue:n,onFileSelect:i,className:`absolute left-0 right-0 ${l.placement==="above"?"bottom-full mb-2":"top-full mt-1"}`})]})},oc=({projectId:e,onSubmit:n,isPending:r,error:a,placeholder:t,buttonText:i,minHeight:o="min-h-[64px]",containerClassName:l="",disabled:u=!1,buttonSize:c="lg",enableScheduledSend:p=!1,baseSessionId:d=null})=>{const m=(C=>{const B=C.match(/(\d+)px/);if(B?.[1]){const H=parseInt(B[1],10);if(!Number.isNaN(H))return H}return 48})(o),{i18n:f}=Ke(),[h,v]=O.useState(""),[S,E]=O.useState([]),[y,w]=O.useState({relative:{top:0,left:0},absolute:{top:0,left:0}}),[I,b]=O.useState("immediate"),[T,D]=O.useState(()=>{const C=new Date;C.setHours(C.getHours()+1);const B=C.getFullYear(),H=String(C.getMonth()+1).padStart(2,"0"),Q=String(C.getDate()).padStart(2,"0"),ue=String(C.getHours()).padStart(2,"0"),me=String(C.getMinutes()).padStart(2,"0");return`${B}-${H}-${Q}T${ue}:${me}`}),_=O.useRef(null),k=O.useRef(null),A=O.useRef(null),j=O.useRef(null),$=O.useRef(null),P=O.useId(),{config:z}=kt(),ee=mS();O.useEffect(()=>{const C=k.current;if(!C)return;C.style.height="auto";const B=C.scrollHeight,H=200;C.style.height=`${Math.max(m,Math.min(B,H))}px`},[h,m]),O.useEffect(()=>{const C=k.current;C&&(C.style.height=`${m}px`)},[m]);const X=async()=>{if(!h.trim()&&S.length===0)return;const C=[],B=[];for(const{file:H}of S){const Q=await dz(H);Q!==null&&(Q.type==="text"?B.push({type:"document",source:{type:"text",media_type:"text/plain",data:Q.content}}):Q.type==="image"?C.push(Q.block):Q.type==="document"&&B.push(Q.block))}if(p&&I==="scheduled"){const H=T.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/);if(!H)throw new Error("Invalid datetime format");const Q=Number(H[1]),ue=Number(H[2]),me=Number(H[3]),he=Number(H[4]),fe=Number(H[5]),Ae=new Date(Q,ue-1,me,he,fe);try{await ee.mutateAsync({name:`Scheduled message at ${T}`,schedule:{type:"reserved",reservedExecutionTime:Ae.toISOString()},message:{content:h,projectId:e,baseSessionId:d},enabled:!0}),de.success(f._({id:"chat.scheduled_send.success",message:"Message scheduled successfully"}),{description:f._({id:"chat.scheduled_send.success_description",message:"You can view and manage it in the Scheduler tab"})}),v(""),E([])}catch(Re){de.error(f._({id:"chat.scheduled_send.failed",message:"Failed to schedule message"}),{description:Re instanceof Error?Re.message:void 0})}}else await n({text:h,images:C.length>0?C:void 0,documents:B.length>0?B:void 0}),v(""),E([])},G=C=>{const B=C.target.files;if(!B)return;const H=Array.from(B).map(Q=>({file:Q,id:`${Q.name}-${Date.now()}-${Math.random()}`}));E(Q=>[...Q,...H]),A.current&&(A.current.value="")},te=C=>{E(B=>B.filter(H=>H.id!==C))},N=C=>{if(!$.current?.handleKeyDown(C)&&!j.current?.handleKeyDown(C)&&C.key==="Enter"&&!C.nativeEvent.isComposing){const B=z?.enterKeyBehavior;(B==="enter-send"&&!C.shiftKey&&!C.metaKey||B==="shift-enter-send"&&C.shiftKey&&!C.metaKey||B==="command-enter-send"&&C.metaKey&&!C.shiftKey)&&(C.preventDefault(),X())}},Y=O.useCallback(()=>{const C=k.current,B=_.current;if(C===null||B===null)return;const H=C.selectionStart,Q=C.value.substring(0,H),ue=C.value.substring(H),me=document.createTextNode(Q),he=document.createTextNode(ue),fe=document.createElement("span");fe.innerHTML=" ";const Ae=document.createElement("div");Ae.innerHTML="",Ae.append(me,fe,he);const Re=window.getComputedStyle(C);for(const Ce of["border","boxSizing","fontFamily","fontSize","fontWeight","letterSpacing","lineHeight","padding","textDecoration","textIndent","textTransform","whiteSpace","wordSpacing","wordWrap"])Ae.style[Ce]=Re[Ce];Ae.style.visibility="hidden",B.prepend(Ae);const pt=fe.getBoundingClientRect(),it=B.getBoundingClientRect();return B.removeChild(Ae),{relative:{top:pt.top-it.top-C.scrollTop,left:pt.left-it.left-C.scrollLeft},absolute:{top:pt.top-C.scrollTop,left:pt.left-C.scrollLeft}}},[]),Z=C=>{v(C),k.current?.focus()},x=C=>{v(C),k.current?.focus()};return s.jsxs("div",{className:l,children:[a&&s.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:[s.jsx(nu,{className:"w-4 h-4 shrink-0 mt-0.5"}),s.jsx("span",{className:"font-medium",children:s.jsx(R,{id:"chat.error.send_failed"})})]}),s.jsxs("div",{className:"relative group",children:[s.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 transition-opacity duration-500","aria-hidden":"true"}),s.jsxs("div",{className:"relative bg-background border border-border/40 rounded-2xl shadow-lg hover:shadow-xl transition-all duration-300 overflow-hidden",children:[s.jsx("div",{className:"relative",ref:_,children:s.jsx(ic,{ref:k,value:h,onChange:C=>{if(C.target.value.endsWith("@")||C.target.value.endsWith("/")){const B=Y();B&&w(B)}v(C.target.value)},onKeyDown:N,placeholder:t,className:"resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent px-5 py-2 text-base transition-all duration-200 placeholder:text-muted-foreground/60 overflow-y-auto leading-6",style:{minHeight:`${m}px`},disabled:r||u,"aria-label":f._("Message input with completion support"),"aria-describedby":P,"aria-expanded":h.startsWith("/")||h.includes("@"),"aria-haspopup":"listbox",role:"combobox","aria-autocomplete":"list"})}),S.length>0&&s.jsx("div",{className:"px-5 py-3 flex flex-wrap gap-2 border-t border-border/40",children:S.map(({file:C,id:B})=>s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-lg text-sm",children:[s.jsx("span",{className:"truncate max-w-[200px]",children:C.name}),s.jsx("button",{type:"button",onClick:()=>te(B),className:"text-muted-foreground hover:text-foreground transition-colors",disabled:r,children:s.jsx(wu,{className:"w-3.5 h-3.5"})})]},B))}),s.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-1 bg-muted/30 border-t border-border/40",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{ref:A,type:"file",multiple:!0,onChange:G,className:"hidden"}),s.jsxs(re,{type:"button",variant:"ghost",size:"sm",onClick:()=>A.current?.click(),disabled:r||u,className:"gap-1.5",children:[s.jsx($T,{className:"w-4 h-4"}),s.jsx("span",{className:"text-xs",children:s.jsx(R,{id:"chat.attach_file"})})]}),s.jsx("span",{className:"text-xs font-medium text-muted-foreground/80",id:P,children:h.length}),(h.startsWith("/")||h.includes("@"))&&s.jsxs("span",{className:"text-xs text-blue-600 dark:text-blue-400 font-medium flex items-center gap-1",children:[s.jsx(GT,{className:"w-3 h-3"}),s.jsx(R,{id:"chat.autocomplete.active"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[p&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ie,{htmlFor:"send-mode",className:"text-xs sr-only",children:s.jsx(R,{id:"chat.send_mode.label"})}),s.jsxs(Ot,{value:I,onValueChange:C=>b(C),disabled:r||u,children:[s.jsx(Dt,{id:"send-mode",className:"h-8 w-[140px] text-xs",children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"immediate",children:s.jsx(R,{id:"chat.send_mode.immediate"})}),s.jsx(Ve,{value:"scheduled",children:s.jsx(R,{id:"chat.send_mode.scheduled"})})]})]}),I==="scheduled"&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ie,{htmlFor:"scheduled-time",className:"text-xs sr-only",children:s.jsx(R,{id:"chat.send_mode.scheduled_time"})}),s.jsx(ht,{id:"scheduled-time",type:"datetime-local",value:T,onChange:C=>D(C.target.value),disabled:r||u,className:"h-8 w-[180px] text-xs"})]})]}),s.jsx(re,{onClick:X,disabled:!h.trim()&&S.length===0||r||u,size:c,className:"gap-2 transition-all duration-200 hover:shadow-md hover:scale-105 active:scale-95 bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-500 hover:to-purple-500 disabled:from-muted disabled:to-muted",children:r?s.jsxs(s.Fragment,{children:[s.jsx(Cn,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:s.jsx(R,{id:"chat.status.processing"})})]}):s.jsxs(s.Fragment,{children:[s.jsx(zT,{className:"w-4 h-4"}),i]})})]})]})]}),s.jsx(hS,{projectId:e,message:h,commandCompletionRef:j,fileCompletionRef:$,handleCommandSelect:Z,handleFileSelect:x,cursorPosition:y})]})]})},bS=(e,n)=>{const r=py();return et({mutationFn:async a=>{const t=await ze.api.cc["session-processes"].$post({json:{projectId:e,baseSessionId:a.baseSessionId,input:a.input}},{init:{signal:AbortSignal.timeout(2e4)}});if(!t.ok)throw new Error(t.statusText);return t.json()},onSuccess:async a=>{r({to:"/projects/$projectId/session",params:{projectId:e},search:t=>({...t,sessionId:a.sessionProcess.sessionId})})}})},hz=(e,n)=>et({mutationFn:async r=>{const a=await ze.api.cc["session-processes"][":sessionProcessId"].continue.$post({param:{sessionProcessId:r.sessionProcessId},json:{projectId:e,baseSessionId:n,input:r.input}},{init:{signal:AbortSignal.timeout(2e4)}});if(!a.ok)throw new Error(a.statusText);return a.json()}});function bz(){const[e,n]=O.useState({relative:{top:0,left:0},absolute:{top:0,left:0}}),r=O.useRef(null),a=O.useRef(null),t=O.useRef(null),i=O.useRef(null),o=O.useCallback(()=>{const d=a.current,g=r.current;if(d===null||g===null)return;const m=d.selectionStart,f=d.value.substring(0,m),h=d.value.substring(m),v=document.createTextNode(f),S=document.createTextNode(h),E=document.createElement("span");E.innerHTML=" ";const y=document.createElement("div");y.innerHTML="",y.append(v,E,S);const w=window.getComputedStyle(d);for(const T of["border","boxSizing","fontFamily","fontSize","fontWeight","letterSpacing","lineHeight","padding","textDecoration","textIndent","textTransform","whiteSpace","wordSpacing","wordWrap"])y.style[T]=w[T];y.style.visibility="hidden",g.prepend(y);const I=E.getBoundingClientRect(),b=g.getBoundingClientRect();return g.removeChild(y),{relative:{top:I.top-b.top-d.scrollTop,left:I.left-b.left-d.scrollLeft},absolute:{top:I.top-d.scrollTop,left:I.left-d.scrollLeft}}},[]),l=O.useCallback((d,g)=>{if(d.endsWith("@")||d.endsWith("/")){const m=o();m&&n(m)}g(d)},[o]),u=O.useCallback(d=>!!(i.current?.handleKeyDown(d)||t.current?.handleKeyDown(d)),[]),c=O.useCallback((d,g)=>{g(d),a.current?.focus()},[]),p=O.useCallback((d,g)=>{g(d),a.current?.focus()},[]);return{cursorPosition:e,containerRef:r,textareaRef:a,commandCompletionRef:t,fileCompletionRef:i,getCursorPosition:o,handleChange:l,handleKeyDown:u,handleCommandSelect:c,handleFileSelect:p}}const yz=({projectId:e,sessionId:n,sessionProcessId:r,sessionProcessStatus:a})=>{const{i18n:t}=Ke(),i=hz(e,n),{config:o}=kt(),l=async p=>{await i.mutateAsync({input:p,sessionProcessId:r})},u=()=>{const p=o?.enterKeyBehavior;return p==="enter-send"?t._({id:"chat.placeholder.continue.enter",message:"Type your message... (Start with / for commands, @ for files, Enter to send)"}):p==="command-enter-send"?t._({id:"chat.placeholder.continue.command_enter",message:"Type your message... (Start with / for commands, @ for files, Command+Enter to send)"}):t._({id:"chat.placeholder.continue.shift_enter",message:"Type your message... (Start with / for commands, @ for files, Shift+Enter to send)"})},c=a==="running";return s.jsx("div",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 pb-3",children:s.jsx(oc,{projectId:e,onSubmit:l,isPending:i.isPending,error:i.error,placeholder:u(),buttonText:s.jsx(R,{id:"chat.send"}),containerClassName:"",buttonSize:"default",enableScheduledSend:!c,baseSessionId:n,disabled:c})})},vz=({projectId:e,sessionId:n})=>{const{i18n:r}=Ke(),a=bS(e),{config:t}=kt(),i=async u=>{await a.mutateAsync({input:u,baseSessionId:n})},o=()=>{const u=t?.enterKeyBehavior;return u==="enter-send"?r._({id:"chat.placeholder.resume.enter",message:"Type your message... (Start with / for commands, @ for files, Enter to send)"}):u==="command-enter-send"?r._({id:"chat.placeholder.resume.command_enter",message:"Type your message... (Start with / for commands, @ for files, Command+Enter to send)"}):r._({id:"chat.placeholder.resume.shift_enter",message:"Type your message... (Start with / for commands, @ for files, Shift+Enter to send)"})},l=s.jsx(R,{id:"chat.resume"});return s.jsx("div",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 pb-3",children:s.jsx(oc,{projectId:e,onSubmit:i,isPending:a.isPending,error:a.error,placeholder:o(),buttonText:l,containerClassName:"",buttonSize:"default",enableScheduledSend:!0,baseSessionId:n})})},Sz=({projectId:e})=>{const{i18n:n}=Ke(),r=bS(e),{config:a}=kt(),t=async o=>{await r.mutateAsync({input:o})},i=()=>{const o=a?.enterKeyBehavior;return o==="enter-send"?n._({id:"chat.placeholder.continue.enter",message:"Type your message... (Start with / for commands, @ for files, Enter to send)"}):o==="command-enter-send"?n._({id:"chat.placeholder.continue.command_enter",message:"Type your message... (Start with / for commands, @ for files, Command+Enter to send)"}):n._({id:"chat.placeholder.continue.shift_enter",message:"Type your message... (Start with / for commands, @ for files, Shift+Enter to send)"})};return s.jsx("div",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 pb-3",children:s.jsx(oc,{projectId:e,onSubmit:t,isPending:r.isPending,error:r.error,placeholder:i(),buttonText:s.jsx(R,{id:"chat.button.start"}),containerClassName:"",buttonSize:"default",enableScheduledSend:!0})})},Ez=e=>e.sessionId?s.jsx(xz,{...e,sessionId:e.sessionId}):s.jsx(yS,{...e,sessionData:null}),xz=e=>{const n=NC(e.projectId,e.sessionId);return s.jsx(yS,{...e,sessionId:e.sessionId,sessionData:n})},yS=({projectId:e,sessionId:n,setIsMobileSidebarOpen:r,projectPath:a,currentBranch:t,revisionsData:i,projectName:o,sessionData:l})=>{const u=l?.conversations??[],c=()=>{},p=l?.getToolResult??c,d=!!n&&l!==null&&l!==void 0,{currentPermissionRequest:g,isDialogOpen:m,onPermissionResponse:f}=xC(),{data:h}=Tu(e),v=i??h,S=wC(),E=IC(),y=O.useMemo(()=>{if(n)return E.getSessionProcess(n)},[E,n]);kC(y?.status==="running");const[w,I]=O.useState(0),[b,T]=O.useState(!1),D=O.useRef(null),_=et({mutationFn:async $=>{const P=await ze.api.cc["session-processes"][":sessionProcessId"].abort.$post({param:{sessionProcessId:$},json:{projectId:e}});if(!P.ok)throw new Error(P.statusText);return P.json()}});O.useEffect(()=>{if(d&&y?.status==="running"&&u.length!==w){I(u.length);const $=D.current;$&&$.scrollTo({top:$.scrollHeight,behavior:"smooth"})}},[u,d,y?.status,w]);const k=()=>{const $=D.current;$&&$.scrollTo({top:0,behavior:"smooth"})},A=()=>{const $=D.current;$&&$.scrollTo({top:$.scrollHeight,behavior:"smooth"})};let j=o??e;return d?l&&n&&(j=l.session.meta.firstUserMessage!==null?Uy(l.session.meta.firstUserMessage):n):j=s.jsx(R,{id:"chat.modal.title"}),s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[s.jsxs("header",{className:"px-2 sm:px-3 py-2 sm:py-3 sticky top-0 z-10 bg-background w-full flex-shrink-0 min-w-0 border-b space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(re,{variant:"ghost",size:"sm",className:"md:hidden flex-shrink-0",onClick:()=>r(!0),"data-testid":"mobile-sidebar-toggle-button",children:s.jsx(DT,{className:"w-4 h-4"})}),s.jsx("h1",{className:"text-lg sm:text-2xl md:text-3xl font-bold break-all overflow-ellipsis line-clamp-1 min-w-0",children:j})]}),s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden flex-1",children:[a&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(pe,{variant:"secondary",className:"h-6 text-xs flex items-center max-w-full cursor-help",children:s.jsx("span",{className:"truncate",children:a.split("/").pop()})})}),s.jsx(Xe,{children:a})]}),t&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsxs(pe,{variant:"secondary",className:"h-6 text-xs flex items-center gap-1 max-w-full cursor-help",children:[s.jsx(Rn,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:t})]})}),s.jsx(Xe,{children:s.jsx(R,{id:"control.branch"})})]}),d&&n&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(pe,{variant:"secondary",className:"h-6 text-xs flex items-center max-w-full font-mono cursor-help",children:s.jsx("span",{className:"truncate",children:n})})}),s.jsx(Xe,{children:s.jsx(R,{id:"control.session_id"})})]})]}),y?.status==="running"&&s.jsxs(pe,{variant:"secondary",className:"bg-green-500/10 text-green-900 dark:text-green-200 border-green-500/20 flex-shrink-0 h-6 text-xs",children:[s.jsx(Cn,{className:"w-3 h-3 mr-1 animate-spin"}),s.jsx(R,{id:"session.conversation.running"})]}),y?.status==="paused"&&s.jsxs(pe,{variant:"secondary",className:"bg-orange-500/10 text-orange-900 dark:text-orange-200 border-orange-500/20 flex-shrink-0 h-6 text-xs",children:[s.jsx(MT,{className:"w-3 h-3 mr-1"}),s.jsx(R,{id:"session.conversation.paused"})]}),n!==void 0&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(re,{variant:"ghost",size:"icon",className:"flex-shrink-0 h-6 w-6",onClick:()=>S.mutate({projectId:e,sessionId:n}),disabled:S.isPending,"aria-label":"Export session to HTML",children:s.jsx(vT,{className:`w-3.5 h-3.5 ${S.isPending?"animate-pulse":""}`})})}),s.jsx(Xe,{children:"Export to HTML"})]}),s.jsxs(vC,{children:[s.jsx(SC,{asChild:!0,children:s.jsx(re,{variant:"ghost",size:"icon",className:"flex-shrink-0 h-6 w-6","aria-label":"Session metadata",children:s.jsx(vy,{className:"w-3.5 h-3.5"})})}),s.jsx(EC,{className:"w-80",align:"end",children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsx("h3",{className:"font-semibold text-sm mb-2",children:s.jsx(R,{id:"control.metadata"})}),s.jsxs("div",{className:"space-y-2",children:[a&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"control.project_path"})}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(pe,{variant:"secondary",className:"h-7 text-xs flex items-center w-fit cursor-help",children:a.split("/").pop()})}),s.jsx(Xe,{children:a})]})]}),n&&d&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"control.session_id"})}),s.jsx(pe,{variant:"secondary",className:"h-7 text-xs flex items-center w-fit font-mono",children:n})]}),t&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"control.branch"})}),s.jsxs(pe,{variant:"secondary",className:"h-7 text-xs flex items-center gap-1 w-fit",children:[s.jsx(Rn,{className:"w-3 h-3"}),t]})]}),d&&l&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"session.cost.label"})}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(pe,{variant:"secondary",className:"h-7 text-xs flex items-center w-fit font-semibold",children:[s.jsx(R,{id:"session.cost.total"}),": $",l.session.meta.cost.totalUsd.toFixed(3)]}),s.jsxs("div",{className:"text-xs space-y-1 pl-2",children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.input_tokens"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.inputTokensUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.inputTokens.toLocaleString(),")"]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.output_tokens"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.outputTokensUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.outputTokens.toLocaleString(),")"]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.cache_creation"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.cacheCreationUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.cacheCreationTokens.toLocaleString(),")"]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.cache_read"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.cacheReadUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.cacheReadTokens.toLocaleString(),")"]})]})]})]})]})]})]})})})]})]})]}),s.jsx("div",{ref:D,className:"flex-1 overflow-y-auto min-h-0 min-w-0","data-testid":"scrollable-content",children:s.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:[s.jsx(pS,{conversations:d?u:[],getToolResult:p,projectId:e,sessionId:n??""}),!d&&s.jsxs("div",{className:"rounded-2xl border border-dashed border-muted-foreground/40 bg-muted/30 p-8 text-center space-y-3",children:[s.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-background shadow-sm",children:s.jsx(pn,{className:"w-5 h-5 text-muted-foreground"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-base font-semibold",children:s.jsx(R,{id:"chat.modal.title"})}),s.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:s.jsx(R,{id:"session.empty_state.description"})})]})]}),d&&y?.status==="running"&&s.jsx("div",{className:"flex justify-start items-center py-8 animate-in fade-in duration-500",children:s.jsxs("div",{className:"flex flex-col items-center gap-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Cn,{className:"w-8 h-8 animate-spin text-primary"}),s.jsx("div",{className:"absolute inset-0 rounded-full bg-primary/20 animate-ping"})]}),s.jsx("p",{className:"text-sm text-muted-foreground font-medium animate-pulse",children:s.jsx(R,{id:"session.processing"})})]})})]})}),s.jsx("div",{className:"w-full pt-3",children:s.jsx(nz,{projectId:e,onScrollToTop:k,onScrollToBottom:A,onOpenDiffModal:d?()=>T(!0):void 0,sessionProcess:y,abortTask:_,isNewChat:!d})}),s.jsx("div",{className:"flex-shrink-0 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:d&&n&&y?s.jsx(yz,{projectId:e,sessionId:n,sessionProcessId:y.id,sessionProcessStatus:y.status}):d&&n?s.jsx(vz,{projectId:e,sessionId:n}):s.jsx(Sz,{projectId:e})})]}),d&&s.jsx(tz,{projectId:e,isOpen:b,onOpenChange:T,revisionsData:v}),s.jsx(aC,{permissionRequest:g,isOpen:m,onResponse:f})]})},vS=({projectId:e})=>{const n=Un(),{i18n:r}=Ke(),{data:a,isLoading:t,error:i,isFetching:o}=Pt({queryKey:Xn(e).queryKey,queryFn:Xn(e).queryFn,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchInterval:!1}),l=()=>{n.invalidateQueries({queryKey:Xn(e).queryKey})};return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{className:"p-3 border-b border-sidebar-border",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-semibold text-sidebar-foreground",children:s.jsx(R,{id:"mcp.title"})}),s.jsx(re,{onClick:l,variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:t||o,title:r._("Reload MCP servers"),children:s.jsx(my,{className:`w-3 h-3 ${t||o?"animate-spin":""}`})})]})}),s.jsxs("div",{className:"flex-1 overflow-auto p-3",children:[t&&s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:s.jsx(an,{})})}),i&&s.jsx("div",{className:"text-sm text-red-500",children:s.jsx(R,{id:"mcp.error.load_failed",values:{error:i.message}})}),a&&a.servers.length===0&&s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:s.jsx(R,{id:"mcp.no.servers"})}),a&&a.servers.length>0&&s.jsx("div",{className:"space-y-3",children:a.servers.map(u=>s.jsx("div",{className:"p-3 bg-sidebar-accent/50 rounded-md border border-sidebar-border",children:s.jsx("div",{className:"flex items-start justify-between",children:s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"text-sm font-medium text-sidebar-foreground truncate",children:u.name}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono break-all",children:u.command})]})})},u.name))})]})]})},SS=({currentSessionId:e,projectId:n})=>{const{data:r,fetchNextPage:a,hasNextPage:t,isFetchingNextPage:i}=Iu(n),o=r.pages.flatMap(m=>m.sessions),l=In(cy),{config:u}=kt(),p=zI({from:"/projects/$projectId/session"}).tab??"sessions",d=e==="",g=[...o].sort((m,f)=>{const h=l.find(D=>D.sessionId===m.id),v=l.find(D=>D.sessionId===f.id),S=h?.status,E=v?.status,y=D=>D==="running"?0:D==="paused"?1:2,w=y(S),I=y(E);if(w!==I)return w-I;const b=m.lastModifiedAt?new Date(m.lastModifiedAt).getTime():0;return(f.lastModifiedAt?new Date(f.lastModifiedAt).getTime():0)-b});return s.jsxs("div",{className:"h-full flex flex-col",children:[s.jsxs("div",{className:"border-b border-sidebar-border p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-2",children:s.jsx("h2",{className:"font-semibold text-lg",children:s.jsx(R,{id:"sessions.title"})})}),s.jsxs("p",{className:"text-xs text-sidebar-foreground/70",children:[o.length," ",s.jsx(R,{id:"sessions.total"})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-0.5",children:[s.jsx(An,{to:"/projects/$projectId/session",params:{projectId:n},search:{tab:p},className:ce("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",d&&"bg-blue-100 dark:bg-blue-900/40 border-blue-400 dark:border-blue-500 shadow-sm"),children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary",children:s.jsx(Nu,{className:"w-4 h-4"})}),s.jsx("div",{className:"space-y-0.5",children:s.jsx("p",{className:"text-sm font-semibold text-sidebar-foreground",children:s.jsx(R,{id:"chat.modal.title"})})})]})}),g.map(m=>{const f=m.id===e,h=m.meta.firstUserMessage!==null?Uy(m.meta.firstUserMessage):m.id,v=l.find(y=>y.sessionId===m.id),S=v?.status==="running",E=v?.status==="paused";return s.jsx(An,{to:"/projects/$projectId/session",params:{projectId:n},search:{tab:p,sessionId:m.id},className:ce("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",f&&"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:s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("h3",{className:"text-sm font-medium line-clamp-2 leading-tight text-sidebar-foreground flex-1",children:h}),(S||E)&&s.jsx(pe,{variant:S?"default":"secondary",className:ce("text-xs",S&&"bg-green-500 text-white",E&&"bg-yellow-500 text-white"),children:S?s.jsx(R,{id:"session.status.running"}):s.jsx(R,{id:"session.status.paused"})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3 text-xs text-sidebar-foreground/70",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(pn,{className:"w-3 h-3"}),s.jsx("span",{children:m.meta.messageCount})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(hT,{className:"w-3 h-3"}),s.jsxs("span",{children:["$",m.meta.cost.totalUsd.toFixed(2)]})]})]}),m.lastModifiedAt&&s.jsx("span",{className:"text-xs text-sidebar-foreground/60",children:_u(m.lastModifiedAt,{locale:u.locale,target:"time"})})]})]})},m.id)}),t&&a&&s.jsx("div",{className:"p-2",children:s.jsx(re,{onClick:()=>a(),disabled:i,variant:"outline",size:"sm",className:"w-full",children:i?s.jsx(R,{id:"common.loading"}):s.jsx(R,{id:"sessions.load.more"})})})]})]})},kz=({currentSessionId:e,projectId:n,isOpen:r,onClose:a})=>{const{i18n:t}=Ke(),[i,o]=O.useState("sessions"),[l,u]=O.useState(!1);O.useEffect(()=>{u(!0)},[]),O.useEffect(()=>{const g=m=>{m.key==="Escape"&&a()};return r&&(document.addEventListener("keydown",g),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",g),document.body.style.overflow=""}},[r,a]);const c=g=>{o(g)},p=g=>{g.target===g.currentTarget&&a()},d=()=>{switch(i){case"sessions":return s.jsx(SS,{currentSessionId:e,projectId:n,isMobile:!0});case"mcp":return s.jsx(vS,{projectId:n});case"settings":return s.jsx("div",{className:"h-full flex flex-col",children:s.jsx(O.Suspense,{fallback:s.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:s.jsx("div",{className:"text-sm text-sidebar-foreground/70",children:s.jsx(R,{id:"settings.loading"})})}),children:s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"font-medium text-sm text-sidebar-foreground",children:s.jsx(R,{id:"settings.session.display"})}),s.jsx(rT,{openingProjectId:n})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"font-medium text-sm text-sidebar-foreground",children:s.jsx(R,{id:"settings.notifications"})}),s.jsx(aT,{})]})]})})});case"system-info":return s.jsx(nT,{});default:return null}};return l?qI.createPortal(s.jsxs("div",{className:ce("fixed inset-0 z-50 transition-all duration-300 ease-out md:hidden",r?"visible opacity-100":"invisible opacity-0 pointer-events-none"),children:[s.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm cursor-default",onClick:p,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&a()},"aria-label":t._("Close sidebar")}),s.jsxs("div",{className:ce("absolute left-0 top-0 h-full w-80 max-w-[85vw] bg-sidebar text-sidebar-foreground transition-transform duration-300 ease-out flex",r?"translate-x-0":"-translate-x-full"),children:[s.jsx("div",{className:"w-12 flex flex-col border-r border-sidebar-border bg-sidebar/50",children:s.jsxs(Sy,{children:[s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(An,{to:"/projects",className:"w-12 h-12 flex items-center justify-center border-b border-sidebar-border hover:bg-sidebar-accent transition-colors",children:s.jsx(Ey,{className:"w-4 h-4 text-sidebar-foreground/70"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.back.to.projects"})})})]}),s.jsxs("div",{className:"flex flex-col p-2 space-y-1",children:[s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("sessions"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="sessions"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"sessions-tab-button-mobile",children:s.jsx(pn,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.show.session.list"})})})]}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("mcp"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="mcp"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"mcp-tab-button-mobile",children:s.jsx(ky,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.show.mcp.settings"})})})]}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("settings"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="settings"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"settings-tab-button-mobile",children:s.jsx(tT,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx(R,{id:"settings.tab.title"})})]}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("system-info"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="system-info"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"system-info-tab-button-mobile",children:s.jsx(vy,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx(R,{id:"system.info.tab.title"})})]})]})]})}),s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-sidebar-border bg-sidebar/80 backdrop-blur-sm",children:[s.jsx("h2",{className:"text-lg font-semibold capitalize",children:i}),s.jsx(re,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0 hover:bg-sidebar-accent/50",children:s.jsx(wu,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"flex-1 overflow-hidden",children:d()})]})]})]}),document.body):null},ES=O.forwardRef(({className:e,checked:n,onCheckedChange:r,disabled:a,...t},i)=>{const o=l=>{r?.(l.target.checked),t.onChange?.(l)};return s.jsxs("label",{className:ce("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",a&&"cursor-not-allowed opacity-50",n?"bg-primary":"bg-input",e),children:[s.jsx("input",{type:"checkbox",className:"sr-only",ref:i,checked:n,onChange:o,disabled:a,...t}),s.jsx("span",{className:ce("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform",n?"translate-x-4":"translate-x-0")})]})});ES.displayName="Switch";const xS=[{value:0,labelKey:s.jsx(R,{id:"cron_builder.sunday"})},{value:1,labelKey:s.jsx(R,{id:"cron_builder.monday"})},{value:2,labelKey:s.jsx(R,{id:"cron_builder.tuesday"})},{value:3,labelKey:s.jsx(R,{id:"cron_builder.wednesday"})},{value:4,labelKey:s.jsx(R,{id:"cron_builder.thursday"})},{value:5,labelKey:s.jsx(R,{id:"cron_builder.friday"})},{value:6,labelKey:s.jsx(R,{id:"cron_builder.saturday"})}];function wz(e){const n=e.trim().split(/\s+/);if(n.length!==5)return null;const r=n[0],a=n[1],t=n[4];if(!r||!a||!t)return null;if(a==="*"&&r==="0")return{mode:"hourly",hour:0,minute:0,dayOfWeek:0};if(t==="*"&&a!=="*"){const i=Number.parseInt(a,10),o=Number.parseInt(r,10);if(!Number.isNaN(i)&&!Number.isNaN(o))return{mode:"daily",hour:i,minute:o,dayOfWeek:0}}if(t!=="*"&&a!=="*"){const i=Number.parseInt(a,10),o=Number.parseInt(r,10),l=Number.parseInt(t,10);if(!Number.isNaN(i)&&!Number.isNaN(o)&&!Number.isNaN(l))return{mode:"weekly",hour:i,minute:o,dayOfWeek:l}}return{mode:"custom",hour:0,minute:0,dayOfWeek:0}}function ub(e,n,r,a){switch(e){case"hourly":return"0 * * * *";case"daily":return`${r} ${n} * * *`;case"weekly":return`${r} ${n} * * ${a}`;case"custom":return"0 0 * * *"}}function _z(e){const n=e.trim().split(/\s+/);if(n.length!==5)return!1;const r=n[0],a=n[1],t=n[2],i=n[3],o=n[4];if(!r||!a||!t||!i||!o)return!1;const l=(u,c,p)=>{if(u==="*")return!0;const d=Number.parseInt(u,10);return!Number.isNaN(d)&&d>=c&&d<=p};return l(r,0,59)&&(a==="*"||l(a,0,23))&&(t==="*"||l(t,1,31))&&(i==="*"||l(i,1,12))&&(o==="*"||l(o,0,6))}function Nz(e){const n=e.trim().split(/\s+/);if(n.length!==5)return"Invalid cron expression";const r=n[0],a=n[1],t=n[4];if(!r||!a||!t)return"Invalid cron expression";if(a==="*")return`Every hour at ${r} minute(s)`;const i=`${a.padStart(2,"0")}:${r.padStart(2,"0")}`;if(t==="*")return`Every day at ${i}`;const o=Number.parseInt(t,10),l=xS.find(u=>u.value===o);return s.jsxs(s.Fragment,{children:["Every ",l?l.labelKey:"unknown"," at ",i]})}function Iz({value:e,onChange:n}){const r=wz(e),[a,t]=O.useState(r?.mode||"daily"),[i,o]=O.useState(r?.hour||9),[l,u]=O.useState(r?.minute||0),[c,p]=O.useState(r?.dayOfWeek||1),[d,g]=O.useState(e),[m,f]=O.useState(null);O.useEffect(()=>{if(a==="custom")_z(d)?(n(d),f(null)):f("Invalid cron expression");else{const v=ub(a,i,l,c);n(v),g(v),f(null)}},[a,i,l,c,d,n]);const h=v=>{if(t(v),v!=="custom"){const S=ub(v,i,l,c);g(S)}};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.schedule_type"})}),s.jsxs(Ot,{value:a,onValueChange:h,children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"hourly",children:s.jsx(R,{id:"cron_builder.hourly"})}),s.jsx(Ve,{value:"daily",children:s.jsx(R,{id:"cron_builder.daily"})}),s.jsx(Ve,{value:"weekly",children:s.jsx(R,{id:"cron_builder.weekly"})}),s.jsx(Ve,{value:"custom",children:s.jsx(R,{id:"cron_builder.custom"})})]})]})]}),a==="daily"&&s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.hour"})}),s.jsx(ht,{type:"number",min:"0",max:"23",value:i,onChange:v=>o(Number.parseInt(v.target.value,10))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.minute"})}),s.jsx(ht,{type:"number",min:"0",max:"59",value:l,onChange:v=>u(Number.parseInt(v.target.value,10))})]})]}),a==="weekly"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.day_of_week"})}),s.jsxs(Ot,{value:String(c),onValueChange:v=>p(Number.parseInt(v,10)),children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsx($t,{children:xS.map(v=>s.jsx(Ve,{value:String(v.value),children:v.labelKey},v.value))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.hour"})}),s.jsx(ht,{type:"number",min:"0",max:"23",value:i,onChange:v=>o(Number.parseInt(v.target.value,10))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.minute"})}),s.jsx(ht,{type:"number",min:"0",max:"59",value:l,onChange:v=>u(Number.parseInt(v.target.value,10))})]})]})]}),a==="custom"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.cron_expression"})}),s.jsx(ht,{value:d,onChange:v=>g(v.target.value),placeholder:"0 9 * * *"})]}),s.jsxs("div",{className:"rounded-md border p-3 text-sm",children:[s.jsx("div",{className:"font-medium mb-1",children:s.jsx(R,{id:"cron_builder.preview"})}),s.jsx("div",{className:"text-muted-foreground",children:m?s.jsx("span",{className:"text-destructive",children:m}):Nz(a==="custom"?d:e)}),s.jsxs("div",{className:"text-xs text-muted-foreground mt-2",children:[s.jsx(R,{id:"cron_builder.expression"}),":"," ",s.jsx("code",{children:a==="custom"?d:e})]})]})]})}const Tz=({open:e,onOpenChange:n,job:r,projectId:a,onSubmit:t,isSubmitting:i=!1})=>{const{_:o,i18n:l}=Ke(),[u,c]=O.useState(""),[p,d]=O.useState("cron"),[g,m]=O.useState("0 9 * * *"),[f,h]=O.useState(()=>{const _=new Date;return _.setHours(_.getHours()+1),_.toISOString().slice(0,16)}),[v,S]=O.useState(""),[E,y]=O.useState(!0),[w,I]=O.useState("skip"),b=bz();O.useEffect(()=>{if(r){if(c(r.name),d(r.schedule.type),r.schedule.type==="cron")m(r.schedule.expression),I(r.schedule.concurrencyPolicy);else if(r.schedule.type==="reserved"){const _=new Date(r.schedule.reservedExecutionTime),k=_.getFullYear(),A=String(_.getMonth()+1).padStart(2,"0"),j=String(_.getDate()).padStart(2,"0"),$=String(_.getHours()).padStart(2,"0"),P=String(_.getMinutes()).padStart(2,"0");h(`${k}-${A}-${j}T${$}:${P}`)}S(r.message.content),y(r.enabled)}else{c(""),d("cron"),m("0 9 * * *");const _=new Date;_.setHours(_.getHours()+1);const k=_.getFullYear(),A=String(_.getMonth()+1).padStart(2,"0"),j=String(_.getDate()).padStart(2,"0"),$=String(_.getHours()).padStart(2,"0"),P=String(_.getMinutes()).padStart(2,"0");h(`${k}-${A}-${j}T${$}:${P}`),S(""),y(!0),I("skip")}},[r]);const T=()=>{const _={name:u,schedule:p==="cron"?{type:"cron",expression:g,concurrencyPolicy:w}:{type:"reserved",reservedExecutionTime:(()=>{const k=f.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/);if(!k)throw new Error("Invalid datetime format");const A=Number(k[1]),j=Number(k[2]),$=Number(k[3]),P=Number(k[4]),z=Number(k[5]);return new Date(A,j-1,$,P,z).toISOString()})()},message:{content:v,projectId:a,baseSessionId:null},enabled:E};t(_)},D=u.trim()!==""&&v.trim()!=="";return s.jsx(cn,{open:e,onOpenChange:n,children:s.jsxs(dn,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsxs(jn,{children:[s.jsx(Mn,{children:r?s.jsx(R,{id:"scheduler.dialog.title.edit"}):s.jsx(R,{id:"scheduler.dialog.title.create"})}),s.jsx(Pn,{children:s.jsx(R,{id:"scheduler.dialog.description"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(Ie,{htmlFor:"enabled",className:"text-base font-semibold",children:s.jsx(R,{id:"scheduler.form.enabled"})}),s.jsx("p",{className:"text-sm text-muted-foreground",children:s.jsx(R,{id:"scheduler.form.enabled.description"})})]}),s.jsx(ES,{id:"enabled",checked:E,onCheckedChange:y,disabled:i})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{htmlFor:"job-name",children:s.jsx(R,{id:"scheduler.form.name"})}),s.jsx(ht,{id:"job-name",value:u,onChange:_=>c(_.target.value),placeholder:o({id:"scheduler.form.name.placeholder",message:"e.g., Daily Report"}),disabled:i})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"scheduler.form.schedule_type"})}),s.jsxs(Ot,{value:p,onValueChange:_=>d(_),disabled:i,children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"cron",children:s.jsx(R,{id:"scheduler.form.schedule_type.cron"})}),s.jsx(Ve,{value:"reserved",children:s.jsx(R,{id:"scheduler.form.schedule_type.reserved"})})]})]})]}),p==="cron"?s.jsx(Iz,{value:g,onChange:m}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{htmlFor:"reserved-datetime",children:s.jsx(R,{id:"scheduler.form.reserved_time"})}),s.jsx(ht,{id:"reserved-datetime",type:"datetime-local",value:f,onChange:_=>h(_.target.value),disabled:i}),s.jsx("p",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"scheduler.form.reserved_time.hint"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{htmlFor:"message-content",children:s.jsx(R,{id:"scheduler.form.message"})}),s.jsxs("div",{className:"relative",ref:b.containerRef,children:[s.jsx(ic,{ref:b.textareaRef,id:"message-content",value:v,onChange:_=>b.handleChange(_.target.value,S),onKeyDown:_=>b.handleKeyDown(_),placeholder:l._({id:"scheduler.form.message.placeholder",message:"Type message to send to Claude Code... (/ for commands, @ for files)"}),rows:4,disabled:i,className:"resize-none","aria-label":l._({id:"scheduler.form.message.aria_label",message:"Message input with completion support (/ for commands, @ for files)"}),"aria-expanded":v.startsWith("/")||v.includes("@"),"aria-haspopup":"listbox",role:"combobox","aria-autocomplete":"list"}),s.jsx(hS,{projectId:a,message:v,commandCompletionRef:b.commandCompletionRef,fileCompletionRef:b.fileCompletionRef,handleCommandSelect:_=>b.handleCommandSelect(_,S),handleFileSelect:_=>b.handleFileSelect(_,S),cursorPosition:b.cursorPosition})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"scheduler.form.message.hint"})})]}),p==="cron"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"scheduler.form.concurrency_policy"})}),s.jsxs(Ot,{value:w,onValueChange:_=>I(_),disabled:i,children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"skip",children:s.jsx(R,{id:"scheduler.form.concurrency_policy.skip"})}),s.jsx(Ve,{value:"run",children:s.jsx(R,{id:"scheduler.form.concurrency_policy.run"})})]})]})]})]}),s.jsxs(gy,{children:[s.jsx(re,{variant:"outline",onClick:()=>n(!1),disabled:i,children:s.jsx(R,{id:"common.cancel"})}),s.jsx(re,{onClick:T,disabled:!D||i,children:i?s.jsx(R,{id:"common.saving"}):r?s.jsx(R,{id:"common.update"}):s.jsx(R,{id:"common.create"})})]})]})})},Az=({projectId:e,sessionId:n})=>{const{i18n:r}=Ke(),{data:a,isLoading:t,isFetching:i,error:o,refetch:l}=rz(),u=mS(),c=az(),p=iz(),[d,g]=O.useState(!1),[m,f]=O.useState(null),[h,v]=O.useState(!1),[S,E]=O.useState(null),y=k=>{u.mutate(k,{onSuccess:()=>{de.success(r._({id:"scheduler.job.created",message:"Job created successfully"})),g(!1)},onError:A=>{de.error(r._({id:"scheduler.job.create_failed",message:"Failed to create job"}),{description:A.message})}})},w=k=>{m&&c.mutate({id:m.id,updates:k},{onSuccess:()=>{de.success(r._({id:"scheduler.job.updated",message:"Job updated successfully"})),g(!1),f(null)},onError:A=>{de.error(r._({id:"scheduler.job.update_failed",message:"Failed to update job"}),{description:A.message})}})},I=()=>{S&&p.mutate(S,{onSuccess:()=>{de.success(r._({id:"scheduler.job.deleted",message:"Job deleted successfully"})),v(!1),E(null)},onError:k=>{de.error(r._({id:"scheduler.job.delete_failed",message:"Failed to delete job"}),{description:k.message})}})},b=k=>{f(k),g(!0)},T=k=>{E(k),v(!0)},D=k=>k.schedule.type==="cron"?`Cron: ${k.schedule.expression}`:k.schedule.type==="reserved"?`Reserved: ${new Date(k.schedule.reservedExecutionTime).toLocaleString()}`:"Unknown schedule type",_=k=>k?new Date(k).toLocaleString():"Never";return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{className:"p-3 border-b border-sidebar-border",children:s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h2",{className:"text-sm font-semibold text-sidebar-foreground",children:s.jsx(R,{id:"scheduler.title"})}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(re,{onClick:()=>l(),variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:t||i,title:r._({id:"common.reload",message:"Reload"}),children:s.jsx(my,{className:`w-3 h-3 ${t||i?"animate-spin":""}`})}),s.jsx(re,{onClick:()=>{f(null),g(!0)},variant:"ghost",size:"sm",className:"h-7 w-7 p-0",title:r._({id:"scheduler.create_job",message:"Create Job"}),children:s.jsx(Nu,{className:"w-3 h-3"})})]})]})}),s.jsxs("div",{className:"flex-1 overflow-auto p-3",children:[t&&s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:s.jsx(an,{})})}),o&&s.jsx("div",{className:"text-sm text-red-500",children:s.jsx(R,{id:"scheduler.error.load_failed",values:{error:o.message}})}),a&&a.length===0&&s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:s.jsx(R,{id:"scheduler.no_jobs"})}),a&&a.length>0&&s.jsx("div",{className:"space-y-3",children:a.map(k=>s.jsxs("div",{className:"p-3 bg-sidebar-accent/50 rounded-md border border-sidebar-border",children:[s.jsxs("div",{className:"flex items-start justify-between mb-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-medium text-sidebar-foreground truncate",children:k.name}),s.jsx(pe,{variant:k.enabled?"default":"secondary",className:"text-xs",children:k.enabled?s.jsx(R,{id:"scheduler.status.enabled"}):s.jsx(R,{id:"scheduler.status.disabled"})})]}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:D(k)})]}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(re,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>b(k),children:s.jsx(VT,{className:"w-3 h-3"})}),s.jsx(re,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive hover:text-destructive",onClick:()=>T(k.id),children:s.jsx(YT,{className:"w-3 h-3"})})]})]}),k.lastRunAt&&s.jsx("div",{className:"text-xs text-muted-foreground mt-2 pt-2 border-t border-sidebar-border",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{children:[s.jsx(R,{id:"scheduler.last_run"}),s.jsx("span",{children:_(k.lastRunAt)})]}),k.lastRunStatus&&s.jsx(pe,{variant:k.lastRunStatus==="success"?"default":"destructive",className:"text-xs",children:k.lastRunStatus})]})})]},k.id))})]}),s.jsx(Tz,{open:d,onOpenChange:k=>{g(k),k||f(null)},job:m,projectId:e,currentSessionId:n,onSubmit:m?w:y,isSubmitting:u.isPending||c.isPending}),s.jsx(cn,{open:h,onOpenChange:v,children:s.jsxs(dn,{children:[s.jsxs(jn,{children:[s.jsx(Mn,{children:s.jsx(R,{id:"scheduler.delete_dialog.title"})}),s.jsx(Pn,{children:s.jsx(R,{id:"scheduler.delete_dialog.description"})})]}),s.jsxs(gy,{children:[s.jsx(re,{variant:"outline",onClick:()=>{v(!1),E(null)},disabled:p.isPending,children:s.jsx(R,{id:"common.cancel"})}),s.jsx(re,{variant:"destructive",onClick:I,disabled:p.isPending,children:p.isPending?s.jsx(R,{id:"common.deleting"}):s.jsx(R,{id:"common.delete"})})]})]})})]})},Rz=({currentSessionId:e,projectId:n,className:r,isMobileOpen:a=!1,onMobileOpenChange:t,initialTab:i})=>{const o=e??"",l=O.useMemo(()=>[{id:"sessions",icon:pn,title:s.jsx(R,{id:"sidebar.show.session.list"}),content:s.jsx(O.Suspense,{fallback:s.jsx(an,{}),children:s.jsx(SS,{currentSessionId:o,projectId:n})})},{id:"mcp",icon:ky,title:s.jsx(R,{id:"sidebar.show.mcp.settings"}),content:s.jsx(vS,{projectId:n})},{id:"scheduler",icon:gT,title:s.jsx(R,{id:"sidebar.show.scheduler.jobs"}),content:s.jsx(Az,{projectId:n,sessionId:o})}],[o,n]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:ce("hidden md:flex h-full",r),children:s.jsx(iT,{projectId:n,additionalTabs:l,defaultActiveTab:i,headerButton:s.jsx(Sy,{children:s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(An,{to:"/projects",className:"w-12 h-12 flex items-center justify-center hover:bg-sidebar-accent transition-colors",children:s.jsx(Ey,{className:"w-4 h-4 text-sidebar-foreground/70"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.back.to.projects"})})})]})})})}),s.jsx(kz,{currentSessionId:o,projectId:n,isOpen:a,onClose:()=>t?.(!1)})]})},Cz=({projectId:e,sessionId:n,isMobileSidebarOpen:r,setIsMobileSidebarOpen:a,tab:t})=>{const{data:i}=Iu(e),{data:o}=Tu(e),l=i.pages[0];if(l===void 0)return null;const u=l.project,c=u.meta.projectPath??u.claudeProjectPath,p=o?.success?o.data.currentBranch?.name:void 0;return s.jsxs(s.Fragment,{children:[s.jsx(O.Suspense,{fallback:s.jsx(an,{}),children:s.jsx(Rz,{currentSessionId:n,projectId:e,isMobileOpen:r,onMobileOpenChange:a,initialTab:t})}),s.jsx(O.Suspense,{fallback:s.jsx(an,{}),children:s.jsx(Ez,{projectId:e,sessionId:n,setIsMobileSidebarOpen:a,projectPath:c,currentBranch:p,revisionsData:o,projectName:u.meta.projectName??"Untitled Project"})})]})},Oz=({projectId:e,sessionId:n,tab:r})=>{const[a,t]=O.useState(!1);return s.jsx("div",{className:"flex h-screen max-h-screen overflow-hidden",children:s.jsx(Cz,{projectId:e,sessionId:n,tab:r,isMobileSidebarOpen:a,setIsMobileSidebarOpen:t})})};function Mz(){const e=vc.useParams(),n=vc.useSearch(),{data:r}=Iu(e.projectId),a=r.pages[0]?.project.meta.projectName,{sessionId:t,tab:i}=n,o=a?`${a} - Claude Code Viewer`:"Claude Code Viewer";return s.jsxs(oT,{children:[s.jsx(GI,{children:s.jsx("title",{children:o})}),s.jsx(Oz,{projectId:e.projectId,sessionId:t,tab:i})]})}export{Mz as component};
|
|
182
|
+
`),q4=({conversation:e})=>{const n=e.operation==="enqueue"?"Queue Operation: Enqueue":"Queue Operation: Dequeue";return s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:n}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Operation:"})," ",e.operation]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Session ID:"})," ",e.sessionId]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Timestamp:"})," ",e.timestamp]}),e.operation==="enqueue"&&s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-muted-foreground",children:"Content:"}),s.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap",children:z4(e.content)})]})]})})})]})},G4=({children:e})=>s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2 mb-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:"Summarized"}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsx("pre",{className:"text-xs overflow-x-auto",children:e})})})]}),H4=({children:e})=>s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.jsxs("div",{className:"flex items-center justify-between cursor-pointer hover:bg-muted/50 rounded p-2 -mx-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:"System Message"}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border p-3 mt-2",children:s.jsx("pre",{className:"text-xs overflow-x-auto",children:e})})})]}),V4=/<(?<tag>[^>]+)>(?<content>\s*[^<]*?\s*)<\/\k<tag>>/g,W4=Je({tag:He(),content:He()});xu([Je({kind:ct("command"),commandName:He(),commandArgs:He().optional(),commandMessage:He().optional()}),Je({kind:ct("local-command"),stdout:He()}),Je({kind:ct("text"),content:He()})]);const K4=e=>{const n=Array.from(e.matchAll(V4)).map(o=>W4.safeParse(o.groups)).filter(o=>o.success).map(o=>o.data);if(n.length===0)return{kind:"text",content:e};const r=n.find(o=>o.tag==="command-name")?.content,a=n.find(o=>o.tag==="command-args")?.content,t=n.find(o=>o.tag==="command-message")?.content,i=n.find(o=>o.tag==="local-command-stdout")?.content;switch(!0){case r!==void 0:return{kind:"command",commandName:r,commandArgs:a,commandMessage:t};case i!==void 0:return{kind:"local-command",stdout:i};default:return{kind:"text",content:e}}},ab=({text:e,id:n})=>{const r=K4(e);return r.kind==="command"?s.jsxs(ut,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3",id:n,children:[s.jsx(nn,{className:"py-0 px-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(au,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),s.jsx(rn,{className:"text-sm font-medium",children:"Claude Code Command"}),s.jsx(pe,{variant:"outline",className:"border-green-300 text-green-700 dark:border-green-700 dark:text-green-300",children:r.commandName})]})}),r.commandArgs||r.commandMessage?s.jsx(fc,{className:"py-0 px-4",children:s.jsx("div",{className:"space-y-2",children:s.jsxs("div",{children:[r.commandArgs&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Arguments:"}),s.jsx("div",{className:"bg-background rounded border p-2 mt-1",children:s.jsx("code",{className:"text-xs whitespace-pre-line break-all",children:r.commandArgs})})]}),r.commandMessage&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Message:"}),s.jsx("div",{className:"bg-background rounded border p-2 mt-1",children:s.jsx("code",{className:"text-xs whitespace-pre-line break-all",children:r.commandMessage})})]})]})})}):null]}):r.kind==="local-command"?s.jsxs(ut,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 gap-2 py-3 mb-3",children:[s.jsx(nn,{className:"py-0 px-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(au,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),s.jsx(rn,{className:"text-sm font-medium",children:"Local Command"})]})}),s.jsx(fc,{className:"py-0 px-4",children:s.jsx("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words",children:r.stdout})})]}):s.jsx(cS,{className:"w-full px-3 py-3 mb-5 border border-border rounded-lg bg-slate-50 dark:bg-slate-900/50",content:r.content})},ib=({content:e,id:n})=>typeof e=="string"?s.jsx(ab,{text:e,id:n}):e.type==="text"?s.jsx(ab,{text:e.text,id:n}):e.type==="image"?e.source.type==="base64"?s.jsx(ut,{className:"border-purple-200 bg-purple-50/50 dark:border-purple-800 dark:bg-purple-950/20 mb-2 p-0 overflow-hidden",id:n,children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.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:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(TT,{className:"h-4 w-4 text-purple-600 dark:text-purple-400"}),s.jsx("span",{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.image"})}),s.jsx(pe,{variant:"outline",className:"border-purple-300 text-purple-700 dark:border-purple-700 dark:text-purple-300",children:e.source.media_type}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-3 px-4 border-t border-purple-200 dark:border-purple-800",children:s.jsx("div",{className:"rounded-lg border overflow-hidden bg-background",children:s.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"})})})})]})}):s.jsx(ut,{className:"border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20",id:n,children:s.jsxs(nn,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nu,{className:"h-4 w-4 text-red-600 dark:text-red-400"}),s.jsx(rn,{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.unsupported_media"})}),s.jsx(pe,{variant:"destructive",children:s.jsx(R,{id:"common.error"})})]}),s.jsx(hc,{className:"text-xs",children:s.jsx(R,{id:"user.content.unsupported_media.description"})})]})}):e.type==="document"?e.source.type==="base64"&&e.source.media_type==="application/pdf"?s.jsx(ut,{className:"border-blue-200 bg-blue-50/50 dark:border-blue-800 dark:bg-blue-950/20 mb-2 p-0 overflow-hidden",id:n,children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.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:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ru,{className:"h-4 w-4 text-blue-600 dark:text-blue-400"}),s.jsx("span",{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.document.pdf"})}),s.jsx(pe,{variant:"outline",className:"border-blue-300 text-blue-700 dark:border-blue-700 dark:text-blue-300",children:e.source.media_type}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-3 px-4 border-t border-blue-200 dark:border-blue-800",children:s.jsx("div",{className:"rounded-lg border overflow-hidden bg-background",children:s.jsx("embed",{src:`data:${e.source.media_type};base64,${e.source.data}`,type:"application/pdf",className:"w-full h-[600px]"})})})})]})}):e.source.type==="text"?s.jsx(ut,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/20 mb-2 p-0 overflow-hidden",id:n,children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.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:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ru,{className:"h-4 w-4 text-green-600 dark:text-green-400"}),s.jsx("span",{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.document.text"})}),s.jsx(pe,{variant:"outline",className:"border-green-300 text-green-700 dark:border-green-700 dark:text-green-300",children:e.source.media_type}),s.jsx($e,{className:"h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180 ml-auto"})]})})}),s.jsx(je,{children:s.jsx("div",{className:"py-3 px-4 border-t border-green-200 dark:border-green-800",children:s.jsx("div",{className:"rounded-lg border overflow-hidden bg-background",children:s.jsx("pre",{className:"p-4 text-sm overflow-auto max-h-96",children:e.source.data})})})})]})}):s.jsx(ut,{className:"border-red-200 bg-red-50/50 dark:border-red-800 dark:bg-red-950/20",id:n,children:s.jsxs(nn,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(nu,{className:"h-4 w-4 text-red-600 dark:text-red-400"}),s.jsx(rn,{className:"text-sm font-medium",children:s.jsx(R,{id:"user.content.unsupported_document"})}),s.jsx(pe,{variant:"destructive",children:s.jsx(R,{id:"common.error"})})]}),s.jsx(hc,{className:"text-xs",children:s.jsx(R,{id:"user.content.unsupported_document.description"})})]})}):(e.type==="tool_result",null),Y4=({conversation:e,getToolResult:n,getAgentIdForToolUse:r,getSidechainConversationByPrompt:a,getSidechainConversations:t,projectId:i,sessionId:o})=>{if(e.type==="summary")return s.jsx(G4,{children:e.summary});if(e.type==="system")return s.jsx(H4,{children:e.content});if(e.type==="file-history-snapshot")return s.jsx(F4,{conversation:e});if(e.type==="queue-operation")return s.jsx(q4,{conversation:e});if(e.type==="user"){const l=typeof e.message.content=="string"?s.jsx(ib,{content:e.message.content,id:`message-${e.uuid}`}):s.jsx("ul",{className:"w-full",id:`message-${e.uuid}`,children:e.message.content.map(u=>s.jsx("li",{children:s.jsx(ib,{content:u})},u.toString()))});return e.isMeta===!0?s.jsx(B4,{children:l}):l}return e.type==="assistant"?s.jsx("ul",{className:"w-full",children:e.message.content.map(l=>s.jsx("li",{children:s.jsx(P4,{content:l,getToolResult:n,getAgentIdForToolUse:r,getSidechainConversationByPrompt:a,getSidechainConversations:t,projectId:i,sessionId:o})},l.toString()))}):null},Z4=e=>typeof e=="object"&&e!==null&&"agentId"in e&&typeof e.agentId=="string",ob=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}`;throw new Error(`Unknown conversation type: ${e}`)},X4=({errorLine:e})=>s.jsx("li",{className:"w-full flex justify-start",children:s.jsx("div",{className:"w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%] px-2",children:s.jsxs(Le,{children:[s.jsx(We,{asChild:!0,children:s.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:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ec,{className:"h-3 w-3 text-red-500"}),s.jsx("span",{className:"text-xs font-medium text-red-600",children:s.jsx(R,{id:"conversation.error.schema"})})]}),s.jsx($e,{className:"h-3 w-3 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]})}),s.jsx(je,{children:s.jsx("div",{className:"bg-background rounded border border-red-200 p-3 mt-2",children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs(UI,{variant:"destructive",className:"border-red-200 bg-red-50",children:[s.jsx(Ec,{className:"h-4 w-4"}),s.jsx(FI,{className:"text-red-800",children:s.jsx(R,{id:"conversation.error.schema_validation"})}),s.jsxs(BI,{className:"text-red-700",children:[s.jsx(R,{id:"conversation.error.schema_validation.description"})," ",s.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:[s.jsx(R,{id:"conversation.error.report_issue"}),s.jsx(ET,{className:"h-3 w-3"})]})]})]}),s.jsxs("div",{className:"bg-gray-50 border rounded px-3 py-2",children:[s.jsx("h5",{className:"text-xs font-medium text-gray-700 mb-2",children:s.jsx(R,{id:"conversation.error.raw_content"})}),s.jsx("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-all font-mono text-gray-800",children:e})]})]})})})]})})}),pS=({conversations:e,getToolResult:n,projectId:r,sessionId:a})=>{const t=O.useMemo(()=>e.filter(d=>d.type!=="x-error"),[e]),{isRootSidechain:i,getSidechainConversations:o,getSidechainConversationByPrompt:l,existsRelatedTaskCall:u}=U4(t),c=O.useMemo(()=>{const d=new Map;for(const g of t){if(g.type!=="user")continue;const m=g.message.content;if(typeof m!="string"){for(const f of m)if(typeof f!="string"&&f.type==="tool_result"){const h=g.toolUseResult;Z4(h)&&d.set(f.tool_use_id,h.agentId)}}}return d},[t]),p=O.useCallback(d=>c.get(d),[c]);return s.jsx("ul",{children:e.flatMap(d=>{if(d.type==="x-error")return s.jsx(X4,{errorLine:d.line},`error_${d.line}`);const g=s.jsx(Y4,{conversation:d,getToolResult:n,getAgentIdForToolUse:p,isRootSidechain:i,getSidechainConversations:o,getSidechainConversationByPrompt:l,existsRelatedTaskCall:u,projectId:r,sessionId:a},ob(d)),m=d.type!=="summary"&&d.type!=="file-history-snapshot"&&d.type!=="queue-operation"&&d.isSidechain;return m?[]:[s.jsx("li",{className:`w-full flex ${m||d.type==="assistant"||d.type==="system"||d.type==="summary"?"justify-start":"justify-end"} animate-in fade-in slide-in-from-bottom-2 duration-300`,children:s.jsx("div",{className:"w-full max-w-3xl lg:max-w-4xl sm:w-[90%] md:w-[85%]",children:g})},ob(d))]})})};function ic({className:e,...n}){return s.jsx("textarea",{"data-slot":"textarea",className:ce("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),...n})}const J4=({hunk:e})=>s.jsxs("div",{className:"relative flex overflow-x-auto",children:[s.jsxs("div",{className:"flex-shrink-0 sticky left-0 z-10 bg-white dark:bg-gray-900",children:[s.jsx("div",{className:"float-left w-10 bg-gray-50 dark:bg-gray-800/50 border-r border-gray-200 dark:border-gray-700",children:e.lines.map((n,r)=>s.jsx("div",{className:"px-1 py-0.5 text-xs text-gray-400 dark:text-gray-600 font-mono text-right leading-tight",children:n.type!=="added"&&n.type!=="hunk"&&n.oldLineNumber?n.oldLineNumber:" "},`old-${n.oldLineNumber}-${r}`))}),s.jsx("div",{className:"float-left w-10 bg-gray-50 dark:bg-gray-800/50 border-r border-gray-200 dark:border-gray-700",children:e.lines.map((n,r)=>s.jsx("div",{className:"px-1 py-0.5 text-xs text-gray-400 dark:text-gray-600 font-mono text-right leading-tight",children:n.type!=="deleted"&&n.type!=="hunk"&&n.newLineNumber?n.newLineNumber:" "},`new-${n.newLineNumber}-${r}`))})]}),s.jsx("div",{className:"flex-1 min-w-0",children:e.lines.map((n,r)=>s.jsx("div",{className:ce("flex border-l-4",{"bg-green-50 dark:bg-green-950/30 border-green-200 dark:border-green-800/50 border-l-green-400":n.type==="added","bg-red-50 dark:bg-red-950/30 border-red-200 dark:border-red-800/50 border-l-red-400":n.type==="deleted","bg-blue-50 dark:bg-blue-950/30 border-blue-200 dark:border-blue-800/50 border-l-blue-400":n.type==="hunk","bg-white dark:bg-gray-900 border-gray-100 dark:border-gray-800 border-l-transparent":n.type==="unchanged"}),children:s.jsx("div",{className:"flex-1 px-2 py-0.5",children:s.jsxs("span",{className:"font-mono text-xs whitespace-pre block leading-tight",children:[s.jsx("span",{className:ce({"text-green-600 dark:text-green-400":n.type==="added","text-red-600 dark:text-red-400":n.type==="deleted","text-blue-600 dark:text-blue-400 font-medium":n.type==="hunk","text-gray-400 dark:text-gray-600":n.type==="unchanged"}),children:n.type==="added"?"+":n.type==="deleted"?"-":n.type==="hunk"?"":" "}),n.content||" "]})})},`content-${n.content}-${n.oldLineNumber}-${n.newLineNumber}-${r}`))})]}),sb=({fileDiff:e,isCollapsed:n,onToggleCollapse:r})=>{const a=()=>e.isNew?s.jsx("span",{className:"text-green-600 dark:text-green-400",children:"A"}):e.isDeleted?s.jsx("span",{className:"text-red-600 dark:text-red-400",children:"D"}):e.isRenamed?s.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"R"}):s.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"M"}),t=async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e.filename),de.success("ファイル名をコピーしました")}catch(o){console.error("Failed to copy filename:",o),de.error("ファイル名のコピーに失敗しました")}};return s.jsxs(re,{onClick:r,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:[s.jsxs("div",{className:"w-full flex items-center gap-2",children:[n?s.jsx(fy,{className:"w-4 h-4 text-gray-500 flex-shrink-0"}):s.jsx($e,{className:"w-4 h-4 text-gray-500 flex-shrink-0"}),s.jsx("div",{className:"w-5 h-5 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center text-xs font-mono flex-shrink-0",children:a()}),s.jsx("span",{className:"font-mono text-xs font-medium text-black dark:text-white text-left truncate flex-1 min-w-0",children:e.filename}),s.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:[e.linesAdded>0&&s.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.linesAdded]}),e.linesDeleted>0&&s.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["-",e.linesDeleted]})]}),s.jsx(re,{onClick:t,variant:"ghost",size:"sm",className:"flex-shrink-0 p-1 h-5 w-5 hover:bg-gray-200 dark:hover:bg-gray-600",children:s.jsx(xy,{className:"w-3 h-3 text-gray-500 dark:text-gray-400"})})]}),e.isBinary&&s.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400 text-left",children:"Binary file (content not shown)"})]})},Q4=({fileDiff:e,className:n})=>{const[r,a]=O.useState(!1),t=()=>{a(!r)};return e.isBinary?s.jsxs("div",{className:ce("border border-gray-200 dark:border-gray-700 rounded-lg",n),children:[s.jsx(sb,{fileDiff:e,isCollapsed:r,onToggleCollapse:t}),!r&&s.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400 text-sm",children:"Binary file cannot be displayed"})]}):s.jsxs("div",{className:ce("border border-gray-200 dark:border-gray-700 rounded-lg",n),children:[s.jsx(sb,{fileDiff:e,isCollapsed:r,onToggleCollapse:t}),!r&&s.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700",children:e.hunks.map((i,o)=>s.jsx(J4,{hunk:i},`${i.oldStart}-${i.newStart}-${o}`))})]})},ez=({summary:e,className:n})=>s.jsx("div",{className:ce("bg-gray-50 dark:bg-gray-800 rounded-lg p-2 border border-gray-200 dark:border-gray-700",n),children:s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(ru,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),s.jsxs("span",{className:"font-medium",children:[s.jsxs("span",{className:"hidden sm:inline",children:[e.filesChanged," ",s.jsx(R,{id:"diff.files.changed"})]}),s.jsxs("span",{className:"sm:hidden",children:[e.filesChanged," ",s.jsx(R,{id:"diff.files"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[e.insertions>0&&s.jsxs("span",{className:"text-green-600 dark:text-green-400 font-medium",children:["+",e.insertions]}),e.deletions>0&&s.jsxs("span",{className:"text-red-600 dark:text-red-400 font-medium",children:["-",e.deletions]})]})]})}),lb=({label:e,value:n,onValueChange:r,refs:a})=>{const t=O.useId(),i=o=>{switch(o){case"branch":return s.jsx(Rn,{className:"h-4 w-4"});case"commit":return s.jsx("span",{className:"text-xs",children:"📝"});case"working":return s.jsx("span",{className:"text-xs",children:"🚧"});default:return s.jsx(Rn,{className:"h-4 w-4"})}};return s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:t,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:e}),s.jsxs(Ot,{value:n,onValueChange:r,children:[s.jsx(Dt,{className:"w-full sm:w-80",children:s.jsx(Lt,{})}),s.jsx($t,{id:t,children:a.map(o=>s.jsx(Ve,{value:o.name,children:s.jsxs("div",{className:"flex items-center gap-2",children:[i(o.type),s.jsx("span",{children:o.displayName}),o.sha&&s.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:o.sha.substring(0,7)})]})},o.name))})]})]})},tz=({isOpen:e,onOpenChange:n,projectId:r,defaultCompareFrom:a="HEAD",defaultCompareTo:t="working",revisionsData:i})=>{const{i18n:o}=Ke(),l=O.useId(),[u,c]=O.useState(a),[p,d]=O.useState(t),[g,m]=O.useState(new Map),[f,h]=O.useState(""),[v,S]=O.useState(!1),{data:E,isLoading:y}=Tu(r),w=i??E,{mutate:I,data:b,isPending:T,error:D}=eC(),_=tC(r),k=nC(r),A=rC(r),j=w?.success&&w.data?[{name:"working",type:"working",displayName:o._("Uncommitted changes")},{name:"HEAD",type:"commit",displayName:"HEAD"},...w.data.baseBranch?[{name:`branch:${w.data.baseBranch.name}`,type:"branch",displayName:`${w.data.baseBranch.name} (base)`,sha:w.data.baseBranch.commit}]:[],...w.data.currentBranch?[{name:`branch:${w.data.currentBranch.name}`,type:"branch",displayName:`${w.data.currentBranch.name} (current)`,sha:w.data.currentBranch.commit}]:[],...w.data.commits.map(x=>({name:`commit:${x.sha}`,type:"commit",displayName:`${x.message.substring(0,50)}${x.message.length>50?"...":""}`,sha:x.sha}))]:[],$=O.useCallback(()=>{u&&p&&u!==p&&I({projectId:r,fromRef:u,toRef:p})},[u,p,I,r]);O.useEffect(()=>{if(b?.success&&b.data.files.length>0){const x=new Map(b.data.files.map(C=>[C.filePath,!0]));m(x)}},[b]),O.useEffect(()=>{e&&u&&p&&$()},[e,u,p,$]);const P=()=>{$()},z=x=>{m(C=>{const B=new Map(C),H=!C.get(x);return B.set(x,H),B})},ee=()=>{b?.success&&b.data.files.length>0&&m(new Map(b.data.files.map(x=>[x.filePath,!0])))},X=()=>{b?.success&&b.data.files.length>0&&m(new Map(b.data.files.map(x=>[x.filePath,!1])))},G=async()=>{const x=Array.from(g.entries()).filter(([C,B])=>B).map(([C])=>C);console.log("[DiffModal.handleCommit] Selected files state:",g),console.log("[DiffModal.handleCommit] Filtered selected files:",x),console.log("[DiffModal.handleCommit] Total files:",b?.success?b.data.files.length:0);try{const C=await _.mutateAsync({files:x,message:f});console.log("[DiffModal.handleCommit] Commit result:",C),C.success?(de.success(`Committed ${C.filesCommitted} files (${C.commitSha.slice(0,7)})`),h(""),$()):de.error(C.error,{description:C.details})}catch(C){console.error("[DiffModal.handleCommit] Error:",C),de.error(o._("Failed to commit"))}},te=async()=>{try{const x=await k.mutateAsync();console.log("[DiffModal.handlePush] Push result:",x),x.success?de.success(`Pushed to ${x.remote}/${x.branch}`):de.error(x.error,{description:x.details})}catch(x){console.error("[DiffModal.handlePush] Error:",x),de.error(o._("Failed to push"))}},N=async()=>{const x=Array.from(g.entries()).filter(([C,B])=>B).map(([C])=>C);console.log("[DiffModal.handleCommitAndPush] Selected files:",x);try{const C=await A.mutateAsync({files:x,message:f});console.log("[DiffModal.handleCommitAndPush] Result:",C),C.success?(de.success(`Committed and pushed (${C.commitSha.slice(0,7)})`),h(""),$()):C.success===!1&&"commitSucceeded"in C&&C.commitSucceeded?(de.warning(`Committed (${C.commitSha?.slice(0,7)}), but push failed: ${C.error}`,{action:{label:o._("Retry Push"),onClick:te}}),h(""),$()):de.error(C.error,{description:C.details})}catch(C){console.error("[DiffModal.handleCommitAndPush] Error:",C),de.error(o._("Failed to commit and push"))}},Y=Array.from(g.values()).filter(Boolean).length,Z=Y===0||f.trim().length===0||_.isPending;return s.jsx(cn,{open:e,onOpenChange:n,children:s.jsxs(dn,{className:"max-w-7xl w-[95vw] h-[90vh] overflow-hidden flex flex-col px-2 md:px-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:items-end",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 flex-1",children:[s.jsx(lb,{label:o._("Compare from"),value:u,onValueChange:c,refs:j.filter(x=>x.name!=="working")}),s.jsx(lb,{label:o._("Compare to"),value:p,onValueChange:d,refs:j})]}),s.jsx(re,{onClick:P,disabled:T||y||u===p,className:"sm:self-end w-full sm:w-auto",children:T?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"common.loading"})]}):s.jsx(FT,{className:"w-4 h-4"})})]}),D&&s.jsx("div",{className:"bg-red-50 dark:bg-red-900/10 border border-red-200 dark:border-red-800 rounded-lg p-4",children:s.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm",children:D.message})}),b?.success&&s.jsxs("div",{className:"flex-1 overflow-auto",children:[s.jsx(ez,{summary:{filesChanged:b.data.files.length,insertions:b.data.summary.totalAdditions,deletions:b.data.summary.totalDeletions,files:b.data.diffs.map(x=>({filename:x.file.filePath,oldFilename:x.file.oldPath,isNew:x.file.status==="added",isDeleted:x.file.status==="deleted",isRenamed:x.file.status==="renamed",isBinary:!1,hunks:x.hunks,linesAdded:x.file.additions,linesDeleted:x.file.deletions}))},className:"mb-3"}),p==="working"&&s.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg mb-4 border border-gray-200 dark:border-gray-700",children:[s.jsxs("button",{type:"button",onClick:()=>S(!v),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:[s.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:s.jsx(R,{id:"diff.commit.changes"})}),v?s.jsx(JI,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):s.jsx($e,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"})]}),v&&s.jsxs("div",{className:"p-4 pt-0 space-y-3",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(re,{size:"sm",variant:"ghost",onClick:ee,disabled:_.isPending,children:s.jsx(R,{id:"diff.select.all"})}),s.jsx(re,{size:"sm",variant:"ghost",onClick:X,disabled:_.isPending,children:s.jsx(R,{id:"diff.deselect.all"})}),s.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:[Y," / ",b.data.files.length," files selected"]})]})}),s.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded p-2",children:b.data.files.map(x=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(QI,{id:`file-${x.filePath}`,checked:g.get(x.filePath)??!1,onCheckedChange:()=>z(x.filePath),disabled:_.isPending}),s.jsx("label",{htmlFor:`file-${x.filePath}`,className:"text-sm font-mono cursor-pointer flex-1",children:x.filePath})]},x.filePath))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:l,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:s.jsx(R,{id:"diff.commit.message"})}),s.jsx(ic,{id:l,placeholder:"Enter commit message...",value:f,onChange:x=>h(x.target.value),disabled:_.isPending,className:"resize-none",rows:3})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(re,{onClick:G,disabled:Z,className:"w-full sm:w-auto",children:_.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"diff.committing"})]}):s.jsx(R,{id:"diff.commit"})}),s.jsx(re,{onClick:te,disabled:k.isPending,variant:"outline",className:"w-full sm:w-auto",children:k.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"diff.pushing"})]}):s.jsx(R,{id:"diff.push"})}),s.jsx(re,{onClick:N,disabled:Z||A.isPending,variant:"secondary",className:"w-full sm:w-auto",children:A.isPending?s.jsxs(s.Fragment,{children:[s.jsx(Tt,{className:"w-4 h-4 mr-2 animate-spin"}),s.jsx(R,{id:"diff.committing.pushing"})]}):s.jsx(R,{id:"diff.commit.push"})}),Z&&!_.isPending&&!A.isPending&&s.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:Y===0?s.jsx(R,{id:"diff.select.file"}):s.jsx(R,{id:"diff.enter.message"})})]})]})]}),s.jsx("div",{className:"space-y-3",children:b.data.diffs.map(x=>s.jsx(Q4,{fileDiff:{filename:x.file.filePath,oldFilename:x.file.oldPath,isNew:x.file.status==="added",isDeleted:x.file.status==="deleted",isRenamed:x.file.status==="renamed",isBinary:!1,hunks:x.hunks,linesAdded:x.file.additions,linesDeleted:x.file.deletions}},x.file.filePath))})]}),T&&s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center space-y-2",children:[s.jsx(Tt,{className:"w-8 h-8 animate-spin mx-auto"}),s.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s.jsx(R,{id:"diff.loading"})})]})})]})})},nz=({projectId:e,isPending:n=!1,onScrollToTop:r,onScrollToBottom:a,onOpenDiffModal:t,sessionProcess:i,abortTask:o,isNewChat:l=!1})=>{const{i18n:u}=Ke(),c=py(),p=()=>{c({to:"/projects/$projectId/session",params:{projectId:e},search:d=>{const{sessionId:g,...m}=d;return m}})};return s.jsx("div",{className:"px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 mb-1",children:s.jsxs("div",{className:"py-0 flex items-center gap-1.5 flex-wrap",children:[t&&s.jsxs(re,{type:"button",variant:"ghost",size:"sm",onClick:t,disabled:n,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",title:u._({id:"control.open_git_dialog",message:"Open Git Dialog"}),children:[s.jsx(NT,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:s.jsx(R,{id:"control.git"})})]}),s.jsxs(re,{type:"button",variant:"ghost",size:"sm",disabled:n||l,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",onClick:p,title:u._({id:"control.new_chat",message:"New Chat"}),children:[s.jsx(Nu,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:s.jsx(R,{id:"control.new"})})]}),r&&s.jsx(re,{type:"button",variant:"ghost",size:"sm",onClick:r,disabled:n,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:s.jsx(pT,{className:"w-3.5 h-3.5"})}),a&&s.jsx(re,{type:"button",variant:"ghost",size:"sm",onClick:a,disabled:n,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:s.jsx(uT,{className:"w-3.5 h-3.5"})}),i&&o&&s.jsxs(re,{type:"button",variant:"destructive",size:"sm",onClick:()=>{o.mutate(i.id)},disabled:o.isPending||n,className:"h-7 px-2 gap-1.5 text-xs bg-muted/20 rounded-lg border border-border/40",children:[o.isPending?s.jsx(Cn,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(wu,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:s.jsx(R,{id:"session.conversation.abort"})})]})]})})},yt={all:["scheduler"],jobs:()=>[...yt.all,"jobs"],job:e=>[...yt.all,"job",e]},rz=()=>Pt({queryKey:yt.jobs(),queryFn:async()=>{const e=await ze.api.scheduler.jobs.$get();if(!e.ok)throw new Error("Failed to fetch scheduler jobs");return e.json()}}),mS=()=>{const e=Un();return et({mutationFn:async n=>{const r=await ze.api.scheduler.jobs.$post({json:n});if(!r.ok)throw new Error("Failed to create scheduler job");return r.json()},onSuccess:()=>{e.invalidateQueries({queryKey:yt.jobs()})}})},az=()=>{const e=Un();return et({mutationFn:async({id:n,updates:r})=>{const a=await ze.api.scheduler.jobs[":id"].$patch({param:{id:n},json:r});if(!a.ok)throw a.status===404?new Error("Job not found"):new Error("Failed to update scheduler job");return a.json()},onSuccess:n=>{e.invalidateQueries({queryKey:yt.job(n.id)}),e.invalidateQueries({queryKey:yt.jobs()})}})},iz=()=>{const e=Un();return et({mutationFn:async n=>{const r=await ze.api.scheduler.jobs[":id"].$delete({param:{id:n}});if(!r.ok)throw r.status===404?new Error("Job not found"):new Error("Failed to delete scheduler job");return r.json()},onSuccess:(n,r)=>{e.invalidateQueries({queryKey:yt.job(r)}),e.invalidateQueries({queryKey:yt.jobs()})}})},gS=Nn(["image/png","image/jpeg","image/gif","image/webp"]),oz=Je({type:ct("image"),source:Je({type:ct("base64"),media_type:gS,data:He()})}),sz=Je({type:ct("document"),source:xu([Je({type:ct("text"),media_type:Nn(["text/plain"]),data:He()}),Je({type:ct("base64"),media_type:Nn(["application/pdf"]),data:He()})])});Je({text:He().min(1),images:tu(oz).optional(),documents:tu(sz).optional()});const lz=e=>e.startsWith("image/")?"image":e==="application/pdf"?"pdf":"text",uz=e=>new Promise((n,r)=>{const a=new FileReader;a.onload=()=>{const t=a.result;if(typeof t=="string"){const i=t.split(",")[1];n(i??"")}else r(new Error("Failed to read file as base64"))},a.onerror=()=>{r(new Error("Failed to read file"))},a.readAsDataURL(e)}),cz=e=>new Promise((n,r)=>{const a=new FileReader;a.onload=()=>{const t=a.result;typeof t=="string"?n(t):r(new Error("Failed to read file as text"))},a.onerror=()=>{r(new Error("Failed to read file"))},a.readAsText(e)}),dz=async e=>{const n=lz(e.type);if(n==="text")return{type:"text",content:await cz(e)};const r=await uz(e);if(n==="image"){const a=gS.safeParse(e.type);return a.success?{type:"image",block:{type:"image",source:{type:"base64",media_type:a.data,data:r}}}:null}return{type:"document",block:{type:"document",source:{type:"base64",media_type:"application/pdf",data:r}}}},pz=O.forwardRef(({projectId:e,inputValue:n,onCommandSelect:r,className:a},t)=>{const{i18n:i}=Ke(),[o,l]=O.useState(!1),[u,c]=O.useState(-1),p=O.useRef(null),d=O.useRef(null),{data:g}=Pt({queryKey:bc(e).queryKey,queryFn:bc(e).queryFn,staleTime:1e3*60*5}),{shouldShowCompletion:m,filteredCommands:f}=O.useMemo(()=>{const y=[...g?.defaultCommands||[],...g?.globalCommands||[],...g?.projectCommands||[]],w=n.startsWith("/"),I=w?n.slice(1).toLowerCase():"",b=w?y.filter(T=>T.toLowerCase().includes(I)):[];return{shouldShowCompletion:w,filteredCommands:b}},[g,n]),h=m&&f.length>0;o!==h&&(l(h),c(-1));const v=O.useCallback(y=>{r(`/${y} `),l(!1),c(-1)},[r]),S=O.useCallback(y=>{if(y>=0&&d.current){const I=d.current.querySelectorAll('button[role="option"]')[y];I&&I.scrollIntoView({block:"nearest",behavior:"smooth"})}},[]),E=O.useCallback(y=>{if(!o||f.length===0)return!1;switch(y.key){case"ArrowDown":return y.preventDefault(),c(w=>{const I=w<f.length-1?w+1:0;return requestAnimationFrame(()=>S(I)),I}),!0;case"ArrowUp":return y.preventDefault(),c(w=>{const I=w>0?w-1:f.length-1;return requestAnimationFrame(()=>S(I)),I}),!0;case"Enter":case"Tab":if(u>=0&&u<f.length){y.preventDefault();const w=f[u];return w&&v(w),!0}break;case"Escape":return y.preventDefault(),l(!1),c(-1),!0}return!1},[o,f.length,u,v,S,f]);return O.useEffect(()=>{const y=w=>{p.current&&!p.current.contains(w.target)&&(l(!1),c(-1))};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]),O.useImperativeHandle(t,()=>({handleKeyDown:E}),[E]),!m||f.length===0?null:s.jsx("div",{ref:p,className:ce("relative",a),children:s.jsx(Le,{open:o,onOpenChange:l,children:s.jsx(je,{children:s.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":i._("Available commands"),children:s.jsx("div",{className:"h-full overflow-y-auto",children:f.length>0&&s.jsxs("div",{className:"p-1.5",children:[s.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:[s.jsx(au,{className:"w-3.5 h-3.5"}),"Available Commands (",f.length,")"]}),f.map((y,w)=>s.jsxs(re,{variant:"ghost",size:"sm",className:ce("w-full justify-start text-left font-mono text-sm h-9 px-3 min-w-0 transition-colors duration-150",w===u?"bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20":"hover:bg-accent/50"),onClick:()=>v(y),onMouseEnter:()=>c(w),role:"option","aria-selected":w===u,"aria-label":`Command: /${y}`,title:`/${y}`,children:[s.jsx("span",{className:"text-muted-foreground mr-1.5 flex-shrink-0",children:"/"}),s.jsx("span",{className:"font-medium truncate min-w-0",children:y}),w===u&&s.jsx(yy,{className:"w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0"})]},y))]})})})})})})}),mz=(e,n,r=!0)=>Pt({queryKey:yc(e,n).queryKey,queryFn:yc(e,n).queryFn,enabled:r&&!!e,staleTime:1e3*60*5}),gz=e=>{const n=e.lastIndexOf("@");if(n===-1)return{shouldShow:!1,searchPath:"",beforeAt:"",afterAt:""};const r=e.slice(0,n),a=e.slice(n+1),t=a.split(/\s/),i=t[0]||"";return{shouldShow:!(t.length>1),searchPath:i,beforeAt:r,afterAt:a}},fS=O.forwardRef(({projectId:e,inputValue:n,onFileSelect:r,className:a},t)=>{const{i18n:i}=Ke(),[o,l]=O.useState(!1),[u,c]=O.useState(-1),p=O.useRef(null),d=O.useRef(null),{shouldShow:g,searchPath:m,beforeAt:f,afterAt:h}=O.useMemo(()=>gz(n),[n]),{basePath:v,filterTerm:S}=O.useMemo(()=>{if(!m)return{basePath:"/",filterTerm:""};const _=m.lastIndexOf("/");if(_===-1)return{basePath:"/",filterTerm:m};const k=m.slice(0,_+1),A=m.slice(_+1);return{basePath:k==="/"?"/":k,filterTerm:A}},[m]),{data:E,isLoading:y}=mz(e,v,g),w=O.useMemo(()=>E?.entries?S?E.entries.filter(_=>_.name.toLowerCase().includes(S.toLowerCase())):E.entries:[],[E?.entries,S]),I=g&&!y&&w.length>0;o!==I&&(l(I),c(-1));const b=O.useCallback((_,k=!1)=>{const A=_.path,j=h.split(/\s/).slice(1).join(" "),$=`${f}@${A}${j}`.trim()+(_.type==="directory"&&!k?"/":" ");r($),(_.type==="file"||k)&&(l(!1),c(-1))},[f,h,r]),T=O.useCallback(_=>{if(_>=0&&d.current){const A=d.current.querySelectorAll('button[role="option"]')[_];A&&A.scrollIntoView({block:"nearest",behavior:"smooth"})}},[]),D=O.useCallback(_=>{if(!o||w.length===0)return!1;switch(_.key){case"ArrowDown":return _.preventDefault(),c(k=>{const A=k<w.length-1?k+1:0;return requestAnimationFrame(()=>T(A)),A}),!0;case"ArrowUp":return _.preventDefault(),c(k=>{const A=k>0?k-1:w.length-1;return requestAnimationFrame(()=>T(A)),A}),!0;case"Enter":if(u>=0&&u<w.length){_.preventDefault();const k=w[u];return k&&b(k,!0),!0}break;case"Tab":if(u>=0&&u<w.length){_.preventDefault();const k=w[u];return k&&b(k,k.type==="file"),!0}break;case"Escape":return _.preventDefault(),l(!1),c(-1),!0}return!1},[o,w.length,u,b,T,w]);return O.useEffect(()=>{const _=k=>{p.current&&!p.current.contains(k.target)&&(l(!1),c(-1))};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[]),O.useImperativeHandle(t,()=>({handleKeyDown:D}),[D]),!g||y||w.length===0?null:s.jsx("div",{ref:p,className:ce("relative",a),children:s.jsx(Le,{open:o,onOpenChange:l,children:s.jsx(je,{children:s.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":i._("Available files and directories"),children:s.jsx("div",{className:"h-full overflow-y-auto",children:w.length>0&&s.jsxs("div",{className:"p-1.5",children:[s.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:[s.jsx(Sc,{className:"w-3.5 h-3.5"}),"Files & Directories (",w.length,")",v!=="/"&&s.jsxs("span",{className:"text-xs font-mono text-muted-foreground/70",children:["in ",v]})]}),w.map((_,k)=>s.jsxs(re,{variant:"ghost",size:"sm",className:ce("w-full justify-start text-left font-mono text-sm h-9 px-3 min-w-0 transition-colors duration-150",k===u?"bg-gradient-to-r from-blue-500/10 to-purple-500/10 text-foreground border border-blue-500/20":"hover:bg-accent/50"),onClick:()=>b(_,_.type==="file"),onMouseEnter:()=>c(k),role:"option","aria-selected":k===u,"aria-label":`${_.type}: ${_.name}`,title:_.path,children:[_.type==="directory"?s.jsx(eT,{className:"w-3.5 h-3.5 mr-2 text-blue-500 dark:text-blue-400 flex-shrink-0"}):s.jsx(Sc,{className:"w-3.5 h-3.5 mr-2 text-gray-500 dark:text-gray-400 flex-shrink-0"}),s.jsx("span",{className:"font-medium truncate min-w-0",children:_.name}),_.type==="directory"&&s.jsx("span",{className:"text-muted-foreground ml-1 flex-shrink-0",children:"/"}),k===u&&s.jsx(yy,{className:"w-3.5 h-3.5 ml-auto text-blue-600 dark:text-blue-400 flex-shrink-0"})]},_.path))]})})})})})})});fS.displayName="FileCompletion";const fz=(e,n,r)=>{const a=typeof window<"u"?window.innerHeight:800,t=a/2,i=48,o=36,l=12,c=Math.min(r,5),p=i+o*c+l,d=n.top<t,g=a-n.top,m=n.top;let f,h;d&&g>=p+20?(f="below",h=e.top+24):!d&&m>=p+20?(f="above",h=e.top-p-16):g>m?(f="below",h=e.top+24):(f="above",h=e.top-p-16);const E=(typeof window<"u"?window.innerWidth:1200)-512-16,y=Math.max(16,Math.min(e.left-16,E));return{top:h,left:y,placement:f}},hS=({projectId:e,message:n,commandCompletionRef:r,fileCompletionRef:a,handleCommandSelect:t,handleFileSelect:i,cursorPosition:o})=>{const l=O.useMemo(()=>fz(o.relative,o.absolute,5),[o]);return s.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:l.top,left:l.left,maxWidth:typeof window<"u"?Math.min(512,window.innerWidth*.8):512},children:[s.jsx(pz,{ref:r,projectId:e,inputValue:n,onCommandSelect:t,className:`absolute left-0 right-0 ${l.placement==="above"?"bottom-full mb-2":"top-full mt-1"}`}),s.jsx(fS,{ref:a,projectId:e,inputValue:n,onFileSelect:i,className:`absolute left-0 right-0 ${l.placement==="above"?"bottom-full mb-2":"top-full mt-1"}`})]})},oc=({projectId:e,onSubmit:n,isPending:r,error:a,placeholder:t,buttonText:i,minHeight:o="min-h-[64px]",containerClassName:l="",disabled:u=!1,buttonSize:c="lg",enableScheduledSend:p=!1,baseSessionId:d=null})=>{const m=(C=>{const B=C.match(/(\d+)px/);if(B?.[1]){const H=parseInt(B[1],10);if(!Number.isNaN(H))return H}return 48})(o),{i18n:f}=Ke(),[h,v]=O.useState(""),[S,E]=O.useState([]),[y,w]=O.useState({relative:{top:0,left:0},absolute:{top:0,left:0}}),[I,b]=O.useState("immediate"),[T,D]=O.useState(()=>{const C=new Date;C.setHours(C.getHours()+1);const B=C.getFullYear(),H=String(C.getMonth()+1).padStart(2,"0"),Q=String(C.getDate()).padStart(2,"0"),ue=String(C.getHours()).padStart(2,"0"),me=String(C.getMinutes()).padStart(2,"0");return`${B}-${H}-${Q}T${ue}:${me}`}),_=O.useRef(null),k=O.useRef(null),A=O.useRef(null),j=O.useRef(null),$=O.useRef(null),P=O.useId(),{config:z}=kt(),ee=mS();O.useEffect(()=>{const C=k.current;if(!C)return;C.style.height="auto";const B=C.scrollHeight,H=200;C.style.height=`${Math.max(m,Math.min(B,H))}px`},[h,m]),O.useEffect(()=>{const C=k.current;C&&(C.style.height=`${m}px`)},[m]);const X=async()=>{if(!h.trim()&&S.length===0)return;const C=[],B=[];for(const{file:H}of S){const Q=await dz(H);Q!==null&&(Q.type==="text"?B.push({type:"document",source:{type:"text",media_type:"text/plain",data:Q.content}}):Q.type==="image"?C.push(Q.block):Q.type==="document"&&B.push(Q.block))}if(p&&I==="scheduled"){const H=T.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/);if(!H)throw new Error("Invalid datetime format");const Q=Number(H[1]),ue=Number(H[2]),me=Number(H[3]),he=Number(H[4]),fe=Number(H[5]),Ae=new Date(Q,ue-1,me,he,fe);try{await ee.mutateAsync({name:`Scheduled message at ${T}`,schedule:{type:"reserved",reservedExecutionTime:Ae.toISOString()},message:{content:h,projectId:e,baseSessionId:d},enabled:!0}),de.success(f._({id:"chat.scheduled_send.success",message:"Message scheduled successfully"}),{description:f._({id:"chat.scheduled_send.success_description",message:"You can view and manage it in the Scheduler tab"})}),v(""),E([])}catch(Re){de.error(f._({id:"chat.scheduled_send.failed",message:"Failed to schedule message"}),{description:Re instanceof Error?Re.message:void 0})}}else await n({text:h,images:C.length>0?C:void 0,documents:B.length>0?B:void 0}),v(""),E([])},G=C=>{const B=C.target.files;if(!B)return;const H=Array.from(B).map(Q=>({file:Q,id:`${Q.name}-${Date.now()}-${Math.random()}`}));E(Q=>[...Q,...H]),A.current&&(A.current.value="")},te=C=>{E(B=>B.filter(H=>H.id!==C))},N=C=>{if(!$.current?.handleKeyDown(C)&&!j.current?.handleKeyDown(C)&&C.key==="Enter"&&!C.nativeEvent.isComposing){const B=z?.enterKeyBehavior;(B==="enter-send"&&!C.shiftKey&&!C.metaKey||B==="shift-enter-send"&&C.shiftKey&&!C.metaKey||B==="command-enter-send"&&C.metaKey&&!C.shiftKey)&&(C.preventDefault(),X())}},Y=O.useCallback(()=>{const C=k.current,B=_.current;if(C===null||B===null)return;const H=C.selectionStart,Q=C.value.substring(0,H),ue=C.value.substring(H),me=document.createTextNode(Q),he=document.createTextNode(ue),fe=document.createElement("span");fe.innerHTML=" ";const Ae=document.createElement("div");Ae.innerHTML="",Ae.append(me,fe,he);const Re=window.getComputedStyle(C);for(const Ce of["border","boxSizing","fontFamily","fontSize","fontWeight","letterSpacing","lineHeight","padding","textDecoration","textIndent","textTransform","whiteSpace","wordSpacing","wordWrap"])Ae.style[Ce]=Re[Ce];Ae.style.visibility="hidden",B.prepend(Ae);const pt=fe.getBoundingClientRect(),it=B.getBoundingClientRect();return B.removeChild(Ae),{relative:{top:pt.top-it.top-C.scrollTop,left:pt.left-it.left-C.scrollLeft},absolute:{top:pt.top-C.scrollTop,left:pt.left-C.scrollLeft}}},[]),Z=C=>{v(C),k.current?.focus()},x=C=>{v(C),k.current?.focus()};return s.jsxs("div",{className:l,children:[a&&s.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:[s.jsx(nu,{className:"w-4 h-4 shrink-0 mt-0.5"}),s.jsx("span",{className:"font-medium",children:s.jsx(R,{id:"chat.error.send_failed"})})]}),s.jsxs("div",{className:"relative group",children:[s.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 transition-opacity duration-500","aria-hidden":"true"}),s.jsxs("div",{className:"relative bg-background border border-border/40 rounded-2xl shadow-lg hover:shadow-xl transition-all duration-300 overflow-hidden",children:[s.jsx("div",{className:"relative",ref:_,children:s.jsx(ic,{ref:k,value:h,onChange:C=>{if(C.target.value.endsWith("@")||C.target.value.endsWith("/")){const B=Y();B&&w(B)}v(C.target.value)},onKeyDown:N,placeholder:t,className:"resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent px-5 py-2 text-base transition-all duration-200 placeholder:text-muted-foreground/60 overflow-y-auto leading-6",style:{minHeight:`${m}px`},disabled:r||u,"aria-label":f._("Message input with completion support"),"aria-describedby":P,"aria-expanded":h.startsWith("/")||h.includes("@"),"aria-haspopup":"listbox",role:"combobox","aria-autocomplete":"list"})}),S.length>0&&s.jsx("div",{className:"px-5 py-3 flex flex-wrap gap-2 border-t border-border/40",children:S.map(({file:C,id:B})=>s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-lg text-sm",children:[s.jsx("span",{className:"truncate max-w-[200px]",children:C.name}),s.jsx("button",{type:"button",onClick:()=>te(B),className:"text-muted-foreground hover:text-foreground transition-colors",disabled:r,children:s.jsx(wu,{className:"w-3.5 h-3.5"})})]},B))}),s.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-1 bg-muted/30 border-t border-border/40",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{ref:A,type:"file",multiple:!0,onChange:G,className:"hidden"}),s.jsxs(re,{type:"button",variant:"ghost",size:"sm",onClick:()=>A.current?.click(),disabled:r||u,className:"gap-1.5",children:[s.jsx($T,{className:"w-4 h-4"}),s.jsx("span",{className:"text-xs",children:s.jsx(R,{id:"chat.attach_file"})})]}),s.jsx("span",{className:"text-xs font-medium text-muted-foreground/80",id:P,children:h.length}),(h.startsWith("/")||h.includes("@"))&&s.jsxs("span",{className:"text-xs text-blue-600 dark:text-blue-400 font-medium flex items-center gap-1",children:[s.jsx(GT,{className:"w-3 h-3"}),s.jsx(R,{id:"chat.autocomplete.active"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[p&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ie,{htmlFor:"send-mode",className:"text-xs sr-only",children:s.jsx(R,{id:"chat.send_mode.label"})}),s.jsxs(Ot,{value:I,onValueChange:C=>b(C),disabled:r||u,children:[s.jsx(Dt,{id:"send-mode",className:"h-8 w-[140px] text-xs",children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"immediate",children:s.jsx(R,{id:"chat.send_mode.immediate"})}),s.jsx(Ve,{value:"scheduled",children:s.jsx(R,{id:"chat.send_mode.scheduled"})})]})]}),I==="scheduled"&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ie,{htmlFor:"scheduled-time",className:"text-xs sr-only",children:s.jsx(R,{id:"chat.send_mode.scheduled_time"})}),s.jsx(ht,{id:"scheduled-time",type:"datetime-local",value:T,onChange:C=>D(C.target.value),disabled:r||u,className:"h-8 w-[180px] text-xs"})]})]}),s.jsx(re,{onClick:X,disabled:!h.trim()&&S.length===0||r||u,size:c,className:"gap-2 transition-all duration-200 hover:shadow-md hover:scale-105 active:scale-95 bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-500 hover:to-purple-500 disabled:from-muted disabled:to-muted",children:r?s.jsxs(s.Fragment,{children:[s.jsx(Cn,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:s.jsx(R,{id:"chat.status.processing"})})]}):s.jsxs(s.Fragment,{children:[s.jsx(zT,{className:"w-4 h-4"}),i]})})]})]})]}),s.jsx(hS,{projectId:e,message:h,commandCompletionRef:j,fileCompletionRef:$,handleCommandSelect:Z,handleFileSelect:x,cursorPosition:y})]})]})},bS=(e,n)=>{const r=py();return et({mutationFn:async a=>{const t=await ze.api.cc["session-processes"].$post({json:{projectId:e,baseSessionId:a.baseSessionId,input:a.input}},{init:{signal:AbortSignal.timeout(2e4)}});if(!t.ok)throw new Error(t.statusText);return t.json()},onSuccess:async a=>{r({to:"/projects/$projectId/session",params:{projectId:e},search:t=>({...t,sessionId:a.sessionProcess.sessionId})})}})},hz=(e,n)=>et({mutationFn:async r=>{const a=await ze.api.cc["session-processes"][":sessionProcessId"].continue.$post({param:{sessionProcessId:r.sessionProcessId},json:{projectId:e,baseSessionId:n,input:r.input}},{init:{signal:AbortSignal.timeout(2e4)}});if(!a.ok)throw new Error(a.statusText);return a.json()}});function bz(){const[e,n]=O.useState({relative:{top:0,left:0},absolute:{top:0,left:0}}),r=O.useRef(null),a=O.useRef(null),t=O.useRef(null),i=O.useRef(null),o=O.useCallback(()=>{const d=a.current,g=r.current;if(d===null||g===null)return;const m=d.selectionStart,f=d.value.substring(0,m),h=d.value.substring(m),v=document.createTextNode(f),S=document.createTextNode(h),E=document.createElement("span");E.innerHTML=" ";const y=document.createElement("div");y.innerHTML="",y.append(v,E,S);const w=window.getComputedStyle(d);for(const T of["border","boxSizing","fontFamily","fontSize","fontWeight","letterSpacing","lineHeight","padding","textDecoration","textIndent","textTransform","whiteSpace","wordSpacing","wordWrap"])y.style[T]=w[T];y.style.visibility="hidden",g.prepend(y);const I=E.getBoundingClientRect(),b=g.getBoundingClientRect();return g.removeChild(y),{relative:{top:I.top-b.top-d.scrollTop,left:I.left-b.left-d.scrollLeft},absolute:{top:I.top-d.scrollTop,left:I.left-d.scrollLeft}}},[]),l=O.useCallback((d,g)=>{if(d.endsWith("@")||d.endsWith("/")){const m=o();m&&n(m)}g(d)},[o]),u=O.useCallback(d=>!!(i.current?.handleKeyDown(d)||t.current?.handleKeyDown(d)),[]),c=O.useCallback((d,g)=>{g(d),a.current?.focus()},[]),p=O.useCallback((d,g)=>{g(d),a.current?.focus()},[]);return{cursorPosition:e,containerRef:r,textareaRef:a,commandCompletionRef:t,fileCompletionRef:i,getCursorPosition:o,handleChange:l,handleKeyDown:u,handleCommandSelect:c,handleFileSelect:p}}const yz=({projectId:e,sessionId:n,sessionProcessId:r,sessionProcessStatus:a})=>{const{i18n:t}=Ke(),i=hz(e,n),{config:o}=kt(),l=async p=>{await i.mutateAsync({input:p,sessionProcessId:r})},u=()=>{const p=o?.enterKeyBehavior;return p==="enter-send"?t._({id:"chat.placeholder.continue.enter",message:"Type your message... (Start with / for commands, @ for files, Enter to send)"}):p==="command-enter-send"?t._({id:"chat.placeholder.continue.command_enter",message:"Type your message... (Start with / for commands, @ for files, Command+Enter to send)"}):t._({id:"chat.placeholder.continue.shift_enter",message:"Type your message... (Start with / for commands, @ for files, Shift+Enter to send)"})},c=a==="running";return s.jsx("div",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 pb-3",children:s.jsx(oc,{projectId:e,onSubmit:l,isPending:i.isPending,error:i.error,placeholder:u(),buttonText:s.jsx(R,{id:"chat.send"}),containerClassName:"",buttonSize:"default",enableScheduledSend:!c,baseSessionId:n,disabled:c})})},vz=({projectId:e,sessionId:n})=>{const{i18n:r}=Ke(),a=bS(e),{config:t}=kt(),i=async u=>{await a.mutateAsync({input:u,baseSessionId:n})},o=()=>{const u=t?.enterKeyBehavior;return u==="enter-send"?r._({id:"chat.placeholder.resume.enter",message:"Type your message... (Start with / for commands, @ for files, Enter to send)"}):u==="command-enter-send"?r._({id:"chat.placeholder.resume.command_enter",message:"Type your message... (Start with / for commands, @ for files, Command+Enter to send)"}):r._({id:"chat.placeholder.resume.shift_enter",message:"Type your message... (Start with / for commands, @ for files, Shift+Enter to send)"})},l=s.jsx(R,{id:"chat.resume"});return s.jsx("div",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 pb-3",children:s.jsx(oc,{projectId:e,onSubmit:i,isPending:a.isPending,error:a.error,placeholder:o(),buttonText:l,containerClassName:"",buttonSize:"default",enableScheduledSend:!0,baseSessionId:n})})},Sz=({projectId:e})=>{const{i18n:n}=Ke(),r=bS(e),{config:a}=kt(),t=async o=>{await r.mutateAsync({input:o})},i=()=>{const o=a?.enterKeyBehavior;return o==="enter-send"?n._({id:"chat.placeholder.continue.enter",message:"Type your message... (Start with / for commands, @ for files, Enter to send)"}):o==="command-enter-send"?n._({id:"chat.placeholder.continue.command_enter",message:"Type your message... (Start with / for commands, @ for files, Command+Enter to send)"}):n._({id:"chat.placeholder.continue.shift_enter",message:"Type your message... (Start with / for commands, @ for files, Shift+Enter to send)"})};return s.jsx("div",{className:"w-full px-4 sm:px-6 md:px-8 lg:px-12 xl:px-16 pb-3",children:s.jsx(oc,{projectId:e,onSubmit:t,isPending:r.isPending,error:r.error,placeholder:i(),buttonText:s.jsx(R,{id:"chat.button.start"}),containerClassName:"",buttonSize:"default",enableScheduledSend:!0})})},Ez=e=>e.sessionId?s.jsx(xz,{...e,sessionId:e.sessionId}):s.jsx(yS,{...e,sessionData:null}),xz=e=>{const n=NC(e.projectId,e.sessionId);return s.jsx(yS,{...e,sessionId:e.sessionId,sessionData:n})},yS=({projectId:e,sessionId:n,setIsMobileSidebarOpen:r,projectPath:a,currentBranch:t,revisionsData:i,projectName:o,sessionData:l})=>{const u=l?.conversations??[],c=()=>{},p=l?.getToolResult??c,d=!!n&&l!==null&&l!==void 0,{currentPermissionRequest:g,isDialogOpen:m,onPermissionResponse:f}=xC(),{data:h}=Tu(e),v=i??h,S=wC(),E=IC(),y=O.useMemo(()=>{if(n)return E.getSessionProcess(n)},[E,n]);kC(y?.status==="running");const[w,I]=O.useState(0),[b,T]=O.useState(!1),D=O.useRef(null),_=et({mutationFn:async $=>{const P=await ze.api.cc["session-processes"][":sessionProcessId"].abort.$post({param:{sessionProcessId:$},json:{projectId:e}});if(!P.ok)throw new Error(P.statusText);return P.json()}});O.useEffect(()=>{if(d&&y?.status==="running"&&u.length!==w){I(u.length);const $=D.current;$&&$.scrollTo({top:$.scrollHeight,behavior:"smooth"})}},[u,d,y?.status,w]);const k=()=>{const $=D.current;$&&$.scrollTo({top:0,behavior:"smooth"})},A=()=>{const $=D.current;$&&$.scrollTo({top:$.scrollHeight,behavior:"smooth"})};let j=o??e;return d?l&&n&&(j=l.session.meta.firstUserMessage!==null?Uy(l.session.meta.firstUserMessage):n):j=s.jsx(R,{id:"chat.modal.title"}),s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[s.jsxs("header",{className:"px-2 sm:px-3 py-2 sm:py-3 sticky top-0 z-10 bg-background w-full flex-shrink-0 min-w-0 border-b space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(re,{variant:"ghost",size:"sm",className:"md:hidden flex-shrink-0",onClick:()=>r(!0),"data-testid":"mobile-sidebar-toggle-button",children:s.jsx(DT,{className:"w-4 h-4"})}),s.jsx("h1",{className:"text-lg sm:text-2xl md:text-3xl font-bold break-all overflow-ellipsis line-clamp-1 min-w-0",children:j})]}),s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden flex-1",children:[a&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(pe,{variant:"secondary",className:"h-6 text-xs flex items-center max-w-full cursor-help",children:s.jsx("span",{className:"truncate",children:a.split("/").pop()})})}),s.jsx(Xe,{children:a})]}),t&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsxs(pe,{variant:"secondary",className:"h-6 text-xs flex items-center gap-1 max-w-full cursor-help",children:[s.jsx(Rn,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:t})]})}),s.jsx(Xe,{children:s.jsx(R,{id:"control.branch"})})]}),d&&n&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(pe,{variant:"secondary",className:"h-6 text-xs flex items-center max-w-full font-mono cursor-help",children:s.jsx("span",{className:"truncate",children:n})})}),s.jsx(Xe,{children:s.jsx(R,{id:"control.session_id"})})]})]}),y?.status==="running"&&s.jsxs(pe,{variant:"secondary",className:"bg-green-500/10 text-green-900 dark:text-green-200 border-green-500/20 flex-shrink-0 h-6 text-xs",children:[s.jsx(Cn,{className:"w-3 h-3 mr-1 animate-spin"}),s.jsx(R,{id:"session.conversation.running"})]}),y?.status==="paused"&&s.jsxs(pe,{variant:"secondary",className:"bg-orange-500/10 text-orange-900 dark:text-orange-200 border-orange-500/20 flex-shrink-0 h-6 text-xs",children:[s.jsx(MT,{className:"w-3 h-3 mr-1"}),s.jsx(R,{id:"session.conversation.paused"})]}),n!==void 0&&s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(re,{variant:"ghost",size:"icon",className:"flex-shrink-0 h-6 w-6",onClick:()=>S.mutate({projectId:e,sessionId:n}),disabled:S.isPending,"aria-label":"Export session to HTML",children:s.jsx(vT,{className:`w-3.5 h-3.5 ${S.isPending?"animate-pulse":""}`})})}),s.jsx(Xe,{children:"Export to HTML"})]}),s.jsxs(vC,{children:[s.jsx(SC,{asChild:!0,children:s.jsx(re,{variant:"ghost",size:"icon",className:"flex-shrink-0 h-6 w-6","aria-label":"Session metadata",children:s.jsx(vy,{className:"w-3.5 h-3.5"})})}),s.jsx(EC,{className:"w-80",align:"end",children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsx("h3",{className:"font-semibold text-sm mb-2",children:s.jsx(R,{id:"control.metadata"})}),s.jsxs("div",{className:"space-y-2",children:[a&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"control.project_path"})}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(pe,{variant:"secondary",className:"h-7 text-xs flex items-center w-fit cursor-help",children:a.split("/").pop()})}),s.jsx(Xe,{children:a})]})]}),n&&d&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"control.session_id"})}),s.jsx(pe,{variant:"secondary",className:"h-7 text-xs flex items-center w-fit font-mono",children:n})]}),t&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"control.branch"})}),s.jsxs(pe,{variant:"secondary",className:"h-7 text-xs flex items-center gap-1 w-fit",children:[s.jsx(Rn,{className:"w-3 h-3"}),t]})]}),d&&l&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"session.cost.label"})}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(pe,{variant:"secondary",className:"h-7 text-xs flex items-center w-fit font-semibold",children:[s.jsx(R,{id:"session.cost.total"}),": $",l.session.meta.cost.totalUsd.toFixed(3)]}),s.jsxs("div",{className:"text-xs space-y-1 pl-2",children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.input_tokens"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.inputTokensUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.inputTokens.toLocaleString(),")"]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.output_tokens"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.outputTokensUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.outputTokens.toLocaleString(),")"]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.cache_creation"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.cacheCreationUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.cacheCreationTokens.toLocaleString(),")"]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsxs("span",{className:"text-muted-foreground",children:[s.jsx(R,{id:"session.cost.cache_read"}),":"]}),s.jsxs("span",{children:["$",l.session.meta.cost.breakdown.cacheReadUsd.toFixed(3)," ","(",l.session.meta.cost.tokenUsage.cacheReadTokens.toLocaleString(),")"]})]})]})]})]})]})]})})})]})]})]}),s.jsx("div",{ref:D,className:"flex-1 overflow-y-auto min-h-0 min-w-0","data-testid":"scrollable-content",children:s.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:[s.jsx(pS,{conversations:d?u:[],getToolResult:p,projectId:e,sessionId:n??""}),!d&&s.jsxs("div",{className:"rounded-2xl border border-dashed border-muted-foreground/40 bg-muted/30 p-8 text-center space-y-3",children:[s.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-background shadow-sm",children:s.jsx(pn,{className:"w-5 h-5 text-muted-foreground"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-base font-semibold",children:s.jsx(R,{id:"chat.modal.title"})}),s.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:s.jsx(R,{id:"session.empty_state.description"})})]})]}),d&&y?.status==="running"&&s.jsx("div",{className:"flex justify-start items-center py-8 animate-in fade-in duration-500",children:s.jsxs("div",{className:"flex flex-col items-center gap-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Cn,{className:"w-8 h-8 animate-spin text-primary"}),s.jsx("div",{className:"absolute inset-0 rounded-full bg-primary/20 animate-ping"})]}),s.jsx("p",{className:"text-sm text-muted-foreground font-medium animate-pulse",children:s.jsx(R,{id:"session.processing"})})]})})]})}),s.jsx("div",{className:"w-full pt-3",children:s.jsx(nz,{projectId:e,onScrollToTop:k,onScrollToBottom:A,onOpenDiffModal:d?()=>T(!0):void 0,sessionProcess:y,abortTask:_,isNewChat:!d})}),s.jsx("div",{className:"flex-shrink-0 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:d&&n&&y?s.jsx(yz,{projectId:e,sessionId:n,sessionProcessId:y.id,sessionProcessStatus:y.status}):d&&n?s.jsx(vz,{projectId:e,sessionId:n}):s.jsx(Sz,{projectId:e})})]}),d&&s.jsx(tz,{projectId:e,isOpen:b,onOpenChange:T,revisionsData:v}),s.jsx(aC,{permissionRequest:g,isOpen:m,onResponse:f})]})},vS=({projectId:e})=>{const n=Un(),{i18n:r}=Ke(),{data:a,isLoading:t,error:i,isFetching:o}=Pt({queryKey:Xn(e).queryKey,queryFn:Xn(e).queryFn,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchInterval:!1}),l=()=>{n.invalidateQueries({queryKey:Xn(e).queryKey})};return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{className:"p-3 border-b border-sidebar-border",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-semibold text-sidebar-foreground",children:s.jsx(R,{id:"mcp.title"})}),s.jsx(re,{onClick:l,variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:t||o,title:r._("Reload MCP servers"),children:s.jsx(my,{className:`w-3 h-3 ${t||o?"animate-spin":""}`})})]})}),s.jsxs("div",{className:"flex-1 overflow-auto p-3",children:[t&&s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:s.jsx(an,{})})}),i&&s.jsx("div",{className:"text-sm text-red-500",children:s.jsx(R,{id:"mcp.error.load_failed",values:{error:i.message}})}),a&&a.servers.length===0&&s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:s.jsx(R,{id:"mcp.no.servers"})}),a&&a.servers.length>0&&s.jsx("div",{className:"space-y-3",children:a.servers.map(u=>s.jsx("div",{className:"p-3 bg-sidebar-accent/50 rounded-md border border-sidebar-border",children:s.jsx("div",{className:"flex items-start justify-between",children:s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"text-sm font-medium text-sidebar-foreground truncate",children:u.name}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono break-all",children:u.command})]})})},u.name))})]})]})},SS=({currentSessionId:e,projectId:n})=>{const{data:r,fetchNextPage:a,hasNextPage:t,isFetchingNextPage:i}=Iu(n),o=r.pages.flatMap(m=>m.sessions),l=In(cy),{config:u}=kt(),p=zI({from:"/projects/$projectId/session"}).tab??"sessions",d=e==="",g=[...o].sort((m,f)=>{const h=l.find(D=>D.sessionId===m.id),v=l.find(D=>D.sessionId===f.id),S=h?.status,E=v?.status,y=D=>D==="running"?0:D==="paused"?1:2,w=y(S),I=y(E);if(w!==I)return w-I;const b=m.lastModifiedAt?new Date(m.lastModifiedAt).getTime():0;return(f.lastModifiedAt?new Date(f.lastModifiedAt).getTime():0)-b});return s.jsxs("div",{className:"h-full flex flex-col",children:[s.jsxs("div",{className:"border-b border-sidebar-border p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-2",children:s.jsx("h2",{className:"font-semibold text-lg",children:s.jsx(R,{id:"sessions.title"})})}),s.jsxs("p",{className:"text-xs text-sidebar-foreground/70",children:[o.length," ",s.jsx(R,{id:"sessions.total"})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-0.5",children:[s.jsx(An,{to:"/projects/$projectId/session",params:{projectId:n},search:{tab:p},className:ce("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",d&&"bg-blue-100 dark:bg-blue-900/40 border-blue-400 dark:border-blue-500 shadow-sm"),children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary",children:s.jsx(Nu,{className:"w-4 h-4"})}),s.jsx("div",{className:"space-y-0.5",children:s.jsx("p",{className:"text-sm font-semibold text-sidebar-foreground",children:s.jsx(R,{id:"chat.modal.title"})})})]})}),g.map(m=>{const f=m.id===e,h=m.meta.firstUserMessage!==null?Uy(m.meta.firstUserMessage):m.id,v=l.find(y=>y.sessionId===m.id),S=v?.status==="running",E=v?.status==="paused";return s.jsx(An,{to:"/projects/$projectId/session",params:{projectId:n},search:{tab:p,sessionId:m.id},className:ce("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",f&&"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:s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("h3",{className:"text-sm font-medium line-clamp-2 leading-tight text-sidebar-foreground flex-1",children:h}),(S||E)&&s.jsx(pe,{variant:S?"default":"secondary",className:ce("text-xs",S&&"bg-green-500 text-white",E&&"bg-yellow-500 text-white"),children:S?s.jsx(R,{id:"session.status.running"}):s.jsx(R,{id:"session.status.paused"})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3 text-xs text-sidebar-foreground/70",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(pn,{className:"w-3 h-3"}),s.jsx("span",{children:m.meta.messageCount})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(hT,{className:"w-3 h-3"}),s.jsxs("span",{children:["$",m.meta.cost.totalUsd.toFixed(2)]})]})]}),m.lastModifiedAt&&s.jsx("span",{className:"text-xs text-sidebar-foreground/60",children:_u(m.lastModifiedAt,{locale:u.locale,target:"time"})})]})]})},m.id)}),t&&a&&s.jsx("div",{className:"p-2",children:s.jsx(re,{onClick:()=>a(),disabled:i,variant:"outline",size:"sm",className:"w-full",children:i?s.jsx(R,{id:"common.loading"}):s.jsx(R,{id:"sessions.load.more"})})})]})]})},kz=({currentSessionId:e,projectId:n,isOpen:r,onClose:a})=>{const{i18n:t}=Ke(),[i,o]=O.useState("sessions"),[l,u]=O.useState(!1);O.useEffect(()=>{u(!0)},[]),O.useEffect(()=>{const g=m=>{m.key==="Escape"&&a()};return r&&(document.addEventListener("keydown",g),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",g),document.body.style.overflow=""}},[r,a]);const c=g=>{o(g)},p=g=>{g.target===g.currentTarget&&a()},d=()=>{switch(i){case"sessions":return s.jsx(SS,{currentSessionId:e,projectId:n,isMobile:!0});case"mcp":return s.jsx(vS,{projectId:n});case"settings":return s.jsx("div",{className:"h-full flex flex-col",children:s.jsx(O.Suspense,{fallback:s.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:s.jsx("div",{className:"text-sm text-sidebar-foreground/70",children:s.jsx(R,{id:"settings.loading"})})}),children:s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"font-medium text-sm text-sidebar-foreground",children:s.jsx(R,{id:"settings.session.display"})}),s.jsx(rT,{openingProjectId:n})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"font-medium text-sm text-sidebar-foreground",children:s.jsx(R,{id:"settings.notifications"})}),s.jsx(aT,{})]})]})})});case"system-info":return s.jsx(nT,{});default:return null}};return l?qI.createPortal(s.jsxs("div",{className:ce("fixed inset-0 z-50 transition-all duration-300 ease-out md:hidden",r?"visible opacity-100":"invisible opacity-0 pointer-events-none"),children:[s.jsx("button",{type:"button",className:"absolute inset-0 bg-black/50 backdrop-blur-sm cursor-default",onClick:p,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&a()},"aria-label":t._("Close sidebar")}),s.jsxs("div",{className:ce("absolute left-0 top-0 h-full w-80 max-w-[85vw] bg-sidebar text-sidebar-foreground transition-transform duration-300 ease-out flex",r?"translate-x-0":"-translate-x-full"),children:[s.jsx("div",{className:"w-12 flex flex-col border-r border-sidebar-border bg-sidebar/50",children:s.jsxs(Sy,{children:[s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(An,{to:"/projects",className:"w-12 h-12 flex items-center justify-center border-b border-sidebar-border hover:bg-sidebar-accent transition-colors",children:s.jsx(Ey,{className:"w-4 h-4 text-sidebar-foreground/70"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.back.to.projects"})})})]}),s.jsxs("div",{className:"flex flex-col p-2 space-y-1",children:[s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("sessions"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="sessions"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"sessions-tab-button-mobile",children:s.jsx(pn,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.show.session.list"})})})]}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("mcp"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="mcp"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"mcp-tab-button-mobile",children:s.jsx(ky,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.show.mcp.settings"})})})]}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("settings"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="settings"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"settings-tab-button-mobile",children:s.jsx(tT,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx(R,{id:"settings.tab.title"})})]}),s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx("button",{type:"button",onClick:()=>c("system-info"),className:ce("w-8 h-8 flex items-center justify-center rounded-md transition-colors","hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",i==="system-info"?"bg-sidebar-accent text-sidebar-accent-foreground shadow-sm":"text-sidebar-foreground/70"),"data-testid":"system-info-tab-button-mobile",children:s.jsx(vy,{className:"w-4 h-4"})})}),s.jsx(Xe,{side:"right",children:s.jsx(R,{id:"system.info.tab.title"})})]})]})]})}),s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-sidebar-border bg-sidebar/80 backdrop-blur-sm",children:[s.jsx("h2",{className:"text-lg font-semibold capitalize",children:i}),s.jsx(re,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0 hover:bg-sidebar-accent/50",children:s.jsx(wu,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"flex-1 overflow-hidden",children:d()})]})]})]}),document.body):null},ES=O.forwardRef(({className:e,checked:n,onCheckedChange:r,disabled:a,...t},i)=>{const o=l=>{r?.(l.target.checked),t.onChange?.(l)};return s.jsxs("label",{className:ce("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",a&&"cursor-not-allowed opacity-50",n?"bg-primary":"bg-input",e),children:[s.jsx("input",{type:"checkbox",className:"sr-only",ref:i,checked:n,onChange:o,disabled:a,...t}),s.jsx("span",{className:ce("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform",n?"translate-x-4":"translate-x-0")})]})});ES.displayName="Switch";const xS=[{value:0,labelKey:s.jsx(R,{id:"cron_builder.sunday"})},{value:1,labelKey:s.jsx(R,{id:"cron_builder.monday"})},{value:2,labelKey:s.jsx(R,{id:"cron_builder.tuesday"})},{value:3,labelKey:s.jsx(R,{id:"cron_builder.wednesday"})},{value:4,labelKey:s.jsx(R,{id:"cron_builder.thursday"})},{value:5,labelKey:s.jsx(R,{id:"cron_builder.friday"})},{value:6,labelKey:s.jsx(R,{id:"cron_builder.saturday"})}];function wz(e){const n=e.trim().split(/\s+/);if(n.length!==5)return null;const r=n[0],a=n[1],t=n[4];if(!r||!a||!t)return null;if(a==="*"&&r==="0")return{mode:"hourly",hour:0,minute:0,dayOfWeek:0};if(t==="*"&&a!=="*"){const i=Number.parseInt(a,10),o=Number.parseInt(r,10);if(!Number.isNaN(i)&&!Number.isNaN(o))return{mode:"daily",hour:i,minute:o,dayOfWeek:0}}if(t!=="*"&&a!=="*"){const i=Number.parseInt(a,10),o=Number.parseInt(r,10),l=Number.parseInt(t,10);if(!Number.isNaN(i)&&!Number.isNaN(o)&&!Number.isNaN(l))return{mode:"weekly",hour:i,minute:o,dayOfWeek:l}}return{mode:"custom",hour:0,minute:0,dayOfWeek:0}}function ub(e,n,r,a){switch(e){case"hourly":return"0 * * * *";case"daily":return`${r} ${n} * * *`;case"weekly":return`${r} ${n} * * ${a}`;case"custom":return"0 0 * * *"}}function _z(e){const n=e.trim().split(/\s+/);if(n.length!==5)return!1;const r=n[0],a=n[1],t=n[2],i=n[3],o=n[4];if(!r||!a||!t||!i||!o)return!1;const l=(u,c,p)=>{if(u==="*")return!0;const d=Number.parseInt(u,10);return!Number.isNaN(d)&&d>=c&&d<=p};return l(r,0,59)&&(a==="*"||l(a,0,23))&&(t==="*"||l(t,1,31))&&(i==="*"||l(i,1,12))&&(o==="*"||l(o,0,6))}function Nz(e){const n=e.trim().split(/\s+/);if(n.length!==5)return"Invalid cron expression";const r=n[0],a=n[1],t=n[4];if(!r||!a||!t)return"Invalid cron expression";if(a==="*")return`Every hour at ${r} minute(s)`;const i=`${a.padStart(2,"0")}:${r.padStart(2,"0")}`;if(t==="*")return`Every day at ${i}`;const o=Number.parseInt(t,10),l=xS.find(u=>u.value===o);return s.jsxs(s.Fragment,{children:["Every ",l?l.labelKey:"unknown"," at ",i]})}function Iz({value:e,onChange:n}){const r=wz(e),[a,t]=O.useState(r?.mode||"daily"),[i,o]=O.useState(r?.hour||9),[l,u]=O.useState(r?.minute||0),[c,p]=O.useState(r?.dayOfWeek||1),[d,g]=O.useState(e),[m,f]=O.useState(null);O.useEffect(()=>{if(a==="custom")_z(d)?(n(d),f(null)):f("Invalid cron expression");else{const v=ub(a,i,l,c);n(v),g(v),f(null)}},[a,i,l,c,d,n]);const h=v=>{if(t(v),v!=="custom"){const S=ub(v,i,l,c);g(S)}};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.schedule_type"})}),s.jsxs(Ot,{value:a,onValueChange:h,children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"hourly",children:s.jsx(R,{id:"cron_builder.hourly"})}),s.jsx(Ve,{value:"daily",children:s.jsx(R,{id:"cron_builder.daily"})}),s.jsx(Ve,{value:"weekly",children:s.jsx(R,{id:"cron_builder.weekly"})}),s.jsx(Ve,{value:"custom",children:s.jsx(R,{id:"cron_builder.custom"})})]})]})]}),a==="daily"&&s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.hour"})}),s.jsx(ht,{type:"number",min:"0",max:"23",value:i,onChange:v=>o(Number.parseInt(v.target.value,10))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.minute"})}),s.jsx(ht,{type:"number",min:"0",max:"59",value:l,onChange:v=>u(Number.parseInt(v.target.value,10))})]})]}),a==="weekly"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.day_of_week"})}),s.jsxs(Ot,{value:String(c),onValueChange:v=>p(Number.parseInt(v,10)),children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsx($t,{children:xS.map(v=>s.jsx(Ve,{value:String(v.value),children:v.labelKey},v.value))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.hour"})}),s.jsx(ht,{type:"number",min:"0",max:"23",value:i,onChange:v=>o(Number.parseInt(v.target.value,10))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.minute"})}),s.jsx(ht,{type:"number",min:"0",max:"59",value:l,onChange:v=>u(Number.parseInt(v.target.value,10))})]})]})]}),a==="custom"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"cron_builder.cron_expression"})}),s.jsx(ht,{value:d,onChange:v=>g(v.target.value),placeholder:"0 9 * * *"})]}),s.jsxs("div",{className:"rounded-md border p-3 text-sm",children:[s.jsx("div",{className:"font-medium mb-1",children:s.jsx(R,{id:"cron_builder.preview"})}),s.jsx("div",{className:"text-muted-foreground",children:m?s.jsx("span",{className:"text-destructive",children:m}):Nz(a==="custom"?d:e)}),s.jsxs("div",{className:"text-xs text-muted-foreground mt-2",children:[s.jsx(R,{id:"cron_builder.expression"}),":"," ",s.jsx("code",{children:a==="custom"?d:e})]})]})]})}const Tz=({open:e,onOpenChange:n,job:r,projectId:a,onSubmit:t,isSubmitting:i=!1})=>{const{_:o,i18n:l}=Ke(),[u,c]=O.useState(""),[p,d]=O.useState("cron"),[g,m]=O.useState("0 9 * * *"),[f,h]=O.useState(()=>{const _=new Date;return _.setHours(_.getHours()+1),_.toISOString().slice(0,16)}),[v,S]=O.useState(""),[E,y]=O.useState(!0),[w,I]=O.useState("skip"),b=bz();O.useEffect(()=>{if(r){if(c(r.name),d(r.schedule.type),r.schedule.type==="cron")m(r.schedule.expression),I(r.schedule.concurrencyPolicy);else if(r.schedule.type==="reserved"){const _=new Date(r.schedule.reservedExecutionTime),k=_.getFullYear(),A=String(_.getMonth()+1).padStart(2,"0"),j=String(_.getDate()).padStart(2,"0"),$=String(_.getHours()).padStart(2,"0"),P=String(_.getMinutes()).padStart(2,"0");h(`${k}-${A}-${j}T${$}:${P}`)}S(r.message.content),y(r.enabled)}else{c(""),d("cron"),m("0 9 * * *");const _=new Date;_.setHours(_.getHours()+1);const k=_.getFullYear(),A=String(_.getMonth()+1).padStart(2,"0"),j=String(_.getDate()).padStart(2,"0"),$=String(_.getHours()).padStart(2,"0"),P=String(_.getMinutes()).padStart(2,"0");h(`${k}-${A}-${j}T${$}:${P}`),S(""),y(!0),I("skip")}},[r]);const T=()=>{const _={name:u,schedule:p==="cron"?{type:"cron",expression:g,concurrencyPolicy:w}:{type:"reserved",reservedExecutionTime:(()=>{const k=f.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/);if(!k)throw new Error("Invalid datetime format");const A=Number(k[1]),j=Number(k[2]),$=Number(k[3]),P=Number(k[4]),z=Number(k[5]);return new Date(A,j-1,$,P,z).toISOString()})()},message:{content:v,projectId:a,baseSessionId:null},enabled:E};t(_)},D=u.trim()!==""&&v.trim()!=="";return s.jsx(cn,{open:e,onOpenChange:n,children:s.jsxs(dn,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[s.jsxs(jn,{children:[s.jsx(Mn,{children:r?s.jsx(R,{id:"scheduler.dialog.title.edit"}):s.jsx(R,{id:"scheduler.dialog.title.create"})}),s.jsx(Pn,{children:s.jsx(R,{id:"scheduler.dialog.description"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[s.jsxs("div",{className:"space-y-0.5",children:[s.jsx(Ie,{htmlFor:"enabled",className:"text-base font-semibold",children:s.jsx(R,{id:"scheduler.form.enabled"})}),s.jsx("p",{className:"text-sm text-muted-foreground",children:s.jsx(R,{id:"scheduler.form.enabled.description"})})]}),s.jsx(ES,{id:"enabled",checked:E,onCheckedChange:y,disabled:i})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{htmlFor:"job-name",children:s.jsx(R,{id:"scheduler.form.name"})}),s.jsx(ht,{id:"job-name",value:u,onChange:_=>c(_.target.value),placeholder:o({id:"scheduler.form.name.placeholder",message:"e.g., Daily Report"}),disabled:i})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"scheduler.form.schedule_type"})}),s.jsxs(Ot,{value:p,onValueChange:_=>d(_),disabled:i,children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"cron",children:s.jsx(R,{id:"scheduler.form.schedule_type.cron"})}),s.jsx(Ve,{value:"reserved",children:s.jsx(R,{id:"scheduler.form.schedule_type.reserved"})})]})]})]}),p==="cron"?s.jsx(Iz,{value:g,onChange:m}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{htmlFor:"reserved-datetime",children:s.jsx(R,{id:"scheduler.form.reserved_time"})}),s.jsx(ht,{id:"reserved-datetime",type:"datetime-local",value:f,onChange:_=>h(_.target.value),disabled:i}),s.jsx("p",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"scheduler.form.reserved_time.hint"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{htmlFor:"message-content",children:s.jsx(R,{id:"scheduler.form.message"})}),s.jsxs("div",{className:"relative",ref:b.containerRef,children:[s.jsx(ic,{ref:b.textareaRef,id:"message-content",value:v,onChange:_=>b.handleChange(_.target.value,S),onKeyDown:_=>b.handleKeyDown(_),placeholder:l._({id:"scheduler.form.message.placeholder",message:"Type message to send to Claude Code... (/ for commands, @ for files)"}),rows:4,disabled:i,className:"resize-none","aria-label":l._({id:"scheduler.form.message.aria_label",message:"Message input with completion support (/ for commands, @ for files)"}),"aria-expanded":v.startsWith("/")||v.includes("@"),"aria-haspopup":"listbox",role:"combobox","aria-autocomplete":"list"}),s.jsx(hS,{projectId:a,message:v,commandCompletionRef:b.commandCompletionRef,fileCompletionRef:b.fileCompletionRef,handleCommandSelect:_=>b.handleCommandSelect(_,S),handleFileSelect:_=>b.handleFileSelect(_,S),cursorPosition:b.cursorPosition})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:s.jsx(R,{id:"scheduler.form.message.hint"})})]}),p==="cron"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ie,{children:s.jsx(R,{id:"scheduler.form.concurrency_policy"})}),s.jsxs(Ot,{value:w,onValueChange:_=>I(_),disabled:i,children:[s.jsx(Dt,{children:s.jsx(Lt,{})}),s.jsxs($t,{children:[s.jsx(Ve,{value:"skip",children:s.jsx(R,{id:"scheduler.form.concurrency_policy.skip"})}),s.jsx(Ve,{value:"run",children:s.jsx(R,{id:"scheduler.form.concurrency_policy.run"})})]})]})]})]}),s.jsxs(gy,{children:[s.jsx(re,{variant:"outline",onClick:()=>n(!1),disabled:i,children:s.jsx(R,{id:"common.cancel"})}),s.jsx(re,{onClick:T,disabled:!D||i,children:i?s.jsx(R,{id:"common.saving"}):r?s.jsx(R,{id:"common.update"}):s.jsx(R,{id:"common.create"})})]})]})})},Az=({projectId:e,sessionId:n})=>{const{i18n:r}=Ke(),{data:a,isLoading:t,isFetching:i,error:o,refetch:l}=rz(),u=mS(),c=az(),p=iz(),[d,g]=O.useState(!1),[m,f]=O.useState(null),[h,v]=O.useState(!1),[S,E]=O.useState(null),y=k=>{u.mutate(k,{onSuccess:()=>{de.success(r._({id:"scheduler.job.created",message:"Job created successfully"})),g(!1)},onError:A=>{de.error(r._({id:"scheduler.job.create_failed",message:"Failed to create job"}),{description:A.message})}})},w=k=>{m&&c.mutate({id:m.id,updates:k},{onSuccess:()=>{de.success(r._({id:"scheduler.job.updated",message:"Job updated successfully"})),g(!1),f(null)},onError:A=>{de.error(r._({id:"scheduler.job.update_failed",message:"Failed to update job"}),{description:A.message})}})},I=()=>{S&&p.mutate(S,{onSuccess:()=>{de.success(r._({id:"scheduler.job.deleted",message:"Job deleted successfully"})),v(!1),E(null)},onError:k=>{de.error(r._({id:"scheduler.job.delete_failed",message:"Failed to delete job"}),{description:k.message})}})},b=k=>{f(k),g(!0)},T=k=>{E(k),v(!0)},D=k=>k.schedule.type==="cron"?`Cron: ${k.schedule.expression}`:k.schedule.type==="reserved"?`Reserved: ${new Date(k.schedule.reservedExecutionTime).toLocaleString()}`:"Unknown schedule type",_=k=>k?new Date(k).toLocaleString():"Never";return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx("div",{className:"p-3 border-b border-sidebar-border",children:s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h2",{className:"text-sm font-semibold text-sidebar-foreground",children:s.jsx(R,{id:"scheduler.title"})}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(re,{onClick:()=>l(),variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:t||i,title:r._({id:"common.reload",message:"Reload"}),children:s.jsx(my,{className:`w-3 h-3 ${t||i?"animate-spin":""}`})}),s.jsx(re,{onClick:()=>{f(null),g(!0)},variant:"ghost",size:"sm",className:"h-7 w-7 p-0",title:r._({id:"scheduler.create_job",message:"Create Job"}),children:s.jsx(Nu,{className:"w-3 h-3"})})]})]})}),s.jsxs("div",{className:"flex-1 overflow-auto p-3",children:[t&&s.jsx("div",{className:"flex items-center justify-center h-32",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:s.jsx(an,{})})}),o&&s.jsx("div",{className:"text-sm text-red-500",children:s.jsx(R,{id:"scheduler.error.load_failed",values:{error:o.message}})}),a&&a.length===0&&s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:s.jsx(R,{id:"scheduler.no_jobs"})}),a&&a.length>0&&s.jsx("div",{className:"space-y-3",children:a.map(k=>s.jsxs("div",{className:"p-3 bg-sidebar-accent/50 rounded-md border border-sidebar-border",children:[s.jsxs("div",{className:"flex items-start justify-between mb-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-medium text-sidebar-foreground truncate",children:k.name}),s.jsx(pe,{variant:k.enabled?"default":"secondary",className:"text-xs",children:k.enabled?s.jsx(R,{id:"scheduler.status.enabled"}):s.jsx(R,{id:"scheduler.status.disabled"})})]}),s.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:D(k)})]}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(re,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>b(k),children:s.jsx(VT,{className:"w-3 h-3"})}),s.jsx(re,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive hover:text-destructive",onClick:()=>T(k.id),children:s.jsx(YT,{className:"w-3 h-3"})})]})]}),k.lastRunAt&&s.jsx("div",{className:"text-xs text-muted-foreground mt-2 pt-2 border-t border-sidebar-border",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{children:[s.jsx(R,{id:"scheduler.last_run"}),s.jsx("span",{children:_(k.lastRunAt)})]}),k.lastRunStatus&&s.jsx(pe,{variant:k.lastRunStatus==="success"?"default":"destructive",className:"text-xs",children:k.lastRunStatus})]})})]},k.id))})]}),s.jsx(Tz,{open:d,onOpenChange:k=>{g(k),k||f(null)},job:m,projectId:e,currentSessionId:n,onSubmit:m?w:y,isSubmitting:u.isPending||c.isPending}),s.jsx(cn,{open:h,onOpenChange:v,children:s.jsxs(dn,{children:[s.jsxs(jn,{children:[s.jsx(Mn,{children:s.jsx(R,{id:"scheduler.delete_dialog.title"})}),s.jsx(Pn,{children:s.jsx(R,{id:"scheduler.delete_dialog.description"})})]}),s.jsxs(gy,{children:[s.jsx(re,{variant:"outline",onClick:()=>{v(!1),E(null)},disabled:p.isPending,children:s.jsx(R,{id:"common.cancel"})}),s.jsx(re,{variant:"destructive",onClick:I,disabled:p.isPending,children:p.isPending?s.jsx(R,{id:"common.deleting"}):s.jsx(R,{id:"common.delete"})})]})]})})]})},Rz=({currentSessionId:e,projectId:n,className:r,isMobileOpen:a=!1,onMobileOpenChange:t,initialTab:i})=>{const o=e??"",l=O.useMemo(()=>[{id:"sessions",icon:pn,title:s.jsx(R,{id:"sidebar.show.session.list"}),content:s.jsx(O.Suspense,{fallback:s.jsx(an,{}),children:s.jsx(SS,{currentSessionId:o,projectId:n})})},{id:"mcp",icon:ky,title:s.jsx(R,{id:"sidebar.show.mcp.settings"}),content:s.jsx(vS,{projectId:n})},{id:"scheduler",icon:gT,title:s.jsx(R,{id:"sidebar.show.scheduler.jobs"}),content:s.jsx(Az,{projectId:n,sessionId:o})}],[o,n]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:ce("hidden md:flex h-full",r),children:s.jsx(iT,{projectId:n,additionalTabs:l,defaultActiveTab:i,headerButton:s.jsx(Sy,{children:s.jsxs(Ye,{children:[s.jsx(Ze,{asChild:!0,children:s.jsx(An,{to:"/projects",className:"w-12 h-12 flex items-center justify-center hover:bg-sidebar-accent transition-colors",children:s.jsx(Ey,{className:"w-4 h-4 text-sidebar-foreground/70"})})}),s.jsx(Xe,{side:"right",children:s.jsx("p",{children:s.jsx(R,{id:"sidebar.back.to.projects"})})})]})})})}),s.jsx(kz,{currentSessionId:o,projectId:n,isOpen:a,onClose:()=>t?.(!1)})]})},Cz=({projectId:e,sessionId:n,isMobileSidebarOpen:r,setIsMobileSidebarOpen:a,tab:t})=>{const{data:i}=Iu(e),{data:o}=Tu(e),l=i.pages[0];if(l===void 0)return null;const u=l.project,c=u.meta.projectPath??u.claudeProjectPath,p=o?.success?o.data.currentBranch?.name:void 0;return s.jsxs(s.Fragment,{children:[s.jsx(O.Suspense,{fallback:s.jsx(an,{}),children:s.jsx(Rz,{currentSessionId:n,projectId:e,isMobileOpen:r,onMobileOpenChange:a,initialTab:t})}),s.jsx(O.Suspense,{fallback:s.jsx(an,{}),children:s.jsx(Ez,{projectId:e,sessionId:n,setIsMobileSidebarOpen:a,projectPath:c,currentBranch:p,revisionsData:o,projectName:u.meta.projectName??"Untitled Project"})})]})},Oz=({projectId:e,sessionId:n,tab:r})=>{const[a,t]=O.useState(!1);return s.jsx("div",{className:"flex h-screen max-h-screen overflow-hidden",children:s.jsx(Cz,{projectId:e,sessionId:n,tab:r,isMobileSidebarOpen:a,setIsMobileSidebarOpen:t})})};function Mz(){const e=vc.useParams(),n=vc.useSearch(),{data:r}=Iu(e.projectId),a=r.pages[0]?.project.meta.projectName,{sessionId:t,tab:i}=n,o=a?`${a} - Claude Code Viewer`:"Claude Code Viewer";return s.jsxs(oT,{children:[s.jsx(GI,{children:s.jsx("title",{children:o})}),s.jsx(Oz,{projectId:e.projectId,sessionId:t,tab:i})]})}export{Mz as component};
|