@muyichengshayu/promptx 0.1.34 → 0.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.35
4
+
5
+ - 收敛中栏消息卡片布局:`PromptX / 执行 / 回复` 三类主卡片统一为满宽展示,标题样式与时间信息位置更一致,阅读节奏更接近标准对话流。
6
+ - 继续简化中栏细节:`PromptX` 附图改为直接展示图片本身,不再额外挂一层“本轮附图”卡片;项目选择器加载文案也收短为 `加载... / Loading...`。
7
+ - 统一消息卡片边框语义:中栏主卡片的虚线边框统一使用 `--theme-borderDefault`,同时补齐毛玻璃主题下部分内容面板的圆角一致性,避免局部观感发飘。
8
+
3
9
  ## 0.1.34
4
10
 
5
11
  - 统一图片预览层遮罩,直接复用和工作台弹窗一致的 `theme-modal-backdrop`,不再单独维护一套 overlay 背景,避免预览层与其它弹窗视觉割裂。
@@ -1 +1 @@
1
- import{u as ye,f as st,d as lt}from"./index-CGOI_HcK.js";import{A as it,n as Pe,e as _e,r as ot,b as Ge,s as rt,f as ze,_ as dt,a as ct,h as Ue}from"./WorkbenchView-CMjjT7fc.js";import{w as he,aB as p,aG as se,aH as le,aD as t,aO as o,u as a,aE as S,aU as ut,aV as pt,aJ as P,aC as f,aP as xe,aQ as Ce,aL as j,aT as mt,aI as gt,b as $,c as _,aX as Je,ak as ft,r as vt,n as ht}from"./vendor-misc-CWjGI0ex.js";import{g as He,h as ve,L as Ie,j as xt,b as Ke,H as yt,m as bt,v as wt,P as St,d as Ve,J as kt,l as $t,p as _t,K as Ct}from"./vendor-ui-D4mCpibF.js";import"./vendor-router-Bcjfmow0.js";import"./vendor-markdown-CNlC48LI.js";import"./vendor-tiptap-BCwG_IWj.js";function Mt(i=[]){return(Array.isArray(i)&&i.length?i:it).filter(u=>u&&typeof u=="object").map(u=>{const k=Pe(u.value);return{...u,value:k,label:String(u.label||_e(k)).trim()||_e(k),enabled:u.enabled!==!1,available:u.available!==!1}})}function Te(i=[]){return Mt(i).filter(T=>T.enabled&&T.available)}async function jt(){const i=await ot("/api/meta",{cache:"no-store"});return Te(i==null?void 0:i.agentEngineOptions)}const It={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Pt={class:"theme-muted-text mt-1 text-xs leading-5"},Tt={class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Rt={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},Dt={class:"flex items-start gap-2 text-xs leading-5"},Et={class:"theme-muted-text shrink-0"},Lt={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},Ft={class:"theme-muted-text mt-4 block text-xs"},Bt={class:"theme-input-shell mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2"},At=["placeholder"],Nt={class:"mt-4 flex items-center gap-1.5"},Ot={class:"theme-content-panel mt-3 min-h-0 flex-1 overflow-y-auto p-2"},zt={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},Ut={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},Ht={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},Vt={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},qt={key:4,class:"theme-empty-state px-3 py-8 text-sm"},Wt={key:5,class:"theme-empty-state px-3 py-8 text-sm"},Gt={key:6,class:"theme-empty-state px-3 py-8 text-sm"},Jt={key:7,class:"space-y-1"},Kt=["onClick"],Qt={class:"min-w-0 flex-1"},Xt=["innerHTML"],Yt=["innerHTML"],Zt={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},en={key:8,class:"space-y-1"},tn={class:"flex items-start gap-1.5"},nn=["onClick"],an=["onClick"],sn={class:"min-w-0 flex-1"},ln={key:0,class:"theme-muted-text truncate font-mono text-[10px]"},on={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"},rn={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},dn=["disabled"],cn=["disabled"],un={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""},suggestions:{type:Array,default:()=>[]}},emits:["close","select"],setup(i,{emit:T}){const u=i,k=T,{t:v}=ye(),c=$(""),h=$(null),M=$(!1),r=$(""),d=$(!1),w=$(""),L=$([]),F=$(!1),R=$(""),C=$("tree"),E=$(""),G=$("");let B=null,A=0;const J=_(()=>de(h.value?[h.value]:[])),O=_(()=>C.value==="search"&&!R.value.trim()),ie=_(()=>C.value==="search"&&!!R.value.trim()&&!d.value&&!w.value&&!L.value.length),V=_(()=>C.value==="tree"&&!M.value&&!r.value&&!J.value.length);function ne(n=""){const m=String(n||"").trim();return/^[a-z]:[\\/]/i.test(m)||m.includes("\\")}function b(n=""){const m=String(n||"").trim();if(!m)return"";const l=ne(m);let g=m.replace(/\\/g,"/");return g.length>1&&!/^[a-z]:\/?$/i.test(g)&&g!=="/"&&(g=g.replace(/\/+$/,"")),l?g.toLowerCase():g}function Z(n="",m=""){const l=b(n),g=b(m);return!l||!g?!1:l===g||l.startsWith(`${g}/`)}function Me(n="",m=""){const l=String(n||"").trim(),g=String(m||"").trim();return l?g?ne(l)?/^[a-z]:\\?$/i.test(l)?`${l.replace(/[\\/]+$/,"")}\\${g}`:`${l.replace(/[\\/]+$/,"")}\\${g}`:l==="/"?`/${g}`:`${l.replace(/\/+$/,"")}/${g}`:l:g}function ae(n="",m=""){const l=b(n),g=b(m);if(!l||!g||!Z(g,l))return[];const D=g===l?"":g.slice(l.length).replace(/^\//,"");return D?D.split("/").filter(Boolean):[]}function K(n){return(n==null?void 0:n.name)||(n==null?void 0:n.path)||v("directoryPicker.unnamedDirectory")}function oe(n=""){const m=String(n||"").trim();return m?m.split(/[\\/]/).filter(Boolean).at(-1)||m:"Home"}function q(n=""){return String(n||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function I(n="",m=""){const l=String(n||""),g=String(m||"").trim().toLowerCase();if(!l||!g)return null;const D=l.toLowerCase(),U=D.indexOf(g);if(U>=0)return{start:U,end:U+g.length};const $e=g.split(/[\\/\s_.-]+/).filter(Boolean).sort((W,Y)=>Y.length-W.length);for(const W of $e){if(W.length<2)continue;const Y=D.indexOf(W);if(Y>=0)return{start:Y,end:Y+W.length}}return null}function be(n="",m=""){const l=String(n||""),g=I(l,m);return g?`${q(l.slice(0,g.start))}<mark class="theme-search-highlight">${q(l.slice(g.start,g.end))}</mark>${q(l.slice(g.end))}`:q(l)}function re(n){return be(K(n),R.value)}function we(n){return be((n==null?void 0:n.path)||"",R.value)}function ee(n,m=0){return{...n,depth:m,expanded:!1,loaded:!1,loading:!1,children:[]}}function de(n=[],m=[]){return n.forEach(l=>{m.push(l),l.expanded&&l.children.length&&de(l.children,m)}),m}function Q(){h.value&&(h.value={...h.value})}function ce(n,m=h.value?[h.value]:[]){const l=b(n);if(!l)return null;for(const g of m){if(b(g.path)===l)return g;if(g.children.length){const D=ce(n,g.children);if(D)return D}}return null}function X(n){E.value=String((n==null?void 0:n.path)||"").trim(),G.value=K(n)}async function ue(n,m={}){if(!(!n||n.loading)&&!(n.loaded&&!m.force)){n.loading=!0,r.value="",Q();try{const l=await ze({path:n.path,limit:240});n.children=(l.items||[]).map(g=>ee(g,n.depth+1)),n.loaded=!0}catch(l){r.value=l.message||v("directoryPicker.loadFailed")}finally{n.loading=!1,Q()}}}async function je(){M.value=!0,r.value="";try{const n=await ze({limit:240});c.value=String(n.path||""),h.value=ee({name:oe(n.path||""),path:String(n.path||""),type:"directory",hasChildren:!0,isHomeRoot:!0},0),h.value.children=(n.items||[]).map(m=>ee(m,1)),h.value.loaded=!0,h.value.expanded=!0,X(h.value)}catch(n){r.value=n.message||v("directoryPicker.treeLoadFailed"),h.value=null,c.value=""}finally{M.value=!1}}async function pe(n=""){const m=String(n||"").trim();if(!m||!c.value||!Z(m,c.value))return;let l=h.value;if(!l)return;X(l);const g=ae(c.value,m);for(const D of g){await ue(l),l.expanded=!0,Q();const U=ce(Me(l.path,D),l.children);if(!U)break;l=U,X(l)}}async function Se(){R.value="",C.value="tree",L.value=[],w.value="",F.value=!1,E.value="",G.value="",await je();const n=String(u.initialPath||"").trim();n&&Z(n,c.value)&&await pe(n)}async function z(n){if(n!=null&&n.path&&(X(n),!!n.hasChildren)){if(!n.loaded){n.expanded=!0,Q(),await ue(n);return}n.expanded=!n.expanded,Q()}}function te(n){n!=null&&n.path&&(X(n),C.value="tree")}async function ke(){const n=String(R.value||"").trim();A+=1;const m=A;if(!u.open||!n||!c.value){d.value=!1,w.value="",L.value=[],F.value=!1;return}d.value=!0,w.value="";try{const l=await rt(n,{path:c.value,limit:80});if(m!==A)return;L.value=Array.isArray(l.items)?l.items:[],F.value=!!l.truncated}catch(l){if(m!==A)return;w.value=l.message||v("directoryPicker.searchFailed"),L.value=[],F.value=!1}finally{m===A&&(d.value=!1)}}function me(){if(B&&(window.clearTimeout(B),B=null),!String(R.value||"").trim()){d.value=!1,w.value="",L.value=[],F.value=!1;return}d.value=!0,w.value="",B=window.setTimeout(()=>{ke()},120)}async function ge(n){n!=null&&n.path&&(C.value="tree",await pe(n.path))}function fe(){E.value&&(k("select",E.value),k("close"))}return he(R,()=>{C.value=R.value.trim()?"search":"tree",me()}),he(()=>u.open,n=>{if(n){Se().catch(()=>{});return}B&&(window.clearTimeout(B),B=null)}),(n,m)=>(p(),se(Ge,{open:i.open,"backdrop-class":"z-[60] items-end justify-center px-0 py-0 sm:items-center sm:px-4 sm:py-6","panel-class":"settings-dialog-panel h-full max-w-4xl sm:h-auto sm:max-h-[86vh]","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":M.value||d.value,"close-on-backdrop":!(M.value||d.value),"close-on-escape":!(M.value||d.value),onClose:m[4]||(m[4]=l=>k("close"))},{title:le(()=>[t("div",null,[t("div",It,[S(a(ve),{class:"h-4 w-4"}),t("span",null,o(a(v)("directoryPicker.title")),1)]),t("p",Pt,o(a(v)("directoryPicker.intro")),1)])]),default:le(()=>[t("div",Tt,[t("div",Rt,[t("div",Dt,[t("span",Et,o(a(v)("directoryPicker.currentSelection")),1),t("span",Lt,o(E.value||a(v)("directoryPicker.selectionPlaceholder")),1)])]),t("label",Ft,[t("span",null,o(a(v)("directoryPicker.searchLabel")),1),t("div",Bt,[S(a(He),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),ut(t("input",{"onUpdate:modelValue":m[0]||(m[0]=l=>R.value=l),type:"text",placeholder:a(v)("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)]"},null,8,At),[[pt,R.value]])])]),t("div",Nt,[t("button",{type:"button",class:P(["inline-flex h-8 items-center gap-1 rounded-sm border px-2 text-[11px] transition",C.value==="search"?"tool-button-accent-subtle":"theme-filter-idle border-dashed"]),onClick:m[1]||(m[1]=l=>C.value="search")},[S(a(He),{class:"h-3.5 w-3.5"}),t("span",null,o(a(v)("directoryPicker.searchTab")),1)],2),t("button",{type:"button",class:P(["inline-flex h-8 items-center gap-1 rounded-sm border px-2 text-[11px] transition",C.value==="tree"?"tool-button-accent-subtle":"theme-filter-idle border-dashed"]),onClick:m[2]||(m[2]=l=>C.value="tree")},[S(a(ve),{class:"h-3.5 w-3.5"}),t("span",null,o(a(v)("directoryPicker.treeTab")),1)],2)]),t("div",Ot,[C.value==="search"&&w.value?(p(),f("div",zt,o(w.value),1)):C.value==="tree"&&r.value?(p(),f("div",Ut,o(r.value),1)):C.value==="search"&&d.value?(p(),f("div",Ht,[S(a(Ie),{class:"h-4 w-4 animate-spin"}),t("span",null,o(a(v)("directoryPicker.searching")),1)])):C.value==="tree"&&M.value?(p(),f("div",Vt,[S(a(Ie),{class:"h-4 w-4 animate-spin"}),t("span",null,o(a(v)("directoryPicker.treeLoading")),1)])):O.value?(p(),f("div",qt,o(a(v)("directoryPicker.searchPrompt")),1)):ie.value?(p(),f("div",Wt,o(a(v)("directoryPicker.noSearchResults")),1)):V.value?(p(),f("div",Gt,o(a(v)("directoryPicker.emptyTree")),1)):C.value==="search"?(p(),f("div",Jt,[(p(!0),f(xe,null,Ce(L.value,l=>(p(),f("button",{key:l.path,type:"button",class:P(["flex w-full items-start gap-2 rounded-sm border border-transparent px-2.5 py-1.5 text-left transition",b(E.value)===b(l.path)?"theme-list-item-active":"theme-list-item-hover"]),onClick:g=>ge(l)},[S(a(ve),{class:"theme-muted-text mt-0.5 h-4 w-4 shrink-0"}),t("div",Qt,[t("div",null,[t("span",{class:"truncate text-[13px] text-[var(--theme-textPrimary)]",innerHTML:re(l)},null,8,Xt)]),t("div",{class:"theme-muted-text truncate font-mono text-[10px]",innerHTML:we(l)},null,8,Yt)])],10,Kt))),128)),F.value?(p(),f("p",Zt,o(a(v)("directoryPicker.truncatedHint")),1)):j("",!0)])):(p(),f("div",en,[(p(!0),f(xe,null,Ce(J.value,l=>(p(),f("div",{key:l.path,class:P(["rounded-sm border border-transparent px-1.5 py-1 transition",b(E.value)===b(l.path)?"theme-list-item-active":l.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:mt({paddingLeft:`${l.depth*16+6}px`})},[t("div",tn,[t("button",{type:"button",class:P(["theme-icon-button h-5 w-5 shrink-0",l.hasChildren?"":"invisible pointer-events-none"]),onClick:gt(g=>z(l),["stop"])},[l.loading?(p(),se(a(Ie),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(p(),se(a(xt),{key:1,class:P(["h-3.5 w-3.5 transition",l.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,nn),t("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:g=>te(l)},[S(a(ve),{class:P(["h-4 w-4 shrink-0",b(E.value)===b(l.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),t("div",sn,[t("div",{class:P(["truncate text-[13px]",l.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},o(K(l)),3),l.isHomeRoot?(p(),f("div",ln,o(l.path),1)):j("",!0)])],8,an)])],6))),128))]))])]),t("div",on,[t("div",rn,[t("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:M.value||d.value,onClick:m[3]||(m[3]=l=>k("close"))},o(a(v)("directoryPicker.cancel")),9,dn),t("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:M.value||d.value||!E.value,onClick:fe},[S(a(Ke),{class:"h-4 w-4"}),t("span",null,o(a(v)("directoryPicker.useCurrentDirectory")),1)],8,cn)])])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},pn={class:"grid gap-4"},mn={class:"theme-muted-text block text-xs"},gn=["value","disabled"],fn={class:"theme-muted-text block text-xs"},vn={class:"mt-1 flex gap-2"},hn=["value","disabled"],xn=["disabled"],yn={id:"codex-manager-workspace-suggestions"},bn=["value"],wn={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Sn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},kn={class:"theme-muted-text block text-xs"},$n={class:"mt-1"},_n={class:"flex items-center gap-2 text-sm"},Cn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Mn=["disabled","onClick"],jn={class:"flex items-center justify-between gap-3"},In={class:"min-w-0 flex-1 truncate"},Pn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Tn={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},Rn={class:"theme-muted-text block text-xs"},Dn={class:"mt-1 flex gap-2"},En=["value","disabled"],Ln=["disabled"],Fn={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},Bn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},qe={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},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:""},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["copy-session-id","open-directory-picker","update:cwd","update:engine","update:sessionId","update:title"],setup(i,{emit:T}){const u=i,k=T,{t:v}=ye(),c=_(()=>{const M=String(u.engine||"").trim();return u.engineOptions.find(r=>String((r==null?void 0:r.value)||"").trim()===M)||null}),h=_(()=>String(u.sessionId||"").trim());return(M,r)=>(p(),f("div",pn,[t("label",mn,[t("span",null,o(a(v)("projectManager.projectTitleOptional")),1),t("input",{value:i.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:i.busy,onInput:r[0]||(r[0]=d=>k("update:title",d.target.value))},null,40,gn)]),t("label",fn,[t("span",null,o(a(v)("projectManager.workingDirectoryField")),1),t("div",vn,[t("input",{value:i.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:P(["tool-input min-w-0 flex-1 disabled:cursor-not-allowed disabled:opacity-80",i.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:i.busy||!i.canEditCwd,onInput:r[1]||(r[1]=d=>k("update:cwd",d.target.value))},null,42,hn),t("button",{type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:i.busy||!i.canEditCwd,onClick:r[2]||(r[2]=d=>k("open-directory-picker"))},[S(a(ve),{class:"h-4 w-4"}),t("span",null,o(i.mobile?a(v)("projectManager.choose"):a(v)("projectManager.chooseDirectory")),1)],8,xn)]),t("datalist",yn,[(p(!0),f(xe,null,Ce(i.workspaceSuggestions,d=>(p(),f("option",{key:d,value:d},null,8,bn))),128))]),i.duplicateCwdMessage?(p(),f("p",wn,o(i.duplicateCwdMessage),1)):i.cwdReadonlyMessage?(p(),f("p",Sn,o(i.cwdReadonlyMessage),1)):j("",!0)]),t("label",kn,[t("span",null,o(a(v)("projectManager.engineField")),1),t("div",$n,[S(dt,{"model-value":i.engine,options:i.engineOptions,disabled:i.busy||!i.canEditEngine,placeholder:a(v)("projectManager.selectEngine"),"empty-text":a(v)("projectManager.noEngines"),"get-option-value":d=>(d==null?void 0:d.value)||"","onUpdate:modelValue":r[3]||(r[3]=d=>k("update:engine",d))},{trigger:le(({disabled:d})=>{var w;return[t("div",_n,[t("span",{class:P(["min-w-0 flex-1 truncate",d?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},o(((w=c.value)==null?void 0:w.label)||a(v)("projectManager.selectEngine")),3),c.value&&c.value.enabled===!1?(p(),f("span",Cn,o(a(v)("projectManager.comingSoon")),1)):j("",!0)])]}),option:le(({option:d,selected:w,select:L})=>[t("button",{type:"button",class:P(["w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm transition",w?"theme-filter-active":"theme-filter-idle"]),disabled:(d==null?void 0:d.enabled)===!1,onClick:L},[t("div",jn,[t("span",In,o(d.label),1),(d==null?void 0:d.enabled)===!1?(p(),f("span",Pn,o(a(v)("projectManager.comingSoon")),1)):j("",!0)])],10,Mn)]),_:1},8,["model-value","options","disabled","placeholder","empty-text","get-option-value"])]),i.engineReadonlyMessage?(p(),f("p",Tn,o(i.engineReadonlyMessage),1)):j("",!0)]),t("label",Rn,[t("span",null,o(a(v)("projectManager.sessionId")),1),t("div",Dn,[t("input",{value:i.sessionId,type:"text",placeholder:"",class:"tool-input min-w-0 flex-1 disabled:cursor-not-allowed disabled:opacity-80",disabled:i.busy||!i.canEditSessionId,onInput:r[4]||(r[4]=d=>k("update:sessionId",d.target.value))},null,40,En),h.value?(p(),f("button",{key:0,type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:i.busy,onClick:r[5]||(r[5]=d=>k("copy-session-id"))},[i.sessionIdCopied?(p(),se(a(Ke),{key:0,class:"h-4 w-4"})):(p(),se(a(yt),{key:1,class:"h-4 w-4"})),t("span",null,o(i.sessionIdCopied?a(v)("projectManager.sessionIdCopied"):a(v)("projectManager.copySessionId")),1)],8,Ln)):j("",!0)]),i.sessionIdReadonlyMessage?(p(),f("p",Fn,o(i.sessionIdReadonlyMessage),1)):(p(),f("p",Bn,o(a(v)("projectManager.sessionIdHint")),1))])]))}},An={class:"flex items-center justify-between gap-3"},Nn={class:"theme-heading text-sm font-medium"},On={key:0,class:"theme-muted-text mt-1 text-xs"},zn=["disabled"],Un=["onClick"],Hn={key:0,class:"theme-selection-indicator absolute inset-y-3 left-0 w-1 rounded-full"},Vn={class:"flex w-full flex-col gap-2 text-left"},qn={class:"theme-heading min-w-0 text-sm font-medium"},Wn=["title"],Gn=["title"],Jn={class:"theme-muted-text flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] leading-5"},Kn={key:0,"aria-hidden":"true"},Qn={key:1},Xn={class:"flex flex-wrap items-center gap-2 pt-1"},Yn={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},We={__name:"CodexSessionManagerList",props:{busy:{type:Boolean,default:!1},editingSessionId:{type:String,default:""},formatUpdatedAt:{type:Function,default:i=>i},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(i,{emit:T}){const u=i,k=T,{t:v}=ye();function c(r){return u.mode==="edit"&&u.editingSessionId===r.id?"theme-card-selected":u.isSessionRunning(r.id)?"theme-card-warning":"theme-card-idle-strong"}function h(r){return u.isCurrentSession(r.id)?v("projectManager.current"):v("projectManager.regular")}function M(r){return u.isCurrentSession(r.id)?"theme-status-info":"theme-status-neutral"}return(r,d)=>(p(),f("div",{class:P(i.mobile?"flex h-full min-h-0 flex-col":"")},[t("div",An,[t("div",null,[t("div",Nn,o(a(v)("projectManager.projectList")),1),i.hasSessions?j("",!0):(p(),f("p",On,o(a(v)("projectManager.noProjects")),1))]),t("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:i.busy,onClick:d[0]||(d[0]=w=>k("create"))},[S(a(bt),{class:"h-4 w-4"}),t("span",null,o(a(v)("projectManager.create")),1)],8,zn)]),t("div",{class:P(["mt-4 space-y-2",i.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)]"])},[(p(!0),f(xe,null,Ce(i.sessions,w=>(p(),f("article",{key:w.id,class:P(["relative cursor-pointer rounded-sm border p-3 transition",c(w)]),onClick:L=>k("select",w.id)},[i.mode==="edit"&&i.editingSessionId===w.id?(p(),f("span",Hn)):j("",!0),t("div",Vn,[t("div",qn,[t("span",{class:"block truncate",title:w.title||a(v)("projectManager.untitledProject")},o(w.title||a(v)("projectManager.untitledProject")),9,Wn)]),t("div",{class:"theme-muted-text break-all font-mono text-[11px] leading-5",title:w.cwd},o(w.cwd),9,Gn),t("div",Jn,[t("span",null,o(a(_e)(w.engine)),1),i.mobile?j("",!0):(p(),f("span",Kn,"·")),i.mobile?j("",!0):(p(),f("span",Qn,o(i.formatUpdatedAt(w.updatedAt)),1))]),t("div",Xn,[t("span",{class:P(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",M(w)])},o(h(w)),3),t("span",{class:P(["inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",i.getRuntimeStatusClass(w.id)])},[i.isSessionRunning(w.id)?(p(),f("span",Yn)):j("",!0),Je(" "+o(i.getRuntimeStatusLabel(w.id)),1)],2),t("span",{class:P(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",i.getThreadStatusClass(w)])},o(i.getThreadStatusLabel(w)),3)])])],10,Un))),128))],2)],2))}},Zn={class:"space-y-3"},ea={class:"dashed-panel px-3 py-3"},ta={class:"theme-muted-text text-[11px]"},na={class:"mt-2 flex flex-wrap gap-2"},aa={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},sa={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},la={class:"dashed-panel px-3 py-3"},ia={class:"theme-muted-text text-[11px]"},oa={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},ra={class:"dashed-panel px-3 py-3"},da={class:"theme-muted-text text-[11px]"},ca={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},ua={class:"dashed-panel px-3 py-3"},pa={class:"theme-muted-text text-[11px]"},ma={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},ga={class:"dashed-panel px-3 py-3"},fa={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},va={class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"},ha={__name:"CodexSessionManagerStatus",props:{activeSession:{type:Object,default:null},formatUpdatedAt:{type:Function,default:i=>i},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(i){const{t:T}=ye();return(u,k)=>{var v,c,h,M,r,d,w;return p(),f("div",Zn,[t("div",ea,[t("div",ta,o(a(T)("projectManager.runtimeStatus")),1),t("div",na,[t("span",{class:P(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",i.getRuntimeStatusClass((v=i.activeSession)==null?void 0:v.id)])},[i.isSessionRunning((c=i.activeSession)==null?void 0:c.id)?(p(),f("span",aa)):j("",!0),Je(" "+o(i.getRuntimeStatusLabel((h=i.activeSession)==null?void 0:h.id)),1)],2),t("span",{class:P(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",i.getThreadStatusClass(i.activeSession)])},o(i.getThreadStatusLabel(i.activeSession)),3),(M=i.activeSession)!=null&&M.id&&i.isCurrentSession(i.activeSession.id)?(p(),f("span",sa,o(a(T)("projectManager.currentProject")),1)):j("",!0)])]),t("div",la,[t("div",ia,o(a(T)("projectManager.engine")),1),t("div",oa,o(a(_e)((r=i.activeSession)==null?void 0:r.engine)),1)]),t("div",ra,[t("div",da,o(a(T)("projectManager.workingDirectory")),1),t("div",ca,o(((d=i.activeSession)==null?void 0:d.cwd)||a(T)("projectManager.notSet")),1)]),t("div",ua,[t("div",pa,o(a(T)("projectManager.updatedAt")),1),t("div",ma,o(i.formatUpdatedAt((w=i.activeSession)==null?void 0:w.updatedAt)),1)]),t("div",ga,[t("div",fa,[S(a(wt),{class:"h-3.5 w-3.5"}),t("span",null,o(a(T)("projectManager.note")),1)]),t("p",va,o(a(T)("projectManager.noteDescription")),1)])])}}},xa={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ya={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},ba={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"},wa={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},Sa={class:"flex flex-wrap items-start justify-between gap-3"},ka={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},$a={class:"mt-5"},_a={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Ca={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"},Ma={class:"flex flex-wrap items-center gap-2"},ja=["disabled"],Ia=["disabled"],Pa={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Ta=["disabled"],Ra=["disabled"],Da=["disabled"],Ea={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},La={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Fa={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},Ba={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Aa={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Na=["disabled"],Oa={class:"min-w-0 flex-1"},za={class:"theme-heading truncate text-sm font-medium"},Ua={key:0,class:"theme-muted-text mt-1 truncate text-xs"},Ha={class:"theme-divider border-b px-4 py-3"},Va={class:"grid grid-cols-2 gap-2"},qa=["disabled"],Wa={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},Ga={key:0},Ja={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Ka={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},Qa=["disabled"],Xa=["disabled"],Ya=["disabled"],is={__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"],setup(i,{emit:T}){const u=i,k=T,{locale:v,t:c}=ye(),h=$("edit"),M=$(""),r=vt({title:"",engine:"codex",cwd:"",sessionId:""}),d=$(""),w=$(!1),L=$(!1),F=$(!1),R=$(!1),C=$(!1),E=$(!1),G=$(!1),B=$(!1),{matches:A}=ct("(max-width: 767px)"),J=$("list"),O=$("basic"),ie=$(Te());let V=null;const ne=_(()=>ke(u.sessions)),b=_(()=>u.sessions.find(e=>e.id===M.value)||null),Z=_(()=>u.sessions.length>0),Me=_(()=>u.sessions.find(e=>e.id===u.selectedSessionId)||null),ae=_(()=>!!(b.value&&z(b.value.id))),K=_(()=>{var e;return!((e=b.value)!=null&&e.started)}),oe=_(()=>{var e;return!((e=b.value)!=null&&e.started)}),q=_(()=>{var e;return!((e=b.value)!=null&&e.started)}),I=_(()=>u.loading||w.value||L.value||F.value||R.value),be=_(()=>String(r.sessionId||"").trim()),re=_(()=>{var x,y;const e=new Set,s=[];return[r.cwd,(x=b.value)==null?void 0:x.cwd,(y=Me.value)==null?void 0:y.cwd,...u.workspaces,...u.sessions.map(H=>H.cwd)].forEach(H=>{const N=String(H||"").trim();!N||e.has(N)||(e.add(N),s.push(N))}),s.slice(0,12)}),we=_(()=>ie.value),ee=_(()=>{const e=Se(r.cwd);return e?u.sessions.filter(s=>{var x;return s.id===((x=b.value)==null?void 0:x.id)?!1:Se(s.cwd)===e}):[]}),de=_(()=>{if(!ee.value.length)return"";const e=ee.value.slice(0,3).map(s=>{const x=s.title||c("projectManager.untitledProject");return v.value==="en-US"?`"${x}"`:`「${x}」`}).join(v.value==="en-US"?", ":"、");return c("projectManager.duplicateDirectory",{labels:e,count:ee.value.length})}),Q=_(()=>h.value!=="edit"||K.value?"":c("projectManager.cwdReadonly")),ce=_(()=>h.value!=="edit"||!b.value||oe.value?"":c("projectManager.engineReadonly")),X=_(()=>h.value!=="edit"||!b.value||q.value?"":c("projectManager.sessionIdReadonly")),ue=_(()=>h.value==="create"?w.value?c("projectManager.creatingProject"):c("projectManager.createProject"):L.value?c("projectManager.savingChanges"):c("projectManager.saveChanges")),je=_(()=>{var e;return h.value==="create"?c("projectManager.newProject"):((e=b.value)==null?void 0:e.title)||c("projectManager.untitledProject")});function pe(e=""){const s=Date.parse(String(e||""));return Number.isFinite(s)?s:0}function Se(e=""){const s=String(e||"").trim();if(!s)return"";const x=/^[a-z]:[\\/]/i.test(s)||s.includes("\\");let y=s.replace(/\\/g,"/");return y.length>1&&!/^[a-z]:\/$/i.test(y)&&(y=y.replace(/\/+$/,"")),x?y.toLowerCase():y}function z(e){var s;return!!((s=u.sessions.find(x=>x.id===e))!=null&&s.running)}function te(e){return!!e&&e===u.selectedSessionId}function ke(e=[]){return[...e].sort((s,x)=>{const y=Number(z(x.id))-Number(z(s.id));if(y)return y;const H=Number(te(x.id))-Number(te(s.id));if(H)return H;const N=pe(x.updatedAt)-pe(s.updatedAt);return N||lt(String(s.title||s.cwd||s.id),String(x.title||x.cwd||x.id))})}function me(e){return z(e)?c("projectManager.running"):c("projectManager.idle")}function ge(e){return z(e)?"theme-status-warning":"theme-status-success"}function fe(e){return e!=null&&e.started?c("projectManager.threadBound"):c("projectManager.notStarted")}function n(e){return e!=null&&e.started?"theme-status-success":"theme-status-neutral"}function m(e=""){if(!e)return c("projectManager.unknown");const s=new Date(e);return Number.isNaN(s.getTime())?e:st(s.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}function l(e){r.title=String((e==null?void 0:e.title)||""),r.engine=Pe(e==null?void 0:e.engine),r.cwd=String((e==null?void 0:e.cwd)||""),r.sessionId=String((e==null?void 0:e.sessionId)||(e==null?void 0:e.engineSessionId)||(e==null?void 0:e.engineThreadId)||(e==null?void 0:e.codexThreadId)||"").trim()}function g(){h.value="create",M.value="",d.value="",r.title="",r.engine="codex",r.cwd="",r.sessionId=""}function D(e){const s=u.sessions.find(x=>x.id===e);s&&(h.value="edit",M.value=s.id,d.value="",l(s))}function U(){var e;return u.selectedSessionId&&u.sessions.some(s=>s.id===u.selectedSessionId)?u.selectedSessionId:((e=ne.value[0])==null?void 0:e.id)||""}function $e(e="basic"){J.value="detail",O.value=e}function W(){J.value="list",O.value="basic"}function Y(){g(),A.value&&$e("basic")}function Re(e){I.value||(D(e),A.value&&$e("basic"))}function Qe(e){r.cwd=String(e||"").trim()}function De(e){r.title=String(e||"")}function Ee(e){r.engine=Pe(e)}function Le(e){r.cwd=String(e||"")}function Fe(e){r.sessionId=String(e||"")}function Be(){d.value="",C.value=!1,E.value=!1,B.value=!1,O.value="basic",J.value=A.value?"list":"detail";const e=U();if(e){D(e);return}g()}async function Xe(){if(!(I.value||typeof u.onRefresh!="function")){d.value="";try{await Promise.all([u.onRefresh(),Ae()])}catch(e){d.value=e.message}}}async function Ae(){try{ie.value=await jt()}catch{ie.value=Te()}}async function Ye(e){var x;if((x=navigator.clipboard)!=null&&x.writeText&&window.isSecureContext){await navigator.clipboard.writeText(e);return}const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly","true"),s.style.position="fixed",s.style.opacity="0",s.style.pointerEvents="none",document.body.appendChild(s),s.select(),document.execCommand("copy"),document.body.removeChild(s)}async function Ne(){const e=be.value;if(e)try{await Ye(e),B.value=!0,V&&clearTimeout(V),V=setTimeout(()=>{B.value=!1,V=null},1800)}catch(s){d.value=(s==null?void 0:s.message)||c("projectManager.copySessionIdFailed")}}async function Oe(){if(!I.value){d.value="";try{const e=Ze();if(!e)return;await et(e)}catch(e){d.value=e.message}}}function Ze(){if(h.value==="create"){const s=String(r.cwd||"").trim();return s?{type:"create",cwd:s,payload:{title:r.title,engine:r.engine,cwd:s,sessionId:String(r.sessionId||"").trim()}}:(d.value=c("projectManager.directoryRequired"),null)}if(!b.value)return d.value=c("projectManager.projectMissing"),null;const e={title:r.title,engine:r.engine};return K.value&&(e.cwd=r.cwd),q.value&&(e.sessionId=String(r.sessionId||"").trim()),{type:"update",sessionId:b.value.id,payload:e}}async function et(e){var s,x;if(e.type==="create"){w.value=!0;try{const y=await((s=u.onCreate)==null?void 0:s.call(u,e.payload));y!=null&&y.id&&(D(y.id),k("select-session",y.id),await ht(),k("project-created",y),k("close"));return}finally{w.value=!1}}L.value=!0;try{const y=await((x=u.onUpdate)==null?void 0:x.call(u,e.sessionId,e.payload));y!=null&&y.id&&D(y.id)}finally{L.value=!1}}async function tt(){var s,x;if(!b.value||F.value)return;const e=b.value.id;d.value="",F.value=!0;try{const y=await((s=u.onDelete)==null?void 0:s.call(u,e));C.value=!1;const H=u.sessions.filter(at=>at.id!==e),N=(y==null?void 0:y.selectedSessionId)||((x=ke(H)[0])==null?void 0:x.id)||"";k("select-session",N),N?(D(N),A.value&&W()):(g(),A.value&&W())}catch(y){d.value=y.message}finally{F.value=!1}}async function nt(){var s;if(!b.value||R.value)return;const e=b.value.id;d.value="",R.value=!0;try{const x=await((s=u.onReset)==null?void 0:s.call(u,e));E.value=!1;const y=(x==null?void 0:x.session)||u.sessions.find(H=>H.id===e)||null;y!=null&&y.id&&D(y.id)}catch(x){d.value=x.message}finally{R.value=!1}}return he(()=>u.open,e=>{if(e){Be(),typeof u.onRefresh=="function"?Xe().catch(()=>{}):Ae().catch(()=>{});return}G.value=!1,C.value=!1,E.value=!1,B.value=!1,d.value=""},{immediate:!0}),he(A,e=>{e||(J.value="detail")},{immediate:!0}),he(()=>u.sessions,()=>{if(!u.open)return;if(h.value==="create"){if(!!(String(r.title||"").trim()||String(r.cwd||"").trim())||!!String(r.sessionId||"").trim())return;const x=U();x&&D(x);return}if(b.value){l(b.value);return}const e=U();if(e){D(e);return}g()}),ft(()=>{V&&(clearTimeout(V),V=null)}),(e,s)=>(p(),f(xe,null,[S(Ue,{open:E.value,title:a(c)("projectManager.confirmResetTitle"),description:b.value?a(c)("projectManager.confirmResetDescription",{title:b.value.title||a(c)("projectManager.untitledProject")}):"","confirm-text":a(c)("projectManager.confirmReset"),"cancel-text":a(c)("projectManager.keep"),loading:R.value,onCancel:s[0]||(s[0]=x=>E.value=!1),onConfirm:nt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),S(Ue,{open:C.value,title:a(c)("projectManager.confirmDeleteTitle"),description:b.value?a(c)("projectManager.confirmDeleteDescription",{title:b.value.title||a(c)("projectManager.untitledProject")}):"","confirm-text":a(c)("projectManager.confirmDelete"),"cancel-text":a(c)("projectManager.keep"),loading:F.value,danger:"",onCancel:s[1]||(s[1]=x=>C.value=!1),onConfirm:tt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),S(un,{open:G.value,"initial-path":r.cwd,suggestions:re.value,onClose:s[2]||(s[2]=x=>G.value=!1),onSelect:Qe},null,8,["open","initial-path","suggestions"]),S(Ge,{open:i.open,"panel-class":"settings-dialog-panel h-full max-w-5xl sm:h-auto sm:max-h-[88vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 overflow-hidden","close-disabled":I.value,"close-on-backdrop":!I.value,"close-on-escape":!I.value,onClose:s[12]||(s[12]=x=>k("close"))},{title:le(()=>[t("div",xa,[S(a(Ct),{class:"h-4 w-4"}),t("span",null,o(a(c)("projectManager.managingTitle")),1)])]),default:le(()=>{var x;return[a(A)?(p(),f("div",Ea,[J.value==="list"?(p(),f("div",La,[t("div",Fa,[S(We,{mobile:"",busy:I.value,"editing-session-id":M.value,"format-updated-at":m,"get-runtime-status-class":ge,"get-runtime-status-label":me,"get-thread-status-class":n,"get-thread-status-label":fe,"has-sessions":Z.value,"is-current-session":te,"is-session-running":z,mode:h.value,sessions:ne.value,onCreate:Y,onSelect:Re},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])])])):(p(),f("div",Ba,[t("div",Aa,[t("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",disabled:I.value,onClick:W},[S(a(_t),{class:"h-4 w-4"}),t("span",null,o(a(c)("projectManager.projectList")),1)],8,Na),t("div",Oa,[t("div",za,o(je.value),1),h.value==="edit"&&((x=b.value)!=null&&x.cwd)?(p(),f("p",Ua,o(b.value.cwd),1)):j("",!0)])]),t("div",Ha,[t("div",Va,[t("button",{type:"button",class:P(["tool-button px-3 py-2 text-sm",O.value==="basic"?"tool-button-accent-subtle":""]),onClick:s[7]||(s[7]=y=>O.value="basic")},o(a(c)("projectManager.basicInfo")),3),t("button",{type:"button",class:P(["tool-button px-3 py-2 text-sm",O.value==="status"?"tool-button-accent-subtle":""]),disabled:h.value==="create",onClick:s[8]||(s[8]=y=>O.value="status")},o(a(c)("projectManager.status")),11,qa)])]),t("div",Wa,[O.value==="basic"?(p(),f("div",Ga,[S(qe,{mobile:"",busy:I.value,"can-edit-engine":h.value!=="edit"||oe.value,"can-edit-cwd":h.value!=="edit"||K.value,"can-edit-session-id":h.value!=="edit"||q.value,cwd:r.cwd,"cwd-readonly-message":Q.value,"duplicate-cwd-message":de.value,engine:r.engine,"engine-options":we.value,"engine-readonly-message":ce.value,"session-id":r.sessionId,"session-id-copied":B.value,"session-id-readonly-message":X.value,title:r.title,"workspace-suggestions":re.value,onCopySessionId:Ne,onOpenDirectoryPicker:s[9]||(s[9]=y=>G.value=!0),"onUpdate:cwd":Le,"onUpdate:engine":Ee,"onUpdate:sessionId":Fe,"onUpdate:title":De},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","engine-options","engine-readonly-message","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"]),d.value?(p(),f("p",Ja,[S(a(Ve),{class:"h-4 w-4"}),t("span",null,o(d.value),1)])):j("",!0),t("div",Ka,[t("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-sm",disabled:I.value,onClick:Oe},o(ue.value),9,Qa),h.value==="edit"&&b.value?(p(),f("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:I.value||ae.value,onClick:s[10]||(s[10]=y=>E.value=!0)},o(R.value?a(c)("projectManager.resettingSession"):a(c)("projectManager.newSession")),9,Xa)):j("",!0),h.value==="edit"&&b.value?(p(),f("button",{key:1,type:"button",class:"tool-button tool-button-danger-subtle w-full px-3 py-2 text-sm",disabled:I.value||ae.value,onClick:s[11]||(s[11]=y=>C.value=!0)},o(F.value?a(c)("projectManager.deletingProject"):a(c)("projectManager.deleteProject")),9,Ya)):j("",!0)])])):(p(),se(ha,{key:1,"active-session":b.value,"format-updated-at":m,"get-runtime-status-class":ge,"get-runtime-status-label":me,"get-thread-status-class":n,"get-thread-status-label":fe,"is-current-session":te,"is-session-running":z},null,8,["active-session"]))])]))])):(p(),f("div",ya,[t("aside",ba,[S(We,{busy:I.value,"editing-session-id":M.value,"format-updated-at":m,"get-runtime-status-class":ge,"get-runtime-status-label":me,"get-thread-status-class":n,"get-thread-status-label":fe,"has-sessions":Z.value,"is-current-session":te,"is-session-running":z,mode:h.value,sessions:ne.value,onCreate:Y,onSelect:Re},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])]),t("div",wa,[t("div",Sa,[t("div",null,[t("div",ka,[S(a(St),{class:"h-4 w-4"}),t("span",null,o(h.value==="create"?a(c)("projectManager.createTitle"):a(c)("projectManager.editTitle")),1)])])]),t("div",$a,[S(qe,{busy:I.value,"can-edit-engine":h.value!=="edit"||oe.value,"can-edit-cwd":h.value!=="edit"||K.value,"can-edit-session-id":h.value!=="edit"||q.value,cwd:r.cwd,"cwd-readonly-message":Q.value,"duplicate-cwd-message":de.value,engine:r.engine,"engine-options":we.value,"engine-readonly-message":ce.value,"session-id":r.sessionId,"session-id-copied":B.value,"session-id-readonly-message":X.value,title:r.title,"workspace-suggestions":re.value,onCopySessionId:Ne,onOpenDirectoryPicker:s[3]||(s[3]=y=>G.value=!0),"onUpdate:cwd":Le,"onUpdate:engine":Ee,"onUpdate:sessionId":Fe,"onUpdate:title":De},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","engine-options","engine-readonly-message","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"])]),d.value?(p(),f("p",_a,[S(a(Ve),{class:"h-4 w-4"}),t("span",null,o(d.value),1)])):j("",!0),t("div",Ca,[t("div",Ma,[h.value==="edit"&&b.value?(p(),f("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:I.value||ae.value,onClick:s[4]||(s[4]=y=>E.value=!0)},[S(a(kt),{class:"h-4 w-4"}),t("span",null,o(R.value?a(c)("projectManager.resettingSession"):a(c)("projectManager.newSession")),1)],8,ja)):j("",!0),h.value==="edit"&&b.value?(p(),f("button",{key:1,type:"button",class:"tool-button tool-button-danger-subtle inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:I.value||ae.value,onClick:s[5]||(s[5]=y=>C.value=!0)},[S(a($t),{class:"h-4 w-4"}),t("span",null,o(F.value?a(c)("projectManager.deletingProject"):a(c)("projectManager.deleteProject")),1)],8,Ia)):j("",!0)]),t("div",Pa,[t("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:I.value,onClick:s[6]||(s[6]=y=>k("close"))},o(a(c)("projectManager.close")),9,Ta),h.value==="create"&&Z.value?(p(),f("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:I.value,onClick:Be},o(a(c)("projectManager.backToList")),9,Ra)):j("",!0),t("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-xs sm:w-auto",disabled:I.value,onClick:Oe},o(ue.value),9,Da)])])])]))]}),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"])],64))}};export{is as default};
1
+ import{u as ye,f as st,d as lt}from"./index-CD4ppQq_.js";import{A as it,n as Pe,e as _e,r as ot,b as Ge,s as rt,f as ze,_ as dt,a as ct,h as Ue}from"./WorkbenchView-BXIMEYIR.js";import{w as he,aB as p,aG as se,aH as le,aD as t,aO as o,u as a,aE as S,aU as ut,aV as pt,aJ as P,aC as f,aP as xe,aQ as Ce,aL as j,aT as mt,aI as gt,b as $,c as _,aX as Je,ak as ft,r as vt,n as ht}from"./vendor-misc-CWjGI0ex.js";import{g as He,h as ve,L as Ie,j as xt,b as Ke,H as yt,m as bt,v as wt,P as St,d as Ve,J as kt,l as $t,p as _t,K as Ct}from"./vendor-ui-D4mCpibF.js";import"./vendor-router-Bcjfmow0.js";import"./vendor-markdown-CNlC48LI.js";import"./vendor-tiptap-BCwG_IWj.js";function Mt(i=[]){return(Array.isArray(i)&&i.length?i:it).filter(u=>u&&typeof u=="object").map(u=>{const k=Pe(u.value);return{...u,value:k,label:String(u.label||_e(k)).trim()||_e(k),enabled:u.enabled!==!1,available:u.available!==!1}})}function Te(i=[]){return Mt(i).filter(T=>T.enabled&&T.available)}async function jt(){const i=await ot("/api/meta",{cache:"no-store"});return Te(i==null?void 0:i.agentEngineOptions)}const It={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Pt={class:"theme-muted-text mt-1 text-xs leading-5"},Tt={class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Rt={class:"theme-divider mt-4 rounded-sm border border-dashed px-3 py-2"},Dt={class:"flex items-start gap-2 text-xs leading-5"},Et={class:"theme-muted-text shrink-0"},Lt={class:"min-w-0 break-all font-mono text-[var(--theme-textPrimary)]"},Ft={class:"theme-muted-text mt-4 block text-xs"},Bt={class:"theme-input-shell mt-1 flex h-10 items-center gap-2 rounded-sm border px-3 transition focus-within:ring-2"},At=["placeholder"],Nt={class:"mt-4 flex items-center gap-1.5"},Ot={class:"theme-content-panel mt-3 min-h-0 flex-1 overflow-y-auto p-2"},zt={key:0,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},Ut={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},Ht={key:2,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},Vt={key:3,class:"theme-empty-state flex items-center justify-center gap-2 px-3 py-8 text-sm"},qt={key:4,class:"theme-empty-state px-3 py-8 text-sm"},Wt={key:5,class:"theme-empty-state px-3 py-8 text-sm"},Gt={key:6,class:"theme-empty-state px-3 py-8 text-sm"},Jt={key:7,class:"space-y-1"},Kt=["onClick"],Qt={class:"min-w-0 flex-1"},Xt=["innerHTML"],Yt=["innerHTML"],Zt={key:0,class:"theme-muted-text px-1 pt-2 text-xs"},en={key:8,class:"space-y-1"},tn={class:"flex items-start gap-1.5"},nn=["onClick"],an=["onClick"],sn={class:"min-w-0 flex-1"},ln={key:0,class:"theme-muted-text truncate font-mono text-[10px]"},on={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"},rn={class:"flex flex-col-reverse gap-2 sm:flex-row sm:items-center"},dn=["disabled"],cn=["disabled"],un={__name:"CodexDirectoryPickerDialog",props:{open:{type:Boolean,default:!1},initialPath:{type:String,default:""},suggestions:{type:Array,default:()=>[]}},emits:["close","select"],setup(i,{emit:T}){const u=i,k=T,{t:v}=ye(),c=$(""),h=$(null),M=$(!1),r=$(""),d=$(!1),w=$(""),L=$([]),F=$(!1),R=$(""),C=$("tree"),E=$(""),G=$("");let B=null,A=0;const J=_(()=>de(h.value?[h.value]:[])),O=_(()=>C.value==="search"&&!R.value.trim()),ie=_(()=>C.value==="search"&&!!R.value.trim()&&!d.value&&!w.value&&!L.value.length),V=_(()=>C.value==="tree"&&!M.value&&!r.value&&!J.value.length);function ne(n=""){const m=String(n||"").trim();return/^[a-z]:[\\/]/i.test(m)||m.includes("\\")}function b(n=""){const m=String(n||"").trim();if(!m)return"";const l=ne(m);let g=m.replace(/\\/g,"/");return g.length>1&&!/^[a-z]:\/?$/i.test(g)&&g!=="/"&&(g=g.replace(/\/+$/,"")),l?g.toLowerCase():g}function Z(n="",m=""){const l=b(n),g=b(m);return!l||!g?!1:l===g||l.startsWith(`${g}/`)}function Me(n="",m=""){const l=String(n||"").trim(),g=String(m||"").trim();return l?g?ne(l)?/^[a-z]:\\?$/i.test(l)?`${l.replace(/[\\/]+$/,"")}\\${g}`:`${l.replace(/[\\/]+$/,"")}\\${g}`:l==="/"?`/${g}`:`${l.replace(/\/+$/,"")}/${g}`:l:g}function ae(n="",m=""){const l=b(n),g=b(m);if(!l||!g||!Z(g,l))return[];const D=g===l?"":g.slice(l.length).replace(/^\//,"");return D?D.split("/").filter(Boolean):[]}function K(n){return(n==null?void 0:n.name)||(n==null?void 0:n.path)||v("directoryPicker.unnamedDirectory")}function oe(n=""){const m=String(n||"").trim();return m?m.split(/[\\/]/).filter(Boolean).at(-1)||m:"Home"}function q(n=""){return String(n||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function I(n="",m=""){const l=String(n||""),g=String(m||"").trim().toLowerCase();if(!l||!g)return null;const D=l.toLowerCase(),U=D.indexOf(g);if(U>=0)return{start:U,end:U+g.length};const $e=g.split(/[\\/\s_.-]+/).filter(Boolean).sort((W,Y)=>Y.length-W.length);for(const W of $e){if(W.length<2)continue;const Y=D.indexOf(W);if(Y>=0)return{start:Y,end:Y+W.length}}return null}function be(n="",m=""){const l=String(n||""),g=I(l,m);return g?`${q(l.slice(0,g.start))}<mark class="theme-search-highlight">${q(l.slice(g.start,g.end))}</mark>${q(l.slice(g.end))}`:q(l)}function re(n){return be(K(n),R.value)}function we(n){return be((n==null?void 0:n.path)||"",R.value)}function ee(n,m=0){return{...n,depth:m,expanded:!1,loaded:!1,loading:!1,children:[]}}function de(n=[],m=[]){return n.forEach(l=>{m.push(l),l.expanded&&l.children.length&&de(l.children,m)}),m}function Q(){h.value&&(h.value={...h.value})}function ce(n,m=h.value?[h.value]:[]){const l=b(n);if(!l)return null;for(const g of m){if(b(g.path)===l)return g;if(g.children.length){const D=ce(n,g.children);if(D)return D}}return null}function X(n){E.value=String((n==null?void 0:n.path)||"").trim(),G.value=K(n)}async function ue(n,m={}){if(!(!n||n.loading)&&!(n.loaded&&!m.force)){n.loading=!0,r.value="",Q();try{const l=await ze({path:n.path,limit:240});n.children=(l.items||[]).map(g=>ee(g,n.depth+1)),n.loaded=!0}catch(l){r.value=l.message||v("directoryPicker.loadFailed")}finally{n.loading=!1,Q()}}}async function je(){M.value=!0,r.value="";try{const n=await ze({limit:240});c.value=String(n.path||""),h.value=ee({name:oe(n.path||""),path:String(n.path||""),type:"directory",hasChildren:!0,isHomeRoot:!0},0),h.value.children=(n.items||[]).map(m=>ee(m,1)),h.value.loaded=!0,h.value.expanded=!0,X(h.value)}catch(n){r.value=n.message||v("directoryPicker.treeLoadFailed"),h.value=null,c.value=""}finally{M.value=!1}}async function pe(n=""){const m=String(n||"").trim();if(!m||!c.value||!Z(m,c.value))return;let l=h.value;if(!l)return;X(l);const g=ae(c.value,m);for(const D of g){await ue(l),l.expanded=!0,Q();const U=ce(Me(l.path,D),l.children);if(!U)break;l=U,X(l)}}async function Se(){R.value="",C.value="tree",L.value=[],w.value="",F.value=!1,E.value="",G.value="",await je();const n=String(u.initialPath||"").trim();n&&Z(n,c.value)&&await pe(n)}async function z(n){if(n!=null&&n.path&&(X(n),!!n.hasChildren)){if(!n.loaded){n.expanded=!0,Q(),await ue(n);return}n.expanded=!n.expanded,Q()}}function te(n){n!=null&&n.path&&(X(n),C.value="tree")}async function ke(){const n=String(R.value||"").trim();A+=1;const m=A;if(!u.open||!n||!c.value){d.value=!1,w.value="",L.value=[],F.value=!1;return}d.value=!0,w.value="";try{const l=await rt(n,{path:c.value,limit:80});if(m!==A)return;L.value=Array.isArray(l.items)?l.items:[],F.value=!!l.truncated}catch(l){if(m!==A)return;w.value=l.message||v("directoryPicker.searchFailed"),L.value=[],F.value=!1}finally{m===A&&(d.value=!1)}}function me(){if(B&&(window.clearTimeout(B),B=null),!String(R.value||"").trim()){d.value=!1,w.value="",L.value=[],F.value=!1;return}d.value=!0,w.value="",B=window.setTimeout(()=>{ke()},120)}async function ge(n){n!=null&&n.path&&(C.value="tree",await pe(n.path))}function fe(){E.value&&(k("select",E.value),k("close"))}return he(R,()=>{C.value=R.value.trim()?"search":"tree",me()}),he(()=>u.open,n=>{if(n){Se().catch(()=>{});return}B&&(window.clearTimeout(B),B=null)}),(n,m)=>(p(),se(Ge,{open:i.open,"backdrop-class":"z-[60] items-end justify-center px-0 py-0 sm:items-center sm:px-4 sm:py-6","panel-class":"settings-dialog-panel h-full max-w-4xl sm:h-auto sm:max-h-[86vh]","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":M.value||d.value,"close-on-backdrop":!(M.value||d.value),"close-on-escape":!(M.value||d.value),onClose:m[4]||(m[4]=l=>k("close"))},{title:le(()=>[t("div",null,[t("div",It,[S(a(ve),{class:"h-4 w-4"}),t("span",null,o(a(v)("directoryPicker.title")),1)]),t("p",Pt,o(a(v)("directoryPicker.intro")),1)])]),default:le(()=>[t("div",Tt,[t("div",Rt,[t("div",Dt,[t("span",Et,o(a(v)("directoryPicker.currentSelection")),1),t("span",Lt,o(E.value||a(v)("directoryPicker.selectionPlaceholder")),1)])]),t("label",Ft,[t("span",null,o(a(v)("directoryPicker.searchLabel")),1),t("div",Bt,[S(a(He),{class:"h-4 w-4 shrink-0 text-[var(--theme-textMuted)]"}),ut(t("input",{"onUpdate:modelValue":m[0]||(m[0]=l=>R.value=l),type:"text",placeholder:a(v)("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)]"},null,8,At),[[pt,R.value]])])]),t("div",Nt,[t("button",{type:"button",class:P(["inline-flex h-8 items-center gap-1 rounded-sm border px-2 text-[11px] transition",C.value==="search"?"tool-button-accent-subtle":"theme-filter-idle border-dashed"]),onClick:m[1]||(m[1]=l=>C.value="search")},[S(a(He),{class:"h-3.5 w-3.5"}),t("span",null,o(a(v)("directoryPicker.searchTab")),1)],2),t("button",{type:"button",class:P(["inline-flex h-8 items-center gap-1 rounded-sm border px-2 text-[11px] transition",C.value==="tree"?"tool-button-accent-subtle":"theme-filter-idle border-dashed"]),onClick:m[2]||(m[2]=l=>C.value="tree")},[S(a(ve),{class:"h-3.5 w-3.5"}),t("span",null,o(a(v)("directoryPicker.treeTab")),1)],2)]),t("div",Ot,[C.value==="search"&&w.value?(p(),f("div",zt,o(w.value),1)):C.value==="tree"&&r.value?(p(),f("div",Ut,o(r.value),1)):C.value==="search"&&d.value?(p(),f("div",Ht,[S(a(Ie),{class:"h-4 w-4 animate-spin"}),t("span",null,o(a(v)("directoryPicker.searching")),1)])):C.value==="tree"&&M.value?(p(),f("div",Vt,[S(a(Ie),{class:"h-4 w-4 animate-spin"}),t("span",null,o(a(v)("directoryPicker.treeLoading")),1)])):O.value?(p(),f("div",qt,o(a(v)("directoryPicker.searchPrompt")),1)):ie.value?(p(),f("div",Wt,o(a(v)("directoryPicker.noSearchResults")),1)):V.value?(p(),f("div",Gt,o(a(v)("directoryPicker.emptyTree")),1)):C.value==="search"?(p(),f("div",Jt,[(p(!0),f(xe,null,Ce(L.value,l=>(p(),f("button",{key:l.path,type:"button",class:P(["flex w-full items-start gap-2 rounded-sm border border-transparent px-2.5 py-1.5 text-left transition",b(E.value)===b(l.path)?"theme-list-item-active":"theme-list-item-hover"]),onClick:g=>ge(l)},[S(a(ve),{class:"theme-muted-text mt-0.5 h-4 w-4 shrink-0"}),t("div",Qt,[t("div",null,[t("span",{class:"truncate text-[13px] text-[var(--theme-textPrimary)]",innerHTML:re(l)},null,8,Xt)]),t("div",{class:"theme-muted-text truncate font-mono text-[10px]",innerHTML:we(l)},null,8,Yt)])],10,Kt))),128)),F.value?(p(),f("p",Zt,o(a(v)("directoryPicker.truncatedHint")),1)):j("",!0)])):(p(),f("div",en,[(p(!0),f(xe,null,Ce(J.value,l=>(p(),f("div",{key:l.path,class:P(["rounded-sm border border-transparent px-1.5 py-1 transition",b(E.value)===b(l.path)?"theme-list-item-active":l.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:mt({paddingLeft:`${l.depth*16+6}px`})},[t("div",tn,[t("button",{type:"button",class:P(["theme-icon-button h-5 w-5 shrink-0",l.hasChildren?"":"invisible pointer-events-none"]),onClick:gt(g=>z(l),["stop"])},[l.loading?(p(),se(a(Ie),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(p(),se(a(xt),{key:1,class:P(["h-3.5 w-3.5 transition",l.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],10,nn),t("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:g=>te(l)},[S(a(ve),{class:P(["h-4 w-4 shrink-0",b(E.value)===b(l.path)?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"]),t("div",sn,[t("div",{class:P(["truncate text-[13px]",l.isHomeRoot?"font-medium text-[var(--theme-textSecondary)]":"font-medium text-[var(--theme-textPrimary)]"])},o(K(l)),3),l.isHomeRoot?(p(),f("div",ln,o(l.path),1)):j("",!0)])],8,an)])],6))),128))]))])]),t("div",on,[t("div",rn,[t("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:M.value||d.value,onClick:m[3]||(m[3]=l=>k("close"))},o(a(v)("directoryPicker.cancel")),9,dn),t("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:M.value||d.value||!E.value,onClick:fe},[S(a(Ke),{class:"h-4 w-4"}),t("span",null,o(a(v)("directoryPicker.useCurrentDirectory")),1)],8,cn)])])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},pn={class:"grid gap-4"},mn={class:"theme-muted-text block text-xs"},gn=["value","disabled"],fn={class:"theme-muted-text block text-xs"},vn={class:"mt-1 flex gap-2"},hn=["value","disabled"],xn=["disabled"],yn={id:"codex-manager-workspace-suggestions"},bn=["value"],wn={key:0,class:"mt-2 text-[11px] leading-5 text-[var(--theme-warningText)]"},Sn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},kn={class:"theme-muted-text block text-xs"},$n={class:"mt-1"},_n={class:"flex items-center gap-2 text-sm"},Cn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Mn=["disabled","onClick"],jn={class:"flex items-center justify-between gap-3"},In={class:"min-w-0 flex-1 truncate"},Pn={key:0,class:"theme-muted-text rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Tn={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},Rn={class:"theme-muted-text block text-xs"},Dn={class:"mt-1 flex gap-2"},En=["value","disabled"],Ln=["disabled"],Fn={key:0,class:"theme-muted-text mt-2 text-[11px] leading-5"},Bn={key:1,class:"theme-muted-text mt-2 text-[11px] leading-5"},qe={__name:"CodexSessionManagerForm",props:{busy:{type:Boolean,default:!1},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:""},title:{type:String,default:""},workspaceSuggestions:{type:Array,default:()=>[]}},emits:["copy-session-id","open-directory-picker","update:cwd","update:engine","update:sessionId","update:title"],setup(i,{emit:T}){const u=i,k=T,{t:v}=ye(),c=_(()=>{const M=String(u.engine||"").trim();return u.engineOptions.find(r=>String((r==null?void 0:r.value)||"").trim()===M)||null}),h=_(()=>String(u.sessionId||"").trim());return(M,r)=>(p(),f("div",pn,[t("label",mn,[t("span",null,o(a(v)("projectManager.projectTitleOptional")),1),t("input",{value:i.title,type:"text",maxlength:"140",placeholder:"",class:"tool-input mt-1",disabled:i.busy,onInput:r[0]||(r[0]=d=>k("update:title",d.target.value))},null,40,gn)]),t("label",fn,[t("span",null,o(a(v)("projectManager.workingDirectoryField")),1),t("div",vn,[t("input",{value:i.cwd,type:"text",list:"codex-manager-workspace-suggestions",placeholder:"",class:P(["tool-input min-w-0 flex-1 disabled:cursor-not-allowed disabled:opacity-80",i.duplicateCwdMessage?"border-[var(--theme-warning)]":""]),disabled:i.busy||!i.canEditCwd,onInput:r[1]||(r[1]=d=>k("update:cwd",d.target.value))},null,42,hn),t("button",{type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:i.busy||!i.canEditCwd,onClick:r[2]||(r[2]=d=>k("open-directory-picker"))},[S(a(ve),{class:"h-4 w-4"}),t("span",null,o(i.mobile?a(v)("projectManager.choose"):a(v)("projectManager.chooseDirectory")),1)],8,xn)]),t("datalist",yn,[(p(!0),f(xe,null,Ce(i.workspaceSuggestions,d=>(p(),f("option",{key:d,value:d},null,8,bn))),128))]),i.duplicateCwdMessage?(p(),f("p",wn,o(i.duplicateCwdMessage),1)):i.cwdReadonlyMessage?(p(),f("p",Sn,o(i.cwdReadonlyMessage),1)):j("",!0)]),t("label",kn,[t("span",null,o(a(v)("projectManager.engineField")),1),t("div",$n,[S(dt,{"model-value":i.engine,options:i.engineOptions,disabled:i.busy||!i.canEditEngine,placeholder:a(v)("projectManager.selectEngine"),"empty-text":a(v)("projectManager.noEngines"),"get-option-value":d=>(d==null?void 0:d.value)||"","onUpdate:modelValue":r[3]||(r[3]=d=>k("update:engine",d))},{trigger:le(({disabled:d})=>{var w;return[t("div",_n,[t("span",{class:P(["min-w-0 flex-1 truncate",d?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},o(((w=c.value)==null?void 0:w.label)||a(v)("projectManager.selectEngine")),3),c.value&&c.value.enabled===!1?(p(),f("span",Cn,o(a(v)("projectManager.comingSoon")),1)):j("",!0)])]}),option:le(({option:d,selected:w,select:L})=>[t("button",{type:"button",class:P(["w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm transition",w?"theme-filter-active":"theme-filter-idle"]),disabled:(d==null?void 0:d.enabled)===!1,onClick:L},[t("div",jn,[t("span",In,o(d.label),1),(d==null?void 0:d.enabled)===!1?(p(),f("span",Pn,o(a(v)("projectManager.comingSoon")),1)):j("",!0)])],10,Mn)]),_:1},8,["model-value","options","disabled","placeholder","empty-text","get-option-value"])]),i.engineReadonlyMessage?(p(),f("p",Tn,o(i.engineReadonlyMessage),1)):j("",!0)]),t("label",Rn,[t("span",null,o(a(v)("projectManager.sessionId")),1),t("div",Dn,[t("input",{value:i.sessionId,type:"text",placeholder:"",class:"tool-input min-w-0 flex-1 disabled:cursor-not-allowed disabled:opacity-80",disabled:i.busy||!i.canEditSessionId,onInput:r[4]||(r[4]=d=>k("update:sessionId",d.target.value))},null,40,En),h.value?(p(),f("button",{key:0,type:"button",class:"tool-button inline-flex shrink-0 items-center gap-2 px-3 py-2 text-xs",disabled:i.busy,onClick:r[5]||(r[5]=d=>k("copy-session-id"))},[i.sessionIdCopied?(p(),se(a(Ke),{key:0,class:"h-4 w-4"})):(p(),se(a(yt),{key:1,class:"h-4 w-4"})),t("span",null,o(i.sessionIdCopied?a(v)("projectManager.sessionIdCopied"):a(v)("projectManager.copySessionId")),1)],8,Ln)):j("",!0)]),i.sessionIdReadonlyMessage?(p(),f("p",Fn,o(i.sessionIdReadonlyMessage),1)):(p(),f("p",Bn,o(a(v)("projectManager.sessionIdHint")),1))])]))}},An={class:"flex items-center justify-between gap-3"},Nn={class:"theme-heading text-sm font-medium"},On={key:0,class:"theme-muted-text mt-1 text-xs"},zn=["disabled"],Un=["onClick"],Hn={key:0,class:"theme-selection-indicator absolute inset-y-3 left-0 w-1 rounded-full"},Vn={class:"flex w-full flex-col gap-2 text-left"},qn={class:"theme-heading min-w-0 text-sm font-medium"},Wn=["title"],Gn=["title"],Jn={class:"theme-muted-text flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] leading-5"},Kn={key:0,"aria-hidden":"true"},Qn={key:1},Xn={class:"flex flex-wrap items-center gap-2 pt-1"},Yn={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},We={__name:"CodexSessionManagerList",props:{busy:{type:Boolean,default:!1},editingSessionId:{type:String,default:""},formatUpdatedAt:{type:Function,default:i=>i},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(i,{emit:T}){const u=i,k=T,{t:v}=ye();function c(r){return u.mode==="edit"&&u.editingSessionId===r.id?"theme-card-selected":u.isSessionRunning(r.id)?"theme-card-warning":"theme-card-idle-strong"}function h(r){return u.isCurrentSession(r.id)?v("projectManager.current"):v("projectManager.regular")}function M(r){return u.isCurrentSession(r.id)?"theme-status-info":"theme-status-neutral"}return(r,d)=>(p(),f("div",{class:P(i.mobile?"flex h-full min-h-0 flex-col":"")},[t("div",An,[t("div",null,[t("div",Nn,o(a(v)("projectManager.projectList")),1),i.hasSessions?j("",!0):(p(),f("p",On,o(a(v)("projectManager.noProjects")),1))]),t("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:i.busy,onClick:d[0]||(d[0]=w=>k("create"))},[S(a(bt),{class:"h-4 w-4"}),t("span",null,o(a(v)("projectManager.create")),1)],8,zn)]),t("div",{class:P(["mt-4 space-y-2",i.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)]"])},[(p(!0),f(xe,null,Ce(i.sessions,w=>(p(),f("article",{key:w.id,class:P(["relative cursor-pointer rounded-sm border p-3 transition",c(w)]),onClick:L=>k("select",w.id)},[i.mode==="edit"&&i.editingSessionId===w.id?(p(),f("span",Hn)):j("",!0),t("div",Vn,[t("div",qn,[t("span",{class:"block truncate",title:w.title||a(v)("projectManager.untitledProject")},o(w.title||a(v)("projectManager.untitledProject")),9,Wn)]),t("div",{class:"theme-muted-text break-all font-mono text-[11px] leading-5",title:w.cwd},o(w.cwd),9,Gn),t("div",Jn,[t("span",null,o(a(_e)(w.engine)),1),i.mobile?j("",!0):(p(),f("span",Kn,"·")),i.mobile?j("",!0):(p(),f("span",Qn,o(i.formatUpdatedAt(w.updatedAt)),1))]),t("div",Xn,[t("span",{class:P(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",M(w)])},o(h(w)),3),t("span",{class:P(["inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",i.getRuntimeStatusClass(w.id)])},[i.isSessionRunning(w.id)?(p(),f("span",Yn)):j("",!0),Je(" "+o(i.getRuntimeStatusLabel(w.id)),1)],2),t("span",{class:P(["inline-flex shrink-0 whitespace-nowrap rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",i.getThreadStatusClass(w)])},o(i.getThreadStatusLabel(w)),3)])])],10,Un))),128))],2)],2))}},Zn={class:"space-y-3"},ea={class:"dashed-panel px-3 py-3"},ta={class:"theme-muted-text text-[11px]"},na={class:"mt-2 flex flex-wrap gap-2"},aa={key:0,class:"h-1.5 w-1.5 rounded-full bg-current animate-pulse"},sa={key:0,class:"theme-status-info inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs"},la={class:"dashed-panel px-3 py-3"},ia={class:"theme-muted-text text-[11px]"},oa={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},ra={class:"dashed-panel px-3 py-3"},da={class:"theme-muted-text text-[11px]"},ca={class:"mt-2 break-all font-mono text-xs leading-6 text-[var(--theme-textPrimary)]"},ua={class:"dashed-panel px-3 py-3"},pa={class:"theme-muted-text text-[11px]"},ma={class:"mt-2 text-sm text-[var(--theme-textPrimary)]"},ga={class:"dashed-panel px-3 py-3"},fa={class:"theme-muted-text inline-flex items-center gap-2 text-[11px]"},va={class:"mt-2 text-xs leading-6 text-[var(--theme-textSecondary)]"},ha={__name:"CodexSessionManagerStatus",props:{activeSession:{type:Object,default:null},formatUpdatedAt:{type:Function,default:i=>i},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(i){const{t:T}=ye();return(u,k)=>{var v,c,h,M,r,d,w;return p(),f("div",Zn,[t("div",ea,[t("div",ta,o(a(T)("projectManager.runtimeStatus")),1),t("div",na,[t("span",{class:P(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",i.getRuntimeStatusClass((v=i.activeSession)==null?void 0:v.id)])},[i.isSessionRunning((c=i.activeSession)==null?void 0:c.id)?(p(),f("span",aa)):j("",!0),Je(" "+o(i.getRuntimeStatusLabel((h=i.activeSession)==null?void 0:h.id)),1)],2),t("span",{class:P(["inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1 text-xs",i.getThreadStatusClass(i.activeSession)])},o(i.getThreadStatusLabel(i.activeSession)),3),(M=i.activeSession)!=null&&M.id&&i.isCurrentSession(i.activeSession.id)?(p(),f("span",sa,o(a(T)("projectManager.currentProject")),1)):j("",!0)])]),t("div",la,[t("div",ia,o(a(T)("projectManager.engine")),1),t("div",oa,o(a(_e)((r=i.activeSession)==null?void 0:r.engine)),1)]),t("div",ra,[t("div",da,o(a(T)("projectManager.workingDirectory")),1),t("div",ca,o(((d=i.activeSession)==null?void 0:d.cwd)||a(T)("projectManager.notSet")),1)]),t("div",ua,[t("div",pa,o(a(T)("projectManager.updatedAt")),1),t("div",ma,o(i.formatUpdatedAt((w=i.activeSession)==null?void 0:w.updatedAt)),1)]),t("div",ga,[t("div",fa,[S(a(wt),{class:"h-3.5 w-3.5"}),t("span",null,o(a(T)("projectManager.note")),1)]),t("p",va,o(a(T)("projectManager.noteDescription")),1)])])}}},xa={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ya={key:0,class:"grid min-h-0 flex-1 gap-0 lg:grid-cols-[minmax(0,300px)_minmax(0,1fr)]"},ba={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"},wa={class:"min-h-0 overflow-y-auto px-4 py-4 sm:px-5"},Sa={class:"flex flex-wrap items-start justify-between gap-3"},ka={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},$a={class:"mt-5"},_a={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Ca={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"},Ma={class:"flex flex-wrap items-center gap-2"},ja=["disabled"],Ia=["disabled"],Pa={class:"flex flex-col-reverse gap-2 sm:flex-row sm:flex-wrap sm:items-center"},Ta=["disabled"],Ra=["disabled"],Da=["disabled"],Ea={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},La={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Fa={class:"min-h-0 flex-1 overflow-hidden px-3 py-3"},Ba={key:1,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Aa={class:"theme-divider flex items-center gap-3 border-b px-4 py-3"},Na=["disabled"],Oa={class:"min-w-0 flex-1"},za={class:"theme-heading truncate text-sm font-medium"},Ua={key:0,class:"theme-muted-text mt-1 truncate text-xs"},Ha={class:"theme-divider border-b px-4 py-3"},Va={class:"grid grid-cols-2 gap-2"},qa=["disabled"],Wa={class:"min-h-0 flex-1 overflow-y-auto px-4 py-4"},Ga={key:0},Ja={key:0,class:"theme-danger-text mt-4 inline-flex items-center gap-2 text-sm"},Ka={class:"theme-divider mt-6 flex flex-col gap-3 border-t border-dashed pt-4"},Qa=["disabled"],Xa=["disabled"],Ya=["disabled"],is={__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"],setup(i,{emit:T}){const u=i,k=T,{locale:v,t:c}=ye(),h=$("edit"),M=$(""),r=vt({title:"",engine:"codex",cwd:"",sessionId:""}),d=$(""),w=$(!1),L=$(!1),F=$(!1),R=$(!1),C=$(!1),E=$(!1),G=$(!1),B=$(!1),{matches:A}=ct("(max-width: 767px)"),J=$("list"),O=$("basic"),ie=$(Te());let V=null;const ne=_(()=>ke(u.sessions)),b=_(()=>u.sessions.find(e=>e.id===M.value)||null),Z=_(()=>u.sessions.length>0),Me=_(()=>u.sessions.find(e=>e.id===u.selectedSessionId)||null),ae=_(()=>!!(b.value&&z(b.value.id))),K=_(()=>{var e;return!((e=b.value)!=null&&e.started)}),oe=_(()=>{var e;return!((e=b.value)!=null&&e.started)}),q=_(()=>{var e;return!((e=b.value)!=null&&e.started)}),I=_(()=>u.loading||w.value||L.value||F.value||R.value),be=_(()=>String(r.sessionId||"").trim()),re=_(()=>{var x,y;const e=new Set,s=[];return[r.cwd,(x=b.value)==null?void 0:x.cwd,(y=Me.value)==null?void 0:y.cwd,...u.workspaces,...u.sessions.map(H=>H.cwd)].forEach(H=>{const N=String(H||"").trim();!N||e.has(N)||(e.add(N),s.push(N))}),s.slice(0,12)}),we=_(()=>ie.value),ee=_(()=>{const e=Se(r.cwd);return e?u.sessions.filter(s=>{var x;return s.id===((x=b.value)==null?void 0:x.id)?!1:Se(s.cwd)===e}):[]}),de=_(()=>{if(!ee.value.length)return"";const e=ee.value.slice(0,3).map(s=>{const x=s.title||c("projectManager.untitledProject");return v.value==="en-US"?`"${x}"`:`「${x}」`}).join(v.value==="en-US"?", ":"、");return c("projectManager.duplicateDirectory",{labels:e,count:ee.value.length})}),Q=_(()=>h.value!=="edit"||K.value?"":c("projectManager.cwdReadonly")),ce=_(()=>h.value!=="edit"||!b.value||oe.value?"":c("projectManager.engineReadonly")),X=_(()=>h.value!=="edit"||!b.value||q.value?"":c("projectManager.sessionIdReadonly")),ue=_(()=>h.value==="create"?w.value?c("projectManager.creatingProject"):c("projectManager.createProject"):L.value?c("projectManager.savingChanges"):c("projectManager.saveChanges")),je=_(()=>{var e;return h.value==="create"?c("projectManager.newProject"):((e=b.value)==null?void 0:e.title)||c("projectManager.untitledProject")});function pe(e=""){const s=Date.parse(String(e||""));return Number.isFinite(s)?s:0}function Se(e=""){const s=String(e||"").trim();if(!s)return"";const x=/^[a-z]:[\\/]/i.test(s)||s.includes("\\");let y=s.replace(/\\/g,"/");return y.length>1&&!/^[a-z]:\/$/i.test(y)&&(y=y.replace(/\/+$/,"")),x?y.toLowerCase():y}function z(e){var s;return!!((s=u.sessions.find(x=>x.id===e))!=null&&s.running)}function te(e){return!!e&&e===u.selectedSessionId}function ke(e=[]){return[...e].sort((s,x)=>{const y=Number(z(x.id))-Number(z(s.id));if(y)return y;const H=Number(te(x.id))-Number(te(s.id));if(H)return H;const N=pe(x.updatedAt)-pe(s.updatedAt);return N||lt(String(s.title||s.cwd||s.id),String(x.title||x.cwd||x.id))})}function me(e){return z(e)?c("projectManager.running"):c("projectManager.idle")}function ge(e){return z(e)?"theme-status-warning":"theme-status-success"}function fe(e){return e!=null&&e.started?c("projectManager.threadBound"):c("projectManager.notStarted")}function n(e){return e!=null&&e.started?"theme-status-success":"theme-status-neutral"}function m(e=""){if(!e)return c("projectManager.unknown");const s=new Date(e);return Number.isNaN(s.getTime())?e:st(s.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}function l(e){r.title=String((e==null?void 0:e.title)||""),r.engine=Pe(e==null?void 0:e.engine),r.cwd=String((e==null?void 0:e.cwd)||""),r.sessionId=String((e==null?void 0:e.sessionId)||(e==null?void 0:e.engineSessionId)||(e==null?void 0:e.engineThreadId)||(e==null?void 0:e.codexThreadId)||"").trim()}function g(){h.value="create",M.value="",d.value="",r.title="",r.engine="codex",r.cwd="",r.sessionId=""}function D(e){const s=u.sessions.find(x=>x.id===e);s&&(h.value="edit",M.value=s.id,d.value="",l(s))}function U(){var e;return u.selectedSessionId&&u.sessions.some(s=>s.id===u.selectedSessionId)?u.selectedSessionId:((e=ne.value[0])==null?void 0:e.id)||""}function $e(e="basic"){J.value="detail",O.value=e}function W(){J.value="list",O.value="basic"}function Y(){g(),A.value&&$e("basic")}function Re(e){I.value||(D(e),A.value&&$e("basic"))}function Qe(e){r.cwd=String(e||"").trim()}function De(e){r.title=String(e||"")}function Ee(e){r.engine=Pe(e)}function Le(e){r.cwd=String(e||"")}function Fe(e){r.sessionId=String(e||"")}function Be(){d.value="",C.value=!1,E.value=!1,B.value=!1,O.value="basic",J.value=A.value?"list":"detail";const e=U();if(e){D(e);return}g()}async function Xe(){if(!(I.value||typeof u.onRefresh!="function")){d.value="";try{await Promise.all([u.onRefresh(),Ae()])}catch(e){d.value=e.message}}}async function Ae(){try{ie.value=await jt()}catch{ie.value=Te()}}async function Ye(e){var x;if((x=navigator.clipboard)!=null&&x.writeText&&window.isSecureContext){await navigator.clipboard.writeText(e);return}const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly","true"),s.style.position="fixed",s.style.opacity="0",s.style.pointerEvents="none",document.body.appendChild(s),s.select(),document.execCommand("copy"),document.body.removeChild(s)}async function Ne(){const e=be.value;if(e)try{await Ye(e),B.value=!0,V&&clearTimeout(V),V=setTimeout(()=>{B.value=!1,V=null},1800)}catch(s){d.value=(s==null?void 0:s.message)||c("projectManager.copySessionIdFailed")}}async function Oe(){if(!I.value){d.value="";try{const e=Ze();if(!e)return;await et(e)}catch(e){d.value=e.message}}}function Ze(){if(h.value==="create"){const s=String(r.cwd||"").trim();return s?{type:"create",cwd:s,payload:{title:r.title,engine:r.engine,cwd:s,sessionId:String(r.sessionId||"").trim()}}:(d.value=c("projectManager.directoryRequired"),null)}if(!b.value)return d.value=c("projectManager.projectMissing"),null;const e={title:r.title,engine:r.engine};return K.value&&(e.cwd=r.cwd),q.value&&(e.sessionId=String(r.sessionId||"").trim()),{type:"update",sessionId:b.value.id,payload:e}}async function et(e){var s,x;if(e.type==="create"){w.value=!0;try{const y=await((s=u.onCreate)==null?void 0:s.call(u,e.payload));y!=null&&y.id&&(D(y.id),k("select-session",y.id),await ht(),k("project-created",y),k("close"));return}finally{w.value=!1}}L.value=!0;try{const y=await((x=u.onUpdate)==null?void 0:x.call(u,e.sessionId,e.payload));y!=null&&y.id&&D(y.id)}finally{L.value=!1}}async function tt(){var s,x;if(!b.value||F.value)return;const e=b.value.id;d.value="",F.value=!0;try{const y=await((s=u.onDelete)==null?void 0:s.call(u,e));C.value=!1;const H=u.sessions.filter(at=>at.id!==e),N=(y==null?void 0:y.selectedSessionId)||((x=ke(H)[0])==null?void 0:x.id)||"";k("select-session",N),N?(D(N),A.value&&W()):(g(),A.value&&W())}catch(y){d.value=y.message}finally{F.value=!1}}async function nt(){var s;if(!b.value||R.value)return;const e=b.value.id;d.value="",R.value=!0;try{const x=await((s=u.onReset)==null?void 0:s.call(u,e));E.value=!1;const y=(x==null?void 0:x.session)||u.sessions.find(H=>H.id===e)||null;y!=null&&y.id&&D(y.id)}catch(x){d.value=x.message}finally{R.value=!1}}return he(()=>u.open,e=>{if(e){Be(),typeof u.onRefresh=="function"?Xe().catch(()=>{}):Ae().catch(()=>{});return}G.value=!1,C.value=!1,E.value=!1,B.value=!1,d.value=""},{immediate:!0}),he(A,e=>{e||(J.value="detail")},{immediate:!0}),he(()=>u.sessions,()=>{if(!u.open)return;if(h.value==="create"){if(!!(String(r.title||"").trim()||String(r.cwd||"").trim())||!!String(r.sessionId||"").trim())return;const x=U();x&&D(x);return}if(b.value){l(b.value);return}const e=U();if(e){D(e);return}g()}),ft(()=>{V&&(clearTimeout(V),V=null)}),(e,s)=>(p(),f(xe,null,[S(Ue,{open:E.value,title:a(c)("projectManager.confirmResetTitle"),description:b.value?a(c)("projectManager.confirmResetDescription",{title:b.value.title||a(c)("projectManager.untitledProject")}):"","confirm-text":a(c)("projectManager.confirmReset"),"cancel-text":a(c)("projectManager.keep"),loading:R.value,onCancel:s[0]||(s[0]=x=>E.value=!1),onConfirm:nt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),S(Ue,{open:C.value,title:a(c)("projectManager.confirmDeleteTitle"),description:b.value?a(c)("projectManager.confirmDeleteDescription",{title:b.value.title||a(c)("projectManager.untitledProject")}):"","confirm-text":a(c)("projectManager.confirmDelete"),"cancel-text":a(c)("projectManager.keep"),loading:F.value,danger:"",onCancel:s[1]||(s[1]=x=>C.value=!1),onConfirm:tt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),S(un,{open:G.value,"initial-path":r.cwd,suggestions:re.value,onClose:s[2]||(s[2]=x=>G.value=!1),onSelect:Qe},null,8,["open","initial-path","suggestions"]),S(Ge,{open:i.open,"panel-class":"settings-dialog-panel h-full max-w-5xl sm:h-auto sm:max-h-[88vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body flex min-h-0 flex-1 overflow-hidden","close-disabled":I.value,"close-on-backdrop":!I.value,"close-on-escape":!I.value,onClose:s[12]||(s[12]=x=>k("close"))},{title:le(()=>[t("div",xa,[S(a(Ct),{class:"h-4 w-4"}),t("span",null,o(a(c)("projectManager.managingTitle")),1)])]),default:le(()=>{var x;return[a(A)?(p(),f("div",Ea,[J.value==="list"?(p(),f("div",La,[t("div",Fa,[S(We,{mobile:"",busy:I.value,"editing-session-id":M.value,"format-updated-at":m,"get-runtime-status-class":ge,"get-runtime-status-label":me,"get-thread-status-class":n,"get-thread-status-label":fe,"has-sessions":Z.value,"is-current-session":te,"is-session-running":z,mode:h.value,sessions:ne.value,onCreate:Y,onSelect:Re},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])])])):(p(),f("div",Ba,[t("div",Aa,[t("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 px-3 py-2 text-xs",disabled:I.value,onClick:W},[S(a(_t),{class:"h-4 w-4"}),t("span",null,o(a(c)("projectManager.projectList")),1)],8,Na),t("div",Oa,[t("div",za,o(je.value),1),h.value==="edit"&&((x=b.value)!=null&&x.cwd)?(p(),f("p",Ua,o(b.value.cwd),1)):j("",!0)])]),t("div",Ha,[t("div",Va,[t("button",{type:"button",class:P(["tool-button px-3 py-2 text-sm",O.value==="basic"?"tool-button-accent-subtle":""]),onClick:s[7]||(s[7]=y=>O.value="basic")},o(a(c)("projectManager.basicInfo")),3),t("button",{type:"button",class:P(["tool-button px-3 py-2 text-sm",O.value==="status"?"tool-button-accent-subtle":""]),disabled:h.value==="create",onClick:s[8]||(s[8]=y=>O.value="status")},o(a(c)("projectManager.status")),11,qa)])]),t("div",Wa,[O.value==="basic"?(p(),f("div",Ga,[S(qe,{mobile:"",busy:I.value,"can-edit-engine":h.value!=="edit"||oe.value,"can-edit-cwd":h.value!=="edit"||K.value,"can-edit-session-id":h.value!=="edit"||q.value,cwd:r.cwd,"cwd-readonly-message":Q.value,"duplicate-cwd-message":de.value,engine:r.engine,"engine-options":we.value,"engine-readonly-message":ce.value,"session-id":r.sessionId,"session-id-copied":B.value,"session-id-readonly-message":X.value,title:r.title,"workspace-suggestions":re.value,onCopySessionId:Ne,onOpenDirectoryPicker:s[9]||(s[9]=y=>G.value=!0),"onUpdate:cwd":Le,"onUpdate:engine":Ee,"onUpdate:sessionId":Fe,"onUpdate:title":De},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","engine-options","engine-readonly-message","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"]),d.value?(p(),f("p",Ja,[S(a(Ve),{class:"h-4 w-4"}),t("span",null,o(d.value),1)])):j("",!0),t("div",Ka,[t("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-sm",disabled:I.value,onClick:Oe},o(ue.value),9,Qa),h.value==="edit"&&b.value?(p(),f("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-sm",disabled:I.value||ae.value,onClick:s[10]||(s[10]=y=>E.value=!0)},o(R.value?a(c)("projectManager.resettingSession"):a(c)("projectManager.newSession")),9,Xa)):j("",!0),h.value==="edit"&&b.value?(p(),f("button",{key:1,type:"button",class:"tool-button tool-button-danger-subtle w-full px-3 py-2 text-sm",disabled:I.value||ae.value,onClick:s[11]||(s[11]=y=>C.value=!0)},o(F.value?a(c)("projectManager.deletingProject"):a(c)("projectManager.deleteProject")),9,Ya)):j("",!0)])])):(p(),se(ha,{key:1,"active-session":b.value,"format-updated-at":m,"get-runtime-status-class":ge,"get-runtime-status-label":me,"get-thread-status-class":n,"get-thread-status-label":fe,"is-current-session":te,"is-session-running":z},null,8,["active-session"]))])]))])):(p(),f("div",ya,[t("aside",ba,[S(We,{busy:I.value,"editing-session-id":M.value,"format-updated-at":m,"get-runtime-status-class":ge,"get-runtime-status-label":me,"get-thread-status-class":n,"get-thread-status-label":fe,"has-sessions":Z.value,"is-current-session":te,"is-session-running":z,mode:h.value,sessions:ne.value,onCreate:Y,onSelect:Re},null,8,["busy","editing-session-id","has-sessions","mode","sessions"])]),t("div",wa,[t("div",Sa,[t("div",null,[t("div",ka,[S(a(St),{class:"h-4 w-4"}),t("span",null,o(h.value==="create"?a(c)("projectManager.createTitle"):a(c)("projectManager.editTitle")),1)])])]),t("div",$a,[S(qe,{busy:I.value,"can-edit-engine":h.value!=="edit"||oe.value,"can-edit-cwd":h.value!=="edit"||K.value,"can-edit-session-id":h.value!=="edit"||q.value,cwd:r.cwd,"cwd-readonly-message":Q.value,"duplicate-cwd-message":de.value,engine:r.engine,"engine-options":we.value,"engine-readonly-message":ce.value,"session-id":r.sessionId,"session-id-copied":B.value,"session-id-readonly-message":X.value,title:r.title,"workspace-suggestions":re.value,onCopySessionId:Ne,onOpenDirectoryPicker:s[3]||(s[3]=y=>G.value=!0),"onUpdate:cwd":Le,"onUpdate:engine":Ee,"onUpdate:sessionId":Fe,"onUpdate:title":De},null,8,["busy","can-edit-engine","can-edit-cwd","can-edit-session-id","cwd","cwd-readonly-message","duplicate-cwd-message","engine","engine-options","engine-readonly-message","session-id","session-id-copied","session-id-readonly-message","title","workspace-suggestions"])]),d.value?(p(),f("p",_a,[S(a(Ve),{class:"h-4 w-4"}),t("span",null,o(d.value),1)])):j("",!0),t("div",Ca,[t("div",Ma,[h.value==="edit"&&b.value?(p(),f("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:I.value||ae.value,onClick:s[4]||(s[4]=y=>E.value=!0)},[S(a(kt),{class:"h-4 w-4"}),t("span",null,o(R.value?a(c)("projectManager.resettingSession"):a(c)("projectManager.newSession")),1)],8,ja)):j("",!0),h.value==="edit"&&b.value?(p(),f("button",{key:1,type:"button",class:"tool-button tool-button-danger-subtle inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:I.value||ae.value,onClick:s[5]||(s[5]=y=>C.value=!0)},[S(a($t),{class:"h-4 w-4"}),t("span",null,o(F.value?a(c)("projectManager.deletingProject"):a(c)("projectManager.deleteProject")),1)],8,Ia)):j("",!0)]),t("div",Pa,[t("button",{type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:I.value,onClick:s[6]||(s[6]=y=>k("close"))},o(a(c)("projectManager.close")),9,Ta),h.value==="create"&&Z.value?(p(),f("button",{key:0,type:"button",class:"tool-button w-full px-3 py-2 text-xs sm:w-auto",disabled:I.value,onClick:Be},o(a(c)("projectManager.backToList")),9,Ra)):j("",!0),t("button",{type:"button",class:"tool-button tool-button-primary w-full px-3 py-2 text-xs sm:w-auto",disabled:I.value,onClick:Oe},o(ue.value),9,Da)])])])]))]}),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"])],64))}};export{is as default};
@@ -1,2 +1,2 @@
1
- import{g as Xe,t as w,f as Ee,u as Re}from"./index-CGOI_HcK.js";import{u as Ye,g as Le,l as Ze,a as et,_ as tt,b as st}from"./WorkbenchView-CMjjT7fc.js";import{w as V,c as T,b as P,n as at,aB as h,aC as p,aD as a,aP as te,aQ as Se,aJ as F,aO as o,aE as S,u as t,aU as De,aV as nt,aL as B,aG as je,aH as ue,f as it,a_ as Ae}from"./vendor-misc-CWjGI0ex.js";import{g as lt,e as Ie,C as Ne,R as Be,b as rt,d as ot,F as qe,h as Ve,x as ze}from"./vendor-ui-D4mCpibF.js";import"./vendor-router-Bcjfmow0.js";import"./vendor-markdown-CNlC48LI.js";import"./vendor-tiptap-BCwG_IWj.js";function Z(e,n,u=""){const d=n==="run"?"run":n==="task"?"task":"workspace";return[String(e||"").trim(),d,String(u||"").trim()].join("::")}function ut(e="",n=""){return`${String(e||"").trim()}::${String(n||"").trim()}`}function dt(e=""){return`${String(e||"").trim()}::`}function Ge(e){if(!e||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function we(e,n){const u=e.get(n);return u?(e.delete(n),e.set(n,u),Ge(u)):null}function _e(e,n,u,d=0){for(e.delete(n),e.set(n,Ge(u));d>0&&e.size>d;){const l=e.keys().next().value;if(typeof l>"u")break;e.delete(l)}}function ee(e=""){const n=String(e||"").trim().toUpperCase();return n==="A"||n==="D"?n:"M"}function ct(e=""){const n=String(e||"");if(!n)return[];const u=n.split(`
1
+ import{g as Xe,t as w,f as Ee,u as Re}from"./index-CD4ppQq_.js";import{u as Ye,g as Le,l as Ze,a as et,_ as tt,b as st}from"./WorkbenchView-BXIMEYIR.js";import{w as V,c as T,b as P,n as at,aB as h,aC as p,aD as a,aP as te,aQ as Se,aJ as F,aO as o,aE as S,u as t,aU as De,aV as nt,aL as B,aG as je,aH as ue,f as it,a_ as Ae}from"./vendor-misc-CWjGI0ex.js";import{g as lt,e as Ie,C as Ne,R as Be,b as rt,d as ot,F as qe,h as Ve,x as ze}from"./vendor-ui-D4mCpibF.js";import"./vendor-router-Bcjfmow0.js";import"./vendor-markdown-CNlC48LI.js";import"./vendor-tiptap-BCwG_IWj.js";function Z(e,n,u=""){const d=n==="run"?"run":n==="task"?"task":"workspace";return[String(e||"").trim(),d,String(u||"").trim()].join("::")}function ut(e="",n=""){return`${String(e||"").trim()}::${String(n||"").trim()}`}function dt(e=""){return`${String(e||"").trim()}::`}function Ge(e){if(!e||typeof e!="object")return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function we(e,n){const u=e.get(n);return u?(e.delete(n),e.set(n,u),Ge(u)):null}function _e(e,n,u,d=0){for(e.delete(n),e.set(n,Ge(u));d>0&&e.size>d;){const l=e.keys().next().value;if(typeof l>"u")break;e.delete(l)}}function ee(e=""){const n=String(e||"").trim().toUpperCase();return n==="A"||n==="D"?n:"M"}function ct(e=""){const n=String(e||"");if(!n)return[];const u=n.split(`
2
2
  `),d=[];let l=0,x=0;return u.forEach((g,r)=>{const k=g.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(k){l=Number(k[1]),x=Number(k[2]),d.push({id:`hunk-${r}`,kind:"hunk",oldNumber:"",newNumber:"",content:g});return}if(g.startsWith("+")&&!g.startsWith("+++")){d.push({id:`line-${r}`,kind:"add",oldNumber:"",newNumber:x,content:g}),x+=1;return}if(g.startsWith("-")&&!g.startsWith("---")){d.push({id:`line-${r}`,kind:"delete",oldNumber:l,newNumber:"",content:g}),l+=1;return}if(g.startsWith(" ")){d.push({id:`line-${r}`,kind:"context",oldNumber:l,newNumber:x,content:g}),l+=1,x+=1;return}d.push({id:`line-${r}`,kind:"meta",oldNumber:"",newNumber:"",content:g})}),d}function ft(e=""){const n=String(e||"").trim();if(!n)return"";const u=n.match(/^当前分支已从 (.+) 切换到 (.+)$/);return u?w("diffReview.warningBranchChanged",{from:u[1],to:u[2]}):n==="当前 HEAD 已不在基线 commit 的后续历史中,仓库可能经历了 reset、rebase 或切分支"?w("diffReview.warningHeadDetachedFromBaseline"):n}function Oe(e=""){const n=String(e||"").trim();if(!n)return"";const d=new Map([["二进制文件暂不支持在线 diff 预览。","diffReview.binaryPreviewUnavailable"],["文件内容较大,暂不展示具体 diff。","diffReview.fileTooLarge"],["diff 内容较长,暂不在页面内完整展示。","diffReview.diffTooLong"],["当前工作目录不是 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(n);return d?w(d):n}function Te(e=null){return!e||typeof e!="object"?e:{...e,reason:Oe(e.reason),warnings:Array.isArray(e.warnings)?e.warnings.map(n=>ft(n)).filter(Boolean):[],files:Array.isArray(e.files)?e.files.map(n=>({...n,message:Oe(n==null?void 0:n.message)})):[]}}function ht(e){const n=P("workspace"),u=P(""),d=P(""),l=P("all"),x=P(""),g=P([]),r=P(null),k=P(!1),D=P(!1),y=P(""),z=P(!1),re=P(null),se=P(0),O=new Map,E=Ye();let J=0,M=0,j="",_="",A="",H=-1;const U=new Map,K=new Map,ae=new Map,ne=T(()=>g.value.filter(s=>s.completed)),de=T(()=>{var i;const s={all:0,A:0,M:0,D:0};return(((i=r.value)==null?void 0:i.files)||[]).forEach(c=>{const v=ee(c==null?void 0:c.status);s.all+=1,s[v]+=1}),s}),Q=T(()=>{var c;const s=((c=r.value)==null?void 0:c.files)||[],i=String(x.value||"").trim().toLowerCase();return s.filter(v=>l.value!=="all"&&ee(v==null?void 0:v.status)!==l.value?!1:i?String((v==null?void 0:v.path)||"").toLowerCase().includes(i):!0)}),ce=T(()=>{const s=Q.value;return s.find(i=>i.path===d.value)||s[0]||null}),oe=T(()=>{var s;return ct(((s=ce.value)==null?void 0:s.patch)||"")}),I=T(()=>oe.value.map((s,i)=>({...s,index:i})).filter(s=>s.kind==="hunk")),fe=T(()=>{var s,i;return D.value&&!((i=(s=r.value)==null?void 0:s.summary)!=null&&i.statsComplete)}),X=T(()=>{var c;const s=((c=r.value)==null?void 0:c.baseline)||null;if(!(s!=null&&s.createdAt)&&!(s!=null&&s.headShort))return"";const i=[];return s.createdAt&&i.push(w("diffReview.baselineTime",{value:Ee(s.createdAt)})),s.branch&&i.push(w("diffReview.baselineBranch",{value:s.branch})),s.headShort&&i.push(w("diffReview.baselineCommit",{value:s.headShort})),s.currentHeadShort&&i.push(w("diffReview.currentHead",{value:s.currentHeadShort})),i.join(" · ")});function L(s){return(s==null?void 0:s.status)==="completed"?w("diffReview.completed"):(s==null?void 0:s.status)==="error"?w("diffReview.failed"):(s==null?void 0:s.status)==="interrupted"?w("diffReview.interrupted"):w("diffReview.stopped")}function b(s,i){if(s){if(i){O.set(s,i);return}O.delete(s)}}function he(s,i={}){const c=I.value;if(!c.length)return;const v=Math.min(Math.max(0,Number(s)||0),c.length-1),$=c[v],R=O.get($.id);R&&(se.value=v,R.scrollIntoView({block:i.block||"center",behavior:i.behavior||"smooth"}))}function me(s=1){I.value.length&&he(se.value+s)}function N(s){return`${new Date((s==null?void 0:s.startedAt)||(s==null?void 0:s.createdAt)).toLocaleString(Xe())} · ${L(s)}`}function f(){const s=ne.value;if(!s.length){u.value="";return}s.some(i=>i.id===u.value)||(u.value=s[0].id)}function Y(){const s=Q.value;if(!s.length){d.value="";return}s.some(i=>i.path===d.value)||(d.value=s[0].path)}function ve(s=""){return ee(s)==="A"?w("diffReview.added"):ee(s)==="D"?w("diffReview.deleted"):w("diffReview.modified")}function pe(s=""){return ee(s)==="A"?"theme-status-success":ee(s)==="D"?"theme-status-danger":"theme-status-warning"}function ge(s="all"){return s==="A"?w("diffReview.added"):s==="D"?w("diffReview.deleted"):s==="M"?w("diffReview.modified"):w("diffReview.all")}function xe(s="all"){return l.value===s?"theme-filter-active":"theme-filter-idle"}function m(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 ie(s,i=""){const c=String(i||"").trim();c&&Array.from(s.keys()).forEach(v=>{String(v||"").startsWith(c)&&s.delete(v)})}function Ce(){const s=dt(e.taskSlug);ie(U,s),ie(K,s),ie(ae,s)}async function Je(){if(!e.taskSlug){g.value=[],u.value="",A="",H=-1;return}const s=E.getTaskRunSyncVersion(e.taskSlug);if(A===e.taskSlug&&H===s)return;const i=await Ze(e.taskSlug,{limit:20,events:"none"});g.value=i.items||[],A=e.taskSlug,H=s,f()}async function Fe(){if(!e.taskSlug||!e.active)return;const s=++J;k.value=!0,D.value=!1,y.value="";try{const i=n.value==="run"?"run":n.value==="task"?"task":"workspace";i==="run"&&await Je();const c=Z(e.taskSlug,i,i==="run"?u.value:"");if(i==="run"&&!u.value){r.value={supported:!1,reason:w("diffReview.noReviewRuns"),repoRoot:"",summary:{fileCount:0,additions:0,deletions:0,statsComplete:!0},files:[]},Y();return}const v=we(U,c);if(v){r.value=v,j=c;const C=we(K,c);C?(r.value={...v,baseline:C.baseline||v.baseline||null,warnings:C.warnings||v.warnings||[],summary:C.summary||v.summary},_=c):_="",Y(),ye().catch(()=>{}),C||He().catch(()=>{});return}const $=await Le(e.taskSlug,{scope:i,runId:i==="run"?u.value:"",includeStats:!1});if(s!==J)return;const R=Te($);r.value=R,_e(U,c,R,36),j=c,_="",Y(),ye().catch(()=>{}),He().catch(()=>{})}catch(i){if(s!==J)return;y.value=i.message,r.value=null}finally{s===J&&(k.value=!1)}}async function He(){var $,R,C;if(!e.taskSlug||!e.active||!(($=r.value)!=null&&$.supported))return;const s=n.value==="run"?"run":n.value==="task"?"task":"workspace",i=s==="run"?u.value:"",c=Z(e.taskSlug,s,i);if(_===c&&((C=(R=r.value)==null?void 0:R.summary)!=null&&C.statsComplete))return;const v=we(K,c);if(v){r.value={...r.value,baseline:v.baseline||r.value.baseline||null,warnings:v.warnings||r.value.warnings||[],summary:v.summary||r.value.summary},_=c,D.value=!1;return}D.value=!0;try{const q=await Le(e.taskSlug,{scope:s,runId:i,includeFiles:!1,includeStats:!0}),le=Z(e.taskSlug,n.value,n.value==="run"?u.value:"");if(c!==le||!r.value)return;const W=Te(q);r.value={...r.value,baseline:W.baseline||r.value.baseline||null,warnings:W.warnings||r.value.warnings||[],summary:W.summary||r.value.summary},_e(K,c,{baseline:W.baseline||null,warnings:W.warnings||[],summary:W.summary||null},36),_=c}catch{}finally{const q=Z(e.taskSlug,n.value,n.value==="run"?u.value:"");c===q&&(D.value=!1)}}async function ye(){var le,W,Me;const s=String(d.value||"").trim();if(!e.taskSlug||!e.active||!s||z.value)return;const i=n.value==="run"?"run":n.value==="task"?"task":"workspace",c=i==="run"?u.value:"",v=Z(e.taskSlug,i,c),$=(((le=r.value)==null?void 0:le.files)||[]).find(G=>G.path===s);if(!$||$.patchLoaded||$.binary||$.tooLarge||$.message)return;const R=ut(v,s),C=we(ae,R);if(C&&((W=r.value)!=null&&W.files)){r.value={...r.value,files:r.value.files.map(G=>G.path===s?C:G)};return}const q=++M;z.value=!0;try{const G=await Le(e.taskSlug,{scope:i,runId:c,filePath:s});if(q!==M)return;const Qe=Z(e.taskSlug,n.value,n.value==="run"?u.value:"");if(v!==Qe)return;const $e=Te(G),Pe=($e.files||[]).find(ke=>ke.path===s);if(!Pe||!((Me=r.value)!=null&&Me.files))return;_e(ae,R,Pe,120),r.value={...r.value,baseline:$e.baseline||r.value.baseline||null,warnings:$e.warnings||r.value.warnings||[],files:r.value.files.map(ke=>ke.path===s?Pe:ke)}}catch(G){y.value=G.message}finally{q===M&&(z.value=!1,String(d.value||"").trim()!==s&&ye().catch(()=>{}))}}function be({force:s=!1}={}){if(!e.taskSlug||!e.active)return;const i=Z(e.taskSlug,n.value,n.value==="run"?u.value:"");!s&&i===j||Fe().catch(()=>{})}async function Ke(){!e.taskSlug||!e.active||k.value||(Ce(),j="",_="",A="",H=-1,await Fe())}return V(()=>[e.taskSlug,e.active,n.value,u.value],([s,i],c=[])=>{const v=c[0]||"";s!==v&&(d.value="",j="",g.value=[],u.value="",A="",H=-1,_=""),!(!s||!i)&&be()},{immediate:!0}),V(()=>{var s,i;return[l.value,((i=(s=r.value)==null?void 0:s.files)==null?void 0:i.length)||0]},()=>{Y()}),V(()=>[d.value,I.value.length],()=>{se.value=0,O.clear(),at(()=>{var s,i;I.value.length?he(0,{behavior:"auto",block:"start"}):(i=(s=re.value)==null?void 0:s.scrollTo)==null||i.call(s,{top:0,behavior:"auto"})})}),V(()=>d.value,()=>{ye().catch(()=>{})},{immediate:!0}),V(()=>[e.preferredScope,e.preferredRunId,e.focusToken],([s,i,c],v=[])=>{const $=Number(v[2]||0),R=s==="run"?"run":s==="task"?"task":"workspace",C=R==="run"&&i?String(i||""):"",q=n.value!==R,le=R==="run"&&C&&u.value!==C;n.value=R,C&&(u.value=C),R!=="run"&&(u.value=""),!q&&!le&&e.active&&e.taskSlug&&c!==$&&(j="",be())},{immediate:!0}),V(()=>E.readyVersion.value,()=>{!e.active||!e.taskSlug||(A="",H=-1,j="",_="",be({force:!0}))}),V(()=>E.getTaskDiffSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||(A="",H=-1,_="",j="",be({force:!0}))}),{activeHunkIndex:se,baselineMetaText:X,diffPayload:r,diffScope:n,error:y,fileSearch:x,filteredFiles:Q,getFilterButtonClass:xe,getFilterLabel:ge,getPatchLineClass:m,getRunStatusLabel:L,getStatusClass:pe,getStatusLabel:ve,jumpToAdjacentHunk:me,loadDiff:Fe,loading:k,normalizeFileStatus:ee,patchLoading:z,patchViewportRef:re,runs:g,selectedFile:ce,selectedFilePath:d,selectedPatchHunks:I,selectedPatchLines:oe,selectedRunId:u,setPatchLineRef:b,showSummarySkeleton:fe,statsLoading:D,statusCounts:de,statusFilter:l,terminalRuns:ne,formatRunOptionLabel:N,refreshDiff:Ke}}const mt={class:"mb-3 grid grid-cols-2 gap-2"},vt=["onClick"],pt={class:"theme-input-shell mb-3 flex items-center gap-2 rounded-sm border px-3 py-2 text-xs text-[var(--theme-textMuted)]"},gt=["placeholder"],xt={key:0,class:"theme-empty-state theme-empty-state-strong mb-3 px-3 py-2 text-[11px]"},yt={key:1,class:"theme-empty-state px-3 py-4 text-xs"},bt={key:2,class:"theme-empty-state px-3 py-4 text-xs"},kt={key:3,class:"space-y-2"},wt=["onClick"],St={class:"flex items-start gap-2"},Rt={class:"min-w-0 flex-1"},Ct={class:"break-all text-xs font-medium"},Ft={class:"mt-1 text-[11px] opacity-75"},Ue={__name:"TaskDiffFileList",props:{diffPayload:{type:Object,default:null},fileSearch:{type:String,default:""},filteredFiles:{type:Array,default:()=>[]},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:n}){const u=e,d=n,{t:l}=Re(),x=T({get:()=>u.fileSearch,set:k=>d("update:fileSearch",k)}),g=T({get:()=>u.statusFilter,set:k=>d("update:statusFilter",k)}),r=T(()=>{var k;return Array.isArray((k=u.diffPayload)==null?void 0:k.files)&&u.diffPayload.files.length>0});return(k,D)=>(h(),p(te,null,[a("div",mt,[(h(),p(te,null,Se(["all","A","M","D"],y=>a("button",{key:y,type:"button",class:F(["inline-flex w-full items-center justify-center gap-1 whitespace-nowrap rounded-sm border px-2 py-1 text-[11px] transition",e.getFilterButtonClass(y)]),onClick:z=>g.value=y},o(e.getFilterLabel(y))+" "+o(e.statusCounts[y]||0),11,vt)),64))]),a("label",pt,[S(t(lt),{class:"h-3.5 w-3.5 shrink-0"}),De(a("input",{"onUpdate:modelValue":D[0]||(D[0]=y=>x.value=y),type:"text",placeholder:t(l)("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,gt),[[nt,x.value]])]),e.showSummarySkeleton?(h(),p("div",xt,o(t(l)("diffReview.statsPending")),1)):B("",!0),r.value?e.filteredFiles.length?(h(),p("div",kt,[(h(!0),p(te,null,Se(e.filteredFiles,y=>(h(),p("button",{key:y.path,type:"button",class:F(["w-full rounded-sm border px-3 py-2 text-left transition",y.path===e.selectedFilePath?"theme-filter-active":"theme-filter-idle"]),onClick:z=>d("select-file",y.path)},[a("div",St,[a("span",{class:F(["inline-flex shrink-0 rounded-sm border px-1.5 py-0.5 text-[10px]",e.getStatusClass(y.status)])},o(e.getStatusLabel(y.status)),3),a("div",Rt,[a("div",Ct,o(y.path),1),a("div",Ft,o(y.statsLoaded?`+${y.additions} / -${y.deletions}`:t(l)("diffReview.statsOnDemand")),1)])])],10,wt))),128))])):(h(),p("div",bt,o(t(l)("diffReview.noMatches")),1)):(h(),p("div",yt,o(t(l)("diffReview.noChanges")),1))],64))}},$t={key:0,class:"flex h-full min-h-0 flex-col overflow-hidden"},Pt={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-xs"},Lt={class:"space-y-3 sm:hidden"},_t={class:"flex items-start gap-2"},Tt={class:"min-w-0 break-all font-medium text-[var(--theme-textPrimary)]"},Dt={class:"flex items-center justify-between gap-3"},jt={class:"opacity-75"},Ht=["disabled"],Mt={class:"min-w-[64px] text-center text-[11px] text-[var(--theme-textSecondary)]"},At=["disabled"],It={class:"hidden items-center gap-3 sm:flex"},Nt={class:"flex min-w-0 flex-1 flex-wrap items-center gap-2"},Bt={class:"break-all font-medium text-[var(--theme-textPrimary)]"},Vt={class:"opacity-75"},zt=["disabled"],Ot={class:"min-w-[64px] text-center text-[11px] text-[var(--theme-textSecondary)]"},Ut=["disabled"],Wt={key:0,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-sm"},Et={class:"theme-empty-state px-4 py-4"},qt={key:1,class:"theme-muted-text flex-1 overflow-y-auto px-4 py-4 text-sm"},Gt={class:"min-w-max px-4 py-4 font-mono text-[11px] leading-5"},Jt={class:"select-none border-r border-[var(--theme-borderMuted)] px-2 py-0.5 text-right opacity-60"},Kt={class:"select-none border-r border-[var(--theme-borderMuted)] px-2 py-0.5 text-right opacity-60"},Qt={class:"overflow-visible whitespace-pre px-3 py-0.5"},Xt={key:3,class:"theme-secondary-text flex-1 overflow-y-auto px-4 py-4 text-sm"},Yt={class:"theme-empty-state px-4 py-4"},Zt={key:1,class:"theme-muted-text flex h-full items-center justify-center px-5 text-sm"},We={__name:"TaskDiffPatchView",props:{activeHunkIndex:{type:Number,default:0},getPatchLineClass:{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:()=>{}}},setup(e){const{t:n}=Re();return(u,d)=>e.selectedFile?(h(),p("div",$t,[a("div",Pt,[a("div",Lt,[a("div",_t,[a("span",{class:F(["inline-flex shrink-0 rounded-sm border px-1.5 py-0.5 text-[10px]",e.getStatusClass(e.selectedFile.status)])},o(e.getStatusLabel(e.selectedFile.status)),3),a("span",Tt,o(e.selectedFile.path),1)]),a("div",Dt,[a("span",jt,o(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:t(n)("diffReview.statsOnDemand")),1),a("div",{class:F(["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]=l=>e.jumpToAdjacentHunk(-1))},[S(t(Ie),{class:"h-4 w-4"})],8,Ht),a("span",Mt,o(t(n)("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]=l=>e.jumpToAdjacentHunk(1))},[S(t(Ne),{class:"h-4 w-4"})],8,At)],2)])]),a("div",It,[a("div",Nt,[a("span",{class:F(["inline-flex rounded-sm border px-1.5 py-0.5 text-[10px]",e.getStatusClass(e.selectedFile.status)])},o(e.getStatusLabel(e.selectedFile.status)),3),a("span",Bt,o(e.selectedFile.path),1),a("span",Vt,o(e.selectedFile.statsLoaded?`+${e.selectedFile.additions} / -${e.selectedFile.deletions}`:t(n)("diffReview.statsOnDemand")),1)]),a("div",{class:F(["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]=l=>e.jumpToAdjacentHunk(-1))},[S(t(Ie),{class:"h-4 w-4"})],8,zt),a("span",Ot,o(t(n)("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]=l=>e.jumpToAdjacentHunk(1))},[S(t(Ne),{class:"h-4 w-4"})],8,Ut)],2)])]),e.selectedFile.message?(h(),p("div",Wt,[a("div",Et,o(e.selectedFile.message),1)])):e.patchLoading&&!e.selectedFile.patchLoaded?(h(),p("div",qt,o(t(n)("diffReview.loadingFileDiff")),1)):e.selectedPatchLines.length?(h(),p("div",{key:2,ref:e.setPatchViewportRef,class:"flex-1 overflow-auto"},[a("div",Gt,[(h(!0),p(te,null,Se(e.selectedPatchLines,l=>{var x;return h(),p("div",{key:l.id,ref_for:!0,ref:g=>e.setPatchLineRef(l.id,g),class:F(["grid grid-cols-[56px_56px_minmax(0,1fr)]",[e.getPatchLineClass(l.kind),l.kind==="hunk"&&((x=e.selectedPatchHunks[e.activeHunkIndex])==null?void 0:x.id)===l.id?"ring-1 ring-inset ring-[var(--theme-warning)]":""]])},[a("span",Jt,o(l.oldNumber),1),a("span",Kt,o(l.newNumber),1),a("pre",Qt,o(l.content),1)],2)}),128))])],512)):(h(),p("div",Xt,[a("div",Yt,o(t(n)("diffReview.noFileDiffContent")),1)]))])):(h(),p("div",Zt,o(t(n)("diffReview.selectFile")),1))}},es={class:"panel flex h-full min-h-0 flex-col overflow-hidden"},ts={class:"theme-divider border-b px-4 py-3"},ss={class:"flex flex-col gap-2"},as={class:"grid grid-cols-4 gap-2 sm:flex sm:flex-wrap sm:items-center"},ns={class:"sm:hidden"},is={class:"hidden sm:inline"},ls={class:"sm:hidden"},rs={class:"hidden sm:inline"},os=["disabled"],us={class:"sm:hidden"},ds={class:"hidden sm:inline"},cs={class:"truncate text-xs text-[var(--theme-textPrimary)]"},fs={class:"theme-divider theme-muted-text border-b border-dashed px-3 py-2 text-[11px]"},hs=["onClick"],ms={class:"flex items-start gap-3"},vs={class:"min-w-0 flex-1"},ps={class:"truncate text-xs font-medium text-[var(--theme-textPrimary)]"},gs={class:"theme-muted-text mt-1 text-[11px]"},xs={key:0,class:"theme-divider theme-danger-text border-b px-4 py-3 text-sm"},ys={class:"inline-flex items-start gap-2"},bs={class:"break-all"},ks={key:1,class:"theme-muted-text flex flex-1 items-center justify-center px-5 text-sm"},ws={key:2,class:"flex flex-1 items-center justify-center px-5"},Ss={class:"theme-empty-state w-full max-w-xl px-4 py-5 text-sm text-[var(--theme-textSecondary)]"},Rs={class:"theme-heading inline-flex items-center gap-2 font-medium"},Cs={class:"mt-2 break-all leading-7"},Fs={key:0,class:"mt-3 flex flex-wrap gap-2 text-xs"},$s={class:"theme-status-neutral inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},Ps={class:"break-all"},Ls={key:0,class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},_s={key:3,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Ts={class:"theme-divider theme-secondary-text border-b px-4 py-3 text-xs"},Ds={class:"flex flex-wrap items-center gap-2"},js={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"},Hs={class:"min-w-0 break-all"},Ms={class:"theme-status-success inline-flex items-center gap-2 rounded-sm border border-dashed px-2.5 py-1.5"},As={class:"text-[var(--theme-textPrimary)]"},Is={class:"font-medium text-[var(--theme-success)]"},Ns={class:"font-medium text-[var(--theme-danger)]"},Bs={key:2,class:"opacity-75"},Vs={key:0,class:"mt-2 break-all text-[11px] opacity-75"},zs={key:1,class:"mt-2 flex flex-col gap-1"},Os={key:0,class:"flex min-h-0 flex-1 flex-col overflow-hidden"},Us={class:"theme-divider border-b px-3 py-3"},Ws={class:"grid grid-cols-2 gap-2"},Es=["disabled"],qs={class:"theme-divider theme-muted-panel min-h-0 flex-1 overflow-y-auto p-3"},Gs={class:"min-h-0 flex-1 overflow-hidden bg-[var(--theme-appPanelStrong)]"},Js={key:1,class:"grid min-h-0 flex-1 grid-cols-[320px_minmax(0,1fr)] overflow-hidden"},Ks={class:"theme-divider theme-muted-panel min-h-0 overflow-y-auto border-r p-3"},Qs={class:"min-h-0 overflow-hidden bg-[var(--theme-appPanelStrong)]"},Xs={__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}},setup(e){const n=e,{activeHunkIndex:u,baselineMetaText:d,diffPayload:l,diffScope:x,error:g,fileSearch:r,filteredFiles:k,formatRunOptionLabel:D,getFilterButtonClass:y,getFilterLabel:z,getPatchLineClass:re,getRunStatusLabel:se,getStatusClass:O,getStatusLabel:E,jumpToAdjacentHunk:J,loading:M,patchLoading:j,patchViewportRef:_,refreshDiff:A,selectedFile:H,selectedFilePath:U,selectedPatchHunks:K,selectedPatchLines:ae,selectedRunId:ne,setPatchLineRef:de,showSummarySkeleton:Q,statsLoading:ce,statusCounts:oe,statusFilter:I,terminalRuns:fe}=ht(n),{matches:X}=et("(max-width: 767px)"),L=P("files"),{t:b}=Re();function he(N){U.value=N,X.value&&(L.value="patch")}function me(N){_.value=N||null}return V(X,N=>{N||(L.value="files")},{immediate:!0}),V(U,N=>{!N&&X.value&&(L.value="files")}),V(x,()=>{X.value&&(L.value="files")}),(N,f)=>{var Y,ve,pe,ge,xe;return h(),p("section",es,[a("div",ts,[a("div",ss,[a("div",as,[a("button",{type:"button",class:F(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(x)==="workspace"?"theme-filter-active":""]),onClick:f[0]||(f[0]=m=>x.value="workspace")},[a("span",ns,o(t(b)("diffReview.scopeCurrentShort")),1),a("span",is,o(t(b)("diffReview.scopeCurrent")),1)],2),a("button",{type:"button",class:F(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(x)==="task"?"theme-filter-active":""]),onClick:f[1]||(f[1]=m=>x.value="task")},[a("span",ls,o(t(b)("diffReview.scopeTaskShort")),1),a("span",rs,o(t(b)("diffReview.scopeTask")),1)],2),a("button",{type:"button",class:F(["tool-button inline-flex items-center justify-center gap-2 px-3 py-2 text-xs",t(x)==="run"?"theme-filter-active":""]),onClick:f[2]||(f[2]=m=>x.value="run")},[a("span",null,o(t(b)("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(M),onClick:f[3]||(f[3]=(...m)=>t(A)&&t(A)(...m))},[S(t(Be),{class:F(["h-3.5 w-3.5 sm:hidden",t(M)?"animate-spin":""])},null,8,["class"]),a("span",us,o(t(b)("diffReview.refresh")),1),S(t(Be),{class:F(["hidden h-3.5 w-3.5 sm:inline-block",t(M)?"animate-spin":""])},null,8,["class"]),a("span",ds,o(t(M)?t(b)("diffReview.refreshing"):t(ce)?t(b)("diffReview.computing"):t(b)("diffReview.refresh")),1)],8,os)]),t(x)==="run"?(h(),je(tt,{key:0,modelValue:t(ne),"onUpdate:modelValue":f[4]||(f[4]=m=>it(ne)?ne.value=m:null),class:"min-w-0 sm:max-w-[360px]",options:t(fe),loading:t(M),"get-option-value":m=>(m==null?void 0:m.id)||"",placeholder:t(b)("diffReview.selectRun"),"empty-text":t(b)("diffReview.noRuns")},{trigger:ue(({selectedOption:m})=>[a("div",cs,o(m?t(D)(m):t(b)("diffReview.selectRun")),1)]),header:ue(()=>[a("div",fs,o(t(b)("diffReview.runCount",{count:t(fe).length})),1)]),option:ue(({option:m,selected:ie,select:Ce})=>[a("button",{type:"button",class:F(["w-full rounded-sm border border-dashed px-3 py-2 text-left transition",ie?"theme-filter-active":"theme-filter-idle"]),onClick:Ce},[a("div",ms,[a("div",vs,[a("div",ps,o(t(Ee)(m.startedAt||m.createdAt)),1),a("div",gs,o(t(se)(m)),1)]),ie?(h(),je(t(rt),{key:0,class:"mt-0.5 h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):B("",!0)])],10,hs)]),_:1},8,["modelValue","options","loading","get-option-value","placeholder","empty-text"])):B("",!0)])]),t(g)?(h(),p("div",xs,[a("div",ys,[S(t(ot),{class:"mt-0.5 h-4 w-4 shrink-0"}),a("span",bs,o(t(g)),1)])])):B("",!0),t(M)&&!t(l)?(h(),p("div",ks,o(t(b)("diffReview.loading")),1)):t(l)&&!t(l).supported?(h(),p("div",ws,[a("div",Ss,[a("div",Rs,[S(t(qe),{class:"h-4 w-4"}),a("span",null,o(t(b)("diffReview.unavailableTitle")),1)]),a("p",Cs,o(t(l).reason||t(b)("diffReview.unavailableReason")),1),t(l).repoRoot?(h(),p("div",Fs,[a("div",$s,[S(t(Ve),{class:"h-3.5 w-3.5 shrink-0"}),a("span",Ps,o(t(l).repoRoot),1)]),t(l).branch?(h(),p("div",Ls,[S(t(ze),{class:"h-3.5 w-3.5 shrink-0"}),a("span",null,o(t(l).branch),1)])):B("",!0)])):B("",!0)])])):t(l)?(h(),p("div",_s,[a("div",Ts,[a("div",Ds,[t(l).repoRoot?(h(),p("div",js,[S(t(Ve),{class:"h-3.5 w-3.5 shrink-0"}),a("span",Hs,o(t(l).repoRoot),1)])):B("",!0),a("div",Ms,[S(t(ze),{class:"h-3.5 w-3.5 shrink-0"}),a("span",null,o(t(l).branch||t(b)("diffReview.unknownBranch")),1),f[16]||(f[16]=a("span",{class:"opacity-50"},"•",-1)),a("span",As,o(t(b)("diffReview.fileCount",{count:((Y=t(l).summary)==null?void 0:Y.fileCount)||0})),1),(ve=t(l).summary)!=null&&ve.statsComplete?(h(),p(te,{key:0},[f[12]||(f[12]=a("span",{class:"opacity-50"},"•",-1)),a("span",Is,"+"+o(((pe=t(l).summary)==null?void 0:pe.additions)||0),1),a("span",Ns,"-"+o(((ge=t(l).summary)==null?void 0:ge.deletions)||0),1)],64)):t(Q)?(h(),p(te,{key:1},[f[13]||(f[13]=a("span",{class:"opacity-50"},"•",-1)),f[14]||(f[14]=a("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-successSoft)]"},null,-1)),f[15]||(f[15]=a("span",{class:"h-3 w-10 animate-pulse rounded bg-[var(--theme-dangerSoft)]"},null,-1))],64)):(h(),p("span",Bs,o(t(b)("diffReview.waitingStats")),1))])]),t(d)?(h(),p("p",Vs,o(t(d)),1)):B("",!0),(xe=t(l).warnings)!=null&&xe.length?(h(),p("div",zs,[(h(!0),p(te,null,Se(t(l).warnings,m=>(h(),p("p",{key:m,class:"text-[11px] text-[var(--theme-warningText)]"},o(m),1))),128))])):B("",!0)]),t(X)?(h(),p("div",Os,[a("div",Us,[a("div",Ws,[a("button",{type:"button",class:F(["tool-button px-3 py-2 text-sm",L.value==="files"?"tool-button-accent-subtle":""]),onClick:f[5]||(f[5]=m=>L.value="files")},o(t(b)("diffReview.filesTab")),3),a("button",{type:"button",class:F(["tool-button px-3 py-2 text-sm",L.value==="patch"?"tool-button-accent-subtle":""]),disabled:!t(H),onClick:f[6]||(f[6]=m=>L.value="patch")},o(t(b)("diffReview.diffTab")),11,Es)])]),De(a("div",qs,[S(Ue,{"diff-payload":t(l),"file-search":t(r),"filtered-files":t(k),"get-filter-button-class":t(y),"get-filter-label":t(z),"get-status-class":t(O),"get-status-label":t(E),"selected-file-path":t(U),"show-summary-skeleton":t(Q),"status-counts":t(oe),"status-filter":t(I),"onUpdate:fileSearch":f[7]||(f[7]=m=>r.value=m),"onUpdate:statusFilter":f[8]||(f[8]=m=>I.value=m),onSelectFile:he},null,8,["diff-payload","file-search","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),[[Ae,L.value==="files"]]),De(a("div",Gs,[S(We,{"active-hunk-index":t(u),"get-patch-line-class":t(re),"get-status-class":t(O),"get-status-label":t(E),"jump-to-adjacent-hunk":t(J),"patch-loading":t(j),"selected-file":t(H),"selected-patch-hunks":t(K),"selected-patch-lines":t(ae),"set-patch-line-ref":t(de),"set-patch-viewport-ref":me},null,8,["active-hunk-index","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),[[Ae,L.value==="patch"]])])):(h(),p("div",Js,[a("div",Ks,[S(Ue,{"diff-payload":t(l),"file-search":t(r),"filtered-files":t(k),"get-filter-button-class":t(y),"get-filter-label":t(z),"get-status-class":t(O),"get-status-label":t(E),"selected-file-path":t(U),"show-summary-skeleton":t(Q),"status-counts":t(oe),"status-filter":t(I),"onUpdate:fileSearch":f[9]||(f[9]=m=>r.value=m),"onUpdate:statusFilter":f[10]||(f[10]=m=>I.value=m),onSelectFile:f[11]||(f[11]=m=>U.value=m)},null,8,["diff-payload","file-search","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",Qs,[S(We,{"active-hunk-index":t(u),"get-patch-line-class":t(re),"get-status-class":t(O),"get-status-label":t(E),"jump-to-adjacent-hunk":t(J),"patch-loading":t(j),"selected-file":t(H),"selected-patch-hunks":t(K),"selected-patch-lines":t(ae),"set-patch-line-ref":t(de),"set-patch-viewport-ref":me},null,8,["active-hunk-index","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"])])]))])):B("",!0)])}}},Ys={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},la={__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"],setup(e,{emit:n}){const u=e,d=n,{t:l}=Re(),x=T(()=>{const g=String(u.taskTitle||"").trim();return g?l("diffReview.dialogTitleWithTask",{title:g}):l("diffReview.dialogTitle")});return(g,r)=>(h(),je(st,{open:e.open,"panel-class":"settings-dialog-panel h-full sm:h-[min(90vh,960px)] sm:max-w-[min(96vw,1560px)]","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:r[0]||(r[0]=k=>d("close"))},{title:ue(()=>[a("div",Ys,[S(t(qe),{class:"h-4 w-4"}),a("span",null,o(x.value),1)])]),default:ue(()=>[S(Xs,{"task-slug":e.taskSlug,active:e.open,"preferred-scope":e.preferredScope,"preferred-run-id":e.preferredRunId,"focus-token":e.focusToken},null,8,["task-slug","active","preferred-scope","preferred-run-id","focus-token"])]),_:1},8,["open"]))}};export{la as default};
@@ -1 +1 @@
1
- import{aB as l,aC as c,aD as e,aO as a,u as i,aP as se,aQ as ne,aJ as Qe,aT as Ct,aG as U,aL as v,c as h,w as We,ak as wt,aH as de,aE as z,aU as te,aW as Rt,aV as xe,b0 as Tt,b as m,r as _e}from"./vendor-misc-CWjGI0ex.js";import{r as H,c as St,_ as Pt,b as Et,d as Mt}from"./WorkbenchView-CMjjT7fc.js";import{u as Xe,c as Ut,f as $t}from"./index-CGOI_HcK.js";import{b as Bt,y as Je,E as Nt,c as Lt,L as me,z as Ke,r as Ft,D as jt,v as It}from"./vendor-ui-D4mCpibF.js";import"./vendor-markdown-CNlC48LI.js";import"./vendor-tiptap-BCwG_IWj.js";import"./vendor-router-Bcjfmow0.js";function qt(){return H("/api/relay/config",{cache:"no-store"})}function Ge($){return H("/api/relay/config",{method:"PUT",body:JSON.stringify($)})}function Vt(){return H("/api/relay/reconnect",{method:"POST"})}function At(){return H("/api/system/config",{cache:"no-store"})}function zt($){return H("/api/system/config",{method:"PUT",body:JSON.stringify($)})}function Ht(){return H("/api/diagnostics/runtime",{cache:"no-store"})}const Ot={class:"space-y-4"},Wt={class:"flex items-center justify-between gap-3"},Jt={class:"theme-heading text-sm font-medium"},Kt={class:"theme-toggle-current theme-badge-muted theme-muted-text rounded-sm border border-dashed px-2 py-1 text-[11px]"},Gt={class:"theme-muted-text theme-note-text mt-1"},Qt={class:"space-y-4"},Xt={class:"theme-muted-text px-1 text-[10px] font-medium uppercase tracking-[0.16em]"},Yt=["onClick"],Zt={class:"flex items-start gap-3"},es={class:"mt-0.5 flex items-center gap-1.5"},ts={class:"min-w-0 flex-1"},ss={class:"flex items-center justify-between gap-2"},ns={class:"truncate text-sm font-medium"},as={class:"theme-muted-text theme-note-text mt-1"},is={__name:"ThemeToggle",setup($){const{currentTheme:O,setTheme:W,themes:ae}=Ut(),{t:T}=Xe(),ge=h(()=>{const b=ae.value.filter(x=>x.mode==="light"),F=ae.value.filter(x=>x.mode==="dark");return[{id:"light",label:T("theme.groupLight"),items:b},{id:"dark",label:T("theme.groupDark"),items:F}].filter(x=>x.items.length)});function ve(b){W(b)}function s(b){return T(`theme.description.${b.id}`,{},b.description)}return(b,F)=>(l(),c("div",Ot,[e("div",null,[e("div",Wt,[e("div",Jt,a(i(T)("theme.heading")),1),e("div",Kt,a(i(T)("theme.currentTheme",{name:i(O).shortName})),1)]),e("div",Gt,a(i(T)("theme.helper")),1)]),e("div",Qt,[(l(!0),c(se,null,ne(ge.value,x=>(l(),c("section",{key:x.id,class:"space-y-1.5"},[e("div",Xt,a(x.label),1),(l(!0),c(se,null,ne(x.items,y=>(l(),c("button",{key:y.id,type:"button",class:Qe(["theme-option theme-toggle-card w-full rounded-sm border px-3 py-2 text-left transition",y.id===i(O).id?"theme-option-active":"theme-option-idle"]),onClick:k=>ve(y.id)},[e("div",Zt,[e("div",es,[(l(!0),c(se,null,ne(y.swatches,(k,C)=>(l(),c("span",{key:`${y.id}-${C}`,class:"h-3 w-3 rounded-full border border-black/10",style:Ct({backgroundColor:k})},null,4))),128))]),e("div",ts,[e("div",ss,[e("span",ns,a(y.shortName),1),y.id===i(O).id?(l(),U(i(Bt),{key:0,class:"h-4 w-4 shrink-0"})):v("",!0)]),e("div",as,a(s(y)),1)])])],10,Yt))),128))]))),128))])]))}},os={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ls={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},rs={key:0,class:"space-y-4"},cs={class:"theme-heading text-base font-medium"},us={class:"theme-muted-text mt-1 text-xs leading-5"},ds={class:"settings-section-card px-4 py-4"},ms={class:"settings-section-card space-y-4 px-4 py-4"},gs={class:"theme-heading text-sm font-medium"},vs={class:"theme-muted-text mt-1 text-xs leading-5"},hs={class:"block space-y-1.5"},ys={class:"theme-muted-text text-xs"},xs={class:"truncate text-sm text-[var(--theme-textPrimary)]"},_s=["onClick"],ps={class:"flex items-center justify-between gap-3"},fs={class:"min-w-0"},bs={class:"truncate text-[var(--theme-textPrimary)]"},Ds={class:"theme-muted-text mt-1 truncate text-xs"},ks={key:0,class:"theme-status-success rounded-sm border border-dashed px-2 py-0.5 text-[10px]"},Cs={class:"theme-muted-text theme-note-text"},ws={key:1,class:"space-y-4"},Rs={class:"flex items-start justify-between gap-3"},Ts={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Ss={class:"settings-section-card space-y-4 px-4 py-4"},Ps={class:"settings-form-card flex items-center justify-between gap-3 px-3 py-2"},Es={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},Ms={class:"theme-muted-text mt-1 text-xs"},Us=["disabled"],$s={class:"grid gap-4 sm:grid-cols-2"},Bs={class:"space-y-1.5 sm:col-span-2"},Ns={class:"theme-muted-text text-xs"},Ls=["disabled"],Fs={class:"space-y-1.5"},js={class:"theme-muted-text text-xs"},Is=["disabled"],qs={class:"space-y-1.5"},Vs={class:"theme-muted-text text-xs"},As={class:"relative"},zs=["type","placeholder","disabled"],Hs=["disabled"],Os={class:"settings-form-footer flex flex-wrap items-center justify-between gap-3"},Ws={class:"min-w-0 space-y-1"},Js={key:0,class:"theme-danger-text theme-note-text"},Ks={key:1,class:"theme-status-warning theme-note-text"},Gs={key:2,class:"theme-danger-text theme-note-text"},Qs={key:3,class:"theme-status-success theme-note-text"},Xs={key:4,class:"theme-danger-text theme-note-text"},Ys={key:5,class:"theme-muted-text theme-note-text"},Zs={key:6,class:"theme-muted-text theme-note-text"},en={key:7,class:"theme-muted-text theme-note-text"},tn={key:8,class:"theme-status-success theme-note-text"},sn={key:9,class:"theme-muted-text theme-note-text"},nn={class:"flex flex-wrap items-center gap-2"},an=["disabled"],on=["disabled"],ln=["disabled"],rn={key:2,class:"space-y-4"},cn={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},un={class:"theme-muted-text mt-1 text-xs leading-5"},dn={class:"settings-section-card space-y-4 px-4 py-4"},mn={class:"space-y-1.5"},gn={class:"theme-muted-text text-xs"},vn=["disabled"],hn={class:"theme-muted-text text-xs leading-5"},yn={class:"settings-form-footer flex flex-wrap items-center justify-between gap-3"},xn={class:"min-w-0 space-y-1"},_n={key:0,class:"theme-status-warning theme-note-text"},pn={key:1,class:"theme-danger-text theme-note-text"},fn={key:2,class:"theme-status-success theme-note-text"},bn={key:3,class:"theme-muted-text theme-note-text"},Dn={class:"flex flex-wrap items-center gap-2"},kn=["disabled"],Cn={class:"settings-section-card space-y-4 px-4 py-4"},wn={class:"flex flex-wrap items-start justify-between gap-3"},Rn={class:"theme-heading text-sm font-medium"},Tn={class:"theme-muted-text mt-1 text-xs leading-5"},Sn={class:"flex flex-wrap items-center gap-2"},Pn=["disabled"],En={class:"min-w-0 space-y-1"},Mn={key:0,class:"theme-danger-text theme-note-text"},Un={key:1,class:"theme-status-success theme-note-text"},$n={key:2,class:"theme-muted-text theme-note-text"},Bn={key:0,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4"},Nn={class:"settings-form-card space-y-1 px-3 py-3"},Ln={class:"theme-heading text-lg font-medium"},Fn={class:"theme-muted-text text-xs"},jn={class:"settings-form-card space-y-1 px-3 py-3"},In={class:"theme-heading text-lg font-medium"},qn={class:"theme-muted-text text-xs"},Vn={class:"settings-form-card space-y-1 px-3 py-3"},An={class:"theme-heading text-lg font-medium"},zn={class:"theme-muted-text text-xs"},Hn={class:"settings-form-card space-y-1 px-3 py-3"},On={class:"theme-heading text-lg font-medium"},Wn={class:"theme-muted-text text-xs"},Jn={key:1,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4"},Kn={class:"settings-form-card space-y-1 px-3 py-3"},Gn={class:"theme-heading text-lg font-medium"},Qn={class:"theme-muted-text text-xs"},Xn={class:"settings-form-card space-y-1 px-3 py-3"},Yn={class:"theme-heading text-lg font-medium"},Zn={class:"theme-muted-text text-xs"},ea={class:"settings-form-card space-y-1 px-3 py-3"},ta={class:"theme-heading text-lg font-medium"},sa={class:"theme-muted-text text-xs"},na={class:"settings-form-card space-y-1 px-3 py-3"},aa={class:"theme-heading text-lg font-medium"},ia={class:"theme-muted-text text-xs"},oa={key:2,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3"},la={class:"settings-form-card space-y-1 px-3 py-3"},ra={class:"theme-heading text-lg font-medium"},ca={class:"theme-muted-text text-xs"},ua={class:"settings-form-card space-y-1 px-3 py-3"},da={class:"theme-heading text-lg font-medium"},ma={class:"theme-muted-text text-xs"},ga={class:"settings-form-card space-y-1 px-3 py-3"},va={class:"theme-heading text-sm font-medium"},ha={class:"theme-muted-text text-xs"},ya={class:"grid gap-4 lg:grid-cols-2"},xa={class:"settings-form-card space-y-3 px-3 py-3"},_a={class:"theme-heading text-sm font-medium"},pa={class:"space-y-2 text-xs"},fa={class:"flex items-center justify-between gap-3"},ba={class:"truncate text-right text-[var(--theme-textPrimary)]"},Da={class:"flex items-center justify-between gap-3"},ka={class:"text-right text-[var(--theme-textPrimary)]"},Ca={class:"flex items-center justify-between gap-3"},wa={class:"text-right text-[var(--theme-textPrimary)]"},Ra={class:"flex items-center justify-between gap-3"},Ta={class:"text-right text-[var(--theme-textPrimary)]"},Sa={class:"flex items-center justify-between gap-3"},Pa={class:"text-right text-[var(--theme-textPrimary)]"},Ea={class:"settings-form-card space-y-3 px-3 py-3"},Ma={class:"theme-heading text-sm font-medium"},Ua={class:"space-y-2 text-xs"},$a={class:"theme-muted-text"},Ba={class:"text-[var(--theme-textPrimary)]"},Na={key:3,class:"settings-form-card space-y-3 px-3 py-3"},La={class:"theme-heading text-sm font-medium"},Fa={class:"grid gap-2 sm:grid-cols-2 xl:grid-cols-3 text-xs"},ja={class:"theme-muted-text"},Ia={class:"text-[var(--theme-textPrimary)]"},qa={key:4,class:"settings-form-card space-y-2 px-3 py-3"},Va={class:"theme-heading text-sm font-medium"},Aa={class:"theme-muted-text text-xs leading-5"},za={class:"theme-muted-text text-xs leading-5"},Ha={key:3,class:"space-y-4"},Oa={class:"theme-heading text-base font-medium"},Wa={class:"theme-muted-text mt-1 text-xs leading-5"},Ja={class:"settings-section-card px-4 py-4"},Ka={class:"flex items-center justify-between gap-3"},Ga={class:"theme-heading text-sm font-medium"},Qa={class:"theme-muted-text mt-1 text-xs leading-5"},Xa={class:"theme-badge-strong rounded-sm border border-dashed px-2.5 py-1 text-xs font-medium"},oi={__name:"WorkbenchSettingsDialog",props:{open:{type:Boolean,default:!1}},emits:["close"],setup($,{emit:O}){const W=$,ae=O,{locale:T,localeOptions:ge,setLocale:ve,t:s}=Xe(),b=m(""),F=m(!1),x=m(""),y=m(!1),k=m(!1),C=m(!1),p=m(""),w=m(""),ie=m(!1),j=m(!1),I=m(""),J=m(""),q=m(!1),K=m(""),R=m(null),u=m(null),f=m(!1),V=_e({runnerMaxConcurrentRuns:!1}),G=m(!1),oe=m(!1),le=m(!1),re=m(!1),r=_e({enabled:!1,relayUrl:"",deviceId:"",deviceToken:""}),A=_e({runnerMaxConcurrentRuns:3}),S=m("theme");let B=null,N=null,ce=null;const Ye=h(()=>[{id:"theme",label:s("theme.title"),description:s("theme.sectionDescription"),icon:jt},{id:"relay",label:s("settingsDialog.relay.sectionLabel"),description:s("settingsDialog.relay.sectionDescription"),icon:Je},{id:"system",label:s("settingsDialog.system.sectionLabel"),description:s("settingsDialog.system.sectionDescription"),icon:Ke},{id:"about",label:s("settingsDialog.about.sectionLabel"),description:s("settingsDialog.about.sectionDescription"),icon:It}]);function Ze(t=null,n=""){const o=String((t==null?void 0:t.messageKey)||"").trim();if(o){const g=s(o);if(g&&g!==o)return g}return String((t==null?void 0:t.message)||"").trim()||(n?s(n):"")}function ue(t="",n=""){const o=String(t||"").trim();if(o){const g=`settingsDialog.relay.reason.${o}`,D=s(g);if(D!==g)return D}return String(n||"").trim()||s("common.notAvailable")}function et(t=null){const n=String((t==null?void 0:t.type)||"").trim()||"unknown",o=`settingsDialog.relay.event.${n}`,g=s(o);return g!==o?g:n}function tt(t=null){const n=String((t==null?void 0:t.lastErrorKey)||"").trim(),o=t!=null&&t.lastErrorParams&&typeof t.lastErrorParams=="object"?t.lastErrorParams:{};return n==="connect_failed"?s("settingsDialog.relay.error.connect_failed"):n==="disconnected"?s("settingsDialog.relay.error.disconnected",{reason:ue(o.reasonCode,t==null?void 0:t.lastCloseReason)}):n==="rejected"?s("settingsDialog.relay.error.rejected",{reason:ue(o.reasonCode,t==null?void 0:t.lastCloseReason)}):n==="closed_with_code"?s("settingsDialog.relay.error.closedWithCode",{code:o.code||(t==null?void 0:t.lastCloseCode)||0}):String((t==null?void 0:t.lastError)||"").trim()}const st=h(()=>{var t,n,o,g;return C.value?s("settingsDialog.relay.status.reconnecting"):k.value||G.value?s("settingsDialog.relay.status.saving"):y.value?s("settingsDialog.relay.status.loading"):(t=u.value)!=null&&t.reconnectPaused?s("settingsDialog.relay.status.paused"):(n=u.value)!=null&&n.connected?s("settingsDialog.relay.status.connected"):(((o=u.value)==null?void 0:o.enabled)??r.enabled)&&Number(((g=u.value)==null?void 0:g.nextReconnectDelayMs)||0)>0?s("settingsDialog.relay.status.waitingReconnect"):r.enabled?s("settingsDialog.relay.status.disconnected"):s("settingsDialog.relay.status.disabled")}),nt=h(()=>{var t,n;return(t=u.value)!=null&&t.reconnectPaused?"theme-status-danger":(n=u.value)!=null&&n.connected?"theme-status-success":r.enabled?"theme-status-warning":"theme-status-neutral"}),at=h(()=>{var t,n,o;return!f.value&&!p.value&&!w.value&&!((t=u.value)!=null&&t.lastError)&&!((n=u.value)!=null&&n.lastCloseReason)&&!((o=u.value)!=null&&o.lastConnectedAt)}),it=h(()=>{const t=r.deviceToken?`${"*".repeat(Math.max(0,r.deviceToken.length-4))}${r.deviceToken.slice(-4)}`:"";return JSON.stringify({generatedAt:new Date().toISOString(),source:"local-settings",config:{enabled:r.enabled,relayUrl:r.relayUrl,deviceId:r.deviceId,deviceTokenMasked:t,managedByEnv:f.value},status:u.value||null},null,2)}),L=h(()=>{var t,n;return((n=(t=R.value)==null?void 0:t.runner)==null?void 0:n.runner)||null}),Q=h(()=>{var t,n;return!!((n=(t=R.value)==null?void 0:t.runner)!=null&&n.ok&&L.value)}),_=h(()=>{var t;return((t=L.value)==null?void 0:t.metrics)||null}),pe=h(()=>{var t;return((t=R.value)==null?void 0:t.recovery)||null}),fe=h(()=>{var t;return((t=R.value)==null?void 0:t.maintenance)||null}),ot=h(()=>{var t;return((t=R.value)==null?void 0:t.gitDiffWorker)||null}),lt=h(()=>JSON.stringify({generatedAt:new Date().toISOString(),source:"local-settings",config:{runner:{maxConcurrentRuns:A.runnerMaxConcurrentRuns,managedByEnv:V.runnerMaxConcurrentRuns}},diagnostics:R.value||null},null,2));function X(t){const n=String(t||"").trim();if(!n)return s("common.notAvailable");const o=new Date(n);return Number.isNaN(o.getTime())?n:$t(o.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}const rt=h(()=>{var t,n,o,g,D,P,E,M;return[{key:"queued_cancelled",label:s("settingsDialog.system.stopReasons.queued_cancelled"),value:Math.max(0,Number((n=(t=_.value)==null?void 0:t.stopReasons)==null?void 0:n.queued_cancelled)||0)},{key:"user_requested",label:s("settingsDialog.system.stopReasons.user_requested"),value:Math.max(0,Number((g=(o=_.value)==null?void 0:o.stopReasons)==null?void 0:g.user_requested)||0)},{key:"user_requested_after_error",label:s("settingsDialog.system.stopReasons.user_requested_after_error"),value:Math.max(0,Number((P=(D=_.value)==null?void 0:D.stopReasons)==null?void 0:P.user_requested_after_error)||0)},{key:"stop_timeout",label:s("settingsDialog.system.stopReasons.stop_timeout"),value:Math.max(0,Number((M=(E=_.value)==null?void 0:E.stopReasons)==null?void 0:M.stop_timeout)||0)}]}),ct=h(()=>{var t,n,o,g,D,P,E,M,Z,ee;return[{key:"runner_timeout_without_stop_request",label:s("settingsDialog.system.stopTimeoutPhases.runner_timeout_without_stop_request"),value:Math.max(0,Number((n=(t=_.value)==null?void 0:t.stopTimeoutPhases)==null?void 0:n.runner_timeout_without_stop_request)||0)},{key:"runner_timeout_before_cancel",label:s("settingsDialog.system.stopTimeoutPhases.runner_timeout_before_cancel"),value:Math.max(0,Number((g=(o=_.value)==null?void 0:o.stopTimeoutPhases)==null?void 0:g.runner_timeout_before_cancel)||0)},{key:"cli_not_exiting",label:s("settingsDialog.system.stopTimeoutPhases.cli_not_exiting"),value:Math.max(0,Number((P=(D=_.value)==null?void 0:D.stopTimeoutPhases)==null?void 0:P.cli_not_exiting)||0)},{key:"os_kill_slow",label:s("settingsDialog.system.stopTimeoutPhases.os_kill_slow"),value:Math.max(0,Number((M=(E=_.value)==null?void 0:E.stopTimeoutPhases)==null?void 0:M.os_kill_slow)||0)},{key:"runner_finalize_after_exit",label:s("settingsDialog.system.stopTimeoutPhases.runner_finalize_after_exit"),value:Math.max(0,Number((ee=(Z=_.value)==null?void 0:Z.stopTimeoutPhases)==null?void 0:ee.runner_finalize_after_exit)||0)}]}),ut=h(()=>ge.value.map(t=>({value:t.value,label:t.value==="zh-CN"?s("locale.zhHans"):s("locale.enUs"),englishLabel:t.englishLabel})));async function dt(){F.value=!0,x.value="";try{const t=await Mt(),n=String((t==null?void 0:t.version)||"").trim();b.value=n,n||(x.value=s("settingsDialog.about.versionPending"))}catch(t){b.value="",x.value=(t==null?void 0:t.message)||s("settingsDialog.about.versionLoadFailed")}finally{F.value=!1}}function he(t={}){r.enabled=!!(t!=null&&t.enabled),r.relayUrl=String((t==null?void 0:t.relayUrl)||""),r.deviceId=String((t==null?void 0:t.deviceId)||""),r.deviceToken=String((t==null?void 0:t.deviceToken)||"")}function be(t={}){var n;A.runnerMaxConcurrentRuns=Math.max(1,Number((n=t==null?void 0:t.runner)==null?void 0:n.maxConcurrentRuns)||3)}async function De(){y.value=!0,p.value="",w.value="";try{const t=await qt();he((t==null?void 0:t.config)||{}),f.value=!!(t!=null&&t.managedByEnv),u.value=(t==null?void 0:t.relay)||null}catch(t){p.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayConfigLoadFailed"),u.value=null}finally{y.value=!1}}async function mt(){var t,n;ie.value=!0,I.value="",J.value="";try{const o=await At();be((o==null?void 0:o.config)||{}),V.runnerMaxConcurrentRuns=!!((n=(t=o==null?void 0:o.managedByEnv)==null?void 0:t.runner)!=null&&n.maxConcurrentRuns),Y()}catch(o){I.value=(o==null?void 0:o.message)||s("settingsDialog.system.systemConfigLoadFailed")}finally{ie.value=!1}}async function Y(){q.value=!0,K.value="";try{R.value=await Ht()}catch(t){K.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemDiagnosticsLoadFailed")}finally{q.value=!1}}async function gt(){k.value=!0,p.value="",w.value="";try{const t=await Ge({enabled:r.enabled,relayUrl:r.relayUrl,deviceId:r.deviceId,deviceToken:r.deviceToken});he((t==null?void 0:t.config)||{}),f.value=!!(t!=null&&t.managedByEnv),u.value=(t==null?void 0:t.relay)||null,w.value=r.enabled?s("settingsDialog.relay.relayConfigSavedEnabled"):s("settingsDialog.relay.relayConfigSavedDisabled")}catch(t){p.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayConfigSaveFailed")}finally{k.value=!1}}async function vt(){C.value=!0,p.value="",w.value="";try{const t=await Vt();u.value=(t==null?void 0:t.relay)||null,w.value=s("settingsDialog.relay.relayReconnectTriggered"),setTimeout(()=>{De()},1200)}catch(t){p.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayReconnectFailed")}finally{C.value=!1}}async function ht(){var t,n;j.value=!0,I.value="",J.value="";try{const o=await zt({runner:{maxConcurrentRuns:A.runnerMaxConcurrentRuns}});be((o==null?void 0:o.config)||{}),V.runnerMaxConcurrentRuns=!!((n=(t=o==null?void 0:o.managedByEnv)==null?void 0:t.runner)!=null&&n.maxConcurrentRuns),J.value=s("settingsDialog.system.systemConfigSaved"),Y()}catch(o){I.value=(o==null?void 0:o.message)||s("settingsDialog.system.systemConfigSaveFailed")}finally{j.value=!1}}function yt(){return!!(String(r.relayUrl||"").trim()&&String(r.deviceId||"").trim()&&String(r.deviceToken||"").trim())}async function xt(){var t;if(!f.value){if(p.value="",w.value="",r.enabled&&!yt()){r.enabled=!1,p.value=s("settingsDialog.relay.relayFieldsRequired");return}G.value=!0;try{const n=await Ge({enabled:r.enabled,relayUrl:r.relayUrl,deviceId:r.deviceId,deviceToken:r.deviceToken});he((n==null?void 0:n.config)||{}),f.value=!!(n!=null&&n.managedByEnv),u.value=(n==null?void 0:n.relay)||null,w.value=r.enabled?s("settingsDialog.relay.relayEnabledSaved"):s("settingsDialog.relay.relayConfigSavedDisabled")}catch(n){r.enabled=!!((t=u.value)!=null&&t.enabled),p.value=(n==null?void 0:n.message)||s("settingsDialog.relay.relayToggleFailed")}finally{G.value=!1}}}async function ke(t){var o;if((o=navigator.clipboard)!=null&&o.writeText&&window.isSecureContext){await navigator.clipboard.writeText(t);return}const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n)}async function _t(){try{await ke(it.value),le.value=!0,B&&clearTimeout(B),B=setTimeout(()=>{le.value=!1,B=null},2e3)}catch(t){p.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayDiagnosticsCopyFailed")}}async function pt(){try{await ke(lt.value),re.value=!0,N&&clearTimeout(N),N=setTimeout(()=>{re.value=!1,N=null},2e3)}catch(t){K.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemDiagnosticsCopyFailed")}}function ft(t){ve(t)}function ye(){ce&&(clearInterval(ce),ce=null)}function bt(){ye(),!(!W.open||S.value!=="system")&&(Y(),ce=setInterval(()=>{Y()},5e3))}return We(()=>W.open,t=>{if(t){S.value="theme",dt(),De(),mt();return}},{immediate:!0}),We([()=>W.open,S],([t,n])=>{if(t&&n==="system"){bt();return}ye()},{immediate:!0}),wt(()=>{B&&(clearTimeout(B),B=null),N&&(clearTimeout(N),N=null),ye()}),(t,n)=>(l(),U(Et,{open:$.open,"backdrop-class":"z-[70] items-end justify-center px-0 py-0 sm:items-center sm:px-4 sm:py-6","panel-class":"settings-dialog-panel h-full max-w-5xl sm:h-[42rem] sm:max-h-[88vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col sm:flex-row",onClose:n[7]||(n[7]=o=>ae("close"))},{title:de(()=>[e("div",os,[z(i(Ft),{class:"h-4 w-4"}),e("span",null,a(i(s)("common.settings")),1)])]),default:de(()=>{var o,g,D,P,E,M,Z,ee,Ce,we,Re,Te,Se,Pe,Ee,Me,Ue,$e,Be,Ne,Le,Fe,je,Ie,qe,Ve,Ae,ze,He,Oe;return[z(St,{modelValue:S.value,"onUpdate:modelValue":n[0]||(n[0]=d=>S.value=d),sections:Ye.value},null,8,["modelValue","sections"]),e("div",ls,[S.value==="theme"?(l(),c("section",rs,[e("div",null,[e("div",cs,a(i(s)("theme.title")),1),e("p",us,a(i(s)("theme.sectionDescription")),1)]),e("section",ds,[z(is)]),e("section",ms,[e("div",null,[e("div",gs,a(i(s)("locale.title")),1),e("p",vs,a(i(s)("locale.description")),1)]),e("label",hs,[e("span",ys,a(i(s)("locale.field")),1),z(Pt,{"model-value":i(T),options:ut.value,"get-option-value":d=>d.value,"onUpdate:modelValue":ft},{trigger:de(({selectedOption:d})=>[e("div",xs,a((d==null?void 0:d.label)||i(s)("common.select")),1)]),option:de(({option:d,selected:Dt,select:kt})=>[e("button",{type:"button",class:"workbench-select-option theme-filter-idle w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm",onClick:Ya=>kt()},[e("div",ps,[e("div",fs,[e("div",bs,a(d.label),1),e("div",Ds,a(d.englishLabel),1)]),Dt?(l(),c("span",ks,a(i(s)("common.enabled")),1)):v("",!0)])],8,_s)]),_:1},8,["model-value","options","get-option-value"])]),e("p",Cs,a(i(s)("locale.immediateHint")),1)])])):S.value==="relay"?(l(),c("section",ws,[e("div",Rs,[e("div",null,[e("div",Ts,[z(i(Je),{class:"h-4 w-4"}),e("span",null,a(i(s)("settingsDialog.relay.title")),1)])]),e("span",{class:Qe(["rounded-sm border border-dashed px-2.5 py-1 text-xs font-medium",nt.value])},a(st.value),3)]),e("section",Ss,[e("label",Ps,[e("div",null,[e("div",Es,a(i(s)("settingsDialog.relay.enableTitle")),1),e("p",Ms,a(i(s)("settingsDialog.relay.enableDescription")),1)]),te(e("input",{"onUpdate:modelValue":n[1]||(n[1]=d=>r.enabled=d),type:"checkbox",class:"h-4 w-4",disabled:f.value,onChange:xt},null,40,Us),[[Rt,r.enabled]])]),e("div",$s,[e("label",Bs,[e("span",Ns,a(i(s)("settingsDialog.relay.relayUrl")),1),te(e("input",{"onUpdate:modelValue":n[2]||(n[2]=d=>r.relayUrl=d),type:"text",placeholder:"https://user1.promptx.example.com",class:"tool-input",disabled:f.value},null,8,Ls),[[xe,r.relayUrl]])]),e("label",Fs,[e("span",js,a(i(s)("settingsDialog.relay.deviceId")),1),te(e("input",{"onUpdate:modelValue":n[3]||(n[3]=d=>r.deviceId=d),type:"text",placeholder:"my-macbook",class:"tool-input",disabled:f.value},null,8,Is),[[xe,r.deviceId]])]),e("label",qs,[e("span",Vs,a(i(s)("settingsDialog.relay.deviceToken")),1),e("div",As,[te(e("input",{"onUpdate:modelValue":n[4]||(n[4]=d=>r.deviceToken=d),type:oe.value?"text":"password",placeholder:i(s)("settingsDialog.relay.deviceTokenPlaceholder"),class:"tool-input pr-10",disabled:f.value},null,8,zs),[[Tt,r.deviceToken]]),e("button",{type:"button",class:"theme-icon-button absolute inset-y-1 right-1 flex h-auto w-8 items-center justify-center",disabled:f.value,onClick:n[5]||(n[5]=d=>oe.value=!oe.value)},[oe.value?(l(),U(i(Lt),{key:1,class:"h-4 w-4"})):(l(),U(i(Nt),{key:0,class:"h-4 w-4"}))],8,Hs)])])]),e("div",Os,[e("div",Ws,[(o=u.value)!=null&&o.reconnectPausedReason?(l(),c("p",Js,a(i(s)("settingsDialog.relay.pausedReconnect",{reason:ue(u.value.reconnectPausedReasonCode,u.value.reconnectPausedReason)})),1)):v("",!0),f.value?(l(),c("p",Ks,a(i(s)("settingsDialog.relay.managedByEnv")),1)):v("",!0),p.value?(l(),c("p",Gs,a(p.value),1)):w.value?(l(),c("p",Qs,a(w.value),1)):(g=u.value)!=null&&g.lastError?(l(),c("p",Xs,a(i(s)("settingsDialog.relay.lastError",{value:tt(u.value)})),1)):(D=u.value)!=null&&D.lastCloseReason?(l(),c("p",Ys,a(i(s)("settingsDialog.relay.lastClosed",{reason:ue(u.value.lastCloseReasonCode,u.value.lastCloseReason),code:u.value.lastCloseCode})),1)):(P=u.value)!=null&&P.lastConnectedAt?(l(),c("p",Zs,a(i(s)("settingsDialog.relay.lastConnected",{value:X(u.value.lastConnectedAt)})),1)):v("",!0),(M=(E=u.value)==null?void 0:E.recentEvents)!=null&&M.length?(l(),c("p",en,a(i(s)("settingsDialog.relay.recentEvent",{value:et(u.value.recentEvents[0])})),1)):v("",!0),le.value?(l(),c("p",tn,a(i(s)("settingsDialog.relay.copied")),1)):v("",!0),at.value?(l(),c("p",sn,a(i(s)("settingsDialog.relay.defaultHint")),1)):v("",!0)]),e("div",nn,[e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:y.value||k.value||G.value||C.value||!(((Z=u.value)==null?void 0:Z.enabled)??r.enabled),onClick:vt},[C.value?(l(),U(i(me),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(C.value?i(s)("settingsDialog.relay.reconnecting"):i(s)("settingsDialog.relay.reconnectNow")),1)],8,an),e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:y.value||C.value,onClick:_t},[e("span",null,a(le.value?i(s)("settingsDialog.relay.diagnosticsCopied"):i(s)("settingsDialog.relay.copyDiagnostics")),1)],8,on),e("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:y.value||k.value||G.value||C.value||f.value,onClick:gt},[k.value?(l(),U(i(me),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(k.value?i(s)("common.saving"):i(s)("settingsDialog.relay.saveConfig")),1)],8,ln)])])])])):S.value==="system"?(l(),c("section",rn,[e("div",null,[e("div",cn,[z(i(Ke),{class:"h-4 w-4"}),e("span",null,a(i(s)("settingsDialog.system.title")),1)]),e("p",un,a(i(s)("settingsDialog.system.intro")),1)]),e("section",dn,[e("label",mn,[e("span",gn,a(i(s)("settingsDialog.system.maxConcurrentRuns")),1),te(e("input",{"onUpdate:modelValue":n[6]||(n[6]=d=>A.runnerMaxConcurrentRuns=d),type:"number",min:"1",max:"16",step:"1",class:"tool-input",disabled:V.runnerMaxConcurrentRuns||ie.value||j.value},null,8,vn),[[xe,A.runnerMaxConcurrentRuns,void 0,{number:!0}]]),e("p",hn,a(i(s)("settingsDialog.system.maxConcurrentRunsHint")),1)]),e("div",yn,[e("div",xn,[V.runnerMaxConcurrentRuns?(l(),c("p",_n,a(i(s)("settingsDialog.system.managedByEnv")),1)):I.value?(l(),c("p",pn,a(I.value),1)):J.value?(l(),c("p",fn,a(J.value),1)):(l(),c("p",bn,a(i(s)("settingsDialog.system.diagnosticsHint")),1))]),e("div",Dn,[e("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:V.runnerMaxConcurrentRuns||ie.value||j.value,onClick:ht},[j.value?(l(),U(i(me),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(j.value?i(s)("common.saving"):i(s)("settingsDialog.system.saveConfig")),1)],8,kn)])])]),e("section",Cn,[e("div",wn,[e("div",null,[e("div",Rn,a(i(s)("settingsDialog.system.runtimeDiagnostics")),1),e("p",Tn,a(i(s)("settingsDialog.system.runtimeDiagnosticsHint")),1)]),e("div",Sn,[e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:q.value,onClick:Y},[q.value?(l(),U(i(me),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(q.value?i(s)("settingsDialog.system.refreshingDiagnostics"):i(s)("settingsDialog.system.refreshDiagnostics")),1)],8,Pn),e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",onClick:pt},[e("span",null,a(re.value?i(s)("settingsDialog.system.diagnosticsCopied"):i(s)("settingsDialog.system.copyDiagnostics")),1)])])]),e("div",En,[K.value?(l(),c("p",Mn,a(K.value),1)):re.value?(l(),c("p",Un,a(i(s)("settingsDialog.system.diagnosticsCopiedHint")),1)):(l(),c("p",$n,a(i(s)("settingsDialog.system.diagnosticsHint")),1))]),Q.value?(l(),c("div",Bn,[e("div",Nn,[n[8]||(n[8]=e("div",{class:"theme-muted-text text-xs"},"active",-1)),e("div",Ln,a(((ee=L.value)==null?void 0:ee.activeRunCount)||0),1),e("p",Fn,a(i(s)("settingsDialog.system.active")),1)]),e("div",jn,[n[9]||(n[9]=e("div",{class:"theme-muted-text text-xs"},"tracked",-1)),e("div",In,a(((Ce=L.value)==null?void 0:Ce.trackedRunCount)||0),1),e("p",qn,a(i(s)("settingsDialog.system.tracked")),1)]),e("div",Vn,[n[10]||(n[10]=e("div",{class:"theme-muted-text text-xs"},"queued",-1)),e("div",An,a(((we=L.value)==null?void 0:we.queuedRunCount)||0),1),e("p",zn,a(i(s)("settingsDialog.system.queued")),1)]),e("div",Hn,[n[11]||(n[11]=e("div",{class:"theme-muted-text text-xs"},"maxConcurrent",-1)),e("div",On,a(((Te=(Re=L.value)==null?void 0:Re.config)==null?void 0:Te.maxConcurrentRuns)||A.runnerMaxConcurrentRuns),1),e("p",Wn,a(i(s)("settingsDialog.system.maxConcurrent")),1)])])):v("",!0),Q.value?(l(),c("div",Jn,[e("div",Kn,[n[12]||(n[12]=e("div",{class:"theme-muted-text text-xs"},"completed",-1)),e("div",Gn,a(((Se=_.value)==null?void 0:Se.totalCompleted)||0),1),e("p",Qn,a(i(s)("settingsDialog.system.completed")),1)]),e("div",Xn,[n[13]||(n[13]=e("div",{class:"theme-muted-text text-xs"},"stopped",-1)),e("div",Yn,a(((Pe=_.value)==null?void 0:Pe.totalStopped)||0),1),e("p",Zn,a(i(s)("settingsDialog.system.stopped")),1)]),e("div",ea,[n[14]||(n[14]=e("div",{class:"theme-muted-text text-xs"},"error",-1)),e("div",ta,a(((Ee=_.value)==null?void 0:Ee.totalErrored)||0),1),e("p",sa,a(i(s)("settingsDialog.system.error")),1)]),e("div",na,[n[15]||(n[15]=e("div",{class:"theme-muted-text text-xs"},"stop_timeout",-1)),e("div",aa,a(((Me=_.value)==null?void 0:Me.totalStopTimeout)||0),1),e("p",ia,a(i(s)("settingsDialog.system.stopTimeout")),1)])])):v("",!0),Q.value?(l(),c("div",oa,[e("div",la,[n[16]||(n[16]=e("div",{class:"theme-muted-text text-xs"},"event flush failures",-1)),e("div",ra,a(((Ue=_.value)==null?void 0:Ue.eventFlushFailureCount)||0),1),e("p",ca,a(i(s)("settingsDialog.system.eventWriteFailures")),1)]),e("div",ua,[n[17]||(n[17]=e("div",{class:"theme-muted-text text-xs"},"recovered runs",-1)),e("div",da,a(((Be=($e=pe.value)==null?void 0:$e.metrics)==null?void 0:Be.totalRecovered)||0),1),e("p",ma,a(i(s)("settingsDialog.system.recoveredRuns")),1)]),e("div",ga,[n[18]||(n[18]=e("div",{class:"theme-muted-text text-xs"},"last cleanup",-1)),e("div",va,a(X((Le=(Ne=fe.value)==null?void 0:Ne.lastCleanup)==null?void 0:Le.finishedAt)),1),e("p",ha,a(i(s)("settingsDialog.system.lastMaintenanceAt")),1)])])):v("",!0),e("div",ya,[e("div",xa,[e("div",_a,a(i(s)("settingsDialog.system.baseStatus")),1),e("div",pa,[e("div",fa,[n[19]||(n[19]=e("span",{class:"theme-muted-text"},"runner baseUrl",-1)),e("span",ba,a(((je=(Fe=R.value)==null?void 0:Fe.runner)==null?void 0:je.baseUrl)||"-"),1)]),e("div",Da,[n[20]||(n[20]=e("span",{class:"theme-muted-text"},"runner startedAt",-1)),e("span",ka,a(X((Ie=L.value)==null?void 0:Ie.startedAt)),1)]),e("div",Ca,[n[21]||(n[21]=e("span",{class:"theme-muted-text"},"last sweep",-1)),e("span",wa,a(X((Ve=(qe=pe.value)==null?void 0:qe.metrics)==null?void 0:Ve.lastSweepFinishedAt)),1)]),e("div",Ra,[n[22]||(n[22]=e("span",{class:"theme-muted-text"},"git diff worker",-1)),e("span",Ta,a(ot.value?i(s)("settingsDialog.system.available"):i(s)("settingsDialog.system.unknown")),1)]),e("div",Sa,[n[23]||(n[23]=e("span",{class:"theme-muted-text"},"db vacuum",-1)),e("span",Pa,a(X((Ae=fe.value)==null?void 0:Ae.lastVacuumAt)),1)])])]),e("div",Ea,[e("div",Ma,a(i(s)("settingsDialog.system.stopReasonTitle")),1),e("div",Ua,[(l(!0),c(se,null,ne(rt.value,d=>(l(),c("div",{key:d.key,class:"flex items-center justify-between gap-3"},[e("span",$a,a(d.label),1),e("span",Ba,a(d.value),1)]))),128))])])]),Q.value?(l(),c("div",Na,[e("div",La,a(i(s)("settingsDialog.system.stopTimeoutPhaseTitle")),1),e("div",Fa,[(l(!0),c(se,null,ne(ct.value,d=>(l(),c("div",{key:d.key,class:"flex items-center justify-between gap-3 rounded-sm border border-dashed border-[var(--theme-borderMuted)] px-2.5 py-2"},[e("span",ja,a(d.label),1),e("span",Ia,a(d.value),1)]))),128))])])):v("",!0),!Q.value&&!q.value?(l(),c("div",qa,[e("div",Va,a(i(s)("settingsDialog.system.runnerUnavailable")),1),e("p",Aa,a(Ze((ze=R.value)==null?void 0:ze.runner,"settingsDialog.system.runnerUnavailableDescription")),1),e("p",za," baseUrl: "+a(((Oe=(He=R.value)==null?void 0:He.runner)==null?void 0:Oe.baseUrl)||"-"),1)])):v("",!0)])])):(l(),c("section",Ha,[e("div",null,[e("div",Oa,a(i(s)("settingsDialog.about.title")),1),e("p",Wa,a(i(s)("settingsDialog.about.intro")),1)]),e("section",Ja,[e("div",Ka,[e("div",null,[e("div",Ga,a(i(s)("settingsDialog.about.versionTitle")),1),e("p",Qa,a(x.value||i(s)("settingsDialog.about.versionDescription")),1)]),e("span",Xa,a(F.value?i(s)("common.loading"):b.value?`v${b.value}`:i(s)("common.unavailable")),1)])])]))])]}),_:1},8,["open"]))}};export{oi as default};
1
+ import{aB as l,aC as c,aD as e,aO as a,u as i,aP as se,aQ as ne,aJ as Qe,aT as Ct,aG as U,aL as v,c as h,w as We,ak as wt,aH as de,aE as z,aU as te,aW as Rt,aV as xe,b0 as Tt,b as m,r as _e}from"./vendor-misc-CWjGI0ex.js";import{r as H,c as St,_ as Pt,b as Et,d as Mt}from"./WorkbenchView-BXIMEYIR.js";import{u as Xe,c as Ut,f as $t}from"./index-CD4ppQq_.js";import{b as Bt,y as Je,E as Nt,c as Lt,L as me,z as Ke,r as Ft,D as jt,v as It}from"./vendor-ui-D4mCpibF.js";import"./vendor-markdown-CNlC48LI.js";import"./vendor-tiptap-BCwG_IWj.js";import"./vendor-router-Bcjfmow0.js";function qt(){return H("/api/relay/config",{cache:"no-store"})}function Ge($){return H("/api/relay/config",{method:"PUT",body:JSON.stringify($)})}function Vt(){return H("/api/relay/reconnect",{method:"POST"})}function At(){return H("/api/system/config",{cache:"no-store"})}function zt($){return H("/api/system/config",{method:"PUT",body:JSON.stringify($)})}function Ht(){return H("/api/diagnostics/runtime",{cache:"no-store"})}const Ot={class:"space-y-4"},Wt={class:"flex items-center justify-between gap-3"},Jt={class:"theme-heading text-sm font-medium"},Kt={class:"theme-toggle-current theme-badge-muted theme-muted-text rounded-sm border border-dashed px-2 py-1 text-[11px]"},Gt={class:"theme-muted-text theme-note-text mt-1"},Qt={class:"space-y-4"},Xt={class:"theme-muted-text px-1 text-[10px] font-medium uppercase tracking-[0.16em]"},Yt=["onClick"],Zt={class:"flex items-start gap-3"},es={class:"mt-0.5 flex items-center gap-1.5"},ts={class:"min-w-0 flex-1"},ss={class:"flex items-center justify-between gap-2"},ns={class:"truncate text-sm font-medium"},as={class:"theme-muted-text theme-note-text mt-1"},is={__name:"ThemeToggle",setup($){const{currentTheme:O,setTheme:W,themes:ae}=Ut(),{t:T}=Xe(),ge=h(()=>{const b=ae.value.filter(x=>x.mode==="light"),F=ae.value.filter(x=>x.mode==="dark");return[{id:"light",label:T("theme.groupLight"),items:b},{id:"dark",label:T("theme.groupDark"),items:F}].filter(x=>x.items.length)});function ve(b){W(b)}function s(b){return T(`theme.description.${b.id}`,{},b.description)}return(b,F)=>(l(),c("div",Ot,[e("div",null,[e("div",Wt,[e("div",Jt,a(i(T)("theme.heading")),1),e("div",Kt,a(i(T)("theme.currentTheme",{name:i(O).shortName})),1)]),e("div",Gt,a(i(T)("theme.helper")),1)]),e("div",Qt,[(l(!0),c(se,null,ne(ge.value,x=>(l(),c("section",{key:x.id,class:"space-y-1.5"},[e("div",Xt,a(x.label),1),(l(!0),c(se,null,ne(x.items,y=>(l(),c("button",{key:y.id,type:"button",class:Qe(["theme-option theme-toggle-card w-full rounded-sm border px-3 py-2 text-left transition",y.id===i(O).id?"theme-option-active":"theme-option-idle"]),onClick:k=>ve(y.id)},[e("div",Zt,[e("div",es,[(l(!0),c(se,null,ne(y.swatches,(k,C)=>(l(),c("span",{key:`${y.id}-${C}`,class:"h-3 w-3 rounded-full border border-black/10",style:Ct({backgroundColor:k})},null,4))),128))]),e("div",ts,[e("div",ss,[e("span",ns,a(y.shortName),1),y.id===i(O).id?(l(),U(i(Bt),{key:0,class:"h-4 w-4 shrink-0"})):v("",!0)]),e("div",as,a(s(y)),1)])])],10,Yt))),128))]))),128))])]))}},os={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ls={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},rs={key:0,class:"space-y-4"},cs={class:"theme-heading text-base font-medium"},us={class:"theme-muted-text mt-1 text-xs leading-5"},ds={class:"settings-section-card px-4 py-4"},ms={class:"settings-section-card space-y-4 px-4 py-4"},gs={class:"theme-heading text-sm font-medium"},vs={class:"theme-muted-text mt-1 text-xs leading-5"},hs={class:"block space-y-1.5"},ys={class:"theme-muted-text text-xs"},xs={class:"truncate text-sm text-[var(--theme-textPrimary)]"},_s=["onClick"],ps={class:"flex items-center justify-between gap-3"},fs={class:"min-w-0"},bs={class:"truncate text-[var(--theme-textPrimary)]"},Ds={class:"theme-muted-text mt-1 truncate text-xs"},ks={key:0,class:"theme-status-success rounded-sm border border-dashed px-2 py-0.5 text-[10px]"},Cs={class:"theme-muted-text theme-note-text"},ws={key:1,class:"space-y-4"},Rs={class:"flex items-start justify-between gap-3"},Ts={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Ss={class:"settings-section-card space-y-4 px-4 py-4"},Ps={class:"settings-form-card flex items-center justify-between gap-3 px-3 py-2"},Es={class:"text-sm font-medium text-[var(--theme-textPrimary)]"},Ms={class:"theme-muted-text mt-1 text-xs"},Us=["disabled"],$s={class:"grid gap-4 sm:grid-cols-2"},Bs={class:"space-y-1.5 sm:col-span-2"},Ns={class:"theme-muted-text text-xs"},Ls=["disabled"],Fs={class:"space-y-1.5"},js={class:"theme-muted-text text-xs"},Is=["disabled"],qs={class:"space-y-1.5"},Vs={class:"theme-muted-text text-xs"},As={class:"relative"},zs=["type","placeholder","disabled"],Hs=["disabled"],Os={class:"settings-form-footer flex flex-wrap items-center justify-between gap-3"},Ws={class:"min-w-0 space-y-1"},Js={key:0,class:"theme-danger-text theme-note-text"},Ks={key:1,class:"theme-status-warning theme-note-text"},Gs={key:2,class:"theme-danger-text theme-note-text"},Qs={key:3,class:"theme-status-success theme-note-text"},Xs={key:4,class:"theme-danger-text theme-note-text"},Ys={key:5,class:"theme-muted-text theme-note-text"},Zs={key:6,class:"theme-muted-text theme-note-text"},en={key:7,class:"theme-muted-text theme-note-text"},tn={key:8,class:"theme-status-success theme-note-text"},sn={key:9,class:"theme-muted-text theme-note-text"},nn={class:"flex flex-wrap items-center gap-2"},an=["disabled"],on=["disabled"],ln=["disabled"],rn={key:2,class:"space-y-4"},cn={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},un={class:"theme-muted-text mt-1 text-xs leading-5"},dn={class:"settings-section-card space-y-4 px-4 py-4"},mn={class:"space-y-1.5"},gn={class:"theme-muted-text text-xs"},vn=["disabled"],hn={class:"theme-muted-text text-xs leading-5"},yn={class:"settings-form-footer flex flex-wrap items-center justify-between gap-3"},xn={class:"min-w-0 space-y-1"},_n={key:0,class:"theme-status-warning theme-note-text"},pn={key:1,class:"theme-danger-text theme-note-text"},fn={key:2,class:"theme-status-success theme-note-text"},bn={key:3,class:"theme-muted-text theme-note-text"},Dn={class:"flex flex-wrap items-center gap-2"},kn=["disabled"],Cn={class:"settings-section-card space-y-4 px-4 py-4"},wn={class:"flex flex-wrap items-start justify-between gap-3"},Rn={class:"theme-heading text-sm font-medium"},Tn={class:"theme-muted-text mt-1 text-xs leading-5"},Sn={class:"flex flex-wrap items-center gap-2"},Pn=["disabled"],En={class:"min-w-0 space-y-1"},Mn={key:0,class:"theme-danger-text theme-note-text"},Un={key:1,class:"theme-status-success theme-note-text"},$n={key:2,class:"theme-muted-text theme-note-text"},Bn={key:0,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4"},Nn={class:"settings-form-card space-y-1 px-3 py-3"},Ln={class:"theme-heading text-lg font-medium"},Fn={class:"theme-muted-text text-xs"},jn={class:"settings-form-card space-y-1 px-3 py-3"},In={class:"theme-heading text-lg font-medium"},qn={class:"theme-muted-text text-xs"},Vn={class:"settings-form-card space-y-1 px-3 py-3"},An={class:"theme-heading text-lg font-medium"},zn={class:"theme-muted-text text-xs"},Hn={class:"settings-form-card space-y-1 px-3 py-3"},On={class:"theme-heading text-lg font-medium"},Wn={class:"theme-muted-text text-xs"},Jn={key:1,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4"},Kn={class:"settings-form-card space-y-1 px-3 py-3"},Gn={class:"theme-heading text-lg font-medium"},Qn={class:"theme-muted-text text-xs"},Xn={class:"settings-form-card space-y-1 px-3 py-3"},Yn={class:"theme-heading text-lg font-medium"},Zn={class:"theme-muted-text text-xs"},ea={class:"settings-form-card space-y-1 px-3 py-3"},ta={class:"theme-heading text-lg font-medium"},sa={class:"theme-muted-text text-xs"},na={class:"settings-form-card space-y-1 px-3 py-3"},aa={class:"theme-heading text-lg font-medium"},ia={class:"theme-muted-text text-xs"},oa={key:2,class:"grid gap-3 sm:grid-cols-2 xl:grid-cols-3"},la={class:"settings-form-card space-y-1 px-3 py-3"},ra={class:"theme-heading text-lg font-medium"},ca={class:"theme-muted-text text-xs"},ua={class:"settings-form-card space-y-1 px-3 py-3"},da={class:"theme-heading text-lg font-medium"},ma={class:"theme-muted-text text-xs"},ga={class:"settings-form-card space-y-1 px-3 py-3"},va={class:"theme-heading text-sm font-medium"},ha={class:"theme-muted-text text-xs"},ya={class:"grid gap-4 lg:grid-cols-2"},xa={class:"settings-form-card space-y-3 px-3 py-3"},_a={class:"theme-heading text-sm font-medium"},pa={class:"space-y-2 text-xs"},fa={class:"flex items-center justify-between gap-3"},ba={class:"truncate text-right text-[var(--theme-textPrimary)]"},Da={class:"flex items-center justify-between gap-3"},ka={class:"text-right text-[var(--theme-textPrimary)]"},Ca={class:"flex items-center justify-between gap-3"},wa={class:"text-right text-[var(--theme-textPrimary)]"},Ra={class:"flex items-center justify-between gap-3"},Ta={class:"text-right text-[var(--theme-textPrimary)]"},Sa={class:"flex items-center justify-between gap-3"},Pa={class:"text-right text-[var(--theme-textPrimary)]"},Ea={class:"settings-form-card space-y-3 px-3 py-3"},Ma={class:"theme-heading text-sm font-medium"},Ua={class:"space-y-2 text-xs"},$a={class:"theme-muted-text"},Ba={class:"text-[var(--theme-textPrimary)]"},Na={key:3,class:"settings-form-card space-y-3 px-3 py-3"},La={class:"theme-heading text-sm font-medium"},Fa={class:"grid gap-2 sm:grid-cols-2 xl:grid-cols-3 text-xs"},ja={class:"theme-muted-text"},Ia={class:"text-[var(--theme-textPrimary)]"},qa={key:4,class:"settings-form-card space-y-2 px-3 py-3"},Va={class:"theme-heading text-sm font-medium"},Aa={class:"theme-muted-text text-xs leading-5"},za={class:"theme-muted-text text-xs leading-5"},Ha={key:3,class:"space-y-4"},Oa={class:"theme-heading text-base font-medium"},Wa={class:"theme-muted-text mt-1 text-xs leading-5"},Ja={class:"settings-section-card px-4 py-4"},Ka={class:"flex items-center justify-between gap-3"},Ga={class:"theme-heading text-sm font-medium"},Qa={class:"theme-muted-text mt-1 text-xs leading-5"},Xa={class:"theme-badge-strong rounded-sm border border-dashed px-2.5 py-1 text-xs font-medium"},oi={__name:"WorkbenchSettingsDialog",props:{open:{type:Boolean,default:!1}},emits:["close"],setup($,{emit:O}){const W=$,ae=O,{locale:T,localeOptions:ge,setLocale:ve,t:s}=Xe(),b=m(""),F=m(!1),x=m(""),y=m(!1),k=m(!1),C=m(!1),p=m(""),w=m(""),ie=m(!1),j=m(!1),I=m(""),J=m(""),q=m(!1),K=m(""),R=m(null),u=m(null),f=m(!1),V=_e({runnerMaxConcurrentRuns:!1}),G=m(!1),oe=m(!1),le=m(!1),re=m(!1),r=_e({enabled:!1,relayUrl:"",deviceId:"",deviceToken:""}),A=_e({runnerMaxConcurrentRuns:3}),S=m("theme");let B=null,N=null,ce=null;const Ye=h(()=>[{id:"theme",label:s("theme.title"),description:s("theme.sectionDescription"),icon:jt},{id:"relay",label:s("settingsDialog.relay.sectionLabel"),description:s("settingsDialog.relay.sectionDescription"),icon:Je},{id:"system",label:s("settingsDialog.system.sectionLabel"),description:s("settingsDialog.system.sectionDescription"),icon:Ke},{id:"about",label:s("settingsDialog.about.sectionLabel"),description:s("settingsDialog.about.sectionDescription"),icon:It}]);function Ze(t=null,n=""){const o=String((t==null?void 0:t.messageKey)||"").trim();if(o){const g=s(o);if(g&&g!==o)return g}return String((t==null?void 0:t.message)||"").trim()||(n?s(n):"")}function ue(t="",n=""){const o=String(t||"").trim();if(o){const g=`settingsDialog.relay.reason.${o}`,D=s(g);if(D!==g)return D}return String(n||"").trim()||s("common.notAvailable")}function et(t=null){const n=String((t==null?void 0:t.type)||"").trim()||"unknown",o=`settingsDialog.relay.event.${n}`,g=s(o);return g!==o?g:n}function tt(t=null){const n=String((t==null?void 0:t.lastErrorKey)||"").trim(),o=t!=null&&t.lastErrorParams&&typeof t.lastErrorParams=="object"?t.lastErrorParams:{};return n==="connect_failed"?s("settingsDialog.relay.error.connect_failed"):n==="disconnected"?s("settingsDialog.relay.error.disconnected",{reason:ue(o.reasonCode,t==null?void 0:t.lastCloseReason)}):n==="rejected"?s("settingsDialog.relay.error.rejected",{reason:ue(o.reasonCode,t==null?void 0:t.lastCloseReason)}):n==="closed_with_code"?s("settingsDialog.relay.error.closedWithCode",{code:o.code||(t==null?void 0:t.lastCloseCode)||0}):String((t==null?void 0:t.lastError)||"").trim()}const st=h(()=>{var t,n,o,g;return C.value?s("settingsDialog.relay.status.reconnecting"):k.value||G.value?s("settingsDialog.relay.status.saving"):y.value?s("settingsDialog.relay.status.loading"):(t=u.value)!=null&&t.reconnectPaused?s("settingsDialog.relay.status.paused"):(n=u.value)!=null&&n.connected?s("settingsDialog.relay.status.connected"):(((o=u.value)==null?void 0:o.enabled)??r.enabled)&&Number(((g=u.value)==null?void 0:g.nextReconnectDelayMs)||0)>0?s("settingsDialog.relay.status.waitingReconnect"):r.enabled?s("settingsDialog.relay.status.disconnected"):s("settingsDialog.relay.status.disabled")}),nt=h(()=>{var t,n;return(t=u.value)!=null&&t.reconnectPaused?"theme-status-danger":(n=u.value)!=null&&n.connected?"theme-status-success":r.enabled?"theme-status-warning":"theme-status-neutral"}),at=h(()=>{var t,n,o;return!f.value&&!p.value&&!w.value&&!((t=u.value)!=null&&t.lastError)&&!((n=u.value)!=null&&n.lastCloseReason)&&!((o=u.value)!=null&&o.lastConnectedAt)}),it=h(()=>{const t=r.deviceToken?`${"*".repeat(Math.max(0,r.deviceToken.length-4))}${r.deviceToken.slice(-4)}`:"";return JSON.stringify({generatedAt:new Date().toISOString(),source:"local-settings",config:{enabled:r.enabled,relayUrl:r.relayUrl,deviceId:r.deviceId,deviceTokenMasked:t,managedByEnv:f.value},status:u.value||null},null,2)}),L=h(()=>{var t,n;return((n=(t=R.value)==null?void 0:t.runner)==null?void 0:n.runner)||null}),Q=h(()=>{var t,n;return!!((n=(t=R.value)==null?void 0:t.runner)!=null&&n.ok&&L.value)}),_=h(()=>{var t;return((t=L.value)==null?void 0:t.metrics)||null}),pe=h(()=>{var t;return((t=R.value)==null?void 0:t.recovery)||null}),fe=h(()=>{var t;return((t=R.value)==null?void 0:t.maintenance)||null}),ot=h(()=>{var t;return((t=R.value)==null?void 0:t.gitDiffWorker)||null}),lt=h(()=>JSON.stringify({generatedAt:new Date().toISOString(),source:"local-settings",config:{runner:{maxConcurrentRuns:A.runnerMaxConcurrentRuns,managedByEnv:V.runnerMaxConcurrentRuns}},diagnostics:R.value||null},null,2));function X(t){const n=String(t||"").trim();if(!n)return s("common.notAvailable");const o=new Date(n);return Number.isNaN(o.getTime())?n:$t(o.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}const rt=h(()=>{var t,n,o,g,D,P,E,M;return[{key:"queued_cancelled",label:s("settingsDialog.system.stopReasons.queued_cancelled"),value:Math.max(0,Number((n=(t=_.value)==null?void 0:t.stopReasons)==null?void 0:n.queued_cancelled)||0)},{key:"user_requested",label:s("settingsDialog.system.stopReasons.user_requested"),value:Math.max(0,Number((g=(o=_.value)==null?void 0:o.stopReasons)==null?void 0:g.user_requested)||0)},{key:"user_requested_after_error",label:s("settingsDialog.system.stopReasons.user_requested_after_error"),value:Math.max(0,Number((P=(D=_.value)==null?void 0:D.stopReasons)==null?void 0:P.user_requested_after_error)||0)},{key:"stop_timeout",label:s("settingsDialog.system.stopReasons.stop_timeout"),value:Math.max(0,Number((M=(E=_.value)==null?void 0:E.stopReasons)==null?void 0:M.stop_timeout)||0)}]}),ct=h(()=>{var t,n,o,g,D,P,E,M,Z,ee;return[{key:"runner_timeout_without_stop_request",label:s("settingsDialog.system.stopTimeoutPhases.runner_timeout_without_stop_request"),value:Math.max(0,Number((n=(t=_.value)==null?void 0:t.stopTimeoutPhases)==null?void 0:n.runner_timeout_without_stop_request)||0)},{key:"runner_timeout_before_cancel",label:s("settingsDialog.system.stopTimeoutPhases.runner_timeout_before_cancel"),value:Math.max(0,Number((g=(o=_.value)==null?void 0:o.stopTimeoutPhases)==null?void 0:g.runner_timeout_before_cancel)||0)},{key:"cli_not_exiting",label:s("settingsDialog.system.stopTimeoutPhases.cli_not_exiting"),value:Math.max(0,Number((P=(D=_.value)==null?void 0:D.stopTimeoutPhases)==null?void 0:P.cli_not_exiting)||0)},{key:"os_kill_slow",label:s("settingsDialog.system.stopTimeoutPhases.os_kill_slow"),value:Math.max(0,Number((M=(E=_.value)==null?void 0:E.stopTimeoutPhases)==null?void 0:M.os_kill_slow)||0)},{key:"runner_finalize_after_exit",label:s("settingsDialog.system.stopTimeoutPhases.runner_finalize_after_exit"),value:Math.max(0,Number((ee=(Z=_.value)==null?void 0:Z.stopTimeoutPhases)==null?void 0:ee.runner_finalize_after_exit)||0)}]}),ut=h(()=>ge.value.map(t=>({value:t.value,label:t.value==="zh-CN"?s("locale.zhHans"):s("locale.enUs"),englishLabel:t.englishLabel})));async function dt(){F.value=!0,x.value="";try{const t=await Mt(),n=String((t==null?void 0:t.version)||"").trim();b.value=n,n||(x.value=s("settingsDialog.about.versionPending"))}catch(t){b.value="",x.value=(t==null?void 0:t.message)||s("settingsDialog.about.versionLoadFailed")}finally{F.value=!1}}function he(t={}){r.enabled=!!(t!=null&&t.enabled),r.relayUrl=String((t==null?void 0:t.relayUrl)||""),r.deviceId=String((t==null?void 0:t.deviceId)||""),r.deviceToken=String((t==null?void 0:t.deviceToken)||"")}function be(t={}){var n;A.runnerMaxConcurrentRuns=Math.max(1,Number((n=t==null?void 0:t.runner)==null?void 0:n.maxConcurrentRuns)||3)}async function De(){y.value=!0,p.value="",w.value="";try{const t=await qt();he((t==null?void 0:t.config)||{}),f.value=!!(t!=null&&t.managedByEnv),u.value=(t==null?void 0:t.relay)||null}catch(t){p.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayConfigLoadFailed"),u.value=null}finally{y.value=!1}}async function mt(){var t,n;ie.value=!0,I.value="",J.value="";try{const o=await At();be((o==null?void 0:o.config)||{}),V.runnerMaxConcurrentRuns=!!((n=(t=o==null?void 0:o.managedByEnv)==null?void 0:t.runner)!=null&&n.maxConcurrentRuns),Y()}catch(o){I.value=(o==null?void 0:o.message)||s("settingsDialog.system.systemConfigLoadFailed")}finally{ie.value=!1}}async function Y(){q.value=!0,K.value="";try{R.value=await Ht()}catch(t){K.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemDiagnosticsLoadFailed")}finally{q.value=!1}}async function gt(){k.value=!0,p.value="",w.value="";try{const t=await Ge({enabled:r.enabled,relayUrl:r.relayUrl,deviceId:r.deviceId,deviceToken:r.deviceToken});he((t==null?void 0:t.config)||{}),f.value=!!(t!=null&&t.managedByEnv),u.value=(t==null?void 0:t.relay)||null,w.value=r.enabled?s("settingsDialog.relay.relayConfigSavedEnabled"):s("settingsDialog.relay.relayConfigSavedDisabled")}catch(t){p.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayConfigSaveFailed")}finally{k.value=!1}}async function vt(){C.value=!0,p.value="",w.value="";try{const t=await Vt();u.value=(t==null?void 0:t.relay)||null,w.value=s("settingsDialog.relay.relayReconnectTriggered"),setTimeout(()=>{De()},1200)}catch(t){p.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayReconnectFailed")}finally{C.value=!1}}async function ht(){var t,n;j.value=!0,I.value="",J.value="";try{const o=await zt({runner:{maxConcurrentRuns:A.runnerMaxConcurrentRuns}});be((o==null?void 0:o.config)||{}),V.runnerMaxConcurrentRuns=!!((n=(t=o==null?void 0:o.managedByEnv)==null?void 0:t.runner)!=null&&n.maxConcurrentRuns),J.value=s("settingsDialog.system.systemConfigSaved"),Y()}catch(o){I.value=(o==null?void 0:o.message)||s("settingsDialog.system.systemConfigSaveFailed")}finally{j.value=!1}}function yt(){return!!(String(r.relayUrl||"").trim()&&String(r.deviceId||"").trim()&&String(r.deviceToken||"").trim())}async function xt(){var t;if(!f.value){if(p.value="",w.value="",r.enabled&&!yt()){r.enabled=!1,p.value=s("settingsDialog.relay.relayFieldsRequired");return}G.value=!0;try{const n=await Ge({enabled:r.enabled,relayUrl:r.relayUrl,deviceId:r.deviceId,deviceToken:r.deviceToken});he((n==null?void 0:n.config)||{}),f.value=!!(n!=null&&n.managedByEnv),u.value=(n==null?void 0:n.relay)||null,w.value=r.enabled?s("settingsDialog.relay.relayEnabledSaved"):s("settingsDialog.relay.relayConfigSavedDisabled")}catch(n){r.enabled=!!((t=u.value)!=null&&t.enabled),p.value=(n==null?void 0:n.message)||s("settingsDialog.relay.relayToggleFailed")}finally{G.value=!1}}}async function ke(t){var o;if((o=navigator.clipboard)!=null&&o.writeText&&window.isSecureContext){await navigator.clipboard.writeText(t);return}const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.opacity="0",n.style.pointerEvents="none",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n)}async function _t(){try{await ke(it.value),le.value=!0,B&&clearTimeout(B),B=setTimeout(()=>{le.value=!1,B=null},2e3)}catch(t){p.value=(t==null?void 0:t.message)||s("settingsDialog.relay.relayDiagnosticsCopyFailed")}}async function pt(){try{await ke(lt.value),re.value=!0,N&&clearTimeout(N),N=setTimeout(()=>{re.value=!1,N=null},2e3)}catch(t){K.value=(t==null?void 0:t.message)||s("settingsDialog.system.systemDiagnosticsCopyFailed")}}function ft(t){ve(t)}function ye(){ce&&(clearInterval(ce),ce=null)}function bt(){ye(),!(!W.open||S.value!=="system")&&(Y(),ce=setInterval(()=>{Y()},5e3))}return We(()=>W.open,t=>{if(t){S.value="theme",dt(),De(),mt();return}},{immediate:!0}),We([()=>W.open,S],([t,n])=>{if(t&&n==="system"){bt();return}ye()},{immediate:!0}),wt(()=>{B&&(clearTimeout(B),B=null),N&&(clearTimeout(N),N=null),ye()}),(t,n)=>(l(),U(Et,{open:$.open,"backdrop-class":"z-[70] items-end justify-center px-0 py-0 sm:items-center sm:px-4 sm:py-6","panel-class":"settings-dialog-panel h-full max-w-5xl sm:h-[42rem] sm:max-h-[88vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col sm:flex-row",onClose:n[7]||(n[7]=o=>ae("close"))},{title:de(()=>[e("div",os,[z(i(Ft),{class:"h-4 w-4"}),e("span",null,a(i(s)("common.settings")),1)])]),default:de(()=>{var o,g,D,P,E,M,Z,ee,Ce,we,Re,Te,Se,Pe,Ee,Me,Ue,$e,Be,Ne,Le,Fe,je,Ie,qe,Ve,Ae,ze,He,Oe;return[z(St,{modelValue:S.value,"onUpdate:modelValue":n[0]||(n[0]=d=>S.value=d),sections:Ye.value},null,8,["modelValue","sections"]),e("div",ls,[S.value==="theme"?(l(),c("section",rs,[e("div",null,[e("div",cs,a(i(s)("theme.title")),1),e("p",us,a(i(s)("theme.sectionDescription")),1)]),e("section",ds,[z(is)]),e("section",ms,[e("div",null,[e("div",gs,a(i(s)("locale.title")),1),e("p",vs,a(i(s)("locale.description")),1)]),e("label",hs,[e("span",ys,a(i(s)("locale.field")),1),z(Pt,{"model-value":i(T),options:ut.value,"get-option-value":d=>d.value,"onUpdate:modelValue":ft},{trigger:de(({selectedOption:d})=>[e("div",xs,a((d==null?void 0:d.label)||i(s)("common.select")),1)]),option:de(({option:d,selected:Dt,select:kt})=>[e("button",{type:"button",class:"workbench-select-option theme-filter-idle w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm",onClick:Ya=>kt()},[e("div",ps,[e("div",fs,[e("div",bs,a(d.label),1),e("div",Ds,a(d.englishLabel),1)]),Dt?(l(),c("span",ks,a(i(s)("common.enabled")),1)):v("",!0)])],8,_s)]),_:1},8,["model-value","options","get-option-value"])]),e("p",Cs,a(i(s)("locale.immediateHint")),1)])])):S.value==="relay"?(l(),c("section",ws,[e("div",Rs,[e("div",null,[e("div",Ts,[z(i(Je),{class:"h-4 w-4"}),e("span",null,a(i(s)("settingsDialog.relay.title")),1)])]),e("span",{class:Qe(["rounded-sm border border-dashed px-2.5 py-1 text-xs font-medium",nt.value])},a(st.value),3)]),e("section",Ss,[e("label",Ps,[e("div",null,[e("div",Es,a(i(s)("settingsDialog.relay.enableTitle")),1),e("p",Ms,a(i(s)("settingsDialog.relay.enableDescription")),1)]),te(e("input",{"onUpdate:modelValue":n[1]||(n[1]=d=>r.enabled=d),type:"checkbox",class:"h-4 w-4",disabled:f.value,onChange:xt},null,40,Us),[[Rt,r.enabled]])]),e("div",$s,[e("label",Bs,[e("span",Ns,a(i(s)("settingsDialog.relay.relayUrl")),1),te(e("input",{"onUpdate:modelValue":n[2]||(n[2]=d=>r.relayUrl=d),type:"text",placeholder:"https://user1.promptx.example.com",class:"tool-input",disabled:f.value},null,8,Ls),[[xe,r.relayUrl]])]),e("label",Fs,[e("span",js,a(i(s)("settingsDialog.relay.deviceId")),1),te(e("input",{"onUpdate:modelValue":n[3]||(n[3]=d=>r.deviceId=d),type:"text",placeholder:"my-macbook",class:"tool-input",disabled:f.value},null,8,Is),[[xe,r.deviceId]])]),e("label",qs,[e("span",Vs,a(i(s)("settingsDialog.relay.deviceToken")),1),e("div",As,[te(e("input",{"onUpdate:modelValue":n[4]||(n[4]=d=>r.deviceToken=d),type:oe.value?"text":"password",placeholder:i(s)("settingsDialog.relay.deviceTokenPlaceholder"),class:"tool-input pr-10",disabled:f.value},null,8,zs),[[Tt,r.deviceToken]]),e("button",{type:"button",class:"theme-icon-button absolute inset-y-1 right-1 flex h-auto w-8 items-center justify-center",disabled:f.value,onClick:n[5]||(n[5]=d=>oe.value=!oe.value)},[oe.value?(l(),U(i(Lt),{key:1,class:"h-4 w-4"})):(l(),U(i(Nt),{key:0,class:"h-4 w-4"}))],8,Hs)])])]),e("div",Os,[e("div",Ws,[(o=u.value)!=null&&o.reconnectPausedReason?(l(),c("p",Js,a(i(s)("settingsDialog.relay.pausedReconnect",{reason:ue(u.value.reconnectPausedReasonCode,u.value.reconnectPausedReason)})),1)):v("",!0),f.value?(l(),c("p",Ks,a(i(s)("settingsDialog.relay.managedByEnv")),1)):v("",!0),p.value?(l(),c("p",Gs,a(p.value),1)):w.value?(l(),c("p",Qs,a(w.value),1)):(g=u.value)!=null&&g.lastError?(l(),c("p",Xs,a(i(s)("settingsDialog.relay.lastError",{value:tt(u.value)})),1)):(D=u.value)!=null&&D.lastCloseReason?(l(),c("p",Ys,a(i(s)("settingsDialog.relay.lastClosed",{reason:ue(u.value.lastCloseReasonCode,u.value.lastCloseReason),code:u.value.lastCloseCode})),1)):(P=u.value)!=null&&P.lastConnectedAt?(l(),c("p",Zs,a(i(s)("settingsDialog.relay.lastConnected",{value:X(u.value.lastConnectedAt)})),1)):v("",!0),(M=(E=u.value)==null?void 0:E.recentEvents)!=null&&M.length?(l(),c("p",en,a(i(s)("settingsDialog.relay.recentEvent",{value:et(u.value.recentEvents[0])})),1)):v("",!0),le.value?(l(),c("p",tn,a(i(s)("settingsDialog.relay.copied")),1)):v("",!0),at.value?(l(),c("p",sn,a(i(s)("settingsDialog.relay.defaultHint")),1)):v("",!0)]),e("div",nn,[e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:y.value||k.value||G.value||C.value||!(((Z=u.value)==null?void 0:Z.enabled)??r.enabled),onClick:vt},[C.value?(l(),U(i(me),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(C.value?i(s)("settingsDialog.relay.reconnecting"):i(s)("settingsDialog.relay.reconnectNow")),1)],8,an),e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:y.value||C.value,onClick:_t},[e("span",null,a(le.value?i(s)("settingsDialog.relay.diagnosticsCopied"):i(s)("settingsDialog.relay.copyDiagnostics")),1)],8,on),e("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:y.value||k.value||G.value||C.value||f.value,onClick:gt},[k.value?(l(),U(i(me),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(k.value?i(s)("common.saving"):i(s)("settingsDialog.relay.saveConfig")),1)],8,ln)])])])])):S.value==="system"?(l(),c("section",rn,[e("div",null,[e("div",cn,[z(i(Ke),{class:"h-4 w-4"}),e("span",null,a(i(s)("settingsDialog.system.title")),1)]),e("p",un,a(i(s)("settingsDialog.system.intro")),1)]),e("section",dn,[e("label",mn,[e("span",gn,a(i(s)("settingsDialog.system.maxConcurrentRuns")),1),te(e("input",{"onUpdate:modelValue":n[6]||(n[6]=d=>A.runnerMaxConcurrentRuns=d),type:"number",min:"1",max:"16",step:"1",class:"tool-input",disabled:V.runnerMaxConcurrentRuns||ie.value||j.value},null,8,vn),[[xe,A.runnerMaxConcurrentRuns,void 0,{number:!0}]]),e("p",hn,a(i(s)("settingsDialog.system.maxConcurrentRunsHint")),1)]),e("div",yn,[e("div",xn,[V.runnerMaxConcurrentRuns?(l(),c("p",_n,a(i(s)("settingsDialog.system.managedByEnv")),1)):I.value?(l(),c("p",pn,a(I.value),1)):J.value?(l(),c("p",fn,a(J.value),1)):(l(),c("p",bn,a(i(s)("settingsDialog.system.diagnosticsHint")),1))]),e("div",Dn,[e("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:V.runnerMaxConcurrentRuns||ie.value||j.value,onClick:ht},[j.value?(l(),U(i(me),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(j.value?i(s)("common.saving"):i(s)("settingsDialog.system.saveConfig")),1)],8,kn)])])]),e("section",Cn,[e("div",wn,[e("div",null,[e("div",Rn,a(i(s)("settingsDialog.system.runtimeDiagnostics")),1),e("p",Tn,a(i(s)("settingsDialog.system.runtimeDiagnosticsHint")),1)]),e("div",Sn,[e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",disabled:q.value,onClick:Y},[q.value?(l(),U(i(me),{key:0,class:"h-4 w-4 animate-spin"})):v("",!0),e("span",null,a(q.value?i(s)("settingsDialog.system.refreshingDiagnostics"):i(s)("settingsDialog.system.refreshDiagnostics")),1)],8,Pn),e("button",{type:"button",class:"tool-button inline-flex items-center gap-2 px-3 py-2 text-xs",onClick:pt},[e("span",null,a(re.value?i(s)("settingsDialog.system.diagnosticsCopied"):i(s)("settingsDialog.system.copyDiagnostics")),1)])])]),e("div",En,[K.value?(l(),c("p",Mn,a(K.value),1)):re.value?(l(),c("p",Un,a(i(s)("settingsDialog.system.diagnosticsCopiedHint")),1)):(l(),c("p",$n,a(i(s)("settingsDialog.system.diagnosticsHint")),1))]),Q.value?(l(),c("div",Bn,[e("div",Nn,[n[8]||(n[8]=e("div",{class:"theme-muted-text text-xs"},"active",-1)),e("div",Ln,a(((ee=L.value)==null?void 0:ee.activeRunCount)||0),1),e("p",Fn,a(i(s)("settingsDialog.system.active")),1)]),e("div",jn,[n[9]||(n[9]=e("div",{class:"theme-muted-text text-xs"},"tracked",-1)),e("div",In,a(((Ce=L.value)==null?void 0:Ce.trackedRunCount)||0),1),e("p",qn,a(i(s)("settingsDialog.system.tracked")),1)]),e("div",Vn,[n[10]||(n[10]=e("div",{class:"theme-muted-text text-xs"},"queued",-1)),e("div",An,a(((we=L.value)==null?void 0:we.queuedRunCount)||0),1),e("p",zn,a(i(s)("settingsDialog.system.queued")),1)]),e("div",Hn,[n[11]||(n[11]=e("div",{class:"theme-muted-text text-xs"},"maxConcurrent",-1)),e("div",On,a(((Te=(Re=L.value)==null?void 0:Re.config)==null?void 0:Te.maxConcurrentRuns)||A.runnerMaxConcurrentRuns),1),e("p",Wn,a(i(s)("settingsDialog.system.maxConcurrent")),1)])])):v("",!0),Q.value?(l(),c("div",Jn,[e("div",Kn,[n[12]||(n[12]=e("div",{class:"theme-muted-text text-xs"},"completed",-1)),e("div",Gn,a(((Se=_.value)==null?void 0:Se.totalCompleted)||0),1),e("p",Qn,a(i(s)("settingsDialog.system.completed")),1)]),e("div",Xn,[n[13]||(n[13]=e("div",{class:"theme-muted-text text-xs"},"stopped",-1)),e("div",Yn,a(((Pe=_.value)==null?void 0:Pe.totalStopped)||0),1),e("p",Zn,a(i(s)("settingsDialog.system.stopped")),1)]),e("div",ea,[n[14]||(n[14]=e("div",{class:"theme-muted-text text-xs"},"error",-1)),e("div",ta,a(((Ee=_.value)==null?void 0:Ee.totalErrored)||0),1),e("p",sa,a(i(s)("settingsDialog.system.error")),1)]),e("div",na,[n[15]||(n[15]=e("div",{class:"theme-muted-text text-xs"},"stop_timeout",-1)),e("div",aa,a(((Me=_.value)==null?void 0:Me.totalStopTimeout)||0),1),e("p",ia,a(i(s)("settingsDialog.system.stopTimeout")),1)])])):v("",!0),Q.value?(l(),c("div",oa,[e("div",la,[n[16]||(n[16]=e("div",{class:"theme-muted-text text-xs"},"event flush failures",-1)),e("div",ra,a(((Ue=_.value)==null?void 0:Ue.eventFlushFailureCount)||0),1),e("p",ca,a(i(s)("settingsDialog.system.eventWriteFailures")),1)]),e("div",ua,[n[17]||(n[17]=e("div",{class:"theme-muted-text text-xs"},"recovered runs",-1)),e("div",da,a(((Be=($e=pe.value)==null?void 0:$e.metrics)==null?void 0:Be.totalRecovered)||0),1),e("p",ma,a(i(s)("settingsDialog.system.recoveredRuns")),1)]),e("div",ga,[n[18]||(n[18]=e("div",{class:"theme-muted-text text-xs"},"last cleanup",-1)),e("div",va,a(X((Le=(Ne=fe.value)==null?void 0:Ne.lastCleanup)==null?void 0:Le.finishedAt)),1),e("p",ha,a(i(s)("settingsDialog.system.lastMaintenanceAt")),1)])])):v("",!0),e("div",ya,[e("div",xa,[e("div",_a,a(i(s)("settingsDialog.system.baseStatus")),1),e("div",pa,[e("div",fa,[n[19]||(n[19]=e("span",{class:"theme-muted-text"},"runner baseUrl",-1)),e("span",ba,a(((je=(Fe=R.value)==null?void 0:Fe.runner)==null?void 0:je.baseUrl)||"-"),1)]),e("div",Da,[n[20]||(n[20]=e("span",{class:"theme-muted-text"},"runner startedAt",-1)),e("span",ka,a(X((Ie=L.value)==null?void 0:Ie.startedAt)),1)]),e("div",Ca,[n[21]||(n[21]=e("span",{class:"theme-muted-text"},"last sweep",-1)),e("span",wa,a(X((Ve=(qe=pe.value)==null?void 0:qe.metrics)==null?void 0:Ve.lastSweepFinishedAt)),1)]),e("div",Ra,[n[22]||(n[22]=e("span",{class:"theme-muted-text"},"git diff worker",-1)),e("span",Ta,a(ot.value?i(s)("settingsDialog.system.available"):i(s)("settingsDialog.system.unknown")),1)]),e("div",Sa,[n[23]||(n[23]=e("span",{class:"theme-muted-text"},"db vacuum",-1)),e("span",Pa,a(X((Ae=fe.value)==null?void 0:Ae.lastVacuumAt)),1)])])]),e("div",Ea,[e("div",Ma,a(i(s)("settingsDialog.system.stopReasonTitle")),1),e("div",Ua,[(l(!0),c(se,null,ne(rt.value,d=>(l(),c("div",{key:d.key,class:"flex items-center justify-between gap-3"},[e("span",$a,a(d.label),1),e("span",Ba,a(d.value),1)]))),128))])])]),Q.value?(l(),c("div",Na,[e("div",La,a(i(s)("settingsDialog.system.stopTimeoutPhaseTitle")),1),e("div",Fa,[(l(!0),c(se,null,ne(ct.value,d=>(l(),c("div",{key:d.key,class:"flex items-center justify-between gap-3 rounded-sm border border-dashed border-[var(--theme-borderMuted)] px-2.5 py-2"},[e("span",ja,a(d.label),1),e("span",Ia,a(d.value),1)]))),128))])])):v("",!0),!Q.value&&!q.value?(l(),c("div",qa,[e("div",Va,a(i(s)("settingsDialog.system.runnerUnavailable")),1),e("p",Aa,a(Ze((ze=R.value)==null?void 0:ze.runner,"settingsDialog.system.runnerUnavailableDescription")),1),e("p",za," baseUrl: "+a(((Oe=(He=R.value)==null?void 0:He.runner)==null?void 0:Oe.baseUrl)||"-"),1)])):v("",!0)])])):(l(),c("section",Ha,[e("div",null,[e("div",Oa,a(i(s)("settingsDialog.about.title")),1),e("p",Wa,a(i(s)("settingsDialog.about.intro")),1)]),e("section",Ja,[e("div",Ka,[e("div",null,[e("div",Ga,a(i(s)("settingsDialog.about.versionTitle")),1),e("p",Qa,a(x.value||i(s)("settingsDialog.about.versionDescription")),1)]),e("span",Xa,a(F.value?i(s)("common.loading"):b.value?`v${b.value}`:i(s)("common.unavailable")),1)])])]))])]}),_:1},8,["open"]))}};export{oi as default};