@openchambery/web 1.17.1-beta.13 → 1.17.1-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-Coq-zdWI.js → AgentAvatar-Bms-mdYQ.js} +1 -1
- package/dist/assets/{AssistantView-BXLxZXL5.js → AssistantView-BsNQRigh.js} +1 -1
- package/dist/assets/{ChatContainer-BJGlptbG.js → ChatContainer-DIwtSgsr.js} +40 -40
- package/dist/assets/{DiagramView-Czx_DVw0.js → DiagramView-D_sANMdv.js} +1 -1
- package/dist/assets/{FadeInOnReveal-1KpYuooP.js → FadeInOnReveal-EV5Qh80w.js} +1 -1
- package/dist/assets/{Icon-Vc-aDche.js → Icon-DFt6p0LW.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-B9Bv95Vd.js → MarkdownRendererImpl-DQNSi5wy.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-RupyXzPu.js → MobileDetailNavigation-9YLiSVDj.js} +1 -1
- package/dist/assets/{MobileShareBridge-LVT1_q5C.js → MobileShareBridge-DTiuPPrq.js} +2 -2
- package/dist/assets/{MobileSurface-BVwSEqn4.js → MobileSurface-CPblBd1D.js} +1 -1
- package/dist/assets/{MultiRunWindow-C7hbEpv9.js → MultiRunWindow-gGcTpldw.js} +1 -1
- package/dist/assets/{OnboardingScreen-CrekVj31.js → OnboardingScreen-BH0mukiU.js} +1 -1
- package/dist/assets/{OverlayScrollbar-vZXoSFA9.js → OverlayScrollbar-DCW9Vqzf.js} +1 -1
- package/dist/assets/{SettingsView-C1sYcHr1.js → SettingsView-B2bn04nf.js} +7 -7
- package/dist/assets/{SettingsWindow-MtcqpoiN.js → SettingsWindow-Dc74E9Dh.js} +1 -1
- package/dist/assets/{TerminalView-DXQZlHNA.js → TerminalView-DjhskjbL.js} +1 -1
- package/dist/assets/{ToolOutputDialog-_Qzdo46T.js → ToolOutputDialog-CPMtqcHe.js} +1 -1
- package/dist/assets/{appThemeRegistry-Chv6_pxq.js → appThemeRegistry-CMVueY2X.js} +2 -2
- package/dist/assets/{button-rDAIP5kY.js → button-TdqFSeGV.js} +1 -1
- package/dist/assets/{collapsible-nLeZm1kw.js → collapsible-BcmzZNos.js} +1 -1
- package/dist/assets/{context-menu-DeJdA9F6.js → context-menu-BqY0FYBE.js} +1 -1
- package/dist/assets/{desktopHosts-RE7NIkeq.js → desktopHosts-BpyCdW6s.js} +1 -1
- package/dist/assets/{desktopRelayRestore-BzyaU7-i.js → desktopRelayRestore-Dsv333nO.js} +1 -1
- package/dist/assets/{diagram-C7qK82ZL.js → diagram-DPzoxeQp.js} +1 -1
- package/dist/assets/{dialog-DlUK6mj-.js → dialog-D4gzlv1Y.js} +1 -1
- package/dist/assets/{fileQueries-D8m3PQr0.js → fileQueries-DO24BEHy.js} +1 -1
- package/dist/assets/{gitApi-DV6F5KKI.js → gitApi-fAXcplj8.js} +1 -1
- package/dist/assets/{gitApiHttp-BswZXfrf.js → gitApiHttp-gCfEig4j.js} +1 -1
- package/dist/assets/{i18n-BAqcSln8.js → i18n-DLJBVySJ.js} +1 -1
- package/dist/assets/{input-CxulMZ9j.js → input-CRIOZS4l.js} +1 -1
- package/dist/assets/{insertionBoundaries-7-TvMfgn.js → insertionBoundaries-BIawMpoi.js} +1 -1
- package/dist/assets/{main-q1V-_wWx.js → main-R4hZDoRL.js} +2 -2
- package/dist/assets/main-l1Oprp3i.js +172 -0
- package/dist/assets/{markdown-worker-DmBYud1m.js → markdown-worker-Cdsb6HMC.js} +1 -1
- package/dist/assets/{markdownTheme-CNJf24L-.js → markdownTheme-DXrASRAr.js} +1 -1
- package/dist/assets/{miniChat-VXuyA8mS.js → miniChat-Cm2pFkB8.js} +2 -2
- package/dist/assets/mobile-D33vRnZI.js +2 -0
- package/dist/assets/{multirun-QqMnIbXa.js → multirun-BI9e-g3X.js} +1 -1
- package/dist/assets/{persistence-CFtygeYy.js → persistence-Dx4t3MFT.js} +1 -1
- package/dist/assets/{projectMeta-WJhNyk90.js → projectMeta-2gK0nfv3.js} +1 -1
- package/dist/assets/radio-BeqCnypA.js +1 -0
- package/dist/assets/{renderElectronMiniChatApp-CnmMV1o9.js → renderElectronMiniChatApp-B3BXS80K.js} +2 -2
- package/dist/assets/renderMobileApp-Bf3XAs8x.js +23 -0
- package/dist/assets/{runtimeConfig-D4ETkuTj.js → runtimeConfig-vDCmAjqe.js} +1 -1
- package/dist/assets/runtimeEndpointReset-BfyidPT5.js +145 -0
- package/dist/assets/{sortable-tabs-strip-Fiq5nrkF.js → sortable-tabs-strip-CXl974q-.js} +1 -1
- package/dist/assets/{terminalApi-MQ285A_s.js → terminalApi-DeRDgtLC.js} +1 -1
- package/dist/assets/{tooltip-CbxKYhKv.js → tooltip-L0UVzQuU.js} +1 -1
- package/dist/assets/{ui-D5j3JxkE.js → ui-DIbCJvaY.js} +19 -19
- package/dist/assets/{url-BSalv2ov.js → url-DNSNOUnB.js} +1 -1
- package/dist/assets/{useAppFontEffects-CaGwli-K.js → useAppFontEffects-D9Xl8fer.js} +4 -4
- package/dist/assets/{useAssistantUIStore-DGtjM827.js → useAssistantUIStore-CKpKMQ7k.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-DCZXksMp.js → useDesktopWindowControlsLayout-CLG2IOgf.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-CssNtlqg.js → useEffectiveDirectory-JsJxeoXM.js} +1 -1
- package/dist/assets/{useFontPreferences-C7FEHFns.js → useFontPreferences-DkEh4AWh.js} +1 -1
- package/dist/assets/{useSessionAutoCleanup-B_mSwN7n.js → useSessionAutoCleanup-CvXVWbFK.js} +1 -1
- package/dist/assets/{useUIStore-WQV8IuFw.js → useUIStore-CZy3uiW5.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-C74ZKDtw.js → useWorkerHighlightedLines-DjdrzMow.js} +1 -1
- package/dist/assets/{utils-Cwlw2GM0.js → utils-DD0PVWqD.js} +1 -1
- package/dist/index.html +8 -8
- package/dist/mini-chat.html +8 -8
- package/dist/mobile.html +8 -8
- package/package.json +1 -1
- package/server/lib/opencode/settings-runtime.js +1 -1
- package/dist/assets/main-CADHVH9Y.js +0 -172
- package/dist/assets/mobile-CaKZM4y3.js +0 -2
- package/dist/assets/radio-C1riLnF0.js +0 -1
- package/dist/assets/renderMobileApp-Bhe41b2q.js +0 -23
- package/dist/assets/runtimeEndpointReset-GtJt8YhT.js +0 -145
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{A as t,D as n,E as r,b as i,j as a,k as o,t as s}from"./useUIStore-CZy3uiW5.js";import{$t as c,Xt as l,_n as u,d,kn as f,kt as p,on as m,r as h,st as g,u as _,yn as v}from"./persistence-Dx4t3MFT.js";import{a as y,i as b}from"./vendor-zustand-B4dlGEM2.js";import{nt as x,rt as S,tt as C}from"./vendor-base-ui-CnHfUmDN.js";import{kt as w,yt as T}from"./gitApiHttp-gCfEig4j.js";import{n as E}from"./vendor-react-DLPElpoQ.js";import{n as D,s as O,t as k}from"./vendor-tanstack-react-query-D7pys_c9.js";import{i as A}from"./terminalApi-DeRDgtLC.js";import{n as j}from"./vendor-reactuses-core-DDoDDyM9.js";import{l as M,n as N,t as ee}from"./i18n-DLJBVySJ.js";import{Ar as P,Cr as F,Dn as I,Dr as te,Gr as ne,Ia as L,Jr as R,Ki as z,Mi as B,Ni as V,Pn as H,Pr as U,Rt as W,Sn as re,Sr as ie,Tn as G,Wa as ae,Wi as oe,_r as se,br as ce,d as K,ei as le,fi as q,fo as ue,gn as de,go as fe,hr as pe,mo as me,mr as he,nn as ge,pr as _e,t as J,vn as ve,vr as ye,xr as be,yn as xe,yr as Se,zt as Ce}from"./ui-DIbCJvaY.js";import{i as we,t as Te}from"./store-CS6l6pH7.js";import{i as Ee,t as De}from"./useAssistantUIStore-CKpKMQ7k.js";import{t as Oe}from"./MobileDetailNavigation-9YLiSVDj.js";import{n as ke,t as Y}from"./utils-DD0PVWqD.js";import{n as X}from"./Icon-DFt6p0LW.js";import{a as Ae,i as je,n as Me,o as Ne,r as Pe,t as Fe}from"./dialog-D4gzlv1Y.js";import{t as Z}from"./button-TdqFSeGV.js";import{d as Ie}from"./gitApi-fAXcplj8.js";import{R as Le,Z as Re,o as ze,s as Be}from"./useAppFontEffects-D9Xl8fer.js";import{A as Ve,N as He,S as Ue,a as We,c as Ge,f as Ke,g as qe,h as Je,i as Ye,j as Xe,m as Ze,n as Qe,o as $e,p as et,r as tt,t as nt,u as rt,v as it,x as at}from"./projectMeta-2gK0nfv3.js";import{t as ot}from"./input-CRIOZS4l.js";import{i as st,n as ct,t as lt}from"./tooltip-L0UVzQuU.js";import{_ as ut,g as dt,h as ft,m as pt}from"./useSessionAutoCleanup-CvXVWbFK.js";import{n as mt,t as ht}from"./useThemeSystem-DMzWVJaW.js";import{A as gt,C as _t,D as vt,E as yt,N as bt,O as xt,Q as St,T as Ct,X as wt,Z as Tt,h as Et,j as Dt,p as Ot,v as kt,y as At}from"./radio-BeqCnypA.js";import{i as jt,t as Mt}from"./OverlayScrollbar-DCW9Vqzf.js";import{g as Nt,x as Pt}from"./markdownTheme-DXrASRAr.js";import{K as Ft,U as It,V as Lt,W as Rt,et as zt,t as Bt,y as Vt,z as Ht}from"./ChatContainer-DIwtSgsr.js";import{n as Ut}from"./useRuntimeAPIs-DSLXJybW.js";import{c as Wt,n as Gt,t as Kt}from"./appThemeRegistry-CMVueY2X.js";import{_ as qt,i as Jt,l as Yt,s as Xt,t as Zt,v as Qt,y as $t}from"./vendor-dnd-kit-core-CvWxUPdb.js";import{a as en,o as tn,s as nn,t as rn}from"./vendor-dnd-kit-sortable-hHdP9lLb.js";import{h as an,p as on}from"./markdown-worker-Cdsb6HMC.js";import{n as sn}from"./useEffectiveDirectory-JsJxeoXM.js";import{f as cn}from"./FadeInOnReveal-EV5Qh80w.js";import{E as ln,T as un,b as dn,g as fn,k as pn,r as mn,x as hn,y as gn}from"./insertionBoundaries-BIawMpoi.js";import{n as _n}from"./useWorkerHighlightedLines-DjdrzMow.js";import{t as vn}from"./vendor-tanstack-react-virtual-tlDgH6PG.js";import{c as yn,d as bn,f as xn,l as Sn,m as Cn,n as wn,o as Tn,p as En,s as Dn,t as On,u as kn}from"./vendor-pierre-diffs-BenIz2TM.js";import{a as An,i as jn,n as Mn}from"./vendor-framer-motion-DFy_BSVd.js";import{E as Nn,H as Pn,J as Fn,P as In,X as Ln,Y as Rn,a as zn,g as Bn,t as Vn,u as Hn}from"./MobileSurface-CPblBd1D.js";import{a as Un,i as Wn,n as Gn,r as Kn,t as qn}from"./context-menu-BqY0FYBE.js";import{n as Jn,r as Yn,t as Xn}from"./collapsible-BcmzZNos.js";import{t as Zn}from"./vendor-cron-parser-CCD11YFT.js";var Q=e(S(),1),Qn=E(),$=x(),$n=e(C(),1);function er(){return new Worker(On,{type:`module`})}var tr=[`typescript`,`javascript`,`tsx`,`jsx`,`json`,`markdown`],nr={unified:{poolSize:1,totalASTLRUCacheSize:24,lineDiffType:`none`},split:{poolSize:2,totalASTLRUCacheSize:56,lineDiffType:`word-alt`}},rr,ir,ar=e=>{let t=nr[e],n=new En({workerFactory:er,poolSize:t.poolSize,totalASTLRUCacheSize:t.totalASTLRUCacheSize},{theme:{light:`pierre-light`,dark:`pierre-dark`},langs:tr,lineDiffType:t.lineDiffType,preferredHighlighter:`shiki-wasm`});return n.initialize(),n},or=e=>{if(!(typeof window>`u`))return e===`split`?(ir??=ar(`split`),ir):(rr??=ar(`unified`),rr)},sr=e=>{let t=(0,Qn.c)(7),{children:n,renderTheme:r}=e,i=lr(`unified`),a=lr(`split`),o,s;t[0]!==r||t[1]!==a||t[2]!==i?(o=()=>{i&&i.setRenderOptions({theme:r,lineDiffType:nr.unified.lineDiffType}),a&&a.setRenderOptions({theme:r,lineDiffType:nr.split.lineDiffType})},s=[r,a,i],t[0]=r,t[1]=a,t[2]=i,t[3]=o,t[4]=s):(o=t[3],s=t[4]),(0,Q.useEffect)(o,s);let c;return t[5]===n?c=t[6]:(c=(0,$.jsx)($.Fragment,{children:n}),t[5]=n,t[6]=c),c},cr=e=>{let t=(0,Qn.c)(11),{children:n}=e,r=ht(),i,a;if(t[0]!==r?.availableThemes||t[1]!==r?.darkThemeId||t[2]!==r?.lightThemeId){let e=Pt(!1),n=Pt(!0),o=r?.lightThemeId??e.metadata.id,s=r?.darkThemeId??n.metadata.id;a=r?.availableThemes.find(e=>e.metadata.id===o)??e,i=r?.availableThemes.find(e=>e.metadata.id===s)??n,Kt(a),Kt(i),t[0]=r?.availableThemes,t[1]=r?.darkThemeId,t[2]=r?.lightThemeId,t[3]=i,t[4]=a}else i=t[3],a=t[4];let o;t[5]!==i.metadata.id||t[6]!==a.metadata.id?(o={light:a.metadata.id,dark:i.metadata.id},t[5]=i.metadata.id,t[6]=a.metadata.id,t[7]=o):o=t[7];let s=o,c;return t[8]!==n||t[9]!==s?(c=(0,$.jsx)(sr,{renderTheme:s,children:n}),t[8]=n,t[9]=s,t[10]=c):c=t[10],c},lr=e=>{let t=(0,Qn.c)(2),n=e===void 0?`unified`:e,r;return t[0]===n?r=t[1]:(r=or(n),t[0]=n,t[1]=r),r},ur={},dr=[],fr=(e,t)=>{if(!e)return t(`mcpDropdown.status.unknown`);switch(e.status){case`connected`:return t(`mcpDropdown.status.connected`);case`failed`:return t(`mcpDropdown.status.failed`,{error:e.error||t(`mcpDropdown.status.unknownError`)});case`needs_auth`:return t(`mcpDropdown.status.needsAuth`);case`needs_client_registration`:return t(`mcpDropdown.status.needsRegistration`,{error:e.error||``});default:return e.status}},pr=e=>{switch(e?.status){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`default`}},mr=({active:e,className:t,headerAction:n,listClassName:r,hideHeader:i=!1,mobileListDensity:a=!1})=>{let{t:o}=ee(),s=T(e=>e.currentDirectory)??null,c=Pn(e=>e.connect),l=Pn(e=>e.disconnect),{data:u,refetch:d,isError:f,error:p}=Rn(s,{enabled:e}),{data:m}=Fn(s,{enabled:e}),h=u??ur,g=m??dr,[_,v]=Q.useState(!1),[y,b]=Q.useState(null),x=Q.useMemo(()=>{let e=new Set(Object.keys(h));for(let t of g)t?.name&&e.add(t.name);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[g,h]),S=Q.useCallback(e=>{if(e?.preventDefault(),_)return;v(!0);let t=new Promise(e=>setTimeout(e,500));Promise.all([d(),t]).finally(()=>{v(!1)})},[_,d]);return(0,$.jsxs)(`div`,{className:Y(`w-full`,t),children:[i?null:(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex items-baseline gap-2`,children:[(0,$.jsx)(`div`,{className:`typography-ui-header font-semibold text-foreground`,children:o(`mcpDropdown.title`)}),s&&(0,$.jsx)(`div`,{className:`truncate typography-micro text-muted-foreground`,children:s.split(`/`).pop()||s})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n,(0,$.jsx)(`button`,{type:`button`,className:`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`,disabled:_,onClick:S,"aria-label":o(`mcpDropdown.actions.refreshAria`),children:(0,$.jsx)(X,{name:`refresh`,className:Y(`h-4 w-4`,_&&`animate-spin`)})})]})]})}),(0,$.jsx)(`div`,{className:Y(`max-h-64 overflow-y-auto`,a?`space-y-1 py-3`:`px-3 py-2.5`,r),children:(0,$.jsxs)(`div`,{className:Y(!a&&x.length>0&&`rounded-xl bg-[var(--surface-muted)] p-1.5`),children:[x.map(e=>{let t=h[e]??(f&&!u&&g.some(t=>t.name===e)?{status:`failed`,error:p.message}:void 0),n=pr(t),r=t?.status===`connected`,i=y===e,d=fr(t,o);return(0,$.jsxs)(`div`,{className:Y(`flex items-center justify-between rounded-lg hover:bg-interactive-hover/50`,a?`gap-3 px-4 py-3`:`gap-2 px-2.5 py-2`),children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsxs)(lt,{children:[(0,$.jsx)(st,{asChild:!0,children:(0,$.jsx)(`span`,{className:Y(`rounded-full flex-shrink-0`,a?`h-2.5 w-2.5`:`h-2 w-2`,n===`success`&&`bg-status-success`,n===`error`&&`bg-status-error`,n===`warning`&&`bg-status-warning`,n==="default"&&`bg-muted-foreground/40`),"aria-label":d})}),(0,$.jsx)(ct,{side:`left`,children:(0,$.jsx)(`p`,{children:d})})]}),(0,$.jsx)(`span`,{className:Y(`truncate`,a?`text-[17px] leading-6 font-medium`:`typography-ui-label`),children:e})]})}),(0,$.jsx)(Ln,{checked:r,disabled:i,className:`data-[checked]:bg-status-info`,onCheckedChange:async t=>{b(e);try{t?await c(e,s):await l(e,s)}finally{b(null)}}})]},e)}),x.length===0&&(0,$.jsx)(`div`,{className:`px-4 py-5 typography-ui-label text-muted-foreground text-center`,children:o(`mcpDropdown.empty.configureInConfig`)})]})})]})},hr=e=>!(e.dismissed===`true`||e.sessionShown===`true`||e.hasActiveToast),gr=e=>!(!e.version||e.seenVersions.has(e.version)||e.dismissedVersion!==null&&e.dismissedVersion===e.version),_r=e=>{if(typeof e!=`object`||!e)return``;let t=e.version;return typeof t==`string`?t.trim():``},vr=e=>!e||e.available!==!0||typeof e.latestVersion!=`string`?``:e.latestVersion.trim(),yr=5e3,br={setTimeout:(e,t)=>globalThis.setTimeout(e,t),clearTimeout:e=>globalThis.clearTimeout(e)};function xr(e,t,n=br){if(!e)return()=>void 0;let r=n.setTimeout(()=>{t().catch(()=>void 0)},yr);return()=>n.clearTimeout(r)}var Sr=`opencode-update-available`,Cr=`opencode-upgrade-progress`,wr=`opencode-update-toast-dismissed-version`,Tr=()=>{let{t:e}=ee(),t=s(e=>e.showOpenCodeUpdateNotifications),n=Q.useRef(new Set),r=Q.useRef(!1);Q.useEffect(()=>{t||J.dismiss(Sr)},[t]);let a=Q.useCallback(()=>{J.dismiss(Cr),ae({message:e(`opencodeUpdate.toast.reload.message`),mode:`projects`,scopes:[`all`]}).catch(()=>void 0)},[e]),o=Q.useCallback(async()=>{if(!r.current){r.current=!0,J.dismiss(Sr),J.message(e(`opencodeUpdate.toast.upgrading.title`),{id:Cr,description:e(`opencodeUpdate.toast.upgrading.description`),duration:1/0,icon:(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})});try{let t=await f(`/api/opencode/upgrade`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),n=await t.json().catch(()=>null);if(!t.ok||n?.success===!1)throw Error(n?.error||t.statusText||e(`opencodeUpdate.toast.failed.description`));J.success(e(`opencodeUpdate.toast.updated.title`),{id:Cr,description:n?.version?e(`opencodeUpdate.toast.updated.descriptionWithVersion`,{version:n.version}):e(`opencodeUpdate.toast.updated.description`),duration:1/0,icon:(0,$.jsx)(X,{name:`check`,className:`h-4 w-4 text-[var(--status-success)]`}),action:{label:e(`opencodeUpdate.toast.actions.reload`),onClick:a}})}catch(t){J.error(e(`opencodeUpdate.toast.failed.title`),{id:Cr,description:t instanceof Error?t.message:e(`opencodeUpdate.toast.failed.description`),duration:1/0})}finally{r.current=!1}}},[a,e]);return Q.useEffect(()=>{let r=t=>{if(!s.getState().showOpenCodeUpdateNotifications){J.dismiss(Sr);return}gr({version:t,dismissedVersion:i().getItem(wr),seenVersions:n.current})&&(n.current.add(t),J.info(e(`opencodeUpdate.toast.available.title`),{id:Sr,description:e(`opencodeUpdate.toast.available.description`,{version:t}),duration:1/0,action:{label:e(`opencodeUpdate.toast.actions.update`),onClick:o},cancel:{label:e(`opencodeUpdate.toast.actions.dismiss`),onClick:()=>{i().setItem(wr,t),h({openCodeUpdateToastDismissedVersion:t}),J.dismiss(Sr)}}}))},a=e=>{let t=_r(e.detail);r(t)},c=!1,l=xr(t,async()=>{try{let e=await f(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`}});if(!e.ok)throw Error(e.statusText||`OpenCode upgrade status check failed`);let t=vr(await e.json().catch(()=>null));!c&&t&&r(t)}catch{}});return window.addEventListener(`openchamber:opencode-update-available`,a),()=>{c=!0,l(),window.removeEventListener(`openchamber:opencode-update-available`,a)}},[o,t,e]),null},Er=()=>{let e=(0,Qn.c)(3),[t,n]=Q.useState(Dr),{isUpdating:r}=t,i,a;if(e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>fe(n),a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),Q.useEffect(i,a),!r)return null;let o;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center bg-background/90`,children:(0,$.jsx)(St,{width:80,height:80,isAnimated:!0})}),e[2]=o):o=e[2],o};function Dr(){return me()}var Or=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?(0,$.jsx)(`div`,{className:`flex items-center justify-center min-h-screen p-4`,children:(0,$.jsxs)(pt,{className:`w-full max-w-md`,children:[(0,$.jsx)(dt,{className:`text-center`,children:(0,$.jsxs)(ut,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,$.jsx)(X,{name:`chat-3`,className:`h-5 w-5`}),this.props.texts.title]})}),(0,$.jsxs)(ft,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:this.props.texts.description}),this.props.sessionId&&(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center`,children:[this.props.texts.sessionLabel,`: `,this.props.sessionId]}),this.state.error&&(0,$.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:this.props.texts.detailsSummary}),(0,$.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto`,children:this.state.error.toString()})]}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:(0,$.jsxs)(Z,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,$.jsx)(X,{name:`restart`,className:`h-4 w-4 mr-2`}),this.props.texts.resetAction]})}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground text-center`,children:this.props.texts.persistentHint})]})]})}):this.props.children}};function kr(e){let t=(0,Qn.c)(22),{t:n}=ee(),r;t[0]===n?r=t[1]:(r=n(`chat.errorBoundary.title`),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=n(`chat.errorBoundary.description`),t[2]=n,t[3]=i);let a;t[4]===n?a=t[5]:(a=n(`chat.errorBoundary.sessionLabel`),t[4]=n,t[5]=a);let o;t[6]===n?o=t[7]:(o=n(`chat.errorBoundary.detailsSummary`),t[6]=n,t[7]=o);let s;t[8]===n?s=t[9]:(s=n(`chat.errorBoundary.resetAction`),t[8]=n,t[9]=s);let c;t[10]===n?c=t[11]:(c=n(`chat.errorBoundary.persistentHint`),t[10]=n,t[11]=c);let l;t[12]!==r||t[13]!==i||t[14]!==a||t[15]!==o||t[16]!==s||t[17]!==c?(l={title:r,description:i,sessionLabel:a,detailsSummary:o,resetAction:s,persistentHint:c},t[12]=r,t[13]=i,t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l):l=t[18];let u;return t[19]!==e||t[20]!==l?(u=(0,$.jsx)(Or,{...e,texts:l}),t[19]=e,t[20]=l,t[21]=u):u=t[21],u}var Ar=e=>{let t=(0,Qn.c)(10),{readOnly:n,active:r,selectionOverride:i}=e,a=n!==void 0&&n,o=r===void 0||r,s=K(jr),c=(i?.sessionId??s)||void 0,l;t[0]!==o||t[1]!==i?(l=i?{...i,active:o}:void 0,t[0]=o,t[1]=i,t[2]=l):l=t[2];let u;t[3]!==o||t[4]!==a||t[5]!==l?(u=(0,$.jsx)(Bt,{readOnly:a,active:o,explicitSession:l}),t[3]=o,t[4]=a,t[5]=l,t[6]=u):u=t[6];let d;return t[7]!==c||t[8]!==u?(d=(0,$.jsx)(kr,{sessionId:c,children:u}),t[7]=c,t[8]=u,t[9]=d):d=t[9],d};function jr(e){return e.currentSessionId}function Mr(e){let t=(0,Qn.c)(85),{draft:n,onEdit:r,onDelete:i,className:a,maxWidth:o}=e,{t:s}=ee(),c=ht()?.currentTheme,[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),p=typeof n.text==`string`?n.text:``,m;t[0]===p?m=t[1]:(m=p.length>150||p.split(`
|
|
2
|
+
`).length>3,t[0]=p,t[1]=m);let h=m,g;t[2]===a?g=t[3]:(g=Y(`rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden transition-all duration-200`,a),t[2]=a,t[3]=g);let _=c?.colors?.surface?.elevated,v=c?.colors?.interactive?.border,y=o?`${Math.max(200,Math.floor(o))}px`:void 0,b;t[4]!==_||t[5]!==v||t[6]!==y?(b={backgroundColor:_,borderColor:v,maxWidth:y},t[4]=_,t[5]=v,t[6]=y,t[7]=b):b=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e.preventDefault(),f(!0)},t[8]=x):x=t[8];let S;t[9]!==g||t[10]!==b?(S=(0,$.jsx)(`div`,{className:g,style:b,"data-comment-card":`true`,onContextMenu:x}),t[9]=g,t[10]=b,t[11]=S):S=t[11];let C;t[12]===n.fileLabel?C=t[13]:(C=(0,$.jsx)(`span`,{className:`truncate max-w-[200px]`,title:n.fileLabel,children:n.fileLabel}),t[12]=n.fileLabel,t[13]=C);let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`span`,{children:`•`}),t[14]=w):w=t[14];let T;t[15]!==n.endLine||t[16]!==n.startLine||t[17]!==s?(T=s(`inlineComment.range.lines`,{start:n.startLine,end:n.endLine}),t[15]=n.endLine,t[16]=n.startLine,t[17]=s,t[18]=T):T=t[18];let E;t[19]===T?E=t[20]:(E=(0,$.jsx)(`span`,{children:T}),t[19]=T,t[20]=E);let D;t[21]===n.side?D=t[22]:(D=n.side&&(0,$.jsxs)(`span`,{children:[`(`,n.side,`)`]}),t[21]=n.side,t[22]=D);let O;t[23]!==E||t[24]!==D||t[25]!==C?(O=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground mb-1.5`,children:[C,w,E,D]}),t[23]=E,t[24]=D,t[25]=C,t[26]=O):O=t[26];let k=l||!h,A=!l&&h&&`line-clamp-3`,j;t[27]===A?j=t[28]:(j=Y(`text-sm whitespace-pre-wrap break-words leading-relaxed`,A),t[27]=A,t[28]=j);let M;t[29]!==p||t[30]!==j?(M=(0,$.jsx)(`div`,{className:j,children:p}),t[29]=p,t[30]=j,t[31]=M):M=t[31];let N;t[32]!==h||t[33]!==l||t[34]!==s?(N=h&&(0,$.jsx)(Yn,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-6 px-0 mt-1 text-xs text-muted-foreground hover:text-foreground w-full justify-start`,children:l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`arrow-up-s`,className:`size-3 mr-1`}),s(`inlineComment.actions.showLess`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-3 mr-1`}),s(`inlineComment.actions.showMore`)]})})}),t[32]=h,t[33]=l,t[34]=s,t[35]=N):N=t[35];let P;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(Jn,{}),t[36]=P):P=t[36];let F;t[37]!==k||t[38]!==M||t[39]!==N?(F=(0,$.jsxs)(Xn,{open:k,onOpenChange:u,children:[M,N,P]}),t[37]=k,t[38]=M,t[39]=N,t[40]=F):F=t[40];let I;t[41]!==O||t[42]!==F?(I=(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[O,F]}),t[41]=O,t[42]=F,t[43]=I):I=t[43];let te;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(bt,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 -mr-1 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`more`,className:`size-4`})})}),t[44]=te):te=t[44];let ne;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(X,{name:`edit`,className:`size-4 mr-2`}),t[45]=ne):ne=t[45];let L;t[46]===s?L=t[47]:(L=s(`inlineComment.actions.editComment`),t[46]=s,t[47]=L);let R;t[48]!==r||t[49]!==L?(R=(0,$.jsxs)(xt,{onClick:r,children:[ne,L]}),t[48]=r,t[49]=L,t[50]=R):R=t[50];let z;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(X,{name:`delete-bin`,className:`size-4 mr-2`}),t[51]=z):z=t[51];let B;t[52]===s?B=t[53]:(B=s(`inlineComment.actions.deleteComment`),t[52]=s,t[53]=B);let V;t[54]!==i||t[55]!==B?(V=(0,$.jsxs)(xt,{onClick:i,className:`text-destructive`,children:[z,B]}),t[54]=i,t[55]=B,t[56]=V):V=t[56];let H;t[57]!==R||t[58]!==V?(H=(0,$.jsxs)(yt,{children:[te,(0,$.jsxs)(vt,{align:`end`,children:[R,V]})]}),t[57]=R,t[58]=V,t[59]=H):H=t[59];let U;t[60]!==I||t[61]!==H?(U=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 p-3`,children:[I,H]}),t[60]=I,t[61]=H,t[62]=U):U=t[62];let W;t[63]!==U||t[64]!==S?(W=(0,$.jsx)(Un,{render:S,children:U}),t[63]=U,t[64]=S,t[65]=W):W=t[65];let re;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(X,{name:`edit`,className:`size-4 mr-2`}),t[66]=re):re=t[66];let ie;t[67]===s?ie=t[68]:(ie=s(`inlineComment.actions.editComment`),t[67]=s,t[68]=ie);let G;t[69]!==r||t[70]!==ie?(G=(0,$.jsxs)(Kn,{onClick:r,children:[re,ie]}),t[69]=r,t[70]=ie,t[71]=G):G=t[71];let ae;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(X,{name:`delete-bin`,className:`size-4 mr-2`}),t[72]=ae):ae=t[72];let oe;t[73]===s?oe=t[74]:(oe=s(`inlineComment.actions.deleteComment`),t[73]=s,t[74]=oe);let se;t[75]!==i||t[76]!==oe?(se=(0,$.jsxs)(Kn,{onClick:i,className:`text-destructive focus:text-destructive`,children:[ae,oe]}),t[75]=i,t[76]=oe,t[77]=se):se=t[77];let ce;t[78]!==G||t[79]!==se?(ce=(0,$.jsxs)(Gn,{children:[G,se]}),t[78]=G,t[79]=se,t[80]=ce):ce=t[80];let K;return t[81]!==d||t[82]!==W||t[83]!==ce?(K=(0,$.jsxs)(qn,{open:d,onOpenChange:f,children:[W,ce]}),t[81]=d,t[82]=W,t[83]=ce,t[84]=K):K=t[84],K}function Nr(e){let t=(0,Qn.c)(67),{initialText:n,onTextChange:r,onSave:i,onCancel:a,fileLabel:o,lineRange:s,isEditing:c,className:l,maxWidth:u,onAddToChat:d}=e,f=n===void 0?``:n,p=c!==void 0&&c,{t:m}=ee(),h=ht()?.currentTheme,{isMobile:g}=jt(),[_,v]=Q.useState(f),y=(0,Q.useRef)(null),b;t[0]===r?b=t[1]:(b=e=>{v(e),r?.(e)},t[0]=r,t[1]=b);let x=b,S=(0,Q.useRef)(s),C,w;t[2]===s?(C=t[3],w=t[4]):(C=()=>{s&&(S.current=s)},w=[s],t[2]=s,t[3]=C,t[4]=w),(0,Q.useEffect)(C,w);let T=Vr,E=T(s),D,O;t[5]===g?(D=t[6],O=t[7]):(D=()=>{let e=y.current;if(!e)return;let t=e.closest(`.overlay-scrollbar-container`),n=t?.scrollTop??window.scrollY,r=t?.scrollLeft??window.scrollX;if(g){e.scrollIntoView({behavior:`auto`,block:`nearest`});try{e.focus({preventScroll:!0})}catch{e.focus()}return}try{e.focus({preventScroll:!0})}catch{e.focus()}let i=e.value.length;try{e.setSelectionRange(i,i)}catch{}requestAnimationFrame(()=>{t?(t.scrollTop=n,t.scrollLeft=r):window.scrollTo({top:n,left:r})})},O=[g],t[5]=g,t[6]=D,t[7]=O),(0,Q.useEffect)(D,O);let k;t[8]!==a||t[9]!==i||t[10]!==_?(k=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`?(e.preventDefault(),_.trim()&&i(_,T(S.current))):e.key===`Escape`&&(e.preventDefault(),a())},t[8]=a,t[9]=i,t[10]=_,t[11]=k):k=t[11];let A=k,j;t[12]!==i||t[13]!==_?(j=e=>{e.stopPropagation(),_.trim()&&i(_,T(S.current))},t[12]=i,t[13]=_,t[14]=j):j=t[14];let M=j,N;t[15]===l?N=t[16]:(N=Y(`rounded-lg border shadow-none w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden animate-in fade-in zoom-in-95 duration-200`,l),t[15]=l,t[16]=N);let P=h?.colors?.surface?.elevated,F=h?.colors?.interactive?.border,I=u?`${Math.max(200,Math.floor(u))}px`:void 0,te;t[17]!==P||t[18]!==F||t[19]!==I?(te={backgroundColor:P,borderColor:F,maxWidth:I},t[17]=P,t[18]=F,t[19]=I,t[20]=te):te=t[20];let ne=Br,L=zr,R=(o||s)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground mb-2`,children:[o&&(0,$.jsx)(`span`,{className:`truncate max-w-[200px]`,children:o}),o&&s&&(0,$.jsx)(`span`,{children:`•`}),E&&(0,$.jsx)(`span`,{children:m(`inlineComment.range.lines`,{start:E.start,end:E.end})})]}),z;t[21]===x?z=t[22]:(z=e=>x(e.target.value),t[21]=x,t[22]=z);let B;t[23]!==g||t[24]!==m?(B=m(g?`inlineComment.input.placeholderShort`:`inlineComment.input.placeholder`),t[23]=g,t[24]=m,t[25]=B):B=t[25];let V;t[26]!==A||t[27]!==z||t[28]!==B||t[29]!==_?(V=(0,$.jsx)($e,{simple:!0,ref:y,value:_,onChange:z,onKeyDown:A,placeholder:B,outerClassName:`rounded-[var(--radius-xl)] bg-[var(--surface-subtle)] ring-1 ring-inset ring-border/60 focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,className:`min-h-[80px] px-3 py-2.5 text-sm resize-y`}),t[26]=A,t[27]=z,t[28]=B,t[29]=_,t[30]=V):V=t[30];let H;t[31]!==E||t[32]!==d||t[33]!==m?(H=E&&d?(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:()=>d(E),onPointerDown:Rr,className:`mr-auto h-8 gap-1.5`,children:[(0,$.jsx)(X,{name:`add`,className:`size-4`}),m(`chat.textSelection.actions.addToChat`),(0,$.jsx)(Lt,{shortcut:`⌘+I`})]}):null,t[31]=E,t[32]=d,t[33]=m,t[34]=H):H=t[34];let U;t[35]===m?U=t[36]:(U=m(`inlineComment.actions.cancel`),t[35]=m,t[36]=U);let W;t[37]!==a||t[38]!==U?(W=(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:a,onPointerDown:Lr,onTouchStart:Ir,className:`h-8 text-muted-foreground hover:text-foreground`,children:U}),t[37]=a,t[38]=U,t[39]=W):W=t[39];let re;t[40]===_?re=t[41]:(re=_.trim(),t[40]=_,t[41]=re);let ie=!re,G=h?.colors?.status?.success,ae=h?.colors?.status?.successForeground,oe;t[42]!==G||t[43]!==ae?(oe={backgroundColor:G,color:ae},t[42]=G,t[43]=ae,t[44]=oe):oe=t[44];let se;t[45]!==p||t[46]!==m?(se=m(p?`inlineComment.actions.save`:`inlineComment.actions.comment`),t[45]=p,t[46]=m,t[47]=se):se=t[47];let ce;t[48]!==M||t[49]!==ie||t[50]!==oe||t[51]!==se?(ce=(0,$.jsx)(Z,{size:`sm`,onClick:M,onPointerDown:Fr,onTouchStart:Pr,disabled:ie,className:`h-8 min-w-[80px]`,style:oe,children:se}),t[48]=M,t[49]=ie,t[50]=oe,t[51]=se,t[52]=ce):ce=t[52];let K;t[53]!==H||t[54]!==W||t[55]!==ce?(K=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 mt-3`,children:[H,W,ce]}),t[53]=H,t[54]=W,t[55]=ce,t[56]=K):K=t[56];let le;t[57]!==R||t[58]!==V||t[59]!==K?(le=(0,$.jsxs)(`div`,{className:`p-3`,children:[R,V,K]}),t[57]=R,t[58]=V,t[59]=K,t[60]=le):le=t[60];let q;return t[61]!==N||t[62]!==te||t[63]!==ne||t[64]!==L||t[65]!==le?(q=(0,$.jsx)(`div`,{className:N,style:te,"data-comment-input":`true`,onPointerDown:ne,onTouchStart:L,children:le}),t[61]=N,t[62]=te,t[63]=ne,t[64]=L,t[65]=le,t[66]=q):q=t[66],q}function Pr(e){return e.stopPropagation()}function Fr(e){return e.stopPropagation()}function Ir(e){return e.stopPropagation()}function Lr(e){return e.stopPropagation()}function Rr(e){return e.stopPropagation()}function zr(e){return e.stopPropagation()}function Br(e){return e.stopPropagation()}function Vr(e){if(!e)return;let t=Math.min(e.start,e.end),n=Math.max(e.start,e.end);return{...e,start:t,end:n}}var Hr=e=>{let t=Math.min(e.startLine,e.endLine),n=Math.max(e.startLine,e.endLine);return{...e,startLine:t,endLine:n}},Ur=e=>{let t=Math.min(e.start,e.end),n=Math.max(e.start,e.end);return{...e,start:t,end:n}};function Wr(e){let t=(0,Qn.c)(40),{t:n}=ee(),{source:r,fileLabel:i,language:a,getCodeForRange:o,toStoreRange:s,fromDraftRange:c}=e,l=K(Xr),u=K(Yr),d=Ft(Jr),f=Ft(qr),p=Ft(Kr),m=Ft(Gr),[h,g]=Q.useState(null),[_,v]=Q.useState(``),[y,b]=Q.useState(null),x=l??(u?`draft`:null),S;bb0:{if(!x||!i){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],S=e;break bb0}let e;t[1]!==m||t[2]!==x?(e=m[x]??[],t[1]=m,t[2]=x,t[3]=e):e=t[3];let n=e,a;if(t[4]!==i||t[5]!==n||t[6]!==r){let e;t[8]!==i||t[9]!==r?(e=e=>e.source===r&&e.fileLabel===i,t[8]=i,t[9]=r,t[10]=e):e=t[10],a=n.filter(e),t[4]=i,t[5]=n,t[6]=r,t[7]=a}else a=t[7];S=a}let C=S,w;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{g(null),v(``),b(null)},t[11]=w):w=t[11];let T=w,E;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{T()},t[12]=E):E=t[12];let D=E,O;t[13]===c?O=t[14]:(O=e=>{let t=Ur(c(e));g(t),v(e.text),b(e.id)},t[13]=c,t[14]=O);let k=O,A;t[15]!==y||t[16]!==p?(A=e=>{p(e.sessionKey,e.id),y===e.id&&T()},t[15]=y,t[16]=p,t[17]=A):A=t[17];let j=A,M;t[18]!==d||t[19]!==y||t[20]!==i||t[21]!==o||t[22]!==a||t[23]!==h||t[24]!==x||t[25]!==r||t[26]!==n||t[27]!==s||t[28]!==f?(M=(e,t)=>{let c=t??h,l=e.trim();if(!c||!l||!i)return;if(!x){J.error(n(`inlineComment.toast.selectSessionToSave`));return}let u=Ur(c),p=Hr(s(u)),m=o(u);y?f(x,y,{fileLabel:i,startLine:p.startLine,endLine:p.endLine,side:p.side,code:m,language:a,text:l}):d({sessionKey:x,source:r,fileLabel:i,startLine:p.startLine,endLine:p.endLine,side:p.side,code:m,language:a,text:l}),T()},t[18]=d,t[19]=y,t[20]=i,t[21]=o,t[22]=a,t[23]=h,t[24]=x,t[25]=r,t[26]=n,t[27]=s,t[28]=f,t[29]=M):M=t[29];let N=M,P;return t[30]!==_||t[31]!==j||t[32]!==C||t[33]!==y||t[34]!==c||t[35]!==N||t[36]!==h||t[37]!==x||t[38]!==k?(P={sessionKey:x,drafts:C,selection:h,setSelection:g,commentText:_,setCommentText:v,editingDraftId:y,setEditingDraftId:b,reset:T,cancel:D,startEdit:k,deleteDraft:j,saveComment:N,fromDraftRange:c},t[30]=_,t[31]=j,t[32]=C,t[33]=y,t[34]=c,t[35]=N,t[36]=h,t[37]=x,t[38]=k,t[39]=P):P=t[39],P}function Gr(e){return e.drafts}function Kr(e){return e.removeDraft}function qr(e){return e.updateDraft}function Jr(e){return e.addDraft}function Yr(e){return e.newSessionDraft?.open}function Xr(e){return e.currentSessionId}function Zr(e){let{drafts:t,editingDraftId:n,commentText:r,onTextChange:i,selection:a,isDragging:o,fileLabel:s,newWidgetId:c,mapDraftToRange:l,onSave:u,onCancel:d,onEdit:f,onDelete:p,onAddToChat:m}=e,h=[];for(let e of t){let t=l(e);if(e.id===n){h.push({afterLine:t.end,id:`edit-${e.id}`,content:(0,$.jsx)(Nr,{initialText:r,onTextChange:i,fileLabel:s,lineRange:t,isEditing:!0,onSave:u,onCancel:d,onAddToChat:m},`edit-${e.id}`)});continue}h.push({afterLine:t.end,id:`card-${e.id}`,content:(0,$.jsx)(Mr,{draft:e,onEdit:()=>f(e),onDelete:()=>p(e)},`card-${e.id}`)})}if(a&&!n&&!o){let e={...a,start:Math.min(a.start,a.end),end:Math.max(a.start,a.end)};h.push({afterLine:e.end,id:c,content:(0,$.jsx)(Nr,{initialText:r,onTextChange:i,fileLabel:s,lineRange:e,isEditing:!1,onSave:u,onCancel:d,onAddToChat:m},c)})}return h}var Qr=e=>{if(e.type===`new`){let t=Math.min(e.selection.start,e.selection.end),n=Math.max(e.selection.start,e.selection.end);return`new-comment-${e.selection.side??`additions`}-${t}-${n}`}return`draft-${e.draft.id}`},$r=e=>{let{drafts:t,editingDraftId:n,selection:r}=e,i=[];for(let e of t){if(!Number.isFinite(e.endLine))continue;let t=Math.max(1,Math.floor(e.endLine)),r=e.side===`original`?`deletions`:`additions`;i.push({lineNumber:t,side:r,metadata:{type:e.id===n?`edit`:`saved`,draft:e}})}return r&&!n&&i.push({lineNumber:Math.max(r.start,r.end),side:r.side??`additions`,metadata:{type:`new`,selection:r}}),i};function ei(e){let t=e.trim();if(!t)return null;if(/^-?\d+(\.\d+)?$/.test(t)){let e=Number.parseFloat(t);return Number.isFinite(e)?e:null}if(t.endsWith(`px`)){let e=Number.parseFloat(t.slice(0,-2));return Number.isFinite(e)?e:null}return null}function ti(e){if(!(!e||e<=0))return Math.max(200,Math.floor(e))}function ni(e){let{diffRootRef:t,drafts:n,selection:r,editingDraftId:i,commentText:a,onTextChange:o,fileLabel:s,onSave:c,onCancel:l,onEdit:u,onDelete:d,onAddToChat:f}=e,[p,m]=Q.useState(0),[h,g]=Q.useState(null),_=Q.useMemo(()=>!r||i?null:Qr({type:`new`,selection:r}),[i,r]),v=Q.useMemo(()=>{let e=n.map(e=>Qr({type:e.id===i?`edit`:`saved`,draft:e}));return _&&e.push(_),e},[n,i,_]),y=Q.useCallback(e=>{let n=t.current;if(!n)return null;let r=n.querySelector(`diffs-container`);if(!(r instanceof HTMLElement))return null;let i=r.querySelector(`[data-annotation-id="${e}"]`);if(i instanceof HTMLElement)return i;let a=r.shadowRoot;return a?a.querySelector(`[data-annotation-id="${e}"]`):null},[t]);Q.useEffect(()=>{if(v.length===0)return;let e=!1,t=0,n=()=>{e||v.every(e=>!!y(e))||t>=12||(t+=1,requestAnimationFrame(()=>{e||(m(e=>e+1),n())}))};return n(),()=>{e=!0}},[v,y]),Q.useEffect(()=>{let e=t.current;if(!e)return;let n=()=>{let t=ei(getComputedStyle(e).getPropertyValue(`--oc-context-panel-width`)),n=e.getBoundingClientRect(),r=t??n.width;g(r>0?r:null)};n();let r=new ResizeObserver(()=>{n()});return r.observe(e),window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n)}},[t]);let b=Q.useCallback(e=>{let n=t.current?.getBoundingClientRect(),r=e.closest(`[data-annotation-content]`),i=r instanceof HTMLElement?r.getBoundingClientRect():e.getBoundingClientRect(),a=[i.width];n&&a.push(n.right-i.left);let o=a.filter(e=>Number.isFinite(e)&&e>0);return o.length>0?ti(Math.min(...o)):ti(h)},[t,h]);return(0,$.jsxs)($.Fragment,{children:[n.map(e=>{let t=Qr({type:e.id===i?`edit`:`saved`,draft:e}),n=y(t);if(!n)return null;let r=b(n);return e.id===i?(0,$n.createPortal)((0,$.jsx)(Nr,{initialText:a,onTextChange:o,fileLabel:s,lineRange:{start:e.startLine,end:e.endLine,side:e.side===`original`?`deletions`:`additions`},isEditing:!0,onSave:c,onCancel:l,onAddToChat:f,maxWidth:r}),n,`draft-edit-${e.id}`):(0,$n.createPortal)((0,$.jsx)(Mr,{draft:e,onEdit:()=>u(e),onDelete:()=>d(e),maxWidth:r}),n,`draft-card-${e.id}`)}),r&&!i&&_&&(()=>{let e=y(_);if(!e)return null;let t=b(e);return(0,$n.createPortal)((0,$.jsx)(Nr,{initialText:a,onTextChange:o,fileLabel:s,lineRange:r,isEditing:!1,onSave:c,onCancel:l,onAddToChat:f,maxWidth:t}),e,_)})()]})}function ri(e){let t=(0,Qn.c)(13),{position:n,onAddToChat:r}=e,{t:i}=ee(),a;t[0]!==n.x||t[1]!==n.y?(a={left:n.x,top:n.y},t[0]=n.x,t[1]=n.y,t[2]=a):a=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(X,{name:`add`,className:`size-4`}),t[3]=o):o=t[3];let s;t[4]===i?s=t[5]:(s=i(`chat.textSelection.actions.addToChat`),t[4]=i,t[5]=s);let c;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(Lt,{shortcut:`⌘+I`}),t[6]=c):c=t[6];let l;t[7]!==r||t[8]!==s?(l=(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2`,onClick:r,children:[o,s,c]}),t[7]=r,t[8]=s,t[9]=l):l=t[9];let u;return t[10]!==a||t[11]!==l?(u=(0,$n.createPortal)((0,$.jsx)(`div`,{"data-code-selection-action":`true`,className:`fixed z-[100] -translate-y-full rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-lg`,style:a,onPointerDown:ii,children:l}),document.body),t[10]=a,t[11]=l,t[12]=u):u=t[12],u}function ii(e){return e.preventDefault()}var ai=5e5,oi=`
|
|
3
|
+
:host {
|
|
4
|
+
font-family: var(--font-mono);
|
|
5
|
+
font-size: var(--text-code);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
pre, [data-code] {
|
|
9
|
+
font-family: var(--font-mono);
|
|
10
|
+
font-size: var(--text-code);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* Mobile touch selection support */
|
|
14
|
+
[data-line-number] {
|
|
15
|
+
touch-action: manipulation;
|
|
16
|
+
-webkit-tap-highlight-color: transparent;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Ensure interactive line numbers work on touch */
|
|
21
|
+
pre[data-interactive-line-numbers] [data-line-number] {
|
|
22
|
+
touch-action: manipulation;
|
|
23
|
+
}
|
|
24
|
+
`,si=`
|
|
25
|
+
${oi}
|
|
26
|
+
|
|
27
|
+
:host {
|
|
28
|
+
--diffs-bg-separator-override: var(--surface-elevated);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[data-diff-header],
|
|
32
|
+
[data-diff] {
|
|
33
|
+
[data-separator] {
|
|
34
|
+
height: 24px !important;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[data-separator="line-info-basic"] {
|
|
39
|
+
height: 24px !important;
|
|
40
|
+
background: var(--diffs-bg) !important;
|
|
41
|
+
position: relative;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[data-diff-type="single"] [data-gutter],
|
|
45
|
+
[data-diff-type="split"] [data-deletions] [data-gutter] {
|
|
46
|
+
[data-separator-wrapper] {
|
|
47
|
+
position: absolute;
|
|
48
|
+
left: 100%;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
gap: unset;
|
|
52
|
+
width: max-content;
|
|
53
|
+
background: transparent;
|
|
54
|
+
color: var(--diffs-fg-number);
|
|
55
|
+
font-family: var(--diffs-header-font-family, var(--font-sans));
|
|
56
|
+
font-size: 0.75rem;
|
|
57
|
+
line-height: 1;
|
|
58
|
+
margin-left: calc(-2ch - 2px);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[data-separator-wrapper][data-separator-multi-button] {
|
|
62
|
+
margin-left: calc(-3ch - 2px);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
[data-expand-button],
|
|
66
|
+
[data-separator-content] {
|
|
67
|
+
display: block;
|
|
68
|
+
align-self: unset;
|
|
69
|
+
min-width: unset;
|
|
70
|
+
min-height: unset;
|
|
71
|
+
padding: 0;
|
|
72
|
+
flex-shrink: 0;
|
|
73
|
+
grid-column: unset;
|
|
74
|
+
border: none;
|
|
75
|
+
width: auto;
|
|
76
|
+
height: auto;
|
|
77
|
+
background-color: transparent;
|
|
78
|
+
color: inherit;
|
|
79
|
+
font: inherit;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
[data-expand-button]:not([data-expand-all-button]) {
|
|
83
|
+
&[data-expand-down]::before {
|
|
84
|
+
content: '\\2191';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&[data-expand-up]::before {
|
|
88
|
+
content: '\\2193';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&[data-expand-both]::before {
|
|
92
|
+
content: '\\2195';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
svg {
|
|
96
|
+
display: none;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
[data-separator-content] {
|
|
101
|
+
background: transparent;
|
|
102
|
+
margin-left: calc(2px + 1ch);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
[data-expand-all-button] {
|
|
106
|
+
position: relative;
|
|
107
|
+
margin-left: 14px;
|
|
108
|
+
text-transform: lowercase;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
[data-expand-all-button]::before {
|
|
112
|
+
content: '';
|
|
113
|
+
display: block;
|
|
114
|
+
position: absolute;
|
|
115
|
+
top: 50%;
|
|
116
|
+
left: -8px;
|
|
117
|
+
margin-top: -1px;
|
|
118
|
+
width: 3px;
|
|
119
|
+
height: 3px;
|
|
120
|
+
border-radius: 2px;
|
|
121
|
+
background-color: var(--diffs-fg-number);
|
|
122
|
+
pointer-events: none;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
[data-separator-content]:hover,
|
|
126
|
+
[data-expand-button]:hover,
|
|
127
|
+
[data-expand-all-button]:hover {
|
|
128
|
+
color: var(--diffs-fg);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
[data-expand-all-button]:hover {
|
|
132
|
+
text-decoration: underline;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`;function ci(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t.toString(16)}function li(e){let t=e.length>400?`${e.slice(0,200)}${e.slice(-200)}`:e;return`${e.length}:${ci(t)}`}var ui=(e,t,n,r)=>{let i=r.side===`deletions`,a=(n?(i?n.deletionLines:n.additionLines).join(``):i?e:t).split(`
|
|
136
|
+
`),o=Math.min(r.start,r.end),s=Math.max(r.start,r.end),c=Math.max(1,o),l=Math.min(a.length,s);return c>l?``:a.slice(c-1,l).join(`
|
|
137
|
+
`)},di=(e,t)=>e===t?!0:!e||!t?!1:e.start===t.start&&e.end===t.end&&e.side===t.side,fi=e=>e===`auto`||e===`scroll`||e===`overlay`,pi=e=>{let t=e?.parentElement??null;for(;t;){if(fi(window.getComputedStyle(t).overflowY))return t;t=t.parentElement}return null},mi=(e,t)=>{if(!e||!t||typeof window>`u`)return()=>{};let n=pi(e);if(!n)return()=>{};let r=t.getBoundingClientRect().height;if(!r)return()=>{};let i=e.getBoundingClientRect().top-n.getBoundingClientRect().top,a=t.style.minHeight;t.style.minHeight=`${Math.ceil(r)}px`;let o=!1;return()=>{if(o)return;o=!0,t.style.minHeight=a;let r=e.getBoundingClientRect().top-n.getBoundingClientRect().top-i;r&&(n.scrollTop+=r)}},hi=(e,t)=>{if(typeof window>`u`)return()=>{};let n=null,r=null,i=!1,a=()=>{i||(r?.disconnect(),r=null,n=window.requestAnimationFrame(()=>{n=window.requestAnimationFrame(()=>{i||t()})}))},o=()=>e.querySelector(`diffs-container`)?.shadowRoot??void 0,s=(e=o())=>!!e?.querySelector(`[data-line]`);return s()?a():typeof MutationObserver<`u`?(r=new MutationObserver(()=>{let e=o();if(e){if(s(e)){a();return}r?.disconnect(),r=new MutationObserver(()=>{s(e)&&a()}),r.observe(e,{childList:!0,subtree:!0})}}),r.observe(e,{childList:!0,subtree:!0})):n=window.requestAnimationFrame(a),()=>{i=!0,r?.disconnect(),n!==null&&window.cancelAnimationFrame(n)}},gi=new WeakMap,_i={lineHeight:24,hunkSeparatorHeight:24,spacing:0};function vi(e){let t=e.closest(`[data-diff-virtual-root]`);if(t instanceof HTMLElement){let e=t.querySelector(`[data-diff-virtual-content]`);return{key:t,root:t,content:e instanceof HTMLElement?e:void 0}}return{key:document,root:document,content:void 0}}function yi(e){if(typeof document>`u`)return null;let t=vi(e),n=gi.get(t.key);if(!n){let e=new Tn;e.setup(t.root,t.content),n={virtualizer:e,refs:0},gi.set(t.key,n)}n.refs+=1;let r=!1;return{virtualizer:n.virtualizer,root:t.root,release:()=>{if(r)return;r=!0;let e=gi.get(t.key);e&&(--e.refs,!(e.refs>0)&&(e.virtualizer.cleanUp(),gi.delete(t.key)))}}}var bi=(e,t,n)=>{if(typeof window>`u`)return()=>{};let r=[],i=()=>{try{e.rerender()}catch{}let r=t?.root;r instanceof HTMLElement?r.dispatchEvent(new Event(`scroll`,{bubbles:!1})):document.dispatchEvent(new Event(`scroll`,{bubbles:!1})),window.dispatchEvent(new Event(`resize`)),n()};return r.push(window.requestAnimationFrame(i)),r.push(window.requestAnimationFrame(()=>{r.push(window.requestAnimationFrame(i))})),()=>{for(let e of r)window.cancelAnimationFrame(e)}},xi=({original:e,modified:t,fileDiff:n,language:r,fileName:i,renderSideBySide:a,wrapLines:o,layout:c=`fill`,enableComments:l=!0,enableSelectionActions:u=!0,focusLine:d=null})=>{let f=ht(),p=f?.currentTheme.metadata.variant===`dark`,m=f?.availableThemes.find(e=>e.metadata.id===f.lightThemeId)??Pt(!1),h=f?.availableThemes.find(e=>e.metadata.id===f.darkThemeId)??Pt(!0),{isMobile:_}=jt(),v=B(e=>e.addCodeSelectionAttachment),y=B(e=>e.setPendingInputText),[b,x]=Q.useState(null),{drafts:S,selection:C,setSelection:w,commentText:T,setCommentText:E,editingDraftId:D,saveComment:O,cancel:k,startEdit:A,deleteDraft:j}=Wr({source:`diff`,fileLabel:i||`unknown`,language:r,getCodeForRange:r=>ui(e,t,n,r),toStoreRange:e=>({startLine:e.start,endLine:e.end,side:e.side===`deletions`?`original`:`modified`}),fromDraftRange:e=>({start:e.startLine,end:e.endLine,side:e.side===`original`?`deletions`:`additions`})}),M=(0,Q.useRef)(null),N=(0,Q.useRef)(null),ee=(0,Q.useRef)(``),P=(0,Q.useRef)(!1),F=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{M.current=C},[C]),(0,Q.useEffect)(()=>{N.current=D},[D]),(0,Q.useEffect)(()=>{ee.current=T},[T]);let I=(0,Q.useCallback)(e=>{if(!l||P.current)return;let t=M.current;if(!(!e&&t&&ee.current.trim())){if(_&&t&&e&&e.side===t.side){let n=Math.min(t.start,e.start),r=Math.max(t.end,e.end);w({...e,start:n,end:r})}else w(e);e&&(N.current||E(``))}},[l,_,E,w]),te=(0,Q.useCallback)(()=>{k()},[k]),ne=(0,Q.useCallback)(e=>{let t=document.createElement(`div`);t.style.position=`relative`;let n=Qr(e.metadata);return t.dataset.annotationId=n,t.dataset.annotationSide=e.side,t.dataset.annotationLine=String(e.lineNumber),t},[]),L=(0,Q.useCallback)((e,t)=>{O(e,t??C??void 0)},[O,C]),R=(0,Q.useCallback)(r=>{if(!i)return;let a=Math.min(r.start,r.end),o=Math.max(r.start,r.end),c=a===o?`${a}`:`${a}-${o}`,l=ui(e,t,n,r);if(!l)return;let u=`${i.replace(/\\/g,`/`).split(`/`).pop()||i}:${c}`;v(i,u,l),y(g(u),`append-inline`),s.getState().setActiveMainTab(`chat`)},[v,n,i,t,e,y]);(0,Q.useEffect)(()=>{if(!u)return;let e=e=>{if(!e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.key.toLowerCase()!==`i`)return;let t=b?.range??M.current;t&&(e.preventDefault(),R(t))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u,R,b]),(0,Q.useEffect)(()=>{x(null)},[i,n,e,t]);let z=(0,Q.useCallback)(e=>{w(e);let t=ie.current;if(t)try{P.current=!0,t.setSelectedLines(e),F.current=e}catch{}finally{P.current=!1}},[w]),V=(0,Q.useCallback)(e=>{let t=e.closest(`[data-line-type]`)?.getAttribute(`data-line-type`)??e.getAttribute(`data-line-type`);if(t===`change-deletion`)return`deletions`;if(t===`change-addition`)return`additions`;let n=e.getAttribute(`data-column-side`)??e.getAttribute(`data-side`)??e.closest(`[data-column-side]`)?.getAttribute(`data-column-side`);if(n===`deletions`||n===`left`||n===`original`)return`deletions`;if(n===`additions`||n===`right`||n===`modified`)return`additions`;let r=e.closest(`[data-line-type]`);if(r instanceof HTMLElement){let t=r.getBoundingClientRect(),n=e.getBoundingClientRect(),i=t.left+t.width/2;return n.left+n.width/2<i?`deletions`:`additions`}return`additions`},[]);Kt(m),Kt(h);let H=`${m.metadata.id}:${h.metadata.id}:${p?`dark`:`light`}`,U=(0,Q.useMemo)(()=>{if(n){let e=n.deletionLines.reduce((e,t)=>e+t.length,0),t=n.additionLines.reduce((e,t)=>e+t.length,0);return Math.max(e,t)>ai}return Math.max(e.length,t.length)>ai},[n,t.length,e.length]),W=(0,Q.useRef)(null),re=(0,Q.useRef)(null),ie=(0,Q.useRef)(null),G=(0,Q.useRef)(null),ae=(0,Q.useRef)(null),oe=(0,Q.useRef)(null),se=(0,Q.useRef)(void 0),ce=(0,Q.useRef)(void 0),K=(0,Q.useRef)(void 0),le=(0,Q.useRef)(void 0),q=(0,Q.useRef)(null),[,ue]=Q.useReducer(e=>e+1,0),de=lr(U?`unified`:a?`split`:`unified`),fe=(0,Q.useMemo)(()=>Gt(m),[m]),pe=(0,Q.useMemo)(()=>Gt(h),[h]);Q.useLayoutEffect(()=>{let e=W.current;if(!e)return;let t=e.querySelector(`diffs-container`);if(!t)return;let n=p?pe:fe,r=(e,t)=>e.colors?.[t],i=r(fe,`terminal.ansiGreen`),a=r(fe,`terminal.ansiRed`),o=r(fe,`terminal.ansiBlue`),s=r(pe,`terminal.ansiGreen`),c=r(pe,`terminal.ansiRed`),l=r(pe,`terminal.ansiBlue`);t.style.setProperty(`--shiki-light`,fe.fg),t.style.setProperty(`--shiki-light-bg`,fe.bg),i&&t.style.setProperty(`--shiki-light-addition-color`,i),a&&t.style.setProperty(`--shiki-light-deletion-color`,a),o&&t.style.setProperty(`--shiki-light-modified-color`,o),t.style.setProperty(`--shiki-dark`,pe.fg),t.style.setProperty(`--shiki-dark-bg`,pe.bg),s&&t.style.setProperty(`--shiki-dark-addition-color`,s),c&&t.style.setProperty(`--shiki-dark-deletion-color`,c),l&&t.style.setProperty(`--shiki-dark-modified-color`,l),t.style.setProperty(`--diffs-bg`,n.bg),t.style.setProperty(`--diffs-fg`,n.fg);let u=p?s:i,d=p?c:a,f=p?l:o;u&&t.style.setProperty(`--diffs-addition-color-override`,u),d&&t.style.setProperty(`--diffs-deletion-color-override`,d),f&&t.style.setProperty(`--diffs-modified-color-override`,f);let m=t.shadowRoot?.querySelector(`pre`);m&&(m.style.setProperty(`--shiki-light`,fe.fg),m.style.setProperty(`--shiki-light-bg`,fe.bg),i&&m.style.setProperty(`--shiki-light-addition-color`,i),a&&m.style.setProperty(`--shiki-light-deletion-color`,a),o&&m.style.setProperty(`--shiki-light-modified-color`,o),m.style.setProperty(`--shiki-dark`,pe.fg),m.style.setProperty(`--shiki-dark-bg`,pe.bg),s&&m.style.setProperty(`--shiki-dark-addition-color`,s),c&&m.style.setProperty(`--shiki-dark-deletion-color`,c),l&&m.style.setProperty(`--shiki-dark-modified-color`,l),m.style.setProperty(`--diffs-bg`,n.bg),m.style.setProperty(`--diffs-fg`,n.fg),u&&m.style.setProperty(`--diffs-addition-color-override`,u),d&&m.style.setProperty(`--diffs-deletion-color-override`,d),f&&m.style.setProperty(`--diffs-modified-color-override`,f))},[pe,H,p,fe]);let me=(0,Q.useMemo)(()=>({theme:{dark:h.metadata.id,light:m.metadata.id},themeType:p?`dark`:`light`,diffStyle:a?`split`:`unified`,diffIndicators:`none`,hunkSeparators:`line-info-basic`,lineDiffType:`none`,maxLineDiffLength:U?0:1e3,maxLineLengthForHighlighting:U?1:1e3,tokenizeMaxLineLength:U?1:1e3,collapsedContextThreshold:0,expansionLineCount:20,overflow:o?`wrap`:`scroll`,disableFileHeader:!0,enableLineSelection:l,enableHoverUtility:!1,onLineSelected:l?I:void 0,unsafeCSS:si,renderAnnotation:l?ne:void 0}),[h.metadata.id,l,p,U,m.metadata.id,a,o,I,ne]),he=(0,Q.useMemo)(()=>l?$r({drafts:S,editingDraftId:D,selection:C}):[],[D,l,S,C]),ge=(0,Q.useRef)(he);if((0,Q.useEffect)(()=>{ge.current=he},[he]),(0,Q.useEffect)(()=>{let e=re.current;return()=>{ie.current?.cleanUp(),ie.current=null,G.current?.release(),G.current=null,ae.current=null,oe.current=null,se.current=void 0,ce.current=void 0,K.current=void 0,le.current=void 0,e&&(e.innerHTML=``)}},[]),(0,Q.useEffect)(()=>{if(typeof window>`u`)return;let a=re.current,o=W.current;if(!a||!de)return;let s=mi(o,a),c=G.current;c||(c=yi(a),G.current=c),G.current=c;let l=c?.virtualizer??null,u=n?void 0:{name:i||``,contents:e,lang:r,cacheKey:`old:${H}:${i}:${li(e)}`},f=n?void 0:{name:i||``,contents:t,lang:r,cacheKey:`new:${H}:${i}:${li(t)}`},p=n?ce.current!==n:ce.current!==void 0||!u||!f||!K.current||!le.current||!Cn(K.current,u)||!Cn(le.current,f),m=ie.current,h=!!(m&&(ae.current!==l||oe.current!==de||l&&(se.current!==me.hunkSeparators||p)));h&&(m?.cleanUp(),ie.current=null,a.innerHTML=``);let g=ie.current,_=!h&&m?!xn(m.options,me):!1;if(g?g.setOptions(me):(g=c?new Dn(me,c.virtualizer,_i,de):new yn(me,de),ie.current=g,F.current=null),ae.current=l,oe.current=de,se.current=l?me.hunkSeparators:void 0,ce.current=n,K.current=u,le.current=f,n)g.render({fileDiff:n,forceRender:_,lineAnnotations:ge.current,containerWrapper:a});else{if(!u||!f)return;g.render({oldFile:u,newFile:f,forceRender:_,lineAnnotations:ge.current,containerWrapper:a})}let v=hi(a,()=>{if(s(),bi(g,c,ue),!d||q.current===d)return;let e=(a.querySelector(`diffs-container`)?.shadowRoot)?.querySelector(`[data-line="${d}"]:not([data-line-type="change-deletion"])`);e instanceof HTMLElement&&(e.scrollIntoView({block:`center`}),q.current=d)});return()=>{v(),s()}},[H,n,i,d,r,t,me,e,de]),(0,Q.useEffect)(()=>{let e=ie.current;if(e){try{e.setLineAnnotations(he)}catch(t){console.error(`Failed to apply diff line annotations`,t);try{e.setLineAnnotations([])}catch{}}requestAnimationFrame(()=>{if(ie.current===e){try{e.rerender()}catch{}ue()}})}},[he]),(0,Q.useEffect)(()=>{let e=ie.current;if(!e||C!==null)return;let t=F.current;if(!di(C,t))try{P.current=!0,e.setSelectedLines(C),F.current=C}catch{}finally{P.current=!1}},[C]),(0,Q.useEffect)(()=>{if(!l)return;let e=re.current;if(!e)return;let t=null,n=()=>{},r=()=>{let i=e.querySelector(`diffs-container`)?.shadowRoot;if(!i){t=requestAnimationFrame(r);return}let a=e=>{if(!(e instanceof MouseEvent)||e.button!==0||!(e.target instanceof Element))return;let t=e.target.closest(`[data-column-number]`);if(!(t instanceof HTMLElement))return;let n=t.getAttribute(`data-column-number`),r=n?parseInt(n,10):NaN;if(Number.isNaN(r))return;let a=V(t);if(I({start:r,end:r,side:a}),u){let e=t.getBoundingClientRect(),n=t.closest(`[data-line-type]`)?.getAttribute(`data-line-type`),o=Array.from(i.querySelectorAll(`[data-line="${r}"]`)).find(e=>!n||e.getAttribute(`data-line-type`)===n);x({range:{start:r,end:r,side:a},x:Math.min(window.innerWidth-240,Math.max(8,o?.getBoundingClientRect().left??e.right+12)),y:e.top-8})}e.preventDefault(),e.stopPropagation()},o=(e,t)=>{let n=(e instanceof Element?e:e.parentElement)?.closest(`[data-line]`);if(!(n instanceof HTMLElement))return null;let r=Number.parseInt(n.getAttribute(`data-line`)??``,10);if(Number.isFinite(r))return{lineNumber:r,side:V(n),lineStartX:n.getBoundingClientRect().left};let i=Array.from(n.querySelectorAll(`[data-column-number]`));if(i.length===0)return null;let a=i.reduce((e,n)=>{let r=Math.abs(e.getBoundingClientRect().right-t);return Math.abs(n.getBoundingClientRect().right-t)<r?n:e}),o=Number.parseInt(a.getAttribute(`data-column-number`)??``,10);return Number.isFinite(o)?{lineNumber:o,side:V(a),lineStartX:a.getBoundingClientRect().right+12}:null},s=()=>{u&&window.requestAnimationFrame(()=>{let e=i.getSelection?.(),t=e?.rangeCount?e:window.getSelection();if(!t)return;let n=t.getComposedRanges?.({shadowRoots:[i]})[0],r=document.createRange();if(n)r.setStart(n.startContainer,n.startOffset),r.setEnd(n.endContainer,n.endOffset);else if(t.rangeCount>0){let e=t.getRangeAt(0);r.setStart(e.startContainer,e.startOffset),r.setEnd(e.endContainer,e.endOffset)}else return;if(!r.toString().trim())return;let a=r.getBoundingClientRect(),s=o(r.startContainer,a.left),c=o(r.endContainer,a.right);!s||!c||s.side!==c.side||x({range:{start:s.lineNumber,end:c.lineNumber,side:s.side},x:Math.min(window.innerWidth-240,Math.max(8,s.lineStartX)),y:Math.max(8,a.top-8)})})};i.addEventListener(`click`,a,!0),i.addEventListener(`pointerup`,s),window.addEventListener(`pointerup`,s,!0),n=()=>{i.removeEventListener(`click`,a,!0),i.removeEventListener(`pointerup`,s),window.removeEventListener(`pointerup`,s,!0)}};return r(),()=>{t!==null&&cancelAnimationFrame(t),n()}},[H,l,u,i,I,V]),(0,Q.useEffect)(()=>{let e=re.current;if(!e)return;let t=null,n=null,r=setTimeout(()=>{let r=e.querySelector(`diffs-container`);if(!(r instanceof HTMLElement))return;let i=r.shadowRoot;t=new MutationObserver(()=>{n&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{ue(),n=null})}),t.observe(r,{childList:!0,subtree:!0}),i&&t.observe(i,{childList:!0,subtree:!0})},100);return()=>{clearTimeout(r),n&&cancelAnimationFrame(n),t?.disconnect()}},[H,i]),typeof window>`u`)return null;let _e=l?(0,$.jsx)(ni,{diffRootRef:W,drafts:S,selection:C,editingDraftId:D,commentText:T,onTextChange:E,fileLabel:i?.split(`/`).pop()??``,onSave:L,onCancel:te,onEdit:e=>{z({start:e.startLine,end:e.endLine,side:e.side===`original`?`deletions`:`additions`}),A(e)},onDelete:j,onAddToChat:u?R:void 0}):null,J=u&&b?(0,$.jsx)(ri,{position:b,onAddToChat:()=>{R(b.range),x(null),window.getSelection()?.removeAllRanges()}}):null;return c===`fill`?(0,$.jsx)(`div`,{className:Y(`flex flex-col relative`,`size-full`),"data-diff-virtual-root":!0,children:(0,$.jsxs)(`div`,{className:`flex-1 relative min-h-0`,children:[(0,$.jsx)(Ve,{outerClassName:`pierre-diff-wrapper size-full`,disableHorizontal:!1,fillContainer:!0,"data-diff-virtual-content":!0,children:(0,$.jsx)(`div`,{ref:W,className:`size-full relative`,children:(0,$.jsx)(`div`,{ref:re,className:`size-full`})})}),_e,J]})}):(0,$.jsxs)(`div`,{className:Y(`relative`,`w-full`),children:[(0,$.jsx)(`div`,{ref:W,className:`pierre-diff-wrapper w-full overflow-x-auto overflow-y-visible relative`,children:(0,$.jsx)(`div`,{ref:re,className:`w-full`})}),_e,J]})},Si=5e3,Ci=(e,t)=>{if(!e)return 1;let n=1;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10&&(n+=1,n>t))return n;return n},wi=(e,t)=>Te(we.getState().dictionary,e,t),Ti=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)?`missing`:`unreadable`},Ei=async(e,t)=>{if(e.readFile){let n=await e.readFile(t,{optional:!0});if(typeof n.exists!=`boolean`)throw Error(`Optional file read requires an existence response header`);return{content:n.content??``,exists:n.exists}}let n=new URLSearchParams({path:t,optional:`true`}),r=await f(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(!r.ok){let e=await r.json().catch(()=>({error:r.statusText}));throw Error(e.error||`Failed to read file`)}let i=r.headers.get(`x-openchamber-file-exists`);if(i!==`true`&&i!==`false`)throw Error(`Optional file read requires an existence response header`);return{content:await r.text(),exists:i===`true`}},Di=async(e,t)=>{try{let{content:n,exists:r}=await Ei(e,t);return r?Ci(n,5e3)>5e3?{ok:!1,reason:`too-large`}:{ok:!0}:{ok:!1,reason:`missing`}}catch(e){return{ok:!1,reason:Ti(e)}}},Oi=e=>e===`too-large`?wi(`contextFileOpen.failure.tooLarge`,{count:Si.toLocaleString(N())}):wi(e===`missing`?`contextFileOpen.failure.missing`:`contextFileOpen.failure.unreadable`),ki=64,Ai=3,ji=new Map,Mi=(e,t,n=Ai)=>{let r=`${e}\0${n}\0${t}`,i=ji.get(r);if(i)return ji.delete(r),ji.set(r,i),i;let a=Pi(t),o=a?bn(wn(t,n),{oldFile:{name:e,contents:a.before},newFile:{name:e,contents:a.after}})??Ii(e):kn(Ni(e,t))[0]?.files[0]??Ii(e);for(ji.set(r,o);ji.size>ki;){let e=ji.keys().next().value;if(!e)break;ji.delete(e)}return o},Ni=(e,t)=>!t.trim()||t.startsWith(`diff --git `)||/^--- [^\n]*\r?\n\+\+\+ /m.test(t)?t:`Index: ${e}\n===================================================================\n--- ${e}\t\n+++ ${e}\t\n${t}`,Pi=e=>{if(!e.startsWith(`diff --git `)&&!/^--- [^\n]*\t?\r?\n\+\+\+ [^\n]*\t?(?:\r?\n|$)/m.test(e))return;let t=[...e.matchAll(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@[^\n]*(?:\r?\n|$)/gm)];if(t.length!==1)return;let n=t[0],r=Number.parseInt(n[1]??``,10),i=Number.parseInt(n[2]??``,10);if(r>1||i>1||!Number.isFinite(r)||!Number.isFinite(i))return;let a=(n.index??0)+n[0].length,o=e.slice(a),s=[],c=[],l;for(let e of o.split(/\r?\n/)){if(e.startsWith(`diff --git `)||e.startsWith(`@@ `))break;if(e.startsWith(`\\`)){if(l===`-`||l===` `){let e=s.at(-1);e&&(e.newline=!1)}if(l===`+`||l===` `){let e=c.at(-1);e&&(e.newline=!1)}continue}if(e.startsWith(`-`)){s.push({text:e.slice(1),newline:!0}),l=`-`;continue}if(e.startsWith(`+`)){c.push({text:e.slice(1),newline:!0}),l=`+`;continue}e.startsWith(` `)&&(s.push({text:e.slice(1),newline:!0}),c.push({text:e.slice(1),newline:!0}),l=` `)}return{before:Fi(s),after:Fi(c)}},Fi=e=>e.map(e=>e.text+(e.newline?`
|
|
138
|
+
`:``)).join(``),Ii=e=>Sn({name:e,contents:``},{name:e,contents:``}),Li=e=>{if(!e)return null;let t=e.split(`
|
|
139
|
+
`),n=null;for(let e of t){let t=e.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(t){let e=Number.parseInt(t[1]??``,10);n=Number.isFinite(e)&&e>=1?e:null;continue}if(n!==null){if(e.startsWith(` `)){n+=1;continue}if(e.startsWith(`+`))return n;if(e.startsWith(`-`))return Math.max(1,n)}}return null},Ri=e=>{let t=[],n=new Set;for(let r of e){let e=r.path.trim(),i=r.patch;if(!e||!i.trim()||n.has(e))continue;n.add(e);let a=0,o=0;for(let e of i.split(`
|
|
140
|
+
`))e.startsWith(`+++`)||e.startsWith(`---`)||(e.startsWith(`+`)&&(a+=1),e.startsWith(`-`)&&(o+=1));let s=/^---\s+\/dev\/null(?:\s|$)/m.test(i)?`added`:/^\+\+\+\s+\/dev\/null(?:\s|$)/m.test(i)?`deleted`:`modified`;t.push({file:e,patch:i,status:s,additions:a,deletions:o})}return t},zi=e=>typeof e.patch==`string`&&e.patch.length>0||typeof e.before==`string`&&e.before.length>0||typeof e.after==`string`&&e.after.length>0,Bi=e=>{for(let t of e)if(t.file?.trim()&&!zi(t))return!0;return!1},Vi=(e,t)=>{if(e.length===0)return[];if(t.length===0)return e.slice();let n=new Map;for(let e of t){let t=e.file?.trim();t&&n.set(t,e)}return e.map(e=>{let t=e.file?.trim();if(!t)return e;let r=n.get(t);return r?{...e,patch:typeof r.patch==`string`?r.patch:e.patch,before:typeof r.before==`string`?r.before:e.before,after:typeof r.after==`string`?r.after:e.after,additions:e.additions??r.additions,deletions:e.deletions??r.deletions,status:e.status??r.status}:e})},Hi=1100,Ui=15e3,Wi=500,Gi=300,Ki=1e6,qi=3,Ji=e=>e<=6?e:e<=12?6:e<=25?4:2,Yi=Q.memo(()=>{let e=(0,Qn.c)(4),{t}=ee(),n;e[0]===t?n=e[1]:(n=t(`diffView.binary.unavailable`),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r=(0,$.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-background px-3 py-2`,children:(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:n})}),e[2]=n,e[3]=r),r}),Xi={"?":{code:`?`,color:`var(--status-info)`,descriptionKey:`diffView.change.untracked`},A:{code:`A`,color:`var(--status-success)`,descriptionKey:`diffView.change.new`},D:{code:`D`,color:`var(--status-error)`,descriptionKey:`diffView.change.deleted`},R:{code:`R`,color:`var(--status-info)`,descriptionKey:`diffView.change.renamed`},C:{code:`C`,color:`var(--status-info)`,descriptionKey:`diffView.change.copied`},M:{code:`M`,color:`var(--status-warning)`,descriptionKey:`diffView.change.modified`}},Zi=Xi.M,Qi=e=>{let t=e.index?.trim(),n=e.working_dir?.trim();return t&&t!==`?`?t.charAt(0):n?n.charAt(0):t?.charAt(0)||n?.charAt(0)||`M`},$i=e=>Xi[Qi(e)]??Zi,ea=e=>{let{index:t,working_dir:n}=e;return t===`A`||n===`A`||t===`?`||n===`?`},ta=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},na=e=>!!e.working_dir?.trim()||e.index===`?`,ra=(e,t)=>Nt(e,t),ia=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/,``),aa=(e,t)=>{let n=e.split(`
|
|
141
|
+
`),r=t.split(`
|
|
142
|
+
`),i=Math.min(n.length,r.length);for(let e=0;e<i;e+=1)if(n[e]!==r[e])return e+1;return r.length>n.length?n.length+1:n.length>r.length?Math.max(1,r.length):1},oa=e=>/^Binary files .+ differ$/m.test(e)||/^GIT binary patch$/m.test(e),sa=e=>Array.isArray(e)?e.filter(e=>!e||typeof e!=`object`?!1:typeof e.file==`string`):[],ca=e=>e===`added`?`A`:e===`deleted`?`D`:`M`,la=(e,t,n)=>oa(t)?{original:``,modified:``,isBinary:!0,patch:t,contextMode:n}:{original:``,modified:``,patch:t,fileDiff:Mi(e,t),contextMode:n},ua=(e,t,n)=>{let r=e??0,i=t??0;return!r&&!i?null:(0,$.jsxs)(`span`,{className:Y(`typography-code flex items-center gap-1 whitespace-nowrap`,n?.shrink?`min-w-0 overflow-hidden`:`flex-shrink-0`,n?.className),children:[r?(0,$.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,r]}):null,i?(0,$.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,i]}):null]})},da=Q.memo(e=>{let t=(0,Qn.c)(53),{scope:n,workingCount:r,stagedCount:i,turnCount:a,onScopeChange:o}=e,{t:s}=ee(),[c,l]=Q.useState(!1),u=n===`staged`?i:n===`turn`?a:r,d;t[0]!==n||t[1]!==s?(d=s(n===`staged`?`diffView.scope.staged`:n===`turn`?`diffView.scope.lastTurn`:`diffView.scope.changed`),t[0]=n,t[1]=s,t[2]=d):d=t[2];let f=d,p;t[3]===s?p=t[4]:(p=s(`diffView.scope.selectorAria`),t[3]=s,t[4]=p);let m;t[5]===u?m=t[6]:(m=(0,$.jsxs)(`span`,{className:`diff-toolbar__scope-count`,children:[`: `,u]}),t[5]=u,t[6]=m);let h;t[7]!==f||t[8]!==m?(h=(0,$.jsxs)(`span`,{className:`whitespace-nowrap`,children:[f,m]}),t[7]=f,t[8]=m,t[9]=h):h=t[9];let g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4 flex-shrink-0 opacity-60`}),t[10]=g):g=t[10];let _;t[11]!==p||t[12]!==h?(_=(0,$.jsx)(bt,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-code font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":p,children:[h,g]})}),t[11]=p,t[12]=h,t[13]=_):_=t[13];let v;t[14]===o?v=t[15]:(v=e=>{(e===`working`||e===`staged`||e===`turn`)&&(o?.(e),l(!1))},t[14]=o,t[15]=v);let y;t[16]===s?y=t[17]:(y=s(`diffView.scope.changed`),t[16]=s,t[17]=y);let b;t[18]===y?b=t[19]:(b=(0,$.jsx)(`span`,{children:y}),t[18]=y,t[19]=b);let x;t[20]===r?x=t[21]:(x=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r}),t[20]=r,t[21]=x);let S;t[22]!==x||t[23]!==b?(S=(0,$.jsx)(Dt,{value:`working`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[b,x]})}),t[22]=x,t[23]=b,t[24]=S):S=t[24];let C;t[25]===s?C=t[26]:(C=s(`diffView.scope.staged`),t[25]=s,t[26]=C);let w;t[27]===C?w=t[28]:(w=(0,$.jsx)(`span`,{children:C}),t[27]=C,t[28]=w);let T;t[29]===i?T=t[30]:(T=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}),t[29]=i,t[30]=T);let E;t[31]!==w||t[32]!==T?(E=(0,$.jsx)(Dt,{value:`staged`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[w,T]})}),t[31]=w,t[32]=T,t[33]=E):E=t[33];let D;t[34]===s?D=t[35]:(D=s(`diffView.scope.lastTurn`),t[34]=s,t[35]=D);let O;t[36]===D?O=t[37]:(O=(0,$.jsx)(`span`,{children:D}),t[36]=D,t[37]=O);let k;t[38]===a?k=t[39]:(k=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a}),t[38]=a,t[39]=k);let A;t[40]!==O||t[41]!==k?(A=(0,$.jsx)(Dt,{value:`turn`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[O,k]})}),t[40]=O,t[41]=k,t[42]=A):A=t[42];let j;t[43]!==n||t[44]!==S||t[45]!==E||t[46]!==A||t[47]!==v?(j=(0,$.jsx)(vt,{align:`start`,className:`w-40`,children:(0,$.jsxs)(gt,{value:n,onValueChange:v,children:[S,E,A]})}),t[43]=n,t[44]=S,t[45]=E,t[46]=A,t[47]=v,t[48]=j):j=t[48];let M;return t[49]!==c||t[50]!==j||t[51]!==_?(M=(0,$.jsxs)(yt,{open:c,onOpenChange:l,children:[_,j]}),t[49]=c,t[50]=j,t[51]=_,t[52]=M):M=t[52],M}),fa=Q.memo(e=>{let t=(0,Qn.c)(11),{changedFiles:n,selectedFile:r,onSelectFile:i}=e,{t:a}=ee();if(n.length===0)return null;let o;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e;t[5]!==i||t[6]!==r||t[7]!==a?(e=e=>{let t=$i(e),n=r===e.path;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),className:Y(`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left transition-colors`,n?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`),children:[(0,$.jsx)(It,{filePath:e.path,className:`size-3 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-code font-semibold w-3.5 text-center uppercase`,style:{color:t.color},title:a(t.descriptionKey),"aria-label":a(t.descriptionKey),children:t.code}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-code`,style:{direction:`rtl`,textAlign:`left`,unicodeBidi:`plaintext`},title:e.path,children:e.path}),ua(e.insertions,e.deletions)]})},e.path)},t[5]=i,t[6]=r,t[7]=a,t[8]=e):e=t[8],o=n.map(e),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o}else o=t[4];let s;return t[9]===o?s=t[10]:(s=(0,$.jsx)(Ve,{outerClassName:`flex-1 min-h-0`,className:`px-2 py-2`,children:(0,$.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o})}),t[9]=o,t[10]=s),s}),pa=Q.memo(e=>{let t=(0,Qn.c)(20),{filePath:n,diff:r,renderSideBySide:i}=e,{t:a}=ee(),o=r.original.length>0,s=r.modified.length>0,c=i?`flex flex-row gap-6 items-start justify-center`:`flex flex-col gap-4 items-center`,l=i?`flex flex-col items-center gap-2 flex-1 min-w-0`:`flex flex-col items-center gap-2`,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={contain:`layout`},t[0]=u):u=t[0];let d;t[1]!==r.original||t[2]!==n||t[3]!==o||t[4]!==l||t[5]!==i||t[6]!==a?(d=o&&(0,$.jsxs)(`div`,{className:l,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground font-medium`,children:a(`diffView.image.original`)}),(0,$.jsx)(`img`,{src:r.original,alt:a(`diffView.image.originalAlt`,{path:n}),className:i?`max-w-full max-h-[70vh] object-contain`:`max-w-full object-contain`,style:{imageRendering:`auto`}})]}),t[1]=r.original,t[2]=n,t[3]=o,t[4]=l,t[5]=i,t[6]=a,t[7]=d):d=t[7];let f;t[8]!==r.modified||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==l||t[13]!==i||t[14]!==a?(f=s&&(0,$.jsxs)(`div`,{className:l,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground font-medium`,children:a(o?`diffView.image.modified`:`diffView.image.new`)}),(0,$.jsx)(`img`,{src:r.modified,alt:a(`diffView.image.modifiedAlt`,{path:n}),className:i?`max-w-full max-h-[70vh] object-contain`:`max-w-full object-contain`,style:{imageRendering:`auto`}})]}),t[8]=r.modified,t[9]=n,t[10]=s,t[11]=o,t[12]=l,t[13]=i,t[14]=a,t[15]=f):f=t[15];let p;return t[16]!==c||t[17]!==d||t[18]!==f?(p=(0,$.jsx)(`div`,{className:`w-full overflow-auto p-4`,style:u,children:(0,$.jsxs)(`div`,{className:c,children:[d,f]})}),t[16]=c,t[17]=d,t[18]=f,t[19]=p):p=t[19],p}),ma=Q.memo(e=>{let t=(0,Qn.c)(17),{filePath:n,diff:r,renderSideBySide:i,wrapLines:a,focusLine:o}=e,s;t[0]===n?s=t[1]:(s=on(n)||`text`,t[0]=n,t[1]=s);let c=s;if(r.isBinary){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Yi,{}),t[2]=e):e=t[2],e}if(an(n)){let e;return t[3]!==r||t[4]!==n||t[5]!==i?(e=(0,$.jsx)(pa,{filePath:n,diff:r,renderSideBySide:i}),t[3]=r,t[4]=n,t[5]=i,t[6]=e):e=t[6],e}let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l={contain:`layout`},t[7]=l):l=t[7];let u;return t[8]!==r.fileDiff||t[9]!==r.modified||t[10]!==r.original||t[11]!==n||t[12]!==o||t[13]!==c||t[14]!==i||t[15]!==a?(u=(0,$.jsx)(`div`,{className:`w-full`,style:l,children:(0,$.jsx)(xi,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:c,fileName:n,renderSideBySide:i,wrapLines:a,focusLine:o,layout:`inline`,enableSelectionActions:!0})}),t[8]=r.fileDiff,t[9]=r.modified,t[10]=r.original,t[11]=n,t[12]=o,t[13]=c,t[14]=i,t[15]=a,t[16]=u):u=t[16],u}),ha=Q.memo(e=>{let t=(0,Qn.c)(7),{filePath:n,staged:r,busyAction:i,disabled:a,onAction:o}=e,{t:s}=ee(),c;return t[0]!==i||t[1]!==a||t[2]!==n||t[3]!==o||t[4]!==r||t[5]!==s?(c=(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-lg backdrop-blur-md`,children:r?(0,$.jsx)(ga,{label:s(`gitView.changes.unstageFileAria`,{path:n}),icon:`arrow-go-back`,loading:i===`unstage`,disabled:a,onClick:()=>o(`unstage`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ga,{label:s(`gitView.changes.revertFileAria`,{path:n}),icon:`arrow-go-back`,loading:i===`discard`,disabled:a,tone:`failure`,onClick:()=>o(`discard`)}),(0,$.jsx)(ga,{label:s(`gitView.changes.stageFileAria`,{path:n}),icon:`add`,loading:i===`stage`,disabled:a,tone:`success`,onClick:()=>o(`stage`)})]})}),t[0]=i,t[1]=a,t[2]=n,t[3]=o,t[4]=r,t[5]=s,t[6]=c):c=t[6],c}),ga=e=>{let t=(0,Qn.c)(14),{label:n,icon:r,loading:i,disabled:a,tone:o,onClick:s}=e,c=o===`failure`&&`text-[var(--status-error)] hover:text-[var(--status-error)]`,l=o===`success`&&`text-[var(--status-success)] hover:text-[var(--status-success)]`,u;t[0]!==c||t[1]!==l?(u=Y(`h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100`,c,l),t[0]=c,t[1]=l,t[2]=u):u=t[2];let d;t[3]===s?d=t[4]:(d=e=>{e.stopPropagation(),s()},t[3]=s,t[4]=d);let f;t[5]!==r||t[6]!==i?(f=i?(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(X,{name:r,className:r===`add`?`size-4`:`size-3.5`}),t[5]=r,t[6]=i,t[7]=f):f=t[7];let p;return t[8]!==a||t[9]!==n||t[10]!==u||t[11]!==d||t[12]!==f?(p=(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:u,disabled:a,title:n,"aria-label":n,onClick:d,children:f}),t[8]=a,t[9]=n,t[10]=u,t[11]=d,t[12]=f,t[13]=p):p=t[13],p},_a=Q.memo(({directory:e,file:t,layout:n,wrapLines:r,isSelected:i,isExpanded:a,isMounted:o,onSelect:c,onExpandedChange:l,registerSectionRef:u,showOpenInEditorAction:d=!1,isOpeningInEditor:f=!1,onOpenInEditor:p,staged:m=!1,loadFullFiles:h=!1,initialDiffData:g=null,focusLine:_=null,showFileActions:v=!0,disableGitFetch:y=!1})=>{let{t:b}=ee(),{git:x}=Ut(),S=dn(Q.useCallback(n=>n.directories.get(e)?.diffCache.get(t.path)??null,[e,t.path])),C=dn(e=>e.setDiff),w=dn(e=>e.fetchStatus),T=s(e=>e.setDiffFileLayout),[E,D]=Q.useState(0),[O,k]=Q.useState(null),[A,j]=Q.useState(!1),[M,N]=Q.useState(null),[P,F]=Q.useState(!1),[I,te]=Q.useState(null),[ne,L]=Q.useState(null),R=Q.useRef(null),z=Q.useRef(null),B=Q.useMemo(()=>$i(t),[t]),V=n===`side-by-side`,H=h?`full`:`patch`,U=`${t.index}:${t.working_dir}:${t.insertions}:${t.deletions}`,W=Q.useMemo(()=>g||(m?ne:I||(S?{original:S.original,modified:S.modified,isBinary:S.isBinary,contextMode:`full`}:null)),[S,g,I,m,ne]),re=W?.contextMode===H,ie=Q.useCallback(e=>{z.current=e,u(t.path,e)},[t.path,u]),G=Q.useCallback(e=>{l(t.path,e)},[t.path,l]),ae=Q.useCallback(()=>{c(t.path)},[t.path,c]);Q.useEffect(()=>{m?L(null):te(null),k(null),R.current=null},[U,m]),Q.useEffect(()=>{if(!a||!o)return;if(y){R.current=null,j(!1);return}if(!e||g||W&&re){R.current=null,j(!1);return}let n=`${e}::${t.path}::${m?`staged`:`unstaged`}::${U}::${H}::${E}`;if(R.current===n)return;R.current=n,k(null),j(!0);let r=!1,i=h?Ki:qi,s=an(t.path)||h?x.getGitFileDiff(e,{path:t.path,staged:m}):x.getGitDiff(e,{path:t.path,staged:m,contextLines:i}),c=Ui,l=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${c}ms`)),c)});return Promise.race([s,l]).then(n=>{if(!r){if(`diff`in n){let e=la(t.path,n.diff,H);m?L(e):te(e)}else{let r={original:n.original??``,modified:n.modified??``,isBinary:n.isBinary,contextMode:`full`};m?L(r):C(e,t.path,r)}j(!1)}}).catch(e=>{if(r)return;let t=e instanceof Error?e.message:String(e);k(t),j(!1)}),()=>{r=!0,R.current===n&&(R.current=null)}},[H,W,re,E,e,y,t.path,U,x,g,a,o,h,C,m]);let oe=Q.useCallback(()=>{G(!a),ae()},[G,ae,a]),se=Q.useCallback(async n=>{if(!(!e||M!==null)){N(n);try{n===`stage`?await x.stageGitFile(e,t.path):n===`unstage`?await x.unstageGitFile(e,t.path):await x.revertGitFile(e,t.path,{scope:`working`}),D(e=>e+1),await w(e,x)}catch(e){let t=n===`unstage`?`gitView.toast.unstageFileFailed`:n===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.revertFailed`;J.error(e instanceof Error?e.message:b(t))}finally{N(e=>e===n?null:e)}}},[e,w,t.path,M,x,b]);return(0,$.jsxs)(`div`,{ref:ie,className:`scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0`,children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80`,children:(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:oe,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),oe())},className:Y(`cursor-pointer`,`group/header relative grid min-h-8 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-1.5 overflow-hidden px-2 py-1`,`bg-transparent`,`text-muted-foreground hover:text-foreground`,i?`bg-[var(--interactive-selection)]/35`:null),children:[(0,$.jsx)(`div`,{className:`absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50`}),(0,$.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`flex size-4 items-center justify-center opacity-70 group-hover/header:opacity-100`,children:a?(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-3.5`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-3.5`})}),(0,$.jsx)(`span`,{className:`typography-code font-semibold leading-none w-3.5 text-center uppercase`,style:{color:B.color},title:b(B.descriptionKey),"aria-label":b(B.descriptionKey),children:B.code}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden typography-code`,title:t.path,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(It,{filePath:t.path,className:`size-3 flex-shrink-0 align-middle`}),(()=>{let e=t.path.lastIndexOf(`/`);if(e===-1)return(0,$.jsx)(`span`,{className:`block min-w-0 truncate typography-code text-foreground`,style:{direction:`rtl`,textAlign:`left`,unicodeBidi:`plaintext`},children:t.path});let n=t.path.slice(0,e),r=t.path.slice(e+1);return(0,$.jsxs)(`span`,{className:`flex min-w-0 items-baseline overflow-hidden`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-code text-muted-foreground`,style:{direction:`rtl`,textAlign:`left`,unicodeBidi:`plaintext`},children:n}),(0,$.jsxs)(`span`,{className:`flex-shrink-0 typography-code`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),(0,$.jsx)(`span`,{className:`text-foreground`,children:r})]})]})})()]})})]}),(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center justify-self-end gap-1.5`,children:[ua(t.insertions,t.deletions),d&&p?(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-5 w-5 p-0 opacity-70 hover:opacity-100`,title:b(`diffView.actions.openFileInEditorAtChange`),onClick:e=>{e.stopPropagation(),p(t.path,W)},disabled:f,children:f?(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(X,{name:`edit`,className:`size-3.5`})}):null,(0,$.jsx)(_n,{mode:V?`side-by-side`:`unified`,onModeChange:e=>{let n=e===`side-by-side`?`side-by-side`:`inline`;T(t.path,n)},className:`opacity-70`})]})]})}),a&&(0,$.jsxs)(`div`,{className:`relative bg-background overflow-hidden`,children:[!o&&!O?(0,$.jsx)(`div`,{className:`h-40 border border-border/40 bg-background/40`}):null,O?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-foreground`,children:b(`diffView.state.failedToLoadDiff`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground max-w-[32rem] text-center`,children:O}),(0,$.jsx)(`button`,{type:`button`,className:`typography-ui-label text-primary hover:underline`,onClick:()=>D(e=>e+1),children:b(`diffView.actions.retry`)})]}):null,o&&A&&!W&&!O?(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),b(`diffView.state.loadingDiff`)]}):null,o&&W&&!P&&t.insertions+t.deletions>Wi?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-foreground`,children:b(`diffView.state.largeDiff`,{count:t.insertions+t.deletions})}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:b(`diffView.state.largeDiffDescription`)}),(0,$.jsx)(`button`,{type:`button`,className:`typography-ui-label text-primary hover:underline`,onClick:()=>F(!0),children:b(`diffView.actions.renderAnyway`)})]}):null,o&&W&&(P||t.insertions+t.deletions<=Wi)?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ma,{filePath:t.path,diff:W,renderSideBySide:V,wrapLines:r,focusLine:_}),v?(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-3 right-3 z-20`,children:(0,$.jsx)(`div`,{className:`pointer-events-auto`,children:(0,$.jsx)(ha,{filePath:t.path,staged:m,busyAction:M,disabled:M!==null,onAction:se})})}):null]}):null]})]})}),va=({hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:t=!1,pinSelectedFileHeaderToTopOnNavigate:n=!1,showOpenInEditorAction:r=!1,diffScope:i=`all`,turnMessageId:a=null,sessionId:o=null,directory:l=null,onDiffScopeChange:u,targetFilePath:d=null,targetLine:f=null,toolPatches:p=null,flushContent:m=!1,singleFileView:h=!1,preloadFullFiles:g=!1,navigationRequestKey:_})=>{let{t:v}=ee(),{git:y,files:b}=Ut(),x=sn(),S=typeof l==`string`&&l.trim()?l.trim():x,{screenWidth:C,isMobile:T}=jt(),E=hn(S??null),D=gn(S??null),O=fn(S??null),k=dn(e=>e.setActiveDirectory),A=dn(e=>e.ensureStatus),j=dn(e=>e.fetchStatus),M=dn(e=>e.setDiff),[N,P]=Q.useState(null),[F,I]=Q.useState(!1),[ne,L]=Q.useState(null),[R,z]=Q.useState(null),[B,V]=Q.useState(()=>new Set),[H,U]=Q.useState(()=>new Set),[W,re]=Q.useState(g),[ie,G]=Q.useState(0),[ae,oe]=Q.useState(!1),[se,ce]=Q.useState(!1),[q,ue]=Q.useState(i);Q.useEffect(()=>{ue(i)},[i]);let de=s(e=>e.pendingDiffFile),fe=s(e=>e.pendingDiffStaged),pe=s(e=>e.pendingDiffScope),me=s(e=>e.pendingDiffLine),he=s(e=>e.setPendingDiffFile),_e=s(e=>e.diffLayoutPreference),ve=s(e=>e.diffFileLayout),ye=s(e=>e.setDiffFileLayout),be=s(e=>e.diffWrapLines),xe=s(e=>e.setDiffWrapLines),Se=s(e=>e.openContextFileAtLine),Ce=K(e=>e.currentSessionId),we=typeof o==`string`&&o.trim()?o.trim():Ce,Te=ge(we??``,S??void 0),Ee=be,De=q===`staged`||q!==`working`&&null,Oe=De??F,ke=T||C<=768,Ae=!!we&&q!==`turn`&&!ke&&!c(),je=!e&&!ke&&C>=1024,Me=Q.useRef(null),Ne=Q.useRef(new Map),Pe=Q.useRef(null),Fe=Q.useRef(null),Ie=Q.useRef(!1),Le=Q.useRef(null),Re=Q.useRef(null),ze=Q.useRef(null),Be=Q.useCallback(()=>{Pe.current=null,Ie.current=!1,z(null),Fe.current!==null&&(window.cancelAnimationFrame(Fe.current),Fe.current=null)},[]),He=Q.useCallback(e=>{V(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),Ue=Q.useMemo(()=>{let e=Te.length-1;if(a&&(e=Te.findIndex(e=>e.id===a),e<0))return[];for(let t=e;t>=0;--t){let e=Te[t];if(e.role===`user`)return sa(e.summary?.diffs)}return[]},[Te,a]),We=Q.useMemo(()=>{let e=Te.length-1;if(a&&(e=Te.findIndex(e=>e.id===a),e<0))return null;for(let t=e;t>=0;--t){let e=Te[t];if(e.role===`user`&&typeof e.id==`string`&&e.id)return e.id}return null},[Te,a]),Ge=Q.useMemo(()=>Ri(p??[]),[p]),Ke=Ge.length>0,[qe,Je]=Q.useState(null),[Ye,Xe]=Q.useState(null),[Ze,Qe]=Q.useState(0),$e=Q.useRef(0),et=Q.useMemo(()=>Ke?Ge:qe?Vi(Ue,qe):Ue,[qe,Ue,Ge,Ke]);Q.useEffect(()=>{if(q!==`turn`||Ke){Je(null),Xe(null);return}if(!we||Ue.length===0){Je(null),Xe(null);return}if(!Bi(Ue)){Je(null),Xe(null);return}let e=++$e.current;return Xe(null),Je(null),w.getSessionDiff({sessionID:we,directory:S,messageID:We}).then(t=>{e===$e.current&&Je(t)}).catch(t=>{if(e!==$e.current)return;let n=t instanceof Error?t.message:String(t);Xe(n),Je(null)}),()=>{$e.current+=1}},[q,we,S,Ue,We,Ze,Ke]);let tt=Q.useMemo(()=>{let e=new Map;for(let t of et)if(t.file){if(typeof t.patch==`string`&&t.patch.length>0){e.set(t.file,la(t.file,t.patch,`patch`));continue}(typeof t.before==`string`&&t.before.length>0||typeof t.after==`string`&&t.after.length>0)&&e.set(t.file,{original:t.before??``,modified:t.after??``,contextMode:`full`})}return e},[et]),nt=Q.useMemo(()=>{if(q===`turn`)return et.map(e=>({path:e.file??``,index:``,working_dir:ca(e.status),insertions:e.additions??0,deletions:e.deletions??0,isNew:e.status===`added`})).filter(e=>e.path).sort((e,t)=>e.path.localeCompare(t.path));if(!D?.files)return[];let e=D.diffStats??{},t=q===`staged`?ta:q===`working`?na:()=>!0;return D.files.filter(t).map(t=>({...t,insertions:e[t.path]?.insertions??0,deletions:e[t.path]?.deletions??0,isNew:ea(t)})).sort((e,t)=>e.path.localeCompare(t.path))},[q,et,D]),rt=Q.useMemo(()=>D?.files?D.files.filter(na).length:0,[D]),it=Q.useMemo(()=>D?.files?D.files.filter(ta).length:0,[D]),at=et.length,ot=Q.useMemo(()=>nt.map(e=>e.path).join(`\0`),[nt]),ut=Q.useMemo(()=>{if(!h)return nt;let e=d?.trim()||N;return e?nt.filter(t=>t.path===e):[]},[nt,N,h,d]);Q.useEffect(()=>{let e=ot?ot.split(`\0`):[],n=new Set(e),r=`${S??``}:${q}:${t?`collapsed`:`default`}`,i=p!==null&&ze.current!==p,a=Re.current!==r||i;Re.current=r,ze.current=p,V(r=>{if(a){let n=t?0:Ji(e.length);return new Set(e.slice(0,n))}let i=!1,o=new Set;for(let e of r){if(!n.has(e)){i=!0;continue}o.add(e)}return i?o:r}),U(e=>{if(a)return new Set;let t=!1,r=new Set;for(let i of e){if(!n.has(i)){t=!0;continue}r.add(i)}return t?r:e})},[q,ot,S,t,p]);let dt=Q.useCallback(()=>{Le.current=null;let e=Me.current;if(!e)return;let t=e.getBoundingClientRect(),n=t.top-Gi,r=t.bottom+Gi,i={};for(let[e,t]of Ne.current){if(!t||!B.has(e))continue;let a=t.getBoundingClientRect();a.bottom<n||a.top>r||(i[e]=!0)}U(e=>{let t=!1,n=new Set(e);for(let e of Object.keys(i))n.has(e)||(n.add(e),t=!0);return t?n:e})},[B]),ft=Q.useCallback(()=>{typeof window>`u`||Le.current===null&&(Le.current=window.requestAnimationFrame(dt))},[dt]);Q.useEffect(()=>{let e=Me.current;if(e)return ft(),e.addEventListener(`scroll`,ft,{passive:!0}),window.addEventListener(`resize`,ft),()=>{e.removeEventListener(`scroll`,ft),window.removeEventListener(`resize`,ft),Le.current!==null&&(window.cancelAnimationFrame(Le.current),Le.current=null)}},[nt,B,ft]);let pt=Q.useCallback(e=>{let t=ve[e.path];if(t)return t;if(_e===`inline`)return`inline`;if(_e===`side-by-side`)return`side-by-side`;let n=C<Hi;return e.isNew||n?`inline`:`side-by-side`},[ve,_e,C]),mt=Q.useMemo(()=>ut.length===0?null:ut.every(e=>pt(e)===`side-by-side`)?`side-by-side`:`inline`,[pt,ut]);Q.useEffect(()=>{S&&(k(S),A(S,y))},[S,k,A,y]),Q.useEffect(()=>{if(S)return le.onGitRefreshHint(e=>{ia(e.directory)===ia(S)&&j(S,y)})},[S,j,y]),Q.useEffect(()=>{q!==`all`&&!pe||de&&(pe&&ue(pe),P(de),I(pe===`staged`||!pe&&fe),L(me),he(null),Ie.current=!0,Pe.current=de,He(de),G(e=>e+1))},[q,He,de,me,pe,fe,he]),Q.useEffect(()=>{if(q===`all`)return;let e=d?.trim();e&&(P(e),I(q===`staged`),L(f),Ie.current=!0,Pe.current=e,He(e),G(e=>e+1))},[q,He,_,d,f]),Q.useEffect(()=>{N&&(nt.some(e=>e.path===N)||(P(null),I(!1)))},[nt,N]);let ht=Q.useCallback((e,t)=>{let n=Ne.current;t?n.set(e,t):n.delete(e),ft()},[ft]),gt=Q.useCallback((e,t)=>{Be(),V(n=>{if(t===n.has(e))return n;let r=new Set(n);return t?r.add(e):r.delete(e),r}),t||U(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),ft()},[Be,ft]),_t=Q.useCallback(()=>{Be(),V(e=>e.size>0?new Set:new Set(nt.map(e=>e.path))),U(new Set),ft()},[Be,nt,ft]),vt=Q.useCallback(async e=>{if(!Ce)return;let t=K.getState().getDirectoryForSession(Ce)||S||``;if(!t){J.error(v(`diffView.reviewDialog.toast.noSessionDirectory`));return}ce(!0);try{await te({originalSessionID:Ce,directory:t,providerID:e.providerID,modelID:e.modelID,agent:e.agent||void 0,variant:e.variant||void 0,generateHandoff:e.generateHandoff,returnAfterHandoffRequest:e.generateHandoff,autoReview:e.autoReview}),oe(!1)}catch(e){console.error(`[review-flow] failed to start review flow`,e),J.error(e instanceof Error?e.message:v(`diffView.reviewDialog.toast.startFailed`))}finally{ce(!1)}},[Ce,S,v]),yt=Q.useCallback(e=>{let t=Ne.current.get(e),n=Me.current;if(!t||!n)return!1;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect().top-r.top,a=Math.max(0,n.scrollHeight-n.clientHeight);return n.scrollTop=Math.min(a,Math.max(0,n.scrollTop+i)),!0},[]);Q.useEffect(()=>{if(!Pe.current)return;let e=0,t=!1,r=()=>{t||(t=!0,Pe.current=null,Ie.current=!1,z(null),Fe.current!==null&&(window.cancelAnimationFrame(Fe.current),Fe.current=null))},i=()=>{if(t){Fe.current=null;return}let a=Pe.current;if(!a){r(),Fe.current=null;return}if(!yt(a)){e+=1,e<20?Fe.current=window.requestAnimationFrame(i):(r(),Fe.current=null);return}n&&Ie.current&&z(a),r()};return Fe.current=window.requestAnimationFrame(i),()=>{t=!0,Fe.current!==null&&(window.cancelAnimationFrame(Fe.current),Fe.current=null)}},[n,ie,yt]);let bt=Q.useCallback(e=>{},[]),xt=Q.useCallback(e=>{Be(),P(e),I(!1),Ie.current=!0,Pe.current=e,He(e),G(e=>e+1),yt(e)},[Be,He,yt]),St=Q.useCallback(e=>{let t=e===`side-by-side`?`side-by-side`:`inline`;ut.forEach(e=>{ye(e.path,t)})},[ye,ut]),[Ct,wt]=Q.useState(null),Tt=Q.useCallback(async(e,t)=>{if(!(!S||!e)){wt(e);try{let n=null;if(t?.patch&&!t.isBinary&&!an(e)?n=Li(t.patch):t&&t.contextMode===`full`&&!t.isBinary&&!an(e)&&(n=aa(t.original,t.modified)),n===null)try{n=Li((await y.getGitDiff(S,{path:e,staged:Oe,contextLines:3})).diff)}catch{n=null}let r=t;if(n===null||!r){let t=await y.getGitFileDiff(S,{path:e,staged:Oe});r={original:t.original??``,modified:t.modified??``,isBinary:t.isBinary},Oe||M(S,e,r)}let i=n??(r.isBinary||an(e)?1:aa(r.original,r.modified)),a=ra(S,e),o=await Di(b,a);if(!o.ok){J.error(Oi(o.reason));return}Se(S,a,i,1)}finally{wt(t=>t===e?null:t)}}},[Oe,S,b,y,Se,M]),Et=()=>{if(!S)return null;let e=e=>De===null?F&&e===N:De;return(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-1 min-h-0 h-full`,m?`gap-0`:`gap-3 px-3 pb-3 pt-2`),children:[je&&(0,$.jsxs)(`section`,{className:`hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-border/40`,children:[(0,$.jsx)(`span`,{className:`typography-code font-semibold text-foreground`,children:v(`diffView.section.files`)}),(0,$.jsx)(`span`,{className:`typography-code text-muted-foreground`,children:nt.length})]}),(0,$.jsx)(fa,{changedFiles:nt,selectedFile:null,onSelectFile:xt})]}),(0,$.jsx)(`div`,{className:`relative flex-1 min-w-0 min-h-0 h-full`,children:(0,$.jsx)(Ve,{ref:Me,outerClassName:`min-h-0 h-full`,className:`[overflow-anchor:none] pb-16 pwa-overlay-scroll`,disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:(0,$.jsx)(`div`,{className:`flex flex-col [overflow-anchor:none]`,"data-diff-virtual-content":!0,children:ut.map(t=>(0,$.jsx)(_a,{directory:S,file:t,layout:pt(t),wrapLines:Ee,isSelected:!1,isExpanded:B.has(t.path),isMounted:H.has(t.path)||t.path===R,onSelect:bt,onExpandedChange:gt,registerSectionRef:ht,showOpenInEditorAction:r&&q!==`turn`,isOpeningInEditor:Ct===t.path,onOpenInEditor:(e,t)=>{Tt(e,t)},staged:e(t.path),loadFullFiles:W,initialDiffData:q===`turn`?tt.get(t.path)??null:null,focusLine:t.path===(d?.trim()||N)?f??ne:null,showFileActions:q!==`turn`,disableGitFetch:q===`turn`},t.path))})})})]})};return(0,$.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden bg-background`,children:[h?null:(0,$.jsxs)(`div`,{className:`@container/diff-toolbar flex min-w-0 items-center gap-1.5 px-2 py-1.5 bg-background`,children:[!T&&(q===`working`||q===`staged`||q===`turn`?(0,$.jsx)(da,{scope:q,workingCount:rt,stagedCount:it,turnCount:at,onScopeChange:e=>{ue(e),u?.(e)}}):(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0`,children:(0,$.jsx)(`span`,{className:`typography-code font-semibold text-foreground`,children:O&&!D?v(`diffView.state.loadingChanges`):ut.length===1?v(`diffView.summary.changedFilesSingle`,{count:ut.length}):v(`diffView.summary.changedFilesPlural`,{count:ut.length})})})),!h&&nt.length>0&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:_t,className:Y(`diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground`,`ml-auto`),title:B.size>0?v(`diffView.actions.collapseAll`):v(`diffView.actions.expandAll`),children:[(0,$.jsx)(X,{name:`expand-up-down`,className:`size-4`}),(0,$.jsx)(`span`,{className:`diff-toolbar__expand-label typography-code`,children:B.size>0?v(`diffView.actions.collapseAll`):v(`diffView.actions.expandAll`)})]}),nt.length>0&&Ae&&(0,$.jsxs)(Z,{variant:`default`,size:`sm`,onClick:()=>oe(!0),disabled:se,className:`diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2`,"aria-label":v(`diffView.actions.reviewAria`),children:[se?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`search-eye`,className:`size-4`}),(0,$.jsx)(`span`,{className:`diff-toolbar__review-label typography-code`,children:v(`diffView.actions.review`)})]}),nt.length>0&&(0,$.jsxs)(lt,{children:[(0,$.jsx)(st,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:()=>re(e=>!e),"aria-pressed":W,"aria-label":v(W?`diffView.actions.disableFullFiles`:`diffView.actions.loadFullFiles`),className:Y(`h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground`,W&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(X,{name:`file-download`,className:`size-4`})})}),(0,$.jsx)(ct,{children:(0,$.jsx)(`p`,{children:v(W?`diffView.actions.disableFullFiles`:`diffView.actions.loadFullFiles`)})})]}),nt.length>0&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,onClick:()=>xe(!be),className:Y(`h-5 w-5 p-0 transition-opacity`,Ee?`text-foreground opacity-100`:`text-muted-foreground opacity-60 hover:opacity-100`),title:v(Ee?`diffView.actions.disableLineWrap`:`diffView.actions.enableLineWrap`),children:(0,$.jsx)(X,{name:`text-wrap`,className:`size-4`})}),mt&&(0,$.jsx)(_n,{mode:mt===`side-by-side`?`side-by-side`:`unified`,onModeChange:St})]}),(0,$.jsx)(Rt,{open:ae,onOpenChange:oe,projectDirectory:S??null,submitting:se,onConfirm:vt}),(()=>{if(!S)return(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:v(`diffView.state.selectSessionDirectory`)});if(q!==`turn`&&O&&!D)return(0,$.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),v(`diffView.state.loadingRepositoryStatus`)]});if(q!==`turn`&&E===!1)return(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:v(`diffView.state.notGitRepository`)});if(ut.length===0)return(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:v(q===`turn`?`diffView.state.noLastTurnChanges`:`diffView.state.cleanWorkingTree`)});let e=q===`turn`&&!Ke&&Bi(Ue),t=!e||qe!==null;return q===`turn`&&e&&Ye&&!t?(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 px-4 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-foreground`,children:v(`diffView.state.failedToLoadDiff`)}),(0,$.jsx)(`div`,{className:`typography-meta max-w-[32rem] text-center text-muted-foreground`,children:Ye}),(0,$.jsx)(`button`,{type:`button`,className:`typography-ui-label text-primary hover:underline`,onClick:()=>Qe(e=>e+1),children:v(`diffView.actions.retry`)}),(0,$.jsx)(`div`,{className:`mt-4 w-full max-w-md space-y-1`,children:nt.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md px-2 py-1 typography-code`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:e.path}),ua(e.insertions,e.deletions)]},e.path))})]}):q===`turn`&&e&&!t?(0,$.jsxs)(`div`,{className:`flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),v(`diffView.state.loadingDiff`)]}):Et()})()]})},ya=y()(b(e=>({expandedWorktreeGroups:{},setWorktreeGroupExpanded:(t,n)=>e(e=>({expandedWorktreeGroups:{...e.expandedWorktreeGroups,[t]:n}}))}),{name:`mobile-session-statusbar-collapse`,storage:p()}));typeof window<`u`&&a(e=>{t(e)&&ya.persist.rehydrate()});var ba=e=>{let t=(0,Qn.c)(24),{size:n,className:r}=e,i=n===void 0?14:n,a=(i-1.5)/2,o=2*Math.PI*a,s=o*.28,c;t[0]===r?c=t[1]:(c=Y(`inline-flex items-center justify-center shrink-0`,r),t[0]=r,t[1]=c);let l;t[2]===i?l=t[3]:(l={width:i,height:i},t[2]=i,t[3]=l);let u=`0 0 ${i} ${i}`,d;t[4]===i?d=t[5]:(d={width:i,height:i},t[4]=i,t[5]=d);let f=i/2,p=i/2,m;t[6]!==a||t[7]!==f||t[8]!==p?(m=(0,$.jsx)(`circle`,{cx:f,cy:p,r:a,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:1.5}),t[6]=a,t[7]=f,t[8]=p,t[9]=m):m=t[9];let h=i/2,g=i/2,_=`${s} ${o-s}`,v;t[10]!==a||t[11]!==g||t[12]!==_||t[13]!==h?(v=(0,$.jsx)(`circle`,{cx:h,cy:g,r:a,fill:`none`,stroke:`var(--surface-muted-foreground)`,strokeWidth:1.5,strokeLinecap:`round`,strokeDasharray:_}),t[10]=a,t[11]=g,t[12]=_,t[13]=h,t[14]=v):v=t[14];let y;t[15]!==v||t[16]!==u||t[17]!==d||t[18]!==m?(y=(0,$.jsxs)(`svg`,{viewBox:u,className:`animate-spin`,style:d,"aria-hidden":`true`,children:[m,v]}),t[15]=v,t[16]=u,t[17]=d,t[18]=m,t[19]=y):y=t[19];let b;return t[20]!==y||t[21]!==c||t[22]!==l?(b=(0,$.jsx)(`span`,{className:c,style:l,"aria-hidden":`true`,children:y}),t[20]=y,t[21]=c,t[22]=l,t[23]=b):b=t[23],b};ba.displayName=`SessionBusyIndicator`;function xa(e){let t=(0,Qn.c)(34),{durationMs:n,size:r,className:i}=e,a=r===void 0?15:r,o=(a-1.5)/2,s=2*Math.PI*o,[c,l]=Q.useState(!1),u;t[0]===n?u=t[1]:(u=()=>Math.max(0,Math.ceil(n/1e3)-1),t[0]=n,t[1]=u);let[d,f]=Q.useState(u),p,m;t[2]===n?(p=t[3],m=t[4]):(p=()=>{let e=performance.now(),t=window.requestAnimationFrame(()=>l(!0)),r=window.setInterval(()=>{let t=performance.now()-e;f(Math.max(0,Math.ceil((n-t)/1e3)-1))},250);return()=>{window.cancelAnimationFrame(t),window.clearInterval(r)}},m=[n],t[2]=n,t[3]=p,t[4]=m),Q.useEffect(p,m);let h;t[5]===i?h=t[6]:(h=Y(`relative inline-flex shrink-0 items-center justify-center`,i),t[5]=i,t[6]=h);let g;t[7]===a?g=t[8]:(g={width:a,height:a},t[7]=a,t[8]=g);let _=`0 0 ${a} ${a}`,v=a/2,y=a/2,b;t[9]!==o||t[10]!==v||t[11]!==y?(b=(0,$.jsx)(`circle`,{cx:v,cy:y,r:o,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:1.5}),t[9]=o,t[10]=v,t[11]=y,t[12]=b):b=t[12];let x=a/2,S=a/2,C=c?s:0,w=`stroke-dashoffset ${n}ms linear`,T;t[13]===w?T=t[14]:(T={transition:w},t[13]=w,t[14]=T);let E;t[15]!==s||t[16]!==o||t[17]!==x||t[18]!==S||t[19]!==C||t[20]!==T?(E=(0,$.jsx)(`circle`,{cx:x,cy:S,r:o,fill:`none`,stroke:`var(--primary-base)`,strokeWidth:1.5,strokeLinecap:`round`,strokeDasharray:s,strokeDashoffset:C,style:T}),t[15]=s,t[16]=o,t[17]=x,t[18]=S,t[19]=C,t[20]=T,t[21]=E):E=t[21];let D;t[22]!==a||t[23]!==b||t[24]!==E||t[25]!==_?(D=(0,$.jsxs)(`svg`,{viewBox:_,width:a,height:a,className:`-rotate-90`,children:[b,E]}),t[22]=a,t[23]=b,t[24]=E,t[25]=_,t[26]=D):D=t[26];let O;t[27]===d?O=t[28]:(O=(0,$.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center !text-[8px] !leading-none font-semibold tabular-nums text-current`,children:d}),t[27]=d,t[28]=O);let k;return t[29]!==D||t[30]!==O||t[31]!==h||t[32]!==g?(k=(0,$.jsxs)(`span`,{className:h,style:g,"aria-hidden":`true`,children:[D,O]}),t[29]=D,t[30]=O,t[31]=h,t[32]=g,t[33]=k):k=t[33],k}function Sa(){s.getState().setArchivedSessionsDialogOpen(!0)}function Ca(e){J.custom(t=>Q.createElement(`div`,{className:`flex w-full min-w-0 max-w-full items-center gap-2.5 text-foreground`},Q.createElement(`span`,{className:`min-w-0 flex-1 truncate text-left typography-ui-label font-medium`},e.message),Q.createElement(`div`,{className:`flex shrink-0 items-center gap-1.5`},e.secondaryLabel&&e.onSecondary?Q.createElement(Z,{variant:`secondary`,size:`sm`,className:`session-mutation-undo-action !h-[26px] !min-h-0 !min-w-0 shrink-0 !px-2 !text-[12px]`,onClick:()=>{e.onSecondary?.(),J.dismiss(t)}},e.secondaryLabel):null,Q.createElement(Z,{variant:`default`,size:`sm`,className:`session-mutation-undo-action !h-[26px] !min-h-0 !min-w-0 shrink-0 gap-1 !pl-2 !pr-1 !text-[12px]`,onClick:()=>{e.onPrimary(),J.dismiss(t)}},e.primaryLabel,Q.createElement(xa,{durationMs:e.durationMs})))),{duration:e.durationMs,className:`session-mutation-undo-toast !max-w-[calc(100vw-2rem)]`})}function wa(e){let t=Array.from(new Set(e.sessionIds.filter(Boolean)));t.length!==0&&Ca({durationMs:P,message:e.message,primaryLabel:e.undoLabel,onPrimary:()=>{(async()=>{(await Promise.all(t.map(e=>R(e)))).some(e=>!e)&&J.error(e.undoFailedMessage)})()},secondaryLabel:e.settingsLabel,onSecondary:()=>{Sa()}})}function Ta(e){let t=Array.from(new Set(e.sessionIds.filter(Boolean)));if(t.length===0)return{batchId:``,scheduledIds:[]};let n=e.delayMs??1e4,{batchId:r,scheduledIds:i}=ne(t,{delayMs:n,onSettled:({failedIds:t})=>{t.length>0&&J.error(e.commitFailedMessage)}});return r&&Ca({durationMs:n,message:e.message,primaryLabel:e.undoLabel,onPrimary:()=>{U(r)}}),{batchId:r,scheduledIds:i}}var Ea=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/,``),Da=e=>{let t=e;return Ea(t.directory??t.project?.worktree??null)},Oa=({open:e,project:t,worktree:n,onClose:r,onDeleted:i})=>{let{t:a}=ee(),o=W(),s=be(e=>e.activeSessions),c=K(e=>e.archiveSessions),l=T(e=>e.currentDirectory),[u,d]=Q.useState(!1),[f,p]=Q.useState(!1),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),v=Ea(n?.path),y=typeof n?.branch==`string`&&n.branch.trim().length>0,b=Q.useMemo(()=>{if(!v)return[];let e=new Map;for(let t of[...s,...o])Da(t)===v&&e.set(t.id,t);return Array.from(e.values())},[s,o,v]);Q.useEffect(()=>{if(!e){d(!1),p(!1),h(!1),_(!1);return}if(!n?.path)return;let t=!1;return Ze(n.path).then(e=>{t||h(!!e?.isDirty)}).catch(()=>{t||h(!!n.status?.isDirty)}),()=>{t=!0}},[e,n?.path,n?.status?.isDirty]);let x=j(e=>{(async()=>{try{await rt(e.project,e.worktree,{deleteRemoteBranch:e.hasBranch&&e.deleteRemoteBranch,deleteLocalBranch:e.hasBranch&&e.deleteLocalBranch}),Ea(e.currentDirectory)===e.worktreePath&&Ea(e.project.path)&&T.getState().setDirectory(Ea(e.project.path),{showOverlay:!1}),J.success(e.t(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:e.hasBranch&&e.deleteRemoteBranch?e.t(`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`):e.t(`sessions.sidebar.sessionDialogs.worktree.removed`)}),e.onDeleted?.()}catch(t){J.error(e.t(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:t instanceof Error?t.message:e.t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}})()}),S=async()=>{if(!n||g)return;let o={worktree:n,project:t,hasBranch:y,deleteLocalBranch:u,deleteRemoteBranch:f,currentDirectory:l,worktreePath:v,onDeleted:i,archiveSessions:c,linkedSessionIds:b.map(e=>e.id),onClose:r,open:e,t:a};_(!0);try{if(o.linkedSessionIds.length>0){let{archivedIds:e,failedIds:t}=await o.archiveSessions(o.linkedSessionIds);if(t.length>0){e.length>0&&J.success(e.length===1?o.t(`sessions.sidebar.bulkActions.archivedSingle`,{count:e.length}):o.t(`sessions.sidebar.bulkActions.archivedPlural`,{count:e.length})),J.error(t.length===1?o.t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:t.length}):o.t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:t.length}),{description:o.t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)}),_(!1);return}}x(o),o.onClose()}catch(e){J.error(o.t(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:e instanceof Error?e.message:o.t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)}),_(!1)}finally{o.open||_(!1)}};if(!n)return null;let C=n.branch||n.label||n.path,w=(e,t,n,r)=>(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e,disabled:r,onClick:()=>t(!e),className:Y(`flex w-full items-center justify-between gap-3 rounded-xl border border-border/50 px-3.5 py-3 text-left transition-colors`,`hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,r&&`pointer-events-none opacity-40`),style:{touchAction:`manipulation`},children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n}),(0,$.jsx)(`span`,{className:Y(`relative h-6 w-10 shrink-0 rounded-full transition-colors`,e?`bg-primary`:`bg-muted-foreground/30`),children:(0,$.jsx)(`span`,{className:Y(`absolute top-0.5 size-5 rounded-full bg-white transition-transform`,e?`translate-x-[1.125rem]`:`translate-x-0.5`)})})]});return(0,$.jsx)(Ht,{open:e,onClose:r,title:a(`mobile.projectEdit.deleteWorktreeTitle`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{variant:`ghost`,className:`flex-1`,onClick:r,disabled:g,children:a(`projectEditDialog.actions.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,className:`flex-1`,onClick:()=>void S(),disabled:g,children:a(`mobile.projectEdit.deleteWorktreeConfirmButton`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-1 py-1`,children:[(0,$.jsx)(`p`,{className:`typography-ui-body text-foreground`,children:a(`mobile.projectEdit.deleteWorktreeConfirm`,{name:C})}),m?(0,$.jsx)(`p`,{className:`rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground`,children:a(`mobile.projectEdit.deleteWorktreeDirty`)}):null,b.length>0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a(`mobile.projectEdit.deleteWorktreeArchiveNote`,{count:b.length})}):null,y?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[w(u,d,a(`mobile.projectEdit.deleteLocalBranch`),g),w(f,p,a(`mobile.projectEdit.deleteRemoteBranch`),g)]}):null]})})},ka=`mobile-surface-root`,Aa=90,ja=16,Ma=100,Na=48,Pa=8,Fa=()=>{if(typeof document>`u`)return null;let e=document.getElementById(ka);return e||(e=document.createElement(`div`),e.id=ka,document.body.appendChild(e)),e},Ia=({open:e,onClose:t,title:n,subtitle:r,trailing:i,onBack:a,disableSwipeDismiss:o=!1,headerless:s=!1,ariaLabel:c,children:l})=>{let{t:u}=ee(),d=Q.useRef(null),[f,p]=Q.useState(!1),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),[v,y]=Q.useState(0),b=Q.useRef(null),x=Q.useRef(!1),S=Q.useRef(null),C=Q.useRef(null),w=Q.useRef(t);Q.useEffect(()=>{w.current=t},[t]),typeof document<`u`&&!d.current&&(d.current=Fa()),Q.useEffect(()=>{if(e){p(!0);let e=window.setTimeout(()=>h(!0),ja);return()=>window.clearTimeout(e)}h(!1);let t=window.setTimeout(()=>p(!1),300);return()=>window.clearTimeout(t)},[e]),Q.useEffect(()=>{if(!e){_(!1);return}let t=window.setTimeout(()=>_(!0),196);return()=>window.clearTimeout(t)},[e]),Q.useEffect(()=>{if(!e)return;let t=document.body.style.overflow;C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow=`hidden`;let n=window.setTimeout(()=>{let e=S.current;e&&(e.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)??e).focus({preventScroll:!0})},ja),r=e=>{if(e.key===`Escape`){w.current();return}if(e.key!==`Tab`)return;let t=S.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`);if(n.length===0){e.preventDefault(),t.focus({preventScroll:!0});return}let r=n[0],i=n[n.length-1],a=document.activeElement;e.shiftKey&&a===r?(e.preventDefault(),i.focus({preventScroll:!0})):!e.shiftKey&&a===i&&(e.preventDefault(),r.focus({preventScroll:!0}))};return document.addEventListener(`keydown`,r),()=>{window.clearTimeout(n),document.body.style.overflow=t,document.removeEventListener(`keydown`,r),wt()||C.current?.focus?.({preventScroll:!0}),C.current=null}},[e]);let T=e=>{o||(b.current=e.touches[0]?.clientY??null,x.current=!0)},E=e=>{if(!x.current||b.current==null)return;let t=(e.touches[0]?.clientY??b.current)-b.current;y(t>0?t:0)},D=()=>{x.current&&(x.current=!1,b.current=null,v>=Aa?(y(0),t()):y(0))};if(!f||!d.current)return null;let O=a?(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":u(`header.actions.backAria`),onClick:a,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}):(0,$.jsx)(`button`,{type:`button`,className:`-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":u(`mobile.surface.closeAria`),onClick:t,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}),k=m?v>0?`translateY(${v}px)`:`none`:`translateY(${Na}px)`,A=n!=null||r!=null;return(0,$n.createPortal)((0,$.jsxs)(`div`,{className:Y(`oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-[rgb(0_0_0_/_0.45)]`,`transition-opacity duration-200 ease-out`,m?`opacity-100`:`opacity-0`),role:`dialog`,"aria-modal":`true`,"aria-label":c,onClick:t,children:[(0,$.jsxs)(`section`,{ref:S,className:`oc-mobile-surface-shell oc-mobile-floating-shell mt-auto flex min-h-0 w-full flex-col overflow-hidden rounded-t-[20px] border-t border-border/40 bg-background text-foreground`,tabIndex:-1,onClick:e=>e.stopPropagation(),onTransitionEnd:e=>{m&&e.target===e.currentTarget&&e.propertyName===`transform`&&_(!0)},style:{height:`calc(100% - var(--oc-safe-area-top, 0px) - ${Pa}px)`,transform:k,transition:x.current?`none`:`transform ${Ma}ms cubic-bezier(0.32, 0.72, 0, 1)`},children:[(0,$.jsxs)(`div`,{className:`shrink-0 select-none`,onTouchStart:T,onTouchMove:E,onTouchEnd:D,onTouchCancel:D,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-center pt-2 pb-1`,children:(0,$.jsx)(`span`,{className:`h-1 w-10 rounded-full bg-[var(--surface-muted)]`,"aria-hidden":!0})}),s?null:(0,$.jsxs)(`header`,{className:`flex h-[var(--oc-header-height,56px)] items-center gap-2 px-3`,children:[A?O:null,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 px-1`,children:[n?typeof n==`string`?(0,$.jsx)(`h2`,{className:`truncate typography-ui-label text-foreground`,children:n}):n:null,r?typeof r==`string`?(0,$.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:r}):r:null]}),i?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:i}):null,A?null:O]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:g?(0,$.jsx)(`div`,{className:`h-full`,style:{animation:`oc-surface-content-in 200ms ease-out`},children:l}):null})]}),(0,$.jsx)(`style`,{children:`@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }`})]}),d.current)},La=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/,``),Ra=e=>{let t=(0,Qn.c)(36),{worktree:n,onDelete:r}=e,{t:i}=ee(),a;t[0]===n.path?a=t[1]:(a={id:n.path},t[0]=n.path,t[1]=a);let{attributes:o,listeners:s,setNodeRef:c,transform:l,transition:u,isDragging:d}=tn(a),f;t[2]===l?f=t[3]:(f=$t.Transform.toString(l),t[2]=l,t[3]=f);let p=d?10:1,m;t[4]!==f||t[5]!==p||t[6]!==u?(m={transform:f,transition:u,zIndex:p},t[4]=f,t[5]=p,t[6]=u,t[7]=m):m=t[7];let h=m,g=n.branch||n.label||n.path,_=d&&`shadow-lg shadow-black/20`,v;t[8]===_?v=t[9]:(v=Y(`flex items-center gap-1 rounded-2xl border border-border/40 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors`,_),t[8]=_,t[9]=v);let y;t[10]!==g||t[11]!==i?(y=i(`mobile.projectEdit.dragWorktreeAria`,{label:g}),t[10]=g,t[11]=i,t[12]=y):y=t[12];let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(X,{name:`drag-move-2`,className:`size-4`}),t[13]=b):b=t[13];let x;t[14]!==o||t[15]!==s||t[16]!==y?(x=(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing`,"aria-label":y,...o,...s,children:b}),t[14]=o,t[15]=s,t[16]=y,t[17]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(X,{name:`node-tree`,className:`size-4 shrink-0 text-muted-foreground`}),t[18]=S):S=t[18];let C;t[19]===g?C=t[20]:(C=(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:g}),t[19]=g,t[20]=C);let w;t[21]!==g||t[22]!==i?(w=i(`mobile.projectEdit.deleteWorktreeAria`,{label:g}),t[21]=g,t[22]=i,t[23]=w):w=t[23];let T,E;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T={touchAction:`manipulation`},E=(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`}),t[24]=T,t[25]=E):(T=t[24],E=t[25]);let D;t[26]!==r||t[27]!==w?(D=(0,$.jsx)(`button`,{type:`button`,className:`flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`,"aria-label":w,onClick:r,style:T,children:E}),t[26]=r,t[27]=w,t[28]=D):D=t[28];let O;return t[29]!==c||t[30]!==h||t[31]!==C||t[32]!==D||t[33]!==v||t[34]!==x?(O=(0,$.jsxs)(`div`,{ref:c,style:h,className:v,children:[x,S,C,D]}),t[29]=c,t[30]=h,t[31]=C,t[32]=D,t[33]=v,t[34]=x,t[35]=O):O=t[35],O},za=({open:e,project:t,onClose:n,onWorktreesChanged:r})=>{let{t:i}=ee(),{currentTheme:a}=mt(),o=ue(e=>e.updateProjectMeta),s=ue(e=>e.discoverProjectIcon),c=ue(e=>e.removeProjectIcon),l=Be(e=>e.setWorktreeOrder),u=ue(e=>t?e.projects.find(e=>e.id===t.id)?.iconImage??null:null),[d,f]=Q.useState(``),[p,m]=Q.useState(null),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),[y,b]=Q.useState([]),[x,S]=Q.useState(null),C=t?.id??null;Q.useEffect(()=>{!e||!t||(f(t.label),m(t.icon??null),g(t.color??null),b(t.worktrees))},[e,C]),Q.useEffect(()=>{!e||!t||b(e=>{let n=t.worktrees.map(e=>e.path),r=e.map(e=>e.path);return n.length===r.length&&n.every(e=>r.includes(e))?e:t.worktrees})},[t?.worktrees]);let w=Qt(qt(Xt,{activationConstraint:{distance:8}}),qt(Jt,{coordinateGetter:en})),T=()=>{if(!t)return;let e=d.trim();o(t.id,{label:e||t.label,icon:p,color:h}),n()},E=()=>{!t||_||(v(!0),s(t.id).then(e=>{if(!e.ok){J.error(e.error||i(`projectEditDialog.toast.failedToDiscoverIcon`));return}if(e.skipped){J.success(i(`projectEditDialog.toast.customIconAlreadySet`));return}J.success(i(`projectEditDialog.toast.iconDiscovered`))}).finally(()=>v(!1)))},D=()=>{t&&c(t.id).then(e=>{if(!e.ok){J.error(e.error||i(`projectEditDialog.toast.failedToRemoveIcon`));return}J.success(i(`projectEditDialog.toast.iconRemoved`))})},O=e=>{let{active:n,over:r}=e;if(!r||n.id===r.id||!t)return;let i=y.findIndex(e=>e.path===n.id),a=y.findIndex(e=>e.path===r.id);if(i<0||a<0)return;let o=[...y],[s]=o.splice(i,1);o.splice(a,0,s),b(o),l(t.id,t.path,o.map(e=>La(e.path)))},k=h?Qe[h]??null:null,A=p?Ye[p]:null,j=!!u;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ia,{open:e,onClose:n,onBack:n,title:i(`projectEditDialog.title`),ariaLabel:i(`projectEditDialog.title`),trailing:(0,$.jsxs)(Z,{type:`button`,variant:`default`,size:`sm`,"aria-label":i(`projectEditDialog.actions.save`),onClick:T,disabled:!d.trim(),style:{touchAction:`manipulation`},children:[(0,$.jsx)(X,{name:`check`,className:`size-4`}),i(`projectEditDialog.actions.save`)]}),children:t?(0,$.jsxs)(`div`,{className:`h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2`,children:[(0,$.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,$.jsx)(`span`,{className:`flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground`,style:t.iconBackground?{backgroundColor:t.iconBackground}:void 0,children:j?(0,$.jsx)(We,{project:{id:t.id,iconImage:u},options:{themeVariant:a.metadata.variant,iconColor:a.colors.surface.foreground},className:`size-full object-contain`,fallback:(0,$.jsx)(X,{name:`folder-6`,className:`size-7`})}):A?(0,$.jsx)(X,{name:A,className:`size-7`,style:k?{color:k}:void 0}):(0,$.jsx)(X,{name:`folder-6`,className:`size-7`,style:k?{color:k}:void 0})})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`projectEditDialog.field.name`)}),(0,$.jsx)(ot,{value:d,onChange:e=>f(e.target.value),placeholder:i(`projectEditDialog.field.namePlaceholder`),className:`h-11`}),(0,$.jsx)(`p`,{className:`truncate typography-meta text-muted-foreground`,title:t.path,children:t.path})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`projectEditDialog.field.color`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(null),"aria-label":i(`projectEditDialog.option.none`),className:Y(`flex size-9 items-center justify-center rounded-xl border-2 transition-all`,h===null?`border-foreground`:`border-border hover:border-border/80`),style:{touchAction:`manipulation`},children:(0,$.jsx)(`span`,{className:`h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40`})}),nt.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(e.key),"aria-label":e.label,title:e.label,className:Y(`size-9 rounded-xl border-2 transition-all`,h===e.key?`border-foreground`:`border-transparent hover:border-border`),style:{backgroundColor:e.cssVar,touchAction:`manipulation`}},e.key))]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`projectEditDialog.field.icon`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(null),"aria-label":i(`projectEditDialog.option.none`),className:Y(`flex size-9 items-center justify-center rounded-xl border-2 transition-all`,p===null?`border-foreground bg-[var(--surface-elevated)]`:`border-border hover:border-border/80`),style:{touchAction:`manipulation`},children:(0,$.jsx)(`span`,{className:`h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40`})}),tt.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>m(e.key),"aria-label":e.label,title:e.label,className:Y(`flex size-9 items-center justify-center rounded-xl border-2 transition-all`,p===e.key?`border-foreground bg-[var(--surface-elevated)]`:`border-border hover:border-border/80`),style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:e.Icon,className:`size-4`,style:k?{color:k}:void 0})},e.key))]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,$.jsx)(Z,{size:`sm`,variant:`outline`,onClick:E,disabled:_,children:i(_?`projectEditDialog.actions.discovering`:`projectEditDialog.actions.discoverFavicon`)}),j?(0,$.jsx)(Z,{size:`sm`,variant:`outline`,onClick:D,children:i(`projectEditDialog.actions.removeProjectIcon`)}):null]})]}),t.isGitRepo?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:i(`mobile.projectEdit.worktreesTitle`)}),y.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`mobile.projectEdit.worktreesEmpty`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`mobile.projectEdit.reorderHint`)}),(0,$.jsx)(Zt,{sensors:w,collisionDetection:Yt,onDragEnd:O,children:(0,$.jsx)(rn,{items:y.map(e=>e.path),strategy:nn,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:y.map(e=>(0,$.jsx)(Ra,{worktree:e,onDelete:()=>S(e)},e.path))})})})]})]}):null]}):null}),t?(0,$.jsx)(Oa,{open:!!x,project:{id:t.id,path:t.path},worktree:x,onClose:()=>S(null),onDeleted:()=>{b(e=>e.filter(e=>e.path!==x?.path)),r?.()}}):null]})},Ba=()=>3,Va=()=>7,Ha=(e,t,n)=>{let r=new Map;for(let[n,i]of e)t.has(n)&&r.set(n,i);for(let e of n)e.status===`success`&&r.set(e.path,e.worktrees??[]);return Ke(r,e)?e:r},Ua=(e,t)=>{t&&e.push(t)},Wa=e=>{let t=[];return Ua(t,e.onRename?{id:`rename`,icon:`pencil-ai`,labelKey:`sessions.sidebar.session.menu.rename`,onClick:e.onRename}:null),Ua(t,e.onTogglePin?{id:`pin`,icon:e.pinned?`unpin`:`pushpin`,labelKey:e.pinned?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`,onClick:e.onTogglePin}:null),e.shared?(Ua(t,e.onCopyLink?{id:`copyLink`,icon:`file-copy`,labelKey:`sessions.sidebar.session.menu.copyLink`,onClick:e.onCopyLink}:null),Ua(t,e.onUnshare?{id:`unshare`,icon:`link-unlink-m`,labelKey:`sessions.sidebar.session.menu.unshare`,onClick:e.onUnshare}:null)):Ua(t,e.onShare?{id:`share`,icon:`share-2`,labelKey:`sessions.sidebar.session.menu.share`,onClick:e.onShare}:null),Ua(t,e.onRefreshTranscript?{id:`refreshTranscript`,icon:`refresh`,labelKey:`sessions.sidebar.session.menu.refreshTranscript`,onClick:e.onRefreshTranscript,disabled:e.refreshTranscriptDisabled,spinning:e.refreshTranscriptSpinning}:null),Ua(t,e.onArchive?{id:`archive`,icon:`archive`,labelKey:`sessions.sidebar.bulkActions.archive`,onClick:e.onArchive}:null),Ua(t,e.onDelete?{id:`delete`,icon:`delete-bin`,labelKey:`sessions.sidebar.bulkActions.delete`,onClick:e.onDelete,destructive:!0,separated:!0}:null),e.extraItems?.length&&t.push(...e.extraItems),t},Ga=e=>{let t=[];return Ua(t,e.onNewSession?{id:`newSession`,icon:`add`,labelKey:`sessions.sidebar.project.actions.newSession`,onClick:e.onNewSession}:null),Ua(t,e.gitRepository&&e.onNewWorktree?{id:`newWorktree`,icon:`node-tree`,labelKey:`sessions.sidebar.project.actions.newWorktree`,onClick:e.onNewWorktree}:null),Ua(t,e.onSyncSessions?{id:`syncSessions`,icon:`refresh`,labelKey:`sessions.sidebar.project.actions.syncSessions`,onClick:e.onSyncSessions}:null),Ua(t,e.onEditProject?{id:`edit`,icon:`pencil-ai`,labelKey:`sessions.sidebar.project.actions.edit`,onClick:e.onEditProject}:null),Ua(t,e.onCloseProject?{id:`closeProject`,icon:`close`,labelKey:`sessions.sidebar.project.actions.closeProject`,onClick:e.onCloseProject,destructive:!0,separated:!0}:null),e.extraItems?.length&&t.push(...e.extraItems),t},Ka=e=>{let t=[];return Ua(t,e.onNewSession?{id:`newSession`,icon:`add`,labelKey:`sessions.sidebar.project.actions.newSession`,onClick:e.onNewSession}:null),Ua(t,e.onDeleteWorktree?{id:`deleteWorktree`,icon:`delete-bin`,labelKey:`mobile.projectEdit.deleteWorktreeConfirmButton`,onClick:e.onDeleteWorktree,destructive:!0,separated:!0}:null),e.extraItems?.length&&t.push(...e.extraItems),t},qa=(e,t)=>t(e.labelKey);function Ja(){let e=(0,Qn.c)(3),t=W(),n=be(Za),r;if(e[0]!==n||e[1]!==t){let i=new Map(t.map(Xa));r=n.map(e=>{let t=i.get(e.id);return t?pe(t,e):e});let a=new Set(r.map(Ya));for(let e of t)a.has(e.id)||r.push(e);e[0]=n,e[1]=t,e[2]=r}else r=e[2];return r}function Ya(e){return e.id}function Xa(e){return[e.id,e]}function Za(e){return e.activeSessions}var Qa=`__pinned_sessions__`,$a=3,eo=7,to=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},no=e=>{let t=e;return to(t.directory??t.project?.worktree??``)},ro=e=>{let t=new Set(e.map(e=>e.id));return e.filter(e=>{let n=e.parentID;return!n||!t.has(n)}).length};function io(e){e.preventBaseUIHandler()}function ao(e,t,n){t&&(e.preventBaseUIHandler(),n(e))}function oo(e){let t=(0,Qn.c)(10),{icon:n,label:r,onClick:i,destructive:a}=e,o=a!==void 0&&a?`destructive`:`ghost`,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={touchAction:`manipulation`},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(X,{name:n,className:`size-5 shrink-0`}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`truncate`,children:r}),t[3]=r,t[4]=l);let u;return t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==l?(u=(0,$.jsxs)(Z,{type:`button`,variant:o,size:`default`,className:`min-h-12 w-full justify-start gap-3 rounded-xl px-3`,onClick:i,style:s,children:[c,l]}),t[5]=i,t[6]=o,t[7]=c,t[8]=l,t[9]=u):u=t[9],u}function so(e,t){let n=(0,Qn.c)(32),r=H(mo),i;if(n[0]!==e){i=new Map;let t=new Set(e.map(po));e.forEach(e=>{let n=e.parentID;n&&t.has(n)&&i.set(n,[...i.get(n)||[],e])}),n[0]=e,n[1]=i}else i=n[1];let a=i,o;n[2]===t?o=n[3]:(o=e=>{let n=t?.[e];return n?.type===`busy`||n?.type===`retry`?n.type:`idle`},n[2]=t,n[3]=o);let s=o,c;n[4]!==s||n[5]!==a?(c=e=>(a.get(e)||[]).some(e=>s(e.id)!==`idle`),n[4]=s,n[5]=a,n[6]=c):c=n[6];let l=c,u;n[7]!==s||n[8]!==a?(u=e=>(a.get(e)||[]).filter(e=>s(e.id)!==`idle`).length,n[7]=s,n[8]=a,n[9]=u):u=n[9];let d=u,f;n[10]!==s||n[11]!==a?(f=e=>(a.get(e)||[]).filter(e=>s(e.id)!==`idle`).map(fo).slice(0,3),n[10]=s,n[11]=a,n[12]=f):f=n[12];let p=f,m;n[13]===e?m=n[14]:(m=new Set(e.map(uo)),n[13]=e,n[14]=m);let h=m,g;if(n[15]!==p||n[16]!==d||n[17]!==s||n[18]!==l||n[19]!==h||n[20]!==e||n[21]!==r){let t=e.filter(e=>{let t=e.parentID;return!t||!h.has(t)}),i=[],a=[];t.forEach(e=>{let t=s(e.id),n=l(e.id),o=(r[e.id]??0)>0,c={...e,_statusType:t,_hasRunningChildren:n,_runningChildrenCount:d(e.id),_childIndicators:p(e.id)};t!==`idle`||n||o?i.push(c):a.push(c)});let o=lo;i.sort(o),a.sort(o),g=[...i,...a],n[15]=p,n[16]=d,n[17]=s,n[18]=l,n[19]=h,n[20]=e,n[21]=r,n[22]=g}else g=n[22];let _=g,v;n[23]===_?v=n[24]:(v=_.reduce(co,0),n[23]=_,n[24]=v);let y=v,b;n[25]!==_||n[26]!==r?(b=_.filter(e=>(r[e.id]??0)>0),n[25]=_,n[26]=r,n[27]=b):b=n[27];let x=b.length,S;return n[28]!==_||n[29]!==y||n[30]!==x?(S={sessions:_,totalRunning:y,totalUnread:x,totalCount:_.length},n[28]=_,n[29]=y,n[30]=x,n[31]=S):S=n[31],S}function co(e,t){return e+(t._statusType===`idle`?0:1)+(t._runningChildrenCount??0)}function lo(e,t){return oe(t)-oe(e)}function uo(e){return e.id}function fo(e){return{session:e,isRunning:!0}}function po(e){return e.id}function mo(e){return e.index.session.unseenCount}function ho(){let e=(0,Qn.c)(7),{t}=ee(),n;e[0]===t?n=e[1]:(n=e=>{let n=e.title;return n&&n.trim()?n:t(`mobile.sessions.newChat`)},e[0]=t,e[1]=n);let r=n,i=H(go),a;e[2]===i?a=e[3]:(a=e=>(i[e]??0)>0,e[2]=i,e[3]=a);let o=a,s;return e[4]!==r||e[5]!==o?(s={getSessionTitle:r,needsAttention:o},e[4]=r,e[5]=o,e[6]=s):s=e[6],s}function go(e){return e.index.session.unseenCount}function _o(e,t,n){let r=(0,Qn.c)(6),i=K(bo),a=K(yo),o=H(vo),s;return r[0]!==i||r[1]!==n||r[2]!==a||r[3]!==o||r[4]!==t?(s=e=>{let r=e=>{let n=t?.[e];return n?.type===`busy`||n?.type===`retry`?n.type:`idle`},s=to(e);if(!s)return{hasRunning:!1,hasUnread:!1};let c=[s],l=i.get(s)??[];for(let e of l){let t=e&&typeof e==`object`&&`path`in e?e.path:null;if(typeof t==`string`&&t.trim()){let e=to(t);e&&e!==s&&c.push(e)}}let u=new Set,d=!1,f=!1;for(let e of c){for(let t of a(e))if(!(!t?.id||u.has(t.id))&&(u.add(t.id),r(t.id)!==`idle`&&(d=!0),t.id!==n&&(o[t.id]??0)>0&&(f=!0),d&&f))break;if(d&&f)break}return{hasRunning:d,hasUnread:f}},r[0]=i,r[1]=n,r[2]=a,r[3]=o,r[4]=t,r[5]=s):s=r[5],s}function vo(e){return e.index.session.unseenCount}function yo(e){return e.getSessionsByDirectory}function bo(e){return e.availableWorktreesByProject}function xo(){let e=(0,Qn.c)(2),t=K(So),n;return e[0]===t?n=e[1]:(n=e=>{let n=to(e.path),r=[n],i=t.get(n)??[];for(let e of i){let t=e&&typeof e==`object`&&`path`in e?e.path:null;if(typeof t==`string`&&t.trim()){let e=to(t);e&&r.push(e)}}return r},e[0]=t,e[1]=n),n}function So(e){return e.availableWorktreesByProject}function Co(e){let t=(0,Qn.c)(2),{isRunning:n,showUnread:r}=e;if(n){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ba,{}),t[0]=e):e=t[0],e}if(r){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`}),t[1]=e):e=t[1],e}return null}function wo(e){let t=(0,Qn.c)(3),{count:n}=e;if(n===0)return null;let r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(ba,{}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[13px] text-[var(--surface-mutedForeground)]`,children:[r,n]}),t[1]=n,t[2]=i),i}function To(e){let t=(0,Qn.c)(3),{count:n}=e;if(n===0)return null;let r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[13px] text-[var(--status-info)]`,children:[r,n]}),t[1]=n,t[2]=i),i}var Eo=()=>{if(typeof window>`u`)return;let e=window.getSelection();e?.rangeCount&&e.removeAllRanges()},Do={touchAction:`manipulation`,userSelect:`none`,WebkitUserSelect:`none`,WebkitTouchCallout:`none`};function Oo(e){let t=(0,Qn.c)(72),{session:n,isCurrent:r,isPinned:i,contextLabel:a,getSessionTitle:o,onClick:s,onRename:c,onTogglePinned:l,onShare:u,onCopyShareUrl:d,onUnshare:f,onArchive:p,onDelete:m,needsAttention:h,longPressHandlers:g}=e,{t:_}=ee(),[v,y]=Q.useState(!1),b;t[0]!==h||t[1]!==n.id?(b=h(n.id),t[0]=h,t[1]=n.id,t[2]=b):b=t[2];let x=b,S=n.share?.url,C=!!S,w=S?void 0:u,T;t[3]!==d||t[4]!==S?(T=S?()=>d(S):void 0,t[3]=d,t[4]=S,t[5]=T):T=t[5];let E=S?f:void 0,D;t[6]!==i||t[7]!==p||t[8]!==m||t[9]!==c||t[10]!==l||t[11]!==C||t[12]!==w||t[13]!==T||t[14]!==E?(D=Wa({pinned:i,shared:C,onRename:c,onTogglePin:l,onShare:w,onCopyLink:T,onUnshare:E,onArchive:p,onDelete:m}),t[6]=i,t[7]=p,t[8]=m,t[9]=c,t[10]=l,t[11]=C,t[12]=w,t[13]=T,t[14]=E,t[15]=D):D=t[15];let O=D,k;t[16]!==g.onContextMenu||t[17]!==g.pressed?(k=e=>{ao(e,g.pressed,g.onContextMenu)},t[16]=g.onContextMenu,t[17]=g.pressed,t[18]=k):k=t[18];let A=n.id,j=`session:${n.id}`,M=g.onPointerDown,N=g.onPointerMove,P=g.onPointerUp,F=g.onPointerCancel,I;t[19]!==v||t[20]!==s?(I=e=>{if(v){e.preventDefault();return}s()},t[19]=v,t[20]=s,t[21]=I):I=t[21];let te=g.pressed&&`bg-[var(--interactive-active)] scale-[0.99]`,ne=r?`bg-[color-mix(in_srgb,var(--interactive-selection)_40%,transparent)]`:`hover:bg-[var(--interactive-hover)]`,L;t[22]!==te||t[23]!==ne?(L=Y(`flex w-full min-h-[56px] items-center gap-3 rounded-xl px-3 py-3 text-left transition-colors select-none`,`active:bg-[var(--interactive-selection)]`,te,ne),t[22]=te,t[23]=ne,t[24]=L):L=t[24];let R;t[25]!==g.onPointerCancel||t[26]!==g.onPointerDown||t[27]!==g.onPointerMove||t[28]!==g.onPointerUp||t[29]!==n.id||t[30]!==I||t[31]!==L||t[32]!==j?(R=(0,$.jsx)(`button`,{type:`button`,"data-mobile-session-context-trigger":A,"data-mobile-long-press-trigger":j,onPointerDown:M,onPointerMove:N,onPointerUp:P,onPointerCancel:F,onClick:I,className:L,style:Do}),t[25]=g.onPointerCancel,t[26]=g.onPointerDown,t[27]=g.onPointerMove,t[28]=g.onPointerUp,t[29]=n.id,t[30]=I,t[31]=L,t[32]=j,t[33]=R):R=t[33];let z=n._statusType!==`idle`,B=x&&!r,V;t[34]!==z||t[35]!==B?(V=(0,$.jsx)(`span`,{className:`flex h-4 w-4 flex-shrink-0 items-center justify-center`,children:(0,$.jsx)(Co,{isRunning:z,showUnread:B})}),t[34]=z,t[35]=B,t[36]=V):V=t[36];let H=r?`font-semibold text-[var(--surface-foreground)]`:`text-[var(--surface-foreground)]`,U;t[37]===H?U=t[38]:(U=Y(`truncate text-[15px] leading-tight`,H),t[37]=H,t[38]=U);let W;t[39]!==o||t[40]!==n?(W=o(n),t[39]=o,t[40]=n,t[41]=W):W=t[41];let re;t[42]!==U||t[43]!==W?(re=(0,$.jsx)(`span`,{className:U,children:W}),t[42]=U,t[43]=W,t[44]=re):re=t[44];let ie;t[45]===a?ie=t[46]:(ie=a?(0,$.jsx)(`span`,{className:`truncate text-[12px] leading-none text-[var(--surface-mutedForeground)]`,children:a}):null,t[45]=a,t[46]=ie);let G;t[47]!==re||t[48]!==ie?(G=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[re,ie]}),t[47]=re,t[48]=ie,t[49]=G):G=t[49];let ae;t[50]===n._runningChildrenCount?ae=t[51]:(ae=(n._runningChildrenCount??0)>0&&(0,$.jsxs)(`span`,{className:`flex flex-shrink-0 items-center gap-1 text-[12px] text-[var(--surface-mutedForeground)]`,children:[(0,$.jsx)(ba,{size:12}),n._runningChildrenCount]}),t[50]=n._runningChildrenCount,t[51]=ae);let oe;t[52]===r?oe=t[53]:(oe=r&&(0,$.jsx)(X,{name:`check`,className:`h-4 w-4 flex-shrink-0 text-[var(--primary-base)]`}),t[52]=r,t[53]=oe);let se;t[54]!==R||t[55]!==V||t[56]!==G||t[57]!==ae||t[58]!==oe||t[59]!==k?(se=(0,$.jsxs)(Un,{onTouchStart:io,onContextMenu:k,render:R,children:[V,G,ae,oe]}),t[54]=R,t[55]=V,t[56]=G,t[57]=ae,t[58]=oe,t[59]=k,t[60]=se):se=t[60];let ce;if(t[61]!==O||t[62]!==_){let e;t[64]===_?e=t[65]:(e=(e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0&&(e.separated||e.id===`archive`)?(0,$.jsx)(Wn,{}):null,(0,$.jsxs)(Kn,{className:`min-h-10 px-3`,onClick:e.onClick,children:[(0,$.jsx)(X,{name:e.icon,className:`size-4`}),qa(e,_)]})]},e.id),t[64]=_,t[65]=e),ce=O.map(e),t[61]=O,t[62]=_,t[63]=ce}else ce=t[63];let K;t[66]===ce?K=t[67]:(K=(0,$.jsx)(Gn,{className:`min-w-[200px] p-1.5`,children:ce}),t[66]=ce,t[67]=K);let le;return t[68]!==v||t[69]!==se||t[70]!==K?(le=(0,$.jsxs)(qn,{open:v,onOpenChange:y,children:[se,K]}),t[68]=v,t[69]=se,t[70]=K,t[71]=le):le=t[71],le}function ko(e){let t=(0,Qn.c)(23),{label:n,leadingIcon:r,icon:i,project:a,iconOptions:o,iconBackground:s,colorVar:c,isActive:l,status:u,onClick:d}=e,f=i?Ye[i]:null,p;t[0]!==c||t[1]!==l||t[2]!==f?(p=f?(0,$.jsx)(X,{name:f,className:`h-4 w-4`,style:!l&&c?{color:c}:void 0}):null,t[0]=c,t[1]=l,t[2]=f,t[3]=p):p=t[3];let m=p,h=l?`border-transparent bg-[var(--primary-base)] text-[var(--primary-foreground)] font-medium`:`border-[var(--interactive-border)] bg-[var(--surface-subtle)] text-[var(--surface-foreground)] active:bg-[var(--interactive-hover)]`,g;t[4]===h?g=t[5]:(g=Y(`flex min-h-[40px] shrink-0 select-none items-center gap-1.5 rounded-full border px-3.5 text-[13px] leading-none whitespace-nowrap transition-colors`,h),t[4]=h,t[5]=g);let _;t[6]!==l||t[7]!==u?(_=u&&(u.hasRunning||u.hasUnread)&&!l&&(u.hasRunning?(0,$.jsx)(ba,{size:10}):(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--status-info)]`})),t[6]=l,t[7]=u,t[8]=_):_=t[8];let v;t[9]!==m||t[10]!==s||t[11]!==o||t[12]!==a?(v=a?.iconImage?(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:s?{backgroundColor:s}:void 0,children:(0,$.jsx)(We,{project:a,options:o,className:`h-full w-full object-contain`,fallback:m})}):m,t[9]=m,t[10]=s,t[11]=o,t[12]=a,t[13]=v):v=t[13];let y;t[14]===n?y=t[15]:(y=(0,$.jsx)(`span`,{className:`max-w-[140px] truncate`,children:n}),t[14]=n,t[15]=y);let b;return t[16]!==r||t[17]!==d||t[18]!==g||t[19]!==_||t[20]!==v||t[21]!==y?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:d,className:g,children:[r,_,v,y]}),t[16]=r,t[17]=d,t[18]=g,t[19]=_,t[20]=v,t[21]=y,t[22]=b):b=t[22],b}var Ao=({onSessionSwitch:e})=>{let{t}=ee(),{git:n}=Ut(),{currentTheme:r}=mt(),i=s(e=>e.isMobile),a=Ja(),o=K(e=>e.currentSessionId),c=Ce(),l=K(e=>e.setCurrentSession),u=K(e=>e.openNewSessionDraft),d=Q.useCallback(e=>{if(!q()){re.getState().openDraft(e);return}u(e)},[u]),f=K(e=>e.archiveSession),p=K(e=>e.shareSession),m=K(e=>e.unshareSession),h=K(e=>e.updateSessionTitle),g=K(e=>e.requestSessionSmartTitle),_=s(e=>e.mobileSessionPanelOpen),v=s(e=>e.setMobileSessionPanelOpen),y=Ct({onDismiss:()=>v(!1)}),b=ue(e=>e.projects),x=ue(e=>e.activeProjectId),S=ue(e=>e.setActiveProjectIdOnly),C=ue(e=>e.removeProject),w=Le(e=>e.ids),T=Le(e=>e.toggle),E=K(e=>e.availableWorktreesByProject),D=Be(e=>e.orderByProject),O=be(e=>e.activePaginationByDirectory),k=ya(e=>e.expandedWorktreeGroups),A=ya(e=>e.setWorktreeGroupExpanded),{sessions:N,totalRunning:P,totalUnread:F}=so(a,c),{getSessionTitle:I,needsAttention:te}=ho(),ne=_o(a,c,o),L=xo(),[R,z]=Q.useState(new Map),[B,V]=Q.useState(new Map),[H,U]=Q.useState(!1),[W,ie]=Q.useState(null),[G,ae]=Q.useState(null),[oe,le]=Q.useState(null),[de,fe]=Q.useState(null),[pe,me]=Q.useState(``),[ge,_e]=Q.useState(null),[ve,ye]=Q.useState(null),[xe,Se]=Q.useState(null),we=Q.useRef(null);we.current||=cn({onPressedKeyChange:le});let Te=Q.useRef(null),[Ee,De]=Q.useState(!1),Oe=s(e=>e.mobileSessionFilterProjectId),Ae=s(e=>e.setMobileSessionFilterProjectId),je=Q.useMemo(()=>N.some(e=>w.has(e.id)),[w,N]);Q.useEffect(()=>{!je&&Oe===Qa&&Ae(null)},[Oe,je,Ae]),Q.useEffect(()=>{_||(ae(null),Se(null),we.current?.reset())},[_]),Q.useEffect(()=>()=>{we.current?.reset()},[]),Q.useEffect(()=>{if(!G)return;Eo();let e=window.requestAnimationFrame(Eo);return document.addEventListener(`selectionchange`,Eo),()=>{window.cancelAnimationFrame(e),document.removeEventListener(`selectionchange`,Eo),Eo()}},[G]);let Me=Q.useMemo(()=>Oe&&Oe!==Qa?b.find(e=>e.id===Oe)??null:null,[Oe,b]),Ne=Q.useMemo(()=>Me??b.find(e=>e.id===x)??null,[x,b,Me]);Q.useEffect(()=>{let e=to(Ne?.path??``);if(!_||!e){De(!1);return}let t=Te.current;if(t?.git===n&&t.path===e){De(t.isGitRepository);return}let r=!1;return De(!1),n.checkIsGitRepository(e).then(t=>{r||(Te.current={git:n,path:e,isGitRepository:t},De(t))}).catch(()=>{r||(Te.current={git:n,path:e,isGitRepository:!1},De(!1))}),()=>{r=!0}},[n,_,Ne]),Q.useEffect(()=>{if(!_||b.length===0)return;let e=!1;return Promise.all(b.map(async e=>({projectId:e.id,branch:await et(e.path).catch(()=>null)}))).then(t=>{e||V(e=>{let n=new Map(e);for(let e of t){let t=e.branch?.trim();t&&t!==`HEAD`&&n.set(e.projectId,t),e.branch===`HEAD`&&n.delete(e.projectId)}return n})}),()=>{e=!0}},[_,b]);let Pe=Q.useMemo(()=>{if(Oe&&Oe!==Qa){let e=b.find(e=>e.id===Oe);return e?L(e):[]}return b.flatMap(L)},[Oe,b,L]);Q.useEffect(()=>{_&&se(Pe)},[_,Pe]),Q.useEffect(()=>{if(!_||b.length===0)return;let e=!1;return(async()=>{let t=await Promise.all(b.map(async t=>{let r=to(t.path);if(!r)return null;let i=!1;try{i=await n.checkIsGitRepository(r)}catch{return{path:r,status:`failed`}}if(!i)return{path:r,status:`success`,worktrees:[]};try{return{path:r,status:`success`,worktrees:(await Ge({id:t.id,path:r},{isCurrent:()=>!e})).worktrees}}catch{return{path:r,status:`failed`}}}));if(e)return;let r=new Set(b.map(e=>to(e.path)).filter(Boolean)),i=t.flatMap(e=>e?[e]:[]);K.setState(e=>{let t=Ha(e.availableWorktreesByProject,r,i);return t===e.availableWorktreesByProject?{}:{availableWorktreesByProject:t,availableWorktrees:Array.from(t.values()).flat()}})})(),()=>{e=!0}},[n,_,b]);let Fe=Q.useCallback(e=>ke(e.path)||e.path,[]),Ie=Q.useMemo(()=>{if(!Oe)return N;if(Oe===Qa)return N.filter(e=>w.has(e.id));let e=b.find(e=>e.id===Oe);if(!e)return N;let t=L(e);return N.filter(e=>{let n=no(e);return t.some(e=>to(e)===n)})},[N,Oe,w,b,L]),Re=Q.useMemo(()=>{if(!Me)return[];let e=to(Me.path),t=ze(D[Me.id],E.get(e)??[]),n=[{key:`${Me.id}::${e}`,directory:e,label:Fe(Me),worktree:null,sessions:[]}];for(let r of t){let t=to(r.path);!t||t===e||n.some(e=>e.directory===t)||n.push({key:`${Me.id}::${t}`,directory:t,label:r.branch||r.label||ke(t),worktree:r,sessions:[]})}let r=new Map(n.map(e=>[e.directory,e]));for(let e of Ie)r.get(no(e))?.sessions.push(e);return n},[E,Ie,Fe,Me,D]),He=Q.useCallback(e=>{let t=no(e);for(let e of b){let n=to(e.path),r=Fe(e);if(t===n){let t=B.get(e.id);return t?`${r} · ${t}`:r}let i=(E.get(n)??[]).find(e=>to(e.path)===t);if(i)return i.branch?`${r} · ${i.branch}`:r}return ke(t)||t||void 0},[E,Fe,b,B]),Ue=Q.useCallback(()=>{ae(null),we.current?.reset(),v(!1)},[v]),We=()=>{ae(null),we.current?.reset()},Ke=e=>({pressed:oe===e.key||G?.key===e.key,onPointerDown:t=>{t.pointerType!==`touch`&&t.pointerType!==`pen`||t.button!==0||we.current?.start({pointerId:t.pointerId,key:e.key,clientX:t.clientX,clientY:t.clientY,onTrigger:()=>{Eo(),ae(e)}})},onPointerMove:e=>{we.current?.move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{we.current?.end(e.pointerId)},onPointerCancel:e=>{we.current?.cancel(e.pointerId)},onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),Eo(),we.current?.openFromContextMenu(e.key,()=>ae(e))}}),qe=(e,t)=>{we.current?.consumeClick(e)||t()},Je=Q.useCallback(t=>{Tt(),Ue();let n=no(t)||null;q()?l(t.id,n):re.getState().openSession({sessionId:t.id,directory:n}),e?.(t.id)},[Ue,e,l]),Ye=Q.useCallback(async e=>{try{if(!(await p(e.id))?.share?.url){J.error(t(`sessions.sidebar.session.share.error`));return}J.success(t(`sessions.sidebar.session.share.successTitle`),{description:t(`sessions.sidebar.session.share.successDescription`)})}catch{J.error(t(`sessions.sidebar.session.share.error`))}},[p,t]),Xe=Q.useCallback(async e=>{if((await M(e)).ok){J.success(t(`sessions.sidebar.session.menu.copied`));return}J.error(t(`sessions.sidebar.session.share.copyUrlError`))},[t]),Ze=Q.useCallback(async e=>{try{if(!await m(e)){J.error(t(`sessions.sidebar.session.unshare.error`));return}J.success(t(`sessions.sidebar.session.unshare.success`))}catch{J.error(t(`sessions.sidebar.session.unshare.error`))}},[t,m]),$e=Q.useCallback(async e=>{if(!await f(e)){J.error(t(`sessions.sidebar.session.archive.error`));return}wa({sessionIds:[e],message:t(`sessions.sidebar.session.archive.success`),undoLabel:t(`sessions.sidebar.undo`),settingsLabel:t(`settings.openchamber.archivedSessions.actions.view`),undoFailedMessage:t(`sessions.sidebar.session.archive.undoFailed`)})},[f,t]),tt=j(e=>{let t=new Map;for(let e of a){let n=e.parentID??null;if(!n)continue;let r=t.get(n)??[];r.push(e.id),t.set(n,r)}let n=[],r=new Set,i=e=>{if(!r.has(e)){r.add(e),n.push(e);for(let n of t.get(e)??[])i(n)}};return i(e),n}),nt=j(e=>{let n=tt(e.id);Ta({sessionIds:n,message:n.length===1?t(`sessions.sidebar.session.delete.success`):t(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:t(`sessions.sidebar.undo`),commitFailedMessage:t(`sessions.sidebar.session.delete.error`)})}),rt=Q.useCallback(e=>{me(I(e)),fe(e)},[I]),it=Q.useCallback(async()=>{if(!de)return;let e=pe.trim();if(e)try{await h(de.id,e),fe(null),me(``)}catch{J.error(t(`sessions.sidebar.session.menu.rename`),{description:t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},[pe,de,t,h]),at=Q.useCallback(async()=>{if(!de)return;let e=de.id;fe(null),me(``);try{await g(e)}catch{J.error(t(`sessions.sidebar.session.rename.smartTitle`),{description:t(`sessions.sidebar.dialogs.deleteResult.tryAgain`)})}},[de,g,t]),st=Q.useCallback(()=>{if(Ue(),Oe){let e=b.find(e=>e.id===Oe);if(e){d({selectedProjectId:e.id,directoryOverride:e.path});return}}let e=[...a].sort((e,t)=>{let n=e.time?.updated??0;return(t.time?.updated??0)-n})[0],t=e?no(e):``;d(t?{directoryOverride:t}:void 0)},[Ue,Oe,b,a,d]),ct=Q.useCallback(()=>{!Ne||!Ee||(Ue(),S(Ne.id),ie(Ne.id),U(!0))},[Ue,S,Ee,Ne]),lt=(e,t)=>{We(),v(!1),d({selectedProjectId:e.id,directoryOverride:t,preserveDirectoryOverride:!0})},ut=e=>{We(),(async()=>{try{await Ge({id:e.project.id,path:e.project.path})}catch(e){console.warn(`[MobileStatus] Worktree refresh before session sync failed:`,e)}let t=K.getState().availableWorktreesByProject.get(e.project.path)??e.worktrees;await ce([e.project.path,...t.map(e=>e.path)],a)})()},dt=j(e=>{A(e,!k[e]),z(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),ft=Q.useCallback(e=>{let t=(R.get(e.key)??$a)+eo;if(z(t=>{let n=new Map(t);return n.set(e.key,(t.get(e.key)??$a)+eo),n}),t<e.sessions.length)return;let n=be.getState().activePaginationByDirectory.get(e.directory);n?.hasMore&&!n.loadingMore&&he(e.directory)},[R]),pt=Q.useCallback(e=>{z(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),ht=e=>{let n=e.worktree===null,r=n||k[e.key]===!0,i=R.get(e.key)??$a,a=e.sessions.slice(0,i),s=O.get(e.directory),c=a.length<e.sessions.length||s?.hasMore===!0,l=e.sessions.length>$a&&i>$a,u=n&&Me?B.get(Me.id):null,d=e.label,f=n?`project:${Me?.id??e.key}`:`worktree:${Me?.id??e.key}:${e.directory}`,p=Me?Ke(n?{key:f,kind:`project`,project:Me,worktrees:Re.flatMap(e=>e.worktree?[e.worktree]:[]),isGitRepository:Ee}:{key:f,kind:`worktree`,project:Me,worktree:e.worktree}):null;return(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl`,children:[n?(0,$.jsxs)(`div`,{"data-mobile-long-press-trigger":f,className:Y(`flex min-h-12 items-center gap-2 rounded-xl px-3 py-2 text-left transition-all select-none`,p?.pressed&&`bg-[var(--interactive-active)] scale-[0.99]`),onPointerDown:p?.onPointerDown,onPointerMove:p?.onPointerMove,onPointerUp:p?.onPointerUp,onPointerCancel:p?.onPointerCancel,onContextMenu:p?.onContextMenu,style:Do,children:[(0,$.jsx)(X,{name:`folder-open`,className:`size-4 shrink-0 text-[var(--surface-mutedForeground)]`}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate text-[14px] font-semibold text-[var(--surface-foreground)]`,children:d}),u?(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-[12px] text-[var(--surface-mutedForeground)]`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:u})]}):null]}),(0,$.jsx)(`span`,{className:`shrink-0 text-[12px] tabular-nums text-[var(--surface-mutedForeground)]`,children:ro(e.sessions)})]}):(0,$.jsxs)(`button`,{type:`button`,"data-mobile-long-press-trigger":f,onClick:()=>qe(f,()=>dt(e.key)),onPointerDown:p?.onPointerDown,onPointerMove:p?.onPointerMove,onPointerUp:p?.onPointerUp,onPointerCancel:p?.onPointerCancel,onContextMenu:p?.onContextMenu,"aria-expanded":r,"aria-label":t(r?`sessions.sidebar.group.collapseAria`:`sessions.sidebar.group.expandAria`,{label:d}),className:Y(`flex min-h-12 w-full items-center gap-2 rounded-xl px-3 py-2 text-left transition-all hover:bg-[var(--interactive-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] select-none`,p?.pressed&&`bg-[var(--interactive-active)] scale-[0.99]`),style:Do,children:[(0,$.jsx)(X,{name:`arrow-down-s`,className:Y(`size-4 shrink-0 text-[var(--surface-mutedForeground)] transition-transform`,r?`rotate-0`:`-rotate-90`)}),(0,$.jsx)(X,{name:`node-tree`,className:`size-4 shrink-0 text-[var(--surface-mutedForeground)]`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[14px] font-semibold text-[var(--surface-foreground)]`,children:d}),(0,$.jsx)(`span`,{className:`shrink-0 text-[12px] tabular-nums text-[var(--surface-mutedForeground)]`,children:ro(e.sessions)})]}),r?(0,$.jsxs)(`div`,{className:`pb-1`,children:[a.map(e=>(0,$.jsx)(Oo,{session:e,isCurrent:e.id===o,isPinned:w.has(e.id),getSessionTitle:I,onClick:()=>qe(`session:${e.id}`,()=>Je(e)),onRename:()=>rt(e),onTogglePinned:()=>T(e.id),onShare:()=>{Ye(e)},onCopyShareUrl:e=>{Xe(e)},onUnshare:()=>{Ze(e.id)},onArchive:()=>{$e(e.id)},onDelete:()=>nt(e),needsAttention:te,longPressHandlers:Ke({key:`session:${e.id}`,kind:`session`,session:e})},e.id)),c||l?(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2 py-1 pr-3 pl-8`,children:[c?(0,$.jsx)(Z,{variant:`ghost`,size:`xs`,disabled:s?.loadingMore===!0,onClick:()=>ft(e),className:`text-muted-foreground/70 hover:text-foreground`,children:t(`sessions.sidebar.group.showMore`)}):null,l?(0,$.jsx)(Z,{variant:`ghost`,size:`xs`,onClick:()=>pt(e.key),className:`text-muted-foreground/70 hover:text-foreground`,children:t(`sessions.sidebar.group.showFewer`)}):null]}):null]}):null]},e.key)},gt=Q.useCallback(()=>(0,$.jsxs)(`div`,{className:`shrink-0`,children:[(0,$.jsx)(_t,{controller:y,ariaLabel:t(`mobile.sessions.sheet.resizeAria`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-4 pb-2`,children:[(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground`,children:t(`mobile.sessions.sheet.title`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(wo,{count:P}),(0,$.jsx)(To,{count:F}),(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,onClick:st,"aria-label":t(`mobile.sessions.newChat`),className:`text-[var(--surface-mutedForeground)]`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`add`,className:`h-5 w-5`})}),Ee&&Ne?(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,onClick:ct,"aria-label":t(`sessions.sidebar.project.actions.newWorktree`),title:t(`sessions.sidebar.project.actions.newWorktree`),className:`text-[var(--surface-mutedForeground)]`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`node-tree`,className:`size-4`})}):null,(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,onClick:Ue,"aria-label":t(`mobile.surface.closeAria`),className:`text-[var(--surface-mutedForeground)]`,style:{touchAction:`manipulation`},children:(0,$.jsx)(X,{name:`close`,className:`h-5 w-5`})})]})]}),(b.length>1||je)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto px-4 py-2.5 scrollbar-none`,style:{scrollbarWidth:`none`,msOverflowStyle:`none`},children:[(0,$.jsx)(ko,{label:t(`chat.modelControls.modeValue.all`),isActive:Oe===null,onClick:()=>Ae(null)}),je?(0,$.jsx)(ko,{label:t(`sessions.sidebar.session.actions.pinned`),leadingIcon:(0,$.jsx)(X,{name:`pushpin-2-fill`,className:`size-3.5`}),isActive:Oe===Qa,onClick:()=>Ae(Qa)}):null,b.map(e=>(0,$.jsx)(ko,{label:Fe(e),icon:e.icon,project:{id:e.id,iconImage:e.iconImage??null},iconOptions:{themeVariant:r.metadata.variant,iconColor:r.colors.surface.foreground},iconBackground:e.iconBackground??null,colorVar:e.color?Qe[e.color]??null:null,isActive:Oe===e.id,status:ne(e.path),onClick:()=>Ae(e.id)},e.id))]})]}),[t,P,F,b,je,Oe,Ae,Fe,r,ne,st,ct,Ue,Ee,Ne,y]),vt=G?.kind===`project`?Fe(G.project):G?.kind===`worktree`?G.worktree.branch||G.worktree.label||ke(G.worktree.path):G?.kind===`session`?I(G.session):``,yt=Q.useMemo(()=>{if(!ge)return null;let e=b.find(e=>e.id===ge);if(!e)return null;let t=to(e.path),n=ze(D[e.id],E.get(t)??[]),r=G?.kind===`project`&&G.project.id===e.id?G.isGitRepository:n.length>0||!!B.get(e.id);return{id:e.id,label:Fe(e),path:t||e.path,icon:e.icon,color:e.color,iconImage:e.iconImage,iconBackground:e.iconBackground,isGitRepo:r,worktrees:n}},[G,E,ge,Fe,b,B,D]),bt=Q.useMemo(()=>{if(!G)return[];if(G.kind===`project`){let e=G.project;return Ga({gitRepository:G.isGitRepository,onNewSession:()=>lt(e,e.path),onNewWorktree:()=>{let t=e.id;We(),Ue(),S(t),ie(t),U(!0)},onSyncSessions:()=>ut(G),onEditProject:()=>{We(),_e(e.id)},onCloseProject:()=>{We(),ye(e)}})}if(G.kind===`worktree`){let{project:e,worktree:t}=G;return Ka({onNewSession:()=>lt(e,t.path),onDeleteWorktree:()=>{We(),Se({project:e,worktree:t})}})}let e=G.session,t=!!e.share?.url;return Wa({pinned:w.has(e.id),shared:t,onRename:()=>{We(),rt(e)},onTogglePin:()=>{We(),T(e.id)},onShare:t?void 0:()=>{We(),Ye(e)},onCopyLink:t?()=>{let t=e.share?.url;We(),t&&Xe(t)}:void 0,onUnshare:t?()=>{We(),Ze(e.id)}:void 0,onArchive:()=>{We(),$e(e.id)},onDelete:()=>{We(),nt(e)}})},[G,rt,We,Ue,$e,Xe,nt,Ye,Ze,w,S,lt,ut,T]),xt=bt.length>0?(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,"data-mobile-session-action-sheet":G?.kind??`none`,children:bt.map(e=>{let n=(0,$.jsx)(oo,{icon:e.icon,label:qa(e,t),destructive:e.destructive,onClick:e.onClick},e.id);return e.separated?(0,$.jsx)(`div`,{className:`mt-3 border-t border-[var(--surface-subtle)] pt-3`,children:n},e.id):n})}):null;return i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kt,{id:At,open:_,onOpenChange:v,keepMounted:!0,presentation:`sheet`,edge:`bottom`,dismissGesture:{reservedTargetSelector:`[data-mobile-sheet-snap-handle]`},ariaLabel:t(`mobile.sessions.sheet.title`),surfaceClassName:y.snapPoint===.98?`h-[98dvh] max-h-[98dvh]`:`h-[72dvh] max-h-[98dvh]`,surfaceElementRef:y.surfaceRef,onExitComplete:y.reset,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[gt(),(0,$.jsx)(Ve,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 max-h-full flex-1`,className:`px-2 py-2 pwa-overlay-scroll`,children:(0,$.jsx)(`div`,{className:`flex min-h-full flex-col gap-0.5`,children:Me?(0,$.jsxs)($.Fragment,{children:[Re.map(ht),Re.every(e=>e.sessions.length===0)?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-8 text-[13px] text-[var(--surface-mutedForeground)]`,children:(0,$.jsx)(`span`,{children:t(`chat.mobileStatus.noSessionsInProject`)})}):null]}):Ie.length===0?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-10 text-[13px] text-[var(--surface-mutedForeground)]`,children:(0,$.jsx)(`span`,{children:t(`chat.mobileStatus.noSessionsInProject`)})}):Ie.map(e=>(0,$.jsx)(Oo,{session:e,isCurrent:e.id===o,isPinned:w.has(e.id),contextLabel:He(e),getSessionTitle:I,onClick:()=>qe(`session:${e.id}`,()=>Je(e)),onRename:()=>rt(e),onTogglePinned:()=>T(e.id),onShare:()=>{Ye(e)},onCopyShareUrl:e=>{Xe(e)},onUnshare:()=>{Ze(e.id)},onArchive:()=>{$e(e.id)},onDelete:()=>nt(e),needsAttention:te,longPressHandlers:Ke({key:`session:${e.id}`,kind:`session`,session:e})},e.id))})})]})}),(0,$.jsx)(Ht,{open:!!G,title:vt,onClose:We,className:`select-none`,contentMaxHeightClassName:`max-h-[min(68dvh,560px)]`,children:xt}),(0,$.jsx)(Ht,{open:!!de,title:t(`sessions.sidebar.session.menu.rename`),onClose:()=>{fe(null),me(``)},footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>{fe(null),me(``)},children:t(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Z,{type:`button`,variant:`default`,className:`flex-1`,disabled:!pe.trim(),onClick:()=>void it(),children:t(`sessions.sidebar.session.rename.save`)})]}),children:(0,$.jsxs)(`form`,{className:`flex flex-col gap-3 px-1 py-1`,onSubmit:e=>{e.preventDefault(),it()},children:[(0,$.jsx)(ot,{value:pe,onChange:e=>me(e.target.value),autoFocus:!0,className:`h-12`}),(0,$.jsxs)(Z,{type:`button`,variant:`outline`,className:`w-full gap-2`,onClick:()=>void at(),children:[(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4`}),t(`sessions.sidebar.session.rename.smartTitle`)]})]})}),(0,$.jsx)(Ht,{open:!!ve,title:t(`sessions.sidebar.project.actions.closeProject`),onClose:()=>ye(null),closeAriaLabel:t(`mobile.surface.closeAria`),footer:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`flex-1`,onClick:()=>ye(null),children:t(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(Z,{type:`button`,variant:`destructive`,className:`flex-1`,onClick:()=>{if(!ve)return;let e=ve;ye(null),C(e.id),J.success(t(`mobile.sessions.toast.projectRemoved`,{label:Fe(e)}))},children:t(`mobile.sessions.confirmRemoveProject`)})]}),children:(0,$.jsx)(`p`,{className:`px-1 py-1 typography-ui-body text-foreground`,children:t(`mobile.projects.closeConfirmMessage`,{title:ve?Fe(ve):``})})}),(0,$.jsx)(Vt,{open:H,projectId:W,onOpenChange:e=>{U(e),e||ie(null)},onWorktreeCreated:(e,t)=>{U(!1),v(!1),t?.sessionId?q()?l(t.sessionId,e):re.getState().openSession({sessionId:t.sessionId,directory:e}):W&&d({selectedProjectId:W,directoryOverride:e,preserveDirectoryOverride:!0})}}),xe?(0,$.jsx)(Oa,{open:!0,project:{id:xe.project.id,path:xe.project.path},worktree:xe.worktree,onClose:()=>Se(null),onDeleted:()=>{let e=to(xe.project.path),t=to(xe.worktree.path);K.setState(n=>{let r=new Map(n.availableWorktreesByProject);return r.set(e,(r.get(e)??[]).filter(e=>to(e.path)!==t)),{availableWorktreesByProject:r,availableWorktrees:Array.from(r.values()).flat()}}),Se(null)}}):null,(0,$.jsx)(za,{open:ge!==null,project:yt,onClose:()=>_e(null)})]}):null},jo=`schedule`,Mo=[`git`,`diff`,`terminal`,`files`,`diagram`,`plan`],No=[`tasks`,`history`],Po=`/session/new`,Fo=new Set(Mo),Io=new Set(No),Lo=new Set([`staged`,`working`,`turn`]);function Ro(e){return!e||e===`chat`?`chat`:e===`scheduled`||e===`schedule`?jo:e===`assistant`?`assistant`:Fo.has(e)?e:`chat`}function zo(e){return Hn(e)}function Bo(e){return e&&Io.has(e)?e:null}function Vo(e){return e&&Lo.has(e)?e:null}function Ho(){return Po}function Uo(e,t){let n=zo(typeof e==`string`?e:e.slug),r=typeof e==`string`?t:e.entityId,i=`/settings/${n}`;return r&&r.trim().length>0?`${i}/${encodeURIComponent(r.trim())}`:i}function Wo(e,t){return t&&t.trim().length>0?`${e}/agent/${encodeURIComponent(t.trim())}`:e}function Go(e={}){let t=Bo(e.scheduleView??e.scheduledView)??`tasks`,n=e.scheduleProjectId??e.scheduledProjectId??null,r=e.scheduleTaskId??e.scheduledTaskId??null,i;return i=n&&r?`/schedule/tasks/${encodeURIComponent(n)}/${encodeURIComponent(r)}`:t===`history`?`/schedule/history`:`/schedule`,Wo(i,e.focusSessionId)}function Ko(e={}){let t=`/assistant`;return e.assistantId&&e.assistantId.trim().length>0&&(t=`/assistant/${encodeURIComponent(e.assistantId.trim())}`),Wo(t,e.focusSessionId)}function qo(e){let t=encodeURIComponent(e.sessionId),n=Ro(e.tab);if(n===`schedule`)return Go({});if(n===`assistant`)return Ko({});let r;r=n===`chat`?`/session/${t}`:n===`plan`?`/session/${t}/plan`:`/session/${t}/${n}`;let i=new URLSearchParams;e.file&&i.set(`file`,e.file),e.mode===`plan`&&n===`chat`&&i.set(`mode`,`plan`);let a=Vo(e.scope);a&&i.set(`scope`,a);let o=i.toString();return o?`${r}?${o}`:r}function Jo(e){let t=Ro(e.tab);return t===`schedule`?Go({scheduleView:e.scheduleView??e.scheduledView,scheduleProjectId:e.scheduleProjectId??e.scheduledProjectId,scheduleTaskId:e.scheduleTaskId??e.scheduledTaskId,focusSessionId:e.focusSessionId}):t===`assistant`?Ko({assistantId:e.assistantId,focusSessionId:e.focusSessionId}):e.sessionId&&e.sessionId.trim().length>0?qo({sessionId:e.sessionId.trim(),tab:t,file:e.file,mode:e.mode??(t===`plan`?`plan`:null),scope:e.scope}):`/`}function Yo(e){let t=new URLSearchParams(e.startsWith(`?`)?e.slice(1):e);return{file:t.get(`file`),mode:t.get(`mode`)===`plan`?`plan`:null,scope:Vo(t.get(`scope`))}}function Xo(e){let t=e.indexOf(`agent`);return t>=0&&e[t+1]?{rest:e.slice(0,t),focusSessionId:decodeURIComponent(e[t+1])}:{rest:e,focusSessionId:null}}function Zo(e,t){let n=e[1];return n?n===`history`?{kind:`schedule`,scheduleView:`history`,scheduleProjectId:null,scheduleTaskId:null,focusSessionId:t}:n===`tasks`&&e[2]&&e[3]?{kind:`schedule`,scheduleView:`tasks`,scheduleProjectId:decodeURIComponent(e[2]),scheduleTaskId:decodeURIComponent(e[3]),focusSessionId:t}:{kind:`schedule`,scheduleView:`tasks`,scheduleProjectId:null,scheduleTaskId:null,focusSessionId:t}:{kind:`schedule`,scheduleView:`tasks`,scheduleProjectId:null,scheduleTaskId:null,focusSessionId:t}}function Qo(e){let t=e,n=``,r=e.indexOf(`?`);r>=0&&(t=e.slice(0,r),n=e.slice(r));let i=t.indexOf(`#`);if(i>=0&&(t=t.slice(0,i)),t===`/session/new`||t===`/new`||t===`/session/new/`)return{kind:`new`};if(t===`/connect`)return{kind:`connect`};let a=t.match(/^\/settings(?:\/([^/]+)(?:\/([^/]+))?)?$/);if(a)return{kind:`settings`,slug:zo(a[1]??`home`),entityId:a[2]?decodeURIComponent(a[2]):null};let o=t.split(`/`).filter(Boolean);if(o.length===0)return{kind:`unknown`};let{rest:s,focusSessionId:c}=Xo(o),l=s[0];if(l===`schedule`||l===`scheduled`)return Zo(s,c);if(l===`assistant`)return{kind:`assistant`,assistantId:s[1]?decodeURIComponent(s[1]):null,focusSessionId:c};if(l===`session`){let e=s[1]?decodeURIComponent(s[1]):``;if(!e)return{kind:`unknown`};if(e===`new`)return{kind:`new`};let{file:t,mode:r,scope:i}=Yo(n),a=s[2];if(a===`schedule`||a===`scheduled`)return Zo(s.slice(2),c);if(a===`assistant`)return{kind:`assistant`,assistantId:s[3]?decodeURIComponent(s[3]):null,focusSessionId:c};if(!a)return r===`plan`?{kind:`session`,sessionId:e,tab:`plan`,file:t,mode:`plan`,scope:i}:{kind:`session`,sessionId:e,tab:`chat`,file:t,mode:r,scope:i};if(a===`plan`)return{kind:`session`,sessionId:e,tab:`plan`,file:t,mode:`plan`,scope:i};let o=Ro(a);return o===`chat`&&a!==`chat`?{kind:`session`,sessionId:e,tab:`chat`,file:t,mode:r,scope:i}:{kind:`session`,sessionId:e,tab:o,file:t,mode:r,scope:i}}return{kind:`unknown`}}function $o(e){return typeof window>`u`?ts():es(e===void 0?`${window.location.pathname}${window.location.search}`:`${window.location.pathname}?${e.toString()}`)}function es(e){let t=Qo(e);switch(t.kind){case`new`:return{...ts(),isNewSession:!0,tab:`chat`};case`session`:{let e=t.tab===`chat`&&t.mode===`plan`?`plan`:t.tab;return{sessionId:t.sessionId,isNewSession:!1,tab:e===`chat`&&t.mode!==`plan`?null:e,settingsPath:null,settingsEntityId:null,diffFile:t.file,diffScope:t.scope,scheduleView:null,scheduleProjectId:null,scheduleTaskId:null,assistantId:null,focusSessionId:null}}case`schedule`:return{sessionId:null,isNewSession:!1,tab:jo,settingsPath:null,settingsEntityId:null,diffFile:null,diffScope:null,scheduleView:t.scheduleView,scheduleProjectId:t.scheduleProjectId,scheduleTaskId:t.scheduleTaskId,assistantId:null,focusSessionId:t.focusSessionId};case`assistant`:return{sessionId:null,isNewSession:!1,tab:`assistant`,settingsPath:null,settingsEntityId:null,diffFile:null,diffScope:null,scheduleView:null,scheduleProjectId:null,scheduleTaskId:null,assistantId:t.assistantId,focusSessionId:t.focusSessionId};case`settings`:return{sessionId:null,isNewSession:!1,tab:null,settingsPath:t.slug,settingsEntityId:t.entityId,diffFile:null,diffScope:null,scheduleView:null,scheduleProjectId:null,scheduleTaskId:null,assistantId:null,focusSessionId:null};default:return ts()}}function ts(){return{sessionId:null,isNewSession:!1,tab:null,settingsPath:null,settingsEntityId:null,diffFile:null,diffScope:null,scheduleView:null,scheduleProjectId:null,scheduleTaskId:null,assistantId:null,focusSessionId:null}}function ns(){if(typeof window>`u`)return!1;try{let e=Qo(`${window.location.pathname}${window.location.search}`);return e.kind===`session`||e.kind===`new`||e.kind===`schedule`||e.kind===`assistant`||e.kind===`settings`||e.kind===`connect`}catch{return!1}}function rs(e){if(e.isSettingsOpen)return Uo({slug:e.settingsPath.trim().length>0?e.settingsPath:`home`,entityId:e.settingsEntityId??null});if(e.tab===`schedule`)return Jo({tab:jo,scheduleView:e.scheduleView,scheduleProjectId:e.scheduleProjectId,scheduleTaskId:e.scheduleTaskId,focusSessionId:e.focusSessionId});if(e.tab===`assistant`)return Jo({tab:`assistant`,assistantId:e.assistantId,focusSessionId:e.focusSessionId});if((e.isNewSession||!e.sessionId&&e.tab===`chat`)&&e.isNewSession)return Ho();if(e.sessionId&&e.sessionId.trim().length>0&&e.sessionId!==`new`){let t=new Set([`diff`,`files`,`diagram`]).has(e.tab)&&e.diffFile?e.diffFile:null;return Jo({sessionId:e.sessionId.trim(),tab:e.tab===`context`?`chat`:e.tab,file:t,mode:e.tab===`plan`?`plan`:null,scope:e.tab===`diff`?e.diffScope??null:null})}return e.isNewSession?Ho():`/`}function is(e){if(typeof window>`u`)return!0;try{let t=`${window.location.pathname}${window.location.search}`,n=rs(e);return JSON.stringify(Qo(t))===JSON.stringify(Qo(n))}catch{return!0}}function as(e,t={}){if(!(typeof window>`u`)&&!(os()||zt())&&!(!t.force&&is(e)))try{let n=rs(e);t.replace?window.history.replaceState({...window.history.state,route:e},``,n):window.history.pushState({route:e},``,n)}catch{}}function os(){return typeof window>`u`?!1:window.__VSCODE_CONFIG__!==void 0}function ss(e){if(!e||e.trim().length===0)return null;let t=be.getState(),n=t.activeSessions.find(t=>t.id===e)??t.archivedSessions.find(t=>t.id===e)??null;if(!n)return null;let r=ye(n);return r?{sessionId:e,directory:r,session:n,fromCache:!t.hasLoaded,source:`memory`}:null}function cs(e){return ss(e)?.directory??null}var ls=new Map;async function us(e,t){let n=e.trim();if(!n)return null;let r=ss(n);if(r)return r;let i=ls.get(n);if(i)return i;let a=(async()=>{let e=ss(n);if(e)return e;let r=await ie(n,{signal:t?.signal});if(r?.directory)return{sessionId:r.id,directory:r.directory,session:null,fromCache:!1,source:`session-index`};if(t?.trySessionGet===!1)return null;try{let e=await w.getSession(n),t=typeof e.directory==`string`&&e.directory.trim()||(typeof e.project?.worktree==`string`?e.project.worktree.trim():``)||null;return t?{sessionId:n,directory:t,session:e,fromCache:!1,source:`session-get`}:null}catch{return null}})().finally(()=>{ls.get(n)===a&&ls.delete(n)});return ls.set(n,a),a}var ds=3e4;function fs(){return typeof window>`u`?!1:window.__VSCODE_CONFIG__!==void 0}function ps(){let e=Q.useMemo(()=>fs(),[]),t=Q.useMemo(()=>zt(),[]),n=Q.useRef(!1),r=Q.useRef(!1),i=Q.useRef(new Set),[c,l]=Q.useState(()=>$o()),u=K(e=>e.setCurrentSession),d=K(e=>e.currentSessionId),f=K(e=>e.currentSessionDirectory),p=s(e=>e.setActiveMainTab),m=s(e=>e.setSettingsDialogOpen),h=s(e=>e.setSettingsPage),g=s(e=>e.navigateToDiff),_=be(e=>e.hasLoaded),v=be(e=>e.activeSessions),y=be(e=>e.archivedSessions),b=Q.useCallback(t=>{if(!e&&$o().sessionId===t){i.current.has(t)||(i.current.add(t),ve(t,`missing-directory`)),r.current=!0;try{m(!1),p(`chat`),as({sessionId:t,tab:`chat`,isSettingsOpen:!1,settingsPath:`home`,diffFile:null},{replace:!0,force:!0}),l($o())}finally{r.current=!1}}},[e,p,l,m]),x=Q.useCallback(async e=>{if(!r.current){r.current=!0;try{if(e.settingsPath){h(Hn(e.settingsPath)),m(!0);return}if(s.getState().isSettingsDialogOpen&&m(!1),e.tab===`schedule`||e.tab===`assistant`){p(e.tab),e.tab===`assistant`&&e.assistantId&&Ee.getState().selectAssistant(e.assistantId);return}if(e.isNewSession){p(`chat`),K.getState().newSessionDraft.open||K.getState().openNewSessionDraft();return}if(e.sessionId){let t=e.sessionId,n=cs(t);if(!n){r.current=!1;let e=await us(t);r.current=!0,n=e?.directory??null}let i=K.getState();n&&(t!==i.currentSessionId||n!==i.currentSessionDirectory)&&u(t,n)}e.tab?p(e.tab):e.sessionId&&p(`chat`),e.diffFile&&(e.tab===`diff`||!e.tab)&&g(e.diffFile)}finally{r.current=!1}}},[u,p,m,h,g]),S=Q.useCallback(()=>{let e=K.getState(),t=s.getState(),n=$o(),r=t.activeMainTab,i=!!e.newSessionDraft?.open&&!e.currentSessionId,a=!i&&(r===`schedule`||r===`assistant`);return{isNewSession:i,sessionId:a||i?null:e.currentSessionId??n.sessionId,tab:i?`chat`:a?r:t.activeMainTab||n.tab||`chat`,isSettingsOpen:t.isSettingsDialogOpen,settingsPath:t.settingsPage,settingsEntityId:n.settingsEntityId,diffFile:a||i?null:t.pendingDiffFile??n.diffFile,diffScope:a||i?null:n.diffScope,scheduleView:a&&r===`schedule`?n.scheduleView:null,scheduleProjectId:a&&r===`schedule`?n.scheduleProjectId:null,scheduleTaskId:a&&r===`schedule`?n.scheduleTaskId:null,assistantId:a&&r===`assistant`?De()??n.assistantId:null,focusSessionId:a?n.focusSessionId:null}},[]),C=Q.useCallback((n={})=>{e||t||r.current||(as(S(),n),l($o()))},[e,t,S]);Q.useEffect(()=>{if(n.current||(n.current=!0,!ns()))return;let r=$o();(async()=>{await x(r),!e&&!t&&as({...S(),isNewSession:r.isNewSession||S().isNewSession,sessionId:r.isNewSession?null:r.sessionId??K.getState().currentSessionId??S().sessionId,tab:r.tab??s.getState().activeMainTab,settingsPath:r.settingsPath??s.getState().settingsPage,diffFile:r.isNewSession?null:r.diffFile??s.getState().pendingDiffFile},{replace:!0,force:!0})})()},[x,S,e,t]),Q.useEffect(()=>{if(!c.sessionId||c.isNewSession)return;let e=!1,t=c.sessionId;if($o().sessionId!==t||d===t&&f||i.current.has(t))return;let n=cs(t);if(n){i.current.delete(t),u(t,n);return}return(async()=>{let n=await us(t);if(!e&&$o().sessionId===t){if(n?.directory){i.current.delete(t);let e=K.getState();(e.currentSessionId!==t||e.currentSessionDirectory!==n.directory)&&u(t,n.directory);return}be.getState().hasLoaded&&b(t)}})(),()=>{e=!0}},[v,y,f,d,b,_,c.isNewSession,c.sessionId,u]),Q.useEffect(()=>{let t=d===c.sessionId&&!!f;if(!c.sessionId||c.isNewSession||e||t)return;let n=c.sessionId,r=setTimeout(()=>{let e=K.getState(),t=e.currentSessionId===n&&!!e.currentSessionDirectory;$o().sessionId===n&&!t&&b(n)},ds);return()=>clearTimeout(r)},[f,d,b,e,c.sessionId]),Q.useEffect(()=>{if(e||t)return;let n=K.getState().currentSessionId,i=!!K.getState().newSessionDraft?.open;return K.subscribe(e=>{let t=e.currentSessionId,a=!!e.newSessionDraft?.open;t===n&&a===i||r.current||(n=t,i=a,C(),l($o()))})},[e,t,C]),Q.useEffect(()=>{if(e||t)return;let n=s.getState().activeMainTab,i=s.getState().isSettingsDialogOpen,a=s.getState().settingsPage,o=s.getState().pendingDiffFile;return s.subscribe(e=>{if(r.current)return;let t=e.activeMainTab!==n,s=e.isSettingsDialogOpen!==i,c=e.settingsPage!==a,l=e.pendingDiffFile!==o&&e.activeMainTab===`diff`;n=e.activeMainTab,i=e.isSettingsDialogOpen,a=e.settingsPage,o=e.pendingDiffFile,(t||s||c||l)&&C()})},[e,t,C]),Q.useEffect(()=>{if(e||t)return;let n=De();return Ee.subscribe(()=>{if(r.current)return;if(s.getState().activeMainTab!==`assistant`){n=De();return}let e=De();e!==n&&(n=e,C())})},[e,t,C]),Q.useEffect(()=>{if(typeof window>`u`||e||t)return;let n=()=>{let e=$o();if(l(e),ns())x(e);else{let e=s.getState();e.isSettingsDialogOpen&&m(!1),e.activeMainTab!==`chat`&&p(`chat`)}};return window.addEventListener(`popstate`,n),()=>{window.removeEventListener(`popstate`,n)}},[x,e,t,p,m]),Q.useEffect(()=>{if(!(e||t))return a(e=>{o(e)&&(i.current.clear(),queueMicrotask(()=>{l($o())}))})},[e,t])}var ms=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||`/`,hs=(e,t)=>{let n=new Set;for(let r of e){if(!r.trim())continue;let e=ms(r);n.add(e);for(let[r,i]of t)if(ms(r)===e)for(let e of i)e.path.trim()&&n.add(ms(e.path))}return[...n]},gs=(e,t,n)=>{let r=hs(e,t),i=n?.currentDirectory?.trim()??``;if(!i)return{directories:r};let a=ms(i),o=null;for(let t of e){if(!t.trim())continue;let e=ms(t);(a===e||a.startsWith(`${e}/`))&&(!o||e.length>o.length)&&(o=e)}for(let[e,n]of t){let t=ms(e);for(let e of n){if(!e.path.trim())continue;let n=ms(e.path);(a===n||a.startsWith(`${n}/`))&&(!o||t.length>o.length)&&(o=t)}}if(!o)return r.includes(a)?{directories:r,priorityDirectories:[a]}:{directories:r};let s=new Set([o]);for(let[e,n]of t)if(ms(e)===o)for(let e of n)e.path.trim()&&s.add(ms(e.path));r.includes(a)&&s.add(a);let c=r.filter(e=>s.has(e));return c.length===0||c.length>=r.length?{directories:r}:{directories:r,priorityDirectories:c}},_s=async(e,t=Se,n)=>{try{await t(e,n)}catch(e){console.warn(`[SessionStartup] Initial session index sync failed:`,e)}finally{de()}},vs=async(e,t,n=Se,r=_e)=>{r().catch(e=>{console.warn(`[SessionStartup] Early session index hydrate failed:`,e)}),await e;let i=t();await _s(i.directories,n,{priorityDirectories:i.priorityDirectories})},ys=()=>{let e=(0,Qn.c)(2),t=Q.useRef(!1),n,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>{if(t.current)return;t.current=!0;let e=Re(r());vs(e,xs),Promise.resolve(e).then(ws)},i=[],e[0]=n,e[1]=i):(n=e[0],i=e[1]),Q.useLayoutEffect(n,i),null};function bs(e){return e.path}function xs(){return gs(ue.getState().projects.map(bs),K.getState().availableWorktreesByProject,{currentDirectory:T.getState().currentDirectory})}function Ss(e){return e.path}function Cs(e){console.warn(`[SessionStartup] Batch git discovery failed (fallback to per-directory):`,e)}function ws(){let e=ue.getState().projects.map(Ss);e.length!==0&&Ie(e).catch(Cs)}var Ts=()=>{let e=(0,Qn.c)(13),[t,n]=(0,Q.useState)(!1),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{n(l())},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Q.useEffect)(r,i);let a;e[2]===t?a=e[3]:(a=async e=>t?await m(e):{success:!0,path:e},e[2]=t,e[3]=a);let o=a,s;e[4]===t?s=e[5]:(s=async e=>t?await u(e):{success:!0},e[4]=t,e[5]=s);let c=s,d;e[6]===t?d=e[7]:(d=async e=>t?await v(e):{success:!0},e[6]=t,e[7]=d);let f=d,p;return e[8]!==t||e[9]!==o||e[10]!==c||e[11]!==f?(p={isDesktop:t,requestAccess:o,startAccessing:c,stopAccessing:f},e[8]=t,e[9]=o,e[10]=c,e[11]=f,e[12]=p):p=e[12],p},Es=e=>e.trim().replace(/\s+/g,`-`).replace(/[^A-Za-z0-9._/-]/g,`-`).replace(/-+/g,`-`).replace(/\/{2,}/g,`/`).replace(/\/-+/g,`/`).replace(/-+\//g,`/`).replace(/^[-/]+/,``).replace(/[-/]+$/,``),Ds=({currentBranch:e,onRename:t,showEditButton:n=!0,iconOnly:r=!1})=>{let{t:i}=ee(),[a,o]=Q.useState(!1),[s,c]=Q.useState(e||``),[l,u]=Q.useState(!1),d=Q.useRef(null),f=()=>{!e||!t||(c(e),o(!0),setTimeout(()=>d.current?.focus(),0))},p=async()=>{if(!e||!t||!s.trim())return;let n=Es(s);if(n===e){o(!1);return}u(!0);try{await t(e,n),o(!1),c(``)}finally{u(!1)}},m=()=>{o(!1),c(``)},h=e=>{e.key===`Enter`?(e.preventDefault(),p()):e.key===`Escape`&&(e.preventDefault(),m())};if(a)return(0,$.jsx)(`div`,{className:`flex h-6 items-center gap-1.5 rounded-md bg-primary/12 px-1.5`,children:(0,$.jsxs)(`form`,{className:`flex w-full items-center gap-1.5`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5 text-primary`}),(0,$.jsx)(`input`,{ref:d,value:s,onChange:e=>c(e.target.value),className:`flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground`,placeholder:i(`gitView.branch.namePlaceholder`),onKeyDown:h,autoFocus:!0}),(0,$.jsx)(`button`,{type:`submit`,disabled:l,"aria-label":i(l?`gitView.branch.renameSaving`:`gitView.branch.renameSave`),title:i(l?`gitView.branch.renameSaving`:`gitView.branch.renameSave`),className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:l?(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(X,{name:`check`,className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`button`,onClick:m,disabled:l,"aria-label":i(`gitView.branch.renameCancel`),title:i(`gitView.branch.renameCancel`),className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,$.jsx)(X,{name:`close`,className:`size-3.5`})})]})});let g=e||i(`gitView.branch.detachedHead`);return r?(0,$.jsxs)(lt,{children:[(0,$.jsx)(st,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,onClick:f,disabled:!e||!t,"aria-label":g,children:(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5`})})}),(0,$.jsx)(ct,{sideOffset:8,children:g})]}):(0,$.jsxs)(`div`,{className:`flex h-6 w-full min-w-0 items-center gap-1 px-0`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5 text-primary shrink-0`}),(0,$.jsxs)(`div`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:g}),n&&t&&e&&(0,$.jsx)(Z,{variant:`ghost`,size:`xs`,className:`size-6 p-0 shrink-0`,onClick:f,title:i(`gitView.branch.renameTitle`),children:(0,$.jsx)(X,{name:`edit`,className:`size-3.5`})})]})]})},Os=e=>{let t=(0,Qn.c)(38),{syncAction:n,remotes:r,onSync:i,disabled:a,aheadCount:o,behindCount:s,trackingRemoteName:c,hasUncommittedChanges:l}=e,u;t[0]===r?u=t[1]:(u=r===void 0?[]:r,t[0]=r,t[1]=u);let d=u,f=o===void 0?0:o,p=s===void 0?0:s,m=l!==void 0&&l,{t:h}=ee(),g;t[2]!==d||t[3]!==c?(g=d.find(e=>e.name===c)??d[0],t[2]=d,t[3]=c,t[4]=g):g=t[4];let _=g,v=p>0&&m,y=a||n!==null||!_||v,b=f>0||p>0,x;t[5]!==f||t[6]!==p||t[7]!==v||t[8]!==b||t[9]!==h||t[10]!==_?(x=v?h(`gitView.sync.commitOrStashTooltip`):_?b?h(`gitView.sync.syncChangesTooltip`,{ahead:f,behind:p}):h(`gitView.sync.syncChanges`):h(`gitView.sync.noRemoteTooltip`),t[5]=f,t[6]=p,t[7]=v,t[8]=b,t[9]=h,t[10]=_,t[11]=x):x=t[11];let S=x,C;t[12]!==i||t[13]!==_?(C=()=>{_&&i(_)},t[12]=i,t[13]=_,t[14]=C):C=t[14];let w=C,T=b?0:void 0,E;t[15]!==f||t[16]!==p||t[17]!==b||t[18]!==h?(E=b?h(`gitView.sync.syncChangesTooltip`,{ahead:f,behind:p}):h(`gitView.sync.syncChanges`),t[15]=f,t[16]=p,t[17]=b,t[18]=h,t[19]=E):E=t[19];let D;t[20]===n?D=t[21]:(D=n===`sync`?(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(X,{name:`refresh`,className:`size-3.5`}),t[20]=n,t[21]=D);let O;t[22]===b?O=t[23]:(O=b?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -right-0.5 top-0 size-1 rounded-full bg-[var(--status-error)] ring-1 ring-[var(--surface-background)]`}):null,t[22]=b,t[23]=O);let k;t[24]!==D||t[25]!==O?(k=(0,$.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[D,O]}),t[24]=D,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==w||t[28]!==y||t[29]!==E||t[30]!==k?(A=(0,$.jsx)(st,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:w,disabled:y,className:`inline-flex h-6 w-fit shrink-0 items-center justify-center gap-1 rounded px-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":E,children:k})}),t[27]=w,t[28]=y,t[29]=E,t[30]=k,t[31]=A):A=t[31];let j;t[32]===S?j=t[33]:(j=(0,$.jsx)(ct,{side:`bottom`,sideOffset:8,children:S}),t[32]=S,t[33]=j);let M;return t[34]!==A||t[35]!==j||t[36]!==T?(M=(0,$.jsxs)(lt,{delayDuration:T,children:[A,j]}),t[34]=A,t[35]=j,t[36]=T,t[37]=M):M=t[37],M},ks={branch:`git-branch`,briefcase:`briefcase`,house:`home`,graduation:`graduation-cap`,code:`code`,heart:`heart`,user:`user-3`},As={keyword:`var(--syntax-keyword)`,error:`var(--status-error)`,string:`var(--syntax-string)`,function:`var(--syntax-function)`,type:`var(--syntax-type)`,success:`var(--status-success)`,info:`var(--status-info)`,warning:`var(--status-warning)`};function js(e){return e&&As[e]||`var(--primary)`}var Ms=e=>{let t=(0,Qn.c)(36),{activeProfile:n,identities:r,onSelect:i,isApplying:a,iconOnly:o}=e,s=o!==void 0&&o,{t:c}=ee(),l=ks[n?.icon??`branch`]??`user-3`,u=n?.color,d;t[0]===u?d=t[1]:(d=js(u),t[0]=u,t[1]=d);let f;t[2]===d?f=t[3]:(f={color:d},t[2]=d,t[3]=f);let p=a||r.length===0,m=a?`loader-4`:l,h=a?`size-4 animate-spin`:`size-4`,g;t[4]!==m||t[5]!==h?(g=(0,$.jsx)(X,{name:m,className:h}),t[4]=m,t[5]=h,t[6]=g):g=t[6];let _;t[7]!==n?.name||t[8]!==s||t[9]!==c?(_=s?null:(0,$.jsx)(`span`,{className:`git-identity-label min-w-0 flex-1 truncate text-left`,children:n?.name||c(`gitView.header.noIdentity`)}),t[7]=n?.name,t[8]=s,t[9]=c,t[10]=_):_=t[10];let v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4 opacity-60`}),t[11]=v):v=t[11];let y;t[12]!==f||t[13]!==p||t[14]!==g||t[15]!==_?(y=(0,$.jsx)(st,{asChild:!0,children:(0,$.jsx)(bt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-8 min-w-0 max-w-[15rem] justify-start gap-1.5 px-2 py-1 typography-ui-label`,style:f,disabled:p,children:[g,_,v]})})}),t[12]=f,t[13]=p,t[14]=g,t[15]=_,t[16]=y):y=t[16];let b;t[17]===c?b=t[18]:(b=c(`gitView.header.identityTooltip`),t[17]=c,t[18]=b);let x;t[19]===b?x=t[20]:(x=(0,$.jsx)(ct,{sideOffset:8,children:b}),t[19]=b,t[20]=x);let S;t[21]!==y||t[22]!==x?(S=(0,$.jsxs)(lt,{children:[y,x]}),t[21]=y,t[22]=x,t[23]=S):S=t[23];let C;if(t[24]!==n?.id||t[25]!==r||t[26]!==i){let e;t[28]!==n?.id||t[29]!==i?(e=e=>(0,$.jsxs)(xt,{onSelect:()=>i(e),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.name}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e.userEmail})]}),n?.id===e.id?(0,$.jsx)(X,{name:`check`,className:`ml-auto size-4 text-foreground`}):null]},e.id),t[28]=n?.id,t[29]=i,t[30]=e):e=t[30],C=r.map(e),t[24]=n?.id,t[25]=r,t[26]=i,t[27]=C}else C=t[27];let w;t[31]===C?w=t[32]:(w=(0,$.jsx)(vt,{align:`end`,className:`w-64`,children:C}),t[31]=C,t[32]=w);let T;return t[33]!==S||t[34]!==w?(T=(0,$.jsxs)(yt,{children:[S,w]}),t[33]=S,t[34]=w,t[35]=T):T=t[35],T},Ns=(e,t)=>e??t,Ps=e=>e===`/`,Fs=e=>e.replace(/\\/g,`/`),Is=e=>{if(!e||Ps(e))return e;let t=e;for(;t.length>1&&t.endsWith(`/`);)t=t.slice(0,-1);return t},Ls=e=>e.endsWith(`/`),Rs=e=>{let t=e.trim();return!t||Ls(t)?t:`${t}/`},zs=e=>e.lastIndexOf(`/`),Bs=e=>{if(Ls(e))return e;let t=zs(e);return t<0?e:e.slice(0,t+1)},Vs=e=>{let t=zs(e);return e.slice(t+1)},Hs=e=>{let t=Is(e.trim());if(!t||t===`~`||t===`~/`||t===`/`)return null;let n=zs(t);return n<0?null:t.startsWith(`~/`)&&n<=1?`~/`:n===0?`/`:`${t.slice(0,n)}/`},Us=e=>Ls(e)&&Hs(e)!==null,Ws=(e,t)=>`${Bs(e)}${t}/`,Gs=e=>{if(!e)return null;let t=Is(Fs(e.trim()));return t?t.toLowerCase():null},Ks=(e,t)=>{let n=e.trim();return n===`~`?t:n.startsWith(`~/`)?`${t}${n.slice(1)}`:n},qs=e=>typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey,Js=e=>{if(!e)return;e.focus({preventScroll:!0});let t=e.value.length;e.setSelectionRange(t,t),e.scrollLeft=e.scrollWidth},Ys=async()=>{try{let e=await f(`/api/fs/home`,{method:`GET`,headers:{Accept:`application/json`}});if(e.ok){let t=await e.json();if(typeof t.home==`string`&&t.home.trim().length>0)return Fs(t.home.trim())}}catch{}return w.getFilesystemHome().catch(()=>null)},Xs=({open:e,onOpenChange:t,forceMobile:n})=>{let{t:r}=ee(),i=T(e=>e.homeDirectory),a=ue(e=>e.projects),o=ue(e=>e.addProject),s=Nn(e=>e.profiles),c=Nn(e=>e.globalIdentity),l=Nn(e=>e.defaultGitIdentityId),u=Nn(e=>e.loadProfiles),d=Nn(e=>e.loadGlobalIdentity),f=Nn(e=>e.loadDefaultGitIdentityId),{isDesktop:p,requestAccess:m,startAccessing:h}=Ts(),g=Ns(n,jt().isMobile),_=Q.useRef(null),v=Q.useRef(new Map),[y,b]=Q.useState(``),[x,S]=Q.useState(`~/`),[C,E]=Q.useState([]),[D,O]=Q.useState(!1),[k,A]=Q.useState(!1),[M,N]=Q.useState(0),[P,F]=Q.useState(!1),[I,te]=Q.useState(!1),[ne,L]=Q.useState(!1),[R,z]=Q.useState(``),[B,V]=Q.useState(null),[H,U]=Q.useState(!1),W=y||i,re=Q.useMemo(()=>new Set(a.map(e=>Gs(e.path)).filter(e=>!!e)),[a]);Q.useEffect(()=>{if(!e)return;S(`~/`),E([]),N(0),F(!1),te(!1),L(!1),z(``),V(null),U(!1),requestAnimationFrame(()=>Js(_.current));let t=!1;return(async()=>{let e=await Ys();t||(b(e||i||``),requestAnimationFrame(()=>Js(_.current)))})(),()=>{t=!0}},[i,e]),Q.useEffect(()=>{e&&(u(),d(),f())},[f,u,d,e]);let ie=Q.useMemo(()=>{let e=new Map;c&&e.set(c.id,c);for(let t of s)e.set(t.id,t);return Array.from(e.values())},[s,c]);Q.useEffect(()=>{if(!e||!ne||B!==null)return;let t=typeof l==`string`?l.trim():``;if(t&&ie.some(e=>e.id===t)){V(t);return}let n=ie.find(e=>e.authType===`ssh`||e.sshKey);n&&V(n.id)},[ie,l,ne,e,B]);let G=Q.useMemo(()=>ie.find(e=>e.id===B)??null,[ie,B]),ae=Q.useMemo(()=>Bs(x),[x]),oe=Q.useMemo(()=>Ls(x)?``:Vs(x),[x]),se=Q.useMemo(()=>W?Ks(ae,W):``,[ae,W]);Q.useEffect(()=>{if(!e||!se){E([]);return}let t=!1;return O(!0),A(!1),w.listLocalDirectory(se).then(e=>{if(t)return;A(!1);let n=e.filter(e=>e.isDirectory).map(e=>({name:e.name,path:Fs(e.path)})).sort((e,t)=>e.name.localeCompare(t.name));E(n)}).catch(()=>{t||(E([]),A(!0))}).finally(()=>{t||O(!1)}),()=>{t=!0}},[se,e]);let ce=Q.useMemo(()=>{let e=oe.toLowerCase(),t=H||oe.startsWith(`.`);return C.filter(n=>n.name.toLowerCase().startsWith(e)&&(t||!n.name.startsWith(`.`)))},[oe,C,H]),le=Q.useMemo(()=>{let e=[];Us(x)&&e.push({type:`up`,value:`browse:up`,name:`..`,path:Hs(x)});for(let t of ce){let n=Gs(t.path);e.push({type:`directory`,value:`browse:${t.path}`,name:t.name,path:t.path,alreadyAdded:!!(n&&re.has(n))})}return e},[re,ce,x]);Q.useEffect(()=>{N(0)},[x,le.length]);let q=Q.useMemo(()=>W?Is(Ks(x,W)):``,[W,x]),de=Gs(q),fe=!!(de&&re.has(de)),pe=Q.useMemo(()=>oe?ce.find(e=>e.name===oe)??null:null,[oe,ce]),me=!!(q&&!fe&&(Ls(x)&&k||!Ls(x)&&oe.trim().length>0&&pe===null)),he=!P&&!I&&!fe&&!!q,ge=he&&R.trim().length>0,_e=le[M]??null,ve=!!_e,ye=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl`,be=r(fe?`directoryExplorerDialog.actions.alreadyAdded`:ne?P?`directoryExplorerDialog.actions.cloning`:`directoryExplorerDialog.actions.cloneAndAdd`:P?`directoryExplorerDialog.actions.adding`:me?`directoryExplorerDialog.actions.createAndAdd`:`directoryExplorerDialog.actions.addProject`);Q.useLayoutEffect(()=>{e&&Js(_.current)},[e]),Q.useLayoutEffect(()=>{let e=le[M];e&&v.current.get(e.value)?.scrollIntoView({block:`nearest`})},[M,le]);let xe=j(()=>{t(!1)}),Se=j(e=>{let t=K.getState();t.newSessionDraft?.open&&t.setNewSessionDraftTarget({projectId:e.id,directoryOverride:e.path},{force:!0})}),Ce=j((e,t)=>{e.stopPropagation();let n=Gs(t);if(n&&re.has(n))return;let i=o(t);if(!i){J.error(r(`directoryExplorerDialog.toast.failedToAddProject`),{description:r(`directoryExplorerDialog.toast.selectValidDirectoryPath`)});return}Se(i)}),we=j(async e=>{if(!e||P)return;let t=Gs(e);if(t&&re.has(t))return;let n=e;F(!0);try{let t=!ne&&me&&Gs(e)===Gs(q);if(ne){let t=R.trim();if(!t){J.error(r(`directoryExplorerDialog.toast.cloneUrlRequired`));return}n=(await w.cloneRepository({remoteUrl:t,destinationPath:e,gitIdentityId:G?.id??null})).path}else t&&await w.createDirectory(e);let i=o(n);if(!i){J.error(r(`directoryExplorerDialog.toast.failedToAddProject`),{description:r(`directoryExplorerDialog.toast.selectValidDirectoryPath`)});return}Se(i),xe()}catch(e){J.error(r(`directoryExplorerDialog.toast.failedToSelectDirectory`),{description:e instanceof Error?e.message:r(`directoryExplorerDialog.toast.unknownError`)})}finally{F(!1)}}),Te=j(e=>{S(Rs(e))}),Ee=j(e=>{S(Ws(x,e.name))}),De=j(e=>{if(e){if(e.type===`up`){e.path&&Te(e.path);return}Ee(e)}}),Oe=j(async()=>{if(!(!p||I)){te(!0);try{let e=await m(q);if(!e.success||!e.path){e.error&&e.error!==`Directory selection cancelled`&&J.error(r(`directoryExplorerDialog.toast.failedToSelectDirectory`),{description:e.error});return}let t=await h(e.path);if(!t.success){J.error(r(`directoryExplorerDialog.toast.failedToOpenDirectory`),{description:t.error||r(`directoryExplorerDialog.toast.desktopCouldNotGrantAccess`)});return}await we(e.path)}catch(e){J.error(r(`directoryExplorerDialog.toast.failedToSelectDirectory`),{description:e instanceof Error?e.message:r(`directoryExplorerDialog.toast.unknownError`)})}finally{te(!1)}}}),ke=j(e=>{if(e.key===`ArrowDown`){e.preventDefault(),N(e=>Math.min(le.length-1,e+1));return}if(e.key===`ArrowUp`){e.preventDefault(),N(e=>Math.max(0,e-1));return}if(e.key===`Enter`){if(e.preventDefault(),qs(e)){we(q);return}ve&&De(_e);return}e.key===`Backspace`&&x===``&&(e.preventDefault(),xe())}),Ie=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>U(e=>!e),className:`flex flex-shrink-0 items-center gap-2 rounded-lg px-2 py-1 typography-meta text-muted-foreground transition-colors hover:bg-interactive-hover/40`,children:[H?(0,$.jsx)(X,{name:`checkbox`,className:`h-4 w-4 text-primary`}):(0,$.jsx)(X,{name:`checkbox-blank`,className:`h-4 w-4`}),r(`directoryExplorerDialog.toggle.showHidden`)]}),Le=(0,$.jsxs)(`div`,{className:`px-2.5 py-1.5`,children:[ne?(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5`,children:[(0,$.jsx)(ot,{value:R,onChange:e=>z(e.target.value),placeholder:r(`directoryExplorerDialog.clone.remoteUrlPlaceholder`),className:`min-w-0 flex-1 border-border/60 bg-[var(--surface-elevated)] font-mono typography-ui-label shadow-none`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`}),(0,$.jsx)(Ms,{activeProfile:G,identities:ie,onSelect:e=>V(e.id),isApplying:P,iconOnly:!0})]}):null,(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{name:`folder-add`,className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/80`}),(0,$.jsx)(ot,{ref:_,value:x,onChange:e=>S(Fs(e.target.value)),onKeyDown:ke,placeholder:r(`directoryExplorerDialog.pathInput.placeholder`),className:`border-transparent bg-transparent pl-9 font-mono typography-ui-label shadow-none focus-visible:ring-0`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`})]})]}),Re=(0,$.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm dark:shadow-none`,children:(0,$.jsxs)(`div`,{className:`max-h-[min(28rem,58vh)] overflow-y-auto p-2`,children:[(0,$.jsx)(`div`,{className:`px-2 pb-1 pt-0.5 typography-meta font-medium uppercase tracking-wide text-muted-foreground/80`,children:r(`directoryExplorerDialog.browse.directories`)}),D?(0,$.jsx)(`div`,{className:`py-10 text-center typography-ui-label text-muted-foreground`,children:r(`directoryExplorerDialog.browse.loading`)}):le.length===0?(0,$.jsx)(`div`,{className:`py-10 text-center typography-ui-label text-muted-foreground`,children:r(`directoryExplorerDialog.browse.empty`)}):(0,$.jsx)(`div`,{className:`space-y-0.5`,children:le.map((e,t)=>{let n=t===M;return(0,$.jsxs)(`div`,{onMouseEnter:()=>N(t),className:Y(`flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,n&&`bg-interactive-selection text-interactive-selection-foreground`,!n&&`hover:bg-interactive-hover/50`),children:[(0,$.jsxs)(`button`,{ref:t=>{t?v.current.set(e.value,t):v.current.delete(e.value)},type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>De(e),className:`flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[e.type===`up`?(0,$.jsx)(X,{name:`arrow-left-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/80`}):(0,$.jsx)(X,{name:`folder-6`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/80`}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:e.name})})]}),e.type===`directory`&&e.alreadyAdded?(0,$.jsx)(`span`,{className:`rounded-full border border-border/60 px-2 py-0.5 typography-meta text-muted-foreground`,children:r(`directoryExplorerDialog.browse.addedBadge`)}):e.type===`directory`?(0,$.jsx)(`button`,{type:`button`,onMouseDown:e=>e.stopPropagation(),onClick:t=>Ce(t,e.path),className:`flex-shrink-0 rounded-full p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,title:r(`directoryExplorerDialog.browse.quickAdd`),children:(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`})}):null]},e.value)})})]})}),ze=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[Le,Re]}),Be=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(X,{name:`arrow-up-s`,className:`h-3.5 w-3.5`}),(0,$.jsx)(X,{name:`arrow-down-s`,className:`-ml-1 h-3.5 w-3.5`}),r(`directoryExplorerDialog.footer.navigate`)]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(X,{name:`corner-down-left`,className:`h-3.5 w-3.5`}),r(`directoryExplorerDialog.footer.select`)]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(`span`,{children:ye}),(0,$.jsx)(X,{name:`corner-down-left`,className:`h-3.5 w-3.5`}),r(`directoryExplorerDialog.footer.add`)]})]}),Ve=()=>(0,$.jsxs)($.Fragment,{children:[g?null:Be,(0,$.jsxs)(`div`,{className:Y(`flex w-full flex-row justify-end gap-2 sm:w-auto`,g&&`justify-stretch`),children:[p?(0,$.jsx)(Z,{variant:`ghost`,size:`xs`,onClick:Oe,disabled:P||I||ne,children:r(I?`directoryExplorerDialog.actions.openingFinder`:`directoryExplorerDialog.actions.openInFinder`)}):null,(0,$.jsx)(Z,{variant:`ghost`,size:`xs`,onClick:()=>L(e=>!e),disabled:P||I,className:Y(g&&`flex-1`),children:r(ne?`directoryExplorerDialog.actions.addLocalProject`:`directoryExplorerDialog.actions.cloneRepository`)}),g?(0,$.jsx)(Z,{size:`xs`,onClick:()=>void we(q),disabled:ne?!ge:!he,className:`flex-1`,children:be}):(0,$.jsx)(Z,{size:`xs`,onClick:()=>void we(q),disabled:ne?!ge:!he,children:be})]})]});return g?(0,$.jsx)(Ht,{open:e,onClose:xe,title:r(`directoryExplorerDialog.title`),className:`h-[88dvh] max-h-[720px] max-w-full`,contentMaxHeightClassName:`flex-1`,footer:(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:Ve()}),children:(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`flex justify-end`,children:Ie}),ze]})}):(0,$.jsx)(Fe,{open:e,onOpenChange:t,children:(0,$.jsxs)(Me,{className:`flex w-full max-w-xl flex-col gap-0 overflow-hidden p-0 sm:max-h-[80vh]`,initialFocus:!1,children:[(0,$.jsx)(Ae,{className:`px-5 pb-2 pt-5`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Ne,{children:r(`directoryExplorerDialog.title`)}),(0,$.jsx)(Pe,{className:`mt-2`,children:r(`directoryExplorerDialog.description`)})]}),Ie]})}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 px-2 pb-0`,children:ze}),(0,$.jsx)(je,{className:`flex w-full flex-col gap-3 px-5 py-3 sm:flex-row sm:items-center sm:justify-between`,children:Ve()})]})})},Zs=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim().length>0)return t.error}catch{return t}return t},Qs=e=>{let t=typeof e==`string`?e.trim():``;if(!t)throw Error(`projectId is required`);return t},$s=e=>e===null||typeof e==`string`,ec=e=>e===null||typeof e==`number`&&Number.isFinite(e),tc=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=864e13,nc=e=>e===null||tc(e),rc=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.projectId==`string`&&t.projectId.length>0&&typeof t.taskId==`string`&&t.taskId.length>0&&typeof t.taskName==`string`&&(t.trigger===`scheduled`||t.trigger===`manual`)&&(t.status===`running`||t.status===`success`||t.status===`error`)&&$s(t.sessionId)&&$s(t.directory)&&$s(t.error)&&tc(t.startedAt)&&nc(t.finishedAt)&&ec(t.durationMs)&&(t.durationMs===null||t.durationMs>=0)},ic=e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed scheduled task runs response`);let t=e;if(!Array.isArray(t.runs)||!t.runs.every(rc)||!$s(t.nextCursor)||typeof t.complete!=`boolean`||t.complete!==(t.nextCursor===null)||t.nextCursor!==null&&t.nextCursor.length===0)throw Error(`Malformed scheduled task runs response`);return{runs:t.runs,nextCursor:t.nextCursor,complete:t.complete}},ac=async(e,t)=>{let n=new URLSearchParams;e.before&&n.set(`before`,e.before);let r=e.limit??20;if(!Number.isInteger(r)||r<1)throw Error(`limit must be a positive integer`);n.set(`limit`,String(r)),e.projectId&&n.set(`projectId`,e.projectId),e.taskId&&n.set(`taskId`,e.taskId);let i=await f(`/api/openchamber/scheduled-task-runs?${n.toString()}`,{signal:t});if(!i.ok)throw Error(await Zs(i,`Failed to load scheduled task history`));return ic(await i.json().catch(()=>null))},oc=async()=>{let e=await f(`/api/openchamber/scheduled-tasks`);if(!e.ok)throw Error(await Zs(e,`Failed to load schedules`));let t=await e.json().catch(()=>null);return{tasks:Array.isArray(t?.tasks)?t.tasks:[],failedProjectIds:Array.isArray(t?.failedProjectIds)?t.failedProjectIds.filter(e=>typeof e==`string`):[]}},sc=async(e,t)=>{let n=Qs(e),r=await f(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks`,{method:`PUT`,headers:{"content-type":`application/json`,accept:`application/json`},body:JSON.stringify({task:t})});if(!r.ok)throw Error(await Zs(r,`Failed to save schedule`));let i=await r.json().catch(()=>null);return!i||!Array.isArray(i.tasks)?[]:i.tasks},cc=async(e,t)=>{let n=Qs(e),r=Qs(t),i=await f(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(r)}`,{method:`DELETE`,headers:{accept:`application/json`}});if(!i.ok)throw Error(await Zs(i,`Failed to delete schedule`));let a=await i.json().catch(()=>null);return!a||!Array.isArray(a.tasks)?[]:a.tasks},lc=async(e,t)=>{let n=Qs(e),r=Qs(t),i=await f(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(r)}/run`,{method:`POST`,headers:{accept:`application/json`}});if(!i.ok)throw Error(await Zs(i,`Failed to run schedule`));let a=await i.json().catch(()=>null);return{sessionId:typeof a?.sessionId==`string`&&a.sessionId.length>0?a.sessionId:void 0}},uc=`oc-settings-group-row border-b border-[var(--oc-settings-row-divider)] last:border-b-0`,dc=`oc-settings-group-label`,fc=Zn();function pc(e){if(!e||!e.trim())return{valid:!1,error:`required`};try{return fc.CronExpressionParser.parse(e),{valid:!0}}catch(e){return{valid:!1,error:e instanceof Error?e.message:`Invalid cron expression`}}}function mc(e,t,n=4){try{let r=t?{tz:t,currentDate:new Date}:{currentDate:new Date},i=fc.CronExpressionParser.parse(e,r),a=[];for(let e=0;e<n;e+=1){let e=i.next();e&&a.push(e.toDate())}return a}catch{return[]}}var hc=[{expression:`*/5 * * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.every5min`},{expression:`0 * * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.everyHour`},{expression:`0 9 * * 1`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.monday9am`},{expression:`0 9,17 * * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.9am5pm`},{expression:`0 0 1 * *`,labelKey:`sessions.scheduledTasks.editor.cronExpression.examples.firstOfMonth`}],gc=[0,1,2,3,4,5,6],_c=`!h-9 !min-h-9 w-full min-w-0 rounded-full border-0 bg-[var(--surface-elevated)] px-3 py-1 ring-1 ring-inset ring-border/60 transition-[background-color,box-shadow,transform] duration-150 ease-out hover:[&:not(:focus)]:bg-[var(--surface-subtle)] hover:[&:not(:focus)]:ring-transparent active:scale-[0.99] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] data-[popup-open]:bg-[var(--surface-subtle)] data-[popup-open]:shadow-sm motion-reduce:transition-none`,vc=`oc-settings-inline-value`,yc=`oc-settings-split-row ${uc}`,bc=vc,xc=yc,Sc=()=>{let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`},Cc=e=>{let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=new Date(n,r-1,i);return Number.isNaN(a.getTime())||a.getFullYear()!==n||a.getMonth()!==r-1||a.getDate()!==i?null:a},wc=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,Tc=(e,t,n)=>{let r=Cc(e);return r?new Intl.DateTimeFormat(n,{month:`short`,day:`numeric`,year:`numeric`}).format(r):t},Ec=(e,t)=>new Date(e.getFullYear(),e.getMonth()+t,1),Dc=(e,t)=>{let n=e.getFullYear(),r=e.getMonth(),i=(new Date(n,r,1).getDay()-t+7)%7,a=new Date(n,r+1,0).getDate(),o=new Date(n,r,0).getDate(),s=[];for(let e=0;e<42;e+=1){let t=e-i+1;if(t<=0){let e=o+t;s.push({date:new Date(n,r-1,e),inCurrentMonth:!1});continue}if(t>a){s.push({date:new Date(n,r+1,t-a),inCurrentMonth:!1});continue}s.push({date:new Date(n,r,t),inCurrentMonth:!0})}return s},Oc=e=>{let t=/^([01]\d|2[0-3]):([0-5]\d)$/.exec(e);if(!t)return{hour24:`00`,hour12:`12`,minute:`00`,meridiem:`AM`};let n=Number(t[1]),r=t[2],i=n>=12?`PM`:`AM`,a=n%12==0?12:n%12;return{hour24:String(n).padStart(2,`0`),hour12:String(a).padStart(2,`0`),minute:r,meridiem:i}},kc=(e,t,n)=>{let r=Number(e),i=Number(t),a=Number.isFinite(r)?Math.min(12,Math.max(1,r)):12,o=Number.isFinite(i)?Math.min(59,Math.max(0,i)):0,s=a%12;return n===`PM`&&(s+=12),`${String(s).padStart(2,`0`)}:${String(o).padStart(2,`0`)}`},Ac=(e,t)=>{let{max:n,min:r=0,loop:i=!1}=t,a=Number.parseInt(e,10);return Number.isFinite(a)?(i?(a>n&&(a=r),a<r&&(a=n)):(a>n&&(a=n),a<r&&(a=r)),String(a).padStart(2,`0`)):`00`},jc=e=>/^(0[1-9]|1[0-2])$/.test(e)?e:Ac(e,{min:1,max:12}),Mc=e=>/^[0-5][0-9]$/.test(e)?e:Ac(e,{max:59}),Nc=(e,t)=>Ac(String(Number.parseInt(e,10)+t),{min:1,max:12,loop:!0}),Pc=(e,t)=>Ac(String(Number.parseInt(e,10)+t),{min:0,max:59,loop:!0}),Fc=e=>{try{let t=Intl.Locale;if(typeof t!=`function`)return 1;let n=new t(e).weekInfo?.firstDay;return typeof n==`number`?n%7:1}catch{return 1}},Ic=e=>{try{let t=new Intl.DateTimeFormat(e,{hour:`numeric`}).resolvedOptions();return typeof t.hour12==`boolean`?!t.hour12:t.hourCycle===`h23`||t.hourCycle===`h24`}catch{return!0}},Lc=e=>{let t=new Intl.DateTimeFormat(e,{weekday:`short`}),n=new Date(2023,0,1);return gc.map(e=>t.format(new Date(n.getFullYear(),n.getMonth(),n.getDate()+e)))},Rc=(e,t)=>[...e.slice(t),...e.slice(0,t)],zc=e=>{let t=(0,Qn.c)(9),{htmlFor:n,required:r,className:i,children:a}=e,o;t[0]===i?o=t[1]:(o=Y(`typography-ui-label font-normal text-foreground`,i),t[0]=i,t[1]=o);let s;t[2]===r?s=t[3]:(s=r&&(0,$.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`}),t[2]=r,t[3]=s);let c;return t[4]!==a||t[5]!==n||t[6]!==o||t[7]!==s?(c=(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,$.jsxs)(`label`,{htmlFor:n,className:o,children:[a,s]})}),t[4]=a,t[5]=n,t[6]=o,t[7]=s,t[8]=c):c=t[8],c},Bc=e=>{let t=(0,Qn.c)(85),{value:n,onChange:r,className:i,use24Hour:a,hourAriaLabel:o,minuteAriaLabel:s,periodAriaLabel:c,amLabel:l,pmLabel:u}=e,d;t[0]===n?d=t[1]:(d=Oc(n),t[0]=n,t[1]=d);let f=d,p=Q.useRef(null),m=Q.useRef(null),[h,g]=Q.useState(null),[_,v]=Q.useState(null),y=Q.useRef(null),b=Q.useRef(null),x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{y.current=e,g(e)},t[2]=x):x=t[2];let S=x,C;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{b.current=e,v(e)},t[3]=C):C=t[3];let w=C,T=Xc,E=Zc,D=Qc,O;t[4]!==r||t[5]!==f.meridiem||t[6]!==f.minute||t[7]!==a?(O=e=>{let t=e.replace(/\D/g,``).slice(0,2);S(t),t.length===2&&(r(a?D(T(t),f.minute):kc(jc(t),f.minute,f.meridiem)),S(null),m.current?.focus())},t[4]=r,t[5]=f.meridiem,t[6]=f.minute,t[7]=a,t[8]=O):O=t[8];let k=O,A;t[9]!==r||t[10]!==f.meridiem||t[11]!==f.minute||t[12]!==a?(A=()=>{let e=y.current;if(e!==null&&(S(null),e.length!==0)){if(a){r(D(T(e.padStart(2,`0`)),f.minute));return}r(kc(jc(e.padStart(2,`0`)),f.minute,f.meridiem))}},t[9]=r,t[10]=f.meridiem,t[11]=f.minute,t[12]=a,t[13]=A):A=t[13];let j=A,M;t[14]!==r||t[15]!==f.hour12||t[16]!==f.hour24||t[17]!==f.meridiem||t[18]!==a?(M=e=>{let t=e.replace(/\D/g,``).slice(0,2);w(t),t.length===2&&(r(a?D(f.hour24,Mc(t)):kc(f.hour12,Mc(t),f.meridiem)),w(null))},t[14]=r,t[15]=f.hour12,t[16]=f.hour24,t[17]=f.meridiem,t[18]=a,t[19]=M):M=t[19];let N=M,ee;t[20]!==r||t[21]!==f.hour12||t[22]!==f.hour24||t[23]!==f.meridiem||t[24]!==a?(ee=()=>{let e=b.current;e!==null&&(w(null),e.length!==0&&r(a?D(f.hour24,Mc(e.padStart(2,`0`))):kc(f.hour12,Mc(e.padStart(2,`0`)),f.meridiem)))},t[20]=r,t[21]=f.hour12,t[22]=f.hour24,t[23]=f.meridiem,t[24]=a,t[25]=ee):ee=t[25];let P=ee,F;t[26]!==r||t[27]!==f.hour12||t[28]!==f.hour24||t[29]!==f.meridiem||t[30]!==f.minute||t[31]!==a?(F=e=>r(a?D(E(f.hour24,e),f.minute):kc(Nc(f.hour12,e),f.minute,f.meridiem)),t[26]=r,t[27]=f.hour12,t[28]=f.hour24,t[29]=f.meridiem,t[30]=f.minute,t[31]=a,t[32]=F):F=t[32];let I=F,te;t[33]!==r||t[34]!==f.hour12||t[35]!==f.hour24||t[36]!==f.meridiem||t[37]!==f.minute||t[38]!==a?(te=e=>r(a?D(f.hour24,Pc(f.minute,e)):kc(f.hour12,Pc(f.minute,e),f.meridiem)),t[33]=r,t[34]=f.hour12,t[35]=f.hour24,t[36]=f.meridiem,t[37]=f.minute,t[38]=a,t[39]=te):te=t[39];let ne=te,L;t[40]!==r||t[41]!==f.hour12||t[42]!==f.meridiem||t[43]!==f.minute?(L=e=>{e!==f.meridiem&&r(kc(f.hour12,f.minute,e))},t[40]=r,t[41]=f.hour12,t[42]=f.meridiem,t[43]=f.minute,t[44]=L):L=t[44];let R=L,z;t[45]!==j||t[46]!==I?(z=e=>{if(e.key===`ArrowRight`){e.preventDefault(),j(),m.current?.focus();return}(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),S(null),I(e.key===`ArrowUp`?1:-1))},t[45]=j,t[46]=I,t[47]=z):z=t[47];let B=z,V;t[48]!==P||t[49]!==ne?(V=e=>{if(e.key===`ArrowLeft`&&(e.currentTarget.selectionStart??0)===0){e.preventDefault(),P(),p.current?.focus();return}(e.key===`ArrowUp`||e.key===`ArrowDown`)&&(e.preventDefault(),w(null),ne(e.key===`ArrowUp`?1:-1))},t[48]=P,t[49]=ne,t[50]=V):V=t[50];let H=V,U=a?`px-2`:`pl-2 pr-1`,W;t[51]!==i||t[52]!==U?(W=Y(`flex h-9 w-full min-w-0 items-center gap-1 rounded-full border-0 bg-[var(--surface-elevated)] ring-1 ring-inset ring-border/60 transition duration-200 ease-out hover:[&:not(:focus-within)]:bg-[var(--surface-subtle)] hover:[&:not(:focus-within)]:ring-transparent focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,U,i),t[51]=i,t[52]=U,t[53]=W):W=t[53];let re=h??(a?f.hour24:f.hour12),ie;t[54]===k?ie=t[55]:(ie=e=>k(e.target.value),t[54]=k,t[55]=ie);let G;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(G=()=>S(``),t[56]=G):G=t[56];let ae;t[57]!==j||t[58]!==o||t[59]!==B||t[60]!==re||t[61]!==ie?(ae=(0,$.jsx)(`input`,{ref:p,inputMode:`numeric`,value:re,onChange:ie,onKeyDown:B,onFocus:G,onBlur:j,maxLength:2,"aria-label":o,className:`h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover`}),t[57]=j,t[58]=o,t[59]=B,t[60]=re,t[61]=ie,t[62]=ae):ae=t[62];let oe;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(`span`,{className:`font-mono text-sm text-muted-foreground`,children:`:`}),t[63]=oe):oe=t[63];let se=_??f.minute,ce;t[64]===N?ce=t[65]:(ce=e=>N(e.target.value),t[64]=N,t[65]=ce);let K;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(K=()=>w(``),t[66]=K):K=t[66];let le;t[67]!==P||t[68]!==s||t[69]!==H||t[70]!==se||t[71]!==ce?(le=(0,$.jsx)(`input`,{ref:m,inputMode:`numeric`,value:se,onChange:ce,onKeyDown:H,onFocus:K,onBlur:P,maxLength:2,"aria-label":s,className:`h-7 w-7 shrink-0 rounded-sm bg-transparent text-center font-mono text-sm tabular-nums text-foreground outline-none caret-transparent focus:bg-interactive-hover`}),t[67]=P,t[68]=s,t[69]=H,t[70]=se,t[71]=ce,t[72]=le):le=t[72];let q;t[73]!==l||t[74]!==f.meridiem||t[75]!==c||t[76]!==u||t[77]!==R||t[78]!==a?(q=a?null:(0,$.jsxs)(Je,{value:f.meridiem,onValueChange:e=>R(e),children:[(0,$.jsx)(at,{"aria-label":c,className:`ml-1 h-7 w-fit border-0 bg-transparent pl-2 pr-1 shadow-none hover:bg-interactive-hover focus:ring-0`,children:(0,$.jsx)(Ue,{})}),(0,$.jsxs)(qe,{className:`motion-reduce:transition-none`,children:[(0,$.jsx)(it,{value:`AM`,children:l}),(0,$.jsx)(it,{value:`PM`,children:u})]})]}),t[73]=l,t[74]=f.meridiem,t[75]=c,t[76]=u,t[77]=R,t[78]=a,t[79]=q):q=t[79];let ue;return t[80]!==W||t[81]!==ae||t[82]!==le||t[83]!==q?(ue=(0,$.jsxs)(`div`,{className:W,children:[ae,oe,le,q]}),t[80]=W,t[81]=ae,t[82]=le,t[83]=q,t[84]=ue):ue=t[84],ue},Vc=e=>new Date(e.getFullYear(),e.getMonth(),1),Hc=()=>{let e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate())},Uc=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),Wc=e=>{if(!e)return[`09:00`];let t=(Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[]).filter(e=>typeof e==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)).map(e=>e.trim()),n=Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t));return n.length>0?n:[`09:00`]},Gc=(e,t)=>{let n=Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`;return e?{id:e.id,name:e.name,enabled:e.enabled,schedule:{kind:e.schedule.kind===`cron`?`cron`:e.schedule.kind===`once`?`once`:e.schedule.kind===`weekly`?`weekly`:`daily`,times:Wc(e),onceDate:typeof e.schedule.date==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e.schedule.date)?e.schedule.date:Sc(),onceTime:typeof e.schedule.time==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e.schedule.time)?e.schedule.time:`09:00`,weekdays:Array.isArray(e.schedule.weekdays)?e.schedule.weekdays:[1],timezone:e.schedule.timezone||n,cronExpression:e.schedule.kind===`cron`&&typeof e.schedule.cron==`string`?e.schedule.cron:``},execution:{prompt:e.execution.prompt,providerID:e.execution.providerID,modelID:e.execution.modelID,variant:e.execution.variant||``,agent:e.execution.agent||``,goalEnabled:e.execution.goalEnabled===!0,goalTokenBudget:typeof e.execution.goalTokenBudget==`number`&&e.execution.goalTokenBudget>0?e.execution.goalTokenBudget:null},state:e.state}:{name:``,enabled:!0,schedule:{kind:`daily`,times:[`09:00`],onceDate:Sc(),onceTime:`09:00`,weekdays:[1],timezone:n,cronExpression:``},execution:{prompt:``,providerID:t.providerID,modelID:t.modelID,variant:t.variant,agent:t.agent,goalEnabled:!1,goalTokenBudget:null}}},Kc=(e,t)=>{if(!e.name.trim())return t(`sessions.scheduledTasks.editor.validation.taskNameRequired`);if(!e.execution.prompt.trim())return t(`sessions.scheduledTasks.editor.validation.promptRequired`);if(!e.execution.providerID.trim()||!e.execution.modelID.trim())return t(`sessions.scheduledTasks.editor.validation.modelRequired`);if(e.schedule.kind===`once`){if(!/^\d{4}-\d{2}-\d{2}$/.test(e.schedule.onceDate))return t(`sessions.scheduledTasks.editor.validation.dateFormat`);if(!/^([01]\d|2[0-3]):([0-5]\d)$/.test(e.schedule.onceTime))return t(`sessions.scheduledTasks.editor.validation.timeFormat`)}else if(e.schedule.kind===`cron`){if(!e.schedule.cronExpression.trim())return t(`sessions.scheduledTasks.editor.validation.cronRequired`);if(!pc(e.schedule.cronExpression).valid)return t(`sessions.scheduledTasks.editor.validation.cronInvalid`)}else if(e.schedule.times.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)).length===0)return t(`sessions.scheduledTasks.editor.validation.atLeastOneTime`);return e.schedule.kind===`weekly`&&e.schedule.weekdays.length===0?t(`sessions.scheduledTasks.editor.validation.atLeastOneWeekday`):e.schedule.timezone.trim()?null:t(`sessions.scheduledTasks.editor.validation.timezoneRequired`)},qc=e=>{let t=e.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e));return Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t))},Jc=e=>{let t=(0,Qn.c)(76),{draft:n,setDraft:r,locale:i,t:a,panel:o,mobilePanel:s}=e,c=o!==void 0&&o,l=s!==void 0&&s,u=c||l,d=l?xc:yc,f=n.schedule.cronExpression,p;t[0]===f?p=t[1]:(p=f.trim()?pc(f):null,t[0]=f,t[1]=p);let m=p,h;bb0:{if(!m?.valid||!f.trim()){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[2]=e):e=t[2],h=e;break bb0}let e;t[3]!==f||t[4]!==n.schedule.timezone?(e=mc(f,n.schedule.timezone),t[3]=f,t[4]=n.schedule.timezone,t[5]=e):e=t[5],h=e}let g=h,_;t[6]!==n.schedule.timezone||t[7]!==i?(_=e=>new Intl.DateTimeFormat(i,{timeZone:n.schedule.timezone,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(e),t[6]=n.schedule.timezone,t[7]=i,t[8]=_):_=t[8];let v=_,y=u&&`gap-0`,b;t[9]===y?b=t[10]:(b=Y(`flex flex-col gap-3`,y),t[9]=y,t[10]=b);let x=u&&d,S;t[11]===x?S=t[12]:(S=Y(`flex flex-col gap-1`,x),t[11]=x,t[12]=S);let C;t[13]===a?C=t[14]:(C=a(`sessions.scheduledTasks.editor.cronExpression.label`),t[13]=a,t[14]=C);let w;t[15]===C?w=t[16]:(w=(0,$.jsx)(zc,{htmlFor:`sched-cron`,required:!0,children:C}),t[15]=C,t[16]=w);let T=u?``:void 0,E=u&&`oc-settings-split-row-control flex-col items-end`,D;t[17]===E?D=t[18]:(D=Y(E),t[17]=E,t[18]=D);let O;t[19]===r?O=t[20]:(O=e=>r(t=>({...t,schedule:{...t.schedule,cronExpression:e.target.value}})),t[19]=r,t[20]=O);let k;t[21]===a?k=t[22]:(k=a(`sessions.scheduledTasks.editor.cronExpression.placeholder`),t[21]=a,t[22]=k);let A=u&&`min-w-[140px] text-right`,j;t[23]===A?j=t[24]:(j=Y(`w-full font-mono`,A),t[23]=A,t[24]=j);let M;t[25]!==f||t[26]!==O||t[27]!==k||t[28]!==j?(M=(0,$.jsx)(ot,{id:`sched-cron`,value:f,onChange:O,placeholder:k,className:j}),t[25]=f,t[26]=O,t[27]=k,t[28]=j,t[29]=M):M=t[29];let N;t[30]!==f||t[31]!==m||t[32]!==a?(N=m&&!m.valid&&f.trim()?(0,$.jsx)(`span`,{className:`typography-micro text-destructive`,children:a(`sessions.scheduledTasks.editor.validation.cronInvalid`)}):null,t[30]=f,t[31]=m,t[32]=a,t[33]=N):N=t[33];let ee;t[34]!==T||t[35]!==D||t[36]!==M||t[37]!==N?(ee=(0,$.jsxs)(`div`,{"data-settings-value":T,className:D,children:[M,N]}),t[34]=T,t[35]=D,t[36]=M,t[37]=N,t[38]=ee):ee=t[38];let P;t[39]!==w||t[40]!==ee||t[41]!==S?(P=(0,$.jsxs)(`div`,{className:S,children:[w,ee]}),t[39]=w,t[40]=ee,t[41]=S,t[42]=P):P=t[42];let F;t[43]!==v||t[44]!==u||t[45]!==g||t[46]!==d||t[47]!==a?(F=g.length>0?(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1`,u&&d),children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a(`sessions.scheduledTasks.editor.cronExpression.nextRuns`)}),(0,$.jsx)(`span`,{"data-settings-value":u?``:void 0,className:Y(`typography-micro text-foreground`,u&&`oc-settings-split-row-control text-right`),children:g.map(v).join(`, `)})]}):null,t[43]=v,t[44]=u,t[45]=g,t[46]=d,t[47]=a,t[48]=F):F=t[48];let I;t[49]!==u||t[50]!==d?(I=u&&[d,`items-start`],t[49]=u,t[50]=d,t[51]=I):I=t[51];let te;t[52]===I?te=t[53]:(te=Y(`flex flex-col gap-1`,I),t[52]=I,t[53]=te);let ne;t[54]===a?ne=t[55]:(ne=a(`sessions.scheduledTasks.editor.cronExpression.examples`),t[54]=a,t[55]=ne);let L;t[56]===ne?L=t[57]:(L=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:ne}),t[56]=ne,t[57]=L);let R=u?``:void 0,z=u&&`oc-settings-split-row-control justify-end`,B;t[58]===z?B=t[59]:(B=Y(`flex flex-wrap gap-1.5`,z),t[58]=z,t[59]=B);let V;t[60]!==r||t[61]!==a?(V=hc.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 typography-micro text-foreground hover:bg-interactive-hover`,onClick:()=>r(t=>({...t,schedule:{...t.schedule,cronExpression:e.expression}})),children:[(0,$.jsx)(`span`,{className:`font-mono`,children:e.expression}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:a(e.labelKey)})]},e.expression)),t[60]=r,t[61]=a,t[62]=V):V=t[62];let H;t[63]!==R||t[64]!==B||t[65]!==V?(H=(0,$.jsx)(`div`,{"data-settings-value":R,className:B,children:V}),t[63]=R,t[64]=B,t[65]=V,t[66]=H):H=t[66];let U;t[67]!==te||t[68]!==L||t[69]!==H?(U=(0,$.jsxs)(`div`,{className:te,children:[L,H]}),t[67]=te,t[68]=L,t[69]=H,t[70]=U):U=t[70];let W;return t[71]!==P||t[72]!==F||t[73]!==U||t[74]!==b?(W=(0,$.jsxs)(`div`,{className:b,children:[P,F,U]}),t[71]=P,t[72]=F,t[73]=U,t[74]=b,t[75]=W):W=t[75],W};function Yc(e){let{open:t,task:n,onOpenChange:r,onSave:i,presentation:a=`dialog`,onDirtyChange:o,onRun:c,onDelete:l,onToggleEnabled:u,actionBusy:d=!1,projectID:f=``,projectOptions:p=[],onProjectChange:m}=e,h=a===`panel`,g=a===`mobile-panel`,_=a===`mobile-tab`,v=g||_,y=g||_,b=h||v,x=v?bc:vc,S=v?xc:yc,{t:C,locale:w}=ee(),T=z(e=>e.loadProviders),E=z(e=>e.loadAgents),D=z(e=>e.providers),O=z(e=>e.currentProviderId),k=z(e=>e.currentModelId),A=z(e=>e.currentVariant||``),j=z(e=>e.currentAgentName||``),M=s(e=>e.timeFormatPreference),N=s(e=>e.weekStartPreference),P=s(e=>e.isMobile),[F,I]=Q.useState(()=>Gc(n,{providerID:O,modelID:k,variant:A,agent:j})),[te,ne]=Q.useState(!1),[R,B]=Q.useState(!1),[V,H]=Q.useState(!1),[U,W]=Q.useState(``),[re,ie]=Q.useState(!1),[G,ae]=Q.useState(``),[oe,se]=Q.useState(!1),[ce,K]=Q.useState(``),[le,q]=Q.useState(()=>{let e=Cc(n?.schedule?.date||``)||new Date;return new Date(e.getFullYear(),e.getMonth(),1)}),ue=Q.useRef(null),de=Q.useRef(null),fe=Q.useRef(null),pe=Q.useRef(null),me=Q.useRef(null),he=Q.useRef(``),ge=Q.useRef(void 0),_e=Q.useRef(n);_e.current=n;let ve=n?.id||null,ye=Q.useMemo(()=>Ic(w),[w]),be=Q.useMemo(()=>Fc(w),[w]),xe=Q.useMemo(()=>M===`24h`||M!==`12h`&&ye,[M,ye]),Se=Q.useMemo(()=>N===`sunday`?0:N===`monday`?1:be,[N,be]),Ce=Q.useMemo(()=>{let e=Lc(w);return Rc(gc.map(t=>({value:t,label:e[t]||``})),Se)},[w,Se]);Q.useEffect(()=>{t&&(T({source:`scheduledTaskEditor`}),E({source:`scheduledTaskEditor`}))},[t,T,E]),Q.useEffect(()=>{if(!t){ge.current=void 0;return}if(ge.current===ve)return;ge.current=ve;let e=_e.current,n=Gc(e,{providerID:O,modelID:k,variant:A,agent:j});he.current=JSON.stringify(n),I(n),o?.(!1);let r=Cc(e?.schedule?.date||``)||new Date;q(new Date(r.getFullYear(),r.getMonth(),1)),B(!1),ie(!1),H(!1),ae(``),W(``)},[t,ve,O,k,A,j,o]),Q.useEffect(()=>{if(!(!t||!n||F.id!==n.id||F.enabled===n.enabled)&&(I(e=>({...e,enabled:n.enabled})),he.current)){let e=JSON.parse(he.current);he.current=JSON.stringify({...e,enabled:n.enabled})}},[F.enabled,F.id,t,n]),Q.useEffect(()=>{!t||!he.current||o?.(JSON.stringify(F)!==he.current)},[F,o,t]),Q.useEffect(()=>{if(!R)return;let e=e=>{ue.current&&!ue.current.contains(e.target)&&B(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[R]);let we=Q.useMemo(()=>D.find(e=>e.id===F.execution.providerID)?.models?.find(e=>e.id===F.execution.modelID),[F.execution.modelID,F.execution.providerID,D]),Te=Q.useMemo(()=>we?.variants?Object.keys(we.variants):[],[we]);Q.useEffect(()=>{!we||!F.execution.variant||Te.includes(F.execution.variant)||I(e=>({...e,execution:{...e.execution,variant:``}}))},[Te,F.execution.variant,we]);let Ee=Q.useCallback((e,t)=>{I(n=>{let r=new Set(n.schedule.weekdays);return t?r.add(e):r.delete(e),{...n,schedule:{...n.schedule,weekdays:Array.from(r).sort((e,t)=>e-t)}}})},[]),De=Q.useCallback((e,t)=>{I(n=>{let r=n.schedule.times.slice();return r[e]=t,{...n,schedule:{...n.schedule,times:r}}})},[]),ke=Q.useCallback(e=>{I(t=>{let n=t.schedule.times.filter((t,n)=>n!==e);return{...t,schedule:{...t.schedule,times:n.length>0?n:[`09:00`]}}})},[]),Ae=Q.useCallback(()=>{I(e=>({...e,schedule:{...e.schedule,times:[...e.schedule.times,`12:00`]}}))},[]),je=Q.useMemo(()=>Hc(),[]),Ie=Q.useMemo(()=>Vc(je),[je]),Le=Q.useMemo(()=>{let e=Cc(F.schedule.onceDate);return e?Uc(e,je)?C(`sessions.scheduledTasks.editor.date.today`):new Intl.DateTimeFormat(w,{weekday:`short`}).format(e):null},[F.schedule.onceDate,w,C,je]),Re=Q.useMemo(()=>Vc(le).getTime()<=Ie.getTime(),[le,Ie]),ze=Q.useMemo(()=>Ce.map(e=>e.label),[Ce]),Be=Q.useCallback(e=>{I(t=>({...t,schedule:{...t.schedule,onceDate:e}}))},[]),Ve=Q.useCallback((e,t)=>{if(e.startsWith(`/`)){let n=e.indexOf(` `),r=e.indexOf(`
|
|
143
|
+
`),i=Math.min(n===-1?e.length:n,r===-1?e.length:r);if(t<=i&&n===-1){ae(e.substring(1,i)),ie(!0),H(!1),se(!1);return}}ie(!1);let n=e.substring(0,t),r=n.lastIndexOf(`#`);if(r!==-1){let e=r>0?n[r-1]:null,t=n.substring(r+1);if((!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
|
|
144
|
+
`)){K(t),se(!0),H(!1);return}}se(!1);let i=n.lastIndexOf(`@`);if(i!==-1){let e=i>0?n[i-1]:null,t=n.substring(i+1);(!e||/\s/.test(e))&&!t.includes(` `)&&!t.includes(`
|
|
145
|
+
`)?(W(t),H(!0)):H(!1);return}H(!1)},[]),We=Q.useCallback(e=>{I(t=>({...t,execution:{...t.execution,prompt:e}}))},[]),Ge=Q.useCallback(e=>{let t=F.execution.prompt,n=de.current?.selectionStart??t.length,r=t.substring(0,n).lastIndexOf(`@`),i=e.relativePath&&e.relativePath.trim().length>0?e.relativePath.trim():e.path||e.name,a=mn(t,r===-1?n:r,n,`@${i}`);We(a.text),H(!1),W(``),requestAnimationFrame(()=>{let e=de.current;e&&(e.selectionStart=a.caret,e.selectionEnd=a.caret,e.focus()),Ve(a.text,a.caret)})},[F.execution.prompt,We,Ve]),Ke=Q.useCallback(e=>{let t=F.execution.prompt,n=de.current?.selectionStart??t.length,r=t.substring(0,n).lastIndexOf(`@`),i=mn(t,r===-1?n:r,n,`@${e}`);We(i.text),H(!1),W(``),requestAnimationFrame(()=>{let e=de.current;e&&(e.selectionStart=i.caret,e.selectionEnd=i.caret,e.focus()),Ve(i.text,i.caret)})},[F.execution.prompt,We,Ve]),Ye=Q.useCallback(e=>{let t=`/${e.name} `;We(t),ie(!1),ae(``),se(!1),requestAnimationFrame(()=>{let e=de.current;e&&(e.focus(),e.selectionStart=e.value.length,e.selectionEnd=e.value.length),Ve(t,t.length)})},[We,Ve]),Ze=Q.useCallback((e,t)=>{let n=F.execution.prompt,r=de.current?.selectionStart??n.length,i=n.substring(0,r).lastIndexOf(`#`),a=i===-1?r:i,o=`${n.substring(0,a)}#${t} ${n.substring(r)}`,s=a+t.length+2;We(o),se(!1),K(``),requestAnimationFrame(()=>{let e=de.current;e&&(e.selectionStart=s,e.selectionEnd=s,e.focus()),Ve(o,s)})},[F.execution.prompt,We,Ve]),Qe=Q.useCallback(e=>{if(re&&pe.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)){e.preventDefault(),pe.current.handleKeyDown(e.key);return}V&&fe.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),fe.current.handleKeyDown(e.key)),oe&&me.current&&(e.key===`Enter`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Escape`||e.key===`Tab`)&&(e.preventDefault(),me.current.handleKeyDown(e.key))},[re,V,oe]),et=Q.useCallback(async()=>{let e=Kc(F,C);if(e){J.error(e);return}let t={...F.id?{id:F.id}:{},name:F.name.trim(),enabled:F.enabled,schedule:{kind:F.schedule.kind,timezone:F.schedule.timezone.trim(),...F.schedule.kind===`cron`?{cron:F.schedule.cronExpression.trim()}:F.schedule.kind===`once`?{date:F.schedule.onceDate,time:F.schedule.onceTime}:{times:qc(F.schedule.times),...F.schedule.kind===`weekly`?{weekdays:F.schedule.weekdays}:{}}},execution:{prompt:F.execution.prompt,providerID:F.execution.providerID,modelID:F.execution.modelID,...F.execution.variant.trim()?{variant:F.execution.variant.trim()}:{},...F.execution.agent.trim()?{agent:F.execution.agent.trim()}:{},...F.execution.goalEnabled?{goalEnabled:!0}:{},...F.execution.goalEnabled&&F.execution.goalTokenBudget?{goalTokenBudget:F.execution.goalTokenBudget}:{}},...F.state?{state:F.state}:{}};ne(!0);try{let e=await i(t);if(a===`panel`){let t=Gc(e||n,{providerID:O,modelID:k,variant:A,agent:j});he.current=JSON.stringify(t),I(t),o?.(!1)}else r(!1)}catch(e){J.error(e instanceof Error?e.message:C(`sessions.scheduledTasks.editor.toast.saveFailed`))}finally{ne(!1)}},[j,k,O,A,F,o,r,i,a,C,n]),tt=Q.useId(),nt=Q.useCallback(()=>typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"], [data-slot="select-content"]`),[]),rt=C(n?`sessions.scheduledTasks.editor.title.edit`:`sessions.scheduledTasks.editor.title.new`),st=C(`sessions.scheduledTasks.editor.description`),ct=(0,$.jsxs)(`div`,{className:Y(`oc-settings-workspace oc-settings-page-content oc-scheduled-task-form`,P?`oc-settings-workspace-mobile`:`oc-settings-workspace-desktop`),children:[(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1`,(h||_)&&`hidden`),children:[(0,$.jsx)(zc,{htmlFor:`sched-name`,required:!0,children:C(`sessions.scheduledTasks.editor.taskName.label`)}),(0,$.jsx)(ot,{id:`sched-name`,value:F.name,onChange:e=>I(t=>({...t,name:e.target.value})),placeholder:C(`sessions.scheduledTasks.editor.taskName.placeholder`),maxLength:80,className:`w-full`})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-3 border-t border-border/40 pt-5`,b&&`oc-settings-group order-4 animate-in fade-in slide-in-from-right-1 border-0 pt-0 duration-200 [animation-delay:80ms] [animation-fill-mode:both] motion-reduce:animate-none`),children:[b?(0,$.jsx)(`h3`,{className:dc,children:C(`sessions.scheduledTasks.editor.panel.frequency`)}):null,(0,$.jsxs)(`div`,{className:Y(b&&`oc-settings-group-card`,b&&F.schedule.kind===`once`&&R&&`overflow-visible`),children:[(0,$.jsx)(`div`,{className:Y(`grid grid-cols-1 gap-x-4 gap-y-3`,b&&`flex flex-col gap-0`,!P&&!b&&`sm:grid-cols-2`),children:(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col gap-1`,b&&[S,`last:border-b`]),children:[(0,$.jsx)(zc,{children:C(`sessions.scheduledTasks.editor.scheduleType.label`)}),(0,$.jsx)(`div`,{"data-settings-value":b?``:void 0,className:Y(b&&`oc-settings-split-row-control`),children:(0,$.jsxs)(Je,{value:F.schedule.kind,onValueChange:e=>{I(t=>({...t,schedule:{...t.schedule,kind:e,...e===`cron`&&!t.schedule.cronExpression?{cronExpression:`0 * * * *`}:{}}}))},children:[(0,$.jsx)(at,{className:Y(!b&&_c,b&&x),children:(0,$.jsx)(Ue,{children:e=>C(e===`daily`?`sessions.scheduledTasks.editor.scheduleType.daily`:e===`weekly`?`sessions.scheduledTasks.editor.scheduleType.weekly`:e===`cron`?`sessions.scheduledTasks.editor.scheduleType.cron`:`sessions.scheduledTasks.editor.scheduleType.once`)})}),(0,$.jsxs)(qe,{className:`motion-reduce:transition-none`,children:[(0,$.jsx)(it,{value:`daily`,children:C(`sessions.scheduledTasks.editor.scheduleType.daily`)}),(0,$.jsx)(it,{value:`weekly`,children:C(`sessions.scheduledTasks.editor.scheduleType.weekly`)}),(0,$.jsx)(it,{value:`once`,children:C(`sessions.scheduledTasks.editor.scheduleType.once`)}),(0,$.jsx)(it,{value:`cron`,children:C(`sessions.scheduledTasks.editor.scheduleType.cron`)})]})]})})]})}),F.schedule.kind===`cron`?(0,$.jsx)(Jc,{draft:F,setDraft:I,locale:w,t:C,panel:h,mobilePanel:v}):F.schedule.kind===`once`?(0,$.jsxs)(`div`,{className:Y(`grid grid-cols-1 gap-x-4 gap-y-3`,b&&`flex flex-col gap-0`,!P&&!b&&`sm:grid-cols-2`),children:[(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col gap-1`,b&&S),ref:ue,children:[(0,$.jsx)(zc,{children:C(`sessions.scheduledTasks.editor.date.label`)}),(0,$.jsxs)(`div`,{"data-settings-value":b?``:void 0,className:Y(`relative`,b&&`oc-settings-split-row-control`),children:[(0,$.jsxs)(`button`,{type:`button`,className:Y(!b&&_c,`flex items-center justify-between gap-2 text-left`,b&&[x,`w-full`]),onClick:()=>B(e=>!e),children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(X,{name:`calendar`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:Tc(F.schedule.onceDate,C(`sessions.scheduledTasks.editor.date.placeholder`),w)})]}),(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]}),R?(0,$.jsxs)(`div`,{className:Y(`absolute top-[calc(100%+6px)] z-50 w-[min(288px,calc(100vw-2rem))] animate-in fade-in zoom-in-95 slide-in-from-top-1 rounded-xl border border-border bg-background p-3 shadow-sm duration-150 motion-reduce:animate-none`,v?`right-0`:`left-0`),children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>q(e=>Ec(e,-1)),"aria-label":C(`sessions.scheduledTasks.editor.date.previousMonth`),disabled:Re,children:(0,$.jsx)(X,{name:`arrow-left-s`,className:`h-4 w-4`})}),(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:new Intl.DateTimeFormat(w,{month:`long`,year:`numeric`}).format(le)}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-interactive-hover`,onClick:()=>q(e=>Ec(e,1)),"aria-label":C(`sessions.scheduledTasks.editor.date.nextMonth`),children:(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4`})})]}),(0,$.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1 px-1`,children:ze.map((e,t)=>(0,$.jsx)(`div`,{className:`py-1 text-center typography-micro text-muted-foreground`,children:e},`${e}-${t}`))}),(0,$.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,children:Dc(le,Se).map(({date:e,inCurrentMonth:t})=>{let n=wc(e),r=n===F.schedule.onceDate,i=Uc(e,je),a=e.getTime()<je.getTime();return(0,$.jsx)(`button`,{type:`button`,onClick:()=>{a||(Be(n),B(!1))},disabled:a,className:[`h-8 rounded-md typography-ui-label`,r?`bg-interactive-selection text-interactive-selection-foreground`:a?`text-muted-foreground/40`:t?`text-foreground hover:bg-interactive-hover`:`text-muted-foreground/60 hover:bg-interactive-hover`,i&&!r?`ring-1 ring-inset ring-interactive-focusRing bg-interactive-hover/50`:``,a?`cursor-not-allowed opacity-45`:``].join(` `),children:e.getDate()},n)})}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-border pt-2`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:Le||``}),(0,$.jsx)(Z,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>{Be(wc(je)),q(new Date(je.getFullYear(),je.getMonth(),1))},children:C(`sessions.scheduledTasks.editor.date.jumpToToday`)})]})]}):null]})]}),(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col gap-1`,b&&S),children:[(0,$.jsx)(zc,{children:C(`sessions.scheduledTasks.editor.time.label`)}),(0,$.jsx)(`div`,{"data-settings-value":b?``:void 0,className:Y(b&&`oc-settings-split-row-control`),children:(0,$.jsx)(Bc,{value:F.schedule.onceTime,className:Y(b&&`oc-settings-inline-value w-fit min-w-0 justify-end`),use24Hour:xe,hourAriaLabel:C(`sessions.scheduledTasks.editor.time.hourAria`),minuteAriaLabel:C(`sessions.scheduledTasks.editor.time.minuteAria`),periodAriaLabel:C(`sessions.scheduledTasks.editor.time.periodAria`),amLabel:C(`sessions.scheduledTasks.editor.time.period.am`),pmLabel:C(`sessions.scheduledTasks.editor.time.period.pm`),onChange:e=>I(t=>({...t,schedule:{...t.schedule,onceTime:e}}))})})]})]}):(0,$.jsxs)(`div`,{className:Y(`grid grid-cols-1 gap-x-4 gap-y-3`,b&&`flex flex-col gap-0`,!P&&!b&&`sm:grid-cols-2`),children:[F.schedule.kind===`weekly`?(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1`,b&&[`oc-settings-group-row border-b border-[var(--oc-settings-row-divider)] last:border-b-0`,`oc-settings-split-row`],!P&&!b&&`sm:col-span-2`),children:[(0,$.jsx)(zc,{children:C(`sessions.scheduledTasks.editor.weekdays.label`)}),(0,$.jsx)(`div`,{"data-settings-value":b?``:void 0,className:Y(`flex flex-wrap gap-x-3 gap-y-2`,b&&`oc-settings-split-row-control justify-end`),children:Ce.map(e=>{let t=F.schedule.weekdays.includes(e.value);return(0,$.jsxs)(`div`,{className:[`group inline-flex items-center gap-1.5 px-0.5 py-0.5 typography-meta`,t?`text-foreground`:`text-muted-foreground`].join(` `),children:[(0,$.jsx)(He,{checked:t,onChange:t=>Ee(e.value,t),ariaLabel:e.label}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>Ee(e.value,!t),className:`group-hover:text-foreground`,children:e.label})]},e.value)})})]}):null,(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col gap-2`,b&&[S,`justify-start`],v&&`flex-col items-stretch`),children:[(0,$.jsx)(zc,{children:C(`sessions.scheduledTasks.editor.times.label`)}),(0,$.jsxs)(`div`,{"data-settings-value":b?``:void 0,className:Y(b?`oc-settings-split-row-control relative flex-wrap justify-end`:`contents`),children:[(0,$.jsx)(`div`,{className:Y(`flex flex-col gap-2`,b&&`flex-row flex-wrap justify-end transition-[padding] motion-reduce:transition-none`,h&&`group-hover:pr-8`),children:F.schedule.times.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Bc,{value:e,className:Y(b&&`oc-settings-inline-value w-fit min-w-0`),use24Hour:xe,hourAriaLabel:C(`sessions.scheduledTasks.editor.time.hourAria`),minuteAriaLabel:C(`sessions.scheduledTasks.editor.time.minuteAria`),periodAriaLabel:C(`sessions.scheduledTasks.editor.time.periodAria`),amLabel:C(`sessions.scheduledTasks.editor.time.period.am`),pmLabel:C(`sessions.scheduledTasks.editor.time.period.pm`),onChange:e=>De(t,e)}),F.schedule.times.length>1?(0,$.jsx)(Z,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>ke(t),"aria-label":C(`sessions.scheduledTasks.editor.times.removeAria`),children:(0,$.jsx)(X,{name:`close`,className:`h-4 w-4`})}):null]},t))}),(0,$.jsx)(`div`,{className:Y(b&&`shrink-0`,h&&`absolute right-0`),children:(0,$.jsxs)(Z,{type:`button`,size:b?`icon`:`sm`,variant:b?`ghost`:`outline`,className:Y(`h-9`,h&&`size-7 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100 motion-reduce:transition-none`,v&&`size-9`),onClick:Ae,"aria-label":C(`sessions.scheduledTasks.editor.times.add`),children:[(0,$.jsx)(X,{name:`add`,className:Y(`h-4 w-4`,!b&&`mr-1`)}),b?null:C(`sessions.scheduledTasks.editor.times.add`)]})})]})]})]})]})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-3 border-t border-border/40 pt-5`,b&&`contents`),children:[(0,$.jsxs)(`div`,{className:Y(b?`oc-settings-group order-2`:`contents`),children:[b?(0,$.jsx)(`h3`,{className:dc,children:C(`sessions.scheduledTasks.editor.panel.details`)}):null,(0,$.jsxs)(`div`,{className:Y(`grid grid-cols-1 gap-x-4 gap-y-3`,b&&[`flex flex-col gap-0 animate-in fade-in slide-in-from-right-1 duration-200 [animation-delay:40ms] [animation-fill-mode:both] motion-reduce:animate-none`,`oc-settings-group-card`],!P&&!b&&`sm:grid-cols-2`),children:[p.length>0?(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col gap-1`,b&&S),children:[(0,$.jsx)(zc,{children:C(`sessions.scheduledTasks.dialog.project.label`)}),(0,$.jsx)(`div`,{"data-settings-value":b?``:void 0,className:Y(b&&`oc-settings-split-row-control`),children:(0,$.jsxs)(Je,{value:f,disabled:!m,onValueChange:m,children:[(0,$.jsx)(at,{className:Y(!b&&_c,b&&x),children:(0,$.jsx)(Ue,{children:e=>p.find(t=>t.id===e)?.label})}),(0,$.jsx)(qe,{className:`motion-reduce:transition-none`,children:p.map(e=>(0,$.jsx)(it,{value:e.id,children:e.label},e.id))})]})})]}):null,(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-col gap-1`,b&&S),children:[(0,$.jsx)(zc,{required:!0,children:C(`sessions.scheduledTasks.editor.model.label`)}),(0,$.jsx)(`div`,{"data-settings-value":b?``:void 0,className:Y(b&&`oc-settings-split-row-control`),children:(0,$.jsx)(Ot,{providerId:F.execution.providerID,modelId:F.execution.modelID,variant:F.execution.variant,className:Y(!b&&_c,b&&x,`[&>div]:min-w-0 [&>div]:flex-1 [&_span]:truncate`),showIcon:!h,onChange:(e,t,n=``)=>{I(r=>({...r,execution:{...r.execution,providerID:e,modelID:t,variant:n}}))}})})]}),b?(0,$.jsxs)(`div`,{className:S,children:[(0,$.jsx)(zc,{children:C(`sessions.scheduledTasks.editor.agent.label`)}),(0,$.jsx)(`div`,{"data-settings-value":``,className:`oc-settings-split-row-control`,children:(0,$.jsx)(Et,{agentName:F.execution.agent,className:Y(x,`[&>div]:min-w-0 [&>div]:flex-1 [&_span]:truncate`),showIcon:!0,filter:e=>L(e.mode),onChange:e=>I(t=>({...t,execution:{...t.execution,agent:e}}))})})]}):null,b?(0,$.jsxs)(`label`,{className:Y(S,`cursor-pointer`),children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:C(`sessions.scheduledTasks.editor.goal.label`)}),(0,$.jsx)(`span`,{"data-settings-value":``,className:`oc-settings-split-row-control`,children:(0,$.jsx)(He,{checked:F.execution.goalEnabled,onChange:e=>I(t=>({...t,execution:{...t.execution,goalEnabled:e}})),ariaLabel:C(`sessions.scheduledTasks.editor.goal.aria`)})})]}):null]})]}),b?null:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,$.jsx)(zc,{children:C(`sessions.scheduledTasks.editor.agent.label`)}),(0,$.jsx)(Et,{agentName:F.execution.agent,className:Y(_c,`[&>div]:min-w-0 [&>div]:flex-1 [&_span]:truncate`),filter:e=>L(e.mode),onChange:e=>I(t=>({...t,execution:{...t.execution,agent:e}}))})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1`,b&&`order-1`),children:[(0,$.jsx)(`div`,{className:Y(b&&`sr-only`),children:(0,$.jsx)(zc,{htmlFor:`sched-prompt`,required:!0,children:C(`sessions.scheduledTasks.editor.prompt.label`)})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)($e,{id:`sched-prompt`,ref:de,value:F.execution.prompt,onChange:e=>{let t=e.target.value;We(t);let n=e.target.selectionStart??t.length;Ve(t,n)},onKeyDown:Qe,rows:b?4:8,simple:b,placeholder:C(`sessions.scheduledTasks.editor.prompt.placeholder`),className:Y(`typography-meta min-h-[120px] max-h-[300px] resize-none overflow-y-auto`,b&&`!h-32 !min-h-32 !max-h-32 rounded-2xl border border-border/60 bg-[var(--surface-elevated)] px-4 py-4 text-base shadow-none ring-0 placeholder:text-muted-foreground/65 focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`)}),re?(0,$.jsx)(ln,{ref:pe,searchQuery:G,onCommandSelect:Ye,onClose:()=>ie(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,V?(0,$.jsx)(pn,{ref:fe,searchQuery:U,onFileSelect:Ge,onAgentSelect:Ke,onClose:()=>H(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null,oe?(0,$.jsx)(un,{ref:me,searchQuery:ce,onSnippetSelect:Ze,onClose:()=>se(!1),style:{left:0,top:`auto`,bottom:`calc(100% + 6px)`,marginBottom:0,maxWidth:`100%`}}):null]})]}),b?null:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-8 gap-y-2`,children:[(0,$.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2`,children:[(0,$.jsx)(He,{checked:F.execution.goalEnabled,onChange:e=>I(t=>({...t,execution:{...t.execution,goalEnabled:e}})),ariaLabel:C(`sessions.scheduledTasks.editor.goal.aria`)}),(0,$.jsx)(`span`,{className:`typography-meta`,children:C(`sessions.scheduledTasks.editor.goal.label`)})]}),F.execution.goalEnabled?(0,$.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2`,children:[(0,$.jsx)(He,{checked:F.execution.goalTokenBudget!==null,onChange:e=>I(t=>({...t,execution:{...t.execution,goalTokenBudget:e?2e5:null}})),ariaLabel:C(`sessions.scheduledTasks.editor.goal.budgetAria`)}),(0,$.jsx)(`span`,{className:`typography-meta`,children:C(`sessions.scheduledTasks.editor.goal.budgetLabel`)})]}):null,F.execution.goalEnabled&&F.execution.goalTokenBudget!==null?(0,$.jsx)(In,{value:F.execution.goalTokenBudget,onValueChange:e=>{typeof e==`number`&&Number.isFinite(e)&&e>0&&I(t=>({...t,execution:{...t.execution,goalTokenBudget:Math.floor(e)}}))},min:1e3,max:1e8,step:5e4}):null]})]})]}),lt=(0,$.jsxs)(`div`,{className:Y(`flex flex-wrap items-center justify-between gap-3`,a===`panel`&&`justify-end`,y&&`flex-nowrap gap-2`),children:[(0,$.jsxs)(`label`,{className:Y(`inline-flex items-center gap-2`,a===`panel`&&`hidden`),children:[(0,$.jsx)(He,{checked:F.enabled,onChange:e=>I(t=>({...t,enabled:e})),ariaLabel:C(`sessions.scheduledTasks.editor.enabled.aria`)}),(0,$.jsx)(`span`,{className:`typography-meta`,children:C(`sessions.scheduledTasks.editor.enabled.label`)})]}),(0,$.jsxs)(`div`,{className:Y(`flex flex-wrap items-center justify-end gap-2`,y&&`ml-auto flex-nowrap`),children:[a!==`panel`&&!y?(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r(!1),disabled:te,children:C(`sessions.scheduledTasks.editor.actions.cancel`)}):null,(0,$.jsx)(Z,{type:`button`,size:`sm`,className:Y(a===`panel`&&`rounded-lg`,y&&`min-h-11 px-5`),onClick:et,disabled:te,children:C(te?`sessions.scheduledTasks.editor.actions.saving`:n?`sessions.scheduledTasks.editor.actions.save`:`sessions.scheduledTasks.dialog.actions.create`)})]})]});return a===`panel`?t?(0,$.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-labelledby":`scheduled-task-panel-title`,children:[(0,$.jsxs)(`header`,{className:`shrink-0 animate-in fade-in slide-in-from-right-1 px-6 pb-4 pt-5 duration-200 motion-reduce:animate-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:Y(`typography-meta font-medium`,n?.enabled?`text-[var(--status-info)]`:`text-muted-foreground`),children:n?n.enabled?C(`sessions.scheduledTasks.dialog.taskToggle.enabled`):C(`sessions.scheduledTasks.dialog.taskToggle.paused`):rt}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[n&&l&&c?(0,$.jsxs)(yt,{children:[(0,$.jsx)(bt,{asChild:!0,children:(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:Y(`rounded-lg transition-transform duration-150 active:scale-90 motion-reduce:transition-none`,P?`size-11`:`size-8`),disabled:te||d,"aria-label":C(`sessions.scheduledTasks.dialog.actions.moreAria`,{taskName:n.name}),children:(0,$.jsx)(X,{name:`more-2`,className:`size-4`})})}),(0,$.jsxs)(vt,{align:`end`,className:`min-w-40 motion-reduce:transition-none`,children:[(0,$.jsxs)(xt,{onSelect:()=>void c(n),children:[(0,$.jsx)(X,{name:`play`,className:`size-4`}),C(`sessions.scheduledTasks.dialog.actions.runNow`)]}),u?(0,$.jsxs)(xt,{onSelect:()=>void u(n,!n.enabled),children:[(0,$.jsx)(X,{name:n.enabled?`pause`:`play`,className:`size-4`}),n.enabled?C(`sessions.scheduledTasks.dialog.taskToggle.pauseAria`,{taskName:n.name}):C(`sessions.scheduledTasks.dialog.taskToggle.enableAria`,{taskName:n.name})]}):null,(0,$.jsxs)(xt,{variant:`destructive`,onSelect:()=>void l(n),children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`}),C(`sessions.scheduledTasks.dialog.actions.delete`)]})]})]}):null,n&&u?(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:Y(`group rounded-lg transition-transform duration-150 active:scale-90 motion-reduce:transition-none`,P?`size-11`:`size-8`),disabled:te||d,onClick:()=>void u(n,!n.enabled),"aria-label":n.enabled?C(`sessions.scheduledTasks.dialog.taskToggle.pauseAria`,{taskName:n.name}):C(`sessions.scheduledTasks.dialog.taskToggle.enableAria`,{taskName:n.name}),children:(0,$.jsx)(X,{name:n.enabled?`pause`:`play`,className:`size-4 transition-transform duration-150 group-active:scale-75 motion-reduce:transition-none`})}):null,(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:Y(`rounded-lg transition-transform duration-150 active:scale-90 motion-reduce:transition-none`,P?`size-11`:`size-8`),onClick:()=>r(!1),"aria-label":C(`sessions.scheduledTasks.editor.actions.cancel`),children:(0,$.jsx)(X,{name:P?`arrow-left`:`close`,className:`size-4`})})]})]}),(0,$.jsx)(`h2`,{id:`scheduled-task-panel-title`,className:`sr-only`,children:rt}),(0,$.jsx)(ot,{value:F.name,onChange:e=>I(t=>({...t,name:e.target.value})),placeholder:C(`sessions.scheduledTasks.editor.taskName.placeholder`),"aria-label":C(`sessions.scheduledTasks.editor.taskName.label`),maxLength:80,className:`mt-1 !h-9 !min-h-9 border-0 bg-transparent px-0 text-lg font-semibold shadow-none ring-0 hover:!bg-transparent focus:!bg-transparent focus:ring-0`})]}),(0,$.jsx)(Xe,{className:`min-h-0 flex-1 overflow-auto [scrollbar-gutter:stable]`,size:64,hideTopShadow:!0,children:(0,$.jsx)(`div`,{className:`px-6 pb-6 pt-2`,children:ct})}),(0,$.jsx)(`footer`,{className:`shrink-0 border-t border-border/50 bg-background/95 px-6 py-3 backdrop-blur-sm`,children:lt})]}):null:a===`mobile-panel`?t?(0,$.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"aria-label":rt,children:[(0,$.jsx)(Xe,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden`,size:48,hideTopShadow:!0,children:(0,$.jsx)(`div`,{className:`w-full px-3 pb-6 pt-4`,children:ct})}),(0,$.jsx)(`footer`,{className:`shrink-0 border-t border-border/50 bg-background/95 px-3 py-2 backdrop-blur-sm`,children:lt})]}):null:a===`mobile-tab`?t?(0,$.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-background`,"aria-label":rt,children:[(0,$.jsx)(Oe,{sticky:!0,title:rt,backAriaLabel:C(`header.actions.backAria`),onBack:()=>r(!1),backDisabled:te}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-[var(--oc-mobile-page-inline-inset)] pb-[calc(var(--oc-mobile-dock-height)+2.5rem+var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px)))] pt-4`,children:[(0,$.jsx)(ot,{value:F.name,onChange:e=>I(t=>({...t,name:e.target.value})),placeholder:C(`sessions.scheduledTasks.editor.taskName.placeholder`),"aria-label":C(`sessions.scheduledTasks.editor.taskName.label`),maxLength:80,className:`oc-mobile-detail-editor-title mb-5 !h-auto min-h-0 border-0 bg-transparent px-0 py-0 text-xl font-semibold shadow-none ring-0 hover:!bg-transparent focus:!bg-transparent focus:ring-0`}),ct]}),(0,$.jsx)(Vn,{as:`footer`,"data-scheduled-editor-footer":``,className:`z-[60]`,children:lt})]}):null:P?(0,$.jsx)(Ht,{open:t,title:rt,onClose:()=>r(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:rt}),e]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:st})]}),footer:lt,children:ct}):(0,$.jsx)(Fe,{open:t,onOpenChange:e=>{!e&&nt()||r(e)},children:(0,$.jsxs)(Me,{"aria-describedby":tt,className:`!max-w-[720px] w-[90vw] h-[680px] max-h-[85vh] gap-0 p-0 overflow-hidden`,children:[(0,$.jsx)(Pe,{id:tt,className:`sr-only`,children:st}),(0,$.jsx)(`header`,{className:`shrink-0 px-4 sm:px-6 pt-5 pb-3`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,$.jsx)(Ne,{className:`typography-ui-label font-medium text-foreground`,children:rt}),(0,$.jsx)(`p`,{className:`typography-meta mt-0.5 text-muted-foreground`,children:st})]})}),(0,$.jsx)(Xe,{className:`flex-1 min-h-0 overflow-auto [scrollbar-gutter:stable_both-edges]`,size:64,hideTopShadow:!0,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-2xl px-4 sm:px-6 pb-5`,children:ct})}),(0,$.jsx)(`div`,{className:`shrink-0 px-4 sm:px-6 py-3`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-2xl`,children:lt})})]})})}function Xc(e){return Ac(e,{min:0,max:23})}function Zc(e,t){return Ac(String(Number.parseInt(e,10)+t),{min:0,max:23,loop:!0})}function Qc(e,t){let n=Number(e),r=Number(t),i=Number.isFinite(n)?Math.min(23,Math.max(0,n)):0,a=Number.isFinite(r)?Math.min(59,Math.max(0,r)):0;return`${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`}var $c=e=>{let t=(Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[]).filter(e=>typeof e==`string`&&/^([01]\d|2[0-3]):([0-5]\d)$/.test(e));return Array.from(new Set(t)).sort((e,t)=>e.localeCompare(t))},el=(e,t,n=!0)=>{let r=$c(e).join(`, `)||`--:--`,i=e=>t(e===0?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sun`:e===1?`sessions.scheduledTasks.dialog.schedule.weekdayShort.mon`:e===2?`sessions.scheduledTasks.dialog.schedule.weekdayShort.tue`:e===3?`sessions.scheduledTasks.dialog.schedule.weekdayShort.wed`:e===4?`sessions.scheduledTasks.dialog.schedule.weekdayShort.thu`:e===5?`sessions.scheduledTasks.dialog.schedule.weekdayShort.fri`:e===6?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sat`:`sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown`);if(e.schedule.kind===`daily`)return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.dailyWithTimezone`,{time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.daily`,{time:r});if(e.schedule.kind===`weekly`){let a=Array.isArray(e.schedule.weekdays)?e.schedule.weekdays.map(e=>i(e)).join(`, `):``;return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone`,{days:a,time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.weekly`,{days:a,time:r})}if(e.schedule.kind===`once`){let r=typeof e.schedule.date==`string`&&e.schedule.date.trim().length>0?e.schedule.date:t(`sessions.scheduledTasks.dialog.schedule.unknownDate`),i=typeof e.schedule.time==`string`&&e.schedule.time.trim().length>0?e.schedule.time:`--:--`;return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.onceWithTimezone`,{date:r,time:i,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.once`,{date:r,time:i})}return n&&e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.cronWithTimezone`,{cron:e.schedule.cron||``,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.cron`,{cron:e.schedule.cron||``})},tl=(e,t)=>{if(!e||!Number.isFinite(e))return``;let n=e-Date.now(),r=Math.abs(n),i=6e4,a=60*i,o=24*a,s=n>=0;if(r<i)return t(s?`sessions.scheduledTasks.dialog.relativeTime.inLessThanOneMinute`:`sessions.scheduledTasks.dialog.relativeTime.justNow`);if(r<a){let e=Math.round(r/i);return t(s?`sessions.scheduledTasks.dialog.relativeTime.inMinutes`:`sessions.scheduledTasks.dialog.relativeTime.minutesAgo`,{count:e})}if(r<o){let e=Math.floor(r/a),n=Math.round(r%a/i),o=n>0?`${e}h ${n}m`:`${e}h`;return t(s?`sessions.scheduledTasks.dialog.relativeTime.inDuration`:`sessions.scheduledTasks.dialog.relativeTime.durationAgo`,{duration:o})}let c=Math.floor(r/o),l=Math.round(r%o/a),u=l>0?`${c}d ${l}h`:`${c}d`;return t(s?`sessions.scheduledTasks.dialog.relativeTime.inDuration`:`sessions.scheduledTasks.dialog.relativeTime.durationAgo`,{duration:u})},nl=e=>new Intl.DateTimeFormat(N(),{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e)),rl=(e,t)=>{if(e.status===`running`)return Math.max(0,t-e.startedAt);if(typeof e.finishedAt==`number`&&Number.isFinite(e.finishedAt)){let t=Math.max(0,e.finishedAt-e.startedAt);return typeof e.durationMs==`number`&&Number.isFinite(e.durationMs)&&e.durationMs>=0?Math.max(e.durationMs,t):t}return typeof e.durationMs==`number`&&Number.isFinite(e.durationMs)&&e.durationMs>=0?e.durationMs:null},il=e=>{if(e===null||!Number.isFinite(e)||e<0)return null;if(e<1e3)return`<1s`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r>0?`${n}m ${r}s`:`${n}m`;let i=Math.floor(n/60),a=n%60;return a>0?`${i}h ${a}m`:`${i}h`},al={success:{tone:`success`,Icon:`checkbox-circle`},error:{tone:`error`,Icon:`error-warning`},running:{tone:`warning`,Icon:`loader-4`,spin:!0},idle:{tone:`muted`,Icon:`pulse`}},ol=e=>e===`muted`?{}:{color:`var(--status-${e})`,backgroundColor:`var(--status-${e}-background)`,borderColor:`var(--status-${e}-border)`},sl=({projectId:e,taskId:t})=>`${e}:${t}`,cl=d.scoped(`scheduled-tasks`),ll=d.scoped(`scheduled-task-runs`),ul=null,dl=()=>ul?ul():(s.getState().setScheduledTasksDialogOpen(!1),!0),fl=(e,t,n)=>({tasks:[...e?.tasks.filter(e=>e.projectId!==t)??[],...n.map(e=>({projectId:t,task:e}))],failedProjectIds:e?.failedProjectIds.filter(e=>e!==t)??[]});function pl(){let e=(0,Qn.c)(9),{t}=ee(),n=s(vl),r=s(_l);if(!s(gl))return null;let i;e[0]===t?i=e[1]:(i=t(`sessions.scheduledTasks.dialog.title`),e[0]=t,e[1]=i);let a;e[2]!==n||e[3]!==r?(a=(0,$.jsx)(yl,{presentation:`mobile-panel`,open:n,onOpenChange:r}),e[2]=n,e[3]=r,e[4]=a):a=e[4];let o;return e[5]!==n||e[6]!==i||e[7]!==a?(o=(0,$.jsx)(Ht,{open:n,title:i,onClose:hl,className:`h-[min(92dvh,760px)] max-w-none sm:max-w-2xl`,contentMaxHeightClassName:`max-h-none`,renderHeader:ml,containedBody:!0,children:a}),e[5]=n,e[6]=i,e[7]=a,e[8]=o):o=e[8],o}function ml(){return null}function hl(){return dl()}function gl(e){return e.isMobile}function _l(e){return e.setScheduledTasksDialogOpen}function vl(e){return e.isScheduledTasksDialogOpen}function yl({presentation:e=`workspace`,open:t=!0,onOpenChange:n,registerEditorBackHandler:r,onEditorActiveChange:i}={}){let{t:a}=ee(),o=Mn(),c=s(e=>e.isMobile),l=s(e=>e.setMainTabGuard),u=ue(e=>e.projects),d=ue(e=>e.getActiveProject())?.id||u[0]?.id||``,[f,p]=Q.useState(d),[m,h]=Q.useState(null),[g,v]=Q.useState(`closed`),[y,b]=Q.useState(`all`),[x,S]=Q.useState(()=>$o().scheduleView===`history`?`history`:`tasks`),[C,w]=Q.useState(``),[T,E]=Q.useState(!1),[A,M]=Q.useState(null),[N,P]=Q.useState(null),[I,te]=Q.useState(null),ne=Q.useRef(null),L=Q.useRef(null),R=e===`mobile-tab`,z=e===`mobile-panel`||R;Q.useEffect(()=>{if(R)return i?.(g!==`closed`),()=>i?.(!1)},[g,R,i]),Q.useEffect(()=>{if(!t)return;let e=()=>{let e=$o();if(e.tab===`schedule`||s.getState().activeMainTab===`schedule`){let t=e.scheduleView===`history`?`history`:`tasks`;S(e=>e===t?e:t)}};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[t]),Q.useEffect(()=>{u.some(e=>e.id===f)||p(d)},[f,d,u]);let B=O({queryKey:cl,enabled:t,refetchOnMount:`always`,queryFn:oc,select:e=>({...e,tasks:[...e.tasks].sort((e,t)=>e.task.enabled===t.task.enabled?e.task.name.localeCompare(t.task.name):e.task.enabled?-1:1)})}),V=Q.useMemo(()=>B.data?.tasks??[],[B.data]),H=B.data?.failedProjectIds??[],U=Q.useMemo(()=>m?V.find(({projectId:e,task:t})=>e===m.projectId&&t.id===m.taskId)??null:null,[m,V]),W=U?.task??null,re=k({queryKey:ll,enabled:t&&x===`history`,initialPageParam:void 0,queryFn:({pageParam:e,signal:t})=>ac({before:e,limit:20},t),getNextPageParam:e=>e.complete?void 0:e.nextCursor??void 0,refetchOnMount:`always`}),ie=Q.useMemo(()=>{let e=new Set,t=[];for(let n of re.data?.pages??[])for(let r of n.runs)e.has(r.id)||(e.add(r.id),t.push(r));return t},[re.data]),G=Q.useMemo(()=>ie.some(e=>e.status===`running`),[ie]),[ae,oe]=Q.useState(()=>Date.now());Q.useEffect(()=>{if(!t||x!==`history`||!G)return;oe(Date.now());let e=window.setInterval(()=>oe(Date.now()),1e3);return()=>window.clearInterval(e)},[G,t,x]);let se=Q.useMemo(()=>new Map(u.map(e=>[e.id,e])),[u]);Q.useEffect(()=>{B.error&&J.error(B.error instanceof Error?B.error.message:a(`sessions.scheduledTasks.dialog.toast.loadFailed`))},[B.error,a]),Q.useEffect(()=>{let e=null,t=F(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{_.invalidateQueries({queryKey:cl,exact:!0}),_.invalidateQueries({queryKey:ll,exact:!0})},400))});return()=>{e&&clearTimeout(e),t()}},[]),Q.useEffect(()=>{g===`edit`&&m&&!U&&B.isSuccess&&(h(null),v(`closed`))},[g,U,m,B.isSuccess]);let ce=D({mutationFn:({projectID:e,taskDraft:t})=>sc(e,t),onSuccess:(e,{projectID:t})=>{_.setQueryData(cl,n=>fl(n,t,e))}}),K=D({mutationFn:({projectID:e,taskID:t})=>cc(e,t),onSuccess:(e,{projectID:t})=>{_.setQueryData(cl,n=>fl(n,t,e))}}),le=D({mutationFn:({projectID:e,taskID:t})=>lc(e,t),onSuccess:()=>{_.invalidateQueries({queryKey:cl,exact:!0}),_.invalidateQueries({queryKey:ll,exact:!0})}}),de=D({mutationFn:({projectID:e,task:t})=>sc(e,t),onMutate:({projectID:e,task:t})=>{let n=_.getQueryData(cl);return _.setQueryData(cl,n=>n&&{...n,tasks:n.tasks.map(n=>n.projectId===e&&n.task.id===t.id?{projectId:e,task:t}:n)}),{previousTasks:n}},onSuccess:(e,{projectID:t})=>{_.setQueryData(cl,n=>fl(n,t,e))},onError:(e,t,n)=>{n?.previousTasks&&_.setQueryData(cl,n.previousTasks)}}),fe=j(()=>!T||window.confirm(a(`sessions.scheduledTasks.workspace.confirm.discardChanges`)));Q.useEffect(()=>{if(!T){l(null);return}let e=e=>e===`schedule`||window.confirm(a(`sessions.scheduledTasks.workspace.confirm.discardChanges`));return l(e),()=>{s.getState().mainTabGuard===e&&l(null)}},[T,l,a]);let pe=j(e=>{let t={projectId:e.projectId,taskId:e.task.id};(sl(t)!==(m?sl(m):``)||g!==`edit`)&&fe()&&(h(t),v(`edit`),E(!1))}),me=j(()=>{!f||!fe()||(h(null),v(`create`),E(!1))}),he=j((e,t)=>{let n=s.getState();as({sessionId:null,tab:`schedule`,isSettingsOpen:n.isSettingsDialogOpen,settingsPath:n.settingsPage,diffFile:null,scheduleView:e,scheduleProjectId:t?.projectId??null,scheduleTaskId:t?.taskId??null})}),ge=j(e=>{x!==e&&(g!==`closed`&&!fe()||(h(null),v(`closed`),E(!1),S(e),he(e,null)))}),_e=j(t=>{e===`mobile-panel`&&t.sessionId&&t.directory&&n?.(!1),xe(t.sessionId,t.directory,{phoneShell:!!(z&&!q()),switchToChat:!0})}),ve=j(async()=>{if(re.data&&re.hasNextPage){await re.fetchNextPage();return}await re.refetch()}),ye=j(e=>{e||!fe()||(h(null),v(`closed`),E(!1))}),be=j(()=>g===`closed`?(n?.(!1),!0):(ye(!1),!0));Q.useEffect(()=>{if(e!==`mobile-panel`||!t)return;ul=be;let n=()=>be();return window.addEventListener(`oc:scheduled-tasks-close-request`,n),()=>{ul===be&&(ul=null),window.removeEventListener(`oc:scheduled-tasks-close-request`,n)}},[e,t]);let Se=j(()=>g!==`closed`&&(ye(!1),!0));Wt({id:`mobile-scheduled-editor`,active:R&&g!==`closed`,onBack:Se,surfaceRef:ne,underlayRef:L}),Q.useEffect(()=>{if(r)return r(Se),()=>r(null)},[r]);let Ce=j(async e=>{let t=m?.projectId||f;if(!t)throw Error(a(`sessions.scheduledTasks.dialog.error.chooseProjectFirst`));let n=new Set(V.filter(e=>e.projectId===t).map(e=>e.task.id)),r=await ce.mutateAsync({projectID:t,taskDraft:e}),i=e.id?r.find(t=>t.id===e.id):r.find(e=>!n.has(e.id)),o=[...r].filter(t=>t.name===e.name).sort((e,t)=>(t.state?.updatedAt||0)-(e.state?.updatedAt||0))[0],s=i||o;return s&&(h({projectId:t,taskId:s.id}),v(`edit`)),E(!1),J.success(a(`sessions.scheduledTasks.dialog.toast.saved`)),s}),we=j(async e=>{let{projectId:t,task:n}=e;if(window.confirm(a(`sessions.scheduledTasks.dialog.confirm.deleteTask`,{taskName:n.name}))){M(sl({projectId:t,taskId:n.id}));try{await K.mutateAsync({projectID:t,taskID:n.id});let e=sl({projectId:t,taskId:n.id});m&&sl(m)===e&&(h(null),v(`closed`),E(!1)),J.success(a(`sessions.scheduledTasks.dialog.toast.deleted`))}catch(e){J.error(e instanceof Error?e.message:a(`sessions.scheduledTasks.dialog.toast.deleteFailed`))}finally{M(null)}}}),Te=j(async({projectId:e,task:t})=>{M(sl({projectId:e,taskId:t.id}));try{await le.mutateAsync({projectID:e,taskID:t.id}),J.success(a(`sessions.scheduledTasks.dialog.toast.started`))}catch(e){J.error(e instanceof Error?e.message:a(`sessions.scheduledTasks.dialog.toast.runFailed`))}finally{M(null)}}),Ee=j(async({projectId:e,task:t},n)=>{M(sl({projectId:e,taskId:t.id}));try{await de.mutateAsync({projectID:e,task:{...t,enabled:n}})}catch(e){J.error(e instanceof Error?e.message:a(`sessions.scheduledTasks.dialog.toast.updateFailed`))}finally{M(null)}}),De=Q.useMemo(()=>{let e=C.trim().toLocaleLowerCase();return V.filter(({task:t})=>y===`active`&&!t.enabled||y===`paused`&&t.enabled?!1:!e||t.name.toLocaleLowerCase().includes(e)||el(t,a).toLocaleLowerCase().includes(e))},[y,C,a,V]),Oe=e=>{let t=e.icon?Ye[e.icon]:null,n=e.color?Qe[e.color]:void 0,r=(0,$.jsx)(X,{name:t??`folder`,className:`size-3.5`,style:n?{color:n}:void 0});return(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:e.iconImage?(0,$.jsx)(We,{project:e,className:`size-full object-contain`,fallback:r}):r}),(0,$.jsx)(`span`,{className:`truncate`,children:ke(e.path)})]})},Ae=u.map(e=>({id:e.id,label:Oe(e)}));return(0,$.jsxs)(`div`,{className:Y(`relative flex min-h-0`,R?`oc-mobile-scheduled-workspace w-full flex-col overflow-visible bg-transparent`:`h-full overflow-hidden bg-background`,z&&`flex-col`),"data-presentation":e,children:[(0,$.jsxs)(`div`,{ref:R?L:void 0,"data-mobile-navigation-underlay":R?`true`:void 0,"aria-hidden":R&&g!==`closed`?!0:void 0,inert:R&&g!==`closed`?!0:void 0,className:Y(R?`flex w-full min-w-0 flex-col gap-[var(--oc-mobile-page-gap)]`:`contents`),children:[R?(0,$.jsx)(zn,{title:a(`sessions.scheduledTasks.dialog.title`)}):null,z&&!R?(0,$.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b border-border/40 px-2`,children:[g===`closed`?null:(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`size-11 shrink-0 rounded-lg`,onClick:be,"aria-label":a(`header.actions.backAria`),children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-5`})}),(0,$.jsx)(`h2`,{className:`min-w-0 flex-1 truncate px-1 typography-ui-label font-semibold text-foreground`,children:a(g===`edit`?`sessions.scheduledTasks.editor.title.edit`:g===`create`?`sessions.scheduledTasks.editor.title.new`:`sessions.scheduledTasks.dialog.title`)}),g===`edit`&&U?(0,$.jsxs)(yt,{children:[(0,$.jsx)(bt,{asChild:!0,children:(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`size-11 shrink-0 rounded-lg`,disabled:!!A,"aria-label":a(`sessions.scheduledTasks.dialog.actions.moreAria`,{taskName:U.task.name}),children:(0,$.jsx)(X,{name:`more-2`,className:`size-5`})})}),(0,$.jsxs)(vt,{align:`end`,className:`min-w-40`,children:[(0,$.jsxs)(xt,{className:`min-h-11`,onSelect:()=>void Te(U),children:[(0,$.jsx)(X,{name:`play`,className:`size-4`}),a(`sessions.scheduledTasks.dialog.actions.runNow`)]}),(0,$.jsxs)(xt,{className:`min-h-11`,onSelect:()=>void Ee(U,!U.task.enabled),children:[(0,$.jsx)(X,{name:U.task.enabled?`pause`:`play`,className:`size-4`}),U.task.enabled?a(`sessions.scheduledTasks.dialog.actions.pause`):a(`sessions.scheduledTasks.dialog.actions.resume`)]}),(0,$.jsxs)(xt,{variant:`destructive`,className:`min-h-11`,onSelect:()=>void we(U),children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`}),a(`sessions.scheduledTasks.dialog.actions.delete`)]})]})]}):g===`closed`?(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:`size-11 shrink-0 rounded-lg`,onClick:be,"aria-label":a(`mobile.surface.closeAria`),children:(0,$.jsx)(X,{name:`close`,className:`size-5`})}):(0,$.jsx)(`span`,{className:`size-11 shrink-0`,"aria-hidden":`true`})]}):null,(0,$.jsxs)(`section`,{className:Y(`min-w-0 flex-col transition-[width] duration-300 ease-out`,R?`flex-none overflow-visible`:`flex-1 overflow-hidden`,z&&!R&&g!==`closed`?`hidden`:`flex`),children:[(0,$.jsx)(`header`,{className:Y(`shrink-0`,R?`pb-0 pt-0`:z?`px-3 pb-3 pt-3`:`px-4 pb-5 pt-4 sm:px-6`),children:(0,$.jsxs)(`div`,{className:Y(`mx-auto w-full`,R?`max-w-[26rem]`:`max-w-4xl`),children:[(0,$.jsx)(`div`,{className:Y((x===`tasks`||!R)&&`mb-3`,R?`oc-mobile-floating-surface oc-mobile-segmented-track`:`grid grid-cols-2 gap-1 rounded-xl bg-[var(--surface-muted)] p-1`),role:`tablist`,"aria-label":a(`sessions.scheduledTasks.workspace.views.aria`),children:[`tasks`,`history`].map(e=>(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,role:`tab`,"aria-selected":x===e,"data-mobile-press-feedback":R?`none`:void 0,className:Y(R?`oc-mobile-segmented-item`:`relative min-h-9 rounded-lg text-muted-foreground transition-[background-color,color,box-shadow] motion-reduce:transition-none`,!R&&z&&`min-h-11`,!R&&(x===e?`text-foreground hover:bg-transparent hover:text-foreground`:`hover:bg-interactive-hover/40 hover:text-foreground`)),onClick:()=>ge(e),children:[x===e?(0,$.jsx)(jn.span,{layoutId:`scheduled-workspace-view-pill`,className:Y(`oc-segmented-selected-pill absolute inset-0`,!R&&`rounded-lg`),transition:{duration:o?0:.18,ease:[.22,1,.36,1]},"aria-hidden":`true`}):null,(0,$.jsxs)(`span`,{className:`relative z-[1] inline-flex items-center gap-1.5`,children:[(0,$.jsx)(X,{name:e===`tasks`?`calendar-schedule`:`history`,className:`size-4 shrink-0`}),a(`sessions.scheduledTasks.workspace.views.${e}`)]})]},e))}),x===`tasks`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:Y(R?`oc-mobile-floating-surface oc-mobile-segmented-track oc-mobile-scheduled-controls`:Y(`flex items-center justify-between`,z?`gap-2`:`gap-3`)),children:[(0,$.jsx)(`div`,{className:Y(R?`oc-mobile-segmented-group`:Y(`flex items-center gap-1`,z&&`min-w-0 flex-1`)),role:`group`,"aria-label":a(`sessions.scheduledTasks.dialog.title`),children:[`all`,`active`,`paused`].map(e=>(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,"data-mobile-press-feedback":R?`none`:void 0,className:Y(R?`oc-mobile-segmented-item`:`relative border-0 bg-transparent text-muted-foreground shadow-none transition-[color,background-color,transform] duration-150 ease-out motion-reduce:transition-none active:scale-[0.97]`,!R&&(z?`h-11 min-h-11 min-w-0 flex-1 rounded-xl px-2`:`!h-9 !min-h-9 rounded-xl px-3`),!R&&(y===e?`text-foreground hover:bg-transparent hover:text-foreground`:`hover:bg-interactive-hover/40 hover:text-foreground`)),"aria-pressed":y===e,onClick:()=>b(e),children:[y===e?(0,$.jsx)(jn.span,{layoutId:`scheduled-task-filter-pill`,className:Y(`oc-segmented-selected-pill absolute inset-0`,!R&&`rounded-xl`),transition:{duration:o?0:.18,ease:[.22,1,.36,1]},"aria-hidden":`true`}):null,(0,$.jsx)(`span`,{className:`relative z-[1]`,children:a(`sessions.scheduledTasks.workspace.filters.${e}`)})]},e))}),R?(0,$.jsx)(Z,{variant:`ghost`,"data-mobile-press-feedback":`none`,className:`oc-mobile-segmented-action shrink-0 bg-foreground text-background transition-[background-color,transform,box-shadow] duration-150 ease-out hover:bg-foreground/90 hover:text-background hover:shadow-sm active:scale-[0.97] motion-reduce:transition-none`,onClick:me,disabled:!f,"aria-label":a(`sessions.scheduledTasks.dialog.actions.create`),children:(0,$.jsx)(X,{name:`add`,className:`size-4`})}):(0,$.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,$.jsxs)(Z,{variant:`ghost`,className:Y(`shrink-0 rounded-full bg-foreground text-background transition-[background-color,transform,box-shadow] duration-150 ease-out hover:bg-foreground/90 hover:text-background hover:shadow-sm active:scale-[0.97] motion-reduce:transition-none`,z?`size-11 min-h-11 px-0 min-[400px]:w-auto min-[400px]:px-3.5`:`!h-9 !min-h-9 px-3.5`),onClick:me,disabled:!f,"aria-label":a(`sessions.scheduledTasks.dialog.actions.create`),children:[(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),` `,(0,$.jsx)(`span`,{className:Y(z&&`hidden min-[400px]:inline`),children:a(`sessions.scheduledTasks.dialog.actions.create`)})]})})]}),R?null:(0,$.jsxs)(`div`,{className:Y(`group relative w-full`,z?`mt-3`:`mt-7`),children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground transition-[color,transform] duration-150 ease-out group-focus-within:scale-105 group-focus-within:text-foreground motion-reduce:transition-none`}),(0,$.jsx)(ot,{value:C,onChange:e=>w(e.target.value),placeholder:a(`sessions.scheduledTasks.workspace.search.placeholder`),className:Y(`rounded-full bg-[var(--surface-elevated)] pl-10 pr-4 ring-1 ring-inset ring-border/50 transition-[background-color,box-shadow,color] duration-200 ease-out hover:[&:not(:focus)]:ring-border focus:bg-[var(--surface-elevated)] focus:shadow-sm focus:ring-2 focus:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,z?`h-11 min-h-11`:`!h-9 !min-h-9`)})]})]}):null]})}),(0,$.jsx)(`div`,{className:Y(R?`flex-none overflow-visible pt-[var(--oc-mobile-page-gap)]`:`min-h-0 flex-1 overflow-y-auto`,!R&&(z?`overscroll-none px-3 pb-[max(1rem,env(safe-area-inset-bottom))]`:`px-6 pb-6 [scrollbar-gutter:stable]`)),children:(0,$.jsx)(`div`,{className:Y(`mx-auto w-full`,R?`max-w-[26rem]`:`max-w-4xl border-t border-border/40 pt-4`),children:x===`history`?(0,$.jsx)(`div`,{className:`space-y-3`,children:re.isLoading?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 typography-meta text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}),a(`sessions.scheduledTasks.history.loading`)]}):re.error&&ie.length===0?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-border p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(X,{name:`error-warning`,className:`mt-0.5 size-4 shrink-0 text-[var(--status-error)]`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-foreground`,children:a(`sessions.scheduledTasks.history.error.title`)}),(0,$.jsx)(`p`,{className:`mt-1 break-words typography-meta text-muted-foreground`,children:re.error instanceof Error?re.error.message:a(`sessions.scheduledTasks.history.error.description`)})]}),(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>void ve(),children:a(`sessions.scheduledTasks.history.retry`)})]})}):ie.length===0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-dashed border-border p-6 text-center`,children:[(0,$.jsx)(X,{name:`history`,className:`mx-auto size-5 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`mt-2 typography-ui-label font-medium text-foreground`,children:a(`sessions.scheduledTasks.history.empty.title`)}),(0,$.jsx)(`p`,{className:`mt-1 typography-meta text-muted-foreground`,children:a(`sessions.scheduledTasks.history.empty.description`)})]}):(0,$.jsxs)(`div`,{className:Y(R?`space-y-4`:z?`space-y-2`:`divide-y divide-border/50 overflow-hidden rounded-xl border border-border/60 bg-[var(--surface-elevated)]`),children:[ie.map(e=>{let t=se.get(e.projectId),n=t?ke(t.path):e.projectId,r=e.directory?ke(e.directory):null,i=r&&r!==n?`${n} · ${r}`:n,o=al[e.status],s=!!(e.sessionId&&e.directory),c=il(rl(e,ae))??(e.status===`running`?a(`sessions.scheduledTasks.history.duration.pending`):null),l=nl(e.startedAt),u=a(`sessions.scheduledTasks.history.trigger.${e.trigger}`),d=e.trigger===`manual`?`play`:`calendar-schedule`,f=a(`sessions.scheduledTasks.dialog.status.${e.status}`),p=o.tone===`muted`?void 0:{color:`var(--status-${o.tone})`},m=t?.icon?Ye[t.icon]??`folder`:`folder`,h=t?.color?Qe[t.color]:void 0,g=(0,$.jsx)(`span`,{className:`flex size-3.5 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:t?.iconImage?(0,$.jsx)(We,{project:t,className:`size-full object-contain`,fallback:(0,$.jsx)(X,{name:m,className:`size-3.5`,style:h?{color:h}:void 0})}):(0,$.jsx)(X,{name:m,className:`size-3.5`,style:h?{color:h}:void 0})}),_=(0,$.jsx)(`span`,{className:Y(`mt-0.5 flex shrink-0 items-center justify-center rounded-full border`,z?`size-7`:`size-8`),style:ol(o.tone),title:f,"aria-label":f,children:(0,$.jsx)(X,{name:o.Icon,className:Y(z?`size-3.5`:`size-4`,o.spin&&`animate-spin motion-reduce:animate-none`)})}),v=(0,$.jsxs)(`p`,{className:Y(`mt-0.5 flex min-w-0 items-center gap-1.5 text-muted-foreground`,z?`typography-micro`:`truncate typography-meta`),title:e.directory??n,children:[g,(0,$.jsx)(`span`,{className:Y(`min-w-0`,z?`break-words`:`truncate`),children:i})]}),y=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[c?(0,$.jsx)(`span`,{className:`typography-micro tabular-nums text-muted-foreground`,title:c,children:c}):null,(0,$.jsx)(`span`,{className:`typography-micro font-medium`,style:p,children:f})]}),b=(0,$.jsxs)(`div`,{className:Y(`flex w-full min-w-0 items-start`,z?`gap-2.5`:`gap-3`),children:[_,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-start justify-between gap-2`,children:[(0,$.jsx)(`h3`,{className:Y(`min-w-0 flex-1 font-semibold text-foreground`,z?`break-words typography-meta leading-snug`:`truncate typography-ui-label`),children:e.taskName}),y]}),v,(0,$.jsxs)(`div`,{className:Y(`mt-1 flex w-full min-w-0 gap-2`,z?`items-center`:`items-center justify-between gap-3`),children:[(0,$.jsxs)(`div`,{className:Y(`flex min-w-0 flex-1 flex-wrap items-center gap-x-3 gap-y-1 typography-micro text-muted-foreground`,z&&`gap-x-2.5 gap-y-0.5`),children:[(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,title:l,children:[(0,$.jsx)(X,{name:`time`,className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`whitespace-nowrap tabular-nums`,children:l})]}),(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,title:u,children:[(0,$.jsx)(X,{name:d,className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:u})]})]}),!z&&s?(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-7 shrink-0 self-center text-foreground`,onClick:()=>_e(e),children:a(`sessions.scheduledTasks.history.openSession`)}):null]}),e.error?(0,$.jsxs)(`p`,{className:Y(`mt-1.5 min-w-0 break-words typography-micro text-[var(--surface-muted-foreground)] [overflow-wrap:anywhere]`,z?`line-clamp-3`:`line-clamp-1`),title:e.error.slice(0,300),children:[(0,$.jsx)(X,{name:`error-warning`,className:`mr-1 inline-block size-3 align-[-0.125em] text-[var(--status-error)]`,"aria-hidden":`true`}),e.error.slice(0,300)]}):null]})]});if(z){let t=a(`sessions.scheduledTasks.history.openSession`),n=Y(`oc-mobile-scheduled-task-card w-full`,R?`oc-mobile-floating-surface oc-mobile-project-shell rounded-[var(--oc-mobile-surface-radius)]`:`rounded-xl border border-border/60 bg-[var(--surface-elevated)] shadow-sm dark:shadow-none`);return s?(0,$.jsx)(`article`,{"data-mobile-press-surface":`soft`,className:n,children:(0,$.jsx)(`button`,{type:`button`,"data-mobile-press-surface-trigger":!0,"data-mobile-press-feedback":`none`,className:Y(`oc-mobile-scheduled-task-row w-full p-3 text-left outline-none`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`),"aria-label":t,onClick:()=>_e(e),children:b})},e.id):(0,$.jsx)(`article`,{className:Y(n,`p-3`),children:b},e.id)}return(0,$.jsx)(`article`,{className:`w-full min-w-0 px-4 py-3`,children:b},e.id)}),re.error?(0,$.jsxs)(`div`,{className:Y(`flex flex-wrap items-center justify-between gap-2 p-3 typography-meta text-[var(--status-error-foreground)]`,z?`rounded-xl border border-[var(--status-error-border)] bg-[var(--status-error-background)]`:`border-t border-[var(--status-error-border)] bg-[var(--status-error-background)]`),children:[(0,$.jsx)(`span`,{children:a(`sessions.scheduledTasks.history.error.more`)}),(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>void ve(),children:a(`sessions.scheduledTasks.history.retry`)})]}):null,re.hasNextPage?(0,$.jsx)(`div`,{className:Y(`flex justify-center`,z?`pt-2`:`border-t border-border/40 px-4 py-3`),children:(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:Y(z&&`min-h-11`),disabled:re.isFetchingNextPage,onClick:()=>void re.fetchNextPage(),children:[re.isFetchingNextPage?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}):(0,$.jsx)(X,{name:`history`,className:`size-4`}),re.isFetchingNextPage?a(`sessions.scheduledTasks.history.loadingMore`):a(`sessions.scheduledTasks.history.loadMore`)]})}):null]})}):(0,$.jsxs)($.Fragment,{children:[H.length>0?(0,$.jsx)(`div`,{className:`mb-3 rounded-xl border p-3 typography-meta`,style:ol(`warning`),children:a(`sessions.scheduledTasks.workspace.partialLoadWarning`)}):null,B.isLoading?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 typography-meta text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),` `,a(`sessions.scheduledTasks.dialog.loading`)]}):B.error?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:B.error instanceof Error?B.error.message:a(`sessions.scheduledTasks.dialog.toast.loadFailed`)}):(0,$.jsx)(An,{initial:!1,mode:`popLayout`,children:De.length===0?(0,$.jsx)(jn.div,{initial:o?{opacity:0}:{opacity:0,y:4},animate:{opacity:1,y:0},exit:o?{opacity:0}:{opacity:0,y:-4},transition:{duration:o?0:.18,ease:[.22,1,.36,1]},className:`rounded-xl border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:V.length>0?a(`sessions.scheduledTasks.workspace.search.noResults`):a(`sessions.scheduledTasks.dialog.empty.noTasks`)},`empty`):(0,$.jsx)(jn.div,{initial:o?{opacity:0}:{opacity:0,y:4},animate:{opacity:1,y:0},exit:o?{opacity:0}:{opacity:0,y:-4},transition:{duration:o?0:.18,ease:[.22,1,.36,1]},className:Y(R?`space-y-4`:`space-y-1`),children:(0,$.jsx)(An,{initial:!1,mode:`popLayout`,children:De.map(e=>{let{projectId:t,task:n}=e,r=sl({projectId:t,taskId:n.id}),i=g===`edit`&&m!==null&&sl(m)===r,s=n.state?.nextRunAt,l=n.state?.lastStatus||`idle`,u=al[l],d=A===r,f=t=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(t,{className:Y(z&&`min-h-11`),onClick:t=>{t.stopPropagation(),Te(e)},disabled:d,children:[(0,$.jsx)(X,{name:`play`,className:`size-4`}),a(`sessions.scheduledTasks.dialog.actions.runNow`)]}),(0,$.jsxs)(t,{className:Y(z&&`min-h-11`),onClick:t=>{t.stopPropagation(),Ee(e,!n.enabled)},disabled:d,children:[(0,$.jsx)(X,{name:n.enabled?`pause`:`play`,className:`size-4`}),n.enabled?a(`sessions.scheduledTasks.dialog.actions.pause`):a(`sessions.scheduledTasks.dialog.actions.resume`)]}),(0,$.jsxs)(t,{onClick:t=>{t.stopPropagation(),we(e)},disabled:d,className:Y(`text-destructive focus:text-destructive`,z&&`min-h-11`),children:[(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`}),a(`sessions.scheduledTasks.dialog.actions.delete`)]})]});return(0,$.jsx)(jn.div,{layout:`position`,initial:!o&&{opacity:0,y:6},animate:{opacity:1,y:0},exit:o?{opacity:0}:{opacity:0,y:-6},transition:{duration:o?0:.18,ease:[.22,1,.36,1]},"data-mobile-press-surface":R?`soft`:void 0,className:Y(R&&`oc-mobile-floating-surface oc-mobile-project-shell oc-mobile-scheduled-task-card`),children:(0,$.jsxs)(qn,{open:N===r,onOpenChange:e=>{e&&te(null),P(e?r:null)},children:[(0,$.jsxs)(`div`,{className:Y(`group flex w-full items-center gap-1`,R&&`oc-mobile-project-card`),children:[(0,$.jsxs)(Un,{render:(0,$.jsx)(`button`,{type:`button`,onClick:()=>pe(e),onContextMenu:!z&&!c?e=>{e.preventDefault(),te(null),P(r)}:void 0,"data-mobile-press-surface-trigger":R?!0:void 0,"data-mobile-press-feedback":R?`none`:void 0,className:Y(`flex min-h-11 min-w-0 flex-1 items-center rounded-xl border py-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,R?`oc-mobile-project-trigger oc-mobile-scheduled-task-row border-0 bg-transparent transition-opacity duration-150`:`transition-[background-color,border-color,box-shadow,transform,opacity] duration-150 ease-out active:scale-[0.995]`,z&&!R?`gap-2.5 px-3`:R?void 0:`gap-3 px-4`,!R&&(i?`border-border/50 bg-[var(--surface-elevated)] shadow-sm dark:shadow-none`:`border-transparent hover:bg-interactive-hover`),!n.enabled&&`opacity-65`),"aria-pressed":i}),children:[(0,$.jsx)(`span`,{className:Y(`flex shrink-0 items-center justify-center rounded-full text-muted-foreground transition-[border-color,color,background-color] duration-150 motion-reduce:transition-none`,R?`oc-mobile-project-icon oc-mobile-glass-control`:`size-5 border border-border`),style:n.enabled&&u.tone!==`muted`?{color:`var(--status-${u.tone})`}:void 0,children:(0,$.jsx)(An,{initial:!1,mode:`wait`,children:(0,$.jsx)(jn.span,{initial:!o&&{opacity:0,scale:.72},animate:{opacity:1,scale:1},exit:o?{opacity:0}:{opacity:0,scale:.72},transition:{duration:o?0:.15},className:`flex`,children:(0,$.jsx)(X,{name:n.enabled?u.Icon:`pause`,className:Y(R?`oc-mobile-project-icon-glyph`:`size-3.5`,u.spin&&n.enabled&&`animate-spin`)})},`${n.enabled}-${l}`)})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:Y(`block truncate font-medium`,R?`oc-mobile-project-title oc-mobile-entity-title font-semibold`:`typography-ui-label`),children:n.name}),(0,$.jsxs)(`span`,{className:Y(`mt-1 flex min-w-0 items-center text-muted-foreground`,R?`oc-mobile-project-meta oc-mobile-entity-meta`:`gap-1 typography-micro`),children:[(0,$.jsx)(`span`,{className:`truncate`,children:el(n,a,!R)}),(0,$.jsx)(`span`,{className:`shrink-0 text-muted-foreground/50`,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0 truncate`,children:s?tl(s,a):`—`})]})]})]}),(0,$.jsxs)(yt,{open:I===r,onOpenChange:e=>{e&&P(null),te(e?r:null)},children:[(0,$.jsx)(bt,{asChild:!0,children:(0,$.jsx)(Z,{type:`button`,variant:`ghost`,size:`icon`,className:Y(`shrink-0 self-center text-muted-foreground transition-[opacity,transform,background-color] duration-150 ease-out active:scale-95 data-[popup-open]:bg-interactive-hover motion-reduce:transition-none`,R?`oc-mobile-project-action oc-mobile-scheduled-task-action rounded-full`:`rounded-lg`,R?void 0:z?`size-11`:`size-8 translate-x-1 opacity-0 group-hover:translate-x-0 group-hover:opacity-100 data-[popup-open]:translate-x-0 data-[popup-open]:opacity-100`,i&&!R&&`opacity-100`),onClick:e=>e.stopPropagation(),"aria-label":a(`sessions.scheduledTasks.dialog.actions.moreAria`,{taskName:n.name}),children:(0,$.jsx)(X,{name:`more-2`,className:R?`size-5`:`size-4`})})}),(0,$.jsx)(vt,{align:`end`,className:`min-w-40 motion-reduce:transition-none`,onClick:e=>e.stopPropagation(),children:f(xt)})]})]}),(0,$.jsx)(Gn,{className:`min-w-40 motion-reduce:transition-none`,children:f(Kn)})]})},r)})})},`tasks`)})]})})})]})]}),c?g===`closed`?null:(0,$.jsx)(`div`,{ref:R?ne:void 0,className:Y(R?`fixed inset-0 z-50 flex h-[100dvh] w-full min-w-0 max-w-full flex-col overflow-hidden bg-background [contain:layout_paint]`:`contents`),children:(0,$.jsx)(Yc,{open:!0,presentation:R?`mobile-tab`:z?`mobile-panel`:void 0,task:g===`edit`?W:null,onOpenChange:ye,onSave:Ce,onDirtyChange:E,onRun:async()=>{U&&await Te(U)},onDelete:async()=>{U&&await we(U)},onToggleEnabled:async(e,t)=>{U&&await Ee(U,t)},actionBusy:!!A,projectID:m?.projectId||f,projectOptions:Ae,onProjectChange:g===`create`?p:void 0})}):(0,$.jsx)(An,{initial:!1,children:g===`closed`?null:(0,$.jsx)(jn.div,{initial:o?{opacity:1,width:0}:{opacity:0,width:0,x:24},animate:{opacity:1,width:`clamp(380px, 36vw, 480px)`,x:0},exit:o?{opacity:0,width:0}:{opacity:0,width:0,x:24},transition:{duration:o?0:.26,ease:[.22,1,.36,1]},className:`h-full min-h-0 max-w-[480px] shrink-0 overflow-hidden`,children:(0,$.jsx)(`aside`,{className:`h-full min-h-0 w-[clamp(380px,36vw,480px)] border-l border-border/60 bg-background`,children:(0,$.jsx)(Yc,{open:!0,presentation:`panel`,task:g===`edit`?W:null,onOpenChange:ye,onSave:Ce,onDirtyChange:E,onRun:async()=>{U&&await Te(U)},onDelete:async()=>{U&&await we(U)},onToggleEnabled:async(e,t)=>{U&&await Ee(U,t)},actionBusy:!!A,projectID:m?.projectId||f,projectOptions:Ae,onProjectChange:g===`create`?p:void 0})})},`scheduled-task-details`)})]})}var bl={"?":{code:`?`,color:`var(--status-info)`,description:`Untracked file`},A:{code:`A`,color:`var(--status-success)`,description:`New file`},D:{code:`D`,color:`var(--status-error)`,description:`Deleted file`},R:{code:`R`,color:`var(--status-info)`,description:`Renamed file`},C:{code:`C`,color:`var(--status-info)`,description:`Copied file`},M:{code:`M`,color:`var(--status-warning)`,description:`Modified file`}},xl=bl.M;function Sl(e){let t=e.index?.trim(),n=e.working_dir?.trim();return t&&t!==`?`?t.charAt(0):n?n.charAt(0):t?.charAt(0)||n?.charAt(0)||`M`}function Cl(e){return bl[Sl(e)]??xl}var wl=Q.memo(function(e){let t=(0,Qn.c)(61),{file:n,actionLabel:r,actionSymbol:i,onAction:a,onViewDiff:o,onRevert:s,isReverting:c,stats:l,rowPaddingClassName:u,indentPx:d,actionAtStart:f,showRevert:p}=e,m=d===void 0?0:d,h=f!==void 0&&f,g=p===void 0||p,_;t[0]===n?_=t[1]:(_=Cl(n),t[0]=n,t[1]=_);let v=_,{t:y}=ee(),b=v.description,x=l?.insertions??0,S=l?.deletions??0,C;t[2]!==a||t[3]!==o?(C=e=>{e.key===` `?(e.preventDefault(),a()):e.key===`Enter`&&(e.preventDefault(),o())},t[2]=a,t[3]=o,t[4]=C):C=t[4];let w=C,T;t[5]===a?T=t[6]:(T=e=>{e.preventDefault(),e.stopPropagation(),a()},t[5]=a,t[6]=T);let E=T,D;t[7]===s?D=t[8]:(D=e=>{e.preventDefault(),e.stopPropagation(),s()},t[7]=s,t[8]=D);let O=D,k;t[9]!==r||t[10]!==i||t[11]!==E?(k=(0,$.jsx)(`button`,{type:`button`,onClick:E,className:`flex size-6 items-center justify-center rounded typography-code font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":r,title:r,children:i}),t[9]=r,t[10]=i,t[11]=E,t[12]=k):k=t[12];let A=k,j=`group flex h-8 items-center cursor-pointer ${u??`px-3`}`,M;t[13]===m?M=t[14]:(M=m>0?{paddingLeft:`${m}px`}:void 0,t[13]=m,t[14]=M);let N=h?A:null,P;t[15]===v.color?P=t[16]:(P={color:v.color},t[15]=v.color,t[16]=P);let F;t[17]!==v.code||t[18]!==b||t[19]!==P?(F=(0,$.jsx)(`span`,{className:`typography-code font-semibold w-3.5 shrink-0 text-center uppercase`,style:P,title:b,"aria-label":b,children:v.code}),t[17]=v.code,t[18]=b,t[19]=P,t[20]=F):F=t[20];let I;t[21]===n.path?I=t[22]:(I=(0,$.jsx)(It,{filePath:n.path,className:`size-3 shrink-0`}),t[21]=n.path,t[22]=I);let te;if(t[23]!==n.path){bb0:{let e=n.path.lastIndexOf(`/`);if(e===-1){let e;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(e={direction:`rtl`,textAlign:`left`,unicodeBidi:`plaintext`},t[25]=e):e=t[25],te=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-code text-foreground`,style:e,title:n.path,children:n.path});break bb0}let r=n.path.slice(0,e),i=n.path.slice(e),a;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(a={direction:`rtl`,textAlign:`left`,unicodeBidi:`plaintext`},t[26]=a):a=t[26];let o;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`/`}),t[27]=o):o=t[27];let s=(0,$.jsx)(`span`,{className:`text-foreground`,children:i.slice(1)}),c;t[28]===s?c=t[29]:(c=(0,$.jsxs)(`span`,{className:`flex-shrink-0 typography-code`,children:[o,s]}),t[28]=s,t[29]=c),te=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline overflow-hidden`,title:n.path,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-code text-muted-foreground`,style:a,children:r}),c]})}t[23]=n.path,t[24]=te}else te=t[24];let ne;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(ne={color:`var(--status-success)`},t[30]=ne):ne=t[30];let L;t[31]===x?L=t[32]:(L=(0,$.jsxs)(`span`,{style:ne,children:[`+`,x]}),t[31]=x,t[32]=L);let R,z;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(`span`,{className:`text-muted-foreground mx-0.5`,children:`/`}),z={color:`var(--status-error)`},t[33]=R,t[34]=z):(R=t[33],z=t[34]);let B;t[35]===S?B=t[36]:(B=(0,$.jsxs)(`span`,{style:z,children:[`-`,S]}),t[35]=S,t[36]=B);let V;t[37]!==L||t[38]!==B?(V=(0,$.jsxs)(`span`,{className:`shrink-0 typography-code tabular-nums`,children:[L,R,B]}),t[37]=L,t[38]=B,t[39]=V):V=t[39];let H;t[40]!==F||t[41]!==I||t[42]!==te||t[43]!==V?(H=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[F,I,te,V]}),t[40]=F,t[41]=I,t[42]=te,t[43]=V,t[44]=H):H=t[44];let U;t[45]!==h||t[46]!==A||t[47]!==n.path||t[48]!==O||t[49]!==c||t[50]!==g||t[51]!==y?(U=h?null:(0,$.jsxs)(`div`,{className:`ml-auto grid shrink-0 grid-flow-col auto-cols-[1.5rem] items-center justify-end`,children:[g?(0,$.jsxs)(lt,{children:[(0,$.jsx)(st,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:O,disabled:c,className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":y(`gitView.changes.revertFileAria`,{path:n.path}),children:c?(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(X,{name:`arrow-go-back`,className:`size-3.5`})})}),(0,$.jsx)(ct,{sideOffset:8,children:y(`gitView.changes.revertFileTooltip`)})]}):null,A]}),t[45]=h,t[46]=A,t[47]=n.path,t[48]=O,t[49]=c,t[50]=g,t[51]=y,t[52]=U):U=t[52];let W;return t[53]!==w||t[54]!==o||t[55]!==M||t[56]!==N||t[57]!==H||t[58]!==U||t[59]!==j?(W=(0,$.jsxs)(`div`,{className:j,role:`button`,tabIndex:0,onClick:o,onKeyDown:w,style:M,children:[N,H,U]}),t[53]=w,t[54]=o,t[55]=M,t[56]=N,t[57]=H,t[58]=U,t[59]=j,t[60]=W):W=t[60],W}),Tl=e=>e.replace(/\\/g,`/`).replace(/^\/+/,``).trim(),El=(e,t)=>({id:`dir:${e}`,path:e,name:t,children:new Map,directFiles:[],files:[]}),Dl=e=>{let t=El(``,``);for(let n of e){let e=Tl(n.path);if(!e)continue;let r=e.split(`/`).filter(Boolean).slice(0,-1),i=t;if(i.files.push(n),r.length>0){let e=``;for(let t of r){e=e?`${e}/${t}`:t;let r=i.children.get(t);if(r){r.files.push(n),i=r;continue}let a=El(e,t);a.files.push(n),i.children.set(t,a),i=a}}i.directFiles.push(n)}return t},Ol=(e,t)=>{let n=[],r=(e,i)=>{let a=Array.from(e.children.values()).sort((e,t)=>e.path.localeCompare(t.path));for(let e of a)n.push({key:e.id,kind:`directory`,depth:i,directory:e}),t.has(e.path)&&r(e,i+1);let o=[...e.directFiles].sort((e,t)=>e.path.localeCompare(t.path));for(let e of o)n.push({key:`file:${Tl(e.path)}`,kind:`file`,depth:i,file:e})};return r(e,0),n},kl=1e3,Al=34,jl=30,Ml=`pl-0 pr-2`,Nl=`ml-auto grid shrink-0 grid-flow-col auto-cols-[1.5rem] items-center justify-end`,Pl=`flex size-6 items-center justify-center tabular-nums typography-code text-muted-foreground`,Fl=`flex size-6 items-center justify-center rounded typography-code font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,Il=`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,Ll=(e,t)=>`${e} ${t}`,Rl=({groups:e,diffStats:t,revertingPaths:n,isRevertingAll:r=!1,headerBackgroundClassName:i=`bg-sidebar`,onVisiblePathsChange:a,onRevertAll:o,onRevertDirectory:c,headerActions:l})=>{let{t:u}=ee(),d=Q.useRef(null),f=s(e=>e.gitChangesViewMode),p=s(e=>e.setGitChangesViewMode),m=f===`tree`,h=Q.useMemo(()=>e.filter(e=>e.entries.length>0),[e]),[g,_]=Q.useState(new Set),[v,y]=Q.useState(new Set),[b,x]=Q.useState(!1),[S,C]=Q.useState(null),w=Q.useRef(new Set),T=Q.useMemo(()=>h.map(e=>Dl(e.entries)),[h]),E=Q.useMemo(()=>{let e=new Map;return h.forEach((t,n)=>{let r=[],i=e=>{e.children.forEach(e=>{r.push(Ll(t.id,e.path)),i(e)})},a=T[n];a&&i(a),e.set(t.id,r)}),e},[T,h]);Q.useEffect(()=>{if(!m){w.current=new Set;return}let e=new Set(Array.from(E.values()).flat()),t=w.current,n=t.size===0&&e.size>0;y(r=>{let i=new Set(r),a=!1;for(let t of i)e.has(t)||(i.delete(t),a=!0);for(let r of e){let e=!t.has(r);(n||e)&&!i.has(r)&&(i.add(r),a=!0)}return a?i:r}),w.current=e},[E,m]);let D=Q.useMemo(()=>{let e=[];return h.forEach((t,n)=>{if(e.push({type:`header`,key:`header:${t.id}`,groupIndex:n}),!g.has(t.id)){if(m){let r=new Set;v.forEach(e=>{e.startsWith(`${t.id} `)&&r.add(e.slice(t.id.length+1))}),Ol(T[n],r).forEach(r=>{r.kind===`file`?e.push({type:`file`,key:`${t.id}:${r.key}`,groupIndex:n,file:r.file,depth:r.depth}):e.push({type:`directory`,key:`${t.id}:${r.key}`,groupIndex:n,directory:r.directory,depth:r.depth})});return}t.entries.forEach(r=>{e.push({type:`file`,key:`${t.id}:file:${r.path}`,groupIndex:n,file:r,depth:0})})}}),o&&h.length>0&&e.push({type:`revert-all`,key:`revert-all`}),e},[g,v,m,o,T,h]),O=h[0]??null,k=Q.useMemo(()=>O?D.filter(e=>e.type!==`header`||e.groupIndex!==0):D,[O,D]),A=k.length,j=A>=kl,M=vn({count:A,enabled:j,getScrollElement:()=>d.current,estimateSize:()=>Al,overscan:12,getItemKey:e=>k[e]?.key??e}),N=M.getVirtualItems(),P=Q.useMemo(()=>{if(!j)return 0;let e=d.current?.scrollTop??0;return N.find(t=>t.end>e)?.index??0},[j,N,d]);Q.useEffect(()=>{if(!a)return;let e=e=>e&&e.type===`file`?e.file.path:null;if(A===0){a([]);return}if(!j){let e=[];for(let t of k)if(t.type===`file`&&(e.push(t.file.path),e.length>=jl))break;a(e);return}a(k.slice(P,P+Math.ceil((d.current?.clientHeight??0)/Al)+jl).map(t=>e(t)).filter(e=>!!e).slice(0,jl))},[a,A,k,j,P]);let F=Q.useCallback(e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),I=Q.useCallback((e,t)=>{y(n=>{let r=new Set(n),i=Ll(e,t);return r.has(i)?r.delete(i):r.add(i),r})},[]),te=Q.useCallback(e=>{let t=E.get(e)??[];y(e=>{let n=new Set(e);return t.forEach(e=>n.add(e)),n})},[E]),ne=Q.useCallback(e=>{let t=E.get(e)??[];y(e=>{let n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[E]),L=Q.useMemo(()=>{let e=new Set;return h.forEach(t=>t.entries.forEach(t=>e.add(t.path))),Array.from(e)},[h]),R=L.length,z=S?r||S.paths.some(e=>n.has(e)):!1,B=Q.useCallback(async()=>{!o||r||L.length===0||(await o(L),x(!1))},[L,r,o]),V=Q.useCallback(async()=>{!c||!S||z||(await c(S.paths),C(null))},[z,c,S]),H=Q.useCallback((e,t={})=>{let{pinned:n=!1,showToolbar:r=!1}=t,a=g.has(e.id),o=e.entries.length,s=E.get(e.id)??[],c=s.length>0&&s.every(e=>v.has(e)),d=u(c?`diffView.actions.collapseAll`:`diffView.actions.expandAll`),f=u(m?`settings.openchamber.git.option.flatList`:`settings.openchamber.git.option.treeView`);return(0,$.jsxs)(`div`,{className:Y(`flex h-8 items-center gap-0`,n?`shrink-0`:`sticky top-0 z-10`,i,Ml,!n&&`mt-3`),children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>F(e.id),className:`flex min-w-0 flex-1 items-center gap-1.5 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-expanded":!a,children:[(0,$.jsx)(`h3`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:e.title}),(0,$.jsx)(`span`,{className:`typography-code text-muted-foreground`,children:o}),(0,$.jsx)(X,{name:`arrow-down-s`,className:Y(`size-3 shrink-0 text-muted-foreground transition-transform`,a&&`-rotate-90`)})]}),(0,$.jsxs)(`div`,{className:Nl,children:[m?(0,$.jsx)(`button`,{type:`button`,onClick:()=>{if(c){ne(e.id);return}te(e.id)},className:Il,"aria-label":d,title:d,children:(0,$.jsx)(X,{name:c?`contract-up-down`:`expand-up-down`,className:`size-3.5`})}):null,(0,$.jsx)(`button`,{type:`button`,onClick:()=>p(m?`flat`:`tree`),"aria-label":f,title:f,"aria-pressed":m,className:Il,children:(0,$.jsx)(X,{name:m?`node-tree`:`list-unordered`,className:`size-3.5`})}),r?l:null,(0,$.jsx)(`button`,{type:`button`,onClick:()=>e.onActionAll(e.entries.map(e=>e.path)),className:Fl,"aria-label":e.actionAllLabel,title:e.actionAllLabel,children:e.actionSymbol})]})]})},[ne,g,E,te,v,l,i,m,p,u,F]),U=Q.useCallback((e,t,i)=>{let a=v.has(Ll(e.id,t.path)),o=t.files.map(e=>e.path),s=r||o.some(e=>n.has(e)),l=e.showRevertActions!==!1&&!!c;return(0,$.jsxs)(`div`,{className:Y(`group flex h-8 items-center`,Ml),style:{paddingLeft:`${i*14}px`},children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>I(e.id,t.path),className:`flex min-w-0 flex-1 items-center gap-1.5 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":u(a?`gitView.changes.collapseDirectoryAria`:`gitView.changes.expandDirectoryAria`,{path:t.path}),children:[a?(0,$.jsx)(X,{name:`folder-open-fill`,className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-3-fill`,className:`h-3.5 w-3.5 flex-shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-code text-foreground`,title:t.path,children:t.name})]}),(0,$.jsxs)(`div`,{className:Nl,children:[(0,$.jsx)(`span`,{className:Pl,children:t.files.length}),l?(0,$.jsx)(`button`,{type:`button`,onClick:()=>C({path:t.path,paths:o,count:o.length}),disabled:s,className:Il,"aria-label":u(`gitView.changes.revertDirectoryAria`,{path:t.path}),title:u(`gitView.changes.revertDirectoryTooltip`),children:s?(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(X,{name:`arrow-go-back`,className:`size-3.5`})}):null,(0,$.jsx)(`button`,{type:`button`,onClick:()=>e.onActionAll(t.files.map(e=>e.path)),className:Fl,"aria-label":u(e.actionSymbol===`+`?`gitView.changes.stageDirectoryAria`:`gitView.changes.unstageDirectoryAria`,{path:t.path}),title:u(e.actionSymbol===`+`?`gitView.changes.stageDirectoryAria`:`gitView.changes.unstageDirectoryAria`,{path:t.path}),children:e.actionSymbol})]})]})},[v,r,c,n,u,I]),W=Q.useCallback(e=>{if(e.type===`revert-all`)return(0,$.jsx)(`div`,{className:Y(`flex justify-end py-2`,Ml),children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:()=>x(!0),disabled:r,className:`gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]`,children:[(0,$.jsx)(X,{name:`arrow-go-back`,className:`size-3.5`}),u(`gitView.changes.revertAll`)]})});let i=h[e.groupIndex];if(!i)return null;if(e.type===`header`)return H(i,{showToolbar:!1});if(e.type===`directory`)return U(i,e.directory,e.depth);let a=e.file;return(0,$.jsx)(wl,{file:a,actionLabel:i.getActionLabel(a.path),actionSymbol:i.actionSymbol,onAction:()=>i.onActionFile(a.path),stats:t?.[a.path],onViewDiff:()=>i.onViewDiff(a.path),onRevert:()=>i.onRevertFile(a.path),isReverting:n.has(a.path)||r,rowPaddingClassName:Ml,indentPx:e.depth*14,actionAtStart:!1,showRevert:i.showRevertActions!==!1})},[t,r,U,H,n,u,h]),re=Q.useCallback(e=>{let t=k[e],n=k[e-1];return!t||!n||t.type!==`file`&&t.type!==`directory`||n.type!==`file`&&n.type!==`directory`?!1:n.groupIndex===t.groupIndex},[k]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 w-full flex-col overflow-hidden`,children:[O?(0,$.jsx)(`div`,{className:Y(`shrink-0`,i),children:H(O,{pinned:!0,showToolbar:!0})}):null,(0,$.jsx)(Xe,{ref:d,className:`overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto`,children:j?(0,$.jsx)(`div`,{style:{height:M.getTotalSize(),position:`relative`},children:N.map(e=>{let t=k[e.index];return t?(0,$.jsx)(`div`,{"data-index":e.index,ref:M.measureElement,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${e.start}px)`},className:Y(re(e.index)&&`before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60`),children:W(t)},t.key):null})}):(0,$.jsx)(`div`,{role:`list`,"aria-label":u(`gitView.changes.changedFilesAria`),children:k.map((e,t)=>(0,$.jsx)(`div`,{className:Y(`relative`,re(t)&&`before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60`),children:W(e)},e.key))})}),(0,$.jsx)(Mt,{containerRef:d,disableHorizontal:!0})]}),(0,$.jsx)(Fe,{open:b,onOpenChange:e=>{!r&&!e&&x(!1)},children:(0,$.jsxs)(Me,{className:`max-w-md`,children:[(0,$.jsxs)(Ae,{children:[(0,$.jsx)(Ne,{children:u(`gitView.changes.revertAllDialogTitle`)}),(0,$.jsx)(Pe,{children:u(R===1?`gitView.changes.revertAllDescriptionSingle`:`gitView.changes.revertAllDescriptionPlural`,{count:R})})]}),(0,$.jsxs)(je,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>x(!1),disabled:r,children:u(`gitView.common.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,onClick:()=>void B(),disabled:r,children:u(r?`gitView.changes.reverting`:`gitView.changes.revertAll`)})]})]})}),(0,$.jsx)(Fe,{open:!!S,onOpenChange:e=>{!z&&!e&&C(null)},children:(0,$.jsxs)(Me,{className:`max-w-md`,children:[(0,$.jsxs)(Ae,{children:[(0,$.jsx)(Ne,{children:u(`gitView.changes.revertDirectoryDialogTitle`)}),(0,$.jsx)(Pe,{children:S?S.count===1?u(`gitView.changes.revertDirectoryDescriptionSingle`,{count:S.count,path:S.path}):u(`gitView.changes.revertDirectoryDescriptionPlural`,{count:S.count,path:S.path}):null})]}),(0,$.jsxs)(je,{children:[(0,$.jsx)(Z,{variant:`outline`,size:`sm`,onClick:()=>C(null),disabled:z,children:u(`gitView.common.cancel`)}),(0,$.jsx)(Z,{variant:`destructive`,size:`sm`,onClick:()=>void V(),disabled:z||!S,children:u(z?`gitView.changes.reverting`:`gitView.changes.revertDirectory`)})]})]})})]})},zl=38,Bl=200,Vl=e=>{let t=(0,Qn.c)(20),{value:n,onChange:r,placeholder:i,disabled:a,hasTouchInput:o,isMobile:c}=e,l=a!==void 0&&a,u=o!==void 0&&o,d=c!==void 0&&c,{t:f}=ee(),p=Q.useRef(null),m=s(Hl),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{let e=p.current;if(!e)return;let t=document.activeElement===e,n=()=>{e.style.height=`${zl}px`;let n=e.scrollHeight,r=Math.min(Math.max(n,zl),Bl);e.style.height=`${r}px`,e.style.overflowY=n>Bl?`auto`:`hidden`,n>Bl&&!t&&(e.scrollTop=e.scrollHeight)};n();let r=window.requestAnimationFrame(n);return()=>{window.cancelAnimationFrame(r)}},t[0]=h):h=t[0];let g;t[1]===n?g=t[2]:(g=[n],t[1]=n,t[2]=g),Q.useLayoutEffect(h,g);let _;t[3]===r?_=t[4]:(_=e=>r(e.target.value),t[3]=r,t[4]=_);let v;t[5]!==i||t[6]!==f?(v=i??f(`gitView.commit.messagePlaceholder`),t[5]=i,t[6]=f,t[7]=v):v=t[7];let y=u?`on`:`off`,b=u?`sentences`:`off`,x=d||m,S=l&&`opacity-50`,C;t[8]===S?C=t[9]:(C=Y(`w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground`,`resize-none outline-none transition-[border-color,box-shadow] duration-150`,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,S),t[8]=S,t[9]=C);let w;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(w={minHeight:zl,maxHeight:Bl},t[10]=w):w=t[10];let T;return t[11]!==l||t[12]!==x||t[13]!==C||t[14]!==_||t[15]!==v||t[16]!==y||t[17]!==b||t[18]!==n?(T=(0,$.jsx)(`textarea`,{ref:p,value:n,onChange:_,placeholder:v,rows:1,disabled:l,autoCorrect:y,autoCapitalize:b,spellCheck:x,className:C,style:w}),t[11]=l,t[12]=x,t[13]=C,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=n,t[19]=T):T=t[19],T};function Hl(e){return e.inputSpellcheckEnabled}var Ul=e=>{let t=(0,Qn.c)(30),{highlights:n,onInsert:r}=e,{t:i}=ee();if(n.length===0)return null;let a;t[0]!==n||t[1]!==r?(a=()=>{r(n)},t[0]=n,t[1]=r,t[2]=a):a=t[2];let o=a,s;t[3]===i?s=t[4]:(s=i(`gitView.commit.aiHighlights.title`),t[3]=i,t[4]=s);let c;t[5]===s?c=t[6]:(c=(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:s}),t[5]=s,t[6]=c);let l;t[7]===i?l=t[8]:(l=i(`gitView.commit.aiHighlights.insertAria`),t[7]=i,t[8]=l);let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(X,{name:`arrow-down`,className:`size-4`}),t[9]=u):u=t[9];let d;t[10]!==o||t[11]!==l?(d=(0,$.jsx)(st,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:o,"aria-label":l,children:u})}),t[10]=o,t[11]=l,t[12]=d):d=t[12];let f;t[13]===i?f=t[14]:(f=i(`gitView.commit.aiHighlights.insertTooltip`),t[13]=i,t[14]=f);let p;t[15]===f?p=t[16]:(p=(0,$.jsx)(ct,{sideOffset:8,children:f}),t[15]=f,t[16]=p);let m;t[17]!==d||t[18]!==p?(m=(0,$.jsxs)(lt,{children:[d,p]}),t[17]=d,t[18]=p,t[19]=m):m=t[19];let h;t[20]!==c||t[21]!==m?(h=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[c,m]}),t[20]=c,t[21]=m,t[22]=h):h=t[22];let g;t[23]===n?g=t[24]:(g=n.map(Wl),t[23]=n,t[24]=g);let _;t[25]===g?_=t[26]:(_=(0,$.jsx)(`ul`,{className:`space-y-1`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==h||t[28]!==_?(v=(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2`,children:[h,_]}),t[27]=h,t[28]=_,t[29]=v):v=t[29],v};function Wl(e,t){return(0,$.jsx)(`li`,{className:`typography-meta text-foreground`,children:e},`${e}-${t}`)}var Gl=e=>{let t=(0,Qn.c)(75),{stagedCount:n,commitMessage:r,onCommitMessageChange:i,generatedHighlights:a,onInsertHighlights:o,onGenerateMessage:s,isGeneratingMessage:c,onCommit:l,onCommitAndPush:u,commitAction:d,hasPendingIndexMutation:f,gitmojiEnabled:p,onOpenGitmojiPicker:m}=e,h=f!==void 0&&f,{t:g}=ee(),_=n>0,v;t[0]!==d||t[1]!==r||t[2]!==h||t[3]!==_?(v=r.trim()&&_&&d===null&&!h,t[0]=d,t[1]=r,t[2]=h,t[3]=_,t[4]=v):v=t[4];let y=v,{isMobile:b,hasTouchInput:x}=jt(),S;t[5]===g?S=t[6]:(S=g(`gitView.commit.title`),t[5]=g,t[6]=S);let C;t[7]===S?C=t[8]:(C=(0,$.jsx)(`h3`,{className:`typography-ui-header font-semibold text-foreground`,children:S}),t[7]=S,t[8]=C);let w;t[9]!==_||t[10]!==g?(w=_?null:(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-meta text-muted-foreground`,children:g(`gitView.commit.stageFilesHint`)}),t[9]=_,t[10]=g,t[11]=w):w=t[11];let T;t[12]!==C||t[13]!==w?(T=(0,$.jsxs)(`div`,{className:`flex w-full items-baseline gap-2 px-0 pt-2 pb-1`,children:[C,w]}),t[12]=C,t[13]=w,t[14]=T):T=t[14];let E;t[15]!==a||t[16]!==o?(E=(0,$.jsx)(Ul,{highlights:a,onInsert:o}),t[15]=a,t[16]=o,t[17]=E):E=t[17];let D;t[18]===g?D=t[19]:(D=g(`gitView.commit.messagePlaceholder`),t[18]=g,t[19]=D);let O=d!==null,k;t[20]!==r||t[21]!==x||t[22]!==b||t[23]!==i||t[24]!==D||t[25]!==O?(k=(0,$.jsx)(Vl,{value:r,onChange:i,placeholder:D,disabled:O,hasTouchInput:x,isMobile:b}),t[20]=r,t[21]=x,t[22]=b,t[23]=i,t[24]=D,t[25]=O,t[26]=k):k=t[26];let A=c||d!==null||h||n===0,j;t[27]===g?j=t[28]:(j=g(`gitView.commit.generateAria`),t[27]=g,t[28]=j);let M;t[29]===c?M=t[30]:(M=c?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-4 text-primary`}),t[29]=c,t[30]=M);let N;t[31]===g?N=t[32]:(N=g(`gitView.commit.generate`),t[31]=g,t[32]=N);let P;t[33]===N?P=t[34]:(P=(0,$.jsx)(`span`,{className:`commit-actions__label`,children:N}),t[33]=N,t[34]=P);let F;t[35]!==s||t[36]!==A||t[37]!==j||t[38]!==M||t[39]!==P?(F=(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:s,disabled:A,type:`button`,"aria-label":j,className:`commit-actions__btn`,children:[M,P]}),t[35]=s,t[36]=A,t[37]=j,t[38]=M,t[39]=P,t[40]=F):F=t[40];let I;t[41]!==p||t[42]!==m||t[43]!==g?(I=p?(0,$.jsxs)(lt,{children:[(0,$.jsx)(st,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:m,"aria-label":g(`gitView.commit.addGitmoji`),className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,$.jsx)(X,{name:`emotion-happy`,className:`size-4`})})}),(0,$.jsx)(ct,{side:`top`,children:(0,$.jsx)(`p`,{children:g(`gitView.commit.addGitmoji`)})})]}):null,t[41]=p,t[42]=m,t[43]=g,t[44]=I):I=t[44];let te;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(`div`,{className:`flex-1`}),t[45]=te):te=t[45];let ne=!y||c,L;t[46]===g?L=t[47]:(L=g(`gitView.commit.commitAria`),t[46]=g,t[47]=L);let R;t[48]!==d||t[49]!==g?(R=d===`commit`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{className:`commit-actions__label`,children:g(`gitView.commit.committing`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`git-commit`,className:`size-4`}),(0,$.jsx)(`span`,{className:`commit-actions__label`,children:g(`gitView.commit.commit`)})]}),t[48]=d,t[49]=g,t[50]=R):R=t[50];let z;t[51]!==l||t[52]!==ne||t[53]!==L||t[54]!==R?(z=(0,$.jsx)(Z,{size:`sm`,variant:`outline`,onClick:l,disabled:ne,className:`commit-actions__btn whitespace-nowrap`,"aria-label":L,children:R}),t[51]=l,t[52]=ne,t[53]=L,t[54]=R,t[55]=z):z=t[55];let B;t[56]!==y||t[57]!==d||t[58]!==c||t[59]!==b||t[60]!==u||t[61]!==g?(B=b?(0,$.jsxs)(lt,{children:[(0,$.jsx)(st,{asChild:!0,children:(0,$.jsx)(Z,{variant:`default`,size:`sm`,onClick:()=>u(),disabled:!y||c,className:`h-7 w-7 p-0`,"aria-label":g(`gitView.commit.pushAria`),children:d===`commitAndPush`?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`arrow-up`,className:`size-3.5`})})}),(0,$.jsx)(ct,{side:`top`,children:(0,$.jsx)(`p`,{children:g(`gitView.commit.push`)})})]}):(0,$.jsx)(Z,{size:`sm`,variant:`default`,onClick:()=>u(),disabled:!y||c,className:`commit-actions__btn`,"aria-label":g(`gitView.commit.pushAria`),children:d===`commitAndPush`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{className:`commit-actions__label commit-actions__label--push`,children:g(`gitView.commit.pushing`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`arrow-up`,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`commit-actions__label commit-actions__label--push`,children:g(`gitView.commit.push`)})]})}),t[56]=y,t[57]=d,t[58]=c,t[59]=b,t[60]=u,t[61]=g,t[62]=B):B=t[62];let V;t[63]!==F||t[64]!==I||t[65]!==z||t[66]!==B?(V=(0,$.jsxs)(`div`,{className:`@container/commit-actions flex items-center gap-2 min-w-0`,children:[F,I,te,z,B]}),t[63]=F,t[64]=I,t[65]=z,t[66]=B,t[67]=V):V=t[67];let H;t[68]!==k||t[69]!==V||t[70]!==E?(H=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-0 pt-1 pb-3`,children:[E,k,V]}),t[68]=k,t[69]=V,t[70]=E,t[71]=H):H=t[71];let U;return t[72]!==H||t[73]!==T?(U=(0,$.jsxs)(`section`,{className:`border-0 bg-transparent rounded-none`,children:[T,H]}),t[72]=H,t[73]=T,t[74]=U):U=t[74],U},Kl=()=>{let e=K.getState(),t=e.currentSessionId,n=s.getState();as({sessionId:t,isNewSession:!!e.newSessionDraft?.open&&!t,tab:n.activeMainTab||`chat`,isSettingsOpen:n.isSettingsDialogOpen,settingsPath:n.settingsPage,diffFile:null,diffScope:null},{replace:!0,force:!0})},ql=()=>{A(),w.reconnectToRuntimeBaseUrl(),z.setState({catalogTransportIdentity:n()}),I()},Jl=e=>{K.getState().prepareForRuntimeSwitch(e.previousRuntimeKey),s.getState().prepareForRuntimeSwitch(e.previousRuntimeKey),e.previousRuntimeKey&&V.getState().stopRunningRunsForRuntime(e.previousRuntimeKey),A(),w.reconnectToRuntimeBaseUrl(),z.setState({catalogTransportIdentity:n(),activeDirectoryKey:`__global__`,directoryScoped:{},providerConfigLoadingByDirectory:{},agentConfigLoadingByDirectory:{},providers:[],agents:[],defaultProviders:{},currentProviderId:``,currentModelId:``,currentVariant:void 0,currentAgentName:void 0,selectedProviderId:``,agentModelSelections:{},lastSelectedAgentName:void 0,lastUserSelection:void 0,globalLastUserSelection:void 0,opencodeDefaultAgent:void 0,opencodeDefaultModel:void 0,selectionSource:`auto`,isConnected:!1,isInitialized:!1,connectionPhase:`connecting`,lastDisconnectReason:null}),ue.getState().resetForRuntimeSwitch(),be.getState().resetForRuntimeSwitch(),G.getState().reset(),Bn(),K.getState().restoreForRuntimeSwitch(e.runtimeKey),s.getState().restoreForRuntimeSwitch(e.runtimeKey),Kl(),I()};export{xi as A,cr as B,Ta as C,Oi as D,va as E,Ar as F,Er as I,Tr as L,Zr as M,Ur as N,Di as O,Wr as P,hr as R,Oa as S,ba as T,Ba as _,pl as a,za as b,Os as c,ps as d,Ao as f,qa as g,Ka as h,Rl as i,ri as j,oi as k,Ds as l,Wa as m,Jl as n,yl as o,Ga as p,Gl as r,Xs as s,ql as t,ys as u,Va as v,wa as w,Ia as x,Ha as y,mr as z};
|