@openchamber/web 1.13.6 → 1.13.7
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/bin/lib/commands-update.test.js +50 -0
- package/dist/assets/{DiagramView-C_f1Il8p.js → DiagramView-BJkP8Fjp.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-BR0DXO9F.js → MarkdownRendererImpl-Nq7bOf31.js} +1 -1
- package/dist/assets/{MultiRunWindow-WBqBXcts.js → MultiRunWindow-CRKVePMG.js} +1 -1
- package/dist/assets/{NewWorktreeDialog-D7l2VA7o.js → NewWorktreeDialog-Dj6KETex.js} +1 -1
- package/dist/assets/{OnboardingScreen-ChaxLu9k.js → OnboardingScreen-DRe8UNiS.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-xaYa-FIx.js → SessionSwitcherDropdown-Cn_yoQrm.js} +1 -1
- package/dist/assets/{SettingsWindow-D5aAKCEM.js → SettingsWindow-BIKNrxSK.js} +1 -1
- package/dist/assets/{TerminalView-D8GzsMZF.js → TerminalView-BDjzrhGS.js} +1 -1
- package/dist/assets/{index-DxqTiFfR.css → index-Bv4711NQ.css} +1 -1
- package/dist/assets/{main-DUn82Iwq.js → main-BByFAmjA.js} +3 -3
- package/dist/assets/{main-CLkcy9_q.js → main-BJDsJGkp.js} +2 -2
- package/dist/assets/miniChat-Ckr71tB9.js +2 -0
- package/dist/assets/mobile-DVDtnIcD.js +2 -0
- package/dist/assets/{renderElectronMiniChatApp-BTsP-lHc.js → renderElectronMiniChatApp-CXvtB6Rd.js} +2 -2
- package/dist/assets/{renderMobileApp-CSEgabkw.js → renderMobileApp-BVAt5rTM.js} +3 -3
- package/dist/assets/{useAppFontEffects-BPhei6aO.js → useAppFontEffects-B66TruVB.js} +111 -111
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/package-manager.js +2 -2
- package/server/lib/package-manager.test.js +13 -1
- package/dist/assets/miniChat-Ag1CYNF5.js +0 -2
- package/dist/assets/mobile-DtojUfiY.js +0 -2
- /package/dist/assets/{index-DJHN0H4h.js → index-AsCHiJ5P.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-
|
|
2
|
-
import{j as s,e as mt,a as ro,R as i,d as Mf,p as fc,b as Ff,H as Xe,I as Lf,u as xa,l as yo,n as ba,D as ya,q as wa,S as $l,v as zl,w as mc,C as hc,L as Ul,N as Vh,O as $h,T as zh,W as Uh,X as ni,Y as Wh,$ as Hh,F as Gh,a0 as Kh,a1 as qh,a2 as Yh,a3 as Of,a4 as Qh,a5 as Jh,a6 as Wl,a7 as Xh,s as Zh,m as ep,a8 as md,a9 as hd,aa as pd,ab as tp,ac as sp,ad as np,ae as rp,af as ip,ag as op,_ as io,ah as gd,ai as xd,aj as bd,G as ap}from"./vendor-.bun-By2L9XvG.js";import{f as pc,h as dr,j as Ji,k as yd,l as lp,m as va,n as Bf,p as cp,e as As,q as Lo,b as Ee,t as dp,v as Oa,w as Gr,a as Ur,x as Wr,y as Hl,z as up,A as fp,R as wd,B as vd,u as Js,C as mp,D as Ni,E as _f,F as Vf,G as gc,o as _n,H as hp,g as Ci,I as pp,r as xc,J as gp,K as bc,L as $f,M as xp,N as bp,O as na,P as ra,Q as yp,S as wp,T as vp,U as jd,V as Sd,W as Nd,X as kd,Y as jp,Z as Sp,_ as Cd,d as Ad,$ as Np,a0 as kp,a1 as Cp,i as Ap,s as Dp}from"./index-DJHN0H4h.js";import{u as Nt,m as Pe,ao as bs,I,p as ur,t as le,ap as en,aq as Rr,ar as tn,as as sn,a as Jn,at as Er,au as Ii,av as Dd,aw as Et,ax as Mt,ay as Ft,az as Ip,ac as Do,aA as ja,aB as ri,ad as Io,ae as zf,a5 as yc,aC as Uf,aD as Pp,Q as ss,z as ut,aE as Tp,a7 as Wf,y as vr,x as wc,D as ws,R as Pi,aF as Hf,aG as Gf,aH as Sa,aI as Kf,aJ as qf,aK as Yf,aL as Qf,aM as Rp,aN as Ep,T as vc,aO as Ba,aP as ii,aQ as jc,aR as ia,X as Zs,aS as Mp,aT as Jf,aU as Fp,aV as Xf,aW as Sc,aX as Hs,aY as Ws,B as $e,aZ as Vs,a_ as $s,a$ as ci,b0 as Lp,b1 as Op,b2 as zo,b3 as Tn,b4 as Zf,b5 as em,a2 as Nc,b6 as Bp,b7 as Id,b8 as Pd,b9 as ki,n as vn,ba as Ti,bb as Xi,bc as _p,bd as Vp,be as $p,bf as zp,bg as _a,bh as Va,bi as $a,bj as za,bk as oi,bl as li,bm as Up,bn as Wp,bo as on,bp as Hp,bq as Gp,br as Kp,bs as qp,bt as Yp,k as Ai,bu as kc,bv as Qp,bw as Jp,bx as Xp,by as Zp,bz as eg,bA as tg,bB as sg,bC as Vn,bD as $n,bE as zn,bF as Nn,bG as Un,bH as Ls,bI as ng,w as Po,M as Ua,S as Wa,bJ as rg,bK as ir,bL as ig,b as di,d as Cc,c as Ha,bM as og,bN as tm,bO as ag,bP as lg,e as Ac,bQ as cg,f as wn,bR as Ga,a3 as Pr,j as dg,bS as ug,bT as ol,bU as fg,bV as mg,F as Hr,bW as Dc,bX as Ka,bY as fn,bZ as Ri,l as Zi,b_ as sm,b$ as hg,c0 as pg,c1 as gg,c2 as Td,c3 as xg,q as Kr,r as Rd,v as Ed,c4 as Md,c5 as nm,c6 as Fd,c7 as Ld,c8 as rm,c9 as bg,ca as im,o as Od,J as yg,cb as al,cc as Ic,cd as wg,ce as vg,cf as jg,cg as Oo,ch as Sg,ci as ll,cj as om,ck as am,cl as Pc,cm as Ng,cn as Tc,co as lm,cp as Uo,cq as kg,cr as Tr,cs as Cg,ct as cm,cu as Ag,cv as Dg,cw as Bd,cx as dm,cy as um,cz as fm,E as Rc,P as qa,G as Ya,L as Na,cA as ka,cB as Ln,H as Ig,K as Pg,cC as Tg,cD as Gl,cE as Rg,cF as Eg,cG as Mg,cH as _d,cI as Fg,cJ as Lg,cK as Ec,cL as mm,cM as Og,cN as Bg,cO as _g,cP as Vg,cQ as Vd,cR as $d,cS as $g,cT as zg,cU as Ug,cV as Wg,cW as Hg,cX as Gg,N as Kg,cY as zd,cZ as qg,c_ as hm,O as Yg,c$ as Qg,A as Jg,C as Xg,d0 as Zg,d1 as ex,d2 as tx,d3 as sx,d4 as nx,d5 as rx,d6 as ix,d7 as ox,d8 as ax,d9 as Ca,da as lx,db as Ud,dc as cx,dd as dx,de as ux,df as oo,dg as fx,dh as Wd,di as mx,dj as hx,dk as px,dl as gx,dm as pm,dn as gm,dp as xx,dq as bx,dr as yx,ds as oa,a9 as wx,dt as vx,du as cl,dv as jx,dw as Sx,U as Nx,V as kx,W as Cx,Y as Hd,Z as Gd,_ as Kd,dx as Ax,$ as xm,a0 as bm,aj as Dx,ak as Ix,al as Px,am as Tx,an as Rx,af as Ex,ag as Mx,ah as Fx,ai as Lx}from"./useAppFontEffects-BPhei6aO.js";import{I as qd,o as Ox,p as Yd,q as Bx,r as Qd,t as Jr,s as _x,v as dl,w as To,U as Aa,x as Da,y as eo,z as Bo,B as to,k as ym,M as wm,i as mn,j as Vx,Q as vm,E as $x,F as zx,G as Ux,l as Kl,H as jm,P as Sm,J as Wx,K as Hx,C as Gx,a as Kx,L as Mc,R as Nm,T as Fc,V as Lc,W as Oc,X as km,Y as Cm,Z as ql,_ as Am,$ as Yl,a0 as aa,a1 as qx,a2 as Yx,e as wo,N as Qx,D as Jx,u as Xx,n as Zx,m as Ql,a3 as eb,a4 as tb,g as sb,a5 as nb,a6 as rb,c as ib,O as Dm,d as ob,a7 as ab}from"./NewWorktreeDialog-D7l2VA7o.js";import{S as lb,C as cb,W as db,g as Bc,r as ub,n as cs,i as Ro,d as so,c as Gi,a as Jd,b as fb,e as vo,f as Im,h as mb,j as hb,u as ul}from"./SessionSwitcherDropdown-xaYa-FIx.js";function Pm(t){const{drafts:e,editingDraftId:n,commentText:r,onTextChange:o,selection:a,isDragging:c,fileLabel:l,newWidgetId:d,mapDraftToRange:u,onSave:m,onCancel:f,onEdit:p,onDelete:y}=t,g=[];for(const b of e){const x=u(b);if(b.id===n){g.push({afterLine:x.end,id:`edit-${b.id}`,content:s.jsx(qd,{initialText:r,onTextChange:o,fileLabel:l,lineRange:x,isEditing:!0,onSave:m,onCancel:f},`edit-${b.id}`)});continue}g.push({afterLine:x.end,id:`card-${b.id}`,content:s.jsx(Ox,{draft:b,onEdit:()=>p(b),onDelete:()=>y(b)},`card-${b.id}`)})}if(a&&!n&&!c){const b={...a,start:Math.min(a.start,a.end),end:Math.max(a.start,a.end)};g.push({afterLine:b.end,id:d,content:s.jsx(qd,{initialText:r,onTextChange:o,fileLabel:l,lineRange:b,isEditing:!1,onSave:m,onCancel:f},d)})}return g}function Xd(t){const e=mt.c(14);let n,r,o,a;e[0]!==t?({size:o,className:n,style:a,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=o,e[4]=a):(n=e[1],r=e[2],o=e[3],a=e[4]);const c=typeof o=="number"?`${o}px`:o,l=typeof o=="number"?`${o}px`:o;let d;e[5]!==a||e[6]!==c||e[7]!==l?(d={width:c,height:l,...a},e[5]=a,e[6]=c,e[7]=l,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("path",{d:"M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z"}),e[9]=u):u=e[9];let m;return e[10]!==n||e[11]!==r||e[12]!==d?(m=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:n,style:d,...r,children:u}),e[10]=n,e[11]=r,e[12]=d,e[13]=m):m=e[13],m}const ai=[{id:"finder",label:"Finder",appName:"Finder"},{id:"terminal",label:"Terminal",appName:"Terminal"},{id:"iterm2",label:"iTerm2",appName:"iTerm"},{id:"ghostty",label:"Ghostty",appName:"Ghostty"},{id:"vscode",label:"VS Code",appName:"Visual Studio Code"},{id:"intellij",label:"IntelliJ",appName:"IntelliJ IDEA"},{id:"visual-studio",label:"Visual Studio",appName:"Visual Studio"},{id:"cursor",label:"Cursor",appName:"Cursor"},{id:"android-studio",label:"Android Studio",appName:"Android Studio"},{id:"pycharm",label:"PyCharm",appName:"PyCharm"},{id:"xcode",label:"Xcode",appName:"Xcode"},{id:"sublime-text",label:"Sublime",appName:"Sublime Text"},{id:"webstorm",label:"WebStorm",appName:"WebStorm"},{id:"rider",label:"Rider",appName:"Rider"},{id:"zed",label:"Zed",appName:"Zed"},{id:"phpstorm",label:"PhpStorm",appName:"PhpStorm"},{id:"eclipse",label:"Eclipse",appName:"Eclipse"},{id:"windsurf",label:"Windsurf",appName:"Windsurf"},{id:"vscodium",label:"VSCodium",appName:"VSCodium"},{id:"rustrover",label:"RustRover",appName:"RustRover"},{id:"kiro",label:"Kiro",appName:"Kiro"},{id:"antigravity",label:"Antigravity",appName:"Antigravity"},{id:"trae",label:"Trae",appName:"Trae"}],Jl="finder",Xl=new Set(["finder","terminal"]),_c=t=>typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="win32"&&t.id==="finder"?{...t,label:"Explorer",appName:"File Explorer"}:t,Zl=t=>{if(!t)return null;const e=ai.find(n=>n.id===t)??null;return e?_c(e):null},fl=()=>ai.filter(t=>Xl.has(t.id)).map(t=>({..._c(t)})),pb=()=>{if(typeof window>"u")return Jl;const t=window.localStorage.getItem("openInAppId");return t&&Zl(t)?t:Jl};let ml=!1,_i=!1,Xr=!1,Zr=0,jo=null;const Zd=()=>{jo&&(clearTimeout(jo),jo=null)},yr=ro()((t,e)=>({selectedAppId:pb(),availableApps:fl(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(ml||typeof window>"u")return;ml=!0;const n=(d,u=!0)=>{if(!Array.isArray(d)||d.length===0){t({availableApps:fl(),hasLoadedApps:u});return}const m=new Set(d.map(g=>g.name)),f=new Map(d.map(g=>[g.name,g.iconDataUrl??void 0])),y=ai.filter(g=>m.has(g.appName)||Xl.has(g.id)).map(g=>({..._c(g),iconDataUrl:f.get(g.appName)}));t({availableApps:y,hasLoadedApps:!0})},r=async d=>{if(!dr()||!Ji()||_i||e().hasLoadedApps&&!d)return;const m=ai.map(f=>f.appName);Zd(),_i=!0,Xr=!1,t({isScanning:!0});try{const{apps:f,success:p,hasCache:y,isCacheStale:g}=await yd(m,d),b=p&&!y&&f.length===0&&Zr<3;if(t({isCacheStale:y?g:!1}),n(f,p?!b:!1),p){if(b){const h=[800,1600,3200][Zr]??3200;Zr+=1,Xr=!0,jo=setTimeout(()=>{r()},h);return}Zr=0,Xr=!1;return}if(Zr<3){const h=[1e3,3e3,7e3][Zr]??7e3;Zr+=1,Xr=!0,jo=setTimeout(()=>{r()},h)}}finally{_i=!1,Xr||t({isScanning:!1})}};r();const o=d=>{const u=d.detail,m=u&&typeof u.openInAppId=="string"&&u.openInAppId.length>0&&Zl(u.openInAppId)?u.openInAppId:null;m&&(window.localStorage.setItem("openInAppId",m),t({selectedAppId:m}))},a=()=>{r()},c=d=>{const u=d.detail;Array.isArray(u)&&(Zr=3,Xr=!1,t({isScanning:!1,isCacheStale:!1}),n(u))};window.addEventListener("openchamber:settings-synced",o),window.addEventListener("openchamber:app-ready",a),window.addEventListener("openchamber:installed-apps-updated",c),window.__openchamberAppReady&&r(),window.setTimeout(()=>{e().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(ml||e().initialize(),!dr()||!Ji()||_i||e().hasLoadedApps&&!n)return;const o=ai.map(a=>a.appName);Zd(),n&&t({hasLoadedApps:!1}),_i=!0,Xr=!1,t({isScanning:!0});try{const{apps:a,hasCache:c,isCacheStale:l}=await yd(o,n),d=new Set(a.map(p=>p.name)),u=new Map(a.map(p=>[p.name,p.iconDataUrl??void 0])),f=ai.filter(p=>d.has(p.appName)||Xl.has(p.id)).map(p=>({...p,iconDataUrl:u.get(p.appName)}));t({availableApps:f.length>0?f:fl(),hasLoadedApps:f.length>0,isCacheStale:c?l:!1})}finally{_i=!1,Xr||t({isScanning:!1})}},selectApp:async n=>{Zl(n)&&(t({selectedAppId:n}),typeof window<"u"&&window.localStorage.setItem("openInAppId",n),await pc({openInAppId:n}))}})),gb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",xb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",hl=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__!=="win32"?gb:t.id==="terminal"?xb:void 0}),eu=t=>{const e=mt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:o}=t,[a,c]=i.useState(!1);let l;e[0]!==n?(l=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=l):l=e[1];const d=l,u=r||o;if(u&&!a){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>c(!0),e[2]=p):p=e[2];let y;return e[3]!==u?(y=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=u,e[4]=y):y=e[4],y}let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=Pe("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=m):m=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:m,children:d}),e[6]=d,e[7]=f):f=e[7],f},bb=t=>{const e=mt.c(75),{directory:n,className:r}=t,{t:o}=Nt(),a=yr(yb),c=yr(wb),l=yr(vb),d=yr(jb),u=yr(Sb),m=yr(Nb),f=yr(kb);let p,y;e[0]!==u?(p=()=>{u()},y=[u],e[0]=u,e[1]=p,e[2]=y):(p=e[1],y=e[2]),i.useEffect(p,y);const g=dr()&&Ji();let b;e:{let ke;e[3]!==c||e[4]!==a?(ke=c.find(O=>O.id===a)??c.find(Cb)??c[0]??ai[0],e[3]=c,e[4]=a,e[5]=ke):ke=e[5];const Y=ke;if(Y){let O;e[6]!==Y?(O=hl(Y),e[6]=Y,e[7]=O):O=e[7],b=O;break e}let ge;e[8]===Symbol.for("react.memo_cache_sentinel")?(ge=hl(ai[0]),e[8]=ge):ge=e[8],b=ge}const x=b;if(!g||!n||c.length===0)return null;let h;e[9]!==n?(h=async ke=>{await lp(n,ke.id,ke.appName)||await va(n,ke.appName)},e[9]=n,e[10]=h):h=e[10];const C=h;let w;e[11]!==C||e[12]!==f?(w=async ke=>{await f(ke.id),await C(ke)},e[11]=C,e[12]=f,e[13]=w):w=e[13];const v=w;let S;e[14]!==n||e[15]!==o?(S=async()=>{(await ur(n)).ok&&le.success(o("openInApp.toast.pathCopied"))},e[14]=n,e[15]=o,e[16]=S):S=e[16];const k=S;let j;e[17]!==r?(j=Pe("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=j):j=e[18];let A;e[19]!==C||e[20]!==x?(A=()=>{C(x)},e[19]=C,e[20]=x,e[21]=A):A=e[21];const D=d&&"animate-pulse";let N;e[22]!==D?(N=Pe("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",D),e[22]=D,e[23]=N):N=e[23];let B;e[24]!==x.label||e[25]!==o?(B=o("openInApp.actions.openInAria",{app:x.label}),e[24]=x.label,e[25]=o,e[26]=B):B=e[26];let T;e[27]!==x.fallbackIconDataUrl||e[28]!==x.iconDataUrl||e[29]!==x.label?(T=s.jsx(eu,{label:x.label,iconDataUrl:x.iconDataUrl,fallbackIconDataUrl:x.fallbackIconDataUrl}),e[27]=x.fallbackIconDataUrl,e[28]=x.iconDataUrl,e[29]=x.label,e[30]=T):T=e[30];let E;e[31]!==N||e[32]!==B||e[33]!==T||e[34]!==A?(E=s.jsx("button",{type:"button",onClick:A,className:N,"aria-label":B,children:T}),e[31]=N,e[32]=B,e[33]=T,e[34]=A,e[35]=E):E=e[35];let _;e[36]===Symbol.for("react.memo_cache_sentinel")?(_=Pe("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=_):_=e[36];let R;e[37]!==o?(R=o("openInApp.actions.chooseAppAria"),e[37]=o,e[38]=R):R=e[38];let V;e[39]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(I,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=V):V=e[39];let $;e[40]!==R?($=s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:_,"aria-label":R,children:V})}),e[40]=R,e[41]=$):$=e[41];let z;e[42]!==k?(z=()=>{k()},e[42]=k,e[43]=z):z=e[43];let F;e[44]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(I,{name:"file-copy",className:"h-4 w-4"}),e[44]=F):F=e[44];let te;e[45]!==o?(te=o("openInApp.actions.copyPath"),e[45]=o,e[46]=te):te=e[46];let ne;e[47]!==te?(ne=s.jsx("span",{className:"typography-ui-label text-foreground",children:te}),e[47]=te,e[48]=ne):ne=e[48];let q;e[49]!==z||e[50]!==ne?(q=s.jsxs(bs,{className:"flex items-center gap-2",onClick:z,children:[F,ne]}),e[49]=z,e[50]=ne,e[51]=q):q=e[51];let H;e[52]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(Rr,{}),e[52]=H):H=e[52];let X;if(e[53]!==c||e[54]!==v||e[55]!==x.id){let ke;e[57]!==v||e[58]!==x.id?(ke=Y=>{const ge=hl(Y);return s.jsxs(bs,{className:"flex items-center gap-2",onClick:()=>{v(Y)},children:[s.jsx(eu,{label:Y.label,iconDataUrl:Y.iconDataUrl,fallbackIconDataUrl:ge.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:Y.label}),x.id===Y.id?s.jsx(I,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},Y.id)},e[57]=v,e[58]=x.id,e[59]=ke):ke=e[59],X=c.map(ke),e[53]=c,e[54]=v,e[55]=x.id,e[56]=X}else X=e[56];let oe;e[60]!==l||e[61]!==m||e[62]!==o?(oe=l?s.jsxs(bs,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(I,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[60]=l,e[61]=m,e[62]=o,e[63]=oe):oe=e[63];let he;e[64]!==q||e[65]!==X||e[66]!==oe?(he=s.jsxs(tn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[q,H,X,oe]}),e[64]=q,e[65]=X,e[66]=oe,e[67]=he):he=e[67];let Se;e[68]!==$||e[69]!==he?(Se=s.jsxs(sn,{children:[$,he]}),e[68]=$,e[69]=he,e[70]=Se):Se=e[70];let Z;return e[71]!==E||e[72]!==Se||e[73]!==j?(Z=s.jsxs("div",{className:j,children:[E,Se]}),e[71]=E,e[72]=Se,e[73]=j,e[74]=Z):Z=e[74],Z};function yb(t){return t.selectedAppId}function wb(t){return t.availableApps}function vb(t){return t.isCacheStale}function jb(t){return t.isScanning}function Sb(t){return t.initialize}function Nb(t){return t.loadInstalledApps}function kb(t){return t.selectApp}function Cb(t){return t.id===Jl}const Ab=1e6,Db="terminal-store";let tu=!1;const pl=t=>typeof t=="object"&&t!==null,Ib=t=>{const e=/^tab-(\d+)$/.exec(t);if(!e)return null;const n=Number(e[1]);return Number.isFinite(n)?n:null};function Dn(t){let e=t.trim();for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e}const gl=(t,e)=>({id:t,terminalSessionId:null,lifecycle:"idle",label:e,iconKey:null,bufferChunks:[],bufferLength:0,isConnecting:!1,createdAt:Date.now(),previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1}),xl=t=>({tabs:[t],activeTabId:t.id}),xr=(t,e)=>t.tabs.findIndex(n=>n.id===e),_s=ro()(Mf(fc((t,e)=>({sessions:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1,hasHydrated:typeof window>"u",ensureDirectory:n=>{const r=Dn(n);r&&t(o=>{if(o.sessions.has(r))return o;const a=new Map(o.sessions),c=`tab-${o.nextTabId}`,l=gl(c,"Terminal");return a.set(r,xl(l)),{sessions:a,nextTabId:o.nextTabId+1}})},getDirectoryState:n=>{const r=Dn(n);return e().sessions.get(r)},getActiveTab:n=>{const r=Dn(n),o=e().sessions.get(r);if(!o)return;const a=o.activeTabId;return a?o.tabs.find(c=>c.id===a)??o.tabs[0]:o.tabs[0]},createTab:n=>{const r=Dn(n);if(!r)return"tab-invalid";const o=`tab-${e().nextTabId}`;return t(a=>{const c=new Map(a.sessions),l=c.get(r),d=a.nextTabId+1,m=`Terminal ${(l?.tabs.length??0)+1}`,f=gl(o,m);return l?c.set(r,{...l,tabs:[...l.tabs,f]}):c.set(r,xl(f)),{sessions:c,nextTabId:d}}),o},setActiveTab:(n,r)=>{const o=Dn(n);t(a=>{const c=new Map(a.sessions),l=c.get(o);return!l||l.activeTabId===r||xr(l,r)<0?a:(c.set(o,{...l,activeTabId:r}),{sessions:c})})},setTabLabel:(n,r,o)=>{const a=Dn(n),c=o.trim();c&&t(l=>{const d=new Map(l.sessions),u=d.get(a);if(!u)return l;const m=xr(u,r);if(m<0||u.tabs[m]?.label===c)return l;const f=[...u.tabs];return f[m]={...f[m],label:c},d.set(a,{...u,tabs:f}),{sessions:d}})},setTabIconKey:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=o?.trim()||null;if(d.tabs[u]?.iconKey===m)return c;const f=[...d.tabs];return f[u]={...f[u],iconKey:m},l.set(a,{...d,tabs:f}),{sessions:l}})},closeTab:async(n,r)=>{const o=Dn(n),l=e().sessions.get(o)?.tabs.find(d=>d.id===r)?.terminalSessionId??null;if(l)try{await cp(l)}catch{}t(d=>{const u=new Map(d.sessions),m=u.get(o);if(!m)return d;const f=xr(m,r);if(f<0)return d;const p=m.tabs.filter(x=>x.id!==r),y=Object.fromEntries(Object.entries(d.projectActionRuns).filter(([,x])=>!(x.directory===o&&x.tabId===r))),g=Object.keys(y).length!==Object.keys(d.projectActionRuns).length;if(p.length===0){const x=`tab-${d.nextTabId}`,h=gl(x,"Terminal");return u.set(o,xl(h)),{sessions:u,nextTabId:d.nextTabId+1,...g?{projectActionRuns:y}:{}}}let b=m.activeTabId;return m.activeTabId===r&&(b=p[Math.min(f,p.length-1)]?.id??p[0]?.id??null),u.set(o,{...m,tabs:p,activeTabId:b}),{sessions:u,...g?{projectActionRuns:y}:{}}})},setTabSessionId:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=d.tabs[u],f=o!==null&&m.terminalSessionId!==o,p=o?"running":m.terminalSessionId?"exited":m.lifecycle,y={...m,terminalSessionId:o,lifecycle:p,isConnecting:!1,...f?{bufferChunks:[],bufferLength:0}:{}},g=[...d.tabs];return g[u]=y,l.set(a,{...d,tabs:g}),{sessions:l}})},setTabLifecycle:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=[...d.tabs];return m[u]={...m[u],lifecycle:o,isConnecting:!1},l.set(a,{...d,tabs:m}),{sessions:l}})},setConnecting:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=[...d.tabs];return m[u]={...m[u],isConnecting:o},l.set(a,{...d,tabs:m}),{sessions:l}})},appendToBuffer:(n,r,o)=>{if(!o)return;const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=d.tabs[u],f=c.nextChunkId,p={id:f,data:o},y=[...m.bufferChunks,p];let g=m.bufferLength+o.length;for(;g>Ab&&y.length>1;){const x=y.shift();if(!x)break;g-=x.data.length}const b=[...d.tabs];return b[u]={...m,bufferChunks:y,bufferLength:g},l.set(a,{...d,tabs:b}),{sessions:l,nextChunkId:f+1}})},setTabPreviewUrl:(n,r,o,a={})=>{const c=Dn(n);t(l=>{const d=new Map(l.sessions),u=d.get(c);if(!u)return l;const m=xr(u,r);if(m<0)return l;const f=u.tabs[m],p=a.autoOpened??f.previewAutoOpened,y=a.locked??f.previewUrlLocked;if(f.previewUrl===o&&f.previewAutoOpened===p&&f.previewUrlLocked===y)return l;const g=[...u.tabs];return g[m]={...f,previewUrl:o,previewAutoOpened:p,previewUrlLocked:y},d.set(c,{...u,tabs:g}),{sessions:d}})},markPreviewAutoOpened:(n,r)=>{const o=Dn(n);t(a=>{const c=new Map(a.sessions),l=c.get(o);if(!l)return a;const d=xr(l,r);if(d<0)return a;const u=l.tabs[d];if(!u.previewUrl||u.previewAutoOpened)return a;const m=[...l.tabs];return m[d]={...u,previewAutoOpened:!0},c.set(o,{...l,tabs:m}),{sessions:c}})},setProjectActionRun:n=>{t(r=>{const o=r.projectActionRuns[n.key];return o&&o.directory===n.directory&&o.actionId===n.actionId&&o.tabId===n.tabId&&o.sessionId===n.sessionId&&o.status===n.status?r:{projectActionRuns:{...r.projectActionRuns,[n.key]:n}}})},updateProjectActionRunStatus:(n,r)=>{t(o=>{const a=o.projectActionRuns[n];return!a||a.status===r?o:{projectActionRuns:{...o.projectActionRuns,[n]:{...a,status:r}}}})},removeProjectActionRun:n=>{t(r=>{if(!r.projectActionRuns[n])return r;const o={...r.projectActionRuns};return delete o[n],{projectActionRuns:o}})},clearBuffer:(n,r)=>{const o=Dn(n);t(a=>{const c=new Map(a.sessions),l=c.get(o);if(!l)return a;const d=xr(l,r);if(d<0)return a;const u=[...l.tabs];return u[d]={...u[d],bufferChunks:[],bufferLength:0},c.set(o,{...l,tabs:u}),{sessions:c}})},removeDirectory:n=>{const r=Dn(n);t(o=>{const a=new Map(o.sessions);a.delete(r);const c=Object.fromEntries(Object.entries(o.projectActionRuns).filter(([,l])=>l.directory!==r));return{sessions:a,projectActionRuns:c}})},clearAll:()=>{t({sessions:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1})}}),{name:Db,storage:Ff(()=>Bf()),partialize:t=>({sessions:Array.from(t.sessions.entries()).map(([e,n])=>[e,{activeTabId:n.activeTabId,tabs:n.tabs.map(r=>({id:r.id,label:r.label,iconKey:r.iconKey,terminalSessionId:r.terminalSessionId,lifecycle:r.lifecycle,createdAt:r.createdAt}))}]),nextTabId:t.nextTabId}),merge:(t,e)=>{if(!pl(t))return e;const n=Array.isArray(t.sessions)?t.sessions:[],r=new Map;let o=0;for(const l of n){if(!Array.isArray(l)||l.length!==2)continue;const[d,u]=l;if(typeof d!="string"||!pl(u))continue;const m=Array.isArray(u.tabs)?u.tabs:[],f=[];for(const g of m){if(!pl(g))continue;const b=typeof g.id=="string"?g.id:null;if(!b)continue;const x=Ib(b);x!==null&&(o=Math.max(o,x));const h=typeof g.terminalSessionId=="string"||g.terminalSessionId===null?g.terminalSessionId:null,C=g.lifecycle,w=C==="idle"||C==="running"||C==="exited"?C:h?"running":"idle";f.push({id:b,label:typeof g.label=="string"?g.label:"Terminal",iconKey:typeof g.iconKey=="string"?g.iconKey:null,terminalSessionId:h,lifecycle:w,createdAt:typeof g.createdAt=="number"?g.createdAt:Date.now(),bufferChunks:[],bufferLength:0,isConnecting:!1,previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1})}if(f.length===0)continue;const p=typeof u.activeTabId=="string"?u.activeTabId:null,y=p?f.some(g=>g.id===p):!1;r.set(d,{tabs:f,activeTabId:y?p:f[0].id})}const a=typeof t.nextTabId=="number"&&Number.isFinite(t.nextTabId)?t.nextTabId:1,c=Math.max(e.nextTabId,a,o+1);return{...e,sessions:r,nextChunkId:1,nextTabId:c,hasHydrated:!0}}})));if(typeof window<"u"&&!tu){tu=!0;const t=_s.persist,e=()=>{_s.getState().hasHydrated||_s.setState({hasHydrated:!0})};t?.hasHydrated?.()?e():t?.onFinishHydration?t.onFinishHydration(e):e()}const Pb=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Tb=["dev","start","preview","serve"];async function Rb(t,e,n){if(!t)return null;const r=Fb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id};if(n){const o=Lb(n);if(o){const a=await Ob(t);return{command:`${a==="npm"?"npm run":a==="yarn"?"yarn":a==="pnpm"?"pnpm":a==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await Eb(t)){const o=await Mb(),a=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${a}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${a}/`}}return null}async function Eb(t){const e=`${t}/index.html`,n=await Ia(e,t);return typeof n=="string"&&n.trim().length>0}async function Mb(){try{const t=await As("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Fb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Tb.some(o=>n.includes(o)))return e}return null}function Lb(t){for(const{pattern:e}of Pb)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Ob(t){const e=await Ia(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of n){const a=await Ia(`${t}/${r}`,t);if(typeof a=="string"&&a.trim().length>0)return o}return"npm"}async function Ia(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await As(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=Lo()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await As(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Bb(t){try{const e=await Ia(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const _b=t=>new Promise(e=>{window.setTimeout(e,t)}),Vb="\x1B",$b=new RegExp(`${Vb}\\[[0-9;?]*[ -/]*[@-~]`,"g"),zb=/https?:\/\/[^\s<>'"`]+/gi,sr="__openchamber_auto_discover_preview__",Ub=15e3,Wb=t=>{let e="";for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(e+=t[n])}return e},Hb=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Gb=t=>{const n=t.replace($b,"").match(zb);if(!n||n.length===0)return null;const r=n.map(a=>a.replace(/[),.;]+$/,"")).filter(Boolean);if(r.length===0)return null;const o=[];for(const a of r)try{const c=new URL(a);c.port&&c.port.length>0&&o.push({raw:a,parsed:c})}catch{}if(o.length>0){const a=c=>{const{parsed:l}=c,d=l.hostname.toLowerCase(),u=d==="localhost"||d==="127.0.0.1"||d==="0.0.0.0"||d==="::1",m=l.pathname||"/",f=m.split("/").filter(Boolean).length,p=m==="/"||m==="",y=!!(l.search||l.hash);let g=0;return u&&(g+=50),p&&(g+=30),g-=Math.min(f*5,20),y&&(g-=10),g};return o.sort((c,l)=>a(l)-a(c)),o[0]?.parsed.origin??o[0]?.raw??null}return r[0]??null},Tm=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:o=!1})=>{const{t:a}=Nt(),{terminal:c,runtime:l}=Jn(),{isMobile:d}=Er(),u=i.useMemo(()=>dr(),[]),m=Yd(U=>U.instances),f=Yd(U=>U.load),p=Ee(U=>U.setBottomTerminalOpen),y=Ee(U=>U.setActiveMainTab),g=Ee(U=>U.setSettingsPage),b=Ee(U=>U.setSettingsDialogOpen),x=Ee(U=>U.setSettingsProjectsSelectedId),h=Ee(U=>U.openContextPreview),C=_s(U=>U.sessions),w=_s(U=>U.ensureDirectory),v=_s(U=>U.setTabLabel),S=_s(U=>U.setTabIconKey),k=_s(U=>U.setActiveTab),j=_s(U=>U.setConnecting),A=_s(U=>U.setTabSessionId),D=_s(U=>U.setTabPreviewUrl),N=_s(U=>U.projectActionRuns),B=_s(U=>U.setProjectActionRun),T=_s(U=>U.updateProjectActionRunStatus),E=_s(U=>U.removeProjectActionRun),[_,R]=i.useState([]),[V,$]=i.useState(null),[z,F]=i.useState(!1),te=i.useRef({}),ne=i.useRef({}),q=i.useRef({}),H=i.useRef({}),X=i.useRef(0),oe=t?.id??null,he=t?.path??"",Se=i.useMemo(()=>oe?{id:oe,path:he}:null,[oe,he]);i.useEffect(()=>{u&&f().catch(()=>{})},[u,f]);const Z=i.useCallback(async U=>{await Ii(U)},[]),ke=i.useCallback(async()=>{if(!Se)return;const U=X.current+1;X.current=U,F(!0);try{const be=await Dd(Se);if(X.current!==U)return;const ve=be.actions;R(ve),$(G=>G===sr||G&&ve.some(ye=>ye.id===G)?G:null)}catch{if(X.current!==U)return}finally{X.current===U&&F(!1)}},[Se]),Y=i.useMemo(()=>Bx(e||Se?.path||""),[e,Se?.path]),ge=i.useMemo(()=>V?_.find(U=>U.id===V)??null:null,[_,V]),O=i.useMemo(()=>({id:sr,name:a("projectActions.actions.autoDiscover"),command:"",icon:"search",autoOpenUrl:!0}),[a]),se=!d,ee=i.useMemo(()=>se?[O,..._]:_,[_,O,se]);i.useEffect(()=>{ke()},[ke]),i.useEffect(()=>{if(typeof window>"u")return;const U=be=>{const ve=be.detail;oe&&(ve?.projectId&&ve.projectId!==oe||ke())};return window.addEventListener(Qd,U),()=>{window.removeEventListener(Qd,U)}},[ke,oe]),i.useEffect(()=>{V&&(V===sr&&se||_.some(U=>U.id===V)||$(null))},[_,se,V]),i.useEffect(()=>{for(const[U,be]of Object.entries(N)){const G=C.get(be.directory)?.tabs.find(ye=>ye.id===be.tabId);(!G||G.terminalSessionId!==be.sessionId)&&E(U)}},[N,E,C]),i.useEffect(()=>{for(const[U,be]of Object.entries(N)){const ve=ne.current[U]??{lastSeenChunkId:null,openedUrl:!1,tail:"",openInPreview:!1};ne.current[U]=ve;const G=ee.find(Oe=>Oe.id===be.actionId);if(!G)continue;const Le=C.get(be.directory)?.tabs.find(Oe=>Oe.id===be.tabId);if(!Le||!Array.isArray(Le.bufferChunks)||Le.bufferChunks.length===0)continue;const Re=Le.bufferChunks.filter(Oe=>ve.lastSeenChunkId===null?!0:Oe.id>ve.lastSeenChunkId);if(Re.length===0)continue;const J=Re.map(Oe=>Oe.data).join(""),L=`${ve.tail}${J}`,ae=!ve.openedUrl&&G.autoOpenUrl===!0?Gb(L):null,re=Re[Re.length-1]?.id??ve.lastSeenChunkId;if(ve.lastSeenChunkId=re,ve.tail=L.slice(-512),ae)if(ve.openedUrl=!0,ve.openInPreview){const Oe=N[U];Oe&&(D(Oe.directory,Oe.tabId,ae,{locked:!1,autoOpened:!1}),Oe.status==="waiting-for-preview"&&T(U,"running"),window.clearTimeout(H.current[U]),delete H.current[U],h(Oe.directory,ae))}else Z(ae),le.success(a("projectActions.toast.openedUrlFromOutput"));ne.current[U]=ve}for(const U of Object.keys(ne.current))N[U]||(delete ne.current[U],window.clearTimeout(H.current[U]),delete H.current[U])},[ee,h,Z,N,D,a,C,T]);const je=i.useCallback(async(U,be={})=>{if(!Y)throw new Error(a("projectActions.error.noActiveDirectory"));const ve=Jr(Y,U.id);w(Y);const G=_s.getState(),ye=G.getDirectoryState(Y);let Le=te.current[ve]||null;const Re=Le?!!ye?.tabs.some(ae=>ae.id===Le):!1;(!Le||!Re)&&(Le=G.createTab(Y),te.current[ve]=Le),v(Y,Le,`Action: ${U.name}`),S(Y,Le,U.icon||"play"),be.revealTerminal!==!1&&(k(Y,Le),p(!0),y("terminal"));const L=_s.getState().getDirectoryState(Y)?.tabs.find(ae=>ae.id===Le);return{key:ve,tabId:Le,sessionId:L?.terminalSessionId??null}},[w,Y,y,k,p,S,v,a]),De=i.useCallback(async U=>{if(l.isVSCode||!o&&d)return;if(!Y){le.error(a("projectActions.error.noActiveDirectoryForAction"));return}const be=Jr(Y,U.id),ve=N[be];if(!(ve&&ve.status==="running"))try{const G=U.id===sr?await(async()=>{const[Je,rt]=await Promise.all([Dd({id:Se?.id??"",path:Y}),Bb(Y)]),bt=await Rb(Y,Je.actions,rt);if(!bt)throw new Error(a("contextPanel.preview.noDevServer"));return{id:sr,name:a("projectActions.actions.autoDiscover"),command:bt.command,icon:"search",autoOpenUrl:!0,openUrl:bt.previewUrlHint||""}})():U,ye=G.autoOpenUrl===!0&&(G.openUrl||"").trim().length>0,{key:Le,tabId:Re,sessionId:J}=await je(G,{revealTerminal:!ye&&U.id!==sr});let L=J,ae=!1;if(!L){j(Y,Re,!0);try{L=(await c.createSession({cwd:Y})).sessionId,ae=!0,A(Y,Re,L)}finally{j(Y,Re,!1)}}if(!L)throw new Error(a("projectActions.error.failedToCreateTerminalSession"));ae&&await _b(350),G.id===sr&&(q.current[Le]?.(),j(Y,Re,!0),q.current[Le]=dp(L,Je=>{Je.type==="data"&&typeof Je.data=="string"&&Je.data.length>0&&_s.getState().appendToBuffer(Y,Re,Je.data),Je.type==="exit"&&(_s.getState().setTabLifecycle(Y,Re,"exited"),_s.getState().setConnecting(Y,Re,!1),_s.getState().removeProjectActionRun(Le),delete ne.current[Le],q.current[Le]?.(),delete q.current[Le],window.clearTimeout(H.current[Le]),delete H.current[Le])},()=>{_s.getState().setConnecting(Y,Re,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));const re=G.autoOpenUrl===!0&&u&&(G.desktopOpenSshForward||"").trim().length>0,Oe=G.autoOpenUrl?Hb(G.openUrl):null,Ge=G.autoOpenUrl&&u?_x(G.desktopOpenSshForward,m):null;B({key:Le,directory:Y,actionId:G.id,tabId:Re,sessionId:L,status:G.id===sr&&!Oe?"waiting-for-preview":"running"}),window.clearTimeout(H.current[Le]),delete H.current[Le],G.id===sr&&!Oe&&(H.current[Le]=window.setTimeout(()=>{_s.getState().updateProjectActionRunStatus(Le,"running"),delete H.current[Le]},Ub)),Ge?(D(Y,Re,null,{locked:!0}),Z(Ge),le.success(a("projectActions.toast.openedForwardedUrl"))):Oe?(D(Y,Re,Oe,{locked:!0,autoOpened:!0}),h(Y,Oe),le.success(a("projectActions.toast.openedActionUrl"))):ye?(D(Y,Re,null,{locked:!0}),le.error(a("projectActions.error.invalidCustomUrlFormat"))):re?(D(Y,Re,null,{locked:!0}),le.error(a("projectActions.error.selectedDesktopSshForwardUnavailable"))):D(Y,Re,null,{locked:!1,autoOpened:!1}),ne.current[Le]={lastSeenChunkId:null,openedUrl:!!Ge||!!Oe||ye,tail:"",openInPreview:G.id===sr};const He=Wb(G.command.trim().replace(/\r\n|\r/g,`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-BDjzrhGS.js","assets/vendor-.bun-By2L9XvG.js","assets/vendor--Dwc_TRgJ.css","assets/useAppFontEffects-B66TruVB.js","assets/index-AsCHiJ5P.js","assets/index-Bv4711NQ.css","assets/NewWorktreeDialog-Dj6KETex.js","assets/mobileLayoutPreference-Dio-WWkI.js","assets/SessionSwitcherDropdown-Cn_yoQrm.js","assets/DiagramView-BJkP8Fjp.js","assets/SettingsWindow-BIKNrxSK.js","assets/MultiRunWindow-CRKVePMG.js","assets/OnboardingScreen-DRe8UNiS.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as s,e as mt,a as ro,R as i,d as Mf,p as fc,b as Ff,H as Xe,I as Lf,u as xa,l as yo,n as ba,D as ya,q as wa,S as $l,v as zl,w as mc,C as hc,L as Ul,N as Vh,O as $h,T as zh,W as Uh,X as ni,Y as Wh,$ as Hh,F as Gh,a0 as Kh,a1 as qh,a2 as Yh,a3 as Of,a4 as Qh,a5 as Jh,a6 as Wl,a7 as Xh,s as Zh,m as ep,a8 as md,a9 as hd,aa as pd,ab as tp,ac as sp,ad as np,ae as rp,af as ip,ag as op,_ as io,ah as gd,ai as xd,aj as bd,G as ap}from"./vendor-.bun-By2L9XvG.js";import{f as pc,h as dr,j as Ji,k as yd,l as lp,m as va,n as Bf,p as cp,e as As,q as Lo,b as Ee,t as dp,v as Oa,w as Gr,a as Ur,x as Wr,y as Hl,z as up,A as fp,R as wd,B as vd,u as Js,C as mp,D as Ni,E as _f,F as Vf,G as gc,o as _n,H as hp,g as Ci,I as pp,r as xc,J as gp,K as bc,L as $f,M as xp,N as bp,O as na,P as ra,Q as yp,S as wp,T as vp,U as jd,V as Sd,W as Nd,X as kd,Y as jp,Z as Sp,_ as Cd,d as Ad,$ as Np,a0 as kp,a1 as Cp,i as Ap,s as Dp}from"./index-AsCHiJ5P.js";import{u as Nt,m as Pe,ao as bs,I,p as ur,t as le,ap as en,aq as Rr,ar as tn,as as sn,a as Jn,at as Er,au as Ii,av as Dd,aw as Et,ax as Mt,ay as Ft,az as Ip,ac as Do,aA as ja,aB as ri,ad as Io,ae as zf,a5 as yc,aC as Uf,aD as Pp,Q as ss,z as ut,aE as Tp,a7 as Wf,y as vr,x as wc,D as ws,R as Pi,aF as Hf,aG as Gf,aH as Sa,aI as Kf,aJ as qf,aK as Yf,aL as Qf,aM as Rp,aN as Ep,T as vc,aO as Ba,aP as ii,aQ as jc,aR as ia,X as Zs,aS as Mp,aT as Jf,aU as Fp,aV as Xf,aW as Sc,aX as Hs,aY as Ws,B as $e,aZ as Vs,a_ as $s,a$ as ci,b0 as Lp,b1 as Op,b2 as zo,b3 as Tn,b4 as Zf,b5 as em,a2 as Nc,b6 as Bp,b7 as Id,b8 as Pd,b9 as ki,n as vn,ba as Ti,bb as Xi,bc as _p,bd as Vp,be as $p,bf as zp,bg as _a,bh as Va,bi as $a,bj as za,bk as oi,bl as li,bm as Up,bn as Wp,bo as on,bp as Hp,bq as Gp,br as Kp,bs as qp,bt as Yp,k as Ai,bu as kc,bv as Qp,bw as Jp,bx as Xp,by as Zp,bz as eg,bA as tg,bB as sg,bC as Vn,bD as $n,bE as zn,bF as Nn,bG as Un,bH as Ls,bI as ng,w as Po,M as Ua,S as Wa,bJ as rg,bK as ir,bL as ig,b as di,d as Cc,c as Ha,bM as og,bN as tm,bO as ag,bP as lg,e as Ac,bQ as cg,f as wn,bR as Ga,a3 as Pr,j as dg,bS as ug,bT as ol,bU as fg,bV as mg,F as Hr,bW as Dc,bX as Ka,bY as fn,bZ as Ri,l as Zi,b_ as sm,b$ as hg,c0 as pg,c1 as gg,c2 as Td,c3 as xg,q as Kr,r as Rd,v as Ed,c4 as Md,c5 as nm,c6 as Fd,c7 as Ld,c8 as rm,c9 as bg,ca as im,o as Od,J as yg,cb as al,cc as Ic,cd as wg,ce as vg,cf as jg,cg as Oo,ch as Sg,ci as ll,cj as om,ck as am,cl as Pc,cm as Ng,cn as Tc,co as lm,cp as Uo,cq as kg,cr as Tr,cs as Cg,ct as cm,cu as Ag,cv as Dg,cw as Bd,cx as dm,cy as um,cz as fm,E as Rc,P as qa,G as Ya,L as Na,cA as ka,cB as Ln,H as Ig,K as Pg,cC as Tg,cD as Gl,cE as Rg,cF as Eg,cG as Mg,cH as _d,cI as Fg,cJ as Lg,cK as Ec,cL as mm,cM as Og,cN as Bg,cO as _g,cP as Vg,cQ as Vd,cR as $d,cS as $g,cT as zg,cU as Ug,cV as Wg,cW as Hg,cX as Gg,N as Kg,cY as zd,cZ as qg,c_ as hm,O as Yg,c$ as Qg,A as Jg,C as Xg,d0 as Zg,d1 as ex,d2 as tx,d3 as sx,d4 as nx,d5 as rx,d6 as ix,d7 as ox,d8 as ax,d9 as Ca,da as lx,db as Ud,dc as cx,dd as dx,de as ux,df as oo,dg as fx,dh as Wd,di as mx,dj as hx,dk as px,dl as gx,dm as pm,dn as gm,dp as xx,dq as bx,dr as yx,ds as oa,a9 as wx,dt as vx,du as cl,dv as jx,dw as Sx,U as Nx,V as kx,W as Cx,Y as Hd,Z as Gd,_ as Kd,dx as Ax,$ as xm,a0 as bm,aj as Dx,ak as Ix,al as Px,am as Tx,an as Rx,af as Ex,ag as Mx,ah as Fx,ai as Lx}from"./useAppFontEffects-B66TruVB.js";import{I as qd,o as Ox,p as Yd,q as Bx,r as Qd,t as Jr,s as _x,v as dl,w as To,U as Aa,x as Da,y as eo,z as Bo,B as to,k as ym,M as wm,i as mn,j as Vx,Q as vm,E as $x,F as zx,G as Ux,l as Kl,H as jm,P as Sm,J as Wx,K as Hx,C as Gx,a as Kx,L as Mc,R as Nm,T as Fc,V as Lc,W as Oc,X as km,Y as Cm,Z as ql,_ as Am,$ as Yl,a0 as aa,a1 as qx,a2 as Yx,e as wo,N as Qx,D as Jx,u as Xx,n as Zx,m as Ql,a3 as eb,a4 as tb,g as sb,a5 as nb,a6 as rb,c as ib,O as Dm,d as ob,a7 as ab}from"./NewWorktreeDialog-Dj6KETex.js";import{S as lb,C as cb,W as db,g as Bc,r as ub,n as cs,i as Ro,d as so,c as Gi,a as Jd,b as fb,e as vo,f as Im,h as mb,j as hb,u as ul}from"./SessionSwitcherDropdown-Cn_yoQrm.js";function Pm(t){const{drafts:e,editingDraftId:n,commentText:r,onTextChange:o,selection:a,isDragging:c,fileLabel:l,newWidgetId:d,mapDraftToRange:u,onSave:m,onCancel:f,onEdit:p,onDelete:y}=t,g=[];for(const b of e){const x=u(b);if(b.id===n){g.push({afterLine:x.end,id:`edit-${b.id}`,content:s.jsx(qd,{initialText:r,onTextChange:o,fileLabel:l,lineRange:x,isEditing:!0,onSave:m,onCancel:f},`edit-${b.id}`)});continue}g.push({afterLine:x.end,id:`card-${b.id}`,content:s.jsx(Ox,{draft:b,onEdit:()=>p(b),onDelete:()=>y(b)},`card-${b.id}`)})}if(a&&!n&&!c){const b={...a,start:Math.min(a.start,a.end),end:Math.max(a.start,a.end)};g.push({afterLine:b.end,id:d,content:s.jsx(qd,{initialText:r,onTextChange:o,fileLabel:l,lineRange:b,isEditing:!1,onSave:m,onCancel:f},d)})}return g}function Xd(t){const e=mt.c(14);let n,r,o,a;e[0]!==t?({size:o,className:n,style:a,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=o,e[4]=a):(n=e[1],r=e[2],o=e[3],a=e[4]);const c=typeof o=="number"?`${o}px`:o,l=typeof o=="number"?`${o}px`:o;let d;e[5]!==a||e[6]!==c||e[7]!==l?(d={width:c,height:l,...a},e[5]=a,e[6]=c,e[7]=l,e[8]=d):d=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx("path",{d:"M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z"}),e[9]=u):u=e[9];let m;return e[10]!==n||e[11]!==r||e[12]!==d?(m=s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",fill:"currentColor",className:n,style:d,...r,children:u}),e[10]=n,e[11]=r,e[12]=d,e[13]=m):m=e[13],m}const ai=[{id:"finder",label:"Finder",appName:"Finder"},{id:"terminal",label:"Terminal",appName:"Terminal"},{id:"iterm2",label:"iTerm2",appName:"iTerm"},{id:"ghostty",label:"Ghostty",appName:"Ghostty"},{id:"vscode",label:"VS Code",appName:"Visual Studio Code"},{id:"intellij",label:"IntelliJ",appName:"IntelliJ IDEA"},{id:"visual-studio",label:"Visual Studio",appName:"Visual Studio"},{id:"cursor",label:"Cursor",appName:"Cursor"},{id:"android-studio",label:"Android Studio",appName:"Android Studio"},{id:"pycharm",label:"PyCharm",appName:"PyCharm"},{id:"xcode",label:"Xcode",appName:"Xcode"},{id:"sublime-text",label:"Sublime",appName:"Sublime Text"},{id:"webstorm",label:"WebStorm",appName:"WebStorm"},{id:"rider",label:"Rider",appName:"Rider"},{id:"zed",label:"Zed",appName:"Zed"},{id:"phpstorm",label:"PhpStorm",appName:"PhpStorm"},{id:"eclipse",label:"Eclipse",appName:"Eclipse"},{id:"windsurf",label:"Windsurf",appName:"Windsurf"},{id:"vscodium",label:"VSCodium",appName:"VSCodium"},{id:"rustrover",label:"RustRover",appName:"RustRover"},{id:"kiro",label:"Kiro",appName:"Kiro"},{id:"antigravity",label:"Antigravity",appName:"Antigravity"},{id:"trae",label:"Trae",appName:"Trae"}],Jl="finder",Xl=new Set(["finder","terminal"]),_c=t=>typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="win32"&&t.id==="finder"?{...t,label:"Explorer",appName:"File Explorer"}:t,Zl=t=>{if(!t)return null;const e=ai.find(n=>n.id===t)??null;return e?_c(e):null},fl=()=>ai.filter(t=>Xl.has(t.id)).map(t=>({..._c(t)})),pb=()=>{if(typeof window>"u")return Jl;const t=window.localStorage.getItem("openInAppId");return t&&Zl(t)?t:Jl};let ml=!1,_i=!1,Xr=!1,Zr=0,jo=null;const Zd=()=>{jo&&(clearTimeout(jo),jo=null)},yr=ro()((t,e)=>({selectedAppId:pb(),availableApps:fl(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(ml||typeof window>"u")return;ml=!0;const n=(d,u=!0)=>{if(!Array.isArray(d)||d.length===0){t({availableApps:fl(),hasLoadedApps:u});return}const m=new Set(d.map(g=>g.name)),f=new Map(d.map(g=>[g.name,g.iconDataUrl??void 0])),y=ai.filter(g=>m.has(g.appName)||Xl.has(g.id)).map(g=>({..._c(g),iconDataUrl:f.get(g.appName)}));t({availableApps:y,hasLoadedApps:!0})},r=async d=>{if(!dr()||!Ji()||_i||e().hasLoadedApps&&!d)return;const m=ai.map(f=>f.appName);Zd(),_i=!0,Xr=!1,t({isScanning:!0});try{const{apps:f,success:p,hasCache:y,isCacheStale:g}=await yd(m,d),b=p&&!y&&f.length===0&&Zr<3;if(t({isCacheStale:y?g:!1}),n(f,p?!b:!1),p){if(b){const h=[800,1600,3200][Zr]??3200;Zr+=1,Xr=!0,jo=setTimeout(()=>{r()},h);return}Zr=0,Xr=!1;return}if(Zr<3){const h=[1e3,3e3,7e3][Zr]??7e3;Zr+=1,Xr=!0,jo=setTimeout(()=>{r()},h)}}finally{_i=!1,Xr||t({isScanning:!1})}};r();const o=d=>{const u=d.detail,m=u&&typeof u.openInAppId=="string"&&u.openInAppId.length>0&&Zl(u.openInAppId)?u.openInAppId:null;m&&(window.localStorage.setItem("openInAppId",m),t({selectedAppId:m}))},a=()=>{r()},c=d=>{const u=d.detail;Array.isArray(u)&&(Zr=3,Xr=!1,t({isScanning:!1,isCacheStale:!1}),n(u))};window.addEventListener("openchamber:settings-synced",o),window.addEventListener("openchamber:app-ready",a),window.addEventListener("openchamber:installed-apps-updated",c),window.__openchamberAppReady&&r(),window.setTimeout(()=>{e().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(ml||e().initialize(),!dr()||!Ji()||_i||e().hasLoadedApps&&!n)return;const o=ai.map(a=>a.appName);Zd(),n&&t({hasLoadedApps:!1}),_i=!0,Xr=!1,t({isScanning:!0});try{const{apps:a,hasCache:c,isCacheStale:l}=await yd(o,n),d=new Set(a.map(p=>p.name)),u=new Map(a.map(p=>[p.name,p.iconDataUrl??void 0])),f=ai.filter(p=>d.has(p.appName)||Xl.has(p.id)).map(p=>({...p,iconDataUrl:u.get(p.appName)}));t({availableApps:f.length>0?f:fl(),hasLoadedApps:f.length>0,isCacheStale:c?l:!1})}finally{_i=!1,Xr||t({isScanning:!1})}},selectApp:async n=>{Zl(n)&&(t({selectedAppId:n}),typeof window<"u"&&window.localStorage.setItem("openInAppId",n),await pc({openInAppId:n}))}})),gb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC",xb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC",hl=t=>({...t,fallbackIconDataUrl:t.id==="finder"&&window.__OPENCHAMBER_PLATFORM__!=="win32"?gb:t.id==="terminal"?xb:void 0}),eu=t=>{const e=mt.c(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:o}=t,[a,c]=i.useState(!1);let l;e[0]!==n?(l=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=l):l=e[1];const d=l,u=r||o;if(u&&!a){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>c(!0),e[2]=p):p=e[2];let y;return e[3]!==u?(y=s.jsx("img",{src:u,alt:"",className:"h-4 w-4 rounded-sm",onError:p}),e[3]=u,e[4]=y):y=e[4],y}let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=Pe("h-4 w-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=m):m=e[5];let f;return e[6]!==d?(f=s.jsx("span",{className:m,children:d}),e[6]=d,e[7]=f):f=e[7],f},bb=t=>{const e=mt.c(75),{directory:n,className:r}=t,{t:o}=Nt(),a=yr(yb),c=yr(wb),l=yr(vb),d=yr(jb),u=yr(Sb),m=yr(Nb),f=yr(kb);let p,y;e[0]!==u?(p=()=>{u()},y=[u],e[0]=u,e[1]=p,e[2]=y):(p=e[1],y=e[2]),i.useEffect(p,y);const g=dr()&&Ji();let b;e:{let ke;e[3]!==c||e[4]!==a?(ke=c.find(O=>O.id===a)??c.find(Cb)??c[0]??ai[0],e[3]=c,e[4]=a,e[5]=ke):ke=e[5];const Y=ke;if(Y){let O;e[6]!==Y?(O=hl(Y),e[6]=Y,e[7]=O):O=e[7],b=O;break e}let ge;e[8]===Symbol.for("react.memo_cache_sentinel")?(ge=hl(ai[0]),e[8]=ge):ge=e[8],b=ge}const x=b;if(!g||!n||c.length===0)return null;let h;e[9]!==n?(h=async ke=>{await lp(n,ke.id,ke.appName)||await va(n,ke.appName)},e[9]=n,e[10]=h):h=e[10];const C=h;let w;e[11]!==C||e[12]!==f?(w=async ke=>{await f(ke.id),await C(ke)},e[11]=C,e[12]=f,e[13]=w):w=e[13];const v=w;let S;e[14]!==n||e[15]!==o?(S=async()=>{(await ur(n)).ok&&le.success(o("openInApp.toast.pathCopied"))},e[14]=n,e[15]=o,e[16]=S):S=e[16];const k=S;let j;e[17]!==r?(j=Pe("app-region-no-drag inline-flex h-7 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r),e[17]=r,e[18]=j):j=e[18];let A;e[19]!==C||e[20]!==x?(A=()=>{C(x)},e[19]=C,e[20]=x,e[21]=A):A=e[21];const D=d&&"animate-pulse";let N;e[22]!==D?(N=Pe("inline-flex h-full items-center px-2.5 typography-ui-label font-medium","text-foreground hover:bg-interactive-hover transition-colors",D),e[22]=D,e[23]=N):N=e[23];let B;e[24]!==x.label||e[25]!==o?(B=o("openInApp.actions.openInAria",{app:x.label}),e[24]=x.label,e[25]=o,e[26]=B):B=e[26];let T;e[27]!==x.fallbackIconDataUrl||e[28]!==x.iconDataUrl||e[29]!==x.label?(T=s.jsx(eu,{label:x.label,iconDataUrl:x.iconDataUrl,fallbackIconDataUrl:x.fallbackIconDataUrl}),e[27]=x.fallbackIconDataUrl,e[28]=x.iconDataUrl,e[29]=x.label,e[30]=T):T=e[30];let E;e[31]!==N||e[32]!==B||e[33]!==T||e[34]!==A?(E=s.jsx("button",{type:"button",onClick:A,className:N,"aria-label":B,children:T}),e[31]=N,e[32]=B,e[33]=T,e[34]=A,e[35]=E):E=e[35];let _;e[36]===Symbol.for("react.memo_cache_sentinel")?(_=Pe("inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors"),e[36]=_):_=e[36];let R;e[37]!==o?(R=o("openInApp.actions.chooseAppAria"),e[37]=o,e[38]=R):R=e[38];let V;e[39]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(I,{name:"arrow-down-s",className:"h-4 w-4"}),e[39]=V):V=e[39];let $;e[40]!==R?($=s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:_,"aria-label":R,children:V})}),e[40]=R,e[41]=$):$=e[41];let z;e[42]!==k?(z=()=>{k()},e[42]=k,e[43]=z):z=e[43];let F;e[44]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsx(I,{name:"file-copy",className:"h-4 w-4"}),e[44]=F):F=e[44];let te;e[45]!==o?(te=o("openInApp.actions.copyPath"),e[45]=o,e[46]=te):te=e[46];let ne;e[47]!==te?(ne=s.jsx("span",{className:"typography-ui-label text-foreground",children:te}),e[47]=te,e[48]=ne):ne=e[48];let q;e[49]!==z||e[50]!==ne?(q=s.jsxs(bs,{className:"flex items-center gap-2",onClick:z,children:[F,ne]}),e[49]=z,e[50]=ne,e[51]=q):q=e[51];let H;e[52]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(Rr,{}),e[52]=H):H=e[52];let X;if(e[53]!==c||e[54]!==v||e[55]!==x.id){let ke;e[57]!==v||e[58]!==x.id?(ke=Y=>{const ge=hl(Y);return s.jsxs(bs,{className:"flex items-center gap-2",onClick:()=>{v(Y)},children:[s.jsx(eu,{label:Y.label,iconDataUrl:Y.iconDataUrl,fallbackIconDataUrl:ge.fallbackIconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:Y.label}),x.id===Y.id?s.jsx(I,{name:"check",className:"ml-auto h-4 w-4 text-primary"}):null]},Y.id)},e[57]=v,e[58]=x.id,e[59]=ke):ke=e[59],X=c.map(ke),e[53]=c,e[54]=v,e[55]=x.id,e[56]=X}else X=e[56];let oe;e[60]!==l||e[61]!==m||e[62]!==o?(oe=l?s.jsxs(bs,{className:"flex items-center gap-2",onClick:()=>{m(!0)},children:[s.jsx(I,{name:"refresh",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:o("openInApp.actions.refreshApps")})]}):null,e[60]=l,e[61]=m,e[62]=o,e[63]=oe):oe=e[63];let he;e[64]!==q||e[65]!==X||e[66]!==oe?(he=s.jsxs(tn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[q,H,X,oe]}),e[64]=q,e[65]=X,e[66]=oe,e[67]=he):he=e[67];let Se;e[68]!==$||e[69]!==he?(Se=s.jsxs(sn,{children:[$,he]}),e[68]=$,e[69]=he,e[70]=Se):Se=e[70];let Z;return e[71]!==E||e[72]!==Se||e[73]!==j?(Z=s.jsxs("div",{className:j,children:[E,Se]}),e[71]=E,e[72]=Se,e[73]=j,e[74]=Z):Z=e[74],Z};function yb(t){return t.selectedAppId}function wb(t){return t.availableApps}function vb(t){return t.isCacheStale}function jb(t){return t.isScanning}function Sb(t){return t.initialize}function Nb(t){return t.loadInstalledApps}function kb(t){return t.selectApp}function Cb(t){return t.id===Jl}const Ab=1e6,Db="terminal-store";let tu=!1;const pl=t=>typeof t=="object"&&t!==null,Ib=t=>{const e=/^tab-(\d+)$/.exec(t);if(!e)return null;const n=Number(e[1]);return Number.isFinite(n)?n:null};function Dn(t){let e=t.trim();for(;e.length>1&&e.endsWith("/");)e=e.slice(0,-1);return e}const gl=(t,e)=>({id:t,terminalSessionId:null,lifecycle:"idle",label:e,iconKey:null,bufferChunks:[],bufferLength:0,isConnecting:!1,createdAt:Date.now(),previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1}),xl=t=>({tabs:[t],activeTabId:t.id}),xr=(t,e)=>t.tabs.findIndex(n=>n.id===e),_s=ro()(Mf(fc((t,e)=>({sessions:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1,hasHydrated:typeof window>"u",ensureDirectory:n=>{const r=Dn(n);r&&t(o=>{if(o.sessions.has(r))return o;const a=new Map(o.sessions),c=`tab-${o.nextTabId}`,l=gl(c,"Terminal");return a.set(r,xl(l)),{sessions:a,nextTabId:o.nextTabId+1}})},getDirectoryState:n=>{const r=Dn(n);return e().sessions.get(r)},getActiveTab:n=>{const r=Dn(n),o=e().sessions.get(r);if(!o)return;const a=o.activeTabId;return a?o.tabs.find(c=>c.id===a)??o.tabs[0]:o.tabs[0]},createTab:n=>{const r=Dn(n);if(!r)return"tab-invalid";const o=`tab-${e().nextTabId}`;return t(a=>{const c=new Map(a.sessions),l=c.get(r),d=a.nextTabId+1,m=`Terminal ${(l?.tabs.length??0)+1}`,f=gl(o,m);return l?c.set(r,{...l,tabs:[...l.tabs,f]}):c.set(r,xl(f)),{sessions:c,nextTabId:d}}),o},setActiveTab:(n,r)=>{const o=Dn(n);t(a=>{const c=new Map(a.sessions),l=c.get(o);return!l||l.activeTabId===r||xr(l,r)<0?a:(c.set(o,{...l,activeTabId:r}),{sessions:c})})},setTabLabel:(n,r,o)=>{const a=Dn(n),c=o.trim();c&&t(l=>{const d=new Map(l.sessions),u=d.get(a);if(!u)return l;const m=xr(u,r);if(m<0||u.tabs[m]?.label===c)return l;const f=[...u.tabs];return f[m]={...f[m],label:c},d.set(a,{...u,tabs:f}),{sessions:d}})},setTabIconKey:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=o?.trim()||null;if(d.tabs[u]?.iconKey===m)return c;const f=[...d.tabs];return f[u]={...f[u],iconKey:m},l.set(a,{...d,tabs:f}),{sessions:l}})},closeTab:async(n,r)=>{const o=Dn(n),l=e().sessions.get(o)?.tabs.find(d=>d.id===r)?.terminalSessionId??null;if(l)try{await cp(l)}catch{}t(d=>{const u=new Map(d.sessions),m=u.get(o);if(!m)return d;const f=xr(m,r);if(f<0)return d;const p=m.tabs.filter(x=>x.id!==r),y=Object.fromEntries(Object.entries(d.projectActionRuns).filter(([,x])=>!(x.directory===o&&x.tabId===r))),g=Object.keys(y).length!==Object.keys(d.projectActionRuns).length;if(p.length===0){const x=`tab-${d.nextTabId}`,h=gl(x,"Terminal");return u.set(o,xl(h)),{sessions:u,nextTabId:d.nextTabId+1,...g?{projectActionRuns:y}:{}}}let b=m.activeTabId;return m.activeTabId===r&&(b=p[Math.min(f,p.length-1)]?.id??p[0]?.id??null),u.set(o,{...m,tabs:p,activeTabId:b}),{sessions:u,...g?{projectActionRuns:y}:{}}})},setTabSessionId:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=d.tabs[u],f=o!==null&&m.terminalSessionId!==o,p=o?"running":m.terminalSessionId?"exited":m.lifecycle,y={...m,terminalSessionId:o,lifecycle:p,isConnecting:!1,...f?{bufferChunks:[],bufferLength:0}:{}},g=[...d.tabs];return g[u]=y,l.set(a,{...d,tabs:g}),{sessions:l}})},setTabLifecycle:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=[...d.tabs];return m[u]={...m[u],lifecycle:o,isConnecting:!1},l.set(a,{...d,tabs:m}),{sessions:l}})},setConnecting:(n,r,o)=>{const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=[...d.tabs];return m[u]={...m[u],isConnecting:o},l.set(a,{...d,tabs:m}),{sessions:l}})},appendToBuffer:(n,r,o)=>{if(!o)return;const a=Dn(n);t(c=>{const l=new Map(c.sessions),d=l.get(a);if(!d)return c;const u=xr(d,r);if(u<0)return c;const m=d.tabs[u],f=c.nextChunkId,p={id:f,data:o},y=[...m.bufferChunks,p];let g=m.bufferLength+o.length;for(;g>Ab&&y.length>1;){const x=y.shift();if(!x)break;g-=x.data.length}const b=[...d.tabs];return b[u]={...m,bufferChunks:y,bufferLength:g},l.set(a,{...d,tabs:b}),{sessions:l,nextChunkId:f+1}})},setTabPreviewUrl:(n,r,o,a={})=>{const c=Dn(n);t(l=>{const d=new Map(l.sessions),u=d.get(c);if(!u)return l;const m=xr(u,r);if(m<0)return l;const f=u.tabs[m],p=a.autoOpened??f.previewAutoOpened,y=a.locked??f.previewUrlLocked;if(f.previewUrl===o&&f.previewAutoOpened===p&&f.previewUrlLocked===y)return l;const g=[...u.tabs];return g[m]={...f,previewUrl:o,previewAutoOpened:p,previewUrlLocked:y},d.set(c,{...u,tabs:g}),{sessions:d}})},markPreviewAutoOpened:(n,r)=>{const o=Dn(n);t(a=>{const c=new Map(a.sessions),l=c.get(o);if(!l)return a;const d=xr(l,r);if(d<0)return a;const u=l.tabs[d];if(!u.previewUrl||u.previewAutoOpened)return a;const m=[...l.tabs];return m[d]={...u,previewAutoOpened:!0},c.set(o,{...l,tabs:m}),{sessions:c}})},setProjectActionRun:n=>{t(r=>{const o=r.projectActionRuns[n.key];return o&&o.directory===n.directory&&o.actionId===n.actionId&&o.tabId===n.tabId&&o.sessionId===n.sessionId&&o.status===n.status?r:{projectActionRuns:{...r.projectActionRuns,[n.key]:n}}})},updateProjectActionRunStatus:(n,r)=>{t(o=>{const a=o.projectActionRuns[n];return!a||a.status===r?o:{projectActionRuns:{...o.projectActionRuns,[n]:{...a,status:r}}}})},removeProjectActionRun:n=>{t(r=>{if(!r.projectActionRuns[n])return r;const o={...r.projectActionRuns};return delete o[n],{projectActionRuns:o}})},clearBuffer:(n,r)=>{const o=Dn(n);t(a=>{const c=new Map(a.sessions),l=c.get(o);if(!l)return a;const d=xr(l,r);if(d<0)return a;const u=[...l.tabs];return u[d]={...u[d],bufferChunks:[],bufferLength:0},c.set(o,{...l,tabs:u}),{sessions:c}})},removeDirectory:n=>{const r=Dn(n);t(o=>{const a=new Map(o.sessions);a.delete(r);const c=Object.fromEntries(Object.entries(o.projectActionRuns).filter(([,l])=>l.directory!==r));return{sessions:a,projectActionRuns:c}})},clearAll:()=>{t({sessions:new Map,projectActionRuns:{},nextChunkId:1,nextTabId:1})}}),{name:Db,storage:Ff(()=>Bf()),partialize:t=>({sessions:Array.from(t.sessions.entries()).map(([e,n])=>[e,{activeTabId:n.activeTabId,tabs:n.tabs.map(r=>({id:r.id,label:r.label,iconKey:r.iconKey,terminalSessionId:r.terminalSessionId,lifecycle:r.lifecycle,createdAt:r.createdAt}))}]),nextTabId:t.nextTabId}),merge:(t,e)=>{if(!pl(t))return e;const n=Array.isArray(t.sessions)?t.sessions:[],r=new Map;let o=0;for(const l of n){if(!Array.isArray(l)||l.length!==2)continue;const[d,u]=l;if(typeof d!="string"||!pl(u))continue;const m=Array.isArray(u.tabs)?u.tabs:[],f=[];for(const g of m){if(!pl(g))continue;const b=typeof g.id=="string"?g.id:null;if(!b)continue;const x=Ib(b);x!==null&&(o=Math.max(o,x));const h=typeof g.terminalSessionId=="string"||g.terminalSessionId===null?g.terminalSessionId:null,C=g.lifecycle,w=C==="idle"||C==="running"||C==="exited"?C:h?"running":"idle";f.push({id:b,label:typeof g.label=="string"?g.label:"Terminal",iconKey:typeof g.iconKey=="string"?g.iconKey:null,terminalSessionId:h,lifecycle:w,createdAt:typeof g.createdAt=="number"?g.createdAt:Date.now(),bufferChunks:[],bufferLength:0,isConnecting:!1,previewUrl:null,previewAutoOpened:!1,previewUrlLocked:!1})}if(f.length===0)continue;const p=typeof u.activeTabId=="string"?u.activeTabId:null,y=p?f.some(g=>g.id===p):!1;r.set(d,{tabs:f,activeTabId:y?p:f[0].id})}const a=typeof t.nextTabId=="number"&&Number.isFinite(t.nextTabId)?t.nextTabId:1,c=Math.max(e.nextTabId,a,o+1);return{...e,sessions:r,nextChunkId:1,nextTabId:c,hasHydrated:!0}}})));if(typeof window<"u"&&!tu){tu=!0;const t=_s.persist,e=()=>{_s.getState().hasHydrated||_s.setState({hasHydrated:!0})};t?.hasHydrated?.()?e():t?.onFinishHydration?t.onFinishHydration(e):e()}const Pb=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],Tb=["dev","start","preview","serve"];async function Rb(t,e,n){if(!t)return null;const r=Fb(e);if(r)return{command:r.command,label:r.name||"Start Preview",actionId:r.id};if(n){const o=Lb(n);if(o){const a=await Ob(t);return{command:`${a==="npm"?"npm run":a==="yarn"?"yarn":a==="pnpm"?"pnpm":a==="bun"?"bun run --shell=bun":"npm run"} ${o}`,label:`Start (${o})`}}}if(await Eb(t)){const o=await Mb(),a=typeof o=="number"&&Number.isFinite(o)&&o>0?o:8e3;return{command:`python3 -m http.server ${a}`,label:"Static preview",previewUrlHint:`http://127.0.0.1:${a}/`}}return null}async function Eb(t){const e=`${t}/index.html`,n=await Ia(e,t);return typeof n=="string"&&n.trim().length>0}async function Mb(){try{const t=await As("/api/system/free-port",{cache:"no-store"});if(!t.ok)return null;const e=await t.json().catch(()=>null),n=typeof e?.port=="number"?e.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Fb(t){for(const e of t){const n=`${e.name} ${e.command}`.toLowerCase();if(Tb.some(o=>n.includes(o)))return e}return null}function Lb(t){for(const{pattern:e}of Pb)for(const n of Object.keys(t))if(e.test(n))return n;return null}async function Ob(t){const e=await Ia(`${t}/package.json`,t);if(e)try{const r=JSON.parse(e),o=typeof r.packageManager=="string"?r.packageManager.toLowerCase():"";if(o.startsWith("bun@"))return"bun";if(o.startsWith("pnpm@"))return"pnpm";if(o.startsWith("yarn@"))return"yarn";if(o.startsWith("npm@"))return"npm"}catch{}const n=[["bun.lock","bun"],["bun.lockb","bun"],["pnpm-lock.yaml","pnpm"],["yarn.lock","yarn"],["package-lock.json","npm"]];for(const[r,o]of n){const a=await Ia(`${t}/${r}`,t);if(typeof a=="string"&&a.trim().length>0)return o}return"npm"}async function Ia(t,e){if(e?.trim())try{const r=new URLSearchParams({path:t,directory:e,optional:"true"}),o=await As(`/api/fs/read?${r.toString()}`,{cache:"no-store"});if(o.ok)return o.text()}catch{}const n=Lo()?.files;if(n?.readFile)try{const r=await n.readFile(t,{optional:!0});return typeof r?.content=="string"?r.content:null}catch{return null}try{const r=await As(`/api/fs/read?path=${encodeURIComponent(t)}&optional=true`,{cache:"no-store"});return r.ok?r.text():null}catch{return null}}async function Bb(t){try{const e=await Ia(`${t}/package.json`,t);if(e==null)return null;const r=JSON.parse(e).scripts;return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}const _b=t=>new Promise(e=>{window.setTimeout(e,t)}),Vb="\x1B",$b=new RegExp(`${Vb}\\[[0-9;?]*[ -/]*[@-~]`,"g"),zb=/https?:\/\/[^\s<>'"`]+/gi,sr="__openchamber_auto_discover_preview__",Ub=15e3,Wb=t=>{let e="";for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(e+=t[n])}return e},Hb=t=>{const e=(t||"").trim();if(!e)return null;const n=/^https?:\/\//i.test(e)?e:`http://${e}`;try{const r=new URL(n);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.toString()}catch{return null}},Gb=t=>{const n=t.replace($b,"").match(zb);if(!n||n.length===0)return null;const r=n.map(a=>a.replace(/[),.;]+$/,"")).filter(Boolean);if(r.length===0)return null;const o=[];for(const a of r)try{const c=new URL(a);c.port&&c.port.length>0&&o.push({raw:a,parsed:c})}catch{}if(o.length>0){const a=c=>{const{parsed:l}=c,d=l.hostname.toLowerCase(),u=d==="localhost"||d==="127.0.0.1"||d==="0.0.0.0"||d==="::1",m=l.pathname||"/",f=m.split("/").filter(Boolean).length,p=m==="/"||m==="",y=!!(l.search||l.hash);let g=0;return u&&(g+=50),p&&(g+=30),g-=Math.min(f*5,20),y&&(g-=10),g};return o.sort((c,l)=>a(l)-a(c)),o[0]?.parsed.origin??o[0]?.raw??null}return r[0]??null},Tm=({projectRef:t,directory:e,className:n,compact:r=!1,allowMobile:o=!1})=>{const{t:a}=Nt(),{terminal:c,runtime:l}=Jn(),{isMobile:d}=Er(),u=i.useMemo(()=>dr(),[]),m=Yd(U=>U.instances),f=Yd(U=>U.load),p=Ee(U=>U.setBottomTerminalOpen),y=Ee(U=>U.setActiveMainTab),g=Ee(U=>U.setSettingsPage),b=Ee(U=>U.setSettingsDialogOpen),x=Ee(U=>U.setSettingsProjectsSelectedId),h=Ee(U=>U.openContextPreview),C=_s(U=>U.sessions),w=_s(U=>U.ensureDirectory),v=_s(U=>U.setTabLabel),S=_s(U=>U.setTabIconKey),k=_s(U=>U.setActiveTab),j=_s(U=>U.setConnecting),A=_s(U=>U.setTabSessionId),D=_s(U=>U.setTabPreviewUrl),N=_s(U=>U.projectActionRuns),B=_s(U=>U.setProjectActionRun),T=_s(U=>U.updateProjectActionRunStatus),E=_s(U=>U.removeProjectActionRun),[_,R]=i.useState([]),[V,$]=i.useState(null),[z,F]=i.useState(!1),te=i.useRef({}),ne=i.useRef({}),q=i.useRef({}),H=i.useRef({}),X=i.useRef(0),oe=t?.id??null,he=t?.path??"",Se=i.useMemo(()=>oe?{id:oe,path:he}:null,[oe,he]);i.useEffect(()=>{u&&f().catch(()=>{})},[u,f]);const Z=i.useCallback(async U=>{await Ii(U)},[]),ke=i.useCallback(async()=>{if(!Se)return;const U=X.current+1;X.current=U,F(!0);try{const be=await Dd(Se);if(X.current!==U)return;const ve=be.actions;R(ve),$(G=>G===sr||G&&ve.some(ye=>ye.id===G)?G:null)}catch{if(X.current!==U)return}finally{X.current===U&&F(!1)}},[Se]),Y=i.useMemo(()=>Bx(e||Se?.path||""),[e,Se?.path]),ge=i.useMemo(()=>V?_.find(U=>U.id===V)??null:null,[_,V]),O=i.useMemo(()=>({id:sr,name:a("projectActions.actions.autoDiscover"),command:"",icon:"search",autoOpenUrl:!0}),[a]),se=!d,ee=i.useMemo(()=>se?[O,..._]:_,[_,O,se]);i.useEffect(()=>{ke()},[ke]),i.useEffect(()=>{if(typeof window>"u")return;const U=be=>{const ve=be.detail;oe&&(ve?.projectId&&ve.projectId!==oe||ke())};return window.addEventListener(Qd,U),()=>{window.removeEventListener(Qd,U)}},[ke,oe]),i.useEffect(()=>{V&&(V===sr&&se||_.some(U=>U.id===V)||$(null))},[_,se,V]),i.useEffect(()=>{for(const[U,be]of Object.entries(N)){const G=C.get(be.directory)?.tabs.find(ye=>ye.id===be.tabId);(!G||G.terminalSessionId!==be.sessionId)&&E(U)}},[N,E,C]),i.useEffect(()=>{for(const[U,be]of Object.entries(N)){const ve=ne.current[U]??{lastSeenChunkId:null,openedUrl:!1,tail:"",openInPreview:!1};ne.current[U]=ve;const G=ee.find(Oe=>Oe.id===be.actionId);if(!G)continue;const Le=C.get(be.directory)?.tabs.find(Oe=>Oe.id===be.tabId);if(!Le||!Array.isArray(Le.bufferChunks)||Le.bufferChunks.length===0)continue;const Re=Le.bufferChunks.filter(Oe=>ve.lastSeenChunkId===null?!0:Oe.id>ve.lastSeenChunkId);if(Re.length===0)continue;const J=Re.map(Oe=>Oe.data).join(""),L=`${ve.tail}${J}`,ae=!ve.openedUrl&&G.autoOpenUrl===!0?Gb(L):null,re=Re[Re.length-1]?.id??ve.lastSeenChunkId;if(ve.lastSeenChunkId=re,ve.tail=L.slice(-512),ae)if(ve.openedUrl=!0,ve.openInPreview){const Oe=N[U];Oe&&(D(Oe.directory,Oe.tabId,ae,{locked:!1,autoOpened:!1}),Oe.status==="waiting-for-preview"&&T(U,"running"),window.clearTimeout(H.current[U]),delete H.current[U],h(Oe.directory,ae))}else Z(ae),le.success(a("projectActions.toast.openedUrlFromOutput"));ne.current[U]=ve}for(const U of Object.keys(ne.current))N[U]||(delete ne.current[U],window.clearTimeout(H.current[U]),delete H.current[U])},[ee,h,Z,N,D,a,C,T]);const je=i.useCallback(async(U,be={})=>{if(!Y)throw new Error(a("projectActions.error.noActiveDirectory"));const ve=Jr(Y,U.id);w(Y);const G=_s.getState(),ye=G.getDirectoryState(Y);let Le=te.current[ve]||null;const Re=Le?!!ye?.tabs.some(ae=>ae.id===Le):!1;(!Le||!Re)&&(Le=G.createTab(Y),te.current[ve]=Le),v(Y,Le,`Action: ${U.name}`),S(Y,Le,U.icon||"play"),be.revealTerminal!==!1&&(k(Y,Le),p(!0),y("terminal"));const L=_s.getState().getDirectoryState(Y)?.tabs.find(ae=>ae.id===Le);return{key:ve,tabId:Le,sessionId:L?.terminalSessionId??null}},[w,Y,y,k,p,S,v,a]),De=i.useCallback(async U=>{if(l.isVSCode||!o&&d)return;if(!Y){le.error(a("projectActions.error.noActiveDirectoryForAction"));return}const be=Jr(Y,U.id),ve=N[be];if(!(ve&&ve.status==="running"))try{const G=U.id===sr?await(async()=>{const[Je,rt]=await Promise.all([Dd({id:Se?.id??"",path:Y}),Bb(Y)]),bt=await Rb(Y,Je.actions,rt);if(!bt)throw new Error(a("contextPanel.preview.noDevServer"));return{id:sr,name:a("projectActions.actions.autoDiscover"),command:bt.command,icon:"search",autoOpenUrl:!0,openUrl:bt.previewUrlHint||""}})():U,ye=G.autoOpenUrl===!0&&(G.openUrl||"").trim().length>0,{key:Le,tabId:Re,sessionId:J}=await je(G,{revealTerminal:!ye&&U.id!==sr});let L=J,ae=!1;if(!L){j(Y,Re,!0);try{L=(await c.createSession({cwd:Y})).sessionId,ae=!0,A(Y,Re,L)}finally{j(Y,Re,!1)}}if(!L)throw new Error(a("projectActions.error.failedToCreateTerminalSession"));ae&&await _b(350),G.id===sr&&(q.current[Le]?.(),j(Y,Re,!0),q.current[Le]=dp(L,Je=>{Je.type==="data"&&typeof Je.data=="string"&&Je.data.length>0&&_s.getState().appendToBuffer(Y,Re,Je.data),Je.type==="exit"&&(_s.getState().setTabLifecycle(Y,Re,"exited"),_s.getState().setConnecting(Y,Re,!1),_s.getState().removeProjectActionRun(Le),delete ne.current[Le],q.current[Le]?.(),delete q.current[Le],window.clearTimeout(H.current[Le]),delete H.current[Le])},()=>{_s.getState().setConnecting(Y,Re,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));const re=G.autoOpenUrl===!0&&u&&(G.desktopOpenSshForward||"").trim().length>0,Oe=G.autoOpenUrl?Hb(G.openUrl):null,Ge=G.autoOpenUrl&&u?_x(G.desktopOpenSshForward,m):null;B({key:Le,directory:Y,actionId:G.id,tabId:Re,sessionId:L,status:G.id===sr&&!Oe?"waiting-for-preview":"running"}),window.clearTimeout(H.current[Le]),delete H.current[Le],G.id===sr&&!Oe&&(H.current[Le]=window.setTimeout(()=>{_s.getState().updateProjectActionRunStatus(Le,"running"),delete H.current[Le]},Ub)),Ge?(D(Y,Re,null,{locked:!0}),Z(Ge),le.success(a("projectActions.toast.openedForwardedUrl"))):Oe?(D(Y,Re,Oe,{locked:!0,autoOpened:!0}),h(Y,Oe),le.success(a("projectActions.toast.openedActionUrl"))):ye?(D(Y,Re,null,{locked:!0}),le.error(a("projectActions.error.invalidCustomUrlFormat"))):re?(D(Y,Re,null,{locked:!0}),le.error(a("projectActions.error.selectedDesktopSshForwardUnavailable"))):D(Y,Re,null,{locked:!1,autoOpened:!1}),ne.current[Le]={lastSeenChunkId:null,openedUrl:!!Ge||!!Oe||ye,tail:"",openInPreview:G.id===sr};const He=Wb(G.command.trim().replace(/\r\n|\r/g,`
|
|
3
3
|
`));await c.sendInput(L,`${He}\r`)}catch(G){E(be),delete ne.current[be],q.current[be]?.(),delete q.current[be],window.clearTimeout(H.current[be]),delete H.current[be],le.error(G instanceof Error?G.message:a("projectActions.error.failedToRunAction"))}},[m,je,o,d,u,Y,Z,h,N,l.isVSCode,E,j,B,D,A,Se?.id,a,c]),Be=i.useCallback(async U=>{const be=Jr(Y,U.id),ve=N[be];if(!ve)return;T(be,"stopping");try{await c.sendInput(ve.sessionId,"")}catch{}if(await new Promise(Le=>{window.setTimeout(Le,1e3)}),_s.getState().getDirectoryState(ve.directory)?.tabs.find(Le=>Le.id===ve.tabId)?.terminalSessionId===ve.sessionId){if(typeof c.forceKill=="function")try{await c.forceKill({sessionId:ve.sessionId})}catch{}else try{await c.close(ve.sessionId)}catch{}A(ve.directory,ve.tabId,null)}E(be),delete ne.current[be],q.current[be]?.(),delete q.current[be],window.clearTimeout(H.current[be]),delete H.current[be]},[Y,N,E,A,c,T]),Fe=i.useCallback(()=>{const U=ge??ee[0];if(!U)return;const be=Jr(Y,U.id),ve=N[be];if(ve?.status!=="stopping"){if(ve){Be(U);return}De(U)}},[ee,Y,De,N,ge,Be]),Me=i.useCallback((U,be=!1)=>{if($(U.id),!be){De(U);return}const ve=Jr(Y,U.id),G=N[ve];if(G?.status!=="stopping"){if(G){Be(U);return}De(U)}},[Y,De,N,Be]),fe=i.useCallback(()=>{Se?.id&&(x(Se.id),g("projects"),b(!0))},[b,g,x,Se?.id]);if(l.isVSCode||!o&&d||!Se||!Y)return null;const Ae=ge??ee[0]??null;if(!Ae)return null;const pe=Ae.icon||"play",ce=Ae.id===sr?"search":dl[pe]||"play",me=Jr(Y,Ae.id),Ne=N[me],ue=Ne?.status==="stopping",P=Ne?.status==="waiting-for-preview",M=Ne?C.get(Ne.directory)?.tabs.find(U=>U.id===Ne.tabId)?.previewUrl??null:null,de=!!(Ne&&M),xe=()=>{!Ne||!M||h(Ne.directory,M)};return r?s.jsxs("div",{className:"inline-flex items-center",children:[s.jsx("button",{type:"button",disabled:z||ue,className:Pe("app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2","typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","disabled:cursor-not-allowed",n),onClick:Fe,"aria-label":Ne?a("projectActions.actions.stopNamedAria",{name:Ae.name}):a("projectActions.actions.runNamedAria",{name:Ae.name}),children:ue||P?s.jsx(I,{name:"loader-4",className:"h-5 w-5 animate-spin text-[var(--status-warning)]"}):Ne?s.jsx(I,{name:"stop",className:"h-5 w-5 text-[var(--status-warning)]"}):s.jsx(I,{name:ce,className:"h-5 w-5"})}),de?s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":a("projectActions.actions.openPreview"),onClick:xe,children:s.jsx(I,{name:"global",className:"h-4 w-4"})})}),s.jsx(Ft,{sideOffset:6,children:a("projectActions.actions.openPreview")})]}):null,s.jsxs(sn,{children:[s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:"app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":a("projectActions.actions.chooseActionAria"),children:s.jsx(I,{name:"arrow-down-s",className:"h-3.5 w-3.5"})})}),s.jsxs(tn,{align:"end",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(bs,{className:"flex items-center gap-2",onClick:fe,children:[s.jsx(I,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:a("projectActions.actions.addNewAction")})]}),s.jsx(Rr,{}),ee.map(U=>{const be=U.icon||"play",ve=U.id===sr?"search":dl[be]||"play",G=Jr(Y,U.id),ye=N[G],Le=!!ye,Re=ye?.status==="stopping";return s.jsxs(bs,{className:"flex items-center gap-2",onClick:()=>{Me(U,!0)},children:[s.jsx(I,{name:ve,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:U.name}),Re||ye?.status==="waiting-for-preview"?s.jsx(I,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Le?s.jsx(I,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},U.id)})]})]})]}):s.jsxs("div",{className:Pe("app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]","bg-[var(--surface-elevated)] overflow-hidden","border border-border/60",r?"h-9":"h-7",n),children:[s.jsx("button",{type:"button",onClick:Fe,disabled:z||ue,className:Pe("inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover",r?"w-9 px-0":"px-2.5","transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed"),"aria-label":Ne?a("projectActions.actions.stopNamedAria",{name:Ae.name}):a("projectActions.actions.runNamedAria",{name:Ae.name}),children:s.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center",children:ue||P?s.jsx(I,{name:"loader-4",className:"h-4 w-4 animate-spin text-[var(--status-warning)]"}):Ne?s.jsx(I,{name:"stop",className:"h-4 w-4 text-[var(--status-warning)]"}):s.jsx(I,{name:ce,className:"h-4 w-4"})})}),de?s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:xe,className:Pe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-foreground","hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),"aria-label":a("projectActions.actions.openPreview"),children:s.jsx(I,{name:"global",className:"h-4 w-4"})})}),s.jsx(Ft,{sideOffset:6,children:a("projectActions.actions.openPreview")})]}):null,s.jsxs(sn,{children:[s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe(r?"inline-flex h-full w-8 items-center justify-center":"inline-flex h-full w-7 items-center justify-center","border-l border-[var(--interactive-border)] text-muted-foreground","hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),"aria-label":a("projectActions.actions.chooseActionAria"),children:s.jsx(I,{name:"arrow-down-s",className:"h-4 w-4"})})}),s.jsxs(tn,{align:"start",className:"w-52 max-h-[70vh] overflow-y-auto",children:[s.jsxs(bs,{className:"flex items-center gap-2",onClick:fe,children:[s.jsx(I,{name:"add",className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:a("projectActions.actions.addNewAction")})]}),s.jsx(Rr,{}),ee.map(U=>{const be=U.icon||"play",ve=U.id===sr?"search":dl[be]||"play",G=Jr(Y,U.id),ye=N[G],Le=!!ye,Re=ye?.status==="stopping";return s.jsxs(bs,{className:"flex items-center gap-2",onClick:()=>{Me(U,!0)},children:[s.jsx(I,{name:ve,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:U.name}),Re||ye?.status==="waiting-for-preview"?s.jsx(I,{name:"loader-4",className:"ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]"}):Le?s.jsx(I,{name:"stop",className:"ml-auto h-4 w-4 text-[var(--status-warning)]"}):null]},U.id)})]})]})]})},Qa="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors",Kb="app-region-no-drag inline-flex h-9 w-9 items-center justify-center gap-2 p-2 rounded-md typography-ui-label font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:text-foreground hover:bg-interactive-hover transition-colors",Wo=i.memo(function(e){const n=mt.c(17),{visible:r,title:o,ariaLabel:a,onClick:c,className:l,Icon:d,iconClassName:u,pressed:m}=e,f=r===void 0?!0:r,p=m===void 0?!1:m;if(!f)return null;const y=l??Qa,g=p&&"bg-interactive-selection text-interactive-selection-foreground";let b;n[0]!==y||n[1]!==g?(b=Pe(y,g),n[0]=y,n[1]=g,n[2]=b):b=n[2];const x=u??"h-[18px] w-[18px]";let h;n[3]!==d||n[4]!==x?(h=s.jsx(I,{name:d,className:x}),n[3]=d,n[4]=x,n[5]=h):h=n[5];let C;n[6]!==a||n[7]!==c||n[8]!==p||n[9]!==b||n[10]!==h?(C=s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:c,"aria-label":a,"aria-pressed":p,className:b,children:h})}),n[6]=a,n[7]=c,n[8]=p,n[9]=b,n[10]=h,n[11]=C):C=n[11];let w;n[12]!==o?(w=s.jsx(Ft,{children:s.jsx("p",{children:o})}),n[12]=o,n[13]=w):w=n[13];let v;return n[14]!==C||n[15]!==w?(v=s.jsxs(Et,{children:[C,w]}),n[14]=C,n[15]=w,n[16]=v):v=n[16],v}),qb=i.memo(function(e){const n=mt.c(42),{isMobile:r,githubAuthStatus:o,githubAccounts:a,githubAvatarUrl:c,githubLogin:l,isSwitchingGitHubAccount:d,handleGitHubAccountSwitch:u}=e,{t:m}=Nt();if(!o?.connected||r)return null;if(a.length>1){let g;n[0]===Symbol.for("react.memo_cache_sentinel")?(g=Pe(Qa,"h-7 w-7 overflow-hidden rounded-full border border-border/60 bg-muted/80 p-0"),n[0]=g):g=n[0];let b;n[1]!==l||n[2]!==m?(b=l?m("header.github.connectedWithLogin",{login:l}):m("header.github.connected"),n[1]=l,n[2]=m,n[3]=b):b=n[3];let x;n[4]!==c||n[5]!==l||n[6]!==m?(x=c?s.jsx("img",{src:c,alt:l?m("header.github.avatarWithLogin",{login:l}):m("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(I,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"}),n[4]=c,n[5]=l,n[6]=m,n[7]=x):x=n[7];let h;n[8]!==d||n[9]!==b||n[10]!==x?(h=s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:g,title:b,disabled:d,children:x})}),n[8]=d,n[9]=b,n[10]=x,n[11]=h):h=n[11];let C;n[12]!==m?(C=m("header.github.accountsTitle"),n[12]=m,n[13]=C):C=n[13];let w;n[14]!==C?(w=s.jsx(Pp,{className:"typography-ui-header font-semibold text-foreground",children:C}),n[14]=C,n[15]=w):w=n[15];let v;n[16]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(Rr,{}),n[16]=v):v=n[16];let S;if(n[17]!==a||n[18]!==u||n[19]!==d||n[20]!==m){let A;n[22]!==u||n[23]!==d||n[24]!==m?(A=D=>{const N=D.user,B=!!D.current,T=D.source==="gh-cli"?m("header.github.accountSource.cli"):m("header.github.accountSource.oauth");return s.jsxs(bs,{className:"gap-2",disabled:d,onSelect:()=>{B||u(D.id)},children:[N?.avatarUrl?s.jsx("img",{src:N.avatarUrl,alt:N.login?m("header.github.avatarWithLogin",{login:N.login}):m("header.github.avatar"),className:"h-6 w-6 rounded-full border border-border/60 bg-muted object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted",children:s.jsx(I,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:N?.name?.trim()||N?.login||"GitHub"}),N?.login?s.jsxs("span",{className:"truncate typography-micro text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:N.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:T})]}):null]}),B?s.jsx(I,{name:"check",className:"h-4 w-4 text-primary"}):null]},D.id)},n[22]=u,n[23]=d,n[24]=m,n[25]=A):A=n[25],S=a.map(A),n[17]=a,n[18]=u,n[19]=d,n[20]=m,n[21]=S}else S=n[21];let k;n[26]!==w||n[27]!==S?(k=s.jsxs(tn,{align:"end",className:"w-64",children:[w,v,S]}),n[26]=w,n[27]=S,n[28]=k):k=n[28];let j;return n[29]!==h||n[30]!==k?(j=s.jsxs(sn,{children:[h,k]}),n[29]=h,n[30]=k,n[31]=j):j=n[31],j}let f;n[32]!==l||n[33]!==m?(f=l?m("header.github.connectedWithLogin",{login:l}):m("header.github.connected"),n[32]=l,n[33]=m,n[34]=f):f=n[34];let p;n[35]!==c||n[36]!==l||n[37]!==m?(p=c?s.jsx("img",{src:c,alt:l?m("header.github.avatarWithLogin",{login:l}):m("header.github.avatar"),className:"h-full w-full object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx(I,{name:"github-fill",className:"h-3.5 w-3.5 text-foreground"}),n[35]=c,n[36]=l,n[37]=m,n[38]=p):p=n[38];let y;return n[39]!==f||n[40]!==p?(y=s.jsx("div",{className:"app-region-no-drag flex h-7 w-7 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80",title:f,children:p}),n[39]=f,n[40]=p,n[41]=y):y=n[41],y}),Yb=i.memo(function(e){const n=mt.c(84),{isDesktopApp:r,currentInstanceLabel:o,compactCurrentInstanceLabel:a,currentInstanceIsLocal:c,isDesktopServicesOpen:l,setIsDesktopServicesOpen:d,refreshCurrentInstanceLabel:u,desktopServicesTab:m,setDesktopServicesTab:f,quotaResultsLength:p,fetchAllQuotas:y,servicesTabItems:g,quotaLastUpdated:b,quotaDisplayMode:x,quotaDisplayTabItems:h,handleDisplayModeChange:C,handleUsageRefresh:w,isQuotaLoading:v,isUsageRefreshSpinning:S,hasRateLimits:k,rateLimitGroups:j,expandedFamilies:A,toggleFamilyExpanded:D,shortcutLabel:N,showDevShutdown:B,isDevShutdownInFlight:T,onDevShutdown:E,remoteUpdateInfo:_,remoteUpdateChecking:R,remoteUpdateError:V,onOpenRemoteUpdate:$,showPredValues:z,timeFormatPreference:F}=e,{t:te}=Nt();let ne;n[0]!==m||n[1]!==y||n[2]!==p||n[3]!==u||n[4]!==d?(ne=Me=>{d(Me),Me&&(u(),m==="usage"&&p===0&&y())},n[0]=m,n[1]=y,n[2]=p,n[3]=u,n[4]=d,n[5]=ne):ne=n[5];let q;n[6]!==o||n[7]!==r||n[8]!==te?(q=r?te("header.services.openWithCurrent",{current:o}):te("header.services.open"),n[6]=o,n[7]=r,n[8]=te,n[9]=q):q=n[9];const H=r?"w-auto max-w-[14rem] justify-start gap-1.5 px-2.5":"h-8 w-8";let X;n[10]!==H?(X=Pe(Qa,H),n[10]=H,n[11]=X):X=n[11];let oe;n[12]===Symbol.for("react.memo_cache_sentinel")?(oe=s.jsx(I,{name:"stack",className:"h-[18px] w-[18px]"}),n[12]=oe):oe=n[12];let he;n[13]!==a||n[14]!==r?(he=r?s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:a}):null,n[13]=a,n[14]=r,n[15]=he):he=n[15];let Se;n[16]!==q||n[17]!==X||n[18]!==he?(Se=s.jsx(Mt,{asChild:!0,children:s.jsx(en,{asChild:!0,children:s.jsxs("button",{type:"button","aria-label":q,className:X,children:[oe,he]})})}),n[16]=q,n[17]=X,n[18]=he,n[19]=Se):Se=n[19];let Z;n[20]!==o||n[21]!==r||n[22]!==N||n[23]!==te?(Z=r?te("header.services.tooltip.currentInstanceWithShortcuts",{current:o,toggle:N("toggle_services_menu"),nextTab:N("cycle_services_tab")}):te("header.services.tooltip.servicesWithShortcuts",{toggle:N("toggle_services_menu"),nextTab:N("cycle_services_tab")}),n[20]=o,n[21]=r,n[22]=N,n[23]=te,n[24]=Z):Z=n[24];let ke;n[25]!==Z?(ke=s.jsx(Ft,{children:s.jsx("p",{children:Z})}),n[25]=Z,n[26]=ke):ke=n[26];let Y;n[27]!==Se||n[28]!==ke?(Y=s.jsxs(Et,{children:[Se,ke]}),n[27]=Se,n[28]=ke,n[29]=Y):Y=n[29];let ge;n[30]!==y||n[31]!==p||n[32]!==f?(ge=Me=>{const fe=Me;f(fe),fe==="usage"&&p===0&&y()},n[30]=y,n[31]=p,n[32]=f,n[33]=ge):ge=n[33];let O;n[34]!==m||n[35]!==g||n[36]!==ge?(O=s.jsx("div",{className:"sticky top-0 z-20 px-2 pt-1.5 pb-px",children:s.jsx("div",{className:"h-9",children:s.jsx(To,{items:g,activeId:m,onSelect:ge,layoutMode:"fit",variant:"active-pill",activePillInsetClassName:"gap-0.5 px-px py-0",activePillButtonClassName:"h-8",className:"h-full"})})}),n[34]=m,n[35]=g,n[36]=ge,n[37]=O):O=n[37];let se;n[38]!==c||n[39]!==m||n[40]!==r||n[41]!==l||n[42]!==$||n[43]!==R||n[44]!==V||n[45]!==_||n[46]!==d||n[47]!==te?(se=r&&m==="instance"?s.jsxs("div",{children:[c?null:s.jsx("div",{className:"border-b border-[var(--interactive-border)] px-4 py-2.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label font-medium text-foreground",children:te("header.services.remoteUpdate.title")}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:_?.available?te("header.services.remoteUpdate.available",{version:_.version||""}):R?te("header.services.remoteUpdate.checking"):V||te("header.services.remoteUpdate.upToDate")})]}),_?.available?s.jsx("button",{type:"button",className:"shrink-0 rounded-md bg-[var(--primary-base)] px-3 py-1.5 typography-ui-label font-medium text-[var(--primary-foreground)] hover:opacity-90",onClick:$,children:te("header.services.remoteUpdate.actions.open")}):null]})}),s.jsx(Ip,{embedded:!0,open:l&&m==="instance",onOpenChange:Xb,onHostSwitched:()=>d(!1)})]}):null,n[38]=c,n[39]=m,n[40]=r,n[41]=l,n[42]=$,n[43]=R,n[44]=V,n[45]=_,n[46]=d,n[47]=te,n[48]=se):se=n[48];let ee;n[49]!==m||n[50]!==l?(ee=m==="mcp"?s.jsx(wm,{active:l&&m==="mcp"}):null,n[49]=m,n[50]=l,n[51]=ee):ee=n[51];let je;n[52]!==m||n[53]!==A||n[54]!==C||n[55]!==w||n[56]!==k||n[57]!==v||n[58]!==S||n[59]!==x||n[60]!==h||n[61]!==b||n[62]!==j||n[63]!==z||n[64]!==te||n[65]!==F||n[66]!==D?(je=m==="usage"?s.jsxs("div",{className:"overflow-x-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--interactive-border)] px-4 py-2.5",children:[s.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[s.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:te("header.services.rateLimits")}),s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:Rm(b,F)})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"h-7 w-[10.5rem]",children:s.jsx(To,{items:h,activeId:x,onSelect:Me=>{C(Me)},layoutMode:"fit",variant:"active-pill",activePillInsetClassName:"gap-0.5 px-px py-0",className:"h-full"})}),s.jsx("button",{type:"button",className:Pe("inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors","hover:text-foreground hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),onClick:w,disabled:v||S,"aria-label":te("header.services.refreshRateLimitsAria"),children:s.jsx(I,{name:"refresh",className:Pe("h-4 w-4",S&&"animate-spin")})})]})]}),k?null:s.jsx("div",{className:"px-4 py-5 text-center",children:s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:te("header.services.noRateLimits")})}),s.jsx("div",{className:"py-2",children:j.map((Me,fe)=>{const Ae=A[Me.providerId]??[];return s.jsxs(i.Fragment,{children:[fe>0?s.jsx("div",{className:"mx-4 my-2 border-t border-[var(--interactive-border)]"}):null,s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",children:[s.jsx(Do,{providerId:Me.providerId,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:Me.providerName})]}),Me.entries.length===0&&(!Me.modelFamilies||Me.modelFamilies.length===0)?s.jsx("div",{className:"px-4 pb-2",children:s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:Me.error??te("header.services.noRateLimitsReported")})}):s.jsxs("div",{className:"space-y-3 px-4 pb-2",children:[Me.entries.map(pe=>{const[ce,me]=pe,Ne=x==="remaining"?me.remainingPercent:me.usedPercent,ue=ja(me.usedPercent,me.resetAt,me.windowSeconds,ce),P=ue?.dailyAllocationPercent!=null?x==="remaining"?100-ri(ue.elapsedRatio):ri(ue.elapsedRatio):null,M=Io(me.valueLabel,Ne),de=zf(me.resetAt,me.resetAfterFormatted??me.resetAtFormatted,F);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:yc(ce)}),de?s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:de}):null]}),s.jsx("span",{className:"typography-ui-label tabular-nums text-foreground",children:M==="-"?"":M})]}),s.jsx(Aa,{percent:Ne,tonePercent:me.usedPercent,className:"h-1.5",expectedMarkerPercent:P}),ue&&z?s.jsx(Da,{paceInfo:ue,compact:!0}):null]},`${Me.providerId}-${ce}`)}),Me.modelFamilies&&Me.modelFamilies.length>0?s.jsx("div",{className:"space-y-0.5",children:Me.modelFamilies.map(pe=>{const ce=pe.familyId??"other",me=Ae.includes(ce);return s.jsxs(eo,{open:me,onOpenChange:()=>D(Me.providerId,ce),children:[s.jsxs(Bo,{className:"flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:pe.familyLabel}),me?s.jsx(I,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):s.jsx(I,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"})]}),s.jsx(to,{children:s.jsx("div",{className:"space-y-2.5 pb-1 pl-1 pt-1",children:pe.models.map(Ne=>{const[ue,P]=Ne,M=x==="remaining"?P.remainingPercent:P.usedPercent,de=ja(P.usedPercent,P.resetAt,P.windowSeconds),xe=de?.dailyAllocationPercent!=null?x==="remaining"?100-ri(de.elapsedRatio):ri(de.elapsedRatio):null,U=Io(P.valueLabel,M);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:ym(ue)}),s.jsx("span",{className:"typography-ui-label tabular-nums text-foreground",children:U==="-"?"":U})]}),s.jsx(Aa,{percent:M,tonePercent:P.usedPercent,className:"h-1.5",expectedMarkerPercent:xe}),de&&z?s.jsx(Da,{paceInfo:de,compact:!0}):null]},`${Me.providerId}-${ue}`)})})})]},ce)})}):null]})]},Me.providerId)})})]}):null,n[52]=m,n[53]=A,n[54]=C,n[55]=w,n[56]=k,n[57]=v,n[58]=S,n[59]=x,n[60]=h,n[61]=b,n[62]=j,n[63]=z,n[64]=te,n[65]=F,n[66]=D,n[67]=je):je=n[67];let De;n[68]!==T||n[69]!==E||n[70]!==B||n[71]!==te?(De=B?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mx-4 my-2 border-t border-[var(--interactive-border)]"}),s.jsx("div",{className:"px-2 pb-2",children:s.jsx(bs,{disabled:T,onSelect:()=>{E()},children:te("header.services.shutdownDev")})})]}):null,n[68]=T,n[69]=E,n[70]=B,n[71]=te,n[72]=De):De=n[72];let Be;n[73]!==O||n[74]!==se||n[75]!==ee||n[76]!==je||n[77]!==De?(Be=s.jsxs(tn,{align:"end",className:"w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto bg-[var(--surface-elevated)] p-0",children:[O,se,ee,je,De]}),n[73]=O,n[74]=se,n[75]=ee,n[76]=je,n[77]=De,n[78]=Be):Be=n[78];let Fe;return n[79]!==l||n[80]!==ne||n[81]!==Y||n[82]!==Be?(Fe=s.jsxs(sn,{open:l,onOpenChange:ne,children:[Y,Be]}),n[79]=l,n[80]=ne,n[81]=Y,n[82]=Be,n[83]=Fe):Fe=n[83],Fe}),Qb=(t,e)=>t===e?!0:!t||!e?!1:t.totalTokens===e.totalTokens&&t.percentage===e.percentage&&t.contextLimit===e.contextLimit&&(t.outputLimit??0)===(e.outputLimit??0)&&(t.normalizedOutput??0)===(e.normalizedOutput??0)&&t.thresholdLimit===e.thresholdLimit&&(t.lastMessageId??"")===(e.lastMessageId??""),Jb=t=>{const e=t.trim();if(!e)return"";const n=e.split(/\s+/).filter(Boolean);if(n.length>=2){const r=n[0],o=n[1].slice(0,3),a=`${r} ${o}`.trim();return n.length>2||a.length<e.length?`${a}...`:a}return e.length>12?`${e.slice(0,9).trimEnd()}...`:e},Rm=(t,e)=>{if(!t)return"-";try{return Uf(t,e,{fallback:"-"})}catch{return"-"}},In=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},ei=t=>!t?.isOpen||!Array.isArray(t.tabs)||t.tabs.length===0?null:(t.tabs.find(n=>n.id===t.activeTabId)??t.tabs[t.tabs.length-1])?.mode??null,su=({onToggleLeftDrawer:t,onToggleRightDrawer:e,leftDrawerOpen:n,rightDrawerOpen:r})=>{const{t:o}=Nt(),a=Ee(Q=>Q.setSessionSwitcherOpen),c=Ee(Q=>Q.toggleSidebar),l=Ee(Q=>Q.isSidebarOpen),d=Ee(Q=>Q.toggleBottomTerminal),u=Ee(Q=>Q.toggleRightSidebar),m=Ee(Q=>Q.openContextOverview),f=Ee(Q=>Q.openContextPlan),p=Ee(Q=>Q.openContextBrowser),y=Ee(Q=>Q.openContextPanelTab),g=Ee(Q=>Q.closeContextPanel),b=Ee(Q=>Q.contextPanelByDirectory),x=Ee(Q=>Q.activeMainTab),h=Ee(Q=>Q.setActiveMainTab),C=Ee(Q=>Q.shortcutOverrides),w=Ee(Q=>Q.timeFormatPreference),v=ss(Q=>Q.getCurrentModel),S=Jn(),[k,j]=i.useState(!1),A=ut(Q=>Q.getContextUsage),D=ut(Q=>!!Q.newSessionDraft?.open),N=ut(Q=>Q.currentSessionId),B=Tp(N??""),T=Wf(N??null),E=vr(Q=>Q.activeSessions),_=wc(),R=ws(Q=>Q.activeProjectId?Q.projects.find(st=>st.id===Q.activeProjectId)??null:null),V=i.useMemo(()=>{if(!R)return null;const Q=R.label?.trim();if(Q)return Q;const st=R.path.split(/[\\/]/).filter(Boolean);return st[st.length-1]??null},[R]),$=mn(Q=>Q.results),z=mn(Q=>Q.fetchAllQuotas),F=mn(Q=>Q.isLoading),te=mn(Q=>Q.lastUpdated),ne=mn(Q=>Q.displayMode),q=mn(Q=>Q.showPredValues),H=mn(Q=>Q.dropdownProviderIds),X=mn(Q=>Q.loadSettings),oe=mn(Q=>Q.setDisplayMode),{isMobile:he}=Er(),Se=Pi(Q=>Q.status),Z=Pi(Q=>Q.setStatus),ke=i.useRef(null),[Y,ge]=i.useState(()=>typeof window>"u"?!1:dr()),O=i.useMemo(()=>Oa(),[]),se=Hf(),[ee,je]=i.useState(!1),De=i.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),Be=i.useMemo(()=>typeof window>"u"?!1:!!window.__OPENCHAMBER_ELECTRON__&&window.__OPENCHAMBER_PLATFORM__==="win32",[]),Fe=i.useMemo(()=>{if(typeof window>"u")return null;const Q=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof Q=="number"&&Number.isFinite(Q)&&Q>0)return Q;if(typeof navigator>"u")return null;const st=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!st)return null;const gt=Number.parseInt(st[1],10),Pt=Number.parseInt(st[2],10);return Number.isNaN(gt)?null:gt===10?Pt:gt},[]);Xe.useEffect(()=>{typeof window>"u"||ge(dr())},[]);const Me=v(),fe=Me&&typeof Me.limit=="object"&&Me.limit!==null?Me.limit:null,Ae=fe&&typeof fe.context=="number"?fe.context:0,pe=fe&&typeof fe.output=="number"?fe.output:0,ce=A(Ae,pe),[me,Ne]=i.useState(null),ue=!N||B;Xe.useEffect(()=>{if(!N){Ne(Q=>Q===null?Q:null);return}if(ce&&ce.totalTokens>0){Ne(Q=>Qb(Q,ce)?Q:ce);return}ue&&Ne(Q=>Q===null?Q:null)},[ce,N,ue]);const P=Ee(Q=>Q.isSessionSwitcherOpen),M=Se?.connected?Se.user?.avatarUrl??null:null,de=Se?.connected?Se.user?.login??null:null,xe=Se?.accounts??[],[U,be]=i.useState(!1),[ve,G]=i.useState(!1),[ye,Le]=i.useState(!1),[Re,J]=i.useState(!1),[L,ae]=i.useState("Local"),[re,Oe]=i.useState(!0),[Ge,He]=i.useState(!1),[Je,rt]=i.useState(null),[bt,yt]=i.useState(!1),[Ve,Ye]=i.useState(null),nt=i.useMemo(()=>Jb(L),[L]),[vt,kt]=i.useState(Y?"instance":"usage"),[wt,St]=i.useState("usage");Xe.useEffect(()=>{!Y&&vt==="instance"&&kt("usage")},[vt,Y]);const et=i.useMemo(()=>Gr(),[]),Ot=!et&&x==="chat"&&!!me&&me.totalTokens>0,ns=me&&me.contextLimit>0?Math.min(999,me.totalTokens/me.contextLimit*100):0,Ut=i.useCallback(async()=>{if(!(typeof window>"u"||!Y))try{if(Ji()){ae("Local"),Oe(!0);return}Oe(!1);const Q=await Gf(),st=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,gt=Ur();if(gt&&Sa(gt,st)){ae("Local"),Oe(!0);return}const Pt=Q.hosts.find(Zt=>gt?Sa(gt,Kf(Zt)):!1);if(Pt?.label?.trim()){ae(qf(Pt.label.trim()));return}ae("Instance")}catch{ae("Local"),Oe(!0)}},[Y]);Xe.useEffect(()=>{Ut()},[Ut]);const _e=i.useCallback(async()=>{if(re){rt(null),Ye(null);return}yt(!0),Ye(null);try{const Q=new URLSearchParams({appType:"web",instanceMode:"remote"}),st=await As(`/api/openchamber/update-check?${Q.toString()}`,{method:"GET",headers:{Accept:"application/json"}});if(!st.ok)throw new Error(`Server responded with ${st.status}`);const gt=await st.json();rt({available:gt.available??!1,version:gt.version,currentVersion:gt.currentVersion??"unknown",body:gt.body,nextSuggestedCheckInSec:typeof gt.nextSuggestedCheckInSec=="number"?gt.nextSuggestedCheckInSec:void 0,packageManager:gt.packageManager,updateCommand:gt.updateCommand})}catch(Q){rt(null),Ye(Q instanceof Error?Q.message:o("header.services.remoteUpdate.error"))}finally{yt(!1)}},[re,o]);i.useEffect(()=>{rt(null),Ye(null),He(!1)},[re,L]),i.useEffect(()=>{if(!Y||re)return;const Q=3e3,st=3600*1e3;let gt=!1,Pt=null;const Zt=is=>{Pt=window.setTimeout(()=>{if(gt||typeof document<"u"&&document.visibilityState!=="visible"){Zt(st);return}_e().finally(()=>{gt||Zt(st)})},is)};return Zt(Q),()=>{gt=!0,Pt!==null&&window.clearTimeout(Pt)}},[_e,re,L,Y]);const Ze=i.useCallback(()=>{if(Je?.available){He(!0);return}_e()},[_e,Je?.available]);Vx();const Vt=mn(Q=>Q.selectedModels),jt=mn(Q=>Q.expandedFamilies),xt=mn(Q=>Q.toggleFamilyExpanded),rs=i.useMemo(()=>{const Q=[];for(const st of vm){if(!H.includes(st.id))continue;const gt=$.find(Fs=>Fs.providerId===st.id),Pt=gt?.usage?.windows??{},Zt=gt?.usage?.models,is=Object.entries(Pt),ms={providerId:st.id,providerName:st.name,entries:is,error:gt&&!gt.ok&>.configured?gt.error:void 0};if(Zt&&Object.keys(Zt).length>0){const Fs=Vt[st.id]??[],qs=Fs.length>0,er=$x(Zt,st.id),qn=zx(st.id),Fr=Ux(qn);ms.modelFamilies=[];for(const gn of Fr){const tr=er.get(gn.id)??[];if(tr.length===0)continue;const xn=qs?tr.filter(bn=>Fs.includes(bn)):tr;if(xn.length===0)continue;const Mn=[];for(const bn of xn){const or=Zt[bn];if(or?.windows){const Cn=Object.entries(or.windows);Cn.length>0&&Mn.push([bn,Cn[0][1]])}}Mn.length>0&&ms.modelFamilies.push({familyId:gn.id,familyLabel:gn.label,models:Mn})}const Bs=er.get(null)??[],Lr=qs?Bs.filter(gn=>Fs.includes(gn)):Bs;if(Lr.length>0){const gn=[];for(const tr of Lr){const xn=Zt[tr];if(xn?.windows){const Mn=Object.entries(xn.windows);Mn.length>0&&gn.push([tr,Mn[0][1]])}}gn.length>0&&ms.modelFamilies.push({familyId:null,familyLabel:o("header.services.modelFamily.other"),models:gn})}}(is.length>0||ms.modelFamilies&&ms.modelFamilies.length>0||ms.error)&&Q.push(ms)}return Q},[H,$,Vt,o]),Gt=rs.length>0;i.useEffect(()=>{X()},[X]);const Wt=i.useCallback(async Q=>{oe(Q);try{await pc({usageDisplayMode:Q})}catch(st){console.warn("Failed to update usage display mode:",st)}},[oe]),as=i.useCallback(()=>{if(Re)return;J(!0);const Q=new Promise(st=>setTimeout(st,500));Promise.all([z(),Q]).finally(()=>{J(!1)})},[z,Re]),Bt=i.useMemo(()=>N?_.find(Q=>Q.id===N)??E.find(Q=>Q.id===N)??T??Yf().find(Q=>Q.id===N)??null:null,[N,T,E,_]),Lt=i.useRef(null),[_t,Kt]=i.useState(0);i.useEffect(()=>{if(!N){Lt.current&&(Lt.current=null,Kt(Pt=>Pt+1));return}if(Bt){Lt.current={sessionId:N,session:Bt,expiresAt:Date.now()+2e3};return}const Q=Lt.current;if(!Q||Q.sessionId!==N)return;const st=Q.expiresAt-Date.now();if(st<=0){Lt.current=null,Kt(Pt=>Pt+1);return}const gt=window.setTimeout(()=>{Lt.current?.sessionId===N&&(Lt.current=null),Kt(Pt=>Pt+1)},st);return()=>{window.clearTimeout(gt)}},[N,Bt]);const Xt=(()=>{if(Bt)return Bt;if(!N)return null;const Q=Lt.current;return Q&&Q.sessionId===N&&Q.expiresAt>Date.now()?Q.session:null})(),Qt=ut(Q=>N?Q.worktreeMetadata.get(N)?.path??"":""),vs=ut(Q=>N?Q.worktreeMetadata.get(N)?.branch?.trim()??null:null),Dt=Qf(Q=>N?Q.getAttachment(N):void 0),$t=i.useMemo(()=>Dt?Rp(Dt,{pending:o("gitView.empty.worktreeSetupInProgress")}):null,[o,Dt]),Ct=i.useMemo(()=>Dt?Dt.legacy?"legacy":Dt.degraded?"degraded":Dt.worktreeStatus==="pending"?"pending":Dt.worktreeStatus==="missing"?"missing":Dt.worktreeStatus==="invalid"?"invalid":Dt.attentionReason?"attention":null:null,[Dt]),ds=i.useMemo(()=>In(Qt||""),[Qt]),qe=i.useMemo(()=>{const Q=typeof Xt?.directory=="string"?Xt.directory:"";return In(Q||"")},[Xt?.directory]),at=ut(Q=>Q.newSessionDraft?.open?In(Q.newSessionDraft.bootstrapPendingDirectory??Q.newSessionDraft.directoryOverride??""):""),Qe=i.useMemo(()=>ds||qe||at,[at,qe,ds]),At=ut(Q=>{const st=In(ds||qe||"");if(!st)return null;for(const gt of Q.availableWorktreesByProject.values()){const Zt=gt.find(is=>In(is.path)===st)?.branch?.trim();if(Zt)return Zt}return null}),ts=Ep(Qe||null)||vs||At,xs=i.useMemo(()=>{if(!N)return V??"OpenChamber";const Q=Xt?.title?.trim();return Q&&Q.length>0?Q:"Untitled Session"},[V,Xt?.title,N]),ks=i.useMemo(()=>In(Qe||R?.path||""),[R?.path,Qe]),Jt=i.useMemo(()=>R?{id:R.id,path:R.path}:null,[R]),ls=i.useRef(null);i.useEffect(()=>{!Jt||!ks||(ls.current={projectRef:Jt,directory:ks})},[ks,Jt]);const Ps=i.useMemo(()=>Jt&&ks?{projectRef:Jt,directory:ks}:ls.current,[ks,Jt]),Ts=vc(Q=>Q.planModeEnabled),hn=ut(Q=>Q.isSessionPlanAvailable),Gs=Ts&&N?hn(N):!1,an=Gs,Rn=i.useRef("");i.useEffect(()=>{if(!Ts){Ee.getState().activeMainTab==="plan"&&Ee.getState().setActiveMainTab("chat");return}if(!N)return;const Q=`${N||"none"}:${qe||"none"}:${Xt?.time?.created||0}:${Xt?.slug||"none"}`;Rn.current!==Q&&(Rn.current=Q),!Gs&&Ee.getState().activeMainTab==="plan"&&Ee.getState().setActiveMainTab("chat")},[Ts,Gs,Xt?.slug,Xt?.time?.created,N,qe]);const Os=i.useCallback(async Q=>{if(!(!Q||U)){be(!0);try{const st=S.github?await S.github.authActivate(Q):await(async()=>{const gt=await As("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:Q})}),Pt=await gt.json().catch(()=>null);if(!gt.ok||!Pt)throw new Error(Pt?.error||gt.statusText);return Pt})();Z(st)}catch(st){console.error("Failed to switch GitHub account:",st)}finally{be(!1)}}},[U,S.github,Z]),we=i.useCallback(()=>{if(typeof document>"u")return;const Q=document.activeElement;if(!Q)return;const st=Q.tagName;(st==="INPUT"||st==="TEXTAREA"||st==="SELECT"||Q.isContentEditable)&&Q.blur()},[]),tt=i.useCallback(()=>{if(he){we(),a(!P);return}c()},[we,he,P,a,c]),dt=i.useCallback(()=>{Wr("desktop_open_draft_mini_chat_window",{directory:In(Qe||R?.path||""),projectId:R?.id??null,apiBaseUrl:Ur(),clientToken:Hl()}).catch(Q=>{console.warn("[header] failed to open draft mini chat window",Q)})},[R?.id,R?.path,Qe]),It=i.useCallback(()=>{if(D){dt();return}N&&Wr("desktop_open_session_mini_chat_window",{sessionId:N,directory:In(Qe||R?.path||""),apiBaseUrl:Ur(),clientToken:Hl()}).catch(Q=>{console.warn("[header] failed to open session mini chat window",Q)})},[R?.path,N,dt,D,Qe]),Ht=i.useCallback(()=>{const Q=In(Qe||"");if(!Q)return;const st=b[Q];if(ei(st)==="context"){g(Q);return}m(Q)},[g,b,m,Qe]),ht=i.useMemo(()=>{const Q=In(Qe||"");if(!Q)return!1;const st=b[Q];return ei(st)==="context"},[b,Qe]),hs=i.useCallback(()=>{const Q=In(Qe||"");if(!Q)return;const st=b[Q];if(ei(st)==="plan"){g(Q);return}f(Q)},[g,b,f,Qe]),ps=i.useCallback(()=>{const Q=In(Qe||"");if(!Q)return;const st=b[Q];if(ei(st)==="diff"){g(Q);return}y(Q,{mode:"diff",stagedDiff:!1})},[g,b,y,Qe]),js=i.useCallback(()=>{const Q=In(Qe||"");if(!Q)return;const st=b[Q];if(ei(st)==="browser"){g(Q);return}p(Q)},[g,b,p,Qe]),Ss=i.useMemo(()=>{const Q=In(Qe||"");if(!Q)return!1;const st=b[Q];return ei(st)==="plan"},[b,Qe]),Ds=i.useMemo(()=>{const Q=In(Qe||"");if(!Q)return!1;const st=b[Q];return ei(st)==="diff"},[b,Qe]),Wn=i.useMemo(()=>{const Q=In(Qe||"");if(!Q)return!1;const st=b[Q];return ei(st)==="browser"},[b,Qe]),Es=Qa,En=Kb,Hn=i.useMemo(()=>ve?"services":n?"sessions":r?"git":x,[x,ve,n,r]),Xn=i.useCallback(()=>{G(!1),n&&t&&t(),r&&e&&e(),!t&&P&&a(!1)},[P,n,t,e,r,a]),We=i.useCallback(()=>{n||G(!1),t?.()},[n,t]),os=i.useCallback(()=>{r||G(!1),e?.()},[e,r]),fs=i.useMemo(()=>Y&&De&&!ee?"5.5rem":se?"max(calc(0.75rem + var(--oc-wco-left-inset, 0px)), 5.5rem)":(!Y||Be)&&!et?"calc(0.75rem + var(--oc-wco-left-inset, 0px))":"0.75rem",[Y,ee,De,se,et,Be]);Xe.useEffect(()=>{typeof document>"u"||document.documentElement.style.setProperty("--oc-titlebar-left-inset",fs)},[fs]);const zs=l?"0.75rem":"var(--oc-titlebar-left-inset, 0.75rem)",Ks=l?"0px":"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)";Xe.useEffect(()=>{if(!Y||!De){je(!1);return}let Q=!1;const st=async()=>{try{const Pt=await Wr("desktop_is_window_fullscreen");Q||je(Pt===!0)}catch{Q||je(!1)}},gt=()=>{st()};return st(),window.addEventListener("openchamber:window-resized",gt),()=>{Q=!0,window.removeEventListener("openchamber:window-resized",gt)}},[Y,De]);const Us=i.useMemo(()=>!Y||!De||Fe===null?"":Fe>=26?"h-12":Fe<=15?"h-14":"",[Y,De,Fe]),pn=i.useMemo(()=>{if(!(Y&&!Be||et))return{paddingRight:"calc(0.75rem + var(--oc-wco-right-inset, 0px))",minHeight:"max(3rem, var(--oc-wco-titlebar-height, 0px))",height:"max(3rem, var(--oc-wco-titlebar-height, 0px))"}},[Y,et,Be]),Ns=i.useCallback(()=>{if(typeof document>"u")return;const Q=ke.current?.getBoundingClientRect().height;Q&&document.documentElement.style.setProperty("--oc-header-height",`${Q}px`)},[]);Xe.useEffect(()=>{if(typeof window>"u")return;Ns();const Q=ke.current;if(!Q||typeof ResizeObserver>"u")return()=>{};let st=0;const gt=()=>{st||(st=requestAnimationFrame(()=>{st=0,Ns()}))},Pt=new ResizeObserver(gt);return Pt.observe(Q),window.addEventListener("resize",gt),window.addEventListener("orientationchange",gt),()=>{st&&cancelAnimationFrame(st),Pt.disconnect(),window.removeEventListener("resize",gt),window.removeEventListener("orientationchange",gt)}},[Ns]),Xe.useEffect(()=>{Ns()},[Ns,he,Us]);const qr=i.useCallback(async Q=>{const st=Q.target;st.closest(".app-region-no-drag")||st.closest("button, a, input, select, textarea")||Q.button===0&&Y&&await up()},[Y]),Gn=i.useMemo(()=>{if(he){const Q=[{id:"chat",label:o("layout.mainTab.chat"),icon:"chat-4"}];return an&&Q.push({id:"plan",label:o("layout.mainTab.plan"),icon:"file-text"}),Q.push({id:"diff",label:o("layout.mainTab.diff"),icon:"diff"},{id:"files",label:o("layout.mainTab.files"),icon:"folder-6"},{id:"terminal",label:o("layout.mainTab.terminal"),icon:"terminal-box"},{id:"context",label:o("layout.mainTab.context"),icon:"file-list-2"},{id:"diagram",label:o("layout.mainTab.diagram"),icon:"file"}),Q}return[]},[he,an,o]),fr=i.useCallback(Q=>Ba(ii(Q,C)),[C]);Xe.useEffect(()=>{!he&&(x==="git"||x==="terminal"||x==="diff"||x==="files"||x==="context")&&h("chat")},[x,he,h]);const Kn=i.useMemo(()=>{const Q=[];return Y&&Q.push({value:"instance",label:o("layout.services.instance"),icon:s.jsx(I,{name:"server",className:"h-3.5 w-3.5"})}),Q.push({value:"usage",label:o("layout.services.usage"),icon:s.jsx(I,{name:"timer",className:"h-3.5 w-3.5"})},{value:"mcp",label:"MCP",icon:s.jsx(Kl,{className:"h-3.5 w-3.5"})}),Q},[Y,o]),gs=i.useMemo(()=>Kn.map(Q=>({id:Q.value,label:Q.label,icon:Q.icon})),[Kn]),Ms=i.useMemo(()=>{if(typeof window>"u"||Y||et)return!1;const Q=window.location.hostname;return Q==="localhost"||Q==="127.0.0.1"||Q==="::1"},[Y,et]),jr=i.useCallback(async()=>{if(k)return;j(!0),Le(!1);const Q=[];let st=!1;try{try{for(const[,gt]of _s.getState().sessions.entries())for(const Pt of gt.tabs)Pt.previewUrl&&Q.push(Pt.previewUrl)}catch{}try{await fp({})}catch{}try{(await As("/api/system/dev-shutdown",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({previewUrls:Q})})).ok?st=!0:st=(await As("/api/system/shutdown",{method:"POST"})).ok}catch{}}finally{st||j(!1)}},[k,Le]),jn=i.useMemo(()=>[{value:"usage",label:o("header.services.used")},{value:"remaining",label:o("header.services.remaining")}],[o]),ln=i.useMemo(()=>jn.map(Q=>({id:Q.value,label:Q.label})),[jn]),Zn=i.useMemo(()=>[{id:"usage",label:o("layout.services.usage"),icon:s.jsx(I,{name:"timer",className:"h-3.5 w-3.5"})},{id:"mcp",label:"MCP",icon:s.jsx(Kl,{className:"h-3.5 w-3.5"})}],[o]);Xe.useEffect(()=>{const Q=st=>{if(jc(st)&&!st.shiftKey&&!st.altKey){const gt=parseInt(st.key,10);gt>=1&><=Gn.length&&(st.preventDefault(),he&&(we(),Xn()),h(Gn[gt-1].id))}};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[we,Xn,he,h,Gn]),Xe.useEffect(()=>{const Q=st=>{const gt=ii("toggle_services_menu",C);if(ia(st,gt)){st.preventDefault(),ye?Le(!1):(Le(!0),Ut(),vt==="usage"&&$.length===0&&z());return}const Pt=ii("cycle_services_tab",C);if(ia(st,Pt)){st.preventDefault();const is=Kn.map(er=>er.value);if(is.length===0)return;const ms=is.indexOf(vt),Fs=ms===-1?0:(ms+1)%is.length,qs=is[Fs];kt(qs),Le(!0),Ut(),qs==="usage"&&$.length===0&&z();return}const Zt=ii("toggle_context_plan",C);ia(st,Zt)&&(st.preventDefault(),hs())};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[C,ye,vt,Kn,$.length,z,Ut,hs]);const Mr=Q=>{const st=x===Q.id,gt=Q.icon==="diff",Pt=gt?null:Q.icon,Zt=Q.id==="chat",is=Fs=>gt?s.jsx(Xd,{size:Fs}):Pt?s.jsx(I,{name:Pt,className:`h-${Fs/4} w-${Fs/4}`}):null,ms=s.jsxs("button",{type:"button",onClick:()=>h(Q.id),className:Pe("relative flex h-8 items-center gap-2 px-3 rounded-lg typography-ui-label font-medium transition-colors",st?"app-region-no-drag bg-interactive-selection text-interactive-selection-foreground shadow-none":"app-region-no-drag text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",Zt&&!he&&"min-w-[100px] justify-center"),"aria-label":Q.label,"aria-selected":st,role:"tab",children:[he?is(20):s.jsxs(s.Fragment,{children:[is(16),s.jsx("span",{className:"header-tab-label",children:Q.label})]}),Q.badge!==void 0&&Q.badge>0&&s.jsx("span",{className:"header-tab-badge typography-micro text-status-info font-medium",children:Q.badge})]});return s.jsx(i.Fragment,{children:ms},Q.id)},Yr=et?null:s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":o("header.actions.toggleChangesPanelAria"),"aria-pressed":Ds,onClick:ps,className:Es,children:s.jsxs("span",{className:"relative h-5 w-5 overflow-hidden rounded-[2px]",children:[s.jsx("span",{className:"absolute left-[4px] top-[4px] h-3 w-[5px] bg-[var(--status-error)]/25"}),s.jsx("span",{className:"absolute right-[4px] top-[4px] h-3 w-[5px] bg-[var(--status-success)]/25"}),s.jsx(I,{name:"layout-column",className:"absolute inset-0 h-5 w-5"})]})})}),s.jsx(Ft,{children:s.jsx("p",{children:o("header.actions.toggleChangesPanel")})})]}),ui=s.jsxs(s.Fragment,{children:[an&&s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":o("header.actions.openPlanAria"),onClick:hs,className:Pe(Es,Ss&&"bg-[var(--interactive-hover)]"),children:s.jsx(I,{name:"file-text",className:"h-[18px] w-[18px]"})})}),s.jsx(Ft,{children:s.jsx("p",{children:o("header.actions.planWithShortcut",{shortcut:fr("toggle_context_plan")})})})]}),s.jsx(bb,{directory:ks,className:"mr-1"}),s.jsx(Yb,{isDesktopApp:Y,currentInstanceLabel:L,compactCurrentInstanceLabel:nt,currentInstanceIsLocal:re,isDesktopServicesOpen:ye,setIsDesktopServicesOpen:Le,refreshCurrentInstanceLabel:Ut,desktopServicesTab:vt,setDesktopServicesTab:kt,quotaResultsLength:$.length,fetchAllQuotas:z,servicesTabItems:gs,quotaLastUpdated:te,quotaDisplayMode:ne,showPredValues:q,quotaDisplayTabItems:ln,handleDisplayModeChange:Wt,handleUsageRefresh:as,isQuotaLoading:F,isUsageRefreshSpinning:Re,hasRateLimits:Gt,rateLimitGroups:rs,expandedFamilies:jt,toggleFamilyExpanded:xt,shortcutLabel:fr,showDevShutdown:Ms,isDevShutdownInFlight:k,onDevShutdown:jr,remoteUpdateInfo:Je,remoteUpdateChecking:bt,remoteUpdateError:Ve,onOpenRemoteUpdate:Ze,timeFormatPreference:w}),s.jsx(Wo,{title:o("header.actions.terminalPanelWithShortcut",{shortcut:fr("toggle_terminal")}),ariaLabel:o("header.actions.toggleTerminalPanelAria"),onClick:d,Icon:"terminal-box"}),he?null:s.jsx(Wo,{title:o("contextPanel.browser.open"),ariaLabel:o("contextPanel.browser.open"),onClick:js,pressed:Wn,Icon:"global"}),s.jsx(Wo,{title:o("header.actions.rightSidebarWithShortcut",{shortcut:fr("toggle_right_sidebar")}),ariaLabel:o("header.actions.toggleRightSidebarAria"),onClick:u,Icon:"layout-right"}),s.jsx(qb,{isMobile:he,githubAuthStatus:Se,githubAccounts:xe,githubAvatarUrl:M,githubLogin:de,isSwitchingGitHubAccount:U,handleGitHubAccountSwitch:Os})]}),mr=O&&(D||!!N),us=()=>s.jsxs("div",{onMouseDown:qr,className:Pe("app-region-drag relative flex h-12 select-none items-center pr-3",Us),style:pn,role:"tablist","aria-label":o("header.navigation.mainAria"),children:[s.jsx("div",{"aria-hidden":!0,className:"shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:zs}}),s.jsx("div",{"aria-hidden":!0,className:"app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",style:{width:Ks}}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[s.jsx(lb,{children:s.jsxs("button",{type:"button","aria-label":o("sessions.switcher.openAria"),className:"app-region-no-drag mr-3 flex min-w-0 flex-col items-start rounded-md px-1 py-0.5 -my-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60",children:[s.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:D?o("sessions.switcher.draftTitle"):xs}),V||ts||!D&&Ct?s.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[V?s.jsx("span",{className:"truncate",children:V}):null,ts?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(I,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:ts})]}):null,!D&&Ct?s.jsxs("span",{className:Pe("inline-flex min-w-0 items-center gap-0.5",Ct==="attention"||Ct==="invalid"||Ct==="missing"?"text-status-warning":"text-muted-foreground/60"),children:[s.jsx(I,{name:"alert",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:$t})]}):null]}):null]})}),Gn.length>0&&s.jsx("div",{className:"flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1",children:Gn.map(Q=>Mr(Q))}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Ot&&me?s.jsx(cb,{totalTokens:me.totalTokens,percentage:ns,colorPercentage:me.percentage,contextLimit:me.contextLimit,outputLimit:me.outputLimit??0,size:"compact",hideIcon:!0,showPercentIcon:!0,onClick:Ht,pressed:ht,className:mr?"":"mr-3.5",valueClassName:"typography-ui-label font-medium leading-none text-foreground",percentIconClassName:"h-4.5 w-4.5"}):null,Yr,s.jsx(Wo,{visible:mr,title:o(D?"header.actions.newMiniChat":"header.actions.openSessionMiniChat"),ariaLabel:o(D?"header.actions.newMiniChatAria":"header.actions.openSessionMiniChatAria"),onClick:It,className:Pe(Es,"mr-1"),Icon:"picture-in-picture-2"}),ui,s.jsx(db,{visible:Be})]})]})]}),cn=()=>s.jsxs("div",{className:"app-region-drag relative flex items-center gap-2 px-3 py-2 select-none",children:[s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t?s.jsx("button",{type:"button",onClick:We,className:Pe(En,Hn==="sessions"&&"bg-interactive-selection text-interactive-selection-foreground"),"aria-label":o(n?"header.actions.closeSessionsAria":"header.actions.openSessionsAria"),children:s.jsx(I,{name:"layout-left",className:"h-5 w-5"})}):P?s.jsx("button",{type:"button",onClick:()=>a(!1),className:"app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active","aria-label":o("header.actions.backAria"),children:s.jsx(I,{name:"arrow-left-s",className:"h-5 w-5"})}):s.jsx("button",{type:"button",onClick:tt,className:"app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active","aria-label":o("header.actions.openSessionsAria"),children:s.jsx(I,{name:"play-list-add",className:"h-5 w-5"})}),!t&&P&&s.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:o("header.sessions.title")})]}),(!P||!!t)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"app-region-no-drag flex min-w-0 flex-1 items-center",children:s.jsx("div",{className:"flex min-w-0 flex-1 overflow-x-auto overflow-y-hidden scrollbar-hidden touch-pan-x overscroll-x-contain",children:s.jsx("div",{className:"flex w-max items-center gap-1 pr-1",children:s.jsx("div",{className:"flex items-center gap-0.5 rounded-lg bg-[var(--surface-muted)]/50 p-0.5",role:"tablist","aria-label":o("header.navigation.mainAria"),children:Gn.map(Q=>{const st=x===Q.id,gt=Q.icon==="diff",Pt=gt?null:Q.icon;return s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>{he&&(we(),Xn()),h(Q.id)},"aria-label":Q.label,"aria-selected":st,role:"tab",className:Pe(En,"relative rounded-lg",Hn===Q.id&&"bg-interactive-selection text-interactive-selection-foreground"),children:[gt?s.jsx(Xd,{className:"h-5 w-5"}):Pt?s.jsx(I,{name:Pt,className:"h-5 w-5"}):null,Q.badge!==void 0&&Q.badge>0&&s.jsx("span",{className:"absolute -top-1 -right-1 text-[10px] font-semibold text-primary",children:Q.badge}),Q.showDot&&s.jsx("span",{className:"absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-primary","aria-label":o("header.changes.availableAria")})]})}),s.jsx(Ft,{children:s.jsx("p",{children:Q.label})})]},Q.id)})})})})}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[Ps&&s.jsx(Tm,{projectRef:Ps.projectRef,directory:Ps.directory,compact:!0,allowMobile:!0,className:"h-9"}),s.jsxs(sn,{open:ve,onOpenChange:Q=>{Q&&(n&&t&&t(),r&&e&&e()),G(Q),Q&&$.length===0&&z()},children:[s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":o("header.services.viewAria"),className:Pe(En,Hn==="services"&&"bg-interactive-selection text-interactive-selection-foreground"),children:s.jsx(I,{name:"stack",className:"h-5 w-5"})})})}),s.jsx(Ft,{children:s.jsx("p",{children:o("header.services.title")})})]}),s.jsx(tn,{align:"end",sideOffset:0,positionerClassName:"!fixed !bottom-0 !left-0 !right-0 !top-[var(--oc-header-height,56px)] !transform-none",className:"h-full w-screen max-h-none rounded-none border-0 p-0 pt-1 overflow-hidden",children:s.jsxs("div",{className:"flex h-full flex-col bg-[var(--surface-elevated)]",children:[s.jsx("div",{className:"sticky top-0 z-20 bg-[var(--surface-elevated)] px-2 py-px",children:s.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-0",children:[s.jsx("div",{className:"h-10 min-w-0 flex-1",children:s.jsx(To,{items:Zn,activeId:wt,onSelect:Q=>{const st=Q;St(st),st==="usage"&&$.length===0&&z()},layoutMode:"fit",variant:"active-pill",activePillInsetClassName:"gap-0.5 px-px py-0",activePillButtonClassName:"h-8",className:"h-full"})}),s.jsx("button",{type:"button",onClick:()=>G(!1),className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover","aria-label":o("header.services.closeAria"),children:s.jsx(I,{name:"close",className:"h-5 w-5"})})]})}),wt==="mcp"&&s.jsx(wm,{active:ve&&wt==="mcp"}),wt==="usage"&&s.jsxs("div",{className:"flex-1 overflow-y-auto overflow-x-hidden pb-[calc(4rem+env(safe-area-inset-bottom))]",children:[s.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3",children:[s.jsxs("div",{className:"flex flex-col min-w-0 gap-0.5",children:[s.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:o("header.services.rateLimits")}),s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:Rm(te,w)})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("div",{className:"flex items-center h-6",children:[s.jsx("button",{type:"button",onClick:()=>Wt("usage"),className:Pe("typography-ui-label px-1 pb-0.5 transition-colors",ne==="usage"?"text-foreground border-b-2 border-[var(--primary-base)]":"text-muted-foreground hover:text-foreground"),children:o("header.services.used")}),s.jsx("span",{className:"text-muted-foreground typography-ui-label px-0.5",children:"·"}),s.jsx("button",{type:"button",onClick:()=>Wt("remaining"),className:Pe("typography-ui-label px-1 pb-0.5 transition-colors",ne==="remaining"?"text-foreground border-b-2 border-[var(--primary-base)]":"text-muted-foreground hover:text-foreground"),children:o("header.services.remaining")})]}),s.jsx("button",{type:"button",className:Pe("inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors","hover:text-foreground hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),onClick:as,disabled:F||Re,"aria-label":o("header.services.refreshRateLimitsAria"),children:s.jsx(I,{name:"refresh",className:Pe("h-4 w-4",Re&&"animate-spin")})})]})]})}),!Gt&&s.jsx("div",{className:"px-4 py-6 text-center",children:s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:o("header.services.noRateLimits")})}),s.jsx("div",{className:"py-1",children:rs.map((Q,st)=>s.jsxs(i.Fragment,{children:[st>0?s.jsx("div",{className:"mx-4 my-1 border-t border-[var(--interactive-border)]"}):null,s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",children:[s.jsx(Do,{providerId:Q.providerId,className:"h-4 w-4"}),s.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:Q.providerName})]}),Q.entries.length===0&&(!Q.modelFamilies||Q.modelFamilies.length===0)?s.jsx("div",{className:"px-4 pb-2",children:s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:Q.error??o("header.services.noRateLimitsReported")})}):s.jsxs("div",{className:"space-y-3 px-4 pb-2",children:[Q.entries.map(([gt,Pt])=>{const Zt=ne==="remaining"?Pt.remainingPercent:Pt.usedPercent,is=ja(Pt.usedPercent,Pt.resetAt,Pt.windowSeconds,gt),ms=is?.dailyAllocationPercent!=null?ne==="remaining"?100-ri(is.elapsedRatio):ri(is.elapsedRatio):null,Fs=Io(Pt.valueLabel,Zt),qs=zf(Pt.resetAt,Pt.resetAfterFormatted??Pt.resetAtFormatted,w);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[s.jsx("span",{className:"truncate typography-ui-label text-foreground",children:yc(gt)}),qs?s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:qs}):null]}),s.jsx("span",{className:"typography-ui-label text-foreground tabular-nums",children:Fs==="-"?"":Fs})]}),s.jsx(Aa,{percent:Zt,tonePercent:Pt.usedPercent,className:"h-1.5",expectedMarkerPercent:ms}),is&&q?s.jsx(Da,{paceInfo:is,compact:!0}):null]},`${Q.providerId}-${gt}`)}),Q.modelFamilies&&Q.modelFamilies.length>0&&s.jsx("div",{className:"space-y-0.5",children:Q.modelFamilies.map(gt=>{const Zt=(jt[Q.providerId]??[]).includes(gt.familyId??"other");return s.jsxs(eo,{open:Zt,onOpenChange:()=>xt(Q.providerId,gt.familyId??"other"),children:[s.jsxs(Bo,{className:"flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx("span",{className:"typography-ui-label font-medium text-foreground",children:gt.familyLabel}),Zt?s.jsx(I,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):s.jsx(I,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"})]}),s.jsx(to,{children:s.jsx("div",{className:"space-y-2.5 pb-1 pl-1 pt-1",children:gt.models.map(([is,ms])=>{const Fs=ne==="remaining"?ms.remainingPercent:ms.usedPercent,qs=ja(ms.usedPercent,ms.resetAt,ms.windowSeconds),er=qs?.dailyAllocationPercent!=null?ne==="remaining"?100-ri(qs.elapsedRatio):ri(qs.elapsedRatio):null,qn=Io(ms.valueLabel,Fs);return s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[s.jsx("span",{className:"truncate typography-micro text-muted-foreground",children:ym(is)}),s.jsx("span",{className:"typography-ui-label text-foreground tabular-nums",children:qn==="-"?"":qn})]}),s.jsx(Aa,{percent:Fs,tonePercent:ms.usedPercent,className:"h-1.5",expectedMarkerPercent:er}),qs&&q?s.jsx(Da,{paceInfo:qs,compact:!0}):null]},`${Q.providerId}-${is}`)})})})]},gt.familyId??"other")})})]})]},Q.providerId))})]})]})})]}),e?s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:os,className:Pe(En,"relative",Hn==="git"&&"bg-interactive-selection text-interactive-selection-foreground"),"aria-label":r?"Close git sidebar":"Open git sidebar",children:s.jsx(I,{name:"layout-right",className:"h-5 w-5"})})}),s.jsx(Ft,{children:s.jsx("p",{children:r?"Close git sidebar":"Open git sidebar"})})]}):null]})]})]}),kn=Pe("header-safe-area relative z-10 bg-background",he&&"border-b border-border/50");return s.jsxs(s.Fragment,{children:[s.jsx("header",{ref:ke,className:kn,style:{"--padding-scale":"1"},children:he?cn():us()}),s.jsx(jm,{open:Ge,onOpenChange:He,info:Je,downloading:!1,downloaded:!1,progress:null,error:Ve,onDownload:()=>{},onRestart:()=>{},runtimeType:"web"})]})};function Xb(){}const nu=180,ru=640,Zb=110,ey=t=>{const e=mt.c(44),{isOpen:n,isMobile:r,children:o}=t,{t:a}=Nt(),c=Ee(ty),l=Ee(sy),d=Ee(ny),u=Ee(ry),[m,f]=i.useState(null),[p,y]=i.useState(!1),g=i.useRef(null),b=i.useRef(0),x=i.useRef(c||300),h=Math.min(ru,Math.max(nu,c||300));let C,w;e[0]!==n?(C=()=>{n||(f(null),y(!1))},w=[n],e[0]=n,e[1]=C,e[2]=w):(C=e[1],w=e[2]),i.useEffect(C,w);let v,S;e[3]!==l||e[4]!==r||e[5]!==n?(v=()=>{if(r||!n||!l)return;const X=()=>{const Se=g.current?.parentElement?.getBoundingClientRect().height;if(!Se||Se<=0)return;const Z=Math.max(0,Math.round(Se));f(ke=>ke===Z?ke:Z)};X();const oe=g.current?.parentElement;if(!oe)return;const he=new ResizeObserver(X);return he.observe(oe),()=>{he.disconnect()}},S=[l,r,n],e[3]=l,e[4]=r,e[5]=n,e[6]=v,e[7]=S):(v=e[6],S=e[7]),i.useEffect(v,S);let k,j;if(e[8]!==l||e[9]!==r||e[10]!==p||e[11]!==d||e[12]!==u?(k=()=>{if(r||!p||l)return;const X=he=>{const Se=b.current-he.clientY,Z=Math.min(ru,Math.max(nu,x.current+Se));d(Z)},oe=()=>{y(!1),Ee.getState().bottomTerminalHeight<=Zb&&u(!1)};return window.addEventListener("pointermove",X),window.addEventListener("pointerup",oe,{once:!0}),()=>{window.removeEventListener("pointermove",X),window.removeEventListener("pointerup",oe)}},j=[l,r,p,d,u],e[8]=l,e[9]=r,e[10]=p,e[11]=d,e[12]=u,e[13]=k,e[14]=j):(k=e[13],j=e[14]),i.useEffect(k,j),r)return null;const A=n?l?Math.max(0,m??h):h:0,D=n&&l;let N;e[15]!==A||e[16]!==l||e[17]!==n?(N=X=>{!n||l||(y(!0),b.current=X.clientY,x.current=A,X.preventDefault())},e[15]=A,e[16]=l,e[17]=n,e[18]=N):N=e[18];const B=N,T=D?"absolute inset-x-0 bottom-0 z-40":"relative",E=p?"transition-none":"transition-[height] duration-300 ease-in-out",_=(!n||D)&&"border-t-0";let R;e[19]!==_||e[20]!==T||e[21]!==E?(R=Pe("flex overflow-hidden border-t border-border bg-sidebar",T,E,_),e[19]=_,e[20]=T,e[21]=E,e[22]=R):R=e[22];let V;e[23]!==A||e[24]!==D?(V=D?{top:0}:{height:`${A}px`,minHeight:`${A}px`,maxHeight:`${A}px`},e[23]=A,e[24]=D,e[25]=V):V=e[25];const $=!n||!l&&A===0;let z;e[26]!==B||e[27]!==l||e[28]!==n||e[29]!==p||e[30]!==a?(z=n&&!l&&s.jsx("div",{className:Pe("absolute left-0 top-0 z-20 h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors",p&&"bg-[var(--interactive-border)]"),onPointerDown:B,role:"separator","aria-orientation":"horizontal","aria-label":a("terminalView.bottomDock.resizeAria")}),e[26]=B,e[27]=l,e[28]=n,e[29]=p,e[30]=a,e[31]=z):z=e[31];const F=!n&&"pointer-events-none select-none opacity-0";let te;e[32]!==F?(te=Pe("relative z-10 flex h-full min-h-0 w-full flex-col transition-opacity duration-300 ease-in-out",F),e[32]=F,e[33]=te):te=e[33];const ne=!n;let q;e[34]!==o||e[35]!==te||e[36]!==ne?(q=s.jsx("div",{className:te,"aria-hidden":ne,children:o}),e[34]=o,e[35]=te,e[36]=ne,e[37]=q):q=e[37];let H;return e[38]!==R||e[39]!==V||e[40]!==$||e[41]!==z||e[42]!==q?(H=s.jsxs("section",{ref:g,className:R,style:V,"aria-hidden":$,children:[z,q]}),e[38]=R,e[39]=V,e[40]=$,e[41]=z,e[42]=q,e[43]=H):H=e[43],H};function ty(t){return t.bottomTerminalHeight}function sy(t){return t.isBottomTerminalExpanded}function ny(t){return t.setBottomTerminalHeight}function ry(t){return t.setBottomTerminalOpen}const iu=280,ou=280,au=500,iy=({isOpen:t,isMobile:e,children:n,className:r,topBar:o})=>{const{t:a}=Nt(),c=Ee(j=>j.sidebarWidth),l=Ee(j=>j.setSidebarWidth),[d,u]=i.useState(!1),m=i.useRef(0),f=i.useRef(c||iu),p=i.useRef(null),y=i.useRef(null),g=i.useRef(null),b=i.useCallback(j=>Math.min(au,Math.max(ou,j)),[]),x=i.useCallback(j=>{const A=g.current;A&&(A.style.width=`${j}px`,A.style.minWidth=`${j}px`,A.style.maxWidth=`${j}px`,A.style.setProperty("--oc-left-sidebar-width",`${j}px`))},[]);if(i.useEffect(()=>{e&&d&&u(!1)},[e,d]),i.useEffect(()=>{d||(p.current=null,y.current=null)},[d]),e)return null;const h=Math.min(au,Math.max(ou,c||iu)),C=t?h:0,w=j=>{if(t){try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}y.current=j.pointerId,u(!0),m.current=j.clientX,f.current=C,p.current=C,x(C),j.preventDefault()}},v=j=>{if(e||!d||y.current!==j.pointerId)return;const A=j.clientX-m.current,D=b(f.current+A);p.current!==D&&(p.current=D,x(D))},S=j=>{if(y.current!==j.pointerId||e)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const A=b(p.current??C);y.current=null,p.current=null,u(!1),l(A)},k=d?p.current??C:C;return s.jsxs("aside",{ref:g,className:Pe("relative flex h-full overflow-hidden border-r border-border/40 will-change-[width] motion-reduce:transition-none","bg-sidebar oc-vibrancy-surface",!t&&"border-r-0",r),style:{width:`${k}px`,minWidth:`${k}px`,maxWidth:`${k}px`,"--oc-left-sidebar-width":`${d?k:h}px`,overflowX:"clip",transitionProperty:d?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||C===0,children:[t&&s.jsx("div",{className:Pe("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:w,onPointerMove:v,onPointerUp:S,onPointerCancel:S,role:"separator","aria-orientation":"vertical","aria-label":a("sidebar.resize.leftPanelAria")}),s.jsxs("div",{className:Pe("relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",d&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[o,s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:s.jsx(Zs,{children:n})})]})]})},oy=()=>{const t=mt.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={height:"var(--oc-header-height, 3rem)"},t[0]=e):e=t[0];let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"app-region-drag shrink-0",style:{width:"var(--oc-titlebar-left-inset, 0.75rem)"}}),t[1]=n):n=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{"aria-hidden":!0,className:"flex shrink-0",style:e,children:[n,s.jsx("div",{className:"app-region-no-drag shrink-0",style:{width:"calc(var(--oc-titlebar-controls-width, 5.5rem) + 0.5rem)"}}),s.jsx("div",{className:"app-region-drag flex-1"})]}),t[2]=r):r=t[2],r},Ho=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function ay(){const t=ws(f=>f.activeProjectId?f.projects.find(p=>p.id===f.activeProjectId)??null:null),e=ut(f=>f.currentSessionId),n=Wf(e??null),r=ut(f=>e?f.worktreeMetadata.get(e)?.path??"":""),o=ut(f=>f.newSessionDraft?.open?Ho(f.newSessionDraft.bootstrapPendingDirectory??f.newSessionDraft.directoryOverride??""):""),a=i.useMemo(()=>Ho(r||""),[r]),c=i.useMemo(()=>{const f=typeof n?.directory=="string"?n.directory:"";return Ho(f||"")},[n?.directory]),l=a||c||o,d=i.useMemo(()=>Ho(l||t?.path||""),[t?.path,l]),u=i.useMemo(()=>t?{id:t.id,path:t.path}:null,[t]),m=i.useRef(null);return i.useEffect(()=>{u&&d&&(m.current={projectRef:u,directory:d})},[d,u]),i.useMemo(()=>u&&d?{projectRef:u,directory:d}:m.current,[u,d])}const lu="app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors",ly=()=>{const t=mt.c(31),{t:e}=Nt(),n=Ee(cy),r=Ee(dy),o=Ee(uy),a=ay(),c=i.useRef(null),l=Ba(ii("toggle_sidebar",o));let d;e:{if(typeof window>"u"){d=!1;break e}d=!!window.__OPENCHAMBER_ELECTRON__&&window.__OPENCHAMBER_PLATFORM__==="win32"}const u=d,m=my;let f,p;t[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{if(typeof document>"u")return;const _=c.current;if(!_)return;const R=()=>{const $=_.getBoundingClientRect().width;document.documentElement.style.setProperty("--oc-titlebar-controls-width",`${Math.round($)}px`)};if(R(),typeof ResizeObserver>"u")return;const V=new ResizeObserver(R);return V.observe(_),()=>{V.disconnect()}},p=[],t[0]=f,t[1]=p):(f=t[0],p=t[1]),i.useEffect(f,p);const y="app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2";let g;t[2]===Symbol.for("react.memo_cache_sentinel")?(g={height:"var(--oc-header-height, 3rem)",paddingLeft:"var(--oc-titlebar-left-inset, 0.75rem)"},t[2]=g):g=t[2];const b="flex items-center gap-2";let x;t[3]!==e?(x=u?s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,"aria-label":e("header.actions.openAppMenuAria"),className:Pe(lu,"shrink-0"),children:s.jsx(I,{name:"menu-2",className:"h-[18px] w-[18px]"})})}),s.jsx(Ft,{children:s.jsx("p",{children:e("header.actions.openAppMenu")})})]}):null,t[3]=e,t[4]=x):x=t[4];const h=Et;let C;t[5]!==e?(C=e("header.actions.openSessionsAria"),t[5]=e,t[6]=C):C=t[6];let w,v;t[7]===Symbol.for("react.memo_cache_sentinel")?(w=Pe(lu,"shrink-0"),v=s.jsx(I,{name:"layout-left",className:"h-[18px] w-[18px]"}),t[7]=w,t[8]=v):(w=t[7],v=t[8]);let S;t[9]!==C||t[10]!==n?(S=s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":C,className:w,children:v})}),t[9]=C,t[10]=n,t[11]=S):S=t[11];const k=Ft,j=e("header.actions.openSessionsWithShortcut",{shortcut:l});let A;t[12]!==j?(A=s.jsx("p",{children:j}),t[12]=j,t[13]=A):A=t[13];let D;t[14]!==k||t[15]!==A?(D=s.jsx(k,{children:A}),t[14]=k,t[15]=A,t[16]=D):D=t[16];let N;t[17]!==h||t[18]!==S||t[19]!==D?(N=s.jsxs(h,{children:[S,D]}),t[17]=h,t[18]=S,t[19]=D,t[20]=N):N=t[20];let B;t[21]!==r||t[22]!==a?(B=a?s.jsx(Tm,{projectRef:a.projectRef,directory:a.directory,className:r?"oc-vibrancy-pill":void 0}):null,t[21]=r,t[22]=a,t[23]=B):B=t[23];let T;t[24]!==N||t[25]!==B||t[26]!==x?(T=s.jsxs("div",{ref:c,className:b,children:[x,N,B]}),t[24]=N,t[25]=B,t[26]=x,t[27]=T):T=t[27];let E;return t[28]!==T||t[29]!==g?(E=s.jsx("div",{className:y,style:g,children:T}),t[28]=T,t[29]=g,t[30]=E):E=t[30],E};function cy(t){return t.toggleSidebar}function dy(t){return t.isSidebarOpen}function uy(t){return t.shortcutOverrides}function fy(t){console.warn("[titlebar] failed to open app menu",t)}function my(t){const e=t.currentTarget.getBoundingClientRect();Wr("desktop_show_app_menu",{x:e.left,y:e.bottom}).catch(fy)}const cu=420,hy=({isOpen:t,children:e,className:n})=>{const{t:r}=Nt(),o=Ee(S=>S.rightSidebarWidth),a=Ee(S=>S.setRightSidebarWidth),[c,l]=i.useState(!1),d=i.useRef(0),u=i.useRef(o||cu),m=i.useRef(null),f=i.useRef(null),p=i.useRef(null),y=i.useCallback(S=>Math.min(wd,Math.max(vd,S)),[]),g=i.useCallback(S=>{const k=p.current;k&&(k.style.width=`${S}px`,k.style.minWidth=`${S}px`,k.style.maxWidth=`${S}px`,k.style.setProperty("--oc-right-sidebar-width",`${S}px`))},[]),b=Math.min(wd,Math.max(vd,o||cu)),x=t?b:0,h=S=>{if(t){try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}f.current=S.pointerId,l(!0),d.current=S.clientX,u.current=x,m.current=x,g(x),S.preventDefault()}},C=S=>{if(!c||f.current!==S.pointerId)return;const k=d.current-S.clientX,j=y(u.current+k);m.current!==j&&(m.current=j,g(j))},w=S=>{if(f.current!==S.pointerId)return;try{S.currentTarget.releasePointerCapture(S.pointerId)}catch{}const k=y(m.current??x);f.current=null,m.current=null,l(!1),a(k)},v=c?m.current??x:x;return s.jsxs("aside",{ref:p,className:Pe("relative flex h-full overflow-hidden border-l border-border/40 will-change-[width] motion-reduce:transition-none","bg-sidebar",!t&&"border-l-0",n),style:{width:`${v}px`,"--oc-right-sidebar-width":`${c?v:b}px`,overflowX:"clip",transitionProperty:c?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t||x===0,children:[t&&s.jsx("div",{className:Pe("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",c&&"bg-[var(--interactive-border)]"),onPointerDown:h,onPointerMove:C,onPointerUp:w,onPointerCancel:w,role:"separator","aria-orientation":"vertical","aria-label":r("sidebar.resize.rightPanelAria")}),s.jsx("div",{className:Pe("relative z-10 flex h-full min-h-0 shrink-0 flex-col pt-2 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",c&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-right-sidebar-width)"},"aria-hidden":!t,children:t?e:null})]})},du=t=>({providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:t.agent});function Em(t){const e=mt.c(120),{t:n}=Nt(),{open:r,onOpenChange:o,target:a,projectDirectory:c,submitting:l,onConfirm:d}=t,u=l===void 0?!1:l,m=ss(Ny),f=ss(Sy),p=Mp(jy),y=ss(vy),g=ss(wy),b=ss(yy),x=ss(by),h=ss(xy);let C;e[0]!==h||e[1]!==b||e[2]!==g||e[3]!==x?(C=()=>du({providerID:g,modelID:b,variant:x,agent:h}),e[0]=h,e[1]=b,e[2]=g,e[3]=x,e[4]=C):C=e[4];const[w,v]=i.useState(C);let S,k;e[5]!==p||e[6]!==f||e[7]!==m||e[8]!==r||e[9]!==c?(S=()=>{r&&(m({directory:c,source:"todoSendDialog"}),f({directory:c}),p())},k=[r,m,f,p,c],e[5]=p,e[6]=f,e[7]=m,e[8]=r,e[9]=c,e[10]=S,e[11]=k):(S=e[10],k=e[11]),i.useEffect(S,k);let j,A;e[12]!==h||e[13]!==b||e[14]!==g||e[15]!==x||e[16]!==r?(j=()=>{r&&v(du({providerID:g,modelID:b,variant:x,agent:h}))},A=[r,g,b,x,h],e[12]=h,e[13]=b,e[14]=g,e[15]=x,e[16]=r,e[17]=j,e[18]=A):(j=e[17],A=e[18]),i.useEffect(j,A);let D,N;e[19]!==w.modelID||e[20]!==w.providerID||e[21]!==r||e[22]!==y?(D=()=>{if(!r||y.length===0)return;const ye=y.find(L=>L.id===w.providerID)??y[0],Le=Array.isArray(ye?.models)?ye.models:[],Re=Le.some(L=>L.id===w.modelID),J=Le[0]?.id??"";ye?.id===w.providerID&&Re||v(L=>({...L,providerID:ye?.id??"",modelID:Re?L.modelID:J,variant:""}))},N=[r,y,w.providerID,w.modelID],e[19]=w.modelID,e[20]=w.providerID,e[21]=r,e[22]=y,e[23]=D,e[24]=N):(D=e[23],N=e[24]),i.useEffect(D,N);const B=gy;let T;if(e[25]!==w.modelID||e[26]!==w.providerID||e[27]!==y){let ye;e[29]!==w.providerID?(ye=Re=>Re.id===w.providerID,e[29]=w.providerID,e[30]=ye):ye=e[30],T=y.find(ye)?.models?.find(Re=>Re.id===w.modelID),e[25]=w.modelID,e[26]=w.providerID,e[27]=y,e[28]=T}else T=e[28];const E=T;let _;e[31]!==E?(_=E?.variants?Object.keys(E.variants):[],e[31]=E,e[32]=_):_=e[32];const R=_,V=R.length>0;let $,z;e[33]!==w.variant||e[34]!==V?($=()=>{V||!w.variant||v(py)},z=[V,w.variant],e[33]=w.variant,e[34]=V,e[35]=$,e[36]=z):($=e[35],z=e[36]),i.useEffect($,z);let F;e[37]!==w.modelID||e[38]!==w.providerID?(F=w.providerID.trim().length>0&&w.modelID.trim().length>0,e[37]=w.modelID,e[38]=w.providerID,e[39]=F):F=e[39];const te=F;let ne;e[40]!==te||e[41]!==w||e[42]!==d||e[43]!==u?(ne=()=>{!te||u||d(w)},e[40]=te,e[41]=w,e[42]=d,e[43]=u,e[44]=ne):ne=e[44];const q=ne;let H,X;e[45]!==q||e[46]!==r?(H=()=>{if(!r)return;const ye=Le=>{(Le.metaKey||Le.ctrlKey)&&Le.key==="Enter"&&(Le.preventDefault(),q())};return window.addEventListener("keydown",ye),()=>window.removeEventListener("keydown",ye)},X=[r,q],e[45]=q,e[46]=r,e[47]=H,e[48]=X):(H=e[47],X=e[48]),i.useEffect(H,X);let oe;e[49]!==n||e[50]!==a?(oe=n(a==="worktree"?"rightSidebar.contextNotesTodo.sendDialog.title.newWorktree":"rightSidebar.contextNotesTodo.sendDialog.title.newSession"),e[49]=n,e[50]=a,e[51]=oe):oe=e[51];const he=oe;let Se;e[52]!==o||e[53]!==u?(Se=ye=>{u||o(ye)},e[52]=o,e[53]=u,e[54]=Se):Se=e[54];let Z;e[55]!==he?(Z=s.jsx(Hs,{children:s.jsx(Ws,{children:he})}),e[55]=he,e[56]=Z):Z=e[56];let ke;e[57]!==n?(ke=n("chat.modelControls.model"),e[57]=n,e[58]=ke):ke=e[58];let Y;e[59]!==ke?(Y=s.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:ke}),e[59]=ke,e[60]=Y):Y=e[60];let ge;e[61]===Symbol.for("react.memo_cache_sentinel")?(ge=(ye,Le)=>{v(Re=>({...Re,providerID:ye,modelID:Le,variant:""}))},e[61]=ge):ge=e[61];let O;e[62]!==w.modelID||e[63]!==w.providerID?(O=s.jsx(Jf,{providerId:w.providerID,modelId:w.modelID,className:"max-w-[320px] justify-between",dropdownPortalToBody:!0,onChange:ge}),e[62]=w.modelID,e[63]=w.providerID,e[64]=O):O=e[64];let se;e[65]!==Y||e[66]!==O?(se=s.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[Y,O]}),e[65]=Y,e[66]=O,e[67]=se):se=e[67];let ee;e[68]!==n?(ee=n("sessions.scheduledTasks.editor.thinkingLevel.label"),e[68]=n,e[69]=ee):ee=e[69];let je;e[70]!==ee?(je=s.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:ee}),e[70]=ee,e[71]=je):je=e[71];const De=!V;let Be;e[72]===Symbol.for("react.memo_cache_sentinel")?(Be=ye=>v(Le=>({...Le,variant:ye})),e[72]=Be):Be=e[72];let Fe;e[73]!==w.variant||e[74]!==De||e[75]!==R?(Fe=s.jsx(Fp,{value:w.variant,options:R,disabled:De,onChange:Be}),e[73]=w.variant,e[74]=De,e[75]=R,e[76]=Fe):Fe=e[76];let Me;e[77]!==je||e[78]!==Fe?(Me=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[je,Fe]}),e[77]=je,e[78]=Fe,e[79]=Me):Me=e[79];let fe;e[80]!==n?(fe=n("sessions.scheduledTasks.editor.agent.label"),e[80]=n,e[81]=fe):fe=e[81];let Ae;e[82]!==fe?(Ae=s.jsx("span",{className:"typography-meta font-medium text-muted-foreground",children:fe}),e[82]=fe,e[83]=Ae):Ae=e[83];let pe;e[84]===Symbol.for("react.memo_cache_sentinel")?(pe=ye=>v(Le=>({...Le,agent:ye})),e[84]=pe):pe=e[84];let ce;e[85]!==w.agent?(ce=s.jsx(Xf,{agentName:w.agent,filter:B,dropdownPortalToBody:!0,onChange:pe}),e[85]=w.agent,e[86]=ce):ce=e[86];let me;e[87]!==Ae||e[88]!==ce?(me=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[Ae,ce]}),e[87]=Ae,e[88]=ce,e[89]=me):me=e[89];let Ne;e[90]!==se||e[91]!==Me||e[92]!==me?(Ne=s.jsxs("div",{className:"flex flex-col gap-4",children:[se,Me,me]}),e[90]=se,e[91]=Me,e[92]=me,e[93]=Ne):Ne=e[93];let ue;e[94]!==o?(ue=()=>o(!1),e[94]=o,e[95]=ue):ue=e[95];let P;e[96]!==n?(P=n("rightSidebar.contextNotesTodo.sendDialog.actions.cancel"),e[96]=n,e[97]=P):P=e[97];let M;e[98]!==u||e[99]!==ue||e[100]!==P?(M=s.jsx($e,{variant:"ghost",size:"sm",onClick:ue,disabled:u,children:P}),e[98]=u,e[99]=ue,e[100]=P,e[101]=M):M=e[101];const de=!te||u;let xe;e[102]!==u||e[103]!==n?(xe=n(u?"rightSidebar.contextNotesTodo.sendDialog.actions.sending":"rightSidebar.contextNotesTodo.sendDialog.actions.send"),e[102]=u,e[103]=n,e[104]=xe):xe=e[104];let U;e[105]!==q||e[106]!==de||e[107]!==xe?(U=s.jsx($e,{size:"sm",onClick:q,disabled:de,children:xe}),e[105]=q,e[106]=de,e[107]=xe,e[108]=U):U=e[108];let be;e[109]!==M||e[110]!==U?(be=s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[M,U]}),e[109]=M,e[110]=U,e[111]=be):be=e[111];let ve;e[112]!==Z||e[113]!==Ne||e[114]!==be?(ve=s.jsxs(Vs,{className:"max-w-md overflow-visible",children:[Z,Ne,be]}),e[112]=Z,e[113]=Ne,e[114]=be,e[115]=ve):ve=e[115];let G;return e[116]!==r||e[117]!==Se||e[118]!==ve?(G=s.jsx($s,{open:r,onOpenChange:Se,children:ve}),e[116]=r,e[117]=Se,e[118]=ve,e[119]=G):G=e[119],G}function py(t){return{...t,variant:""}}function gy(t){return Sc(t.mode)}function xy(t){return t.currentAgentName||""}function by(t){return t.currentVariant||""}function yy(t){return t.currentModelId}function wy(t){return t.currentProviderId}function vy(t){return t.providers}function jy(t){return t.loadAgents}function Sy(t){return t.loadAgents}function Ny(t){return t.loadProviders}const ec=5,Mm=15,Go=new Map,la=t=>{const e=Math.sqrt(t/100),n=12*e,r=24*e;return Math.ceil(n+r+1)},ky=(t,e)=>{const n=la(e);return Math.max(n*ec,Math.min(n*Mm,n*t))},Cy=async(t,e)=>{const n=await _p(t.path);return{...t,title:n?.title||t.path.split("/").pop()||e}},Ay=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`todo_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,uu=t=>[...t.filter(e=>!e.completed),...t.filter(e=>e.completed)],fu=(t,e)=>{const n=t.findIndex(r=>r.completed);return n===-1?[...t,e]:[...t.slice(0,n),e,...t.slice(n)]},Dy=t=>{const e=mt.c(20),{id:n,children:r}=t;let o;e[0]!==n?(o={id:n},e[0]=n,e[1]=o):o=e[1];const{attributes:a,listeners:c,setNodeRef:l,setActivatorNodeRef:d,transform:u,transition:m,isDragging:f}=mc(o);let p;e[2]!==u?(p=hc.Transform.toString(u),e[2]=u,e[3]=p):p=e[3];let y;e[4]!==p||e[5]!==m?(y={transform:p,transition:m},e[4]=p,e[5]=m,e[6]=y):y=e[6];const g=f&&"opacity-60";let b;e[7]!==g?(b=Pe(g),e[7]=g,e[8]=b):b=e[8];let x;e[9]!==a||e[10]!==r||e[11]!==f||e[12]!==c||e[13]!==d?(x=r({attributes:a,listeners:c,setActivatorNodeRef:d,isDragging:f}),e[9]=a,e[10]=r,e[11]=f,e[12]=c,e[13]=d,e[14]=x):x=e[14];let h;return e[15]!==l||e[16]!==y||e[17]!==b||e[18]!==x?(h=s.jsx("li",{ref:l,style:y,className:b,children:x}),e[15]=l,e[16]=y,e[17]=b,e[18]=x,e[19]=h):h=e[19],h},Iy=({projectRef:t,projectLabel:e,canCreateWorktree:n=!1,onActionComplete:r,className:o})=>{const{t:a}=Nt(),[c,l]=i.useState(!1),[d,u]=i.useState(""),[m,f]=i.useState([]),[p,y]=i.useState(""),[g,b]=i.useState(null),[x,h]=i.useState(()=>new Set),[C,w]=i.useState([]),[v,S]=i.useState(null),[k,j]=i.useState(!1),[A,D]=i.useState(0),N=i.useRef(!1),B=i.useRef(""),T=i.useRef(null),E=Ee(L=>L.todoPanelHeight),_=Ee(L=>L.setTodoPanelHeight),R=Ee(L=>L.notesPanelHeight),V=Ee(L=>L.setNotesPanelHeight),[$,z]=i.useState(!1),F=i.useRef(0),te=i.useRef(E),ne=ut(L=>L.currentSessionId),q=ut(L=>L.createSession),H=ut(L=>L.initializeNewOpenChamberSession),X=ut(L=>L.sendMessage),oe=ut(L=>L.setCurrentSession),he=ci(L=>L.setPendingInputText),Se=Js(L=>L.currentDirectory),Z=Ee(L=>L.openContextPanelTab),ke=Ee(L=>L.setActiveMainTab),Y=Ee(L=>L.setSessionSwitcherOpen),ge=Ee(L=>L.padding),O=i.useCallback(async(L,ae)=>{if(!t)return!1;const re=t.id,Ge=(Go.get(re)??Promise.resolve()).catch(()=>{}).then(()=>Lp(t,{notes:L,todos:ae}));Go.set(re,Ge);try{const He=await Ge;return He||le.error(a("rightSidebar.contextNotesTodo.toast.saveNotesFailed")),He}finally{Go.get(re)===Ge&&Go.delete(re)}},[t,a]);i.useEffect(()=>{if(!t){u(""),f([]),w([]),y(""),h(new Set);return}let L=!1;return l(!0),(async()=>{try{const ae=await Op(t),re=await Promise.all(ae.plans.map(Oe=>Cy(Oe,a("rightSidebar.contextNotesTodo.plan.defaultTitle"))));if(L)return;u(ae.notes),f(uu(ae.todos)),w(re),B.current=ae.notes,N.current=!0,y(""),h(new Set)}catch{L||(le.error(a("rightSidebar.contextNotesTodo.toast.loadNotesFailed")),u(""),f([]),w([]),B.current="",N.current=!0)}finally{L||l(!1)}})(),()=>{L=!0}},[A,t,a]),i.useEffect(()=>{if(!t)return;const L=ae=>{const re=ae.detail;re?.projectId&&re.projectId!==t.id||D(Oe=>Oe+1)};return window.addEventListener("openchamber:project-plan-saved",L),window.addEventListener("openchamber:project-notes-updated",L),()=>{window.removeEventListener("openchamber:project-plan-saved",L),window.removeEventListener("openchamber:project-notes-updated",L)}},[t]),i.useEffect(()=>{if(m.length<7)return;const L=ky(m.length,ge),ae=la(ge)*ec;E!==L&&(E<ae||E>L)&&_(L)},[m.length,ge,E,_]),i.useEffect(()=>{if(!$)return;const L=re=>{const Oe=re.clientY-F.current,Ge=Math.min(la(ge)*Mm,Math.max(la(ge)*ec,te.current+Oe));_(Ge)},ae=()=>{z(!1)};return window.addEventListener("pointermove",L),window.addEventListener("pointerup",ae,{once:!0}),window.addEventListener("pointercancel",ae,{once:!0}),()=>{window.removeEventListener("pointermove",L),window.removeEventListener("pointerup",ae),window.removeEventListener("pointercancel",ae)}},[$,ge,_]);const se=i.useCallback(L=>{z(!0),F.current=L.clientY,te.current=E,L.preventDefault()},[E]),ee=i.useCallback(()=>{T.current!==null&&(window.clearTimeout(T.current),T.current=null)},[]),je=i.useCallback(()=>{ee(),B.current=d,O(d,m)},[ee,d,O,m]);i.useEffect(()=>{if(!(!t||!N.current)&&d!==B.current)return T.current=window.setTimeout(()=>{T.current=null,B.current=d,O(d,m)},400),()=>{ee()}},[ee,d,O,t,m]),i.useEffect(()=>()=>ee(),[ee]);const De=i.useCallback(()=>{const L=p.trim();if(!L)return;const ae=fu(m,{id:Ay(),text:L.slice(0,zo),completed:!1,createdAt:Date.now()});f(ae),y(""),O(d,ae)},[p,d,O,m]),Be=i.useCallback(L=>{h(ae=>{const re=new Set(ae);return re.has(L)?re.delete(L):re.add(L),re})},[]),Fe=i.useCallback((L,ae)=>{const re=m.find(Je=>Je.id===L);if(!re||re.completed===ae)return;const Oe=m.filter(Je=>Je.id!==L),Ge={...re,completed:ae},He=ae?[...Oe,Ge]:fu(Oe,Ge);f(He),O(d,He)},[d,O,m]),Me=i.useCallback(L=>{const ae=m.filter(re=>re.id!==L);f(ae),O(d,ae)},[d,O,m]),fe=i.useCallback(()=>{const L=m.filter(ae=>!ae.completed);L.length!==m.length&&(f(L),O(d,L))},[d,O,m]),Ae=i.useCallback(L=>{const{active:ae,over:re}=L;if(!re||ae.id===re.id)return;const Oe=m.findIndex(Je=>Je.id===ae.id),Ge=m.findIndex(Je=>Je.id===re.id);if(Oe===-1||Ge===-1)return;const He=uu(Lf(m,Oe,Ge));f(He),O(d,He)},[d,O,m]),pe=xa(yo(ba,{activationConstraint:{distance:8}})),ce=p.slice(0,zo),me=m.reduce((L,ae)=>L+(ae.completed?1:0),0),Ne=i.useCallback(()=>{ke("chat"),Y(!1)},[ke,Y]),ue=i.useCallback((L,ae)=>{!t||g||S({kind:"session",todoId:L,todoText:ae})},[t,g]),P=i.useCallback(L=>{if(!ne){le.error(a("rightSidebar.contextNotesTodo.toast.noActiveSession"));return}Ne();const ae=`\`\`\`md
|
|
4
4
|
${L}
|
|
5
5
|
\`\`\``;he(ae,"append"),le.success(a("rightSidebar.contextNotesTodo.toast.sentToCurrentSession")),r?.()},[ne,r,Ne,he,a]),M=i.useCallback((L,ae)=>{if(!(!t||g)){if(!n){le.error(a("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}S({kind:"worktree",todoId:L,todoText:ae})}},[n,t,g,a]),de=i.useCallback(async L=>{if(!t||!v)return;const ae=await Tn("plan.todo.visible",{todo_text:v.todoText}),Oe=[{synthetic:!0,text:await Tn("plan.todo.instructions",{todo_text:v.todoText})}];j(!0),b(v.todoId);try{Ne();let Ge=null,He=t.path;if(v.kind==="worktree"){if(!n){le.error(a("rightSidebar.contextNotesTodo.toast.worktreeRequiresGitRepo"));return}const rt=await Zf(t.path,em());if(!rt?.id)return;Ge=rt.id,He=rt.path}else{const rt=await q(void 0,t.path,null);if(!rt?.id){le.error(a("rightSidebar.contextNotesTodo.toast.createSessionFailed"));return}Ge=rt.id,He=rt.directory??t.path,H(rt.id,ss.getState().agents??[])}if(!Ge)return;const Je=Nc.getState();Je.saveSessionModelSelection(Ge,L.providerID,L.modelID),L.agent.trim()&&(Je.saveSessionAgentSelection(Ge,L.agent),Je.saveAgentModelForSession(Ge,L.agent,L.providerID,L.modelID),Je.saveAgentModelVariantForSession(Ge,L.agent,L.providerID,L.modelID,L.variant||void 0)),oe(Ge,He),await X(ae,L.providerID,L.modelID,L.agent.trim()||void 0,void 0,void 0,Oe,L.variant||void 0),le.success(v.kind==="worktree"?a("rightSidebar.contextNotesTodo.toast.sentToNewWorktreeSession"):a("rightSidebar.contextNotesTodo.toast.sentToNewSession")),S(null),r?.()}catch(Ge){const He=Ge instanceof Error?Ge.message:void 0;le.error(a("rightSidebar.contextNotesTodo.toast.sendTodoFailed"),He?{description:He}:void 0)}finally{j(!1),b(null)}},[n,q,H,r,v,t,Ne,X,oe,a]),xe=i.useRef(null),[U,be]=i.useState(!1),[ve,G]=i.useState(null),ye=i.useCallback(async L=>{if(!(!t||ve)){G(L);try{if(!await Bp(t,L)){le.error(a("rightSidebar.contextNotesTodo.toast.deletePlanFailed"));return}w(re=>re.filter(Oe=>Oe.id!==L)),window.dispatchEvent(new CustomEvent("openchamber:project-plan-saved",{detail:{projectId:t.id}}))}finally{G(null)}}},[ve,t,a]),Le=i.useCallback(async()=>{if(!t||U)return;const L=await mp({defaultPath:t.path,filters:[{name:"Plan files",extensions:["md","markdown","txt"]},{name:"All files",extensions:["*"]}]});if(L.success&&L.path){be(!0);try{const ae=new URLSearchParams({path:L.path,allowOutsideWorkspace:"true"});L.outsideFileGrant&&ae.set("outsideFileGrant",L.outsideFileGrant);const re=await As(`/api/fs/read?${ae.toString()}`,{cache:"no-store"});if(!re.ok){le.error(a("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"));return}const Oe=await re.text();if(!Oe.trim()){le.error(a("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const Ge=L.path.split("/").pop()?.replace(/\.(md|markdown|txt)$/i,"").trim()||"";if(!await Id(t,Oe,Ge)){le.error(a("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}window.dispatchEvent(new CustomEvent("openchamber:project-plan-saved",{detail:{projectId:t.id}})),le.success(a("rightSidebar.contextNotesTodo.toast.planImported"))}catch(ae){const re=ae instanceof Error?ae.message:void 0;le.error(a("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),re?{description:re}:void 0)}finally{be(!1)}}else L.error==="Native file picker not available"&&xe.current?.click()},[U,t,a]),Re=i.useCallback(async L=>{if(!(!t||!L)){be(!0);try{const ae=await L.text();if(!ae.trim()){le.error(a("rightSidebar.contextNotesTodo.toast.planFileEmpty"));return}const re=L.name.replace(/\.(md|markdown|txt)$/i,"").trim();if(!await Id(t,ae,re)){le.error(a("rightSidebar.contextNotesTodo.toast.importPlanFailed"));return}window.dispatchEvent(new CustomEvent("openchamber:project-plan-saved",{detail:{projectId:t.id}})),le.success(a("rightSidebar.contextNotesTodo.toast.planImported"))}catch(ae){const re=ae instanceof Error?ae.message:void 0;le.error(a("rightSidebar.contextNotesTodo.toast.readPlanFileFailed"),re?{description:re}:void 0)}finally{be(!1)}}},[t,a]),J=i.useCallback(L=>{const ae=t?.path?.trim(),re=Se?.trim()||ae;re&&Z(re,{mode:"plan",targetPath:L.path,dedupeKey:L.path,label:L.title})},[Se,Z,t]);return t?s.jsxs("div",{className:Pe("w-full min-w-0 space-y-3 p-3",o),children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h3",{className:"min-w-0 truncate typography-ui-label font-semibold text-foreground",title:t.path,children:a("rightSidebar.contextNotesTodo.notes.title",{project:e?.trim()||t.path.split("/").filter(Boolean).pop()||t.path})}),s.jsxs("span",{className:"typography-meta text-muted-foreground",children:[d.length,"/",Pd]})]}),s.jsx(ki,{value:d,onChange:L=>u(L.target.value.slice(0,Pd)),onBlur:je,placeholder:a("rightSidebar.contextNotesTodo.notes.placeholder"),resizedHeight:R,onResizeHeightChange:V,useScrollShadow:!0,scrollShadowSize:56,disabled:c})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"typography-ui-label font-semibold text-foreground",children:a("rightSidebar.contextNotesTodo.todo.title")}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:m.length===1?a("rightSidebar.contextNotesTodo.todo.itemsSingle",{count:m.length}):a("rightSidebar.contextNotesTodo.todo.itemsPlural",{count:m.length})}),s.jsx("button",{type:"button",onClick:fe,disabled:c||me===0,className:"typography-meta rounded-md px-1.5 py-0.5 text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",children:a("rightSidebar.contextNotesTodo.todo.clearCompleted")})]}),s.jsxs("span",{className:"typography-meta text-muted-foreground",children:[ce.length,"/",zo]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(vn,{value:ce,onChange:L=>y(L.target.value.slice(0,zo)),onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),De())},placeholder:a("rightSidebar.contextNotesTodo.todo.inputPlaceholder"),disabled:c,className:"h-8"}),s.jsx("button",{type:"button",onClick:De,disabled:c||ce.trim().length===0,className:"inline-flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("rightSidebar.contextNotesTodo.todo.addAria"),title:a("rightSidebar.contextNotesTodo.todo.addAria"),children:s.jsx(I,{name:"add",className:"h-4 w-4"})})]}),s.jsx("div",{className:Pe("overflow-y-auto rounded-lg border border-border/60 bg-background/40",$&&"transition-none"),style:m.length<7?void 0:{height:`${E}px`,maxHeight:`${E}px`},children:m.length===0?s.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:a("rightSidebar.contextNotesTodo.todo.empty")}):s.jsx(ya,{sensors:pe,collisionDetection:wa,onDragEnd:Ae,children:s.jsx($l,{items:m.map(L=>L.id),strategy:zl,children:s.jsx("ul",{className:"divide-y divide-border/50",children:m.map(L=>{const ae=x.has(L.id);return s.jsx(Dy,{id:L.id,children:re=>s.jsxs("div",{className:Pe("flex gap-1.5 px-2.5 py-1.5",ae?"items-start":"items-center"),children:[s.jsx("button",{type:"button",ref:re.setActivatorNodeRef,...re.attributes,...re.listeners,onClick:Oe=>{Oe.preventDefault(),Oe.stopPropagation()},className:"flex h-6 w-4 flex-shrink-0 touch-none items-center justify-center text-muted-foreground hover:text-foreground","aria-label":a("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:L.text}),title:a("rightSidebar.contextNotesTodo.todo.actions.reorder",{text:L.text}),children:s.jsx(I,{name:"draggable",className:"h-3.5 w-3.5"})}),s.jsx("div",{className:"flex h-6 items-center",children:s.jsx(Ti,{checked:L.completed,onChange:Oe=>Fe(L.id,Oe),ariaLabel:a("rightSidebar.contextNotesTodo.todo.actions.markComplete",{text:L.text})})}),s.jsx("button",{type:"button",onClick:()=>Be(L.id),className:Pe("block min-h-6 min-w-0 flex-1 bg-transparent p-0 text-left typography-ui-label leading-normal text-foreground",ae?"whitespace-normal break-words":"overflow-hidden text-ellipsis whitespace-nowrap","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",L.completed&&"text-muted-foreground line-through"),title:ae?void 0:L.text,"aria-label":ae?a("rightSidebar.contextNotesTodo.todo.actions.collapse",{text:L.text}):a("rightSidebar.contextNotesTodo.todo.actions.expand",{text:L.text}),children:L.text}),s.jsxs("div",{className:"flex h-6 items-center gap-0.5",children:[s.jsx("button",{type:"button",onClick:()=>Me(L.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":a("rightSidebar.contextNotesTodo.todo.actions.delete",{text:L.text}),title:a("rightSidebar.contextNotesTodo.todo.actions.delete",{text:L.text}),children:s.jsx(I,{name:"delete-bin",className:"h-3.5 w-3.5"})}),s.jsxs(sn,{children:[s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",disabled:g===L.id,className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("rightSidebar.contextNotesTodo.todo.actions.send",{text:L.text}),title:a("rightSidebar.contextNotesTodo.todo.actions.send",{text:L.text}),children:s.jsx(I,{name:"send-plane",className:"h-3.5 w-3.5"})})}),s.jsxs(tn,{align:"end",className:"w-56",children:[s.jsx(bs,{onClick:()=>P(L.text),children:a("rightSidebar.contextNotesTodo.todo.sendMenu.currentSession")}),s.jsx(bs,{onClick:()=>ue(L.id,L.text),children:a("rightSidebar.contextNotesTodo.todo.sendMenu.newSession")}),s.jsx(bs,{onClick:()=>{M(L.id,L.text)},disabled:!n,children:a("rightSidebar.contextNotesTodo.todo.sendMenu.newWorktreeSession")})]})]})]})]})},L.id)})})})})}),m.length>=7&&s.jsx("div",{className:Pe("h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors",$&&"bg-[var(--interactive-border)]"),onPointerDown:se,role:"separator","aria-orientation":"horizontal","aria-label":a("rightSidebar.contextNotesTodo.todo.resizeAria")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"typography-ui-label font-semibold text-foreground",children:a("rightSidebar.contextNotesTodo.plans.title")}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:C.length===1?a("rightSidebar.contextNotesTodo.plans.filesSingle",{count:C.length}):a("rightSidebar.contextNotesTodo.plans.filesPlural",{count:C.length})})]}),s.jsx("input",{ref:xe,type:"file",accept:".md,.markdown,.txt,text/markdown,text/plain",className:"hidden",onChange:L=>{const ae=L.target.files?.[0]??null;Re(ae),L.currentTarget.value=""}}),s.jsx("button",{type:"button",onClick:Le,disabled:!t||U,className:"inline-flex h-6 w-6 items-center justify-center rounded-md border border-border/70 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("rightSidebar.contextNotesTodo.plans.importFromFile"),title:a("rightSidebar.contextNotesTodo.plans.importFromFile"),children:s.jsx(I,{name:"add",className:"h-3.5 w-3.5"})})]}),s.jsx("div",{className:"max-h-56 overflow-y-auto rounded-lg border border-border/60 bg-background/40",children:C.length===0?s.jsx("p",{className:"px-3 py-3 typography-meta text-muted-foreground",children:a("rightSidebar.contextNotesTodo.plans.empty")}):s.jsx("ul",{className:"divide-y divide-border/50",children:C.map(L=>s.jsxs("li",{className:"flex items-center gap-1.5 px-2.5 py-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>J(L),className:"flex min-w-0 flex-1 items-center justify-between gap-3 rounded-md px-1.5 py-1 text-left hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-foreground",children:L.title}),s.jsx("span",{className:"flex-shrink-0 typography-micro text-muted-foreground",children:new Date(L.createdAt).toLocaleDateString(Xi())})]}),s.jsx("button",{type:"button",onClick:()=>{ye(L.id)},disabled:ve===L.id,className:"inline-flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed disabled:opacity-50",title:a("rightSidebar.contextNotesTodo.plans.deletePlan"),"aria-label":a("rightSidebar.contextNotesTodo.plans.deletePlanWithTitle",{title:L.title}),children:s.jsx(I,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},L.id))})})]}),s.jsx(Em,{open:v!==null,onOpenChange:L=>{!L&&!k&&S(null)},target:v?.kind??"session",projectDirectory:t?.path??null,submitting:k,onConfirm:de})]}):s.jsx("div",{className:Pe("w-full min-w-0 p-3",o),children:s.jsx("p",{className:"typography-meta text-muted-foreground",children:a("rightSidebar.contextNotesTodo.empty.selectProject")})})},Fm=12,Py=[{id:"left",x:22,y:58,delay:0,radius:120,colorVar:"--status-success"},{id:"center",x:50,y:42,delay:120,radius:150,colorVar:"--primary-base"},{id:"right",x:78,y:55,delay:200,radius:130,colorVar:"--status-info"}],Ty=t=>{const e=mt.c(18),{isActive:n,burstKey:r,className:o,durationMs:a,bursts:c,onComplete:l}=t,d=r===void 0?0:r,u=a===void 0?900:a,m=c===void 0?Py:c,f=Xe.useRef(!1);let p,y;e[0]!==n||e[1]!==l?(p=()=>{!n&&f.current&&l?.(),n&&(f.current=!0)},y=[n,l],e[0]=n,e[1]=l,e[2]=p,e[3]=y):(p=e[2],y=e[3]),Xe.useEffect(p,y);let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=Array.from({length:Fm},Ry),e[4]=g):g=e[4];const b=g;if(!n)return null;let x;e[5]!==o?(x=Pe("fireworks-overlay pointer-events-none",o),e[5]=o,e[6]=x):x=e[6];let h;if(e[7]!==d||e[8]!==m||e[9]!==u){let w;e[11]!==d||e[12]!==u?(w=v=>{const S={"--burst-delay":`${v.delay}ms`,"--burst-x":`${v.x}%`,"--burst-y":`${v.y}%`,"--firework-color":`var(${v.colorVar})`,"--firework-duration":`${u}ms`};return s.jsx("div",{className:"firework-burst",style:S,children:b.map((k,j)=>{const A=k.x*v.radius,D=k.y*v.radius,N={"--translate-x":`${A}px`,"--translate-y":`${D}px`,"--particle-delay":`${k.delay}ms`,color:`var(${v.colorVar})`};return s.jsx("span",{className:"firework-particle",style:N},`${v.id}-${j}-${d}`)})},`${v.id}-${d}`)},e[11]=d,e[12]=u,e[13]=w):w=e[13],h=m.map(w),e[7]=d,e[8]=m,e[9]=u,e[10]=h}else h=e[10];let C;return e[14]!==d||e[15]!==x||e[16]!==h?(C=s.jsx("div",{className:x,"aria-hidden":"true","data-burst-key":d,children:h}),e[14]=d,e[15]=x,e[16]=h,e[17]=C):C=e[17],C};function Ry(t,e){const n=Math.PI*2*e/Fm;return{x:Math.cos(n),y:Math.sin(n),delay:e*18}}const Ey=t=>{const e=mt.c(13);let n;e[0]!==t?(n={},e[0]=t,e[1]=n):n=e[1];const{durationMs:r}=n,o=r===void 0?3400:r;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a={isActive:!1,cycle:0},e[2]=a):a=e[2];const[c,l]=Xe.useState(a),d=Xe.useRef(null);let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},e[3]=u):u=e[3];const m=u;let f;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{m(),l(My)},e[4]=f):f=e[4];const p=f;let y;e[5]!==o?(y=()=>{m(),l(Fy),d.current=window.setTimeout(()=>{l(Ly),d.current=null},o)},e[5]=o,e[6]=y):y=e[6];const g=y;let b,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=()=>()=>m(),x=[m],e[7]=b,e[8]=x):(b=e[7],x=e[8]),Xe.useEffect(b,x);let h;return e[9]!==c.cycle||e[10]!==c.isActive||e[11]!==g?(h={isActive:c.isActive,burstKey:c.cycle,triggerFireworks:g,dismissFireworks:p},e[9]=c.cycle,e[10]=c.isActive,e[11]=g,e[12]=h):h=e[12],h};function My(t){return t.isActive?{...t,isActive:!1}:t}function Fy(t){return{isActive:!0,cycle:t.cycle+1}}function Ly(t){return t.isActive?{...t,isActive:!1}:t}const Lm=i.createContext(void 0),Oy=t=>{const e=mt.c(10),{children:n}=t,{isActive:r,burstKey:o,triggerFireworks:a,dismissFireworks:c}=Ey();let l;e[0]!==c||e[1]!==a?(l={triggerFireworks:a,dismissFireworks:c},e[0]=c,e[1]=a,e[2]=l):l=e[2];const d=l;let u;e[3]!==o||e[4]!==r?(u=s.jsx(Ty,{isActive:r,burstKey:o}),e[3]=o,e[4]=r,e[5]=u):u=e[5];let m;return e[6]!==n||e[7]!==u||e[8]!==d?(m=s.jsxs(Lm.Provider,{value:d,children:[n,u]}),e[6]=n,e[7]=u,e[8]=d,e[9]=m):m=e[9],m},By=()=>{const t=i.useContext(Lm);if(!t)throw new Error("useFireworksCelebration must be used within FireworksProvider");return t},Om="gitmojiCache",_y=1e3*60*60*24*7,Bm="1",Vy="https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json",_m=t=>{if(!t||typeof t!="object")return!1;const e=t;return typeof e.emoji=="string"&&typeof e.code=="string"&&typeof e.description=="string"},bl=()=>{if(typeof window>"u")return null;try{const t=window.localStorage.getItem(Om);if(!t)return null;const e=JSON.parse(t);return!e||e.version!==Bm||typeof e.fetchedAt!="number"||!Array.isArray(e.gitmojis)?null:{gitmojis:e.gitmojis.filter(_m),fetchedAt:e.fetchedAt,version:e.version}}catch{return null}},$y=t=>{if(!(typeof window>"u"))try{const e={gitmojis:t,fetchedAt:Date.now(),version:Bm};window.localStorage.setItem(Om,JSON.stringify(e))}catch{return}},mu=t=>Date.now()-t.fetchedAt<_y;let Ko=null;const So=new Set,hu=async()=>{if(Ko)return Ko;const t=(async()=>{try{const e=await fetch(Vy);if(!e.ok)throw new Error(`Failed to load gitmojis: ${e.statusText}`);const n=await e.json(),r=Array.isArray(n.gitmojis)?n.gitmojis.filter(_m):[];return $y(r),So.forEach(o=>o(r)),r}catch(e){console.warn("Failed to load gitmoji list:",e);const n=[];return So.forEach(r=>r(n)),n}finally{Ko=null}})();return Ko=t,t},zy=t=>{const[e,n]=i.useState(()=>t?bl()?.gitmojis??[]:[]),[r,o]=i.useState(!1),a=i.useRef(t);a.current=t,i.useEffect(()=>{if(!t){So.delete(n),n([]),o(!1);return}const l=bl();if(l&&(n(l.gitmojis),mu(l)))return;So.add(n),o(!0);let d=!1;return hu().finally(()=>{!d&&a.current&&o(!1)}),()=>{d=!0,So.delete(n)}},[t]);const c=i.useCallback(async()=>{if(!a.current)return[];if(e.length>0)return e;const l=bl();return l&&mu(l)?l.gitmojis:hu()},[e]);return{gitmojis:e,isLoading:r,ensureLoaded:c}},pu=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")};function Uy(t,e,n){const r=mt.c(5),[o,a]=i.useState();let c,l;return r[0]!==n||r[1]!==t||r[2]!==e?(c=()=>{if(e){a(void 0);return}if(!t){a(void 0);return}a(void 0);let d=!1;return(async()=>{const[u,m]=await Promise.all([Vp(t),$p(t)]).catch(Wy);if(d)return;const f=pu(u),p=pu(m);if(!f||!p||p===f)return;const y=n||"",g=p.split("/").filter(Boolean).pop()||p;a({source:"sdk",path:p,projectDirectory:f,branch:y,label:y||g,name:g,worktreeRoot:p,worktreeStatus:"ready",headState:y?"branch":"unborn",worktreeSource:"existing"})})(),()=>{d=!0}},l=[t,e,n],r[0]=n,r[1]=t,r[2]=e,r[3]=c,r[4]=l):(c=r[3],l=r[4]),i.useEffect(c,l),e??o}function Wy(){return["",""]}const ao=async(t,e)=>{const n=await As(`/api/git/integrate/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>null);throw new Error(r?.error||`Git integrate request failed: ${n.statusText}`)}return n.json()};async function ho(t){return ao("plan",t)}async function Hy(t){return ao("conflict-details",{tempWorktreePath:t})}async function Gy(t){return(await ao("cherry-pick-status",{tempWorktreePath:t})).inProgress}async function Ky(t){return ao("run",{plan:t})}async function qy(t){await ao("abort",{state:t})}async function Yy(t){return ao("continue",{state:t})}const Qy=({repoRoot:t,sourceBranch:e,worktreeMetadata:n,localBranches:r,defaultTargetBranch:o,refreshKey:a,onRefresh:c})=>{const{t:l}=Nt(),d=ut(F=>F.currentSessionId),u=Ee(F=>F.setActiveMainTab),[m,f]=Xe.useState(!1),p=Xe.useRef(null),[y,g]=Xe.useState(o);Xe.useEffect(()=>{g(o)},[o]),Xe.useEffect(()=>{if(m){const F=setTimeout(()=>{p.current?.focus()},0);return()=>clearTimeout(F)}},[m]);const b=!!(t&&e&&y&&y!=="HEAD"&&e!==y),[x,h]=Xe.useState({kind:"idle"}),[C,w]=Xe.useState(!1),[v,S]=Xe.useState([]),k=Xe.useMemo(()=>d?`openchamber.integrate.conflict:${d}`:null,[d]);Xe.useEffect(()=>{if(!k||typeof window>"u")return;const F=window.localStorage.getItem(k);if(!F)return;let te=!1;try{const ne=JSON.parse(F);if(!ne?.tempWorktreePath||ne.repoRoot!==t){window.localStorage.removeItem(k);return}(async()=>{const q=await Gy(ne.tempWorktreePath).catch(()=>!1);if(te)return;if(!q){window.localStorage.removeItem(k);return}const H=await Hy(ne.tempWorktreePath).catch(()=>null);te||H&&h({kind:"conflict",state:ne,details:H})})()}catch{window.localStorage.removeItem(k)}return()=>{te=!0}},[k,t]),Xe.useEffect(()=>{if(!b){h({kind:"idle"});return}let F=!1;return h({kind:"loading"}),(async()=>{try{const te=await ho({repoRoot:t,sourceBranch:e,targetBranch:y});if(F)return;if(h({kind:"ready",plan:te}),te.commits.length>0){const q=te.commits.slice(-50).reverse(),H=await zp(t,q);F||(S(H),w(!1))}else F||(S([]),w(!1))}catch{F||h({kind:"idle"})}})(),()=>{F=!0}},[b,t,e,y,a]);const j=Xe.useCallback(F=>{d&&ut.getState().setWorktreeMetadata(d,{...n,createdFromBranch:F})},[d,n]),A=ut(F=>F.openNewSessionDraft),D=Xe.useCallback(async F=>{const te=await Tn("git.integrate.cherrypick.resolve.visible",{current_commit:F.state.currentCommit,target_branch:F.state.targetBranch}),ne=await Tn("git.integrate.cherrypick.resolve.instructions",{repo_root:F.state.repoRoot,temp_worktree_path:F.state.tempWorktreePath,source_branch:F.state.sourceBranch,target_branch:F.state.targetBranch,current_commit:F.state.currentCommit}),q=`Cherry-pick conflict context (JSON)
|
|
@@ -210,5 +210,5 @@ ${e.trim()}
|
|
|
210
210
|
Now write the final fused answer.`,synthetic:!0}],directory:te??_n.getDirectory()})}catch(z){console.error("[MultiRunFusion] Failed to start fusion",z),le.error(r("multirun.fusion.toast.failed"))}finally{A(!1)}}};return s.jsx($s,{open:e,onOpenChange:n,children:s.jsxs(Vs,{className:"max-w-xl overflow-visible",children:[s.jsxs(Hs,{children:[s.jsx(Ws,{children:r("multirun.fusion.title")}),s.jsx(on,{children:r("multirun.fusion.description")})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("div",{className:"max-w-full",children:s.jsx(jh,{selectedModels:b,onAdd:R,onUpdate:(z,F)=>R(F),onRemove:()=>{x([]),p(""),g(""),C("")},maxModels:1,addButtonLabel:V,showChips:!1,addButtonClassName:"h-8 w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5",dropdownSide:"bottom",dropdownClassName:"w-[min(28rem,calc(100vw-8rem))]",triggerIcon:f?s.jsx(Do,{providerId:f,className:"h-3.5 w-3.5 mr-1"}):void 0})}),E.length>0?s.jsxs($n,{value:h||"__default__",onValueChange:z=>C(z==="__default__"?"":z),children:[s.jsxs(zn,{size:"lg",className:"h-8 w-fit rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 typography-meta font-medium text-foreground px-3 py-1.5",children:[s.jsx(I,{name:"brain-ai-3",className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Nn,{children:z=>z==="__default__"?r("multirun.modelMultiSelect.variant.default"):z})]}),s.jsxs(Un,{fitContent:!0,portalToBody:!0,children:[s.jsx(Ls,{value:"__default__",children:r("multirun.modelMultiSelect.variant.default")}),E.map(z=>s.jsx(Ls,{value:z,children:z},z))]})]}):null,s.jsx(wh,{value:w,onChange:v,portalToBody:!0,className:"h-8 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"typography-meta font-medium text-foreground",children:r("multirun.fusion.sources.label",{count:S.length})}),s.jsx("div",{className:"max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1",children:S.map(z=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta",children:[s.jsx(Do,{providerId:pa(z.session.title)?.providerID??"",className:"h-4 w-4"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:z.session.title||z.session.id}),s.jsx("button",{type:"button",onClick:()=>k(F=>F.filter(te=>te.session.id!==z.session.id)),className:"text-muted-foreground hover:text-foreground",children:s.jsx(I,{name:"close",className:"h-4 w-4"})})]},z.session.id))})]}),s.jsxs(ir,{children:[s.jsx($e,{variant:"ghost",onClick:()=>n(!1),children:r("multirun.fusion.actions.cancel")}),s.jsx($e,{onClick:$,disabled:!_,children:r(j?"multirun.fusion.actions.starting":"multirun.fusion.actions.start")})]})]})})}function B2(t){const e=mt.c(7);let n,r,o,a,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("path",{d:"M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),r=s.jsx("path",{d:"M9.25 7.25 12 4.5l2.75 2.75",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round"}),o=s.jsx("circle",{cx:"4",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),a=s.jsx("circle",{cx:"12",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),c=s.jsx("circle",{cx:"20",cy:"17.25",r:"1.55",stroke:"currentColor",strokeWidth:"1.65"}),e[0]=n,e[1]=r,e[2]=o,e[3]=a,e[4]=c):(n=e[0],r=e[1],o=e[2],a=e[3],c=e[4]);let l;return e[5]!==t?(l=s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",...t,children:[n,r,o,a,c]}),e[5]=t,e[6]=l):l=e[6],l}const _2=i.memo(function(e){const n=mt.c(22),{archiveLabel:r,deleteLabel:o,buttonSizeClass:a,iconSizeClass:c,onPointerDown:l,onMouseDown:d,onArchive:u,onDelete:m}=e,f=b2(),p=f?o:r;let y;n[0]!==u||n[1]!==m||n[2]!==f?(y=k=>{if(f||k.shiftKey){m(k);return}u(k)},n[0]=u,n[1]=m,n[2]=f,n[3]=y):y=n[3];const g=y,b=f?"text-destructive hover:text-destructive":"text-muted-foreground hover:text-foreground";let x;n[4]!==a||n[5]!==b?(x=Pe("inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",b,a),n[4]=a,n[5]=b,n[6]=x):x=n[6];const h=f?"delete-bin":"archive";let C;n[7]!==c||n[8]!==h?(C=s.jsx(I,{name:h,className:c}),n[7]=c,n[8]=h,n[9]=C):C=n[9];let w;n[10]!==g||n[11]!==p||n[12]!==d||n[13]!==l||n[14]!==x||n[15]!==C?(w=s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",className:x,"aria-label":p,onPointerDown:l,onMouseDown:d,onClick:g,onKeyDown:G2,children:C})}),n[10]=g,n[11]=p,n[12]=d,n[13]=l,n[14]=x,n[15]=C,n[16]=w):w=n[16];let v;n[17]!==p?(v=s.jsx(Ft,{side:"left",sideOffset:8,children:p}),n[17]=p,n[18]=v):v=n[18];let S;return n[19]!==w||n[20]!==v?(S=s.jsxs(Et,{children:[w,v]}),n[19]=w,n[20]=v,n[21]=S):S=n[21],S});function V2(t){const{t:e}=Nt(),{node:n,depth:r=0,groupDirectory:o,projectId:a,archivedBucket:c=!1,currentSessionId:l,pinnedSessionIds:d,expandedParents:u,hasSessionSearchQuery:m,normalizedSessionSearchQuery:f,notifyOnSubtasks:p,editingId:y,setEditingId:g,editTitle:b,setEditTitle:x,handleSaveEdit:h,handleCancelEdit:C,toggleParent:w,handleSessionSelect:v,handleSessionDoubleClick:S,togglePinnedSession:k,handleShareSession:j,copiedSessionId:A,handleCopyShareUrl:D,handleUnshareSession:N,openSidebarMenuKey:B,setOpenSidebarMenuKey:T,renamingFolderId:E,getFoldersForScope:_,getSessionFolderId:R,removeSessionFromFolder:V,addSessionToFolder:$,createFolderAndStartRename:z,openContextPanelTab:F,handleDeleteSession:te,mobileVariant:ne,alwaysShowActions:q,renderSessionNode:H,secondaryMeta:X,renderContext:oe="project",subtreeContainsActive:he,subtreeContainsEditing:Se,menuOpenSessionId:Z,childRenderExtrasFor:ke,liveSessionById:Y}=t,ge=!!X?.projectLabel,O=!!X?.branchLabel,se=Dr(We=>We.displayMode),ee=i.useMemo(()=>Gr(),[]),je=se==="minimal"||ee,De=i.useMemo(()=>Oa(),[]),Be=i.useContext(Lg),Fe=ee?"group-hover:opacity-100 group-hover:pointer-events-auto":"group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto",Me=ee?"group-hover:opacity-0":"group-hover:opacity-0 group-focus-within:opacity-0",fe=ee,Ae=!c&&!ne,pe=je?ee?Ae&&fe?"group-hover:pr-18":Ae||fe?"group-hover:pr-14":"group-hover:pr-8":"group-hover:pr-2 group-focus-within:pr-2":ee?Ae&&fe?"group-hover:pr-18":Ae||fe?"group-hover:pr-12":"group-hover:pr-5":Ae?"group-hover:pr-12 group-focus-within:pr-12":"group-hover:pr-5 group-focus-within:pr-5",ce=Ae?"pr-13":"pr-7",me=i.useRef(!1),[Ne,ue]=i.useState(!1),P=i.useRef(y);P.current=y;const M=i.useRef(null),de=i.useRef(h);de.current=h;const[xe,U]=i.useState(b),be=i.useRef(xe);be.current=xe;const ve=i.useRef(null),G=i.useRef(null),ye=n.session,Le=Y.get(ye.id)??ye,Re=cs(ye.directory??null)??cs(o??null),J=om(Re??void 0,{bootstrap:!c}),L=Ec(),ae=Bn(We=>We.enabled),re=Bn(i.useCallback(We=>We.selectedIds.has(ye.id),[ye.id])),Oe=Bn(We=>We.toggleSelected),Ge=Bn(We=>We.setRange),He=i.useCallback(We=>{const os=[],fs=zs=>{zs.children.forEach(Ks=>{os.push(Ks.session.id),fs(Ks)})};return fs(We),os},[]),[Je,rt]=i.useState(!1),[bt,yt]=i.useState(!0),Ve=`${oe}:${c?"archived":"active"}:${ye.id}`,Ye=mm(i.useCallback(We=>!!We.sessionMemoryState.get(Og(ye.id))?.isZombie,[ye.id])),nt=Bg(ye.id),vt=_g(ye.id,Re??void 0),kt=l===ye.id,wt=Le.title||e("sessions.sidebar.session.untitled"),St=n.children.length>0,et=d.has(ye.id),Ot=Ve,ns=m?!0:u.has(Ot),Ut=!!Le.parentID,Ze=Vg(ye.id)>0&&(!Ut||p),Vt=Le.time?.updated||Le.time?.created||Date.now(),jt=mb(Vt),xt=hb(Vt),rs=B===Ve,[Gt,Wt]=i.useState(!1),as=rs||Gt,Bt=i.useMemo(()=>pa(Le.title)!==null,[Le.title]),[Lt,_t]=i.useState(!1),Kt=ee&&oe==="recent"&&!je,Xt=ee&&oe==="recent"&&je,Qt=i.useMemo(()=>He(n).length,[He,n]),vs=i.useCallback(async We=>{const os=[];let fs=0;for(const zs of We)try{await L.ensureSessionRenderable(zs.session.id);const Ks=Vd(J.getState(),zs.session.id).list,Us=zs.session.title||e("sessions.sidebar.session.export.untitledSubagent"),pn=zs.session.agent,Ns=await vs(zs.children);fs+=Ns.skipped,os.push({title:Us,agent:pn,records:Ks,children:Ns.children})}catch{fs+=He(zs).length+1}return{children:os,skipped:fs}},[He,J,L,e]),Dt=i.useCallback(We=>{We<=0||le.warning(We===1?e("sessions.sidebar.session.export.skippedSubtaskSingle",{count:We}):e("sessions.sidebar.session.export.skippedSubtaskMany",{count:We}))},[e]),$t=i.useCallback(async We=>{if(!Re){le.error(e("sessions.sidebar.session.export.nothingToExport"));return}await L.ensureSessionRenderable(ye.id);const os=Vd(J.getState(),ye.id).list;if(os.length===0){le.error(e("sessions.sidebar.session.export.nothingToExport"));return}let fs,zs=0;if(We&&n.children.length>0){const Ns=await vs(n.children);fs=Ns.children,zs=Ns.skipped}const Ks=n2(os,Le.title??null,fs),Us=l2(Le.title??null),pn=await i2(Ks,Us);if(pn){le.success(e("sessions.sidebar.session.export.success"),{action:{label:e(a2()),onClick:()=>{o2(pn).then(Ns=>{Ns||le.error(e("sessions.sidebar.session.export.failedRevealPath"))})}}}),Dt(zs);return}r2(Ks,Us),le.success(e("sessions.sidebar.session.export.success")),Dt(zs)},[vs,J,n.children,Le.title,ye.id,Re,Dt,L,e]),Ct=i.useCallback(async()=>{if(n.children.length>0){yt(!0),rt(!0);return}await $t(!1)},[$t,n.children.length]),ds=i.useCallback(()=>{Re&&Wr("desktop_open_session_mini_chat_window",{sessionId:ye.id,directory:Re,apiBaseUrl:Ur(),clientToken:Hl()}).catch(We=>{console.warn("[session-sidebar] failed to open mini chat window",We)})},[ye.id,Re]);if(i.useEffect(()=>{if(y!==ye.id)return;const We=os=>{G.current&&!G.current.contains(os.target)&&de.current(be.current)};return document.addEventListener("mousedown",We),()=>document.removeEventListener("mousedown",We)},[y,ye.id]),i.useLayoutEffect(()=>{if(y!==ye.id){ve.current===ye.id&&(ve.current=null);return}ve.current!==ye.id&&(ve.current=ye.id,U(b))},[y,b,ye.id]),y===ye.id)return s.jsx("div",{className:Pe("group relative flex items-center rounded-sm px-1.5 py-1",r>0&&"pl-[20px]"),children:s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0",children:[s.jsxs("form",{ref:G,className:"flex w-full items-center gap-2",onSubmit:We=>{We.preventDefault(),h(xe)},children:[s.jsx("input",{value:xe,onChange:We=>U(We.target.value),className:"flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground",autoFocus:!0,placeholder:e("sessions.sidebar.session.menu.rename"),onKeyDown:We=>{if(We.stopPropagation(),We.key==="Escape"){C();return}}}),s.jsx("button",{type:"submit","aria-label":e("sessions.sidebar.session.rename.save"),title:e("sessions.sidebar.session.rename.save"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(I,{name:"check",className:"size-4"})}),s.jsx("button",{type:"button",onClick:C,"aria-label":e("sessions.sidebar.session.rename.cancel"),title:e("sessions.sidebar.session.rename.cancel"),className:"shrink-0 text-muted-foreground hover:text-foreground",children:s.jsx(I,{name:"close",className:"size-4"})})]}),je?null:s.jsx("div",{className:"flex items-center justify-between gap-3 text-muted-foreground/60 min-w-0 overflow-hidden leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 overflow-hidden",children:[St?s.jsx("span",{className:"inline-flex items-center justify-center flex-shrink-0",children:ns?s.jsx(I,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(I,{name:"arrow-right-s",className:"h-3 w-3"})}):null,s.jsx("span",{className:"flex-shrink-0",children:jt}),ge?s.jsx("span",{className:"truncate",children:X?.projectLabel}):null,O?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(I,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:X?.branchLabel})]}):null]})})]})},ye.id);const qe=nt?.type??"idle",at=qe==="busy"||qe==="retry",Qe=vt.length,Tt=at||!at&&Ze&&!kt,ts=at?s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse","aria-label":e("sessions.sidebar.session.status.active"),title:e("sessions.sidebar.session.status.active")}):s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--status-info)]","aria-label":e("sessions.sidebar.session.status.unread"),title:e("sessions.sidebar.session.status.unread")}),xs=!q&&St&&(Tt||et),ks=et&&!Tt,Jt=s.jsx(I,{name:"pushpin",className:"h-3 w-3 flex-shrink-0 text-primary","aria-label":e("sessions.sidebar.session.status.pinned")}),ls=Tt||ks?s.jsxs("span",{className:Pe("pointer-events-none absolute left-0.5 inline-flex h-3.5 w-3.5 items-center justify-center transition-opacity",je?"top-1/2 -translate-y-1/2":"top-[14.5px] -translate-y-1/2",xs?"opacity-100 group-hover:opacity-0 group-focus-within:opacity-0":""),children:[Tt?ts:null,ks?Jt:null]}):null,Ps=St&&!q&&(Tt||et),Ts=St?s.jsx("span",{role:"button",tabIndex:0,onClick:We=>{We.stopPropagation(),w(Ot)},onKeyDown:We=>{(We.key==="Enter"||We.key===" ")&&(We.preventDefault(),We.stopPropagation(),w(Ot))},style:{minWidth:14,minHeight:14},className:Pe("inline-flex h-3.5 w-3.5 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",Kt?"absolute left-1.5 bottom-1":Xt?"relative mr-0.5 shrink-0":Pe("absolute left-0.5",je?"top-1/2 -translate-y-1/2":"top-[14.5px] -translate-y-1/2"),!Kt&&!Xt&&Ps?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto":""),"aria-label":e(ns?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),children:ns?s.jsx(I,{name:"arrow-down-s",className:"h-3 w-3"}):s.jsx(I,{name:"arrow-right-s",className:"h-3 w-3"})}):null,hn=Ye?s.jsx(I,{name:"error-warning",className:"h-4 w-4 text-status-warning"}):null,Gs=We=>{We&&Wt(!1),T(We?Ve:null)},an=We=>{if(!We&&M.current){const{id:os,title:fs}=M.current;M.current=null,g(os),x(fs)}},Rn=We=>{Wt(We)},Os=We=>{We.preventDefault(),We.stopPropagation(),T(rs?null:Ve)},we=We=>{We.preventDefault(),We.stopPropagation()},tt=We=>{We.preventDefault(),We.stopPropagation()},dt=We=>{We.preventDefault(),We.stopPropagation()},It=We=>{We.preventDefault(),We.stopPropagation()},Ht=We=>{We.preventDefault(),We.stopPropagation(),T(null),te(ye,{archivedBucket:c})},ht=We=>{We.preventDefault(),We.stopPropagation(),T(null),te(ye,{archivedBucket:c,hardDelete:!0,skipConfirm:!0})},hs=We=>{We.preventDefault(),We.stopPropagation()},ps=We=>{We.preventDefault(),We.stopPropagation()},js=We=>{We.preventDefault(),We.stopPropagation(),Be?.vscode?.executeCommand("openchamber.openSessionInEditor",ye.id,wt)},Ss=We=>{if(me.current){me.current=!1;return}if(ae){if(We?.preventDefault(),We?.stopPropagation(),We?.shiftKey){const fs=(typeof document<"u"?Array.from(document.querySelectorAll("[data-session-row]")):[]).map(Us=>Us.getAttribute("data-session-row")).filter(Us=>typeof Us=="string"&&Us.length>0),zs=Bn.getState().anchorId,Ks=new Map;Ks.set(ye.id,He(n)),Ge(zs,ye.id,fs,Re??null,Ks);return}Oe(ye.id,Re??null,He(n));return}v(ye.id,Re,a)},Ds=We=>{(We.button===2||We.button===0&&We.ctrlKey&&!ae)&&(me.current=!0)},Wn=We=>{ne&&We.pointerType==="touch"&&ue(!0)},Es=We=>{ne&&We.pointerType==="touch"&&ue(!1)},En=({Item:We,Separator:os,Sub:fs,SubTrigger:zs,SubContent:Ks})=>s.jsxs(s.Fragment,{children:[s.jsxs(We,{onClick:()=>{M.current={id:ye.id,title:wt}},className:"[&>svg]:mr-1",children:[s.jsx(I,{name:"pencil-ai",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.rename")]}),s.jsxs(We,{onClick:()=>k(ye.id),className:"[&>svg]:mr-1",children:[et?s.jsx(I,{name:"unpin",className:"mr-1 h-4 w-4"}):s.jsx(I,{name:"pushpin",className:"mr-1 h-4 w-4"}),e(et?"sessions.sidebar.session.menu.unpin":"sessions.sidebar.session.menu.pin")]}),Le.share?s.jsxs(s.Fragment,{children:[s.jsx(We,{onClick:()=>{Le.share?.url&&D(Le.share.url,ye.id)},className:"[&>svg]:mr-1",children:A===ye.id?s.jsxs(s.Fragment,{children:[s.jsx(I,{name:"check",className:"mr-1 h-4 w-4",style:{color:"var(--status-success)"}}),e("sessions.sidebar.session.menu.copied")]}):s.jsxs(s.Fragment,{children:[s.jsx(I,{name:"file-copy",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.copyLink")]})}),s.jsxs(We,{onClick:()=>N(ye.id),className:"[&>svg]:mr-1",children:[s.jsx(I,{name:"link-unlink-m",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.unshare")]})]}):s.jsxs(We,{onClick:()=>j(Le),className:"[&>svg]:mr-1",children:[s.jsx(I,{name:"share-2",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.share")]}),s.jsxs(We,{onClick:()=>{Ct()},className:"[&>svg]:mr-1",children:[s.jsx(I,{name:"download",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.exportMarkdown")]}),Bt?s.jsxs(We,{onClick:()=>_t(!0),className:"[&>svg]:mr-1",children:[s.jsx(B2,{className:"mr-1 h-4 w-4"}),e("sessions.sidebar.session.menu.runFusion")]}):null,Re&&!c?(()=>{const Us=_(Re),pn=R(Re,ye.id);return s.jsxs(s.Fragment,{children:[s.jsx(os,{}),s.jsxs(fs,{children:[s.jsxs(zs,{className:"[&>svg]:mr-1",children:[s.jsx(I,{name:"folder",className:"h-4 w-4"}),e("sessions.sidebar.folders.moveToFolder")]}),s.jsxs(Ks,{className:"min-w-[180px]",children:[Us.length===0?s.jsx(We,{disabled:!0,className:"text-muted-foreground",children:e("sessions.sidebar.folders.none")}):Us.map(Ns=>s.jsxs(We,{onClick:()=>{pn===Ns.id?V(Re,ye.id):$(Re,Ns.id,ye.id)},children:[s.jsx("span",{className:"flex-1 truncate",children:Ns.name}),pn===Ns.id?s.jsx(I,{name:"check",className:"ml-2 h-3.5 w-3.5 text-primary flex-shrink-0"}):null]},Ns.id)),s.jsx(os,{}),s.jsxs(We,{onClick:()=>{const Ns=z(Re);Ns&&$(Re,Ns.id,ye.id)},children:[s.jsx(I,{name:"add",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.newFolderEllipsis")]}),pn?s.jsxs(We,{onClick:()=>{V(Re,ye.id)},className:"text-destructive focus:text-destructive",children:[s.jsx(I,{name:"close",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.folders.removeFromFolder")]}):null]})]})]})})():null,ee?null:s.jsxs(We,{disabled:!Re,onClick:()=>{Re&&F(Re,{mode:"chat",dedupeKey:`session:${ye.id}`,label:wt,sessionTitleFallback:wt})},className:"[&>svg]:mr-1",children:[s.jsx(I,{name:"chat-4",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openInSidePanel")}),s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:e("sessions.sidebar.session.menu.betaBadge")})]}),De?s.jsxs(We,{disabled:!Re,onClick:ds,className:"[&>svg]:mr-1",children:[s.jsx(I,{name:"window",className:"mr-1 h-4 w-4"}),s.jsx("span",{className:"truncate",children:e("sessions.sidebar.session.menu.openMiniChatWindow")})]}):null,s.jsx(os,{}),c?null:s.jsxs(We,{className:"[&>svg]:mr-1",onClick:()=>te(ye,{archivedBucket:c}),children:[s.jsx(I,{name:"inbox-archive",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.archive")]}),s.jsxs(We,{className:"text-destructive focus:text-destructive [&>svg]:mr-1",onClick:()=>te(ye,{archivedBucket:c,hardDelete:!0}),children:[s.jsx(I,{name:"delete-bin",className:"mr-1 h-4 w-4"}),e("sessions.sidebar.bulkActions.delete")]})]}),Hn=s.jsx(tn,{align:"end",className:"min-w-[180px]",finalFocus:()=>!(E||P.current),children:En({Item:bs,Separator:Rr,Sub:Wg,SubTrigger:Hg,SubContent:Gg})}),Xn=s.jsx(md,{children:s.jsx(hd,{className:"app-region-no-drag z-50",children:s.jsx(pd,{"data-slot":"dropdown-menu-content",finalFocus:()=>!(E||P.current),style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Pe($d,"min-w-[180px]"),children:En({Item:({className:We,...os})=>s.jsx(np,{className:Pe($g,We),...os}),Separator:({className:We,...os})=>s.jsx(rp,{className:Pe(zg,We),...os}),Sub:ip,SubTrigger:({className:We,children:os,...fs})=>s.jsxs(op,{className:Pe(Ug,We),...fs,children:[os,s.jsx(I,{name:"arrow-right-s",className:"ml-auto size-3.5"})]}),SubContent:({className:We,children:os,...fs})=>s.jsx(md,{children:s.jsx(hd,{className:"app-region-no-drag z-50",children:s.jsx(pd,{"data-slot":"dropdown-menu-sub-content",style:{backgroundColor:"var(--surface-elevated)",color:"var(--surface-elevated-foreground)"},className:Pe($d,We),...fs,children:os})})})})})})});return s.jsxs(i.Fragment,{children:[s.jsx(NN,{sessionId:ye.id,sessionDirectory:Re??null,sessionTitle:wt,children:s.jsxs(tp,{open:Gt,onOpenChange:Rn,onOpenChangeComplete:an,children:[s.jsxs(sp,{render:s.jsx("div",{"data-session-row":ye.id,"data-session-scope":Re??"","data-session-archived":c?"1":"0",className:Pe("group relative my-0.5 flex items-center rounded-md py-1 pr-1.5","-ml-3",r>0?"pl-[32px]":"pl-[18px]",kt&&!re&&"bg-primary/10",re&&"bg-interactive-selection")}),children:[ls,Ts,s.jsx("div",{className:"flex min-w-0 flex-1 items-center",children:je?s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onPointerDown:Wn,onPointerUp:Es,onPointerCancel:Es,onMouseDown:Ds,onClick:We=>Ss(We),onDoubleClick:We=>{We.stopPropagation(),S(ye.id,wt)},className:Pe("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 text-foreground select-none transition-[padding]",Ne&&"bg-interactive-hover/70",q?ee?pe:ce:pe),children:s.jsxs("div",{className:Pe("flex w-full items-center min-w-0 flex-1 overflow-hidden","gap-1"),children:[s.jsx("div",{className:Pe("block min-w-0 flex-1 truncate typography-ui-label font-normal",kt?"text-primary":"text-foreground"),children:vo(wt,f)}),q?s.jsx("span",{className:"ml-2 flex-shrink-0 text-[0.72rem] text-muted-foreground/75",children:xt}):null,q?null:s.jsx("div",{className:"relative ml-1 flex h-4 min-w-4 flex-shrink-0 items-center justify-end",children:s.jsx("span",{className:Pe("whitespace-nowrap text-right text-[0.72rem] text-muted-foreground/75 transition-opacity duration-150",as?"opacity-0":Me),children:xt})}),Qe>0?s.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(I,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Qe})]}):null]})})}),ee?null:s.jsx(Ft,{side:"right",sideOffset:8,className:"max-w-xs text-left",children:s.jsxs("div",{className:"flex flex-col gap-1 text-left text-xs",children:[s.jsxs("div",{className:Pe("flex items-center gap-3 text-left text-muted-foreground",X?.projectLabel?"justify-between":"justify-start"),children:[X?.projectLabel?s.jsx("div",{className:"min-w-0 truncate",children:X.projectLabel}):null,s.jsx("div",{className:"flex-shrink-0",children:jt})]}),X?.branchLabel?s.jsx("div",{className:"flex items-center gap-3 text-left text-muted-foreground justify-start",children:s.jsx("div",{className:"flex min-w-0 items-center gap-1.5 overflow-hidden",children:s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(I,{name:"git-branch",className:"h-3 w-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:X.branchLabel})]})})}):null]})})]}):s.jsxs("button",{type:"button",onPointerDown:Wn,onPointerUp:Es,onPointerCancel:Es,onMouseDown:Ds,onClick:We=>Ss(We),onDoubleClick:We=>{We.stopPropagation(),S(ye.id,wt)},className:Pe("flex min-w-0 flex-1 cursor-pointer flex-col gap-0 overflow-hidden rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 text-foreground select-none transition-[padding]",Ne&&"bg-interactive-hover/70",q?ee?pe:ce:pe),children:[s.jsxs("div",{className:Pe("flex w-full items-center min-w-0 flex-1 overflow-hidden","gap-1"),children:[s.jsx("div",{className:Pe("block min-w-0 flex-1 truncate typography-ui-label font-normal",kt?"text-primary":"text-foreground"),children:vo(wt,f)}),Qe>0?s.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0",title:e("sessions.sidebar.session.status.permissionRequired"),"aria-label":e("sessions.sidebar.session.status.permissionRequired"),children:[s.jsx(I,{name:"shield",className:"h-3 w-3"}),s.jsx("span",{className:"leading-none",children:Qe})]}):null]}),je?null:s.jsx("div",{className:"flex items-center justify-between gap-3 text-muted-foreground/60 min-w-0 overflow-hidden leading-tight",style:{fontSize:"calc(var(--text-ui-label) * 0.85)"},children:s.jsxs("div",{className:Pe("flex min-w-0 items-center gap-1.5 overflow-hidden",Kt&&St?"pl-4":""),children:[s.jsx("span",{className:"flex-shrink-0",children:jt}),ge?s.jsx("span",{className:"truncate",children:X?.projectLabel}):null,O?s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[s.jsx(I,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:X?.branchLabel})]}):null]})})]})}),hn&&!ne?s.jsx("div",{className:Pe("absolute top-1/2 -translate-y-1/2 z-10",je?"right-0":"right-[30px]"),children:hn}):null,s.jsxs("div",{className:Pe("absolute right-0 top-1/2 z-10 flex -translate-y-1/2 items-center gap-0.5 transition-opacity",as||q&&!ee?"opacity-100":Pe("opacity-0",Fe)),children:[Ae?s.jsx(_2,{archiveLabel:e("sessions.sidebar.bulkActions.archive"),deleteLabel:e("sessions.sidebar.bulkActions.delete"),buttonSizeClass:je&&!q?"h-4 w-4":"h-6 w-6",iconSizeClass:je&&!q?"h-2.5 w-2.5":"h-3.5 w-3.5",onPointerDown:dt,onMouseDown:It,onArchive:Ht,onDelete:ht}):null,fe?s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",je&&!q?"h-4 w-4":"h-6 w-6"),"aria-label":e("sessions.sidebar.session.actions.openInEditor"),onPointerDown:hs,onMouseDown:ps,onClick:js,onKeyDown:We=>We.stopPropagation(),children:s.jsx(I,{name:"external-link",className:Pe(je&&!q?"h-2.5 w-2.5":"h-3.5 w-3.5")})})}),s.jsx(Ft,{side:"left",sideOffset:8,children:e("sessions.sidebar.session.actions.openInEditor")})]}):null,s.jsxs(sn,{open:rs,onOpenChange:Gs,onOpenChangeComplete:an,children:[s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:Pe("inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity",je&&!q?as?"h-4 w-4 opacity-100":Pe("h-4 w-4 opacity-0",Fe):"h-6 w-6 opacity-100"),"aria-label":e("sessions.sidebar.session.menu.label"),onPointerDown:we,onMouseDown:tt,onClick:Os,onKeyDown:We=>We.stopPropagation(),children:s.jsx(I,{name:"more-2",className:Pe(je&&!q?"h-2.5 w-2.5":"h-3.5 w-3.5")})})}),Hn]})]})]}),Xn]})}),St&&ns?n.children.map(We=>{const os=ke?ke(We):{subtreeContainsActive:he,subtreeContainsEditing:Se,menuOpenSessionId:Z,nodeStructureKey:""};return H(We,r+1,Re??o,a,c,void 0,oe,os)}):null,s.jsx($s,{open:Je,onOpenChange:rt,children:s.jsxs(Vs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[s.jsxs(Hs,{children:[s.jsx(Ws,{children:e("sessions.sidebar.session.export.dialog.title")}),s.jsx(on,{children:Qt===1?e("sessions.sidebar.session.export.dialog.descriptionSingle",{count:Qt}):e("sessions.sidebar.session.export.dialog.descriptionMany",{count:Qt})})]}),s.jsxs("label",{className:"flex items-center gap-2 typography-ui-label cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:bt,onChange:We=>yt(We.target.checked),className:"h-4 w-4 rounded border-border accent-primary"}),e("sessions.sidebar.session.export.dialog.includeSubtasks")]}),s.jsxs(ir,{children:[s.jsx($e,{type:"button",onClick:()=>rt(!1),variant:"outline",size:"sm",children:e("sessions.sidebar.dialogs.cancel")}),s.jsx($e,{type:"button",onClick:()=>{rt(!1),$t(bt)},size:"sm",children:e("sessions.sidebar.session.export.dialog.confirm")})]})]})}),Bt?s.jsx(O2,{session:Le,open:Lt,onOpenChange:_t}):null]},ye.id)}const xf=t=>cs(t.session.directory??null),$2=(t,e)=>(t?.projectLabel??null)===(e?.projectLabel??null)&&(t?.branchLabel??null)===(e?.branchLabel??null),z2=t=>{if(!t.openSidebarMenuKey)return null;const e=t.archivedBucket?"archived":"active",n=`${t.renderContext??"project"}:${e}:`;return t.openSidebarMenuKey.startsWith(n)?t.openSidebarMenuKey.slice(n.length):null},ta=t=>t.menuOpenSessionId??z2(t),$i=(t,e,n)=>e?n.has(t.node.session.id)?!0:zr(t.node,e):!1,Fa=(t,e,n,r,o)=>{if(t.session.id!==e.session.id)return!0;const a=o(t);if(n.has(a)!==r.has(a)||t.children.length!==e.children.length)return!0;for(let c=0;c<t.children.length;c+=1)if(Fa(t.children[c],e.children[c],n,r,o))return!0;return!1},Sh=(t,e,n,r)=>{if(t.session.id!==e.session.id)return!0;const o=t.session.id;if((n.get(o)??t.session)!==(r.get(o)??e.session)||t.children.length!==e.children.length)return!0;for(let a=0;a<t.children.length;a+=1)if(Sh(t.children[a],e.children[a],n,r))return!0;return!1},U2=(t,e)=>{if(t.hasSessionSearchQuery||e.hasSessionSearchQuery)return!1;const n=t.archivedBucket?"archived":"active",r=e.archivedBucket?"archived":"active";return Fa(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${t.renderContext??"project"}:${n}:${o.session.id}`)||Fa(t.node,e.node,t.expandedParents,e.expandedParents,o=>`${e.renderContext??"project"}:${r}:${o.session.id}`)},W2=(t,e)=>{if(t.node.session.id!==e.node.session.id||t.depth!==e.depth||t.groupDirectory!==e.groupDirectory||t.projectId!==e.projectId||t.archivedBucket!==e.archivedBucket||(t.renderContext??"project")!==(e.renderContext??"project")||t.mobileVariant!==e.mobileVariant||t.alwaysShowActions!==e.alwaysShowActions||t.hasSessionSearchQuery!==e.hasSessionSearchQuery||t.normalizedSessionSearchQuery!==e.normalizedSessionSearchQuery||t.notifyOnSubtasks!==e.notifyOnSubtasks||t.nodeStructureKey!==e.nodeStructureKey||xf(t.node)!==xf(e.node)||!$2(t.secondaryMeta,e.secondaryMeta)||t.liveSessionById!==e.liveSessionById&&Sh(t.node,e.node,t.liveSessionById,e.liveSessionById)||t.pinnedSessionIds!==e.pinnedSessionIds&&Fa(t.node,e.node,t.pinnedSessionIds,e.pinnedSessionIds,n=>n.session.id)||t.expandedParents!==e.expandedParents&&U2(t,e)||t.currentSessionId!==e.currentSessionId&&($i(t,t.currentSessionId,t.subtreeContainsActive)||$i(e,e.currentSessionId,e.subtreeContainsActive))||t.editingId!==e.editingId&&($i(t,t.editingId,t.subtreeContainsEditing)||$i(e,e.editingId,e.subtreeContainsEditing))||t.editTitle!==e.editTitle&&($i(t,t.editingId,t.subtreeContainsEditing)||$i(e,e.editingId,e.subtreeContainsEditing))||t.copiedSessionId!==e.copiedSessionId&&(zr(t.node,t.copiedSessionId)||zr(e.node,e.copiedSessionId)))return!1;if(t.openSidebarMenuKey!==e.openSidebarMenuKey){const n=ta(t),r=ta(e);if(zr(t.node,n)||zr(e.node,r))return!1}if(t.renamingFolderId!==e.renamingFolderId){const n=ta(t),r=ta(e);if(zr(t.node,n)||zr(e.node,r))return!1}return t.setEditingId===e.setEditingId&&t.setEditTitle===e.setEditTitle&&t.handleSaveEdit===e.handleSaveEdit&&t.handleCancelEdit===e.handleCancelEdit&&t.toggleParent===e.toggleParent&&t.handleSessionSelect===e.handleSessionSelect&&t.handleSessionDoubleClick===e.handleSessionDoubleClick&&t.togglePinnedSession===e.togglePinnedSession&&t.handleShareSession===e.handleShareSession&&t.handleCopyShareUrl===e.handleCopyShareUrl&&t.handleUnshareSession===e.handleUnshareSession&&t.setOpenSidebarMenuKey===e.setOpenSidebarMenuKey&&t.getFoldersForScope===e.getFoldersForScope&&t.getSessionFolderId===e.getSessionFolderId&&t.removeSessionFromFolder===e.removeSessionFromFolder&&t.addSessionToFolder===e.addSessionToFolder&&t.createFolderAndStartRename===e.createFolderAndStartRename&&t.openContextPanelTab===e.openContextPanelTab&&t.handleDeleteSession===e.handleDeleteSession&&t.renderSessionNode===e.renderSessionNode},H2=i.memo(V2,W2);function G2(t){return t.stopPropagation()}function K2(t){const e=mt.c(71),{t:n}=Nt(),{value:r,setValue:o,showDeletionDialog:a,setShowDeletionDialog:c,onConfirm:l}=t;let d,u,m,f,p,y,g,b,x,h;if(e[0]!==o||e[1]!==n||e[2]!==r){const F=n("sessions.sidebar.session.untitled");f=$s,x=!!r,e[13]!==o?(h=ne=>{ne||o(null)},e[13]=o,e[14]=h):h=e[14],m=Vs,g=!1,b="max-w-sm gap-5",u=Hs;let te;e[15]!==n||e[16]!==r?.archivedBucket?(te=r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.title"):n("sessions.sidebar.dialogs.archiveSession.title"),e[15]=n,e[16]=r?.archivedBucket,e[17]=te):te=e[17],e[18]!==te?(y=s.jsx(Ws,{children:te}),e[18]=te,e[19]=y):y=e[19],d=on,p=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n("sessions.sidebar.dialogs.deleteSession.withOneSubtask",{sessionTitle:r.session.title||F,count:r.descendantCount}):n("sessions.sidebar.dialogs.deleteSession.withManySubtasks",{sessionTitle:r.session.title||F,count:r.descendantCount}):r.descendantCount===1?n("sessions.sidebar.dialogs.archiveSession.withOneSubtask",{sessionTitle:r.session.title||F,count:r.descendantCount}):n("sessions.sidebar.dialogs.archiveSession.withManySubtasks",{sessionTitle:r.session.title||F,count:r.descendantCount}):r?.archivedBucket?n("sessions.sidebar.dialogs.deleteSession.single",{sessionTitle:r?.session.title||F}):n("sessions.sidebar.dialogs.archiveSession.single",{sessionTitle:r?.session.title||F}),e[0]=o,e[1]=n,e[2]=r,e[3]=d,e[4]=u,e[5]=m,e[6]=f,e[7]=p,e[8]=y,e[9]=g,e[10]=b,e[11]=x,e[12]=h}else d=e[3],u=e[4],m=e[5],f=e[6],p=e[7],y=e[8],g=e[9],b=e[10],x=e[11],h=e[12];let C;e[20]!==d||e[21]!==p?(C=s.jsx(d,{children:p}),e[20]=d,e[21]=p,e[22]=C):C=e[22];let w;e[23]!==u||e[24]!==y||e[25]!==C?(w=s.jsxs(u,{children:[y,C]}),e[23]=u,e[24]=y,e[25]=C,e[26]=w):w=e[26];let v;e[27]!==c||e[28]!==a?(v=()=>c(!a),e[27]=c,e[28]=a,e[29]=v):v=e[29];const S=!a;let k;e[30]!==a?(k=a?s.jsx(I,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(I,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[30]=a,e[31]=k):k=e[31];let j;e[32]!==n?(j=n("sessions.sidebar.dialogs.neverAsk"),e[32]=n,e[33]=j):j=e[33];let A;e[34]!==k||e[35]!==j||e[36]!==v||e[37]!==S?(A=s.jsxs("button",{type:"button",onClick:v,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":S,children:[k,j]}),e[34]=k,e[35]=j,e[36]=v,e[37]=S,e[38]=A):A=e[38];let D;e[39]!==o?(D=()=>o(null),e[39]=o,e[40]=D):D=e[40];let N;e[41]!==n?(N=n("sessions.sidebar.dialogs.cancel"),e[41]=n,e[42]=N):N=e[42];let B;e[43]!==D||e[44]!==N?(B=s.jsx("button",{type:"button",onClick:D,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:N}),e[43]=D,e[44]=N,e[45]=B):B=e[45];let T;e[46]!==l?(T=()=>{l()},e[46]=l,e[47]=T):T=e[47];let E;e[48]!==n||e[49]!==r?.archivedBucket?(E=r?.archivedBucket?n("sessions.sidebar.bulkActions.delete"):n("sessions.sidebar.bulkActions.archive"),e[48]=n,e[49]=r?.archivedBucket,e[50]=E):E=e[50];let _;e[51]!==T||e[52]!==E?(_=s.jsx("button",{type:"button",onClick:T,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:E}),e[51]=T,e[52]=E,e[53]=_):_=e[53];let R;e[54]!==B||e[55]!==_?(R=s.jsxs("div",{className:"flex items-center gap-2",children:[B,_]}),e[54]=B,e[55]=_,e[56]=R):R=e[56];let V;e[57]!==A||e[58]!==R?(V=s.jsxs(ir,{className:"w-full sm:items-center sm:justify-between",children:[A,R]}),e[57]=A,e[58]=R,e[59]=V):V=e[59];let $;e[60]!==m||e[61]!==g||e[62]!==V||e[63]!==b||e[64]!==w?($=s.jsxs(m,{showCloseButton:g,className:b,children:[w,V]}),e[60]=m,e[61]=g,e[62]=V,e[63]=b,e[64]=w,e[65]=$):$=e[65];let z;return e[66]!==f||e[67]!==$||e[68]!==x||e[69]!==h?(z=s.jsx(f,{open:x,onOpenChange:h,children:$}),e[66]=f,e[67]=$,e[68]=x,e[69]=h,e[70]=z):z=e[70],z}function q2(t){const e=mt.c(57),{t:n}=Nt(),{value:r,setValue:o,showDeletionDialog:a,setShowDeletionDialog:c,onConfirm:l}=t,d=r?.archivedBucket===!0,u=r?.sessionCount??0;let m;e[0]!==d||e[1]!==u||e[2]!==n?(m=n(d?u===1?"sessions.sidebar.dialogs.deleteSession.title":"sessions.sidebar.dialogs.deleteSessions.title":u===1?"sessions.sidebar.dialogs.archiveSession.title":"sessions.sidebar.dialogs.archiveSessions.title"),e[0]=d,e[1]=u,e[2]=n,e[3]=m):m=e[3];const f=m;let p;e[4]!==d||e[5]!==u||e[6]!==n?(p=d?u===1?n("sessions.sidebar.dialogs.deleteSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.deleteSessions.pluralDescription",{count:u}):u===1?n("sessions.sidebar.dialogs.archiveSessions.singleDescription",{count:u}):n("sessions.sidebar.dialogs.archiveSessions.pluralDescription",{count:u}),e[4]=d,e[5]=u,e[6]=n,e[7]=p):p=e[7];const y=p,g=!!r;let b;e[8]!==o?(b=z=>{z||o(null)},e[8]=o,e[9]=b):b=e[9];let x;e[10]!==f?(x=s.jsx(Ws,{children:f}),e[10]=f,e[11]=x):x=e[11];let h;e[12]!==y?(h=s.jsx(on,{children:y}),e[12]=y,e[13]=h):h=e[13];let C;e[14]!==x||e[15]!==h?(C=s.jsxs(Hs,{children:[x,h]}),e[14]=x,e[15]=h,e[16]=C):C=e[16];let w;e[17]!==c||e[18]!==a?(w=()=>c(!a),e[17]=c,e[18]=a,e[19]=w):w=e[19];const v=!a;let S;e[20]!==a?(S=a?s.jsx(I,{name:"checkbox-blank",className:"h-4 w-4"}):s.jsx(I,{name:"checkbox",className:"h-4 w-4 text-primary"}),e[20]=a,e[21]=S):S=e[21];let k;e[22]!==n?(k=n("sessions.sidebar.dialogs.neverAsk"),e[22]=n,e[23]=k):k=e[23];let j;e[24]!==k||e[25]!==w||e[26]!==v||e[27]!==S?(j=s.jsxs("button",{type:"button",onClick:w,className:"inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":v,children:[S,k]}),e[24]=k,e[25]=w,e[26]=v,e[27]=S,e[28]=j):j=e[28];let A;e[29]!==o?(A=()=>o(null),e[29]=o,e[30]=A):A=e[30];let D;e[31]!==n?(D=n("sessions.sidebar.dialogs.cancel"),e[31]=n,e[32]=D):D=e[32];let N;e[33]!==A||e[34]!==D?(N=s.jsx("button",{type:"button",onClick:A,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:D}),e[33]=A,e[34]=D,e[35]=N):N=e[35];let B;e[36]!==l?(B=()=>{l()},e[36]=l,e[37]=B):B=e[37];let T;e[38]!==d||e[39]!==n?(T=n(d?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[38]=d,e[39]=n,e[40]=T):T=e[40];let E;e[41]!==B||e[42]!==T?(E=s.jsx("button",{type:"button",onClick:B,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:T}),e[41]=B,e[42]=T,e[43]=E):E=e[43];let _;e[44]!==N||e[45]!==E?(_=s.jsxs("div",{className:"flex items-center gap-2",children:[N,E]}),e[44]=N,e[45]=E,e[46]=_):_=e[46];let R;e[47]!==j||e[48]!==_?(R=s.jsxs(ir,{className:"w-full sm:items-center sm:justify-between",children:[j,_]}),e[47]=j,e[48]=_,e[49]=R):R=e[49];let V;e[50]!==R||e[51]!==C?(V=s.jsxs(Vs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[C,R]}),e[50]=R,e[51]=C,e[52]=V):V=e[52];let $;return e[53]!==g||e[54]!==V||e[55]!==b?($=s.jsx($s,{open:g,onOpenChange:b,children:V}),e[53]=g,e[54]=V,e[55]=b,e[56]=$):$=e[56],$}function Y2(t){const e=mt.c(36),{t:n}=Nt(),{value:r,setValue:o,onConfirm:a}=t,c=!!r;let l;e[0]!==o?(l=S=>{S||o(null)},e[0]=o,e[1]=l):l=e[1];let d;e[2]!==n?(d=n("sessions.sidebar.dialogs.deleteFolder.title"),e[2]=n,e[3]=d):d=e[3];let u;e[4]!==d?(u=s.jsx(Ws,{children:d}),e[4]=d,e[5]=u):u=e[5];let m;e[6]!==n||e[7]!==r?(m=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n("sessions.sidebar.dialogs.deleteFolder.withOneSubfolder",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withManySubfolders",{folderName:r.folderName,count:r.subFolderCount}):n("sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders",{folderName:r.folderName}):n("sessions.sidebar.dialogs.deleteFolder.single",{folderName:r?.folderName??""}),e[6]=n,e[7]=r,e[8]=m):m=e[8];let f;e[9]!==m?(f=s.jsx(on,{children:m}),e[9]=m,e[10]=f):f=e[10];let p;e[11]!==u||e[12]!==f?(p=s.jsxs(Hs,{children:[u,f]}),e[11]=u,e[12]=f,e[13]=p):p=e[13];let y;e[14]!==o?(y=()=>o(null),e[14]=o,e[15]=y):y=e[15];let g;e[16]!==n?(g=n("sessions.sidebar.dialogs.cancel"),e[16]=n,e[17]=g):g=e[17];let b;e[18]!==y||e[19]!==g?(b=s.jsx("button",{type:"button",onClick:y,className:"inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:g}),e[18]=y,e[19]=g,e[20]=b):b=e[20];let x;e[21]!==n?(x=n("sessions.sidebar.bulkActions.delete"),e[21]=n,e[22]=x):x=e[22];let h;e[23]!==a||e[24]!==x?(h=s.jsx("button",{type:"button",onClick:a,className:"inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50",children:x}),e[23]=a,e[24]=x,e[25]=h):h=e[25];let C;e[26]!==h||e[27]!==b?(C=s.jsxs(ir,{children:[b,h]}),e[26]=h,e[27]=b,e[28]=C):C=e[28];let w;e[29]!==C||e[30]!==p?(w=s.jsxs(Vs,{showCloseButton:!1,className:"max-w-sm gap-5",children:[p,C]}),e[29]=C,e[30]=p,e[31]=w):w=e[31];let v;return e[32]!==c||e[33]!==l||e[34]!==w?(v=s.jsx($s,{open:c,onOpenChange:l,children:w}),e[32]=c,e[33]=l,e[34]=w,e[35]=v):v=e[35],v}const Q2=t=>{const e=mt.c(46),{selectedCount:n,scopeKey:r,scopeFolders:o,archivedBucket:a,onMoveToFolder:c,onCreateFolderAndMove:l,onRemoveFromFolder:d,canRemoveFromFolder:u,onDelete:m,onDone:f}=t,{t:p}=Nt(),y=!!r&&!a;let g;e[0]!==a||e[1]!==p?(g=p(a?"sessions.sidebar.bulkActions.delete":"sessions.sidebar.bulkActions.archive"),e[0]=a,e[1]=p,e[2]=g):g=e[2];const b=g;let x;e[3]!==n||e[4]!==p?(x=p("sessions.sidebar.bulkActions.selectedCount",{count:n}),e[3]=n,e[4]=p,e[5]=x):x=e[5];let h;e[6]!==x?(h=s.jsx("span",{className:"typography-ui-label text-muted-foreground whitespace-nowrap",children:x}),e[6]=x,e[7]=h):h=e[7];let C;e[8]!==y||e[9]!==u||e[10]!==l||e[11]!==c||e[12]!==d||e[13]!==o||e[14]!==p?(C=y?s.jsxs(sn,{children:[s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx(en,{asChild:!0,children:s.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":p("sessions.sidebar.bulkActions.moveToFolder"),children:s.jsx(I,{name:"folder",className:"h-4 w-4"})})})}),s.jsx(Ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:p("sessions.sidebar.bulkActions.moveToFolder")})})]}),s.jsxs(tn,{align:"end",className:"min-w-[180px]",children:[o.length===0?s.jsx(bs,{disabled:!0,className:"text-muted-foreground",children:p("sessions.sidebar.folders.none")}):o.map(V=>s.jsx(bs,{onClick:()=>c(V.id),children:s.jsx("span",{className:"flex-1 truncate",children:V.name})},V.id)),s.jsx(Rr,{}),s.jsxs(bs,{onClick:l,children:[s.jsx(I,{name:"add",className:"mr-1 h-4 w-4"}),p("sessions.sidebar.folders.newFolderEllipsis")]}),u?s.jsxs(bs,{onClick:d,className:"text-destructive focus:text-destructive",children:[s.jsx(I,{name:"close",className:"mr-1 h-4 w-4"}),p("sessions.sidebar.folders.removeFromFolder")]}):null]})]}):null,e[8]=y,e[9]=u,e[10]=l,e[11]=c,e[12]=d,e[13]=o,e[14]=p,e[15]=C):C=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=Pe("inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50"),e[16]=w):w=e[16];let v;e[17]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx(I,{name:"delete-bin",className:"h-4 w-4"}),e[17]=v):v=e[17];let S;e[18]!==b||e[19]!==m?(S=s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:m,className:w,"aria-label":b,children:v})}),e[18]=b,e[19]=m,e[20]=S):S=e[20];let k;e[21]!==b?(k=s.jsx(Ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:b})}),e[21]=b,e[22]=k):k=e[22];let j;e[23]!==S||e[24]!==k?(j=s.jsxs(Et,{children:[S,k]}),e[23]=S,e[24]=k,e[25]=j):j=e[25];let A;e[26]!==p?(A=p("sessions.sidebar.header.actions.exitSelection"),e[26]=p,e[27]=A):A=e[27];let D;e[28]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(I,{name:"close",className:"h-4 w-4"}),e[28]=D):D=e[28];let N;e[29]!==f||e[30]!==A?(N=s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:f,className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":A,children:D})}),e[29]=f,e[30]=A,e[31]=N):N=e[31];let B;e[32]!==p?(B=p("sessions.sidebar.header.actions.exitSelection"),e[32]=p,e[33]=B):B=e[33];let T;e[34]!==B?(T=s.jsx(Ft,{side:"top",sideOffset:4,children:s.jsx("p",{children:B})}),e[34]=B,e[35]=T):T=e[35];let E;e[36]!==N||e[37]!==T?(E=s.jsxs(Et,{children:[N,T]}),e[36]=N,e[37]=T,e[38]=E):E=e[38];let _;e[39]!==E||e[40]!==C||e[41]!==j?(_=s.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[C,j,E]}),e[39]=E,e[40]=C,e[41]=j,e[42]=_):_=e[42];let R;return e[43]!==_||e[44]!==h?(R=s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5",children:[h,_]}),e[43]=_,e[44]=h,e[45]=R):R=e[45],R},J2=t=>{const{t:e}=Nt(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:o,addSessionsToFolder:a,removeSessionsFromFolders:c,createFolderAndStartRename:l,archiveSessions:d,deleteSessions:u,setBulkDeleteConfirm:m}=t,f=Bn(T=>T.enabled),p=Bn(T=>T.selectedIds.size),y=p>0,g=Bn(T=>T.selectedIds),b=Bn(T=>T.scopeKey),x=i.useCallback(()=>{Bn.getState().toggleMode()},[]),h=i.useCallback(()=>{Bn.getState().disable()},[]),C=i.useMemo(()=>{if(!y||typeof document>"u")return!1;let T=!1,E=!1;for(const _ of g){const R=document.querySelectorAll(`[data-session-row="${CSS.escape(_)}"]`);for(const V of R)V.getAttribute("data-session-archived")==="1"?E=!0:T=!0}return E&&!T},[y,g]),w=i.useMemo(()=>{if(b)return b;if(!y||typeof document>"u")return null;for(const T of g){const _=document.querySelector(`[data-session-row="${CSS.escape(T)}"]`)?.getAttribute("data-session-scope");if(_&&_.length>0)return _}return null},[y,g,b]),v=i.useMemo(()=>w?o[w]??[]:[],[o,w]),S=i.useMemo(()=>{if(!w||!y)return!1;const T=o[w]??[];for(const E of T)for(const _ of E.sessionIds)if(g.has(_))return!0;return!1},[o,w,y,g]),k=i.useCallback(T=>{!w||!y||a(w,T,Array.from(g))},[a,g,w,y]),j=i.useCallback(()=>{if(!w||!y)return;const T=l(w);T&&a(w,T.id,Array.from(g))},[a,l,g,w,y]),A=i.useCallback(()=>{!w||!y||c(w,Array.from(g))},[c,g,w,y]),D=i.useCallback(async()=>{const T=Array.from(g);if(T.length!==0){if(C){const{deletedIds:E,failedIds:_}=await u(T);E.length>0&&le.success(E.length===1?e("sessions.sidebar.bulkActions.deletedSingle",{count:E.length}):e("sessions.sidebar.bulkActions.deletedPlural",{count:E.length})),_.length>0&&le.error(_.length===1?e("sessions.sidebar.bulkActions.failedDeleteSingle",{count:_.length}):e("sessions.sidebar.bulkActions.failedDeletePlural",{count:_.length}))}else{const{archivedIds:E,failedIds:_}=await d(T);E.length>0&&le.success(E.length===1?e("sessions.sidebar.bulkActions.archivedSingle",{count:E.length}):e("sessions.sidebar.bulkActions.archivedPlural",{count:E.length})),_.length>0&&le.error(_.length===1?e("sessions.sidebar.bulkActions.failedArchiveSingle",{count:_.length}):e("sessions.sidebar.bulkActions.failedArchivePlural",{count:_.length}))}Bn.getState().clear()}},[d,C,u,g,e]),N=i.useCallback(()=>{if(!y)return;const T=g.size;if(!r){D();return}m({sessionCount:T,archivedBucket:C})},[C,D,g,r,m,y]),B=i.useCallback(async()=>{m(null),await D()},[D]);return i.useEffect(()=>{if(!f)return;const T=typeof navigator<"u"&&/Macintosh|Mac OS X/.test(navigator.userAgent||""),E=_=>{if(n)return;const R=_.target;if(R&&(R.tagName==="INPUT"||R.tagName==="TEXTAREA"||R.isContentEditable))return;const V=T?_.metaKey:_.ctrlKey;if(_.key==="Escape"){_.preventDefault(),Bn.getState().disable();return}if(V&&_.key==="Backspace"){_.preventDefault(),N();return}if(V&&(_.key==="a"||_.key==="A")){const $=typeof document<"u"?Array.from(document.querySelectorAll("[data-session-row]")):[];if($.length===0)return;_.preventDefault();const F=Bn.getState().scopeKey??$[0]?.getAttribute("data-session-scope")??null,te=q=>F?q.getAttribute("data-session-scope")===F:!0,ne=$.filter(te).map(q=>q.getAttribute("data-session-row")).filter(q=>typeof q=="string"&&q.length>0);if(ne.length===0)return;Bn.getState().replaceAll(ne,F||null)}};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[N,n,f]),{selectionModeEnabled:f,hasSelection:y,selectedIdsSize:p,bulkScopeIsArchived:C,derivedSelectionScope:w,bulkScopeFolders:v,bulkCanRemoveFromFolder:S,handleToggleSelectionMode:x,handleExitSelectionMode:h,handleBulkMoveToFolder:k,handleBulkCreateFolderAndMove:j,handleBulkRemoveFromFolder:A,handleBulkDelete:N,confirmBulkDelete:B}},X2=2880*60*1e3,Z2=t=>!!t.parentID,ek=t=>!!t.time?.archived,dc=t=>{const e=t.time?.updated,n=t.time?.created;return typeof e=="number"&&Number.isFinite(e)?e:typeof n=="number"&&Number.isFinite(n)?n:0},tk=t=>[...t].sort((e,n)=>dc(n)-dc(e)),sk=(t,e=Date.now())=>{const n=e-X2,r=t.filter(o=>ek(o)||Z2(o)?!1:dc(o)>=n);return tk(r)},sa="oc.sessions.projectCollapse",bf="oc.sessions.groupOrder",yf="oc.sessions.groupCollapse",wf="oc.sessions.activeSessionByProject",Ll="oc.sessions.expandedParents.v2",nk="oc.sessions.expandedParents",rk="oc.sessions.pinned",ik=(t,e,n)=>{const r=new Set;for(const o of t){const a=cs(o.path)?.toLowerCase();a&&r.add(a)}if(n?.includeWorktrees===!1)return r;for(const o of e.values())for(const a of o){const c=cs(a.path)?.toLowerCase();c&&r.add(c)}return r},ok=(t,e,n)=>{if(t.time?.archived)return!0;const r=cs(Tr(t))?.toLowerCase();return r?e.size===0?n?.allowEmptyDirectorySet??!0:e.has(r):n?.allowUnknownDirectory??!0},ak=5*6e4,vf=new Set,Ar=t=>{const e=i.useRef(t);return e.current=t,i.useCallback((...n)=>e.current(...n),[])},jf=({mobileVariant:t=!1,onSessionSelected:e,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:o=!1})=>{const{t:a}=Nt(),[c,l]=i.useState(!1),[d,u]=i.useState(""),m=i.useRef(null),f=i.useRef(null),p=i.useRef(new Set),[y,g]=i.useState(null),[b,x]=i.useState(""),[h,C]=i.useState(null),[w,v]=i.useState(new Set),S=i.useMemo(()=>Ni(),[]),[k,j]=i.useState(new Set),[A,D]=i.useState(new Map),[N,B]=i.useState(new Map),T=Ee(ie=>ie.isNewWorktreeDialogOpen),E=Ee(ie=>ie.setNewWorktreeDialogOpen),[_,R]=i.useState(!1),[V,$]=i.useState(null),[z,F]=i.useState(null),[te,ne]=i.useState(""),[q,H]=i.useState(null),[X,oe]=i.useState(null),[he,Se]=i.useState(null),Z=ul(ie=>ie.ids),ke=ul(ie=>ie.setIds),Y=ul(ie=>ie.toggle),[ge,O]=i.useState(()=>{try{const ie=Ni().getItem(yf);if(!ie)return new Set;const lt=JSON.parse(ie);return new Set(Array.isArray(lt)?lt.filter(it=>typeof it=="string"):[])}catch{return new Set}}),[se,ee]=i.useState(()=>{try{const ie=Ni().getItem(bf);if(!ie)return new Map;const lt=JSON.parse(ie),it=new Map;return Object.entries(lt).forEach(([pt,zt])=>{Array.isArray(zt)&&it.set(pt,zt.filter(Is=>typeof Is=="string"))}),it}catch{return new Map}}),[je,De]=i.useState(()=>{try{const ie=Ni().getItem(wf);if(!ie)return new Map;const lt=JSON.parse(ie),it=new Map;return Object.entries(lt).forEach(([pt,zt])=>{typeof zt=="string"&&zt.length>0&&it.set(pt,zt)}),it}catch{return new Map}}),[Be,Fe]=i.useState(new Map),Me=i.useRef(new Map),fe=i.useRef(0),Ae=Js(ie=>ie.homeDirectory),pe=Js(ie=>ie.currentDirectory),ce=Js(ie=>ie.setDirectory),me=ws(ie=>ie.projects),Ne=ws(ie=>ie.activeProjectId),ue=ws(ie=>ie.removeProject),P=ws(ie=>ie.setActiveProjectIdOnly),M=ws(ie=>ie.updateProjectMeta),de=ws(ie=>ie.reorderProjects),xe=Ee(ie=>ie.setActiveMainTab),U=Ee(ie=>ie.openContextPanelTab),be=Ee(ie=>ie.setSettingsDialogOpen),ve=Ee(ie=>ie.toggleHelpDialog),G=Ee(ie=>ie.setAboutDialogOpen),ye=Ee(ie=>ie.setSessionSwitcherOpen),Le=Ee(ie=>ie.setScheduledTasksDialogOpen),Re=Ee(ie=>ie.openMultiRunLauncher),J=Ee(ie=>ie.notifyOnSubtasks),L=Ee(ie=>ie.showDeletionDialog),ae=Ee(ie=>ie.setShowDeletionDialog),re=Ka(d,120),Oe=i.useMemo(()=>re.trim().toLowerCase(),[re]),Ge=Oe.length>0,He=Ln(ie=>ie.collapsedFolderIds),Je=Ln(ie=>ie.foldersMap),rt=Ln(ie=>ie.getFoldersForScope),bt=Ln(ie=>ie.createFolder),yt=Ln(ie=>ie.renameFolder),Ve=Ln(ie=>ie.deleteFolder),Ye=Ln(ie=>ie.addSessionToFolder),nt=Ln(ie=>ie.addSessionsToFolder),vt=Ln(ie=>ie.removeSessionFromFolder),kt=Ln(ie=>ie.removeSessionsFromFolders),wt=Ln(ie=>ie.toggleFolderCollapse),St=Ln(ie=>ie.cleanupSessions),et=Ln(ie=>ie.getSessionFolderId);$S({isSessionSearchOpen:c,setIsSessionSearchOpen:l,sessionSearchInputRef:f,sessionSearchContainerRef:m});const Ot=lm(),ns=Ec(),Ut=wc(),_e=i.useMemo(()=>Gr(),[]),Ze=vr(ie=>ie.hasLoaded),Vt=vr(ie=>ie.activeSessions),jt=vr(ie=>ie.archivedSessions),xt=ut(ie=>ie.currentSessionId),rs=ut(ie=>!!ie.newSessionDraft?.open),Gt=ut(ie=>ie.setCurrentSession),Wt=ut(ie=>ie.updateSessionTitle),as=ut(ie=>ie.shareSession),Bt=ut(ie=>ie.unshareSession),Lt=ut(ie=>ie.worktreeMetadata),_t=ut(ie=>ie.availableWorktreesByProject),Kt=ut(ie=>ie.openNewSessionDraft),Xt=i.useCallback(ie=>{Kt(ie),_e&&window.dispatchEvent(new CustomEvent("openchamber:navigate",{detail:{view:"chat"}}))},[_e,Kt]),Qt=wo(Ul(ie=>({checkForUpdates:ie.checkForUpdates,available:ie.available,runtimeType:ie.runtimeType,info:ie.info,downloading:ie.downloading,downloaded:ie.downloaded,progress:ie.progress,error:ie.error,downloadUpdate:ie.downloadUpdate,restartToUpdate:ie.restartToUpdate}))),vs=i.useMemo(()=>ik(me,_t,{includeWorktrees:!_e}),[_t,_e,me]),Dt=i.useMemo(()=>{const ie=new Map(Ut.map(pt=>[pt.id,pt])),lt=Vt.map(pt=>{const zt=ie.get(pt.id);return zt?Kg(zt,pt):pt}),it=new Set(lt.map(pt=>pt.id));return Ut.forEach(pt=>{it.has(pt.id)||lt.push(pt)}),lt.filter(pt=>ok(pt,vs,{allowUnknownDirectory:!_e,allowEmptyDirectorySet:!_e}))},[Vt,_e,vs,Ut]),$t=i.useMemo(()=>Ut.map(ie=>{const lt=cs(ie.directory??null)??"";return`${ie.id}:${ie.title??""}:${ie.time?.archived?1:0}:${lt}`}).join("|"),[Ut]),Ct=i.useRef(Ut);i.useEffect(()=>{Ct.current=Ut},[$t,Ut]);const ds=i.useMemo(()=>new Map(Ut.map(ie=>[ie.id,ie])),[Ut]),qe=i.useMemo(()=>me.map(ie=>`${ie.id}:${cs(ie.path)??""}`).join("|"),[me]),at=i.useRef(!1);i.useEffect(()=>{at.current||(at.current=!0,Na(Ct.current))},[]);const Qe=i.useRef("");i.useEffect(()=>{let ie=!1;const lt=async()=>{const it=ws.getState().projects;if(it.length===0)return;const pt=new Map,zt=[],Is=3;let Xs=0;const un=Array.from({length:Is},async()=>{for(;;){const Fn=Xs;if(Xs+=1,Fn>=it.length)return;const Sn=it[Fn],An=cs(Sn.path);if(An)try{if(!(wn.getState().directories.get(An)?.isGitRepo??await hm(An)))continue;const gi=await Yg({id:Sn.id,path:An});if(ie||gi.length===0)continue;pt.set(An,gi),zt.push(...gi)}catch{}}});await Promise.all(un),!ie&&ut.setState({availableWorktrees:zt,availableWorktreesByProject:pt})};if(Qe.current!==qe)return Qe.current=qe,lt(),()=>{ie=!0}},[qe]),i.useEffect(()=>{let ie=null;const lt=hh(it=>{it.type==="scheduled-task-ran"&&(ie&&clearTimeout(ie),ie=setTimeout(()=>{Na(Ct.current)},500))});return()=>{ie&&clearTimeout(ie),lt()}},[]);const At=i.useMemo(()=>dr(),[]),{isTablet:Tt}=Er(),ts=t||Tt,{buildGroupSearchText:xs,filterSessionNodesForSearch:ks,buildGroupedSessions:Jt}=VS({homeDirectory:Ae,worktreeMetadata:Lt,pinnedSessionIds:Z,gitBranches:Ot,isVSCode:_e}),{scheduleCollapsedProjectsPersist:ls}=qS({isVSCode:_e,hasLoadedGlobalSessions:Ze,safeStorage:S,keys:{sessionExpanded:Ll,sessionExpandedLegacy:nk,projectCollapse:sa,sessionPinned:rk,groupOrder:bf,projectActiveSession:wf,groupCollapse:yf},sessions:Dt,setPinnedSessionIds:ke,groupOrderByProject:se,activeSessionByProject:je,collapsedGroups:ge,setExpandedParents:v,setCollapsedProjects:j}),Ps=i.useMemo(()=>[...Dt].sort((ie,lt)=>Gi(ie,lt,Z)),[Dt,Z]),Ts=i.useMemo(()=>Ps.map(ie=>`${ie.id}:${ie.time?.updated??0}`).join("|"),[Ps]),hn=i.useRef(null),Gs=i.useMemo(()=>{const ie=hn.current;if(ie&&ie.signature===Ts)return ie.map;const lt=new Map(Ps.map((it,pt)=>[it.id,pt]));return hn.current={signature:Ts,map:lt},lt},[Ts,Ps]),an=i.useMemo(()=>{const ie=new Map;return Ps.forEach(lt=>{const it=lt.parentID;if(!it)return;const pt=ie.get(it)??[];pt.push(lt),ie.set(it,pt)}),ie.forEach(lt=>lt.sort((it,pt)=>Gi(it,pt,Z))),ie},[Ps,Z]),Rn=s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:a("sessions.sidebar.empty.noSessions.title")}),s.jsx("p",{className:"typography-meta mt-1",children:a("sessions.sidebar.empty.noSessions.description")})]}),Os=i.useMemo(()=>me.find(ie=>ie.id===h)??null,[me,h]),we=i.useCallback(ie=>{h&&(M(h,ie),C(null))},[h,M]),tt=i.useCallback(()=>{E(!0)},[E]),dt=i.useCallback(()=>{const ie=wo.getState();if(ie.available&&ie.info){R(!0);return}Qt.checkForUpdates().then(()=>{const{available:lt,error:it}=wo.getState();if(it){le.error(a("sessions.sidebar.updateCheck.errorTitle"),{description:it});return}if(!lt){le.success(a("sessions.sidebar.updateCheck.latestVersion"));return}R(!0)})},[a,Qt]),It=i.useCallback(()=>{t&&ye(!1),be(!0)},[t,ye,be]),Ht=Qt.available&&(Qt.runtimeType==="desktop"||Qt.runtimeType==="web"),ht=ut(ie=>ie.deleteSession),hs=ut(ie=>ie.deleteSessions),ps=ut(ie=>ie.archiveSession),js=ut(ie=>ie.archiveSessions),{copiedSessionId:Ss,handleSessionSelect:Ds,handleSessionDoubleClick:Wn,handleSaveEdit:Es,handleCancelEdit:En,handleShareSession:Hn,handleCopyShareUrl:Xn,handleUnshareSession:We,handleDeleteSession:os,confirmDeleteSession:fs}=zS({activeProjectId:Ne,currentDirectory:pe,currentSessionId:xt,mobileVariant:t,allowReselect:n,onSessionSelected:e,isSessionSearchOpen:c,sessionSearchQuery:d,setSessionSearchQuery:u,setIsSessionSearchOpen:l,setActiveProjectIdOnly:P,setDirectory:ce,setActiveMainTab:xe,setSessionSwitcherOpen:ye,setCurrentSession:Gt,updateSessionTitle:Wt,shareSession:as,unshareSession:Bt,deleteSession:ht,deleteSessions:hs,archiveSession:ps,archiveSessions:js,childrenMap:an,showDeletionDialog:L,setDeleteSessionConfirm:H,deleteSessionConfirm:q,setEditingId:g,setEditTitle:x,editingId:y,editTitle:b}),zs=i.useCallback(()=>{if(!X)return;const{scopeKey:ie,folderId:lt}=X;oe(null),Ve(ie,lt)},[X,Ve]),Ks=i.useCallback(()=>{Pr.requestDirectoryDialog()},[]);i.useEffect(()=>{if(!xt)return;const lt=Dt.find(pt=>pt.id===xt)?.parentID;if(!lt)return;const it=[`project:active:${lt}`,`project:archived:${lt}`,`recent:active:${lt}`,`recent:archived:${lt}`];v(pt=>{if(it.every(Is=>pt.has(Is)))return pt;const zt=new Set(pt);it.forEach(Is=>zt.add(Is));try{S.setItem(Ll,JSON.stringify(Array.from(zt)))}catch{}return zt})},[xt,Dt,S]);const Us=i.useCallback(ie=>{v(lt=>{const it=new Set(lt);it.has(ie)?it.delete(ie):it.add(ie);try{S.setItem(Ll,JSON.stringify(Array.from(it)))}catch{}return it})},[S]),pn=i.useCallback((ie,lt)=>{if(!ie)return null;lt&&He.has(lt)&&wt(lt);const it=bt(ie,a("sessions.sidebar.folder.newFolderName"),lt);return F(it.id),ne(it.name),it},[He,wt,bt,a]),Ns=Ar(Ds),qr=Ar(Wn),Gn=Ar(Es),fr=Ar(En),Kn=Ar(Hn),gs=Ar(Xn),Ms=Ar(We),jr=Ar(os),jn=Ar(pn),ln=i.useCallback((ie,lt)=>{B(it=>{const pt=new Map(it);return pt.set(ie,lt+7),pt})},[]),Zn=i.useCallback(ie=>{B(lt=>{if(!lt.has(ie))return lt;const it=new Map(lt);return it.delete(ie),it})},[]),Mr=i.useCallback(ie=>{B(lt=>{let it=!1;const pt=new Map(lt),zt=`${ie}:`;for(const Is of pt.keys())Is.startsWith(zt)&&(pt.delete(Is),it=!0);return it?pt:lt})},[]),Yr=i.useCallback(()=>{fe.current=Date.now()+150,B(new Map),j(()=>{const ie=new Set(me.map(lt=>lt.id));try{S.setItem(sa,JSON.stringify(Array.from(ie)))}catch{}return _e||ls(ie),ie})},[me,_e,S,ls]),ui=i.useCallback(()=>{fe.current=Date.now()+150,B(new Map),j(()=>{const ie=new Set;try{S.setItem(sa,JSON.stringify([]))}catch{}return _e||ls(ie),ie})},[_e,S,ls]),mr=i.useCallback(ie=>{fe.current=Date.now()+150,Mr(ie),j(lt=>{const it=new Set(lt);it.has(ie)?it.delete(ie):it.add(ie);try{S.setItem(sa,JSON.stringify(Array.from(it)))}catch{}return _e||ls(it),it})},[_e,Mr,S,ls]),us=i.useMemo(()=>me.map(ie=>({...ie,normalizedPath:cs(ie.path)})).filter(ie=>!!ie.normalizedPath),[me]),cn=i.useMemo(()=>us.map(ie=>ie.normalizedPath),[us]),kn=i.useMemo(()=>{const ie=new Set;return us.forEach(lt=>{if(lt.normalizedPath&&ie.add(lt.normalizedPath),_e)return;(_t.get(lt.normalizedPath)??[]).forEach(pt=>{const zt=cs(pt.path);zt&&ie.add(zt)})}),[...ie].sort()},[_t,_e,us]),Q=i.useRef(null);i.useEffect(()=>{const ie=new Set(kn),lt=Q.current;if(Q.current=ie,!lt){_e&&kn.length>0&&zd(kn,Ct.current);return}const it=kn.filter(pt=>!lt.has(pt));it.length!==0&&zd(it,Ct.current)},[_e,kn]);const{github:st}=Jn(),gt=Pi(ie=>ie.status),Pt=Pi(ie=>ie.hasChecked),Zt=qg(cn),is=rr(ie=>ie.ensureEntry),ms=rr(ie=>ie.setParams),Fs=rr(ie=>ie.refreshTargets);YS({normalizedProjects:us,gitRepoStatus:Zt,setProjectRepoStatus:D,setProjectRootBranches:Fe});const qs=ut(ie=>ie.isLoading);tN({isSessionsLoading:qs,hasLoadedGlobalSessions:Ze,sessions:Dt,archivedSessions:jt,normalizedProjects:us,isVSCode:_e,availableWorktreesByProject:_t,cleanupSessions:St});const{getSessionsForProject:er,getArchivedSessionsForProject:qn}=QS({isVSCode:_e,sessions:Dt,archivedSessions:jt,availableWorktreesByProject:_t,normalizedProjects:us});RS({normalizedProjects:us,sessions:Dt,archivedSessions:jt,availableWorktreesByProject:_t,isVSCode:_e,isSessionsLoading:qs,foldersMap:Je,createFolder:bt,addSessionToFolder:Ye,cleanupSessions:St});const Fr=i.useRef(!1);Ne&&A.has(Ne)&&(Fr.current=!!A.get(Ne));const{projectSections:Bs,groupSearchDataByGroup:Lr,sectionsForRender:gn,searchMatchCount:tr}=FS({normalizedProjects:us,getSessionsForProject:er,getArchivedSessionsForProject:qn,availableWorktreesByProject:_t,projectRepoStatus:A,projectRootBranches:Be,lastRepoStatus:Fr.current,buildGroupedSessions:Jt,hasSessionSearchQuery:Ge,normalizedSessionSearchQuery:Oe,filterSessionNodesForSearch:ks,buildGroupSearchText:xs,foldersMap:Je}),xn=s.jsxs("div",{className:"py-6 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-ui-label font-semibold",children:a("sessions.sidebar.empty.noMatches.title")}),s.jsx("p",{className:"typography-meta mt-1",children:a("sessions.sidebar.empty.noMatches.description")})]});OS({projectSections:Bs,activeProjectId:Ne,activeSessionByProject:je,setActiveSessionByProject:De,currentSessionId:xt,handleSessionSelect:Ds,newSessionDraftOpen:rs,mobileVariant:t,openNewSessionDraft:Kt,setActiveMainTab:xe,setSessionSwitcherOpen:ye});const{getOrderedGroups:Mn}=BS(se),bn=i.useRef(!1);i.useEffect(()=>{if(bn.current||Bs.length===0)return;const ie=Bs.flatMap(lt=>lt.groups.filter(it=>it.isArchivedBucket).map(it=>`${lt.project.id}:${it.id}`));ie.length>0&&O(lt=>new Set([...lt,...ie])),bn.current=!0},[Bs]);const or=i.useMemo(()=>{const ie=new Map,lt=new Map;return Bs.forEach(it=>{const pt=Im(it.project.label?.trim()||Ri(it.project.normalizedPath,Ae)||it.project.normalizedPath);it.groups.forEach(zt=>{const Is=zt.branch&&zt.branch!=="HEAD"&&zt.branch!==pt?zt.branch:null,Xs={projectLabel:pt,branchLabel:Is},un=Fn=>{Fn.forEach(Sn=>{const An=it.project.normalizedPath.length,hi=lt.get(Sn.session.id)??-1;An<hi||(ie.set(Sn.session.id,{node:Sn,projectId:it.project.id,groupDirectory:zt.directory,secondaryMeta:Xs}),lt.set(Sn.session.id,An),Sn.children.length>0&&un(Sn.children))})};un(zt.sessions)})}),ie},[Bs,Ae]),Cn=Dr(ie=>ie.showRecentSection),Sr=Dr(ie=>ie.showArchivedSessions),Or=i.useMemo(()=>!Cn||_e?[]:sk(Dt).sort((ie,lt)=>Gi(ie,lt,Z)),[_e,Z,Dt,Cn]),Nr=i.useMemo(()=>{if(_e||!Cn)return[];const ie=Or,lt=pt=>{const zt=or.get(pt.id),Is=cs(pt.directory??null),Xs=zt?.node??{session:pt,children:[],worktree:null},Fn=(Ge?ks([Xs],Oe):[Xs])[0];if(!Fn)return null;const Sn=zt?.secondaryMeta?{projectLabel:zt.secondaryMeta.projectLabel,branchLabel:_e?null:zt.secondaryMeta.branchLabel}:null;return{node:Fn,projectId:zt?.projectId??null,groupDirectory:zt?.groupDirectory??Is,secondaryMeta:Sn}},it=ie.map(lt).filter(pt=>pt!==null);return[{key:"active-now",title:a("sessions.sidebar.activity.recentTitle"),items:it}]},[Or,ks,Ge,_e,Oe,or,Cn,a]),Ei=i.useMemo(()=>Nr.some(ie=>ie.items.length>0),[Nr]),fi=i.useMemo(()=>new Set(Or.map(ie=>ie.id)),[Or]),Mi=i.useMemo(()=>[...fi],[fi]);Yj({currentSessionId:xt,sortedSessions:Ps,recentSessionIds:Mi,ensureSessionRenderable:ns.ensureSessionRenderable});const nn=i.useMemo(()=>Sr?gn:gn.map(ie=>({...ie,groups:ie.groups.filter(lt=>!lt.isArchivedBucket)})),[gn,Sr]),hr=i.useMemo(()=>{const ie=new Set;return nn.forEach(lt=>{lt.groups.forEach(it=>{const pt=cs(it.directory??null),zt=it.branch?.trim()||Ot.get(pt||"")?.trim();!pt||!zt||ie.add(No(pt,zt))})}),[...ie]},[Ot,nn]),Ys=Tw(hr);i.useEffect(()=>{if(!Pt||!gt?.connected||!st)return;const ie=[],lt=Date.now();if(nn.forEach(pt=>{k.has(pt.project.id)||pt.groups.forEach(zt=>{const Is=cs(zt.directory??null),Xs=zt.branch?.trim()||Ot.get(Is||"")?.trim();if(!Is||!Xs)return;const un=No(Is,Xs),Fn=rr.getState().entries[un],Sn=!!Fn?.status?.pr,An=`${Is}::${Xs}`,hi=Math.max(Fn?.lastRefreshAt??0,Fn?.lastDiscoveryPollAt??0),pi=!!(Fn?.isInitialStatusResolved&&!Sn&&(!p.current.has(An)||lt-hi>=ak));(!Fn||!Fn.isInitialStatusResolved||pi)&&(pi&&p.current.add(An),ie.push({directory:Is,branch:Xs}))})}),ie.length===0)return;const it=new Map;ie.forEach(pt=>{const zt=No(pt.directory,pt.branch,pt.remoteName??null);it.has(zt)||it.set(zt,pt)}),it.forEach((pt,zt)=>{is(zt),ms(zt,{directory:pt.directory,branch:pt.branch,remoteName:pt.remoteName??null,canShow:!0,github:st,githubAuthChecked:Pt,githubConnected:gt.connected})}),Fs([...it.values()],{silent:!0,markInitialResolved:!0})},[k,is,st,Pt,gt?.connected,Ot,Fs,nn,ms]);const co=t?"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed":"inline-flex h-6 w-6 cursor-pointer items-center justify-center rounded-md leading-none text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:cursor-not-allowed",Br="h-4.5 w-4.5",ar=iN({isDesktopShellRuntime:At,projectSections:Bs,projectHeaderSentinelRefs:Me}),kr=Ar((ie,lt=0,it,pt,zt=!1,Is,Xs="project",un)=>s.jsx(H2,{node:ie,depth:lt,groupDirectory:it,projectId:pt,archivedBucket:zt,currentSessionId:xt,pinnedSessionIds:Z,expandedParents:w,hasSessionSearchQuery:Ge,normalizedSessionSearchQuery:Oe,notifyOnSubtasks:J,editingId:y,setEditingId:g,editTitle:b,setEditTitle:x,handleSaveEdit:Gn,handleCancelEdit:fr,toggleParent:Us,handleSessionSelect:Ns,handleSessionDoubleClick:qr,togglePinnedSession:Y,handleShareSession:Kn,copiedSessionId:Ss,handleCopyShareUrl:gs,handleUnshareSession:Ms,openSidebarMenuKey:V,setOpenSidebarMenuKey:$,renamingFolderId:z,getFoldersForScope:rt,getSessionFolderId:et,removeSessionFromFolder:vt,addSessionToFolder:Ye,createFolderAndStartRename:jn,openContextPanelTab:U,handleDeleteSession:jr,mobileVariant:t,alwaysShowActions:ts,renderSessionNode:kr,secondaryMeta:Is,renderContext:Xs,subtreeContainsActive:un?.subtreeContainsActive??vf,subtreeContainsEditing:un?.subtreeContainsEditing??vf,menuOpenSessionId:un?.menuOpenSessionId??null,nodeStructureKey:un?.nodeStructureKey??"",childRenderExtrasFor:un?.childRenderExtrasFor,liveSessionById:ds})),dn=i.useCallback(ie=>{Zn(ie),O(lt=>{const it=new Set(lt);return it.has(ie)?it.delete(ie):it.add(ie),it})},[Zn]),lr=i.useMemo(()=>{const ie=new Map;for(const[lt,it]of Ys)ie.set(lt,{visualState:it.visualState,number:it.number,url:it.url,state:it.prState,draft:it.draft,title:it.title,base:it.base,head:it.head,checks:it.checks,canMerge:it.canMerge,mergeableState:it.mergeableState,repo:it.repo});return ie},[Ys]),Fi=i.useCallback((ie,lt,it,pt,zt,Is,Xs)=>s.jsx(FN,{group:ie,groupKey:lt,projectId:it,hideGroupLabel:pt,compactBodyPadding:Is,hasSessionSearchQuery:Ge,normalizedSessionSearchQuery:Oe,groupSearchDataByGroup:Lr,visibleSessionCount:N.get(lt),collapsedGroups:ge,hideDirectoryControls:r,collapsedFolderIds:He,toggleFolderCollapse:wt,renameFolder:yt,deleteFolder:Ve,showDeletionDialog:L,setDeleteFolderConfirm:oe,renderSessionNode:kr,projectRepoStatus:A,lastRepoStatus:Fr.current,showMoreGroupSessions:ln,resetGroupSessionLimit:Zn,mobileVariant:t,alwaysShowActions:ts,activeProjectId:Ne,setActiveProjectIdOnly:P,setActiveMainTab:xe,setSessionSwitcherOpen:ye,openNewSessionDraft:Xt,addSessionToFolder:Ye,createFolderAndStartRename:jn,renamingFolderId:z,renameFolderDraft:te,setRenameFolderDraft:ne,setRenamingFolderId:F,pinnedSessionIds:Z,expandedParents:w,sessionOrderIndex:Gs,currentSessionId:xt,editingId:y,editTitle:b,openSidebarMenuKey:V,liveSessionById:ds,prVisualStateByDirectoryBranch:lr,onToggleCollapsedGroup:dn,dragHandleProps:zt,scrollContainerRef:Xs}),[Ge,Oe,Lr,N,ge,r,He,wt,yt,Ve,L,kr,A,ln,Zn,t,ts,Ne,P,xe,ye,Xt,Ye,jn,z,te,Z,w,Gs,xt,y,b,V,ds,lr,dn]),Li=!_e&&Cn&&!Ge?s.jsx(WN,{sections:Nr,renderSessionNode:kr,currentSessionId:xt,editingId:y,openSidebarMenuKey:V,variant:"section"}):null,_r=!!(z||y||h),{selectionModeEnabled:mi,hasSelection:rn,selectedIdsSize:Oi,bulkScopeIsArchived:uo,derivedSelectionScope:fo,bulkScopeFolders:K,bulkCanRemoveFromFolder:Ce,handleToggleSelectionMode:Te,handleExitSelectionMode:ze,handleBulkMoveToFolder:ft,handleBulkCreateFolderAndMove:Rt,handleBulkRemoveFromFolder:qt,handleBulkDelete:Yt,confirmBulkDelete:ys}=J2({isInlineEditing:_r,showDeletionDialog:L,foldersMap:Je,addSessionsToFolder:nt,removeSessionsFromFolders:kt,createFolderAndStartRename:pn,archiveSessions:js,deleteSessions:hs,setBulkDeleteConfirm:Se}),pr=i.useCallback(()=>{xe("chat"),t&&ye(!1),Re()},[t,Re,xe,ye]),Cr=i.useCallback(()=>{xe("chat"),t&&ye(!1),Kt()},[t,Kt,xe,ye]);return s.jsxs("div",{ref:m,className:Pe("relative flex h-full flex-col text-foreground overflow-x-hidden",t?"":"bg-transparent"),children:[s.jsx(LN,{hideDirectoryControls:r,showRecentControls:!_e,handleOpenDirectoryDialog:Ks,openNewSessionDraft:Cr,canOpenMultiRun:me.length>0,openMultiRunLauncher:pr,headerActionIconClass:Br,headerActionButtonClass:co,isSessionSearchOpen:c,setIsSessionSearchOpen:l,sessionSearchInputRef:f,sessionSearchQuery:d,setSessionSearchQuery:u,hasSessionSearchQuery:Ge,searchMatchCount:tr,collapseAllProjects:Yr,expandAllProjects:ui,openScheduledTasksDialog:()=>Le(!0),selectionModeEnabled:mi,onToggleSelectionMode:Te}),s.jsx(XN,{topContent:Li,hasSharedSessions:Ei,sectionsForRender:nn,projectSections:Bs,activeProjectId:Ne,showOnlyMainWorkspace:o,hasSessionSearchQuery:Ge,emptyState:Rn,searchEmptyState:xn,renderGroupSessions:Fi,homeDirectory:Ae,collapsedProjects:k,hideDirectoryControls:r,projectRepoStatus:A,isDesktopShellRuntime:At,stuckProjectHeaders:ar,mobileVariant:t,alwaysShowActions:ts,toggleProject:mr,setActiveProjectIdOnly:P,setActiveMainTab:xe,setSessionSwitcherOpen:ye,openNewSessionDraft:Xt,openNewWorktreeDialog:tt,openProjectEditDialog:C,removeProject:ue,projectHeaderSentinelRefs:Me,reorderProjects:de,getOrderedGroups:Mn,setGroupOrderByProject:ee,openSidebarMenuKey:V,setOpenSidebarMenuKey:$,isInlineEditing:_r}),mi&&rn?s.jsx(Q2,{selectedCount:Oi,scopeKey:fo,scopeFolders:K,archivedBucket:uo,onMoveToFolder:ft,onCreateFolderAndMove:Rt,onRemoveFromFolder:qt,canRemoveFromFolder:Ce,onDelete:Yt,onDone:ze}):null,s.jsx(HN,{onOpenSettings:It,onOpenShortcuts:ve,onOpenAbout:()=>G(!0),onOpenUpdate:dt,showRuntimeButtons:!_e,showUpdateButton:Ht}),s.jsx(jm,{open:_,onOpenChange:R,info:Qt.info,downloading:Qt.downloading,downloaded:Qt.downloaded,progress:Qt.progress,error:Qt.error,onDownload:Qt.downloadUpdate,onRestart:Qt.restartToUpdate,runtimeType:Qt.runtimeType}),Os?s.jsx(aN,{open:!!Os,onOpenChange:ie=>{ie||C(null)},projectId:Os.id,projectName:Os.label||Ri(Os.path,Ae),projectPath:Os.path,initialIcon:Os.icon,initialColor:Os.color,initialIconBackground:Os.iconBackground,onSave:we}):null,s.jsx(Qx,{open:T,onOpenChange:E,onWorktreeCreated:(ie,lt)=>{if(xe("chat"),t&&ye(!1),lt?.sessionId){Gt(lt.sessionId,ie);return}Kt({directoryOverride:ie,preserveDirectoryOverride:!0})}}),s.jsx(PS,{}),s.jsx(K2,{value:q,setValue:H,showDeletionDialog:L,setShowDeletionDialog:ae,onConfirm:fs}),s.jsx(Y2,{value:X,setValue:oe,onConfirm:zs}),s.jsx(q2,{value:he,setValue:Se,showDeletionDialog:L,setShowDeletionDialog:ae,onConfirm:ys})]})},wi=t=>t?s.jsx("span",{className:"text-foreground/80 dark:text-foreground/70",children:t}):void 0,br=t=>{if(!t)return"";const e=t.replace(/\\/g,"/");return e==="/"?"/":e.replace(/\/+$/,"")},lk=()=>{const{t}=Nt(),[e,n]=i.useState(!1),[r,o]=i.useState(!1),[a,c]=i.useState(null),[l,d]=i.useState([]),[u,m]=i.useState(!1),[f,p]=i.useState(!1),[y,g]=i.useState(!1),[b,x]=i.useState(!1),[h,C]=i.useState(new Set),w=ut(ce=>ce.getWorktreeMetadata),v=ut(ce=>ce.newSessionDraft),S=ut(ce=>ce.setNewSessionDraftTarget),k=ut(ce=>ce.setDraftBootstrapPendingDirectory),j=Qg,A=Zg,D=ut(ce=>ce.deleteSessions),N=ut(ce=>ce.archiveSessions),B=Ee(ce=>ce.showDeletionDialog),T=Ee(ce=>ce.setShowDeletionDialog),E=Js(ce=>ce.currentDirectory),_=Js(ce=>ce.homeDirectory),R=Js(ce=>ce.isHomeReady),V=ws(ce=>ce.projects),$=ws(ce=>ce.activeProjectId),{isMobile:z,isTablet:F,hasTouchInput:te}=Er(),ne=z||F||te,q=i.useMemo(()=>{const me=($?V.find(Ne=>Ne.id===$)??null:null)?.path??E;return br(me)},[$,E,V]),H=i.useCallback(ce=>{const Ne=br(ce.projectDirectory)||q;return{id:(V.find(P=>br(P.path)===Ne)??null)?.id??`path:${Ne}`,path:Ne}},[q,V]),X=b&&h.size>0,oe=i.useMemo(()=>{const ce=a?.worktree;return ce&&typeof ce.branch=="string"&&ce.branch.trim().length>0?!0:l.length>0&&l.every(({metadata:me})=>typeof me.branch=="string"&&me.branch.trim().length>0)},[a?.worktree,l]),he=a?.mode==="worktree",Se=he,Z=y||!he||!oe,ke=y||!he;i.useEffect(()=>{r||!R||V.length>0||(o(!0),n(!0))},[r,R,V.length]);const Y=i.useCallback(ce=>{c({sessions:ce.sessions,dateLabel:ce.dateLabel,mode:ce.mode??"session",worktree:ce.worktree??null})},[]),ge=i.useCallback(()=>{c(null),d([]),m(!1),p(!1),g(!1),x(!1),C(new Set)},[]),O=i.useCallback(async ce=>{if(ce.sessions.length===0)return;if(ce.sessions.length===1){const P=ce.sessions[0];await j(P.id)?le.success(t("sessions.sidebar.session.delete.success")):le.error(t("sessions.sidebar.session.delete.error"));return}const me=ce.sessions.map(P=>P.id),{deletedIds:Ne,failedIds:ue}=await D(me);if(Ne.length>0){const P=ue.length>0?ue.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:ue.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:ue.length}):ce.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:ce.dateLabel}):void 0;le.success(Ne.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:Ne.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:Ne.length}),{description:wi(P)})}ue.length>0&&le.error(ue.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:ue.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:ue.length}),{description:wi(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))})},[j,D,t]);i.useEffect(()=>Pr.onDeleteRequest(ce=>{if(!B&&(ce.mode??"session")==="session"){O(ce);return}Y(ce)}),[Y,B,O]),i.useEffect(()=>Pr.onDirectoryRequest(()=>{n(!0)}),[]),i.useEffect(()=>{if(!a){d([]),m(!1),p(!1),x(!1),C(new Set);return}const ce=a.sessions.map(ue=>{const P=w(ue.id);return P?{session:ue,metadata:P}:null}).filter(ue=>!!ue);d(ce),m(!1),x(!1),C(new Set);const me=new Map;if(a.worktree?.path&&me.set(br(a.worktree.path),a.worktree),ce.forEach(({metadata:ue})=>{ue.path&&me.set(br(ue.path),ue)}),me.size===0){x(!0);return}let Ne=!1;return(async()=>{const ue=new Map,P=new Set;await Promise.all(Array.from(me.entries()).map(async([M,de])=>{try{const xe=await Jg(de.path);ue.set(M,xe),xe?.isDirty&&P.add(M)}catch{de.status&&(ue.set(M,de.status),de.status.isDirty&&P.add(M))}})).catch(M=>{console.warn("Failed to inspect worktree status before deletion:",M)}),!Ne&&(C(P),x(!0),c(M=>{if(!M?.worktree?.path)return M;const de=br(M.worktree.path),xe=ue.get(de);if(!xe)return M;const U=M.worktree.status;return U?.isDirty===xe.isDirty&&U?.ahead===xe.ahead&&U?.behind===xe.behind&&U?.upstream===xe.upstream?M:{...M,worktree:{...M.worktree,status:xe}}}),d(M=>M.map(de=>{const xe=br(de.metadata.path),U=ue.get(xe);return U?{session:de.session,metadata:{...de.metadata,status:U}}:de})))})(),()=>{Ne=!0}},[a,w]),i.useEffect(()=>{oe||m(!1)},[oe]);const se=i.useCallback(async(ce,me)=>{const Ne=u&&oe,ue=H(ce),P=br(ce.path),M=br(ue.path);try{await Xg(ue,ce,{deleteRemoteBranch:Ne,deleteLocalBranch:me});const de=br(v?.directoryOverride);return v?.open&&P&&de===P&&M&&(k(null),S({projectId:ue.id,directoryOverride:M},{force:!0})),br(E)===P&&M&&Js.getState().setDirectory(M,{showOverlay:!1}),!0}catch(de){return le.error(t("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle"),{description:wi(de instanceof Error?de.message:t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),!1}},[oe,E,u,H,v?.directoryOverride,v?.open,k,S,t]),ee=i.useCallback((ce,me)=>{const Ne=u&&oe;(async()=>{if(!await se(ce,me))return;const P=t(Ne?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed");le.success(t("sessions.sidebar.sessionDialogs.worktree.removedTitle"),{description:wi(P)})})()},[oe,u,se,t]),je=i.useCallback(async()=>{if(a){g(!0);try{const ce=Se,me=ce&&u,Ne=ce&&f;if(a.sessions.length===0&&he&&a.worktree){ee(a.worktree,Ne),ge();return}if(a.sessions.length===1){const ue=a.sessions[0];if(!(he?await A(ue.id):await j(ue.id,{archiveWorktree:!1,deleteRemoteBranch:me,deleteLocalBranch:Ne}))){le.error(t(he?"sessions.sidebar.session.archive.error":"sessions.sidebar.session.delete.error")),g(!1);return}const M=!he&&ce?t(me?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.attachedArchived"):void 0;le.success(t(he?"sessions.sidebar.session.archive.success":"sessions.sidebar.session.delete.success"),{description:wi(M),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}else{const ue=a.sessions.map(de=>de.id);let P=[],M=[];if(he){const de=await N(ue);P=de.archivedIds,M=de.failedIds}else{const de=await D(ue);P=de.deletedIds,M=de.failedIds}if(he&&a.worktree&&M.length===0&&ee(a.worktree,Ne),P.length>0){const de=!he&&ce?t(me?"sessions.sidebar.sessionDialogs.worktree.archivedAndRemoteRemoved":"sessions.sidebar.sessionDialogs.worktree.attachedArchivedPlural"):void 0,U=[M.length>0?he?M.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToArchive",{count:M.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToArchive",{count:M.length}):M.length===1?t("sessions.sidebar.dialogs.deleteResult.singleFailedToDelete",{count:M.length}):t("sessions.sidebar.dialogs.deleteResult.manyFailedToDelete",{count:M.length}):a.dateLabel?t("sessions.sidebar.dialogs.deleteResult.removedFromDate",{dateLabel:a.dateLabel}):void 0,de].filter(Boolean).join(" ");le.success(he?P.length===1?t("sessions.sidebar.bulkActions.archivedSingle",{count:P.length}):t("sessions.sidebar.bulkActions.archivedPlural",{count:P.length}):P.length===1?t("sessions.sidebar.bulkActions.deletedSingle",{count:P.length}):t("sessions.sidebar.bulkActions.deletedPlural",{count:P.length}),{description:wi(U||void 0),action:{label:t("sessions.sidebar.sessionDialogs.ok"),onClick:()=>{}}})}if(M.length>0&&(le.error(he?M.length===1?t("sessions.sidebar.bulkActions.failedArchiveSingle",{count:M.length}):t("sessions.sidebar.bulkActions.failedArchivePlural",{count:M.length}):M.length===1?t("sessions.sidebar.bulkActions.failedDeleteSingle",{count:M.length}):t("sessions.sidebar.bulkActions.failedDeletePlural",{count:M.length}),{description:wi(t("sessions.sidebar.dialogs.deleteResult.tryAgain"))}),P.length===0)){g(!1);return}}he&&a.sessions.length===1&&a.worktree&&ee(a.worktree,Ne),ge()}finally{g(!1)}}},[a,u,f,j,D,A,N,ge,Se,he,ee,t]),De=a?.worktree??l[0]?.metadata??null,Be=a?a.mode==="worktree"?a.sessions.length===0?t("sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked"):a.sessions.length===1?t("sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked",{count:a.sessions.length}):t("sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked",{count:a.sessions.length}):a.sessions.length===1?a.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate",{dateLabel:a.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionOne"):a.dateLabel?t("sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate",{count:a.sessions.length,dateLabel:a.dateLabel}):t("sessions.sidebar.dialogs.sessionDelete.descriptionMany",{count:a.sessions.length}):"",Fe=a?s.jsxs("div",{className:Pe(he?"space-y-3":"space-y-2"),children:[a.sessions.length>0&&s.jsxs("div",{className:Pe(he?"rounded-lg bg-muted/30 p-3":"space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3"),children:[he&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-meta font-medium text-foreground",children:a.sessions.length===1?t("sessions.sidebar.sessionDialogs.linkedSessionSingle"):t("sessions.sidebar.sessionDialogs.linkedSessionPlural")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:a.sessions.length})]}),s.jsxs("ul",{className:Pe(he?"mt-2 space-y-1":"space-y-0.5"),children:[a.sessions.slice(0,5).map(ce=>s.jsxs("li",{className:Pe(he?"flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground":"typography-micro text-muted-foreground/80"),children:[s.jsx("span",{className:Pe(!he&&"hidden"),children:"•"}),s.jsx("span",{className:"truncate",children:ce.title||t("sessions.sidebar.session.untitled")})]},ce.id)),a.sessions.length>5&&s.jsx("li",{className:Pe(he?"px-2.5 py-1 text-xs text-muted-foreground/70":"typography-micro text-muted-foreground/70"),children:t("sessions.sidebar.dialogs.sessionList.more",{count:a.sessions.length-5})})]})]}),he?s.jsxs("div",{className:"space-y-2 rounded-lg bg-muted/30 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(I,{name:"git-branch",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-meta font-medium text-foreground",children:t("sessions.sidebar.sessionDialogs.worktree.label")}),De?.label?s.jsx("span",{className:"typography-micro text-muted-foreground/70",children:De.label}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground/80 break-all",children:De?ka(De.path,_):t("sessions.sidebar.sessionDialogs.worktree.pathUnavailable")}),X&&s.jsx("p",{className:"typography-micro text-status-warning",children:t("sessions.sidebar.sessionDialogs.worktree.uncommittedWarning")})]}):s.jsx("div",{className:"rounded-xl border border-border/40 bg-sidebar/60 p-3",children:s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("sessions.sidebar.sessionDialogs.delete.note")})})]}):null,Me=he?oe?s.jsxs("button",{type:"button",onClick:()=>{Z||m(ce=>!ce)},disabled:Z,className:Pe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",Z?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[u?s.jsx(I,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(I,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch")]}):s.jsx("span",{className:"text-xs text-muted-foreground/70",children:t("sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable")}):null,fe=he?s.jsxs("button",{type:"button",onClick:()=>{ke||p(ce=>!ce)},disabled:ke,className:Pe("flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors",ke?"cursor-not-allowed opacity-60":"hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"),children:[f?s.jsx(I,{name:"checkbox",className:"size-4 text-primary"}):s.jsx(I,{name:"checkbox-blank",className:"size-4"}),t("sessions.sidebar.sessionDialogs.actions.deleteLocalBranch")]}):null,Ae=he?s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex flex-col items-start gap-1",children:[fe,Me]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($e,{variant:"ghost",onClick:ge,disabled:y,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx($e,{variant:"destructive",onClick:je,disabled:y,children:t(y?"sessions.sidebar.sessionDialogs.actions.deleting":"sessions.sidebar.sessionDialogs.actions.deleteWorktree")})]})]}):s.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>T(!B),className:"inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50","aria-pressed":!B,children:[B?s.jsx(I,{name:"checkbox-blank",className:"size-4"}):s.jsx(I,{name:"checkbox",className:"size-4 text-primary"}),t("sessions.sidebar.dialogs.neverAsk")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($e,{variant:"ghost",onClick:ge,disabled:y,children:t("sessions.sidebar.dialogs.cancel")}),s.jsx($e,{variant:"destructive",onClick:je,disabled:y,children:y?t("sessions.sidebar.sessionDialogs.actions.deleting"):a?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction")})]})]}),pe=he?t("sessions.sidebar.sessionDialogs.actions.deleteWorktree"):a?.sessions.length===1?t("sessions.sidebar.dialogs.deleteSession.titleAction"):t("sessions.sidebar.dialogs.deleteSessions.titleAction");return s.jsxs(s.Fragment,{children:[ne?s.jsx(Ua,{open:!!a,onClose:()=>{y||ge()},title:pe,footer:s.jsx("div",{className:"flex justify-end gap-2",children:Ae}),children:s.jsxs("div",{className:"space-y-2 pb-2",children:[Be&&s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:Be}),Fe]})}):s.jsx($s,{open:!!a,onOpenChange:ce=>{if(!ce){if(y)return;ge()}},children:s.jsxs(Vs,{className:Pe(he?"max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3":"max-w-[min(520px,100vw-2rem)] space-y-2 pb-2"),children:[s.jsxs(Hs,{children:[s.jsxs(Ws,{className:Pe(he&&"flex items-center gap-2"),children:[he&&s.jsx(I,{name:"delete-bin",className:"h-5 w-5"}),pe]}),Be&&s.jsx(on,{children:Be})]}),s.jsx("div",{className:Pe(he&&"flex-1 min-h-0 overflow-y-auto space-y-2"),children:Fe}),s.jsx(ir,{className:"mt-2 gap-2 pt-1 pb-1",children:Ae})]})}),s.jsx(Jx,{open:e,onOpenChange:n})]})},uc=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").substring(0,50),ck=(t,e)=>{const n=uc(t),r=uc(e);return`${n}-${r}`.substring(0,60)},Sf=(t,e)=>`${t}/${e}`,dk=t=>{const e=t.replace(/\\/g,"/");return e==="/"?"/":e.length>1?e.replace(/\/+$/,""):e},Nf=(t,e)=>{const n=dk(e),r=t.directory,o=typeof r=="string"&&r.trim().length>0?t:{...t,directory:n};ax(t.id,n),ut.getState().markSessionAsOpenChamberCreated(t.id),vr.getState().upsertSession(o);try{Ca().ensureChild(n,{bootstrap:!1}).setState(c=>{const l=c.session.findIndex(u=>u.id===t.id);if(l>=0&&c.session[l]===o)return c;const d=l>=0?c.session.map((u,m)=>m===l?o:u):[...c.session,o].sort((u,m)=>u.id.localeCompare(m.id));return{session:d,sessionTotal:Math.max(c.sessionTotal,d.length),limit:Math.max(c.limit,d.length)}})}catch{}return o},uk=()=>{const t=ws.getState(),e=t.activeProjectId;if(!e)return null;const n=t.projects.find(o=>o.id===e);if(n?.path)return{id:n.id,path:n.path};const r=Js.getState().currentDirectory??null;if(r&&r.trim().length>0){const o=r.replace(/\\/g,"/").replace(/\/+$/,"")||r;return{id:`path:${o}`,path:o}}return null},Ol=ro()(Mf(t=>({isLoading:!1,error:null,createMultiRun:async e=>{const n=e.name.trim(),{groups:r,agent:o,files:a,setupCommands:c}=e;if(!n)return t({error:"Group name is required"}),null;if(!r||r.length===0)return t({error:"At least one run group is required"}),null;for(let l=0;l<r.length;l++){if(!r[l].prompt.trim())return t({error:`Group ${l+1}: prompt is required`}),null;if(r[l].models.length<1)return t({error:`Group ${l+1}: select at least 1 model`}),null;if(r[l].models.length>5)return t({error:`Group ${l+1}: maximum 5 models allowed`}),null}t({isLoading:!0,error:null});try{const l=uk();if(!l)return t({error:"Select a project",isLoading:!1}),null;const d=l.path,m=await hm(d)&&e.isolateRuns!==!1,f=uc(n),p=m?await Ga(d):void 0,y=m?await ex(d):null,g=[],b=c?.filter(v=>v.trim().length>0)??[];for(let v=0;v<r.length;v++){const S=r[v],k=S.prompt,j=new Map;for(const D of S.models){const N=`${D.providerID}:${D.modelID}`;j.set(N,(j.get(N)||0)+1)}const A=new Map;for(const D of S.models){const N=`${D.providerID}:${D.modelID}`,B=j.get(N)||1,T=(A.get(N)||0)+1;A.set(N,T);const E=ck(D.providerID,D.modelID),_=r.length>1?`g${v+1}`:void 0,R=B>1?Sf(f,`${E}/${T}`):Sf(f,E),V=_?`${_}/${R}`:R,$=w2({groupSlug:f,runGroup:_,providerID:D.providerID,modelID:D.modelID,index:B>1?T:void 0});try{if(!m){const ne=await _n.withDirectory(d,()=>_n.createSession({title:$}));Nf(ne,d),g.push({sessionId:ne.id,worktreePath:d,providerID:D.providerID,modelID:D.modelID,variant:D.variant,prompt:k});continue}const z=await tx(l,{preferredName:V,mode:"new",branchName:V,worktreeName:V,startRef:e.worktreeBaseBranch||"HEAD",setupCommands:b,returnAfterDirectoryCreated:!0},{resolvedRootTrackingRemote:y}),F={...z,createdFromBranch:p,kind:"standard"};await sx(l)&&await nx(z.path);const te=await _n.withDirectory(z.path,()=>_n.createSession({title:$}));Nf(te,z.path),ut.getState().setWorktreeMetadata(te.id,F),g.push({sessionId:te.id,worktreePath:z.path,providerID:D.providerID,modelID:D.modelID,variant:D.variant,prompt:k})}catch(z){console.warn("[MultiRun] Failed to create session:",z)}}}const x=c?.filter(v=>v.trim().length>0)??[];x.length>0&&rx(l,x).catch(()=>{console.warn("[MultiRun] Failed to save worktree setup commands")});const h=g.map(v=>v.sessionId),C=g[0]?.sessionId??null;if(h.length===0)return t({error:"Failed to create any sessions",isLoading:!1}),null;const w=a?.map(v=>({type:"file",mime:v.mime,filename:v.filename,url:v.url}));return(async()=>{try{const v=ix.getState().expandText;await Promise.allSettled(g.map(async S=>{try{const k=await v(S.prompt).catch(()=>S.prompt);await ox({sessionId:S.sessionId,directory:S.worktreePath,content:k,providerID:S.providerID,modelID:S.modelID,variant:S.variant,agent:o,files:w})}catch(k){console.warn("[MultiRun] Failed to start run:",k)}}))}catch(v){console.warn("[MultiRun] Failed to start runs:",v)}})(),t({isLoading:!1}),{groupSlug:f,sessionIds:h,firstSessionId:C}}catch(l){return t({error:l instanceof Error?l.message:"Failed to create Multi-Run",isLoading:!1}),null}},clearError:()=>{t({error:null})}}),{name:"multirun-store"})),fk="oc:lastWorktreeSourceBranch";function Nh(t){const e=mt.c(30),{git:n}=Jn(),r=tm(t),o=Cc(t),a=Ac(t),c=lx(t),l=wn(xk),d=wn(gk);let u,m;e[0]!==t||e[1]!==d||e[2]!==n||e[3]!==o||e[4]!==a?(u=()=>{!t||!n||o!==null||a||d(t,n,{silent:!0})},m=[t,n,d,o,a],e[0]=t,e[1]=d,e[2]=n,e[3]=o,e[4]=a,e[5]=u,e[6]=m):(u=e[5],m=e[6]),i.useEffect(u,m);let f;e[7]!==r?.all||e[8]!==t||e[9]!==l||e[10]!==n||e[11]!==o?(f=()=>{!t||!n||o===!0&&(r?.all||l(t,n))},e[7]=r?.all,e[8]=t,e[9]=l,e[10]=n,e[11]=o,e[12]=f):f=e[12];const p=r?.all;let y;e[13]!==t||e[14]!==l||e[15]!==n||e[16]!==o||e[17]!==p?(y=[t,n,o,p,l],e[13]=t,e[14]=l,e[15]=n,e[16]=o,e[17]=p,e[18]=y):y=e[18],i.useEffect(f,y);const g=a||o===!0&&c;let b;e:{if(!r?.all){let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[19]=j):j=e[19],b=j;break e}let k;e[20]!==r.all?(k=r.all.filter(pk).sort(),e[20]=r.all,e[21]=k):k=e[21],b=k}const x=b;let h;e:{if(!r?.all){let j;e[22]===Symbol.for("react.memo_cache_sentinel")?(j=[],e[22]=j):j=e[22],h=j;break e}let k;e[23]!==r.all?(k=r.all.filter(hk).map(mk).sort(),e[23]=r.all,e[24]=k):k=e[24],h=k}const C=h;let w;e:{if(!t){w=null;break e}if(o!==null){w=o;break e}if(g){w=null;break e}w=r?.all?!0:null}const v=w;let S;return e[25]!==v||e[26]!==g||e[27]!==x||e[28]!==C?(S={localBranches:x,remoteBranches:C,isLoading:g,isGitRepository:v},e[25]=v,e[26]=g,e[27]=x,e[28]=C,e[29]=S):S=e[29],S}function mk(t){return t.replace(/^remotes\//,"")}function hk(t){return t.startsWith("remotes/")}function pk(t){return!t.startsWith("remotes/")}function gk(t){return t.fetchStatus}function xk(t){return t.fetchBranches}const bk=({directory:t,value:e,onChange:n,className:r,disabled:o,id:a})=>{const{t:c}=Nt(),{localBranches:l,remoteBranches:d,isLoading:u,isGitRepository:m}=Nh(t),f=i.useMemo(()=>[...l,...d.map(y=>`remotes/${y}`)],[l,d]);i.useEffect(()=>{if(o||u||f.length===0||e&&f.includes(e))return;(async()=>{try{const g=t?await Ga(t).catch(()=>null):null,b=localStorage.getItem(fk);b&&f.includes(b)?n(b):g&&f.includes(g)?n(g):f.includes("main")?n("main"):f.includes("master")?n("master"):f[0]&&n(f[0])}catch{}})()},[f,t,o,u,n,e]);const p=o||!m||u;return s.jsxs("div",{children:[s.jsxs($n,{value:e,onValueChange:n,disabled:p,children:[s.jsx(zn,{id:a,size:"lg",className:r??"w-fit typography-meta text-foreground",children:s.jsx(Nn,{placeholder:c(u?"multiRun.branchSelector.status.loadingBranches":"multiRun.branchSelector.placeholder.selectSourceBranch")})}),s.jsx(Un,{className:"max-h-[280px] max-w-[320px]",children:u?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:c("multiRun.branchSelector.status.loadingBranches")}):l.length===0&&d.length===0?s.jsx("div",{className:"px-2 py-4 text-center typography-meta text-muted-foreground",children:c("multiRun.branchSelector.status.noBranchesFound")}):s.jsxs(s.Fragment,{children:[l.length>0&&s.jsxs(Gl,{children:[s.jsx(Ud,{className:"font-semibold text-foreground",children:c("multiRun.branchSelector.groups.localBranches")}),l.map(y=>s.jsx(Ls,{value:y,className:"whitespace-normal break-all",children:y},y))]}),l.length>0&&d.length>0&&s.jsx(cx,{}),d.length>0&&s.jsxs(Gl,{children:[s.jsx(Ud,{className:"font-semibold text-foreground",children:c("multiRun.branchSelector.groups.remoteBranches")}),d.map(y=>s.jsx(Ls,{value:`remotes/${y}`,className:"whitespace-normal break-all",children:y},`remotes/${y}`))]})]})})]}),m===!1&&s.jsx("p",{className:"typography-micro text-muted-foreground/70 mt-2",children:c("multiRun.branchSelector.status.notInGitRepository")})]})},yk=10*1024*1024,Bl=5,ga=t=>{const e=mt.c(3),{children:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:-1,className:"inline-flex items-center justify-center text-muted-foreground/50 hover:text-muted-foreground transition-colors",children:s.jsx(I,{name:"information",className:"h-3.5 w-3.5"})})}),e[0]=r):r=e[0];let o;return e[1]!==n?(o=s.jsxs(Et,{children:[r,s.jsx(Ft,{side:"top",className:"max-w-[240px]",children:n})]}),e[1]=n,e[2]=o):o=e[2],o},Si=t=>{const e=mt.c(9),{htmlFor:n,required:r,children:o,info:a}=t;let c;e[0]!==r?(c=r&&s.jsx("span",{className:"text-destructive ml-0.5",children:"*"}),e[0]=r,e[1]=c):c=e[1];let l;e[2]!==o||e[3]!==n||e[4]!==c?(l=s.jsxs("label",{htmlFor:n,className:"typography-meta font-medium text-foreground",children:[o,c]}),e[2]=o,e[3]=n,e[4]=c,e[5]=l):l=e[5];const d=a&&a;let u;return e[6]!==l||e[7]!==d?(u=s.jsxs("div",{className:"flex items-center gap-1.5",children:[l,d]}),e[6]=l,e[7]=d,e[8]=u):u=e[8],u},wk=({initialPrompt:t,onCreated:e,onCancel:n,isWindowed:r=!1})=>{const{t:o}=Nt(),[a,c]=i.useState(""),[l,d]=i.useState(()=>[{id:Ao(),prompt:"",models:[]}]),[u,m]=i.useState(""),[f,p]=i.useState([]),[y,g]=i.useState(!1),[b,x]=i.useState([]),[h,C]=i.useState(!1),[w,v]=i.useState(!1),[S,k]=i.useState(!0),j=i.useRef(null),A=Js(M=>M.currentDirectory??null),D=Js(M=>M.homeDirectory??null),N=i.useMemo(()=>{if(typeof window>"u")return null;const M=window.__VSCODE_CONFIG__?.workspaceFolder;return typeof M=="string"&&M.trim().length>0?M.trim():null},[]),B=ws(M=>M.activeProjectId),T=ws(M=>M.setActiveProjectIdOnly),E=ws(M=>M.projects),[_,R]=i.useState(()=>B??null);i.useEffect(()=>{if(B){R(B);return}!_&&E.length>0&&R(E[0].id)},[B,E,_]);const V=i.useMemo(()=>_?E.find(M=>M.id===_)??null:null,[E,_]),$=V?.path??A,z=i.useCallback(M=>{R(M),M!==B&&T(M)},[B,T]),{currentTheme:F}=Kr(),te=i.useCallback(M=>{const de=M.label?.trim()||Ri(M.path,D),xe=M.icon?Rc[M.icon]:null,U=M.color?qa[M.color]:void 0,be=xe?s.jsx(I,{name:xe,className:"h-3.5 w-3.5 shrink-0",style:U?{color:U}:void 0}):s.jsx(I,{name:"folder",className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80",style:U?{color:U}:void 0});return s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[M.iconImage?s.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center overflow-hidden rounded-[3px]",style:M.iconBackground?{backgroundColor:M.iconBackground}:void 0,children:s.jsx(Ya,{project:{id:M.id,iconImage:M.iconImage??null},options:{themeVariant:F.metadata.variant,iconColor:F.colors.surface.foreground},className:"h-full w-full object-contain",fallback:be})}):be,s.jsx("span",{className:"truncate",children:de})]})},[D,F.metadata.variant,F.colors.surface.foreground]),ne=i.useMemo(()=>{if(V?.path)return{id:V.id,path:V.path};const M=A??N;return M?{id:`path:${M}`,path:M}:null},[V,A,N]),[q]=i.useState(()=>typeof window<"u"?dr():!1),H=i.useMemo(()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),[]),X=Hf(),oe=i.useMemo(()=>{if(typeof window>"u")return null;const M=window.__OPENCHAMBER_MACOS_MAJOR__;if(typeof M=="number"&&Number.isFinite(M)&&M>0)return M;if(typeof navigator>"u")return null;const de=(navigator.userAgent||"").match(/Mac OS X (\d+)[._](\d+)/);if(!de)return null;const xe=Number.parseInt(de[1],10),U=Number.parseInt(de[2],10);return Number.isNaN(xe)?null:xe===10?U:xe},[]),he=i.useMemo(()=>q&&H||X?"pl-[5.5rem]":"pl-3",[q,H,X]),Se=i.useMemo(()=>!q||!H||oe===null?"":oe>=26?"h-12":oe<=15?"h-14":"",[q,H,oe]),Z=i.useCallback(async M=>{M.target.closest("button, a, input, select, textarea")||M.button===0&&q&&await dx()},[q]);i.useEffect(()=>{if(!n)return;const M=de=>{de.key==="Escape"&&(de.preventDefault(),de.stopPropagation(),n())};return window.addEventListener("keydown",M,!0),()=>window.removeEventListener("keydown",M,!0)},[n]);const[ke,Y]=i.useState(""),{isLoading:ge,isGitRepository:O}=Nh($),se=i.useRef(!1),ee=O===!0,je=ee&&S;i.useEffect(()=>{if(O===!1){se.current=!0,k(!1);return}O===!0&&se.current&&(se.current=!1,k(!0))},[O]);const De=Ol(M=>M.createMultiRun),Be=Ol(M=>M.error),Fe=Ol(M=>M.clearError);i.useEffect(()=>{typeof t=="string"&&t.trim().length>0&&d(M=>{const de=[...M];return de.length>0&&!de[0].prompt.trim()&&(de[0]={...de[0],prompt:t}),de})},[t]),i.useEffect(()=>{if(!ne)return;let M=!1;return v(!0),(async()=>{try{const de=await ux(ne);M||x(de)}catch{}finally{M||v(!1)}})(),()=>{M=!0}},[ne]);const Me=i.useCallback((M,de)=>{d(xe=>xe.map(U=>U.id===M?{...U,...de}:U))},[]),fe=i.useCallback(M=>{d(de=>de.filter(xe=>xe.id!==M))},[]),Ae=i.useCallback(()=>{d(M=>[...M,{id:Ao(),prompt:"",models:[]}])},[]),pe=async M=>{const de=M.target.files;if(!de)return;let xe=0;for(let U=0;U<de.length;U++){const be=de[U];if(be.size>yk){le.error(o("multirun.launcher.toast.fileTooLarge",{fileName:be.name}));continue}try{const ve=await new Promise((G,ye)=>{const Le=new FileReader;Le.onload=()=>G(Le.result),Le.onerror=ye,Le.readAsDataURL(be)});p(G=>[...G,{id:Ao(),filename:be.name,mimeType:be.type||"application/octet-stream",size:be.size,dataUrl:ve}]),xe++}catch(ve){console.error("File attach failed",ve),le.error(o("multirun.launcher.toast.attachFailed",{fileName:be.name}))}}xe>0&&le.success(xe===1?o("multirun.launcher.toast.attachedSingle",{count:xe}):o("multirun.launcher.toast.attachedPlural",{count:xe})),j.current&&(j.current.value="")},ce=M=>{p(de=>de.filter(xe=>xe.id!==M))},me=i.useMemo(()=>l.reduce((M,de)=>M+de.models.length,0),[l]),Ne=async M=>{M.preventDefault();const de=l.filter(xe=>xe.prompt.trim()&&xe.models.length>=1);if(de.length!==0&&!(me<1)){g(!0),Fe();try{_&&_!==B&&T(_);const xe=f.map(ye=>({mime:ye.mimeType,filename:ye.filename,url:ye.dataUrl})),U=b.filter(ye=>ye.trim().length>0),be=de.map(ye=>({prompt:ye.prompt.trim(),models:ye.models.map(Le=>({providerID:Le.providerID,modelID:Le.modelID,displayName:Le.displayName,variant:Le.variant}))})),ve={name:a.trim(),groups:be,agent:u||void 0,worktreeBaseBranch:je?ke:void 0,isolateRuns:je,files:xe.length>0?xe:void 0,setupCommands:U.length>0?U:void 0},G=await De(ve);G&&(G.firstSessionId&&ut.getState().setCurrentSession(G.firstSessionId),e?.())}finally{g(!1)}}},ue=!!(a.trim()&&l.some(M=>M.prompt.trim()&&M.models.length>=1)&&me>=1&&$&&!ge&&(O===!1||!je||ke)),P=b.filter(M=>M.trim()).length;return s.jsxs("form",{onSubmit:Ne,className:"flex flex-col h-full bg-background",children:[r?null:s.jsxs("header",{onMouseDown:Z,className:Pe("relative flex h-12 shrink-0 items-center justify-center border-b app-region-drag select-none",he,Se),style:{borderColor:"var(--interactive-border)"},children:[s.jsx("h1",{className:"typography-ui-label font-medium",children:o("multirun.launcher.title")}),n&&s.jsx("div",{className:"absolute right-0 flex items-center pr-3",children:s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:n,"aria-label":o("multirun.launcher.actions.closeEsc"),className:"inline-flex h-9 w-9 items-center justify-center p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary app-region-no-drag",children:s.jsx(I,{name:"close",className:"h-5 w-5"})})}),s.jsx(Ft,{children:s.jsx("p",{children:o("multirun.launcher.actions.closeEsc")})})]})})]}),s.jsx(Wa,{className:"flex-1 min-h-0 overflow-auto",size:64,hideTopShadow:!0,children:s.jsx("div",{className:"mx-auto w-full max-w-2xl px-4 sm:px-6 py-5",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Si,{htmlFor:"multirun-project",required:!0,children:o("multirun.launcher.project.label")}),E.length>0?s.jsxs($n,{value:_??void 0,onValueChange:z,children:[s.jsx(zn,{id:"multirun-project",size:"lg",className:"w-fit max-w-full",children:V?s.jsx(Nn,{children:te(V)}):s.jsx(Nn,{placeholder:o("multirun.launcher.project.placeholder")})}),s.jsx(Un,{fitContent:!0,children:E.map(M=>s.jsx(Ls,{value:M.id,className:"max-w-[24rem]",children:te(M)},M.id))})]}):s.jsx("p",{className:"typography-micro text-muted-foreground py-2",children:o("multirun.launcher.project.empty")})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Si,{htmlFor:"group-name",required:!0,info:s.jsx(ga,{children:o("multirun.launcher.groupName.info")}),children:o("multirun.launcher.groupName.label")}),s.jsx(vn,{id:"group-name",value:a,onChange:M=>c(M.target.value),placeholder:o("multirun.launcher.groupName.placeholder"),className:"typography-meta w-full",required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Si,{htmlFor:"multirun-worktree-base-branch",info:s.jsx(ga,{children:o("multirun.launcher.baseBranch.info")}),children:o("multirun.launcher.baseBranch.label")}),s.jsx(bk,{directory:$,value:ke,onChange:Y,disabled:!je,id:"multirun-worktree-base-branch"}),s.jsxs("label",{className:"mt-1.5 flex w-fit items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(Ti,{checked:S,onChange:k,disabled:!ee,ariaLabel:o("multirun.launcher.isolateRuns.label")}),s.jsx("span",{children:o("multirun.launcher.isolateRuns.label")})]})]}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(Si,{htmlFor:"multirun-agent",info:s.jsx(ga,{children:o("multirun.launcher.agent.info")}),children:o("multirun.launcher.agent.label")}),s.jsx(wh,{value:u,onChange:m,id:"multirun-agent"})]})]}),s.jsxs(eo,{open:h,onOpenChange:C,children:[s.jsxs(Bo,{className:"w-full flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-lg hover:bg-[var(--interactive-hover)]/50 transition-colors group",children:[s.jsx(I,{name:"terminal",className:"h-3.5 w-3.5 text-muted-foreground/70"}),s.jsx("span",{className:"typography-meta font-medium text-muted-foreground group-hover:text-foreground transition-colors",children:o("multirun.launcher.setupCommands.label")}),P>0&&s.jsx("span",{className:"inline-flex items-center justify-center h-4 min-w-4 px-1 rounded-full typography-micro font-medium",style:{backgroundColor:"var(--primary-base)",color:"var(--primary-foreground)",fontSize:"0.625rem",lineHeight:1},children:P}),s.jsx(I,{name:"arrow-down-s",className:Pe("h-3.5 w-3.5 text-muted-foreground/50 transition-transform duration-200 ml-auto",h&&"rotate-180")})]}),s.jsx(to,{children:s.jsx("div",{className:"pt-2 space-y-1.5",children:w?s.jsx("p",{className:"typography-meta text-muted-foreground/70 px-2",children:o("multirun.launcher.setupCommands.loading")}):s.jsxs(s.Fragment,{children:[b.map((M,de)=>s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx(vn,{value:M,onChange:xe=>{const U=[...b];U[de]=xe.target.value,x(U)},placeholder:o("multirun.launcher.setupCommands.commandPlaceholder"),className:"h-8 flex-1 font-mono text-xs"}),s.jsx("button",{type:"button",onClick:()=>x(b.filter((xe,U)=>U!==de)),className:"flex-shrink-0 flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50","aria-label":o("multirun.launcher.setupCommands.removeCommandAria"),children:s.jsx(I,{name:"close",className:"h-3.5 w-3.5"})})]},`${M}-${de}`)),s.jsxs("button",{type:"button",onClick:()=>x([...b,""]),className:"flex items-center gap-1 typography-meta text-muted-foreground hover:text-foreground transition-colors px-1",children:[s.jsx(I,{name:"add",className:"h-3 w-3"}),o("multirun.launcher.setupCommands.addCommand")]})]})})})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Si,{htmlFor:"prompt",required:!0,children:o("multirun.launcher.attachments.label")}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("input",{ref:j,type:"file",multiple:!0,className:"hidden",onChange:pe,accept:"*/*"}),s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>j.current?.click(),className:"inline-flex items-center gap-1 h-6 px-2 rounded-md typography-micro text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(I,{name:"attachment-2",className:"h-3 w-3"}),o("multirun.launcher.attachments.attach")]})}),s.jsx(Ft,{children:o("multirun.launcher.attachments.tooltip")})]}),f.map(M=>s.jsxs("div",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md typography-micro border",style:{backgroundColor:"var(--surface-elevated)",borderColor:"var(--interactive-border)"},children:[M.mimeType.startsWith("image/")?s.jsx(I,{name:"file-image",className:"h-3 w-3 text-muted-foreground"}):s.jsx(I,{name:"file",className:"h-3 w-3 text-muted-foreground"}),s.jsx("span",{className:"truncate max-w-[100px]",title:M.filename,children:M.filename}),s.jsx("button",{type:"button",onClick:()=>ce(M.id),className:"text-muted-foreground hover:text-destructive",children:s.jsx(I,{name:"close",className:"h-3 w-3"})})]},M.id))]})]}),l.map((M,de)=>s.jsx(vk,{group:M,groupIndex:de,canRemove:l.length>1,onUpdate:Me,onRemove:fe},M.id)),s.jsxs("button",{type:"button",onClick:Ae,className:"flex items-center gap-1.5 py-2 px-3 -mx-3 rounded-lg typography-meta font-medium text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 transition-colors",children:[s.jsx(I,{name:"add",className:"h-3.5 w-3.5"}),o("multirun.launcher.groups.addGroup")]}),Be&&s.jsx("div",{className:"px-3 py-2 rounded-lg typography-meta",style:{backgroundColor:"var(--status-error-background)",color:"var(--status-error)",borderWidth:1,borderColor:"var(--status-error-border)"},children:Be})]})})}),s.jsx("div",{className:"shrink-0 px-4 sm:px-6 py-3",children:s.jsxs("div",{className:"mx-auto w-full max-w-2xl flex items-center justify-end gap-2",children:[!je&&O!==null?s.jsxs("div",{className:"mr-auto flex min-w-0 items-center gap-1.5 typography-micro text-muted-foreground",children:[s.jsx(I,{name:"information",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:o("multirun.launcher.project.gitRequired")})]}):null,s.jsx($e,{type:"button",variant:"ghost",size:"sm",onClick:n,children:o("multirun.launcher.actions.cancel")}),s.jsx($e,{type:"submit",size:"sm",disabled:!ue||y,children:y?o("multirun.launcher.actions.creating"):s.jsx(s.Fragment,{children:o("multirun.launcher.actions.startWithRunCount",{count:me})})})]})})]})},vk=t=>{const e=mt.c(99),{group:n,groupIndex:r,canRemove:o,onUpdate:a,onRemove:c}=t,{t:l}=Nt(),[d,u]=i.useState(!1),[m,f]=i.useState(""),[p,y]=i.useState(!1),[g,b]=i.useState(""),[x,h]=i.useState(!1),[C,w]=i.useState(""),v=i.useRef(null),S=i.useRef(null),k=i.useRef(null),j=i.useRef(null);let A;e[0]!==n.id||e[1]!==n.models||e[2]!==a?(A=U=>{n.models.length>=Bl||a(n.id,{models:[...n.models,U]})},e[0]=n.id,e[1]=n.models,e[2]=a,e[3]=A):A=e[3];const D=A;let N;e[4]!==n.id||e[5]!==n.models||e[6]!==a?(N=U=>{a(n.id,{models:n.models.filter((be,ve)=>ve!==U)})},e[4]=n.id,e[5]=n.models,e[6]=a,e[7]=N):N=e[7];const B=N;let T;e[8]!==n.id||e[9]!==n.models||e[10]!==a?(T=(U,be)=>{a(n.id,{models:n.models.map((ve,G)=>G===U?be:ve)})},e[8]=n.id,e[9]=n.models,e[10]=a,e[11]=T):T=e[11];const E=T;let _;e[12]===Symbol.for("react.memo_cache_sentinel")?(_=(U,be)=>{if(U.startsWith("/")){const Le=U.indexOf(" "),Re=U.indexOf(`
|
|
211
211
|
`),J=Math.min(Le===-1?U.length:Le,Re===-1?U.length:Re);if(be<=J&&Le===-1){b(U.substring(1,J)),y(!0),u(!1),h(!1);return}}y(!1);const ve=U.substring(0,be),G=ve.lastIndexOf("#");if(G!==-1){const Le=G>0?ve[G-1]:null,Re=ve.substring(G+1);if((!Le||/\s/.test(Le))&&!Re.includes(" ")&&!Re.includes(`
|
|
212
212
|
`)){w(Re),h(!0),u(!1);return}}h(!1);const ye=ve.lastIndexOf("@");if(ye!==-1){const Le=ye>0?ve[ye-1]:null,Re=ve.substring(ye+1);(!Le||/\s/.test(Le))&&!Re.includes(" ")&&!Re.includes(`
|
|
213
|
-
`)?(f(Re),u(!0)):u(!1);return}u(!1)},e[12]=_):_=e[12];const R=_;let V;e[13]!==n.id||e[14]!==a?(V=U=>{a(n.id,{prompt:U})},e[13]=n.id,e[14]=a,e[15]=V):V=e[15];const $=V;let z;e[16]!==n.prompt||e[17]!==$?(z=U=>{const be=n.prompt,G=v.current?.selectionStart??be.length,Le=be.substring(0,G).lastIndexOf("@"),Re=U.relativePath&&U.relativePath.trim().length>0?U.relativePath.trim():U.path||U.name,J=Le!==-1?Le:G,L=`${be.substring(0,J)}@${Re} ${be.substring(G)}`,ae=J+Re.length+2;$(L),u(!1),f(""),requestAnimationFrame(()=>{const re=v.current;re&&(re.selectionStart=ae,re.selectionEnd=ae,re.focus()),R(L,ae)})},e[16]=n.prompt,e[17]=$,e[18]=z):z=e[18];const F=z;let te;e[19]!==n.prompt||e[20]!==$?(te=U=>{const be=n.prompt,G=v.current?.selectionStart??be.length,Le=be.substring(0,G).lastIndexOf("@"),Re=Le!==-1?Le:G,J=`${be.substring(0,Re)}@${U} ${be.substring(G)}`,L=Re+U.length+2;$(J),u(!1),f(""),requestAnimationFrame(()=>{const ae=v.current;ae&&(ae.selectionStart=L,ae.selectionEnd=L,ae.focus()),R(J,L)})},e[19]=n.prompt,e[20]=$,e[21]=te):te=e[21];const ne=te;let q;e[22]!==$?(q=U=>{const be=`/${U.name} `;$(be),y(!1),b(""),h(!1),requestAnimationFrame(()=>{const ve=v.current;ve&&(ve.focus(),ve.selectionStart=ve.value.length,ve.selectionEnd=ve.value.length),R(be,be.length)})},e[22]=$,e[23]=q):q=e[23];const H=q;let X;e[24]!==n.prompt||e[25]!==$?(X=(U,be)=>{const ve=n.prompt,ye=v.current?.selectionStart??ve.length,Re=ve.substring(0,ye).lastIndexOf("#"),J=Re!==-1?Re:ye,L=`${ve.substring(0,J)}#${be} ${ve.substring(ye)}`,ae=J+be.length+2;$(L),h(!1),w(""),requestAnimationFrame(()=>{const re=v.current;re&&(re.selectionStart=ae,re.selectionEnd=ae,re.focus()),R(L,ae)})},e[24]=n.prompt,e[25]=$,e[26]=X):X=e[26];const oe=X;let he;e[27]!==p||e[28]!==d||e[29]!==x?(he=U=>{if(p&&k.current&&(U.key==="Enter"||U.key==="ArrowUp"||U.key==="ArrowDown"||U.key==="Escape"||U.key==="Tab")){U.preventDefault(),k.current.handleKeyDown(U.key);return}d&&S.current&&(U.key==="Enter"||U.key==="ArrowUp"||U.key==="ArrowDown"||U.key==="Escape"||U.key==="Tab")&&(U.preventDefault(),S.current.handleKeyDown(U.key)),x&&j.current&&(U.key==="Enter"||U.key==="ArrowUp"||U.key==="ArrowDown"||U.key==="Escape"||U.key==="Tab")&&(U.preventDefault(),j.current.handleKeyDown(U.key))},e[27]=p,e[28]=d,e[29]=x,e[30]=he):he=e[30];const Se=he,Z=r+1;let ke;e[31]!==l||e[32]!==Z?(ke=l("multirun.launcher.groups.groupLabel",{index:Z}),e[31]=l,e[32]=Z,e[33]=ke):ke=e[33];let Y;e[34]!==ke?(Y=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:ke}),e[34]=ke,e[35]=Y):Y=e[35];let ge;e[36]!==o||e[37]!==n.id||e[38]!==c||e[39]!==l?(ge=o&&s.jsx("button",{type:"button",onClick:()=>c(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":l("multirun.launcher.groups.removeGroup"),children:s.jsx(I,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=o,e[37]=n.id,e[38]=c,e[39]=l,e[40]=ge):ge=e[40];let O;e[41]!==Y||e[42]!==ge?(O=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Y,ge]}),e[41]=Y,e[42]=ge,e[43]=O):O=e[43];let se;e[44]!==l?(se=l("multirun.launcher.groups.prompt.label"),e[44]=l,e[45]=se):se=e[45];let ee;e[46]!==se?(ee=s.jsx(Si,{required:!0,children:se}),e[46]=se,e[47]=ee):ee=e[47];const je=n.prompt;let De;e[48]!==$?(De=U=>{const be=U.target.value;$(be);const ve=U.target.selectionStart??be.length;R(be,ve)},e[48]=$,e[49]=De):De=e[49];let Be;e[50]!==l?(Be=l("multirun.launcher.groups.prompt.placeholder"),e[50]=l,e[51]=Be):Be=e[51];let Fe;e[52]!==n.prompt||e[53]!==Se||e[54]!==De||e[55]!==Be?(Fe=s.jsx(ki,{ref:v,value:je,onChange:De,onKeyDown:Se,placeholder:Be,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=Se,e[54]=De,e[55]=Be,e[56]=Fe):Fe=e[56];let Me;e[57]!==g||e[58]!==H||e[59]!==p?(Me=p?s.jsx(dm,{ref:k,searchQuery:g,onCommandSelect:H,onClose:()=>y(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=g,e[58]=H,e[59]=p,e[60]=Me):Me=e[60];let fe;e[61]!==ne||e[62]!==F||e[63]!==m||e[64]!==d?(fe=d?s.jsx(um,{ref:S,searchQuery:m,onFileSelect:F,onAgentSelect:ne,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=ne,e[62]=F,e[63]=m,e[64]=d,e[65]=fe):fe=e[65];let Ae;e[66]!==oe||e[67]!==x||e[68]!==C?(Ae=x?s.jsx(fm,{ref:j,searchQuery:C,onSnippetSelect:oe,onClose:()=>h(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=oe,e[67]=x,e[68]=C,e[69]=Ae):Ae=e[69];let pe;e[70]!==Fe||e[71]!==Me||e[72]!==fe||e[73]!==Ae?(pe=s.jsxs("div",{className:"relative",children:[Fe,Me,fe,Ae]}),e[70]=Fe,e[71]=Me,e[72]=fe,e[73]=Ae,e[74]=pe):pe=e[74];let ce;e[75]!==ee||e[76]!==pe?(ce=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ee,pe]}),e[75]=ee,e[76]=pe,e[77]=ce):ce=e[77];let me;e[78]!==l?(me=l("multirun.launcher.models.info",{max:Bl}),e[78]=l,e[79]=me):me=e[79];let Ne;e[80]!==me?(Ne=s.jsx(ga,{children:me}),e[80]=me,e[81]=Ne):Ne=e[81];let ue;e[82]!==l?(ue=l("multirun.launcher.models.label"),e[82]=l,e[83]=ue):ue=e[83];let P;e[84]!==Ne||e[85]!==ue?(P=s.jsx(Si,{required:!0,info:Ne,children:ue}),e[84]=Ne,e[85]=ue,e[86]=P):P=e[86];let M;e[87]!==n.models||e[88]!==D||e[89]!==B||e[90]!==E?(M=s.jsx(jh,{selectedModels:n.models,onAdd:D,onRemove:B,onUpdate:E,minModels:1,maxModels:Bl}),e[87]=n.models,e[88]=D,e[89]=B,e[90]=E,e[91]=M):M=e[91];let de;e[92]!==P||e[93]!==M?(de=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[P,M]}),e[92]=P,e[93]=M,e[94]=de):de=e[94];let xe;return e[95]!==O||e[96]!==ce||e[97]!==de?(xe=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[O,ce,de]}),e[95]=O,e[96]=ce,e[97]=de,e[98]=xe):xe=e[98],xe},jk=i.createContext(null),Sk=t=>{const e=mt.c(3),{children:n,value:r}=t;let o;return e[0]!==n||e[1]!==r?(o=s.jsx(jk.Provider,{value:r,children:n}),e[0]=n,e[1]=r,e[2]=o):o=e[2],o},kf=oo(()=>io(()=>import("./TerminalView-D8GzsMZF.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(t=>({default:t.TerminalView}))),Nk=oo(()=>io(()=>import("./DiagramView-C_f1Il8p.js"),__vite__mapDeps([9,1,2,4,5,3,6,7,8])).then(t=>({default:t.DiagramView}))),kk=oo(()=>io(()=>import("./NewWorktreeDialog-D7l2VA7o.js").then(t=>t.a8),__vite__mapDeps([6,1,2,3,4,5,7])).then(t=>({default:t.SettingsView}))),Ck=oo(()=>io(()=>import("./SettingsWindow-D5aAKCEM.js"),__vite__mapDeps([10,1,2,3,4,5,6,7])).then(t=>({default:t.SettingsWindow}))),Ak=oo(()=>io(()=>import("./MultiRunWindow-WBqBXcts.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8])).then(t=>({default:t.MultiRunWindow}))),Dk=()=>{const o=Ee(X=>X.isSidebarOpen),a=Ee(X=>X.isRightSidebarOpen),c=Ee(X=>X.isBottomTerminalOpen),l=Ee(X=>X.setRightSidebarOpen),d=Ee(X=>X.setBottomTerminalOpen),u=Ee(X=>X.activeMainTab),m=Ee(X=>X.setIsMobile),f=Ee(X=>X.isSessionSwitcherOpen),p=Ee(X=>X.isSettingsDialogOpen),y=Ee(X=>X.setSettingsDialogOpen),g=Ee(X=>X.isMultiRunLauncherOpen),b=Ee(X=>X.setMultiRunLauncherOpen),x=Ee(X=>X.multiRunLauncherPrefillPrompt),{isMobile:h,isTablet:C}=Er(),w=i.useRef(!1),v=i.useRef(!1),S=i.useRef(!1),[k,j]=i.useState(!1),[A,D]=i.useState(!1),[N,B]=i.useState(!1),[T,E]=i.useState(!1),_=i.useCallback(X=>{j(X),Ee.getState().setSessionSwitcherOpen(X)},[]),R=i.useRef(!1),V=i.useRef(typeof window>"u"?0:window.innerWidth),$=gd(-V.current),z=Xe.useRef(0),F=gd(V.current),te=Xe.useRef(0);Xe.useEffect(()=>{h&&(z.current=window.innerWidth,te.current=window.innerWidth)},[h]),Xe.useEffect(()=>{if(!h){B(!1);return}k&&B(!0),xd($,k?0:-z.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[k,h,$]),Xe.useEffect(()=>{if(!h){E(!1);return}R.current=A,A&&E(!0),xd(F,A?0:te.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[h,A,F]),Xe.useEffect(()=>{if(h)return $.on("change",X=>{const oe=z.current||V.current,he=k||X>-oe+.5;B(Se=>Se===he?Se:he)})},[h,$,k]),Xe.useEffect(()=>{if(h)return F.on("change",X=>{const oe=te.current||V.current,he=A||X<oe-.5;E(Se=>Se===he?Se:he)})},[h,A,F]),Xe.useEffect(()=>{h&&!f&&k&&_(!1)},[f,h,k,_]),Xe.useEffect(()=>{if(!h){S.current=!1;return}S.current||(S.current=!0,_(!1),D(!1),Ee.getState().isRightSidebarOpen&&l(!1))},[h,_,l]),Xe.useEffect(()=>{if(!h||u!=="chat"||k||A||p)return;let X=!1,oe;const he=Se=>{oe=window.setTimeout(()=>{if(X)return;const Z=ut.getState(),ke=Ee.getState();if(!(ke.activeMainTab!=="chat"||ke.isSettingsDialogOpen||Z.currentSessionId||Z.newSessionDraft?.open)){if(Z.isLoading){he(250);return}Z.openNewSessionDraft()}},Se)};return he(500),()=>{X=!0,oe!==void 0&&window.clearTimeout(oe)}},[u,h,p,k,A]),Xe.useEffect(()=>{!h||!p||(_(!1),D(!1),a&&l(!1))},[h,p,a,_,l]),Xx(),i.useEffect(()=>{Ee.getState().isMobile!==h&&m(h)},[h,m]),i.useEffect(()=>{if(typeof window>"u")return;let X;const oe=()=>{X===void 0&&(X=window.requestAnimationFrame(()=>{X=void 0,Ee.getState().updateProportionalSidebarWidths()}))};return window.addEventListener("resize",oe),()=>{window.removeEventListener("resize",oe),X!==void 0&&window.cancelAnimationFrame(X)}},[]),i.useEffect(()=>{if(typeof window>"u")return;let X;const oe=()=>{const Se=Ee.getState(),Z=window.innerWidth,ke=window.innerHeight;if(!h&&!C){const Y=Z<1140,ge=Z>=1220;Y?Se.isRightSidebarOpen&&(l(!1),w.current=!0):ge&&w.current&&(l(!0),w.current=!1);const O=ke<640,se=ke>=700;O?Se.isBottomTerminalOpen&&(d(!1),v.current=!0):se&&v.current&&(d(!0),v.current=!1)}},he=()=>{X===void 0&&(X=window.requestAnimationFrame(()=>{X=void 0,oe()}))};return oe(),window.addEventListener("resize",he),()=>{window.removeEventListener("resize",he),X!==void 0&&window.cancelAnimationFrame(X)}},[h,C,d,l]),i.useEffect(()=>{if(typeof window>"u")return;const X=Ee.subscribe((oe,he)=>{const Se=window.innerWidth,Z=window.innerHeight,ke=Se>=1220,Y=Z>=700;oe.isRightSidebarOpen!==he.isRightSidebarOpen&&ke&&(w.current=!1),oe.isBottomTerminalOpen!==he.isBottomTerminalOpen&&Y&&(v.current=!1)});return()=>{X()}},[h,C,d,l]);const ne=i.useCallback(()=>{k&&_(!1),D(!A)},[k,A,_]),q=i.useMemo(()=>{switch(u){case"plan":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Zm,{})});case"git":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(tc,{isActive:!A})});case"diff":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(qm,{})});case"terminal":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(kf,{})});case"files":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Xm,{})});case"context":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Wm,{})});case"diagram":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Nk,{})});default:return null}},[u,A]),H=u==="chat";return s.jsx(Zx,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:Pe("main-content-safe-area",h?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[s.jsx(J0,{}),s.jsx(Bj,{}),s.jsx(zj,{}),s.jsx(lk,{}),h?s.jsxs(Sk,{value:{leftDrawerOpen:k,rightDrawerOpen:A,toggleLeftDrawer:()=>{const X=!k;A&&D(!1),_(X)},toggleRightDrawer:ne,leftDrawerX:$,rightDrawerX:F,leftDrawerWidth:z,rightDrawerWidth:te,setMobileLeftDrawerOpen:_,setRightSidebarOpen:D},children:[!p&&s.jsx(su,{onToggleLeftDrawer:()=>{const X=!k;A&&D(!1),_(X)},onToggleRightDrawer:()=>{ne()},leftDrawerOpen:k,rightDrawerOpen:A}),s.jsx("div",{"data-page-scroll-lock":"true",className:Pe("flex flex-1 overflow-hidden relative",p&&"hidden"),children:s.jsxs("main",{className:"w-full h-full overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:Pe("absolute inset-0",!H&&"invisible"),children:s.jsx(Zs,{children:s.jsx(Ql,{})})}),q&&s.jsx("div",{className:"absolute inset-0",children:s.jsx(Zs,{children:q})}),g&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Zs,{children:s.jsx(wk,{initialPrompt:x,onCreated:()=>b(!1),onCancel:()=>b(!1)})})}),N&&s.jsx(bd.div,{className:"absolute inset-0 z-20 bg-sidebar","data-page-scroll-lock":"true",style:{x:$},"aria-hidden":!k,children:s.jsx(Zs,{children:s.jsx(jf,{mobileVariant:!0})})}),T&&s.jsx(bd.div,{className:"absolute inset-0 z-20 bg-sidebar","data-page-scroll-lock":"true",style:{x:F},"aria-hidden":!A,children:s.jsx(Zs,{children:s.jsx(i.Suspense,{fallback:null,children:s.jsx(tc,{isActive:A})})})})]})}),p&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:s.jsx(Zs,{children:s.jsx(i.Suspense,{fallback:null,children:s.jsx(kk,{onClose:()=>y(!1)})})})})]}):s.jsxs(s.Fragment,{children:[s.jsx(ly,{}),s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[s.jsx(iy,{isOpen:o,isMobile:h,className:"border-border/50",topBar:s.jsx(oy,{}),children:s.jsx(jf,{})}),s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[s.jsx(su,{}),s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border/50 bg-background","data-page-scroll-lock":"true",children:[s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true",children:[s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:Pe("absolute inset-0",!H&&"invisible"),children:s.jsx(Zs,{children:s.jsx(Ql,{})})}),q&&s.jsx("div",{className:"absolute inset-0",children:s.jsx(Zs,{children:q})})]}),s.jsx(Q0,{})]})}),s.jsx(ey,{isOpen:c,isMobile:h,children:c?s.jsx(Zs,{children:s.jsx(i.Suspense,{fallback:null,children:s.jsx(kf,{})})}):null})]}),s.jsx(hy,{isOpen:a,className:"bg-background border-t border-border/50",children:s.jsx(Zs,{children:s.jsx(Rv,{})})})]})]})]}),s.jsx(i.Suspense,{fallback:null,children:s.jsx(Ck,{open:p,onOpenChange:y})}),s.jsx(i.Suspense,{fallback:null,children:s.jsx(Ak,{open:g,onOpenChange:b,initialPrompt:x})})]})]})})},Ik=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},On=t=>{const e=mt.c(8),{label:n,value:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=o):o=e[0];let a;e[1]!==n?(a=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=a):a=e[2];let c;e[3]!==r?(c=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=c):c=e[4];let l;return e[5]!==a||e[6]!==c?(l=s.jsxs("div",{className:"rounded-md p-2",style:o,children:[a,c]}),e[5]=a,e[6]=c,e[7]=l):l=e[7],l},Cf=t=>{const e=mt.c(43),{title:n,snapshot:r,emptyLabel:o}=t,{t:a}=Nt();let c;if(e[0]!==o||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==a||e[6]!==n){const l=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(Rk,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let m;e[10]!==n?(m=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=m):m=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==a?(f=r.startedAt?Ik(r.durationMs):a("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=a,e[15]=f):f=e[15];let p;e[16]!==f?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=p):p=e[17];let y;e[18]!==m||e[19]!==p?(y=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m,p]}),e[18]=m,e[19]=p,e[20]=y):y=e[20];let g;e[21]!==a?(g=a("memoryDebugPanel.metric.metrics"),e[21]=a,e[22]=g):g=e[22];let b;e[23]!==r.entries.length||e[24]!==g?(b=s.jsx(On,{label:g,value:r.entries.length}),e[23]=r.entries.length,e[24]=g,e[25]=b):b=e[25];let x;e[26]!==a?(x=a("memoryDebugPanel.metric.samples"),e[26]=a,e[27]=x):x=e[27];let h;e[28]!==x||e[29]!==u?(h=s.jsx(On,{label:x,value:u}),e[28]=x,e[29]=u,e[30]=h):h=e[30];let C;e[31]!==a?(C=a("memoryDebugPanel.metric.lastUpdate"),e[31]=a,e[32]=C):C=e[32];let w;e[33]!==r.lastUpdatedAt||e[34]!==a?(w=r.lastUpdatedAt?a("memoryDebugPanel.common.live"):a("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=a,e[35]=w):w=e[35];let v;e[36]!==C||e[37]!==w?(v=s.jsx(On,{label:C,value:w}),e[36]=C,e[37]=w,e[38]=v):v=e[38];let S;e[39]!==h||e[40]!==v||e[41]!==b?(S=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[b,h,v]}),e[39]=h,e[40]=v,e[41]=b,e[42]=S):S=e[42],c=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[y,S,l.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:o}):s.jsx(Vn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:l.map(k=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:k.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:a("memoryDebugPanel.metric.countValue",{value:k.count})}),s.jsx("span",{children:a("memoryDebugPanel.metric.avgValue",{value:k.avg})}),s.jsx("span",{children:a("memoryDebugPanel.metric.maxValue",{value:k.max})}),s.jsx("span",{children:a("memoryDebugPanel.metric.totalValue",{value:k.total})})]})]},k.metric))})})]}),e[0]=o,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=a,e[6]=n,e[7]=c}else c=e[7];return c},Pk=t=>{const e=mt.c(99),{onClose:n}=t,{t:r}=Nt(),[o,a]=i.useState("memory"),[c,l]=i.useState("idle"),d=ut(Ek),u=mm(Mk),m=Ic(),f=fx(Fk),p=rr(Lk),[y,g]=i.useState(Ok),[b,x]=i.useState(Bk);let h;e[0]!==y.entries?(h=new Map,y.entries.forEach(ue=>{h.set(ue.metric,ue.count)}),e[0]=y.entries,e[1]=h):h=e[1];let C;e[2]!==h?(C=h.get("ui.message_list.render")??0,e[2]=h,e[3]=C):C=e[3];let w;e[4]!==h?(w=h.get("ui.message_list.render.streaming")??0,e[4]=h,e[5]=w):w=e[5];let v;e[6]!==h?(v=h.get("ui.chat_message.render")??0,e[6]=h,e[7]=v):v=e[7];let S;e[8]!==h?(S=h.get("ui.chat_message.render.streaming")??0,e[8]=h,e[9]=S):S=e[9];let k;e[10]!==h?(k=h.get("ui.chat_message.render.static_during_stream")??0,e[10]=h,e[11]=k):k=e[11];let j;e[12]!==h?(j=h.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[12]=h,e[13]=j):j=e[13];let A;e[14]!==C||e[15]!==w||e[16]!==v||e[17]!==S||e[18]!==k||e[19]!==j?(A={messageListRender:C,messageListRenderStreaming:w,chatMessageRender:v,chatMessageRenderStreaming:S,chatMessageRenderStaticDuringStream:k,chatMessageRenderStaticOutsideActiveTurnDuringStream:j},e[14]=C,e[15]=w,e[16]=v,e[17]=S,e[18]=k,e[19]=j,e[20]=A):A=e[20];const D=A;let N,B;e[21]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{const ue=()=>{g(na()),x(ra())};ue();const P=window.setInterval(ue,500);return()=>window.clearInterval(P)},B=[],e[21]=N,e[22]=B):(N=e[21],B=e[22]),i.useEffect(N,B);let T,E;e[23]!==c?(T=()=>{if(c==="idle")return;const ue=window.setTimeout(()=>{l("idle")},1500);return()=>window.clearTimeout(ue)},E=[c],e[23]=c,e[24]=T,e[25]=E):(T=e[24],E=e[25]),i.useEffect(T,E);let _=0,R=0,V=0;for(const ue of Object.keys(f)){const P=f[ue]??[];R=R+P.length;for(const M of P)M.role==="user"?V=V+1:M.role==="assistant"&&(_=_+1)}let $;e[26]!==_||e[27]!==R||e[28]!==V?($={assistant:_,total:R,user:V},e[26]=_,e[27]=R,e[28]=V,e[29]=$):$=e[29];const z=$;let F;if(e[30]!==d||e[31]!==f||e[32]!==u||e[33]!==m||e[34]!==r){let ue;e[36]!==d||e[37]!==f||e[38]!==u||e[39]!==r?(ue=P=>{const M=f[P.id]??[];let de=0,xe=0;for(const be of M)be.role==="user"?xe=xe+1:be.role==="assistant"&&(de=de+1);const U=u.get(P.id);return{id:P.id,title:P.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:de,messageCount:M.length,userMessageCount:xe,isStreaming:U?.isStreaming||!1,isZombie:U?.isZombie||!1,backgroundCount:U?.backgroundMessageCount||0,lastAccessed:U?.lastAccessedAt||0,isCurrent:P.id===d}},e[36]=d,e[37]=f,e[38]=u,e[39]=r,e[40]=ue):ue=e[40],F=m.map(ue).sort(_k),e[30]=d,e[31]=f,e[32]=u,e[33]=m,e[34]=r,e[35]=F}else F=e[35];const te=F;let ne;e[41]!==f?(ne=Object.keys(f),e[41]=f,e[42]=ne):ne=e[42];const q=ne.length;let H;e[43]===Symbol.for("react.memo_cache_sentinel")?(H=async()=>{try{const ue={generatedAt:new Date().toISOString(),ui:na(),vscode:ra()};await navigator.clipboard.writeText(JSON.stringify(ue,null,2)),l("copied")}catch{l("error")}},e[43]=H):H=e[43];const X=H;let oe;e[44]===Symbol.for("react.memo_cache_sentinel")?(oe={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[44]=oe):oe=e[44];let he;e[45]!==o?(he=o==="memory"?s.jsx(I,{name:"database-2",className:"h-4 w-4 text-[var(--surface-foreground)]"}):s.jsx(I,{name:"bar-chart-box",className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[45]=o,e[46]=he):he=e[46];let Se;e[47]!==r?(Se=r("memoryDebugPanel.title"),e[47]=r,e[48]=Se):Se=e[48];let Z;e[49]!==Se?(Z=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:Se}),e[49]=Se,e[50]=Z):Z=e[50];let ke;e[51]!==he||e[52]!==Z?(ke=s.jsxs("div",{className:"flex items-center gap-2",children:[he,Z]}),e[51]=he,e[52]=Z,e[53]=ke):ke=e[53];let Y;e[54]!==o?(Y=o==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx($e,{size:"xs",variant:"ghost",onClick:X,children:s.jsx(I,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx($e,{size:"xs",variant:"ghost",onClick:()=>{yp(),g(na()),x(ra())},children:s.jsx(I,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[54]=o,e[55]=Y):Y=e[55];let ge;e[56]!==n?(ge=n?s.jsx($e,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(I,{name:"close",className:"h-4 w-4"})}):null,e[56]=n,e[57]=ge):ge=e[57];let O;e[58]!==Y||e[59]!==ge?(O=s.jsxs("div",{className:"flex items-center gap-1",children:[Y,ge]}),e[58]=Y,e[59]=ge,e[60]=O):O=e[60];let se;e[61]!==ke||e[62]!==O?(se=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[ke,O]}),e[61]=ke,e[62]=O,e[63]=se):se=e[63];let ee;e[64]===Symbol.for("react.memo_cache_sentinel")?(ee={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[64]=ee):ee=e[64];const je=o==="memory"?"secondary":"ghost";let De;e[65]===Symbol.for("react.memo_cache_sentinel")?(De=()=>a("memory"),e[65]=De):De=e[65];let Be;e[66]!==r?(Be=r("memoryDebugPanel.tabs.memory"),e[66]=r,e[67]=Be):Be=e[67];let Fe;e[68]!==je||e[69]!==Be?(Fe=s.jsx($e,{size:"sm",variant:je,className:"flex-1",onClick:De,children:Be}),e[68]=je,e[69]=Be,e[70]=Fe):Fe=e[70];const Me=o==="streaming"?"secondary":"ghost";let fe;e[71]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>a("streaming"),e[71]=fe):fe=e[71];let Ae;e[72]!==r?(Ae=r("memoryDebugPanel.tabs.streaming"),e[72]=r,e[73]=Ae):Ae=e[73];let pe;e[74]!==Me||e[75]!==Ae?(pe=s.jsx($e,{size:"sm",variant:Me,className:"flex-1",onClick:fe,children:Ae}),e[74]=Me,e[75]=Ae,e[76]=pe):pe=e[76];let ce;e[77]!==Fe||e[78]!==pe?(ce=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ee,children:[Fe,pe]}),e[77]=Fe,e[78]=pe,e[79]=ce):ce=e[79];let me;e[80]!==o||e[81]!==q||e[82]!==c||e[83]!==d||e[84]!==f||e[85]!==z||e[86]!==u||e[87]!==te||e[88]!==m||e[89]!==D||e[90]!==y||e[91]!==r||e[92]!==p||e[93]!==b?(me=o==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(On,{label:r("memoryDebugPanel.metric.totalMessages"),value:z.total}),s.jsx(On,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${q} / ${Wd.MAX_SESSIONS}`}),s.jsx(On,{label:r("memoryDebugPanel.metric.userMessages"),value:z.user}),s.jsx(On,{label:r("memoryDebugPanel.metric.assistantMessages"),value:z.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:mx()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:Wd.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:p})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(Vn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:te.map(ue=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:ue.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:ue.title}),ue.isStreaming?s.jsx(I,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,ue.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:ue.assistantMessageCount,user:ue.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:ue.messageCount})}),ue.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",ue.backgroundCount]}):null]})]},ue.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx($e,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:m.map(Vk),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:z,sessionMessageRoleCounts:te.map($k),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(Ft,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(c==="copied"?"memoryDebugPanel.streaming.copy.copied":c==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx($e,{size:"xs",variant:"outline",onClick:X,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(On,{label:r("memoryDebugPanel.metric.uiMetrics"),value:y.entries.length}),s.jsx(On,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:b.entries.length}),s.jsx(On,{label:r("memoryDebugPanel.metric.messageListRenders"),value:D.messageListRender}),s.jsx(On,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:D.messageListRenderStreaming}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:D.chatMessageRender}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:D.chatMessageRenderStreaming}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:D.chatMessageRenderStaticDuringStream}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:D.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Cf,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:y,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),b.entries.length>0?s.jsx(Cf,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}),e[80]=o,e[81]=q,e[82]=c,e[83]=d,e[84]=f,e[85]=z,e[86]=u,e[87]=te,e[88]=m,e[89]=D,e[90]=y,e[91]=r,e[92]=p,e[93]=b,e[94]=me):me=e[94];let Ne;return e[95]!==se||e[96]!==ce||e[97]!==me?(Ne=s.jsxs(hx,{className:"fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area",style:oe,children:[se,ce,me]}),e[95]=se,e[96]=ce,e[97]=me,e[98]=Ne):Ne=e[98],Ne},Tk=Pk;function Rk(t,e){return t+e.count}function Ek(t){return t.currentSessionId}function Mk(t){return t.sessionMemoryState}function Fk(t){return t.message}function Lk(t){return t.totalRequestCount}function Ok(){return na()}function Bk(){return ra()}function _k(t,e){return e.lastAccessed-t.lastAccessed}function Vk(t){return{id:t.id,title:t.title}}function $k(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}const zk=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},Uk=async()=>{const t=zk()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Af="openchamber:menu-action",_l="openchamber:check-for-updates",Wk=t=>{const e=ut(j=>j.openNewSessionDraft),n=Ee(j=>j.toggleCommandPalette),r=Ee(j=>j.setCommandPaletteOpen),o=Ee(j=>j.toggleHelpDialog),a=Ee(j=>j.toggleSidebar),c=Ee(j=>j.setSessionSwitcherOpen),l=Ee(j=>j.setActiveMainTab),d=Ee(j=>j.setSettingsDialogOpen),u=Ee(j=>j.setAboutDialogOpen),m=Ee(j=>j.toggleRightSidebar),f=Ee(j=>j.setRightSidebarOpen),p=Ee(j=>j.setRightSidebarTab),y=Ee(j=>j.toggleBottomTerminal),g=Ee(j=>j.setBottomTerminalExpanded),b=wo(j=>j.checkForUpdates),{setThemeMode:x}=Kr(),h=i.useRef(!1),C=i.useCallback(()=>{h.current||(h.current=!0,b().then(()=>{const{available:j,error:A}=wo.getState();if(A){le.error("Failed to check for updates",{description:A});return}j||le.success("You are on the latest version")}).finally(()=>{h.current=!1}))},[b]),w=i.useCallback(()=>{Pr.requestDirectoryDialog()},[]),v=i.useCallback(j=>{const A=px();if(A.length===0)return;const D=ut.getState().currentSessionId,N=A.findIndex(E=>E.id===D);let B=j>0?0:A.length-1;N>=0&&(B=(N+j+A.length)%A.length);const T=A[B];T&&(l("chat"),c(!1),ut.getState().setCurrentSession(T.id))},[l,c]),S=i.useCallback(j=>{const{activeProjectId:A,projects:D,setActiveProject:N}=ws.getState();if(D.length===0)return;const B=D.findIndex(_=>_.id===A);let T=j>0?0:D.length-1;B>=0&&(T=(B+j+D.length)%D.length);const E=D[T];E&&N(E.id)},[]),k=i.useCallback(j=>{switch(j){case"about":u(!0);break;case"settings":d(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l("chat"),c(!1),e();break;case"new-worktree-session":l("chat"),c(!1),cm();break;case"change-workspace":w();break;case"toggle-right-sidebar":m();break;case"open-right-sidebar-git":f(!0),p("git");break;case"open-right-sidebar-files":f(!0),p("files");break;case"toggle-terminal":y();break;case"toggle-terminal-expanded":g(!Ee.getState().isBottomTerminalExpanded);break;case"copy":{const A=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(A)||Uk();break}case"theme-light":x("light");break;case"theme-dark":x("dark");break;case"theme-system":x("system");break;case"toggle-sidebar":a();break;case"toggle-memory-debug":t?.();break;case"go-back":Js.getState().goBack();break;case"go-forward":Js.getState().goForward();break;case"previous-session":v(-1);break;case"next-session":v(1);break;case"previous-project":S(-1);break;case"next-project":S(1);break;case"help-dialog":o();break;case"download-logs":{gx().catch(()=>{le.error("Failed to collect OpenCode status")});break}}},[w,S,v,t,e,u,l,c,r,d,g,f,p,x,y,n,o,m,a]);i.useEffect(()=>{const j=D=>{const N=D.detail;N&&k(N)},A=()=>{C()};return window.addEventListener(Af,j),window.addEventListener(_l,A),()=>{window.removeEventListener(Af,j),window.removeEventListener(_l,A)}},[k,C]),i.useEffect(()=>{if(typeof window>"u")return;const A=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof A!="function")return;let D=null,N=null;return A("openchamber:menu-action",B=>{const T=B?.payload;typeof T=="string"&&k(T)}).then(B=>{D=B}).catch(()=>{}),A("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(_l))}).then(B=>{N=B}).catch(()=>{}),()=>{(async()=>{try{const T=D?.();T instanceof Promise&&await T}catch{}try{const T=N?.();T instanceof Promise&&await T}catch{}})()}},[k])},Hk="openchamber:tray-action",Df=5e3,Gk=120,Kk=45e3,kh=20,If=()=>typeof window>"u"?!1:window.__OPENCHAMBER_PLATFORM__==="darwin",qk=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},Yk=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},La=t=>t.time?.updated??t.time?.created??0,Qk=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},Jk=(t,e,n,r,o)=>{if(!t)return"";const a=wx(n,r,t),c=e.project?.name,l=a?.label?.trim()||c?.trim()||Qk(t),d=oa(t);let u=d&&o.get(d)||"";if(!u){for(const[m,f]of wn.getState().directories)if(oa(m)===d){u=f.status?.current??"";break}}if(!u)for(const m of r.values()){const f=m.find(p=>oa(p.path)===d);if(f?.branch){u=f.branch;break}}return u?`${l} · ${u}`:l},Xk=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=mn.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(c=>[c.providerId,c])),a=[];for(const c of vm){if(!e.includes(c.id))continue;const l=o.get(c.id);if(!l||l.configured!==!0)continue;const d=[];for(const[m,f]of Object.entries(l.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:yc(m),value:Io(f.valueLabel,p)})}const u=!l.ok&&l.error?l.error:d.length===0?"No rate limits reported":null;a.push({provider:c.name,rows:d,status:u})}return{mode:r,groups:a}},Zk=async()=>{try{if(Ji())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Ur();if(e&&Sa(e,t))return"Local OpenChamber";const r=(await Gf()).hosts.find(o=>e?Sa(e,Kf(o)):!1);return r?.label?.trim()?qf(r.label.trim()):"Instance"}catch{return""}},eC=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=Ca()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[a,c]of o.children.entries()){const l=c.getState();l.vcs?.branch&&e.set(oa(a)??a,l.vcs.branch);for(const d of l.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(l.session_status??{})){const m=u?.type,f=m==="busy"?"busy":m==="retry"?"retry":"idle",p=t.get(d);(!p||p==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(l.permission??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"permission",id:m.id,sessionId:f,sessionTitle:"",label:qk(m),directory:a})}for(const[d,u]of Object.entries(l.question??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"question",id:m.id,sessionId:f,sessionTitle:"",label:Yk(m),directory:a})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},tC=()=>{const t=vr.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort((r,o)=>La(o)-La(r)).slice(0,kh).forEach(r=>{const o=Tr(r);o&&e.add(o)});const n=new Map;for(const r of t){if(!r?.id)continue;const o=Tr(r);if(!o||!e.has(o))continue;const a=n.get(o)??[];a.push(r.id),n.set(o,a)}return n},sC=t=>{const e=eC(),n=pm.getState().index.session,r=vr.getState().activeSessions,o=new Map(e.titleById),a=new Map;for(const x of r)if(x?.id&&(x.title&&o.set(x.id,x.title),x.parentID)){const h=a.get(x.parentID)??[];h.push(x.id),a.set(x.parentID,h)}const c=x=>{const h=[],C=[...a.get(x)??[]],w=new Set;for(;C.length;){const v=C.pop();w.has(v)||(w.add(v),h.push(v),C.push(...a.get(v)??[]))}return h},l=gm.getState().statusById,d=x=>{const h=e.statusById.get(x);return h&&h!=="idle"?h:l.get(x)?.status??h??"idle"},u=x=>{const h=x.map(C=>d(C));return h.includes("busy")?"busy":h.includes("retry")?"retry":"idle"},m=ws.getState().projects,f=ut.getState().availableWorktreesByProject,p=r.filter(x=>x?.id&&!x.parentID).slice().sort((x,h)=>La(h)-La(x)).slice(0,kh).map(x=>{const h=[x.id,...c(x.id)],C=Tr(x)??"";return{id:x.id,title:x.title||"Untitled session",status:u(h),branch:C?e.branchByDirectory.get(C)??"":"",unseen:h.reduce((w,v)=>w+(n.unseenCount[v]??0),0),hasError:h.some(w=>n.unseenHasError[w]??!1),directory:C,subtitle:Jk(C,x,m,f,e.branchByDirectory)}}),y=e.approvals.map(x=>({...x,sessionTitle:o.get(x.sessionId)||""})),g=Ee.getState();let b=0;if(g.dockBadgeEnabled)for(const x of r){if(!x?.id||x.parentID)continue;let h=n.unseenCount[x.id]??0;h===0&&g.notifyOnSubtasks&&(h=c(x.id).reduce((C,w)=>C+(n.unseenCount[w]??0),0)),h>0&&(b+=1)}return{sessions:p,approvals:y,instanceName:t,usage:Xk(),dockBadgeCount:b}},nC=()=>{i.useEffect(()=>{if(!If()||!Oa())return;let t=!1,e="",n=null,r="";const o=()=>{if(t)return;const k=sC(r),j=JSON.stringify(k);j!==e&&(e=j,Wr("desktop_tray_update",k))};Zk().then(k=>{t||(r=k,o())});const a=async()=>{const k=tC();await Promise.all([...k.entries()].map(async([j,A])=>{const D=await _n.getSessionStatusForDirectory(j).catch(()=>null);t||D===null||bx(j,D,A)}))},c=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,o()},Gk))},l=new Map,d=()=>{if(t)return;let k;try{k=Ca()}catch{return}const j=new Set;for(const[A,D]of k.children.entries())j.add(A),l.has(A)||l.set(A,D.subscribe(()=>c()));for(const[A,D]of l)j.has(A)||(D(),l.delete(A))};let u=null;try{u=Ca().subscribeRegistry(()=>{d(),c()})}catch{}d();const m=pm.subscribe(()=>c()),f=vr.subscribe(()=>c()),p=ws.subscribe(()=>c()),y=ut.subscribe(()=>c()),g=wn.subscribe(()=>c()),b=Ee.subscribe(()=>c()),x=gm.subscribe(()=>c());xx(Yf());const h=window.setInterval(()=>{Na()},Kk);a();const C=window.setInterval(()=>{a()},Df),w=mn.subscribe(()=>c());mn.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:k,results:j}=mn.getState();k.length>0&&k.some(D=>!j.some(N=>N.providerId===D))&&mn.getState().fetchAllQuotas()});const v=window.setInterval(()=>{const k=mn.getState();k.autoRefresh&&k.dropdownProviderIds.length>0&&k.fetchAllQuotas()},Math.max(3e4,mn.getState().refreshIntervalMs||6e4)),S=window.setInterval(()=>{d(),o()},Df);return o(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(S),window.clearInterval(h),window.clearInterval(C),window.clearInterval(v),m(),f(),p(),y(),g(),b(),x(),w(),u?.();for(const k of l.values())k();l.clear()}},[]),i.useEffect(()=>{if(!If()||typeof window>"u")return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=o=>{o.type==="respond-permission"&&yx(o.sessionId,o.id,o.response).catch(()=>{le.error("Failed to respond to permission request")})};let r=null;return e(Hk,o=>{const a=o?.payload;!a||typeof a!="object"||typeof a.type!="string"||n(a)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},rC="/api/notifications/stream",iC=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),oC=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="openchamber:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},aC=t=>{const e=mt.c(3),n=t?.enabled??!0;let r,o;e[0]!==n?(r=()=>{if(!n||dr()||!bc()||typeof window>"u"||typeof EventSource>"u")return;const a=new EventSource(Ci().sse(rC));return a.onmessage=lC,()=>{a.close()}},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),i.useEffect(r,o)};function lC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Ee.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&iC())return;const r=oC(e);if(!r)return;Lo()?.notifications?.notifyAgentCompletion(r)}const Pf="pwa-install-toast-shown",Tf="pwa-install-toast-dismissed",cC=()=>{const t=mt.c(6),{browserTab:e}=eb(),{t:n}=Nt(),r=i.useRef(n);let o,a;t[0]!==n?(o=()=>{r.current=n},a=[n],t[0]=n,t[1]=o,t[2]=a):(o=t[1],a=t[2]),i.useEffect(o,a);let c,l;t[3]!==e?(c=()=>{if(typeof window>"u"||!bc()||!e)return;let d=null,u=null;const m=()=>{u!==null&&(le.dismiss(u),u=null)},f=async()=>{if(!d)return;const g=d;d=null,m(),await g.prompt();const{outcome:b}=await g.userChoice;b==="accepted"&&le.success(r.current("pwa.installPrompt.started"))},p=g=>{const b=g;if(typeof b.prompt!="function")return;b.preventDefault(),d=b;const x=Ni(),h=Bf();tb({dismissed:x.getItem(Tf),sessionShown:h.getItem(Pf),hasActiveToast:u!==null})&&(h.setItem(Pf,"true"),u=le.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Ni().setItem(Tf,"true"),m()}}}))},y=()=>{d=null,m(),le.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",y),()=>{m(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",y)}},l=[e],t[3]=e,t[4]=c,t[5]=l):(c=t[4],l=t[5]),i.useEffect(c,l)},dC=({open:t,onOpenChange:e})=>{const{t:n}=Nt(),r=!1,[o,a]=i.useState(null),[c,l]=i.useState(null),[d,u]=i.useState(!1),[m,f]=i.useState(!1),[p,y]=i.useState(null),[g,b]=i.useState(!1);i.useCallback(async()=>{},[p,d,r,n]),i.useEffect(()=>{if(!t)return;(async()=>{try{const C=await As("/api/system/info");if(C.ok){const w=await C.json();if(typeof w.openchamberVersion=="string"&&w.openchamberVersion.trim()){a(w.openchamberVersion);return}}}catch{}a(await vx())})()},[t]),i.useEffect(()=>{if(!t)return;let h=!1;return(async()=>{try{const w=await As("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!w.ok)return;const v=await w.json().catch(()=>null),S=typeof v?.currentVersion=="string"?v.currentVersion.trim():"";!h&&S&&l(S)}catch{}})(),()=>{h=!0}},[t]),i.useEffect(()=>{{y(null),b(!1);return}},[t,r]);const x=o;return s.jsx($s,{open:t,onOpenChange:e,children:s.jsx(Vs,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Tc,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[x&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:x})}),c&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:c})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/btriapitsyn/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(I,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(I,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(I,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Vl=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},uC=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to OpenChamber and click Authorize again.":n},fC=()=>{const t=sb(a=>a.completeAuth),[e,n]=i.useState("working"),[r,o]=i.useState("Completing MCP authorization...");return i.useEffect(()=>{if(typeof window>"u"){n("error"),o("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),c=Vl(a,"code"),l=nb(a),d=rb(a),u=Vl(a,"error"),m=Vl(a,"error_description");if(u){d&&As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`,{method:"DELETE"}).catch(()=>{}),n("error"),o(m??u);return}(async()=>{try{if(!c)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");let f=l;if(!f&&d){const p=await As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`);if(p.ok){const y=await p.json().catch(()=>null);y?.name?.trim()&&(f={name:y.name.trim(),directory:typeof y.directory=="string"&&y.directory.trim()?y.directory.trim():null})}}if(!f?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");await t(f.name,c,f.directory),d&&await As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`,{method:"DELETE"}).catch(()=>{}),n("success"),o("Authorization completed. You can close this tab and return to OpenChamber.")}catch(f){d&&await As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`,{method:"DELETE"}).catch(()=>{}),n("error"),o(uC(f,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("div",{className:e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]",children:s.jsx("h1",{className:"typography-hero font-semibold",children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"})}),s.jsx("p",{className:"typography-body text-muted-foreground",children:r})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx($e,{type:"button",onClick:()=>{typeof window>"u"||window.location.replace("/")},children:"Return to OpenChamber"})})]})})},Rf=oo(()=>io(()=>import("./OnboardingScreen-ChaxLu9k.js"),__vite__mapDeps([12,1,2,4,5,3])).then(t=>({default:t.OnboardingScreen}))),mC=()=>{const t=mt.c(3),e=Ee(yC),n=Ee(wC);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(dC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},hC=t=>{const e=mt.c(21),{onRetry:n,isRetrying:r}=t,{t:o}=Nt();let a;e[0]!==o?(a=o("startup.initRecovery.title"),e[0]=o,e[1]=a):a=e[1];let c;e[2]!==a?(c=s.jsx("h1",{className:"typography-title text-foreground",children:a}),e[2]=a,e[3]=c):c=e[3];let l;e[4]!==o?(l=o("startup.initRecovery.description"),e[4]=o,e[5]=l):l=e[5];let d;e[6]!==l?(d=s.jsx("p",{className:"typography-body text-muted-foreground",children:l}),e[6]=l,e[7]=d):d=e[7];let u;e[8]!==c||e[9]!==d?(u=s.jsxs("div",{className:"flex flex-col gap-2",children:[c,d]}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let m;e[11]!==r||e[12]!==o?(m=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=o,e[13]=m):m=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==m?(f=s.jsx($e,{type:"button",onClick:n,disabled:r,children:m}),e[14]=r,e[15]=n,e[16]=m,e[17]=f):f=e[17];let p;return e[18]!==u||e[19]!==f?(p=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[u,f]})}),e[18]=u,e[19]=f,e[20]=p):p=e[20],p},Ef=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",pC=()=>{if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search);if(t.get("ocPanel")!=="session-chat")return null;const e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),o=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:o,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true"}},gC=()=>typeof window>"u"?!1:window.location.pathname===ab,xC=t=>{const e=mt.c(23),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:o}=t,a=Js(vC),c=ut(jC),l=ut(SC),d=Ec(),u=i.useRef(null);let m;e[0]!==n.directory?(m=Ef(n.directory),e[0]=n.directory,e[1]=m):m=e[1];const f=m;let p;e[2]!==a?(p=Ef(a),e[2]=a,e[3]=p):p=e[3];const y=p;let g,b;if(e[4]!==y||e[5]!==c||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==l||e[11]!==d?(g=()=>{if(r||f&&y!==f)return;const S=`${f}
|
|
213
|
+
`)?(f(Re),u(!0)):u(!1);return}u(!1)},e[12]=_):_=e[12];const R=_;let V;e[13]!==n.id||e[14]!==a?(V=U=>{a(n.id,{prompt:U})},e[13]=n.id,e[14]=a,e[15]=V):V=e[15];const $=V;let z;e[16]!==n.prompt||e[17]!==$?(z=U=>{const be=n.prompt,G=v.current?.selectionStart??be.length,Le=be.substring(0,G).lastIndexOf("@"),Re=U.relativePath&&U.relativePath.trim().length>0?U.relativePath.trim():U.path||U.name,J=Le!==-1?Le:G,L=`${be.substring(0,J)}@${Re} ${be.substring(G)}`,ae=J+Re.length+2;$(L),u(!1),f(""),requestAnimationFrame(()=>{const re=v.current;re&&(re.selectionStart=ae,re.selectionEnd=ae,re.focus()),R(L,ae)})},e[16]=n.prompt,e[17]=$,e[18]=z):z=e[18];const F=z;let te;e[19]!==n.prompt||e[20]!==$?(te=U=>{const be=n.prompt,G=v.current?.selectionStart??be.length,Le=be.substring(0,G).lastIndexOf("@"),Re=Le!==-1?Le:G,J=`${be.substring(0,Re)}@${U} ${be.substring(G)}`,L=Re+U.length+2;$(J),u(!1),f(""),requestAnimationFrame(()=>{const ae=v.current;ae&&(ae.selectionStart=L,ae.selectionEnd=L,ae.focus()),R(J,L)})},e[19]=n.prompt,e[20]=$,e[21]=te):te=e[21];const ne=te;let q;e[22]!==$?(q=U=>{const be=`/${U.name} `;$(be),y(!1),b(""),h(!1),requestAnimationFrame(()=>{const ve=v.current;ve&&(ve.focus(),ve.selectionStart=ve.value.length,ve.selectionEnd=ve.value.length),R(be,be.length)})},e[22]=$,e[23]=q):q=e[23];const H=q;let X;e[24]!==n.prompt||e[25]!==$?(X=(U,be)=>{const ve=n.prompt,ye=v.current?.selectionStart??ve.length,Re=ve.substring(0,ye).lastIndexOf("#"),J=Re!==-1?Re:ye,L=`${ve.substring(0,J)}#${be} ${ve.substring(ye)}`,ae=J+be.length+2;$(L),h(!1),w(""),requestAnimationFrame(()=>{const re=v.current;re&&(re.selectionStart=ae,re.selectionEnd=ae,re.focus()),R(L,ae)})},e[24]=n.prompt,e[25]=$,e[26]=X):X=e[26];const oe=X;let he;e[27]!==p||e[28]!==d||e[29]!==x?(he=U=>{if(p&&k.current&&(U.key==="Enter"||U.key==="ArrowUp"||U.key==="ArrowDown"||U.key==="Escape"||U.key==="Tab")){U.preventDefault(),k.current.handleKeyDown(U.key);return}d&&S.current&&(U.key==="Enter"||U.key==="ArrowUp"||U.key==="ArrowDown"||U.key==="Escape"||U.key==="Tab")&&(U.preventDefault(),S.current.handleKeyDown(U.key)),x&&j.current&&(U.key==="Enter"||U.key==="ArrowUp"||U.key==="ArrowDown"||U.key==="Escape"||U.key==="Tab")&&(U.preventDefault(),j.current.handleKeyDown(U.key))},e[27]=p,e[28]=d,e[29]=x,e[30]=he):he=e[30];const Se=he,Z=r+1;let ke;e[31]!==l||e[32]!==Z?(ke=l("multirun.launcher.groups.groupLabel",{index:Z}),e[31]=l,e[32]=Z,e[33]=ke):ke=e[33];let Y;e[34]!==ke?(Y=s.jsx("span",{className:"typography-meta font-medium text-foreground",children:ke}),e[34]=ke,e[35]=Y):Y=e[35];let ge;e[36]!==o||e[37]!==n.id||e[38]!==c||e[39]!==l?(ge=o&&s.jsx("button",{type:"button",onClick:()=>c(n.id),className:"inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10","aria-label":l("multirun.launcher.groups.removeGroup"),children:s.jsx(I,{name:"close",className:"h-3.5 w-3.5"})}),e[36]=o,e[37]=n.id,e[38]=c,e[39]=l,e[40]=ge):ge=e[40];let O;e[41]!==Y||e[42]!==ge?(O=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Y,ge]}),e[41]=Y,e[42]=ge,e[43]=O):O=e[43];let se;e[44]!==l?(se=l("multirun.launcher.groups.prompt.label"),e[44]=l,e[45]=se):se=e[45];let ee;e[46]!==se?(ee=s.jsx(Si,{required:!0,children:se}),e[46]=se,e[47]=ee):ee=e[47];const je=n.prompt;let De;e[48]!==$?(De=U=>{const be=U.target.value;$(be);const ve=U.target.selectionStart??be.length;R(be,ve)},e[48]=$,e[49]=De):De=e[49];let Be;e[50]!==l?(Be=l("multirun.launcher.groups.prompt.placeholder"),e[50]=l,e[51]=Be):Be=e[51];let Fe;e[52]!==n.prompt||e[53]!==Se||e[54]!==De||e[55]!==Be?(Fe=s.jsx(ki,{ref:v,value:je,onChange:De,onKeyDown:Se,placeholder:Be,className:"typography-meta min-h-[80px] max-h-[200px] resize-none overflow-y-auto field-sizing-content",required:!0}),e[52]=n.prompt,e[53]=Se,e[54]=De,e[55]=Be,e[56]=Fe):Fe=e[56];let Me;e[57]!==g||e[58]!==H||e[59]!==p?(Me=p?s.jsx(dm,{ref:k,searchQuery:g,onCommandSelect:H,onClose:()=>y(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[57]=g,e[58]=H,e[59]=p,e[60]=Me):Me=e[60];let fe;e[61]!==ne||e[62]!==F||e[63]!==m||e[64]!==d?(fe=d?s.jsx(um,{ref:S,searchQuery:m,onFileSelect:F,onAgentSelect:ne,onClose:()=>u(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[61]=ne,e[62]=F,e[63]=m,e[64]=d,e[65]=fe):fe=e[65];let Ae;e[66]!==oe||e[67]!==x||e[68]!==C?(Ae=x?s.jsx(fm,{ref:j,searchQuery:C,onSnippetSelect:oe,onClose:()=>h(!1),style:{left:0,top:"auto",bottom:"calc(100% + 6px)",marginBottom:0,maxWidth:"100%"}}):null,e[66]=oe,e[67]=x,e[68]=C,e[69]=Ae):Ae=e[69];let pe;e[70]!==Fe||e[71]!==Me||e[72]!==fe||e[73]!==Ae?(pe=s.jsxs("div",{className:"relative",children:[Fe,Me,fe,Ae]}),e[70]=Fe,e[71]=Me,e[72]=fe,e[73]=Ae,e[74]=pe):pe=e[74];let ce;e[75]!==ee||e[76]!==pe?(ce=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[ee,pe]}),e[75]=ee,e[76]=pe,e[77]=ce):ce=e[77];let me;e[78]!==l?(me=l("multirun.launcher.models.info",{max:Bl}),e[78]=l,e[79]=me):me=e[79];let Ne;e[80]!==me?(Ne=s.jsx(ga,{children:me}),e[80]=me,e[81]=Ne):Ne=e[81];let ue;e[82]!==l?(ue=l("multirun.launcher.models.label"),e[82]=l,e[83]=ue):ue=e[83];let P;e[84]!==Ne||e[85]!==ue?(P=s.jsx(Si,{required:!0,info:Ne,children:ue}),e[84]=Ne,e[85]=ue,e[86]=P):P=e[86];let M;e[87]!==n.models||e[88]!==D||e[89]!==B||e[90]!==E?(M=s.jsx(jh,{selectedModels:n.models,onAdd:D,onRemove:B,onUpdate:E,minModels:1,maxModels:Bl}),e[87]=n.models,e[88]=D,e[89]=B,e[90]=E,e[91]=M):M=e[91];let de;e[92]!==P||e[93]!==M?(de=s.jsxs("div",{className:"flex flex-col gap-1.5",children:[P,M]}),e[92]=P,e[93]=M,e[94]=de):de=e[94];let xe;return e[95]!==O||e[96]!==ce||e[97]!==de?(xe=s.jsxs("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[O,ce,de]}),e[95]=O,e[96]=ce,e[97]=de,e[98]=xe):xe=e[98],xe},jk=i.createContext(null),Sk=t=>{const e=mt.c(3),{children:n,value:r}=t;let o;return e[0]!==n||e[1]!==r?(o=s.jsx(jk.Provider,{value:r,children:n}),e[0]=n,e[1]=r,e[2]=o):o=e[2],o},kf=oo(()=>io(()=>import("./TerminalView-BDjzrhGS.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(t=>({default:t.TerminalView}))),Nk=oo(()=>io(()=>import("./DiagramView-BJkP8Fjp.js"),__vite__mapDeps([9,1,2,4,5,3,6,7,8])).then(t=>({default:t.DiagramView}))),kk=oo(()=>io(()=>import("./NewWorktreeDialog-Dj6KETex.js").then(t=>t.a8),__vite__mapDeps([6,1,2,3,4,5,7])).then(t=>({default:t.SettingsView}))),Ck=oo(()=>io(()=>import("./SettingsWindow-BIKNrxSK.js"),__vite__mapDeps([10,1,2,3,4,5,6,7])).then(t=>({default:t.SettingsWindow}))),Ak=oo(()=>io(()=>import("./MultiRunWindow-CRKVePMG.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8])).then(t=>({default:t.MultiRunWindow}))),Dk=()=>{const o=Ee(X=>X.isSidebarOpen),a=Ee(X=>X.isRightSidebarOpen),c=Ee(X=>X.isBottomTerminalOpen),l=Ee(X=>X.setRightSidebarOpen),d=Ee(X=>X.setBottomTerminalOpen),u=Ee(X=>X.activeMainTab),m=Ee(X=>X.setIsMobile),f=Ee(X=>X.isSessionSwitcherOpen),p=Ee(X=>X.isSettingsDialogOpen),y=Ee(X=>X.setSettingsDialogOpen),g=Ee(X=>X.isMultiRunLauncherOpen),b=Ee(X=>X.setMultiRunLauncherOpen),x=Ee(X=>X.multiRunLauncherPrefillPrompt),{isMobile:h,isTablet:C}=Er(),w=i.useRef(!1),v=i.useRef(!1),S=i.useRef(!1),[k,j]=i.useState(!1),[A,D]=i.useState(!1),[N,B]=i.useState(!1),[T,E]=i.useState(!1),_=i.useCallback(X=>{j(X),Ee.getState().setSessionSwitcherOpen(X)},[]),R=i.useRef(!1),V=i.useRef(typeof window>"u"?0:window.innerWidth),$=gd(-V.current),z=Xe.useRef(0),F=gd(V.current),te=Xe.useRef(0);Xe.useEffect(()=>{h&&(z.current=window.innerWidth,te.current=window.innerWidth)},[h]),Xe.useEffect(()=>{if(!h){B(!1);return}k&&B(!0),xd($,k?0:-z.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[k,h,$]),Xe.useEffect(()=>{if(!h){E(!1);return}R.current=A,A&&E(!0),xd(F,A?0:te.current,{type:"spring",stiffness:400,damping:35,mass:.8})},[h,A,F]),Xe.useEffect(()=>{if(h)return $.on("change",X=>{const oe=z.current||V.current,he=k||X>-oe+.5;B(Se=>Se===he?Se:he)})},[h,$,k]),Xe.useEffect(()=>{if(h)return F.on("change",X=>{const oe=te.current||V.current,he=A||X<oe-.5;E(Se=>Se===he?Se:he)})},[h,A,F]),Xe.useEffect(()=>{h&&!f&&k&&_(!1)},[f,h,k,_]),Xe.useEffect(()=>{if(!h){S.current=!1;return}S.current||(S.current=!0,_(!1),D(!1),Ee.getState().isRightSidebarOpen&&l(!1))},[h,_,l]),Xe.useEffect(()=>{if(!h||u!=="chat"||k||A||p)return;let X=!1,oe;const he=Se=>{oe=window.setTimeout(()=>{if(X)return;const Z=ut.getState(),ke=Ee.getState();if(!(ke.activeMainTab!=="chat"||ke.isSettingsDialogOpen||Z.currentSessionId||Z.newSessionDraft?.open)){if(Z.isLoading){he(250);return}Z.openNewSessionDraft()}},Se)};return he(500),()=>{X=!0,oe!==void 0&&window.clearTimeout(oe)}},[u,h,p,k,A]),Xe.useEffect(()=>{!h||!p||(_(!1),D(!1),a&&l(!1))},[h,p,a,_,l]),Xx(),i.useEffect(()=>{Ee.getState().isMobile!==h&&m(h)},[h,m]),i.useEffect(()=>{if(typeof window>"u")return;let X;const oe=()=>{X===void 0&&(X=window.requestAnimationFrame(()=>{X=void 0,Ee.getState().updateProportionalSidebarWidths()}))};return window.addEventListener("resize",oe),()=>{window.removeEventListener("resize",oe),X!==void 0&&window.cancelAnimationFrame(X)}},[]),i.useEffect(()=>{if(typeof window>"u")return;let X;const oe=()=>{const Se=Ee.getState(),Z=window.innerWidth,ke=window.innerHeight;if(!h&&!C){const Y=Z<1140,ge=Z>=1220;Y?Se.isRightSidebarOpen&&(l(!1),w.current=!0):ge&&w.current&&(l(!0),w.current=!1);const O=ke<640,se=ke>=700;O?Se.isBottomTerminalOpen&&(d(!1),v.current=!0):se&&v.current&&(d(!0),v.current=!1)}},he=()=>{X===void 0&&(X=window.requestAnimationFrame(()=>{X=void 0,oe()}))};return oe(),window.addEventListener("resize",he),()=>{window.removeEventListener("resize",he),X!==void 0&&window.cancelAnimationFrame(X)}},[h,C,d,l]),i.useEffect(()=>{if(typeof window>"u")return;const X=Ee.subscribe((oe,he)=>{const Se=window.innerWidth,Z=window.innerHeight,ke=Se>=1220,Y=Z>=700;oe.isRightSidebarOpen!==he.isRightSidebarOpen&&ke&&(w.current=!1),oe.isBottomTerminalOpen!==he.isBottomTerminalOpen&&Y&&(v.current=!1)});return()=>{X()}},[h,C,d,l]);const ne=i.useCallback(()=>{k&&_(!1),D(!A)},[k,A,_]),q=i.useMemo(()=>{switch(u){case"plan":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Zm,{})});case"git":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(tc,{isActive:!A})});case"diff":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(qm,{})});case"terminal":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(kf,{})});case"files":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Xm,{})});case"context":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Wm,{})});case"diagram":return s.jsx(i.Suspense,{fallback:null,children:s.jsx(Nk,{})});default:return null}},[u,A]),H=u==="chat";return s.jsx(Zx,{children:s.jsxs("div",{"data-page-scroll-lock":"true",className:Pe("main-content-safe-area",h?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[s.jsx(J0,{}),s.jsx(Bj,{}),s.jsx(zj,{}),s.jsx(lk,{}),h?s.jsxs(Sk,{value:{leftDrawerOpen:k,rightDrawerOpen:A,toggleLeftDrawer:()=>{const X=!k;A&&D(!1),_(X)},toggleRightDrawer:ne,leftDrawerX:$,rightDrawerX:F,leftDrawerWidth:z,rightDrawerWidth:te,setMobileLeftDrawerOpen:_,setRightSidebarOpen:D},children:[!p&&s.jsx(su,{onToggleLeftDrawer:()=>{const X=!k;A&&D(!1),_(X)},onToggleRightDrawer:()=>{ne()},leftDrawerOpen:k,rightDrawerOpen:A}),s.jsx("div",{"data-page-scroll-lock":"true",className:Pe("flex flex-1 overflow-hidden relative",p&&"hidden"),children:s.jsxs("main",{className:"w-full h-full overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:Pe("absolute inset-0",!H&&"invisible"),children:s.jsx(Zs,{children:s.jsx(Ql,{})})}),q&&s.jsx("div",{className:"absolute inset-0",children:s.jsx(Zs,{children:q})}),g&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",children:s.jsx(Zs,{children:s.jsx(wk,{initialPrompt:x,onCreated:()=>b(!1),onCancel:()=>b(!1)})})}),N&&s.jsx(bd.div,{className:"absolute inset-0 z-20 bg-sidebar","data-page-scroll-lock":"true",style:{x:$},"aria-hidden":!k,children:s.jsx(Zs,{children:s.jsx(jf,{mobileVariant:!0})})}),T&&s.jsx(bd.div,{className:"absolute inset-0 z-20 bg-sidebar","data-page-scroll-lock":"true",style:{x:F},"aria-hidden":!A,children:s.jsx(Zs,{children:s.jsx(i.Suspense,{fallback:null,children:s.jsx(tc,{isActive:A})})})})]})}),p&&s.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:s.jsx(Zs,{children:s.jsx(i.Suspense,{fallback:null,children:s.jsx(kk,{onClose:()=>y(!1)})})})})]}):s.jsxs(s.Fragment,{children:[s.jsx(ly,{}),s.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[s.jsx(iy,{isOpen:o,isMobile:h,className:"border-border/50",topBar:s.jsx(oy,{}),children:s.jsx(jf,{})}),s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[s.jsx(su,{}),s.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[s.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border/50 bg-background","data-page-scroll-lock":"true",children:[s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:s.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true",children:[s.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[s.jsx("div",{className:Pe("absolute inset-0",!H&&"invisible"),children:s.jsx(Zs,{children:s.jsx(Ql,{})})}),q&&s.jsx("div",{className:"absolute inset-0",children:s.jsx(Zs,{children:q})})]}),s.jsx(Q0,{})]})}),s.jsx(ey,{isOpen:c,isMobile:h,children:c?s.jsx(Zs,{children:s.jsx(i.Suspense,{fallback:null,children:s.jsx(kf,{})})}):null})]}),s.jsx(hy,{isOpen:a,className:"bg-background border-t border-border/50",children:s.jsx(Zs,{children:s.jsx(Rv,{})})})]})]})]}),s.jsx(i.Suspense,{fallback:null,children:s.jsx(Ck,{open:p,onOpenChange:y})}),s.jsx(i.Suspense,{fallback:null,children:s.jsx(Ak,{open:g,onOpenChange:b,initialPrompt:x})})]})]})})},Ik=t=>{if(t<1e3)return`${Math.round(t)}ms`;const e=t/1e3;if(e<60)return`${e.toFixed(1)}s`;const n=Math.floor(e/60),r=Math.round(e%60);return`${n}m ${r}s`},On=t=>{const e=mt.c(8),{label:n,value:r}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[0]=o):o=e[0];let a;e[1]!==n?(a=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:n}),e[1]=n,e[2]=a):a=e[2];let c;e[3]!==r?(c=s.jsx("div",{className:"typography-markdown font-semibold text-[var(--surface-foreground)]",children:r}),e[3]=r,e[4]=c):c=e[4];let l;return e[5]!==a||e[6]!==c?(l=s.jsxs("div",{className:"rounded-md p-2",style:o,children:[a,c]}),e[5]=a,e[6]=c,e[7]=l):l=e[7],l},Cf=t=>{const e=mt.c(43),{title:n,snapshot:r,emptyLabel:o}=t,{t:a}=Nt();let c;if(e[0]!==o||e[1]!==r.durationMs||e[2]!==r.entries||e[3]!==r.lastUpdatedAt||e[4]!==r.startedAt||e[5]!==a||e[6]!==n){const l=r.entries.slice(0,12);let d;e[8]!==r.entries?(d=r.entries.reduce(Rk,0),e[8]=r.entries,e[9]=d):d=e[9];const u=d;let m;e[10]!==n?(m=s.jsx("div",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:n}),e[10]=n,e[11]=m):m=e[11];let f;e[12]!==r.durationMs||e[13]!==r.startedAt||e[14]!==a?(f=r.startedAt?Ik(r.durationMs):a("memoryDebugPanel.common.idle"),e[12]=r.durationMs,e[13]=r.startedAt,e[14]=a,e[15]=f):f=e[15];let p;e[16]!==f?(p=s.jsx("div",{className:"typography-meta text-[var(--surface-muted-foreground)]",children:f}),e[16]=f,e[17]=p):p=e[17];let y;e[18]!==m||e[19]!==p?(y=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m,p]}),e[18]=m,e[19]=p,e[20]=y):y=e[20];let g;e[21]!==a?(g=a("memoryDebugPanel.metric.metrics"),e[21]=a,e[22]=g):g=e[22];let b;e[23]!==r.entries.length||e[24]!==g?(b=s.jsx(On,{label:g,value:r.entries.length}),e[23]=r.entries.length,e[24]=g,e[25]=b):b=e[25];let x;e[26]!==a?(x=a("memoryDebugPanel.metric.samples"),e[26]=a,e[27]=x):x=e[27];let h;e[28]!==x||e[29]!==u?(h=s.jsx(On,{label:x,value:u}),e[28]=x,e[29]=u,e[30]=h):h=e[30];let C;e[31]!==a?(C=a("memoryDebugPanel.metric.lastUpdate"),e[31]=a,e[32]=C):C=e[32];let w;e[33]!==r.lastUpdatedAt||e[34]!==a?(w=r.lastUpdatedAt?a("memoryDebugPanel.common.live"):a("memoryDebugPanel.common.notAvailable"),e[33]=r.lastUpdatedAt,e[34]=a,e[35]=w):w=e[35];let v;e[36]!==C||e[37]!==w?(v=s.jsx(On,{label:C,value:w}),e[36]=C,e[37]=w,e[38]=v):v=e[38];let S;e[39]!==h||e[40]!==v||e[41]!==b?(S=s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[b,h,v]}),e[39]=h,e[40]=v,e[41]=b,e[42]=S):S=e[42],c=s.jsxs("div",{className:"space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0",children:[y,S,l.length===0?s.jsx("div",{className:"rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]",style:{backgroundColor:"color-mix(in srgb, var(--surface-muted) 45%, transparent)"},children:o}):s.jsx(Vn,{outerClassName:"max-h-64",className:"pr-1",children:s.jsx("div",{className:"space-y-1",children:l.map(k=>s.jsxs("div",{className:"rounded-md border border-[var(--interactive-border)] p-2",style:{backgroundColor:"color-mix(in srgb, var(--surface-elevated) 88%, transparent)"},children:[s.jsx("div",{className:"typography-meta font-medium text-[var(--surface-foreground)] break-all",children:k.metric}),s.jsxs("div",{className:"mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:a("memoryDebugPanel.metric.countValue",{value:k.count})}),s.jsx("span",{children:a("memoryDebugPanel.metric.avgValue",{value:k.avg})}),s.jsx("span",{children:a("memoryDebugPanel.metric.maxValue",{value:k.max})}),s.jsx("span",{children:a("memoryDebugPanel.metric.totalValue",{value:k.total})})]})]},k.metric))})})]}),e[0]=o,e[1]=r.durationMs,e[2]=r.entries,e[3]=r.lastUpdatedAt,e[4]=r.startedAt,e[5]=a,e[6]=n,e[7]=c}else c=e[7];return c},Pk=t=>{const e=mt.c(99),{onClose:n}=t,{t:r}=Nt(),[o,a]=i.useState("memory"),[c,l]=i.useState("idle"),d=ut(Ek),u=mm(Mk),m=Ic(),f=fx(Fk),p=rr(Lk),[y,g]=i.useState(Ok),[b,x]=i.useState(Bk);let h;e[0]!==y.entries?(h=new Map,y.entries.forEach(ue=>{h.set(ue.metric,ue.count)}),e[0]=y.entries,e[1]=h):h=e[1];let C;e[2]!==h?(C=h.get("ui.message_list.render")??0,e[2]=h,e[3]=C):C=e[3];let w;e[4]!==h?(w=h.get("ui.message_list.render.streaming")??0,e[4]=h,e[5]=w):w=e[5];let v;e[6]!==h?(v=h.get("ui.chat_message.render")??0,e[6]=h,e[7]=v):v=e[7];let S;e[8]!==h?(S=h.get("ui.chat_message.render.streaming")??0,e[8]=h,e[9]=S):S=e[9];let k;e[10]!==h?(k=h.get("ui.chat_message.render.static_during_stream")??0,e[10]=h,e[11]=k):k=e[11];let j;e[12]!==h?(j=h.get("ui.chat_message.render.static_outside_active_turn_during_stream")??0,e[12]=h,e[13]=j):j=e[13];let A;e[14]!==C||e[15]!==w||e[16]!==v||e[17]!==S||e[18]!==k||e[19]!==j?(A={messageListRender:C,messageListRenderStreaming:w,chatMessageRender:v,chatMessageRenderStreaming:S,chatMessageRenderStaticDuringStream:k,chatMessageRenderStaticOutsideActiveTurnDuringStream:j},e[14]=C,e[15]=w,e[16]=v,e[17]=S,e[18]=k,e[19]=j,e[20]=A):A=e[20];const D=A;let N,B;e[21]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{const ue=()=>{g(na()),x(ra())};ue();const P=window.setInterval(ue,500);return()=>window.clearInterval(P)},B=[],e[21]=N,e[22]=B):(N=e[21],B=e[22]),i.useEffect(N,B);let T,E;e[23]!==c?(T=()=>{if(c==="idle")return;const ue=window.setTimeout(()=>{l("idle")},1500);return()=>window.clearTimeout(ue)},E=[c],e[23]=c,e[24]=T,e[25]=E):(T=e[24],E=e[25]),i.useEffect(T,E);let _=0,R=0,V=0;for(const ue of Object.keys(f)){const P=f[ue]??[];R=R+P.length;for(const M of P)M.role==="user"?V=V+1:M.role==="assistant"&&(_=_+1)}let $;e[26]!==_||e[27]!==R||e[28]!==V?($={assistant:_,total:R,user:V},e[26]=_,e[27]=R,e[28]=V,e[29]=$):$=e[29];const z=$;let F;if(e[30]!==d||e[31]!==f||e[32]!==u||e[33]!==m||e[34]!==r){let ue;e[36]!==d||e[37]!==f||e[38]!==u||e[39]!==r?(ue=P=>{const M=f[P.id]??[];let de=0,xe=0;for(const be of M)be.role==="user"?xe=xe+1:be.role==="assistant"&&(de=de+1);const U=u.get(P.id);return{id:P.id,title:P.title||r("memoryDebugPanel.common.untitled"),assistantMessageCount:de,messageCount:M.length,userMessageCount:xe,isStreaming:U?.isStreaming||!1,isZombie:U?.isZombie||!1,backgroundCount:U?.backgroundMessageCount||0,lastAccessed:U?.lastAccessedAt||0,isCurrent:P.id===d}},e[36]=d,e[37]=f,e[38]=u,e[39]=r,e[40]=ue):ue=e[40],F=m.map(ue).sort(_k),e[30]=d,e[31]=f,e[32]=u,e[33]=m,e[34]=r,e[35]=F}else F=e[35];const te=F;let ne;e[41]!==f?(ne=Object.keys(f),e[41]=f,e[42]=ne):ne=e[42];const q=ne.length;let H;e[43]===Symbol.for("react.memo_cache_sentinel")?(H=async()=>{try{const ue={generatedAt:new Date().toISOString(),ui:na(),vscode:ra()};await navigator.clipboard.writeText(JSON.stringify(ue,null,2)),l("copied")}catch{l("error")}},e[43]=H):H=e[43];const X=H;let oe;e[44]===Symbol.for("react.memo_cache_sentinel")?(oe={backgroundColor:"color-mix(in srgb, var(--surface-background) 94%, transparent)"},e[44]=oe):oe=e[44];let he;e[45]!==o?(he=o==="memory"?s.jsx(I,{name:"database-2",className:"h-4 w-4 text-[var(--surface-foreground)]"}):s.jsx(I,{name:"bar-chart-box",className:"h-4 w-4 text-[var(--surface-foreground)]"}),e[45]=o,e[46]=he):he=e[46];let Se;e[47]!==r?(Se=r("memoryDebugPanel.title"),e[47]=r,e[48]=Se):Se=e[48];let Z;e[49]!==Se?(Z=s.jsx("h3",{className:"typography-ui-label font-semibold text-[var(--surface-foreground)]",children:Se}),e[49]=Se,e[50]=Z):Z=e[50];let ke;e[51]!==he||e[52]!==Z?(ke=s.jsxs("div",{className:"flex items-center gap-2",children:[he,Z]}),e[51]=he,e[52]=Z,e[53]=ke):ke=e[53];let Y;e[54]!==o?(Y=o==="streaming"?s.jsxs(s.Fragment,{children:[s.jsx($e,{size:"xs",variant:"ghost",onClick:X,children:s.jsx(I,{name:"file-copy",className:"h-3.5 w-3.5"})}),s.jsx($e,{size:"xs",variant:"ghost",onClick:()=>{yp(),g(na()),x(ra())},children:s.jsx(I,{name:"refresh",className:"h-3.5 w-3.5"})})]}):null,e[54]=o,e[55]=Y):Y=e[55];let ge;e[56]!==n?(ge=n?s.jsx($e,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:n,children:s.jsx(I,{name:"close",className:"h-4 w-4"})}):null,e[56]=n,e[57]=ge):ge=e[57];let O;e[58]!==Y||e[59]!==ge?(O=s.jsxs("div",{className:"flex items-center gap-1",children:[Y,ge]}),e[58]=Y,e[59]=ge,e[60]=O):O=e[60];let se;e[61]!==ke||e[62]!==O?(se=s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[ke,O]}),e[61]=ke,e[62]=O,e[63]=se):se=e[63];let ee;e[64]===Symbol.for("react.memo_cache_sentinel")?(ee={backgroundColor:"color-mix(in srgb, var(--surface-muted) 55%, transparent)"},e[64]=ee):ee=e[64];const je=o==="memory"?"secondary":"ghost";let De;e[65]===Symbol.for("react.memo_cache_sentinel")?(De=()=>a("memory"),e[65]=De):De=e[65];let Be;e[66]!==r?(Be=r("memoryDebugPanel.tabs.memory"),e[66]=r,e[67]=Be):Be=e[67];let Fe;e[68]!==je||e[69]!==Be?(Fe=s.jsx($e,{size:"sm",variant:je,className:"flex-1",onClick:De,children:Be}),e[68]=je,e[69]=Be,e[70]=Fe):Fe=e[70];const Me=o==="streaming"?"secondary":"ghost";let fe;e[71]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>a("streaming"),e[71]=fe):fe=e[71];let Ae;e[72]!==r?(Ae=r("memoryDebugPanel.tabs.streaming"),e[72]=r,e[73]=Ae):Ae=e[73];let pe;e[74]!==Me||e[75]!==Ae?(pe=s.jsx($e,{size:"sm",variant:Me,className:"flex-1",onClick:fe,children:Ae}),e[74]=Me,e[75]=Ae,e[76]=pe):pe=e[76];let ce;e[77]!==Fe||e[78]!==pe?(ce=s.jsxs("div",{className:"mb-3 flex gap-1 rounded-md p-1",style:ee,children:[Fe,pe]}),e[77]=Fe,e[78]=pe,e[79]=ce):ce=e[79];let me;e[80]!==o||e[81]!==q||e[82]!==c||e[83]!==d||e[84]!==f||e[85]!==z||e[86]!==u||e[87]!==te||e[88]!==m||e[89]!==D||e[90]!==y||e[91]!==r||e[92]!==p||e[93]!==b?(me=o==="memory"?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 typography-meta",children:[s.jsx(On,{label:r("memoryDebugPanel.metric.totalMessages"),value:z.total}),s.jsx(On,{label:r("memoryDebugPanel.metric.cachedSessions"),value:`${q} / ${Wd.MAX_SESSIONS}`}),s.jsx(On,{label:r("memoryDebugPanel.metric.userMessages"),value:z.user}),s.jsx(On,{label:r("memoryDebugPanel.metric.assistantMessages"),value:z.assistant})]}),s.jsxs("div",{className:"typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2",children:[s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.viewportWindow")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.messagesValue",{count:mx()})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.zombieTimeout")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.minutesValue",{count:Wd.ZOMBIE_TIMEOUT/1e3/60})})]}),s.jsxs("div",{className:"flex justify-between gap-2",children:[s.jsx("span",{className:"text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.githubTotalRequests")}),s.jsx("span",{className:"text-[var(--surface-foreground)]",children:p})]})]}),s.jsxs("div",{className:"border-t border-[var(--interactive-border)] pt-2",children:[s.jsx("div",{className:"mb-1 typography-meta font-semibold text-[var(--surface-foreground)]",children:r("memoryDebugPanel.section.sessionsInMemory")}),s.jsx(Vn,{outerClassName:"max-h-48",className:"space-y-1 pr-1",children:te.map(ue=>s.jsxs("div",{className:"typography-meta flex items-center justify-between rounded p-1.5",style:{backgroundColor:ue.isCurrent?"color-mix(in srgb, var(--interactive-selection) 22%, transparent)":"color-mix(in srgb, var(--surface-muted) 35%, transparent)"},children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:"truncate text-[var(--surface-foreground)]",children:ue.title}),ue.isStreaming?s.jsx(I,{name:"pulse",className:"h-3 w-3 animate-pulse text-[var(--status-info)]"}):null,ue.isZombie?s.jsx("span",{className:"text-[var(--status-warning)]",children:"!"}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"font-mono text-[var(--surface-muted-foreground)]",children:r("memoryDebugPanel.metric.roleMsgsValue",{assistant:ue.assistantMessageCount,user:ue.userMessageCount})}),s.jsx("span",{className:"font-mono text-[var(--surface-foreground)]",children:r("memoryDebugPanel.metric.msgsValue",{count:ue.messageCount})}),ue.backgroundCount>0?s.jsxs("span",{className:"text-[var(--status-info)]",children:["+",ue.backgroundCount]}):null]})]},ue.id))})]}),s.jsx("div",{className:"flex gap-2 border-t border-[var(--interactive-border)] pt-2",children:s.jsxs(Et,{children:[s.jsx(Mt,{asChild:!0,children:s.jsx($e,{size:"sm",variant:"outline",className:"typography-meta",onClick:()=>{console.log("[DebugPanel] Session store state:",{sessions:m.map(Vk),currentSessionId:d,cachedSessions:Object.keys(f),messageRoleCounts:z,sessionMessageRoleCounts:te.map($k),memoryStates:Object.fromEntries(u)})},children:r("memoryDebugPanel.actions.logState")})}),s.jsx(Ft,{side:"top",children:r("memoryDebugPanel.tooltip.logCurrentState")})]})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]",children:[s.jsx("span",{children:r(c==="copied"?"memoryDebugPanel.streaming.copy.copied":c==="error"?"memoryDebugPanel.streaming.copy.failed":"memoryDebugPanel.streaming.copy.hint")}),s.jsx($e,{size:"xs",variant:"outline",onClick:X,children:r("memoryDebugPanel.actions.copyJson")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(On,{label:r("memoryDebugPanel.metric.uiMetrics"),value:y.entries.length}),s.jsx(On,{label:r("memoryDebugPanel.metric.vscodeMetrics"),value:b.entries.length}),s.jsx(On,{label:r("memoryDebugPanel.metric.messageListRenders"),value:D.messageListRender}),s.jsx(On,{label:r("memoryDebugPanel.metric.messageListStreamRenders"),value:D.messageListRenderStreaming}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageRenders"),value:D.chatMessageRender}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageStreamRenders"),value:D.chatMessageRenderStreaming}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageStaticDuringStream"),value:D.chatMessageRenderStaticDuringStream}),s.jsx(On,{label:r("memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn"),value:D.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),s.jsx(Cf,{title:r("memoryDebugPanel.section.uiStreamingMetrics"),snapshot:y,emptyLabel:r("memoryDebugPanel.section.noUiSamples")}),b.entries.length>0?s.jsx(Cf,{title:r("memoryDebugPanel.section.vscodeBridgeMetrics"),snapshot:b,emptyLabel:r("memoryDebugPanel.section.noVscodeSamples")}):null]}),e[80]=o,e[81]=q,e[82]=c,e[83]=d,e[84]=f,e[85]=z,e[86]=u,e[87]=te,e[88]=m,e[89]=D,e[90]=y,e[91]=r,e[92]=p,e[93]=b,e[94]=me):me=e[94];let Ne;return e[95]!==se||e[96]!==ce||e[97]!==me?(Ne=s.jsxs(hx,{className:"fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area",style:oe,children:[se,ce,me]}),e[95]=se,e[96]=ce,e[97]=me,e[98]=Ne):Ne=e[98],Ne},Tk=Pk;function Rk(t,e){return t+e.count}function Ek(t){return t.currentSessionId}function Mk(t){return t.sessionMemoryState}function Fk(t){return t.message}function Lk(t){return t.totalRequestCount}function Ok(){return na()}function Bk(){return ra()}function _k(t,e){return e.lastAccessed-t.lastAccessed}function Vk(t){return{id:t.id,title:t.title}}function $k(t){return{id:t.id,title:t.title,total:t.messageCount,user:t.userMessageCount,assistant:t.assistantMessageCount}}const zk=()=>{if(typeof document>"u")return"";const t=document.activeElement;if(t instanceof HTMLTextAreaElement)return t.value.slice(t.selectionStart??0,t.selectionEnd??0);if(t instanceof HTMLInputElement){const e=t.type?.toLowerCase()??"text";if(["text","search","url","tel","password"].includes(e))return t.value.slice(t.selectionStart??0,t.selectionEnd??0)}return t instanceof HTMLElement&&t.isContentEditable?t.ownerDocument.defaultView?.getSelection?.()?.toString()??"":""},Uk=async()=>{const t=zk()||window.getSelection()?.toString()||"";if(!t.trim())return!1;try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}return document.execCommand("copy")},Af="openchamber:menu-action",_l="openchamber:check-for-updates",Wk=t=>{const e=ut(j=>j.openNewSessionDraft),n=Ee(j=>j.toggleCommandPalette),r=Ee(j=>j.setCommandPaletteOpen),o=Ee(j=>j.toggleHelpDialog),a=Ee(j=>j.toggleSidebar),c=Ee(j=>j.setSessionSwitcherOpen),l=Ee(j=>j.setActiveMainTab),d=Ee(j=>j.setSettingsDialogOpen),u=Ee(j=>j.setAboutDialogOpen),m=Ee(j=>j.toggleRightSidebar),f=Ee(j=>j.setRightSidebarOpen),p=Ee(j=>j.setRightSidebarTab),y=Ee(j=>j.toggleBottomTerminal),g=Ee(j=>j.setBottomTerminalExpanded),b=wo(j=>j.checkForUpdates),{setThemeMode:x}=Kr(),h=i.useRef(!1),C=i.useCallback(()=>{h.current||(h.current=!0,b().then(()=>{const{available:j,error:A}=wo.getState();if(A){le.error("Failed to check for updates",{description:A});return}j||le.success("You are on the latest version")}).finally(()=>{h.current=!1}))},[b]),w=i.useCallback(()=>{Pr.requestDirectoryDialog()},[]),v=i.useCallback(j=>{const A=px();if(A.length===0)return;const D=ut.getState().currentSessionId,N=A.findIndex(E=>E.id===D);let B=j>0?0:A.length-1;N>=0&&(B=(N+j+A.length)%A.length);const T=A[B];T&&(l("chat"),c(!1),ut.getState().setCurrentSession(T.id))},[l,c]),S=i.useCallback(j=>{const{activeProjectId:A,projects:D,setActiveProject:N}=ws.getState();if(D.length===0)return;const B=D.findIndex(_=>_.id===A);let T=j>0?0:D.length-1;B>=0&&(T=(B+j+D.length)%D.length);const E=D[T];E&&N(E.id)},[]),k=i.useCallback(j=>{switch(j){case"about":u(!0);break;case"settings":d(!0);break;case"command-palette":n();break;case"quick-open":r(!0);break;case"new-session":l("chat"),c(!1),e();break;case"new-worktree-session":l("chat"),c(!1),cm();break;case"change-workspace":w();break;case"toggle-right-sidebar":m();break;case"open-right-sidebar-git":f(!0),p("git");break;case"open-right-sidebar-files":f(!0),p("files");break;case"toggle-terminal":y();break;case"toggle-terminal-expanded":g(!Ee.getState().isBottomTerminalExpanded);break;case"copy":{const A=new Event("openchamber:copy",{cancelable:!0});!window.dispatchEvent(A)||Uk();break}case"theme-light":x("light");break;case"theme-dark":x("dark");break;case"theme-system":x("system");break;case"toggle-sidebar":a();break;case"toggle-memory-debug":t?.();break;case"go-back":Js.getState().goBack();break;case"go-forward":Js.getState().goForward();break;case"previous-session":v(-1);break;case"next-session":v(1);break;case"previous-project":S(-1);break;case"next-project":S(1);break;case"help-dialog":o();break;case"download-logs":{gx().catch(()=>{le.error("Failed to collect OpenCode status")});break}}},[w,S,v,t,e,u,l,c,r,d,g,f,p,x,y,n,o,m,a]);i.useEffect(()=>{const j=D=>{const N=D.detail;N&&k(N)},A=()=>{C()};return window.addEventListener(Af,j),window.addEventListener(_l,A),()=>{window.removeEventListener(Af,j),window.removeEventListener(_l,A)}},[k,C]),i.useEffect(()=>{if(typeof window>"u")return;const A=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof A!="function")return;let D=null,N=null;return A("openchamber:menu-action",B=>{const T=B?.payload;typeof T=="string"&&k(T)}).then(B=>{D=B}).catch(()=>{}),A("openchamber:check-for-updates",()=>{window.dispatchEvent(new Event(_l))}).then(B=>{N=B}).catch(()=>{}),()=>{(async()=>{try{const T=D?.();T instanceof Promise&&await T}catch{}try{const T=N?.();T instanceof Promise&&await T}catch{}})()}},[k])},Hk="openchamber:tray-action",Df=5e3,Gk=120,Kk=45e3,kh=20,If=()=>typeof window>"u"?!1:window.__OPENCHAMBER_PLATFORM__==="darwin",qk=t=>{const e=typeof t.permission=="string"?t.permission:"Permission",n=Array.isArray(t.patterns)?t.patterns.find(r=>typeof r=="string"&&r.trim()):"";return n?`${e}: ${n}`:e},Yk=t=>{const e=Array.isArray(t.questions)?t.questions[0]:void 0;return e?.header||e?.question||"Question"},La=t=>t.time?.updated??t.time?.created??0,Qk=t=>{const e=t.replace(/\\/g,"/").replace(/\/+$/,""),n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},Jk=(t,e,n,r,o)=>{if(!t)return"";const a=wx(n,r,t),c=e.project?.name,l=a?.label?.trim()||c?.trim()||Qk(t),d=oa(t);let u=d&&o.get(d)||"";if(!u){for(const[m,f]of wn.getState().directories)if(oa(m)===d){u=f.status?.current??"";break}}if(!u)for(const m of r.values()){const f=m.find(p=>oa(p.path)===d);if(f?.branch){u=f.branch;break}}return u?`${l} · ${u}`:l},Xk=()=>{const{results:t,dropdownProviderIds:e,displayMode:n}=mn.getState(),r=n==="remaining"?"remaining":"usage";if(!e.length)return{mode:r,groups:[]};const o=new Map(t.map(c=>[c.providerId,c])),a=[];for(const c of vm){if(!e.includes(c.id))continue;const l=o.get(c.id);if(!l||l.configured!==!0)continue;const d=[];for(const[m,f]of Object.entries(l.usage?.windows??{})){const p=r==="remaining"?f.remainingPercent:f.usedPercent;d.push({label:yc(m),value:Io(f.valueLabel,p)})}const u=!l.ok&&l.error?l.error:d.length===0?"No rate limits reported":null;a.push({provider:c.name,rows:d,status:u})}return{mode:r,groups:a}},Zk=async()=>{try{if(Ji())return"Local OpenChamber";const t=window.__OPENCHAMBER_LOCAL_ORIGIN__||window.location.origin,e=Ur();if(e&&Sa(e,t))return"Local OpenChamber";const r=(await Gf()).hosts.find(o=>e?Sa(e,Kf(o)):!1);return r?.label?.trim()?qf(r.label.trim()):"Instance"}catch{return""}},eC=()=>{const t=new Map,e=new Map,n=[],r=new Map;let o;try{o=Ca()}catch{return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}}for(const[a,c]of o.children.entries()){const l=c.getState();l.vcs?.branch&&e.set(oa(a)??a,l.vcs.branch);for(const d of l.session)d?.id&&r.set(d.id,d.title);for(const[d,u]of Object.entries(l.session_status??{})){const m=u?.type,f=m==="busy"?"busy":m==="retry"?"retry":"idle",p=t.get(d);(!p||p==="idle")&&t.set(d,f)}for(const[d,u]of Object.entries(l.permission??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"permission",id:m.id,sessionId:f,sessionTitle:"",label:qk(m),directory:a})}for(const[d,u]of Object.entries(l.question??{}))for(const m of u??[]){if(!m?.id)continue;const f=m.sessionID||d;n.push({kind:"question",id:m.id,sessionId:f,sessionTitle:"",label:Yk(m),directory:a})}}return{statusById:t,branchByDirectory:e,approvals:n,titleById:r}},tC=()=>{const t=vr.getState().activeSessions,e=new Set;t.filter(r=>r?.id&&!r.parentID).slice().sort((r,o)=>La(o)-La(r)).slice(0,kh).forEach(r=>{const o=Tr(r);o&&e.add(o)});const n=new Map;for(const r of t){if(!r?.id)continue;const o=Tr(r);if(!o||!e.has(o))continue;const a=n.get(o)??[];a.push(r.id),n.set(o,a)}return n},sC=t=>{const e=eC(),n=pm.getState().index.session,r=vr.getState().activeSessions,o=new Map(e.titleById),a=new Map;for(const x of r)if(x?.id&&(x.title&&o.set(x.id,x.title),x.parentID)){const h=a.get(x.parentID)??[];h.push(x.id),a.set(x.parentID,h)}const c=x=>{const h=[],C=[...a.get(x)??[]],w=new Set;for(;C.length;){const v=C.pop();w.has(v)||(w.add(v),h.push(v),C.push(...a.get(v)??[]))}return h},l=gm.getState().statusById,d=x=>{const h=e.statusById.get(x);return h&&h!=="idle"?h:l.get(x)?.status??h??"idle"},u=x=>{const h=x.map(C=>d(C));return h.includes("busy")?"busy":h.includes("retry")?"retry":"idle"},m=ws.getState().projects,f=ut.getState().availableWorktreesByProject,p=r.filter(x=>x?.id&&!x.parentID).slice().sort((x,h)=>La(h)-La(x)).slice(0,kh).map(x=>{const h=[x.id,...c(x.id)],C=Tr(x)??"";return{id:x.id,title:x.title||"Untitled session",status:u(h),branch:C?e.branchByDirectory.get(C)??"":"",unseen:h.reduce((w,v)=>w+(n.unseenCount[v]??0),0),hasError:h.some(w=>n.unseenHasError[w]??!1),directory:C,subtitle:Jk(C,x,m,f,e.branchByDirectory)}}),y=e.approvals.map(x=>({...x,sessionTitle:o.get(x.sessionId)||""})),g=Ee.getState();let b=0;if(g.dockBadgeEnabled)for(const x of r){if(!x?.id||x.parentID)continue;let h=n.unseenCount[x.id]??0;h===0&&g.notifyOnSubtasks&&(h=c(x.id).reduce((C,w)=>C+(n.unseenCount[w]??0),0)),h>0&&(b+=1)}return{sessions:p,approvals:y,instanceName:t,usage:Xk(),dockBadgeCount:b}},nC=()=>{i.useEffect(()=>{if(!If()||!Oa())return;let t=!1,e="",n=null,r="";const o=()=>{if(t)return;const k=sC(r),j=JSON.stringify(k);j!==e&&(e=j,Wr("desktop_tray_update",k))};Zk().then(k=>{t||(r=k,o())});const a=async()=>{const k=tC();await Promise.all([...k.entries()].map(async([j,A])=>{const D=await _n.getSessionStatusForDirectory(j).catch(()=>null);t||D===null||bx(j,D,A)}))},c=()=>{t||n!==null||(n=window.setTimeout(()=>{n=null,o()},Gk))},l=new Map,d=()=>{if(t)return;let k;try{k=Ca()}catch{return}const j=new Set;for(const[A,D]of k.children.entries())j.add(A),l.has(A)||l.set(A,D.subscribe(()=>c()));for(const[A,D]of l)j.has(A)||(D(),l.delete(A))};let u=null;try{u=Ca().subscribeRegistry(()=>{d(),c()})}catch{}d();const m=pm.subscribe(()=>c()),f=vr.subscribe(()=>c()),p=ws.subscribe(()=>c()),y=ut.subscribe(()=>c()),g=wn.subscribe(()=>c()),b=Ee.subscribe(()=>c()),x=gm.subscribe(()=>c());xx(Yf());const h=window.setInterval(()=>{Na()},Kk);a();const C=window.setInterval(()=>{a()},Df),w=mn.subscribe(()=>c());mn.getState().loadSettings().then(()=>{if(t)return;const{dropdownProviderIds:k,results:j}=mn.getState();k.length>0&&k.some(D=>!j.some(N=>N.providerId===D))&&mn.getState().fetchAllQuotas()});const v=window.setInterval(()=>{const k=mn.getState();k.autoRefresh&&k.dropdownProviderIds.length>0&&k.fetchAllQuotas()},Math.max(3e4,mn.getState().refreshIntervalMs||6e4)),S=window.setInterval(()=>{d(),o()},Df);return o(),()=>{t=!0,n!==null&&window.clearTimeout(n),window.clearInterval(S),window.clearInterval(h),window.clearInterval(C),window.clearInterval(v),m(),f(),p(),y(),g(),b(),x(),w(),u?.();for(const k of l.values())k();l.clear()}},[]),i.useEffect(()=>{if(!If()||typeof window>"u")return;const e=window.__OPENCHAMBER_DESKTOP__?.listen;if(typeof e!="function")return;const n=o=>{o.type==="respond-permission"&&yx(o.sessionId,o.id,o.response).catch(()=>{le.error("Failed to respond to permission request")})};let r=null;return e(Hk,o=>{const a=o?.payload;!a||typeof a!="object"||typeof a.type!="string"||n(a)}).then(o=>{r=o}).catch(()=>{}),()=>{try{const o=r?.();o instanceof Promise&&o.catch(()=>{})}catch{}}},[])},rC="/api/notifications/stream",iC=()=>typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus(),oC=t=>{if(!t||typeof t!="object")return null;const e=t,n=e.properties&&typeof e.properties=="object"?e.properties:null;return e.type!=="openchamber:notification"||!n?null:{title:typeof n.title=="string"?n.title:void 0,body:typeof n.body=="string"?n.body:void 0,tag:typeof n.tag=="string"?n.tag:void 0}},aC=t=>{const e=mt.c(3),n=t?.enabled??!0;let r,o;e[0]!==n?(r=()=>{if(!n||dr()||!bc()||typeof window>"u"||typeof EventSource>"u")return;const a=new EventSource(Ci().sse(rC));return a.onmessage=lC,()=>{a.close()}},o=[n],e[0]=n,e[1]=r,e[2]=o):(r=e[1],o=e[2]),i.useEffect(r,o)};function lC(t){let e;try{e=JSON.parse(t.data)}catch{return}const n=Ee.getState();if(!n.nativeNotificationsEnabled||n.notificationMode!=="always"&&iC())return;const r=oC(e);if(!r)return;Lo()?.notifications?.notifyAgentCompletion(r)}const Pf="pwa-install-toast-shown",Tf="pwa-install-toast-dismissed",cC=()=>{const t=mt.c(6),{browserTab:e}=eb(),{t:n}=Nt(),r=i.useRef(n);let o,a;t[0]!==n?(o=()=>{r.current=n},a=[n],t[0]=n,t[1]=o,t[2]=a):(o=t[1],a=t[2]),i.useEffect(o,a);let c,l;t[3]!==e?(c=()=>{if(typeof window>"u"||!bc()||!e)return;let d=null,u=null;const m=()=>{u!==null&&(le.dismiss(u),u=null)},f=async()=>{if(!d)return;const g=d;d=null,m(),await g.prompt();const{outcome:b}=await g.userChoice;b==="accepted"&&le.success(r.current("pwa.installPrompt.started"))},p=g=>{const b=g;if(typeof b.prompt!="function")return;b.preventDefault(),d=b;const x=Ni(),h=Bf();tb({dismissed:x.getItem(Tf),sessionShown:h.getItem(Pf),hasActiveToast:u!==null})&&(h.setItem(Pf,"true"),u=le.info(r.current("pwa.installPrompt.description"),{duration:1/0,action:{label:r.current("pwa.installPrompt.action"),onClick:()=>{f()}},cancel:{label:r.current("pwa.installPrompt.dismiss"),onClick:()=>{Ni().setItem(Tf,"true"),m()}}}))},y=()=>{d=null,m(),le.success(r.current("pwa.installPrompt.installed"))};return window.addEventListener("beforeinstallprompt",p),window.addEventListener("appinstalled",y),()=>{m(),window.removeEventListener("beforeinstallprompt",p),window.removeEventListener("appinstalled",y)}},l=[e],t[3]=e,t[4]=c,t[5]=l):(c=t[4],l=t[5]),i.useEffect(c,l)},dC=({open:t,onOpenChange:e})=>{const{t:n}=Nt(),r=!1,[o,a]=i.useState(null),[c,l]=i.useState(null),[d,u]=i.useState(!1),[m,f]=i.useState(!1),[p,y]=i.useState(null),[g,b]=i.useState(!1);i.useCallback(async()=>{},[p,d,r,n]),i.useEffect(()=>{if(!t)return;(async()=>{try{const C=await As("/api/system/info");if(C.ok){const w=await C.json();if(typeof w.openchamberVersion=="string"&&w.openchamberVersion.trim()){a(w.openchamberVersion);return}}}catch{}a(await vx())})()},[t]),i.useEffect(()=>{if(!t)return;let h=!1;return(async()=>{try{const w=await As("/api/opencode/upgrade-status",{headers:{Accept:"application/json"}});if(!w.ok)return;const v=await w.json().catch(()=>null),S=typeof v?.currentVersion=="string"?v.currentVersion.trim():"";!h&&S&&l(S)}catch{}})(),()=>{h=!0}},[t]),i.useEffect(()=>{{y(null),b(!1);return}},[t,r]);const x=o;return s.jsx($s,{open:t,onOpenChange:e,children:s.jsx(Vs,{className:"max-w-xs p-6",children:s.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[s.jsx(Tc,{width:64,height:64}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"OpenChamber"}),s.jsxs("div",{className:"space-y-0.5 typography-meta text-muted-foreground",children:[x&&s.jsx("p",{children:n("aboutDialog.openChamberVersionLabel",{version:x})}),c&&s.jsx("p",{children:n("aboutDialog.openCodeVersionLabel",{version:c})})]})]}),r,s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-4",children:[s.jsxs("a",{href:"https://github.com/btriapitsyn/openchamber",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(I,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://discord.gg/ZYRSdnwwKA",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(I,{name:"discord-fill",className:"h-4 w-4"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:"https://x.com/openchamber_dev",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors",children:[s.jsx(I,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/60 pt-2",children:n("aboutDialog.footerNote")})]})})})},Vl=(t,e)=>{const n=t.get(e);return typeof n!="string"?null:n.trim()||null},uC=(t,e)=>{const n=t instanceof Error?t.message:e;return/oauth state required/i.test(n)?"Authorization session expired or was cleared during reload. Return to OpenChamber and click Authorize again.":n},fC=()=>{const t=sb(a=>a.completeAuth),[e,n]=i.useState("working"),[r,o]=i.useState("Completing MCP authorization...");return i.useEffect(()=>{if(typeof window>"u"){n("error"),o("Browser context unavailable.");return}const a=new URLSearchParams(window.location.search),c=Vl(a,"code"),l=nb(a),d=rb(a),u=Vl(a,"error"),m=Vl(a,"error_description");if(u){d&&As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`,{method:"DELETE"}).catch(()=>{}),n("error"),o(m??u);return}(async()=>{try{if(!c)throw new Error("Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");let f=l;if(!f&&d){const p=await As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`);if(p.ok){const y=await p.json().catch(()=>null);y?.name?.trim()&&(f={name:y.name.trim(),directory:typeof y.directory=="string"&&y.directory.trim()?y.directory.trim():null})}}if(!f?.name)throw new Error("Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into OpenChamber manually.");await t(f.name,c,f.directory),d&&await As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`,{method:"DELETE"}).catch(()=>{}),n("success"),o("Authorization completed. You can close this tab and return to OpenChamber.")}catch(f){d&&await As(`/api/mcp/auth/pending?state=${encodeURIComponent(d)}`,{method:"DELETE"}).catch(()=>{}),n("error"),o(uC(f,"Failed to complete MCP authorization."))}})()},[t]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground",children:s.jsxs("div",{className:"w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm",children:[s.jsxs("div",{className:"space-y-3 text-center",children:[s.jsx("div",{className:e==="error"?"text-[var(--status-error)]":e==="success"?"text-[var(--status-success)]":"text-[var(--status-info)]",children:s.jsx("h1",{className:"typography-hero font-semibold",children:e==="working"?"Completing Authorization":e==="success"?"Authorization Complete":"Authorization Failed"})}),s.jsx("p",{className:"typography-body text-muted-foreground",children:r})]}),e!=="working"&&s.jsx("div",{className:"mt-8 flex justify-center",children:s.jsx($e,{type:"button",onClick:()=>{typeof window>"u"||window.location.replace("/")},children:"Return to OpenChamber"})})]})})},Rf=oo(()=>io(()=>import("./OnboardingScreen-DRe8UNiS.js"),__vite__mapDeps([12,1,2,4,5,3])).then(t=>({default:t.OnboardingScreen}))),mC=()=>{const t=mt.c(3),e=Ee(yC),n=Ee(wC);let r;return t[0]!==e||t[1]!==n?(r=s.jsx(dC,{open:e,onOpenChange:n}),t[0]=e,t[1]=n,t[2]=r):r=t[2],r},hC=t=>{const e=mt.c(21),{onRetry:n,isRetrying:r}=t,{t:o}=Nt();let a;e[0]!==o?(a=o("startup.initRecovery.title"),e[0]=o,e[1]=a):a=e[1];let c;e[2]!==a?(c=s.jsx("h1",{className:"typography-title text-foreground",children:a}),e[2]=a,e[3]=c):c=e[3];let l;e[4]!==o?(l=o("startup.initRecovery.description"),e[4]=o,e[5]=l):l=e[5];let d;e[6]!==l?(d=s.jsx("p",{className:"typography-body text-muted-foreground",children:l}),e[6]=l,e[7]=d):d=e[7];let u;e[8]!==c||e[9]!==d?(u=s.jsxs("div",{className:"flex flex-col gap-2",children:[c,d]}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let m;e[11]!==r||e[12]!==o?(m=o(r?"startup.initRecovery.retrying":"startup.initRecovery.retry"),e[11]=r,e[12]=o,e[13]=m):m=e[13];let f;e[14]!==r||e[15]!==n||e[16]!==m?(f=s.jsx($e,{type:"button",onClick:n,disabled:r,children:m}),e[14]=r,e[15]=n,e[16]=m,e[17]=f):f=e[17];let p;return e[18]!==u||e[19]!==f?(p=s.jsx("div",{className:"flex h-full items-center justify-center bg-background px-6 text-foreground",children:s.jsxs("div",{className:"flex max-w-md flex-col items-center gap-4 text-center",children:[u,f]})}),e[18]=u,e[19]=f,e[20]=p):p=e[20],p},Ef=t=>t?t.replace(/\\/g,"/").replace(/\/+$/g,""):"",pC=()=>{if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search);if(t.get("ocPanel")!=="session-chat")return null;const e=t.get("sessionId"),n=typeof e=="string"?e.trim():"";if(!n)return null;const r=t.get("directory"),o=typeof r=="string"&&r.trim().length>0?r.trim():null;return{sessionId:n,directory:o,readOnly:t.get("readOnly")==="1"||t.get("readOnly")==="true"}},gC=()=>typeof window>"u"?!1:window.location.pathname===ab,xC=t=>{const e=mt.c(23),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:o}=t,a=Js(vC),c=ut(jC),l=ut(SC),d=Ec(),u=i.useRef(null);let m;e[0]!==n.directory?(m=Ef(n.directory),e[0]=n.directory,e[1]=m):m=e[1];const f=m;let p;e[2]!==a?(p=Ef(a),e[2]=a,e[3]=p):p=e[3];const y=p;let g,b;if(e[4]!==y||e[5]!==c||e[6]!==n.directory||e[7]!==n.sessionId||e[8]!==f||e[9]!==r||e[10]!==l||e[11]!==d?(g=()=>{if(r||f&&y!==f)return;const S=`${f}
|
|
214
214
|
${n.sessionId}`;u.current===S&&c===n.sessionId||(u.current=S,l(n.sessionId,n.directory),d.ensureSessionRenderable(n.sessionId,!0))},b=[y,c,n.directory,n.sessionId,f,r,l,d],e[4]=y,e[5]=c,e[6]=n.directory,e[7]=n.sessionId,e[8]=f,e[9]=r,e[10]=l,e[11]=d,e[12]=g,e[13]=b):(g=e[12],b=e[13]),i.useEffect(g,b),f&&y!==f)return null;let x;e[14]!==o?(x=s.jsx(xm,{embeddedBackgroundWorkEnabled:o}),e[14]=o,e[15]=x):x=e[15];let h;e[16]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(Dm,{}),e[16]=h):h=e[16];let C;e[17]!==n.readOnly?(C=s.jsx(Ql,{readOnly:n.readOnly}),e[17]=n.readOnly,e[18]=C):C=e[18];let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(bm,{}),e[19]=w):w=e[19];let v;return e[20]!==x||e[21]!==C?(v=s.jsxs(s.Fragment,{children:[x,h,C,w]}),e[20]=x,e[21]=C,e[22]=v):v=e[22],v};function bC({apis:t}){i.useEffect(()=>{wp("App:mounted"),vp()&&console.info("[startup-trace] enabled. Run console.table(window.__OPENCHAMBER_STARTUP_TRACE__) after startup.")},[]);const e=ss(O=>O.initializeApp),n=ss(O=>O.isInitialized),r=ss(O=>O.isConnected),o=ss(O=>O.providers.length),a=ss(O=>O.agents.length),c=ss(O=>O.loadProviders),l=ss(O=>O.loadAgents),d=ut(O=>O.error),u=ut(O=>O.clearError),m=Js(O=>O.currentDirectory),f=Js(O=>O.setDirectory),p=Js(O=>O.isSwitchingDirectory),[y,g]=i.useState(!1),b=Pi(O=>O.refreshStatus),[x,h]=i.useState(()=>t.runtime.isVSCode),[C,w]=i.useState(!0),[v,S]=i.useState(!1),[k,j]=i.useState(0),[A,D]=i.useState(0),[N,B]=i.useState(!1),T=Ee(O=>O.wideChatLayoutEnabled),E=Ee(O=>O.mobileKeyboardMode),_=i.useMemo(()=>dr(),[]),R=vc(O=>O.setPlanModeEnabled),[V,$]=i.useState(()=>jd()),[z,F]=i.useState(()=>{const O=Sd();return O!==null?Nd({isDesktopShell:!0,bootOutcome:O}):null}),te=i.useRef(!1),ne=i.useMemo(()=>pC(),[]),q=!ne||C,H=i.useMemo(()=>gC(),[]);i.useEffect(()=>(kd(y),()=>{kd(!1)}),[y]),i.useEffect(()=>{jp(E)},[E]),i.useEffect(()=>{h(t.runtime.isVSCode)},[t.runtime.isVSCode]),i.useEffect(()=>$f(O=>{ut.getState().prepareForRuntimeSwitch(O.previousRuntimeKey),Ee.getState().prepareForRuntimeSwitch(O.previousRuntimeKey),O.previousRuntimeKey&&cl.getState().stopRunningRunsForRuntime(O.previousRuntimeKey),Sp(),_n.reconnectToRuntimeBaseUrl(),ss.setState({providers:[],agents:[],isConnected:!1,isInitialized:!1,connectionPhase:"connecting",lastDisconnectReason:null}),ws.getState().resetForRuntimeSwitch(),ut.getState().restoreForRuntimeSwitch(O.runtimeKey),Ee.getState().restoreForRuntimeSwitch(O.runtimeKey),jx(),D(se=>se+1),S(!1),j(se=>se+1)}),[]);const X=cl(O=>{const se=Cd();return Object.values(O.runsByOriginalSessionID).filter(ee=>ee.status==="running"&&ee.runtimeKey===se).map(ee=>`${ee.originalSessionID}:${ee.phase}:${ee.lastForwardedMessageID??""}:${ee.expectedAssistantParentID??""}`).sort().join("|")});i.useEffect(()=>{if(ne)return;const O=Cd(),se=Object.values(cl.getState().runsByOriginalSessionID).filter(ee=>ee.status==="running"&&ee.runtimeKey===O);for(const ee of se)Sx(ee.originalSessionID)},[X,ne,A]),i.useEffect(()=>(document.documentElement.classList.toggle("wide-chat-layout",T),()=>{document.documentElement.classList.remove("wide-chat-layout")}),[T]),i.useEffect(()=>(Ad(t),()=>Ad(null)),[t]),i.useEffect(()=>{ne||b(t.github,{force:!0})},[t.github,ne,b]),Nx();const oe=V==="valid",he=z?.screen==="main";i.useEffect(()=>{if(!Np({isDesktopShell:_,isInitialized:n,bootOutcomeKnown:oe,bootViewIsMain:he}))return;const O=setTimeout(()=>{const se=document.getElementById("initial-loading");se&&(se.classList.add("fade-out"),setTimeout(()=>{se.remove()},300))},150);return()=>clearTimeout(O)},[_,n,oe,he]),i.useEffect(()=>{if(!_||V!=="malformed")return;const O=document.getElementById("initial-loading");O&&(O.textContent="Desktop startup failed — please restart the app.")},[_,V]),i.useEffect(()=>{if(_)return;const O=setTimeout(()=>{const se=document.getElementById("initial-loading");se&&!n&&(se.classList.add("fade-out"),setTimeout(()=>{se.remove()},300))},5e3);return()=>clearTimeout(O)},[_,n]),i.useEffect(()=>{let O=!1;return(async()=>{const ee=await As("/health",{method:"GET"}).catch(()=>null);if(!ee||!ee.ok||O)return;const je=await ee.json().catch(()=>null);if(!je||O)return;const De=je.planModeExperimentalEnabled;R(De===!0||De===1||De==="1"||De==="true")})(),()=>{O=!0}},[R]),i.useEffect(()=>{x||e()},[e,x]),i.useEffect(()=>{if(x||n)return;let O=!0,se,ee=0;const je=10,De=1e3,Be=async()=>{if(!O)return;if(ee>=je){S(!0);return}const Fe=ss.getState();if(Fe.isInitialized){S(!1);return}ee+=1,await Fe.initializeApp();const Me=ss.getState();if(!O)return;if(Me.isInitialized){S(!1);return}if(ee>=je){S(!0);return}const fe=Math.min(De*Math.pow(2,ee-1),16e3);se=setTimeout(Be,fe)};return se=setTimeout(Be,De),()=>{O=!1,se&&clearTimeout(se)}},[k,n,x]),i.useEffect(()=>{n&&S(!1)},[n]),i.useEffect(()=>{if(!v)return;const O=document.getElementById("initial-loading");O&&(O.classList.add("fade-out"),setTimeout(()=>{O.remove()},300))},[v]),i.useEffect(()=>{if(x||!r||o>0&&a>0)return;let O=!0,se=0;const ee=15,je=async()=>{const Be=ss.getState();if(!(Be.providers.length>0&&Be.agents.length>0))try{Be.providers.length===0&&await c({source:"startupRecovery"}),ss.getState().agents.length===0&&await l({source:"startupRecovery"})}catch{}};je();const De=setInterval(()=>{if(O){if(++se>=ee){clearInterval(De);return}je()}},2e3);return()=>{O=!1,clearInterval(De)}},[r,x,l,c,o,a]),i.useEffect(()=>{p||x||r&&_n.setDirectory(m)},[m,p,r,x]),i.useEffect(()=>{if(!ne||typeof window>"u")return;const O=je=>{const De=je?.visible===!0;w(De)},se=je=>{if(je.origin!==window.location.origin)return;const De=je.data;De?.type==="openchamber:embedded-visibility"&&O(De.payload)},ee=window;return ee.__openchamberSetEmbeddedVisibility=O,window.addEventListener("message",se),()=>{window.removeEventListener("message",se),ee.__openchamberSetEmbeddedVisibility===O&&delete ee.__openchamberSetEmbeddedVisibility}},[ne]),i.useEffect(()=>{!ne?.directory||x||m!==ne.directory&&f(ne.directory,{showOverlay:!1})},[m,ne,x,f]),i.useEffect(()=>{if(!ne||typeof window>"u")return;const O=se=>{se.storageArea===window.localStorage&&se.key==="ui-store"&&Ee.persist.rehydrate()};return window.addEventListener("storage",O),()=>{window.removeEventListener("storage",O)}},[ne]),i.useEffect(()=>{if(typeof window>"u")return;const O=se=>{const ee=se.detail,je=typeof ee?.sessionId=="string"?ee.sessionId.trim():"";if(!je)return;const De=typeof ee?.directory=="string"&&ee.directory.trim().length>0?ee.directory.trim():null;Ee.getState().setActiveMainTab("chat"),ut.getState().setCurrentSession(je,De)};return window.addEventListener("openchamber:open-session",O),()=>window.removeEventListener("openchamber:open-session",O)},[]),i.useEffect(()=>{if(typeof window>"u")return;const O=()=>{const se=Js.getState().currentDirectory,{activeProjectId:ee,projects:je}=ws.getState(),De=je.find(Be=>Be.id===ee)??null;Wr("desktop_open_draft_mini_chat_window",{directory:se||De?.path||"",projectId:De?.id??null})};return window.addEventListener("openchamber:open-mini-chat",O),()=>window.removeEventListener("openchamber:open-mini-chat",O)},[]),i.useEffect(()=>{if(typeof window>"u")return;const O=()=>{const se=ut.getState().currentSessionId;se&&am(se)};return window.addEventListener("focus",O),()=>window.removeEventListener("focus",O)},[]),i.useEffect(()=>{if(typeof window>"u")return;const O=se=>{const ee=se.detail,je=typeof ee?.directory=="string"&&ee.directory.trim().length>0?ee.directory.trim():null,De=typeof ee?.projectId=="string"&&ee.projectId.trim().length>0?ee.projectId.trim():null;Ee.getState().setActiveMainTab("chat"),Ee.getState().setSessionSwitcherOpen(!1),ut.getState().openNewSessionDraft({selectedProjectId:De,directoryOverride:je,preserveDirectoryOverride:!!je})};return window.addEventListener("openchamber:open-draft-session",O),()=>window.removeEventListener("openchamber:open-draft-session",O)},[]),i.useEffect(()=>{if(typeof window>"u")return;const O=se=>{const ee=se.detail,je=typeof ee?.projectPath=="string"?ee.projectPath.trim():"";if(!je)return;const De=ws.getState(),Be=De.projects.find(Fe=>Fe.path===je);Be?De.setActiveProject(Be.id):De.addProject(je)};return window.addEventListener("openchamber:open-project",O),()=>window.removeEventListener("openchamber:open-project",O)},[]),i.useEffect(()=>{typeof window>"u"||!n||p||te.current||(te.current=!0,window.__openchamberAppReady=!0,window.dispatchEvent(new Event("openchamber:app-ready")))},[n,p]),kx({enabled:q}),aC({enabled:q}),cC(),Cx(),ib();const Se=i.useCallback(()=>{g(O=>!O)},[]);Wk(Se),nC(),i.useEffect(()=>{if(ne)return;const O=se=>{jc(se)&&se.shiftKey&&!se.altKey&&(se.code==="KeyD"||se.key.toLowerCase()==="d")&&(se.preventDefault(),g(je=>!je))};return window.addEventListener("keydown",O,!0),()=>window.removeEventListener("keydown",O,!0)},[ne]),i.useEffect(()=>{ne||d&&setTimeout(()=>u(),5e3)},[u,ne,d]),i.useEffect(()=>{if(!_||V!=="not-injected")return;let O=!1,se=0;const ee=200,je=2e3,De=50,Be=()=>{if(O)return;se++;const Fe=jd();if(Fe!=="not-injected"){if(O=!0,$(Fe),Fe==="valid"){const fe=Sd();fe&&F(Nd({isDesktopShell:!0,bootOutcome:fe}))}return}const Me=Math.min(ee*Math.pow(1.1,se),je);if(se>=De){const fe=document.getElementById("initial-loading");fe&&!fe.textContent?.includes("taking longer")&&(fe.textContent="Desktop startup is taking longer than expected...")}window.setTimeout(Be,Me)};return window.setTimeout(Be,ee),()=>{O=!0}},[_,V]);const Z=i.useCallback(async()=>{if(kp({isDesktopShell:dr(),isDesktopLocalOriginActive:Ji()})){await Cp();return}window.location.reload()},[]),ke=i.useCallback(async()=>{if(!N){S(!1),B(!0);try{await ss.getState().initializeApp()}finally{B(!1)}ss.getState().isInitialized||j(O=>O+1)}},[N]),Y=O=>{if(O.screen==="recovery")return O.variant};if(_&&z&&z.screen!=="main"){if(z.screen==="chooser")return s.jsx(Zs,{children:s.jsx("div",{className:"h-full text-foreground bg-transparent",children:s.jsx(i.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Rf,{mode:"first-launch",onCliAvailable:Z,onChooseRemote:()=>{}})})})});const O=Y(z),se=z.screen==="recovery"&&"url"in z?z.url:void 0;return s.jsx(Zs,{children:s.jsx("div",{className:"h-full text-foreground bg-transparent",children:s.jsx(i.Suspense,{fallback:s.jsx("div",{className:"h-full"}),children:s.jsx(Rf,{mode:"recovery",recoveryVariant:O,recoveryHostUrl:se,recoveryHostLabel:void 0,onCliAvailable:Z})})})})}if(ne)return s.jsx(Zs,{children:s.jsx(Hd,{sdk:_n.getSdkClient(),directory:m||"",children:s.jsx(Gd,{apis:t,children:s.jsx(Kd,{delayDuration:300,skipDelayDuration:150,children:s.jsx("div",{className:"h-full text-foreground bg-background",children:s.jsx(xC,{embeddedSessionChat:ne,isVSCodeRuntime:x,embeddedBackgroundWorkEnabled:q})})})})},A)});if(H)return s.jsx(Zs,{children:s.jsx(fC,{})});if(v&&!n&&!x&&!ne)return s.jsx(Zs,{children:s.jsx(hC,{onRetry:()=>{ke()},isRetrying:N})});const ge=!n&&!_;return s.jsx(Zs,{children:s.jsx(Hd,{sdk:_n.getSdkClient(),directory:m||"",children:s.jsx(Gd,{apis:t,children:s.jsx(Oy,{children:s.jsx(Ax,{children:s.jsx(Kd,{delayDuration:300,skipDelayDuration:150,children:s.jsxs("div",{className:_?"h-full text-foreground bg-transparent":"h-full text-foreground bg-background",children:[s.jsx(xm,{embeddedBackgroundWorkEnabled:q}),s.jsx(Dm,{}),s.jsx(Dk,{}),s.jsx(bm,{}),!ge&&s.jsxs(s.Fragment,{children:[s.jsx(ob,{}),s.jsx(mC,{}),y&&s.jsx(Tk,{onClose:()=>g(!1)})]})]})})})})})},A)})}function yC(t){return t.isAboutDialogOpen}function wC(t){return t.setAboutDialogOpen}function vC(t){return t.currentDirectory}function jC(t){return t.currentSessionId}function SC(t){return t.setCurrentSession}const NC=typeof window<"u"&&window.__OPENCHAMBER_RUNTIME_APIS__||(()=>{throw new Error("Runtime APIs not provided for legacy UI entrypoint.")})();Dx();Ap().then(()=>{Promise.all([Dp(),Ix()]).catch(t=>{console.error("[main] settings init failed:",t)}),Px(),Tx(),Rx()}).catch(t=>{console.error("[main] appearance init failed:",t)});const Ch=document.getElementById("root");if(!Ch)throw new Error("Root element not found");ap.createRoot(Ch).render(s.jsx(Xe.StrictMode,{children:s.jsx(Ex,{children:s.jsx(Mx,{children:s.jsx(Fx,{children:s.jsx(Lx,{children:s.jsx(bC,{apis:NC})})})})})}));const EC=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{h1 as D,wk as M,EC as m,_s as u};
|