@muyichengshayu/promptx 0.2.4 → 0.2.6

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.
@@ -1,3 +1,3 @@
1
- import{W as dt,f as ht,m as Mt,s as jt,n as It,o as ut,d as Et,p as tt,c as Pt,q as ct,t as ft,v as At,w as qe,x as Dt,y as et}from"./WorkbenchView-EAjf4pvb.js";import{u as Ve,f as Rt,e as Tt}from"./index-DpCCivzJ.js";import{w as oe,n as me,ak as at,aD as c,aI as re,aJ as De,aF as n,aQ as d,u as i,aG as I,aW as Lt,aU as Bt,aX as Ft,aE as g,aR as he,aS as Se,aL as O,aN as M,aV as Nt,aK as nt,b as $,c as C,o as Ot,aZ as yt,r as Ut}from"./vendor-misc-u-M8sNMf.js";import{c as Ht,L as Ge,F as Xe,e as zt,b as st,X as pt,C as Kt,M as qt,j as Vt,x as Wt,P as Qt,i as gt,E as Gt,N as Xt,q as Jt,r as Yt,O as Zt}from"./vendor-ui-BwEQCho1.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";import"./vendor-router-Dn8q3tJM.js";const en={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},tn={class:"theme-muted-text mt-1 text-xs leading-5"},nn={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},sn={class:"flex items-start gap-2 text-xs leading-5"},an={class:"theme-muted-text shrink-0"},ln={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},on={class:"theme-muted-text mt-4 block text-xs"},rn={class:"theme-input-shell mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2"},dn=["placeholder"],un={class:"theme-content-panel mt-3 min-h-0 flex-1 overflow-y-auto p-2"},cn={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},fn={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},pn={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},gn={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},vn={key:4,class:"theme-empty-state px-3 py-8 text-sm"},mn={key:5,class:"theme-empty-state px-3 py-8 text-sm"},hn={key:6,class:"theme-empty-state px-3 py-8 text-sm"},yn={key:7,class:"space-y-1"},xn=["onClick"],bn={class:"min-w-0 flex-1"},wn=["innerHTML"],Sn=["innerHTML"],kn={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},Cn={key:8,class:"space-y-1"},_n={class:"flex items-start gap-1.5"},$n=["onClick"],Mn=["onClick"],jn={class:"min-w-0 flex-1"},In={key:0,class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all"},En={class:"theme-divider flex flex-col-reverse gap-2 border-t border-dashed px-4 py-4 sm:flex-row sm:items-center sm:justify-end sm:px-5"},Pn={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},An=["disabled"],Dn=["disabled"],Rn={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""},suggestions:{type:Array,default:()=>[]}},emits:["close","select"],setup(r,{emit:q}){const j=r,A=q,{t:y}=Ve(),B=$(""),D=$(null),p=$(!1),S=$(""),E=$(!1),o=$(""),b=$([]),P=$(!1),u=$(""),_=$(""),de=$(null);let V=null,U=0,F=null;const H=new Map,z=C(()=>$e(D.value?[D.value]:[])),G=C(()=>String(u.value||"").trim()),X=C(()=>G.value.length>=dt),R=C(()=>!!G.value),Q=C(()=>R.value?b.value:z.value),Z=C(()=>Q.value.map(e=>{const l=m((e==null?void 0:e.path)||""),s=e!=null&&e.expanded?1:0,f=e!=null&&e.loading?1:0;return`${l}:${s}:${f}`}).join("|")),ge=C(()=>R.value&&!X.value&&!E.value&&!o.value),ae=C(()=>R.value&&X.value&&!E.value&&!o.value&&!b.value.length),J=C(()=>!R.value&&!p.value&&!S.value&&!z.value.length);function h(e=""){const l=String(e||"").trim();return/^[a-z]:[\\/]/i.test(l)||l.includes("\\")}function m(e=""){const l=String(e||"").trim();if(!l)return"";const s=h(l);let f=l.replace(/\\/g,"/");return f.length>1&&!/^[a-z]:\/?$/i.test(f)&&f!=="/"&&(f=f.replace(/\/+$/,"")),s?f.toLowerCase():f}function v(e="",l=""){const s=m(e),f=m(l);return!s||!f?!1:s===f||s.startsWith(`${f}/`)}function K(e="",l=""){const s=String(e||"").trim(),f=String(l||"").trim();return s?f?h(s)?/^[a-z]:\\?$/i.test(s)?`${s.replace(/[\\/]+$/,"")}\\${f}`:`${s.replace(/[\\/]+$/,"")}\\${f}`:s==="/"?`/${f}`:`${s.replace(/\/+$/,"")}/${f}`:s:f}function ee(e="",l=""){const s=m(e),f=m(l);if(!s||!f||!v(f,s))return[];const W=f===s?"":f.slice(s.length).replace(/^\//,"");return W?W.split("/").filter(Boolean):[]}function w(e=""){const l=String(e||"").trim();if(!l||m(l)===m(B.value))return"";const s=h(l),f=l.replace(/\\/g,"/");if(s){const ie=f.replace(/\/+$/,""),le=ie.lastIndexOf("/");if(le<=2)return"";const ze=ie.slice(0,le).replace(/\//g,"\\");return v(ze,B.value)?ze:""}const W=f.replace(/\/+$/,""),se=W.lastIndexOf("/");if(se<=0)return"";const we=W.slice(0,se)||"/";return v(we,B.value)?we:""}function ke(e){return(e==null?void 0:e.name)||(e==null?void 0:e.path)||y("directoryPicker.unnamedDirectory")}function Je(e=""){const l=String(e||"").trim();return l?l.split(/[\\/]/).filter(Boolean).at(-1)||l:"Home"}function ue(e=""){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ce(e="",l=""){const s=String(e||""),f=String(l||"").trim().toLowerCase();if(!s||!f)return null;const W=s.toLowerCase(),se=W.indexOf(f);if(se>=0)return{start:se,end:se+f.length};const we=f.split(/[\\/\s_.-]+/).filter(Boolean).sort((ie,le)=>le.length-ie.length);for(const ie of we){if(ie.length<2)continue;const le=W.indexOf(ie);if(le>=0)return{start:le,end:le+ie.length}}return null}function _e(e="",l=""){const s=String(e||""),f=Ce(s,l);return f?`${ue(s.slice(0,f.start))}<mark class="theme-search-highlight">${ue(s.slice(f.start,f.end))}</mark>${ue(s.slice(f.end))}`:ue(s)}function ce(e){return _e(ke(e),u.value)}function T(e){return _e((e==null?void 0:e.path)||"",u.value)}function Re(e,l=0){return{...e,depth:l,expanded:!1,loaded:!1,loading:!1,children:[]}}function $e(e=[],l=[]){return e.forEach(s=>{l.push(s),s.expanded&&s.children.length&&$e(s.children,l)}),l}function fe(){D.value&&(D.value={...D.value})}function ye(){V&&(window.clearTimeout(V),V=null),F&&(F.abort(),F=null)}function xe(e,l=D.value?[D.value]:[]){const s=m(e);if(!s)return null;for(const f of l){if(m(f.path)===s)return f;if(f.children.length){const W=xe(e,f.children);if(W)return W}}return null}function Y(e){_.value=String((e==null?void 0:e.path)||"").trim()}function pe(e=""){return m(e)}function Te(e,l){const s=pe(e);if(s){if(l){H.set(s,l);return}H.delete(s)}}function be(){var l;const e=H.get(pe(_.value));(l=e==null?void 0:e.scrollIntoView)==null||l.call(e,{block:"nearest"})}function We(){me(()=>{var e,l;(l=(e=de.value)==null?void 0:e.focus)==null||l.call(e)})}function Ye(){const e=Q.value;if(!e.length){_.value="";return}const l=pe(_.value);l&&e.some(s=>pe((s==null?void 0:s.path)||"")===l)||Y(e[0])}function Me(){const e=Q.value;if(!e.length)return-1;const l=pe(_.value),s=e.findIndex(f=>pe((f==null?void 0:f.path)||"")===l);return s>=0?s:0}function te(){const e=Q.value,l=Me();return l<0||!e.length?null:e[l]||null}function ve(e=1){const l=Q.value;if(!l.length)return!1;const s=Me(),f=s<0?0:(s+e+l.length)%l.length;return Y(l[f]),me(be),!0}async function Qe(){if(R.value)return!1;const e=te();if(!e||!e.hasChildren)return!1;if(!e.expanded)return await ne(e),!0;const l=Q.value,s=Me(),f=l[s+1];return f&&w(f.path)===e.path?(Y(f),me(be),!0):!1}function Le(){if(R.value)return!1;const e=te();if(!e)return!1;if(e.expanded&&e.hasChildren)return e.expanded=!1,fe(),Y(e),!0;const l=w(e.path);if(!l)return!1;const s=xe(l);return s?(Y(s),me(be),!0):!1}function je(e){var l,s,f;if((l=e==null?void 0:e.preventDefault)==null||l.call(e),G.value){(s=e==null?void 0:e.stopPropagation)==null||s.call(e),u.value="";return}(f=e==null?void 0:e.stopPropagation)==null||f.call(e),A("close")}function Be(e){const l=String((e==null?void 0:e.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(l)&&!(R.value&&(l==="ArrowLeft"||l==="ArrowRight"))){if(l==="ArrowDown"){e.preventDefault(),ve(1);return}if(l==="ArrowUp"){e.preventDefault(),ve(-1);return}if(l==="Escape"){je(e);return}if(R.value){if(l==="Enter"){e.preventDefault();const s=te();s&&Ue(s)}return}if(l==="ArrowRight"){e.preventDefault(),Qe();return}if(l==="ArrowLeft"){e.preventDefault(),Le();return}l==="Enter"&&(e.preventDefault(),He())}}async function Ie(e,l={}){if(!(!e||e.loading)&&!(e.loaded&&!l.force)){e.loading=!0,S.value="",fe();try{const s=await ut({path:e.path,limit:240});e.children=(s.items||[]).map(f=>Re(f,e.depth+1)),e.loaded=!0}catch(s){S.value=s.message||y("directoryPicker.loadFailed")}finally{e.loading=!1,fe()}}}async function Ee(){p.value=!0,S.value="";try{const e=await ut({limit:240});B.value=String(e.path||""),D.value=Re({name:Je(e.path||""),path:String(e.path||""),type:"directory",hasChildren:!0,isHomeRoot:!0},0),D.value.children=(e.items||[]).map(l=>Re(l,1)),D.value.loaded=!0,D.value.expanded=!0,Y(D.value)}catch(e){S.value=e.message||y("directoryPicker.treeLoadFailed"),D.value=null,B.value=""}finally{p.value=!1}}async function Fe(e=""){const l=String(e||"").trim();if(!l||!B.value||!v(l,B.value))return;let s=D.value;if(!s)return;Y(s);const f=ee(B.value,l);for(const W of f){await Ie(s),s.expanded=!0,fe();const se=xe(K(s.path,W),s.children);if(!se)break;s=se,Y(s)}}async function Pe(){u.value="",b.value=[],o.value="",P.value=!1,_.value="",await Ee();const e=String(j.initialPath||"").trim();e&&v(e,B.value)&&await Fe(e)}async function ne(e){if(e!=null&&e.path&&(Y(e),!!e.hasChildren)){if(!e.loaded){e.expanded=!0,fe(),await Ie(e);return}e.expanded=!e.expanded,fe()}}function Ae(e){e!=null&&e.path&&Y(e)}async function Ne(){const e=String(u.value||"").trim();U+=1;const l=U;if(ye(),!j.open||!e||!B.value||!X.value){E.value=!1,o.value="",b.value=[],P.value=!1;return}E.value=!0,o.value="",F=new AbortController;try{const s=await jt(e,{path:B.value,limit:80,signal:F.signal});if(l!==U)return;b.value=Array.isArray(s.items)?s.items:[],P.value=!!s.truncated}catch(s){if(It(s)||l!==U)return;o.value=s.message||y("directoryPicker.searchFailed"),b.value=[],P.value=!1}finally{l===U&&(F=null),l===U&&(E.value=!1)}}function Oe(){if(ye(),!String(u.value||"").trim()||!X.value){E.value=!1,o.value="",b.value=[],P.value=!1;return}E.value=!0,o.value="",V=window.setTimeout(()=>{V=null,Ne()},Mt)}async function Ue(e){e!=null&&e.path&&(await Fe(e.path),u.value="")}function He(){_.value&&(A("select",_.value),A("close"))}return oe(u,()=>{Oe()}),oe(Z,()=>{Ye(),me(be)},{immediate:!0}),oe(()=>j.open,e=>{if(e){Pe().catch(()=>{}),We();return}ye()}),at(()=>{ye()}),(e,l)=>(c(),re(ht,{open:r.open,"stack-level":1,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-4xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:px-5","close-disabled":p.value||E.value,"close-on-backdrop":!(p.value||E.value),"close-on-escape":!(p.value||E.value),onClose:l[2]||(l[2]=s=>A("close"))},{title:De(()=>[n("div",null,[n("div",en,[I(i(Xe),{class:"h-4 w-4"}),n("span",null,d(i(y)("directoryPicker.title")),1)]),n("p",tn,d(i(y)("directoryPicker.intro")),1)])]),default:De(()=>[n("div",{class:"flex min-h-0 flex-1 flex-col overflow-hidden",onKeydown:Be},[n("div",nn,[n("div",sn,[n("span",an,d(i(y)("directoryPicker.currentSelection")),1),n("span",ln,d(_.value||i(y)("directoryPicker.selectionPlaceholder")),1)])]),n("label",on,[n("span",null,d(i(y)("directoryPicker.searchLabel")),1),n("div",rn,[I(i(Ht),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),Lt(n("input",{ref_key:"searchInputRef",ref:de,"onUpdate:modelValue":l[0]||(l[0]=s=>u.value=s),type:"text",placeholder:i(y)("directoryPicker.searchPlaceholder"),class:"min-w-0 flex-1 border-0 bg-transparent px-0 text-sm text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]",onKeydown:Bt(je,["esc"])},null,40,dn),[[Ft,u.value]])])]),n("div",un,[R.value&&o.value?(c(),g("div",cn,d(o.value),1)):!R.value&&S.value?(c(),g("div",fn,d(S.value),1)):R.value&&E.value?(c(),g("div",pn,[I(i(Ge),{class:"h-4 w-4 animate-spin"}),n("span",null,d(i(y)("directoryPicker.searching")),1)])):!R.value&&p.value?(c(),g("div",gn,[I(i(Ge),{class:"h-4 w-4 animate-spin"}),n("span",null,d(i(y)("directoryPicker.treeLoading")),1)])):ge.value?(c(),g("div",vn,d(i(y)("directoryPicker.searchMinKeywordHint",{count:i(dt)})),1)):ae.value?(c(),g("div",mn,d(i(y)("directoryPicker.noSearchResults")),1)):J.value?(c(),g("div",hn,d(i(y)("directoryPicker.emptyTree")),1)):R.value?(c(),g("div",yn,[(c(!0),g(he,null,Se(b.value,s=>(c(),g("button",{key:s.path,ref_for:!0,ref:f=>Te(s.path,f),type:"button",class:O(["theme-list-row focus:outline-none",m(_.value)===m(s.path)?"theme-list-item-active":"theme-list-item-hover"]),onClick:f=>Ue(s)},[I(i(Xe),{class:"theme-list-item-icon"}),n("div",bn,[n("div",null,[n("span",{class:"theme-list-item-title block break-all",innerHTML:ce(s)},null,8,wn)]),n("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:T(s)},null,8,Sn)])],10,xn))),128)),P.value?(c(),g("p",kn,d(i(y)("directoryPicker.truncatedHint")),1)):M("",!0)])):(c(),g("div",Cn,[(c(!0),g(he,null,Se(z.value,s=>(c(),g("div",{key:s.path,ref_for:!0,ref:f=>Te(s.path,f),class:O(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",m(_.value)===m(s.path)?"theme-list-item-active":s.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Nt({paddingLeft:`${s.depth*16+6}px`})},[n("div",_n,[n("button",{type:"button",class:O(["theme-icon-button h-5 w-5 shrink-0",s.hasChildren?"":"invisible pointer-events-none"]),onClick:nt(f=>ne(s),["stop"])},[s.loading?(c(),re(i(Ge),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(c(),re(i(zt),{key:1,class:O(["h-3.5 w-3.5 transition",s.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,$n),n("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left",onClick:f=>Ae(s)},[I(i(Xe),{class:O(["h-4 w-4 shrink-0",m(_.value)===m(s.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),n("div",jn,[n("div",{class:O(["theme-list-item-title truncate",s.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},d(ke(s)),3),s.isHomeRoot?(c(),g("div",In,d(s.path),1)):M("",!0)])],8,Mn)])],6))),128))]))])],32),n("div",En,[n("div",Pn,[n("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:p.value||E.value,onClick:l[1]||(l[1]=s=>A("close"))},d(i(y)("directoryPicker.cancel")),9,An),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex w-full items-center justify-center gap-2 px-3 py-2 text-xs sm:w-auto",disabled:p.value||E.value||!_.value,onClick:He},[I(i(st),{class:"h-4 w-4"}),n("span",null,d(i(y)("directoryPicker.useCurrentDirectory")),1)],8,Dn)])])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},Tn={class:"grid gap-4"},Ln={class:"theme-muted-text block text-xs"},Bn=["value","disabled"],Fn={class:"theme-muted-text block text-xs"},Nn={class:"mt-1 flex gap-2"},On={class:"relative min-w-0 flex-1"},Un=["value","disabled"],Hn=["disabled"],zn=["disabled"],Kn={id:"codex-manager-workspace-suggestions"},qn=["value"],Vn={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Wn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},Qn={class:"theme-muted-text block text-xs"},Gn={class:"mt-1"},Xn={class:"flex items-center gap-2 text-sm"},Jn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Yn=["disabled","onClick"],Zn={class:"flex items-center justify-between gap-3"},es={class:"min-w-0 flex-1 truncate"},ts={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},ns={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},ss={class:"theme-muted-text block text-xs"},as={class:"mt-2 grid gap-2"},is=["disabled","onClick"],ls={class:"min-w-0"},os={class:"text-sm text-[var(--theme-textPrimary)]"},rs={class:"theme-muted-text mt-0.5 text-[11px] leading-5"},ds={class:"theme-muted-text mt-2 text-[11px] leading-5"},us={class:"theme-muted-text block text-xs"},cs={class:"mt-1 flex gap-2"},fs=["value","disabled"],ps=["disabled"],gs={key:1,class:"theme-popover theme-divider absolute left-0 right-0 top-[calc(100%+0.375rem)] z-20 overflow-hidden rounded-sm border border-solid shadow-sm"},vs={class:"flex items-center justify-between gap-2 border-b border-solid px-3 py-2 text-[11px] leading-5"},ms={class:"font-medium text-[var(--theme-textPrimary)]"},hs={key:0,class:"theme-muted-text"},ys={key:0,class:"max-h-72 overflow-y-auto p-2"},xs=["disabled","onClick"],bs={class:"flex min-w-0 items-center justify-between gap-3"},ws={class:"min-w-0 flex-1 truncate text-xs font-medium text-[var(--theme-textPrimary)]"},Ss={class:"shrink-0 text-[11px] leading-4 text-[var(--theme-textMuted)]"},ks={key:1,class:"theme-empty-state px-3 py-4 text-xs"},Cs=["disabled"],_s={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},$s={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},vt={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},agentEngines:{type:Array,default:()=>[]},canEditEngine:{type:Boolean,default:!0},canEditCwd:{type:Boolean,default:!0},canEditSessionId:{type:Boolean,default:!0},cwd:{type:String,default:""},cwdReadonlyMessage:{type:String,default:""},duplicateCwdMessage:{type:String,default:""},engine:{type:String,default:"codex"},engineOptions:{type:Array,default:()=>[]},engineReadonlyMessage:{type:String,default:""},mobile:{type:Boolean,default:!1},sessionId:{type:String,default:""},sessionIdCopied:{type:Boolean,default:!1},sessionIdReadonlyMessage:{type:String,default:""},sessionCandidates:{type:Array,default:()=>[]},sessionCandidatesLoading:{type:Boolean,default:!1},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["copy-session-id","open-directory-picker","select-session-candidate","update:agentEngines","update:cwd","update:engine","update:sessionId","update:title"],setup(r,{emit:q}){const j=r,A=q,{t:y}=Ve(),B=$(null),D=$(null),p=$(!1),S=$(-1),E=C(()=>{const h=String(j.engine||"").trim();return j.engineOptions.find(m=>String((m==null?void 0:m.value)||"").trim()===h)||null}),o=C(()=>{const h=Array.isArray(j.agentEngines)?j.agentEngines:[];return[...new Set(h.map(m=>String(m||"").trim()).filter(Boolean))]}),b=C(()=>j.engineOptions.filter(h=>String((h==null?void 0:h.value)||"").trim()!==String(j.engine||"").trim())),P=C(()=>!!String(j.cwd||"").trim()),u=C(()=>String(j.sessionId||"").trim()),_=C(()=>u.value.toLowerCase()),de=C(()=>j.sessionCandidates.filter(h=>h==null?void 0:h.matchedCwd)),V=C(()=>{const h=_.value,m=de.value;return h?m.filter(v=>[v==null?void 0:v.label,v==null?void 0:v.id,v==null?void 0:v.cwd].map(ee=>String(ee||"").toLowerCase()).some(ee=>ee.includes(h))).slice(0,10):m.slice(0,10)});function U(){j.busy||!j.canEditSessionId||!P.value||(p.value=!0)}function F(){p.value=!1,S.value=-1}function H(){const h=V.value;if(!h.length){S.value=-1;return}const m=h.findIndex(v=>v.id===u.value);S.value=m>=0?m:0}function z(){me(()=>{var h,m;(m=(h=D.value)==null?void 0:h.focus)==null||m.call(h)})}function G(){if(p.value){F();return}U(),z()}function X(){A("update:cwd","")}function R(h){if(!j.canEditEngine||j.busy)return;const m=String(h||"").trim(),v=o.value.includes(m)?o.value.filter(K=>K!==m):[...o.value,m];A("update:agentEngines",v)}function Q(){A("update:sessionId",""),F(),z()}function Z(h){var m;A("update:sessionId",((m=h==null?void 0:h.target)==null?void 0:m.value)||""),P.value&&U()}function ge(h){A("select-session-candidate",h),F(),z()}function ae(h){if(j.busy||!j.canEditSessionId||!P.value)return;const m=V.value;if(h.key==="ArrowDown"){if(h.preventDefault(),!p.value){U(),H();return}if(!m.length)return;S.value=S.value<0?0:Math.min(m.length-1,S.value+1);return}if(h.key==="ArrowUp"){if(h.preventDefault(),!p.value){U(),H();return}if(!m.length)return;S.value=S.value<0?m.length-1:Math.max(0,S.value-1);return}if(h.key==="Enter"&&p.value&&m.length&&S.value>=0){h.preventDefault(),ge(m[S.value]);return}h.key==="Escape"&&p.value&&(h.preventDefault(),F())}function J(h){!p.value||!B.value||B.value.contains(h.target)||F()}return oe(V,()=>{H()}),oe(()=>j.canEditSessionId,h=>{(!h||!P.value)&&F()}),oe(P,h=>{h||F()}),Ot(()=>{document.addEventListener("pointerdown",J)}),at(()=>{document.removeEventListener("pointerdown",J)}),(h,m)=>(c(),g("div",Tn,[n("label",Ln,[n("span",null,d(i(y)("projectManager.projectTitleOptional")),1),n("input",{value:r.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:r.busy,onInput:m[0]||(m[0]=v=>A("update:title",v.target.value))},null,40,Bn)]),n("label",Fn,[n("span",null,d(i(y)("projectManager.workingDirectoryField")),1),n("div",Nn,[n("div",On,[n("input",{value:r.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:O(["tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",r.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:r.busy||!r.canEditCwd,onInput:m[1]||(m[1]=v=>A("update:cwd",v.target.value))},null,42,Un),r.cwd&&r.canEditCwd?(c(),g("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:r.busy,onClick:X},[I(i(pt),{class:"h-3.5 w-3.5"})],8,Hn)):M("",!0)]),n("button",{type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:r.busy||!r.canEditCwd,onClick:m[2]||(m[2]=v=>A("open-directory-picker"))},[I(i(Xe),{class:"h-4 w-4"}),n("span",null,d(r.mobile?i(y)("projectManager.choose"):i(y)("projectManager.chooseDirectory")),1)],8,zn)]),n("datalist",Kn,[(c(!0),g(he,null,Se(r.workspaceSuggestions,v=>(c(),g("option",{key:v,value:v},null,8,qn))),128))]),r.duplicateCwdMessage?(c(),g("p",Vn,d(r.duplicateCwdMessage),1)):r.cwdReadonlyMessage?(c(),g("p",Wn,d(r.cwdReadonlyMessage),1)):M("",!0)]),n("label",Qn,[n("span",null,d(i(y)("projectManager.engineField")),1),n("div",Gn,[I(Et,{"model-value":r.engine,options:r.engineOptions,disabled:r.busy||!r.canEditEngine,placeholder:i(y)("projectManager.selectEngine"),"empty-text":i(y)("projectManager.noEngines"),"get-option-value":v=>(v==null?void 0:v.value)||"","onUpdate:modelValue":m[3]||(m[3]=v=>A("update:engine",v))},{trigger:De(({disabled:v})=>{var K;return[n("div",Xn,[n("span",{class:O(["min-w-0 flex-1 truncate",v?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},d(((K=E.value)==null?void 0:K.label)||i(y)("projectManager.selectEngine")),3),E.value&&E.value.enabled===!1?(c(),g("span",Jn,d(i(y)("projectManager.comingSoon")),1)):M("",!0)])]}),option:De(({option:v,selected:K,select:ee})=>[n("button",{type:"button",class:O(["w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm transition",K?"theme-filter-active":"theme-filter-idle"]),disabled:(v==null?void 0:v.enabled)===!1,onClick:ee},[n("div",Zn,[n("span",es,d(v.label),1),(v==null?void 0:v.enabled)===!1?(c(),g("span",ts,d(i(y)("projectManager.comingSoon")),1)):M("",!0)])],10,Yn)]),_:1},8,["model-value","options","disabled","placeholder","empty-text","get-option-value"])]),r.engineReadonlyMessage?(c(),g("p",ns,d(r.engineReadonlyMessage),1)):M("",!0)]),n("div",ss,[n("span",null,d(i(y)("projectManager.collaborationAgents")),1),n("div",as,[(c(!0),g(he,null,Se(b.value,v=>(c(),g("button",{key:v.value,type:"button",class:O(["theme-list-row flex items-center justify-between gap-3 rounded-sm border border-solid px-3 py-2 text-left transition",o.value.includes(v.value)?"theme-list-item-active":"theme-list-item-hover"]),disabled:r.busy||!r.canEditEngine,onClick:K=>R(v.value)},[n("div",ls,[n("div",os,d(v.label),1),n("div",rs,d(o.value.includes(v.value)?i(y)("projectManager.agentEnabled"):i(y)("projectManager.agentDisabled")),1)]),o.value.includes(v.value)?(c(),re(i(st),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textPrimary)]"})):M("",!0)],10,is))),128))]),n("p",ds,d(i(y)("projectManager.collaborationAgentsHint")),1)]),n("label",us,[n("span",null,d(i(y)("projectManager.sessionId")),1),n("div",cs,[n("div",{ref_key:"sessionComboboxRef",ref:B,class:"relative min-w-0 flex-1"},[n("input",{ref_key:"sessionInputRef",ref:D,value:r.sessionId,type:"text",placeholder:"",class:"tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",disabled:r.busy||!r.canEditSessionId,onFocus:U,onInput:Z,onKeydown:ae},null,40,fs),r.canEditSessionId?(c(),g("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:r.busy||!P.value,onClick:G},[r.sessionCandidatesLoading?(c(),re(i(Ge),{key:0,class:"h-3.5 w-3.5 animate-spin"})):u.value?(c(),re(i(pt),{key:1,class:"h-3.5 w-3.5",onClick:nt(Q,["stop"])})):(c(),re(i(Kt),{key:2,class:O(["h-3.5 w-3.5 transition",p.value?"rotate-180":""])},null,8,["class"]))],8,ps)):M("",!0),r.canEditSessionId&&p.value?(c(),g("div",gs,[n("div",vs,[n("span",ms,d(i(y)("projectManager.sessionCandidates")),1),r.sessionCandidatesLoading?(c(),g("span",hs,d(i(y)("projectManager.sessionCandidatesLoading")),1)):M("",!0)]),V.value.length?(c(),g("div",ys,[(c(!0),g(he,null,Se(V.value,(v,K)=>(c(),g("button",{key:`${v.engine}:${v.id}`,type:"button",class:O(["theme-list-row mb-1 w-full px-2 py-1.5 text-left last:mb-0",K===S.value?"theme-list-item-active":"theme-list-item-hover"]),disabled:r.busy,onMousedown:m[4]||(m[4]=nt(()=>{},["prevent"])),onClick:ee=>ge(v)},[n("div",bs,[n("span",ws,d(v.label||v.id),1),n("span",Ss,d(v.updatedAtLabel||i(y)("projectManager.unknown")),1)])],42,xs))),128))])):(c(),g("div",ks,d(P.value?i(y)("projectManager.noSessionCandidates"):i(y)("projectManager.sessionCandidatesNeedDirectory")),1))])):M("",!0)],512),u.value?(c(),g("button",{key:0,type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:r.busy,onClick:m[5]||(m[5]=v=>A("copy-session-id"))},[r.sessionIdCopied?(c(),re(i(st),{key:0,class:"h-4 w-4"})):(c(),re(i(qt),{key:1,class:"h-4 w-4"})),n("span",null,d(r.sessionIdCopied?i(y)("projectManager.sessionIdCopied"):i(y)("projectManager.copySessionId")),1)],8,Cs)):M("",!0)]),r.sessionIdReadonlyMessage?(c(),g("p",_s,d(r.sessionIdReadonlyMessage),1)):(c(),g("p",$s,d(P.value?i(y)("projectManager.sessionIdHint"):i(y)("projectManager.sessionCandidatesNeedDirectory")),1))])]))}},Ms={class:"flex items-center justify-between gap-3"},js={class:"theme-heading text-sm font-medium"},Is={key:0,class:"theme-muted-text mt-1 text-xs"},Es=["disabled"],Ps=["onClick"],As={key:0,class:"theme-selection-indicator absolute inset-y-3 left-0 w-1 rounded-full"},Ds={class:"flex w-full flex-col gap-2 text-left"},Rs={class:"theme-heading min-w-0 text-sm font-medium"},Ts=["title"],Ls=["title"],Bs={class:"theme-muted-text flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] leading-5"},Fs={key:0,"aria-hidden":"true"},Ns={key:1},Os={class:"flex flex-wrap items-center gap-2 pt-1"},Us={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},mt={__name:"CodexSessionManagerList",props:{busy:{type:Boolean,default:!1},editingSessionId:{type:String,default:""},formatUpdatedAt:{type:Function,default:r=>r},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},hasSessions:{type:Boolean,default:!1},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1},mode:{type:String,default:"edit"},mobile:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]}},emits:["create","select"],setup(r,{emit:q}){const j=r,A=q,{t:y}=Ve();function B(S){return j.mode==="edit"&&j.editingSessionId===S.id?"theme-card-selected":j.isSessionRunning(S.id)?"theme-card-warning":"theme-card-idle-strong"}function D(S){return j.isCurrentSession(S.id)?y("projectManager.current"):y("projectManager.regular")}function p(S){return j.isCurrentSession(S.id)?"theme-status-info":"theme-status-neutral"}return(S,E)=>(c(),g("div",{class:O(r.mobile?"flex h-full min-h-0 flex-col":"")},[n("div",Ms,[n("div",null,[n("div",js,d(i(y)("projectManager.projectList")),1),r.hasSessions?M("",!0):(c(),g("p",Is,d(i(y)("projectManager.noProjects")),1))]),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:r.busy,onClick:E[0]||(E[0]=o=>A("create"))},[I(i(Vt),{class:"h-4 w-4"}),n("span",null,d(i(y)("projectManager.create")),1)],8,Es)]),n("div",{class:O(["mt-4 space-y-2",r.mobile?"min-h-0 flex-1 overflow-y-auto":"max-h-52 overflow-y-auto pr-1 sm:max-h-64 lg:max-h-[calc(88vh-11rem)]"])},[(c(!0),g(he,null,Se(r.sessions,o=>{var b;return c(),g("article",{key:o.id,class:O(["relative cursor-pointer rounded-sm border p-3 transition",B(o)]),onClick:P=>A("select",o.id)},[r.mode==="edit"&&r.editingSessionId===o.id?(c(),g("span",As)):M("",!0),n("div",Ds,[n("div",Rs,[n("span",{class:"block truncate",title:o.title||i(y)("projectManager.untitledProject")},d(o.title||i(y)("projectManager.untitledProject")),9,Ts)]),n("div",{class:"theme-muted-text break-all font-mono text-[11px] leading-5",title:o.cwd},d(o.cwd),9,Ls),n("div",Bs,[n("span",null,d(((b=o==null?void 0:o.agentBindings)==null?void 0:b.length)>1?i(y)("projectManager.agentCount",{count:o.agentBindings.length}):i(tt)(o.engine)),1),r.mobile?M("",!0):(c(),g("span",Fs,"·")),r.mobile?M("",!0):(c(),g("span",Ns,d(r.formatUpdatedAt(o.updatedAt)),1))]),n("div",Os,[n("span",{class:O(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",p(o)])},d(D(o)),3),n("span",{class:O(["inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",r.getRuntimeStatusClass(o.id)])},[r.isSessionRunning(o.id)?(c(),g("span",Us)):M("",!0),yt(" "+d(r.getRuntimeStatusLabel(o.id)),1)],2),n("span",{class:O(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",r.getThreadStatusClass(o)])},d(r.getThreadStatusLabel(o)),3)])])],10,Ps)}),128))],2)],2))}},Hs={class:"space-y-3"},zs={class:"dashed-panel px-3 py-3"},Ks={class:"theme-muted-text text-[11px]"},qs={class:"mt-2 flex flex-wrap gap-2"},Vs={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},Ws={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},Qs={class:"dashed-panel px-3 py-3"},Gs={class:"theme-muted-text text-[11px]"},Xs={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},Js={key:0,class:"mt-2 flex flex-wrap gap-1.5"},Ys={class:"dashed-panel px-3 py-3"},Zs={class:"theme-muted-text text-[11px]"},ea={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},ta={class:"dashed-panel px-3 py-3"},na={class:"theme-muted-text text-[11px]"},sa={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},aa={class:"dashed-panel px-3 py-3"},ia={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},la={class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"},oa={__name:"CodexSessionManagerStatus",props:{activeSession:{type:Object,default:null},formatUpdatedAt:{type:Function,default:r=>r},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1}},setup(r){const{t:q}=Ve();return(j,A)=>{var y,B,D,p,S,E,o,b,P;return c(),g("div",Hs,[n("div",zs,[n("div",Ks,d(i(q)("projectManager.runtimeStatus")),1),n("div",qs,[n("span",{class:O(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",r.getRuntimeStatusClass((y=r.activeSession)==null?void 0:y.id)])},[r.isSessionRunning((B=r.activeSession)==null?void 0:B.id)?(c(),g("span",Vs)):M("",!0),yt(" "+d(r.getRuntimeStatusLabel((D=r.activeSession)==null?void 0:D.id)),1)],2),n("span",{class:O(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",r.getThreadStatusClass(r.activeSession)])},d(r.getThreadStatusLabel(r.activeSession)),3),(p=r.activeSession)!=null&&p.id&&r.isCurrentSession(r.activeSession.id)?(c(),g("span",Ws,d(i(q)("projectManager.currentProject")),1)):M("",!0)])]),n("div",Qs,[n("div",Gs,d(i(q)("projectManager.engine")),1),n("div",Xs,d(i(tt)((S=r.activeSession)==null?void 0:S.engine)),1),((o=(E=r.activeSession)==null?void 0:E.agentBindings)==null?void 0:o.length)>1?(c(),g("div",Js,[(c(!0),g(he,null,Se(r.activeSession.agentBindings,u=>(c(),g("span",{key:u.engine,class:"theme-status-neutral inline-flex items-center rounded-sm border border-solid px-1.5 py-0.5 text-[10px]"},d(i(tt)(u.engine)),1))),128))])):M("",!0)]),n("div",Ys,[n("div",Zs,d(i(q)("projectManager.workingDirectory")),1),n("div",ea,d(((b=r.activeSession)==null?void 0:b.cwd)||i(q)("projectManager.notSet")),1)]),n("div",ta,[n("div",na,d(i(q)("projectManager.updatedAt")),1),n("div",sa,d(r.formatUpdatedAt((P=r.activeSession)==null?void 0:P.updatedAt)),1)]),n("div",aa,[n("div",ia,[I(i(Wt),{class:"h-3.5 w-3.5"}),n("span",null,d(i(q)("projectManager.note")),1)]),n("p",la,d(i(q)("projectManager.noteDescription")),1)])])}}},ra={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},da={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},ua={class:"theme-divider theme-muted-panel border-b px-3 py-3 sm:px-4 sm:py-4 lg:border-b-0 lg:border-r"},ca={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},fa={class:"flex flex-wrap items-start justify-between gap-3"},pa={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ga={class:"mt-5"},va={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},ma={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4 sm:flex-row sm:items-center sm:justify-between"},ha={class:"flex flex-wrap items-center gap-2"},ya=["disabled"],xa=["disabled"],ba=["disabled"],wa={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Sa=["disabled"],ka=["disabled"],Ca=["disabled"],_a={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},$a={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ma={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},ja={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ia={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Ea=["disabled"],Pa={class:"min-w-0 flex-1"},Aa={class:"theme-heading truncate text-sm font-medium"},Da={key:0,class:"theme-muted-text mt-1 truncate text-xs"},Ra={class:"theme-divider border-b px-4 py-3"},Ta={class:"grid grid-cols-2 gap-2"},La=["disabled"],Ba={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},Fa={key:0},Na={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Oa={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},Ua=["disabled"],Ha=["disabled"],za=["disabled"],Ka=["disabled"],qa=3e3,Za={__name:"CodexSessionManagerDialog",props:{open:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]},workspaces:{type:Array,default:()=>[]},selectedSessionId:{type:String,default:""},selectionLocked:{type:Boolean,default:!1},selectionLockReason:{type:String,default:""},loading:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},onRefresh:{type:Function,default:null},onCreate:{type:Function,default:null},onUpdate:{type:Function,default:null},onDelete:{type:Function,default:null},onReset:{type:Function,default:null}},emits:["close","project-created","select-session","open-source-browser"],setup(r,{expose:q,emit:j}){const A=new Map;function y(t="",a=""){const x=qe(t),k=et(a);return!x||!k?"":`${x}
2
- ${k}`}function B(t=""){if(!t)return null;const a=A.get(t);return a?a.expiresAt<=Date.now()?(A.delete(t),null):Array.isArray(a.items)?a.items:[]:null}function D(t="",a=[]){t&&A.set(t,{expiresAt:Date.now()+qa,items:Array.isArray(a)?a:[]})}const p=r,S=j,{locale:E,t:o}=Ve(),b=$("edit"),P=$(""),u=Ut({title:"",engine:"codex",agentEngines:[],cwd:"",sessionId:""}),_=$(""),de=$(!1),V=$(!1),U=$(!1),F=$(!1),H=$(!1),z=$(!1),G=$(!1),X=$(!1),{matches:R}=Pt("(max-width: 767px)"),Q=$("list"),Z=$("basic"),ge=$(ct()),ae=$([]),J=$(!1);let h=null,m=null,v=null,K=0;const ee=C(()=>Qe(p.sessions)),w=C(()=>p.sessions.find(t=>t.id===P.value)||null),ke=C(()=>p.sessions.length>0),Je=C(()=>p.sessions.find(t=>t.id===p.selectedSessionId)||null),ue=C(()=>!!(w.value&&te(w.value.id))),Ce=C(()=>{var t;return!((t=w.value)!=null&&t.started)}),_e=C(()=>{var t;return!((t=w.value)!=null&&t.started)}),ce=C(()=>{var t;return!((t=w.value)!=null&&t.started)}),T=C(()=>p.loading||de.value||V.value||U.value||F.value),Re=C(()=>String(u.sessionId||"").trim()),$e=C(()=>{var x,k;const t=new Set,a=[];return[u.cwd,(x=w.value)==null?void 0:x.cwd,(k=Je.value)==null?void 0:k.cwd,...p.workspaces,...p.sessions.map(N=>N.cwd)].forEach(N=>{const L=String(N||"").trim();!L||t.has(L)||(t.add(L),a.push(L))}),a.slice(0,12)}),fe=C(()=>ge.value),ye=C(()=>ae.value.map(t=>({...t,updatedAtLabel:t.updatedAt?Ee(t.updatedAt):""}))),xe=C(()=>{const t=et(u.cwd);return t?p.sessions.filter(a=>{var x;return a.id===((x=w.value)==null?void 0:x.id)?!1:et(a.cwd)===t}):[]}),Y=C(()=>{if(!xe.value.length)return"";const t=xe.value.slice(0,3).map(a=>{const x=a.title||o("projectManager.untitledProject");return E.value==="en-US"?`"${x}"`:`「${x}」`}).join(E.value==="en-US"?", ":"、");return o("projectManager.duplicateDirectory",{labels:t,count:xe.value.length})}),pe=C(()=>b.value!=="edit"||Ce.value?"":o("projectManager.cwdReadonly")),Te=C(()=>b.value!=="edit"||!w.value||_e.value?"":o("projectManager.engineReadonly")),be=C(()=>b.value!=="edit"||!w.value||ce.value?"":o("projectManager.sessionIdReadonly")),We=C(()=>b.value==="create"?de.value?o("projectManager.creatingProject"):o("projectManager.createProject"):V.value?o("projectManager.savingChanges"):o("projectManager.saveChanges")),Ye=C(()=>{var t;return b.value==="create"?o("projectManager.newProject"):((t=w.value)==null?void 0:t.title)||o("projectManager.untitledProject")});function Me(t=""){const a=Date.parse(String(t||""));return Number.isFinite(a)?a:0}function te(t){var a;return!!((a=p.sessions.find(x=>x.id===t))!=null&&a.running)}function ve(t){return!!t&&t===p.selectedSessionId}function Qe(t=[]){return[...t].sort((a,x)=>{const k=Number(te(x.id))-Number(te(a.id));if(k)return k;const N=Number(ve(x.id))-Number(ve(a.id));if(N)return N;const L=Me(x.updatedAt)-Me(a.updatedAt);return L||Tt(String(a.title||a.cwd||a.id),String(x.title||x.cwd||x.id))})}function Le(t){return te(t)?o("projectManager.running"):o("projectManager.idle")}function je(t){return te(t)?"theme-status-warning":"theme-status-success"}function Be(t){return t!=null&&t.started?o("projectManager.threadBound"):o("projectManager.notStarted")}function Ie(t){return t!=null&&t.started?"theme-status-success":"theme-status-neutral"}function Ee(t=""){if(!t)return o("projectManager.unknown");const a=new Date(t);return Number.isNaN(a.getTime())?t:Rt(a.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Fe(t){u.title=String((t==null?void 0:t.title)||""),u.engine=qe(t==null?void 0:t.engine),u.agentEngines=(Array.isArray(t==null?void 0:t.agentBindings)?t.agentBindings:[]).map(a=>qe(a==null?void 0:a.engine)).filter(a=>a&&a!==u.engine),u.cwd=String((t==null?void 0:t.cwd)||""),u.sessionId=String((t==null?void 0:t.sessionId)||(t==null?void 0:t.engineSessionId)||(t==null?void 0:t.engineThreadId)||(t==null?void 0:t.codexThreadId)||"").trim()}function Pe(){b.value="create",P.value="",_.value="",u.title="",u.engine="codex",u.agentEngines=[],u.cwd="",u.sessionId=""}function ne(t){const a=p.sessions.find(x=>x.id===t);a&&(b.value="edit",P.value=a.id,_.value="",Fe(a))}function Ae(){var t;return p.selectedSessionId&&p.sessions.some(a=>a.id===p.selectedSessionId)?p.selectedSessionId:((t=ee.value[0])==null?void 0:t.id)||""}function Ne(t="basic"){Q.value="detail",Z.value=t}function Oe(){Q.value="list",Z.value="basic"}function Ue(){Pe(),R.value&&Ne("basic")}function He(t){T.value||(ne(t),R.value&&Ne("basic"))}function e(t){u.cwd=String(t||"").trim()}async function l(){var a,x;const t=((a=w.value)==null?void 0:a.id)||Ae();return!t||((!w.value||w.value.id!==t)&&(ne(t),await me()),!((x=w.value)!=null&&x.cwd))?!1:(R.value&&Ne("basic"),S("open-source-browser",w.value),S("close"),!0)}function s(){return H.value?(H.value=!1,!0):z.value?(z.value=!1,!0):G.value?(G.value=!1,!0):p.open?(S("close"),!0):!1}function f(t){u.title=String(t||"")}function W(t){u.engine=qe(t),u.agentEngines=u.agentEngines.filter(a=>a!==u.engine)}function se(t){u.agentEngines=[...new Set((Array.isArray(t)?t:[]).map(a=>qe(a)).filter(a=>a&&a!==u.engine))]}function we(t){u.cwd=String(t||"")}function ie(t){u.sessionId=String(t||"")}function le(t){u.sessionId=String((t==null?void 0:t.id)||"").trim()}function ze(){_.value="",H.value=!1,z.value=!1,X.value=!1,Z.value="basic",Q.value=R.value?"list":"detail";const t=Ae();if(t){ne(t);return}Pe()}async function xt(){if(!(T.value||typeof p.onRefresh!="function")){_.value="";try{await Promise.all([p.onRefresh(),it()])}catch(t){_.value=t.message}}}async function it(){try{ge.value=await At()}catch{ge.value=ct()}}function Ze(){m&&(clearTimeout(m),m=null)}function Ke(){v&&(v.abort(),v=null)}async function bt(){const t=String(u.cwd||"").trim();if(!p.open||!ce.value||!t){ae.value=[],J.value=!1,Ke();return}const a=++K;Ke();const x=y(u.engine,t),k=B(x);if(k){ae.value=k,J.value=!1;return}v=new AbortController,J.value=!0;try{const N=await Dt({engine:u.engine,cwd:t,limit:50,signal:v.signal});if(a!==K)return;const L=Array.isArray(N==null?void 0:N.items)?N.items:[];ae.value=L,D(x,L)}catch(N){if((N==null?void 0:N.name)==="AbortError")return;a===K&&(ae.value=[])}finally{a===K&&(J.value=!1,v=null)}}function lt(t=250){if(Ze(),!p.open||!ce.value||!String(u.cwd||"").trim()){ae.value=[],J.value=!1,Ke();return}m=setTimeout(()=>{m=null,bt().catch(()=>{})},t)}async function wt(t){var x;if((x=navigator.clipboard)!=null&&x.writeText&&window.isSecureContext){await navigator.clipboard.writeText(t);return}const a=document.createElement("textarea");a.value=t,a.setAttribute("readonly","true"),a.style.position="fixed",a.style.opacity="0",a.style.pointerEvents="none",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}async function ot(){const t=Re.value;if(t)try{await wt(t),X.value=!0,h&&clearTimeout(h),h=setTimeout(()=>{X.value=!1,h=null},1800)}catch(a){_.value=(a==null?void 0:a.message)||o("projectManager.copySessionIdFailed")}}async function rt(){if(!T.value){_.value="";try{const t=St();if(!t)return;await kt(t)}catch(t){_.value=t.message}}}function St(){if(b.value==="create"){const a=String(u.cwd||"").trim();return a?{type:"create",cwd:a,payload:{title:u.title,engine:u.engine,agentEngines:[u.engine,...u.agentEngines],cwd:a,sessionId:String(u.sessionId||"").trim()}}:(_.value=o("projectManager.directoryRequired"),null)}if(!w.value)return _.value=o("projectManager.projectMissing"),null;const t={title:u.title,engine:u.engine,agentEngines:[u.engine,...u.agentEngines]};return Ce.value&&(t.cwd=u.cwd),ce.value&&(t.sessionId=String(u.sessionId||"").trim()),{type:"update",sessionId:w.value.id,payload:t}}async function kt(t){var a,x;if(t.type==="create"){de.value=!0;try{const k=await((a=p.onCreate)==null?void 0:a.call(p,t.payload));k!=null&&k.id&&(ne(k.id),S("select-session",k.id),await me(),S("project-created",k),S("close"));return}finally{de.value=!1}}V.value=!0;try{const k=await((x=p.onUpdate)==null?void 0:x.call(p,t.sessionId,t.payload));k!=null&&k.id&&ne(k.id)}finally{V.value=!1}}async function Ct(){var a,x;if(!w.value||U.value)return;const t=w.value.id;_.value="",U.value=!0;try{const k=await((a=p.onDelete)==null?void 0:a.call(p,t));H.value=!1;const N=p.sessions.filter($t=>$t.id!==t),L=(k==null?void 0:k.selectedSessionId)||((x=Qe(N)[0])==null?void 0:x.id)||"";S("select-session",L),L?(ne(L),R.value&&Oe()):(Pe(),R.value&&Oe())}catch(k){_.value=k.message}finally{U.value=!1}}async function _t(){var a;if(!w.value||F.value)return;const t=w.value.id;_.value="",F.value=!0;try{const x=await((a=p.onReset)==null?void 0:a.call(p,t));z.value=!1;const k=(x==null?void 0:x.session)||p.sessions.find(N=>N.id===t)||null;k!=null&&k.id&&ne(k.id)}catch(x){_.value=x.message}finally{F.value=!1}}return oe(()=>p.open,t=>{if(t){ze(),typeof p.onRefresh=="function"?xt().catch(()=>{}):it().catch(()=>{});return}G.value=!1,H.value=!1,z.value=!1,X.value=!1,_.value="",Ze(),Ke(),ae.value=[],J.value=!1},{immediate:!0}),oe(R,t=>{t||(Q.value="detail")},{immediate:!0}),oe(()=>p.sessions,()=>{if(!p.open)return;if(b.value==="create"){if(!!(String(u.title||"").trim()||String(u.cwd||"").trim())||!!String(u.sessionId||"").trim())return;const x=Ae();x&&ne(x);return}if(w.value){Fe(w.value);return}const t=Ae();if(t){ne(t);return}Pe()}),oe(()=>[p.open,b.value,u.engine,u.cwd,ce.value].join(`
3
- `),()=>{lt(250)},{immediate:!0}),oe(()=>{var t;return((t=w.value)==null?void 0:t.id)||""},()=>{lt(0)}),at(()=>{h&&(clearTimeout(h),h=null),Ze(),Ke()}),q({closeTopDialog:s}),(t,a)=>(c(),g(he,null,[I(ft,{open:z.value,title:i(o)("projectManager.confirmResetTitle"),description:w.value?i(o)("projectManager.confirmResetDescription",{title:w.value.title||i(o)("projectManager.untitledProject")}):"","confirm-text":i(o)("projectManager.confirmReset"),"cancel-text":i(o)("projectManager.keep"),loading:F.value,onCancel:a[0]||(a[0]=x=>z.value=!1),onConfirm:_t},null,8,["open","title","description","confirm-text","cancel-text","loading"]),I(ft,{open:H.value,title:i(o)("projectManager.confirmDeleteTitle"),description:w.value?i(o)("projectManager.confirmDeleteDescription",{title:w.value.title||i(o)("projectManager.untitledProject")}):"","confirm-text":i(o)("projectManager.confirmDelete"),"cancel-text":i(o)("projectManager.keep"),loading:U.value,danger:"",onCancel:a[1]||(a[1]=x=>H.value=!1),onConfirm:Ct},null,8,["open","title","description","confirm-text","cancel-text","loading"]),I(Rn,{open:G.value,"initial-path":u.cwd,suggestions:$e.value,onClose:a[2]||(a[2]=x=>G.value=!1),onSelect:e},null,8,["open","initial-path","suggestions"]),I(ht,{open:r.open,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-5xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 overflow-hidden","close-disabled":T.value,"close-on-backdrop":!T.value,"close-on-escape":!T.value,onClose:a[12]||(a[12]=x=>S("close"))},{title:De(()=>[n("div",ra,[I(i(Zt),{class:"h-4 w-4"}),n("span",null,d(i(o)("projectManager.managingTitle")),1)])]),default:De(()=>{var x,k,N;return[i(R)?(c(),g("div",_a,[Q.value==="list"?(c(),g("div",$a,[n("div",Ma,[I(mt,{mobile:"",busy:T.value,"editing-session-id":P.value,"format-updated-at":Ee,"get-runtime-status-class":je,"get-runtime-status-label":Le,"get-thread-status-class":Ie,"get-thread-status-label":Be,"has-sessions":ke.value,"is-current-session":ve,"is-session-running":te,mode:b.value,sessions:ee.value,onCreate:Ue,onSelect:He},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])])])):(c(),g("div",ja,[n("div",Ia,[n("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",disabled:T.value,onClick:Oe},[I(i(Yt),{class:"h-4 w-4"}),n("span",null,d(i(o)("projectManager.projectList")),1)],8,Ea),n("div",Pa,[n("div",Aa,d(Ye.value),1),b.value==="edit"&&((k=w.value)!=null&&k.cwd)?(c(),g("p",Da,d(w.value.cwd),1)):M("",!0)])]),n("div",Ra,[n("div",Ta,[n("button",{type:"button",class:O(["tool-button px-3 py-2 text-sm",Z.value==="basic"?"tool-button-accent-subtle":""]),onClick:a[7]||(a[7]=L=>Z.value="basic")},d(i(o)("projectManager.basicInfo")),3),n("button",{type:"button",class:O(["tool-button px-3 py-2 text-sm",Z.value==="status"?"tool-button-accent-subtle":""]),disabled:b.value==="create",onClick:a[8]||(a[8]=L=>Z.value="status")},d(i(o)("projectManager.status")),11,La)])]),n("div",Ba,[Z.value==="basic"?(c(),g("div",Fa,[I(vt,{mobile:"",busy:T.value,"can-edit-engine":b.value!=="edit"||_e.value,"can-edit-cwd":b.value!=="edit"||Ce.value,"can-edit-session-id":b.value!=="edit"||ce.value,cwd:u.cwd,"cwd-readonly-message":pe.value,"duplicate-cwd-message":Y.value,engine:u.engine,"agent-engines":u.agentEngines,"engine-options":fe.value,"engine-readonly-message":Te.value,"session-candidates":ye.value,"session-candidates-loading":J.value,"session-id":u.sessionId,"session-id-copied":X.value,"session-id-readonly-message":be.value,title:u.title,"workspace-suggestions":$e.value,onCopySessionId:ot,onOpenDirectoryPicker:a[9]||(a[9]=L=>G.value=!0),onSelectSessionCandidate:le,"onUpdate:cwd":we,"onUpdate:engine":W,"onUpdate:agentEngines":se,"onUpdate:sessionId":ie,"onUpdate:title":f},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","agent-engines","engine-options","engine-readonly-message","session-candidates","session-candidates-loading","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"]),_.value?(c(),g("p",Na,[I(i(gt),{class:"h-4 w-4"}),n("span",null,d(_.value),1)])):M("",!0),n("div",Oa,[n("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-sm",disabled:T.value,onClick:rt},d(We.value),9,Ua),b.value==="edit"&&w.value?(c(),g("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:T.value||!((N=w.value)!=null&&N.cwd),onClick:l},d(i(o)("projectManager.viewSource")),9,Ha)):M("",!0),b.value==="edit"&&w.value?(c(),g("button",{key:1,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:T.value||ue.value,onClick:a[10]||(a[10]=L=>z.value=!0)},d(F.value?i(o)("projectManager.resettingSession"):i(o)("projectManager.newSession")),9,za)):M("",!0),b.value==="edit"&&w.value?(c(),g("button",{key:2,type:"button",class:"tool-button tool-button-danger-subtle w-full px-3 py-2 text-sm",disabled:T.value||ue.value,onClick:a[11]||(a[11]=L=>H.value=!0)},d(U.value?i(o)("projectManager.deletingProject"):i(o)("projectManager.deleteProject")),9,Ka)):M("",!0)])])):(c(),re(oa,{key:1,"active-session":w.value,"format-updated-at":Ee,"get-runtime-status-class":je,"get-runtime-status-label":Le,"get-thread-status-class":Ie,"get-thread-status-label":Be,"is-current-session":ve,"is-session-running":te},null,8,["active-session"]))])]))])):(c(),g("div",da,[n("aside",ua,[I(mt,{busy:T.value,"editing-session-id":P.value,"format-updated-at":Ee,"get-runtime-status-class":je,"get-runtime-status-label":Le,"get-thread-status-class":Ie,"get-thread-status-label":Be,"has-sessions":ke.value,"is-current-session":ve,"is-session-running":te,mode:b.value,sessions:ee.value,onCreate:Ue,onSelect:He},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])]),n("div",ca,[n("div",fa,[n("div",null,[n("div",pa,[I(i(Qt),{class:"h-4 w-4"}),n("span",null,d(b.value==="create"?i(o)("projectManager.createTitle"):i(o)("projectManager.editTitle")),1)])])]),n("div",ga,[I(vt,{busy:T.value,"can-edit-engine":b.value!=="edit"||_e.value,"can-edit-cwd":b.value!=="edit"||Ce.value,"can-edit-session-id":b.value!=="edit"||ce.value,cwd:u.cwd,"cwd-readonly-message":pe.value,"duplicate-cwd-message":Y.value,engine:u.engine,"agent-engines":u.agentEngines,"engine-options":fe.value,"engine-readonly-message":Te.value,"session-candidates":ye.value,"session-candidates-loading":J.value,"session-id":u.sessionId,"session-id-copied":X.value,"session-id-readonly-message":be.value,title:u.title,"workspace-suggestions":$e.value,onCopySessionId:ot,onOpenDirectoryPicker:a[3]||(a[3]=L=>G.value=!0),onSelectSessionCandidate:le,"onUpdate:cwd":we,"onUpdate:engine":W,"onUpdate:agentEngines":se,"onUpdate:sessionId":ie,"onUpdate:title":f},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","agent-engines","engine-options","engine-readonly-message","session-candidates","session-candidates-loading","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"])]),_.value?(c(),g("p",va,[I(i(gt),{class:"h-4 w-4"}),n("span",null,d(_.value),1)])):M("",!0),n("div",ma,[n("div",ha,[b.value==="edit"&&w.value?(c(),g("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||!((x=w.value)!=null&&x.cwd),onClick:l},[I(i(Gt),{class:"h-4 w-4"}),n("span",null,d(i(o)("projectManager.viewSource")),1)],8,ya)):M("",!0),b.value==="edit"&&w.value?(c(),g("button",{key:1,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||ue.value,onClick:a[4]||(a[4]=L=>z.value=!0)},[I(i(Xt),{class:"h-4 w-4"}),n("span",null,d(F.value?i(o)("projectManager.resettingSession"):i(o)("projectManager.newSession")),1)],8,xa)):M("",!0),b.value==="edit"&&w.value?(c(),g("button",{key:2,type:"button",class:"tool-button tool-button-danger-subtle inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||ue.value,onClick:a[5]||(a[5]=L=>H.value=!0)},[I(i(Jt),{class:"h-4 w-4"}),n("span",null,d(U.value?i(o)("projectManager.deletingProject"):i(o)("projectManager.deleteProject")),1)],8,ba)):M("",!0)]),n("div",wa,[n("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:a[6]||(a[6]=L=>S("close"))},d(i(o)("projectManager.close")),9,Sa),b.value==="create"&&ke.value?(c(),g("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:ze},d(i(o)("projectManager.backToList")),9,ka)):M("",!0),n("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:rt},d(We.value),9,Ca)])])])]))]}),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"])],64))}};export{Za as default};
1
+ import{W as dt,j as ht,o as Mt,s as jt,p as It,q as ut,h as Et,t as tt,f as At,v as ct,w as ft,x as Pt,y as qe,z as Dt,A as et}from"./WorkbenchView-BqHMDZ1g.js";import{u as Ve,f as Rt,e as Tt}from"./index-7F-RPTS_.js";import{w as oe,n as me,ak as at,aD as c,aI as re,aJ as De,aF as n,aQ as d,u as i,aG as I,aW as Lt,aU as Bt,aX as Ft,aE as g,aR as he,aS as Se,aL as O,aN as M,aV as Nt,aK as nt,b as $,c as C,o as Ot,aZ as yt,r as Ut}from"./vendor-misc-u-M8sNMf.js";import{c as zt,L as Ge,F as Xe,e as Ht,b as st,X as pt,C as Kt,O as qt,j as Vt,x as Wt,P as Qt,i as gt,E as Gt,Q as Xt,q as Yt,r as Jt,Y as Zt}from"./vendor-ui-BglsaDbv.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";import"./vendor-router-Dn8q3tJM.js";const en={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},tn={class:"theme-muted-text mt-1 text-xs leading-5"},nn={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},sn={class:"flex items-start gap-2 text-xs leading-5"},an={class:"theme-muted-text shrink-0"},ln={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},on={class:"theme-muted-text mt-4 block text-xs"},rn={class:"theme-input-shell mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2"},dn=["placeholder"],un={class:"theme-content-panel mt-3 min-h-0 flex-1 overflow-y-auto p-2"},cn={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},fn={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},pn={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},gn={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},vn={key:4,class:"theme-empty-state px-3 py-8 text-sm"},mn={key:5,class:"theme-empty-state px-3 py-8 text-sm"},hn={key:6,class:"theme-empty-state px-3 py-8 text-sm"},yn={key:7,class:"space-y-1"},xn=["onClick"],bn={class:"min-w-0 flex-1"},wn=["innerHTML"],Sn=["innerHTML"],kn={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},Cn={key:8,class:"space-y-1"},_n={class:"flex items-start gap-1.5"},$n=["onClick"],Mn=["onClick"],jn={class:"min-w-0 flex-1"},In={key:0,class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all"},En={class:"theme-divider flex flex-col-reverse gap-2 border-t border-dashed px-4 py-4 sm:flex-row sm:items-center sm:justify-end sm:px-5"},An={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},Pn=["disabled"],Dn=["disabled"],Rn={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""},suggestions:{type:Array,default:()=>[]}},emits:["close","select"],setup(r,{emit:q}){const j=r,P=q,{t:y}=Ve(),B=$(""),D=$(null),p=$(!1),S=$(""),E=$(!1),o=$(""),b=$([]),A=$(!1),u=$(""),_=$(""),de=$(null);let V=null,U=0,F=null;const z=new Map,H=C(()=>$e(D.value?[D.value]:[])),G=C(()=>String(u.value||"").trim()),X=C(()=>G.value.length>=dt),R=C(()=>!!G.value),Q=C(()=>R.value?b.value:H.value),Z=C(()=>Q.value.map(e=>{const l=m((e==null?void 0:e.path)||""),s=e!=null&&e.expanded?1:0,f=e!=null&&e.loading?1:0;return`${l}:${s}:${f}`}).join("|")),ge=C(()=>R.value&&!X.value&&!E.value&&!o.value),ae=C(()=>R.value&&X.value&&!E.value&&!o.value&&!b.value.length),Y=C(()=>!R.value&&!p.value&&!S.value&&!H.value.length);function h(e=""){const l=String(e||"").trim();return/^[a-z]:[\\/]/i.test(l)||l.includes("\\")}function m(e=""){const l=String(e||"").trim();if(!l)return"";const s=h(l);let f=l.replace(/\\/g,"/");return f.length>1&&!/^[a-z]:\/?$/i.test(f)&&f!=="/"&&(f=f.replace(/\/+$/,"")),s?f.toLowerCase():f}function v(e="",l=""){const s=m(e),f=m(l);return!s||!f?!1:s===f||s.startsWith(`${f}/`)}function K(e="",l=""){const s=String(e||"").trim(),f=String(l||"").trim();return s?f?h(s)?/^[a-z]:\\?$/i.test(s)?`${s.replace(/[\\/]+$/,"")}\\${f}`:`${s.replace(/[\\/]+$/,"")}\\${f}`:s==="/"?`/${f}`:`${s.replace(/\/+$/,"")}/${f}`:s:f}function ee(e="",l=""){const s=m(e),f=m(l);if(!s||!f||!v(f,s))return[];const W=f===s?"":f.slice(s.length).replace(/^\//,"");return W?W.split("/").filter(Boolean):[]}function w(e=""){const l=String(e||"").trim();if(!l||m(l)===m(B.value))return"";const s=h(l),f=l.replace(/\\/g,"/");if(s){const ie=f.replace(/\/+$/,""),le=ie.lastIndexOf("/");if(le<=2)return"";const He=ie.slice(0,le).replace(/\//g,"\\");return v(He,B.value)?He:""}const W=f.replace(/\/+$/,""),se=W.lastIndexOf("/");if(se<=0)return"";const we=W.slice(0,se)||"/";return v(we,B.value)?we:""}function ke(e){return(e==null?void 0:e.name)||(e==null?void 0:e.path)||y("directoryPicker.unnamedDirectory")}function Ye(e=""){const l=String(e||"").trim();return l?l.split(/[\\/]/).filter(Boolean).at(-1)||l:"Home"}function ue(e=""){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ce(e="",l=""){const s=String(e||""),f=String(l||"").trim().toLowerCase();if(!s||!f)return null;const W=s.toLowerCase(),se=W.indexOf(f);if(se>=0)return{start:se,end:se+f.length};const we=f.split(/[\\/\s_.-]+/).filter(Boolean).sort((ie,le)=>le.length-ie.length);for(const ie of we){if(ie.length<2)continue;const le=W.indexOf(ie);if(le>=0)return{start:le,end:le+ie.length}}return null}function _e(e="",l=""){const s=String(e||""),f=Ce(s,l);return f?`${ue(s.slice(0,f.start))}<mark class="theme-search-highlight">${ue(s.slice(f.start,f.end))}</mark>${ue(s.slice(f.end))}`:ue(s)}function ce(e){return _e(ke(e),u.value)}function T(e){return _e((e==null?void 0:e.path)||"",u.value)}function Re(e,l=0){return{...e,depth:l,expanded:!1,loaded:!1,loading:!1,children:[]}}function $e(e=[],l=[]){return e.forEach(s=>{l.push(s),s.expanded&&s.children.length&&$e(s.children,l)}),l}function fe(){D.value&&(D.value={...D.value})}function ye(){V&&(window.clearTimeout(V),V=null),F&&(F.abort(),F=null)}function xe(e,l=D.value?[D.value]:[]){const s=m(e);if(!s)return null;for(const f of l){if(m(f.path)===s)return f;if(f.children.length){const W=xe(e,f.children);if(W)return W}}return null}function J(e){_.value=String((e==null?void 0:e.path)||"").trim()}function pe(e=""){return m(e)}function Te(e,l){const s=pe(e);if(s){if(l){z.set(s,l);return}z.delete(s)}}function be(){var l;const e=z.get(pe(_.value));(l=e==null?void 0:e.scrollIntoView)==null||l.call(e,{block:"nearest"})}function We(){me(()=>{var e,l;(l=(e=de.value)==null?void 0:e.focus)==null||l.call(e)})}function Je(){const e=Q.value;if(!e.length){_.value="";return}const l=pe(_.value);l&&e.some(s=>pe((s==null?void 0:s.path)||"")===l)||J(e[0])}function Me(){const e=Q.value;if(!e.length)return-1;const l=pe(_.value),s=e.findIndex(f=>pe((f==null?void 0:f.path)||"")===l);return s>=0?s:0}function te(){const e=Q.value,l=Me();return l<0||!e.length?null:e[l]||null}function ve(e=1){const l=Q.value;if(!l.length)return!1;const s=Me(),f=s<0?0:(s+e+l.length)%l.length;return J(l[f]),me(be),!0}async function Qe(){if(R.value)return!1;const e=te();if(!e||!e.hasChildren)return!1;if(!e.expanded)return await ne(e),!0;const l=Q.value,s=Me(),f=l[s+1];return f&&w(f.path)===e.path?(J(f),me(be),!0):!1}function Le(){if(R.value)return!1;const e=te();if(!e)return!1;if(e.expanded&&e.hasChildren)return e.expanded=!1,fe(),J(e),!0;const l=w(e.path);if(!l)return!1;const s=xe(l);return s?(J(s),me(be),!0):!1}function je(e){var l,s,f;if((l=e==null?void 0:e.preventDefault)==null||l.call(e),G.value){(s=e==null?void 0:e.stopPropagation)==null||s.call(e),u.value="";return}(f=e==null?void 0:e.stopPropagation)==null||f.call(e),P("close")}function Be(e){const l=String((e==null?void 0:e.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(l)&&!(R.value&&(l==="ArrowLeft"||l==="ArrowRight"))){if(l==="ArrowDown"){e.preventDefault(),ve(1);return}if(l==="ArrowUp"){e.preventDefault(),ve(-1);return}if(l==="Escape"){je(e);return}if(R.value){if(l==="Enter"){e.preventDefault();const s=te();s&&Ue(s)}return}if(l==="ArrowRight"){e.preventDefault(),Qe();return}if(l==="ArrowLeft"){e.preventDefault(),Le();return}l==="Enter"&&(e.preventDefault(),ze())}}async function Ie(e,l={}){if(!(!e||e.loading)&&!(e.loaded&&!l.force)){e.loading=!0,S.value="",fe();try{const s=await ut({path:e.path,limit:240});e.children=(s.items||[]).map(f=>Re(f,e.depth+1)),e.loaded=!0}catch(s){S.value=s.message||y("directoryPicker.loadFailed")}finally{e.loading=!1,fe()}}}async function Ee(){p.value=!0,S.value="";try{const e=await ut({limit:240});B.value=String(e.path||""),D.value=Re({name:Ye(e.path||""),path:String(e.path||""),type:"directory",hasChildren:!0,isHomeRoot:!0},0),D.value.children=(e.items||[]).map(l=>Re(l,1)),D.value.loaded=!0,D.value.expanded=!0,J(D.value)}catch(e){S.value=e.message||y("directoryPicker.treeLoadFailed"),D.value=null,B.value=""}finally{p.value=!1}}async function Fe(e=""){const l=String(e||"").trim();if(!l||!B.value||!v(l,B.value))return;let s=D.value;if(!s)return;J(s);const f=ee(B.value,l);for(const W of f){await Ie(s),s.expanded=!0,fe();const se=xe(K(s.path,W),s.children);if(!se)break;s=se,J(s)}}async function Ae(){u.value="",b.value=[],o.value="",A.value=!1,_.value="",await Ee();const e=String(j.initialPath||"").trim();e&&v(e,B.value)&&await Fe(e)}async function ne(e){if(e!=null&&e.path&&(J(e),!!e.hasChildren)){if(!e.loaded){e.expanded=!0,fe(),await Ie(e);return}e.expanded=!e.expanded,fe()}}function Pe(e){e!=null&&e.path&&J(e)}async function Ne(){const e=String(u.value||"").trim();U+=1;const l=U;if(ye(),!j.open||!e||!B.value||!X.value){E.value=!1,o.value="",b.value=[],A.value=!1;return}E.value=!0,o.value="",F=new AbortController;try{const s=await jt(e,{path:B.value,limit:80,signal:F.signal});if(l!==U)return;b.value=Array.isArray(s.items)?s.items:[],A.value=!!s.truncated}catch(s){if(It(s)||l!==U)return;o.value=s.message||y("directoryPicker.searchFailed"),b.value=[],A.value=!1}finally{l===U&&(F=null),l===U&&(E.value=!1)}}function Oe(){if(ye(),!String(u.value||"").trim()||!X.value){E.value=!1,o.value="",b.value=[],A.value=!1;return}E.value=!0,o.value="",V=window.setTimeout(()=>{V=null,Ne()},Mt)}async function Ue(e){e!=null&&e.path&&(await Fe(e.path),u.value="")}function ze(){_.value&&(P("select",_.value),P("close"))}return oe(u,()=>{Oe()}),oe(Z,()=>{Je(),me(be)},{immediate:!0}),oe(()=>j.open,e=>{if(e){Ae().catch(()=>{}),We();return}ye()}),at(()=>{ye()}),(e,l)=>(c(),re(ht,{open:r.open,"stack-level":1,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-4xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 flex-col overflow-hidden px-4 py-4 sm:px-5","close-disabled":p.value||E.value,"close-on-backdrop":!(p.value||E.value),"close-on-escape":!(p.value||E.value),onClose:l[2]||(l[2]=s=>P("close"))},{title:De(()=>[n("div",null,[n("div",en,[I(i(Xe),{class:"h-4 w-4"}),n("span",null,d(i(y)("directoryPicker.title")),1)]),n("p",tn,d(i(y)("directoryPicker.intro")),1)])]),default:De(()=>[n("div",{class:"flex min-h-0 flex-1 flex-col overflow-hidden",onKeydown:Be},[n("div",nn,[n("div",sn,[n("span",an,d(i(y)("directoryPicker.currentSelection")),1),n("span",ln,d(_.value||i(y)("directoryPicker.selectionPlaceholder")),1)])]),n("label",on,[n("span",null,d(i(y)("directoryPicker.searchLabel")),1),n("div",rn,[I(i(zt),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),Lt(n("input",{ref_key:"searchInputRef",ref:de,"onUpdate:modelValue":l[0]||(l[0]=s=>u.value=s),type:"text",placeholder:i(y)("directoryPicker.searchPlaceholder"),class:"min-w-0 flex-1 border-0 bg-transparent px-0 text-sm text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]",onKeydown:Bt(je,["esc"])},null,40,dn),[[Ft,u.value]])])]),n("div",un,[R.value&&o.value?(c(),g("div",cn,d(o.value),1)):!R.value&&S.value?(c(),g("div",fn,d(S.value),1)):R.value&&E.value?(c(),g("div",pn,[I(i(Ge),{class:"h-4 w-4 animate-spin"}),n("span",null,d(i(y)("directoryPicker.searching")),1)])):!R.value&&p.value?(c(),g("div",gn,[I(i(Ge),{class:"h-4 w-4 animate-spin"}),n("span",null,d(i(y)("directoryPicker.treeLoading")),1)])):ge.value?(c(),g("div",vn,d(i(y)("directoryPicker.searchMinKeywordHint",{count:i(dt)})),1)):ae.value?(c(),g("div",mn,d(i(y)("directoryPicker.noSearchResults")),1)):Y.value?(c(),g("div",hn,d(i(y)("directoryPicker.emptyTree")),1)):R.value?(c(),g("div",yn,[(c(!0),g(he,null,Se(b.value,s=>(c(),g("button",{key:s.path,ref_for:!0,ref:f=>Te(s.path,f),type:"button",class:O(["theme-list-row focus:outline-none",m(_.value)===m(s.path)?"theme-list-item-active":"theme-list-item-hover"]),onClick:f=>Ue(s)},[I(i(Xe),{class:"theme-list-item-icon"}),n("div",bn,[n("div",null,[n("span",{class:"theme-list-item-title block break-all",innerHTML:ce(s)},null,8,wn)]),n("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:T(s)},null,8,Sn)])],10,xn))),128)),A.value?(c(),g("p",kn,d(i(y)("directoryPicker.truncatedHint")),1)):M("",!0)])):(c(),g("div",Cn,[(c(!0),g(he,null,Se(H.value,s=>(c(),g("div",{key:s.path,ref_for:!0,ref:f=>Te(s.path,f),class:O(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",m(_.value)===m(s.path)?"theme-list-item-active":s.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Nt({paddingLeft:`${s.depth*16+6}px`})},[n("div",_n,[n("button",{type:"button",class:O(["theme-icon-button h-5 w-5 shrink-0",s.hasChildren?"":"invisible pointer-events-none"]),onClick:nt(f=>ne(s),["stop"])},[s.loading?(c(),re(i(Ge),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(c(),re(i(Ht),{key:1,class:O(["h-3.5 w-3.5 transition",s.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,$n),n("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left",onClick:f=>Pe(s)},[I(i(Xe),{class:O(["h-4 w-4 shrink-0",m(_.value)===m(s.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),n("div",jn,[n("div",{class:O(["theme-list-item-title truncate",s.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},d(ke(s)),3),s.isHomeRoot?(c(),g("div",In,d(s.path),1)):M("",!0)])],8,Mn)])],6))),128))]))])],32),n("div",En,[n("div",An,[n("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:p.value||E.value,onClick:l[1]||(l[1]=s=>P("close"))},d(i(y)("directoryPicker.cancel")),9,Pn),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex w-full items-center justify-center gap-2 px-3 py-2 text-xs sm:w-auto",disabled:p.value||E.value||!_.value,onClick:ze},[I(i(st),{class:"h-4 w-4"}),n("span",null,d(i(y)("directoryPicker.useCurrentDirectory")),1)],8,Dn)])])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},Tn={class:"grid gap-4"},Ln={class:"theme-muted-text block text-xs"},Bn=["value","disabled"],Fn={class:"theme-muted-text block text-xs"},Nn={class:"mt-1 flex gap-2"},On={class:"relative min-w-0 flex-1"},Un=["value","disabled"],zn=["disabled"],Hn=["disabled"],Kn={id:"codex-manager-workspace-suggestions"},qn=["value"],Vn={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Wn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},Qn={class:"theme-muted-text block text-xs"},Gn={class:"mt-1"},Xn={class:"flex items-center gap-2 text-sm"},Yn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Jn=["disabled","onClick"],Zn={class:"flex items-center justify-between gap-3"},es={class:"min-w-0 flex-1 truncate"},ts={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},ns={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},ss={class:"theme-muted-text block text-xs"},as={class:"mt-2 grid gap-2"},is=["disabled","onClick"],ls={class:"min-w-0"},os={class:"text-sm text-[var(--theme-textPrimary)]"},rs={class:"theme-muted-text mt-0.5 text-[11px] leading-5"},ds={class:"theme-muted-text mt-2 text-[11px] leading-5"},us={class:"theme-muted-text block text-xs"},cs={class:"mt-1 flex gap-2"},fs=["value","disabled"],ps=["disabled"],gs={key:1,class:"theme-popover theme-divider absolute left-0 right-0 top-[calc(100%+0.375rem)] z-20 overflow-hidden rounded-sm border border-solid shadow-sm"},vs={class:"flex items-center justify-between gap-2 border-b border-solid px-3 py-2 text-[11px] leading-5"},ms={class:"font-medium text-[var(--theme-textPrimary)]"},hs={key:0,class:"theme-muted-text"},ys={key:0,class:"max-h-72 overflow-y-auto p-2"},xs=["disabled","onClick"],bs={class:"flex min-w-0 items-center justify-between gap-3"},ws={class:"min-w-0 flex-1 truncate text-xs font-medium text-[var(--theme-textPrimary)]"},Ss={class:"shrink-0 text-[11px] leading-4 text-[var(--theme-textMuted)]"},ks={key:1,class:"theme-empty-state px-3 py-4 text-xs"},Cs=["disabled"],_s={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},$s={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},vt={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},agentEngines:{type:Array,default:()=>[]},canEditEngine:{type:Boolean,default:!0},canEditCwd:{type:Boolean,default:!0},canEditSessionId:{type:Boolean,default:!0},cwd:{type:String,default:""},cwdReadonlyMessage:{type:String,default:""},duplicateCwdMessage:{type:String,default:""},engine:{type:String,default:"codex"},engineOptions:{type:Array,default:()=>[]},engineReadonlyMessage:{type:String,default:""},mobile:{type:Boolean,default:!1},sessionId:{type:String,default:""},sessionIdCopied:{type:Boolean,default:!1},sessionIdReadonlyMessage:{type:String,default:""},sessionCandidates:{type:Array,default:()=>[]},sessionCandidatesLoading:{type:Boolean,default:!1},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["copy-session-id","open-directory-picker","select-session-candidate","update:agentEngines","update:cwd","update:engine","update:sessionId","update:title"],setup(r,{emit:q}){const j=r,P=q,{t:y}=Ve(),B=$(null),D=$(null),p=$(!1),S=$(-1),E=C(()=>{const h=String(j.engine||"").trim();return j.engineOptions.find(m=>String((m==null?void 0:m.value)||"").trim()===h)||null}),o=C(()=>{const h=Array.isArray(j.agentEngines)?j.agentEngines:[];return[...new Set(h.map(m=>String(m||"").trim()).filter(Boolean))]}),b=C(()=>j.engineOptions.filter(h=>String((h==null?void 0:h.value)||"").trim()!==String(j.engine||"").trim())),A=C(()=>!!String(j.cwd||"").trim()),u=C(()=>String(j.sessionId||"").trim()),_=C(()=>u.value.toLowerCase()),de=C(()=>j.sessionCandidates.filter(h=>h==null?void 0:h.matchedCwd)),V=C(()=>{const h=_.value,m=de.value;return h?m.filter(v=>[v==null?void 0:v.label,v==null?void 0:v.id,v==null?void 0:v.cwd].map(ee=>String(ee||"").toLowerCase()).some(ee=>ee.includes(h))).slice(0,10):m.slice(0,10)});function U(){j.busy||!j.canEditSessionId||!A.value||(p.value=!0)}function F(){p.value=!1,S.value=-1}function z(){const h=V.value;if(!h.length){S.value=-1;return}const m=h.findIndex(v=>v.id===u.value);S.value=m>=0?m:0}function H(){me(()=>{var h,m;(m=(h=D.value)==null?void 0:h.focus)==null||m.call(h)})}function G(){if(p.value){F();return}U(),H()}function X(){P("update:cwd","")}function R(h){if(!j.canEditEngine||j.busy)return;const m=String(h||"").trim(),v=o.value.includes(m)?o.value.filter(K=>K!==m):[...o.value,m];P("update:agentEngines",v)}function Q(){P("update:sessionId",""),F(),H()}function Z(h){var m;P("update:sessionId",((m=h==null?void 0:h.target)==null?void 0:m.value)||""),A.value&&U()}function ge(h){P("select-session-candidate",h),F(),H()}function ae(h){if(j.busy||!j.canEditSessionId||!A.value)return;const m=V.value;if(h.key==="ArrowDown"){if(h.preventDefault(),!p.value){U(),z();return}if(!m.length)return;S.value=S.value<0?0:Math.min(m.length-1,S.value+1);return}if(h.key==="ArrowUp"){if(h.preventDefault(),!p.value){U(),z();return}if(!m.length)return;S.value=S.value<0?m.length-1:Math.max(0,S.value-1);return}if(h.key==="Enter"&&p.value&&m.length&&S.value>=0){h.preventDefault(),ge(m[S.value]);return}h.key==="Escape"&&p.value&&(h.preventDefault(),F())}function Y(h){!p.value||!B.value||B.value.contains(h.target)||F()}return oe(V,()=>{z()}),oe(()=>j.canEditSessionId,h=>{(!h||!A.value)&&F()}),oe(A,h=>{h||F()}),Ot(()=>{document.addEventListener("pointerdown",Y)}),at(()=>{document.removeEventListener("pointerdown",Y)}),(h,m)=>(c(),g("div",Tn,[n("label",Ln,[n("span",null,d(i(y)("projectManager.projectTitleOptional")),1),n("input",{value:r.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:r.busy,onInput:m[0]||(m[0]=v=>P("update:title",v.target.value))},null,40,Bn)]),n("label",Fn,[n("span",null,d(i(y)("projectManager.workingDirectoryField")),1),n("div",Nn,[n("div",On,[n("input",{value:r.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:O(["tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",r.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:r.busy||!r.canEditCwd,onInput:m[1]||(m[1]=v=>P("update:cwd",v.target.value))},null,42,Un),r.cwd&&r.canEditCwd?(c(),g("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:r.busy,onClick:X},[I(i(pt),{class:"h-3.5 w-3.5"})],8,zn)):M("",!0)]),n("button",{type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:r.busy||!r.canEditCwd,onClick:m[2]||(m[2]=v=>P("open-directory-picker"))},[I(i(Xe),{class:"h-4 w-4"}),n("span",null,d(r.mobile?i(y)("projectManager.choose"):i(y)("projectManager.chooseDirectory")),1)],8,Hn)]),n("datalist",Kn,[(c(!0),g(he,null,Se(r.workspaceSuggestions,v=>(c(),g("option",{key:v,value:v},null,8,qn))),128))]),r.duplicateCwdMessage?(c(),g("p",Vn,d(r.duplicateCwdMessage),1)):r.cwdReadonlyMessage?(c(),g("p",Wn,d(r.cwdReadonlyMessage),1)):M("",!0)]),n("label",Qn,[n("span",null,d(i(y)("projectManager.engineField")),1),n("div",Gn,[I(Et,{"model-value":r.engine,options:r.engineOptions,disabled:r.busy||!r.canEditEngine,placeholder:i(y)("projectManager.selectEngine"),"empty-text":i(y)("projectManager.noEngines"),"get-option-value":v=>(v==null?void 0:v.value)||"","onUpdate:modelValue":m[3]||(m[3]=v=>P("update:engine",v))},{trigger:De(({disabled:v})=>{var K;return[n("div",Xn,[n("span",{class:O(["min-w-0 flex-1 truncate",v?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},d(((K=E.value)==null?void 0:K.label)||i(y)("projectManager.selectEngine")),3),E.value&&E.value.enabled===!1?(c(),g("span",Yn,d(i(y)("projectManager.comingSoon")),1)):M("",!0)])]}),option:De(({option:v,selected:K,select:ee})=>[n("button",{type:"button",class:O(["w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm transition",K?"theme-filter-active":"theme-filter-idle"]),disabled:(v==null?void 0:v.enabled)===!1,onClick:ee},[n("div",Zn,[n("span",es,d(v.label),1),(v==null?void 0:v.enabled)===!1?(c(),g("span",ts,d(i(y)("projectManager.comingSoon")),1)):M("",!0)])],10,Jn)]),_:1},8,["model-value","options","disabled","placeholder","empty-text","get-option-value"])]),r.engineReadonlyMessage?(c(),g("p",ns,d(r.engineReadonlyMessage),1)):M("",!0)]),n("div",ss,[n("span",null,d(i(y)("projectManager.collaborationAgents")),1),n("div",as,[(c(!0),g(he,null,Se(b.value,v=>(c(),g("button",{key:v.value,type:"button",class:O(["theme-list-row flex items-center justify-between gap-3 rounded-sm border border-solid px-3 py-2 text-left transition",o.value.includes(v.value)?"theme-list-item-active":"theme-list-item-hover"]),disabled:r.busy||!r.canEditEngine,onClick:K=>R(v.value)},[n("div",ls,[n("div",os,d(v.label),1),n("div",rs,d(o.value.includes(v.value)?i(y)("projectManager.agentEnabled"):i(y)("projectManager.agentDisabled")),1)]),o.value.includes(v.value)?(c(),re(i(st),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textPrimary)]"})):M("",!0)],10,is))),128))]),n("p",ds,d(i(y)("projectManager.collaborationAgentsHint")),1)]),n("label",us,[n("span",null,d(i(y)("projectManager.sessionId")),1),n("div",cs,[n("div",{ref_key:"sessionComboboxRef",ref:B,class:"relative min-w-0 flex-1"},[n("input",{ref_key:"sessionInputRef",ref:D,value:r.sessionId,type:"text",placeholder:"",class:"tool-input min-w-0 w-full pr-9 disabled:cursor-not-allowed disabled:opacity-80",disabled:r.busy||!r.canEditSessionId,onFocus:U,onInput:Z,onKeydown:ae},null,40,fs),r.canEditSessionId?(c(),g("button",{key:0,type:"button",class:"theme-muted-text absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm transition hover:bg-[var(--theme-appPanelHover)] hover:text-[var(--theme-textPrimary)]",disabled:r.busy||!A.value,onClick:G},[r.sessionCandidatesLoading?(c(),re(i(Ge),{key:0,class:"h-3.5 w-3.5 animate-spin"})):u.value?(c(),re(i(pt),{key:1,class:"h-3.5 w-3.5",onClick:nt(Q,["stop"])})):(c(),re(i(Kt),{key:2,class:O(["h-3.5 w-3.5 transition",p.value?"rotate-180":""])},null,8,["class"]))],8,ps)):M("",!0),r.canEditSessionId&&p.value?(c(),g("div",gs,[n("div",vs,[n("span",ms,d(i(y)("projectManager.sessionCandidates")),1),r.sessionCandidatesLoading?(c(),g("span",hs,d(i(y)("projectManager.sessionCandidatesLoading")),1)):M("",!0)]),V.value.length?(c(),g("div",ys,[(c(!0),g(he,null,Se(V.value,(v,K)=>(c(),g("button",{key:`${v.engine}:${v.id}`,type:"button",class:O(["theme-list-row mb-1 w-full px-2 py-1.5 text-left last:mb-0",K===S.value?"theme-list-item-active":"theme-list-item-hover"]),disabled:r.busy,onMousedown:m[4]||(m[4]=nt(()=>{},["prevent"])),onClick:ee=>ge(v)},[n("div",bs,[n("span",ws,d(v.label||v.id),1),n("span",Ss,d(v.updatedAtLabel||i(y)("projectManager.unknown")),1)])],42,xs))),128))])):(c(),g("div",ks,d(A.value?i(y)("projectManager.noSessionCandidates"):i(y)("projectManager.sessionCandidatesNeedDirectory")),1))])):M("",!0)],512),u.value?(c(),g("button",{key:0,type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:r.busy,onClick:m[5]||(m[5]=v=>P("copy-session-id"))},[r.sessionIdCopied?(c(),re(i(st),{key:0,class:"h-4 w-4"})):(c(),re(i(qt),{key:1,class:"h-4 w-4"})),n("span",null,d(r.sessionIdCopied?i(y)("projectManager.sessionIdCopied"):i(y)("projectManager.copySessionId")),1)],8,Cs)):M("",!0)]),r.sessionIdReadonlyMessage?(c(),g("p",_s,d(r.sessionIdReadonlyMessage),1)):(c(),g("p",$s,d(A.value?i(y)("projectManager.sessionIdHint"):i(y)("projectManager.sessionCandidatesNeedDirectory")),1))])]))}},Ms={class:"flex items-center justify-between gap-3"},js={class:"theme-heading text-sm font-medium"},Is={key:0,class:"theme-muted-text mt-1 text-xs"},Es=["disabled"],As=["onClick"],Ps={key:0,class:"theme-selection-indicator absolute inset-y-3 left-0 w-1 rounded-full"},Ds={class:"flex w-full flex-col gap-2 text-left"},Rs={class:"theme-heading min-w-0 text-sm font-medium"},Ts=["title"],Ls=["title"],Bs={class:"theme-muted-text flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] leading-5"},Fs={key:0,"aria-hidden":"true"},Ns={key:1},Os={class:"flex flex-wrap items-center gap-2 pt-1"},Us={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},mt={__name:"CodexSessionManagerList",props:{busy:{type:Boolean,default:!1},editingSessionId:{type:String,default:""},formatUpdatedAt:{type:Function,default:r=>r},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},hasSessions:{type:Boolean,default:!1},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1},mode:{type:String,default:"edit"},mobile:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]}},emits:["create","select"],setup(r,{emit:q}){const j=r,P=q,{t:y}=Ve();function B(S){return j.mode==="edit"&&j.editingSessionId===S.id?"theme-card-selected":j.isSessionRunning(S.id)?"theme-card-warning":"theme-card-idle-strong"}function D(S){return j.isCurrentSession(S.id)?y("projectManager.current"):y("projectManager.regular")}function p(S){return j.isCurrentSession(S.id)?"theme-status-info":"theme-status-neutral"}return(S,E)=>(c(),g("div",{class:O(r.mobile?"flex h-full min-h-0 flex-col":"")},[n("div",Ms,[n("div",null,[n("div",js,d(i(y)("projectManager.projectList")),1),r.hasSessions?M("",!0):(c(),g("p",Is,d(i(y)("projectManager.noProjects")),1))]),n("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:r.busy,onClick:E[0]||(E[0]=o=>P("create"))},[I(i(Vt),{class:"h-4 w-4"}),n("span",null,d(i(y)("projectManager.create")),1)],8,Es)]),n("div",{class:O(["mt-4 space-y-2",r.mobile?"min-h-0 flex-1 overflow-y-auto":"max-h-52 overflow-y-auto pr-1 sm:max-h-64 lg:max-h-[calc(88vh-11rem)]"])},[(c(!0),g(he,null,Se(r.sessions,o=>{var b;return c(),g("article",{key:o.id,class:O(["relative cursor-pointer rounded-sm border p-3 transition",B(o)]),onClick:A=>P("select",o.id)},[r.mode==="edit"&&r.editingSessionId===o.id?(c(),g("span",Ps)):M("",!0),n("div",Ds,[n("div",Rs,[n("span",{class:"block truncate",title:o.title||i(y)("projectManager.untitledProject")},d(o.title||i(y)("projectManager.untitledProject")),9,Ts)]),n("div",{class:"theme-muted-text break-all font-mono text-[11px] leading-5",title:o.cwd},d(o.cwd),9,Ls),n("div",Bs,[n("span",null,d(((b=o==null?void 0:o.agentBindings)==null?void 0:b.length)>1?i(y)("projectManager.agentCount",{count:o.agentBindings.length}):i(tt)(o.engine)),1),r.mobile?M("",!0):(c(),g("span",Fs,"·")),r.mobile?M("",!0):(c(),g("span",Ns,d(r.formatUpdatedAt(o.updatedAt)),1))]),n("div",Os,[n("span",{class:O(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",p(o)])},d(D(o)),3),n("span",{class:O(["inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",r.getRuntimeStatusClass(o.id)])},[r.isSessionRunning(o.id)?(c(),g("span",Us)):M("",!0),yt(" "+d(r.getRuntimeStatusLabel(o.id)),1)],2),n("span",{class:O(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",r.getThreadStatusClass(o)])},d(r.getThreadStatusLabel(o)),3)])])],10,As)}),128))],2)],2))}},zs={class:"space-y-3"},Hs={class:"dashed-panel px-3 py-3"},Ks={class:"theme-muted-text text-[11px]"},qs={class:"mt-2 flex flex-wrap gap-2"},Vs={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},Ws={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},Qs={class:"dashed-panel px-3 py-3"},Gs={class:"theme-muted-text text-[11px]"},Xs={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},Ys={key:0,class:"mt-2 flex flex-wrap gap-1.5"},Js={class:"dashed-panel px-3 py-3"},Zs={class:"theme-muted-text text-[11px]"},ea={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},ta={class:"dashed-panel px-3 py-3"},na={class:"theme-muted-text text-[11px]"},sa={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},aa={class:"dashed-panel px-3 py-3"},ia={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},la={class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"},oa={__name:"CodexSessionManagerStatus",props:{activeSession:{type:Object,default:null},formatUpdatedAt:{type:Function,default:r=>r},getRuntimeStatusClass:{type:Function,default:()=>""},getRuntimeStatusLabel:{type:Function,default:()=>""},getThreadStatusClass:{type:Function,default:()=>""},getThreadStatusLabel:{type:Function,default:()=>""},isCurrentSession:{type:Function,default:()=>!1},isSessionRunning:{type:Function,default:()=>!1}},setup(r){const{t:q}=Ve();return(j,P)=>{var y,B,D,p,S,E,o,b,A;return c(),g("div",zs,[n("div",Hs,[n("div",Ks,d(i(q)("projectManager.runtimeStatus")),1),n("div",qs,[n("span",{class:O(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",r.getRuntimeStatusClass((y=r.activeSession)==null?void 0:y.id)])},[r.isSessionRunning((B=r.activeSession)==null?void 0:B.id)?(c(),g("span",Vs)):M("",!0),yt(" "+d(r.getRuntimeStatusLabel((D=r.activeSession)==null?void 0:D.id)),1)],2),n("span",{class:O(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",r.getThreadStatusClass(r.activeSession)])},d(r.getThreadStatusLabel(r.activeSession)),3),(p=r.activeSession)!=null&&p.id&&r.isCurrentSession(r.activeSession.id)?(c(),g("span",Ws,d(i(q)("projectManager.currentProject")),1)):M("",!0)])]),n("div",Qs,[n("div",Gs,d(i(q)("projectManager.engine")),1),n("div",Xs,d(i(tt)((S=r.activeSession)==null?void 0:S.engine)),1),((o=(E=r.activeSession)==null?void 0:E.agentBindings)==null?void 0:o.length)>1?(c(),g("div",Ys,[(c(!0),g(he,null,Se(r.activeSession.agentBindings,u=>(c(),g("span",{key:u.engine,class:"theme-status-neutral inline-flex items-center rounded-sm border border-solid px-1.5 py-0.5 text-[10px]"},d(i(tt)(u.engine)),1))),128))])):M("",!0)]),n("div",Js,[n("div",Zs,d(i(q)("projectManager.workingDirectory")),1),n("div",ea,d(((b=r.activeSession)==null?void 0:b.cwd)||i(q)("projectManager.notSet")),1)]),n("div",ta,[n("div",na,d(i(q)("projectManager.updatedAt")),1),n("div",sa,d(r.formatUpdatedAt((A=r.activeSession)==null?void 0:A.updatedAt)),1)]),n("div",aa,[n("div",ia,[I(i(Wt),{class:"h-3.5 w-3.5"}),n("span",null,d(i(q)("projectManager.note")),1)]),n("p",la,d(i(q)("projectManager.noteDescription")),1)])])}}},ra={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},da={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},ua={class:"theme-divider theme-muted-panel border-b px-3 py-3 sm:px-4 sm:py-4 lg:border-b-0 lg:border-r"},ca={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},fa={class:"flex flex-wrap items-start justify-between gap-3"},pa={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ga={class:"mt-5"},va={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},ma={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4 sm:flex-row sm:items-center sm:justify-between"},ha={class:"flex flex-wrap items-center gap-2"},ya=["disabled"],xa=["disabled"],ba=["disabled"],wa={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Sa=["disabled"],ka=["disabled"],Ca=["disabled"],_a={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},$a={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ma={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},ja={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ia={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Ea=["disabled"],Aa={class:"min-w-0 flex-1"},Pa={class:"theme-heading truncate text-sm font-medium"},Da={key:0,class:"theme-muted-text mt-1 truncate text-xs"},Ra={class:"theme-divider border-b px-4 py-3"},Ta={class:"grid grid-cols-2 gap-2"},La=["disabled"],Ba={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},Fa={key:0},Na={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Oa={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},Ua=["disabled"],za=["disabled"],Ha=["disabled"],Ka=["disabled"],qa=3e3,Za={__name:"CodexSessionManagerDialog",props:{open:{type:Boolean,default:!1},sessions:{type:Array,default:()=>[]},workspaces:{type:Array,default:()=>[]},selectedSessionId:{type:String,default:""},selectionLocked:{type:Boolean,default:!1},selectionLockReason:{type:String,default:""},loading:{type:Boolean,default:!1},sending:{type:Boolean,default:!1},onRefresh:{type:Function,default:null},onCreate:{type:Function,default:null},onUpdate:{type:Function,default:null},onDelete:{type:Function,default:null},onReset:{type:Function,default:null}},emits:["close","project-created","select-session","open-source-browser"],setup(r,{expose:q,emit:j}){const P=new Map;function y(t="",a=""){const x=qe(t),k=et(a);return!x||!k?"":`${x}
2
+ ${k}`}function B(t=""){if(!t)return null;const a=P.get(t);return a?a.expiresAt<=Date.now()?(P.delete(t),null):Array.isArray(a.items)?a.items:[]:null}function D(t="",a=[]){t&&P.set(t,{expiresAt:Date.now()+qa,items:Array.isArray(a)?a:[]})}const p=r,S=j,{locale:E,t:o}=Ve(),b=$("edit"),A=$(""),u=Ut({title:"",engine:"codex",agentEngines:[],cwd:"",sessionId:""}),_=$(""),de=$(!1),V=$(!1),U=$(!1),F=$(!1),z=$(!1),H=$(!1),G=$(!1),X=$(!1),{matches:R}=At("(max-width: 767px)"),Q=$("list"),Z=$("basic"),ge=$(ct()),ae=$([]),Y=$(!1);let h=null,m=null,v=null,K=0;const ee=C(()=>Qe(p.sessions)),w=C(()=>p.sessions.find(t=>t.id===A.value)||null),ke=C(()=>p.sessions.length>0),Ye=C(()=>p.sessions.find(t=>t.id===p.selectedSessionId)||null),ue=C(()=>!!(w.value&&te(w.value.id))),Ce=C(()=>{var t;return!((t=w.value)!=null&&t.started)}),_e=C(()=>{var t;return!((t=w.value)!=null&&t.started)}),ce=C(()=>{var t;return!((t=w.value)!=null&&t.started)}),T=C(()=>p.loading||de.value||V.value||U.value||F.value),Re=C(()=>String(u.sessionId||"").trim()),$e=C(()=>{var x,k;const t=new Set,a=[];return[u.cwd,(x=w.value)==null?void 0:x.cwd,(k=Ye.value)==null?void 0:k.cwd,...p.workspaces,...p.sessions.map(N=>N.cwd)].forEach(N=>{const L=String(N||"").trim();!L||t.has(L)||(t.add(L),a.push(L))}),a.slice(0,12)}),fe=C(()=>ge.value),ye=C(()=>ae.value.map(t=>({...t,updatedAtLabel:t.updatedAt?Ee(t.updatedAt):""}))),xe=C(()=>{const t=et(u.cwd);return t?p.sessions.filter(a=>{var x;return a.id===((x=w.value)==null?void 0:x.id)?!1:et(a.cwd)===t}):[]}),J=C(()=>{if(!xe.value.length)return"";const t=xe.value.slice(0,3).map(a=>{const x=a.title||o("projectManager.untitledProject");return E.value==="en-US"?`"${x}"`:`「${x}」`}).join(E.value==="en-US"?", ":"、");return o("projectManager.duplicateDirectory",{labels:t,count:xe.value.length})}),pe=C(()=>b.value!=="edit"||Ce.value?"":o("projectManager.cwdReadonly")),Te=C(()=>b.value!=="edit"||!w.value||_e.value?"":o("projectManager.engineReadonly")),be=C(()=>b.value!=="edit"||!w.value||ce.value?"":o("projectManager.sessionIdReadonly")),We=C(()=>b.value==="create"?de.value?o("projectManager.creatingProject"):o("projectManager.createProject"):V.value?o("projectManager.savingChanges"):o("projectManager.saveChanges")),Je=C(()=>{var t;return b.value==="create"?o("projectManager.newProject"):((t=w.value)==null?void 0:t.title)||o("projectManager.untitledProject")});function Me(t=""){const a=Date.parse(String(t||""));return Number.isFinite(a)?a:0}function te(t){var a;return!!((a=p.sessions.find(x=>x.id===t))!=null&&a.running)}function ve(t){return!!t&&t===p.selectedSessionId}function Qe(t=[]){return[...t].sort((a,x)=>{const k=Number(te(x.id))-Number(te(a.id));if(k)return k;const N=Number(ve(x.id))-Number(ve(a.id));if(N)return N;const L=Me(x.updatedAt)-Me(a.updatedAt);return L||Tt(String(a.title||a.cwd||a.id),String(x.title||x.cwd||x.id))})}function Le(t){return te(t)?o("projectManager.running"):o("projectManager.idle")}function je(t){return te(t)?"theme-status-warning":"theme-status-success"}function Be(t){return t!=null&&t.started?o("projectManager.threadBound"):o("projectManager.notStarted")}function Ie(t){return t!=null&&t.started?"theme-status-success":"theme-status-neutral"}function Ee(t=""){if(!t)return o("projectManager.unknown");const a=new Date(t);return Number.isNaN(a.getTime())?t:Rt(a.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Fe(t){u.title=String((t==null?void 0:t.title)||""),u.engine=qe(t==null?void 0:t.engine),u.agentEngines=(Array.isArray(t==null?void 0:t.agentBindings)?t.agentBindings:[]).map(a=>qe(a==null?void 0:a.engine)).filter(a=>a&&a!==u.engine),u.cwd=String((t==null?void 0:t.cwd)||""),u.sessionId=String((t==null?void 0:t.sessionId)||(t==null?void 0:t.engineSessionId)||(t==null?void 0:t.engineThreadId)||(t==null?void 0:t.codexThreadId)||"").trim()}function Ae(){b.value="create",A.value="",_.value="",u.title="",u.engine="codex",u.agentEngines=[],u.cwd="",u.sessionId=""}function ne(t){const a=p.sessions.find(x=>x.id===t);a&&(b.value="edit",A.value=a.id,_.value="",Fe(a))}function Pe(){var t;return p.selectedSessionId&&p.sessions.some(a=>a.id===p.selectedSessionId)?p.selectedSessionId:((t=ee.value[0])==null?void 0:t.id)||""}function Ne(t="basic"){Q.value="detail",Z.value=t}function Oe(){Q.value="list",Z.value="basic"}function Ue(){Ae(),R.value&&Ne("basic")}function ze(t){T.value||(ne(t),R.value&&Ne("basic"))}function e(t){u.cwd=String(t||"").trim()}async function l(){var a,x;const t=((a=w.value)==null?void 0:a.id)||Pe();return!t||((!w.value||w.value.id!==t)&&(ne(t),await me()),!((x=w.value)!=null&&x.cwd))?!1:(R.value&&Ne("basic"),S("open-source-browser",w.value),S("close"),!0)}function s(){return z.value?(z.value=!1,!0):H.value?(H.value=!1,!0):G.value?(G.value=!1,!0):p.open?(S("close"),!0):!1}function f(t){u.title=String(t||"")}function W(t){u.engine=qe(t),u.agentEngines=u.agentEngines.filter(a=>a!==u.engine)}function se(t){u.agentEngines=[...new Set((Array.isArray(t)?t:[]).map(a=>qe(a)).filter(a=>a&&a!==u.engine))]}function we(t){u.cwd=String(t||"")}function ie(t){u.sessionId=String(t||"")}function le(t){u.sessionId=String((t==null?void 0:t.id)||"").trim()}function He(){_.value="",z.value=!1,H.value=!1,X.value=!1,Z.value="basic",Q.value=R.value?"list":"detail";const t=Pe();if(t){ne(t);return}Ae()}async function xt(){if(!(T.value||typeof p.onRefresh!="function")){_.value="";try{await Promise.all([p.onRefresh(),it()])}catch(t){_.value=t.message}}}async function it(){try{ge.value=await Pt()}catch{ge.value=ct()}}function Ze(){m&&(clearTimeout(m),m=null)}function Ke(){v&&(v.abort(),v=null)}async function bt(){const t=String(u.cwd||"").trim();if(!p.open||!ce.value||!t){ae.value=[],Y.value=!1,Ke();return}const a=++K;Ke();const x=y(u.engine,t),k=B(x);if(k){ae.value=k,Y.value=!1;return}v=new AbortController,Y.value=!0;try{const N=await Dt({engine:u.engine,cwd:t,limit:50,signal:v.signal});if(a!==K)return;const L=Array.isArray(N==null?void 0:N.items)?N.items:[];ae.value=L,D(x,L)}catch(N){if((N==null?void 0:N.name)==="AbortError")return;a===K&&(ae.value=[])}finally{a===K&&(Y.value=!1,v=null)}}function lt(t=250){if(Ze(),!p.open||!ce.value||!String(u.cwd||"").trim()){ae.value=[],Y.value=!1,Ke();return}m=setTimeout(()=>{m=null,bt().catch(()=>{})},t)}async function wt(t){var x;if((x=navigator.clipboard)!=null&&x.writeText&&window.isSecureContext){await navigator.clipboard.writeText(t);return}const a=document.createElement("textarea");a.value=t,a.setAttribute("readonly","true"),a.style.position="fixed",a.style.opacity="0",a.style.pointerEvents="none",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}async function ot(){const t=Re.value;if(t)try{await wt(t),X.value=!0,h&&clearTimeout(h),h=setTimeout(()=>{X.value=!1,h=null},1800)}catch(a){_.value=(a==null?void 0:a.message)||o("projectManager.copySessionIdFailed")}}async function rt(){if(!T.value){_.value="";try{const t=St();if(!t)return;await kt(t)}catch(t){_.value=t.message}}}function St(){if(b.value==="create"){const a=String(u.cwd||"").trim();return a?{type:"create",cwd:a,payload:{title:u.title,engine:u.engine,agentEngines:[u.engine,...u.agentEngines],cwd:a,sessionId:String(u.sessionId||"").trim()}}:(_.value=o("projectManager.directoryRequired"),null)}if(!w.value)return _.value=o("projectManager.projectMissing"),null;const t={title:u.title,engine:u.engine,agentEngines:[u.engine,...u.agentEngines]};return Ce.value&&(t.cwd=u.cwd),ce.value&&(t.sessionId=String(u.sessionId||"").trim()),{type:"update",sessionId:w.value.id,payload:t}}async function kt(t){var a,x;if(t.type==="create"){de.value=!0;try{const k=await((a=p.onCreate)==null?void 0:a.call(p,t.payload));k!=null&&k.id&&(ne(k.id),S("select-session",k.id),await me(),S("project-created",k),S("close"));return}finally{de.value=!1}}V.value=!0;try{const k=await((x=p.onUpdate)==null?void 0:x.call(p,t.sessionId,t.payload));k!=null&&k.id&&ne(k.id)}finally{V.value=!1}}async function Ct(){var a,x;if(!w.value||U.value)return;const t=w.value.id;_.value="",U.value=!0;try{const k=await((a=p.onDelete)==null?void 0:a.call(p,t));z.value=!1;const N=p.sessions.filter($t=>$t.id!==t),L=(k==null?void 0:k.selectedSessionId)||((x=Qe(N)[0])==null?void 0:x.id)||"";S("select-session",L),L?(ne(L),R.value&&Oe()):(Ae(),R.value&&Oe())}catch(k){_.value=k.message}finally{U.value=!1}}async function _t(){var a;if(!w.value||F.value)return;const t=w.value.id;_.value="",F.value=!0;try{const x=await((a=p.onReset)==null?void 0:a.call(p,t));H.value=!1;const k=(x==null?void 0:x.session)||p.sessions.find(N=>N.id===t)||null;k!=null&&k.id&&ne(k.id)}catch(x){_.value=x.message}finally{F.value=!1}}return oe(()=>p.open,t=>{if(t){He(),typeof p.onRefresh=="function"?xt().catch(()=>{}):it().catch(()=>{});return}G.value=!1,z.value=!1,H.value=!1,X.value=!1,_.value="",Ze(),Ke(),ae.value=[],Y.value=!1},{immediate:!0}),oe(R,t=>{t||(Q.value="detail")},{immediate:!0}),oe(()=>p.sessions,()=>{if(!p.open)return;if(b.value==="create"){if(!!(String(u.title||"").trim()||String(u.cwd||"").trim())||!!String(u.sessionId||"").trim())return;const x=Pe();x&&ne(x);return}if(w.value){Fe(w.value);return}const t=Pe();if(t){ne(t);return}Ae()}),oe(()=>[p.open,b.value,u.engine,u.cwd,ce.value].join(`
3
+ `),()=>{lt(250)},{immediate:!0}),oe(()=>{var t;return((t=w.value)==null?void 0:t.id)||""},()=>{lt(0)}),at(()=>{h&&(clearTimeout(h),h=null),Ze(),Ke()}),q({closeTopDialog:s}),(t,a)=>(c(),g(he,null,[I(ft,{open:H.value,title:i(o)("projectManager.confirmResetTitle"),description:w.value?i(o)("projectManager.confirmResetDescription",{title:w.value.title||i(o)("projectManager.untitledProject")}):"","confirm-text":i(o)("projectManager.confirmReset"),"cancel-text":i(o)("projectManager.keep"),loading:F.value,onCancel:a[0]||(a[0]=x=>H.value=!1),onConfirm:_t},null,8,["open","title","description","confirm-text","cancel-text","loading"]),I(ft,{open:z.value,title:i(o)("projectManager.confirmDeleteTitle"),description:w.value?i(o)("projectManager.confirmDeleteDescription",{title:w.value.title||i(o)("projectManager.untitledProject")}):"","confirm-text":i(o)("projectManager.confirmDelete"),"cancel-text":i(o)("projectManager.keep"),loading:U.value,danger:"",onCancel:a[1]||(a[1]=x=>z.value=!1),onConfirm:Ct},null,8,["open","title","description","confirm-text","cancel-text","loading"]),I(Rn,{open:G.value,"initial-path":u.cwd,suggestions:$e.value,onClose:a[2]||(a[2]=x=>G.value=!1),onSelect:e},null,8,["open","initial-path","suggestions"]),I(ht,{open:r.open,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-5xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 overflow-hidden","close-disabled":T.value,"close-on-backdrop":!T.value,"close-on-escape":!T.value,onClose:a[12]||(a[12]=x=>S("close"))},{title:De(()=>[n("div",ra,[I(i(Zt),{class:"h-4 w-4"}),n("span",null,d(i(o)("projectManager.managingTitle")),1)])]),default:De(()=>{var x,k,N;return[i(R)?(c(),g("div",_a,[Q.value==="list"?(c(),g("div",$a,[n("div",Ma,[I(mt,{mobile:"",busy:T.value,"editing-session-id":A.value,"format-updated-at":Ee,"get-runtime-status-class":je,"get-runtime-status-label":Le,"get-thread-status-class":Ie,"get-thread-status-label":Be,"has-sessions":ke.value,"is-current-session":ve,"is-session-running":te,mode:b.value,sessions:ee.value,onCreate:Ue,onSelect:ze},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])])])):(c(),g("div",ja,[n("div",Ia,[n("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",disabled:T.value,onClick:Oe},[I(i(Jt),{class:"h-4 w-4"}),n("span",null,d(i(o)("projectManager.projectList")),1)],8,Ea),n("div",Aa,[n("div",Pa,d(Je.value),1),b.value==="edit"&&((k=w.value)!=null&&k.cwd)?(c(),g("p",Da,d(w.value.cwd),1)):M("",!0)])]),n("div",Ra,[n("div",Ta,[n("button",{type:"button",class:O(["tool-button px-3 py-2 text-sm",Z.value==="basic"?"tool-button-accent-subtle":""]),onClick:a[7]||(a[7]=L=>Z.value="basic")},d(i(o)("projectManager.basicInfo")),3),n("button",{type:"button",class:O(["tool-button px-3 py-2 text-sm",Z.value==="status"?"tool-button-accent-subtle":""]),disabled:b.value==="create",onClick:a[8]||(a[8]=L=>Z.value="status")},d(i(o)("projectManager.status")),11,La)])]),n("div",Ba,[Z.value==="basic"?(c(),g("div",Fa,[I(vt,{mobile:"",busy:T.value,"can-edit-engine":b.value!=="edit"||_e.value,"can-edit-cwd":b.value!=="edit"||Ce.value,"can-edit-session-id":b.value!=="edit"||ce.value,cwd:u.cwd,"cwd-readonly-message":pe.value,"duplicate-cwd-message":J.value,engine:u.engine,"agent-engines":u.agentEngines,"engine-options":fe.value,"engine-readonly-message":Te.value,"session-candidates":ye.value,"session-candidates-loading":Y.value,"session-id":u.sessionId,"session-id-copied":X.value,"session-id-readonly-message":be.value,title:u.title,"workspace-suggestions":$e.value,onCopySessionId:ot,onOpenDirectoryPicker:a[9]||(a[9]=L=>G.value=!0),onSelectSessionCandidate:le,"onUpdate:cwd":we,"onUpdate:engine":W,"onUpdate:agentEngines":se,"onUpdate:sessionId":ie,"onUpdate:title":f},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","agent-engines","engine-options","engine-readonly-message","session-candidates","session-candidates-loading","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"]),_.value?(c(),g("p",Na,[I(i(gt),{class:"h-4 w-4"}),n("span",null,d(_.value),1)])):M("",!0),n("div",Oa,[n("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-sm",disabled:T.value,onClick:rt},d(We.value),9,Ua),b.value==="edit"&&w.value?(c(),g("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:T.value||!((N=w.value)!=null&&N.cwd),onClick:l},d(i(o)("projectManager.viewSource")),9,za)):M("",!0),b.value==="edit"&&w.value?(c(),g("button",{key:1,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:T.value||ue.value,onClick:a[10]||(a[10]=L=>H.value=!0)},d(F.value?i(o)("projectManager.resettingSession"):i(o)("projectManager.newSession")),9,Ha)):M("",!0),b.value==="edit"&&w.value?(c(),g("button",{key:2,type:"button",class:"tool-button tool-button-danger-subtle w-full px-3 py-2 text-sm",disabled:T.value||ue.value,onClick:a[11]||(a[11]=L=>z.value=!0)},d(U.value?i(o)("projectManager.deletingProject"):i(o)("projectManager.deleteProject")),9,Ka)):M("",!0)])])):(c(),re(oa,{key:1,"active-session":w.value,"format-updated-at":Ee,"get-runtime-status-class":je,"get-runtime-status-label":Le,"get-thread-status-class":Ie,"get-thread-status-label":Be,"is-current-session":ve,"is-session-running":te},null,8,["active-session"]))])]))])):(c(),g("div",da,[n("aside",ua,[I(mt,{busy:T.value,"editing-session-id":A.value,"format-updated-at":Ee,"get-runtime-status-class":je,"get-runtime-status-label":Le,"get-thread-status-class":Ie,"get-thread-status-label":Be,"has-sessions":ke.value,"is-current-session":ve,"is-session-running":te,mode:b.value,sessions:ee.value,onCreate:Ue,onSelect:ze},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])]),n("div",ca,[n("div",fa,[n("div",null,[n("div",pa,[I(i(Qt),{class:"h-4 w-4"}),n("span",null,d(b.value==="create"?i(o)("projectManager.createTitle"):i(o)("projectManager.editTitle")),1)])])]),n("div",ga,[I(vt,{busy:T.value,"can-edit-engine":b.value!=="edit"||_e.value,"can-edit-cwd":b.value!=="edit"||Ce.value,"can-edit-session-id":b.value!=="edit"||ce.value,cwd:u.cwd,"cwd-readonly-message":pe.value,"duplicate-cwd-message":J.value,engine:u.engine,"agent-engines":u.agentEngines,"engine-options":fe.value,"engine-readonly-message":Te.value,"session-candidates":ye.value,"session-candidates-loading":Y.value,"session-id":u.sessionId,"session-id-copied":X.value,"session-id-readonly-message":be.value,title:u.title,"workspace-suggestions":$e.value,onCopySessionId:ot,onOpenDirectoryPicker:a[3]||(a[3]=L=>G.value=!0),onSelectSessionCandidate:le,"onUpdate:cwd":we,"onUpdate:engine":W,"onUpdate:agentEngines":se,"onUpdate:sessionId":ie,"onUpdate:title":f},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","agent-engines","engine-options","engine-readonly-message","session-candidates","session-candidates-loading","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"])]),_.value?(c(),g("p",va,[I(i(gt),{class:"h-4 w-4"}),n("span",null,d(_.value),1)])):M("",!0),n("div",ma,[n("div",ha,[b.value==="edit"&&w.value?(c(),g("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||!((x=w.value)!=null&&x.cwd),onClick:l},[I(i(Gt),{class:"h-4 w-4"}),n("span",null,d(i(o)("projectManager.viewSource")),1)],8,ya)):M("",!0),b.value==="edit"&&w.value?(c(),g("button",{key:1,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||ue.value,onClick:a[4]||(a[4]=L=>H.value=!0)},[I(i(Xt),{class:"h-4 w-4"}),n("span",null,d(F.value?i(o)("projectManager.resettingSession"):i(o)("projectManager.newSession")),1)],8,xa)):M("",!0),b.value==="edit"&&w.value?(c(),g("button",{key:2,type:"button",class:"tool-button tool-button-danger-subtle inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:T.value||ue.value,onClick:a[5]||(a[5]=L=>z.value=!0)},[I(i(Yt),{class:"h-4 w-4"}),n("span",null,d(U.value?i(o)("projectManager.deletingProject"):i(o)("projectManager.deleteProject")),1)],8,ba)):M("",!0)]),n("div",wa,[n("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:a[6]||(a[6]=L=>S("close"))},d(i(o)("projectManager.close")),9,Sa),b.value==="create"&&ke.value?(c(),g("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:He},d(i(o)("projectManager.backToList")),9,ka)):M("",!0),n("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-xs sm:w-auto",disabled:T.value,onClick:rt},d(We.value),9,Ca)])])])]))]}),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"])],64))}};export{Za as default};
@@ -0,0 +1,5 @@
1
+ import{g as ut,t as U,f as tt,u as ke,a as st,b as ct}from"./index-7F-RPTS_.js";import{u as ft,g as He,b as ht,l as mt,_ as vt,a as gt,c as pt,r as xt,e as yt,D as Be,d as bt,i as wt,f as kt,h as St,j as Rt}from"./WorkbenchView-BqHMDZ1g.js";import{w as te,c as z,b as Q,n as at,aD as c,aE as h,aF as a,aR as he,aS as Ie,aL as Z,aQ as o,aG as V,u as t,aW as Ue,aX as $t,aN as O,aI as ve,aT as Ft,ak as _t,aJ as we,f as Pt,a$ as We}from"./vendor-misc-u-M8sNMf.js";import{c as Ct,D as Te,f as Ke,M as Lt,V as Tt,p as It,k as Ge,C as Je,R as Qe,b as Dt,i as Mt,h as nt,F as Xe,z as Ye}from"./vendor-ui-BglsaDbv.js";import"./vendor-router-Dn8q3tJM.js";import"./vendor-markdown-9aQhqbjm.js";import"./vendor-tiptap-rwYdQb1L.js";function oe(e,r,i=""){const w=r==="run"?"run":r==="task"?"task":"workspace";return[String(e||"").trim(),w,String(i||"").trim()].join("::")}function Ne(e="",r=""){return`${String(e||"").trim()}::${String(r||"").trim()}`}function jt(e=""){return`${String(e||"").trim()}::`}function it(e){if(!e||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function ye(e,r){const i=e.get(r);return i?(e.delete(r),e.set(r,i),it(i)):null}function be(e,r,i,w=0){for(e.delete(r),e.set(r,it(i));w>0&&e.size>w;){const b=e.keys().next().value;if(typeof b>"u")break;e.delete(b)}}function fe(e=""){const r=String(e||"").trim().toUpperCase();return r==="A"||r==="D"?r:"M"}function At(e=""){const r=String(e||"");if(!r)return[];const i=r.split(`
2
+ `),w=[];let b=0,T=0;return i.forEach((v,u)=>{const I=v.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(I){b=Number(I[1]),T=Number(I[2]),w.push({id:`hunk-${u}`,kind:"hunk",oldNumber:"",newNumber:"",content:v});return}if(v.startsWith("+")&&!v.startsWith("+++")){w.push({id:`line-${u}`,kind:"add",oldNumber:"",newNumber:T,content:v}),T+=1;return}if(v.startsWith("-")&&!v.startsWith("---")){w.push({id:`line-${u}`,kind:"delete",oldNumber:b,newNumber:"",content:v}),b+=1;return}if(v.startsWith(" ")){w.push({id:`line-${u}`,kind:"context",oldNumber:b,newNumber:T,content:v}),b+=1,T+=1;return}w.push({id:`line-${u}`,kind:"meta",oldNumber:"",newNumber:"",content:v})}),w}function Ht(e=""){const r=String(e||"").trim();if(!r)return"";const i=r.match(/^当前分支已从 (.+) 切换到 (.+)$/);return i?U("diffReview.warningBranchChanged",{from:i[1],to:i[2]}):r==="当前 HEAD 已不在基线 commit 的后续历史中,仓库可能经历了 reset、rebase 或切分支"?U("diffReview.warningHeadDetachedFromBaseline"):r}function De(e=""){const r=String(e||"").trim();if(!r)return"";const w=new Map([["二进制文件暂不支持在线 diff 预览。","diffReview.binaryPreviewUnavailable"],["文件内容较大,暂不展示具体 diff。","diffReview.fileTooLarge"],["diff 内容较长,暂不在页面内完整展示。","diffReview.diffTooLong"],["diff 内容较长,当前仅展示摘要预览。","diffReview.diffPreviewOnly"],["当前工作目录不是 Git 仓库,暂不支持代码变更审查。","diffReview.notGitRepo"],["任务不存在。","diffReview.taskNotFound"],["请选择一轮执行后再查看本轮代码变更。","diffReview.runRequired"],["没有找到对应的执行记录。","diffReview.runNotFound"],["这轮执行还没有建立代码变更基线,暂时无法查看本轮 diff。","diffReview.runBaselineMissing"],["当前任务还没有建立代码变更基线,请先让 Codex 执行一轮。","diffReview.taskBaselineMissing"],["这轮执行缺少结束快照,暂时无法准确还原本轮代码变更。","diffReview.runSnapshotMissing"],["原工作目录已不是有效的 Git 仓库,暂时无法读取代码变更。","diffReview.originalRepoInvalid"],["基线对应的 commit 已不存在,仓库可能被 reset、rebase 或切换到无关历史,暂时无法准确读取该范围的代码变更。","diffReview.baselineCommitMissing"]]).get(r);return w?U(w):/^git diff 计算超时(>\d+ms)[。.]?$/.test(r)||r==="该文件 diff 计算超时,暂不在线展示详细内容。"?U("diffReview.fileDiffTimedOut"):r}function Ve(e=null){return!e||typeof e!="object"?e:{...e,reason:De(e.reason),warnings:Array.isArray(e.warnings)?e.warnings.map(r=>Ht(r)).filter(Boolean):[],files:Array.isArray(e.files)?e.files.map(r=>({...r,message:De(r==null?void 0:r.message)})):[]}}function Bt(e=[],r="",i=0){const w=Math.max(0,Number(i)||0);if(!w)return[];const b=String(r||"").trim(),T=Array.isArray(e)?e:[],v=[],u=new Set;return b&&T.find(R=>String((R==null?void 0:R.path)||"").trim()===b)&&(v.push(b),u.add(b)),T.forEach(I=>{const R=String((I==null?void 0:I.path)||"").trim();!R||u.has(R)||v.length>=w||(v.push(R),u.add(R))}),v}function Nt(e){const r=Q("workspace"),i=Q(""),w=Q(""),b=Q("all"),T=Q(""),v=Q([]),u=Q(null),I=Q(!1),R=Q(!1),M=Q(""),N=Q(!1),G=Q(null),j=Q(0),E=new Map,se=ft();let _=0,$=0,f="",C="",p="",g=-1;const X=new Map,J=new Map,q=new Map,Y=new Map,W=12e3,re=3,de=z(()=>v.value.filter(s=>s.completed)),n=z(()=>{var l;const s={all:0,A:0,M:0,D:0};return(((l=u.value)==null?void 0:l.files)||[]).forEach(m=>{const y=fe(m==null?void 0:m.status);s.all+=1,s[y]+=1}),s}),d=z(()=>{var m;const s=((m=u.value)==null?void 0:m.files)||[],l=String(T.value||"").trim().toLowerCase();return s.filter(y=>b.value!=="all"&&fe(y==null?void 0:y.status)!==b.value?!1:l?String((y==null?void 0:y.path)||"").toLowerCase().includes(l):!0)}),k=z(()=>{const s=d.value;return s.find(l=>l.path===w.value)||s[0]||null}),A=z(()=>{var s;return At(((s=k.value)==null?void 0:s.patch)||"")}),P=z(()=>A.value.map((s,l)=>({...s,index:l})).filter(s=>s.kind==="hunk")),ae=z(()=>Bt(d.value,w.value,re)),x=z(()=>{var s,l;return R.value&&!((l=(s=u.value)==null?void 0:s.summary)!=null&&l.statsComplete)}),H=z(()=>{var m;const s=((m=u.value)==null?void 0:m.baseline)||null;if(!(s!=null&&s.createdAt)&&!(s!=null&&s.headShort))return"";const l=[];return s.createdAt&&l.push(U("diffReview.baselineTime",{value:tt(s.createdAt)})),s.branch&&l.push(U("diffReview.baselineBranch",{value:s.branch})),s.headShort&&l.push(U("diffReview.baselineCommit",{value:s.headShort})),s.currentHeadShort&&l.push(U("diffReview.currentHead",{value:s.currentHeadShort})),l.join(" · ")});function L(s){return(s==null?void 0:s.status)==="completed"?U("diffReview.completed"):(s==null?void 0:s.status)==="error"?U("diffReview.failed"):(s==null?void 0:s.status)==="interrupted"?U("diffReview.interrupted"):U("diffReview.stopped")}function me(s,l){if(s){if(l){E.set(s,l);return}E.delete(s)}}function ue(s,l={}){const m=P.value;if(!m.length)return;const y=Math.min(Math.max(0,Number(s)||0),m.length-1),K=m[y],B=E.get(K.id);B&&(j.value=y,B.scrollIntoView({block:l.block||"center",behavior:l.behavior||"smooth"}))}function le(s=1){P.value.length&&ue(j.value+s)}function S(s){return`${new Date((s==null?void 0:s.startedAt)||(s==null?void 0:s.createdAt)).toLocaleString(ut())} · ${L(s)}`}function Se(){const s=de.value;if(!s.length){i.value="";return}s.some(l=>l.id===i.value)||(i.value=s[0].id)}function ce(){const s=d.value;if(!s.length){w.value="";return}s.some(l=>l.path===w.value)||(w.value=s[0].path)}function Re(s=""){return fe(s)==="A"?U("diffReview.added"):fe(s)==="D"?U("diffReview.deleted"):U("diffReview.modified")}function $e(s=""){return fe(s)==="A"?"theme-status-success":fe(s)==="D"?"theme-status-danger":"theme-status-warning"}function Fe(s="all"){return s==="A"?U("diffReview.added"):s==="D"?U("diffReview.deleted"):s==="M"?U("diffReview.modified"):U("diffReview.all")}function F(s="all"){return b.value===s?"theme-filter-active":"theme-filter-idle"}function _e(s="context"){return s==="add"?"theme-patch-add":s==="delete"?"theme-patch-delete":s==="hunk"?"theme-patch-hunk":s==="meta"?"theme-patch-meta":"theme-patch-context"}function ge(s,l=""){const m=String(l||"").trim();m&&Array.from(s.keys()).forEach(y=>{String(y||"").startsWith(m)&&s.delete(y)})}function lt(){const s=jt(e.taskSlug);ge(X,s),ge(J,s),ge(q,s)}function Me(){const s=r.value==="run"?"run":r.value==="task"?"task":"workspace",l=s==="run"?i.value:"",m=oe(e.taskSlug,s,l);return{scope:s,runId:l,signature:m}}function rt(s,l="after"){const m=String((s==null?void 0:s.path)||"").trim();if(!e.taskSlug||!m)return"";const y=Me();return ht(e.taskSlug,{scope:y.scope,runId:y.runId,filePath:m,side:l})}function ze(s=""){var m;const l=String(s||"").trim();return l&&(((m=u.value)==null?void 0:m.files)||[]).find(y=>y.path===l)||null}function Oe(s=null){return!!s&&!s.patchLoaded&&!s.binary&&!s.tooLarge&&!s.message}function pe(s="",l="",m=null,y=null){var B;const K=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");return s!==K||!m||!((B=u.value)!=null&&B.files)?!1:(u.value={...u.value,baseline:(y==null?void 0:y.baseline)||u.value.baseline||null,warnings:(y==null?void 0:y.warnings)||u.value.warnings||[],files:u.value.files.map(D=>D.path===l?m:D)},!0)}async function Ee(s="",l={}){const m=String(s||"").trim(),y=String(l.signature||"").trim();if(!m||!y)return null;const K=Ne(y,m),B=ye(q,K);if(B)return{detailedFile:B,normalizedPayload:null};const D=Y.get(K);if(D)return D;const ne=(async()=>{try{const ee=await He(e.taskSlug,{scope:l.scope,runId:l.runId,filePath:m,timeoutMs:W}),ie=Ve(ee),xe=(ie.files||[]).find(Le=>Le.path===m);if(!xe)throw new Error(U("diffReview.noFileDiffContent"));return be(q,K,xe,120),{detailedFile:xe,normalizedPayload:ie}}catch(ee){return{error:ee}}finally{Y.delete(K)}})();return Y.set(K,ne),ne}async function je(){var l,m;if(!e.taskSlug||!e.active||!((l=u.value)!=null&&l.supported))return;const s=Me();for(const y of ae.value){const K=ze(y);if(!Oe(K))continue;const B=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");if(s.signature!==B)return;const D=await Ee(y,s);if(D){if(D.error){const ne=De(((m=D.error)==null?void 0:m.message)||"")||U("diffReview.fileDiffTimedOut"),ee={...K,patch:"",patchLoaded:!0,tooLarge:!0,message:ne};be(q,Ne(s.signature,y),ee,120),pe(s.signature,y,ee,null);continue}pe(s.signature,y,D.detailedFile,D.normalizedPayload)}}}async function ot(){if(!e.taskSlug){v.value=[],i.value="",p="",g=-1;return}const s=se.getTaskRunSyncVersion(e.taskSlug);if(p===e.taskSlug&&g===s)return;const l=await mt(e.taskSlug,{limit:20,events:"none"});v.value=l.items||[],p=e.taskSlug,g=s,Se()}async function Ae(){if(!e.taskSlug||!e.active)return;const s=++_;I.value=!0,R.value=!1,M.value="";try{const l=r.value==="run"?"run":r.value==="task"?"task":"workspace";l==="run"&&await ot();const m=oe(e.taskSlug,l,l==="run"?i.value:"");if(l==="run"&&!i.value){u.value={supported:!1,reason:U("diffReview.noReviewRuns"),repoRoot:"",summary:{fileCount:0,additions:0,deletions:0,statsComplete:!0},files:[]},ce();return}const y=ye(X,m);if(y){u.value=y,f=m;const D=ye(J,m);D?(u.value={...y,baseline:D.baseline||y.baseline||null,warnings:D.warnings||y.warnings||[],summary:D.summary||y.summary},C=m):C="",ce(),Pe().catch(()=>{}),je().catch(()=>{}),D||qe().catch(()=>{});return}const K=await He(e.taskSlug,{scope:l,runId:l==="run"?i.value:"",includeStats:!1});if(s!==_)return;const B=Ve(K);u.value=B,be(X,m,B,36),f=m,C="",ce(),Pe().catch(()=>{}),je().catch(()=>{}),qe().catch(()=>{})}catch(l){if(s!==_)return;M.value=l.message,u.value=null}finally{s===_&&(I.value=!1)}}async function qe(){var K,B,D;if(!e.taskSlug||!e.active||!((K=u.value)!=null&&K.supported))return;const s=r.value==="run"?"run":r.value==="task"?"task":"workspace",l=s==="run"?i.value:"",m=oe(e.taskSlug,s,l);if(C===m&&((D=(B=u.value)==null?void 0:B.summary)!=null&&D.statsComplete))return;const y=ye(J,m);if(y){u.value={...u.value,baseline:y.baseline||u.value.baseline||null,warnings:y.warnings||u.value.warnings||[],summary:y.summary||u.value.summary},C=m,R.value=!1;return}R.value=!0;try{const ne=await He(e.taskSlug,{scope:s,runId:l,includeFiles:!1,includeStats:!0}),ee=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");if(m!==ee||!u.value)return;const ie=Ve(ne);u.value={...u.value,baseline:ie.baseline||u.value.baseline||null,warnings:ie.warnings||u.value.warnings||[],summary:ie.summary||u.value.summary},be(J,m,{baseline:ie.baseline||null,warnings:ie.warnings||[],summary:ie.summary||null},36),C=m}catch{}finally{const ne=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");m===ne&&(R.value=!1)}}async function Pe(){var D,ne;const s=String(w.value||"").trim();if(!e.taskSlug||!e.active||!s)return;const l=Me(),m=ze(s);if(!Oe(m))return;const y=Ne(l.signature,s),K=ye(q,y);if(K&&((D=u.value)!=null&&D.files)){pe(l.signature,s,K,null);return}const B=++$;N.value=!0;try{const ee=await Ee(s,l);if(B!==$||!ee)return;const ie=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");if(l.signature!==ie)return;if(ee.error){const xe=De(((ne=ee.error)==null?void 0:ne.message)||"")||U("diffReview.fileDiffTimedOut"),Le={...m,patch:"",patchLoaded:!0,tooLarge:!0,message:xe};be(q,y,Le,120),pe(l.signature,s,Le,null);return}pe(l.signature,s,ee.detailedFile,ee.normalizedPayload)}finally{B===$&&(N.value=!1,String(w.value||"").trim()!==s&&Pe().catch(()=>{}))}}function Ce({force:s=!1}={}){if(!e.taskSlug||!e.active)return;const l=oe(e.taskSlug,r.value,r.value==="run"?i.value:"");!s&&l===f||Ae().catch(()=>{})}async function dt(){!e.taskSlug||!e.active||I.value||(lt(),f="",C="",p="",g=-1,await Ae())}return te(()=>[e.taskSlug,e.active,r.value,i.value],([s,l],m=[])=>{const y=m[0]||"";s!==y&&(w.value="",f="",v.value=[],i.value="",p="",g=-1,C=""),!(!s||!l)&&Ce()},{immediate:!0}),te(()=>{var s,l;return[b.value,((l=(s=u.value)==null?void 0:s.files)==null?void 0:l.length)||0]},()=>{ce()}),te(()=>[w.value,P.value.length],()=>{j.value=0,E.clear(),at(()=>{var s,l;P.value.length?ue(0,{behavior:"auto",block:"start"}):(l=(s=G.value)==null?void 0:s.scrollTo)==null||l.call(s,{top:0,behavior:"auto"})})}),te(()=>w.value,()=>{Pe().catch(()=>{})},{immediate:!0}),te(()=>{var s;return[e.active,(s=u.value)==null?void 0:s.supported,ae.value.join(`
3
+ `)]},([s,l])=>{!s||!l||je().catch(()=>{})}),te(()=>[e.preferredScope,e.preferredRunId,e.focusToken],([s,l,m],y=[])=>{const K=Number(y[2]||0),B=s==="run"?"run":s==="task"?"task":"workspace",D=B==="run"&&l?String(l||""):"",ne=r.value!==B,ee=B==="run"&&D&&i.value!==D;r.value=B,D&&(i.value=D),B!=="run"&&(i.value=""),!ne&&!ee&&e.active&&e.taskSlug&&m!==K&&(f="",Ce())},{immediate:!0}),te(()=>se.readyVersion.value,()=>{!e.active||!e.taskSlug||(p="",g=-1,f="",C="",Ce({force:!0}))}),te(()=>se.getTaskDiffSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||(p="",g=-1,C="",f="",Ce({force:!0}))}),{activeHunkIndex:j,baselineMetaText:H,diffPayload:u,diffScope:r,error:M,fileSearch:T,filteredFiles:d,getFilterButtonClass:F,getFilterLabel:Fe,getFileBlobUrl:rt,getPatchLineClass:_e,getRunStatusLabel:L,getStatusClass:$e,getStatusLabel:Re,jumpToAdjacentHunk:le,loadDiff:Ae,loading:I,normalizeFileStatus:fe,patchLoading:N,patchViewportRef:G,runs:v,selectedFile:k,selectedFilePath:w,selectedPatchHunks:P,selectedPatchLines:A,selectedRunId:i,setPatchLineRef:me,showSummarySkeleton:x,statsLoading:R,statusCounts:n,statusFilter:b,terminalRuns:de,formatRunOptionLabel:S,refreshDiff:dt}}const Vt={class:"mb-3 grid grid-cols-2 gap-2"},Ut=["onClick"],zt={class:"theme-input-shell mb-3 flex items-center gap-2 rounded-sm border px-3 py-2 text-xs text-[var(--theme-textMuted)]"},Ot=["placeholder"],Et={key:0,class:"theme-empty-state theme-empty-state-strong mb-3 px-3 py-2 text-[11px]"},qt={key:1,class:"theme-empty-state px-3 py-4 text-xs"},Wt={key:2,class:"theme-empty-state px-3 py-4 text-xs"},Kt={key:3,class:"space-y-1"},Gt=["onClick","onKeydown"],Jt={class:"min-w-0 flex-1"},Qt={class:"flex items-start gap-2"},Xt={class:"theme-list-item-title min-w-0 flex-1 break-all"},Yt={key:0,class:"theme-status-info inline-flex shrink-0 items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Zt={class:"theme-list-item-meta mt-1"},Ze={__name:"TaskDiffFileList",props:{diffPayload:{type:Object,default:null},fileSearch:{type:String,default:""},autoFocusSelected:{type:Boolean,default:!1},filteredFiles:{type:Array,default:()=>[]},focusToken:{type:Number,default:0},getFilterButtonClass:{type:Function,default:()=>""},getFilterLabel:{type:Function,default:e=>e},getStatusClass:{type:Function,default:()=>""},getStatusLabel:{type:Function,default:e=>e},selectedFilePath:{type:String,default:""},showSummarySkeleton:{type:Boolean,default:!1},statusCounts:{type:Object,default:()=>({})},statusFilter:{type:String,default:"all"}},emits:["select-file","update:fileSearch","update:statusFilter"],setup(e,{emit:r}){const i=e,w=r,{t:b}=ke(),T=new Map,v=Q(0),u=Q(0),I=z({get:()=>i.fileSearch,set:_=>w("update:fileSearch",_)}),R=z({get:()=>i.statusFilter,set:_=>w("update:statusFilter",_)}),M=z(()=>{var _;return Array.isArray((_=i.diffPayload)==null?void 0:_.files)&&i.diffPayload.files.length>0});function N(_,$){if($){T.set(_,$);return}T.delete(_)}function G(_){at(()=>{var f,C;const $=T.get(_);(f=$==null?void 0:$.focus)==null||f.call($),(C=$==null?void 0:$.scrollIntoView)==null||C.call($,{block:"nearest",inline:"nearest"})})}function j(){!i.autoFocusSelected||!i.selectedFilePath||v.value===u.value||(u.value=v.value,G(i.selectedFilePath))}function E(_=1,$=""){const f=Array.isArray(i.filteredFiles)?i.filteredFiles:[];if(!f.length)return;const C=f.findIndex(q=>q.path===$),p=f.findIndex(q=>q.path===i.selectedFilePath),X=(Math.max(0,C>=0?C:p)+_+f.length)%f.length,J=f[X];J!=null&&J.path&&(w("select-file",J.path),G(J.path))}function se(_,$){const f=String((_==null?void 0:_.key)||"");if(f==="ArrowDown"){_.preventDefault(),E(1,$);return}if(f==="ArrowUp"){_.preventDefault(),E(-1,$);return}(f==="Enter"||f===" ")&&$&&(_.preventDefault(),w("select-file",$))}return te(()=>i.focusToken,_=>{v.value=_,j()},{immediate:!0}),te(()=>i.selectedFilePath,()=>{j()}),(_,$)=>(c(),h(he,null,[a("div",Vt,[(c(),h(he,null,Ie(["all","A","M","D"],f=>a("button",{key:f,type:"button",class:Z(["inline-flex w-full items-center justify-center gap-1 whitespace-nowrap rounded-sm border px-2 py-1 text-[11px] transition",e.getFilterButtonClass(f)]),onClick:C=>R.value=f},o(e.getFilterLabel(f))+" "+o(e.statusCounts[f]||0),11,Ut)),64))]),a("label",zt,[V(t(Ct),{class:"h-3.5 w-3.5 shrink-0"}),Ue(a("input",{"onUpdate:modelValue":$[0]||($[0]=f=>I.value=f),type:"text",placeholder:t(b)("diffReview.searchFilePath"),class:"min-w-0 flex-1 bg-transparent text-xs text-[var(--theme-textPrimary)] outline-none placeholder:text-[var(--theme-textMuted)]"},null,8,Ot),[[$t,I.value]])]),e.showSummarySkeleton?(c(),h("div",Et,o(t(b)("diffReview.statsPending")),1)):O("",!0),M.value?e.filteredFiles.length?(c(),h("div",Kt,[(c(!0),h(he,null,Ie(e.filteredFiles,f=>{var C;return c(),h("button",{key:f.path,ref_for:!0,ref:p=>N(f.path,p),type:"button",class:Z(["theme-list-row focus:outline-none",f.path===e.selectedFilePath?"theme-list-item-active":"theme-list-item-hover"]),onClick:p=>w("select-file",f.path),onKeydown:p=>se(p,f.path)},[a("span",{class:Z(["theme-list-item-badge",e.getStatusClass(f.status)])},o(e.getStatusLabel(f.status)),3),a("div",Jt,[a("div",Qt,[a("div",Xt,o(f.path),1),f.binary?(c(),h("span",Yt,o(t(b)("diffReview.binaryTag")),1)):O("",!0)]),a("div",Zt,o(f.binary?((C=f.binaryPreview)==null?void 0:C.mimeType)||t(b)("diffReview.binaryPreviewTitle"):f.statsLoaded?`+${f.additions} / -${f.deletions}`:t(b)("diffReview.statsOnDemand")),1)])],42,Gt)}),128))])):(c(),h("div",Wt,o(t(b)("diffReview.noMatches")),1)):(c(),h("div",qt,o(t(b)("diffReview.noChanges")),1))],64))}},es={class:"flex h-full min-h-0 flex-col overflow-hidden"},ts={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-[12px]"},ss={class:"flex flex-wrap items-center gap-2"},as={class:"font-medium text-[var(--theme-textPrimary)]"},ns={class:"theme-muted-text"},is={class:"min-h-0 flex-1 overflow-auto p-4"},ls={key:0,class:"grid min-h-full gap-4 md:grid-cols-2"},rs={class:"theme-inline-panel flex min-h-[20rem] flex-col rounded-sm border p-3"},os={class:"mb-3 flex items-center justify-between gap-2"},ds={class:"min-w-0"},us={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},cs={class:"theme-muted-text mt-1 text-[11px]"},fs=["href","download","title"],hs={key:0,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},ms={key:1,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},vs={key:2,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},gs=["title"],ps=["src","alt"],xs=["src"],ys=["src"],bs=["src","title"],ws={class:"theme-inline-panel flex min-h-[20rem] flex-col rounded-sm border p-3"},ks={class:"mb-3 flex items-center justify-between gap-2"},Ss={class:"min-w-0"},Rs={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},$s={class:"theme-muted-text mt-1 text-[11px]"},Fs=["href","download","title"],_s={key:0,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},Ps={key:1,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},Cs={key:2,class:"theme-empty-state flex min-h-[16rem] flex-1 items-center justify-center text-[12px]"},Ls=["title"],Ts=["src","alt"],Is=["src"],Ds=["src"],Ms=["src","title"],js={key:1,class:"theme-inline-panel flex min-h-full flex-col rounded-sm border p-4"},As={class:"flex items-center gap-2"},Hs={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},Bs={class:"mt-4 grid gap-3 md:grid-cols-2"},Ns={class:"rounded-sm border border-dashed px-3 py-3"},Vs={class:"text-xs font-medium text-[var(--theme-textPrimary)]"},Us={class:"theme-muted-text mt-2 space-y-1 text-[12px]"},zs={key:0},Os=["href","download"],Es={class:"rounded-sm border border-dashed px-3 py-3"},qs={class:"text-xs font-medium text-[var(--theme-textPrimary)]"},Ws={class:"theme-muted-text mt-2 space-y-1 text-[12px]"},Ks={key:0},Gs=["href","download"],Js={__name:"TaskDiffBinaryPreview",props:{getFileBlobUrl:{type:Function,default:()=>""},selectedFile:{type:Object,default:null}},setup(e){const r=e,{t:i}=ke(),w=Q(""),b=Q({before:!1,after:!1});function T(p=0){const g=Math.max(0,Number(p)||0);return g<1024?`${g} B`:g<1024*1024?`${(g/1024).toFixed(g<10*1024?1:0)} KB`:`${(g/(1024*1024)).toFixed(g<10*1024*1024?1:0)} MB`}function v(p="after"){var g,X;return((X=(g=r.selectedFile)==null?void 0:g.binaryPreview)==null?void 0:X[p])||{exists:!1,size:0,hashShort:"",mimeType:"",previewKind:"binary",tooLarge:!1}}function u(p="after"){return r.selectedFile?r.getFileBlobUrl(r.selectedFile,p):""}function I(p="binary"){return p==="image"?Ke:p==="audio"?Lt:p==="video"?Tt:p==="pdf"?It:Ke}const R=z(()=>{var p,g;return String(((g=(p=r.selectedFile)==null?void 0:p.binaryPreview)==null?void 0:g.kind)||"binary")}),M=z(()=>v("before")),N=z(()=>v("after")),G=z(()=>u("before")),j=z(()=>u("after")),E=z(()=>{var p;return String(((p=r.selectedFile)==null?void 0:p.path)||"").trim()}),se=z(()=>["image","audio","video","pdf"].includes(R.value)),_=z(()=>R.value!=="image"?[]:[M.value.exists&&!M.value.tooLarge&&!b.value.before?G.value:"",N.value.exists&&!N.value.tooLarge&&!b.value.after?j.value:""].filter(Boolean));function $(p){return(p==null?void 0:p.exists)&&!(p!=null&&p.tooLarge)}function f(p="before"){b.value={...b.value,[p]:!0}}function C(p=""){const g=String(p||"").trim();g&&(w.value=g)}return te(()=>{var p,g,X,J,q,Y,W;return[String(((p=r.selectedFile)==null?void 0:p.path)||"").trim(),String(G.value||"").trim(),String(j.value||"").trim(),String(((J=(X=(g=r.selectedFile)==null?void 0:g.binaryPreview)==null?void 0:X.before)==null?void 0:J.hash)||"").trim(),String(((W=(Y=(q=r.selectedFile)==null?void 0:q.binaryPreview)==null?void 0:Y.after)==null?void 0:W.hash)||"").trim()].join(`
4
+ `)},()=>{w.value="",b.value={before:!1,after:!1}},{immediate:!0}),(p,g)=>{var X,J,q,Y;return c(),h("div",es,[a("div",ts,[a("div",ss,[a("span",as,o(E.value),1),a("span",ns,o(t(i)("diffReview.binaryPreviewTitle")),1)])]),a("div",is,[se.value?(c(),h("div",ls,[a("section",rs,[a("div",os,[a("div",ds,[a("p",us,o(t(i)("diffReview.binaryBefore")),1),a("p",cs,o(M.value.exists?`${T(M.value.size)} · ${M.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1)]),$(M.value)?(c(),h("a",{key:0,class:"theme-icon-button h-8 w-8",href:G.value,download:((X=e.selectedFile)==null?void 0:X.path)||"before.bin",title:t(i)("diffReview.downloadBinarySide")},[V(t(Te),{class:"h-4 w-4"})],8,fs)):O("",!0)]),M.value.exists?M.value.tooLarge?(c(),h("div",ms,o(t(i)("diffReview.binaryPreviewTooLarge")),1)):b.value.before?(c(),h("div",vs,o(t(i)("diffReview.binaryPreviewUnavailable")),1)):R.value==="image"?(c(),h("button",{key:3,type:"button",class:"task-diff-binary-image-wrap flex min-h-[16rem] flex-1 cursor-zoom-in items-center justify-center rounded-sm border p-3",title:t(i)("diffReview.openImagePreview"),onClick:g[1]||(g[1]=W=>C(G.value))},[a("img",{src:G.value,alt:`${E.value} before`,class:"max-h-full max-w-full object-contain",onError:g[0]||(g[0]=W=>f("before"))},null,40,ps)],8,gs)):R.value==="audio"?(c(),h("audio",{key:4,class:"w-full",src:G.value,controls:"",preload:"metadata",onError:g[2]||(g[2]=W=>f("before"))},null,40,xs)):R.value==="video"?(c(),h("video",{key:5,class:"max-h-[26rem] w-full rounded-sm border bg-black",src:G.value,controls:"",preload:"metadata",onError:g[3]||(g[3]=W=>f("before"))},null,40,ys)):R.value==="pdf"?(c(),h("iframe",{key:6,class:"min-h-[26rem] w-full rounded-sm border bg-white",src:G.value,title:`${E.value} before`,onError:g[4]||(g[4]=W=>f("before"))},null,40,bs)):O("",!0):(c(),h("div",hs,o(t(i)("diffReview.binarySideMissing")),1))]),a("section",ws,[a("div",ks,[a("div",Ss,[a("p",Rs,o(t(i)("diffReview.binaryAfter")),1),a("p",$s,o(N.value.exists?`${T(N.value.size)} · ${N.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1)]),$(N.value)?(c(),h("a",{key:0,class:"theme-icon-button h-8 w-8",href:j.value,download:((J=e.selectedFile)==null?void 0:J.path)||"after.bin",title:t(i)("diffReview.downloadBinarySide")},[V(t(Te),{class:"h-4 w-4"})],8,Fs)):O("",!0)]),N.value.exists?N.value.tooLarge?(c(),h("div",Ps,o(t(i)("diffReview.binaryPreviewTooLarge")),1)):b.value.after?(c(),h("div",Cs,o(t(i)("diffReview.binaryPreviewUnavailable")),1)):R.value==="image"?(c(),h("button",{key:3,type:"button",class:"task-diff-binary-image-wrap flex min-h-[16rem] flex-1 cursor-zoom-in items-center justify-center rounded-sm border p-3",title:t(i)("diffReview.openImagePreview"),onClick:g[6]||(g[6]=W=>C(j.value))},[a("img",{src:j.value,alt:`${E.value} after`,class:"max-h-full max-w-full object-contain",onError:g[5]||(g[5]=W=>f("after"))},null,40,Ts)],8,Ls)):R.value==="audio"?(c(),h("audio",{key:4,class:"w-full",src:j.value,controls:"",preload:"metadata",onError:g[7]||(g[7]=W=>f("after"))},null,40,Is)):R.value==="video"?(c(),h("video",{key:5,class:"max-h-[26rem] w-full rounded-sm border bg-black",src:j.value,controls:"",preload:"metadata",onError:g[8]||(g[8]=W=>f("after"))},null,40,Ds)):R.value==="pdf"?(c(),h("iframe",{key:6,class:"min-h-[26rem] w-full rounded-sm border bg-white",src:j.value,title:`${E.value} after`,onError:g[9]||(g[9]=W=>f("after"))},null,40,Ms)):O("",!0):(c(),h("div",_s,o(t(i)("diffReview.binarySideMissing")),1))])])):(c(),h("div",js,[a("div",As,[(c(),ve(Ft(I(R.value)),{class:"h-5 w-5 text-[var(--theme-textSecondary)]"})),a("span",Hs,o(t(i)("diffReview.binaryMetaTitle")),1)]),a("div",Bs,[a("div",Ns,[a("div",Vs,o(t(i)("diffReview.binaryBefore")),1),a("div",Us,[a("p",null,o(M.value.exists?`${T(M.value.size)} · ${M.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1),M.value.mimeType?(c(),h("p",zs,o(M.value.mimeType),1)):O("",!0)]),$(M.value)?(c(),h("a",{key:0,class:"tool-button mt-3 inline-flex items-center gap-2 px-3 py-2 text-xs",href:G.value,download:((q=e.selectedFile)==null?void 0:q.path)||"before.bin"},[V(t(Te),{class:"h-3.5 w-3.5"}),a("span",null,o(t(i)("diffReview.downloadBinarySide")),1)],8,Os)):O("",!0)]),a("div",Es,[a("div",qs,o(t(i)("diffReview.binaryAfter")),1),a("div",Ws,[a("p",null,o(N.value.exists?`${T(N.value.size)} · ${N.value.hashShort||"-"}`:t(i)("diffReview.binarySideMissing")),1),N.value.mimeType?(c(),h("p",Ks,o(N.value.mimeType),1)):O("",!0)]),$(N.value)?(c(),h("a",{key:0,class:"tool-button mt-3 inline-flex items-center gap-2 px-3 py-2 text-xs",href:j.value,download:((Y=e.selectedFile)==null?void 0:Y.path)||"after.bin"},[V(t(Te),{class:"h-3.5 w-3.5"}),a("span",null,o(t(i)("diffReview.downloadBinarySide")),1)],8,Gs)):O("",!0)])])]))]),V(vt,{modelValue:w.value,"onUpdate:modelValue":g[10]||(g[10]=W=>w.value=W),images:_.value},null,8,["modelValue","images"])])}}},Qs=st(Js,[["__scopeId","data-v-4703ec91"]]),Xs={key:0,class:"flex h-full min-h-0 flex-col overflow-hidden"},Ys={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-[12px]"},Zs={class:"space-y-3 sm:hidden"},ea={class:"flex items-start gap-2"},ta={class:"min-w-0 break-all font-medium text-[var(--theme-textPrimary)]"},sa={class:"flex items-center justify-between gap-3"},aa={class:"min-w-0"},na={class:"opacity-75"},ia={key:0,class:"theme-muted-text mt-1 text-[11px]"},la=["disabled"],ra={class:"min-w-[64px] text-center text-[12px] text-[var(--theme-textSecondary)]"},oa=["disabled"],da={class:"hidden items-center gap-3 sm:flex"},ua={class:"flex min-w-0 flex-1 flex-wrap items-center gap-2"},ca={class:"break-all font-medium text-[var(--theme-textPrimary)]"},fa={class:"opacity-75"},ha={key:0,class:"theme-muted-text text-[11px]"},ma=["disabled"],va={class:"min-w-[64px] text-center text-[12px] text-[var(--theme-textSecondary)]"},ga=["disabled"],pa={key:1,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},xa={class:"theme-empty-state px-4 py-4"},ya={key:2,class:"theme-muted-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},ba={class:"task-diff-view min-w-max px-4 py-4 font-mono"},wa={key:0,class:"theme-inline-panel theme-secondary-text mb-3 rounded-sm border border-dashed px-3 py-2 text-[12px]"},ka=["data-line-id","data-line-kind"],Sa={class:"task-diff-row__number select-none"},Ra={class:"task-diff-row__number select-none"},$a=["innerHTML"],Fa={key:4,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-[12px]"},_a={class:"theme-empty-state px-4 py-4"},Pa={key:1,class:"theme-muted-text flex h-full items-center justify-center px-5 text-[12px]"},Ca={__name:"TaskDiffPatchView",props:{activeHunkIndex:{type:Number,default:0},getPatchLineClass:{type:Function,default:()=>""},getFileBlobUrl:{type:Function,default:()=>""},getStatusClass:{type:Function,default:()=>""},getStatusLabel:{type:Function,default:e=>e},jumpToAdjacentHunk:{type:Function,default:()=>{}},patchLoading:{type:Boolean,default:!1},selectedFile:{type:Object,default:null},selectedPatchHunks:{type:Array,default:()=>[]},selectedPatchLines:{type:Array,default:()=>[]},setPatchLineRef:{type:Function,default:()=>{}},setPatchViewportRef:{type:Function,default:()=>{}}},emits:["insert-code-context"],setup(e,{emit:r}){const i=e,w=r,{t:b}=ke(),{isDark:T}=ct(),v=Q([]),u=z(()=>{var n;return wt(((n=i.selectedFile)==null?void 0:n.path)||"")}),I=Q(null),R=new Map,M=z(()=>{var n,d;return!!((n=i.selectedFile)!=null&&n.binary&&((d=i.selectedFile)!=null&&d.binaryPreview))});function N(n={}){return["add","delete","context"].includes(String((n==null?void 0:n.kind)||"").trim())}function G(n=""){const d=String(n||"").trim();return d&&v.value.find(k=>k.id===d)||null}const{selectedRows:j,selectionAction:E,clearSelectionState:se,handleSelectionMouseUp:_,updateSelectionActionFromDom:$}=gt({getContainer:()=>I.value,isActive:()=>!!(i.selectedFile&&i.selectedPatchLines.length),rowSelector:".task-diff-row[data-line-id]",getOrderedRowElements:n=>[...n.querySelectorAll(".task-diff-row[data-line-id]")].filter(d=>N(G(d.getAttribute("data-line-id")))),mapRowElement:n=>{var d;return G(((d=n==null?void 0:n.getAttribute)==null?void 0:d.call(n,"data-line-id"))||"")},getCodeLeft:n=>{var ae,x,H;const d=(ae=n==null?void 0:n.querySelector)==null?void 0:ae.call(n,".task-diff-line");if(!d)return 0;const k=(x=d.getBoundingClientRect)==null?void 0:x.call(d),A=(H=window.getComputedStyle)==null?void 0:H.call(window,d),P=Number.parseFloat((A==null?void 0:A.paddingLeft)||"0")||0;return((k==null?void 0:k.left)||0)+P},debounceMs:72});function f(n=[]){const d=n.flatMap(P=>[Number((P==null?void 0:P.oldNumber)||0),Number((P==null?void 0:P.newNumber)||0)]).filter(P=>P>0);if(!d.length)return{start:0,end:0,label:""};const k=Math.min(...d),A=Math.max(...d);return{start:k,end:A,label:k===A?`L${k}`:`L${k}-L${A}`}}function C(n=[]){return n.map(d=>String((d==null?void 0:d.content)||"")).join(`
5
+ `).replace(/\u200b/g,"").trim()}function p(){var d,k,A;if(!i.selectedFile||!E.value.visible||!j.value.length)return;const n=f(j.value);w("insert-code-context",{source:"diff",filePath:String(i.selectedFile.path||""),language:"diff",rangeLabel:n.label,lineStart:n.start,lineEnd:n.end,content:C(j.value)||String(E.value.content||"").trim()}),(A=(k=(d=window.getSelection)==null?void 0:d.call(window))==null?void 0:k.removeAllRanges)==null||A.call(k),se()}function g(n,d){if(i.setPatchLineRef(n,d),!!n){if(d){R.set(n,d);return}R.delete(n)}}function X(n){I.value=n||null,i.setPatchViewportRef(n)}function J(n){var H,L,me,ue;const d=(H=window.getSelection)==null?void 0:H.call(window),k=I.value;if(!d||d.rangeCount<1||d.isCollapsed||!k)return;$();const P=d.getRangeAt(0).commonAncestorContainer;if(!k.contains((P==null?void 0:P.nodeType)===1?P:P==null?void 0:P.parentNode))return;const ae=j.value;if(!ae.length)return;const x=C(ae);x&&((me=(L=n==null?void 0:n.clipboardData)==null?void 0:L.setData)==null||me.call(L,"text/plain",x),(ue=n==null?void 0:n.preventDefault)==null||ue.call(n))}function q(n){return(n==null?void 0:n.kind)==="add"?"+":(n==null?void 0:n.kind)==="delete"?"-":(n==null?void 0:n.kind)==="context"?" ":""}function Y(n){const d=String((n==null?void 0:n.content)||"");return(n==null?void 0:n.kind)==="add"||(n==null?void 0:n.kind)==="delete"||(n==null?void 0:n.kind)==="context"?d.slice(1):d}function W(n=""){return String(n||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function re(n,d=""){if((n==null?void 0:n.kind)==="add"||(n==null?void 0:n.kind)==="delete"||(n==null?void 0:n.kind)==="context"){const k=q(n),A=`task-diff-line__prefix--${n.kind}`;return{...n,renderedHtml:`<span class="task-diff-line__prefix ${A}">${W(k||" ")}</span><span class="task-diff-line__body">${d||"&#8203;"}</span>`}}return{...n,renderedHtml:W(String((n==null?void 0:n.content)||""))}}async function de(){const n=Array.isArray(i.selectedPatchLines)?i.selectedPatchLines:[],d=[];n.forEach((x,H)=>{((x==null?void 0:x.kind)==="add"||(x==null?void 0:x.kind)==="delete"||(x==null?void 0:x.kind)==="context")&&d.push({lineIndex:H,body:Y(x)})});const k=xt(d.map(x=>x.body));let A=0;if(v.value=n.map(x=>{if((x==null?void 0:x.kind)==="add"||(x==null?void 0:x.kind)==="delete"||(x==null?void 0:x.kind)==="context"){const H=k[A]||"&#8203;";return A+=1,re(x,H)}return re(x)}),!d.length||yt(d.map(x=>x.body),Be))return;const P=await bt(d.map(x=>x.body),{isDark:T.value,language:u.value,maxHighlightLines:Be.maxLines,maxHighlightChars:Be.maxChars});let ae=0;v.value=n.map(x=>{if((x==null?void 0:x.kind)==="add"||(x==null?void 0:x.kind)==="delete"||(x==null?void 0:x.kind)==="context"){const H=P[ae]||"&#8203;";return ae+=1,re(x,H)}return re(x)})}return te(()=>{var n;return[i.selectedPatchLines,(n=i.selectedFile)==null?void 0:n.path,T.value]},()=>{se(),de()},{immediate:!0,deep:!0}),_t(()=>{var n,d,k;(k=(d=(n=window.getSelection)==null?void 0:n.call(window))==null?void 0:d.removeAllRanges)==null||k.call(d),se({clearBrowserSelection:!0}),R.clear()}),(n,d)=>e.selectedFile?(c(),h("div",Xs,[a("div",Ys,[a("div",Zs,[a("div",ea,[a("span",{class:Z(["inline-flex shrink-0 rounded-sm border px-1.5 py-0.5 text-[12px]",e.getStatusClass(e.selectedFile.status)])},o(e.getStatusLabel(e.selectedFile.status)),3),a("span",ta,o(e.selectedFile.path),1)]),a("div",sa,[a("div",aa,[a("div",na,o(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:t(b)("diffReview.statsOnDemand")),1),M.value?O("",!0):(c(),h("div",ia,o(t(b)("diffReview.selectCodeLineHint")),1))]),a("div",{class:Z(["inline-flex h-8 shrink-0 items-center gap-1 rounded-sm border px-1.5 py-1",e.selectedPatchHunks.length?"theme-inline-panel":"pointer-events-none invisible border-transparent"])},[a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex<=0,onClick:d[0]||(d[0]=k=>e.jumpToAdjacentHunk(-1))},[V(t(Ge),{class:"h-4 w-4"})],8,la),a("span",ra,o(t(b)("diffReview.changeIndex",{current:Math.min(e.activeHunkIndex+1,e.selectedPatchHunks.length),total:e.selectedPatchHunks.length})),1),a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex>=e.selectedPatchHunks.length-1,onClick:d[1]||(d[1]=k=>e.jumpToAdjacentHunk(1))},[V(t(Je),{class:"h-4 w-4"})],8,oa)],2)])]),a("div",da,[a("div",ua,[a("span",{class:Z(["inline-flex rounded-sm border px-1.5 py-0.5 text-[12px]",e.getStatusClass(e.selectedFile.status)])},o(e.getStatusLabel(e.selectedFile.status)),3),a("span",ca,o(e.selectedFile.path),1),a("span",fa,o(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:t(b)("diffReview.statsOnDemand")),1),M.value?O("",!0):(c(),h("span",ha,o(t(b)("diffReview.selectCodeLineHint")),1))]),a("div",{class:Z(["inline-flex h-8 w-[132px] shrink-0 items-center gap-1 rounded-sm border px-1.5 py-1",e.selectedPatchHunks.length?"theme-inline-panel":"pointer-events-none invisible border-transparent"])},[a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex<=0,onClick:d[2]||(d[2]=k=>e.jumpToAdjacentHunk(-1))},[V(t(Ge),{class:"h-4 w-4"})],8,ma),a("span",va,o(t(b)("diffReview.changeIndex",{current:Math.min(e.activeHunkIndex+1,e.selectedPatchHunks.length),total:e.selectedPatchHunks.length})),1),a("button",{type:"button",class:"theme-icon-button h-6 w-6 disabled:opacity-50",disabled:e.activeHunkIndex>=e.selectedPatchHunks.length-1,onClick:d[3]||(d[3]=k=>e.jumpToAdjacentHunk(1))},[V(t(Je),{class:"h-4 w-4"})],8,ga)],2)])]),e.selectedFile.binary&&e.selectedFile.binaryPreview?(c(),ve(Qs,{key:0,"get-file-blob-url":e.getFileBlobUrl,"selected-file":e.selectedFile},null,8,["get-file-blob-url","selected-file"])):e.selectedFile.message&&!e.selectedPatchLines.length?(c(),h("div",pa,[a("div",xa,o(e.selectedFile.message),1)])):e.patchLoading&&!e.selectedFile.patchLoaded?(c(),h("div",ya,o(t(b)("diffReview.loadingFileDiff")),1)):e.selectedPatchLines.length?(c(),h("div",{key:3,ref:X,class:"relative flex-1 overflow-auto",onCopy:J,onMouseup:d[4]||(d[4]=(...k)=>t(_)&&t(_)(...k))},[a("div",ba,[e.selectedFile.message?(c(),h("div",wa,o(e.selectedFile.message),1)):O("",!0),(c(!0),h(he,null,Ie(v.value,k=>{var A;return c(),h("div",{key:k.id,ref_for:!0,ref:P=>g(k.id,P),class:Z(["task-diff-row grid",[e.getPatchLineClass(k.kind),k.kind==="hunk"&&((A=e.selectedPatchHunks[e.activeHunkIndex])==null?void 0:A.id)===k.id?"ring-1 ring-inset ring-[var(--theme-warning)]":""]]),"data-line-id":k.id,"data-line-kind":k.kind},[a("span",Sa,o(k.oldNumber),1),a("span",Ra,o(k.newNumber),1),a("pre",{class:Z(["task-diff-line overflow-visible whitespace-pre px-3 py-0.5",k.kind==="meta"||k.kind==="hunk"?"task-diff-line--plain":""]),innerHTML:k.renderedHtml},null,10,$a)],10,ka)}),128))]),t(E).visible?(c(),ve(pt,{key:0,top:t(E).top,left:t(E).left,label:t(b)("diffReview.insertSelection"),onClick:p},null,8,["top","left","label"])):O("",!0)],32)):(c(),h("div",Fa,[a("div",_a,o(t(b)("diffReview.noFileDiffContent")),1)]))])):(c(),h("div",Pa,o(t(b)("diffReview.selectFile")),1))}},et=st(Ca,[["__scopeId","data-v-ee7937d4"]]),La={class:"panel flex h-full min-h-0 flex-col overflow-hidden"},Ta={class:"theme-divider border-b px-4 py-3"},Ia={class:"flex flex-col gap-2"},Da={class:"grid grid-cols-4 gap-2 sm:flex sm:flex-wrap sm:items-center"},Ma={class:"sm:hidden"},ja={class:"hidden sm:inline"},Aa={class:"sm:hidden"},Ha={class:"hidden sm:inline"},Ba=["disabled"],Na={class:"sm:hidden"},Va={class:"hidden sm:inline"},Ua={class:"truncate text-xs text-[var(--theme-textPrimary)]"},za={class:"theme-divider theme-muted-text border-b border-dashed px-3 py-2 text-[11px]"},Oa=["onClick"],Ea={class:"flex items-start gap-3"},qa={class:"min-w-0 flex-1"},Wa={class:"truncate text-xs font-medium text-[var(--theme-textPrimary)]"},Ka={class:"theme-muted-text mt-1 text-[11px]"},Ga={key:0,class:"theme-divider theme-danger-text border-b px-4 py-3 text-sm"},Ja={class:"inline-flex items-start gap-2"},Qa={class:"break-all"},Xa={key:1,class:"theme-muted-text flex flex-1 items-center justify-center px-5 text-sm"},Ya={key:2,class:"flex flex-1 items-center justify-center px-5"},Za={class:"theme-empty-state w-full max-w-xl px-4 py-5 text-sm text-[var(--theme-textSecondary)]"},en={class:"theme-heading inline-flex items-center gap-2 font-medium"},tn={class:"mt-2 break-all leading-7"},sn={key:0,class:"mt-3 flex flex-wrap gap-2 text-xs"},an={class:"theme-status-neutral inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},nn={class:"break-all"},ln={key:0,class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},rn={key:3,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},on={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-xs"},dn={class:"flex flex-wrap items-center gap-2"},un={key:0,class:"theme-status-info inline-flex min-w-0 items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},cn={class:"min-w-0 break-all"},fn={class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},hn={class:"text-[var(--theme-textPrimary)]"},mn={class:"font-medium text-[var(--theme-success)]"},vn={class:"font-medium text-[var(--theme-danger)]"},gn={key:2,class:"opacity-75"},pn={key:0,class:"mt-2 break-all text-[11px] opacity-75"},xn={key:1,class:"mt-2 flex flex-col gap-1"},yn={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},bn={class:"theme-divider border-b px-3 py-3"},wn={class:"grid grid-cols-2 gap-2"},kn=["disabled"],Sn={class:"theme-divider theme-muted-panel min-h-0 flex-1 overflow-y-auto p-3"},Rn={class:"min-h-0 flex-1 overflow-hidden bg-[var(--theme-appPanelStrong)]"},$n={key:1,class:"grid min-h-0 flex-1 grid-cols-[320px_minmax(0,1fr)] overflow-hidden"},Fn={class:"theme-divider theme-muted-panel min-h-0 overflow-y-auto border-r p-3"},_n={class:"min-h-0 overflow-hidden bg-[var(--theme-appPanelStrong)]"},Pn={__name:"TaskDiffReviewPanel",props:{taskSlug:{type:String,default:""},preferredScope:{type:String,default:"workspace"},preferredRunId:{type:String,default:""},focusToken:{type:Number,default:0},active:{type:Boolean,default:!1}},emits:["insert-code-context"],setup(e,{emit:r}){const i=e,w=r,{activeHunkIndex:b,baselineMetaText:T,diffPayload:v,diffScope:u,error:I,fileSearch:R,filteredFiles:M,formatRunOptionLabel:N,getFilterButtonClass:G,getFilterLabel:j,getFileBlobUrl:E,getPatchLineClass:se,getRunStatusLabel:_,getStatusClass:$,getStatusLabel:f,jumpToAdjacentHunk:C,loading:p,patchLoading:g,patchViewportRef:X,refreshDiff:J,selectedFile:q,selectedFilePath:Y,selectedPatchHunks:W,selectedPatchLines:re,selectedRunId:de,setPatchLineRef:n,showSummarySkeleton:d,statsLoading:k,statusCounts:A,statusFilter:P,terminalRuns:ae}=Nt(i),{matches:x}=kt("(max-width: 767px)"),H=Q("files"),{t:L}=ke();function me(le){Y.value=le,x.value&&(H.value="patch")}function ue(le){X.value=le||null}return te(x,le=>{le||(H.value="files")},{immediate:!0}),te(Y,le=>{!le&&x.value&&(H.value="files")}),te(u,()=>{x.value&&(H.value="files")}),(le,S)=>{var Se,ce,Re,$e,Fe;return c(),h("section",La,[a("div",Ta,[a("div",Ia,[a("div",Da,[a("button",{type:"button",class:Z(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(u)==="workspace"?"theme-filter-active":""]),onClick:S[0]||(S[0]=F=>u.value="workspace")},[a("span",Ma,o(t(L)("diffReview.scopeCurrentShort")),1),a("span",ja,o(t(L)("diffReview.scopeCurrent")),1)],2),a("button",{type:"button",class:Z(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(u)==="task"?"theme-filter-active":""]),onClick:S[1]||(S[1]=F=>u.value="task")},[a("span",Aa,o(t(L)("diffReview.scopeTaskShort")),1),a("span",Ha,o(t(L)("diffReview.scopeTask")),1)],2),a("button",{type:"button",class:Z(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(u)==="run"?"theme-filter-active":""]),onClick:S[2]||(S[2]=F=>u.value="run")},[a("span",null,o(t(L)("diffReview.scopeRun")),1)],2),a("button",{type:"button",class:"tool-button tool-button-info-subtle inline-flex shrink-0 items-center justify-center gap-2 px-3 py-2 text-xs",disabled:t(p),onClick:S[3]||(S[3]=(...F)=>t(J)&&t(J)(...F))},[V(t(Qe),{class:Z(["h-3.5 w-3.5 sm:hidden",t(p)?"animate-spin":""])},null,8,["class"]),a("span",Na,o(t(L)("diffReview.refresh")),1),V(t(Qe),{class:Z(["hidden h-3.5 w-3.5 sm:inline-block",t(p)?"animate-spin":""])},null,8,["class"]),a("span",Va,o(t(p)?t(L)("diffReview.refreshing"):t(k)?t(L)("diffReview.computing"):t(L)("diffReview.refresh")),1)],8,Ba)]),t(u)==="run"?(c(),ve(St,{key:0,modelValue:t(de),"onUpdate:modelValue":S[4]||(S[4]=F=>Pt(de)?de.value=F:null),class:"min-w-0 sm:max-w-[360px]",options:t(ae),loading:t(p),"get-option-value":F=>(F==null?void 0:F.id)||"",placeholder:t(L)("diffReview.selectRun"),"empty-text":t(L)("diffReview.noRuns")},{trigger:we(({selectedOption:F})=>[a("div",Ua,o(F?t(N)(F):t(L)("diffReview.selectRun")),1)]),header:we(()=>[a("div",za,o(t(L)("diffReview.runCount",{count:t(ae).length})),1)]),option:we(({option:F,selected:_e,select:ge})=>[a("button",{type:"button",class:Z(["w-full rounded-sm border border-dashed px-3 py-2 text-left transition",_e?"theme-filter-active":"theme-filter-idle"]),onClick:ge},[a("div",Ea,[a("div",qa,[a("div",Wa,o(t(tt)(F.startedAt||F.createdAt)),1),a("div",Ka,o(t(_)(F)),1)]),_e?(c(),ve(t(Dt),{key:0,class:"mt-0.5 h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):O("",!0)])],10,Oa)]),_:1},8,["modelValue","options","loading","get-option-value","placeholder","empty-text"])):O("",!0)])]),t(I)?(c(),h("div",Ga,[a("div",Ja,[V(t(Mt),{class:"mt-0.5 h-4 w-4 shrink-0"}),a("span",Qa,o(t(I)),1)])])):O("",!0),t(p)&&!t(v)?(c(),h("div",Xa,o(t(L)("diffReview.loading")),1)):t(v)&&!t(v).supported?(c(),h("div",Ya,[a("div",Za,[a("div",en,[V(t(nt),{class:"h-4 w-4"}),a("span",null,o(t(L)("diffReview.unavailableTitle")),1)]),a("p",tn,o(t(v).reason||t(L)("diffReview.unavailableReason")),1),t(v).repoRoot?(c(),h("div",sn,[a("div",an,[V(t(Xe),{class:"h-3.5 w-3.5 shrink-0"}),a("span",nn,o(t(v).repoRoot),1)]),t(v).branch?(c(),h("div",ln,[V(t(Ye),{class:"h-3.5 w-3.5 shrink-0"}),a("span",null,o(t(v).branch),1)])):O("",!0)])):O("",!0)])])):t(v)?(c(),h("div",rn,[a("div",on,[a("div",dn,[t(v).repoRoot?(c(),h("div",un,[V(t(Xe),{class:"h-3.5 w-3.5 shrink-0"}),a("span",cn,o(t(v).repoRoot),1)])):O("",!0),a("div",fn,[V(t(Ye),{class:"h-3.5 w-3.5 shrink-0"}),a("span",null,o(t(v).branch||t(L)("diffReview.unknownBranch")),1),S[18]||(S[18]=a("span",{class:"opacity-50"},"•",-1)),a("span",hn,o(t(L)("diffReview.fileCount",{count:((Se=t(v).summary)==null?void 0:Se.fileCount)||0})),1),(ce=t(v).summary)!=null&&ce.statsComplete?(c(),h(he,{key:0},[S[14]||(S[14]=a("span",{class:"opacity-50"},"•",-1)),a("span",mn,"+"+o(((Re=t(v).summary)==null?void 0:Re.additions)||0),1),a("span",vn,"-"+o((($e=t(v).summary)==null?void 0:$e.deletions)||0),1)],64)):t(d)?(c(),h(he,{key:1},[S[15]||(S[15]=a("span",{class:"opacity-50"},"•",-1)),S[16]||(S[16]=a("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-successSoft)]"},null,-1)),S[17]||(S[17]=a("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-dangerSoft)]"},null,-1))],64)):(c(),h("span",gn,o(t(L)("diffReview.waitingStats")),1))])]),t(T)?(c(),h("p",pn,o(t(T)),1)):O("",!0),(Fe=t(v).warnings)!=null&&Fe.length?(c(),h("div",xn,[(c(!0),h(he,null,Ie(t(v).warnings,F=>(c(),h("p",{key:F,class:"text-[11px] text-[var(--theme-warningText)]"},o(F),1))),128))])):O("",!0)]),t(x)?(c(),h("div",yn,[a("div",bn,[a("div",wn,[a("button",{type:"button",class:Z(["tool-button px-3 py-2 text-sm",H.value==="files"?"tool-button-accent-subtle":""]),onClick:S[5]||(S[5]=F=>H.value="files")},o(t(L)("diffReview.filesTab")),3),a("button",{type:"button",class:Z(["tool-button px-3 py-2 text-sm",H.value==="patch"?"tool-button-accent-subtle":""]),disabled:!t(q),onClick:S[6]||(S[6]=F=>H.value="patch")},o(t(L)("diffReview.diffTab")),11,kn)])]),Ue(a("div",Sn,[V(Ze,{"auto-focus-selected":e.active&&H.value==="files","diff-payload":t(v),"file-search":t(R),"focus-token":e.focusToken,"filtered-files":t(M),"get-filter-button-class":t(G),"get-filter-label":t(j),"get-status-class":t($),"get-status-label":t(f),"selected-file-path":t(Y),"show-summary-skeleton":t(d),"status-counts":t(A),"status-filter":t(P),"onUpdate:fileSearch":S[7]||(S[7]=F=>R.value=F),"onUpdate:statusFilter":S[8]||(S[8]=F=>P.value=F),onSelectFile:me},null,8,["auto-focus-selected","diff-payload","file-search","focus-token","filtered-files","get-filter-button-class","get-filter-label","get-status-class","get-status-label","selected-file-path","show-summary-skeleton","status-counts","status-filter"])],512),[[We,H.value==="files"]]),Ue(a("div",Rn,[V(et,{"active-hunk-index":t(b),"get-file-blob-url":t(E),"get-patch-line-class":t(se),"get-status-class":t($),"get-status-label":t(f),"jump-to-adjacent-hunk":t(C),"patch-loading":t(g),"selected-file":t(q),"selected-patch-hunks":t(W),"selected-patch-lines":t(re),"set-patch-line-ref":t(n),"set-patch-viewport-ref":ue,onInsertCodeContext:S[9]||(S[9]=F=>w("insert-code-context",F))},null,8,["active-hunk-index","get-file-blob-url","get-patch-line-class","get-status-class","get-status-label","jump-to-adjacent-hunk","patch-loading","selected-file","selected-patch-hunks","selected-patch-lines","set-patch-line-ref"])],512),[[We,H.value==="patch"]])])):(c(),h("div",$n,[a("div",Fn,[V(Ze,{"auto-focus-selected":e.active,"diff-payload":t(v),"file-search":t(R),"focus-token":e.focusToken,"filtered-files":t(M),"get-filter-button-class":t(G),"get-filter-label":t(j),"get-status-class":t($),"get-status-label":t(f),"selected-file-path":t(Y),"show-summary-skeleton":t(d),"status-counts":t(A),"status-filter":t(P),"onUpdate:fileSearch":S[10]||(S[10]=F=>R.value=F),"onUpdate:statusFilter":S[11]||(S[11]=F=>P.value=F),onSelectFile:S[12]||(S[12]=F=>Y.value=F)},null,8,["auto-focus-selected","diff-payload","file-search","focus-token","filtered-files","get-filter-button-class","get-filter-label","get-status-class","get-status-label","selected-file-path","show-summary-skeleton","status-counts","status-filter"])]),a("div",_n,[V(et,{"active-hunk-index":t(b),"get-file-blob-url":t(E),"get-patch-line-class":t(se),"get-status-class":t($),"get-status-label":t(f),"jump-to-adjacent-hunk":t(C),"patch-loading":t(g),"selected-file":t(q),"selected-patch-hunks":t(W),"selected-patch-lines":t(re),"set-patch-line-ref":t(n),"set-patch-viewport-ref":ue,onInsertCodeContext:S[13]||(S[13]=F=>w("insert-code-context",F))},null,8,["active-hunk-index","get-file-blob-url","get-patch-line-class","get-status-class","get-status-label","jump-to-adjacent-hunk","patch-loading","selected-file","selected-patch-hunks","selected-patch-lines","set-patch-line-ref"])])]))])):O("",!0)])}}},Cn={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Hn={__name:"TaskDiffReviewDialog",props:{open:{type:Boolean,default:!1},taskSlug:{type:String,default:""},taskTitle:{type:String,default:""},preferredScope:{type:String,default:"task"},preferredRunId:{type:String,default:""},focusToken:{type:Number,default:0}},emits:["close","insert-code-context"],setup(e,{emit:r}){const i=e,w=r,{t:b}=ke(),T=z(()=>{const u=String(i.taskTitle||"").trim();return u?b("diffReview.dialogTitleWithTask",{title:u}):b("diffReview.dialogTitle")});function v(u){w("insert-code-context",u),w("close")}return(u,I)=>(c(),ve(Rt,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] sm:h-[96vh] sm:max-h-[96vh] sm:w-[90vw] sm:max-w-[90vw]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex-1 overflow-hidden p-3 sm:p-4",onClose:I[0]||(I[0]=R=>w("close"))},{title:we(()=>[a("div",Cn,[V(t(nt),{class:"h-4 w-4"}),a("span",null,o(T.value),1)])]),default:we(()=>[V(Pn,{"task-slug":e.taskSlug,active:e.open,"preferred-scope":e.preferredScope,"preferred-run-id":e.preferredRunId,"focus-token":e.focusToken,onInsertCodeContext:v},null,8,["task-slug","active","preferred-scope","preferred-run-id","focus-token"])]),_:1},8,["open"]))}};export{Hn as default};
@@ -0,0 +1 @@
1
+ .task-diff-binary-image-wrap[data-v-4703ec91]{background:linear-gradient(45deg,color-mix(in srgb,var(--theme-borderMuted) 60%,transparent) 25%,transparent 25%),linear-gradient(-45deg,color-mix(in srgb,var(--theme-borderMuted) 60%,transparent) 25%,transparent 25%),linear-gradient(45deg,transparent 75%,color-mix(in srgb,var(--theme-borderMuted) 60%,transparent) 75%),linear-gradient(-45deg,transparent 75%,color-mix(in srgb,var(--theme-borderMuted) 60%,transparent) 75%);background-color:var(--theme-panel);background-position:0 0,0 8px,8px -8px,-8px 0;background-size:16px 16px}.task-diff-row[data-v-ee7937d4]{grid-template-columns:3.1rem 3.1rem minmax(0,1fr)}.task-diff-view[data-v-ee7937d4]{font-size:var(--theme-codeViewFontSize);line-height:var(--theme-codeViewLineHeight)}.task-diff-row__number[data-v-ee7937d4]{border-right:1px solid var(--theme-borderMuted);color:color-mix(in srgb,var(--theme-textPrimary) 52%,transparent);font-size:var(--theme-codeViewGutterFontSize);font-variant-numeric:tabular-nums;padding:.125rem .5rem;text-align:right}.task-diff-line[data-v-ee7937d4]{color:inherit;-moz-user-select:text;user-select:text;-webkit-user-select:text}.task-diff-line[data-v-ee7937d4] .task-diff-line__prefix{display:inline-block;font-weight:600;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:1ch}.task-diff-line[data-v-ee7937d4] .task-diff-line__prefix--add{color:var(--theme-successText)}.task-diff-line[data-v-ee7937d4] .task-diff-line__prefix--delete{color:var(--theme-dangerText)}.task-diff-line[data-v-ee7937d4] .task-diff-line__prefix--context{color:color-mix(in srgb,var(--theme-textPrimary) 35%,transparent)}.task-diff-line[data-v-ee7937d4] .task-diff-line__body{display:inline}.task-diff-line--plain[data-v-ee7937d4]{color:inherit}