@muyichengshayu/promptx 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,27 +1,27 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-shiki-theme-github-dark-default-DBX58552.js","assets/vendor-shiki-core-1BqeTDsZ.js","assets/vendor-misc-u-M8sNMf.js","assets/vendor-misc-ClI1dyrl.css","assets/vendor-shiki-theme-github-light-RLAvZv0q.js","assets/vendor-shiki-lang-bash-zsQu0xn-.js","assets/vendor-shiki-lang-c-BDF8vgks.js","assets/vendor-shiki-lang-cpp-DyDAaXl6.js","assets/vendor-shiki-lang-csharp-BWfTXJXw.js","assets/vendor-shiki-lang-css-DbAm1fUO.js","assets/vendor-shiki-lang-diff-DmGC1G26.js","assets/vendor-shiki-lang-dockerfile-3x-8396r.js","assets/vendor-shiki-lang-dotenv--IVOlX2Q.js","assets/vendor-shiki-lang-fish-Bpv3hhJP.js","assets/vendor-shiki-lang-go-CIGC59jP.js","assets/vendor-shiki-lang-html-Bt_TLLZN.js","assets/vendor-shiki-lang-ini-BIllfys4.js","assets/vendor-shiki-lang-java-CXxu9crF.js","assets/vendor-shiki-lang-javascript-Cha7GNZm.js","assets/vendor-shiki-lang-json-CCZCjDUh.js","assets/vendor-shiki-lang-less-DAToytC5.js","assets/vendor-shiki-lang-markdown-C6lwMXFp.js","assets/vendor-shiki-lang-python-Bi9rmtY7.js","assets/vendor-shiki-lang-powershell-lrpuM0ez.js","assets/vendor-shiki-lang-rust-GTGDbY6A.js","assets/vendor-shiki-lang-sass-DFtHupN8.js","assets/vendor-shiki-lang-scss-BrfBNyyi.js","assets/vendor-shiki-lang-sql-H6--iFN-.js","assets/vendor-shiki-lang-toml-aTteTWYL.js","assets/vendor-shiki-lang-tsx-DoKZm6AV.js","assets/vendor-shiki-lang-typescript-B5awnqri.js","assets/vendor-shiki-lang-vue-CnrgQ7Z5.js","assets/vendor-shiki-lang-xml-Bv-TNPJt.js","assets/vendor-shiki-lang-yaml-DpxUxQ6M.js","assets/CodexSessionManagerDialog-CELTkz9T.js","assets/index-8vfFmsVl.js","assets/vendor-router-Dn8q3tJM.js","assets/index-BPfQQtEB.css","assets/vendor-ui-BwEQCho1.js","assets/vendor-markdown-9aQhqbjm.js","assets/vendor-tiptap-rwYdQb1L.js","assets/TaskDiffReviewDialog-VwZmo00b.js","assets/TaskDiffReviewDialog-CeGj0idf.css","assets/WorkbenchSettingsDialog-CThWkZHd.js"])))=>i.map(i=>d[i]);
2
- import{u as St,t as We,f as xr,_ as ze,a as br,b as kr,g as Os,s as xa,c as ba}from"./index-8vfFmsVl.js";import{w as $e,ak as It,aD as g,aI as Ce,aG as ue,aJ as Je,aE as x,aK as Qe,aL as Se,aF as i,aM as Jt,u as a,aN as me,aO as _r,aP as os,c as W,aQ as S,aR as et,aS as ut,aT as cn,o as dn,aU as Gt,aV as kn,b as q,n as at,aW as Wt,aX as Xn,aY as jo,r as rs,aC as ka,aZ as an,f as _a,a_ as fo,a$ as $s,G as Ta,al as Ca,b0 as gn,b1 as hn}from"./vendor-misc-u-M8sNMf.js";import{X as Tr,T as Ea,L as Ht,C as ko,a as Is,B as Fo,S as Aa,P as Zn,b as Cr,c as $a,A as Ia,F as Dn,d as Sn,e as Er,f as Pa,E as Da,g as La,h as Uo,i as _o,j as Ps,k as Ba,l as Ma,m as Ra,U as Na,W as Oa,n as Ar,o as ja,p as Ds,q as js,I as $r,r as Fa,s as Ua,t as Va,u as za,G as Ha,v as qa,w as Ka,x as Wa,y as Ga}from"./vendor-ui-BwEQCho1.js";import{M as Ir}from"./vendor-markdown-9aQhqbjm.js";import{n as To,N as Pr,a as Co,i as Xa,V as Xs,b as Vo,u as Ya,c as Ja,E as Qa}from"./vendor-tiptap-rwYdQb1L.js";const Za="shell",ei=new Set(["!","!"]),zo="text";function Ss(e=""){return String(e||"").replace(/\r\n/g,`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-shiki-theme-github-dark-default-DBX58552.js","assets/vendor-shiki-core-1BqeTDsZ.js","assets/vendor-misc-u-M8sNMf.js","assets/vendor-misc-ClI1dyrl.css","assets/vendor-shiki-theme-github-light-RLAvZv0q.js","assets/vendor-shiki-lang-bash-zsQu0xn-.js","assets/vendor-shiki-lang-c-BDF8vgks.js","assets/vendor-shiki-lang-cpp-DyDAaXl6.js","assets/vendor-shiki-lang-csharp-BWfTXJXw.js","assets/vendor-shiki-lang-css-DbAm1fUO.js","assets/vendor-shiki-lang-diff-DmGC1G26.js","assets/vendor-shiki-lang-dockerfile-3x-8396r.js","assets/vendor-shiki-lang-dotenv--IVOlX2Q.js","assets/vendor-shiki-lang-fish-Bpv3hhJP.js","assets/vendor-shiki-lang-go-CIGC59jP.js","assets/vendor-shiki-lang-html-Bt_TLLZN.js","assets/vendor-shiki-lang-ini-BIllfys4.js","assets/vendor-shiki-lang-java-CXxu9crF.js","assets/vendor-shiki-lang-javascript-Cha7GNZm.js","assets/vendor-shiki-lang-json-CCZCjDUh.js","assets/vendor-shiki-lang-less-DAToytC5.js","assets/vendor-shiki-lang-markdown-C6lwMXFp.js","assets/vendor-shiki-lang-python-Bi9rmtY7.js","assets/vendor-shiki-lang-powershell-lrpuM0ez.js","assets/vendor-shiki-lang-rust-GTGDbY6A.js","assets/vendor-shiki-lang-sass-DFtHupN8.js","assets/vendor-shiki-lang-scss-BrfBNyyi.js","assets/vendor-shiki-lang-sql-H6--iFN-.js","assets/vendor-shiki-lang-toml-aTteTWYL.js","assets/vendor-shiki-lang-tsx-DoKZm6AV.js","assets/vendor-shiki-lang-typescript-B5awnqri.js","assets/vendor-shiki-lang-vue-CnrgQ7Z5.js","assets/vendor-shiki-lang-xml-Bv-TNPJt.js","assets/vendor-shiki-lang-yaml-DpxUxQ6M.js","assets/CodexSessionManagerDialog-CCBswCOE.js","assets/index-DpCCivzJ.js","assets/vendor-router-Dn8q3tJM.js","assets/index-DhKg39i4.css","assets/vendor-ui-BwEQCho1.js","assets/vendor-markdown-9aQhqbjm.js","assets/vendor-tiptap-rwYdQb1L.js","assets/TaskDiffReviewDialog-PZ63ypA4.js","assets/TaskDiffReviewDialog-hxUGDcmF.css","assets/WorkbenchSettingsDialog-sRvpVVLk.js"])))=>i.map(i=>d[i]);
2
+ import{u as St,t as We,f as xr,_ as ze,a as br,b as kr,g as Os,s as xa,c as ba}from"./index-DpCCivzJ.js";import{w as $e,ak as It,aD as g,aI as Ce,aG as ue,aJ as Je,aE as x,aK as Qe,aL as Se,aF as i,aM as Jt,u as a,aN as me,aO as _r,aP as os,c as W,aQ as w,aR as et,aS as ut,aT as cn,o as dn,aU as Gt,aV as kn,b as q,n as at,aW as Wt,aX as Xn,aY as jo,r as rs,aC as ka,aZ as an,f as _a,a_ as fo,a$ as $s,G as Ta,al as Ca,b0 as gn,b1 as hn}from"./vendor-misc-u-M8sNMf.js";import{X as Tr,T as Ea,L as Ht,C as ko,a as Is,B as Fo,S as Aa,P as Zn,b as Cr,c as $a,A as Ia,F as Dn,d as Sn,e as Er,f as Pa,E as Da,g as La,h as Uo,i as _o,j as Ps,k as Ba,l as Ma,m as Ra,U as Na,W as Oa,n as Ar,o as ja,p as Ds,q as js,I as $r,r as Fa,s as Ua,t as Va,u as za,G as Ha,v as qa,w as Ka,x as Wa,y as Ga}from"./vendor-ui-BwEQCho1.js";import{M as Ir}from"./vendor-markdown-9aQhqbjm.js";import{n as To,N as Pr,a as Co,i as Xa,V as Xs,b as Vo,u as Ya,c as Ja,E as Qa}from"./vendor-tiptap-rwYdQb1L.js";const Za="shell",ei=new Set(["!","!"]),zo="text";function Ss(e=""){return String(e||"").replace(/\r\n/g,`
3
3
  `).trim()}function ti(e=""){const t=String(e||"");return ei.has(t.charAt(0))}function ni(e=""){const t=Ss(e);return t?t.charAt(0)==="!"?`!${t.slice(1)}`:t:""}function si(e={}){const n=(Array.isArray(e==null?void 0:e.promptBlocks)?e.promptBlocks:[]).filter(c=>!!Ss(c==null?void 0:c.content)),o=n.length>0,s=o?n.filter(c=>String((c==null?void 0:c.type)||"").trim()===zo).map(c=>Ss(c==null?void 0:c.content)).filter(Boolean).join(`
4
4
 
5
- `).trim():Ss(e==null?void 0:e.prompt);if(!ti(s))return{mode:"",prompt:s,command:"",reason:""};if(o&&n.some(p=>String((p==null?void 0:p.type)||"").trim()!==zo))return{mode:"",prompt:s,command:"",reason:"unsupported_blocks"};const l=ni(s).slice(1).trim();return l?{mode:Za,prompt:s,command:l,reason:""}:{mode:"",prompt:s,command:"",reason:"empty_command"}}const Zt={NONE:"none",LATEST:"latest",ALL:"all"};function oi(e="",t={}){const n=String(e||"").trim().toLowerCase();return n===Zt.ALL?Zt.ALL:n===Zt.LATEST?Zt.LATEST:n===Zt.NONE?Zt.NONE:t.includeEvents?Zt.ALL:t.includeLatestEvents?Zt.LATEST:Zt.NONE}const Vt={SESSION:"session",SESSION_UPDATED:"session.updated",STATUS:"status",STDOUT:"stdout",STDERR:"stderr",AGENT_EVENT:"agent_event",COMPLETED:"completed",STOPPED:"stopped",ERROR:"error"};function Dr(e=""){const t=String(e||"").trim().toLowerCase();return t==="codex"?Vt.AGENT_EVENT:t}const vt={THREAD_STARTED:"thread.started",TURN_STARTED:"turn.started",TURN_COMPLETED:"turn.completed",TURN_FAILED:"turn.failed",ERROR:"error",ITEM_STARTED:"item.started",ITEM_UPDATED:"item.updated",ITEM_COMPLETED:"item.completed"},rt={REASONING:"reasoning",WEB_SEARCH:"web_search",COLLAB_TOOL_CALL:"collab_tool_call",FILE_CHANGE:"file_change",COMMAND_EXECUTION:"command_execution",TODO_LIST:"todo_list",AGENT_MESSAGE:"agent_message"},ri={none:{label:"不过期",hours:null}};Object.entries(ri).map(([e,t])=>({value:e,label:t.label}));const ws={CODEX:"codex",CLAUDE_CODE:"claude-code",OPENCODE:"opencode"},Eo=[{value:ws.CODEX,label:"Codex",enabled:!0},{value:ws.CLAUDE_CODE,label:"Claude Code",enabled:!0},{value:ws.OPENCODE,label:"OpenCode",enabled:!0}],$t={TEXT:"text",IMAGE:"image",IMPORTED_TEXT:"imported_text"},ai=[{value:"local",label:"跟随本机时区"}],ii={SKIP:"skip"},li=[{value:ii.SKIP,label:"已有运行时跳过本次"}],Ys={DINGTALK:"dingtalk",FEISHU:"feishu",WEBHOOK:"webhook"},ui=[{value:Ys.DINGTALK,label:"钉钉 Webhook"},{value:Ys.FEISHU,label:"飞书 Webhook"},{value:Ys.WEBHOOK,label:"通用 Webhook"}],Js={COMPLETED:"completed",SUCCESS:"success",ERROR:"error"},ci=[{value:Js.COMPLETED,label:"本次运行结束后"},{value:Js.SUCCESS,label:"本次运行成功后"},{value:Js.ERROR,label:"本次运行失败后"}],di={SUMMARY:"summary"},fi=[{value:di.SUMMARY,label:"摘要消息"}],Ho={ZH_CN:"zh-CN",EN_US:"en-US"},pi=[{value:Ho.ZH_CN,label:"简体中文"},{value:Ho.EN_US,label:"English"}];function Ls(e){var n;const t=String(e||"").trim().toLowerCase();return((n=Eo.find(o=>o.value===t))==null?void 0:n.value)||ws.CODEX}function ct(e){var t;return((t=Eo.find(n=>n.value===Ls(e)))==null?void 0:t.label)||"Codex"}function fy(e=""){const t=String(e||"").trim();if(!t)return"";const n=/^[a-z]:[\\/]/i.test(t)||t.includes("\\");let o=t.replace(/\\/g,"/");return o.length>1&&!/^[a-z]:\/$/i.test(o)&&(o=o.replace(/\/+$/,"")),n?o.toLowerCase():o}function mi(e=[],t=10){const n=e.find(o=>{var s;return(o.type===$t.TEXT||o.type===$t.IMPORTED_TEXT)&&((s=o.content)==null?void 0:s.trim())});return n?n.content.replace(/\s+/g," ").trim().slice(0,t):""}const gi={class:"min-w-0 flex-1"},hi={key:0,class:"flex items-center gap-2"},vi=["disabled"],Fs={__name:"DialogShell",props:{open:{type:Boolean,default:!1},backdropClass:{type:String,default:""},stackLevel:{type:Number,default:0},panelClass:{type:String,default:""},headerClass:{type:String,default:"px-4 py-4 sm:px-5"},bodyClass:{type:String,default:"min-h-0 flex-1"},showClose:{type:Boolean,default:!0},closeDisabled:{type:Boolean,default:!1},closeOnBackdrop:{type:Boolean,default:!0},closeOnEscape:{type:Boolean,default:!0},lockBodyScroll:{type:Boolean,default:!0}},emits:["close"],setup(e,{emit:t}){const n=e,o=t,s=W(()=>n.backdropClass?n.backdropClass:`${n.stackLevel>=4?"z-[90]":n.stackLevel===3?"z-[75]":n.stackLevel===2?"z-[70]":n.stackLevel===1?"z-[60]":"z-50"} items-end justify-center px-0 py-0 sm:items-center sm:px-4 sm:py-6`);function r(){n.closeDisabled||o("close")}function l(){!n.closeOnBackdrop||n.closeDisabled||o("close")}function c(p){!n.open||!n.closeOnEscape||n.closeDisabled||p.key==="Escape"&&o("close")}return $e(()=>n.open,p=>{if(n.lockBodyScroll&&document.body.classList.toggle("overflow-hidden",p),p&&n.closeOnEscape){window.addEventListener("keydown",c);return}window.removeEventListener("keydown",c)},{immediate:!0}),It(()=>{n.lockBodyScroll&&document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",c)}),(p,w)=>(g(),Ce(os,{to:"body"},[ue(_r,{name:"dialog-shell"},{default:Je(()=>[e.open?(g(),x("div",{key:0,class:Se(["theme-modal-backdrop dialog-shell-backdrop fixed inset-0 flex",s.value]),onClick:Qe(l,["self"])},[i("section",{class:Se(["panel dialog-shell-panel flex min-h-0 w-full flex-col overflow-hidden",e.panelClass])},[p.$slots.title||p.$slots.header||p.$slots["header-actions"]||e.showClose?(g(),x("div",{key:0,class:Se(["theme-divider flex items-start justify-between gap-4 border-b",e.headerClass])},[i("div",gi,[Jt(p.$slots,"header",{},()=>[Jt(p.$slots,"title")])]),p.$slots["header-actions"]||e.showClose?(g(),x("div",hi,[Jt(p.$slots,"header-actions"),e.showClose?(g(),x("button",{key:0,type:"button",class:"theme-icon-button h-8 w-8 shrink-0",disabled:e.closeDisabled,onClick:r},[ue(a(Tr),{class:"h-4 w-4"})],8,vi)):me("",!0)])):me("",!0)],2)):me("",!0),i("div",{class:Se(e.bodyClass)},[Jt(p.$slots,"default")],2)],2)],2)):me("",!0)]),_:3})]))}},yi={class:"flex items-start gap-3"},Si={class:"theme-heading text-base font-semibold"},wi={key:0,class:"theme-muted-text mt-1 text-sm leading-6"},xi={class:"flex justify-end gap-2 px-5 py-4"},bi=["disabled"],ki=["disabled"],ps={__name:"ConfirmDialog",props:{open:{type:Boolean,default:!1},title:{type:String,default:""},description:{type:String,default:""},confirmText:{type:String,default:""},cancelText:{type:String,default:""},loading:{type:Boolean,default:!1},danger:{type:Boolean,default:!1}},emits:["cancel","confirm"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=W(()=>n.title||s("common.confirm")),l=W(()=>n.confirmText||s("common.confirm")),c=W(()=>n.cancelText||s("common.cancel"));return(p,w)=>(g(),Ce(Fs,{open:e.open,"stack-level":4,"panel-class":"max-w-md","header-class":"px-5 py-4","body-class":"flex flex-col","close-disabled":e.loading,"close-on-backdrop":!e.loading,"close-on-escape":!e.loading,onClose:w[2]||(w[2]=d=>o("cancel"))},{title:Je(()=>[i("div",yi,[i("span",{class:Se(["inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-sm border border-dashed",e.danger?"theme-status-danger":"theme-status-neutral"])},[ue(a(Ea),{class:"h-4 w-4"})],2),i("div",null,[i("h2",Si,S(r.value),1),e.description?(g(),x("p",wi,S(e.description),1)):me("",!0)])])]),default:Je(()=>[i("div",xi,[i("button",{type:"button",class:"tool-button px-4 py-2 text-sm",disabled:e.loading,onClick:w[0]||(w[0]=d=>o("cancel"))},S(c.value),9,bi),i("button",{type:"button",class:Se(["tool-button px-4 py-2 text-sm",e.danger?"tool-button-danger":"tool-button-primary"]),disabled:e.loading,onClick:w[1]||(w[1]=d=>o("confirm"))},S(e.loading?a(s)("common.processing"):l.value),11,ki)])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},_i={class:"theme-divider settings-dialog-nav border-b px-3 py-3 sm:w-60 sm:shrink-0 sm:border-b-0 sm:border-r sm:px-4 sm:py-4"},Ti={class:"settings-nav flex gap-2 overflow-x-auto sm:flex-col sm:overflow-visible"},Ci=["onClick"],Ei={class:"min-w-0"},Ai={class:"text-sm font-medium"},$i={class:"theme-muted-text mt-1 hidden text-xs leading-5 sm:block"},Ii={__name:"DialogSideNav",props:{modelValue:{type:String,default:""},sections:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(e,{emit:t}){const n=t;function o(s=""){n("update:modelValue",String(s||""))}return(s,r)=>(g(),x("aside",_i,[i("nav",Ti,[(g(!0),x(et,null,ut(e.sections,l=>(g(),x("button",{key:l.id,type:"button",class:Se(["settings-nav__item flex min-w-0 items-start gap-3 rounded-sm border px-3 py-3 text-left transition sm:w-full",e.modelValue===l.id?"theme-card-selected":"theme-card-idle-muted border-dashed hover:border-[var(--theme-borderStrong)] hover:bg-[var(--theme-appPanelStrong)]"]),onClick:c=>o(l.id)},[(g(),Ce(cn(l.icon),{class:"mt-0.5 h-4 w-4 shrink-0"})),i("div",Ei,[i("div",Ai,S(l.label),1),i("p",$i,S(l.description),1)])],10,Ci))),128))])]))}},Pi=["aria-label","disabled","onKeydown"],Di={class:"min-w-0 flex-1"},Li={class:"theme-muted-text text-sm"},Bi={class:"flex min-h-0 w-full flex-col"},Mi={class:"min-h-0 flex-1 space-y-2 overflow-y-auto p-2"},Ri=["onClick"],Ni={class:"theme-empty-state px-3 py-4 text-sm"},en={__name:"WorkbenchSelect",props:{modelValue:{type:[String,Number],default:""},options:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:""},emptyText:{type:String,default:""},ariaLabel:{type:String,default:""},getOptionValue:{type:Function,default:e=>(e==null?void 0:e.id)??(e==null?void 0:e.value)??""},triggerClass:{type:String,default:""}},emits:["update:modelValue","refresh-intent"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=q(null),l=q(null),c=q(!1),p=q(!1),w=q({}),d=W(()=>{const U=String(n.modelValue??"");return n.options.find(se=>String(n.getOptionValue(se)??"")===U)||null}),m=W(()=>n.placeholder||s("common.select")),f=W(()=>n.emptyText||s("common.noOptions"));function b(U){return U&&typeof U=="object"&&Object.prototype.hasOwnProperty.call(U,"label")?String(U.label||""):String(n.getOptionValue(U)??"")}function v(){n.disabled||(c.value||o("refresh-intent"),c.value=!0)}function P(){c.value=!1}function ne(){if(c.value){P();return}v()}function y(U){o("update:modelValue",String(n.getOptionValue(U)??"").trim()),P()}function L(){if(!c.value||!r.value||typeof window>"u")return;const U=r.value.getBoundingClientRect(),se=window.innerWidth,A=window.innerHeight,G=8,ce=8,pe=160,I=360,Q=Math.max(0,A-U.bottom-ce),le=Math.max(0,U.top-ce);p.value=Q<260&&le>Q;const ie=p.value?le-G:Q-G,ve=Math.max(Math.min(I,Math.max(ie,0)),Math.min(pe,p.value?le:Q)),_=Math.min(U.width,se-ce*2),H=Math.min(Math.max(ce,U.left),Math.max(ce,se-ce-_));w.value={left:`${H}px`,top:p.value?`${U.top-G}px`:`${U.bottom+G}px`,width:`${_}px`,maxHeight:`${Math.max(ve,120)}px`,transform:p.value?"translateY(-100%)":"none"}}function O(U){var se;!c.value||!r.value||r.value.contains(U.target)||(se=l.value)!=null&&se.contains(U.target)||P()}function z(U){U.key==="Escape"&&P()}return $e(()=>n.disabled,U=>{U&&P()}),$e(c,async U=>{U&&(await at(),L())}),dn(()=>{document.addEventListener("pointerdown",O),document.addEventListener("keydown",z),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0)}),It(()=>{document.removeEventListener("pointerdown",O),document.removeEventListener("keydown",z),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}),(U,se)=>(g(),x("div",{ref_key:"rootRef",ref:r,class:"relative min-w-0"},[i("button",{type:"button",class:Se(["workbench-select-trigger flex w-full items-center gap-3 rounded-sm border px-3 py-2 text-left transition focus:outline-none focus:ring-2",[n.triggerClass,e.disabled?"cursor-not-allowed border-[color-mix(in_srgb,var(--theme-borderDefault)_88%,var(--theme-textMuted))] bg-[color-mix(in_srgb,var(--theme-appPanelMuted)_82%,var(--theme-appBg))] text-[var(--theme-textMuted)]":"theme-input-shell text-[var(--theme-textPrimary)] hover:border-[var(--theme-borderStrong)] focus:border-[var(--theme-borderStrong)] focus:ring-[var(--theme-focusRing)]"]]),"aria-label":n.ariaLabel||void 0,disabled:e.disabled,onClick:ne,onKeydown:[Gt(Qe(v,["prevent"]),["down"]),Gt(Qe(ne,["prevent"]),["enter"]),Gt(Qe(ne,["prevent"]),["space"])]},[i("div",Di,[Jt(U.$slots,"trigger",{selectedOption:d.value,open:c.value,loading:e.loading,disabled:e.disabled},()=>[i("div",Li,S(d.value?b(d.value):m.value),1)])]),i("div",{class:Se(["flex shrink-0 items-center gap-2",e.disabled?"text-[var(--theme-textMuted)] opacity-80":"theme-muted-text"])},[e.loading?(g(),Ce(a(Ht),{key:0,class:"h-4 w-4 animate-spin"})):me("",!0),ue(a(ko),{class:Se(["h-4 w-4 transition",c.value?"rotate-180":""])},null,8,["class"])],2)],42,Pi),(g(),Ce(os,{to:"body"},[c.value?(g(),x("div",{key:0,ref_key:"panelRef",ref:l,class:"workbench-select-panel theme-popover fixed z-[90] flex overflow-hidden rounded-sm border",style:kn(w.value)},[i("div",Bi,[Jt(U.$slots,"header",{loading:e.loading,options:e.options}),i("div",Mi,[e.options.length?(g(!0),x(et,{key:0},ut(e.options,A=>Jt(U.$slots,"option",{key:String(e.getOptionValue(A)??""),option:A,selected:String(e.getOptionValue(A)??"")===String(e.modelValue??""),select:()=>y(A)},()=>[i("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:G=>y(A)},S(b(A)),9,Ri)])),128)):Jt(U.$slots,"empty",{key:1},()=>[i("div",Ni,S(f.value),1)])])])],4)):me("",!0)]))],512))}},qo={},Lr=typeof import.meta<"u"&&qo?qo:{};function Oi(){if(typeof window>"u")return"http://localhost:3000";const e=new URL(window.location.origin),t=String(Lr.VITE_API_PORT||"").trim();if(t)return e.port=t,e.toString().replace(/\/$/,"");const n=String(e.port||"");return new Set(["4173","5173","5174"]).has(n)?(e.port="3000",e.toString().replace(/\/$/,"")):e.toString().replace(/\/$/,"")}const Ao=(Lr.VITE_API_BASE_URL||Oi()).replace(/\/$/,"");function $o(e={},t="errors.requestFailed"){const n=String((e==null?void 0:e.messageKey)||"").trim();if(n){const o=We(n);if(o&&o!==n)return o}return(e==null?void 0:e.message)||We(t)}async function Ze(e,t={}){const n=typeof t.body<"u"&&!(t.body instanceof FormData),o=await fetch(`${Ao}${e}`,{headers:{...n?{"Content-Type":"application/json"}:{},...t.headers||{}},...t});if(!o.ok){const r=await o.json().catch(()=>({}));throw new Error($o(r))}return o.status===204?null:(o.headers.get("content-type")||"").includes("application/json")?o.json():o.text()}function Io(){return Ao}function xs(e){return e?e.startsWith("http")?e:`${Ao}${e}`:""}function py(){return Ze("/api/meta",{cache:"no-store"})}function ji(){return Ze("/api/tasks")}function Fi(e=30){const t=new URLSearchParams,n=Math.max(1,Number(e)||30);return t.set("limit",String(n)),Ze(`/api/tasks/workspace-diff-summaries?${t.toString()}`,{cache:"no-store"})}function Ui(e){return Ze("/api/tasks",{method:"POST",body:JSON.stringify(e)})}function Vi(e=[]){return Ze("/api/tasks/reorder",{method:"POST",body:JSON.stringify({slugs:e})})}function Br(e){return Ze(`/api/tasks/${e}`)}function Mr(e,t){return Ze(`/api/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)})}function zi(e){return Ze(`/api/tasks/${e}`,{method:"DELETE"})}const Rr=Io();async function Hi(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Rr}/api/uploads`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error($o(o,"errors.uploadFailed"))}return n.json()}async function qi(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Rr}/api/imports/pdf`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error($o(o,"errors.pdfImportFailed"))}return n.json()}function Ki(){return Ze("/api/codex/sessions")}function Wi(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim();n&&t.set("engine",n);const o=t.toString();return Ze(`/api/codex/workspaces${o?`?${o}`:""}`)}function my(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim(),o=String(e.cwd||"").trim(),s=Number(e.limit||0);n&&t.set("engine",n),o&&t.set("cwd",o),Number.isFinite(s)&&s>0&&t.set("limit",String(s));const r=t.toString();return Ze(`/api/codex/session-candidates${r?`?${r}`:""}`,{cache:"no-store",signal:e.signal})}function gy(e={}){const t=new URLSearchParams,n=String(e.path||"").trim(),o=Number(e.limit||0);n&&t.set("path",n),Number.isFinite(o)&&o>0&&t.set("limit",String(o));const s=t.toString();return Ze(`/api/codex/directories/tree${s?`?${s}`:""}`,{cache:"no-store",signal:e.signal})}function hy(e,t={}){const n=new URLSearchParams,o=String(e||"").trim(),s=String(t.path||"").trim(),r=Number(t.limit||0);o&&n.set("q",o),s&&n.set("path",s),Number.isFinite(r)&&r>0&&n.set("limit",String(r));const l=n.toString();return Ze(`/api/codex/directories/search${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function Gi(e){return Ze("/api/codex/sessions",{method:"POST",body:JSON.stringify(e)})}function Xi(e,t){return Ze(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function Yi(e){return Ze(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function Ji(e){return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/reset`,{method:"POST"})}function Qi(e,t={}){const n=new URLSearchParams,o=String(t.path||"").trim(),s=String(t.refreshToken||"").trim();o&&n.set("path",o),s&&n.set("_",s);const r=n.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/tree${r?`?${r}`:""}`,{cache:"no-store",signal:t.signal})}function Zi(e,t,n={}){const o=new URLSearchParams,s=String(t||"").trim(),r=Number(n.limit||60),l=String(n.refreshToken||"").trim();s&&o.set("q",s),Number.isFinite(r)&&r>0&&o.set("limit",String(r)),l&&o.set("_",l);const c=o.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/search${c?`?${c}`:""}`,{cache:"no-store",signal:n.signal})}function el(e,t={}){const n=new URLSearchParams,o=String(t.path||"").trim(),s=Number(t.limit||0),r=String(t.refreshToken||"").trim();o&&n.set("path",o),Number.isFinite(s)&&s>0&&n.set("limit",String(s)),r&&n.set("_",r);const l=n.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/content${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function tl(e,t,n={}){const o=new URLSearchParams,s=String(t||"").trim(),r=Number(n.limit||80),l=String(n.refreshToken||"").trim();s&&o.set("q",s),Number.isFinite(r)&&r>0&&o.set("limit",String(r)),l&&o.set("_",l);const c=o.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/content-search${c?`?${c}`:""}`,{cache:"no-store",signal:n.signal})}function nl(e,t){return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-session`,{method:"POST",body:JSON.stringify({sessionId:t})})}function sl(e,t={}){const n=new URLSearchParams,o=Number(t.limit||20),s=oi(t.events,t);Number.isFinite(o)&&o>0&&n.set("limit",String(o)),n.set("events",s);const r=n.toString();return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-runs${r?`?${r}`:""}`,{cache:"no-store"})}function ol(e,t={}){const n=new URLSearchParams,o=Math.max(0,Number(t.afterSeq)||0),s=Math.max(1,Number(t.limit)||5e3);o>0&&n.set("afterSeq",String(o)),s>0&&n.set("limit",String(s));const r=n.toString();return Ze(`/api/codex/runs/${encodeURIComponent(e)}/events${r?`?${r}`:""}`,{cache:"no-store"})}function vy(e,t={}){const n=new URLSearchParams,o=String(t.scope||"workspace").trim(),s=String(t.runId||"").trim(),r=String(t.filePath||"").trim(),l=t.includeFiles!==!1,c=t.includeStats!==!1;o==="run"?n.set("scope","run"):o==="task"?n.set("scope","task"):n.set("scope","workspace"),s&&n.set("runId",s),r&&n.set("filePath",r),l||n.set("includeFiles","false"),c||n.set("includeStats","false");const p=n.toString();return Ze(`/api/tasks/${encodeURIComponent(e)}/git-diff${p?`?${p}`:""}`,{cache:"no-store"})}function rl(e,t){return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"POST",body:JSON.stringify(t)})}function al(e){return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"DELETE"})}function il(e){return Ze(`/api/codex/runs/${encodeURIComponent(e)}/stop`,{method:"POST"})}const ll={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ul={class:"theme-muted-text mt-1 text-xs"},cl={class:"min-h-0 flex flex-1 flex-col overflow-hidden sm:flex-row"},dl={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},fl={key:0,class:"theme-muted-text flex items-center gap-2 py-4 text-sm"},pl={key:1,class:"space-y-4"},ml={key:0,class:"space-y-4"},gl={class:"theme-heading text-base font-medium"},hl={class:"theme-muted-text mt-1 text-xs leading-5"},vl={class:"settings-section-card px-4 py-4"},yl={class:"block space-y-1.5"},Sl={class:"theme-muted-text text-xs"},wl=["placeholder"],xl={key:1,class:"space-y-4"},bl={class:"flex items-start justify-between gap-3"},kl={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},_l={class:"theme-muted-text mt-1 text-xs leading-5"},Tl={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Cl={class:"settings-section-card px-4 py-4"},El={class:"grid gap-4 sm:grid-cols-2"},Al={class:"space-y-1.5 sm:col-span-2"},$l={class:"theme-muted-text text-xs"},Il={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Pl={class:"space-y-1.5"},Dl={class:"theme-muted-text text-xs"},Ll=["disabled"],Bl={key:0,class:"space-y-1.5"},Ml={class:"theme-muted-text text-xs"},Rl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Nl={class:"space-y-1.5"},Ol={class:"theme-muted-text text-xs"},jl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Fl={class:"theme-muted-text text-xs"},Ul={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Vl={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},zl={key:2,class:"space-y-4"},Hl={class:"flex items-start justify-between gap-3"},ql={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Kl={class:"theme-muted-text mt-1 text-xs leading-5"},Wl={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Gl={class:"settings-section-card px-4 py-4"},Xl={class:"grid gap-4 sm:grid-cols-2"},Yl={class:"space-y-1.5"},Jl={class:"theme-muted-text text-xs"},Ql={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Zl={class:"space-y-1.5"},eu={class:"theme-muted-text text-xs"},tu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},nu={class:"space-y-1.5 sm:col-span-2"},su={class:"theme-muted-text text-xs"},ou=["placeholder","disabled"],ru={class:"space-y-1.5"},au={class:"theme-muted-text text-xs"},iu=["placeholder","disabled"],lu={class:"space-y-1.5"},uu={class:"theme-muted-text text-xs"},cu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},du={class:"space-y-1.5"},fu={class:"theme-muted-text text-xs"},pu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},mu={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},gu={key:0,class:"theme-danger-text"},hu={key:3,class:"theme-danger-text text-sm"},vu={class:"theme-divider flex flex-col gap-3 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-between"},yu={class:"theme-muted-text theme-note-text"},Su={class:"flex items-center justify-end gap-2"},wu=["disabled"],xu=["disabled"],bu="0 9 * * 1-5",Qs="weekdays",Wn="09:00",An="1",ku={__name:"EditTaskDialog",props:{open:{type:Boolean,default:!1},taskSlug:{type:String,default:""},taskTitle:{type:String,default:""}},emits:["close","saved"],setup(e,{emit:t}){const n=e,o=t,{locale:s,t:r}=St(),l=q(!1),c=q(!1),p=q(""),w=q("basic"),d=rs({title:"",automationEnabled:!1,automationMode:Qs,automationTime:Wn,automationWeekday:An,automationTimezone:"local",automationConcurrencyPolicy:"skip",automationLastTriggeredAt:"",automationNextTriggerAt:"",notificationEnabled:!1,notificationChannelType:"dingtalk",notificationWebhookUrl:"",notificationSecret:"",notificationTriggerOn:"completed",notificationLocale:"zh-CN",notificationMessageMode:"summary",notificationLastStatus:"",notificationLastError:"",notificationLastSentAt:""}),m=W(()=>String(n.taskTitle||"").trim()||r("workbench.untitledTask")),f=W(()=>[{id:"basic",label:r("taskDialog.sections.basic.label"),description:r("taskDialog.sections.basic.description"),icon:Zn},{id:"automation",label:r("taskDialog.sections.automation.label"),description:r("taskDialog.sections.automation.description"),icon:Is},{id:"notification",label:r("taskDialog.sections.notification.label"),description:r("taskDialog.sections.notification.description"),icon:Fo}]),b=W(()=>[{value:"daily",label:r("taskDialog.sections.automation.modeDaily")},{value:"weekdays",label:r("taskDialog.sections.automation.modeWeekdays")},{value:"weekly",label:r("taskDialog.sections.automation.modeWeekly")}]),v=W(()=>[{value:"1",label:r("taskDialog.sections.automation.weekday1")},{value:"2",label:r("taskDialog.sections.automation.weekday2")},{value:"3",label:r("taskDialog.sections.automation.weekday3")},{value:"4",label:r("taskDialog.sections.automation.weekday4")},{value:"5",label:r("taskDialog.sections.automation.weekday5")},{value:"6",label:r("taskDialog.sections.automation.weekday6")},{value:"0",label:r("taskDialog.sections.automation.weekday0")}]),P=W(()=>ai.map(_=>({..._,label:_.value==="local"?r("taskDialog.sections.automation.timezoneLocal"):_.label}))),ne=W(()=>li.map(_=>({..._,label:_.value==="skip"?r("taskDialog.sections.automation.concurrencySkip"):_.label}))),y=W(()=>ui.map(_=>({..._,label:_.value==="dingtalk"?r("taskDialog.sections.notification.channelDingtalk"):_.value==="feishu"?r("taskDialog.sections.notification.channelFeishu"):_.value==="webhook"?r("taskDialog.sections.notification.channelWebhook"):_.label}))),L=W(()=>ci.map(_=>({..._,label:_.value==="completed"?r("taskDialog.sections.notification.triggerCompleted"):_.value==="success"?r("taskDialog.sections.notification.triggerSuccess"):_.value==="error"?r("taskDialog.sections.notification.triggerError"):_.label}))),O=W(()=>fi.map(_=>({..._,label:_.value==="summary"?r("taskDialog.sections.notification.messageSummary"):_.label}))),z=W(()=>pi.map(_=>({..._,label:_.value==="zh-CN"?r("taskDialog.sections.notification.localeZhCn"):_.value==="en-US"?r("taskDialog.sections.notification.localeEnUs"):_.label}))),U=W(()=>d.notificationEnabled?d.notificationLastStatus==="success"?r("taskDialog.sections.notification.statusSuccess"):d.notificationLastStatus==="error"?r("taskDialog.sections.notification.statusError"):r("taskDialog.sections.notification.statusPending"):r("taskDialog.sections.notification.statusDisabled"));function se(){d.title="",d.automationEnabled=!1,d.automationMode=Qs,d.automationTime=Wn,d.automationWeekday=An,d.automationTimezone="local",d.automationConcurrencyPolicy="skip",d.automationLastTriggeredAt="",d.automationNextTriggerAt="",d.notificationEnabled=!1,d.notificationChannelType="dingtalk",d.notificationWebhookUrl="",d.notificationSecret="",d.notificationTriggerOn="completed",d.notificationLocale=String(s.value||"zh-CN"),d.notificationMessageMode="summary",d.notificationLastStatus="",d.notificationLastError="",d.notificationLastSentAt=""}function A(_=0){return String(_).padStart(2,"0")}function G(_=""){const H=String(_||"").trim().replace(/\s+/g," ");let F=H.match(/^(\d{1,2}) (\d{1,2}) \* \* 1-5$/);return F?{mode:"weekdays",time:`${A(F[2])}:${A(F[1])}`,weekday:An}:(F=H.match(/^(\d{1,2}) (\d{1,2}) \* \* \*$/),F?{mode:"daily",time:`${A(F[2])}:${A(F[1])}`,weekday:An}:(F=H.match(/^(\d{1,2}) (\d{1,2}) \* \* ([0-6])$/),F?{mode:"weekly",time:`${A(F[2])}:${A(F[1])}`,weekday:String(F[3])}:{mode:Qs,time:Wn,weekday:An}))}function ce(_=""){const F=String(_||"").trim().match(/^(\d{1,2}):(\d{2})$/);if(!F)return Wn;const He=Number(F[1]),De=Number(F[2]);return!Number.isInteger(He)||!Number.isInteger(De)||He<0||He>23||De<0||De>59?Wn:`${A(He)}:${A(De)}`}function pe(){var Fe;const _=ce(d.automationTime),[H,F]=_.split(":"),He=Number(H),De=Number(F);if(d.automationMode==="daily")return`${De} ${He} * * *`;if(d.automationMode==="weekly"){const je=((Fe=v.value.find(Ke=>Ke.value===String(d.automationWeekday||"")))==null?void 0:Fe.value)||An;return`${De} ${He} * * ${je}`}return`${De} ${He} * * 1-5`}function I(_={}){var F,He,De,Fe,je,Ke,tt,xe,R,J,fe,_e,ge,Ie,Ae,Be;d.title=String(_.title||""),d.automationEnabled=!!((F=_.automation)!=null&&F.enabled);const H=G(((He=_.automation)==null?void 0:He.cron)||bu);d.automationMode=H.mode,d.automationTime=H.time,d.automationWeekday=H.weekday,d.automationTimezone=String(((De=_.automation)==null?void 0:De.timezone)||"local"),d.automationConcurrencyPolicy=String(((Fe=_.automation)==null?void 0:Fe.concurrencyPolicy)||"skip"),d.automationLastTriggeredAt=String(((je=_.automation)==null?void 0:je.lastTriggeredAt)||""),d.automationNextTriggerAt=String(((Ke=_.automation)==null?void 0:Ke.nextTriggerAt)||""),d.notificationEnabled=!!((tt=_.notification)!=null&&tt.enabled),d.notificationChannelType=String(((xe=_.notification)==null?void 0:xe.channelType)||"dingtalk"),d.notificationWebhookUrl=String(((R=_.notification)==null?void 0:R.webhookUrl)||""),d.notificationSecret=String(((J=_.notification)==null?void 0:J.secret)||""),d.notificationTriggerOn=String(((fe=_.notification)==null?void 0:fe.triggerOn)||"completed"),d.notificationLocale=String(((_e=_.notification)==null?void 0:_e.locale)||s.value||"zh-CN"),d.notificationMessageMode=String(((ge=_.notification)==null?void 0:ge.messageMode)||"summary"),d.notificationLastStatus=String(((Ie=_.notification)==null?void 0:Ie.lastStatus)||""),d.notificationLastError=String(((Ae=_.notification)==null?void 0:Ae.lastError)||""),d.notificationLastSentAt=String(((Be=_.notification)==null?void 0:Be.lastSentAt)||"")}async function Q(){const _=String(n.taskSlug||"").trim();if(!_){se();return}l.value=!0,p.value="";try{const H=await Br(_);I(H)}catch(H){p.value=(H==null?void 0:H.message)||r("taskDialog.loadFailed")}finally{l.value=!1}}function le(){return{title:d.title,automation:{enabled:d.automationEnabled,cron:pe(),timezone:d.automationTimezone,concurrencyPolicy:d.automationConcurrencyPolicy},notification:{enabled:d.notificationEnabled,channelType:d.notificationChannelType,webhookUrl:d.notificationWebhookUrl,secret:d.notificationSecret,triggerOn:d.notificationTriggerOn,locale:d.notificationLocale,messageMode:d.notificationMessageMode}}}async function ie(){const _=String(n.taskSlug||"").trim();if(!(!_||l.value||c.value)){c.value=!0,p.value="";try{const H=await Mr(_,le());I(H),o("saved",H),o("close")}catch(H){p.value=(H==null?void 0:H.message)||r("taskDialog.saveFailed")}finally{c.value=!1}}}function ve(_=""){if(!_)return r("common.notAvailable");const H=new Date(_);return Number.isNaN(H.getTime())?r("common.notAvailable"):xr(H.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return $e(()=>n.open,_=>{if(_){w.value="basic",Q();return}},{immediate:!0}),$e(()=>n.taskSlug,()=>{n.open&&Q()}),(_,H)=>(g(),Ce(Fs,{open:e.open,"stack-level":3,"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 overflow-hidden",onClose:H[16]||(H[16]=F=>o("close"))},{title:Je(()=>[i("div",null,[i("div",ll,[ue(a(Zn),{class:"h-4 w-4"}),i("span",null,S(a(r)("taskDialog.title")),1)]),i("p",ul,S(a(r)("taskDialog.currentTask",{title:m.value})),1)])]),default:Je(()=>[i("div",cl,[ue(Ii,{modelValue:w.value,"onUpdate:modelValue":H[0]||(H[0]=F=>w.value=F),sections:f.value},null,8,["modelValue","sections"]),i("div",dl,[l.value?(g(),x("div",fl,[ue(a(Ht),{class:"h-4 w-4 animate-spin"}),i("span",null,S(a(r)("taskDialog.loading")),1)])):(g(),x("div",pl,[w.value==="basic"?(g(),x("section",ml,[i("div",null,[i("div",gl,S(a(r)("taskDialog.sections.basic.title")),1),i("p",hl,S(a(r)("taskDialog.sections.basic.intro")),1)]),i("section",vl,[i("label",yl,[i("span",Sl,S(a(r)("taskDialog.sections.basic.taskTitle")),1),Wt(i("input",{"onUpdate:modelValue":H[1]||(H[1]=F=>d.title=F),type:"text",maxlength:"140",class:"tool-input",placeholder:a(r)("taskDialog.sections.basic.taskTitlePlaceholder")},null,8,wl),[[Xn,d.title]])])])])):w.value==="automation"?(g(),x("section",xl,[i("div",bl,[i("div",null,[i("div",kl,[ue(a(Is),{class:"h-4 w-4"}),i("span",null,S(a(r)("taskDialog.sections.automation.title")),1)]),i("p",_l,S(a(r)("taskDialog.sections.automation.intro")),1)]),i("label",Tl,[Wt(i("input",{"onUpdate:modelValue":H[2]||(H[2]=F=>d.automationEnabled=F),type:"checkbox",class:"h-4 w-4"},null,512),[[jo,d.automationEnabled]]),i("span",null,S(a(r)("taskDialog.enabled")),1)])]),i("section",Cl,[i("div",El,[i("label",Al,[i("span",$l,S(a(r)("taskDialog.sections.automation.mode")),1),ue(en,{modelValue:d.automationMode,"onUpdate:modelValue":H[3]||(H[3]=F=>d.automationMode=F),options:b.value,disabled:!d.automationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",Il,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Pl,[i("span",Dl,S(a(r)("taskDialog.sections.automation.time")),1),Wt(i("input",{"onUpdate:modelValue":H[4]||(H[4]=F=>d.automationTime=F),type:"time",class:"tool-input",disabled:!d.automationEnabled},null,8,Ll),[[Xn,d.automationTime]])]),d.automationMode==="weekly"?(g(),x("label",Bl,[i("span",Ml,S(a(r)("taskDialog.sections.automation.weekday")),1),ue(en,{modelValue:d.automationWeekday,"onUpdate:modelValue":H[5]||(H[5]=F=>d.automationWeekday=F),options:v.value,disabled:!d.automationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",Rl,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])):me("",!0),i("label",Nl,[i("span",Ol,S(a(r)("taskDialog.sections.automation.timezone")),1),ue(en,{modelValue:d.automationTimezone,"onUpdate:modelValue":H[6]||(H[6]=F=>d.automationTimezone=F),options:P.value,disabled:!d.automationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",jl,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",{class:Se(["space-y-1.5",d.automationMode==="weekly"?"":"sm:col-span-2"])},[i("span",Fl,S(a(r)("taskDialog.sections.automation.concurrencyPolicy")),1),ue(en,{modelValue:d.automationConcurrencyPolicy,"onUpdate:modelValue":H[7]||(H[7]=F=>d.automationConcurrencyPolicy=F),options:ne.value,disabled:!d.automationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",Ul,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])],2)]),i("div",Vl,[i("p",null,S(a(r)("taskDialog.sections.automation.lastTriggered",{value:ve(d.automationLastTriggeredAt)})),1),i("p",null,S(a(r)("taskDialog.sections.automation.nextTriggered",{value:ve(d.automationNextTriggerAt)})),1)])])])):(g(),x("section",zl,[i("div",Hl,[i("div",null,[i("div",ql,[ue(a(Fo),{class:"h-4 w-4"}),i("span",null,S(a(r)("taskDialog.sections.notification.title")),1)]),i("p",Kl,S(a(r)("taskDialog.sections.notification.intro")),1)]),i("label",Wl,[Wt(i("input",{"onUpdate:modelValue":H[8]||(H[8]=F=>d.notificationEnabled=F),type:"checkbox",class:"h-4 w-4"},null,512),[[jo,d.notificationEnabled]]),i("span",null,S(a(r)("taskDialog.enabled")),1)])]),i("section",Gl,[i("div",Xl,[i("label",Yl,[i("span",Jl,S(a(r)("taskDialog.sections.notification.channelType")),1),ue(en,{modelValue:d.notificationChannelType,"onUpdate:modelValue":H[9]||(H[9]=F=>d.notificationChannelType=F),options:y.value,disabled:!d.notificationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",Ql,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Zl,[i("span",eu,S(a(r)("taskDialog.sections.notification.triggerOn")),1),ue(en,{modelValue:d.notificationTriggerOn,"onUpdate:modelValue":H[10]||(H[10]=F=>d.notificationTriggerOn=F),options:L.value,disabled:!d.notificationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",tu,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",nu,[i("span",su,S(a(r)("taskDialog.sections.notification.webhookUrl")),1),Wt(i("input",{"onUpdate:modelValue":H[11]||(H[11]=F=>d.notificationWebhookUrl=F),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.webhookUrlPlaceholder"),disabled:!d.notificationEnabled},null,8,ou),[[Xn,d.notificationWebhookUrl]])]),i("label",ru,[i("span",au,S(a(r)("taskDialog.sections.notification.secret")),1),Wt(i("input",{"onUpdate:modelValue":H[12]||(H[12]=F=>d.notificationSecret=F),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.secretPlaceholder"),disabled:!d.notificationEnabled},null,8,iu),[[Xn,d.notificationSecret]])]),i("label",lu,[i("span",uu,S(a(r)("taskDialog.sections.notification.locale")),1),ue(en,{modelValue:d.notificationLocale,"onUpdate:modelValue":H[13]||(H[13]=F=>d.notificationLocale=F),options:z.value,disabled:!d.notificationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",cu,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",du,[i("span",fu,S(a(r)("taskDialog.sections.notification.messageMode")),1),ue(en,{modelValue:d.notificationMessageMode,"onUpdate:modelValue":H[14]||(H[14]=F=>d.notificationMessageMode=F),options:O.value,disabled:!d.notificationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",pu,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])]),i("div",mu,[i("p",null,S(a(r)("taskDialog.sections.notification.status",{value:U.value})),1),i("p",null,S(a(r)("taskDialog.sections.notification.lastSent",{value:ve(d.notificationLastSentAt)})),1),d.notificationLastError?(g(),x("p",gu,S(a(r)("taskDialog.sections.notification.lastError",{value:d.notificationLastError})),1)):me("",!0)])])])),p.value?(g(),x("p",hu,S(p.value),1)):me("",!0)]))])]),i("div",vu,[i("p",yu,S(a(r)("taskDialog.footerHint")),1),i("div",Su,[i("button",{type:"button",class:"tool-button px-3 py-2 text-sm",disabled:c.value,onClick:H[15]||(H[15]=F=>o("close"))},S(a(r)("common.cancel")),9,wu),i("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-sm",disabled:c.value||l.value,onClick:ie},[c.value?(g(),Ce(a(Ht),{key:0,class:"h-4 w-4 animate-spin"})):(g(),Ce(a(Aa),{key:1,class:"h-4 w-4"})),i("span",null,S(c.value?a(r)("common.saving"):a(r)("taskDialog.saveTaskConfig")),1)],8,xu)])])]),_:1},8,["open"]))}};function _u(e=[]){return(Array.isArray(e)&&e.length?e:Eo).filter(n=>n&&typeof n=="object").map(n=>{const o=Ls(n.value);return{...n,value:o,label:String(n.label||ct(o)).trim()||ct(o),enabled:n.enabled!==!1,available:n.available!==!1}})}function Tu(e=[]){return _u(e).filter(t=>t.enabled&&t.available)}async function yy(){const e=await Ze("/api/meta",{cache:"no-store"});return Tu(e==null?void 0:e.agentEngineOptions)}function Nr(e={},t={}){const{defaultLabel:n="默认",prefix:o=""}=t,s=ct(e==null?void 0:e.engine),r=`${String(o||"")}${s}`;return e!=null&&e.isDefault?`${r} · ${n}`:r}const Cu={key:0,class:"flex items-center gap-2 text-sm"},Eu={class:"min-w-0 flex-1 truncate"},Au={class:"theme-muted-text ml-2 hidden font-mono text-[11px] sm:inline"},$u={class:"theme-status-neutral hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex"},Iu={key:1,class:"theme-muted-text text-sm"},Pu={class:"theme-divider theme-muted-text flex items-center justify-between gap-3 border-b border-dashed px-3 py-2 text-[11px]"},Du=["onClick"],Lu={class:"flex items-center gap-3"},Bu={class:"min-w-0 flex-1"},Mu={class:"flex items-center gap-2 text-sm sm:hidden"},Ru={class:"min-w-0 flex-1 truncate font-medium text-[var(--theme-textPrimary)]"},Nu={class:"hidden items-center gap-2 text-sm sm:flex"},Ou={class:"min-w-0 flex-1 truncate"},ju={class:"font-medium text-[var(--theme-textPrimary)]"},Fu={class:"theme-muted-text ml-2 font-mono text-[11px]"},Uu={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Vu={__name:"CodexSessionSelect",props:{modelValue:{type:String,default:""},sessions:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","refresh-intent"],setup(e,{emit:t}){const n=t,{t:o}=St();function s(d){return(d==null?void 0:d.title)||o("projectManager.untitledProject")}function r(d){return(d==null?void 0:d.cwd)||o("projectManager.notSet")}function l(d){return d!=null&&d.running?o("projectManager.running"):o("projectManager.idle")}function c(d){return d!=null&&d.running?"theme-status-warning":"theme-status-success"}function p(d){var f;const m=Math.max(0,Number((f=d==null?void 0:d.agentBindings)==null?void 0:f.length)||0);return m>1?o("projectManager.agentCount",{count:m}):ct(d==null?void 0:d.engine)}function w(d){return d?"theme-filter-active":"theme-filter-idle"}return(d,m)=>(g(),Ce(en,{"model-value":e.modelValue,options:e.sessions,loading:e.loading,disabled:e.disabled,"trigger-class":"h-9",placeholder:a(o)("projectManager.selectProject"),"empty-text":a(o)("projectManager.noProjectsInSelect"),"get-option-value":f=>(f==null?void 0:f.id)||"","onUpdate:modelValue":m[0]||(m[0]=f=>n("update:modelValue",f)),onRefreshIntent:m[1]||(m[1]=f=>n("refresh-intent"))},{trigger:Je(({selectedOption:f,disabled:b})=>[f?(g(),x("div",Cu,[i("span",Eu,[i("span",{class:Se(["font-medium",b?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},S(s(f)),3),i("span",Au,S(r(f)),1)]),i("span",$u,S(p(f)),1),i("span",{class:Se(["hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex",c(f)])},S(l(f)),3)])):(g(),x("div",Iu,S(e.loading?a(o)("projectManager.syncingProjects"):a(o)("projectManager.selectProject")),1))]),header:Je(()=>[i("div",Pu,[i("span",null,S(e.loading?a(o)("projectManager.syncingLatestProjects"):a(o)("projectManager.projectCount",{count:e.sessions.length})),1),e.loading?(g(),Ce(a(Ht),{key:0,class:"h-3.5 w-3.5 animate-spin"})):me("",!0)])]),option:Je(({option:f,selected:b,select:v})=>[i("button",{type:"button",class:Se(["w-full rounded-sm border border-dashed p-3 text-left transition",w(b)]),onClick:v},[i("div",Lu,[i("div",Bu,[i("div",Mu,[i("span",Ru,S(s(f)),1)]),i("div",Nu,[i("span",Ou,[i("span",ju,S(s(f)),1),i("span",Fu,S(r(f)),1)]),i("span",Uu,S(p(f)),1),i("span",{class:Se(["inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",c(f)])},S(l(f)),3)])]),b?(g(),Ce(a(Cr),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):me("",!0)])],10,Du)]),_:1},8,["model-value","options","loading","disabled","placeholder","empty-text","get-option-value"]))}},zu=["disabled"],Hu=["disabled"],qu=["src","alt"],Or={__name:"ImagePreviewOverlay",props:{modelValue:{type:String,default:""},images:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=q(1),l=W(()=>n.images.map(y=>String(y||"").trim()).filter(Boolean)),c=W(()=>l.value.findIndex(y=>y===n.modelValue)),p=W(()=>c.value>=0?l.value[c.value]:"");function w(){o("update:modelValue",""),r.value=1}function d(y){o("update:modelValue",String(y||"").trim()),r.value=1}function m(){c.value<=0||d(l.value[c.value-1])}function f(){c.value<0||c.value>=l.value.length-1||d(l.value[c.value+1])}function b(y){const L=Math.min(3,Math.max(.5,r.value+y));r.value=Math.round(L*100)/100}function v(){r.value=1}function P(y){p.value&&(y.preventDefault(),b(y.deltaY<0?.1:-.1))}function ne(y){if(p.value){if(y.key==="Escape"){y.preventDefault(),w();return}if(y.key==="ArrowLeft"){y.preventDefault(),m();return}if(y.key==="ArrowRight"){y.preventDefault(),f();return}if(y.key==="+"||y.key==="="){y.preventDefault(),b(.1);return}if(y.key==="-"){y.preventDefault(),b(-.1);return}y.key==="0"&&(y.preventDefault(),v())}}return $e(()=>n.modelValue,y=>{y||(r.value=1)}),$e(l,y=>{if(n.modelValue){if(!y.length){w();return}if(!y.includes(n.modelValue)){const L=Math.min(c.value,y.length-1);d(y[L]||y[0])}}},{immediate:!0}),dn(()=>{window.addEventListener("keydown",ne)}),It(()=>{window.removeEventListener("keydown",ne)}),(y,L)=>(g(),Ce(os,{to:"body"},[p.value?(g(),x("div",{key:0,class:"theme-modal-backdrop image-preview-overlay fixed inset-0 z-50 flex items-center justify-center p-6",onClick:w,onWheel:P},[i("div",{class:"absolute left-4 top-4 flex items-center gap-2",onClick:L[2]||(L[2]=Qe(()=>{},["stop"]))},[i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:L[0]||(L[0]=O=>b(-.1))},S(a(s)("imagePreview.zoomOut")),1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:v},S(Math.round(r.value*100))+"% ",1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:L[1]||(L[1]=O=>b(.1))},S(a(s)("imagePreview.zoomIn")),1)]),i("div",{class:"absolute right-4 top-4 flex items-center gap-2",onClick:L[3]||(L[3]=Qe(()=>{},["stop"]))},[i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition disabled:cursor-not-allowed disabled:opacity-40",disabled:c.value<=0,onClick:m},S(a(s)("imagePreview.previous")),9,zu),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition disabled:cursor-not-allowed disabled:opacity-40",disabled:c.value<0||c.value>=l.value.length-1,onClick:f},S(a(s)("imagePreview.next")),9,Hu),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:w},S(a(s)("imagePreview.close")),1)]),i("img",{src:p.value,alt:a(s)("imagePreview.alt"),class:"image-preview-overlay__image max-h-[90vh] max-w-[90vw] object-contain shadow-2xl transition-transform",style:kn({transform:`scale(${r.value})`}),onClick:L[4]||(L[4]=Qe(()=>{},["stop"]))},null,12,qu)],32)):me("",!0)]))}};let Zs=null;const Sy={maxLines:2e3,maxChars:2e5},eo={maxLines:2e3,maxChars:2e5},Ku={"github-dark-default":()=>ze(()=>import("./vendor-shiki-theme-github-dark-default-DBX58552.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),"github-light":()=>ze(()=>import("./vendor-shiki-theme-github-light-RLAvZv0q.js"),__vite__mapDeps([4,1,2,3])).then(e=>e.default)},Wu={bash:()=>ze(()=>import("./vendor-shiki-lang-bash-zsQu0xn-.js"),__vite__mapDeps([5,1,2,3])).then(e=>e.default),c:()=>ze(()=>import("./vendor-shiki-lang-c-BDF8vgks.js"),__vite__mapDeps([6,1,2,3])).then(e=>e.default),cpp:()=>ze(()=>import("./vendor-shiki-lang-cpp-DyDAaXl6.js"),__vite__mapDeps([7,1,2,3])).then(e=>e.default),csharp:()=>ze(()=>import("./vendor-shiki-lang-csharp-BWfTXJXw.js"),__vite__mapDeps([8,1,2,3])).then(e=>e.default),css:()=>ze(()=>import("./vendor-shiki-lang-css-DbAm1fUO.js"),__vite__mapDeps([9,1,2,3])).then(e=>e.default),diff:()=>ze(()=>import("./vendor-shiki-lang-diff-DmGC1G26.js"),__vite__mapDeps([10,1,2,3])).then(e=>e.default),dockerfile:()=>ze(()=>import("./vendor-shiki-lang-dockerfile-3x-8396r.js"),__vite__mapDeps([11,1,2,3])).then(e=>e.default),dotenv:()=>ze(()=>import("./vendor-shiki-lang-dotenv--IVOlX2Q.js"),__vite__mapDeps([12,1,2,3])).then(e=>e.default),fish:()=>ze(()=>import("./vendor-shiki-lang-fish-Bpv3hhJP.js"),__vite__mapDeps([13,1,2,3])).then(e=>e.default),go:()=>ze(()=>import("./vendor-shiki-lang-go-CIGC59jP.js"),__vite__mapDeps([14,1,2,3])).then(e=>e.default),html:()=>ze(()=>import("./vendor-shiki-lang-html-Bt_TLLZN.js"),__vite__mapDeps([15,1,2,3])).then(e=>e.default),ini:()=>ze(()=>import("./vendor-shiki-lang-ini-BIllfys4.js"),__vite__mapDeps([16,1,2,3])).then(e=>e.default),java:()=>ze(()=>import("./vendor-shiki-lang-java-CXxu9crF.js"),__vite__mapDeps([17,1,2,3])).then(e=>e.default),javascript:()=>ze(()=>import("./vendor-shiki-lang-javascript-Cha7GNZm.js"),__vite__mapDeps([18,1,2,3])).then(e=>e.default),json:()=>ze(()=>import("./vendor-shiki-lang-json-CCZCjDUh.js"),__vite__mapDeps([19,1,2,3])).then(e=>e.default),less:()=>ze(()=>import("./vendor-shiki-lang-less-DAToytC5.js"),__vite__mapDeps([20,1,2,3])).then(e=>e.default),markdown:()=>ze(()=>import("./vendor-shiki-lang-markdown-C6lwMXFp.js"),__vite__mapDeps([21,1,2,3])).then(e=>e.default),python:()=>ze(()=>import("./vendor-shiki-lang-python-Bi9rmtY7.js"),__vite__mapDeps([22,1,2,3])).then(e=>e.default),powershell:()=>ze(()=>import("./vendor-shiki-lang-powershell-lrpuM0ez.js"),__vite__mapDeps([23,1,2,3])).then(e=>e.default),rust:()=>ze(()=>import("./vendor-shiki-lang-rust-GTGDbY6A.js"),__vite__mapDeps([24,1,2,3])).then(e=>e.default),sass:()=>ze(()=>import("./vendor-shiki-lang-sass-DFtHupN8.js"),__vite__mapDeps([25,1,2,3])).then(e=>e.default),scss:()=>ze(()=>import("./vendor-shiki-lang-scss-BrfBNyyi.js"),__vite__mapDeps([26,1,2,3])).then(e=>e.default),sql:()=>ze(()=>import("./vendor-shiki-lang-sql-H6--iFN-.js"),__vite__mapDeps([27,1,2,3])).then(e=>e.default),toml:()=>ze(()=>import("./vendor-shiki-lang-toml-aTteTWYL.js"),__vite__mapDeps([28,1,2,3])).then(e=>e.default),tsx:()=>ze(()=>import("./vendor-shiki-lang-tsx-DoKZm6AV.js"),__vite__mapDeps([29,1,2,3])).then(e=>e.default),typescript:()=>ze(()=>import("./vendor-shiki-lang-typescript-B5awnqri.js"),__vite__mapDeps([30,1,2,3])).then(e=>e.default),vue:()=>ze(()=>import("./vendor-shiki-lang-vue-CnrgQ7Z5.js"),__vite__mapDeps([31,1,2,3])).then(e=>e.default),xml:()=>ze(()=>import("./vendor-shiki-lang-xml-Bv-TNPJt.js"),__vite__mapDeps([32,1,2,3])).then(e=>e.default),yaml:()=>ze(()=>import("./vendor-shiki-lang-yaml-DpxUxQ6M.js"),__vite__mapDeps([33,1,2,3])).then(e=>e.default)};function jr(e=0){return Number(e)>9999?"3.4rem":"2.6rem"}function Po(e=[]){const t=Array.isArray(e)?e.map(o=>String(o??"")):[],n=t.reduce((o,s)=>o+s.length,0);return{lines:t,lineCount:t.length,charCount:n}}function Do(e={},t={}){const n=Number(t.maxHighlightLines||0),o=Number(t.maxHighlightChars||0);return n>0&&Number(e.lineCount||0)>n||o>0&&Number(e.charCount||0)>o}function Gu(e=[],t={}){const n=Po(e);return Do(n,{maxHighlightLines:t.maxLines,maxHighlightChars:t.maxChars})}function Xu(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
5
+ `).trim():Ss(e==null?void 0:e.prompt);if(!ti(s))return{mode:"",prompt:s,command:"",reason:""};if(o&&n.some(p=>String((p==null?void 0:p.type)||"").trim()!==zo))return{mode:"",prompt:s,command:"",reason:"unsupported_blocks"};const l=ni(s).slice(1).trim();return l?{mode:Za,prompt:s,command:l,reason:""}:{mode:"",prompt:s,command:"",reason:"empty_command"}}const Zt={NONE:"none",LATEST:"latest",ALL:"all"};function oi(e="",t={}){const n=String(e||"").trim().toLowerCase();return n===Zt.ALL?Zt.ALL:n===Zt.LATEST?Zt.LATEST:n===Zt.NONE?Zt.NONE:t.includeEvents?Zt.ALL:t.includeLatestEvents?Zt.LATEST:Zt.NONE}const Vt={SESSION:"session",SESSION_UPDATED:"session.updated",STATUS:"status",STDOUT:"stdout",STDERR:"stderr",AGENT_EVENT:"agent_event",COMPLETED:"completed",STOPPED:"stopped",ERROR:"error"};function Dr(e=""){const t=String(e||"").trim().toLowerCase();return t==="codex"?Vt.AGENT_EVENT:t}const vt={THREAD_STARTED:"thread.started",TURN_STARTED:"turn.started",TURN_COMPLETED:"turn.completed",TURN_FAILED:"turn.failed",ERROR:"error",ITEM_STARTED:"item.started",ITEM_UPDATED:"item.updated",ITEM_COMPLETED:"item.completed"},rt={REASONING:"reasoning",WEB_SEARCH:"web_search",COLLAB_TOOL_CALL:"collab_tool_call",FILE_CHANGE:"file_change",COMMAND_EXECUTION:"command_execution",TODO_LIST:"todo_list",AGENT_MESSAGE:"agent_message"},ri={none:{label:"不过期",hours:null}};Object.entries(ri).map(([e,t])=>({value:e,label:t.label}));const ws={CODEX:"codex",CLAUDE_CODE:"claude-code",OPENCODE:"opencode"},Eo=[{value:ws.CODEX,label:"Codex",enabled:!0},{value:ws.CLAUDE_CODE,label:"Claude Code",enabled:!0},{value:ws.OPENCODE,label:"OpenCode",enabled:!0}],$t={TEXT:"text",IMAGE:"image",IMPORTED_TEXT:"imported_text"},ai=[{value:"local",label:"跟随本机时区"}],ii={SKIP:"skip"},li=[{value:ii.SKIP,label:"已有运行时跳过本次"}],Ys={DINGTALK:"dingtalk",FEISHU:"feishu",WEBHOOK:"webhook"},ui=[{value:Ys.DINGTALK,label:"钉钉 Webhook"},{value:Ys.FEISHU,label:"飞书 Webhook"},{value:Ys.WEBHOOK,label:"通用 Webhook"}],Js={COMPLETED:"completed",SUCCESS:"success",ERROR:"error"},ci=[{value:Js.COMPLETED,label:"本次运行结束后"},{value:Js.SUCCESS,label:"本次运行成功后"},{value:Js.ERROR,label:"本次运行失败后"}],di={SUMMARY:"summary"},fi=[{value:di.SUMMARY,label:"摘要消息"}],Ho={ZH_CN:"zh-CN",EN_US:"en-US"},pi=[{value:Ho.ZH_CN,label:"简体中文"},{value:Ho.EN_US,label:"English"}];function Ls(e){var n;const t=String(e||"").trim().toLowerCase();return((n=Eo.find(o=>o.value===t))==null?void 0:n.value)||ws.CODEX}function ct(e){var t;return((t=Eo.find(n=>n.value===Ls(e)))==null?void 0:t.label)||"Codex"}function fy(e=""){const t=String(e||"").trim();if(!t)return"";const n=/^[a-z]:[\\/]/i.test(t)||t.includes("\\");let o=t.replace(/\\/g,"/");return o.length>1&&!/^[a-z]:\/$/i.test(o)&&(o=o.replace(/\/+$/,"")),n?o.toLowerCase():o}function mi(e=[],t=10){const n=e.find(o=>{var s;return(o.type===$t.TEXT||o.type===$t.IMPORTED_TEXT)&&((s=o.content)==null?void 0:s.trim())});return n?n.content.replace(/\s+/g," ").trim().slice(0,t):""}const gi={class:"min-w-0 flex-1"},hi={key:0,class:"flex items-center gap-2"},vi=["disabled"],Fs={__name:"DialogShell",props:{open:{type:Boolean,default:!1},backdropClass:{type:String,default:""},stackLevel:{type:Number,default:0},panelClass:{type:String,default:""},headerClass:{type:String,default:"px-4 py-4 sm:px-5"},bodyClass:{type:String,default:"min-h-0 flex-1"},showClose:{type:Boolean,default:!0},closeDisabled:{type:Boolean,default:!1},closeOnBackdrop:{type:Boolean,default:!0},closeOnEscape:{type:Boolean,default:!0},lockBodyScroll:{type:Boolean,default:!0}},emits:["close"],setup(e,{emit:t}){const n=e,o=t,s=W(()=>n.backdropClass?n.backdropClass:`${n.stackLevel>=4?"z-[90]":n.stackLevel===3?"z-[75]":n.stackLevel===2?"z-[70]":n.stackLevel===1?"z-[60]":"z-50"} items-end justify-center px-0 py-0 sm:items-center sm:px-4 sm:py-6`);function r(){n.closeDisabled||o("close")}function l(){!n.closeOnBackdrop||n.closeDisabled||o("close")}function c(p){!n.open||!n.closeOnEscape||n.closeDisabled||p.key==="Escape"&&o("close")}return $e(()=>n.open,p=>{if(n.lockBodyScroll&&document.body.classList.toggle("overflow-hidden",p),p&&n.closeOnEscape){window.addEventListener("keydown",c);return}window.removeEventListener("keydown",c)},{immediate:!0}),It(()=>{n.lockBodyScroll&&document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",c)}),(p,S)=>(g(),Ce(os,{to:"body"},[ue(_r,{name:"dialog-shell"},{default:Je(()=>[e.open?(g(),x("div",{key:0,class:Se(["theme-modal-backdrop dialog-shell-backdrop fixed inset-0 flex",s.value]),onClick:Qe(l,["self"])},[i("section",{class:Se(["panel dialog-shell-panel flex min-h-0 w-full flex-col overflow-hidden",e.panelClass])},[p.$slots.title||p.$slots.header||p.$slots["header-actions"]||e.showClose?(g(),x("div",{key:0,class:Se(["theme-divider flex items-start justify-between gap-4 border-b",e.headerClass])},[i("div",gi,[Jt(p.$slots,"header",{},()=>[Jt(p.$slots,"title")])]),p.$slots["header-actions"]||e.showClose?(g(),x("div",hi,[Jt(p.$slots,"header-actions"),e.showClose?(g(),x("button",{key:0,type:"button",class:"theme-icon-button h-8 w-8 shrink-0",disabled:e.closeDisabled,onClick:r},[ue(a(Tr),{class:"h-4 w-4"})],8,vi)):me("",!0)])):me("",!0)],2)):me("",!0),i("div",{class:Se(e.bodyClass)},[Jt(p.$slots,"default")],2)],2)],2)):me("",!0)]),_:3})]))}},yi={class:"flex items-start gap-3"},Si={class:"theme-heading text-base font-semibold"},wi={key:0,class:"theme-muted-text mt-1 text-sm leading-6"},xi={class:"flex justify-end gap-2 px-5 py-4"},bi=["disabled"],ki=["disabled"],ps={__name:"ConfirmDialog",props:{open:{type:Boolean,default:!1},title:{type:String,default:""},description:{type:String,default:""},confirmText:{type:String,default:""},cancelText:{type:String,default:""},loading:{type:Boolean,default:!1},danger:{type:Boolean,default:!1}},emits:["cancel","confirm"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=W(()=>n.title||s("common.confirm")),l=W(()=>n.confirmText||s("common.confirm")),c=W(()=>n.cancelText||s("common.cancel"));return(p,S)=>(g(),Ce(Fs,{open:e.open,"stack-level":4,"panel-class":"max-w-md","header-class":"px-5 py-4","body-class":"flex flex-col","close-disabled":e.loading,"close-on-backdrop":!e.loading,"close-on-escape":!e.loading,onClose:S[2]||(S[2]=d=>o("cancel"))},{title:Je(()=>[i("div",yi,[i("span",{class:Se(["inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-sm border border-dashed",e.danger?"theme-status-danger":"theme-status-neutral"])},[ue(a(Ea),{class:"h-4 w-4"})],2),i("div",null,[i("h2",Si,w(r.value),1),e.description?(g(),x("p",wi,w(e.description),1)):me("",!0)])])]),default:Je(()=>[i("div",xi,[i("button",{type:"button",class:"tool-button px-4 py-2 text-sm",disabled:e.loading,onClick:S[0]||(S[0]=d=>o("cancel"))},w(c.value),9,bi),i("button",{type:"button",class:Se(["tool-button px-4 py-2 text-sm",e.danger?"tool-button-danger":"tool-button-primary"]),disabled:e.loading,onClick:S[1]||(S[1]=d=>o("confirm"))},w(e.loading?a(s)("common.processing"):l.value),11,ki)])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},_i={class:"theme-divider settings-dialog-nav border-b px-3 py-3 sm:w-60 sm:shrink-0 sm:border-b-0 sm:border-r sm:px-4 sm:py-4"},Ti={class:"settings-nav flex gap-2 overflow-x-auto sm:flex-col sm:overflow-visible"},Ci=["onClick"],Ei={class:"min-w-0"},Ai={class:"text-sm font-medium"},$i={class:"theme-muted-text mt-1 hidden text-xs leading-5 sm:block"},Ii={__name:"DialogSideNav",props:{modelValue:{type:String,default:""},sections:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(e,{emit:t}){const n=t;function o(s=""){n("update:modelValue",String(s||""))}return(s,r)=>(g(),x("aside",_i,[i("nav",Ti,[(g(!0),x(et,null,ut(e.sections,l=>(g(),x("button",{key:l.id,type:"button",class:Se(["settings-nav__item flex min-w-0 items-start gap-3 rounded-sm border px-3 py-3 text-left transition sm:w-full",e.modelValue===l.id?"theme-card-selected":"theme-card-idle-muted border-dashed hover:border-[var(--theme-borderStrong)] hover:bg-[var(--theme-appPanelStrong)]"]),onClick:c=>o(l.id)},[(g(),Ce(cn(l.icon),{class:"mt-0.5 h-4 w-4 shrink-0"})),i("div",Ei,[i("div",Ai,w(l.label),1),i("p",$i,w(l.description),1)])],10,Ci))),128))])]))}},Pi=["aria-label","disabled","onKeydown"],Di={class:"min-w-0 flex-1"},Li={class:"theme-muted-text text-sm"},Bi={class:"flex min-h-0 w-full flex-col"},Mi={class:"min-h-0 flex-1 space-y-2 overflow-y-auto p-2"},Ri=["onClick"],Ni={class:"theme-empty-state px-3 py-4 text-sm"},en={__name:"WorkbenchSelect",props:{modelValue:{type:[String,Number],default:""},options:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:""},emptyText:{type:String,default:""},ariaLabel:{type:String,default:""},getOptionValue:{type:Function,default:e=>(e==null?void 0:e.id)??(e==null?void 0:e.value)??""},triggerClass:{type:String,default:""}},emits:["update:modelValue","refresh-intent"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=q(null),l=q(null),c=q(!1),p=q(!1),S=q({}),d=W(()=>{const U=String(n.modelValue??"");return n.options.find(se=>String(n.getOptionValue(se)??"")===U)||null}),m=W(()=>n.placeholder||s("common.select")),f=W(()=>n.emptyText||s("common.noOptions"));function b(U){return U&&typeof U=="object"&&Object.prototype.hasOwnProperty.call(U,"label")?String(U.label||""):String(n.getOptionValue(U)??"")}function v(){n.disabled||(c.value||o("refresh-intent"),c.value=!0)}function P(){c.value=!1}function ne(){if(c.value){P();return}v()}function y(U){o("update:modelValue",String(n.getOptionValue(U)??"").trim()),P()}function L(){if(!c.value||!r.value||typeof window>"u")return;const U=r.value.getBoundingClientRect(),se=window.innerWidth,A=window.innerHeight,G=8,ce=8,pe=160,I=360,Q=Math.max(0,A-U.bottom-ce),le=Math.max(0,U.top-ce);p.value=Q<260&&le>Q;const ie=p.value?le-G:Q-G,ve=Math.max(Math.min(I,Math.max(ie,0)),Math.min(pe,p.value?le:Q)),_=Math.min(U.width,se-ce*2),H=Math.min(Math.max(ce,U.left),Math.max(ce,se-ce-_));S.value={left:`${H}px`,top:p.value?`${U.top-G}px`:`${U.bottom+G}px`,width:`${_}px`,maxHeight:`${Math.max(ve,120)}px`,transform:p.value?"translateY(-100%)":"none"}}function O(U){var se;!c.value||!r.value||r.value.contains(U.target)||(se=l.value)!=null&&se.contains(U.target)||P()}function z(U){U.key==="Escape"&&P()}return $e(()=>n.disabled,U=>{U&&P()}),$e(c,async U=>{U&&(await at(),L())}),dn(()=>{document.addEventListener("pointerdown",O),document.addEventListener("keydown",z),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0)}),It(()=>{document.removeEventListener("pointerdown",O),document.removeEventListener("keydown",z),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}),(U,se)=>(g(),x("div",{ref_key:"rootRef",ref:r,class:"relative min-w-0"},[i("button",{type:"button",class:Se(["workbench-select-trigger flex w-full items-center gap-3 rounded-sm border px-3 py-2 text-left transition focus:outline-none focus:ring-2",[n.triggerClass,e.disabled?"cursor-not-allowed border-[color-mix(in_srgb,var(--theme-borderDefault)_88%,var(--theme-textMuted))] bg-[color-mix(in_srgb,var(--theme-appPanelMuted)_82%,var(--theme-appBg))] text-[var(--theme-textMuted)]":"theme-input-shell text-[var(--theme-textPrimary)] hover:border-[var(--theme-borderStrong)] focus:border-[var(--theme-borderStrong)] focus:ring-[var(--theme-focusRing)]"]]),"aria-label":n.ariaLabel||void 0,disabled:e.disabled,onClick:ne,onKeydown:[Gt(Qe(v,["prevent"]),["down"]),Gt(Qe(ne,["prevent"]),["enter"]),Gt(Qe(ne,["prevent"]),["space"])]},[i("div",Di,[Jt(U.$slots,"trigger",{selectedOption:d.value,open:c.value,loading:e.loading,disabled:e.disabled},()=>[i("div",Li,w(d.value?b(d.value):m.value),1)])]),i("div",{class:Se(["flex shrink-0 items-center gap-2",e.disabled?"text-[var(--theme-textMuted)] opacity-80":"theme-muted-text"])},[e.loading?(g(),Ce(a(Ht),{key:0,class:"h-4 w-4 animate-spin"})):me("",!0),ue(a(ko),{class:Se(["h-4 w-4 transition",c.value?"rotate-180":""])},null,8,["class"])],2)],42,Pi),(g(),Ce(os,{to:"body"},[c.value?(g(),x("div",{key:0,ref_key:"panelRef",ref:l,class:"workbench-select-panel theme-popover fixed z-[90] flex overflow-hidden rounded-sm border",style:kn(S.value)},[i("div",Bi,[Jt(U.$slots,"header",{loading:e.loading,options:e.options}),i("div",Mi,[e.options.length?(g(!0),x(et,{key:0},ut(e.options,A=>Jt(U.$slots,"option",{key:String(e.getOptionValue(A)??""),option:A,selected:String(e.getOptionValue(A)??"")===String(e.modelValue??""),select:()=>y(A)},()=>[i("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:G=>y(A)},w(b(A)),9,Ri)])),128)):Jt(U.$slots,"empty",{key:1},()=>[i("div",Ni,w(f.value),1)])])])],4)):me("",!0)]))],512))}},qo={},Lr=typeof import.meta<"u"&&qo?qo:{};function Oi(){if(typeof window>"u")return"http://localhost:3000";const e=new URL(window.location.origin),t=String(Lr.VITE_API_PORT||"").trim();if(t)return e.port=t,e.toString().replace(/\/$/,"");const n=String(e.port||"");return new Set(["4173","5173","5174"]).has(n)?(e.port="3000",e.toString().replace(/\/$/,"")):e.toString().replace(/\/$/,"")}const Ao=(Lr.VITE_API_BASE_URL||Oi()).replace(/\/$/,"");function $o(e={},t="errors.requestFailed"){const n=String((e==null?void 0:e.messageKey)||"").trim();if(n){const o=We(n);if(o&&o!==n)return o}return(e==null?void 0:e.message)||We(t)}async function Ze(e,t={}){const n=typeof t.body<"u"&&!(t.body instanceof FormData),o=await fetch(`${Ao}${e}`,{headers:{...n?{"Content-Type":"application/json"}:{},...t.headers||{}},...t});if(!o.ok){const r=await o.json().catch(()=>({}));throw new Error($o(r))}return o.status===204?null:(o.headers.get("content-type")||"").includes("application/json")?o.json():o.text()}function Io(){return Ao}function xs(e){return e?e.startsWith("http")?e:`${Ao}${e}`:""}function py(){return Ze("/api/meta",{cache:"no-store"})}function ji(){return Ze("/api/tasks")}function Fi(e=30){const t=new URLSearchParams,n=Math.max(1,Number(e)||30);return t.set("limit",String(n)),Ze(`/api/tasks/workspace-diff-summaries?${t.toString()}`,{cache:"no-store"})}function Ui(e){return Ze("/api/tasks",{method:"POST",body:JSON.stringify(e)})}function Vi(e=[]){return Ze("/api/tasks/reorder",{method:"POST",body:JSON.stringify({slugs:e})})}function Br(e){return Ze(`/api/tasks/${e}`)}function Mr(e,t){return Ze(`/api/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)})}function zi(e){return Ze(`/api/tasks/${e}`,{method:"DELETE"})}const Rr=Io();async function Hi(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Rr}/api/uploads`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error($o(o,"errors.uploadFailed"))}return n.json()}async function qi(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Rr}/api/imports/pdf`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error($o(o,"errors.pdfImportFailed"))}return n.json()}function Ki(){return Ze("/api/codex/sessions")}function Wi(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim();n&&t.set("engine",n);const o=t.toString();return Ze(`/api/codex/workspaces${o?`?${o}`:""}`)}function my(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim(),o=String(e.cwd||"").trim(),s=Number(e.limit||0);n&&t.set("engine",n),o&&t.set("cwd",o),Number.isFinite(s)&&s>0&&t.set("limit",String(s));const r=t.toString();return Ze(`/api/codex/session-candidates${r?`?${r}`:""}`,{cache:"no-store",signal:e.signal})}function gy(e={}){const t=new URLSearchParams,n=String(e.path||"").trim(),o=Number(e.limit||0);n&&t.set("path",n),Number.isFinite(o)&&o>0&&t.set("limit",String(o));const s=t.toString();return Ze(`/api/codex/directories/tree${s?`?${s}`:""}`,{cache:"no-store",signal:e.signal})}function hy(e,t={}){const n=new URLSearchParams,o=String(e||"").trim(),s=String(t.path||"").trim(),r=Number(t.limit||0);o&&n.set("q",o),s&&n.set("path",s),Number.isFinite(r)&&r>0&&n.set("limit",String(r));const l=n.toString();return Ze(`/api/codex/directories/search${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function Gi(e){return Ze("/api/codex/sessions",{method:"POST",body:JSON.stringify(e)})}function Xi(e,t){return Ze(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function Yi(e){return Ze(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function Ji(e){return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/reset`,{method:"POST"})}function Qi(e,t={}){const n=new URLSearchParams,o=String(t.path||"").trim(),s=String(t.refreshToken||"").trim();o&&n.set("path",o),s&&n.set("_",s);const r=n.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/tree${r?`?${r}`:""}`,{cache:"no-store",signal:t.signal})}function Zi(e,t,n={}){const o=new URLSearchParams,s=String(t||"").trim(),r=Number(n.limit||60),l=String(n.refreshToken||"").trim();s&&o.set("q",s),Number.isFinite(r)&&r>0&&o.set("limit",String(r)),l&&o.set("_",l);const c=o.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/search${c?`?${c}`:""}`,{cache:"no-store",signal:n.signal})}function el(e,t={}){const n=new URLSearchParams,o=String(t.path||"").trim(),s=Number(t.limit||0),r=String(t.refreshToken||"").trim();o&&n.set("path",o),Number.isFinite(s)&&s>0&&n.set("limit",String(s)),r&&n.set("_",r);const l=n.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/content${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function tl(e,t,n={}){const o=new URLSearchParams,s=String(t||"").trim(),r=Number(n.limit||80),l=String(n.refreshToken||"").trim();s&&o.set("q",s),Number.isFinite(r)&&r>0&&o.set("limit",String(r)),l&&o.set("_",l);const c=o.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/content-search${c?`?${c}`:""}`,{cache:"no-store",signal:n.signal})}function nl(e,t){return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-session`,{method:"POST",body:JSON.stringify({sessionId:t})})}function sl(e,t={}){const n=new URLSearchParams,o=Number(t.limit||20),s=oi(t.events,t);Number.isFinite(o)&&o>0&&n.set("limit",String(o)),n.set("events",s);const r=n.toString();return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-runs${r?`?${r}`:""}`,{cache:"no-store"})}function ol(e,t={}){const n=new URLSearchParams,o=Math.max(0,Number(t.afterSeq)||0),s=Math.max(1,Number(t.limit)||5e3);o>0&&n.set("afterSeq",String(o)),s>0&&n.set("limit",String(s));const r=n.toString();return Ze(`/api/codex/runs/${encodeURIComponent(e)}/events${r?`?${r}`:""}`,{cache:"no-store"})}function vy(e,t={}){const n=new URLSearchParams,o=String(t.scope||"workspace").trim(),s=String(t.runId||"").trim(),r=String(t.filePath||"").trim(),l=t.includeFiles!==!1,c=t.includeStats!==!1,p=Math.max(0,Number(t.timeoutMs)||0);o==="run"?n.set("scope","run"):o==="task"?n.set("scope","task"):n.set("scope","workspace"),s&&n.set("runId",s),r&&n.set("filePath",r),l||n.set("includeFiles","false"),c||n.set("includeStats","false"),p>0&&n.set("timeoutMs",String(p));const S=n.toString();return Ze(`/api/tasks/${encodeURIComponent(e)}/git-diff${S?`?${S}`:""}`,{cache:"no-store"})}function rl(e,t){return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"POST",body:JSON.stringify(t)})}function al(e){return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"DELETE"})}function il(e){return Ze(`/api/codex/runs/${encodeURIComponent(e)}/stop`,{method:"POST"})}const ll={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ul={class:"theme-muted-text mt-1 text-xs"},cl={class:"min-h-0 flex flex-1 flex-col overflow-hidden sm:flex-row"},dl={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},fl={key:0,class:"theme-muted-text flex items-center gap-2 py-4 text-sm"},pl={key:1,class:"space-y-4"},ml={key:0,class:"space-y-4"},gl={class:"theme-heading text-base font-medium"},hl={class:"theme-muted-text mt-1 text-xs leading-5"},vl={class:"settings-section-card px-4 py-4"},yl={class:"block space-y-1.5"},Sl={class:"theme-muted-text text-xs"},wl=["placeholder"],xl={key:1,class:"space-y-4"},bl={class:"flex items-start justify-between gap-3"},kl={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},_l={class:"theme-muted-text mt-1 text-xs leading-5"},Tl={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Cl={class:"settings-section-card px-4 py-4"},El={class:"grid gap-4 sm:grid-cols-2"},Al={class:"space-y-1.5 sm:col-span-2"},$l={class:"theme-muted-text text-xs"},Il={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Pl={class:"space-y-1.5"},Dl={class:"theme-muted-text text-xs"},Ll=["disabled"],Bl={key:0,class:"space-y-1.5"},Ml={class:"theme-muted-text text-xs"},Rl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Nl={class:"space-y-1.5"},Ol={class:"theme-muted-text text-xs"},jl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Fl={class:"theme-muted-text text-xs"},Ul={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Vl={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},zl={key:2,class:"space-y-4"},Hl={class:"flex items-start justify-between gap-3"},ql={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Kl={class:"theme-muted-text mt-1 text-xs leading-5"},Wl={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Gl={class:"settings-section-card px-4 py-4"},Xl={class:"grid gap-4 sm:grid-cols-2"},Yl={class:"space-y-1.5"},Jl={class:"theme-muted-text text-xs"},Ql={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Zl={class:"space-y-1.5"},eu={class:"theme-muted-text text-xs"},tu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},nu={class:"space-y-1.5 sm:col-span-2"},su={class:"theme-muted-text text-xs"},ou=["placeholder","disabled"],ru={class:"space-y-1.5"},au={class:"theme-muted-text text-xs"},iu=["placeholder","disabled"],lu={class:"space-y-1.5"},uu={class:"theme-muted-text text-xs"},cu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},du={class:"space-y-1.5"},fu={class:"theme-muted-text text-xs"},pu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},mu={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},gu={key:0,class:"theme-danger-text"},hu={key:3,class:"theme-danger-text text-sm"},vu={class:"theme-divider flex flex-col gap-3 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-between"},yu={class:"theme-muted-text theme-note-text"},Su={class:"flex items-center justify-end gap-2"},wu=["disabled"],xu=["disabled"],bu="0 9 * * 1-5",Qs="weekdays",Wn="09:00",An="1",ku={__name:"EditTaskDialog",props:{open:{type:Boolean,default:!1},taskSlug:{type:String,default:""},taskTitle:{type:String,default:""}},emits:["close","saved"],setup(e,{emit:t}){const n=e,o=t,{locale:s,t:r}=St(),l=q(!1),c=q(!1),p=q(""),S=q("basic"),d=rs({title:"",automationEnabled:!1,automationMode:Qs,automationTime:Wn,automationWeekday:An,automationTimezone:"local",automationConcurrencyPolicy:"skip",automationLastTriggeredAt:"",automationNextTriggerAt:"",notificationEnabled:!1,notificationChannelType:"dingtalk",notificationWebhookUrl:"",notificationSecret:"",notificationTriggerOn:"completed",notificationLocale:"zh-CN",notificationMessageMode:"summary",notificationLastStatus:"",notificationLastError:"",notificationLastSentAt:""}),m=W(()=>String(n.taskTitle||"").trim()||r("workbench.untitledTask")),f=W(()=>[{id:"basic",label:r("taskDialog.sections.basic.label"),description:r("taskDialog.sections.basic.description"),icon:Zn},{id:"automation",label:r("taskDialog.sections.automation.label"),description:r("taskDialog.sections.automation.description"),icon:Is},{id:"notification",label:r("taskDialog.sections.notification.label"),description:r("taskDialog.sections.notification.description"),icon:Fo}]),b=W(()=>[{value:"daily",label:r("taskDialog.sections.automation.modeDaily")},{value:"weekdays",label:r("taskDialog.sections.automation.modeWeekdays")},{value:"weekly",label:r("taskDialog.sections.automation.modeWeekly")}]),v=W(()=>[{value:"1",label:r("taskDialog.sections.automation.weekday1")},{value:"2",label:r("taskDialog.sections.automation.weekday2")},{value:"3",label:r("taskDialog.sections.automation.weekday3")},{value:"4",label:r("taskDialog.sections.automation.weekday4")},{value:"5",label:r("taskDialog.sections.automation.weekday5")},{value:"6",label:r("taskDialog.sections.automation.weekday6")},{value:"0",label:r("taskDialog.sections.automation.weekday0")}]),P=W(()=>ai.map(_=>({..._,label:_.value==="local"?r("taskDialog.sections.automation.timezoneLocal"):_.label}))),ne=W(()=>li.map(_=>({..._,label:_.value==="skip"?r("taskDialog.sections.automation.concurrencySkip"):_.label}))),y=W(()=>ui.map(_=>({..._,label:_.value==="dingtalk"?r("taskDialog.sections.notification.channelDingtalk"):_.value==="feishu"?r("taskDialog.sections.notification.channelFeishu"):_.value==="webhook"?r("taskDialog.sections.notification.channelWebhook"):_.label}))),L=W(()=>ci.map(_=>({..._,label:_.value==="completed"?r("taskDialog.sections.notification.triggerCompleted"):_.value==="success"?r("taskDialog.sections.notification.triggerSuccess"):_.value==="error"?r("taskDialog.sections.notification.triggerError"):_.label}))),O=W(()=>fi.map(_=>({..._,label:_.value==="summary"?r("taskDialog.sections.notification.messageSummary"):_.label}))),z=W(()=>pi.map(_=>({..._,label:_.value==="zh-CN"?r("taskDialog.sections.notification.localeZhCn"):_.value==="en-US"?r("taskDialog.sections.notification.localeEnUs"):_.label}))),U=W(()=>d.notificationEnabled?d.notificationLastStatus==="success"?r("taskDialog.sections.notification.statusSuccess"):d.notificationLastStatus==="error"?r("taskDialog.sections.notification.statusError"):r("taskDialog.sections.notification.statusPending"):r("taskDialog.sections.notification.statusDisabled"));function se(){d.title="",d.automationEnabled=!1,d.automationMode=Qs,d.automationTime=Wn,d.automationWeekday=An,d.automationTimezone="local",d.automationConcurrencyPolicy="skip",d.automationLastTriggeredAt="",d.automationNextTriggerAt="",d.notificationEnabled=!1,d.notificationChannelType="dingtalk",d.notificationWebhookUrl="",d.notificationSecret="",d.notificationTriggerOn="completed",d.notificationLocale=String(s.value||"zh-CN"),d.notificationMessageMode="summary",d.notificationLastStatus="",d.notificationLastError="",d.notificationLastSentAt=""}function A(_=0){return String(_).padStart(2,"0")}function G(_=""){const H=String(_||"").trim().replace(/\s+/g," ");let F=H.match(/^(\d{1,2}) (\d{1,2}) \* \* 1-5$/);return F?{mode:"weekdays",time:`${A(F[2])}:${A(F[1])}`,weekday:An}:(F=H.match(/^(\d{1,2}) (\d{1,2}) \* \* \*$/),F?{mode:"daily",time:`${A(F[2])}:${A(F[1])}`,weekday:An}:(F=H.match(/^(\d{1,2}) (\d{1,2}) \* \* ([0-6])$/),F?{mode:"weekly",time:`${A(F[2])}:${A(F[1])}`,weekday:String(F[3])}:{mode:Qs,time:Wn,weekday:An}))}function ce(_=""){const F=String(_||"").trim().match(/^(\d{1,2}):(\d{2})$/);if(!F)return Wn;const He=Number(F[1]),De=Number(F[2]);return!Number.isInteger(He)||!Number.isInteger(De)||He<0||He>23||De<0||De>59?Wn:`${A(He)}:${A(De)}`}function pe(){var Fe;const _=ce(d.automationTime),[H,F]=_.split(":"),He=Number(H),De=Number(F);if(d.automationMode==="daily")return`${De} ${He} * * *`;if(d.automationMode==="weekly"){const je=((Fe=v.value.find(Ke=>Ke.value===String(d.automationWeekday||"")))==null?void 0:Fe.value)||An;return`${De} ${He} * * ${je}`}return`${De} ${He} * * 1-5`}function I(_={}){var F,He,De,Fe,je,Ke,tt,xe,R,J,fe,_e,ge,Ie,Ae,Be;d.title=String(_.title||""),d.automationEnabled=!!((F=_.automation)!=null&&F.enabled);const H=G(((He=_.automation)==null?void 0:He.cron)||bu);d.automationMode=H.mode,d.automationTime=H.time,d.automationWeekday=H.weekday,d.automationTimezone=String(((De=_.automation)==null?void 0:De.timezone)||"local"),d.automationConcurrencyPolicy=String(((Fe=_.automation)==null?void 0:Fe.concurrencyPolicy)||"skip"),d.automationLastTriggeredAt=String(((je=_.automation)==null?void 0:je.lastTriggeredAt)||""),d.automationNextTriggerAt=String(((Ke=_.automation)==null?void 0:Ke.nextTriggerAt)||""),d.notificationEnabled=!!((tt=_.notification)!=null&&tt.enabled),d.notificationChannelType=String(((xe=_.notification)==null?void 0:xe.channelType)||"dingtalk"),d.notificationWebhookUrl=String(((R=_.notification)==null?void 0:R.webhookUrl)||""),d.notificationSecret=String(((J=_.notification)==null?void 0:J.secret)||""),d.notificationTriggerOn=String(((fe=_.notification)==null?void 0:fe.triggerOn)||"completed"),d.notificationLocale=String(((_e=_.notification)==null?void 0:_e.locale)||s.value||"zh-CN"),d.notificationMessageMode=String(((ge=_.notification)==null?void 0:ge.messageMode)||"summary"),d.notificationLastStatus=String(((Ie=_.notification)==null?void 0:Ie.lastStatus)||""),d.notificationLastError=String(((Ae=_.notification)==null?void 0:Ae.lastError)||""),d.notificationLastSentAt=String(((Be=_.notification)==null?void 0:Be.lastSentAt)||"")}async function Q(){const _=String(n.taskSlug||"").trim();if(!_){se();return}l.value=!0,p.value="";try{const H=await Br(_);I(H)}catch(H){p.value=(H==null?void 0:H.message)||r("taskDialog.loadFailed")}finally{l.value=!1}}function le(){return{title:d.title,automation:{enabled:d.automationEnabled,cron:pe(),timezone:d.automationTimezone,concurrencyPolicy:d.automationConcurrencyPolicy},notification:{enabled:d.notificationEnabled,channelType:d.notificationChannelType,webhookUrl:d.notificationWebhookUrl,secret:d.notificationSecret,triggerOn:d.notificationTriggerOn,locale:d.notificationLocale,messageMode:d.notificationMessageMode}}}async function ie(){const _=String(n.taskSlug||"").trim();if(!(!_||l.value||c.value)){c.value=!0,p.value="";try{const H=await Mr(_,le());I(H),o("saved",H),o("close")}catch(H){p.value=(H==null?void 0:H.message)||r("taskDialog.saveFailed")}finally{c.value=!1}}}function ve(_=""){if(!_)return r("common.notAvailable");const H=new Date(_);return Number.isNaN(H.getTime())?r("common.notAvailable"):xr(H.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return $e(()=>n.open,_=>{if(_){S.value="basic",Q();return}},{immediate:!0}),$e(()=>n.taskSlug,()=>{n.open&&Q()}),(_,H)=>(g(),Ce(Fs,{open:e.open,"stack-level":3,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-5xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col overflow-hidden",onClose:H[16]||(H[16]=F=>o("close"))},{title:Je(()=>[i("div",null,[i("div",ll,[ue(a(Zn),{class:"h-4 w-4"}),i("span",null,w(a(r)("taskDialog.title")),1)]),i("p",ul,w(a(r)("taskDialog.currentTask",{title:m.value})),1)])]),default:Je(()=>[i("div",cl,[ue(Ii,{modelValue:S.value,"onUpdate:modelValue":H[0]||(H[0]=F=>S.value=F),sections:f.value},null,8,["modelValue","sections"]),i("div",dl,[l.value?(g(),x("div",fl,[ue(a(Ht),{class:"h-4 w-4 animate-spin"}),i("span",null,w(a(r)("taskDialog.loading")),1)])):(g(),x("div",pl,[S.value==="basic"?(g(),x("section",ml,[i("div",null,[i("div",gl,w(a(r)("taskDialog.sections.basic.title")),1),i("p",hl,w(a(r)("taskDialog.sections.basic.intro")),1)]),i("section",vl,[i("label",yl,[i("span",Sl,w(a(r)("taskDialog.sections.basic.taskTitle")),1),Wt(i("input",{"onUpdate:modelValue":H[1]||(H[1]=F=>d.title=F),type:"text",maxlength:"140",class:"tool-input",placeholder:a(r)("taskDialog.sections.basic.taskTitlePlaceholder")},null,8,wl),[[Xn,d.title]])])])])):S.value==="automation"?(g(),x("section",xl,[i("div",bl,[i("div",null,[i("div",kl,[ue(a(Is),{class:"h-4 w-4"}),i("span",null,w(a(r)("taskDialog.sections.automation.title")),1)]),i("p",_l,w(a(r)("taskDialog.sections.automation.intro")),1)]),i("label",Tl,[Wt(i("input",{"onUpdate:modelValue":H[2]||(H[2]=F=>d.automationEnabled=F),type:"checkbox",class:"h-4 w-4"},null,512),[[jo,d.automationEnabled]]),i("span",null,w(a(r)("taskDialog.enabled")),1)])]),i("section",Cl,[i("div",El,[i("label",Al,[i("span",$l,w(a(r)("taskDialog.sections.automation.mode")),1),ue(en,{modelValue:d.automationMode,"onUpdate:modelValue":H[3]||(H[3]=F=>d.automationMode=F),options:b.value,disabled:!d.automationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",Il,w((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Pl,[i("span",Dl,w(a(r)("taskDialog.sections.automation.time")),1),Wt(i("input",{"onUpdate:modelValue":H[4]||(H[4]=F=>d.automationTime=F),type:"time",class:"tool-input",disabled:!d.automationEnabled},null,8,Ll),[[Xn,d.automationTime]])]),d.automationMode==="weekly"?(g(),x("label",Bl,[i("span",Ml,w(a(r)("taskDialog.sections.automation.weekday")),1),ue(en,{modelValue:d.automationWeekday,"onUpdate:modelValue":H[5]||(H[5]=F=>d.automationWeekday=F),options:v.value,disabled:!d.automationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",Rl,w((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])):me("",!0),i("label",Nl,[i("span",Ol,w(a(r)("taskDialog.sections.automation.timezone")),1),ue(en,{modelValue:d.automationTimezone,"onUpdate:modelValue":H[6]||(H[6]=F=>d.automationTimezone=F),options:P.value,disabled:!d.automationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",jl,w((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",{class:Se(["space-y-1.5",d.automationMode==="weekly"?"":"sm:col-span-2"])},[i("span",Fl,w(a(r)("taskDialog.sections.automation.concurrencyPolicy")),1),ue(en,{modelValue:d.automationConcurrencyPolicy,"onUpdate:modelValue":H[7]||(H[7]=F=>d.automationConcurrencyPolicy=F),options:ne.value,disabled:!d.automationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",Ul,w((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])],2)]),i("div",Vl,[i("p",null,w(a(r)("taskDialog.sections.automation.lastTriggered",{value:ve(d.automationLastTriggeredAt)})),1),i("p",null,w(a(r)("taskDialog.sections.automation.nextTriggered",{value:ve(d.automationNextTriggerAt)})),1)])])])):(g(),x("section",zl,[i("div",Hl,[i("div",null,[i("div",ql,[ue(a(Fo),{class:"h-4 w-4"}),i("span",null,w(a(r)("taskDialog.sections.notification.title")),1)]),i("p",Kl,w(a(r)("taskDialog.sections.notification.intro")),1)]),i("label",Wl,[Wt(i("input",{"onUpdate:modelValue":H[8]||(H[8]=F=>d.notificationEnabled=F),type:"checkbox",class:"h-4 w-4"},null,512),[[jo,d.notificationEnabled]]),i("span",null,w(a(r)("taskDialog.enabled")),1)])]),i("section",Gl,[i("div",Xl,[i("label",Yl,[i("span",Jl,w(a(r)("taskDialog.sections.notification.channelType")),1),ue(en,{modelValue:d.notificationChannelType,"onUpdate:modelValue":H[9]||(H[9]=F=>d.notificationChannelType=F),options:y.value,disabled:!d.notificationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",Ql,w((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Zl,[i("span",eu,w(a(r)("taskDialog.sections.notification.triggerOn")),1),ue(en,{modelValue:d.notificationTriggerOn,"onUpdate:modelValue":H[10]||(H[10]=F=>d.notificationTriggerOn=F),options:L.value,disabled:!d.notificationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",tu,w((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",nu,[i("span",su,w(a(r)("taskDialog.sections.notification.webhookUrl")),1),Wt(i("input",{"onUpdate:modelValue":H[11]||(H[11]=F=>d.notificationWebhookUrl=F),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.webhookUrlPlaceholder"),disabled:!d.notificationEnabled},null,8,ou),[[Xn,d.notificationWebhookUrl]])]),i("label",ru,[i("span",au,w(a(r)("taskDialog.sections.notification.secret")),1),Wt(i("input",{"onUpdate:modelValue":H[12]||(H[12]=F=>d.notificationSecret=F),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.secretPlaceholder"),disabled:!d.notificationEnabled},null,8,iu),[[Xn,d.notificationSecret]])]),i("label",lu,[i("span",uu,w(a(r)("taskDialog.sections.notification.locale")),1),ue(en,{modelValue:d.notificationLocale,"onUpdate:modelValue":H[13]||(H[13]=F=>d.notificationLocale=F),options:z.value,disabled:!d.notificationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",cu,w((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",du,[i("span",fu,w(a(r)("taskDialog.sections.notification.messageMode")),1),ue(en,{modelValue:d.notificationMessageMode,"onUpdate:modelValue":H[14]||(H[14]=F=>d.notificationMessageMode=F),options:O.value,disabled:!d.notificationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",pu,w((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])]),i("div",mu,[i("p",null,w(a(r)("taskDialog.sections.notification.status",{value:U.value})),1),i("p",null,w(a(r)("taskDialog.sections.notification.lastSent",{value:ve(d.notificationLastSentAt)})),1),d.notificationLastError?(g(),x("p",gu,w(a(r)("taskDialog.sections.notification.lastError",{value:d.notificationLastError})),1)):me("",!0)])])])),p.value?(g(),x("p",hu,w(p.value),1)):me("",!0)]))])]),i("div",vu,[i("p",yu,w(a(r)("taskDialog.footerHint")),1),i("div",Su,[i("button",{type:"button",class:"tool-button px-3 py-2 text-sm",disabled:c.value,onClick:H[15]||(H[15]=F=>o("close"))},w(a(r)("common.cancel")),9,wu),i("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-sm",disabled:c.value||l.value,onClick:ie},[c.value?(g(),Ce(a(Ht),{key:0,class:"h-4 w-4 animate-spin"})):(g(),Ce(a(Aa),{key:1,class:"h-4 w-4"})),i("span",null,w(c.value?a(r)("common.saving"):a(r)("taskDialog.saveTaskConfig")),1)],8,xu)])])]),_:1},8,["open"]))}};function _u(e=[]){return(Array.isArray(e)&&e.length?e:Eo).filter(n=>n&&typeof n=="object").map(n=>{const o=Ls(n.value);return{...n,value:o,label:String(n.label||ct(o)).trim()||ct(o),enabled:n.enabled!==!1,available:n.available!==!1}})}function Tu(e=[]){return _u(e).filter(t=>t.enabled&&t.available)}async function yy(){const e=await Ze("/api/meta",{cache:"no-store"});return Tu(e==null?void 0:e.agentEngineOptions)}function Nr(e={},t={}){const{defaultLabel:n="默认",prefix:o=""}=t,s=ct(e==null?void 0:e.engine),r=`${String(o||"")}${s}`;return e!=null&&e.isDefault?`${r} · ${n}`:r}const Cu={key:0,class:"flex items-center gap-2 text-sm"},Eu={class:"min-w-0 flex-1 truncate"},Au={class:"theme-muted-text ml-2 hidden font-mono text-[11px] sm:inline"},$u={class:"theme-status-neutral hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex"},Iu={key:1,class:"theme-muted-text text-sm"},Pu={class:"theme-divider theme-muted-text flex items-center justify-between gap-3 border-b border-dashed px-3 py-2 text-[11px]"},Du=["onClick"],Lu={class:"flex items-center gap-3"},Bu={class:"min-w-0 flex-1"},Mu={class:"flex items-center gap-2 text-sm sm:hidden"},Ru={class:"min-w-0 flex-1 truncate font-medium text-[var(--theme-textPrimary)]"},Nu={class:"hidden items-center gap-2 text-sm sm:flex"},Ou={class:"min-w-0 flex-1 truncate"},ju={class:"font-medium text-[var(--theme-textPrimary)]"},Fu={class:"theme-muted-text ml-2 font-mono text-[11px]"},Uu={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Vu={__name:"CodexSessionSelect",props:{modelValue:{type:String,default:""},sessions:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","refresh-intent"],setup(e,{emit:t}){const n=t,{t:o}=St();function s(d){return(d==null?void 0:d.title)||o("projectManager.untitledProject")}function r(d){return(d==null?void 0:d.cwd)||o("projectManager.notSet")}function l(d){return d!=null&&d.running?o("projectManager.running"):o("projectManager.idle")}function c(d){return d!=null&&d.running?"theme-status-warning":"theme-status-success"}function p(d){var f;const m=Math.max(0,Number((f=d==null?void 0:d.agentBindings)==null?void 0:f.length)||0);return m>1?o("projectManager.agentCount",{count:m}):ct(d==null?void 0:d.engine)}function S(d){return d?"theme-filter-active":"theme-filter-idle"}return(d,m)=>(g(),Ce(en,{"model-value":e.modelValue,options:e.sessions,loading:e.loading,disabled:e.disabled,"trigger-class":"h-9",placeholder:a(o)("projectManager.selectProject"),"empty-text":a(o)("projectManager.noProjectsInSelect"),"get-option-value":f=>(f==null?void 0:f.id)||"","onUpdate:modelValue":m[0]||(m[0]=f=>n("update:modelValue",f)),onRefreshIntent:m[1]||(m[1]=f=>n("refresh-intent"))},{trigger:Je(({selectedOption:f,disabled:b})=>[f?(g(),x("div",Cu,[i("span",Eu,[i("span",{class:Se(["font-medium",b?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},w(s(f)),3),i("span",Au,w(r(f)),1)]),i("span",$u,w(p(f)),1),i("span",{class:Se(["hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex",c(f)])},w(l(f)),3)])):(g(),x("div",Iu,w(e.loading?a(o)("projectManager.syncingProjects"):a(o)("projectManager.selectProject")),1))]),header:Je(()=>[i("div",Pu,[i("span",null,w(e.loading?a(o)("projectManager.syncingLatestProjects"):a(o)("projectManager.projectCount",{count:e.sessions.length})),1),e.loading?(g(),Ce(a(Ht),{key:0,class:"h-3.5 w-3.5 animate-spin"})):me("",!0)])]),option:Je(({option:f,selected:b,select:v})=>[i("button",{type:"button",class:Se(["w-full rounded-sm border border-dashed p-3 text-left transition",S(b)]),onClick:v},[i("div",Lu,[i("div",Bu,[i("div",Mu,[i("span",Ru,w(s(f)),1)]),i("div",Nu,[i("span",Ou,[i("span",ju,w(s(f)),1),i("span",Fu,w(r(f)),1)]),i("span",Uu,w(p(f)),1),i("span",{class:Se(["inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",c(f)])},w(l(f)),3)])]),b?(g(),Ce(a(Cr),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):me("",!0)])],10,Du)]),_:1},8,["model-value","options","loading","disabled","placeholder","empty-text","get-option-value"]))}},zu=["disabled"],Hu=["disabled"],qu=["src","alt"],Or={__name:"ImagePreviewOverlay",props:{modelValue:{type:String,default:""},images:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=q(1),l=W(()=>n.images.map(y=>String(y||"").trim()).filter(Boolean)),c=W(()=>l.value.findIndex(y=>y===n.modelValue)),p=W(()=>c.value>=0?l.value[c.value]:"");function S(){o("update:modelValue",""),r.value=1}function d(y){o("update:modelValue",String(y||"").trim()),r.value=1}function m(){c.value<=0||d(l.value[c.value-1])}function f(){c.value<0||c.value>=l.value.length-1||d(l.value[c.value+1])}function b(y){const L=Math.min(3,Math.max(.5,r.value+y));r.value=Math.round(L*100)/100}function v(){r.value=1}function P(y){p.value&&(y.preventDefault(),b(y.deltaY<0?.1:-.1))}function ne(y){if(p.value){if(y.key==="Escape"){y.preventDefault(),S();return}if(y.key==="ArrowLeft"){y.preventDefault(),m();return}if(y.key==="ArrowRight"){y.preventDefault(),f();return}if(y.key==="+"||y.key==="="){y.preventDefault(),b(.1);return}if(y.key==="-"){y.preventDefault(),b(-.1);return}y.key==="0"&&(y.preventDefault(),v())}}return $e(()=>n.modelValue,y=>{y||(r.value=1)}),$e(l,y=>{if(n.modelValue){if(!y.length){S();return}if(!y.includes(n.modelValue)){const L=Math.min(c.value,y.length-1);d(y[L]||y[0])}}},{immediate:!0}),dn(()=>{window.addEventListener("keydown",ne)}),It(()=>{window.removeEventListener("keydown",ne)}),(y,L)=>(g(),Ce(os,{to:"body"},[p.value?(g(),x("div",{key:0,class:"theme-modal-backdrop image-preview-overlay fixed inset-0 z-50 flex items-center justify-center p-6",onClick:S,onWheel:P},[i("div",{class:"absolute left-4 top-4 flex items-center gap-2",onClick:L[2]||(L[2]=Qe(()=>{},["stop"]))},[i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:L[0]||(L[0]=O=>b(-.1))},w(a(s)("imagePreview.zoomOut")),1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:v},w(Math.round(r.value*100))+"% ",1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:L[1]||(L[1]=O=>b(.1))},w(a(s)("imagePreview.zoomIn")),1)]),i("div",{class:"absolute right-4 top-4 flex items-center gap-2",onClick:L[3]||(L[3]=Qe(()=>{},["stop"]))},[i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition disabled:cursor-not-allowed disabled:opacity-40",disabled:c.value<=0,onClick:m},w(a(s)("imagePreview.previous")),9,zu),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition disabled:cursor-not-allowed disabled:opacity-40",disabled:c.value<0||c.value>=l.value.length-1,onClick:f},w(a(s)("imagePreview.next")),9,Hu),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:S},w(a(s)("imagePreview.close")),1)]),i("img",{src:p.value,alt:a(s)("imagePreview.alt"),class:"image-preview-overlay__image max-h-[90vh] max-w-[90vw] object-contain shadow-2xl transition-transform",style:kn({transform:`scale(${r.value})`}),onClick:L[4]||(L[4]=Qe(()=>{},["stop"]))},null,12,qu)],32)):me("",!0)]))}};let Zs=null;const Sy={maxLines:2e3,maxChars:2e5},eo={maxLines:2e3,maxChars:2e5},Ku={"github-dark-default":()=>ze(()=>import("./vendor-shiki-theme-github-dark-default-DBX58552.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),"github-light":()=>ze(()=>import("./vendor-shiki-theme-github-light-RLAvZv0q.js"),__vite__mapDeps([4,1,2,3])).then(e=>e.default)},Wu={bash:()=>ze(()=>import("./vendor-shiki-lang-bash-zsQu0xn-.js"),__vite__mapDeps([5,1,2,3])).then(e=>e.default),c:()=>ze(()=>import("./vendor-shiki-lang-c-BDF8vgks.js"),__vite__mapDeps([6,1,2,3])).then(e=>e.default),cpp:()=>ze(()=>import("./vendor-shiki-lang-cpp-DyDAaXl6.js"),__vite__mapDeps([7,1,2,3])).then(e=>e.default),csharp:()=>ze(()=>import("./vendor-shiki-lang-csharp-BWfTXJXw.js"),__vite__mapDeps([8,1,2,3])).then(e=>e.default),css:()=>ze(()=>import("./vendor-shiki-lang-css-DbAm1fUO.js"),__vite__mapDeps([9,1,2,3])).then(e=>e.default),diff:()=>ze(()=>import("./vendor-shiki-lang-diff-DmGC1G26.js"),__vite__mapDeps([10,1,2,3])).then(e=>e.default),dockerfile:()=>ze(()=>import("./vendor-shiki-lang-dockerfile-3x-8396r.js"),__vite__mapDeps([11,1,2,3])).then(e=>e.default),dotenv:()=>ze(()=>import("./vendor-shiki-lang-dotenv--IVOlX2Q.js"),__vite__mapDeps([12,1,2,3])).then(e=>e.default),fish:()=>ze(()=>import("./vendor-shiki-lang-fish-Bpv3hhJP.js"),__vite__mapDeps([13,1,2,3])).then(e=>e.default),go:()=>ze(()=>import("./vendor-shiki-lang-go-CIGC59jP.js"),__vite__mapDeps([14,1,2,3])).then(e=>e.default),html:()=>ze(()=>import("./vendor-shiki-lang-html-Bt_TLLZN.js"),__vite__mapDeps([15,1,2,3])).then(e=>e.default),ini:()=>ze(()=>import("./vendor-shiki-lang-ini-BIllfys4.js"),__vite__mapDeps([16,1,2,3])).then(e=>e.default),java:()=>ze(()=>import("./vendor-shiki-lang-java-CXxu9crF.js"),__vite__mapDeps([17,1,2,3])).then(e=>e.default),javascript:()=>ze(()=>import("./vendor-shiki-lang-javascript-Cha7GNZm.js"),__vite__mapDeps([18,1,2,3])).then(e=>e.default),json:()=>ze(()=>import("./vendor-shiki-lang-json-CCZCjDUh.js"),__vite__mapDeps([19,1,2,3])).then(e=>e.default),less:()=>ze(()=>import("./vendor-shiki-lang-less-DAToytC5.js"),__vite__mapDeps([20,1,2,3])).then(e=>e.default),markdown:()=>ze(()=>import("./vendor-shiki-lang-markdown-C6lwMXFp.js"),__vite__mapDeps([21,1,2,3])).then(e=>e.default),python:()=>ze(()=>import("./vendor-shiki-lang-python-Bi9rmtY7.js"),__vite__mapDeps([22,1,2,3])).then(e=>e.default),powershell:()=>ze(()=>import("./vendor-shiki-lang-powershell-lrpuM0ez.js"),__vite__mapDeps([23,1,2,3])).then(e=>e.default),rust:()=>ze(()=>import("./vendor-shiki-lang-rust-GTGDbY6A.js"),__vite__mapDeps([24,1,2,3])).then(e=>e.default),sass:()=>ze(()=>import("./vendor-shiki-lang-sass-DFtHupN8.js"),__vite__mapDeps([25,1,2,3])).then(e=>e.default),scss:()=>ze(()=>import("./vendor-shiki-lang-scss-BrfBNyyi.js"),__vite__mapDeps([26,1,2,3])).then(e=>e.default),sql:()=>ze(()=>import("./vendor-shiki-lang-sql-H6--iFN-.js"),__vite__mapDeps([27,1,2,3])).then(e=>e.default),toml:()=>ze(()=>import("./vendor-shiki-lang-toml-aTteTWYL.js"),__vite__mapDeps([28,1,2,3])).then(e=>e.default),tsx:()=>ze(()=>import("./vendor-shiki-lang-tsx-DoKZm6AV.js"),__vite__mapDeps([29,1,2,3])).then(e=>e.default),typescript:()=>ze(()=>import("./vendor-shiki-lang-typescript-B5awnqri.js"),__vite__mapDeps([30,1,2,3])).then(e=>e.default),vue:()=>ze(()=>import("./vendor-shiki-lang-vue-CnrgQ7Z5.js"),__vite__mapDeps([31,1,2,3])).then(e=>e.default),xml:()=>ze(()=>import("./vendor-shiki-lang-xml-Bv-TNPJt.js"),__vite__mapDeps([32,1,2,3])).then(e=>e.default),yaml:()=>ze(()=>import("./vendor-shiki-lang-yaml-DpxUxQ6M.js"),__vite__mapDeps([33,1,2,3])).then(e=>e.default)};function jr(e=0){return Number(e)>9999?"3.4rem":"2.6rem"}function Po(e=[]){const t=Array.isArray(e)?e.map(o=>String(o??"")):[],n=t.reduce((o,s)=>o+s.length,0);return{lines:t,lineCount:t.length,charCount:n}}function Do(e={},t={}){const n=Number(t.maxHighlightLines||0),o=Number(t.maxHighlightChars||0);return n>0&&Number(e.lineCount||0)>n||o>0&&Number(e.charCount||0)>o}function Gu(e=[],t={}){const n=Po(e);return Do(n,{maxHighlightLines:t.maxLines,maxHighlightChars:t.maxChars})}function Xu(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
6
6
  `);return Gu(n?n.split(`
7
7
  `):[],t)}async function Fr(){return Zs||(Zs=Promise.all([ze(()=>import("./vendor-shiki-core-1BqeTDsZ.js").then(e=>e.F),__vite__mapDeps([1,2,3])),ze(()=>import("./vendor-shiki-core-1BqeTDsZ.js").then(e=>e.G),__vite__mapDeps([1,2,3]))]).then(async([e,t])=>e.createHighlighterCore({engine:t.createJavaScriptRegexEngine(),langs:[],themes:[]}))),Zs}async function Ur(e,t){if(!t||e.getLoadedThemes().includes(t))return;const n=Ku[t];n&&await e.loadTheme(await n())}async function Vr(e,t){if(!t||e.getLoadedLanguages().includes(t))return;const n=Wu[t];n&&await e.loadLanguage(await n())}function Ln(e=""){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Yu={bash:"bash",c:"c",cpp:"cpp",cs:"csharp",csharp:"csharp",csh:"bash",css:"css",diff:"diff",dockerfile:"dockerfile",dotenv:"dotenv",env:"dotenv",fish:"fish",go:"go",html:"html",ini:"ini",java:"java",js:"javascript",javascript:"javascript",json:"json",jsx:"tsx",less:"less",md:"markdown",markdown:"markdown",powershell:"powershell",ps1:"powershell",pwsh:"powershell",python:"python",react:"tsx",rust:"rust",sass:"sass",scss:"scss",sh:"bash",shell:"bash",sql:"sql",svg:"html",text:"",toml:"toml",ts:"typescript",typescript:"typescript",tsx:"tsx",vue:"vue",xml:"xml",yaml:"yaml",yml:"yaml",zsh:"bash"};function Us(e=""){const t=String(e||"").trim().toLowerCase();return t?Yu[t]||t:""}function wy(e="",t=""){const n=Us(t);if(n)return n;const o=String(e||"").trim().toLowerCase();if(!o)return"";const s=o.split("/").pop()||"",r=s.includes(".")?s.slice(s.lastIndexOf(".")):"",l={".c":"c",".cc":"cpp",".conf":"ini",".cpp":"cpp",".cs":"csharp",".csh":"bash",".css":"css",".diff":"diff",".env":"dotenv",".fish":"fish",".go":"go",".htm":"html",".html":"html",".ini":"ini",".java":"java",".js":"javascript",".json":"json",".jsx":"tsx",".less":"less",".md":"markdown",".ps1":"powershell",".py":"python",".rs":"rust",".sass":"sass",".scss":"scss",".sh":"bash",".sql":"sql",".svg":"html",".toml":"toml",".ts":"typescript",".tsx":"tsx",".vue":"vue",".xml":"xml",".yaml":"yaml",".yml":"yaml",".zsh":"bash"};return s===".env"?"dotenv":s==="dockerfile"?"dockerfile":s==="makefile"?"":l[r]||""}function zr(e){const t=[];e!=null&&e.color&&t.push(`color:${e.color}`),(e==null?void 0:e.fontStyle)&1&&t.push("font-style:italic"),(e==null?void 0:e.fontStyle)&2&&t.push("font-weight:600"),(e==null?void 0:e.fontStyle)&4&&t.push("text-decoration:underline");const n=Ln((e==null?void 0:e.content)||"");return`<span${t.length?` style="${t.join(";")}"`:""}>${n}</span>`}function Hr(e=[],t={}){const n=Math.max(1,Number(t.startLine)||1);return{html:e.map((o,s)=>`<tr class="source-code-view__line" data-line="${n+s}"><td class="source-code-view__gutter" data-line="${n+s}">${n+s}</td><td class="source-code-view__code"><span class="source-code-view__line-inner">${o}</span></td></tr>`).join(""),lineCount:e.length,bg:t.bg||"",fg:t.fg||"",gutterWidth:jr(e.length)}}function xy(e=[]){return(Array.isArray(e)?e.map(n=>String(n??"")):[]).map(n=>n?Ln(n):"&#8203;")}function to(e=""){const t=String(e||"").replace(/\r\n/g,`
8
8
  `);return Hr(t.split(`
9
9
  `).map(n=>n?Ln(n):"&#8203;"),{})}async function Ju(e=[],t={}){const n=Po(e),o=n.lines,s=t.isDark?"github-dark-default":"github-light",r=Us(t.language);if(!o.length)return[];if(Do(n,t))return o.map(l=>l?Ln(l):"&#8203;");if(!r)return o.map(l=>l?Ln(l):"&#8203;");try{const l=await Fr();return await Ur(l,s),await Vr(l,r),(await l.codeToTokens(o.join(`
10
10
  `),{lang:r,theme:s})).tokens.map(p=>p.length?p.map(zr).join(""):"&#8203;")}catch{return o.map(l=>l?Ln(l):"&#8203;")}}async function Qu(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
11
11
  `),o=t.isDark?"github-dark-default":"github-light",s=Us(t.language),r=n?n.split(`
12
- `):[],l=Po(r);if(!n)return{html:"",lineCount:0,bg:"",fg:"",gutterWidth:jr(0)};if(Do(l,t)||!s)return to(n);try{const c=await Fr();await Ur(c,o),await Vr(c,s);const p=await c.codeToTokens(n,{lang:s,theme:o});return Hr(p.tokens.map(w=>w.length?w.map(zr).join(""):"&#8203;"),{bg:p.bg||"",fg:p.fg||""})}catch{return to(n)}}const Zu=new Ir,ec="__PROMPTX_FENCE__";function qr(e=""){return String(e||"").trim().toLowerCase()}function ms(e=""){return Zu.utils.escapeHtml(String(e||""))}function tc(e=""){const t=qr(e);return t?["js","javascript"].includes(t)?"JavaScript":["jsx","react"].includes(t)?"React":["ts","typescript"].includes(t)?"TypeScript":t==="tsx"?"TSX":["sh","shell","zsh","bash","csh"].includes(t)?"Bash":t==="fish"?"Fish":["ps1","pwsh","powershell"].includes(t)?"PowerShell":t==="md"?"Markdown":t==="html"?"HTML":t==="vue"?"Vue":t==="svg"?"SVG":t==="json"?"JSON":t==="sql"?"SQL":t==="scss"?"SCSS":t==="sass"?"Sass":t==="less"?"Less":t==="toml"?"TOML":t==="ini"?"INI":["env","dotenv"].includes(t)?".env":["cs","csharp"].includes(t)?"C#":t.charAt(0).toUpperCase()+t.slice(1):""}function Kr(e={}){const t=new Ir({html:!1,breaks:!0,linkify:!0,typographer:!1}),n=t.renderer.rules.link_open,o=t.renderer.rules.table_open,s=t.renderer.rules.table_close,r=t.renderer.rules.fence;return t.renderer.rules.link_open=(l,c,p,w,d)=>{const m=l[c];return m.attrSet("target","_blank"),m.attrSet("rel","noreferrer noopener"),typeof n=="function"?n(l,c,p,w,d):d.renderToken(l,c,p)},t.renderer.rules.table_open=(l,c,p,w,d)=>`<div class="codex-table-wrap">${typeof o=="function"?o(l,c,p,w,d):d.renderToken(l,c,p)}`,t.renderer.rules.table_close=(l,c,p,w,d)=>`${typeof s=="function"?s(l,c,p,w,d):d.renderToken(l,c,p)}</div>`,e.captureFences?t.renderer.rules.fence=(l,c,p,w={},d)=>{const m=l[c],f=Array.isArray(w.__promptxFences)?w.__promptxFences:[],b=f.length,v=`${ec}${b}__`;return f.push({content:String((m==null?void 0:m.content)||""),language:String((m==null?void 0:m.info)||"").trim().split(/\s+/)[0]||"",placeholder:v}),w.__promptxFences=f,v}:typeof r=="function"&&(t.renderer.rules.fence=r),t}const nc=Kr({captureFences:!0}),sc=Kr();async function oc(e="",t="",n={}){const o=String(e||"").replace(/\r\n/g,`
12
+ `):[],l=Po(r);if(!n)return{html:"",lineCount:0,bg:"",fg:"",gutterWidth:jr(0)};if(Do(l,t)||!s)return to(n);try{const c=await Fr();await Ur(c,o),await Vr(c,s);const p=await c.codeToTokens(n,{lang:s,theme:o});return Hr(p.tokens.map(S=>S.length?S.map(zr).join(""):"&#8203;"),{bg:p.bg||"",fg:p.fg||""})}catch{return to(n)}}const Zu=new Ir,ec="__PROMPTX_FENCE__";function qr(e=""){return String(e||"").trim().toLowerCase()}function ms(e=""){return Zu.utils.escapeHtml(String(e||""))}function tc(e=""){const t=qr(e);return t?["js","javascript"].includes(t)?"JavaScript":["jsx","react"].includes(t)?"React":["ts","typescript"].includes(t)?"TypeScript":t==="tsx"?"TSX":["sh","shell","zsh","bash","csh"].includes(t)?"Bash":t==="fish"?"Fish":["ps1","pwsh","powershell"].includes(t)?"PowerShell":t==="md"?"Markdown":t==="html"?"HTML":t==="vue"?"Vue":t==="svg"?"SVG":t==="json"?"JSON":t==="sql"?"SQL":t==="scss"?"SCSS":t==="sass"?"Sass":t==="less"?"Less":t==="toml"?"TOML":t==="ini"?"INI":["env","dotenv"].includes(t)?".env":["cs","csharp"].includes(t)?"C#":t.charAt(0).toUpperCase()+t.slice(1):""}function Kr(e={}){const t=new Ir({html:!1,breaks:!0,linkify:!0,typographer:!1}),n=t.renderer.rules.link_open,o=t.renderer.rules.table_open,s=t.renderer.rules.table_close,r=t.renderer.rules.fence;return t.renderer.rules.link_open=(l,c,p,S,d)=>{const m=l[c];return m.attrSet("target","_blank"),m.attrSet("rel","noreferrer noopener"),typeof n=="function"?n(l,c,p,S,d):d.renderToken(l,c,p)},t.renderer.rules.table_open=(l,c,p,S,d)=>`<div class="codex-table-wrap">${typeof o=="function"?o(l,c,p,S,d):d.renderToken(l,c,p)}`,t.renderer.rules.table_close=(l,c,p,S,d)=>`${typeof s=="function"?s(l,c,p,S,d):d.renderToken(l,c,p)}</div>`,e.captureFences?t.renderer.rules.fence=(l,c,p,S={},d)=>{const m=l[c],f=Array.isArray(S.__promptxFences)?S.__promptxFences:[],b=f.length,v=`${ec}${b}__`;return f.push({content:String((m==null?void 0:m.content)||""),language:String((m==null?void 0:m.info)||"").trim().split(/\s+/)[0]||"",placeholder:v}),S.__promptxFences=f,v}:typeof r=="function"&&(t.renderer.rules.fence=r),t}const nc=Kr({captureFences:!0}),sc=Kr();async function oc(e="",t="",n={}){const o=String(e||"").replace(/\r\n/g,`
13
13
  `),s=qr(t),r=Us(s),c=(await Ju(o.split(`
14
14
  `),{isDark:!!n.isDark,language:r||s})).join(`
15
- `),p=s?` class="language-${ms(s)}"`:"",w=tc(t),d=ms(String(n.copyLabel||"Copy")),m=ms(String(n.copyAriaLabel||d)),b=`<div class="codex-code-block__header">${w?`<span class="codex-code-block__language">${ms(w)}</span>`:'<span class="codex-code-block__language-placeholder" aria-hidden="true"></span>'}<button type="button" class="codex-code-block__copy" data-copy-code="1" aria-label="${m}">${d}</button></div>`;return`<div class="${w?"codex-code-block codex-code-block--labeled":"codex-code-block"}">${b}<pre><code${p}>${c}</code></pre></div>`}async function rc(e="",t=[],n={}){if(!Array.isArray(t)||!t.length)return e;const o=await Promise.all(t.map(s=>oc(s.content,s.language,n)));return t.reduce((s,r,l)=>s.replace(r.placeholder,o[l]||r.placeholder),e)}async function ac(e="",t={}){const n=String(e||"").trim();if(!n)return"";const o={},s=nc.render(n,o);return rc(s,o.__promptxFences||[],t)}function Wr(e=""){const t=String(e||"").trim();return t?sc.render(t):""}function ic(e=""){let t=5381;for(const n of String(e||""))t=(t<<5)+t+n.charCodeAt(0),t|=0;return String(t>>>0)}function Ko(e={}){const t=String((e==null?void 0:e.id)||"").trim();return t?`id:${t}`:`${(e==null?void 0:e.type)||"block"}:${ic(JSON.stringify(e||{}))}`}function lc(e=[]){const t=Array.isArray(e)?e:[],n=t.reduce((s,r)=>{const l=Ko(r);return s.set(l,(s.get(l)||0)+1),s},new Map),o=new Map;return t.map(s=>{const r=Ko(s),l=(o.get(r)||0)+1;return o.set(r,l),{key:`${r}:${l}`,signature:r,occurrence:l,duplicateCount:n.get(r)||1}})}const uc={key:0,class:"process-detail min-w-0 w-full max-w-full space-y-2"},cc={key:0,class:"process-detail-meta"},dc={key:0,class:"process-detail-meta__label"},fc={key:1,class:"process-detail-panel"},pc={class:"space-y-1.5"},mc={key:1,class:"process-detail-checklist__dot"},gc={key:0,class:"process-detail-footnote"},hc={key:0},vc={key:2,class:"process-detail-panel"},yc={class:"process-detail-directory__heading"},Sc={key:0,class:"font-medium"},wc={key:1,class:"process-detail-directory__type"},xc={class:"process-detail-directory__list"},bc={key:0,class:"process-detail-footnote"},kc={key:0},_c={key:3,class:"process-detail-panel"},Tc={class:"list-disc min-w-0 w-full max-w-full space-y-1.5 pl-5"},Cc={key:0,class:"process-detail-footnote"},Ec={key:4,class:"process-detail-panel"},Ac={class:"space-y-1.5"},$c={class:"process-detail-filechange__kind"},Ic={class:"process-detail-filechange__path process-detail-mobile-code-scroll"},Pc={key:5,class:"process-detail-panel"},Dc={class:"space-y-2"},Lc={class:"flex min-w-0 items-center gap-2 text-xs leading-5"},Bc={class:"min-w-0 flex flex-1 items-center gap-2"},Mc={class:"shrink-0 font-medium text-[var(--theme-textPrimary)]"},Rc=["title"],Nc=["onClick"],Oc={class:"process-detail-directory__type shrink-0"},jc={key:0,class:"mt-2 border-l border-dashed border-[var(--theme-borderDefault)] pl-3"},Fc={key:1,class:"whitespace-pre-wrap break-words text-xs leading-5"},Uc=["innerHTML"],Vc={key:7,class:"process-detail-text"},zc=Object.assign({name:"ProcessDetailRenderer"},{__name:"ProcessDetailRenderer",props:{blocks:{type:Array,default:()=>[]},kind:{type:String,default:""},detail:{type:String,default:""}},setup(e){const t=e,{t:n}=St(),o=q(new Set),s=W(()=>{const I=Array.isArray(t.blocks)?t.blocks.filter(Boolean):[];return I.length?I:String(t.detail||"").trim()?[{type:"text",text:String(t.detail||"").trim()}]:[]}),r=W(()=>lc(s.value)),l=W(()=>r.value.map(I=>I.key));$e(s,(I=[])=>{const Q=new Set;I.forEach((le,ie)=>{(le==null?void 0:le.type)==="sub_agent_list"&&(Array.isArray(le.items)?le.items:[]).forEach((ve,_)=>{Q.add(se(ie,ve,_))})}),o.value=new Set([...o.value].filter(le=>Q.has(le)))},{immediate:!0});function c(I=""){return Wr(String(I||""))}function p(I=""){const Q=String(I||"").trim();return n(Q==="create"?"processDetail.changeCreate":Q==="delete"?"processDetail.changeDelete":Q==="update"?"processDetail.changeUpdate":"processDetail.changeGeneric")}function w(I={}){const Q=String((I==null?void 0:I.label)||"").trim().toLowerCase(),le=String((I==null?void 0:I.value)||"").trim();return le?le.length>56||["命令","command","目标","target","url","路径","path"].includes(Q)&&le.length>28?!0:le.includes(" ")&&le.length>36:!1}function d(I={},Q=[]){const le=String((I==null?void 0:I.label)||"").trim().toLowerCase();return["命令","command"].includes(le)?Array.isArray(Q)&&Q.length===1:!1}function m(I={}){const Q=String((I==null?void 0:I.label)||"").trim().toLowerCase();return["命令","command","路径","path","url","目标","target"].includes(Q)}function f(I={}){return I!=null&&I.completed?"completed":String((I==null?void 0:I.status)||"").trim().toLowerCase()==="in_progress"?"in_progress":"pending"}function b(I=0){return n("processDetail.hiddenItems",{count:I})}function v(I=0){return n("processDetail.directorySummary",{count:I})}function P(I=0){return n("processDetail.directoryHidden",{count:I})}function ne(I=0){return l.value[I]||`block-${I}`}function y(I=""){const Q=String(I||"").trim().toLowerCase();return n(Q==="completed"?"processDetail.subAgentCompleted":Q==="failed"?"processDetail.subAgentFailed":Q==="running"?"processDetail.subAgentRunning":Q==="pending_init"?"processDetail.subAgentPending":"processDetail.subAgentUnknown")}function L(I={}){return String((I==null?void 0:I.title)||(I==null?void 0:I.target)||(I==null?void 0:I.id)||"").trim()}function O(I={}){const Q=L(I),le=[],ie=String((I==null?void 0:I.role)||"").trim(),ve=String((I==null?void 0:I.target)||"").trim(),_=String((I==null?void 0:I.model)||"").trim();return ie&&ie.toLowerCase()!=="default"&&le.push(ie),ve&&ve!==Q&&le.push(ve),_&&le.push(_),le.join(" · ")}function z(I={}){return!!String((I==null?void 0:I.message)||"").trim()}function U(I={}){const Q=String((I==null?void 0:I.message)||"").replace(/\s+/g," ").trim();return Q||O(I)}function se(I=0,Q={},le=0){return`${ne(I)}:sub-agent:${String((Q==null?void 0:Q.id)||(Q==null?void 0:Q.target)||(Q==null?void 0:Q.title)||le)}`}function A(I=0,Q={},le=0){return o.value.has(se(I,Q,le))}function G(I=0,Q={},le=0){const ie=se(I,Q,le),ve=new Set(o.value);ve.has(ie)?ve.delete(ie):ve.add(ie),o.value=ve}function ce(I={}){return Array.isArray(I==null?void 0:I.messageBlocks)?I.messageBlocks.filter(Boolean):[]}function pe(I={}){return ce(I).some(le=>!["text","markdown"].includes(String((le==null?void 0:le.type)||"").trim()))}return(I,Q)=>{const le=ka("ProcessDetailRenderer",!0);return s.value.length?(g(),x("div",uc,[(g(!0),x(et,null,ut(s.value,(ie,ve)=>(g(),x(et,{key:l.value[ve]||`${ie.type}-${ve}`},[ie.type==="meta"?(g(),x("div",cc,[(g(!0),x(et,null,ut(ie.items||[],(_,H)=>(g(),x("div",{key:`${ve}-meta-${H}`,class:Se(["process-detail-meta__item",{"process-detail-meta__item--long":w(_),"process-detail-meta__item--value-only":d(_,ie.items)}])},[d(_,ie.items)?me("",!0):(g(),x("span",dc,S(_.label),1)),i("span",{class:Se(["process-detail-meta__value",{"process-detail-mobile-code-scroll":w(_),"process-detail-meta__value--mono":m(_)}])},S(_.value),3)],2))),128))])):ie.type==="checklist"?(g(),x("div",fc,[i("div",pc,[(g(!0),x(et,null,ut(ie.items||[],(_,H)=>(g(),x("div",{key:`${ve}-check-${H}`,class:"process-detail-checklist__item"},[i("span",{class:Se(["process-detail-checklist__icon",`is-${f(_)}`])},[f(_)==="completed"?(g(),Ce(a(Cr),{key:0,class:"h-3 w-3"})):f(_)==="in_progress"?(g(),x("span",mc)):me("",!0)],2),i("span",{class:Se(f(_)==="completed"?"line-through":"")},S(_.text),3)]))),128))]),ie.totalCount?(g(),x("div",gc,[an(S(`已完成 ${(ie.items||[]).filter(_=>_.completed).length} / ${ie.totalCount}`)+" ",1),ie.hiddenCount?(g(),x("span",hc,S(`,还有 ${ie.hiddenCount} 项`),1)):me("",!0)])):me("",!0)])):ie.type==="directory_list"?(g(),x("div",vc,[i("div",yc,[ie.path?(g(),x("span",Sc,S(ie.path),1)):me("",!0),ie.entryType?(g(),x("span",wc,S(ie.entryType),1)):me("",!0)]),i("div",xc,[(g(!0),x(et,null,ut(ie.entries||[],(_,H)=>(g(),x("div",{key:`${ve}-entry-${H}`,class:"process-detail-directory__item"},S(_),1))),128))]),ie.totalCount?(g(),x("div",bc,[an(S(v(ie.totalCount))+" ",1),ie.hiddenCount?(g(),x("span",kc,S(P(ie.hiddenCount)),1)):me("",!0)])):me("",!0)])):ie.type==="bullet_list"?(g(),x("div",_c,[i("ul",Tc,[(g(!0),x(et,null,ut(ie.items||[],(_,H)=>(g(),x("li",{key:`${ve}-bullet-${H}`,class:"min-w-0 w-full max-w-full break-words [overflow-wrap:anywhere]"},S(_),1))),128))]),ie.hiddenCount?(g(),x("div",Cc,S(b(ie.hiddenCount)),1)):me("",!0)])):ie.type==="file_changes"?(g(),x("div",Ec,[i("div",Ac,[(g(!0),x(et,null,ut(ie.items||[],(_,H)=>(g(),x("div",{key:`${ve}-change-${H}`,class:"process-detail-filechange__item"},[i("span",$c,S(p(_.kind)),1),i("span",Ic,S(_.path),1)]))),128))])])):ie.type==="sub_agent_list"?(g(),x("div",Pc,[i("div",Dc,[(g(!0),x(et,null,ut(ie.items||[],(_,H)=>(g(),x("div",{key:`${ve}-sub-agent-${H}`,class:"min-w-0"},[i("div",Lc,[i("div",Bc,[i("span",Mc,S(L(_)),1),U(_)?(g(),x("span",{key:0,class:"process-detail-subagent__preview min-w-0 flex-1",title:U(_)},S(U(_)),9,Rc)):me("",!0)]),z(_)?(g(),x("button",{key:0,type:"button",class:"shrink-0 text-[11px] underline decoration-dashed underline-offset-2",onClick:F=>G(ve,_,H)},S(A(ve,_,H)?a(n)("common.collapse"):a(n)("common.expand")),9,Nc)):me("",!0),i("span",Oc,S(y(_.status)),1)]),z(_)&&A(ve,_,H)?(g(),x("div",jc,[pe(_)?(g(),Ce(le,{key:0,blocks:ce(_),kind:"sub-agent-message"},null,8,["blocks"])):(g(),x("pre",Fc,S(_.message),1))])):me("",!0)]))),128))])])):ie.type==="markdown"?(g(),x("div",{key:6,class:Se(["codex-markdown process-detail-markdown",{"process-detail-markdown--reasoning":t.kind==="reasoning"}]),innerHTML:c(ie.text)},null,10,Uc)):(g(),x("pre",Vc,S(ie.text),1))],64))),128))])):me("",!0)}}}),Gr={__name:"SelectionInsertButton",props:{label:{type:String,default:""},top:{type:Number,default:0},left:{type:Number,default:0}},emits:["click"],setup(e,{emit:t}){function n(s){var r,l;typeof(s==null?void 0:s.button)=="number"&&s.button!==0||((r=s==null?void 0:s.preventDefault)==null||r.call(s),(l=s==null?void 0:s.stopPropagation)==null||l.call(s),o("click"))}const o=t;return(s,r)=>(g(),x("button",{type:"button",class:"tool-button tool-button-primary absolute z-20 inline-flex items-center gap-2 px-3 py-1.5 text-xs shadow-sm",style:kn({top:`${e.top}px`,left:`${e.left}px`}),onPointerdown:n,onKeydown:[r[0]||(r[0]=Gt(Qe(l=>o("click"),["prevent"]),["enter"])),r[1]||(r[1]=Gt(Qe(l=>o("click"),["prevent"]),["space"]))]},S(e.label),37))}},Xr=96,Wo=34,rn=8,Hc=72;function qc(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement||null:null}function Go(e,t,n){var r;const o=qc(e);if(!o||!n)return null;const s=(r=o.closest)==null?void 0:r.call(o,t);return s&&n.contains(s)?s:null}function Kc(e){const t=(e==null?void 0:e.commonAncestorContainer)||null;return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentNode||null:null}function Wc(e,t,{codeLeft:n=0,buttonWidth:o=Xr,scrollTop:s=0,scrollLeft:r=0,clientWidth:l=0,clientHeight:c=0}={}){const w=Math.max(e.left||0,Number(n)||0)-t.left+r,d=r+rn,m=r+Math.max(rn,l-o-rn),f=Math.max(d,Math.min(m,w||r+rn)),b=e.bottom-t.top+s+rn,v=e.top-t.top+s-Wo-rn,P=s+rn,ne=s+c-rn;return{top:b+Wo<=ne?b:Math.max(P,v),left:f}}function Yr(e={}){const t=q([]),n=q({visible:!1,top:0,left:0,content:""});let o=null,s=0;function r(){var z;return typeof e.getContainer=="function"?e.getContainer():((z=e.containerRef)==null?void 0:z.value)||null}function l(){return typeof e.getPositionContainer=="function"?e.getPositionContainer():r()}function c(){o&&(window.clearTimeout(o),o=null)}function p(){s&&(window.cancelAnimationFrame(s),s=0)}function w(z=[]){var U;t.value=z,(U=e.onSelectedRowsChange)==null||U.call(e,z)}function d({clearBrowserSelection:z=!1}={}){var U,se,A,G;c(),p(),z&&((A=(se=(U=window.getSelection)==null?void 0:U.call(window))==null?void 0:se.removeAllRanges)==null||A.call(se)),n.value={visible:!1,top:0,left:0,content:""},w([]),(G=e.onClear)==null||G.call(e)}function m(z){return z?typeof e.getOrderedRowElements=="function"?e.getOrderedRowElements(z).filter(Boolean):[...z.querySelectorAll(String(e.rowSelector||""))]:[]}function f(z){var U;return((U=e.mapRowElement)==null?void 0:U.call(e,z))??z}function b(z,U,se){const A=String(e.rowSelector||"").trim(),G=m(se);if(!A||!G.length)return[];const ce=Go(z.anchorNode,A,se),pe=Go(z.focusNode,A,se);if(ce&&pe){const I=G.indexOf(ce),Q=G.indexOf(pe);if(I>=0&&Q>=0){const[le,ie]=I<=Q?[I,Q]:[Q,I];return G.slice(le,ie+1)}}return G.filter(I=>{try{return U.intersectsNode(I)}catch{return!1}})}function v(){var H,F,He;const z=(H=window.getSelection)==null?void 0:H.call(window),U=r(),se=l();if(!(typeof e.isActive=="function"?e.isActive():!0)||!z||z.rangeCount<1||z.isCollapsed||!U||!se){d();return}const G=z.getRangeAt(0),ce=Kc(G);if(!ce||!U.contains(ce)){d();return}const pe=String(z.toString()||"").replace(/\u200b/g,"");if(!pe.trim()){d();return}const I=b(z,G,U);if(!I.length){d();return}const Q=I.map(De=>f(De)).filter(De=>De!==null&&typeof De<"u");if(!Q.length){d();return}const le=G.getBoundingClientRect(),ie=(F=se.getBoundingClientRect)==null?void 0:F.call(se);if(!ie){d();return}const ve=((He=e.getCodeLeft)==null?void 0:He.call(e,I[0]))||le.left,_=Wc(le,ie,{codeLeft:ve,buttonWidth:Number(e.buttonWidth||Xr),scrollTop:Number(se.scrollTop||0),scrollLeft:Number(se.scrollLeft||0),clientWidth:Number(se.clientWidth||0),clientHeight:Number(se.clientHeight||0)});n.value={visible:!0,top:_.top,left:_.left,content:pe},w(Q)}function P(){c(),o=window.setTimeout(()=>{o=null,v()},Number(e.debounceMs||Hc))}function ne(){P()}function y(){P()}function L(){!n.value.visible||s||(s=window.requestAnimationFrame(()=>{s=0,v()}))}function O(){L()}return dn(()=>{var z,U,se,A;document.addEventListener("selectionchange",y),document.addEventListener("mouseup",y),document.addEventListener("scroll",O,!0),window.addEventListener("resize",O),(U=(z=window.visualViewport)==null?void 0:z.addEventListener)==null||U.call(z,"resize",O),(A=(se=window.visualViewport)==null?void 0:se.addEventListener)==null||A.call(se,"scroll",O)}),It(()=>{var z,U,se,A;d({clearBrowserSelection:!0}),document.removeEventListener("selectionchange",y),document.removeEventListener("mouseup",y),document.removeEventListener("scroll",O,!0),window.removeEventListener("resize",O),(U=(z=window.visualViewport)==null?void 0:z.removeEventListener)==null||U.call(z,"resize",O),(A=(se=window.visualViewport)==null?void 0:se.removeEventListener)==null||A.call(se,"scroll",O)}),{selectedRows:t,selectionAction:n,clearSelectionState:d,clearScheduledSelectionUpdate:c,handleSelectionMouseUp:ne,scheduleSelectionUpdate:P,updateSelectionActionFromDom:v}}const Gc=250,Xc=350,Yc=180,bs=2;function Jr(e){return(e==null?void 0:e.name)==="AbortError"}const no="promptx:codex-recent-paths",Jc=12;function Qr(e){const{getMode:t,props:n,onSelect:o}=e,s=q([]),r=q(!1),l=q(""),c=q([]),p=q(!1),w=q(""),d=q([]),m=q([]),f=q("tree"),b=q(""),v=new Map;let P=null,ne=0,y=0,L=null;const O=W(()=>String(n.query||"").trim()),z=W(()=>Math.max(1,Number(e.minimumQueryLength)||bs)),U=W(()=>O.value.length>=z.value),se=W(()=>typeof t=="function"),A=W(()=>se.value?String((t==null?void 0:t())||"").trim()==="search"?"search":"tree":f.value),G=W(()=>tt(s.value)),ce=W(()=>String(n.sessionId||"").trim()),pe=W(()=>ce.value?`promptx:codex-tree-expanded:${ce.value}`:""),I=W(()=>{if(!O.value)return d.value;const V=new Set(c.value.map(X=>X.path));return d.value.filter(X=>V.has(X.path))}),Q=W(()=>{const V=new Set(I.value.map(X=>X.path));return c.value.filter(X=>!V.has(X.path))}),le=W(()=>O.value?[...I.value,...Q.value]:d.value),ie=W(()=>A.value==="search"?le.value:G.value),ve=W(()=>A.value==="search"?p.value:r.value),_=W(()=>A.value==="search"?w.value:l.value),H=W(()=>A.value==="search"&&!!n.sessionId&&U.value&&!p.value&&!w.value&&!le.value.length),F=W(()=>A.value==="search"&&!!n.sessionId&&!!O.value&&!U.value&&!p.value&&!w.value),He=W(()=>A.value==="tree"&&!!n.sessionId&&!r.value&&!l.value&&!G.value.length);function De(V,X){if(!V||typeof window>"u")return X;try{const de=window.localStorage.getItem(V);return de?JSON.parse(de):X}catch{return X}}function Fe(V,X){if(!(!V||typeof window>"u"))try{window.localStorage.setItem(V,JSON.stringify(X))}catch{}}function je(V=[]){return[...V].sort((X,de)=>{const he=+(X.type!=="directory")-+(de.type!=="directory");return he||String(X.path||X.name||"").localeCompare(String(de.path||de.name||""),"zh-CN")})}function Ke(V){return{...V,children:[],expanded:!1,loaded:!1,loading:!1}}function tt(V=[],X=0,de=[]){return V.forEach(he=>{de.push({...he,depth:X}),he.type==="directory"&&he.expanded&&he.children.length&&tt(he.children,X+1,de)}),de}function xe(V,X=s.value){for(const de of X){if(de.path===V)return de;if(de.children.length){const he=xe(V,de.children);if(he)return he}}return null}function R(){s.value=[...s.value]}function J(){P&&(window.clearTimeout(P),P=null),L&&(L.abort(),L=null)}function fe(V=s.value,X=[]){return V.forEach(de=>{de.type==="directory"&&de.expanded&&(X.push(de.path),de.children.length&&fe(de.children,X))}),X}function _e(){if(!pe.value)return;const V=[...new Set(fe())];m.value=V,Fe(pe.value,V)}function ge(){m.value=pe.value?De(pe.value,[]).filter(Boolean):[]}function Ie(V=s.value,X=new Set){if(!X.size)return!1;const de=V.filter(he=>he.type==="directory"&&he.hasChildren).map(he=>he.path);return!de.length||de.length!==X.size?!1:de.every(he=>X.has(he))}function Ae(){const V=De(no,[]);if(!Array.isArray(V)||!ce.value){d.value=[];return}d.value=V.filter(X=>X&&X.sessionId===ce.value&&X.path).sort((X,de)=>Number(de.usedAt||0)-Number(X.usedAt||0)).slice(0,Jc)}function Be(V){return V.name||V.path||"."}function Xe(V){return V.path||"."}function Pe(V){if(!ce.value||!(V!=null&&V.path))return;const X={sessionId:ce.value,path:V.path,name:V.name||Be(V),type:V.type||"file",usedAt:Date.now()},de=De(no,[]),he=[X];Array.isArray(de)&&de.forEach(Ue=>{!(Ue!=null&&Ue.path)||!(Ue!=null&&Ue.sessionId)||Ue.sessionId===X.sessionId&&Ue.path===X.path||he.push(Ue)}),Fe(no,he.slice(0,40)),Ae()}function it(V=""){const X=String(V||"").trim();return!X||!X.includes("/")?"":X.slice(0,X.lastIndexOf("/"))}function Me(){const V=ie.value;if(!V.length)return-1;const X=V.findIndex(de=>de.path===b.value);return X>=0?X:0}function Ne(){const V=ie.value,X=Me();return X<0||!V.length?null:V[X]||null}function Ee(){const V=ie.value;if(!V.length){b.value="";return}V.some(X=>X.path===b.value)||(b.value=V[0].path)}function lt(V,X){if(X){v.set(V,X);return}v.delete(V)}function ht(){var X;const V=v.get(b.value);(X=V==null?void 0:V.scrollIntoView)==null||X.call(V,{block:"nearest"})}function dt(V=""){return String(V||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function wt(V="",X=""){const de=String(V||""),he=String(X||"").trim().toLowerCase();if(!de||!he)return null;const Ue=de.toLowerCase(),Tt=Ue.indexOf(he);if(Tt>=0)return{start:Tt,end:Tt+he.length};const qt=he.split(/[\\/\s_.-]+/).filter(Boolean).sort((At,Ot)=>Ot.length-At.length);for(const At of qt){if(At.length<2)continue;const Ot=Ue.indexOf(At);if(Ot>=0)return{start:Ot,end:Ot+At.length}}return null}function Ct(V="",X=""){const de=String(V||""),he=wt(de,X);return he?`${dt(de.slice(0,he.start))}<mark class="theme-search-highlight">${dt(de.slice(he.start,he.end))}</mark>${dt(de.slice(he.end))}`:dt(de)}function T(V){return Ct(Be(V),O.value)}function j(V){return Ct(Xe(V),O.value)}async function te(V="",X={}){if(!n.sessionId){s.value=[],l.value="",r.value=!1;return}const de=!V,he=de?null:xe(V);if(!(!de&&!he)&&!(!X.force&&(de&&s.value.length||!de&&he.loaded))){de?(r.value=!0,l.value=""):(he.loading=!0,l.value="",R());try{const Ue=await Qi(n.sessionId,{path:V,refreshToken:X.refreshToken||""}),Tt=je(Ue.items||[]).map(Ke);if(de){s.value=Tt;return}he.children=Tt,he.loaded=!0}catch(Ue){l.value=Ue.message}finally{de?r.value=!1:(he.loading=!1,R())}}}async function ye(V=s.value,X=new Set,de={}){for(const he of V)he.type!=="directory"||!X.has(he.path)||(he.expanded=!0,R(),await te(he.path,de),he.children.length&&await ye(he.children,X,de))}async function Oe(V={}){await te("",V);const X=new Set(m.value),de=Ie(s.value,X),he=X.size>0&&!de;de&&(m.value=[],Fe(pe.value,[]),X.clear());for(const Ue of s.value)Ue.type!=="directory"||!Ue.hasChildren||(Ue.expanded=he?X.has(Ue.path):!1);if(R(),he){await ye(s.value,X,V);return}}async function Re(V){if(A.value!=="tree")return;const X=xe(V);if(!(!X||X.type!=="directory")){if(!X.loaded&&!X.loading){X.expanded=!0,R(),await te(X.path),_e();return}X.expanded=!X.expanded,R(),_e()}}function Ge(V){return V!=null&&V.path?(Pe(V),o==null||o(V),!0):!1}async function Ye(V={}){const X=O.value;ne+=1;const de=ne,he=V.refreshToken||"";if(J(),!n.open||!n.sessionId||!X||!U.value){p.value=!1,w.value="",c.value=[];return}L=new AbortController;try{const Ue=await Zi(n.sessionId,X,{limit:80,refreshToken:he,signal:L.signal});if(de!==ne)return;c.value=Ue.items||[]}catch(Ue){if(Jr(Ue)||de!==ne)return;w.value=Ue.message,c.value=[]}finally{de===ne&&(L=null),de===ne&&(p.value=!1)}}function nt(V={}){if(J(),!n.open||!n.sessionId||!O.value||!U.value){p.value=!1,w.value="",c.value=[];return}p.value=!0,w.value="",P=window.setTimeout(()=>{P=null,Ye(V)},Gc)}function yt(){if(!n.sessionId){s.value=[],l.value="",r.value=!1,c.value=[],w.value="",p.value=!1;return}y=Date.now(),s.value=[],l.value="",c.value=[],w.value="",Oe({force:!0,refreshToken:y}),nt({refreshToken:y})}function st(){if(se.value)return!1;const V=O.value?"search":"tree";return f.value===V?!1:(f.value=V,!0)}function ft(){Ae(),ge(),st(),yt()}function _t(){J(),c.value=[],w.value="",p.value=!1}function Bt(V){const X=ie.value;if(!X.length)return!1;const de=Me(),he=de<0?0:(de+V+X.length)%X.length;return b.value=X[he].path,at(ht),!0}async function re(){if(A.value!=="tree")return!1;const V=Ne();if(!V||V.type!=="directory")return!1;if(!V.expanded)return await Re(V.path),b.value=V.path,!0;const X=ie.value,de=Me(),he=X[de+1];return he&&it(he.path)===V.path?(b.value=he.path,!0):!1}function Le(){if(A.value!=="tree")return!1;const V=Ne();if(!V)return!1;if(V.type==="directory"&&V.expanded){const de=xe(V.path);return de&&(de.expanded=!1,R(),_e()),b.value=V.path,!0}const X=it(V.path);return X?(b.value=X,!0):!1}function ot(){const V=ie.value;return V.length?Ge(V[Me()]):!1}function xt(){s.value=[],l.value="",r.value=!1,c.value=[],w.value="",p.value=!1,Ae(),ge(),n.sessionId&&n.open&&(Oe({force:!0}),nt())}function Et(){st(),nt()}function pt(){Ee(),at(ht)}return It(()=>{J()}),{activeKey:b,collapseActiveDirectory:Le,confirmActive:ot,currentError:_,currentLoading:ve,emitSelect:Ge,expandActiveDirectory:re,getDisplayName:Be,getHighlightedName:T,getHighlightedPath:j,handleQueryChange:Et,handleSessionChange:xt,handleVisibleItemsChange:pt,initializeData:ft,moveActive:Bt,normalSearchItems:Q,normalizedQuery:O,recentSearchItems:I,resetData:_t,setItemRef:lt,showSearchPromptState:F,showSearchEmptyState:H,showTreeEmptyState:He,toggleDirectory:Re,treeItems:G,visibleItems:ie}}const Qc={class:"min-w-0"},Zc={class:"theme-heading truncate text-sm font-medium"},ed={class:"source-browser-layout grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[21rem_minmax(0,1fr)]"},td={class:"theme-divider border-b px-4 py-3"},nd={class:"block"},sd={class:"sr-only"},od={class:"relative"},rd=["placeholder","onKeydown"],ad=["title","aria-label"],id={class:"min-h-0 flex-1 overflow-y-auto p-2"},ld={key:0,class:"theme-empty-state px-3 py-4 text-[12px]"},ud={key:1,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},cd={key:2,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},dd={key:3,class:"theme-empty-state px-3 py-4 text-[12px]"},fd={key:4,class:"theme-empty-state px-3 py-4 text-[12px]"},pd={key:5,class:"theme-empty-state px-3 py-4 text-[12px]"},md={key:6,class:"theme-empty-state px-3 py-4 text-[12px]"},gd={key:7,class:"theme-empty-state px-3 py-4 text-[12px]"},hd={key:8,class:"theme-empty-state px-3 py-4 text-[12px]"},vd={key:9,class:"theme-empty-state px-3 py-4 text-[12px]"},yd={key:10,class:"theme-empty-state px-3 py-4 text-[12px]"},Sd={key:11,class:"space-y-1"},wd={key:0,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},xd=["onClick"],bd={class:"min-w-0 flex-1"},kd=["innerHTML"],_d=["innerHTML"],Td={key:1,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},Cd=["onClick"],Ed={class:"min-w-0 flex-1"},Ad=["innerHTML"],$d=["innerHTML"],Id={key:12,class:"space-y-3"},Pd={class:"theme-divider flex items-start gap-2.5 border-b px-3 py-2.5"},Dd={class:"min-w-0 flex-1"},Ld={class:"theme-list-item-title theme-list-item-title--strong break-all"},Bd={key:0,class:"theme-list-item-meta truncate"},Md={class:"theme-list-item-meta shrink-0 pt-0.5"},Rd={class:"space-y-1 px-2 py-2"},Nd=["onClick"],Od=["innerHTML"],jd={key:0,class:"theme-muted-text px-1 text-[12px]"},Fd={key:13,class:"space-y-1"},Ud=["onClick"],Vd={class:"flex items-start gap-1.5"},zd=["onClick"],Hd={key:1,class:"block h-5 w-5 shrink-0"},qd=["onClick"],Kd={class:"flex min-h-0 flex-col overflow-hidden"},Wd={class:"theme-divider border-b px-4 py-2"},Gd={class:"flex items-center justify-between gap-3"},Xd={class:"min-w-0"},Yd={key:0,class:"theme-muted-text truncate text-[12px]"},Jd={key:1,class:"theme-muted-text mt-1 text-[11px]"},Qd={class:"min-h-0 flex-1 overflow-auto px-4 py-3"},Zd={key:0,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},ef={key:1,class:"theme-status-danger rounded-sm border px-4 py-3 text-[12px]"},tf={key:2,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},nf={key:3,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},sf={key:4,class:"source-browser-image-wrap flex h-full min-h-[12rem] items-center justify-center overflow-hidden rounded-sm border p-4"},of=["src","alt"],rf={key:5,class:"theme-empty-state flex h-full min-h-[12rem] flex-col items-center justify-center gap-3 text-[12px]"},af={class:"source-code-view"},lf={class:"source-code-view__table"},uf=["innerHTML"],cf=20,df={__name:"CodexSessionSourceBrowserDialog",props:{open:{type:Boolean,default:!1},session:{type:Object,default:null}},emits:["close","insert-code-context"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),{isDark:r}=kr(),l=rs({open:!1,sessionId:"",query:""}),c=q(""),p=q(""),w=q(!1),d=q(""),m=q(null),f=q(""),b=q("path"),v=q([]),P=q(!1),ne=q(""),y=q(""),L=q(!1),O=q(""),z=new Map,U=q(null),se=q(null),A=q(0),G=q([]),ce=q("");let pe=0,I=0,Q=null,le=null;const ie=Xc,ve=Yc;let _=null;const H=new Map,F=W(()=>{var u;return String(((u=n.session)==null?void 0:u.id)||"").trim()}),He=W(()=>{var u;return String(((u=n.session)==null?void 0:u.cwd)||"").trim()}),De=W(()=>b.value!=="content"),Fe=W(()=>b.value==="content"),je=W(()=>String(f.value||"").trim()),Ke=W(()=>je.value.length>=bs),tt=W(()=>{var u;return((u=m.value)==null?void 0:u.name)||c.value||""}),xe=W(()=>{var u;return((u=m.value)==null?void 0:u.path)||c.value||""}),R=W(()=>{var u;return Ut(((u=m.value)==null?void 0:u.size)||0)}),J=W(()=>{var C,B;const u=[];return(xe.value||tt.value)&&u.push(xe.value||tt.value),(C=m.value)!=null&&C.size&&u.push(R.value),(B=m.value)!=null&&B.truncated&&u.push(s("sourceBrowser.truncated")),u.join(" ")}),fe=W(()=>{var u;return!!((u=m.value)!=null&&u.previewUrl)}),_e=W(()=>{var u,C;return!!((u=m.value)!=null&&u.binary&&!((C=m.value)!=null&&C.previewUrl))}),ge=W(()=>!!(m.value&&!m.value.binary&&!m.value.previewUrl)),Ie=q(""),Ae=q(""),Be=q(""),Xe=q("2.6rem"),{selectedRows:Pe,selectionAction:it,clearSelectionState:Me,handleSelectionMouseUp:Ne,updateSelectionActionFromDom:Ee}=Yr({getContainer:()=>se.value,isActive:()=>n.open&&ge.value,rowSelector:".source-code-view__line",mapRowElement:u=>{var B;const C=Number(((B=u==null?void 0:u.getAttribute)==null?void 0:B.call(u,"data-line"))||0);return C>0?C:null},getCodeLeft:u=>{var Te,qe,Ve;const C=(Te=u==null?void 0:u.querySelector)==null?void 0:Te.call(u,".source-code-view__code");if(!C)return 0;const B=(qe=C.getBoundingClientRect)==null?void 0:qe.call(C),M=(Ve=window.getComputedStyle)==null?void 0:Ve.call(window,C),oe=Number.parseFloat((M==null?void 0:M.paddingLeft)||"0")||0;return((B==null?void 0:B.left)||0)+oe},debounceMs:72}),lt=W(()=>[...new Set(Pe.value)].map(u=>Number(u)||0).filter(u=>u>0).sort((u,C)=>u-C)),ht=W(()=>{var B;const u=String(((B=m.value)==null?void 0:B.content)||"").replace(/\r\n/g,`
15
+ `),p=s?` class="language-${ms(s)}"`:"",S=tc(t),d=ms(String(n.copyLabel||"Copy")),m=ms(String(n.copyAriaLabel||d)),b=`<div class="codex-code-block__header">${S?`<span class="codex-code-block__language">${ms(S)}</span>`:'<span class="codex-code-block__language-placeholder" aria-hidden="true"></span>'}<button type="button" class="codex-code-block__copy" data-copy-code="1" aria-label="${m}">${d}</button></div>`;return`<div class="${S?"codex-code-block codex-code-block--labeled":"codex-code-block"}">${b}<pre><code${p}>${c}</code></pre></div>`}async function rc(e="",t=[],n={}){if(!Array.isArray(t)||!t.length)return e;const o=await Promise.all(t.map(s=>oc(s.content,s.language,n)));return t.reduce((s,r,l)=>s.replace(r.placeholder,o[l]||r.placeholder),e)}async function ac(e="",t={}){const n=String(e||"").trim();if(!n)return"";const o={},s=nc.render(n,o);return rc(s,o.__promptxFences||[],t)}function Wr(e=""){const t=String(e||"").trim();return t?sc.render(t):""}function ic(e=""){let t=5381;for(const n of String(e||""))t=(t<<5)+t+n.charCodeAt(0),t|=0;return String(t>>>0)}function Ko(e={}){const t=String((e==null?void 0:e.id)||"").trim();return t?`id:${t}`:`${(e==null?void 0:e.type)||"block"}:${ic(JSON.stringify(e||{}))}`}function lc(e=[]){const t=Array.isArray(e)?e:[],n=t.reduce((s,r)=>{const l=Ko(r);return s.set(l,(s.get(l)||0)+1),s},new Map),o=new Map;return t.map(s=>{const r=Ko(s),l=(o.get(r)||0)+1;return o.set(r,l),{key:`${r}:${l}`,signature:r,occurrence:l,duplicateCount:n.get(r)||1}})}const uc={key:0,class:"process-detail min-w-0 w-full max-w-full space-y-2"},cc={key:0,class:"process-detail-meta"},dc={key:0,class:"process-detail-meta__label"},fc={key:1,class:"process-detail-panel"},pc={class:"space-y-1.5"},mc={key:1,class:"process-detail-checklist__dot"},gc={key:0,class:"process-detail-footnote"},hc={key:0},vc={key:2,class:"process-detail-panel"},yc={class:"process-detail-directory__heading"},Sc={key:0,class:"font-medium"},wc={key:1,class:"process-detail-directory__type"},xc={class:"process-detail-directory__list"},bc={key:0,class:"process-detail-footnote"},kc={key:0},_c={key:3,class:"process-detail-panel"},Tc={class:"list-disc min-w-0 w-full max-w-full space-y-1.5 pl-5"},Cc={key:0,class:"process-detail-footnote"},Ec={key:4,class:"process-detail-panel"},Ac={class:"space-y-1.5"},$c={class:"process-detail-filechange__kind"},Ic={class:"process-detail-filechange__path process-detail-mobile-code-scroll"},Pc={key:5,class:"process-detail-panel"},Dc={class:"space-y-2"},Lc={class:"flex min-w-0 items-center gap-2 text-xs leading-5"},Bc={class:"min-w-0 flex flex-1 items-center gap-2"},Mc={class:"shrink-0 font-medium text-[var(--theme-textPrimary)]"},Rc=["title"],Nc=["onClick"],Oc={class:"process-detail-directory__type shrink-0"},jc={key:0,class:"mt-2 border-l border-dashed border-[var(--theme-borderDefault)] pl-3"},Fc={key:1,class:"whitespace-pre-wrap break-words text-xs leading-5"},Uc=["innerHTML"],Vc={key:7,class:"process-detail-text"},zc=Object.assign({name:"ProcessDetailRenderer"},{__name:"ProcessDetailRenderer",props:{blocks:{type:Array,default:()=>[]},kind:{type:String,default:""},detail:{type:String,default:""}},setup(e){const t=e,{t:n}=St(),o=q(new Set),s=W(()=>{const I=Array.isArray(t.blocks)?t.blocks.filter(Boolean):[];return I.length?I:String(t.detail||"").trim()?[{type:"text",text:String(t.detail||"").trim()}]:[]}),r=W(()=>lc(s.value)),l=W(()=>r.value.map(I=>I.key));$e(s,(I=[])=>{const Q=new Set;I.forEach((le,ie)=>{(le==null?void 0:le.type)==="sub_agent_list"&&(Array.isArray(le.items)?le.items:[]).forEach((ve,_)=>{Q.add(se(ie,ve,_))})}),o.value=new Set([...o.value].filter(le=>Q.has(le)))},{immediate:!0});function c(I=""){return Wr(String(I||""))}function p(I=""){const Q=String(I||"").trim();return n(Q==="create"?"processDetail.changeCreate":Q==="delete"?"processDetail.changeDelete":Q==="update"?"processDetail.changeUpdate":"processDetail.changeGeneric")}function S(I={}){const Q=String((I==null?void 0:I.label)||"").trim().toLowerCase(),le=String((I==null?void 0:I.value)||"").trim();return le?le.length>56||["命令","command","目标","target","url","路径","path"].includes(Q)&&le.length>28?!0:le.includes(" ")&&le.length>36:!1}function d(I={},Q=[]){const le=String((I==null?void 0:I.label)||"").trim().toLowerCase();return["命令","command"].includes(le)?Array.isArray(Q)&&Q.length===1:!1}function m(I={}){const Q=String((I==null?void 0:I.label)||"").trim().toLowerCase();return["命令","command","路径","path","url","目标","target"].includes(Q)}function f(I={}){return I!=null&&I.completed?"completed":String((I==null?void 0:I.status)||"").trim().toLowerCase()==="in_progress"?"in_progress":"pending"}function b(I=0){return n("processDetail.hiddenItems",{count:I})}function v(I=0){return n("processDetail.directorySummary",{count:I})}function P(I=0){return n("processDetail.directoryHidden",{count:I})}function ne(I=0){return l.value[I]||`block-${I}`}function y(I=""){const Q=String(I||"").trim().toLowerCase();return n(Q==="completed"?"processDetail.subAgentCompleted":Q==="failed"?"processDetail.subAgentFailed":Q==="running"?"processDetail.subAgentRunning":Q==="pending_init"?"processDetail.subAgentPending":"processDetail.subAgentUnknown")}function L(I={}){return String((I==null?void 0:I.title)||(I==null?void 0:I.target)||(I==null?void 0:I.id)||"").trim()}function O(I={}){const Q=L(I),le=[],ie=String((I==null?void 0:I.role)||"").trim(),ve=String((I==null?void 0:I.target)||"").trim(),_=String((I==null?void 0:I.model)||"").trim();return ie&&ie.toLowerCase()!=="default"&&le.push(ie),ve&&ve!==Q&&le.push(ve),_&&le.push(_),le.join(" · ")}function z(I={}){return!!String((I==null?void 0:I.message)||"").trim()}function U(I={}){const Q=String((I==null?void 0:I.message)||"").replace(/\s+/g," ").trim();return Q||O(I)}function se(I=0,Q={},le=0){return`${ne(I)}:sub-agent:${String((Q==null?void 0:Q.id)||(Q==null?void 0:Q.target)||(Q==null?void 0:Q.title)||le)}`}function A(I=0,Q={},le=0){return o.value.has(se(I,Q,le))}function G(I=0,Q={},le=0){const ie=se(I,Q,le),ve=new Set(o.value);ve.has(ie)?ve.delete(ie):ve.add(ie),o.value=ve}function ce(I={}){return Array.isArray(I==null?void 0:I.messageBlocks)?I.messageBlocks.filter(Boolean):[]}function pe(I={}){return ce(I).some(le=>!["text","markdown"].includes(String((le==null?void 0:le.type)||"").trim()))}return(I,Q)=>{const le=ka("ProcessDetailRenderer",!0);return s.value.length?(g(),x("div",uc,[(g(!0),x(et,null,ut(s.value,(ie,ve)=>(g(),x(et,{key:l.value[ve]||`${ie.type}-${ve}`},[ie.type==="meta"?(g(),x("div",cc,[(g(!0),x(et,null,ut(ie.items||[],(_,H)=>(g(),x("div",{key:`${ve}-meta-${H}`,class:Se(["process-detail-meta__item",{"process-detail-meta__item--long":S(_),"process-detail-meta__item--value-only":d(_,ie.items)}])},[d(_,ie.items)?me("",!0):(g(),x("span",dc,w(_.label),1)),i("span",{class:Se(["process-detail-meta__value",{"process-detail-mobile-code-scroll":S(_),"process-detail-meta__value--mono":m(_)}])},w(_.value),3)],2))),128))])):ie.type==="checklist"?(g(),x("div",fc,[i("div",pc,[(g(!0),x(et,null,ut(ie.items||[],(_,H)=>(g(),x("div",{key:`${ve}-check-${H}`,class:"process-detail-checklist__item"},[i("span",{class:Se(["process-detail-checklist__icon",`is-${f(_)}`])},[f(_)==="completed"?(g(),Ce(a(Cr),{key:0,class:"h-3 w-3"})):f(_)==="in_progress"?(g(),x("span",mc)):me("",!0)],2),i("span",{class:Se(f(_)==="completed"?"line-through":"")},w(_.text),3)]))),128))]),ie.totalCount?(g(),x("div",gc,[an(w(`已完成 ${(ie.items||[]).filter(_=>_.completed).length} / ${ie.totalCount}`)+" ",1),ie.hiddenCount?(g(),x("span",hc,w(`,还有 ${ie.hiddenCount} 项`),1)):me("",!0)])):me("",!0)])):ie.type==="directory_list"?(g(),x("div",vc,[i("div",yc,[ie.path?(g(),x("span",Sc,w(ie.path),1)):me("",!0),ie.entryType?(g(),x("span",wc,w(ie.entryType),1)):me("",!0)]),i("div",xc,[(g(!0),x(et,null,ut(ie.entries||[],(_,H)=>(g(),x("div",{key:`${ve}-entry-${H}`,class:"process-detail-directory__item"},w(_),1))),128))]),ie.totalCount?(g(),x("div",bc,[an(w(v(ie.totalCount))+" ",1),ie.hiddenCount?(g(),x("span",kc,w(P(ie.hiddenCount)),1)):me("",!0)])):me("",!0)])):ie.type==="bullet_list"?(g(),x("div",_c,[i("ul",Tc,[(g(!0),x(et,null,ut(ie.items||[],(_,H)=>(g(),x("li",{key:`${ve}-bullet-${H}`,class:"min-w-0 w-full max-w-full break-words [overflow-wrap:anywhere]"},w(_),1))),128))]),ie.hiddenCount?(g(),x("div",Cc,w(b(ie.hiddenCount)),1)):me("",!0)])):ie.type==="file_changes"?(g(),x("div",Ec,[i("div",Ac,[(g(!0),x(et,null,ut(ie.items||[],(_,H)=>(g(),x("div",{key:`${ve}-change-${H}`,class:"process-detail-filechange__item"},[i("span",$c,w(p(_.kind)),1),i("span",Ic,w(_.path),1)]))),128))])])):ie.type==="sub_agent_list"?(g(),x("div",Pc,[i("div",Dc,[(g(!0),x(et,null,ut(ie.items||[],(_,H)=>(g(),x("div",{key:`${ve}-sub-agent-${H}`,class:"min-w-0"},[i("div",Lc,[i("div",Bc,[i("span",Mc,w(L(_)),1),U(_)?(g(),x("span",{key:0,class:"process-detail-subagent__preview min-w-0 flex-1",title:U(_)},w(U(_)),9,Rc)):me("",!0)]),z(_)?(g(),x("button",{key:0,type:"button",class:"shrink-0 text-[11px] underline decoration-dashed underline-offset-2",onClick:F=>G(ve,_,H)},w(A(ve,_,H)?a(n)("common.collapse"):a(n)("common.expand")),9,Nc)):me("",!0),i("span",Oc,w(y(_.status)),1)]),z(_)&&A(ve,_,H)?(g(),x("div",jc,[pe(_)?(g(),Ce(le,{key:0,blocks:ce(_),kind:"sub-agent-message"},null,8,["blocks"])):(g(),x("pre",Fc,w(_.message),1))])):me("",!0)]))),128))])])):ie.type==="markdown"?(g(),x("div",{key:6,class:Se(["codex-markdown process-detail-markdown",{"process-detail-markdown--reasoning":t.kind==="reasoning"}]),innerHTML:c(ie.text)},null,10,Uc)):(g(),x("pre",Vc,w(ie.text),1))],64))),128))])):me("",!0)}}}),Gr={__name:"SelectionInsertButton",props:{label:{type:String,default:""},top:{type:Number,default:0},left:{type:Number,default:0}},emits:["click"],setup(e,{emit:t}){function n(s){var r,l;typeof(s==null?void 0:s.button)=="number"&&s.button!==0||((r=s==null?void 0:s.preventDefault)==null||r.call(s),(l=s==null?void 0:s.stopPropagation)==null||l.call(s),o("click"))}const o=t;return(s,r)=>(g(),x("button",{type:"button",class:"tool-button tool-button-primary absolute z-20 inline-flex items-center gap-2 px-3 py-1.5 text-xs shadow-sm",style:kn({top:`${e.top}px`,left:`${e.left}px`}),onPointerdown:n,onKeydown:[r[0]||(r[0]=Gt(Qe(l=>o("click"),["prevent"]),["enter"])),r[1]||(r[1]=Gt(Qe(l=>o("click"),["prevent"]),["space"]))]},w(e.label),37))}},Xr=96,Wo=34,rn=8,Hc=72;function qc(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement||null:null}function Go(e,t,n){var r;const o=qc(e);if(!o||!n)return null;const s=(r=o.closest)==null?void 0:r.call(o,t);return s&&n.contains(s)?s:null}function Kc(e){const t=(e==null?void 0:e.commonAncestorContainer)||null;return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentNode||null:null}function Wc(e,t,{codeLeft:n=0,buttonWidth:o=Xr,scrollTop:s=0,scrollLeft:r=0,clientWidth:l=0,clientHeight:c=0}={}){const S=Math.max(e.left||0,Number(n)||0)-t.left+r,d=r+rn,m=r+Math.max(rn,l-o-rn),f=Math.max(d,Math.min(m,S||r+rn)),b=e.bottom-t.top+s+rn,v=e.top-t.top+s-Wo-rn,P=s+rn,ne=s+c-rn;return{top:b+Wo<=ne?b:Math.max(P,v),left:f}}function Yr(e={}){const t=q([]),n=q({visible:!1,top:0,left:0,content:""});let o=null,s=0;function r(){var z;return typeof e.getContainer=="function"?e.getContainer():((z=e.containerRef)==null?void 0:z.value)||null}function l(){return typeof e.getPositionContainer=="function"?e.getPositionContainer():r()}function c(){o&&(window.clearTimeout(o),o=null)}function p(){s&&(window.cancelAnimationFrame(s),s=0)}function S(z=[]){var U;t.value=z,(U=e.onSelectedRowsChange)==null||U.call(e,z)}function d({clearBrowserSelection:z=!1}={}){var U,se,A,G;c(),p(),z&&((A=(se=(U=window.getSelection)==null?void 0:U.call(window))==null?void 0:se.removeAllRanges)==null||A.call(se)),n.value={visible:!1,top:0,left:0,content:""},S([]),(G=e.onClear)==null||G.call(e)}function m(z){return z?typeof e.getOrderedRowElements=="function"?e.getOrderedRowElements(z).filter(Boolean):[...z.querySelectorAll(String(e.rowSelector||""))]:[]}function f(z){var U;return((U=e.mapRowElement)==null?void 0:U.call(e,z))??z}function b(z,U,se){const A=String(e.rowSelector||"").trim(),G=m(se);if(!A||!G.length)return[];const ce=Go(z.anchorNode,A,se),pe=Go(z.focusNode,A,se);if(ce&&pe){const I=G.indexOf(ce),Q=G.indexOf(pe);if(I>=0&&Q>=0){const[le,ie]=I<=Q?[I,Q]:[Q,I];return G.slice(le,ie+1)}}return G.filter(I=>{try{return U.intersectsNode(I)}catch{return!1}})}function v(){var H,F,He;const z=(H=window.getSelection)==null?void 0:H.call(window),U=r(),se=l();if(!(typeof e.isActive=="function"?e.isActive():!0)||!z||z.rangeCount<1||z.isCollapsed||!U||!se){d();return}const G=z.getRangeAt(0),ce=Kc(G);if(!ce||!U.contains(ce)){d();return}const pe=String(z.toString()||"").replace(/\u200b/g,"");if(!pe.trim()){d();return}const I=b(z,G,U);if(!I.length){d();return}const Q=I.map(De=>f(De)).filter(De=>De!==null&&typeof De<"u");if(!Q.length){d();return}const le=G.getBoundingClientRect(),ie=(F=se.getBoundingClientRect)==null?void 0:F.call(se);if(!ie){d();return}const ve=((He=e.getCodeLeft)==null?void 0:He.call(e,I[0]))||le.left,_=Wc(le,ie,{codeLeft:ve,buttonWidth:Number(e.buttonWidth||Xr),scrollTop:Number(se.scrollTop||0),scrollLeft:Number(se.scrollLeft||0),clientWidth:Number(se.clientWidth||0),clientHeight:Number(se.clientHeight||0)});n.value={visible:!0,top:_.top,left:_.left,content:pe},S(Q)}function P(){c(),o=window.setTimeout(()=>{o=null,v()},Number(e.debounceMs||Hc))}function ne(){P()}function y(){P()}function L(){!n.value.visible||s||(s=window.requestAnimationFrame(()=>{s=0,v()}))}function O(){L()}return dn(()=>{var z,U,se,A;document.addEventListener("selectionchange",y),document.addEventListener("mouseup",y),document.addEventListener("scroll",O,!0),window.addEventListener("resize",O),(U=(z=window.visualViewport)==null?void 0:z.addEventListener)==null||U.call(z,"resize",O),(A=(se=window.visualViewport)==null?void 0:se.addEventListener)==null||A.call(se,"scroll",O)}),It(()=>{var z,U,se,A;d({clearBrowserSelection:!0}),document.removeEventListener("selectionchange",y),document.removeEventListener("mouseup",y),document.removeEventListener("scroll",O,!0),window.removeEventListener("resize",O),(U=(z=window.visualViewport)==null?void 0:z.removeEventListener)==null||U.call(z,"resize",O),(A=(se=window.visualViewport)==null?void 0:se.removeEventListener)==null||A.call(se,"scroll",O)}),{selectedRows:t,selectionAction:n,clearSelectionState:d,clearScheduledSelectionUpdate:c,handleSelectionMouseUp:ne,scheduleSelectionUpdate:P,updateSelectionActionFromDom:v}}const Gc=250,Xc=350,Yc=180,bs=2;function Jr(e){return(e==null?void 0:e.name)==="AbortError"}const no="promptx:codex-recent-paths",Jc=12;function Qr(e){const{getMode:t,props:n,onSelect:o}=e,s=q([]),r=q(!1),l=q(""),c=q([]),p=q(!1),S=q(""),d=q([]),m=q([]),f=q("tree"),b=q(""),v=new Map;let P=null,ne=0,y=0,L=null;const O=W(()=>String(n.query||"").trim()),z=W(()=>Math.max(1,Number(e.minimumQueryLength)||bs)),U=W(()=>O.value.length>=z.value),se=W(()=>typeof t=="function"),A=W(()=>se.value?String((t==null?void 0:t())||"").trim()==="search"?"search":"tree":f.value),G=W(()=>tt(s.value)),ce=W(()=>String(n.sessionId||"").trim()),pe=W(()=>ce.value?`promptx:codex-tree-expanded:${ce.value}`:""),I=W(()=>{if(!O.value)return d.value;const V=new Set(c.value.map(X=>X.path));return d.value.filter(X=>V.has(X.path))}),Q=W(()=>{const V=new Set(I.value.map(X=>X.path));return c.value.filter(X=>!V.has(X.path))}),le=W(()=>O.value?[...I.value,...Q.value]:d.value),ie=W(()=>A.value==="search"?le.value:G.value),ve=W(()=>A.value==="search"?p.value:r.value),_=W(()=>A.value==="search"?S.value:l.value),H=W(()=>A.value==="search"&&!!n.sessionId&&U.value&&!p.value&&!S.value&&!le.value.length),F=W(()=>A.value==="search"&&!!n.sessionId&&!!O.value&&!U.value&&!p.value&&!S.value),He=W(()=>A.value==="tree"&&!!n.sessionId&&!r.value&&!l.value&&!G.value.length);function De(V,X){if(!V||typeof window>"u")return X;try{const de=window.localStorage.getItem(V);return de?JSON.parse(de):X}catch{return X}}function Fe(V,X){if(!(!V||typeof window>"u"))try{window.localStorage.setItem(V,JSON.stringify(X))}catch{}}function je(V=[]){return[...V].sort((X,de)=>{const he=+(X.type!=="directory")-+(de.type!=="directory");return he||String(X.path||X.name||"").localeCompare(String(de.path||de.name||""),"zh-CN")})}function Ke(V){return{...V,children:[],expanded:!1,loaded:!1,loading:!1}}function tt(V=[],X=0,de=[]){return V.forEach(he=>{de.push({...he,depth:X}),he.type==="directory"&&he.expanded&&he.children.length&&tt(he.children,X+1,de)}),de}function xe(V,X=s.value){for(const de of X){if(de.path===V)return de;if(de.children.length){const he=xe(V,de.children);if(he)return he}}return null}function R(){s.value=[...s.value]}function J(){P&&(window.clearTimeout(P),P=null),L&&(L.abort(),L=null)}function fe(V=s.value,X=[]){return V.forEach(de=>{de.type==="directory"&&de.expanded&&(X.push(de.path),de.children.length&&fe(de.children,X))}),X}function _e(){if(!pe.value)return;const V=[...new Set(fe())];m.value=V,Fe(pe.value,V)}function ge(){m.value=pe.value?De(pe.value,[]).filter(Boolean):[]}function Ie(V=s.value,X=new Set){if(!X.size)return!1;const de=V.filter(he=>he.type==="directory"&&he.hasChildren).map(he=>he.path);return!de.length||de.length!==X.size?!1:de.every(he=>X.has(he))}function Ae(){const V=De(no,[]);if(!Array.isArray(V)||!ce.value){d.value=[];return}d.value=V.filter(X=>X&&X.sessionId===ce.value&&X.path).sort((X,de)=>Number(de.usedAt||0)-Number(X.usedAt||0)).slice(0,Jc)}function Be(V){return V.name||V.path||"."}function Xe(V){return V.path||"."}function Pe(V){if(!ce.value||!(V!=null&&V.path))return;const X={sessionId:ce.value,path:V.path,name:V.name||Be(V),type:V.type||"file",usedAt:Date.now()},de=De(no,[]),he=[X];Array.isArray(de)&&de.forEach(Ue=>{!(Ue!=null&&Ue.path)||!(Ue!=null&&Ue.sessionId)||Ue.sessionId===X.sessionId&&Ue.path===X.path||he.push(Ue)}),Fe(no,he.slice(0,40)),Ae()}function it(V=""){const X=String(V||"").trim();return!X||!X.includes("/")?"":X.slice(0,X.lastIndexOf("/"))}function Me(){const V=ie.value;if(!V.length)return-1;const X=V.findIndex(de=>de.path===b.value);return X>=0?X:0}function Ne(){const V=ie.value,X=Me();return X<0||!V.length?null:V[X]||null}function Ee(){const V=ie.value;if(!V.length){b.value="";return}V.some(X=>X.path===b.value)||(b.value=V[0].path)}function lt(V,X){if(X){v.set(V,X);return}v.delete(V)}function ht(){var X;const V=v.get(b.value);(X=V==null?void 0:V.scrollIntoView)==null||X.call(V,{block:"nearest"})}function dt(V=""){return String(V||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function wt(V="",X=""){const de=String(V||""),he=String(X||"").trim().toLowerCase();if(!de||!he)return null;const Ue=de.toLowerCase(),Tt=Ue.indexOf(he);if(Tt>=0)return{start:Tt,end:Tt+he.length};const qt=he.split(/[\\/\s_.-]+/).filter(Boolean).sort((At,Ot)=>Ot.length-At.length);for(const At of qt){if(At.length<2)continue;const Ot=Ue.indexOf(At);if(Ot>=0)return{start:Ot,end:Ot+At.length}}return null}function Ct(V="",X=""){const de=String(V||""),he=wt(de,X);return he?`${dt(de.slice(0,he.start))}<mark class="theme-search-highlight">${dt(de.slice(he.start,he.end))}</mark>${dt(de.slice(he.end))}`:dt(de)}function T(V){return Ct(Be(V),O.value)}function j(V){return Ct(Xe(V),O.value)}async function te(V="",X={}){if(!n.sessionId){s.value=[],l.value="",r.value=!1;return}const de=!V,he=de?null:xe(V);if(!(!de&&!he)&&!(!X.force&&(de&&s.value.length||!de&&he.loaded))){de?(r.value=!0,l.value=""):(he.loading=!0,l.value="",R());try{const Ue=await Qi(n.sessionId,{path:V,refreshToken:X.refreshToken||""}),Tt=je(Ue.items||[]).map(Ke);if(de){s.value=Tt;return}he.children=Tt,he.loaded=!0}catch(Ue){l.value=Ue.message}finally{de?r.value=!1:(he.loading=!1,R())}}}async function ye(V=s.value,X=new Set,de={}){for(const he of V)he.type!=="directory"||!X.has(he.path)||(he.expanded=!0,R(),await te(he.path,de),he.children.length&&await ye(he.children,X,de))}async function Oe(V={}){await te("",V);const X=new Set(m.value),de=Ie(s.value,X),he=X.size>0&&!de;de&&(m.value=[],Fe(pe.value,[]),X.clear());for(const Ue of s.value)Ue.type!=="directory"||!Ue.hasChildren||(Ue.expanded=he?X.has(Ue.path):!1);if(R(),he){await ye(s.value,X,V);return}}async function Re(V){if(A.value!=="tree")return;const X=xe(V);if(!(!X||X.type!=="directory")){if(!X.loaded&&!X.loading){X.expanded=!0,R(),await te(X.path),_e();return}X.expanded=!X.expanded,R(),_e()}}function Ge(V){return V!=null&&V.path?(Pe(V),o==null||o(V),!0):!1}async function Ye(V={}){const X=O.value;ne+=1;const de=ne,he=V.refreshToken||"";if(J(),!n.open||!n.sessionId||!X||!U.value){p.value=!1,S.value="",c.value=[];return}L=new AbortController;try{const Ue=await Zi(n.sessionId,X,{limit:80,refreshToken:he,signal:L.signal});if(de!==ne)return;c.value=Ue.items||[]}catch(Ue){if(Jr(Ue)||de!==ne)return;S.value=Ue.message,c.value=[]}finally{de===ne&&(L=null),de===ne&&(p.value=!1)}}function nt(V={}){if(J(),!n.open||!n.sessionId||!O.value||!U.value){p.value=!1,S.value="",c.value=[];return}p.value=!0,S.value="",P=window.setTimeout(()=>{P=null,Ye(V)},Gc)}function yt(){if(!n.sessionId){s.value=[],l.value="",r.value=!1,c.value=[],S.value="",p.value=!1;return}y=Date.now(),s.value=[],l.value="",c.value=[],S.value="",Oe({force:!0,refreshToken:y}),nt({refreshToken:y})}function st(){if(se.value)return!1;const V=O.value?"search":"tree";return f.value===V?!1:(f.value=V,!0)}function ft(){Ae(),ge(),st(),yt()}function _t(){J(),c.value=[],S.value="",p.value=!1}function Bt(V){const X=ie.value;if(!X.length)return!1;const de=Me(),he=de<0?0:(de+V+X.length)%X.length;return b.value=X[he].path,at(ht),!0}async function re(){if(A.value!=="tree")return!1;const V=Ne();if(!V||V.type!=="directory")return!1;if(!V.expanded)return await Re(V.path),b.value=V.path,!0;const X=ie.value,de=Me(),he=X[de+1];return he&&it(he.path)===V.path?(b.value=he.path,!0):!1}function Le(){if(A.value!=="tree")return!1;const V=Ne();if(!V)return!1;if(V.type==="directory"&&V.expanded){const de=xe(V.path);return de&&(de.expanded=!1,R(),_e()),b.value=V.path,!0}const X=it(V.path);return X?(b.value=X,!0):!1}function ot(){const V=ie.value;return V.length?Ge(V[Me()]):!1}function xt(){s.value=[],l.value="",r.value=!1,c.value=[],S.value="",p.value=!1,Ae(),ge(),n.sessionId&&n.open&&(Oe({force:!0}),nt())}function Et(){st(),nt()}function pt(){Ee(),at(ht)}return It(()=>{J()}),{activeKey:b,collapseActiveDirectory:Le,confirmActive:ot,currentError:_,currentLoading:ve,emitSelect:Ge,expandActiveDirectory:re,getDisplayName:Be,getHighlightedName:T,getHighlightedPath:j,handleQueryChange:Et,handleSessionChange:xt,handleVisibleItemsChange:pt,initializeData:ft,moveActive:Bt,normalSearchItems:Q,normalizedQuery:O,recentSearchItems:I,resetData:_t,setItemRef:lt,showSearchPromptState:F,showSearchEmptyState:H,showTreeEmptyState:He,toggleDirectory:Re,treeItems:G,visibleItems:ie}}const Qc={class:"min-w-0"},Zc={class:"theme-heading truncate text-sm font-medium"},ed={class:"source-browser-layout grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[21rem_minmax(0,1fr)]"},td={class:"theme-divider border-b px-4 py-3"},nd={class:"block"},sd={class:"sr-only"},od={class:"relative"},rd=["placeholder","onKeydown"],ad=["title","aria-label"],id={class:"min-h-0 flex-1 overflow-y-auto p-2"},ld={key:0,class:"theme-empty-state px-3 py-4 text-[12px]"},ud={key:1,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},cd={key:2,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},dd={key:3,class:"theme-empty-state px-3 py-4 text-[12px]"},fd={key:4,class:"theme-empty-state px-3 py-4 text-[12px]"},pd={key:5,class:"theme-empty-state px-3 py-4 text-[12px]"},md={key:6,class:"theme-empty-state px-3 py-4 text-[12px]"},gd={key:7,class:"theme-empty-state px-3 py-4 text-[12px]"},hd={key:8,class:"theme-empty-state px-3 py-4 text-[12px]"},vd={key:9,class:"theme-empty-state px-3 py-4 text-[12px]"},yd={key:10,class:"theme-empty-state px-3 py-4 text-[12px]"},Sd={key:11,class:"space-y-1"},wd={key:0,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},xd=["onClick"],bd={class:"min-w-0 flex-1"},kd=["innerHTML"],_d=["innerHTML"],Td={key:1,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},Cd=["onClick"],Ed={class:"min-w-0 flex-1"},Ad=["innerHTML"],$d=["innerHTML"],Id={key:12,class:"space-y-3"},Pd={class:"theme-divider flex items-start gap-2.5 border-b px-3 py-2.5"},Dd={class:"min-w-0 flex-1"},Ld={class:"theme-list-item-title theme-list-item-title--strong break-all"},Bd={key:0,class:"theme-list-item-meta truncate"},Md={class:"theme-list-item-meta shrink-0 pt-0.5"},Rd={class:"space-y-1 px-2 py-2"},Nd=["onClick"],Od=["innerHTML"],jd={key:0,class:"theme-muted-text px-1 text-[12px]"},Fd={key:13,class:"space-y-1"},Ud=["onClick"],Vd={class:"flex items-start gap-1.5"},zd=["onClick"],Hd={key:1,class:"block h-5 w-5 shrink-0"},qd=["onClick"],Kd={class:"flex min-h-0 flex-col overflow-hidden"},Wd={class:"theme-divider border-b px-4 py-2"},Gd={class:"flex items-center justify-between gap-3"},Xd={class:"min-w-0"},Yd={key:0,class:"theme-muted-text truncate text-[12px]"},Jd={key:1,class:"theme-muted-text mt-1 text-[11px]"},Qd={class:"min-h-0 flex-1 overflow-auto px-4 py-3"},Zd={key:0,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},ef={key:1,class:"theme-status-danger rounded-sm border px-4 py-3 text-[12px]"},tf={key:2,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},nf={key:3,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},sf={key:4,class:"source-browser-image-wrap flex h-full min-h-[12rem] items-center justify-center overflow-hidden rounded-sm border p-4"},of=["src","alt"],rf={key:5,class:"theme-empty-state flex h-full min-h-[12rem] flex-col items-center justify-center gap-3 text-[12px]"},af={class:"source-code-view"},lf={class:"source-code-view__table"},uf=["innerHTML"],cf=20,df={__name:"CodexSessionSourceBrowserDialog",props:{open:{type:Boolean,default:!1},session:{type:Object,default:null}},emits:["close","insert-code-context"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),{isDark:r}=kr(),l=rs({open:!1,sessionId:"",query:""}),c=q(""),p=q(""),S=q(!1),d=q(""),m=q(null),f=q(""),b=q("path"),v=q([]),P=q(!1),ne=q(""),y=q(""),L=q(!1),O=q(""),z=new Map,U=q(null),se=q(null),A=q(0),G=q([]),ce=q("");let pe=0,I=0,Q=null,le=null;const ie=Xc,ve=Yc;let _=null;const H=new Map,F=W(()=>{var u;return String(((u=n.session)==null?void 0:u.id)||"").trim()}),He=W(()=>{var u;return String(((u=n.session)==null?void 0:u.cwd)||"").trim()}),De=W(()=>b.value!=="content"),Fe=W(()=>b.value==="content"),je=W(()=>String(f.value||"").trim()),Ke=W(()=>je.value.length>=bs),tt=W(()=>{var u;return((u=m.value)==null?void 0:u.name)||c.value||""}),xe=W(()=>{var u;return((u=m.value)==null?void 0:u.path)||c.value||""}),R=W(()=>{var u;return Ut(((u=m.value)==null?void 0:u.size)||0)}),J=W(()=>{var C,B;const u=[];return(xe.value||tt.value)&&u.push(xe.value||tt.value),(C=m.value)!=null&&C.size&&u.push(R.value),(B=m.value)!=null&&B.truncated&&u.push(s("sourceBrowser.truncated")),u.join(" ")}),fe=W(()=>{var u;return!!((u=m.value)!=null&&u.previewUrl)}),_e=W(()=>{var u,C;return!!((u=m.value)!=null&&u.binary&&!((C=m.value)!=null&&C.previewUrl))}),ge=W(()=>!!(m.value&&!m.value.binary&&!m.value.previewUrl)),Ie=q(""),Ae=q(""),Be=q(""),Xe=q("2.6rem"),{selectedRows:Pe,selectionAction:it,clearSelectionState:Me,handleSelectionMouseUp:Ne,updateSelectionActionFromDom:Ee}=Yr({getContainer:()=>se.value,isActive:()=>n.open&&ge.value,rowSelector:".source-code-view__line",mapRowElement:u=>{var B;const C=Number(((B=u==null?void 0:u.getAttribute)==null?void 0:B.call(u,"data-line"))||0);return C>0?C:null},getCodeLeft:u=>{var Te,qe,Ve;const C=(Te=u==null?void 0:u.querySelector)==null?void 0:Te.call(u,".source-code-view__code");if(!C)return 0;const B=(qe=C.getBoundingClientRect)==null?void 0:qe.call(C),M=(Ve=window.getComputedStyle)==null?void 0:Ve.call(window,C),oe=Number.parseFloat((M==null?void 0:M.paddingLeft)||"0")||0;return((B==null?void 0:B.left)||0)+oe},debounceMs:72}),lt=W(()=>[...new Set(Pe.value)].map(u=>Number(u)||0).filter(u=>u>0).sort((u,C)=>u-C)),ht=W(()=>{var B;const u=String(((B=m.value)==null?void 0:B.content)||"").replace(/\r\n/g,`
16
16
  `),C=u?u.split(`
17
17
  `):[];return[...lt.value].sort((M,oe)=>M-oe).map(M=>({lineNumber:M,content:String(C[M-1]||"")})).filter(M=>M.lineNumber>0)}),dt=W(()=>ht.value.length>0),wt=W(()=>Fe.value?s("sourceBrowser.contentSearchPlaceholder"):s("sourceBrowser.searchPlaceholder")),Ct=W(()=>Fe.value?s("sourceBrowser.searchModeContent"):s("sourceBrowser.searchModePath")),T=W(()=>!!je.value),j=W(()=>T.value?"search":"tree"),te=W(()=>T.value&&Fe.value?P.value:Le.value),ye=W(()=>De.value&&Qt.value),Oe=W(()=>De.value&&Ot.value),Re=W(()=>T.value&&Fe.value&&!Ke.value&&!P.value&&!ne.value),Ge=W(()=>T.value&&Fe.value&&Ke.value&&!!y.value&&!P.value&&!ne.value&&!v.value.length),Ye=W(()=>T.value&&Fe.value&&Ke.value&&!P.value&&!ne.value&&!y.value&&!v.value.length),nt=W(()=>{const u=[],C=new Map;return v.value.forEach(B=>{const M=String((B==null?void 0:B.path)||"").trim();if(!M)return;let oe=C.get(M);oe||(oe={path:M,name:String((B==null?void 0:B.name)||M.split("/").pop()||M),items:[]},C.set(M,oe),u.push(oe)),oe.items.push(B)}),u}),yt=W(()=>v.value.map(u=>ee(u)).join("|")),st=W(()=>K.value.map(u=>{const C=String((u==null?void 0:u.path)||"").trim(),B=u!=null&&u.expanded?1:0,M=u!=null&&u.loading?1:0;return`${C}:${B}:${M}`}).join("|")),{activeKey:ft,collapseActiveDirectory:_t,expandActiveDirectory:Bt,currentError:re,currentLoading:Le,getDisplayName:ot,getHighlightedName:xt,getHighlightedPath:Et,handleQueryChange:pt,handleSessionChange:V,handleVisibleItemsChange:X,initializeData:de,moveActive:he,normalSearchItems:Ue,recentSearchItems:Tt,resetData:qt,setItemRef:At,showSearchPromptState:Ot,showSearchEmptyState:Qt,showTreeEmptyState:nn,toggleDirectory:E,treeItems:k,visibleItems:K}=Qr({getMode:()=>j.value,props:l,onSelect:on});function ae(u=""){return String(u||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ee(u){return`${(u==null?void 0:u.path)||""}:${(u==null?void 0:u.line)||0}:${(u==null?void 0:u.column)||0}`}function h(u,C){if(C){z.set(u,C);return}z.delete(u)}function Y(){var C;const u=z.get(O.value);(C=u==null?void 0:u.scrollIntoView)==null||C.call(u,{block:"nearest"})}function D(u="",C=""){const B=String(u||""),M=String(C||"").trim();if(!B||!M)return ae(B);const oe=B.toLowerCase(),Te=M.toLowerCase(),qe=oe.indexOf(Te);if(qe<0)return ae(B);const Ve=qe+Te.length;return`${ae(B.slice(0,qe))}<mark class="theme-search-highlight">${ae(B.slice(qe,Ve))}</mark>${ae(B.slice(Ve))}`}function be(u="",C=""){const B=String(u||""),M=String(C||"").trim();if(!B||!M)return[];const oe=B.toLowerCase(),Te=M.toLowerCase(),qe=[];let Ve=0;for(;Ve<oe.length;){const bt=oe.indexOf(Te,Ve);if(bt<0)break;qe.push({start:bt,end:bt+Te.length}),Ve=bt+Te.length}return qe}function Mt(u,C,B){if(!u)return null;if(u.nodeType===Node.TEXT_NODE){const oe=u.textContent||"",Te=B.offset,qe=Te+oe.length;if(B.offset=qe,!oe)return document.createTextNode("");const Ve=C.filter(Kt=>Kt.start<qe&&Kt.end>Te);if(!Ve.length)return document.createTextNode(oe);const bt=document.createDocumentFragment();let Rt=0;return Ve.forEach(Kt=>{const fs=Math.max(0,Kt.start-Te),Ws=Math.min(oe.length,Kt.end-Te);if(fs>Rt&&bt.appendChild(document.createTextNode(oe.slice(Rt,fs))),Ws>fs){const Gs=document.createElement("mark");Gs.className="source-code-view__search-hit",Gs.textContent=oe.slice(fs,Ws),bt.appendChild(Gs)}Rt=Math.max(Rt,Ws)}),Rt<oe.length&&bt.appendChild(document.createTextNode(oe.slice(Rt))),bt}if(u.nodeType!==Node.ELEMENT_NODE)return u.cloneNode(!0);const M=u.cloneNode(!1);return Array.from(u.childNodes||[]).forEach(oe=>{const Te=Mt(oe,C,B);Te&&M.appendChild(Te)}),M}function jt(u=se.value){var C,B,M;u&&((M=(B=(C=u.querySelectorAll)==null?void 0:C.call(u,".source-code-view__line-inner[data-original-html]"))==null?void 0:B.forEach)==null||M.call(B,oe=>{const Te=oe.dataset.originalHtml;typeof Te=="string"&&(oe.innerHTML=Te)}))}function Ft(){var B,M,oe;const u=se.value,C=String(ce.value||"").trim();u&&(jt(u),C&&((oe=(M=(B=u.querySelectorAll)==null?void 0:B.call(u,".source-code-view__line.is-match .source-code-view__line-inner"))==null?void 0:M.forEach)==null||oe.call(M,Te=>{Te.dataset.originalHtml||(Te.dataset.originalHtml=Te.innerHTML);const qe=be(Te.textContent||"",C);if(!qe.length)return;const Ve=document.createDocumentFragment(),bt={offset:0};Array.from(Te.childNodes||[]).forEach(Rt=>{const Kt=Mt(Rt,qe,bt);Kt&&Ve.appendChild(Kt)}),Te.replaceChildren(Ve)})))}function Ut(u=0){const C=Math.max(0,Number(u)||0);return C<1024?`${C} B`:C<1024*1024?`${(C/1024).toFixed(C<10*1024?1:0)} KB`:`${(C/(1024*1024)).toFixed(1)} MB`}function Pt(){var C,B,M;const u=se.value;u&&(jt(u),(M=(B=(C=u.querySelectorAll)==null?void 0:C.call(u,".source-code-view__line.is-match, .source-code-view__line.is-focus-match"))==null?void 0:B.forEach)==null||M.call(B,oe=>oe.classList.remove("is-match","is-focus-match")))}function mt(){var C,B,M;const u=se.value;u&&((M=(B=(C=u.querySelectorAll)==null?void 0:C.call(u,".source-code-view__line.is-selected"))==null?void 0:B.forEach)==null||M.call(B,oe=>oe.classList.remove("is-selected")))}function Xt(){mt();const u=se.value;!u||!lt.value.length||lt.value.forEach(C=>{var oe,Te;const B=u.querySelector(`.source-code-view__gutter[data-line="${C}"]`),M=(oe=B==null?void 0:B.closest)==null?void 0:oe.call(B,"tr");(Te=M==null?void 0:M.classList)==null||Te.add("is-selected")})}function Vs(){if(!lt.value.length)return"";const u=[...lt.value].sort((C,B)=>C-B);return u[0]===u[u.length-1]?`L${u[0]}`:`L${u[0]}-${u[u.length-1]}`}function Fn(){var C,B,M,oe;if(!m.value||!dt.value)return;const u=ht.value.map(Te=>Te.lineNumber);o("insert-code-context",{source:"source",filePath:xe.value,language:String(((C=m.value)==null?void 0:C.language)||""),rangeLabel:Vs(),lineStart:Math.min(...u),lineEnd:Math.max(...u),content:String(it.value.content||"").trim()||ht.value.map(Te=>Te.content).join(`
18
- `)}),(oe=(M=(B=window.getSelection)==null?void 0:B.call(window))==null?void 0:M.removeAllRanges)==null||oe.call(M),Me(),o("close")}function zs(u){var qe,Ve,bt,Rt;const C=(qe=window.getSelection)==null?void 0:qe.call(window),B=se.value;if(!C||C.rangeCount<1||C.isCollapsed||!B)return;Ee();const oe=C.getRangeAt(0).commonAncestorContainer;if(!B.contains((oe==null?void 0:oe.nodeType)===1?oe:oe==null?void 0:oe.parentNode))return;const Te=String(C.toString()||"").replace(/\u200b/g,"");Te&&((bt=(Ve=u==null?void 0:u.clipboardData)==null?void 0:Ve.setData)==null||bt.call(Ve,"text/plain",Te),(Rt=u==null?void 0:u.preventDefault)==null||Rt.call(u))}function zt(){_&&(window.clearTimeout(_),_=null)}function is(){H.clear()}function Hs(u=""){const C=String(u||"").trim();if(!C||!H.has(C))return null;const B=H.get(C);return H.delete(C),H.set(C,B),B}function Un(u="",C=null){const B=String(u||"").trim();if(!(!B||!C))for(H.delete(B),H.set(B,C);H.size>cf;){const M=H.keys().next().value;if(!M)break;H.delete(M)}}function ls(u){zt(),_=window.setTimeout(()=>{_=null,u==null||u()},ve)}function sn(){at(()=>{var u,C;(C=(u=U.value)==null?void 0:u.focus)==null||C.call(u)})}function Vn(u){var C,B,M;if((C=u==null?void 0:u.preventDefault)==null||C.call(u),je.value){(B=u==null?void 0:u.stopPropagation)==null||B.call(u),f.value="";return}(M=u==null?void 0:u.stopPropagation)==null||M.call(u),o("close")}function zn(){zt(),pe+=1,is(),c.value="",p.value="",w.value=!1,d.value="",m.value=null,Ie.value="",Ae.value="",Be.value="",Xe.value="2.6rem",A.value=0,G.value=[],ce.value="",Me(),Pt()}function Yt(){I+=1,Q&&(window.clearTimeout(Q),Q=null),le&&(le.abort(),le=null),v.value=[],P.value=!1,ne.value="",y.value="",L.value=!1,O.value="",G.value=[],ce.value="",Pt()}function us(){if(Q&&(window.clearTimeout(Q),Q=null),!n.open||!F.value||!Fe.value)return;if(!je.value||!Ke.value){Yt();return}P.value=!0,ne.value="",Q=window.setTimeout(()=>{Q=null,Kn()},ie)}function Hn(u=1){const C=v.value;if(!C.length)return!1;const B=C.findIndex(oe=>ee(oe)===O.value),M=B<0?0:(B+u+C.length)%C.length;return O.value=ee(C[M]),at(Y),!0}function Tn(){return K.value.length&&(K.value.find(u=>u.path===ft.value)||K.value[0])||null}function fn(u,C={}){return u?(ft.value=(u==null?void 0:u.path)||"",O.value="",c.value=String((u==null?void 0:u.path)||"").trim(),p.value=String((u==null?void 0:u.type)||"").trim(),d.value="",A.value=0,G.value=[],ce.value="",(u==null?void 0:u.type)==="directory"?(zt(),m.value=null,C.toggleDirectory&&!T.value&&E(u.path),!0):C.previewMode==="debounced"?(ls(()=>En(u==null?void 0:u.path)),!0):(zt(),En(u==null?void 0:u.path),!0)):!1}function cs(){const u=v.value;if(!u.length)return!1;const C=u.find(B=>ee(B)===O.value)||u[0];return mn(C),!0}function qs(u){const C=String((u==null?void 0:u.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(C)&&!(T.value&&(C==="ArrowLeft"||C==="ArrowRight"))){if(Fe.value&&T.value){if(C==="ArrowDown"){if(u.preventDefault(),Hn(1)){const B=v.value,M=B.find(oe=>ee(oe)===O.value)||B[0];mn(M,{previewMode:"debounced"})}return}if(C==="ArrowUp"){if(u.preventDefault(),Hn(-1)){const B=v.value,M=B.find(oe=>ee(oe)===O.value)||B[0];mn(M,{previewMode:"debounced"})}return}if(C==="Enter"){u.preventDefault(),cs();return}C==="Escape"&&Vn(u);return}if(C==="ArrowDown"){u.preventDefault(),he(1)&&at(()=>{fn(Tn(),{previewMode:"debounced"})});return}if(C==="ArrowUp"){u.preventDefault(),he(-1)&&at(()=>{fn(Tn(),{previewMode:"debounced"})});return}if(C==="ArrowRight"){u.preventDefault(),Bt();return}if(C==="ArrowLeft"){u.preventDefault(),_t();return}if(C==="Enter"){u.preventDefault(),fn(Tn(),{toggleDirectory:!0});return}C==="Escape"&&Vn(u)}}async function Cn(){const u=Fe.value?"path":"content";if(b.value=u,!je.value){u==="content"?Yt():(Yt(),l.query="");return}if(u==="content"){l.query="",Kn();return}Yt(),l.query=f.value}function Ks(u){var C;u.preventDefault(),(C=u.stopPropagation)==null||C.call(u),Cn().finally(()=>{sn()})}async function pn(){var Te;if(await at(),Pt(),!se.value)return;const u=[...new Set(G.value.map(qe=>Math.max(0,Number(qe)||0)).filter(qe=>qe>0))],C=Math.max(0,Number(A.value)||0);if(u.forEach(qe=>{var Rt,Kt;const Ve=se.value.querySelector(`.source-code-view__gutter[data-line="${qe}"]`),bt=(Rt=Ve==null?void 0:Ve.closest)==null?void 0:Rt.call(Ve,"tr");(Kt=bt==null?void 0:bt.classList)==null||Kt.add("is-match")}),Ft(),!C){Xt();return}const B=C,M=se.value.querySelector(`.source-code-view__gutter[data-line="${B}"]`),oe=(Te=M==null?void 0:M.closest)==null?void 0:Te.call(M,"tr");if(!oe){Xt();return}oe.classList.add("is-match","is-focus-match"),Ft(),oe.scrollIntoView({block:"center",inline:"nearest"}),Xt()}async function qn(){var Te,qe,Ve;if(!ge.value){Ie.value="",Ae.value="",Be.value="";return}const u=pe,C=String(((Te=m.value)==null?void 0:Te.content)||"").replace(/\r\n/g,`
19
- `),B=((qe=m.value)==null?void 0:qe.language)||"",M=Xu(C,eo),oe=await Qu(((Ve=m.value)==null?void 0:Ve.content)||"",{isDark:r.value,language:B,maxHighlightLines:eo.maxLines,maxHighlightChars:eo.maxChars});u===pe&&(Ie.value=oe.html,Ae.value=M?"":oe.bg||"",Be.value=M?"":oe.fg||"",Xe.value=oe.gutterWidth||"2.6rem",await at(),Xt())}async function En(u="",C={}){var qe;const B=String(u||"").trim();if(!F.value||!B)return;A.value=Math.max(0,Number(C.focusLine)||0),Me();const M=String(((qe=m.value)==null?void 0:qe.path)||"").trim();if(!C.forceReload&&M===B&&!w.value&&!d.value){await pn();return}if(!C.forceReload&&w.value&&c.value===B)return;pe+=1;const oe=pe;d.value="";const Te=C.forceReload?null:Hs(B);if(Te){w.value=!1,m.value=Te,await qn(),oe===pe&&ge.value&&await pn();return}w.value=!0;try{const Ve=await el(F.value,{path:B,limit:204800,refreshToken:String(Date.now())});if(oe!==pe)return;m.value=Ve,Un(B,Ve),await qn()}catch(Ve){if(oe!==pe)return;m.value=null,d.value=(Ve==null?void 0:Ve.message)||s("sourceBrowser.previewFailed")}finally{oe===pe&&(w.value=!1,ge.value&&await pn())}}function on(u){fn(u,{toggleDirectory:!0}),at(sn)}function ds(u,C){var B,M;(M=(B=u==null?void 0:u.currentTarget)==null?void 0:B.focus)==null||M.call(B),on(C)}async function Kn(){const u=je.value;if(!n.open||!F.value)return;I+=1;const C=I;if(!u||!Ke.value){Yt();return}le&&(le.abort(),le=null),P.value=!0,ne.value="",v.value=[],L.value=!1,O.value="",le=new AbortController;try{const B=await tl(F.value,u,{limit:80,refreshToken:String(Date.now()),signal:le.signal});if(C!==I)return;y.value=u,v.value=Array.isArray(B.items)?B.items:[],L.value=!!B.truncated,O.value=v.value[0]?ee(v.value[0]):"",v.value[0]&&mn(v.value[0],{previewMode:"debounced"})}catch(B){if(Jr(B)||C!==I)return;y.value=u,v.value=[],ne.value=(B==null?void 0:B.message)||s("sourceBrowser.contentSearchFailed")}finally{C===I&&(le=null),C===I&&(P.value=!1)}}function mn(u,C={}){O.value=ee(u),ft.value=(u==null?void 0:u.path)||"",c.value=String((u==null?void 0:u.path)||"").trim(),p.value="file",d.value="",ce.value=y.value||je.value,G.value=v.value.filter(M=>(M==null?void 0:M.path)===(u==null?void 0:u.path)).map(M=>Number((M==null?void 0:M.line)||0)).filter(M=>M>0);const B=()=>En(u==null?void 0:u.path,{focusLine:u==null?void 0:u.line});if(C.previewMode==="debounced"){ls(B),at(sn);return}zt(),B(),at(sn)}function $(u){const C=String((u==null?void 0:u.path)||"").trim();if(!C)return"";const B=C.split("/");return B[B.length-1]||C}function Z(u){const C=String((u==null?void 0:u.path)||"").trim();return!C||!C.includes("/")?"":C.slice(0,C.lastIndexOf("/"))}function we(u){return`${Array.isArray(u==null?void 0:u.items)?u.items.length:0} 处`}function ke(u){const C=y.value||je.value;return D((u==null?void 0:u.preview)||"",C)}return $e(()=>n.open,u=>{var C,B,M,oe,Te,qe;if(l.open=u,u){(M=(B=(C=window.getSelection)==null?void 0:C.call(window))==null?void 0:B.removeAllRanges)==null||M.call(B),l.sessionId=F.value,f.value="",b.value="path",l.query="",zn(),Yt(),de(),sn();return}(qe=(Te=(oe=window.getSelection)==null?void 0:oe.call(window))==null?void 0:Te.removeAllRanges)==null||qe.call(Te),f.value="",b.value="path",zn(),Yt(),qt()},{immediate:!0}),$e(F,u=>{l.sessionId=u,n.open&&(zn(),Yt(),V())}),$e(f,u=>{if(De.value){l.query=u;return}String(u||"").trim()!==String(y.value||"").trim()&&(ce.value="",Ft()),us()}),$e(()=>l.query,()=>{De.value&&pt()}),$e(yt,()=>{at(Y)}),$e(st,()=>{X(),!(!T.value||!De.value)&&at(()=>{const u=Tn();u&&fn(u,{previewMode:"debounced"})})}),$e(r,async()=>{!n.open||!ge.value||(await qn(),await pn())}),$e(lt,()=>{Xt()}),It(()=>{var u,C,B;(B=(C=(u=window.getSelection)==null?void 0:u.call(window))==null?void 0:C.removeAllRanges)==null||B.call(C),Me({clearBrowserSelection:!0}),zt()}),(u,C)=>(g(),Ce(Fs,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-full sm:h-[90vh] sm:w-[90vw] sm:max-w-[90vw]","header-class":"settings-dialog-header px-5 py-3.5","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col overflow-hidden",onClose:C[2]||(C[2]=B=>o("close"))},{title:Je(()=>[i("div",Qc,[i("div",Zc,S(He.value||a(s)("sourceBrowser.title")),1)])]),default:Je(()=>{var B;return[i("div",ed,[i("aside",{class:"theme-divider flex min-h-0 flex-col border-b md:border-b-0 md:border-r",onKeydown:qs},[i("div",td,[i("label",nd,[i("span",sd,S(a(s)("sourceBrowser.searchLabel")),1),i("div",od,[ue(a($a),{class:"theme-muted-text pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),Wt(i("input",{ref_key:"searchInputRef",ref:U,"onUpdate:modelValue":C[0]||(C[0]=M=>f.value=M),type:"text",class:"tool-input w-full pl-9 pr-18 text-[12px]",placeholder:wt.value,onKeydown:[Gt(Vn,["esc"]),Gt(Qe(Ks,["prevent"]),["tab"])]},null,40,rd),[[Xn,f.value]]),te.value?(g(),Ce(a(Ht),{key:0,class:"theme-muted-text pointer-events-none absolute right-10 top-1/2 h-4 w-4 -translate-y-1/2 animate-spin"})):me("",!0),i("button",{type:"button",class:"tool-button absolute right-1.5 top-1/2 inline-flex h-7 w-7 -translate-y-1/2 items-center justify-center px-0",title:Ct.value,"aria-label":Ct.value,onClick:Qe(Cn,["stop","prevent"])},[ue(a(Ia),{class:"h-3.5 w-3.5"})],8,ad)])])]),i("div",id,[F.value?T.value&&Fe.value&&ne.value?(g(),x("div",ud,S(ne.value),1)):a(re)?(g(),x("div",cd,S(a(re)),1)):Oe.value?(g(),x("div",dd,S(a(s)("sourceBrowser.searchMinKeywordHint",{count:a(bs)})),1)):ye.value?(g(),x("div",fd,S(a(s)("sourceBrowser.searchEmpty")),1)):Re.value?(g(),x("div",pd,S(a(s)("sourceBrowser.searchMinKeywordHint",{count:a(bs)})),1)):Ye.value?(g(),x("div",md,S(a(s)("sourceBrowser.contentSearchPrompt")),1)):Ge.value?(g(),x("div",gd,S(a(s)("sourceBrowser.contentSearchEmpty")),1)):a(nn)?(g(),x("div",hd,S(a(s)("sourceBrowser.treeEmpty")),1)):T.value&&Fe.value&&P.value&&!v.value.length?(g(),x("div",vd,S(a(s)("sourceBrowser.contentSearching")),1)):a(Le)&&!a(K).length?(g(),x("div",yd,S(a(s)("sourceBrowser.loadingFiles")),1)):T.value&&De.value?(g(),x("div",Sd,[a(Tt).length?(g(),x("div",wd,S(a(s)("sourceBrowser.recent")),1)):me("",!0),(g(!0),x(et,null,ut(a(Tt),M=>(g(),x("button",{key:`recent-${M.path}`,ref_for:!0,ref:oe=>a(At)(M.path,oe),type:"button",class:Se(["theme-list-row focus:outline-none",a(ft)===M.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:oe=>on(M)},[(g(),Ce(cn(M.type==="directory"?a(Dn):a(Sn)),{class:"theme-list-item-icon"})),i("div",bd,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(xt)(M)},null,8,kd)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Et)(M)},null,8,_d)])],10,xd))),128)),l.query.trim()&&a(Ue).length?(g(),x("div",Td,S(a(s)("sourceBrowser.results")),1)):me("",!0),(g(!0),x(et,null,ut(a(Ue),M=>(g(),x("button",{key:`result-${M.path}`,ref_for:!0,ref:oe=>a(At)(M.path,oe),type:"button",class:Se(["theme-list-row focus:outline-none",a(ft)===M.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:oe=>on(M)},[(g(),Ce(cn(M.type==="directory"?a(Dn):a(Sn)),{class:"theme-list-item-icon"})),i("div",Ed,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(xt)(M)},null,8,Ad)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Et)(M)},null,8,$d)])],10,Cd))),128))])):T.value?(g(),x("div",Id,[(g(!0),x(et,null,ut(nt.value,M=>(g(),x("div",{key:M.path,class:"rounded-sm border border-[var(--theme-borderDefault)] bg-[var(--theme-panel)]"},[i("div",Pd,[ue(a(Sn),{class:"theme-list-item-icon"}),i("div",Dd,[i("div",Ld,S($(M)),1),Z(M)?(g(),x("div",Bd,S(Z(M)),1)):me("",!0)]),i("div",Md,S(we(M)),1)]),i("div",Rd,[(g(!0),x(et,null,ut(M.items,oe=>(g(),x("button",{key:ee(oe),ref_for:!0,ref:Te=>h(ee(oe),Te),type:"button",class:Se(["theme-list-row gap-0 focus:outline-none",O.value===ee(oe)?"theme-list-item-active":"theme-list-item-hover"]),onClick:Te=>mn(oe)},[i("div",{class:"theme-list-item-title min-w-0 flex-1 break-words leading-[1.45rem]",innerHTML:ke(oe)},null,8,Od)],10,Nd))),128))])]))),128)),L.value?(g(),x("div",jd,S(a(s)("sourceBrowser.contentSearchTruncated")),1)):me("",!0)])):(g(),x("div",Fd,[(g(!0),x(et,null,ut(a(k),M=>(g(),x("div",{key:M.path,ref_for:!0,ref:oe=>a(At)(M.path,oe),class:Se(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(ft)===M.path?"theme-list-item-active":M.type==="directory"&&M.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:kn({paddingLeft:`${M.depth*16+6}px`}),tabindex:"-1",onClick:oe=>ds(oe,M)},[i("div",Vd,[M.type==="directory"?(g(),x("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:Qe(oe=>a(E)(M.path),["stop"])},[M.loading?(g(),Ce(a(Ht),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),Ce(a(Er),{key:1,class:Se(["h-3.5 w-3.5 transition",M.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,zd)):(g(),x("span",Hd)),i("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 outline-none focus:outline-none",onClick:Qe(oe=>on(M),["stop"])},[(g(),Ce(cn(M.type==="directory"?a(Dn):a(Sn)),{class:Se(["h-4 w-4 shrink-0",M.type==="directory"&&M.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("span",{class:Se(["theme-list-item-title min-w-0 flex-1 truncate",M.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},S(a(ot)(M)),3)],8,qd)])],14,Ud))),128))])):(g(),x("div",ld,S(a(s)("sourceBrowser.noProject")),1))])],32),i("section",Kd,[i("div",Wd,[i("div",Gd,[i("div",Xd,[J.value?(g(),x("p",Yd,S(J.value),1)):me("",!0),ge.value?(g(),x("p",Jd,S(a(s)("sourceBrowser.selectCodeLineHint")),1)):me("",!0)])])]),i("div",Qd,[w.value?(g(),x("div",Zd,[i("span",null,S(a(s)("sourceBrowser.previewLoading")),1)])):d.value?(g(),x("div",ef,S(d.value),1)):p.value==="directory"?(g(),x("div",tf,S(a(s)("sourceBrowser.selectFileHint")),1)):c.value?fe.value?(g(),x("div",sf,[i("img",{src:m.value.previewUrl,alt:tt.value,class:"source-browser-image object-contain"},null,8,of)])):_e.value?(g(),x("div",rf,[ue(a(Pa),{class:"h-8 w-8"}),i("span",null,S((B=m.value)!=null&&B.tooLarge?a(s)("sourceBrowser.binaryTooLarge"):a(s)("sourceBrowser.binaryUnsupported")),1)])):ge.value?(g(),x("div",{key:6,ref_key:"previewContainerRef",ref:se,class:"source-browser-code relative rounded-sm border",style:kn({"--source-code-bg":Ae.value||"var(--theme-panel)","--source-code-fg":Be.value||"var(--theme-textPrimary)","--source-code-gutter-width":Xe.value}),onCopy:zs,onMouseup:C[1]||(C[1]=(...M)=>a(Ne)&&a(Ne)(...M))},[i("div",af,[i("table",lf,[i("tbody",{innerHTML:Ie.value},null,8,uf)])]),e.open&&a(it).visible?(g(),Ce(Gr,{key:0,top:a(it).top,left:a(it).left,label:a(s)("sourceBrowser.insertSelection"),onClick:Fn},null,8,["top","left","label"])):me("",!0)],36)):me("",!0):(g(),x("div",nf,S(a(s)("sourceBrowser.selectFile")),1))])])])]}),_:1},8,["open"]))}},ff=br(df,[["__scopeId","data-v-8ccd6589"]]);function pf(e={}){const{items:t,themeKey:n,getCacheKey:o=y=>String((y==null?void 0:y.id)||"").trim(),getSource:s=y=>String((y==null?void 0:y.content)||""),shouldRender:r=()=>!0,renderAsync:l=async y=>y,renderFallback:c=y=>y,onRendered:p=null}=e,w=new Map,d=new Map,m=q(0),f=W(()=>(Array.isArray(t==null?void 0:t.value)?t.value:[]).map(y=>{const L=!!r(y),O=String(o(y)||"").trim(),z=L?String(s(y)||""):"";return{item:y,active:L,cacheKey:O,source:z}}));function b(y){if(m.value,!r(y))return"";const L=String(s(y)||""),O=String(o(y)||"").trim(),z=String((n==null?void 0:n.value)||"");if(!O)return c(L,y);const U=w.get(O);return(U==null?void 0:U.source)===L&&(U==null?void 0:U.theme)===z?U.html:c(L,y)}async function v(y){if(!r(y))return;const L=String(s(y)||""),O=String(o(y)||"").trim();if(!O)return;const z=String((n==null?void 0:n.value)||""),U=w.get(O);if((U==null?void 0:U.source)===L&&(U==null?void 0:U.theme)===z)return;const se=Symbol(O);d.set(O,se);try{const A=await l(L,y,{themeKey:z});if(d.get(O)!==se)return;w.set(O,{source:L,theme:z,html:A}),m.value+=1,p==null||p(y,{cacheKey:O,source:L,themeKey:z})}catch{}finally{d.get(O)===se&&d.delete(O)}}function P(y=[]){y.forEach(L=>{L!=null&&L.item&&v(L.item)})}function ne(y=[]){const L=new Set((Array.isArray(y)?y:[]).filter(z=>z==null?void 0:z.active).map(z=>String((z==null?void 0:z.cacheKey)||"").trim()).filter(Boolean));let O=!1;for(const z of w.keys())L.has(z)||(w.delete(z),O=!0);for(const z of d.keys())L.has(z)||d.delete(z);O&&(m.value+=1)}return $e(f,()=>{ne(f.value||[]),P(f.value||[])},{immediate:!0}),$e(n,()=>{P(f.value||[])}),It(()=>{d.clear()}),{getRenderedHtml:b}}const mf=`${Io()}/api/events/stream`,Bn=new Set;let wn=null,ks=null;function po(){ks&&(window.clearTimeout(ks),ks=null)}function Zr(){wn&&(wn.close(),wn=null)}function gf(e){Bn.forEach(t=>{try{t(e)}catch{}})}function ea(){typeof window>"u"||typeof window.EventSource>"u"||wn||!Bn.size||(po(),wn=new window.EventSource(mf),wn.onmessage=e=>{try{const t=JSON.parse(String(e.data||"{}"));if(!(t!=null&&t.type))return;gf(t)}catch{}},wn.onerror=()=>{Zr(),Bn.size&&(po(),ks=window.setTimeout(()=>{ea()},1500))})}function hf(e){return typeof e!="function"?()=>{}:(Bn.add(e),ea(),()=>{Bn.delete(e),!Bn.size&&(po(),Zr())})}const ta=q(0),mo=q(0),_s=q(""),Yn=q(""),Ts=q(0),na=rs({}),go=rs({}),ho=rs({}),Jn=new Map;let Xo=!1;const vf=new Set(["created","updated","deleted","reordered","session-linked","session-cleared"]),yf=new Set(["completed","error","stopped","interrupted","stop_timeout"]);function so(e,t=""){const n=String(t||"").trim();n&&(e[n]=Math.max(0,Number(e[n])||0)+1)}function Sf(e={}){const t=String(e.type||"").trim(),n=String(e.reason||"").trim();return{updatesTaskList:t==="runs.changed"||t==="tasks.changed"&&vf.has(n),updatesSessions:t==="ready"||t==="runs.changed"||t==="sessions.changed",updatesTaskRuns:t==="runs.changed",updatesTaskDiff:t==="runs.changed"||t==="tasks.changed"&&(n==="session-linked"||n==="session-cleared")}}function wf(e=null,t=null){const n=String((e==null?void 0:e.runId)||"").trim(),o=String((e==null?void 0:e.status)||"").trim(),s=String((t==null?void 0:t.runId)||"").trim(),r=String((t==null?void 0:t.status)||"").trim();return!n||!s||n!==s||!o||o!==r?!1:yf.has(r)}function xf(e="",t={}){const n=String(e||"").trim();if(!n)return;const o=Jn.get(n);o!=null&&o.size&&o.forEach(s=>{try{s(t)}catch{}})}function bf(e={}){const t=String(e.type||"").trim(),n=String(e.taskSlug||"").trim(),o=Sf(e);if(t){if(t==="ready"){ta.value+=1,_s.value="",Yn.value="",Ts.value+=1;return}if(t==="tasks.changed"){_s.value=n,Yn.value=String(e.reason||"").trim(),o.updatesTaskList&&(mo.value+=1),o.updatesTaskDiff&&so(go,n);return}if(t==="runs.changed"){_s.value=n,Yn.value="";const s={runId:String(e.runId||"").trim(),status:String(e.status||"").trim(),sentAt:String(e.sentAt||"").trim()},r=n&&ho[n]||null,l=wf(r,s);n&&(ho[n]=s),o.updatesTaskList&&!l&&(mo.value+=1),o.updatesSessions&&(Ts.value+=1),o.updatesTaskRuns&&so(na,n),o.updatesTaskDiff&&!l&&so(go,n);return}if(t==="sessions.changed"){Yn.value="",o.updatesSessions&&(Ts.value+=1);return}t==="run.event"&&xf(n,{taskSlug:n,runId:String(e.runId||"").trim(),event:e.event||null})}}function sa(){Xo||typeof window>"u"||(hf(e=>{bf(e)}),Xo=!0)}function kf(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(na[t])||0):0}function _f(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(go[t])||0):0}function Tf(e=""){const t=String(e||"").trim();return t&&ho[t]||null}function Cf(e="",t){const n=String(e||"").trim();if(!n||typeof t!="function")return()=>{};sa();const o=Jn.get(n)||new Set;return o.add(t),Jn.set(n,o),()=>{const s=Jn.get(n);s&&(s.delete(t),s.size||Jn.delete(n))}}function oa(){return sa(),{readyVersion:ta,listSyncVersion:mo,listSyncTaskSlug:_s,listSyncReason:Yn,sessionsSyncVersion:Ts,getTaskRunSyncVersion:kf,getTaskRunChange:Tf,getTaskDiffSyncVersion:_f}}const Ef=/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)/g,Af=/\u001B\[[0-?]*[ -/]*[@-~]/g,$f=/\u001B[@-_]/g,If=/[\u0000-\u0008\u000B-\u001A\u001C-\u001F\u007F]/g;function Pf(e=""){let t="";for(const n of String(e||"")){if(n==="\b"||n===""){t=t.slice(0,-1);continue}t+=n}return t}function On(e=""){return Pf(String(e||"")).replace(Ef,"").replace(Af,"").replace($f,"").replace(/\r\n/g,`
18
+ `)}),(oe=(M=(B=window.getSelection)==null?void 0:B.call(window))==null?void 0:M.removeAllRanges)==null||oe.call(M),Me(),o("close")}function zs(u){var qe,Ve,bt,Rt;const C=(qe=window.getSelection)==null?void 0:qe.call(window),B=se.value;if(!C||C.rangeCount<1||C.isCollapsed||!B)return;Ee();const oe=C.getRangeAt(0).commonAncestorContainer;if(!B.contains((oe==null?void 0:oe.nodeType)===1?oe:oe==null?void 0:oe.parentNode))return;const Te=String(C.toString()||"").replace(/\u200b/g,"");Te&&((bt=(Ve=u==null?void 0:u.clipboardData)==null?void 0:Ve.setData)==null||bt.call(Ve,"text/plain",Te),(Rt=u==null?void 0:u.preventDefault)==null||Rt.call(u))}function zt(){_&&(window.clearTimeout(_),_=null)}function is(){H.clear()}function Hs(u=""){const C=String(u||"").trim();if(!C||!H.has(C))return null;const B=H.get(C);return H.delete(C),H.set(C,B),B}function Un(u="",C=null){const B=String(u||"").trim();if(!(!B||!C))for(H.delete(B),H.set(B,C);H.size>cf;){const M=H.keys().next().value;if(!M)break;H.delete(M)}}function ls(u){zt(),_=window.setTimeout(()=>{_=null,u==null||u()},ve)}function sn(){at(()=>{var u,C;(C=(u=U.value)==null?void 0:u.focus)==null||C.call(u)})}function Vn(u){var C,B,M;if((C=u==null?void 0:u.preventDefault)==null||C.call(u),je.value){(B=u==null?void 0:u.stopPropagation)==null||B.call(u),f.value="";return}(M=u==null?void 0:u.stopPropagation)==null||M.call(u),o("close")}function zn(){zt(),pe+=1,is(),c.value="",p.value="",S.value=!1,d.value="",m.value=null,Ie.value="",Ae.value="",Be.value="",Xe.value="2.6rem",A.value=0,G.value=[],ce.value="",Me(),Pt()}function Yt(){I+=1,Q&&(window.clearTimeout(Q),Q=null),le&&(le.abort(),le=null),v.value=[],P.value=!1,ne.value="",y.value="",L.value=!1,O.value="",G.value=[],ce.value="",Pt()}function us(){if(Q&&(window.clearTimeout(Q),Q=null),!n.open||!F.value||!Fe.value)return;if(!je.value||!Ke.value){Yt();return}P.value=!0,ne.value="",Q=window.setTimeout(()=>{Q=null,Kn()},ie)}function Hn(u=1){const C=v.value;if(!C.length)return!1;const B=C.findIndex(oe=>ee(oe)===O.value),M=B<0?0:(B+u+C.length)%C.length;return O.value=ee(C[M]),at(Y),!0}function Tn(){return K.value.length&&(K.value.find(u=>u.path===ft.value)||K.value[0])||null}function fn(u,C={}){return u?(ft.value=(u==null?void 0:u.path)||"",O.value="",c.value=String((u==null?void 0:u.path)||"").trim(),p.value=String((u==null?void 0:u.type)||"").trim(),d.value="",A.value=0,G.value=[],ce.value="",(u==null?void 0:u.type)==="directory"?(zt(),m.value=null,C.toggleDirectory&&!T.value&&E(u.path),!0):C.previewMode==="debounced"?(ls(()=>En(u==null?void 0:u.path)),!0):(zt(),En(u==null?void 0:u.path),!0)):!1}function cs(){const u=v.value;if(!u.length)return!1;const C=u.find(B=>ee(B)===O.value)||u[0];return mn(C),!0}function qs(u){const C=String((u==null?void 0:u.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(C)&&!(T.value&&(C==="ArrowLeft"||C==="ArrowRight"))){if(Fe.value&&T.value){if(C==="ArrowDown"){if(u.preventDefault(),Hn(1)){const B=v.value,M=B.find(oe=>ee(oe)===O.value)||B[0];mn(M,{previewMode:"debounced"})}return}if(C==="ArrowUp"){if(u.preventDefault(),Hn(-1)){const B=v.value,M=B.find(oe=>ee(oe)===O.value)||B[0];mn(M,{previewMode:"debounced"})}return}if(C==="Enter"){u.preventDefault(),cs();return}C==="Escape"&&Vn(u);return}if(C==="ArrowDown"){u.preventDefault(),he(1)&&at(()=>{fn(Tn(),{previewMode:"debounced"})});return}if(C==="ArrowUp"){u.preventDefault(),he(-1)&&at(()=>{fn(Tn(),{previewMode:"debounced"})});return}if(C==="ArrowRight"){u.preventDefault(),Bt();return}if(C==="ArrowLeft"){u.preventDefault(),_t();return}if(C==="Enter"){u.preventDefault(),fn(Tn(),{toggleDirectory:!0});return}C==="Escape"&&Vn(u)}}async function Cn(){const u=Fe.value?"path":"content";if(b.value=u,!je.value){u==="content"?Yt():(Yt(),l.query="");return}if(u==="content"){l.query="",Kn();return}Yt(),l.query=f.value}function Ks(u){var C;u.preventDefault(),(C=u.stopPropagation)==null||C.call(u),Cn().finally(()=>{sn()})}async function pn(){var Te;if(await at(),Pt(),!se.value)return;const u=[...new Set(G.value.map(qe=>Math.max(0,Number(qe)||0)).filter(qe=>qe>0))],C=Math.max(0,Number(A.value)||0);if(u.forEach(qe=>{var Rt,Kt;const Ve=se.value.querySelector(`.source-code-view__gutter[data-line="${qe}"]`),bt=(Rt=Ve==null?void 0:Ve.closest)==null?void 0:Rt.call(Ve,"tr");(Kt=bt==null?void 0:bt.classList)==null||Kt.add("is-match")}),Ft(),!C){Xt();return}const B=C,M=se.value.querySelector(`.source-code-view__gutter[data-line="${B}"]`),oe=(Te=M==null?void 0:M.closest)==null?void 0:Te.call(M,"tr");if(!oe){Xt();return}oe.classList.add("is-match","is-focus-match"),Ft(),oe.scrollIntoView({block:"center",inline:"nearest"}),Xt()}async function qn(){var Te,qe,Ve;if(!ge.value){Ie.value="",Ae.value="",Be.value="";return}const u=pe,C=String(((Te=m.value)==null?void 0:Te.content)||"").replace(/\r\n/g,`
19
+ `),B=((qe=m.value)==null?void 0:qe.language)||"",M=Xu(C,eo),oe=await Qu(((Ve=m.value)==null?void 0:Ve.content)||"",{isDark:r.value,language:B,maxHighlightLines:eo.maxLines,maxHighlightChars:eo.maxChars});u===pe&&(Ie.value=oe.html,Ae.value=M?"":oe.bg||"",Be.value=M?"":oe.fg||"",Xe.value=oe.gutterWidth||"2.6rem",await at(),Xt())}async function En(u="",C={}){var qe;const B=String(u||"").trim();if(!F.value||!B)return;A.value=Math.max(0,Number(C.focusLine)||0),Me();const M=String(((qe=m.value)==null?void 0:qe.path)||"").trim();if(!C.forceReload&&M===B&&!S.value&&!d.value){await pn();return}if(!C.forceReload&&S.value&&c.value===B)return;pe+=1;const oe=pe;d.value="";const Te=C.forceReload?null:Hs(B);if(Te){S.value=!1,m.value=Te,await qn(),oe===pe&&ge.value&&await pn();return}S.value=!0;try{const Ve=await el(F.value,{path:B,limit:204800,refreshToken:String(Date.now())});if(oe!==pe)return;m.value=Ve,Un(B,Ve),await qn()}catch(Ve){if(oe!==pe)return;m.value=null,d.value=(Ve==null?void 0:Ve.message)||s("sourceBrowser.previewFailed")}finally{oe===pe&&(S.value=!1,ge.value&&await pn())}}function on(u){fn(u,{toggleDirectory:!0}),at(sn)}function ds(u,C){var B,M;(M=(B=u==null?void 0:u.currentTarget)==null?void 0:B.focus)==null||M.call(B),on(C)}async function Kn(){const u=je.value;if(!n.open||!F.value)return;I+=1;const C=I;if(!u||!Ke.value){Yt();return}le&&(le.abort(),le=null),P.value=!0,ne.value="",v.value=[],L.value=!1,O.value="",le=new AbortController;try{const B=await tl(F.value,u,{limit:80,refreshToken:String(Date.now()),signal:le.signal});if(C!==I)return;y.value=u,v.value=Array.isArray(B.items)?B.items:[],L.value=!!B.truncated,O.value=v.value[0]?ee(v.value[0]):"",v.value[0]&&mn(v.value[0],{previewMode:"debounced"})}catch(B){if(Jr(B)||C!==I)return;y.value=u,v.value=[],ne.value=(B==null?void 0:B.message)||s("sourceBrowser.contentSearchFailed")}finally{C===I&&(le=null),C===I&&(P.value=!1)}}function mn(u,C={}){O.value=ee(u),ft.value=(u==null?void 0:u.path)||"",c.value=String((u==null?void 0:u.path)||"").trim(),p.value="file",d.value="",ce.value=y.value||je.value,G.value=v.value.filter(M=>(M==null?void 0:M.path)===(u==null?void 0:u.path)).map(M=>Number((M==null?void 0:M.line)||0)).filter(M=>M>0);const B=()=>En(u==null?void 0:u.path,{focusLine:u==null?void 0:u.line});if(C.previewMode==="debounced"){ls(B),at(sn);return}zt(),B(),at(sn)}function $(u){const C=String((u==null?void 0:u.path)||"").trim();if(!C)return"";const B=C.split("/");return B[B.length-1]||C}function Z(u){const C=String((u==null?void 0:u.path)||"").trim();return!C||!C.includes("/")?"":C.slice(0,C.lastIndexOf("/"))}function we(u){return`${Array.isArray(u==null?void 0:u.items)?u.items.length:0} 处`}function ke(u){const C=y.value||je.value;return D((u==null?void 0:u.preview)||"",C)}return $e(()=>n.open,u=>{var C,B,M,oe,Te,qe;if(l.open=u,u){(M=(B=(C=window.getSelection)==null?void 0:C.call(window))==null?void 0:B.removeAllRanges)==null||M.call(B),l.sessionId=F.value,f.value="",b.value="path",l.query="",zn(),Yt(),de(),sn();return}(qe=(Te=(oe=window.getSelection)==null?void 0:oe.call(window))==null?void 0:Te.removeAllRanges)==null||qe.call(Te),f.value="",b.value="path",zn(),Yt(),qt()},{immediate:!0}),$e(F,u=>{l.sessionId=u,n.open&&(zn(),Yt(),V())}),$e(f,u=>{if(De.value){l.query=u;return}String(u||"").trim()!==String(y.value||"").trim()&&(ce.value="",Ft()),us()}),$e(()=>l.query,()=>{De.value&&pt()}),$e(yt,()=>{at(Y)}),$e(st,()=>{X(),!(!T.value||!De.value)&&at(()=>{const u=Tn();u&&fn(u,{previewMode:"debounced"})})}),$e(r,async()=>{!n.open||!ge.value||(await qn(),await pn())}),$e(lt,()=>{Xt()}),It(()=>{var u,C,B;(B=(C=(u=window.getSelection)==null?void 0:u.call(window))==null?void 0:C.removeAllRanges)==null||B.call(C),Me({clearBrowserSelection:!0}),zt()}),(u,C)=>(g(),Ce(Fs,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] sm:h-[96vh] sm:max-h-[96vh] sm:w-[90vw] sm:max-w-[90vw]","header-class":"settings-dialog-header px-5 py-3.5","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col overflow-hidden",onClose:C[2]||(C[2]=B=>o("close"))},{title:Je(()=>[i("div",Qc,[i("div",Zc,w(He.value||a(s)("sourceBrowser.title")),1)])]),default:Je(()=>{var B;return[i("div",ed,[i("aside",{class:"theme-divider flex min-h-0 flex-col border-b md:border-b-0 md:border-r",onKeydown:qs},[i("div",td,[i("label",nd,[i("span",sd,w(a(s)("sourceBrowser.searchLabel")),1),i("div",od,[ue(a($a),{class:"theme-muted-text pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),Wt(i("input",{ref_key:"searchInputRef",ref:U,"onUpdate:modelValue":C[0]||(C[0]=M=>f.value=M),type:"text",class:"tool-input w-full pl-9 pr-18 text-[12px]",placeholder:wt.value,onKeydown:[Gt(Vn,["esc"]),Gt(Qe(Ks,["prevent"]),["tab"])]},null,40,rd),[[Xn,f.value]]),te.value?(g(),Ce(a(Ht),{key:0,class:"theme-muted-text pointer-events-none absolute right-10 top-1/2 h-4 w-4 -translate-y-1/2 animate-spin"})):me("",!0),i("button",{type:"button",class:"tool-button absolute right-1.5 top-1/2 inline-flex h-7 w-7 -translate-y-1/2 items-center justify-center px-0",title:Ct.value,"aria-label":Ct.value,onClick:Qe(Cn,["stop","prevent"])},[ue(a(Ia),{class:"h-3.5 w-3.5"})],8,ad)])])]),i("div",id,[F.value?T.value&&Fe.value&&ne.value?(g(),x("div",ud,w(ne.value),1)):a(re)?(g(),x("div",cd,w(a(re)),1)):Oe.value?(g(),x("div",dd,w(a(s)("sourceBrowser.searchMinKeywordHint",{count:a(bs)})),1)):ye.value?(g(),x("div",fd,w(a(s)("sourceBrowser.searchEmpty")),1)):Re.value?(g(),x("div",pd,w(a(s)("sourceBrowser.searchMinKeywordHint",{count:a(bs)})),1)):Ye.value?(g(),x("div",md,w(a(s)("sourceBrowser.contentSearchPrompt")),1)):Ge.value?(g(),x("div",gd,w(a(s)("sourceBrowser.contentSearchEmpty")),1)):a(nn)?(g(),x("div",hd,w(a(s)("sourceBrowser.treeEmpty")),1)):T.value&&Fe.value&&P.value&&!v.value.length?(g(),x("div",vd,w(a(s)("sourceBrowser.contentSearching")),1)):a(Le)&&!a(K).length?(g(),x("div",yd,w(a(s)("sourceBrowser.loadingFiles")),1)):T.value&&De.value?(g(),x("div",Sd,[a(Tt).length?(g(),x("div",wd,w(a(s)("sourceBrowser.recent")),1)):me("",!0),(g(!0),x(et,null,ut(a(Tt),M=>(g(),x("button",{key:`recent-${M.path}`,ref_for:!0,ref:oe=>a(At)(M.path,oe),type:"button",class:Se(["theme-list-row focus:outline-none",a(ft)===M.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:oe=>on(M)},[(g(),Ce(cn(M.type==="directory"?a(Dn):a(Sn)),{class:"theme-list-item-icon"})),i("div",bd,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(xt)(M)},null,8,kd)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Et)(M)},null,8,_d)])],10,xd))),128)),l.query.trim()&&a(Ue).length?(g(),x("div",Td,w(a(s)("sourceBrowser.results")),1)):me("",!0),(g(!0),x(et,null,ut(a(Ue),M=>(g(),x("button",{key:`result-${M.path}`,ref_for:!0,ref:oe=>a(At)(M.path,oe),type:"button",class:Se(["theme-list-row focus:outline-none",a(ft)===M.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:oe=>on(M)},[(g(),Ce(cn(M.type==="directory"?a(Dn):a(Sn)),{class:"theme-list-item-icon"})),i("div",Ed,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(xt)(M)},null,8,Ad)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Et)(M)},null,8,$d)])],10,Cd))),128))])):T.value?(g(),x("div",Id,[(g(!0),x(et,null,ut(nt.value,M=>(g(),x("div",{key:M.path,class:"rounded-sm border border-[var(--theme-borderDefault)] bg-[var(--theme-panel)]"},[i("div",Pd,[ue(a(Sn),{class:"theme-list-item-icon"}),i("div",Dd,[i("div",Ld,w($(M)),1),Z(M)?(g(),x("div",Bd,w(Z(M)),1)):me("",!0)]),i("div",Md,w(we(M)),1)]),i("div",Rd,[(g(!0),x(et,null,ut(M.items,oe=>(g(),x("button",{key:ee(oe),ref_for:!0,ref:Te=>h(ee(oe),Te),type:"button",class:Se(["theme-list-row gap-0 focus:outline-none",O.value===ee(oe)?"theme-list-item-active":"theme-list-item-hover"]),onClick:Te=>mn(oe)},[i("div",{class:"theme-list-item-title min-w-0 flex-1 break-words leading-[1.45rem]",innerHTML:ke(oe)},null,8,Od)],10,Nd))),128))])]))),128)),L.value?(g(),x("div",jd,w(a(s)("sourceBrowser.contentSearchTruncated")),1)):me("",!0)])):(g(),x("div",Fd,[(g(!0),x(et,null,ut(a(k),M=>(g(),x("div",{key:M.path,ref_for:!0,ref:oe=>a(At)(M.path,oe),class:Se(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(ft)===M.path?"theme-list-item-active":M.type==="directory"&&M.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:kn({paddingLeft:`${M.depth*16+6}px`}),tabindex:"-1",onClick:oe=>ds(oe,M)},[i("div",Vd,[M.type==="directory"?(g(),x("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:Qe(oe=>a(E)(M.path),["stop"])},[M.loading?(g(),Ce(a(Ht),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),Ce(a(Er),{key:1,class:Se(["h-3.5 w-3.5 transition",M.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,zd)):(g(),x("span",Hd)),i("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 outline-none focus:outline-none",onClick:Qe(oe=>on(M),["stop"])},[(g(),Ce(cn(M.type==="directory"?a(Dn):a(Sn)),{class:Se(["h-4 w-4 shrink-0",M.type==="directory"&&M.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("span",{class:Se(["theme-list-item-title min-w-0 flex-1 truncate",M.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},w(a(ot)(M)),3)],8,qd)])],14,Ud))),128))])):(g(),x("div",ld,w(a(s)("sourceBrowser.noProject")),1))])],32),i("section",Kd,[i("div",Wd,[i("div",Gd,[i("div",Xd,[J.value?(g(),x("p",Yd,w(J.value),1)):me("",!0),ge.value?(g(),x("p",Jd,w(a(s)("sourceBrowser.selectCodeLineHint")),1)):me("",!0)])])]),i("div",Qd,[S.value?(g(),x("div",Zd,[i("span",null,w(a(s)("sourceBrowser.previewLoading")),1)])):d.value?(g(),x("div",ef,w(d.value),1)):p.value==="directory"?(g(),x("div",tf,w(a(s)("sourceBrowser.selectFileHint")),1)):c.value?fe.value?(g(),x("div",sf,[i("img",{src:m.value.previewUrl,alt:tt.value,class:"source-browser-image object-contain"},null,8,of)])):_e.value?(g(),x("div",rf,[ue(a(Pa),{class:"h-8 w-8"}),i("span",null,w((B=m.value)!=null&&B.tooLarge?a(s)("sourceBrowser.binaryTooLarge"):a(s)("sourceBrowser.binaryUnsupported")),1)])):ge.value?(g(),x("div",{key:6,ref_key:"previewContainerRef",ref:se,class:"source-browser-code relative rounded-sm border",style:kn({"--source-code-bg":Ae.value||"var(--theme-panel)","--source-code-fg":Be.value||"var(--theme-textPrimary)","--source-code-gutter-width":Xe.value}),onCopy:zs,onMouseup:C[1]||(C[1]=(...M)=>a(Ne)&&a(Ne)(...M))},[i("div",af,[i("table",lf,[i("tbody",{innerHTML:Ie.value},null,8,uf)])]),e.open&&a(it).visible?(g(),Ce(Gr,{key:0,top:a(it).top,left:a(it).left,label:a(s)("sourceBrowser.insertSelection"),onClick:Fn},null,8,["top","left","label"])):me("",!0)],36)):me("",!0):(g(),x("div",nf,w(a(s)("sourceBrowser.selectFile")),1))])])])]}),_:1},8,["open"]))}},ff=br(df,[["__scopeId","data-v-100e8f17"]]);function pf(e={}){const{items:t,themeKey:n,getCacheKey:o=y=>String((y==null?void 0:y.id)||"").trim(),getSource:s=y=>String((y==null?void 0:y.content)||""),shouldRender:r=()=>!0,renderAsync:l=async y=>y,renderFallback:c=y=>y,onRendered:p=null}=e,S=new Map,d=new Map,m=q(0),f=W(()=>(Array.isArray(t==null?void 0:t.value)?t.value:[]).map(y=>{const L=!!r(y),O=String(o(y)||"").trim(),z=L?String(s(y)||""):"";return{item:y,active:L,cacheKey:O,source:z}}));function b(y){if(m.value,!r(y))return"";const L=String(s(y)||""),O=String(o(y)||"").trim(),z=String((n==null?void 0:n.value)||"");if(!O)return c(L,y);const U=S.get(O);return(U==null?void 0:U.source)===L&&(U==null?void 0:U.theme)===z?U.html:c(L,y)}async function v(y){if(!r(y))return;const L=String(s(y)||""),O=String(o(y)||"").trim();if(!O)return;const z=String((n==null?void 0:n.value)||""),U=S.get(O);if((U==null?void 0:U.source)===L&&(U==null?void 0:U.theme)===z)return;const se=Symbol(O);d.set(O,se);try{const A=await l(L,y,{themeKey:z});if(d.get(O)!==se)return;S.set(O,{source:L,theme:z,html:A}),m.value+=1,p==null||p(y,{cacheKey:O,source:L,themeKey:z})}catch{}finally{d.get(O)===se&&d.delete(O)}}function P(y=[]){y.forEach(L=>{L!=null&&L.item&&v(L.item)})}function ne(y=[]){const L=new Set((Array.isArray(y)?y:[]).filter(z=>z==null?void 0:z.active).map(z=>String((z==null?void 0:z.cacheKey)||"").trim()).filter(Boolean));let O=!1;for(const z of S.keys())L.has(z)||(S.delete(z),O=!0);for(const z of d.keys())L.has(z)||d.delete(z);O&&(m.value+=1)}return $e(f,()=>{ne(f.value||[]),P(f.value||[])},{immediate:!0}),$e(n,()=>{P(f.value||[])}),It(()=>{d.clear()}),{getRenderedHtml:b}}const mf=`${Io()}/api/events/stream`,Bn=new Set;let wn=null,ks=null;function po(){ks&&(window.clearTimeout(ks),ks=null)}function Zr(){wn&&(wn.close(),wn=null)}function gf(e){Bn.forEach(t=>{try{t(e)}catch{}})}function ea(){typeof window>"u"||typeof window.EventSource>"u"||wn||!Bn.size||(po(),wn=new window.EventSource(mf),wn.onmessage=e=>{try{const t=JSON.parse(String(e.data||"{}"));if(!(t!=null&&t.type))return;gf(t)}catch{}},wn.onerror=()=>{Zr(),Bn.size&&(po(),ks=window.setTimeout(()=>{ea()},1500))})}function hf(e){return typeof e!="function"?()=>{}:(Bn.add(e),ea(),()=>{Bn.delete(e),!Bn.size&&(po(),Zr())})}const ta=q(0),mo=q(0),_s=q(""),Yn=q(""),Ts=q(0),na=rs({}),go=rs({}),ho=rs({}),Jn=new Map;let Xo=!1;const vf=new Set(["created","updated","deleted","reordered","session-linked","session-cleared"]),yf=new Set(["completed","error","stopped","interrupted","stop_timeout"]);function so(e,t=""){const n=String(t||"").trim();n&&(e[n]=Math.max(0,Number(e[n])||0)+1)}function Sf(e={}){const t=String(e.type||"").trim(),n=String(e.reason||"").trim();return{updatesTaskList:t==="runs.changed"||t==="tasks.changed"&&vf.has(n),updatesSessions:t==="ready"||t==="runs.changed"||t==="sessions.changed",updatesTaskRuns:t==="runs.changed",updatesTaskDiff:t==="runs.changed"||t==="tasks.changed"&&(n==="session-linked"||n==="session-cleared")}}function wf(e=null,t=null){const n=String((e==null?void 0:e.runId)||"").trim(),o=String((e==null?void 0:e.status)||"").trim(),s=String((t==null?void 0:t.runId)||"").trim(),r=String((t==null?void 0:t.status)||"").trim();return!n||!s||n!==s||!o||o!==r?!1:yf.has(r)}function xf(e="",t={}){const n=String(e||"").trim();if(!n)return;const o=Jn.get(n);o!=null&&o.size&&o.forEach(s=>{try{s(t)}catch{}})}function bf(e={}){const t=String(e.type||"").trim(),n=String(e.taskSlug||"").trim(),o=Sf(e);if(t){if(t==="ready"){ta.value+=1,_s.value="",Yn.value="",Ts.value+=1;return}if(t==="tasks.changed"){_s.value=n,Yn.value=String(e.reason||"").trim(),o.updatesTaskList&&(mo.value+=1),o.updatesTaskDiff&&so(go,n);return}if(t==="runs.changed"){_s.value=n,Yn.value="";const s={runId:String(e.runId||"").trim(),status:String(e.status||"").trim(),sentAt:String(e.sentAt||"").trim()},r=n&&ho[n]||null,l=wf(r,s);n&&(ho[n]=s),o.updatesTaskList&&!l&&(mo.value+=1),o.updatesSessions&&(Ts.value+=1),o.updatesTaskRuns&&so(na,n),o.updatesTaskDiff&&!l&&so(go,n);return}if(t==="sessions.changed"){Yn.value="",o.updatesSessions&&(Ts.value+=1);return}t==="run.event"&&xf(n,{taskSlug:n,runId:String(e.runId||"").trim(),event:e.event||null})}}function sa(){Xo||typeof window>"u"||(hf(e=>{bf(e)}),Xo=!0)}function kf(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(na[t])||0):0}function _f(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(go[t])||0):0}function Tf(e=""){const t=String(e||"").trim();return t&&ho[t]||null}function Cf(e="",t){const n=String(e||"").trim();if(!n||typeof t!="function")return()=>{};sa();const o=Jn.get(n)||new Set;return o.add(t),Jn.set(n,o),()=>{const s=Jn.get(n);s&&(s.delete(t),s.size||Jn.delete(n))}}function oa(){return sa(),{readyVersion:ta,listSyncVersion:mo,listSyncTaskSlug:_s,listSyncReason:Yn,sessionsSyncVersion:Ts,getTaskRunSyncVersion:kf,getTaskRunChange:Tf,getTaskDiffSyncVersion:_f}}const Ef=/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)/g,Af=/\u001B\[[0-?]*[ -/]*[@-~]/g,$f=/\u001B[@-_]/g,If=/[\u0000-\u0008\u000B-\u001A\u001C-\u001F\u007F]/g;function Pf(e=""){let t="";for(const n of String(e||"")){if(n==="\b"||n===""){t=t.slice(0,-1);continue}t+=n}return t}function On(e=""){return Pf(String(e||"")).replace(Ef,"").replace(Af,"").replace($f,"").replace(/\r\n/g,`
20
20
  `).replace(/\r/g,`
21
21
  `).replace(If,"")}function as(e=""){return On(e)}function _n(e=""){return String(e||"").replace(/^(?:[ \t]*\n)+/,"").replace(/(?:\n[ \t]*)+$/,"")}function Lo(e=[],t=12){const n=Array.isArray(e)?e:[];return n.length<=t?{items:n,hiddenCount:0}:{items:n.slice(0,t),hiddenCount:n.length-t}}function Df(e=""){const t=_n(as(e));if(!t.trim())return null;const n=t.split(`
22
22
  `),o=String(n[0]||"").trim();if(!o)return null;const s=o.match(/^([A-Za-z][A-Za-z0-9 _/-]{1,24}):\s*(.+)$/);if(!s)return null;const r=s[1].trim().toLowerCase();if(!new Set(["read","grep","glob","find","ls","dir","tree","list","path","file","command"]).has(r))return null;const c=_n(n.slice(1).join(`
23
23
  `));return{meta:{type:"meta",items:[{label:s[1].trim(),value:s[2].trim()}]},rest:c}}function Lf(e="",t={}){const n=_n(as(e));if(!n.trim()||!n.includes("<path>")||!n.includes("<entries>"))return null;const o=n.match(/<path>([\s\S]*?)<\/path>/i),s=n.match(/<type>([\s\S]*?)<\/type>/i),r=n.match(/<entries>([\s\S]*?)<\/entries>/i);if(!o&&!r)return null;const l=String((r==null?void 0:r[1])||"").split(`
24
- `).map(w=>w.trim()).filter(Boolean).filter(w=>!/^\(\d+\s+entries?\)$/i.test(w)),{items:c,hiddenCount:p}=Lo(l,t.maxItems??12);return{type:"directory_list",path:String((o==null?void 0:o[1])||"").trim(),entryType:String((s==null?void 0:s[1])||"").trim(),entries:c,totalCount:l.length,hiddenCount:p}}function Bf(e="",t={}){const n=_n(as(e));if(!n.trim())return null;const o=n.split(`
24
+ `).map(S=>S.trim()).filter(Boolean).filter(S=>!/^\(\d+\s+entries?\)$/i.test(S)),{items:c,hiddenCount:p}=Lo(l,t.maxItems??12);return{type:"directory_list",path:String((o==null?void 0:o[1])||"").trim(),entryType:String((s==null?void 0:s[1])||"").trim(),entries:c,totalCount:l.length,hiddenCount:p}}function Bf(e="",t={}){const n=_n(as(e));if(!n.trim())return null;const o=n.split(`
25
25
  `).map(c=>c.trimEnd()),s=o.map(c=>{const p=c.match(/^\s*\[([ xX])\]\s+(.+)$/);return p?{completed:p[1].toLowerCase()==="x",text:p[2].trim()}:null}).filter(Boolean);if(!s.length||s.length<Math.ceil(o.filter(Boolean).length*.6))return null;const{items:r,hiddenCount:l}=Lo(s,t.maxItems??12);return{type:"checklist",items:r,totalCount:s.length,hiddenCount:l}}function Mf(e="",t={}){const n=_n(as(e));if(!n.trim())return null;const o=n.split(`
26
26
  `),s=o.map(c=>{const p=c.match(/^[-*]\s+(.+)$/);return p?p[1].trim():null}).filter(Boolean);if(s.length<2||s.length<Math.ceil(o.filter(Boolean).length*.6))return null;const{items:r,hiddenCount:l}=Lo(s,t.maxItems??12);return{type:"bullet_list",items:r,totalCount:s.length,hiddenCount:l}}function Rf(e="",t={}){return{type:t.preferMarkdown?"markdown":"text",text:e}}function Nf(e=[]){return e.reduce((t,n)=>{const o=t[t.length-1];return o&&n&&o.type===n.type&&["text","markdown"].includes(n.type)?(o.text=`${o.text}
27
27
 
@@ -31,30 +31,30 @@ ${n.text}`,t):(t.push(n),t)},[])}function Of(e="",t={}){const n=String(e||"").sp
31
31
  ...`:r}function yn(e=[]){const t=Array.isArray(e)?e:[];return t.length?t.map(n=>{const o=String((n==null?void 0:n.status)||"").trim().toLowerCase();return`${n.completed?"[x]":o==="in_progress"?"[-]":"[ ]"} ${n.text||N("未命名任务","Untitled Task")}`}).join(`
32
32
  `):""}function Dt(e=0){const t=Number(e||0);return Number.isFinite(t)?t.toLocaleString(Os()):"0"}function Mo(e=""){return String(e||"").trim().toLowerCase()==="shell"}function Ff(e=""){return Mo(e)?N("Shell","Shell"):ct(e)}function Uf(e=""){const t=String(e||"").trim().toLowerCase();return["completed","complete","succeeded","success","done"].includes(t)?"completed":["failed","error","errored","cancelled","canceled","stopped"].includes(t)?"failed":["running","in_progress","in-progress"].includes(t)?"running":["pending_init","pending"].includes(t)?"pending_init":t||"pending_init"}function aa(e={}){const t=[],n=o=>{const s=String(o||"").trim();!s||t.includes(s)||t.push(s)};return(Array.isArray(e.receiver_thread_ids)?e.receiver_thread_ids:[]).forEach(n),e.agents_states&&typeof e.agents_states=="object"&&Object.keys(e.agents_states).forEach(n),t}function Bs(e={}){return aa(e).length}function ia(e={}){const t=aa(e),n=e.agents_states&&typeof e.agents_states=="object"?e.agents_states:{};return t.map(o=>{const s=n[o]&&typeof n[o]=="object"?n[o]:{},r=String(s.message||s.result||"").trim();return{id:o,status:Uf(s.status),title:String(s.title||s.description||s.name||"").trim(),role:String(s.role||s.subagent_type||s.agent||"").trim(),target:String(s.target||s.path||"").trim(),model:String(s.model||"").trim(),message:r,messageBlocks:r?bn(r):[]}})}function Vf(e={},t=120){const n=ia(e).map(o=>o.message).filter(Boolean);return gt(n.join(ln()?" | ":"|"),t)}function la(e=0){const t=Math.max(0,Math.floor(Number(e)||0));if(t<66)return`${t}s`;const n=Math.floor(t/3600),o=Math.floor(t%3600/60),s=t%60;return n>0?ln()?`${n}h ${o}m ${s}s`:`${n}小时${o}分${s}秒`:ln()?`${o}m ${s}s`:`${o}分${s}秒`}function gt(e="",t=140){const n=String(e||"").replace(/\s+/g," ").trim();return n?n.length<=t?n:`${n.slice(0,t)}...`:""}function ua(e="",t=[]){const n=t.filter(Boolean);if(!n.length)return"";const o=n.map(s=>`- ${s}`).join(`
33
33
  `);return e?`${e}
34
- ${o}`:o}function es(e=[]){const t=e.map(n=>({label:String((n==null?void 0:n.label)||"").trim(),value:String((n==null?void 0:n.value)||"").trim()})).filter(n=>n.label&&n.value);return t.length?{type:"meta",items:t}:null}function zf(e=""){const t=String(e||"").trim().toLowerCase();return["done","completed","complete","checked"].includes(t)?"completed":["in_progress","in-progress","active","doing","running"].includes(t)?"in_progress":"pending"}function Hf(e={}){return[e==null?void 0:e.text,e==null?void 0:e.content,e==null?void 0:e.title,e==null?void 0:e.label,e==null?void 0:e.activeForm].map(n=>String(n||"").trim()).find(Boolean)||N("未命名任务","Untitled Task")}function Cs(e=[]){return(Array.isArray(e)?e:[]).map(t=>{if(!t||typeof t!="object")return null;const n=zf(t.status??(t.completed?"completed":"pending"));return{completed:n==="completed",status:n,text:Hf(t)}}).filter(Boolean)}function Qo(e){const t=String(e||"").trim();if(!t)return[];try{const n=JSON.parse(t);if(Array.isArray(n))return Cs(n);if(n&&typeof n=="object"){if(Array.isArray(n.todos))return Cs(n.todos);if(Array.isArray(n.items))return Cs(n.items)}}catch{return[]}return[]}function ca(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];return t.length?{type:"checklist",items:t,totalCount:t.length,hiddenCount:0}:null}function Ro(e=""){var w;const t=String(e||"").trim(),n=t.indexOf(":"),o=n>0&&n<=24,s=o?t.slice(0,n).trim():"",r=o?t.slice(n+1).trim():t,l=s.toLowerCase(),p=o?((w=Object.entries({shell:["bash","shell","sh","terminal","cmd","powershell"],read:["read","open","view","cat"],grep:["grep","rg","search","find"],list:["glob","ls","dir","tree","list"],web:["websearch","web_search","webfetch","fetch","browse","open_page"],todo:["todowrite","todo","tasklist","tasks"],edit:["edit","multiedit","write","patch","apply_patch","replace","create"]}).find(([,d])=>d.includes(l)))==null?void 0:w[0])||"generic":"shell";return{raw:t,toolName:s,normalizedTool:l,subject:r,category:p}}function ts(e={},t=null){const n=t||Ro(e.command);if(n.category!=="todo")return[];const o=Qo(e.aggregated_output);return o.length?o:Qo(n.subject)}function bn(e="",t={}){return Bo(On(e),t)}function Zo(e={}){const t=e.action||{},n=String(e.query||t.query||"").trim(),o=Array.isArray(t.queries)?t.queries.map(c=>String(c||"").trim()).filter(Boolean):[],s=String(t.url||"").trim(),r=[],l=es([n?{label:N("关键词","Query"),value:n}:null,s?{label:"URL",value:s}:null]);return l&&r.push(l),o.length>1&&r.push({type:"bullet_list",items:o,totalCount:o.length,hiddenCount:0}),r}function er(e={}){const t=String(e.tool||"").trim(),n=Bs(e),o=String(e.prompt||"").trim(),s=ia(e),r=[],l=[t?{label:N("工具","Tool"),value:t}:null,n?{label:N("子代理","Sub-agent"),value:String(n)}:null],c=es(l);return c&&r.push(c),s.length&&r.push({type:"sub_agent_list",items:s,totalCount:s.length,hiddenCount:0}),o&&r.push(...bn(o,{preferMarkdown:!0})),r}function tr(e={}){const t=Array.isArray(e.changes)?e.changes:[];return t.length?[{type:"file_changes",items:t.map(n=>({kind:String((n==null?void 0:n.kind)||"").trim(),path:String((n==null?void 0:n.path)||"").trim()})),totalCount:t.length,hiddenCount:0}]:[]}function gs(e={},t=!1,n="codex"){const o=[],s=Ro(e.command),r=ts(e,s),l=ca(r),c=typeof e.exit_code=="number",p=c?e.exit_code===0:e.status==="completed",w=es([s.toolName?{label:N("工具","Tool"),value:s.toolName}:null,l||s.category!=="shell"?null:s.subject?{label:N("命令","Command"),value:s.subject}:e.command?{label:N("命令","Command"),value:e.command}:null,n&&n!=="codex"?{label:N("引擎","Engine"),value:Ff(n)}:null,c&&!p?{label:N("退出码","Exit code"),value:String(e.exit_code)}:null]);if(w&&o.push(w),l&&o.push(l),t){if(l)return o;const d=ra(e.aggregated_output);d&&o.push(...bn(d,{preferMarkdown:s.category==="web"||s.category==="edit"}))}return o}function In(e={}){const t=Ro(e.command);return{groupType:["read","grep","list","web","todo"].includes(t.category)?t.category:"",groupTarget:t.subject||e.command||"",toolName:t.toolName||""}}function oo(e={}){const t=Array.isArray(e.items)?Cs(e.items):[];return t.length?[ca(t)]:[]}function jn(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function vo(e=[],t=""){const n=String(t||"").trim();return n&&(Array.isArray(e)?e:[]).find(o=>(o==null?void 0:o.runId)===n)||null}function qf(e,t,n,o,s){const r=vo(e,t);return r?(r.events=[],r.lastEventSeq=0,r.summary=jn(),((n==null?void 0:n.items)||[]).forEach(l=>{Oo(r,l,o,s)}),r.eventCount=Math.max(Math.max(0,Number(r.eventCount)||0),Array.isArray(n==null?void 0:n.items)?n.items.length:0,Math.max(0,Number(r.lastEventSeq)||0)),r.eventsLoaded=!0,r.eventsLoading=!1,r):null}function da(e={}){const t=String((e==null?void 0:e.displayEngine)||"").trim();return t?Ls(t):Mo(e==null?void 0:e.engine)?"codex":Ls(e==null?void 0:e.engine)}function Lt(e={}){return ct(da(e))}function Kf(e={}){return Mo(e==null?void 0:e.engine)}function ns(e=""){return jf.has(String(e||"").trim())}function No(e=""){const t=String(e||"").trim();if(!t)return null;const n=t.match(/^Reconnecting\.\.\.\s*(\d+)\/(\d+)\s*\(([\s\S]+)\)$/i);return n?{attempt:Number(n[1]||0),total:Number(n[2]||0),reason:String(n[3]||"").trim(),rawMessage:t}:null}function nr(e={},t="completed"){const n=e.action||{},o=String(n.type||"").trim(),s=String(e.query||n.query||"").trim(),r=Array.isArray(n.queries)?n.queries.map(c=>String(c||"").trim()).filter(Boolean):[],l=String(n.url||s||"").trim();return o==="search"?{kind:"command",title:t==="started"?N("正在搜索网页","Searching the web"):N("已搜索网页","Web search completed"),detail:ua(s?N(`关键词:${s}`,`Query: ${s}`):"",r.length>1?r:[])}:o==="open_page"?{kind:"command",title:t==="started"?N("正在打开网页","Opening page"):N("已打开网页","Page opened"),detail:l}:{kind:"command",title:t==="started"?N("准备网页检索","Preparing web search"):N("网页检索已更新","Web search updated"),detail:s}}function sr(e={},t="completed"){const n=String(e.tool||"").trim(),o=Bs(e),s=gt(e.prompt);return n==="spawn_agent"?{kind:"todo",title:t==="started"?N("正在启动子代理","Starting sub-agent"):N(`已启动 ${o||1} 个子代理`,`Started ${o||1} sub-agent(s)`),detail:s?N(`任务:${s}`,`Task: ${s}`):""}:n==="wait"?{kind:"todo",title:t==="started"?o?N(`等待 ${o} 个子代理返回结果`,`Waiting for ${o} sub-agent result(s)`):N("等待子代理返回结果","Waiting for sub-agent results"):N("子代理结果已汇总","Sub-agent results aggregated"),detail:s?N(`等待内容:${s}`,`Waiting on: ${s}`):""}:{kind:"todo",title:t==="started"?N(`正在执行协作工具:${n||"未知工具"}`,`Running collaboration tool: ${n||"Unknown tool"}`):N(`协作工具完成:${n||"未知工具"}`,`Collaboration tool completed: ${n||"Unknown tool"}`),detail:s?N(`任务:${s}`,`Task: ${s}`):""}}function or(e={},t="completed"){const n=Array.isArray(e.changes)?e.changes:[],o={create:N("新增","Added"),update:N("更新","Updated"),delete:N("删除","Deleted")};return{kind:"command",title:t==="started"?N("正在整理文件变更","Collecting file changes"):N(`已记录 ${n.length||0} 个文件改动`,`Recorded ${n.length||0} file change(s)`),detail:ua("",n.map(s=>{const r=String((s==null?void 0:s.path)||"").trim();return`${o[String((s==null?void 0:s.kind)||"").trim()]||N("变更","Changed")} ${r||N("未命名文件","Unnamed file")}`}))}}function Wf(e,t={}){var l,c,p,w,d,m,f,b;e!=null&&e.summary||(e.summary=jn());const n=e.summary,o=Lt(e),s=String(t.type||"").trim(),r=t.item||{};if(s===vt.TURN_STARTED){n.currentActivity=N("正在分析任务","Analyzing task"),n.latestActivity=N(`${o} 开始执行`,`${o} started`),n.latestDetail="";return}if(s===vt.TURN_COMPLETED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=N(`${o} 执行完成`,`${o} completed`),n.latestDetail="";return}if(s===vt.TURN_FAILED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=N("本轮运行失败","This run failed"),n.latestDetail="";return}if(s===vt.ERROR){const v=No(ss(t));if(v){n.currentActivity=N(`网络异常,正在重试 (${v.attempt}/${v.total})`,`Network error, retrying (${v.attempt}/${v.total})`),n.latestActivity=n.currentActivity,n.latestDetail=gt(v.reason,120);return}n.currentActivity="",n.latestActivity=N(`${o} 返回错误`,`${o} returned an error`),n.latestDetail=gt(ss(t),120);return}if(s===vt.ITEM_STARTED){if(r.type===rt.REASONING){n.currentActivity=N("正在思考","Thinking"),n.latestActivity=N("正在思考","Thinking"),n.latestDetail=gt(r.text,120);return}if(r.type===rt.COMMAND_EXECUTION){if(In(r).groupType==="todo"){const P=yn(ts(r));n.currentActivity=N("正在更新待办列表","Updating todo list"),n.latestActivity=N("正在更新待办列表","Updating todo list"),n.latestDetail=gt(P,120);return}n.currentActivity=N("正在执行命令","Running command"),n.latestActivity=N("开始执行命令","Command started"),n.latestDetail=gt(r.command,120);return}if(r.type===rt.WEB_SEARCH){n.currentActivity=((l=r.action)==null?void 0:l.type)==="open_page"?N("正在打开网页","Opening page"):N("正在搜索网页","Searching the web"),n.latestActivity=n.currentActivity,n.latestDetail=gt(((c=r.action)==null?void 0:c.type)==="open_page"?((p=r.action)==null?void 0:p.url)||r.query:r.query||((w=r.action)==null?void 0:w.query),120);return}if(r.type===rt.COLLAB_TOOL_CALL){if(r.tool==="wait"){const v=Bs(r);n.waitingAgentCount=v,n.currentActivity=v?N(`等待 ${v} 个子代理返回结果`,`Waiting for ${v} sub-agent result(s)`):N("等待子代理返回结果","Waiting for sub-agent results"),n.latestActivity=n.currentActivity,n.latestDetail=gt(r.prompt,120);return}if(r.tool==="spawn_agent"){n.currentActivity=N("正在启动子代理","Starting sub-agent"),n.latestActivity=N("正在启动子代理","Starting sub-agent"),n.latestDetail=gt(r.prompt,120);return}}if(r.type===rt.FILE_CHANGE){n.currentActivity=N("正在整理文件变更","Collecting file changes"),n.latestActivity=N("正在整理文件变更","Collecting file changes"),n.latestDetail=gt((r.changes||[]).map(v=>v==null?void 0:v.path).filter(Boolean).join(ln()?", ":","),120);return}r.type===rt.TODO_LIST&&(n.currentActivity=N("正在规划执行步骤","Planning steps"),n.latestActivity=N("正在规划执行步骤","Planning steps"),n.latestDetail=gt((r.items||[]).map(v=>v==null?void 0:v.text).filter(Boolean).join(ln()?"; ":";"),120));return}if(s===vt.ITEM_COMPLETED){if(r.type===rt.COMMAND_EXECUTION){if(In(r).groupType==="todo"){n.currentActivity="",n.latestActivity=N("待办列表已更新","Todo list updated"),n.latestDetail=gt(yn(ts(r)),120);return}n.commandCount+=1,n.currentActivity="",n.latestActivity=N("命令执行完成","Command completed"),n.latestDetail=gt(r.command,120);return}if(r.type===rt.WEB_SEARCH){n.webSearchCount+=1,n.currentActivity="",n.latestActivity=((d=r.action)==null?void 0:d.type)==="open_page"?N("已打开网页","Page opened"):N("已搜索网页","Web search completed"),n.latestDetail=gt(((m=r.action)==null?void 0:m.type)==="open_page"?((f=r.action)==null?void 0:f.url)||r.query:r.query||((b=r.action)==null?void 0:b.query),120);return}if(r.type===rt.COLLAB_TOOL_CALL){if(r.tool==="spawn_agent"){const v=Bs(r);n.subAgentCount+=v,n.currentActivity="",n.latestActivity=v?N(`已启动 ${v} 个子代理`,`Started ${v} sub-agent(s)`):N("已启动子代理","Started sub-agent"),n.latestDetail=gt(r.prompt,120);return}if(r.tool==="wait"){n.waitingAgentCount=0,n.currentActivity="",n.latestActivity=N("子代理结果已汇总","Sub-agent results aggregated"),n.latestDetail=Vf(r,120)||gt(r.prompt,120);return}n.currentActivity="",n.latestActivity=N(`协作工具完成:${r.tool||"未知工具"}`,`Collaboration tool completed: ${r.tool||"Unknown tool"}`),n.latestDetail=gt(r.prompt,120);return}if(r.type===rt.FILE_CHANGE){const v=Array.isArray(r.changes)?r.changes:[];n.fileChangeCount+=v.length,n.currentActivity="",n.latestActivity=v.length?N(`已记录 ${v.length} 个文件改动`,`Recorded ${v.length} file change(s)`):N("已记录文件改动","Recorded file changes"),n.latestDetail=gt(v.map(P=>P==null?void 0:P.path).filter(Boolean).join(ln()?", ":","),120);return}if(r.type===rt.TODO_LIST){n.currentActivity="",n.latestActivity=N("待办列表已更新","Todo list updated"),n.latestDetail=gt((r.items||[]).map(v=>v==null?void 0:v.text).filter(Boolean).join(ln()?"; ":";"),120);return}r.type===rt.AGENT_MESSAGE&&(n.currentActivity="",n.latestActivity=N(`${o} 已返回结果`,`${o} returned a result`),n.latestDetail=gt(r.text,120))}}function Gf(e={},t={}){const n=Date.parse(String(e.startedAt||""));if(!Number.isFinite(n))return 0;if(ns(e.status)){if(t.currentRunningRunId&&String(t.currentRunningRunId)===String(e.runId||"")&&Number.isFinite(Number(t.runningElapsedSeconds)))return Math.max(0,Math.floor(Number(t.runningElapsedSeconds)||0));const s=Number(t.nowMs)||Date.now();return Math.max(0,Math.floor((s-n)/1e3))}const o=Date.parse(String(e.finishedAt||""));return Number.isFinite(o)&&o>=n?Math.max(0,Math.floor((o-n)/1e3)):0}function fa(e={},t={}){const n=e.summary||jn(),o=[],s=Gf(e,t);return s>0&&o.push({key:"elapsed",label:N("耗时","Elapsed"),value:la(s)}),n.webSearchCount&&o.push({key:"web",label:N("网页","Web"),value:Dt(n.webSearchCount)}),n.commandCount&&o.push({key:"command",label:N("命令","Command"),value:Dt(n.commandCount)}),n.fileChangeCount&&o.push({key:"file",label:N("改动","Changes"),value:Dt(n.fileChangeCount)}),n.subAgentCount&&o.push({key:"agent",label:N("子代理","Sub-agent"),value:Dt(n.subAgentCount)}),o}function pa(e={}){const t=e.summary||jn();return t.waitingAgentCount>0?N(`当前:等待 ${Dt(t.waitingAgentCount)} 个子代理返回结果`,`Current: waiting for ${Dt(t.waitingAgentCount)} sub-agent result(s)`):t.currentActivity?N(`当前:${t.currentActivity}`,`Current: ${t.currentActivity}`):t.latestActivity?N(`最近:${t.latestActivity}`,`Latest: ${t.latestActivity}`):ns(e.status)?N(`当前:正在等待 ${Lt(e)} 返回更多事件`,`Current: waiting for more events from ${Lt(e)}`):""}function ma(e={}){const t=e.summary||jn();return String(t.latestDetail||"").trim()}function Xf(e={}){return!!(fa(e).length||pa(e)||ma(e))}const Yf=[{type:"startup_config",title:e=>N(`${ct(e)} 启动配置冲突`,`${ct(e)} startup config conflict`),summary:e=>N(`${ct(e)} 当前启动参数可能与本机包装脚本、别名或外部环境配置冲突,请检查 CLI 启动方式。`,`${ct(e)} startup arguments may conflict with your local wrapper script, alias, or external environment configuration. Please check how the CLI is launched.`),patterns:[/not inside a trusted directory/i,/do you trust the contents of this directory/i,/trusted directory/i,/skip-git-repo-check/i,/prompt injection/i,/目录.*信任/,/可信目录/]},{type:"billing",title:N("额度或账单异常","Quota or billing issue"),summary:e=>N(`${ct(e)} 可能因为额度不足、欠费或账单限制而无法继续执行。`,`${ct(e)} may be unable to continue due to quota exhaustion, billing issues, or account limits.`),patterns:[/insufficient_quota/i,/exceeded your current quota/i,/\bquota\b/i,/\bbilling\b/i,/credit balance/i,/payment required/i,/余额不足/,/欠费/,/账单/,/充值/]},{type:"permission",title:N("权限不足","Insufficient permissions"),summary:e=>N(`${ct(e)} 当前权限不够,无法访问所需文件、命令或资源。`,`${ct(e)} does not currently have permission to access the required files, commands, or resources.`),patterns:[/permission denied/i,/insufficient permissions?/i,/forbidden/i,/unauthorized/i,/authentication_failed/i,/invalid token/i,/invalid api key/i,/\b401\b/,/access denied/i,/not allowed/i,/权限不足/,/没有权限/,/无权/,/拒绝访问/,/无效的令牌/]},{type:"rate_limit",title:N("请求过于频繁","Too many requests"),summary:e=>N(`${ct(e)} 可能触发了限流,请稍后再试。`,`${ct(e)} may have hit a rate limit. Please try again later.`),patterns:[/rate limit/i,/too many requests/i,/\b429\b/,/请求过于频繁/,/限流/]},{type:"context_limit",title:N("上下文过长","Context too long"),summary:N("这次发送的内容可能过长,超过了模型可处理的上下文限制。","The content sent in this run may be too long and exceed the model context limit."),patterns:[/context length/i,/maximum context length/i,/context_length_exceeded/i,/token limit/i,/prompt is too long/i,/上下文过长/,/超过.*token/i,/超出.*上下文/]},{type:"model_unavailable",title:N("模型或服务暂不可用","Model or service unavailable"),summary:e=>N(`${ct(e)} 背后的模型或服务当前不可用,请稍后重试。`,`The model or service behind ${ct(e)} is currently unavailable. Please try again later.`),patterns:[/model .*not found/i,/model .*unavailable/i,/service unavailable/i,/server error/i,/overloaded/i,/\b503\b/,/模型不可用/,/服务不可用/]},{type:"network",title:N("网络连接异常","Network connection issue"),summary:e=>N(`${ct(e)} 在请求过程中遇到了网络问题或连接超时。`,`${ct(e)} encountered a network problem or timeout while making the request.`),patterns:[/timed out/i,/\btimeout\b/i,/stream disconnected/i,/error sending request/i,/connection reset/i,/connection closed/i,/socket hang up/i,/network error/i,/fetch failed/i,/econnreset/i,/econnrefused/i,/enotfound/i,/network is unreachable/i,/temporary failure in name resolution/i,/网络异常/,/连接超时/]},{type:"cli_missing",title:e=>N(`${ct(e)} CLI 不可用`,`${ct(e)} CLI unavailable`),summary:e=>N(`当前环境没有正确安装或配置 ${ct(e)} CLI。`,`${ct(e)} CLI is not correctly installed or configured in the current environment.`),patterns:[/找不到 Codex CLI/,/找不到 Claude Code CLI/,/找不到 OpenCode CLI/,/codex --version/i,/claude --version/i,/opencode --version/i,/enoent/i,/not recognized as an internal or external command/i,/command not found/i]}];function Nn(e="",t="codex"){const n=On(e).trim();if(!n)return null;const o=Yf.find(s=>s.patterns.some(r=>r.test(n)));return o?{type:o.type,title:typeof o.title=="function"?o.title(t):o.title,summary:typeof o.summary=="function"?o.summary(t):o.summary,rawMessage:n}:null}function tn(e="",t="codex"){const n=On(e).trim();if(!n)return"";const o=Nn(n,t);return o?`${o.summary}
34
+ ${o}`:o}function es(e=[]){const t=e.map(n=>({label:String((n==null?void 0:n.label)||"").trim(),value:String((n==null?void 0:n.value)||"").trim()})).filter(n=>n.label&&n.value);return t.length?{type:"meta",items:t}:null}function zf(e=""){const t=String(e||"").trim().toLowerCase();return["done","completed","complete","checked"].includes(t)?"completed":["in_progress","in-progress","active","doing","running"].includes(t)?"in_progress":"pending"}function Hf(e={}){return[e==null?void 0:e.text,e==null?void 0:e.content,e==null?void 0:e.title,e==null?void 0:e.label,e==null?void 0:e.activeForm].map(n=>String(n||"").trim()).find(Boolean)||N("未命名任务","Untitled Task")}function Cs(e=[]){return(Array.isArray(e)?e:[]).map(t=>{if(!t||typeof t!="object")return null;const n=zf(t.status??(t.completed?"completed":"pending"));return{completed:n==="completed",status:n,text:Hf(t)}}).filter(Boolean)}function Qo(e){const t=String(e||"").trim();if(!t)return[];try{const n=JSON.parse(t);if(Array.isArray(n))return Cs(n);if(n&&typeof n=="object"){if(Array.isArray(n.todos))return Cs(n.todos);if(Array.isArray(n.items))return Cs(n.items)}}catch{return[]}return[]}function ca(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];return t.length?{type:"checklist",items:t,totalCount:t.length,hiddenCount:0}:null}function Ro(e=""){var S;const t=String(e||"").trim(),n=t.indexOf(":"),o=n>0&&n<=24,s=o?t.slice(0,n).trim():"",r=o?t.slice(n+1).trim():t,l=s.toLowerCase(),p=o?((S=Object.entries({shell:["bash","shell","sh","terminal","cmd","powershell"],read:["read","open","view","cat"],grep:["grep","rg","search","find"],list:["glob","ls","dir","tree","list"],web:["websearch","web_search","webfetch","fetch","browse","open_page"],todo:["todowrite","todo","tasklist","tasks"],edit:["edit","multiedit","write","patch","apply_patch","replace","create"]}).find(([,d])=>d.includes(l)))==null?void 0:S[0])||"generic":"shell";return{raw:t,toolName:s,normalizedTool:l,subject:r,category:p}}function ts(e={},t=null){const n=t||Ro(e.command);if(n.category!=="todo")return[];const o=Qo(e.aggregated_output);return o.length?o:Qo(n.subject)}function bn(e="",t={}){return Bo(On(e),t)}function Zo(e={}){const t=e.action||{},n=String(e.query||t.query||"").trim(),o=Array.isArray(t.queries)?t.queries.map(c=>String(c||"").trim()).filter(Boolean):[],s=String(t.url||"").trim(),r=[],l=es([n?{label:N("关键词","Query"),value:n}:null,s?{label:"URL",value:s}:null]);return l&&r.push(l),o.length>1&&r.push({type:"bullet_list",items:o,totalCount:o.length,hiddenCount:0}),r}function er(e={}){const t=String(e.tool||"").trim(),n=Bs(e),o=String(e.prompt||"").trim(),s=ia(e),r=[],l=[t?{label:N("工具","Tool"),value:t}:null,n?{label:N("子代理","Sub-agent"),value:String(n)}:null],c=es(l);return c&&r.push(c),s.length&&r.push({type:"sub_agent_list",items:s,totalCount:s.length,hiddenCount:0}),o&&r.push(...bn(o,{preferMarkdown:!0})),r}function tr(e={}){const t=Array.isArray(e.changes)?e.changes:[];return t.length?[{type:"file_changes",items:t.map(n=>({kind:String((n==null?void 0:n.kind)||"").trim(),path:String((n==null?void 0:n.path)||"").trim()})),totalCount:t.length,hiddenCount:0}]:[]}function gs(e={},t=!1,n="codex"){const o=[],s=Ro(e.command),r=ts(e,s),l=ca(r),c=typeof e.exit_code=="number",p=c?e.exit_code===0:e.status==="completed",S=es([s.toolName?{label:N("工具","Tool"),value:s.toolName}:null,l||s.category!=="shell"?null:s.subject?{label:N("命令","Command"),value:s.subject}:e.command?{label:N("命令","Command"),value:e.command}:null,n&&n!=="codex"?{label:N("引擎","Engine"),value:Ff(n)}:null,c&&!p?{label:N("退出码","Exit code"),value:String(e.exit_code)}:null]);if(S&&o.push(S),l&&o.push(l),t){if(l)return o;const d=ra(e.aggregated_output);d&&o.push(...bn(d,{preferMarkdown:s.category==="web"||s.category==="edit"}))}return o}function In(e={}){const t=Ro(e.command);return{groupType:["read","grep","list","web","todo"].includes(t.category)?t.category:"",groupTarget:t.subject||e.command||"",toolName:t.toolName||""}}function oo(e={}){const t=Array.isArray(e.items)?Cs(e.items):[];return t.length?[ca(t)]:[]}function jn(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function vo(e=[],t=""){const n=String(t||"").trim();return n&&(Array.isArray(e)?e:[]).find(o=>(o==null?void 0:o.runId)===n)||null}function qf(e,t,n,o,s){const r=vo(e,t);return r?(r.events=[],r.lastEventSeq=0,r.summary=jn(),((n==null?void 0:n.items)||[]).forEach(l=>{Oo(r,l,o,s)}),r.eventCount=Math.max(Math.max(0,Number(r.eventCount)||0),Array.isArray(n==null?void 0:n.items)?n.items.length:0,Math.max(0,Number(r.lastEventSeq)||0)),r.eventsLoaded=!0,r.eventsLoading=!1,r):null}function da(e={}){const t=String((e==null?void 0:e.displayEngine)||"").trim();return t?Ls(t):Mo(e==null?void 0:e.engine)?"codex":Ls(e==null?void 0:e.engine)}function Lt(e={}){return ct(da(e))}function Kf(e={}){return Mo(e==null?void 0:e.engine)}function ns(e=""){return jf.has(String(e||"").trim())}function No(e=""){const t=String(e||"").trim();if(!t)return null;const n=t.match(/^Reconnecting\.\.\.\s*(\d+)\/(\d+)\s*\(([\s\S]+)\)$/i);return n?{attempt:Number(n[1]||0),total:Number(n[2]||0),reason:String(n[3]||"").trim(),rawMessage:t}:null}function nr(e={},t="completed"){const n=e.action||{},o=String(n.type||"").trim(),s=String(e.query||n.query||"").trim(),r=Array.isArray(n.queries)?n.queries.map(c=>String(c||"").trim()).filter(Boolean):[],l=String(n.url||s||"").trim();return o==="search"?{kind:"command",title:t==="started"?N("正在搜索网页","Searching the web"):N("已搜索网页","Web search completed"),detail:ua(s?N(`关键词:${s}`,`Query: ${s}`):"",r.length>1?r:[])}:o==="open_page"?{kind:"command",title:t==="started"?N("正在打开网页","Opening page"):N("已打开网页","Page opened"),detail:l}:{kind:"command",title:t==="started"?N("准备网页检索","Preparing web search"):N("网页检索已更新","Web search updated"),detail:s}}function sr(e={},t="completed"){const n=String(e.tool||"").trim(),o=Bs(e),s=gt(e.prompt);return n==="spawn_agent"?{kind:"todo",title:t==="started"?N("正在启动子代理","Starting sub-agent"):N(`已启动 ${o||1} 个子代理`,`Started ${o||1} sub-agent(s)`),detail:s?N(`任务:${s}`,`Task: ${s}`):""}:n==="wait"?{kind:"todo",title:t==="started"?o?N(`等待 ${o} 个子代理返回结果`,`Waiting for ${o} sub-agent result(s)`):N("等待子代理返回结果","Waiting for sub-agent results"):N("子代理结果已汇总","Sub-agent results aggregated"),detail:s?N(`等待内容:${s}`,`Waiting on: ${s}`):""}:{kind:"todo",title:t==="started"?N(`正在执行协作工具:${n||"未知工具"}`,`Running collaboration tool: ${n||"Unknown tool"}`):N(`协作工具完成:${n||"未知工具"}`,`Collaboration tool completed: ${n||"Unknown tool"}`),detail:s?N(`任务:${s}`,`Task: ${s}`):""}}function or(e={},t="completed"){const n=Array.isArray(e.changes)?e.changes:[],o={create:N("新增","Added"),update:N("更新","Updated"),delete:N("删除","Deleted")};return{kind:"command",title:t==="started"?N("正在整理文件变更","Collecting file changes"):N(`已记录 ${n.length||0} 个文件改动`,`Recorded ${n.length||0} file change(s)`),detail:ua("",n.map(s=>{const r=String((s==null?void 0:s.path)||"").trim();return`${o[String((s==null?void 0:s.kind)||"").trim()]||N("变更","Changed")} ${r||N("未命名文件","Unnamed file")}`}))}}function Wf(e,t={}){var l,c,p,S,d,m,f,b;e!=null&&e.summary||(e.summary=jn());const n=e.summary,o=Lt(e),s=String(t.type||"").trim(),r=t.item||{};if(s===vt.TURN_STARTED){n.currentActivity=N("正在分析任务","Analyzing task"),n.latestActivity=N(`${o} 开始执行`,`${o} started`),n.latestDetail="";return}if(s===vt.TURN_COMPLETED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=N(`${o} 执行完成`,`${o} completed`),n.latestDetail="";return}if(s===vt.TURN_FAILED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=N("本轮运行失败","This run failed"),n.latestDetail="";return}if(s===vt.ERROR){const v=No(ss(t));if(v){n.currentActivity=N(`网络异常,正在重试 (${v.attempt}/${v.total})`,`Network error, retrying (${v.attempt}/${v.total})`),n.latestActivity=n.currentActivity,n.latestDetail=gt(v.reason,120);return}n.currentActivity="",n.latestActivity=N(`${o} 返回错误`,`${o} returned an error`),n.latestDetail=gt(ss(t),120);return}if(s===vt.ITEM_STARTED){if(r.type===rt.REASONING){n.currentActivity=N("正在思考","Thinking"),n.latestActivity=N("正在思考","Thinking"),n.latestDetail=gt(r.text,120);return}if(r.type===rt.COMMAND_EXECUTION){if(In(r).groupType==="todo"){const P=yn(ts(r));n.currentActivity=N("正在更新待办列表","Updating todo list"),n.latestActivity=N("正在更新待办列表","Updating todo list"),n.latestDetail=gt(P,120);return}n.currentActivity=N("正在执行命令","Running command"),n.latestActivity=N("开始执行命令","Command started"),n.latestDetail=gt(r.command,120);return}if(r.type===rt.WEB_SEARCH){n.currentActivity=((l=r.action)==null?void 0:l.type)==="open_page"?N("正在打开网页","Opening page"):N("正在搜索网页","Searching the web"),n.latestActivity=n.currentActivity,n.latestDetail=gt(((c=r.action)==null?void 0:c.type)==="open_page"?((p=r.action)==null?void 0:p.url)||r.query:r.query||((S=r.action)==null?void 0:S.query),120);return}if(r.type===rt.COLLAB_TOOL_CALL){if(r.tool==="wait"){const v=Bs(r);n.waitingAgentCount=v,n.currentActivity=v?N(`等待 ${v} 个子代理返回结果`,`Waiting for ${v} sub-agent result(s)`):N("等待子代理返回结果","Waiting for sub-agent results"),n.latestActivity=n.currentActivity,n.latestDetail=gt(r.prompt,120);return}if(r.tool==="spawn_agent"){n.currentActivity=N("正在启动子代理","Starting sub-agent"),n.latestActivity=N("正在启动子代理","Starting sub-agent"),n.latestDetail=gt(r.prompt,120);return}}if(r.type===rt.FILE_CHANGE){n.currentActivity=N("正在整理文件变更","Collecting file changes"),n.latestActivity=N("正在整理文件变更","Collecting file changes"),n.latestDetail=gt((r.changes||[]).map(v=>v==null?void 0:v.path).filter(Boolean).join(ln()?", ":","),120);return}r.type===rt.TODO_LIST&&(n.currentActivity=N("正在规划执行步骤","Planning steps"),n.latestActivity=N("正在规划执行步骤","Planning steps"),n.latestDetail=gt((r.items||[]).map(v=>v==null?void 0:v.text).filter(Boolean).join(ln()?"; ":";"),120));return}if(s===vt.ITEM_COMPLETED){if(r.type===rt.COMMAND_EXECUTION){if(In(r).groupType==="todo"){n.currentActivity="",n.latestActivity=N("待办列表已更新","Todo list updated"),n.latestDetail=gt(yn(ts(r)),120);return}n.commandCount+=1,n.currentActivity="",n.latestActivity=N("命令执行完成","Command completed"),n.latestDetail=gt(r.command,120);return}if(r.type===rt.WEB_SEARCH){n.webSearchCount+=1,n.currentActivity="",n.latestActivity=((d=r.action)==null?void 0:d.type)==="open_page"?N("已打开网页","Page opened"):N("已搜索网页","Web search completed"),n.latestDetail=gt(((m=r.action)==null?void 0:m.type)==="open_page"?((f=r.action)==null?void 0:f.url)||r.query:r.query||((b=r.action)==null?void 0:b.query),120);return}if(r.type===rt.COLLAB_TOOL_CALL){if(r.tool==="spawn_agent"){const v=Bs(r);n.subAgentCount+=v,n.currentActivity="",n.latestActivity=v?N(`已启动 ${v} 个子代理`,`Started ${v} sub-agent(s)`):N("已启动子代理","Started sub-agent"),n.latestDetail=gt(r.prompt,120);return}if(r.tool==="wait"){n.waitingAgentCount=0,n.currentActivity="",n.latestActivity=N("子代理结果已汇总","Sub-agent results aggregated"),n.latestDetail=Vf(r,120)||gt(r.prompt,120);return}n.currentActivity="",n.latestActivity=N(`协作工具完成:${r.tool||"未知工具"}`,`Collaboration tool completed: ${r.tool||"Unknown tool"}`),n.latestDetail=gt(r.prompt,120);return}if(r.type===rt.FILE_CHANGE){const v=Array.isArray(r.changes)?r.changes:[];n.fileChangeCount+=v.length,n.currentActivity="",n.latestActivity=v.length?N(`已记录 ${v.length} 个文件改动`,`Recorded ${v.length} file change(s)`):N("已记录文件改动","Recorded file changes"),n.latestDetail=gt(v.map(P=>P==null?void 0:P.path).filter(Boolean).join(ln()?", ":","),120);return}if(r.type===rt.TODO_LIST){n.currentActivity="",n.latestActivity=N("待办列表已更新","Todo list updated"),n.latestDetail=gt((r.items||[]).map(v=>v==null?void 0:v.text).filter(Boolean).join(ln()?"; ":";"),120);return}r.type===rt.AGENT_MESSAGE&&(n.currentActivity="",n.latestActivity=N(`${o} 已返回结果`,`${o} returned a result`),n.latestDetail=gt(r.text,120))}}function Gf(e={},t={}){const n=Date.parse(String(e.startedAt||""));if(!Number.isFinite(n))return 0;if(ns(e.status)){if(t.currentRunningRunId&&String(t.currentRunningRunId)===String(e.runId||"")&&Number.isFinite(Number(t.runningElapsedSeconds)))return Math.max(0,Math.floor(Number(t.runningElapsedSeconds)||0));const s=Number(t.nowMs)||Date.now();return Math.max(0,Math.floor((s-n)/1e3))}const o=Date.parse(String(e.finishedAt||""));return Number.isFinite(o)&&o>=n?Math.max(0,Math.floor((o-n)/1e3)):0}function fa(e={},t={}){const n=e.summary||jn(),o=[],s=Gf(e,t);return s>0&&o.push({key:"elapsed",label:N("耗时","Elapsed"),value:la(s)}),n.webSearchCount&&o.push({key:"web",label:N("网页","Web"),value:Dt(n.webSearchCount)}),n.commandCount&&o.push({key:"command",label:N("命令","Command"),value:Dt(n.commandCount)}),n.fileChangeCount&&o.push({key:"file",label:N("改动","Changes"),value:Dt(n.fileChangeCount)}),n.subAgentCount&&o.push({key:"agent",label:N("子代理","Sub-agent"),value:Dt(n.subAgentCount)}),o}function pa(e={}){const t=e.summary||jn();return t.waitingAgentCount>0?N(`当前:等待 ${Dt(t.waitingAgentCount)} 个子代理返回结果`,`Current: waiting for ${Dt(t.waitingAgentCount)} sub-agent result(s)`):t.currentActivity?N(`当前:${t.currentActivity}`,`Current: ${t.currentActivity}`):t.latestActivity?N(`最近:${t.latestActivity}`,`Latest: ${t.latestActivity}`):ns(e.status)?N(`当前:正在等待 ${Lt(e)} 返回更多事件`,`Current: waiting for more events from ${Lt(e)}`):""}function ma(e={}){const t=e.summary||jn();return String(t.latestDetail||"").trim()}function Xf(e={}){return!!(fa(e).length||pa(e)||ma(e))}const Yf=[{type:"startup_config",title:e=>N(`${ct(e)} 启动配置冲突`,`${ct(e)} startup config conflict`),summary:e=>N(`${ct(e)} 当前启动参数可能与本机包装脚本、别名或外部环境配置冲突,请检查 CLI 启动方式。`,`${ct(e)} startup arguments may conflict with your local wrapper script, alias, or external environment configuration. Please check how the CLI is launched.`),patterns:[/not inside a trusted directory/i,/do you trust the contents of this directory/i,/trusted directory/i,/skip-git-repo-check/i,/prompt injection/i,/目录.*信任/,/可信目录/]},{type:"billing",title:N("额度或账单异常","Quota or billing issue"),summary:e=>N(`${ct(e)} 可能因为额度不足、欠费或账单限制而无法继续执行。`,`${ct(e)} may be unable to continue due to quota exhaustion, billing issues, or account limits.`),patterns:[/insufficient_quota/i,/exceeded your current quota/i,/\bquota\b/i,/\bbilling\b/i,/credit balance/i,/payment required/i,/余额不足/,/欠费/,/账单/,/充值/]},{type:"permission",title:N("权限不足","Insufficient permissions"),summary:e=>N(`${ct(e)} 当前权限不够,无法访问所需文件、命令或资源。`,`${ct(e)} does not currently have permission to access the required files, commands, or resources.`),patterns:[/permission denied/i,/insufficient permissions?/i,/forbidden/i,/unauthorized/i,/authentication_failed/i,/invalid token/i,/invalid api key/i,/\b401\b/,/access denied/i,/not allowed/i,/权限不足/,/没有权限/,/无权/,/拒绝访问/,/无效的令牌/]},{type:"rate_limit",title:N("请求过于频繁","Too many requests"),summary:e=>N(`${ct(e)} 可能触发了限流,请稍后再试。`,`${ct(e)} may have hit a rate limit. Please try again later.`),patterns:[/rate limit/i,/too many requests/i,/\b429\b/,/请求过于频繁/,/限流/]},{type:"context_limit",title:N("上下文过长","Context too long"),summary:N("这次发送的内容可能过长,超过了模型可处理的上下文限制。","The content sent in this run may be too long and exceed the model context limit."),patterns:[/context length/i,/maximum context length/i,/context_length_exceeded/i,/token limit/i,/prompt is too long/i,/上下文过长/,/超过.*token/i,/超出.*上下文/]},{type:"model_unavailable",title:N("模型或服务暂不可用","Model or service unavailable"),summary:e=>N(`${ct(e)} 背后的模型或服务当前不可用,请稍后重试。`,`The model or service behind ${ct(e)} is currently unavailable. Please try again later.`),patterns:[/model .*not found/i,/model .*unavailable/i,/service unavailable/i,/server error/i,/overloaded/i,/\b503\b/,/模型不可用/,/服务不可用/]},{type:"network",title:N("网络连接异常","Network connection issue"),summary:e=>N(`${ct(e)} 在请求过程中遇到了网络问题或连接超时。`,`${ct(e)} encountered a network problem or timeout while making the request.`),patterns:[/timed out/i,/\btimeout\b/i,/stream disconnected/i,/error sending request/i,/connection reset/i,/connection closed/i,/socket hang up/i,/network error/i,/fetch failed/i,/econnreset/i,/econnrefused/i,/enotfound/i,/network is unreachable/i,/temporary failure in name resolution/i,/网络异常/,/连接超时/]},{type:"cli_missing",title:e=>N(`${ct(e)} CLI 不可用`,`${ct(e)} CLI unavailable`),summary:e=>N(`当前环境没有正确安装或配置 ${ct(e)} CLI。`,`${ct(e)} CLI is not correctly installed or configured in the current environment.`),patterns:[/找不到 Codex CLI/,/找不到 Claude Code CLI/,/找不到 OpenCode CLI/,/codex --version/i,/claude --version/i,/opencode --version/i,/enoent/i,/not recognized as an internal or external command/i,/command not found/i]}];function Nn(e="",t="codex"){const n=On(e).trim();if(!n)return null;const o=Yf.find(s=>s.patterns.some(r=>r.test(n)));return o?{type:o.type,title:typeof o.title=="function"?o.title(t):o.title,summary:typeof o.summary=="function"?o.summary(t):o.summary,rawMessage:n}:null}function tn(e="",t="codex"){const n=On(e).trim();if(!n)return"";const o=Nn(n,t);return o?`${o.summary}
35
35
 
36
- ${N("原始错误","Raw error")}: ${o.rawMessage}`:n}function yo(e,t=0){if(!e||t>4)return"";if(typeof e=="string")return On(e).trim();if(typeof e!="object")return"";const n=["message","detail","error","last_error","cause","reason","stderr","text","summary"];for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const s=yo(e[o],t+1);if(s)return s}for(const o of Object.values(e)){const s=yo(o,t+1);if(s)return s}return""}function ss(e={}){return yo(e)}function Jf(e={},t="Codex",n="codex"){var r,l,c,p;const o=String(e.type||"").trim(),s=e.item||{};if(!o)return{title:N(`收到 ${t} 事件`,`Received ${t} event`),detail:""};if(o===vt.THREAD_STARTED){const w=e.thread_id?N(`线程 ID: ${e.thread_id}`,`Thread ID: ${e.thread_id}`):"";return{title:N(`${t} 会话已创建`,`${t} session created`),detail:w,detailBlocks:w?[es([{label:"ID",value:e.thread_id}])]:[]}}if(o===vt.TURN_STARTED)return{title:N(`${t} 开始执行`,`${t} started`),detail:""};if(o===vt.TURN_COMPLETED){const w=e.usage?[N(`输入 ${Dt(e.usage.input_tokens)}`,`Input ${Dt(e.usage.input_tokens)}`),e.usage.cached_input_tokens?N(`缓存 ${Dt(e.usage.cached_input_tokens)}`,`Cached ${Dt(e.usage.cached_input_tokens)}`):"",N(`输出 ${Dt(e.usage.output_tokens)}`,`Output ${Dt(e.usage.output_tokens)}`)].filter(Boolean).join(" / "):"";return{title:N(`${t} 执行完成`,`${t} completed`),detail:w,detailBlocks:e.usage?[es([{label:N("输入","Input"),value:Dt(e.usage.input_tokens)},e.usage.cached_input_tokens?{label:N("缓存","Cached"),value:Dt(e.usage.cached_input_tokens)}:null,{label:N("输出","Output"),value:Dt(e.usage.output_tokens)}])]:[]}}if(o==="claude.system"&&!String(e.detail||"").trim())return{title:"",detail:""};if(o===vt.ERROR||o===vt.TURN_FAILED){const w=ss(e)||N(`${t} 执行失败`,`${t} failed`),d=o===vt.ERROR?No(w):null;if(d)return{kind:"info",title:N(`网络异常,正在重试 (${d.attempt}/${d.total})`,`Network error, retrying (${d.attempt}/${d.total})`),detail:tn(d.reason||d.rawMessage,n),detailBlocks:bn(tn(d.reason||d.rawMessage,n),{preferMarkdown:!0})};const m=Nn(w,n);return{kind:"error",title:(m==null?void 0:m.title)||(o===vt.TURN_FAILED?N("本轮运行失败","This run failed"):N(`${t} 返回错误`,`${t} returned an error`)),detail:tn(w,n),detailBlocks:bn(tn(w,n),{preferMarkdown:!0})}}if(o===vt.ITEM_STARTED)return s.type===rt.REASONING?{kind:"reasoning",title:N("思考过程","Thinking"),detail:s.text||"",detailBlocks:bn(s.text||"",{preferMarkdown:!0}),groupType:"reasoning",phase:"updated"}:s.type===rt.WEB_SEARCH?{...nr(s,"started"),detailBlocks:Zo(s),groupType:"web",groupTarget:String(s.query||((r=s.action)==null?void 0:r.query)||((l=s.action)==null?void 0:l.url)||"").trim(),phase:"started"}:s.type===rt.COLLAB_TOOL_CALL?{...sr(s,"started"),detailBlocks:er(s)}:s.type===rt.FILE_CHANGE?{...or(s,"started"),detailBlocks:tr(s)}:s.type===rt.COMMAND_EXECUTION?In(s).groupType==="todo"?{kind:"todo",title:N("更新待办列表","Update todo list"),detail:yn(ts(s)),detailBlocks:gs(s,!1,n),groupType:"todo",phase:"started"}:{kind:"command",title:N("开始执行命令","Command started"),detail:s.command||"",detailBlocks:gs(s,!1,n),...In(s),phase:"started"}:s.type===rt.TODO_LIST?{kind:"todo",title:N("更新待办列表","Update todo list"),detail:yn(s.items),detailBlocks:oo(s),groupType:"todo",phase:"started"}:{title:N(`开始处理 ${s.type||"未知项目"}`,`Started handling ${s.type||"unknown item"}`),detail:""};if(o===vt.ITEM_UPDATED&&s.type===rt.TODO_LIST)return{kind:"todo",title:N("更新待办列表","Update todo list"),detail:yn(s.items),detailBlocks:oo(s),groupType:"todo",phase:"updated"};if(o===vt.ITEM_COMPLETED){if(s.type===rt.AGENT_MESSAGE&&s.text)return{kind:"result",title:N(`${t} 已返回结果`,`${t} returned a result`),detail:""};if(s.type===rt.WEB_SEARCH)return{...nr(s,"completed"),detailBlocks:Zo(s),groupType:"web",groupTarget:String(s.query||((c=s.action)==null?void 0:c.query)||((p=s.action)==null?void 0:p.url)||"").trim(),phase:"completed"};if(s.type===rt.COLLAB_TOOL_CALL)return{...sr(s,"completed"),detailBlocks:er(s)};if(s.type===rt.FILE_CHANGE)return{...or(s,"completed"),detailBlocks:tr(s)};if(s.type===rt.COMMAND_EXECUTION){if(In(s).groupType==="todo"){const m=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:m?"todo":"error",title:m?N("更新待办列表","Update todo list"):N("更新待办列表失败","Todo list update failed"),detail:yn(ts(s)),detailBlocks:gs(s,!0,n),groupType:"todo",phase:"completed"}}const d=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:d?"command":"error",title:d?N("命令执行完成","Command completed"):N(`命令执行失败(exit ${s.exit_code??"?"})`,`Command failed (exit ${s.exit_code??"?"})`),detail:[s.command,ra(s.aggregated_output)].filter(Boolean).join(`
36
+ ${N("原始错误","Raw error")}: ${o.rawMessage}`:n}function yo(e,t=0){if(!e||t>4)return"";if(typeof e=="string")return On(e).trim();if(typeof e!="object")return"";const n=["message","detail","error","last_error","cause","reason","stderr","text","summary"];for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const s=yo(e[o],t+1);if(s)return s}for(const o of Object.values(e)){const s=yo(o,t+1);if(s)return s}return""}function ss(e={}){return yo(e)}function Jf(e={},t="Codex",n="codex"){var r,l,c,p;const o=String(e.type||"").trim(),s=e.item||{};if(!o)return{title:N(`收到 ${t} 事件`,`Received ${t} event`),detail:""};if(o===vt.THREAD_STARTED){const S=e.thread_id?N(`线程 ID: ${e.thread_id}`,`Thread ID: ${e.thread_id}`):"";return{title:N(`${t} 会话已创建`,`${t} session created`),detail:S,detailBlocks:S?[es([{label:"ID",value:e.thread_id}])]:[]}}if(o===vt.TURN_STARTED)return{title:N(`${t} 开始执行`,`${t} started`),detail:""};if(o===vt.TURN_COMPLETED){const S=e.usage?[N(`输入 ${Dt(e.usage.input_tokens)}`,`Input ${Dt(e.usage.input_tokens)}`),e.usage.cached_input_tokens?N(`缓存 ${Dt(e.usage.cached_input_tokens)}`,`Cached ${Dt(e.usage.cached_input_tokens)}`):"",N(`输出 ${Dt(e.usage.output_tokens)}`,`Output ${Dt(e.usage.output_tokens)}`)].filter(Boolean).join(" / "):"";return{title:N(`${t} 执行完成`,`${t} completed`),detail:S,detailBlocks:e.usage?[es([{label:N("输入","Input"),value:Dt(e.usage.input_tokens)},e.usage.cached_input_tokens?{label:N("缓存","Cached"),value:Dt(e.usage.cached_input_tokens)}:null,{label:N("输出","Output"),value:Dt(e.usage.output_tokens)}])]:[]}}if(o==="claude.system"&&!String(e.detail||"").trim())return{title:"",detail:""};if(o===vt.ERROR||o===vt.TURN_FAILED){const S=ss(e)||N(`${t} 执行失败`,`${t} failed`),d=o===vt.ERROR?No(S):null;if(d)return{kind:"info",title:N(`网络异常,正在重试 (${d.attempt}/${d.total})`,`Network error, retrying (${d.attempt}/${d.total})`),detail:tn(d.reason||d.rawMessage,n),detailBlocks:bn(tn(d.reason||d.rawMessage,n),{preferMarkdown:!0})};const m=Nn(S,n);return{kind:"error",title:(m==null?void 0:m.title)||(o===vt.TURN_FAILED?N("本轮运行失败","This run failed"):N(`${t} 返回错误`,`${t} returned an error`)),detail:tn(S,n),detailBlocks:bn(tn(S,n),{preferMarkdown:!0})}}if(o===vt.ITEM_STARTED)return s.type===rt.REASONING?{kind:"reasoning",title:N("思考过程","Thinking"),detail:s.text||"",detailBlocks:bn(s.text||"",{preferMarkdown:!0}),groupType:"reasoning",phase:"updated"}:s.type===rt.WEB_SEARCH?{...nr(s,"started"),detailBlocks:Zo(s),groupType:"web",groupTarget:String(s.query||((r=s.action)==null?void 0:r.query)||((l=s.action)==null?void 0:l.url)||"").trim(),phase:"started"}:s.type===rt.COLLAB_TOOL_CALL?{...sr(s,"started"),detailBlocks:er(s)}:s.type===rt.FILE_CHANGE?{...or(s,"started"),detailBlocks:tr(s)}:s.type===rt.COMMAND_EXECUTION?In(s).groupType==="todo"?{kind:"todo",title:N("更新待办列表","Update todo list"),detail:yn(ts(s)),detailBlocks:gs(s,!1,n),groupType:"todo",phase:"started"}:{kind:"command",title:N("开始执行命令","Command started"),detail:s.command||"",detailBlocks:gs(s,!1,n),...In(s),phase:"started"}:s.type===rt.TODO_LIST?{kind:"todo",title:N("更新待办列表","Update todo list"),detail:yn(s.items),detailBlocks:oo(s),groupType:"todo",phase:"started"}:{title:N(`开始处理 ${s.type||"未知项目"}`,`Started handling ${s.type||"unknown item"}`),detail:""};if(o===vt.ITEM_UPDATED&&s.type===rt.TODO_LIST)return{kind:"todo",title:N("更新待办列表","Update todo list"),detail:yn(s.items),detailBlocks:oo(s),groupType:"todo",phase:"updated"};if(o===vt.ITEM_COMPLETED){if(s.type===rt.AGENT_MESSAGE&&s.text)return{kind:"result",title:N(`${t} 已返回结果`,`${t} returned a result`),detail:""};if(s.type===rt.WEB_SEARCH)return{...nr(s,"completed"),detailBlocks:Zo(s),groupType:"web",groupTarget:String(s.query||((c=s.action)==null?void 0:c.query)||((p=s.action)==null?void 0:p.url)||"").trim(),phase:"completed"};if(s.type===rt.COLLAB_TOOL_CALL)return{...sr(s,"completed"),detailBlocks:er(s)};if(s.type===rt.FILE_CHANGE)return{...or(s,"completed"),detailBlocks:tr(s)};if(s.type===rt.COMMAND_EXECUTION){if(In(s).groupType==="todo"){const m=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:m?"todo":"error",title:m?N("更新待办列表","Update todo list"):N("更新待办列表失败","Todo list update failed"),detail:yn(ts(s)),detailBlocks:gs(s,!0,n),groupType:"todo",phase:"completed"}}const d=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:d?"command":"error",title:d?N("命令执行完成","Command completed"):N(`命令执行失败(exit ${s.exit_code??"?"})`,`Command failed (exit ${s.exit_code??"?"})`),detail:[s.command,ra(s.aggregated_output)].filter(Boolean).join(`
37
37
 
38
- `),detailBlocks:gs(s,!0,n),...In(s),phase:"completed"}}return s.type===rt.TODO_LIST?{kind:"todo",title:N("更新待办列表","Update todo list"),detail:yn(s.items),detailBlocks:oo(s),groupType:"todo",phase:"completed"}:{title:N(`完成 ${s.type||"未知项目"}`,`Completed ${s.type||"unknown item"}`),detail:""}}return{title:N(`事件: ${o}`,`Event: ${o}`),detail:""}}function Qf(e){return e.status==="queued"?N("排队中","Queued"):e.status==="starting"?N("启动中","Starting"):e.status==="stopping"?N("停止中","Stopping"):e.status==="running"?N("进行中","Running"):e.status==="error"?N("失败","Failed"):e.status==="interrupted"?N("已中断","Interrupted"):e.status==="stopped"?N("已停止","Stopped"):e.status==="stop_timeout"?N("停止超时","Stop timeout"):N("已完成","Completed")}function ga(e={},t){if(typeof e=="string"){const r=e.trim();return r?{id:t(),kind:"info",title:r,detail:""}:null}const n=String(e.title||"").trim(),o=String(e.detail||"").trim(),s=Array.isArray(e.detailBlocks)&&e.detailBlocks.length?e.detailBlocks.filter(Boolean):o?bn(o,{preferMarkdown:e.kind==="error"}):[];return!n&&!o?null:{id:t(),kind:e.kind||"info",title:n||o,detail:n?o:"",detailBlocks:s,groupType:String(e.groupType||"").trim(),groupTarget:String(e.groupTarget||"").trim(),toolName:String(e.toolName||"").trim(),phase:String(e.phase||"").trim()}}function Zf(e={},t){const n=Array.isArray(e.promptBlocks)?e.promptBlocks.map(o=>({...o,meta:o!=null&&o.meta?{...o.meta}:{},content:(o==null?void 0:o.type)==="image"?xs(o.content):o.content})):[];return{id:t(),runId:String(e.id||"").trim(),engine:String(e.engine||"").trim(),displayEngine:String(e.displayEngine||"").trim(),prompt:String(e.prompt||"").trim(),promptBlocks:n,status:"completed",startedAt:e.startedAt||e.createdAt||"",finishedAt:e.finishedAt||"",events:[],eventCount:Math.max(0,Number(e.eventCount)||(Array.isArray(e.events)?e.events.length:0)),eventsLoaded:!!e.eventsIncluded,eventsLoading:!1,responseMessage:"",errorMessage:"",lastEventSeq:0,summary:jn()}}function vn(e,t,n){const o=ga(t,n);o&&(e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120))}function ep(e,t,n){var s;const o=ga(t,n);if(o){for(let r=e.events.length-1;r>=0;r-=1){const l=N("网络异常,正在重试","Network error, retrying");if(String(((s=e.events[r])==null?void 0:s.title)||"").startsWith(l)){e.events.splice(r,1,o);return}}e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120)}}function tp(e,t={},n,o=()=>{}){var r,l,c,p,w,d,m,f,b;const s=Dr(t.type);if(s===Vt.SESSION){o(t.session);return}if(s===Vt.SESSION_UPDATED){o(t.session);return}if(s===Vt.STATUS){if(t.stage==="starting"||t.stage==="resuming")return;vn(e,{title:t.message||N("状态已更新","Status updated"),detail:""},n);return}if(s===Vt.STDERR){const v=Nn(t.text,e.engine);vn(e,{kind:"error",title:(v==null?void 0:v.title)||"stderr",detail:tn(t.text,e.engine)},n);return}if(s===Vt.STDOUT){vn(e,{kind:"command",title:"stdout",detail:t.text},n);return}if(s===Vt.AGENT_EVENT){if(Wf(e,t.event),((r=t.event)==null?void 0:r.type)===vt.THREAD_STARTED)return;const v=Jf(t.event,Lt(e),e.engine);String(v.title||"").startsWith(N("网络异常,正在重试","Network error, retrying"))?ep(e,v,n):vn(e,v,n),((l=t.event)==null?void 0:l.type)===vt.ITEM_COMPLETED&&((p=(c=t.event)==null?void 0:c.item)==null?void 0:p.type)===rt.AGENT_MESSAGE&&((d=(w=t.event)==null?void 0:w.item)!=null&&d.text)&&(e.responseMessage=t.event.item.text);const P=ss(t.event)||N(`${Lt(e)} 执行失败`,`${Lt(e)} failed`);if(!(((m=t.event)==null?void 0:m.type)==="error"?No(P):null)&&(((f=t.event)==null?void 0:f.type)===vt.ERROR||((b=t.event)==null?void 0:b.type)===vt.TURN_FAILED)){const y=ss(t.event)||N(`${Lt(e)} 执行失败`,`${Lt(e)} failed`);e.errorMessage=tn(y,e.engine),e.status="error"}return}if(s===Vt.COMPLETED){vn(e,{kind:"result",title:N("本轮执行结束","Run finished"),detail:""},n),t.message&&(e.responseMessage=t.message);return}if(s===Vt.STOPPED){vn(e,{title:t.message||N("执行已手动停止","Execution stopped manually"),detail:""},n);return}if(s===Vt.ERROR){const v=Nn(t.message,e.engine);vn(e,{kind:"error",title:(v==null?void 0:v.title)||N("执行失败","Execution failed"),detail:tn(t.message||N(`${Lt(e)} 执行失败`,`${Lt(e)} failed`),e.engine)},n)}}function np(e="",t="",n="codex"){const o=String(e||"").trim(),s=String(t||"").trim();if(!s)return!1;if(!o||/no last agent message|wrote empty content/i.test(o)||/执行失败[。.]?$/i.test(o))return!0;const r=Nn(o,n),l=Nn(s,n);return!r&&!!l}function sp(e,t={}){e.status=t.status||"completed",e.responseMessage=String(t.responseMessage||e.responseMessage||""),e.finishedAt=String(t.finishedAt||e.finishedAt||"");const n=tn(String(t.errorMessage||""),e.engine),o=String(e.errorMessage||"");return e.errorMessage=np(t.errorMessage,o,e.engine)?o:n,e.status==="completed"&&!e.responseMessage&&(e.responseMessage=N(`本轮 ${Lt(e)} 执行已完成,没有返回额外文本。`,`${Lt(e)} completed in this run without returning additional text.`)),e}function Oo(e,t={},n,o=()=>{}){const s=Math.max(0,Number(t==null?void 0:t.seq)||0);if(s&&s<=Number(e.lastEventSeq||0))return!1;const r=(t==null?void 0:t.payload)||{};tp(e,r,n,o);const l=Dr(r.type);return l===Vt.COMPLETED?(e.status="completed",e.finishedAt=new Date().toISOString()):l===Vt.STOPPED?(e.status="stopped",e.errorMessage="",e.finishedAt=new Date().toISOString()):l===Vt.ERROR&&(e.status="error",e.errorMessage=tn(String(r.message||e.errorMessage||N(`${Lt(e)} 执行失败`,`${Lt(e)} failed`)),e.engine),e.finishedAt=new Date().toISOString()),s&&(e.lastEventSeq=s),e.eventCount=Math.max(Math.max(0,Number(e.eventCount)||0),s,Array.isArray(e.events)?e.events.length:0),(s||Array.isArray(e.events)&&e.events.length)&&(e.eventsLoaded=!0),!0}function rr(e,t,n,o){const s=Zf(e,t);return(e.events||[]).forEach(r=>{Oo(s,r,n,o)}),sp(s,e)}const op=1800,ar=7200,rp=15e3,ro={clearTaskCodexRuns:al,listCodexRunEvents:ol,listTaskCodexRuns:sl};function Qn(e={},t=!0){const n={id:String((e==null?void 0:e.runId)||(e==null?void 0:e.id)||"").trim(),prompt:String((e==null?void 0:e.prompt)||"").trim(),promptBlocks:Array.isArray(e==null?void 0:e.promptBlocks)?e.promptBlocks.map(o=>({type:String((o==null?void 0:o.type)||"").trim(),content:String((o==null?void 0:o.content)||"")})):[],responseMessage:String((e==null?void 0:e.responseMessage)||""),errorMessage:String((e==null?void 0:e.errorMessage)||"")};return t?{...n,status:String((e==null?void 0:e.status)||"").trim(),updatedAt:String((e==null?void 0:e.updatedAt)||""),eventCount:Math.max(0,Number(e==null?void 0:e.eventCount)||0),lastEventSeq:Math.max(0,Number(e==null?void 0:e.lastEventSeq)||0)}:n}function ap(e=[],t=!0){const n=Array.isArray(e)?e:[];return JSON.stringify(n.map(o=>Qn(o,t)))}function ip(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function lp(e={}){const{props:t,turns:n,sessions:o,sending:s,sendingStartedAt:r,currentRunningRunId:l,sessionError:c,supportsServerEvents:p,scheduleScrollToBottom:w,resetAutoStickToBottom:d,mergeSessionRecord:m,mergeSession:f,loadSessions:b,showProcessLogs:v}=e;let P=0,ne=0,y=null,L="",O=null,z=null,U="",se=!!(v!=null&&v.value),A=0;const G=new Map;function ce(){return P+=1,P}function pe(){return ne+=1,ne}function I(){O&&(window.clearInterval(O),O=null)}function Q(){z&&(window.clearInterval(z),z=null)}function le(){A=Date.now()}function ie(){G.clear(),n.value=[],s.value=!1,r.value=0,l.value="",U="",L="",P=0,ne=0,d()}function ve(){const R=[...n.value].reverse().find(J=>ns(J.status))||null;if(l.value=(R==null?void 0:R.runId)||"",s.value=!!R,R!=null&&R.startedAt){const J=Date.parse(String(R.startedAt||""));r.value=Number.isFinite(J)?J:Date.now();return}r.value=0}function _(R=null){return R?{...R}:ip()}function H(R,J=null){if(!(J!=null&&J.runId)||R.eventsLoaded||!J.eventsLoaded)return G.has(R.runId)&&(R.eventsLoading=!0),R;const fe=Math.max(Math.max(0,Number(J.lastEventSeq)||0),Math.max(0,Number(J.eventCount)||0),Array.isArray(J.events)?J.events.length:0),_e=Math.max(0,Number(R.eventCount)||0);return fe<_e?(G.has(R.runId)&&(R.eventsLoading=!0),R):(R.events=Array.isArray(J.events)?[...J.events]:[],R.eventCount=Math.max(Math.max(0,Number(R.eventCount)||0),Math.max(0,Number(J.eventCount)||0),R.events.length),R.eventsLoaded=!0,R.eventsLoading=G.has(R.runId),R.lastEventSeq=Math.max(0,Number(J.lastEventSeq)||0),R.summary=_(J.summary),R)}function F(R,J){const fe=vo(n.value,R);return fe?(fe.eventsLoading=!!J,n.value=[...n.value],fe):null}async function He(R,J={}){const fe=String((R==null?void 0:R.runId)||"").trim(),{force:_e=!1}=J;if(!fe)return[];const ge=vo(n.value,fe)||R;if(ge!=null&&ge.eventsLoaded&&!_e)return ge.events;if(G.has(fe))return G.get(fe);F(fe,!0);const Ie=(async()=>{var Ae;try{const Be=Qn(ge,!!(v!=null&&v.value)),Xe=await ro.listCodexRunEvents(fe,{limit:5e3}),Pe=qf(n.value,fe,Xe,pe,Me=>{f(Me,{preserveRunning:!0})});if(!Pe)return Array.isArray(ge==null?void 0:ge.events)?ge.events:[];const it=JSON.stringify(Be)!==JSON.stringify(Qn(Pe,!!(v!=null&&v.value)));return n.value=[...n.value],it&&t.active&&((Ae=n.value.at(-1))==null?void 0:Ae.runId)===fe&&w(),Pe.events}catch(Be){throw c.value=Be.message,Be}finally{F(fe,!1),G.delete(fe)}})();return G.set(fe,Ie),Ie}function De(R,J){const fe=String(R||"").trim();if(!fe||!J)return!1;const _e=n.value.findIndex(Xe=>Xe.runId===fe);if(_e<0)return!1;const ge=n.value[_e],Ie=Qn(ge,!!(v!=null&&v.value));if(!Oo(ge,J,pe,Xe=>{f(Xe,{preserveRunning:!0})}))return!0;const Be=JSON.stringify(Ie)!==JSON.stringify(Qn(ge,!!(v!=null&&v.value)));return n.value=[...n.value],ve(),Be&&w(),!0}function Fe(){if(I(),Q(),!(!t.active||!s.value||!t.taskSlug)){if(p){z=window.setInterval(()=>{Ke({force:!0}).catch(()=>{});const R=Date.now();R-A<ar||(A=R,b({force:!0}).catch(()=>{}))},rp);return}O=window.setInterval(()=>{Ke({force:!0}).catch(()=>{});const R=Date.now();R-A<ar||(A=R,b({force:!0}).catch(()=>{}))},op)}}function je(R=[]){const J=[...o.value],fe=new Map(n.value.filter(ge=>String((ge==null?void 0:ge.runId)||"").trim()).map(ge=>[String(ge.runId||"").trim(),ge])),_e=ge=>{if(!(ge!=null&&ge.id))return;const Ie=J.findIndex(Ae=>Ae.id===ge.id);Ie>=0?J[Ie]=m(J[Ie],ge,{preserveRunning:!0}):J.unshift(m(null,ge,{preserveRunning:!0}))};P=0,ne=0,n.value=[...R||[]].reverse().map(ge=>{const Ie=rr(ge,ce,pe,_e);return H(Ie,fe.get(String((ge==null?void 0:ge.id)||"").trim())||null)}),o.value=J,ve()}async function Ke(R={}){const{force:J=!1,scrollToLatest:fe=!1}=R,_e=String(t.taskSlug||"").trim();if(!(!_e||!t.active&&!J))return y&&L===_e||y&&!J||(L=_e,y=(async()=>{try{const Ie=(await ro.listTaskCodexRuns(_e,{limit:30,events:"latest"})).items||[],Ae=!!(v!=null&&v.value),Be=ap(Ie,Ae),Xe=fe||U&&se===Ae&&Be!==U;je(Ie),U=Be,se=Ae,Fe();const Pe=n.value.at(-1)||null;if(Pe!=null&&Pe.runId&&!Pe.eventsLoaded){const it=Pe.runId;He(Pe).catch(()=>{}).finally(()=>{var Me;fe&&t.active&&((Me=n.value.at(-1))==null?void 0:Me.runId)===it&&w({force:!0})})}Xe&&w({force:fe})}catch(ge){c.value=ge.message}finally{y=null,L=""}})()),y}function tt(R={}){const J=(R==null?void 0:R.run)||null,fe=(R==null?void 0:R.session)||null;if(fe&&f(fe,{preserveRunning:!0}),!(J!=null&&J.id)){ve(),w({force:!0});return}const ge=rr(J,ce,pe,Ae=>{f(Ae,{preserveRunning:!0})}),Ie=n.value.findIndex(Ae=>Ae.runId===ge.runId);if(Ie>=0){const Ae=[...n.value];Ae.splice(Ie,1,ge),n.value=Ae}else n.value=[...n.value,ge];ve(),w({force:!0})}async function xe(){if(!(!t.taskSlug||s.value))try{await ro.clearTaskCodexRuns(t.taskSlug),ie(),w({force:!0})}catch(R){c.value=R.message}}return{applyCreatedRun:tt,applyIncomingRunEvent:De,clearRealtimeReconcileTimer:Q,clearRunPollTimer:I,clearTurns:xe,loadTurnEvents:He,markFallbackSessionPollNow:le,refreshRunHistory:Ke,resetRunHistoryState:ie,syncRunningStateFromTurns:ve,updatePollingState:Fe}}const up=1500,cp=3e4;function dp(e={}){const{props:t,sessions:n,workspaces:o,loading:s,managerBusy:r,sending:l,stopping:c,sessionError:p,showManager:w,selectedSessionId:d,currentRunningRunId:m,supportsServerEvents:f,mergeSession:b,applyCreatedRun:v,refreshRunHistory:P,markFallbackSessionPollNow:ne,showToast:y,getActiveAgentBinding:L=null}=e;let O=null,z=null,U=0,se=0;const A=W(()=>typeof t.buildPrompt=="function"||!!String(t.prompt||"").trim()),G=W(()=>n.value.length>0),ce=W(()=>Jo(n.value,d.value)),pe=W(()=>G.value?"":We("projectManager.noProjects"));async function I(xe={}){const{force:R=!1}=xe;if(O)return O;const J=Date.now();return!R&&U&&J-U<up?{items:n.value,workspaces:o.value}:(O=(async()=>{s.value=!0,p.value="";try{const _e=(await Ki()).items||[];return n.value=_e,U=Date.now(),{items:_e,workspaces:o.value}}catch(fe){throw p.value=fe.message,fe}finally{s.value=!1,O=null}})(),O)}async function Q(xe={}){const{force:R=!1}=xe;if(z)return z;const J=Date.now();return!R&&se&&J-se<cp?{items:o.value}:(z=(async()=>{try{const fe=await Wi();return o.value=fe.items||[],se=Date.now(),{items:o.value}}finally{z=null}})(),z)}async function le(xe={}){const{forceSessions:R=!1,forceWorkspaces:J=!1}=xe,[fe,_e]=await Promise.all([I({force:R}),Q({force:J})]);return{items:(fe==null?void 0:fe.items)||n.value,workspaces:(_e==null?void 0:_e.items)||o.value}}function ie(xe=""){const R=String(xe||"").trim();!R||o.value.includes(R)||(o.value=[R,...o.value])}function ve(){w.value=!0,Q().catch(()=>{})}function _(){w.value=!1}function H(xe){const R=String(xe||"").trim();if(t.sessionSelectionLocked&&R&&R!==d.value){p.value=t.sessionSelectionLockReason||We("taskActions.sessionLocked");return}d.value=R}function F(){le({forceSessions:!0,forceWorkspaces:!0}).catch(()=>{})}async function He(xe){r.value=!0,p.value="";try{const R=await Gi(xe);return b(R),ie(R.cwd),d.value=R.id,R}catch(R){throw p.value=R.message,R}finally{r.value=!1}}async function De(xe,R){r.value=!0,p.value="";try{const J=await Xi(xe,R);return b(J),ie(J.cwd),J}catch(J){throw p.value=J.message,J}finally{r.value=!1}}async function Fe(xe){var J;const R=String(xe||"").trim();if(!R)return{deletedSessionId:"",selectedSessionId:d.value};r.value=!0,p.value="";try{await Yi(R);const fe=n.value.filter(ge=>ge.id!==R);n.value=fe;let _e=d.value;return d.value===R&&(_e=((J=Jo(fe,"")[0])==null?void 0:J.id)||"",d.value=_e),{deletedSessionId:R,selectedSessionId:_e}}catch(fe){throw p.value=fe.message,fe}finally{r.value=!1}}async function je(xe){const R=String(xe||"").trim();if(!R)return null;r.value=!0,p.value="";try{const J=await Ji(R);return J!=null&&J.session&&b(J.session),ne(),await Promise.all([P({force:!0}),I({force:!0})]),y==null||y({message:We("projectManager.sessionReset"),type:"success"}),J}catch(J){throw p.value=J.message,J}finally{r.value=!1}}async function Ke(){if(!t.taskSlug||!A.value||l.value||c.value)return!1;if(!d.value){const xe=We("projectManager.selectProject");return p.value=xe,y==null||y({message:xe,type:"warning"}),!1}p.value="";try{await le({forceSessions:!0});const xe=n.value.find(Pe=>Pe.id===d.value)||null;if(!xe)return p.value=We("projectManager.projectMissing"),!1;if(xe.running)return p.value=We("sessionTurns.currentProjectRunning"),!1;const R=typeof t.buildPrompt=="function"?await t.buildPrompt():t.prompt,J=typeof t.buildPromptBlocks=="function"?await t.buildPromptBlocks():[],fe=si({prompt:R,promptBlocks:J});if(fe.reason){const Pe=fe.reason==="unsupported_blocks"?We("sessionPanel.shellUnsupportedBlocks"):We("sessionPanel.shellEmptyCommand");return p.value=Pe,y==null||y({message:Pe,type:"warning"}),!1}if(!String(R||"").trim())return p.value=We("sessionTurns.noPromptToSend"),!1;const _e=fp(xe),ge=typeof L=="function"?L(xe):null,Ie=String((ge==null?void 0:ge.engine)||"").trim();if(Ie&&!_e.some(Pe=>Pe.engine===Ie)){const Pe=We("sessionPanel.agentNotEnabled");return p.value=Pe,y==null||y({message:Pe,type:"warning"}),!1}const Ae=ge,Be=String(fe.mode==="shell"?d.value:(Ae==null?void 0:Ae.sessionRecordId)||d.value).trim(),Xe=await rl(t.taskSlug,{projectSessionId:d.value,sessionId:Be,displayEngine:Ie,prompt:fe.mode==="shell"?fe.prompt:R,promptBlocks:J,commandMode:fe.mode,command:fe.command});return v(Xe),typeof t.afterSend=="function"&&Promise.resolve(t.afterSend()).catch(Pe=>{console.error("[promptx] afterSend failed",Pe)}),f||(ne(),Promise.all([P({force:!0}),I({force:!0})]).catch(Pe=>{p.value=Pe.message})),!0}catch(xe){return p.value=xe.message,!1}}async function tt(){if(!(!m.value||c.value))try{c.value=!0,await il(m.value),f||(ne(),await Promise.all([P({force:!0}),I({force:!0})]))}catch(xe){c.value=!1,p.value=xe.message}}return{closeManager:_,handleCreateSession:He,handleDeleteSession:Fe,handleResetSession:je,handleSelectSession:H,handleSend:Ke,handleUpdateSession:De,hasPrompt:A,helperText:pe,loadSessions:I,loadSessionResources:le,loadWorkspaces:Q,openManager:ve,refreshSessionsForSelection:F,sortedSessions:ce,stopSending:tt}}function fp(e={}){return Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length?e.agentBindings:e!=null&&e.id?[{engine:pp(e.engine),sessionRecordId:e.id,sessionId:e.sessionId||"",isDefault:!0,running:!!e.running,started:!!e.started}]:[]}function pp(e=""){const t=String(e||"").trim().toLowerCase();return t==="claude"||t==="claudecode"?"claude-code":t==="opencode"||t==="open-code"?"opencode":t==="claude-code"?"claude-code":"codex"}function mp(e={}){const{transcriptRef:t,hasNewerMessages:n,threshold:o=48}=e;let s=0,r=[],l=!1,c=!1,p=0,w=!0;function d(){if(typeof window>"u"||!r.length){r=[];return}r.forEach(ce=>{window.cancelAnimationFrame(ce)}),r=[]}function m(){s+=1,d()}function f(ce){c=!!ce,(n==null?void 0:n.value)!==void 0&&(n.value=c)}function b(){l=!1,p+=1,w=!0,f(!1)}function v(ce=t==null?void 0:t.value){return ce?ce.scrollHeight-ce.scrollTop-ce.clientHeight<=o:!0}function P(){return w&&!l}function ne(){w&&!l&&f(!1)}function y(){if(w=v(),!w){m();return}ne()}function L(){p+=1,l=!0,m()}function O(){const ce=p+1;p=ce,at(()=>{ce===p&&requestAnimationFrame(()=>{ce===p&&(l=!1,w=v(),ne())})})}function z(){l=!0,m()}function U(){O()}function se(ce={}){const{force:pe=!1}=ce;pe&&b(),m();const I=s;at(()=>{if(!(t==null?void 0:t.value)||I!==s)return;if(!pe&&!P()){f(!0);return}const le=()=>{const ve=t==null?void 0:t.value;!ve||I!==s||(ve.scrollTop=ve.scrollHeight,w=!0,f(!1))};le(),r=[requestAnimationFrame(()=>{le(),r=[requestAnimationFrame(le)]})]})}function A(){se({force:!0})}function G(){p+=1,m()}return{cancelScheduledScrollToBottom:m,destroy:G,handleTranscriptScroll:y,handleTranscriptTouchEnd:U,handleTranscriptTouchMove:z,handleTranscriptTouchStart:L,isTranscriptNearBottom:v,resetAutoStickToBottom:b,scheduleScrollToBottom:se,scrollToBottom:A}}const gp=150,ha="promptx:session-panel:show-process";function hp(e){return!(e==="0"||e==="false")}function vp(){if(typeof window>"u")return!0;try{return hp(window.localStorage.getItem(ha))}catch{return!0}}function yp(e,t,n={}){const{preserveRunning:o=!1}=n;if(!(t!=null&&t.id))return e||null;const s={...e||{},...t};return(!Array.isArray(t==null?void 0:t.agentBindings)||!t.agentBindings.length)&&Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length&&(s.agentBindings=e.agentBindings),o&&(s.running=!!(e!=null&&e.running)),s}function Sp(e,t){const n=oa(),o=q([]),s=q([]),r=q(!1),l=q(!1),c=q(!1),p=q(!1),w=q(""),d=q([]),m=q(null),f=q(0),b=q(0),v=q(!1),P=q(""),ne=q(!1),y=q(vp()),L=typeof window<"u"&&typeof window.EventSource<"u";function O(re=""){const Le=typeof re=="object"&&re!==null?String(re.message||"").trim():String(re||"").trim();Le&&t("toast",typeof re=="object"&&re!==null?{...re,message:Le}:Le)}let z=null,U=null,se=null,A={sessions:!1,runs:!1};const G=W({get(){return String(e.selectedSessionId||"").trim()},set(re){t("selected-session-change",String(re||"").trim())}}),ce=W(()=>p.value?We("sessionPanel.stopping"):`${We("projectManager.running")} (${la(b.value)})`),pe=W(()=>o.value.find(re=>re.id===G.value)||null),I=W(()=>{var Le;if(Array.isArray((Le=pe.value)==null?void 0:Le.agentBindings)&&pe.value.agentBindings.length)return pe.value.agentBindings;const re=pe.value;return re!=null&&re.id?[{engine:re.engine,sessionRecordId:re.id,sessionId:re.sessionId||"",started:!!re.started,running:!!re.running,isDefault:!0}]:[]}),Q=W({get(){var Le,ot;const re=ao(e.selectedAgentEngine,I.value);return re||((Le=I.value.find(xt=>xt.isDefault))==null?void 0:Le.engine)||((ot=I.value[0])==null?void 0:ot.engine)||""},set(re){const Le=ao(re,I.value);Le&&t("update:selectedAgentEngine",Le)}}),le=W(()=>I.value.find(re=>re.engine===Q.value)||I.value[0]||null),{destroy:ie,handleTranscriptScroll:ve,handleTranscriptTouchEnd:_,handleTranscriptTouchMove:H,handleTranscriptTouchStart:F,resetAutoStickToBottom:He,scheduleScrollToBottom:De,scrollToBottom:Fe}=mp({transcriptRef:m,hasNewerMessages:ne});function je(re,Le,ot={}){return yp(re,Le,ot)}function Ke(re,Le={}){if(!(re!=null&&re.id))return;const ot=[...o.value],xt=ot.findIndex(Et=>Et.id===re.id);xt>=0?ot[xt]=je(ot[xt],re,Le):ot.unshift(je(null,re,Le)),o.value=ot}const{applyCreatedRun:tt,applyIncomingRunEvent:xe,clearRealtimeReconcileTimer:R,clearRunPollTimer:J,clearTurns:fe,loadTurnEvents:_e,markFallbackSessionPollNow:ge,refreshRunHistory:Ie,resetRunHistoryState:Ae,updatePollingState:Be}=lp({props:e,turns:d,sessions:o,sending:c,sendingStartedAt:f,currentRunningRunId:P,sessionError:w,supportsServerEvents:L,scheduleScrollToBottom:De,resetAutoStickToBottom:He,showProcessLogs:y,mergeSessionRecord:je,mergeSession:Ke,loadSessions:(...re)=>dt(...re)}),{closeManager:Xe,handleCreateSession:Pe,handleDeleteSession:it,handleResetSession:Me,handleSelectSession:Ne,handleSend:Ee,handleUpdateSession:lt,helperText:ht,loadSessions:dt,loadSessionResources:wt,loadWorkspaces:Ct,openManager:T,refreshSessionsForSelection:j,sortedSessions:te,stopSending:ye}=dp({props:e,sessions:o,workspaces:s,loading:r,managerBusy:l,sending:c,stopping:p,sessionError:w,showManager:v,selectedSessionId:G,currentRunningRunId:P,supportsServerEvents:L,mergeSession:Ke,applyCreatedRun:tt,refreshRunHistory:Ie,markFallbackSessionPollNow:ge,showToast:O,getActiveAgentBinding:()=>le.value});function Oe(){z&&(window.clearInterval(z),z=null)}function Re(){Oe(),f.value||(f.value=Date.now()),b.value=Math.max(0,Math.floor((Date.now()-f.value)/1e3)),z=window.setInterval(()=>{b.value=Math.max(0,Math.floor((Date.now()-f.value)/1e3))},1e3)}function Ge(){se&&(window.clearTimeout(se),se=null)}function Ye(){Ge();const re=A;A={sessions:!1,runs:!1},re.sessions&&dt({force:!0}).catch(()=>{}),re.runs&&Ie({force:!0}).catch(()=>{})}function nt(re={}){typeof window>"u"||(A={sessions:A.sessions||!!re.sessions,runs:A.runs||!!re.runs},!(se||!A.sessions&&!A.runs)&&(se=window.setTimeout(()=>{Ye()},gp)))}function yt(re){return fa(re,{currentRunningRunId:P.value,runningElapsedSeconds:b.value,nowMs:Date.now()})}function st(re=""){if(!re)return"";const Le=new Date(re);return Number.isNaN(Le.getTime())?"":Le.toLocaleTimeString(Os(),{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ft(re){return re.status==="error"||re.status==="stop_timeout"?"theme-process-error":re.status==="interrupted"||re.status==="stopped"?"theme-process-stopped":re.status==="completed"?"theme-process-completed":"theme-process-running"}function _t(){y.value=!y.value}function Bt(re){return!!(re.responseMessage||re.errorMessage||re.status==="completed")}return $e(y,re=>{if(!(typeof window>"u"))try{window.localStorage.setItem(ha,re?"true":"false")}catch{}},{immediate:!0}),$e(c,re=>{re?(f.value||(f.value=Date.now()),Re()):(Oe(),f.value=0,b.value=0,p.value=!1),Be(),t("sending-change",re)},{immediate:!0}),$e(()=>!!e.taskRunning,re=>{!e.active||re||!c.value||nt({sessions:!0,runs:!0})}),$e(()=>e.active,re=>{if(re){wt({forceSessions:!0}).catch(()=>{});return}Ge(),R(),J()},{immediate:!0}),$e(()=>e.taskSlug,()=>{Ae(),v.value=!1,w.value="",e.active&&Ie({force:!0,scrollToLatest:!0}).catch(()=>{})},{immediate:!0}),$e(()=>{var re;return[((re=pe.value)==null?void 0:re.id)||"",I.value.map(Le=>Le.engine).join(","),e.selectedAgentEngine||""].join(`
39
- `)},()=>{var pt,V,X;const re=String(((pt=pe.value)==null?void 0:pt.id)||"").trim(),Le=I.value,ot=Q.value;if(t("agent-bindings-change",{sessionId:re,bindings:Le,selectedEngine:ot}),!re||ao(e.selectedAgentEngine,Le))return;const Et=((V=Le.find(de=>de.isDefault))==null?void 0:V.engine)||((X=Le[0])==null?void 0:X.engine)||"";Et&&t("update:selectedAgentEngine",Et)},{immediate:!0}),It(()=>{Oe(),R(),J(),Ge(),ie(),U==null||U()}),$e(()=>n.readyVersion.value,()=>{const re=String(e.taskSlug||"").trim();!e.active&&!v.value||(v.value&&Ct().catch(()=>{}),nt({sessions:!0,runs:!!re}))}),$e(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!v.value||nt({sessions:!0})}),$e(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||nt({sessions:!0,runs:!0})}),$e(()=>String(e.taskSlug||"").trim(),re=>{U==null||U(),U=null,re&&(U=Cf(re,({runId:Le,event:ot})=>{if(!e.active)return;xe(Le,ot)||nt({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:le,activeAgentEngine:Q,clearTurns:fe,closeManager:Xe,formatTurnTime:st,getProcessCardClass:ft,getProcessStatus:Qf,getTurnAgentLabel:Lt,getTurnSummaryDetail:ma,getDisplayTurnSummaryItems:yt,getTurnSummaryStatus:pa,handleCreateSession:Pe,handleDeleteSession:it,handleResetSession:Me,handleSelectSession:Ne,handleSend:Ee,handleUpdateSession:lt,loadTurnEvents:_e,hasTurnSummary:Xf,helperText:ht,loading:r,managerBusy:l,openManager:T,refreshSessionsForSelection:j,selectedSessionId:G,sending:c,showProcessLogs:y,stopping:p,sessionError:w,shouldShowResponse:Bt,showManager:v,sortedSessions:te,stopSending:ye,toggleProcessLogs:_t,hasNewerMessages:ne,transcriptRef:m,turns:d,workspaces:s,workingLabel:ce,sessions:o,loadSessions:dt,currentProjectAgentBindings:I,handleTranscriptScroll:ve,handleTranscriptTouchEnd:_,handleTranscriptTouchMove:H,handleTranscriptTouchStart:F,scheduleScrollToBottom:De,scrollToBottom:Fe}}function ao(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const wp=8,xp=320,bp=10,kp=400;function ir(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function _p(e={}){const{turns:t,loadTurnEvents:n}=e,o=q({}),s=q({}),r=q({});function l(A){return String((A==null?void 0:A.runId)||(A==null?void 0:A.id)||"").trim()}function c(A){const G=l(A);return!!G&&G===l(t.value.at(-1))}function p(A){return Math.max(0,Number(A==null?void 0:A.eventCount)||0,Array.isArray(A==null?void 0:A.events)?A.events.length:0)}function w(A){return!ns(A==null?void 0:A.status)&&!c(A)&&p(A)>3}function d(A){return ir(A==null?void 0:A.prompt,wp,xp)}function m(A){return!ns(A==null?void 0:A.status)&&!c(A)&&d(A)}function f(A){return String((A==null?void 0:A.errorMessage)||(A==null?void 0:A.responseMessage)||"")}function b(A){return ir(f(A),bp,kp)}function v(A){return!(A!=null&&A.errorMessage)&&!c(A)&&b(A)}function P(A){return p(A)>0}function ne(A=[]){const G=new Set((A||[]).map(I=>l(I)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([I])=>G.has(I))),s.value=Object.fromEntries(Object.entries(s.value).filter(([I])=>G.has(I))),r.value=Object.fromEntries(Object.entries(r.value).filter(([I])=>G.has(I)));const ce=(A||[]).at(-1)||null,pe=l(ce);pe&&(Object.prototype.hasOwnProperty.call(o.value,pe)||(o.value={...o.value,[pe]:!1}),Object.prototype.hasOwnProperty.call(s.value,pe)||(s.value={...s.value,[pe]:!1}),Object.prototype.hasOwnProperty.call(r.value,pe)||(r.value={...r.value,[pe]:!1}))}function y(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(o.value,G)?!!o.value[G]:w(A):!1}async function L(A){const G=l(A);if(!G)return;const ce=!y(A);o.value={...o.value,[G]:ce},!ce&&P(A)&&!A.eventsLoaded&&!A.eventsLoading&&await n(A).catch(()=>{})}function O(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(s.value,G)?!!s.value[G]:m(A):!1}function z(A){const G=l(A);!G||!d(A)||(s.value={...s.value,[G]:!O(A)})}function U(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(r.value,G)?!!r.value[G]:v(A):!1}function se(A){const G=l(A);!G||!b(A)||(r.value={...r.value,[G]:!U(A)})}return $e(t,A=>{ne(A)},{immediate:!0,deep:!0}),{canCollapsePrompt:d,canCollapseResponse:b,getTurnEventCollapseKey:l,getTurnEventCount:p,hasTurnEventHistory:P,isLatestTurn:c,isPromptCollapsed:O,isResponseCollapsed:U,isTurnEventsCollapsed:y,togglePrompt:z,toggleResponse:se,toggleTurnEvents:L}}function Tp(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function Cp(e=[]){const t=e.map(n=>({label:String((n==null?void 0:n.label)||"").trim(),value:String((n==null?void 0:n.value)||"").trim()})).filter(n=>n.label&&n.value);return t.length?{type:"meta",items:t}:null}function Ep(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function io(e="",t=0){const n=Math.max(1,Number(t)||0);return e==="read"?`连续读取 ${n} 项`:e==="grep"?`连续检索 ${n} 次`:e==="list"?`连续列出 ${n} 处`:e==="web"?`连续网页检索 ${n} 次`:e==="todo"?"待办列表":e==="reasoning"?"思考过程":`连续处理 ${n} 项`}function lo(e="",t=[],n=[]){var l;const o=Tp(t.map(c=>c.groupTarget)),s=[];if(e==="todo"){const c=[...n].reverse().flatMap(p=>Array.isArray(p==null?void 0:p.detailBlocks)?p.detailBlocks:[]).find(p=>(p==null?void 0:p.type)==="checklist");return c?[c]:[]}if(e==="reasoning"){const c=[...t].reverse().find(p=>Array.isArray(p==null?void 0:p.detailBlocks)&&p.detailBlocks.length);return(l=c==null?void 0:c.detailBlocks)!=null&&l.length?c.detailBlocks:[]}const r=Cp([{label:"类型",value:Ep(e)},{label:"次数",value:String(t.length)}]);return r&&s.push(r),o.length&&s.push({type:"bullet_list",items:o.slice(0,8),totalCount:o.length,hiddenCount:Math.max(0,o.length-8)}),s}function va(e=[]){if(!e.length)return[];const[t]=e,n=String(t.groupType||"").trim();if(!n)return e;if(n==="reasoning"){if(e.length===1)return e;const s=e[e.length-1];return[{...s,id:`${s.id}-group`,title:io(n,e.length),detail:"",detailBlocks:lo(n,e,e),isGrouped:!0,groupedCount:e.length}]}const o=e.filter(s=>s.phase==="completed"||s.phase==="updated"||s.kind==="error");if(!o.length)return[e[e.length-1]];if(n==="todo"){if(e.length===1)return e;const s=o[o.length-1];return[{...s,id:`${s.id}-group`,title:io(n,e.length),detail:"",detailBlocks:lo(n,e,o),isGrouped:!0,groupedCount:e.length}]}return o.length===1&&e.length<=2?[o[0]]:[{...o[o.length-1],id:`${o[o.length-1].id}-group`,title:io(n,o.length),detail:"",detailBlocks:lo(n,o,o),isGrouped:!0,groupedCount:o.length}]}function Ap(e=[]){const t=Array.isArray(e)?e:[],n=t.filter(r=>String((r==null?void 0:r.groupType)||"").trim()==="todo");if(n.length<=1)return t;const[o]=va(n);if(!o)return t;const s=t.reduce((r,l,c)=>String((l==null?void 0:l.groupType)||"").trim()==="todo"?c:r,-1);return s<0?t:t.flatMap((r,l)=>String((r==null?void 0:r.groupType)||"").trim()!=="todo"?[r]:l===s?[o]:[])}function $p(e=[]){var o;const t=Ap(Array.isArray(e)?e.filter(Boolean):[]),n=[];for(let s=0;s<t.length;s+=1){const r=t[s],l=String((r==null?void 0:r.groupType)||"").trim();if(!l){n.push(r);continue}const c=[r];for(;s+1<t.length&&String(((o=t[s+1])==null?void 0:o.groupType)||"").trim()===l;)c.push(t[s+1]),s+=1;n.push(...va(c))}return n}const Ip={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},Pp={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},Dp={class:"flex flex-col gap-2"},Lp={class:"flex items-center gap-2"},Bp=["title"],Mp={class:"flex shrink-0 items-center gap-1.5"},Rp=["aria-pressed","aria-label","title"],Np=["disabled"],Op={class:"hidden sm:inline"},jp=["disabled"],Fp={class:"hidden sm:inline"},Up=["aria-label"],Vp=["aria-pressed"],zp=["aria-pressed","title","onClick"],Hp={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},qp={class:"min-h-0 flex-1"},Kp={key:0,class:"theme-empty-state px-4 py-6 text-sm"},Wp={key:1,class:"theme-empty-state px-4 py-6 text-sm"},Gp=["data-turn-id","data-run-id"],Xp={class:"flex justify-end"},Yp={class:"transcript-card transcript-card--prompt min-w-0 w-full rounded-sm bg-[var(--theme-promptBg)] px-4 py-3 font-mono text-sm text-[var(--theme-promptText)]"},Jp={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},Qp={class:"font-semibold"},Zp={class:"flex items-center gap-2"},em=["onClick"],tm={class:"relative mt-2"},nm={key:0,class:"space-y-3"},sm={key:0,class:"whitespace-pre-wrap break-words leading-7"},om=["onClick"],rm=["src","alt"],am={key:1,class:"whitespace-pre-wrap break-words leading-7"},im={key:0,class:"flex min-w-0 justify-start"},lm={class:"flex items-center justify-between gap-3 text-xs"},um={class:"font-semibold"},cm={class:"flex items-center gap-2"},dm=["disabled","onClick"],fm={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},pm={key:1,class:"mt-2 min-w-0 space-y-2"},mm={class:"text-sm font-medium leading-6"},gm={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},hm={key:3,class:"mt-2 text-xs text-current"},vm={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},ym={key:0,class:"leading-5"},Sm={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},wm={key:2,class:"mt-2 flex flex-wrap gap-2"},xm={class:"font-medium"},bm={key:1,class:"flex justify-start"},km={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},_m={class:"font-semibold"},Tm={class:"flex items-center gap-2"},Cm=["onClick"],Em=["onClick"],Am={class:"relative mt-2"},$m={key:0,class:"whitespace-pre-wrap break-words"},Im=["innerHTML"],Pm={class:"pointer-events-none absolute bottom-1 right-1 z-10 flex flex-col items-end gap-1.5 sm:bottom-3 sm:right-3"},Dm=["disabled"],Lm={key:2,class:"task-loading-dots","aria-hidden":"true"},Bm={__name:"CodexSessionPanel",props:{prompt:{type:String,default:""},buildPrompt:{type:Function,default:null},buildPromptBlocks:{type:Function,default:null},beforeSend:{type:Function,default:null},afterSend:{type:Function,default:null},taskSlug:{type:String,default:""},selectedSessionId:{type:String,default:""},selectedAgentEngine:{type:String,default:""},active:{type:Boolean,default:!1},sessionSelectionLocked:{type:Boolean,default:!1},sessionSelectionLockReason:{type:String,default:""},diffSupported:{type:Boolean,default:!1},taskRunning:{type:Boolean,default:!1}},emits:["agent-bindings-change","insert-code-context","project-created","selected-session-change","sending-change","open-diff","toast","update:selectedAgentEngine"],setup(e,{expose:t,emit:n}){const o=fo(()=>ze(()=>import("./CodexSessionManagerDialog-CELTkz9T.js"),__vite__mapDeps([34,35,2,3,36,37,38,39,40]))),s=n,r=e,{closeManager:l,formatTurnTime:c,getProcessCardClass:p,getProcessStatus:w,getTurnAgentLabel:d,getDisplayTurnSummaryItems:m,getTurnSummaryDetail:f,getTurnSummaryStatus:b,handleCreateSession:v,handleDeleteSession:P,handleResetSession:ne,handleSelectSession:y,handleSend:L,handleTranscriptScroll:O,handleTranscriptTouchEnd:z,handleTranscriptTouchMove:U,handleTranscriptTouchStart:se,handleUpdateSession:A,helperText:G,loadTurnEvents:ce,loading:pe,managerBusy:I,openManager:Q,refreshSessionsForSelection:le,selectedSessionId:ie,sending:ve,showProcessLogs:_,stopping:H,hasTurnSummary:F,hasNewerMessages:He,sessionError:De,shouldShowResponse:Fe,showManager:je,sortedSessions:Ke,stopSending:tt,toggleProcessLogs:xe,transcriptRef:R,turns:J,workspaces:fe,sessions:_e,loadSessions:ge,currentProjectAgentBindings:Ie,scheduleScrollToBottom:Ae,scrollToBottom:Be}=Sp(r,s),Xe=q(null),Pe=q(!1),it=q(""),Me=q(""),Ne=q("all"),{t:Ee}=St(),{isDark:lt}=kr(),ht=W(()=>lt.value?"dark":"light"),dt=W(()=>{const h=new Set;return(Array.isArray(Ie.value)?Ie.value:[]).filter(Y=>{const D=String((Y==null?void 0:Y.engine)||"").trim();return!D||h.has(D)?!1:(h.add(D),!0)})}),wt=W(()=>dt.value.length>1),Ct=W(()=>{const h=String(Ne.value||"").trim();return!wt.value||h==="all"?J.value:J.value.filter(Y=>da(Y)===h)}),{selectionAction:T,clearSelectionState:j,handleSelectionMouseUp:te}=Yr({getContainer:()=>R.value,isActive:()=>!!(r.active&&J.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:h=>[...h.querySelectorAll("[data-response-selection-root]")],getCodeLeft:h=>{var Y,D;return((D=(Y=h==null?void 0:h.getBoundingClientRect)==null?void 0:Y.call(h))==null?void 0:D.left)||0},debounceMs:72});$e([Ne,()=>dt.value.map(h=>h.engine).join(`
38
+ `),detailBlocks:gs(s,!0,n),...In(s),phase:"completed"}}return s.type===rt.TODO_LIST?{kind:"todo",title:N("更新待办列表","Update todo list"),detail:yn(s.items),detailBlocks:oo(s),groupType:"todo",phase:"completed"}:{title:N(`完成 ${s.type||"未知项目"}`,`Completed ${s.type||"unknown item"}`),detail:""}}return{title:N(`事件: ${o}`,`Event: ${o}`),detail:""}}function Qf(e){return e.status==="queued"?N("排队中","Queued"):e.status==="starting"?N("启动中","Starting"):e.status==="stopping"?N("停止中","Stopping"):e.status==="running"?N("进行中","Running"):e.status==="error"?N("失败","Failed"):e.status==="interrupted"?N("已中断","Interrupted"):e.status==="stopped"?N("已停止","Stopped"):e.status==="stop_timeout"?N("停止超时","Stop timeout"):N("已完成","Completed")}function ga(e={},t){if(typeof e=="string"){const r=e.trim();return r?{id:t(),kind:"info",title:r,detail:""}:null}const n=String(e.title||"").trim(),o=String(e.detail||"").trim(),s=Array.isArray(e.detailBlocks)&&e.detailBlocks.length?e.detailBlocks.filter(Boolean):o?bn(o,{preferMarkdown:e.kind==="error"}):[];return!n&&!o?null:{id:t(),kind:e.kind||"info",title:n||o,detail:n?o:"",detailBlocks:s,groupType:String(e.groupType||"").trim(),groupTarget:String(e.groupTarget||"").trim(),toolName:String(e.toolName||"").trim(),phase:String(e.phase||"").trim()}}function Zf(e={},t){const n=Array.isArray(e.promptBlocks)?e.promptBlocks.map(o=>({...o,meta:o!=null&&o.meta?{...o.meta}:{},content:(o==null?void 0:o.type)==="image"?xs(o.content):o.content})):[];return{id:t(),runId:String(e.id||"").trim(),engine:String(e.engine||"").trim(),displayEngine:String(e.displayEngine||"").trim(),prompt:String(e.prompt||"").trim(),promptBlocks:n,status:"completed",startedAt:e.startedAt||e.createdAt||"",finishedAt:e.finishedAt||"",events:[],eventCount:Math.max(0,Number(e.eventCount)||(Array.isArray(e.events)?e.events.length:0)),eventsLoaded:!!e.eventsIncluded,eventsLoading:!1,responseMessage:"",errorMessage:"",lastEventSeq:0,summary:jn()}}function vn(e,t,n){const o=ga(t,n);o&&(e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120))}function ep(e,t,n){var s;const o=ga(t,n);if(o){for(let r=e.events.length-1;r>=0;r-=1){const l=N("网络异常,正在重试","Network error, retrying");if(String(((s=e.events[r])==null?void 0:s.title)||"").startsWith(l)){e.events.splice(r,1,o);return}}e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120)}}function tp(e,t={},n,o=()=>{}){var r,l,c,p,S,d,m,f,b;const s=Dr(t.type);if(s===Vt.SESSION){o(t.session);return}if(s===Vt.SESSION_UPDATED){o(t.session);return}if(s===Vt.STATUS){if(t.stage==="starting"||t.stage==="resuming")return;vn(e,{title:t.message||N("状态已更新","Status updated"),detail:""},n);return}if(s===Vt.STDERR){const v=Nn(t.text,e.engine);vn(e,{kind:"error",title:(v==null?void 0:v.title)||"stderr",detail:tn(t.text,e.engine)},n);return}if(s===Vt.STDOUT){vn(e,{kind:"command",title:"stdout",detail:t.text},n);return}if(s===Vt.AGENT_EVENT){if(Wf(e,t.event),((r=t.event)==null?void 0:r.type)===vt.THREAD_STARTED)return;const v=Jf(t.event,Lt(e),e.engine);String(v.title||"").startsWith(N("网络异常,正在重试","Network error, retrying"))?ep(e,v,n):vn(e,v,n),((l=t.event)==null?void 0:l.type)===vt.ITEM_COMPLETED&&((p=(c=t.event)==null?void 0:c.item)==null?void 0:p.type)===rt.AGENT_MESSAGE&&((d=(S=t.event)==null?void 0:S.item)!=null&&d.text)&&(e.responseMessage=t.event.item.text);const P=ss(t.event)||N(`${Lt(e)} 执行失败`,`${Lt(e)} failed`);if(!(((m=t.event)==null?void 0:m.type)==="error"?No(P):null)&&(((f=t.event)==null?void 0:f.type)===vt.ERROR||((b=t.event)==null?void 0:b.type)===vt.TURN_FAILED)){const y=ss(t.event)||N(`${Lt(e)} 执行失败`,`${Lt(e)} failed`);e.errorMessage=tn(y,e.engine),e.status="error"}return}if(s===Vt.COMPLETED){vn(e,{kind:"result",title:N("本轮执行结束","Run finished"),detail:""},n),t.message&&(e.responseMessage=t.message);return}if(s===Vt.STOPPED){vn(e,{title:t.message||N("执行已手动停止","Execution stopped manually"),detail:""},n);return}if(s===Vt.ERROR){const v=Nn(t.message,e.engine);vn(e,{kind:"error",title:(v==null?void 0:v.title)||N("执行失败","Execution failed"),detail:tn(t.message||N(`${Lt(e)} 执行失败`,`${Lt(e)} failed`),e.engine)},n)}}function np(e="",t="",n="codex"){const o=String(e||"").trim(),s=String(t||"").trim();if(!s)return!1;if(!o||/no last agent message|wrote empty content/i.test(o)||/执行失败[。.]?$/i.test(o))return!0;const r=Nn(o,n),l=Nn(s,n);return!r&&!!l}function sp(e,t={}){e.status=t.status||"completed",e.responseMessage=String(t.responseMessage||e.responseMessage||""),e.finishedAt=String(t.finishedAt||e.finishedAt||"");const n=tn(String(t.errorMessage||""),e.engine),o=String(e.errorMessage||"");return e.errorMessage=np(t.errorMessage,o,e.engine)?o:n,e.status==="completed"&&!e.responseMessage&&(e.responseMessage=N(`本轮 ${Lt(e)} 执行已完成,没有返回额外文本。`,`${Lt(e)} completed in this run without returning additional text.`)),e}function Oo(e,t={},n,o=()=>{}){const s=Math.max(0,Number(t==null?void 0:t.seq)||0);if(s&&s<=Number(e.lastEventSeq||0))return!1;const r=(t==null?void 0:t.payload)||{};tp(e,r,n,o);const l=Dr(r.type);return l===Vt.COMPLETED?(e.status="completed",e.finishedAt=new Date().toISOString()):l===Vt.STOPPED?(e.status="stopped",e.errorMessage="",e.finishedAt=new Date().toISOString()):l===Vt.ERROR&&(e.status="error",e.errorMessage=tn(String(r.message||e.errorMessage||N(`${Lt(e)} 执行失败`,`${Lt(e)} failed`)),e.engine),e.finishedAt=new Date().toISOString()),s&&(e.lastEventSeq=s),e.eventCount=Math.max(Math.max(0,Number(e.eventCount)||0),s,Array.isArray(e.events)?e.events.length:0),(s||Array.isArray(e.events)&&e.events.length)&&(e.eventsLoaded=!0),!0}function rr(e,t,n,o){const s=Zf(e,t);return(e.events||[]).forEach(r=>{Oo(s,r,n,o)}),sp(s,e)}const op=1800,ar=7200,rp=15e3,ro={clearTaskCodexRuns:al,listCodexRunEvents:ol,listTaskCodexRuns:sl};function Qn(e={},t=!0){const n={id:String((e==null?void 0:e.runId)||(e==null?void 0:e.id)||"").trim(),prompt:String((e==null?void 0:e.prompt)||"").trim(),promptBlocks:Array.isArray(e==null?void 0:e.promptBlocks)?e.promptBlocks.map(o=>({type:String((o==null?void 0:o.type)||"").trim(),content:String((o==null?void 0:o.content)||"")})):[],responseMessage:String((e==null?void 0:e.responseMessage)||""),errorMessage:String((e==null?void 0:e.errorMessage)||"")};return t?{...n,status:String((e==null?void 0:e.status)||"").trim(),updatedAt:String((e==null?void 0:e.updatedAt)||""),eventCount:Math.max(0,Number(e==null?void 0:e.eventCount)||0),lastEventSeq:Math.max(0,Number(e==null?void 0:e.lastEventSeq)||0)}:n}function ap(e=[],t=!0){const n=Array.isArray(e)?e:[];return JSON.stringify(n.map(o=>Qn(o,t)))}function ip(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function lp(e={}){const{props:t,turns:n,sessions:o,sending:s,sendingStartedAt:r,currentRunningRunId:l,sessionError:c,supportsServerEvents:p,scheduleScrollToBottom:S,resetAutoStickToBottom:d,mergeSessionRecord:m,mergeSession:f,loadSessions:b,showProcessLogs:v}=e;let P=0,ne=0,y=null,L="",O=null,z=null,U="",se=!!(v!=null&&v.value),A=0;const G=new Map;function ce(){return P+=1,P}function pe(){return ne+=1,ne}function I(){O&&(window.clearInterval(O),O=null)}function Q(){z&&(window.clearInterval(z),z=null)}function le(){A=Date.now()}function ie(){G.clear(),n.value=[],s.value=!1,r.value=0,l.value="",U="",L="",P=0,ne=0,d()}function ve(){const R=[...n.value].reverse().find(J=>ns(J.status))||null;if(l.value=(R==null?void 0:R.runId)||"",s.value=!!R,R!=null&&R.startedAt){const J=Date.parse(String(R.startedAt||""));r.value=Number.isFinite(J)?J:Date.now();return}r.value=0}function _(R=null){return R?{...R}:ip()}function H(R,J=null){if(!(J!=null&&J.runId)||R.eventsLoaded||!J.eventsLoaded)return G.has(R.runId)&&(R.eventsLoading=!0),R;const fe=Math.max(Math.max(0,Number(J.lastEventSeq)||0),Math.max(0,Number(J.eventCount)||0),Array.isArray(J.events)?J.events.length:0),_e=Math.max(0,Number(R.eventCount)||0);return fe<_e?(G.has(R.runId)&&(R.eventsLoading=!0),R):(R.events=Array.isArray(J.events)?[...J.events]:[],R.eventCount=Math.max(Math.max(0,Number(R.eventCount)||0),Math.max(0,Number(J.eventCount)||0),R.events.length),R.eventsLoaded=!0,R.eventsLoading=G.has(R.runId),R.lastEventSeq=Math.max(0,Number(J.lastEventSeq)||0),R.summary=_(J.summary),R)}function F(R,J){const fe=vo(n.value,R);return fe?(fe.eventsLoading=!!J,n.value=[...n.value],fe):null}async function He(R,J={}){const fe=String((R==null?void 0:R.runId)||"").trim(),{force:_e=!1}=J;if(!fe)return[];const ge=vo(n.value,fe)||R;if(ge!=null&&ge.eventsLoaded&&!_e)return ge.events;if(G.has(fe))return G.get(fe);F(fe,!0);const Ie=(async()=>{var Ae;try{const Be=Qn(ge,!!(v!=null&&v.value)),Xe=await ro.listCodexRunEvents(fe,{limit:5e3}),Pe=qf(n.value,fe,Xe,pe,Me=>{f(Me,{preserveRunning:!0})});if(!Pe)return Array.isArray(ge==null?void 0:ge.events)?ge.events:[];const it=JSON.stringify(Be)!==JSON.stringify(Qn(Pe,!!(v!=null&&v.value)));return n.value=[...n.value],it&&t.active&&((Ae=n.value.at(-1))==null?void 0:Ae.runId)===fe&&S(),Pe.events}catch(Be){throw c.value=Be.message,Be}finally{F(fe,!1),G.delete(fe)}})();return G.set(fe,Ie),Ie}function De(R,J){const fe=String(R||"").trim();if(!fe||!J)return!1;const _e=n.value.findIndex(Xe=>Xe.runId===fe);if(_e<0)return!1;const ge=n.value[_e],Ie=Qn(ge,!!(v!=null&&v.value));if(!Oo(ge,J,pe,Xe=>{f(Xe,{preserveRunning:!0})}))return!0;const Be=JSON.stringify(Ie)!==JSON.stringify(Qn(ge,!!(v!=null&&v.value)));return n.value=[...n.value],ve(),Be&&S(),!0}function Fe(){if(I(),Q(),!(!t.active||!s.value||!t.taskSlug)){if(p){z=window.setInterval(()=>{Ke({force:!0}).catch(()=>{});const R=Date.now();R-A<ar||(A=R,b({force:!0}).catch(()=>{}))},rp);return}O=window.setInterval(()=>{Ke({force:!0}).catch(()=>{});const R=Date.now();R-A<ar||(A=R,b({force:!0}).catch(()=>{}))},op)}}function je(R=[]){const J=[...o.value],fe=new Map(n.value.filter(ge=>String((ge==null?void 0:ge.runId)||"").trim()).map(ge=>[String(ge.runId||"").trim(),ge])),_e=ge=>{if(!(ge!=null&&ge.id))return;const Ie=J.findIndex(Ae=>Ae.id===ge.id);Ie>=0?J[Ie]=m(J[Ie],ge,{preserveRunning:!0}):J.unshift(m(null,ge,{preserveRunning:!0}))};P=0,ne=0,n.value=[...R||[]].reverse().map(ge=>{const Ie=rr(ge,ce,pe,_e);return H(Ie,fe.get(String((ge==null?void 0:ge.id)||"").trim())||null)}),o.value=J,ve()}async function Ke(R={}){const{force:J=!1,scrollToLatest:fe=!1}=R,_e=String(t.taskSlug||"").trim();if(!(!_e||!t.active&&!J))return y&&L===_e||y&&!J||(L=_e,y=(async()=>{try{const Ie=(await ro.listTaskCodexRuns(_e,{limit:30,events:"latest"})).items||[],Ae=!!(v!=null&&v.value),Be=ap(Ie,Ae),Xe=fe||U&&se===Ae&&Be!==U;je(Ie),U=Be,se=Ae,Fe();const Pe=n.value.at(-1)||null;if(Pe!=null&&Pe.runId&&!Pe.eventsLoaded){const it=Pe.runId;He(Pe).catch(()=>{}).finally(()=>{var Me;fe&&t.active&&((Me=n.value.at(-1))==null?void 0:Me.runId)===it&&S({force:!0})})}Xe&&S({force:fe})}catch(ge){c.value=ge.message}finally{y=null,L=""}})()),y}function tt(R={}){const J=(R==null?void 0:R.run)||null,fe=(R==null?void 0:R.session)||null;if(fe&&f(fe,{preserveRunning:!0}),!(J!=null&&J.id)){ve(),S({force:!0});return}const ge=rr(J,ce,pe,Ae=>{f(Ae,{preserveRunning:!0})}),Ie=n.value.findIndex(Ae=>Ae.runId===ge.runId);if(Ie>=0){const Ae=[...n.value];Ae.splice(Ie,1,ge),n.value=Ae}else n.value=[...n.value,ge];ve(),S({force:!0})}async function xe(){if(!(!t.taskSlug||s.value))try{await ro.clearTaskCodexRuns(t.taskSlug),ie(),S({force:!0})}catch(R){c.value=R.message}}return{applyCreatedRun:tt,applyIncomingRunEvent:De,clearRealtimeReconcileTimer:Q,clearRunPollTimer:I,clearTurns:xe,loadTurnEvents:He,markFallbackSessionPollNow:le,refreshRunHistory:Ke,resetRunHistoryState:ie,syncRunningStateFromTurns:ve,updatePollingState:Fe}}const up=1500,cp=3e4;function dp(e={}){const{props:t,sessions:n,workspaces:o,loading:s,managerBusy:r,sending:l,stopping:c,sessionError:p,showManager:S,selectedSessionId:d,currentRunningRunId:m,supportsServerEvents:f,mergeSession:b,applyCreatedRun:v,refreshRunHistory:P,markFallbackSessionPollNow:ne,showToast:y,getActiveAgentBinding:L=null}=e;let O=null,z=null,U=0,se=0;const A=W(()=>typeof t.buildPrompt=="function"||!!String(t.prompt||"").trim()),G=W(()=>n.value.length>0),ce=W(()=>Jo(n.value,d.value)),pe=W(()=>G.value?"":We("projectManager.noProjects"));async function I(xe={}){const{force:R=!1}=xe;if(O)return O;const J=Date.now();return!R&&U&&J-U<up?{items:n.value,workspaces:o.value}:(O=(async()=>{s.value=!0,p.value="";try{const _e=(await Ki()).items||[];return n.value=_e,U=Date.now(),{items:_e,workspaces:o.value}}catch(fe){throw p.value=fe.message,fe}finally{s.value=!1,O=null}})(),O)}async function Q(xe={}){const{force:R=!1}=xe;if(z)return z;const J=Date.now();return!R&&se&&J-se<cp?{items:o.value}:(z=(async()=>{try{const fe=await Wi();return o.value=fe.items||[],se=Date.now(),{items:o.value}}finally{z=null}})(),z)}async function le(xe={}){const{forceSessions:R=!1,forceWorkspaces:J=!1}=xe,[fe,_e]=await Promise.all([I({force:R}),Q({force:J})]);return{items:(fe==null?void 0:fe.items)||n.value,workspaces:(_e==null?void 0:_e.items)||o.value}}function ie(xe=""){const R=String(xe||"").trim();!R||o.value.includes(R)||(o.value=[R,...o.value])}function ve(){S.value=!0,Q().catch(()=>{})}function _(){S.value=!1}function H(xe){const R=String(xe||"").trim();if(t.sessionSelectionLocked&&R&&R!==d.value){p.value=t.sessionSelectionLockReason||We("taskActions.sessionLocked");return}d.value=R}function F(){le({forceSessions:!0,forceWorkspaces:!0}).catch(()=>{})}async function He(xe){r.value=!0,p.value="";try{const R=await Gi(xe);return b(R),ie(R.cwd),d.value=R.id,R}catch(R){throw p.value=R.message,R}finally{r.value=!1}}async function De(xe,R){r.value=!0,p.value="";try{const J=await Xi(xe,R);return b(J),ie(J.cwd),J}catch(J){throw p.value=J.message,J}finally{r.value=!1}}async function Fe(xe){var J;const R=String(xe||"").trim();if(!R)return{deletedSessionId:"",selectedSessionId:d.value};r.value=!0,p.value="";try{await Yi(R);const fe=n.value.filter(ge=>ge.id!==R);n.value=fe;let _e=d.value;return d.value===R&&(_e=((J=Jo(fe,"")[0])==null?void 0:J.id)||"",d.value=_e),{deletedSessionId:R,selectedSessionId:_e}}catch(fe){throw p.value=fe.message,fe}finally{r.value=!1}}async function je(xe){const R=String(xe||"").trim();if(!R)return null;r.value=!0,p.value="";try{const J=await Ji(R);return J!=null&&J.session&&b(J.session),ne(),await Promise.all([P({force:!0}),I({force:!0})]),y==null||y({message:We("projectManager.sessionReset"),type:"success"}),J}catch(J){throw p.value=J.message,J}finally{r.value=!1}}async function Ke(){if(!t.taskSlug||!A.value||l.value||c.value)return!1;if(!d.value){const xe=We("projectManager.selectProject");return p.value=xe,y==null||y({message:xe,type:"warning"}),!1}p.value="";try{await le({forceSessions:!0});const xe=n.value.find(Pe=>Pe.id===d.value)||null;if(!xe)return p.value=We("projectManager.projectMissing"),!1;if(xe.running)return p.value=We("sessionTurns.currentProjectRunning"),!1;const R=typeof t.buildPrompt=="function"?await t.buildPrompt():t.prompt,J=typeof t.buildPromptBlocks=="function"?await t.buildPromptBlocks():[],fe=si({prompt:R,promptBlocks:J});if(fe.reason){const Pe=fe.reason==="unsupported_blocks"?We("sessionPanel.shellUnsupportedBlocks"):We("sessionPanel.shellEmptyCommand");return p.value=Pe,y==null||y({message:Pe,type:"warning"}),!1}if(!String(R||"").trim())return p.value=We("sessionTurns.noPromptToSend"),!1;const _e=fp(xe),ge=typeof L=="function"?L(xe):null,Ie=String((ge==null?void 0:ge.engine)||"").trim();if(Ie&&!_e.some(Pe=>Pe.engine===Ie)){const Pe=We("sessionPanel.agentNotEnabled");return p.value=Pe,y==null||y({message:Pe,type:"warning"}),!1}const Ae=ge,Be=String(fe.mode==="shell"?d.value:(Ae==null?void 0:Ae.sessionRecordId)||d.value).trim(),Xe=await rl(t.taskSlug,{projectSessionId:d.value,sessionId:Be,displayEngine:Ie,prompt:fe.mode==="shell"?fe.prompt:R,promptBlocks:J,commandMode:fe.mode,command:fe.command});return v(Xe),typeof t.afterSend=="function"&&Promise.resolve(t.afterSend()).catch(Pe=>{console.error("[promptx] afterSend failed",Pe)}),f||(ne(),Promise.all([P({force:!0}),I({force:!0})]).catch(Pe=>{p.value=Pe.message})),!0}catch(xe){return p.value=xe.message,!1}}async function tt(){if(!(!m.value||c.value))try{c.value=!0,await il(m.value),f||(ne(),await Promise.all([P({force:!0}),I({force:!0})]))}catch(xe){c.value=!1,p.value=xe.message}}return{closeManager:_,handleCreateSession:He,handleDeleteSession:Fe,handleResetSession:je,handleSelectSession:H,handleSend:Ke,handleUpdateSession:De,hasPrompt:A,helperText:pe,loadSessions:I,loadSessionResources:le,loadWorkspaces:Q,openManager:ve,refreshSessionsForSelection:F,sortedSessions:ce,stopSending:tt}}function fp(e={}){return Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length?e.agentBindings:e!=null&&e.id?[{engine:pp(e.engine),sessionRecordId:e.id,sessionId:e.sessionId||"",isDefault:!0,running:!!e.running,started:!!e.started}]:[]}function pp(e=""){const t=String(e||"").trim().toLowerCase();return t==="claude"||t==="claudecode"?"claude-code":t==="opencode"||t==="open-code"?"opencode":t==="claude-code"?"claude-code":"codex"}function mp(e={}){const{transcriptRef:t,hasNewerMessages:n,threshold:o=48}=e;let s=0,r=[],l=!1,c=!1,p=0,S=!0;function d(){if(typeof window>"u"||!r.length){r=[];return}r.forEach(ce=>{window.cancelAnimationFrame(ce)}),r=[]}function m(){s+=1,d()}function f(ce){c=!!ce,(n==null?void 0:n.value)!==void 0&&(n.value=c)}function b(){l=!1,p+=1,S=!0,f(!1)}function v(ce=t==null?void 0:t.value){return ce?ce.scrollHeight-ce.scrollTop-ce.clientHeight<=o:!0}function P(){return S&&!l}function ne(){S&&!l&&f(!1)}function y(){if(S=v(),!S){m();return}ne()}function L(){p+=1,l=!0,m()}function O(){const ce=p+1;p=ce,at(()=>{ce===p&&requestAnimationFrame(()=>{ce===p&&(l=!1,S=v(),ne())})})}function z(){l=!0,m()}function U(){O()}function se(ce={}){const{force:pe=!1}=ce;pe&&b(),m();const I=s;at(()=>{if(!(t==null?void 0:t.value)||I!==s)return;if(!pe&&!P()){f(!0);return}const le=()=>{const ve=t==null?void 0:t.value;!ve||I!==s||(ve.scrollTop=ve.scrollHeight,S=!0,f(!1))};le(),r=[requestAnimationFrame(()=>{le(),r=[requestAnimationFrame(le)]})]})}function A(){se({force:!0})}function G(){p+=1,m()}return{cancelScheduledScrollToBottom:m,destroy:G,handleTranscriptScroll:y,handleTranscriptTouchEnd:U,handleTranscriptTouchMove:z,handleTranscriptTouchStart:L,isTranscriptNearBottom:v,resetAutoStickToBottom:b,scheduleScrollToBottom:se,scrollToBottom:A}}const gp=150,ha="promptx:session-panel:show-process";function hp(e){return!(e==="0"||e==="false")}function vp(){if(typeof window>"u")return!0;try{return hp(window.localStorage.getItem(ha))}catch{return!0}}function yp(e,t,n={}){const{preserveRunning:o=!1}=n;if(!(t!=null&&t.id))return e||null;const s={...e||{},...t};return(!Array.isArray(t==null?void 0:t.agentBindings)||!t.agentBindings.length)&&Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length&&(s.agentBindings=e.agentBindings),o&&(s.running=!!(e!=null&&e.running)),s}function Sp(e,t){const n=oa(),o=q([]),s=q([]),r=q(!1),l=q(!1),c=q(!1),p=q(!1),S=q(""),d=q([]),m=q(null),f=q(0),b=q(0),v=q(!1),P=q(""),ne=q(!1),y=q(vp()),L=typeof window<"u"&&typeof window.EventSource<"u";function O(re=""){const Le=typeof re=="object"&&re!==null?String(re.message||"").trim():String(re||"").trim();Le&&t("toast",typeof re=="object"&&re!==null?{...re,message:Le}:Le)}let z=null,U=null,se=null,A={sessions:!1,runs:!1};const G=W({get(){return String(e.selectedSessionId||"").trim()},set(re){t("selected-session-change",String(re||"").trim())}}),ce=W(()=>p.value?We("sessionPanel.stopping"):`${We("projectManager.running")} (${la(b.value)})`),pe=W(()=>o.value.find(re=>re.id===G.value)||null),I=W(()=>{var Le;if(Array.isArray((Le=pe.value)==null?void 0:Le.agentBindings)&&pe.value.agentBindings.length)return pe.value.agentBindings;const re=pe.value;return re!=null&&re.id?[{engine:re.engine,sessionRecordId:re.id,sessionId:re.sessionId||"",started:!!re.started,running:!!re.running,isDefault:!0}]:[]}),Q=W({get(){var Le,ot;const re=ao(e.selectedAgentEngine,I.value);return re||((Le=I.value.find(xt=>xt.isDefault))==null?void 0:Le.engine)||((ot=I.value[0])==null?void 0:ot.engine)||""},set(re){const Le=ao(re,I.value);Le&&t("update:selectedAgentEngine",Le)}}),le=W(()=>I.value.find(re=>re.engine===Q.value)||I.value[0]||null),{destroy:ie,handleTranscriptScroll:ve,handleTranscriptTouchEnd:_,handleTranscriptTouchMove:H,handleTranscriptTouchStart:F,resetAutoStickToBottom:He,scheduleScrollToBottom:De,scrollToBottom:Fe}=mp({transcriptRef:m,hasNewerMessages:ne});function je(re,Le,ot={}){return yp(re,Le,ot)}function Ke(re,Le={}){if(!(re!=null&&re.id))return;const ot=[...o.value],xt=ot.findIndex(Et=>Et.id===re.id);xt>=0?ot[xt]=je(ot[xt],re,Le):ot.unshift(je(null,re,Le)),o.value=ot}const{applyCreatedRun:tt,applyIncomingRunEvent:xe,clearRealtimeReconcileTimer:R,clearRunPollTimer:J,clearTurns:fe,loadTurnEvents:_e,markFallbackSessionPollNow:ge,refreshRunHistory:Ie,resetRunHistoryState:Ae,updatePollingState:Be}=lp({props:e,turns:d,sessions:o,sending:c,sendingStartedAt:f,currentRunningRunId:P,sessionError:S,supportsServerEvents:L,scheduleScrollToBottom:De,resetAutoStickToBottom:He,showProcessLogs:y,mergeSessionRecord:je,mergeSession:Ke,loadSessions:(...re)=>dt(...re)}),{closeManager:Xe,handleCreateSession:Pe,handleDeleteSession:it,handleResetSession:Me,handleSelectSession:Ne,handleSend:Ee,handleUpdateSession:lt,helperText:ht,loadSessions:dt,loadSessionResources:wt,loadWorkspaces:Ct,openManager:T,refreshSessionsForSelection:j,sortedSessions:te,stopSending:ye}=dp({props:e,sessions:o,workspaces:s,loading:r,managerBusy:l,sending:c,stopping:p,sessionError:S,showManager:v,selectedSessionId:G,currentRunningRunId:P,supportsServerEvents:L,mergeSession:Ke,applyCreatedRun:tt,refreshRunHistory:Ie,markFallbackSessionPollNow:ge,showToast:O,getActiveAgentBinding:()=>le.value});function Oe(){z&&(window.clearInterval(z),z=null)}function Re(){Oe(),f.value||(f.value=Date.now()),b.value=Math.max(0,Math.floor((Date.now()-f.value)/1e3)),z=window.setInterval(()=>{b.value=Math.max(0,Math.floor((Date.now()-f.value)/1e3))},1e3)}function Ge(){se&&(window.clearTimeout(se),se=null)}function Ye(){Ge();const re=A;A={sessions:!1,runs:!1},re.sessions&&dt({force:!0}).catch(()=>{}),re.runs&&Ie({force:!0}).catch(()=>{})}function nt(re={}){typeof window>"u"||(A={sessions:A.sessions||!!re.sessions,runs:A.runs||!!re.runs},!(se||!A.sessions&&!A.runs)&&(se=window.setTimeout(()=>{Ye()},gp)))}function yt(re){return fa(re,{currentRunningRunId:P.value,runningElapsedSeconds:b.value,nowMs:Date.now()})}function st(re=""){if(!re)return"";const Le=new Date(re);return Number.isNaN(Le.getTime())?"":Le.toLocaleTimeString(Os(),{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ft(re){return re.status==="error"||re.status==="stop_timeout"?"theme-process-error":re.status==="interrupted"||re.status==="stopped"?"theme-process-stopped":re.status==="completed"?"theme-process-completed":"theme-process-running"}function _t(){y.value=!y.value}function Bt(re){return!!(re.responseMessage||re.errorMessage||re.status==="completed")}return $e(y,re=>{if(!(typeof window>"u"))try{window.localStorage.setItem(ha,re?"true":"false")}catch{}},{immediate:!0}),$e(c,re=>{re?(f.value||(f.value=Date.now()),Re()):(Oe(),f.value=0,b.value=0,p.value=!1),Be(),t("sending-change",re)},{immediate:!0}),$e(()=>!!e.taskRunning,re=>{!e.active||re||!c.value||nt({sessions:!0,runs:!0})}),$e(()=>e.active,re=>{if(re){wt({forceSessions:!0}).catch(()=>{});return}Ge(),R(),J()},{immediate:!0}),$e(()=>e.taskSlug,()=>{Ae(),v.value=!1,S.value="",e.active&&Ie({force:!0,scrollToLatest:!0}).catch(()=>{})},{immediate:!0}),$e(()=>{var re;return[((re=pe.value)==null?void 0:re.id)||"",I.value.map(Le=>Le.engine).join(","),e.selectedAgentEngine||""].join(`
39
+ `)},()=>{var pt,V,X;const re=String(((pt=pe.value)==null?void 0:pt.id)||"").trim(),Le=I.value,ot=Q.value;if(t("agent-bindings-change",{sessionId:re,bindings:Le,selectedEngine:ot}),!re||ao(e.selectedAgentEngine,Le))return;const Et=((V=Le.find(de=>de.isDefault))==null?void 0:V.engine)||((X=Le[0])==null?void 0:X.engine)||"";Et&&t("update:selectedAgentEngine",Et)},{immediate:!0}),It(()=>{Oe(),R(),J(),Ge(),ie(),U==null||U()}),$e(()=>n.readyVersion.value,()=>{const re=String(e.taskSlug||"").trim();!e.active&&!v.value||(v.value&&Ct().catch(()=>{}),nt({sessions:!0,runs:!!re}))}),$e(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!v.value||nt({sessions:!0})}),$e(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||nt({sessions:!0,runs:!0})}),$e(()=>String(e.taskSlug||"").trim(),re=>{U==null||U(),U=null,re&&(U=Cf(re,({runId:Le,event:ot})=>{if(!e.active)return;xe(Le,ot)||nt({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:le,activeAgentEngine:Q,clearTurns:fe,closeManager:Xe,formatTurnTime:st,getProcessCardClass:ft,getProcessStatus:Qf,getTurnAgentLabel:Lt,getTurnSummaryDetail:ma,getDisplayTurnSummaryItems:yt,getTurnSummaryStatus:pa,handleCreateSession:Pe,handleDeleteSession:it,handleResetSession:Me,handleSelectSession:Ne,handleSend:Ee,handleUpdateSession:lt,loadTurnEvents:_e,hasTurnSummary:Xf,helperText:ht,loading:r,managerBusy:l,openManager:T,refreshSessionsForSelection:j,selectedSessionId:G,sending:c,showProcessLogs:y,stopping:p,sessionError:S,shouldShowResponse:Bt,showManager:v,sortedSessions:te,stopSending:ye,toggleProcessLogs:_t,hasNewerMessages:ne,transcriptRef:m,turns:d,workspaces:s,workingLabel:ce,sessions:o,loadSessions:dt,currentProjectAgentBindings:I,handleTranscriptScroll:ve,handleTranscriptTouchEnd:_,handleTranscriptTouchMove:H,handleTranscriptTouchStart:F,scheduleScrollToBottom:De,scrollToBottom:Fe}}function ao(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const wp=8,xp=320,bp=10,kp=400;function ir(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function _p(e={}){const{turns:t,loadTurnEvents:n}=e,o=q({}),s=q({}),r=q({});function l(A){return String((A==null?void 0:A.runId)||(A==null?void 0:A.id)||"").trim()}function c(A){const G=l(A);return!!G&&G===l(t.value.at(-1))}function p(A){return Math.max(0,Number(A==null?void 0:A.eventCount)||0,Array.isArray(A==null?void 0:A.events)?A.events.length:0)}function S(A){return!ns(A==null?void 0:A.status)&&!c(A)&&p(A)>3}function d(A){return ir(A==null?void 0:A.prompt,wp,xp)}function m(A){return!ns(A==null?void 0:A.status)&&!c(A)&&d(A)}function f(A){return String((A==null?void 0:A.errorMessage)||(A==null?void 0:A.responseMessage)||"")}function b(A){return ir(f(A),bp,kp)}function v(A){return!(A!=null&&A.errorMessage)&&!c(A)&&b(A)}function P(A){return p(A)>0}function ne(A=[]){const G=new Set((A||[]).map(I=>l(I)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([I])=>G.has(I))),s.value=Object.fromEntries(Object.entries(s.value).filter(([I])=>G.has(I))),r.value=Object.fromEntries(Object.entries(r.value).filter(([I])=>G.has(I)));const ce=(A||[]).at(-1)||null,pe=l(ce);pe&&(Object.prototype.hasOwnProperty.call(o.value,pe)||(o.value={...o.value,[pe]:!1}),Object.prototype.hasOwnProperty.call(s.value,pe)||(s.value={...s.value,[pe]:!1}),Object.prototype.hasOwnProperty.call(r.value,pe)||(r.value={...r.value,[pe]:!1}))}function y(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(o.value,G)?!!o.value[G]:S(A):!1}async function L(A){const G=l(A);if(!G)return;const ce=!y(A);o.value={...o.value,[G]:ce},!ce&&P(A)&&!A.eventsLoaded&&!A.eventsLoading&&await n(A).catch(()=>{})}function O(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(s.value,G)?!!s.value[G]:m(A):!1}function z(A){const G=l(A);!G||!d(A)||(s.value={...s.value,[G]:!O(A)})}function U(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(r.value,G)?!!r.value[G]:v(A):!1}function se(A){const G=l(A);!G||!b(A)||(r.value={...r.value,[G]:!U(A)})}return $e(t,A=>{ne(A)},{immediate:!0,deep:!0}),{canCollapsePrompt:d,canCollapseResponse:b,getTurnEventCollapseKey:l,getTurnEventCount:p,hasTurnEventHistory:P,isLatestTurn:c,isPromptCollapsed:O,isResponseCollapsed:U,isTurnEventsCollapsed:y,togglePrompt:z,toggleResponse:se,toggleTurnEvents:L}}function Tp(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function Cp(e=[]){const t=e.map(n=>({label:String((n==null?void 0:n.label)||"").trim(),value:String((n==null?void 0:n.value)||"").trim()})).filter(n=>n.label&&n.value);return t.length?{type:"meta",items:t}:null}function Ep(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function io(e="",t=0){const n=Math.max(1,Number(t)||0);return e==="read"?`连续读取 ${n} 项`:e==="grep"?`连续检索 ${n} 次`:e==="list"?`连续列出 ${n} 处`:e==="web"?`连续网页检索 ${n} 次`:e==="todo"?"待办列表":e==="reasoning"?"思考过程":`连续处理 ${n} 项`}function lo(e="",t=[],n=[]){var l;const o=Tp(t.map(c=>c.groupTarget)),s=[];if(e==="todo"){const c=[...n].reverse().flatMap(p=>Array.isArray(p==null?void 0:p.detailBlocks)?p.detailBlocks:[]).find(p=>(p==null?void 0:p.type)==="checklist");return c?[c]:[]}if(e==="reasoning"){const c=[...t].reverse().find(p=>Array.isArray(p==null?void 0:p.detailBlocks)&&p.detailBlocks.length);return(l=c==null?void 0:c.detailBlocks)!=null&&l.length?c.detailBlocks:[]}const r=Cp([{label:"类型",value:Ep(e)},{label:"次数",value:String(t.length)}]);return r&&s.push(r),o.length&&s.push({type:"bullet_list",items:o.slice(0,8),totalCount:o.length,hiddenCount:Math.max(0,o.length-8)}),s}function va(e=[]){if(!e.length)return[];const[t]=e,n=String(t.groupType||"").trim();if(!n)return e;if(n==="reasoning"){if(e.length===1)return e;const s=e[e.length-1];return[{...s,id:`${s.id}-group`,title:io(n,e.length),detail:"",detailBlocks:lo(n,e,e),isGrouped:!0,groupedCount:e.length}]}const o=e.filter(s=>s.phase==="completed"||s.phase==="updated"||s.kind==="error");if(!o.length)return[e[e.length-1]];if(n==="todo"){if(e.length===1)return e;const s=o[o.length-1];return[{...s,id:`${s.id}-group`,title:io(n,e.length),detail:"",detailBlocks:lo(n,e,o),isGrouped:!0,groupedCount:e.length}]}return o.length===1&&e.length<=2?[o[0]]:[{...o[o.length-1],id:`${o[o.length-1].id}-group`,title:io(n,o.length),detail:"",detailBlocks:lo(n,o,o),isGrouped:!0,groupedCount:o.length}]}function Ap(e=[]){const t=Array.isArray(e)?e:[],n=t.filter(r=>String((r==null?void 0:r.groupType)||"").trim()==="todo");if(n.length<=1)return t;const[o]=va(n);if(!o)return t;const s=t.reduce((r,l,c)=>String((l==null?void 0:l.groupType)||"").trim()==="todo"?c:r,-1);return s<0?t:t.flatMap((r,l)=>String((r==null?void 0:r.groupType)||"").trim()!=="todo"?[r]:l===s?[o]:[])}function $p(e=[]){var o;const t=Ap(Array.isArray(e)?e.filter(Boolean):[]),n=[];for(let s=0;s<t.length;s+=1){const r=t[s],l=String((r==null?void 0:r.groupType)||"").trim();if(!l){n.push(r);continue}const c=[r];for(;s+1<t.length&&String(((o=t[s+1])==null?void 0:o.groupType)||"").trim()===l;)c.push(t[s+1]),s+=1;n.push(...va(c))}return n}const Ip={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},Pp={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},Dp={class:"flex flex-col gap-2"},Lp={class:"flex items-center gap-2"},Bp=["title"],Mp={class:"flex shrink-0 items-center gap-1.5"},Rp=["aria-pressed","aria-label","title"],Np=["disabled"],Op={class:"hidden sm:inline"},jp=["disabled"],Fp={class:"hidden sm:inline"},Up=["aria-label"],Vp=["aria-pressed"],zp=["aria-pressed","title","onClick"],Hp={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},qp={class:"min-h-0 flex-1"},Kp={key:0,class:"theme-empty-state px-4 py-6 text-sm"},Wp={key:1,class:"theme-empty-state px-4 py-6 text-sm"},Gp=["data-turn-id","data-run-id"],Xp={class:"flex justify-end"},Yp={class:"transcript-card transcript-card--prompt min-w-0 w-full rounded-sm bg-[var(--theme-promptBg)] px-4 py-3 font-mono text-sm text-[var(--theme-promptText)]"},Jp={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},Qp={class:"font-semibold"},Zp={class:"flex items-center gap-2"},em=["onClick"],tm={class:"relative mt-2"},nm={key:0,class:"space-y-3"},sm={key:0,class:"whitespace-pre-wrap break-words leading-7"},om=["onClick"],rm=["src","alt"],am={key:1,class:"whitespace-pre-wrap break-words leading-7"},im={key:0,class:"flex min-w-0 justify-start"},lm={class:"flex items-center justify-between gap-3 text-xs"},um={class:"font-semibold"},cm={class:"flex items-center gap-2"},dm=["disabled","onClick"],fm={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},pm={key:1,class:"mt-2 min-w-0 space-y-2"},mm={class:"text-sm font-medium leading-6"},gm={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},hm={key:3,class:"mt-2 text-xs text-current"},vm={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},ym={key:0,class:"leading-5"},Sm={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},wm={key:2,class:"mt-2 flex flex-wrap gap-2"},xm={class:"font-medium"},bm={key:1,class:"flex justify-start"},km={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},_m={class:"font-semibold"},Tm={class:"flex items-center gap-2"},Cm=["onClick"],Em=["onClick"],Am={class:"relative mt-2"},$m={key:0,class:"whitespace-pre-wrap break-words"},Im=["innerHTML"],Pm={class:"pointer-events-none absolute bottom-1 right-1 z-10 flex flex-col items-end gap-1.5 sm:bottom-3 sm:right-3"},Dm=["disabled"],Lm={key:2,class:"task-loading-dots","aria-hidden":"true"},Bm={__name:"CodexSessionPanel",props:{prompt:{type:String,default:""},buildPrompt:{type:Function,default:null},buildPromptBlocks:{type:Function,default:null},beforeSend:{type:Function,default:null},afterSend:{type:Function,default:null},taskSlug:{type:String,default:""},selectedSessionId:{type:String,default:""},selectedAgentEngine:{type:String,default:""},active:{type:Boolean,default:!1},sessionSelectionLocked:{type:Boolean,default:!1},sessionSelectionLockReason:{type:String,default:""},diffSupported:{type:Boolean,default:!1},taskRunning:{type:Boolean,default:!1}},emits:["agent-bindings-change","insert-code-context","project-created","selected-session-change","sending-change","open-diff","toast","update:selectedAgentEngine"],setup(e,{expose:t,emit:n}){const o=fo(()=>ze(()=>import("./CodexSessionManagerDialog-CCBswCOE.js"),__vite__mapDeps([34,35,2,3,36,37,38,39,40]))),s=n,r=e,{closeManager:l,formatTurnTime:c,getProcessCardClass:p,getProcessStatus:S,getTurnAgentLabel:d,getDisplayTurnSummaryItems:m,getTurnSummaryDetail:f,getTurnSummaryStatus:b,handleCreateSession:v,handleDeleteSession:P,handleResetSession:ne,handleSelectSession:y,handleSend:L,handleTranscriptScroll:O,handleTranscriptTouchEnd:z,handleTranscriptTouchMove:U,handleTranscriptTouchStart:se,handleUpdateSession:A,helperText:G,loadTurnEvents:ce,loading:pe,managerBusy:I,openManager:Q,refreshSessionsForSelection:le,selectedSessionId:ie,sending:ve,showProcessLogs:_,stopping:H,hasTurnSummary:F,hasNewerMessages:He,sessionError:De,shouldShowResponse:Fe,showManager:je,sortedSessions:Ke,stopSending:tt,toggleProcessLogs:xe,transcriptRef:R,turns:J,workspaces:fe,sessions:_e,loadSessions:ge,currentProjectAgentBindings:Ie,scheduleScrollToBottom:Ae,scrollToBottom:Be}=Sp(r,s),Xe=q(null),Pe=q(!1),it=q(""),Me=q(""),Ne=q("all"),{t:Ee}=St(),{isDark:lt}=kr(),ht=W(()=>lt.value?"dark":"light"),dt=W(()=>{const h=new Set;return(Array.isArray(Ie.value)?Ie.value:[]).filter(Y=>{const D=String((Y==null?void 0:Y.engine)||"").trim();return!D||h.has(D)?!1:(h.add(D),!0)})}),wt=W(()=>dt.value.length>1),Ct=W(()=>{const h=String(Ne.value||"").trim();return!wt.value||h==="all"?J.value:J.value.filter(Y=>da(Y)===h)}),{selectionAction:T,clearSelectionState:j,handleSelectionMouseUp:te}=Yr({getContainer:()=>R.value,isActive:()=>!!(r.active&&J.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:h=>[...h.querySelectorAll("[data-response-selection-root]")],getCodeLeft:h=>{var Y,D;return((D=(Y=h==null?void 0:h.getBoundingClientRect)==null?void 0:Y.call(h))==null?void 0:D.left)||0},debounceMs:72});$e([Ne,()=>dt.value.map(h=>h.engine).join(`
40
40
  `)],()=>{Ne.value!=="all"&&(dt.value.some(h=>h.engine===Ne.value)||(Ne.value="all"))},{immediate:!0}),$e(Ne,()=>{j({clearBrowserSelection:!0}),Ae({force:!0})});function ye(h={}){if((h==null?void 0:h.kind)==="reasoning")return!0;const Y=String((h==null?void 0:h.title)||"").trim();return Y?[/^已连接项目:/,/^工作目录:/,/^项目会话已更新$/,/^Codex 会话已创建$/,/^Claude Code 会话已创建$/,/^OpenCode 会话已创建$/,/^事件: claude\.system$/,/^线程 ID:/,/^Thread ID:/,/^Connected project:/,/^Working directory:/,/^Project session updated$/,/ session created$/,/^Event: claude\.system$/,/ 已返回结果$/,/ returned a result$/,/^本轮执行结束$/,/^Run finished$/].some(D=>D.test(Y)):!1}function Oe(h={}){return Ee("sessionPanel.promptTitleWithAgent",{agent:d(h)})}function Re(h={}){return h.errorMessage?Ee("sessionPanel.errorSuffix",{agent:d(h)}):Ee("sessionPanel.responseSuffix",{agent:d(h)})}const{getTurnEventCount:Ge,hasTurnEventHistory:Ye,isTurnEventsCollapsed:nt,toggleTurnEvents:yt}=_p({turns:J,loadTurnEvents:ce});function st(h){return String((h==null?void 0:h.runId)||(h==null?void 0:h.id)||"").trim()}function ft(h){h!=null&&h.runId&&s("open-diff",{scope:"run",runId:h.runId})}function _t(){s("open-diff",{scope:"workspace",runId:""})}const{getRenderedHtml:Bt}=pf({items:J,themeKey:ht,getCacheKey:st,getSource:h=>String((h==null?void 0:h.responseMessage)||""),shouldRender:h=>!!(h!=null&&h.responseMessage)&&!(h!=null&&h.errorMessage),renderAsync:h=>ac(h,{isDark:lt.value,copyLabel:Ee("sessionPanel.copyCode"),copyAriaLabel:Ee("sessionPanel.copyCodeAria")}),renderFallback:h=>Wr(h),onRendered:h=>{const Y=J.value.at(-1)||null;!r.active||!(Y!=null&&Y.runId)||Y.runId!==(h==null?void 0:h.runId)||Ae()}});function re(h){Me.value=String(h||"").trim()}async function Le(h){var D;if((D=navigator.clipboard)!=null&&D.writeText&&window.isSecureContext){await navigator.clipboard.writeText(h);return}const Y=document.createElement("textarea");Y.value=h,Y.setAttribute("readonly","true"),Y.style.position="fixed",Y.style.opacity="0",Y.style.pointerEvents="none",document.body.appendChild(Y),Y.select(),document.execCommand("copy"),document.body.removeChild(Y)}function ot(h={}){const D=(Array.isArray(h==null?void 0:h.promptBlocks)?h.promptBlocks:[]).filter(be=>(be==null?void 0:be.type)==="text"||(be==null?void 0:be.type)==="imported_text").map(be=>String((be==null?void 0:be.content)||"").replace(/\u200b/g,"").trim()).filter(Boolean).join(`
41
41
 
42
- `);return D||String((h==null?void 0:h.prompt)||"").replace(/\u200b/g,"").trim()}function xt(h={}){const Y=ot(h);Y&&s("insert-code-context",{source:"response",content:Y})}async function Et(h){var jt,Ft,Ut,Pt,mt;const Y=(Ft=(jt=h==null?void 0:h.target)==null?void 0:jt.closest)==null?void 0:Ft.call(jt,'[data-copy-code="1"]');if(!Y)return;const D=Y.closest(".codex-code-block"),be=(Ut=D==null?void 0:D.querySelector)==null?void 0:Ut.call(D,"pre code"),Mt=String((be==null?void 0:be.textContent)||"").replace(/\u200b/g,"");if(Mt){(Pt=h.preventDefault)==null||Pt.call(h),(mt=h.stopPropagation)==null||mt.call(h);try{await Le(Mt),s("toast",{message:Ee("sessionPanel.codeCopied"),type:"success"})}catch{s("toast",{message:Ee("errors.requestFailed"),type:"warning"})}}}function pt(){if(!T.value.visible)return;const h=String(T.value.content||"").replace(/\u200b/g,"").trim();if(!h){j({clearBrowserSelection:!0});return}s("insert-code-context",{source:"response",content:h}),j({clearBrowserSelection:!0})}function V(h={}){if(h!=null&&h.errorMessage)return;const Y=String((h==null?void 0:h.responseMessage)||"").replace(/\u200b/g,"").trim();Y&&s("insert-code-context",{source:"response",content:Y})}const X=W(()=>J.value.flatMap(h=>(Array.isArray(h==null?void 0:h.promptBlocks)?h.promptBlocks:[]).filter(Y=>(Y==null?void 0:Y.type)==="image").map(Y=>Y.content)));function de(h){const D=(Array.isArray(h==null?void 0:h.events)?h.events:[]).filter(be=>!ye(be));return $p(D)}function he(h){return Ge(h)}function Ue(h){return h!=null&&h.eventsLoaded?he(h)>0:Ye(h)}function Tt(h){return!!(h!=null&&h.eventsLoading)}function qt(h){return!!(h!=null&&h.eventsLoaded)&&de(h).length>0&&!nt(h)}function At(h){return!!(h!=null&&h.eventsLoaded)&&he(h)>0&&nt(h)}function Ot(h){return Ye(h)&&!(h!=null&&h.eventsLoaded)&&!(h!=null&&h.eventsLoading)}function Qt(h={}){return Nr(h,{defaultLabel:Ee("sessionPanel.defaultAgent")})}function nn(h={}){return!Kf(h)}function E(h={}){return"bg-[var(--theme-appPanelStrong)]"}function k(h=null){const Y=String((h==null?void 0:h.id)||"").trim();if(Y)return _e.value.find(be=>be.id===Y)||null;const D=String(ie.value||"").trim();return D?_e.value.find(be=>be.id===D)||null:Ke.value[0]||null}function K(h=null){const Y=k(h);return Y!=null&&Y.cwd?(it.value=Y.id,Pe.value=!0,!0):!1}function ae(){return I.value?!1:(Q(),!0)}function ee(){var h,Y;return Pe.value?(Pe.value=!1,!0):(Y=(h=Xe.value)==null?void 0:h.closeTopDialog)!=null&&Y.call(h)?!0:je.value?(l(),!0):!1}return t({closeTopDialog:ee,openProjectManager:ae,openSourceBrowser:K,send:L,scrollToBottom:Be,stop:tt}),(h,Y)=>(g(),x("section",Ip,[ue(ff,{open:Pe.value,session:a(_e).find(D=>D.id===it.value)||null,onInsertCodeContext:Y[0]||(Y[0]=D=>s("insert-code-context",D)),onClose:Y[1]||(Y[1]=D=>Pe.value=!1)},null,8,["open","session"]),ue(a(o),{ref_key:"managerDialogRef",ref:Xe,open:a(je),sessions:a(_e),workspaces:a(fe),"selected-session-id":a(ie),"selection-locked":e.sessionSelectionLocked,"selection-lock-reason":e.sessionSelectionLockReason,loading:a(pe),sending:a(ve),"on-refresh":a(ge),"on-create":a(v),"on-update":a(A),"on-delete":a(P),"on-reset":a(ne),onClose:a(l),onOpenSourceBrowser:Y[2]||(Y[2]=D=>K(D)),onProjectCreated:Y[3]||(Y[3]=D=>s("project-created",D)),onSelectSession:a(y)},null,8,["open","sessions","workspaces","selected-session-id","selection-locked","selection-lock-reason","loading","sending","on-refresh","on-create","on-update","on-delete","on-reset","onClose","onSelectSession"]),i("div",Pp,[i("div",Dp,[i("div",Lp,[i("div",{class:"min-w-0 flex-1",title:a(G)||""},[ue(Vu,{modelValue:a(ie),"onUpdate:modelValue":Y[4]||(Y[4]=D=>_a(ie)?ie.value=D:null),sessions:a(Ke),loading:a(pe),disabled:a(ve)||a(I)||e.sessionSelectionLocked,onRefreshIntent:a(le)},null,8,["modelValue","sessions","loading","disabled","onRefreshIntent"])],8,Bp),i("div",Mp,[i("button",{type:"button",class:Se(["tool-button inline-flex h-9 w-9 items-center justify-center whitespace-nowrap px-0 py-0 text-xs",a(_)?"tool-button-accent-subtle":""]),"aria-pressed":a(_)?"true":"false","aria-label":a(_)?a(Ee)("sessionPanel.hideProcessToggle"):a(Ee)("sessionPanel.showProcessToggle"),title:a(_)?a(Ee)("sessionPanel.hideProcessToggle"):a(Ee)("sessionPanel.showProcessToggle"),onClick:Y[5]||(Y[5]=(...D)=>a(xe)&&a(xe)(...D))},[a(_)?(g(),Ce(a(Da),{key:0,class:"h-4 w-4"})):(g(),Ce(a(La),{key:1,class:"h-4 w-4"}))],10,Rp),e.diffSupported?(g(),x("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-1.5 whitespace-nowrap px-2.5 py-2 text-xs sm:gap-2 sm:px-3",disabled:!e.taskSlug,onClick:_t},[ue(a(Uo),{class:"h-4 w-4"}),Y[17]||(Y[17]=i("span",{class:"sm:hidden"},"代码",-1)),i("span",Op,S(a(Ee)("sessionPanel.diff")),1)],8,Np)):me("",!0),i("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 whitespace-nowrap px-2.5 py-2 text-xs sm:gap-2 sm:px-3",disabled:a(I),onClick:Y[6]||(Y[6]=(...D)=>a(Q)&&a(Q)(...D))},[ue(a(Zn),{class:"h-4 w-4"}),Y[18]||(Y[18]=i("span",{class:"sm:hidden"},"项目",-1)),i("span",Fp,S(a(Ee)("sessionPanel.manageProjects")),1)],8,jp)])]),wt.value?(g(),x("div",{key:0,class:"flex max-w-full items-center gap-1.5 overflow-x-auto pb-0.5","aria-label":a(Ee)("sessionPanel.agentFilter")},[i("button",{type:"button",class:Se(["theme-agent-selector-button",Ne.value==="all"?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Ne.value==="all"?"true":"false",onClick:Y[7]||(Y[7]=D=>Ne.value="all")},S(a(Ee)("sessionPanel.allAgents")),11,Vp),(g(!0),x(et,null,ut(dt.value,D=>(g(),x("button",{key:D.engine,type:"button",class:Se(["theme-agent-selector-button",Ne.value===D.engine?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Ne.value===D.engine?"true":"false",title:Qt(D),onClick:be=>Ne.value=D.engine},S(Qt(D)),11,zp))),128))],8,Up)):me("",!0),a(De)?(g(),x("p",Hp,[ue(a(_o),{class:"h-4 w-4"}),i("span",null,S(a(De)),1)])):me("",!0)])]),i("div",qp,[i("div",{ref_key:"transcriptRef",ref:R,"data-promptx-transcript":"1",class:"workbench-transcript relative flex h-full flex-col gap-3 overflow-x-hidden overflow-y-auto px-4 py-4",onScroll:Y[9]||(Y[9]=(...D)=>a(O)&&a(O)(...D)),onTouchstartPassive:Y[10]||(Y[10]=(...D)=>a(se)&&a(se)(...D)),onTouchmovePassive:Y[11]||(Y[11]=(...D)=>a(U)&&a(U)(...D)),onTouchendPassive:Y[12]||(Y[12]=(...D)=>a(z)&&a(z)(...D)),onTouchcancelPassive:Y[13]||(Y[13]=(...D)=>a(z)&&a(z)(...D))},[a(J).length?Ct.value.length?me("",!0):(g(),x("div",Wp,S(a(Ee)("sessionPanel.emptyAgentFilter")),1)):(g(),x("div",Kp,S(a(Ee)("sessionPanel.empty")),1)),(g(!0),x(et,null,ut(Ct.value,D=>(g(),x("div",{key:D.id,"data-promptx-turn":"1","data-turn-id":D.id,"data-run-id":D.runId||"",class:"flex min-w-0 flex-col gap-3"},[i("div",Xp,[i("div",Yp,[i("div",Jp,[i("span",Qp,S(Oe(D)),1),i("div",Zp,[ot(D)?(g(),x("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:be=>xt(D)},[ue(a(Ps),{class:"h-3 w-3"}),i("span",null,S(a(Ee)("sessionPanel.insert")),1)],8,em)):me("",!0),i("span",null,S(a(c)(D.startedAt)),1)])]),i("div",tm,[Array.isArray(D.promptBlocks)&&D.promptBlocks.length?(g(),x("div",nm,[(g(!0),x(et,null,ut(D.promptBlocks,(be,Mt)=>(g(),x(et,{key:`${D.id}-prompt-${Mt}`},[be.type==="text"||be.type==="imported_text"?(g(),x("pre",sm,S(be.content),1)):(g(),x("button",{key:1,type:"button",class:"inline-flex cursor-zoom-in justify-center rounded-sm",onClick:jt=>re(be.content)},[i("img",{src:be.content,alt:a(Ee)("sessionPanel.promptImageAlt"),class:"max-h-52 w-auto max-w-full rounded-sm object-contain shadow-sm"},null,8,rm)],8,om))],64))),128))])):(g(),x("pre",am,S(D.prompt),1))])])]),a(_)&&nn(D)?(g(),x("div",im,[i("div",{class:Se(["transcript-card transcript-card--process min-w-0 w-full rounded-sm px-4 py-3",a(p)(D)])},[i("div",lm,[i("span",um,S(a(Ee)("sessionPanel.processTitle")),1),i("div",cm,[Ue(D)?(g(),x("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",disabled:D.eventsLoading,onClick:be=>a(yt)(D)},[Tt(D)?(g(),Ce(a(Ht),{key:0,class:"h-3 w-3 animate-spin"})):a(nt)(D)?(g(),Ce(a(ko),{key:1,class:"h-3 w-3"})):(g(),Ce(a(Ba),{key:2,class:"h-3 w-3"})),i("span",null,S(D.eventsLoading?a(Ee)("sessionPanel.loading"):a(nt)(D)?`${a(Ee)("sessionPanel.expand")} (${he(D)})`:a(Ee)("sessionPanel.collapse")),1)],8,dm)):me("",!0),i("span",null,S(a(w)(D)),1)])]),Tt(D)?(g(),x("div",fm,S(a(Ee)("sessionPanel.loadingEvents")),1)):qt(D)?(g(),x("div",pm,[(g(!0),x(et,null,ut(de(D),be=>(g(),x("div",{key:be.id,class:Se(["transcript-event-card min-w-0 rounded-sm px-3 py-2",E(be)])},[i("div",mm,S(be.title),1),be.detail||Array.isArray(be.detailBlocks)&&be.detailBlocks.length?(g(),Ce(zc,{key:0,detail:be.detail,blocks:be.detailBlocks,kind:be.kind,class:"mt-2"},null,8,["detail","blocks","kind"])):me("",!0)],2))),128))])):At(D)||Ot(D)?(g(),x("div",gm,S(D.eventsLoaded?a(Ee)("sessionPanel.hiddenEventsLoaded",{count:he(D)}):a(Ee)("sessionPanel.hiddenEventsLoadLater",{count:he(D)})),1)):(g(),x("p",hm,S(["queued","starting","running","stopping"].includes(D.status)?a(Ee)("sessionPanel.waitingEvents",{agent:a(d)(D)}):a(Ee)("sessionPanel.noEvents")),1)),a(F)(D)?(g(),x("div",vm,[a(b)(D)?(g(),x("div",ym,S(a(b)(D)),1)):me("",!0),a(f)(D)?(g(),x("div",Sm,S(a(f)(D)),1)):me("",!0),a(m)(D).length?(g(),x("div",wm,[(g(!0),x(et,null,ut(a(m)(D),be=>(g(),x("span",{key:be.key,class:"transcript-card__pill inline-flex items-center gap-1 rounded-sm border border-dashed border-[var(--theme-borderDefault)] px-2 py-1"},[i("span",null,S(be.label),1),i("span",xm,S(be.value),1)]))),128))])):me("",!0)])):me("",!0)],2)])):me("",!0),a(Fe)(D)?(g(),x("div",bm,[i("div",{class:Se(["transcript-card transcript-card--response min-w-0 w-full rounded-sm px-4 py-3 text-sm leading-7",D.errorMessage?"bg-[var(--theme-dangerSoft)] text-[var(--theme-dangerText)]":"bg-[var(--theme-responseBg)] text-[var(--theme-responseText)]"])},[i("div",km,[i("span",_m,S(Re(D)),1),i("div",Tm,[e.diffSupported&&D.runId?(g(),x("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:be=>ft(D)},[ue(a(Uo),{class:"h-3 w-3"}),i("span",null,S(a(Ee)("sessionPanel.view")),1)],8,Cm)):me("",!0),D.responseMessage&&!D.errorMessage?(g(),x("button",{key:1,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:be=>V(D)},[ue(a(Ps),{class:"h-3 w-3"}),i("span",null,S(a(Ee)("sessionPanel.insert")),1)],8,Em)):me("",!0),i("span",null,S(a(c)(D.finishedAt||D.startedAt)),1)])]),i("div",Am,[D.errorMessage?(g(),x("div",$m,S(D.errorMessage),1)):(g(),x("div",{key:1,class:"prose-like codex-markdown","data-response-selection-root":"1",onMouseup:Y[8]||(Y[8]=(...be)=>a(te)&&a(te)(...be)),onClick:Et,innerHTML:a(Bt)(D)},null,40,Im))])],2)])):me("",!0)],8,Gp))),128)),a(T).visible?(g(),Ce(Gr,{key:2,top:a(T).top,left:a(T).left,label:a(Ee)("sourceBrowser.insertSelection"),onClick:pt},null,8,["top","left","label"])):me("",!0)],544),i("div",Pm,[a(He)?(g(),x("button",{key:0,type:"button",class:Se([a(ve)?"mb-10 sm:mb-8":"","tool-button pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur"]),onClick:Y[14]||(Y[14]=(...D)=>a(Be)&&a(Be)(...D))},[ue(a(Ma),{class:"h-3.5 w-3.5"}),i("span",null,S(a(Ee)("sessionPanel.jumpToLatest")),1)],2)):me("",!0),a(ve)?(g(),x("button",{key:1,type:"button",class:"tool-button tool-button-warning-subtle pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur",disabled:a(H),onClick:Y[15]||(Y[15]=(...D)=>a(tt)&&a(tt)(...D))},[a(H)?(g(),Ce(a(Ht),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),Ce(a(Ra),{key:1,class:"h-3.5 w-3.5"})),i("span",null,S(a(H)?a(Ee)("sessionPanel.stopping"):a(Ee)("sessionPanel.stop")),1),a(H)?me("",!0):(g(),x("span",Lm,[...Y[19]||(Y[19]=[i("span",{class:"task-loading-dots__dot"},null,-1),i("span",{class:"task-loading-dots__dot"},null,-1),i("span",{class:"task-loading-dots__dot"},null,-1)])]))],8,Dm)):me("",!0)])]),ue(Or,{modelValue:Me.value,"onUpdate:modelValue":Y[16]||(Y[16]=D=>Me.value=D),images:X.value},null,8,["modelValue","images"])]))}},Mm={key:0,class:"h-full min-h-0"},Rm={key:1,class:"panel theme-muted-text flex h-full items-center px-5 py-4 text-sm"},lr={__name:"WorkbenchActivityPanel",props:{taskSlug:{type:String,default:""},buildPrompt:{type:Function,default:null},buildPromptBlocks:{type:Function,default:null},selectedSessionId:{type:String,default:""},selectedAgentEngine:{type:String,default:""},sessionSelectionLocked:{type:Boolean,default:!1},sessionSelectionLockReason:{type:String,default:""},diffSupported:{type:Boolean,default:!1},taskRunning:{type:Boolean,default:!1},emptyMessage:{type:String,default:""}},emits:["agent-bindings-change","insert-code-context","sending-change","project-created","selected-session-change","open-diff","toast","update:selectedAgentEngine"],setup(e,{expose:t,emit:n}){const o=n,s=q(null);function r(){var m,f;return(f=(m=s.value)==null?void 0:m.send)==null?void 0:f.call(m)}function l(){var m,f;(f=(m=s.value)==null?void 0:m.stop)==null||f.call(m)}function c(){var m,f;(f=(m=s.value)==null?void 0:m.scrollToBottom)==null||f.call(m)}function p(){var m,f;return((f=(m=s.value)==null?void 0:m.openProjectManager)==null?void 0:f.call(m))||!1}function w(){var m,f;return((f=(m=s.value)==null?void 0:m.openSourceBrowser)==null?void 0:f.call(m))||!1}function d(){var m,f;return((f=(m=s.value)==null?void 0:m.closeTopDialog)==null?void 0:f.call(m))||!1}return t({closeTopDialog:d,openProjectManager:p,openSourceBrowser:w,send:r,stop:l,scrollToBottom:c}),(m,f)=>e.taskSlug?(g(),x("div",Mm,[ue(Bm,{ref_key:"panelRef",ref:s,active:!!e.taskSlug,"task-slug":e.taskSlug,"build-prompt":e.buildPrompt||(()=>""),"build-prompt-blocks":e.buildPromptBlocks||(()=>[]),"selected-session-id":e.selectedSessionId,"selected-agent-engine":e.selectedAgentEngine,"session-selection-locked":e.sessionSelectionLocked,"session-selection-lock-reason":e.sessionSelectionLockReason,"diff-supported":e.diffSupported,"task-running":e.taskRunning,onAgentBindingsChange:f[0]||(f[0]=b=>o("agent-bindings-change",b)),onInsertCodeContext:f[1]||(f[1]=b=>o("insert-code-context",b)),onProjectCreated:f[2]||(f[2]=b=>o("project-created",b)),onSendingChange:f[3]||(f[3]=b=>o("sending-change",b)),onSelectedSessionChange:f[4]||(f[4]=b=>o("selected-session-change",b)),"onUpdate:selectedAgentEngine":f[5]||(f[5]=b=>o("update:selectedAgentEngine",b)),onOpenDiff:f[6]||(f[6]=b=>o("open-diff",b)),onToast:f[7]||(f[7]=b=>o("toast",b))},null,8,["active","task-slug","build-prompt","build-prompt-blocks","selected-session-id","selected-agent-engine","session-selection-locked","session-selection-lock-reason","diff-supported","task-running"])])):e.emptyMessage?(g(),x("section",Rm,S(e.emptyMessage),1)):me("",!0)}},Nm=["title"],Om={class:"flex min-w-0 items-center gap-1.5"},jm=["aria-pressed","title","data-agent-engine","onClick"],ur={__name:"WorkbenchAgentSelector",props:{agentBindings:{type:Array,default:()=>[]},selectedAgentEngine:{type:String,default:""},align:{type:String,default:"start"}},emits:["update:selectedAgentEngine"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=W(()=>{const d=new Set;return(Array.isArray(n.agentBindings)?n.agentBindings:[]).filter(m=>{const f=String((m==null?void 0:m.engine)||"").trim();return!f||d.has(f)?!1:(d.add(f),!0)})}),l=W(()=>r.value.length>1),c=W(()=>{var m,f;const d=String(n.selectedAgentEngine||"").trim();return r.value.some(b=>b.engine===d)?d:((m=r.value.find(b=>b.isDefault))==null?void 0:m.engine)||((f=r.value[0])==null?void 0:f.engine)||""}),p=W(()=>n.align==="end"?"sm:justify-end":n.align==="center"?"sm:justify-center":"sm:justify-start");function w(d={}){return Nr(d,{prefix:"→ ",defaultLabel:s("sessionPanel.defaultAgent")})}return(d,m)=>l.value?(g(),x("div",{key:0,class:Se(["flex w-full overflow-x-auto pb-0.5",p.value]),title:a(s)("editor.selectAgent"),"data-promptx-agent-targets":"",onMousedown:m[1]||(m[1]=Qe(()=>{},["stop"]))},[i("div",Om,[(g(!0),x(et,null,ut(r.value,f=>(g(),x("button",{key:f.engine,type:"button",class:Se(["theme-agent-selector-button",f.engine===c.value?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":f.engine===c.value,title:w(f),"data-agent-engine":f.engine,onMousedown:m[0]||(m[0]=Qe(()=>{},["prevent"])),onClick:b=>o("update:selectedAgentEngine",f.engine)},S(w(f)),43,jm))),128))])],42,Nm)):me("",!0)}},Fm={class:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:items-center sm:justify-end sm:gap-2","data-promptx-editor-actions":""},Um={class:"grid w-full grid-cols-5 gap-2 sm:flex sm:w-full sm:flex-wrap sm:justify-end sm:gap-2"},Vm=["disabled","title","aria-label"],zm={class:"sr-only sm:not-sr-only sm:inline"},Hm=["title","aria-label"],qm={class:"sr-only sm:not-sr-only sm:inline"},Km=["disabled","title","aria-label"],Wm={class:"sr-only sm:not-sr-only sm:inline"},Gm=["title","aria-label"],Xm={class:"sr-only sm:not-sr-only sm:inline"},Ym={key:0,class:"absolute right-1 top-1 min-w-[1rem] rounded-full bg-[var(--theme-primaryBg)] px-1 text-[10px] font-semibold leading-4 text-[var(--theme-primaryText)] sm:hidden"},Jm=["disabled","title","aria-label"],Qm={class:"sr-only sm:not-sr-only sm:inline"},cr={__name:"WorkbenchEditorActions",props:{canAddTodo:{type:Boolean,default:!1},uploading:{type:Boolean,default:!1},isCurrentTaskSending:{type:Boolean,default:!1},sendState:{type:String,default:"idle"},todoCount:{type:Number,default:0}},emits:["add-todo","open-file-picker","clear-request","copy-request","manage-todo","send-request"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=W(()=>n.sendState==="sending"||n.sendState==="running");function l(){return n.todoCount>0?s("editor.todoWithCount",{count:n.todoCount}):s("editor.todo")}return(c,p)=>(g(),x("div",Fm,[i("div",Um,[i("button",{type:"button",class:"tool-button inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:e.uploading,title:a(s)("editor.chooseFiles"),"aria-label":a(s)("editor.chooseFiles"),"data-promptx-editor-action":"files",onMousedown:p[0]||(p[0]=Qe(()=>{},["prevent"])),onClick:p[1]||(p[1]=w=>o("open-file-picker"))},[e.uploading?(g(),Ce(a(Ht),{key:0,class:"h-4 w-4 animate-spin"})):(g(),Ce(a(Na),{key:1,class:"h-4 w-4"})),i("span",zm,S(a(s)("editor.chooseFiles")),1)],40,Vm),i("button",{type:"button",class:"tool-button inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",title:a(s)("editor.clear"),"aria-label":a(s)("editor.clear"),"data-promptx-editor-action":"clear",onMousedown:p[2]||(p[2]=Qe(()=>{},["prevent"])),onClick:p[3]||(p[3]=w=>o("clear-request"))},[ue(a(Oa),{class:"h-4 w-4"}),i("span",qm,S(a(s)("editor.clear")),1)],40,Hm),i("button",{type:"button",class:"tool-button inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:!e.canAddTodo,title:a(s)("editor.todo"),"aria-label":a(s)("editor.todo"),"data-promptx-editor-action":"todo-add",onMousedown:p[4]||(p[4]=Qe(()=>{},["prevent"])),onClick:p[5]||(p[5]=w=>o("add-todo"))},[ue(a(Ps),{class:"h-4 w-4"}),i("span",Wm,S(a(s)("editor.todo")),1)],40,Km),i("button",{type:"button",class:"tool-button relative inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",title:l(),"aria-label":l(),"data-promptx-editor-action":"todo-manage",onMousedown:p[6]||(p[6]=Qe(()=>{},["prevent"])),onClick:p[7]||(p[7]=w=>o("manage-todo"))},[ue(a(Ar),{class:"h-4 w-4"}),i("span",Xm,S(l()),1),e.todoCount>0?(g(),x("span",Ym,S(e.todoCount>9?"9+":e.todoCount),1)):me("",!0)],40,Gm),i("button",{type:"button",class:"tool-button tool-button-primary inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:e.isCurrentTaskSending,title:a(s)("editor.send"),"aria-label":a(s)("editor.send"),"data-promptx-editor-action":"send",onMousedown:p[8]||(p[8]=Qe(()=>{},["prevent"])),onClick:p[9]||(p[9]=w=>o("send-request"))},[r.value?(g(),Ce(a(Ht),{key:0,class:"h-4 w-4 animate-spin"})):(g(),Ce(a(ja),{key:1,class:"h-4 w-4"})),i("span",Qm,S(a(s)("editor.send")),1)],40,Jm)])]))}};function Zm(e){const{props:t,panelRef:n,onClose:o}=e,s=q({left:"12px",top:"12px",width:"560px",maxHeight:"420px"}),r=q(!1),l=q("bottom");function c(){o==null||o()}function p(b=!1){const v=window.innerWidth,P=window.innerHeight,ne=12,y=8,L=320,O=560,z=420,U=180,se=Math.min(O,Math.max(L,v-ne*2)),A=Math.min(se,v-ne*2),G=t.anchorRect||{left:(v-A)/2,top:P/2,bottom:P/2};let ce=G.left;ce+A>v-ne&&(ce=v-ne-A),ce<ne&&(ce=ne);const pe=Math.max(0,P-ne-(G.bottom+y)),I=Math.max(0,G.top-y-ne);b?l.value=pe>=I?"bottom":"top":l.value==="bottom"&&pe<U&&I>pe+24?l.value="top":l.value==="top"&&I<U&&pe>I+24&&(l.value="bottom");const Q=l.value,le=Q==="bottom"?pe:I,ie=Math.max(140,P-ne*2),ve=Math.min(ie,Math.max(Math.min(z,le||z),U)),_={left:`${Math.round(ce)}px`,width:`${Math.round(A)}px`,maxHeight:`${Math.round(ve)}px`,top:"auto",bottom:"auto"};return Q==="bottom"?_.top=`${Math.round(Math.max(ne,G.bottom+y))}px`:_.bottom=`${Math.round(Math.max(ne,P-G.top+y))}px`,_}function w(b=!1){const v=p(b);s.value={...s.value,left:v.left,top:v.top,bottom:v.bottom,width:v.width,maxHeight:v.maxHeight}}function d(){return!t.open||!t.anchorRect?!1:(l.value="bottom",w(!0),r.value=!0,!0)}function m(){r.value=!1}function f(b){!t.open||!n.value||n.value.contains(b.target)||c()}return dn(()=>{document.addEventListener("pointerdown",f)}),It(()=>{document.removeEventListener("pointerdown",f)}),{closePicker:c,initializePanel:d,panelReady:r,panelStyle:s,resetPanel:m,updatePanelPosition:w}}function eg(e){const{props:t,panelRef:n,onClose:o,onSelect:s}=e,{closePicker:r,initializePanel:l,panelReady:c,panelStyle:p,resetPanel:w,updatePanelPosition:d}=Zm({props:t,panelRef:n,onClose:o}),m=Qr({getMode:()=>String(t.query||"").trim()?"search":"tree",props:t,onSelect:s});return $e(()=>t.open,f=>{if(!f){m.resetData(),w();return}w(),t.anchorRect&&l()&&m.initializeData()},{flush:"sync"}),$e(()=>t.anchorRect,f=>{if(!(!t.open||!f)){if(!c.value){l()&&m.initializeData();return}d(!1)}},{flush:"sync"}),$e(()=>t.sessionId,()=>{m.handleSessionChange()},{flush:"sync",immediate:!0}),$e(()=>t.query,()=>{m.handleQueryChange()},{immediate:!0}),$e(m.visibleItems,()=>{m.handleVisibleItemsChange()},{immediate:!0}),{...m,closePicker:r,panelReady:c,panelStyle:p}}const tg={class:"theme-divider flex items-center justify-end gap-2 border-b border-dashed px-2.5 py-2"},ng={class:"flex shrink-0 items-center gap-2"},sg={class:"min-h-0 flex-1 overflow-y-auto p-2"},og={key:0,class:"theme-empty-state px-3 py-4 text-xs"},rg={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},ag={key:2,class:"theme-empty-state px-3 py-4 text-xs"},ig={key:3,class:"theme-empty-state px-3 py-4 text-xs"},lg={key:4,class:"theme-empty-state px-3 py-4 text-xs"},ug={key:5,class:"space-y-1"},cg={key:0,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},dg=["onClick"],fg={class:"min-w-0 flex-1"},pg=["innerHTML"],mg=["innerHTML"],gg={key:1,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},hg=["onClick"],vg={class:"min-w-0 flex-1"},yg=["innerHTML"],Sg=["innerHTML"],wg={key:6,class:"space-y-1"},xg={class:"flex items-start gap-1.5"},bg=["onClick"],kg={key:1,class:"block h-5 w-5 shrink-0"},_g=["onClick"],Tg={class:"min-w-0 flex-1"},Cg={class:"flex items-center gap-1.5"},Eg={__name:"PathMentionPicker",props:{open:{type:Boolean,default:!1},sessionId:{type:String,default:""},query:{type:String,default:""},anchorRect:{type:Object,default:null}},emits:["close","select"],setup(e,{expose:t,emit:n}){const o=e,s=n,r=q(null),{t:l}=St(),{activeKey:c,closePicker:p,collapseActiveDirectory:w,confirmActive:d,currentError:m,currentLoading:f,emitSelect:b,expandActiveDirectory:v,getDisplayName:P,getHighlightedName:ne,getHighlightedPath:y,moveActive:L,normalSearchItems:O,normalizedQuery:z,panelReady:U,panelStyle:se,recentSearchItems:A,setItemRef:G,showSearchEmptyState:ce,showTreeEmptyState:pe,toggleDirectory:I,treeItems:Q,visibleItems:le}=eg({props:o,panelRef:r,onClose:()=>s("close"),onSelect:ie=>s("select",ie)});return t({collapseActiveDirectory:w,moveActive:L,confirmActive:d,expandActiveDirectory:v}),(ie,ve)=>(g(),Ce(os,{to:"body"},[e.open&&a(U)?(g(),x("div",{key:0,ref_key:"panelRef",ref:r,class:"theme-popover fixed z-40 flex flex-col overflow-hidden rounded-sm border shadow-lg",style:kn(a(se))},[i("div",tg,[i("div",ng,[i("div",{class:Se(["theme-muted-text inline-flex h-7 w-7 items-center justify-center",a(f)?"opacity-100":"opacity-0"])},[ue(a(Ht),{class:"h-3.5 w-3.5 animate-spin"})],2),i("button",{type:"button",class:"tool-button inline-flex h-7 w-7 items-center justify-center",onClick:ve[0]||(ve[0]=(..._)=>a(p)&&a(p)(..._))},[ue(a(Tr),{class:"h-4 w-4"})])])]),i("div",sg,[e.sessionId?a(m)?(g(),x("div",rg,S(a(m)),1)):a(ce)?(g(),x("div",ag,S(a(l)("pathPicker.noResults")),1)):a(pe)?(g(),x("div",ig,S(a(l)("pathPicker.emptyDirectory")),1)):a(f)&&!a(le).length?(g(),x("div",lg,S(a(l)("pathPicker.loading")),1)):a(z)?(g(),x("div",ug,[a(A).length?(g(),x("div",cg,S(a(l)("pathPicker.recent")),1)):me("",!0),(g(!0),x(et,null,ut(a(A),_=>(g(),x("button",{key:_.path,ref_for:!0,ref:H=>a(G)(_.path,H),type:"button",class:Se(["theme-list-row focus:outline-none",a(c)===_.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:H=>a(b)(_)},[(g(),Ce(cn(_.type==="directory"?a(Dn):a(Sn)),{class:"theme-list-item-icon"})),i("div",fg,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(ne)(_)},null,8,pg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(y)(_)},null,8,mg)])],10,dg))),128)),a(z)&&a(O).length?(g(),x("div",gg,S(a(l)("pathPicker.results")),1)):me("",!0),(g(!0),x(et,null,ut(a(O),_=>(g(),x("button",{key:_.path,ref_for:!0,ref:H=>a(G)(_.path,H),type:"button",class:Se(["theme-list-row focus:outline-none",a(c)===_.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:H=>a(b)(_)},[(g(),Ce(cn(_.type==="directory"?a(Dn):a(Sn)),{class:"theme-list-item-icon"})),i("div",vg,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(ne)(_)},null,8,yg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(y)(_)},null,8,Sg)])],10,hg))),128))])):(g(),x("div",wg,[(g(!0),x(et,null,ut(a(Q),_=>(g(),x("div",{key:_.path,ref_for:!0,ref:H=>a(G)(_.path,H),class:Se(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(c)===_.path?"theme-list-item-active":_.type==="directory"&&_.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:kn({paddingLeft:`${_.depth*16+6}px`})},[i("div",xg,[_.type==="directory"?(g(),x("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:Qe(H=>a(I)(_.path),["stop"])},[_.loading?(g(),Ce(a(Ht),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),Ce(a(Er),{key:1,class:Se(["h-3.5 w-3.5 transition",_.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,bg)):(g(),x("span",kg)),i("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:H=>a(b)(_)},[(g(),Ce(cn(_.type==="directory"?a(Dn):a(Sn)),{class:Se(["h-4 w-4 shrink-0",_.type==="directory"&&_.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("div",Tg,[i("div",Cg,[i("span",{class:Se(["theme-list-item-title truncate",_.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},S(a(P)(_)),3)])])],8,_g)])],6))),128))])):(g(),x("div",og,S(a(l)("pathPicker.selectProjectFirst")),1))])],4)):me("",!0)]))}},Ag={__name:"TiptapTextBlockView",props:To,setup(e){return(t,n)=>(g(),Ce(a(Co),{"data-promptx-node":"text"},{default:Je(()=>[ue(a(Pr),{"data-promptx-node-content":"text",class:"min-h-[40px] whitespace-pre-wrap break-words border-0 bg-transparent p-0 text-[15px] leading-8 text-[var(--theme-textPrimary)] outline-none",as:"div"})]),_:1}))}},ya={__name:"TiptapSpecialBlockFrame",props:{frameClass:{type:String,default:""},headerPaddingClass:{type:String,default:"px-4 py-3"},headerClass:{type:String,default:""},selected:{type:Boolean,default:!1}},setup(e){const t=e,n=W(()=>t.selected?"ring-1 ring-inset ring-[var(--theme-borderStrong)]":""),o=W(()=>t.selected?"opacity-100":"opacity-100 sm:opacity-45 sm:group-hover:opacity-100 sm:focus-within:opacity-100");return(s,r)=>(g(),x("div",{class:Se(["overflow-hidden rounded-sm transition",[e.frameClass,n.value]])},[i("div",{class:Se(["theme-divider border-b text-xs",[e.headerPaddingClass,e.headerClass]])},[Jt(s.$slots,"header",{actionsStateClass:o.value})],2),Jt(s.$slots,"default")],2))}},kt={DOC:"doc",TEXT_BLOCK:"paragraph",IMPORTED_TEXT_BLOCK:"promptxImportedTextBlock",IMAGE_BLOCK:"promptxImageBlock",TEXT:"text",HARD_BREAK:"hardBreak"};function $g(){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))||`block-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Mn(e={}){return{...e,clientId:String((e==null?void 0:e.clientId)||(e==null?void 0:e.id)||$g()),meta:e!=null&&e.meta?{...e.meta}:{}}}function Pn(e=""){return Mn({type:$t.TEXT,content:e,meta:{}})}function hs(e){return e&&e.type!==$t.TEXT}function xn(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];if(!t.length)return[Pn("")];const n=[];return t.forEach((o,s)=>{const r=Mn(o),l=n[n.length-1];!l&&hs(r)&&n.push(Pn("")),l&&hs(l)&&hs(r)&&n.push(Pn("")),n.push(r),s===t.length-1&&hs(r)&&n.push(Pn(""))}),n}function So(e=""){const t=String(e||"").split(`
42
+ `);return D||String((h==null?void 0:h.prompt)||"").replace(/\u200b/g,"").trim()}function xt(h={}){const Y=ot(h);Y&&s("insert-code-context",{source:"response",content:Y})}async function Et(h){var jt,Ft,Ut,Pt,mt;const Y=(Ft=(jt=h==null?void 0:h.target)==null?void 0:jt.closest)==null?void 0:Ft.call(jt,'[data-copy-code="1"]');if(!Y)return;const D=Y.closest(".codex-code-block"),be=(Ut=D==null?void 0:D.querySelector)==null?void 0:Ut.call(D,"pre code"),Mt=String((be==null?void 0:be.textContent)||"").replace(/\u200b/g,"");if(Mt){(Pt=h.preventDefault)==null||Pt.call(h),(mt=h.stopPropagation)==null||mt.call(h);try{await Le(Mt),s("toast",{message:Ee("sessionPanel.codeCopied"),type:"success"})}catch{s("toast",{message:Ee("errors.requestFailed"),type:"warning"})}}}function pt(){if(!T.value.visible)return;const h=String(T.value.content||"").replace(/\u200b/g,"").trim();if(!h){j({clearBrowserSelection:!0});return}s("insert-code-context",{source:"response",content:h}),j({clearBrowserSelection:!0})}function V(h={}){if(h!=null&&h.errorMessage)return;const Y=String((h==null?void 0:h.responseMessage)||"").replace(/\u200b/g,"").trim();Y&&s("insert-code-context",{source:"response",content:Y})}const X=W(()=>J.value.flatMap(h=>(Array.isArray(h==null?void 0:h.promptBlocks)?h.promptBlocks:[]).filter(Y=>(Y==null?void 0:Y.type)==="image").map(Y=>Y.content)));function de(h){const D=(Array.isArray(h==null?void 0:h.events)?h.events:[]).filter(be=>!ye(be));return $p(D)}function he(h){return Ge(h)}function Ue(h){return h!=null&&h.eventsLoaded?he(h)>0:Ye(h)}function Tt(h){return!!(h!=null&&h.eventsLoading)}function qt(h){return!!(h!=null&&h.eventsLoaded)&&de(h).length>0&&!nt(h)}function At(h){return!!(h!=null&&h.eventsLoaded)&&he(h)>0&&nt(h)}function Ot(h){return Ye(h)&&!(h!=null&&h.eventsLoaded)&&!(h!=null&&h.eventsLoading)}function Qt(h={}){return Nr(h,{defaultLabel:Ee("sessionPanel.defaultAgent")})}function nn(h={}){return!Kf(h)}function E(h={}){return"bg-[var(--theme-appPanelStrong)]"}function k(h=null){const Y=String((h==null?void 0:h.id)||"").trim();if(Y)return _e.value.find(be=>be.id===Y)||null;const D=String(ie.value||"").trim();return D?_e.value.find(be=>be.id===D)||null:Ke.value[0]||null}function K(h=null){const Y=k(h);return Y!=null&&Y.cwd?(it.value=Y.id,Pe.value=!0,!0):!1}function ae(){return I.value?!1:(Q(),!0)}function ee(){var h,Y;return Pe.value?(Pe.value=!1,!0):(Y=(h=Xe.value)==null?void 0:h.closeTopDialog)!=null&&Y.call(h)?!0:je.value?(l(),!0):!1}return t({closeTopDialog:ee,openProjectManager:ae,openSourceBrowser:K,send:L,scrollToBottom:Be,stop:tt}),(h,Y)=>(g(),x("section",Ip,[ue(ff,{open:Pe.value,session:a(_e).find(D=>D.id===it.value)||null,onInsertCodeContext:Y[0]||(Y[0]=D=>s("insert-code-context",D)),onClose:Y[1]||(Y[1]=D=>Pe.value=!1)},null,8,["open","session"]),ue(a(o),{ref_key:"managerDialogRef",ref:Xe,open:a(je),sessions:a(_e),workspaces:a(fe),"selected-session-id":a(ie),"selection-locked":e.sessionSelectionLocked,"selection-lock-reason":e.sessionSelectionLockReason,loading:a(pe),sending:a(ve),"on-refresh":a(ge),"on-create":a(v),"on-update":a(A),"on-delete":a(P),"on-reset":a(ne),onClose:a(l),onOpenSourceBrowser:Y[2]||(Y[2]=D=>K(D)),onProjectCreated:Y[3]||(Y[3]=D=>s("project-created",D)),onSelectSession:a(y)},null,8,["open","sessions","workspaces","selected-session-id","selection-locked","selection-lock-reason","loading","sending","on-refresh","on-create","on-update","on-delete","on-reset","onClose","onSelectSession"]),i("div",Pp,[i("div",Dp,[i("div",Lp,[i("div",{class:"min-w-0 flex-1",title:a(G)||""},[ue(Vu,{modelValue:a(ie),"onUpdate:modelValue":Y[4]||(Y[4]=D=>_a(ie)?ie.value=D:null),sessions:a(Ke),loading:a(pe),disabled:a(ve)||a(I)||e.sessionSelectionLocked,onRefreshIntent:a(le)},null,8,["modelValue","sessions","loading","disabled","onRefreshIntent"])],8,Bp),i("div",Mp,[i("button",{type:"button",class:Se(["tool-button inline-flex h-9 w-9 items-center justify-center whitespace-nowrap px-0 py-0 text-xs",a(_)?"tool-button-accent-subtle":""]),"aria-pressed":a(_)?"true":"false","aria-label":a(_)?a(Ee)("sessionPanel.hideProcessToggle"):a(Ee)("sessionPanel.showProcessToggle"),title:a(_)?a(Ee)("sessionPanel.hideProcessToggle"):a(Ee)("sessionPanel.showProcessToggle"),onClick:Y[5]||(Y[5]=(...D)=>a(xe)&&a(xe)(...D))},[a(_)?(g(),Ce(a(Da),{key:0,class:"h-4 w-4"})):(g(),Ce(a(La),{key:1,class:"h-4 w-4"}))],10,Rp),e.diffSupported?(g(),x("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-1.5 whitespace-nowrap px-2.5 py-2 text-xs sm:gap-2 sm:px-3",disabled:!e.taskSlug,onClick:_t},[ue(a(Uo),{class:"h-4 w-4"}),Y[17]||(Y[17]=i("span",{class:"sm:hidden"},"代码",-1)),i("span",Op,w(a(Ee)("sessionPanel.diff")),1)],8,Np)):me("",!0),i("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 whitespace-nowrap px-2.5 py-2 text-xs sm:gap-2 sm:px-3",disabled:a(I),onClick:Y[6]||(Y[6]=(...D)=>a(Q)&&a(Q)(...D))},[ue(a(Zn),{class:"h-4 w-4"}),Y[18]||(Y[18]=i("span",{class:"sm:hidden"},"项目",-1)),i("span",Fp,w(a(Ee)("sessionPanel.manageProjects")),1)],8,jp)])]),wt.value?(g(),x("div",{key:0,class:"flex max-w-full items-center gap-1.5 overflow-x-auto pb-0.5","aria-label":a(Ee)("sessionPanel.agentFilter")},[i("button",{type:"button",class:Se(["theme-agent-selector-button",Ne.value==="all"?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Ne.value==="all"?"true":"false",onClick:Y[7]||(Y[7]=D=>Ne.value="all")},w(a(Ee)("sessionPanel.allAgents")),11,Vp),(g(!0),x(et,null,ut(dt.value,D=>(g(),x("button",{key:D.engine,type:"button",class:Se(["theme-agent-selector-button",Ne.value===D.engine?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Ne.value===D.engine?"true":"false",title:Qt(D),onClick:be=>Ne.value=D.engine},w(Qt(D)),11,zp))),128))],8,Up)):me("",!0),a(De)?(g(),x("p",Hp,[ue(a(_o),{class:"h-4 w-4"}),i("span",null,w(a(De)),1)])):me("",!0)])]),i("div",qp,[i("div",{ref_key:"transcriptRef",ref:R,"data-promptx-transcript":"1",class:"workbench-transcript relative flex h-full flex-col gap-3 overflow-x-hidden overflow-y-auto px-4 py-4",onScroll:Y[9]||(Y[9]=(...D)=>a(O)&&a(O)(...D)),onTouchstartPassive:Y[10]||(Y[10]=(...D)=>a(se)&&a(se)(...D)),onTouchmovePassive:Y[11]||(Y[11]=(...D)=>a(U)&&a(U)(...D)),onTouchendPassive:Y[12]||(Y[12]=(...D)=>a(z)&&a(z)(...D)),onTouchcancelPassive:Y[13]||(Y[13]=(...D)=>a(z)&&a(z)(...D))},[a(J).length?Ct.value.length?me("",!0):(g(),x("div",Wp,w(a(Ee)("sessionPanel.emptyAgentFilter")),1)):(g(),x("div",Kp,w(a(Ee)("sessionPanel.empty")),1)),(g(!0),x(et,null,ut(Ct.value,D=>(g(),x("div",{key:D.id,"data-promptx-turn":"1","data-turn-id":D.id,"data-run-id":D.runId||"",class:"flex min-w-0 flex-col gap-3"},[i("div",Xp,[i("div",Yp,[i("div",Jp,[i("span",Qp,w(Oe(D)),1),i("div",Zp,[ot(D)?(g(),x("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:be=>xt(D)},[ue(a(Ps),{class:"h-3 w-3"}),i("span",null,w(a(Ee)("sessionPanel.insert")),1)],8,em)):me("",!0),i("span",null,w(a(c)(D.startedAt)),1)])]),i("div",tm,[Array.isArray(D.promptBlocks)&&D.promptBlocks.length?(g(),x("div",nm,[(g(!0),x(et,null,ut(D.promptBlocks,(be,Mt)=>(g(),x(et,{key:`${D.id}-prompt-${Mt}`},[be.type==="text"||be.type==="imported_text"?(g(),x("pre",sm,w(be.content),1)):(g(),x("button",{key:1,type:"button",class:"inline-flex cursor-zoom-in justify-center rounded-sm",onClick:jt=>re(be.content)},[i("img",{src:be.content,alt:a(Ee)("sessionPanel.promptImageAlt"),class:"max-h-52 w-auto max-w-full rounded-sm object-contain shadow-sm"},null,8,rm)],8,om))],64))),128))])):(g(),x("pre",am,w(D.prompt),1))])])]),a(_)&&nn(D)?(g(),x("div",im,[i("div",{class:Se(["transcript-card transcript-card--process min-w-0 w-full rounded-sm px-4 py-3",a(p)(D)])},[i("div",lm,[i("span",um,w(a(Ee)("sessionPanel.processTitle")),1),i("div",cm,[Ue(D)?(g(),x("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",disabled:D.eventsLoading,onClick:be=>a(yt)(D)},[Tt(D)?(g(),Ce(a(Ht),{key:0,class:"h-3 w-3 animate-spin"})):a(nt)(D)?(g(),Ce(a(ko),{key:1,class:"h-3 w-3"})):(g(),Ce(a(Ba),{key:2,class:"h-3 w-3"})),i("span",null,w(D.eventsLoading?a(Ee)("sessionPanel.loading"):a(nt)(D)?`${a(Ee)("sessionPanel.expand")} (${he(D)})`:a(Ee)("sessionPanel.collapse")),1)],8,dm)):me("",!0),i("span",null,w(a(S)(D)),1)])]),Tt(D)?(g(),x("div",fm,w(a(Ee)("sessionPanel.loadingEvents")),1)):qt(D)?(g(),x("div",pm,[(g(!0),x(et,null,ut(de(D),be=>(g(),x("div",{key:be.id,class:Se(["transcript-event-card min-w-0 rounded-sm px-3 py-2",E(be)])},[i("div",mm,w(be.title),1),be.detail||Array.isArray(be.detailBlocks)&&be.detailBlocks.length?(g(),Ce(zc,{key:0,detail:be.detail,blocks:be.detailBlocks,kind:be.kind,class:"mt-2"},null,8,["detail","blocks","kind"])):me("",!0)],2))),128))])):At(D)||Ot(D)?(g(),x("div",gm,w(D.eventsLoaded?a(Ee)("sessionPanel.hiddenEventsLoaded",{count:he(D)}):a(Ee)("sessionPanel.hiddenEventsLoadLater",{count:he(D)})),1)):(g(),x("p",hm,w(["queued","starting","running","stopping"].includes(D.status)?a(Ee)("sessionPanel.waitingEvents",{agent:a(d)(D)}):a(Ee)("sessionPanel.noEvents")),1)),a(F)(D)?(g(),x("div",vm,[a(b)(D)?(g(),x("div",ym,w(a(b)(D)),1)):me("",!0),a(f)(D)?(g(),x("div",Sm,w(a(f)(D)),1)):me("",!0),a(m)(D).length?(g(),x("div",wm,[(g(!0),x(et,null,ut(a(m)(D),be=>(g(),x("span",{key:be.key,class:"transcript-card__pill inline-flex items-center gap-1 rounded-sm border border-dashed border-[var(--theme-borderDefault)] px-2 py-1"},[i("span",null,w(be.label),1),i("span",xm,w(be.value),1)]))),128))])):me("",!0)])):me("",!0)],2)])):me("",!0),a(Fe)(D)?(g(),x("div",bm,[i("div",{class:Se(["transcript-card transcript-card--response min-w-0 w-full rounded-sm px-4 py-3 text-sm leading-7",D.errorMessage?"bg-[var(--theme-dangerSoft)] text-[var(--theme-dangerText)]":"bg-[var(--theme-responseBg)] text-[var(--theme-responseText)]"])},[i("div",km,[i("span",_m,w(Re(D)),1),i("div",Tm,[e.diffSupported&&D.runId?(g(),x("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:be=>ft(D)},[ue(a(Uo),{class:"h-3 w-3"}),i("span",null,w(a(Ee)("sessionPanel.view")),1)],8,Cm)):me("",!0),D.responseMessage&&!D.errorMessage?(g(),x("button",{key:1,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:be=>V(D)},[ue(a(Ps),{class:"h-3 w-3"}),i("span",null,w(a(Ee)("sessionPanel.insert")),1)],8,Em)):me("",!0),i("span",null,w(a(c)(D.finishedAt||D.startedAt)),1)])]),i("div",Am,[D.errorMessage?(g(),x("div",$m,w(D.errorMessage),1)):(g(),x("div",{key:1,class:"prose-like codex-markdown","data-response-selection-root":"1",onMouseup:Y[8]||(Y[8]=(...be)=>a(te)&&a(te)(...be)),onClick:Et,innerHTML:a(Bt)(D)},null,40,Im))])],2)])):me("",!0)],8,Gp))),128)),a(T).visible?(g(),Ce(Gr,{key:2,top:a(T).top,left:a(T).left,label:a(Ee)("sourceBrowser.insertSelection"),onClick:pt},null,8,["top","left","label"])):me("",!0)],544),i("div",Pm,[a(He)?(g(),x("button",{key:0,type:"button",class:Se([a(ve)?"mb-10 sm:mb-8":"","tool-button pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur"]),onClick:Y[14]||(Y[14]=(...D)=>a(Be)&&a(Be)(...D))},[ue(a(Ma),{class:"h-3.5 w-3.5"}),i("span",null,w(a(Ee)("sessionPanel.jumpToLatest")),1)],2)):me("",!0),a(ve)?(g(),x("button",{key:1,type:"button",class:"tool-button tool-button-warning-subtle pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur",disabled:a(H),onClick:Y[15]||(Y[15]=(...D)=>a(tt)&&a(tt)(...D))},[a(H)?(g(),Ce(a(Ht),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),Ce(a(Ra),{key:1,class:"h-3.5 w-3.5"})),i("span",null,w(a(H)?a(Ee)("sessionPanel.stopping"):a(Ee)("sessionPanel.stop")),1),a(H)?me("",!0):(g(),x("span",Lm,[...Y[19]||(Y[19]=[i("span",{class:"task-loading-dots__dot"},null,-1),i("span",{class:"task-loading-dots__dot"},null,-1),i("span",{class:"task-loading-dots__dot"},null,-1)])]))],8,Dm)):me("",!0)])]),ue(Or,{modelValue:Me.value,"onUpdate:modelValue":Y[16]||(Y[16]=D=>Me.value=D),images:X.value},null,8,["modelValue","images"])]))}},Mm={key:0,class:"h-full min-h-0"},Rm={key:1,class:"panel theme-muted-text flex h-full items-center px-5 py-4 text-sm"},lr={__name:"WorkbenchActivityPanel",props:{taskSlug:{type:String,default:""},buildPrompt:{type:Function,default:null},buildPromptBlocks:{type:Function,default:null},selectedSessionId:{type:String,default:""},selectedAgentEngine:{type:String,default:""},sessionSelectionLocked:{type:Boolean,default:!1},sessionSelectionLockReason:{type:String,default:""},diffSupported:{type:Boolean,default:!1},taskRunning:{type:Boolean,default:!1},emptyMessage:{type:String,default:""}},emits:["agent-bindings-change","insert-code-context","sending-change","project-created","selected-session-change","open-diff","toast","update:selectedAgentEngine"],setup(e,{expose:t,emit:n}){const o=n,s=q(null);function r(){var m,f;return(f=(m=s.value)==null?void 0:m.send)==null?void 0:f.call(m)}function l(){var m,f;(f=(m=s.value)==null?void 0:m.stop)==null||f.call(m)}function c(){var m,f;(f=(m=s.value)==null?void 0:m.scrollToBottom)==null||f.call(m)}function p(){var m,f;return((f=(m=s.value)==null?void 0:m.openProjectManager)==null?void 0:f.call(m))||!1}function S(){var m,f;return((f=(m=s.value)==null?void 0:m.openSourceBrowser)==null?void 0:f.call(m))||!1}function d(){var m,f;return((f=(m=s.value)==null?void 0:m.closeTopDialog)==null?void 0:f.call(m))||!1}return t({closeTopDialog:d,openProjectManager:p,openSourceBrowser:S,send:r,stop:l,scrollToBottom:c}),(m,f)=>e.taskSlug?(g(),x("div",Mm,[ue(Bm,{ref_key:"panelRef",ref:s,active:!!e.taskSlug,"task-slug":e.taskSlug,"build-prompt":e.buildPrompt||(()=>""),"build-prompt-blocks":e.buildPromptBlocks||(()=>[]),"selected-session-id":e.selectedSessionId,"selected-agent-engine":e.selectedAgentEngine,"session-selection-locked":e.sessionSelectionLocked,"session-selection-lock-reason":e.sessionSelectionLockReason,"diff-supported":e.diffSupported,"task-running":e.taskRunning,onAgentBindingsChange:f[0]||(f[0]=b=>o("agent-bindings-change",b)),onInsertCodeContext:f[1]||(f[1]=b=>o("insert-code-context",b)),onProjectCreated:f[2]||(f[2]=b=>o("project-created",b)),onSendingChange:f[3]||(f[3]=b=>o("sending-change",b)),onSelectedSessionChange:f[4]||(f[4]=b=>o("selected-session-change",b)),"onUpdate:selectedAgentEngine":f[5]||(f[5]=b=>o("update:selectedAgentEngine",b)),onOpenDiff:f[6]||(f[6]=b=>o("open-diff",b)),onToast:f[7]||(f[7]=b=>o("toast",b))},null,8,["active","task-slug","build-prompt","build-prompt-blocks","selected-session-id","selected-agent-engine","session-selection-locked","session-selection-lock-reason","diff-supported","task-running"])])):e.emptyMessage?(g(),x("section",Rm,w(e.emptyMessage),1)):me("",!0)}},Nm=["title"],Om={class:"flex min-w-0 items-center gap-1.5"},jm=["aria-pressed","title","data-agent-engine","onClick"],ur={__name:"WorkbenchAgentSelector",props:{agentBindings:{type:Array,default:()=>[]},selectedAgentEngine:{type:String,default:""},align:{type:String,default:"start"}},emits:["update:selectedAgentEngine"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=W(()=>{const d=new Set;return(Array.isArray(n.agentBindings)?n.agentBindings:[]).filter(m=>{const f=String((m==null?void 0:m.engine)||"").trim();return!f||d.has(f)?!1:(d.add(f),!0)})}),l=W(()=>r.value.length>1),c=W(()=>{var m,f;const d=String(n.selectedAgentEngine||"").trim();return r.value.some(b=>b.engine===d)?d:((m=r.value.find(b=>b.isDefault))==null?void 0:m.engine)||((f=r.value[0])==null?void 0:f.engine)||""}),p=W(()=>n.align==="end"?"sm:justify-end":n.align==="center"?"sm:justify-center":"sm:justify-start");function S(d={}){return Nr(d,{prefix:"→ ",defaultLabel:s("sessionPanel.defaultAgent")})}return(d,m)=>l.value?(g(),x("div",{key:0,class:Se(["flex w-full overflow-x-auto pb-0.5",p.value]),title:a(s)("editor.selectAgent"),"data-promptx-agent-targets":"",onMousedown:m[1]||(m[1]=Qe(()=>{},["stop"]))},[i("div",Om,[(g(!0),x(et,null,ut(r.value,f=>(g(),x("button",{key:f.engine,type:"button",class:Se(["theme-agent-selector-button",f.engine===c.value?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":f.engine===c.value,title:S(f),"data-agent-engine":f.engine,onMousedown:m[0]||(m[0]=Qe(()=>{},["prevent"])),onClick:b=>o("update:selectedAgentEngine",f.engine)},w(S(f)),43,jm))),128))])],42,Nm)):me("",!0)}},Fm={class:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:items-center sm:justify-end sm:gap-2","data-promptx-editor-actions":""},Um={class:"grid w-full grid-cols-5 gap-2 sm:flex sm:w-full sm:flex-wrap sm:justify-end sm:gap-2"},Vm=["disabled","title","aria-label"],zm={class:"sr-only sm:not-sr-only sm:inline"},Hm=["title","aria-label"],qm={class:"sr-only sm:not-sr-only sm:inline"},Km=["disabled","title","aria-label"],Wm={class:"sr-only sm:not-sr-only sm:inline"},Gm=["title","aria-label"],Xm={class:"sr-only sm:not-sr-only sm:inline"},Ym={key:0,class:"absolute right-1 top-1 min-w-[1rem] rounded-full bg-[var(--theme-primaryBg)] px-1 text-[10px] font-semibold leading-4 text-[var(--theme-primaryText)] sm:hidden"},Jm=["disabled","title","aria-label"],Qm={class:"sr-only sm:not-sr-only sm:inline"},cr={__name:"WorkbenchEditorActions",props:{canAddTodo:{type:Boolean,default:!1},uploading:{type:Boolean,default:!1},isCurrentTaskSending:{type:Boolean,default:!1},sendState:{type:String,default:"idle"},todoCount:{type:Number,default:0}},emits:["add-todo","open-file-picker","clear-request","copy-request","manage-todo","send-request"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=W(()=>n.sendState==="sending"||n.sendState==="running");function l(){return n.todoCount>0?s("editor.todoWithCount",{count:n.todoCount}):s("editor.todo")}return(c,p)=>(g(),x("div",Fm,[i("div",Um,[i("button",{type:"button",class:"tool-button inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:e.uploading,title:a(s)("editor.chooseFiles"),"aria-label":a(s)("editor.chooseFiles"),"data-promptx-editor-action":"files",onMousedown:p[0]||(p[0]=Qe(()=>{},["prevent"])),onClick:p[1]||(p[1]=S=>o("open-file-picker"))},[e.uploading?(g(),Ce(a(Ht),{key:0,class:"h-4 w-4 animate-spin"})):(g(),Ce(a(Na),{key:1,class:"h-4 w-4"})),i("span",zm,w(a(s)("editor.chooseFiles")),1)],40,Vm),i("button",{type:"button",class:"tool-button inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",title:a(s)("editor.clear"),"aria-label":a(s)("editor.clear"),"data-promptx-editor-action":"clear",onMousedown:p[2]||(p[2]=Qe(()=>{},["prevent"])),onClick:p[3]||(p[3]=S=>o("clear-request"))},[ue(a(Oa),{class:"h-4 w-4"}),i("span",qm,w(a(s)("editor.clear")),1)],40,Hm),i("button",{type:"button",class:"tool-button inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:!e.canAddTodo,title:a(s)("editor.todo"),"aria-label":a(s)("editor.todo"),"data-promptx-editor-action":"todo-add",onMousedown:p[4]||(p[4]=Qe(()=>{},["prevent"])),onClick:p[5]||(p[5]=S=>o("add-todo"))},[ue(a(Ps),{class:"h-4 w-4"}),i("span",Wm,w(a(s)("editor.todo")),1)],40,Km),i("button",{type:"button",class:"tool-button relative inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",title:l(),"aria-label":l(),"data-promptx-editor-action":"todo-manage",onMousedown:p[6]||(p[6]=Qe(()=>{},["prevent"])),onClick:p[7]||(p[7]=S=>o("manage-todo"))},[ue(a(Ar),{class:"h-4 w-4"}),i("span",Xm,w(l()),1),e.todoCount>0?(g(),x("span",Ym,w(e.todoCount>9?"9+":e.todoCount),1)):me("",!0)],40,Gm),i("button",{type:"button",class:"tool-button tool-button-primary inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:e.isCurrentTaskSending,title:a(s)("editor.send"),"aria-label":a(s)("editor.send"),"data-promptx-editor-action":"send",onMousedown:p[8]||(p[8]=Qe(()=>{},["prevent"])),onClick:p[9]||(p[9]=S=>o("send-request"))},[r.value?(g(),Ce(a(Ht),{key:0,class:"h-4 w-4 animate-spin"})):(g(),Ce(a(ja),{key:1,class:"h-4 w-4"})),i("span",Qm,w(a(s)("editor.send")),1)],40,Jm)])]))}};function Zm(e){const{props:t,panelRef:n,onClose:o}=e,s=q({left:"12px",top:"12px",width:"560px",maxHeight:"420px"}),r=q(!1),l=q("bottom");function c(){o==null||o()}function p(b=!1){const v=window.innerWidth,P=window.innerHeight,ne=12,y=8,L=320,O=560,z=420,U=180,se=Math.min(O,Math.max(L,v-ne*2)),A=Math.min(se,v-ne*2),G=t.anchorRect||{left:(v-A)/2,top:P/2,bottom:P/2};let ce=G.left;ce+A>v-ne&&(ce=v-ne-A),ce<ne&&(ce=ne);const pe=Math.max(0,P-ne-(G.bottom+y)),I=Math.max(0,G.top-y-ne);b?l.value=pe>=I?"bottom":"top":l.value==="bottom"&&pe<U&&I>pe+24?l.value="top":l.value==="top"&&I<U&&pe>I+24&&(l.value="bottom");const Q=l.value,le=Q==="bottom"?pe:I,ie=Math.max(140,P-ne*2),ve=Math.min(ie,Math.max(Math.min(z,le||z),U)),_={left:`${Math.round(ce)}px`,width:`${Math.round(A)}px`,maxHeight:`${Math.round(ve)}px`,top:"auto",bottom:"auto"};return Q==="bottom"?_.top=`${Math.round(Math.max(ne,G.bottom+y))}px`:_.bottom=`${Math.round(Math.max(ne,P-G.top+y))}px`,_}function S(b=!1){const v=p(b);s.value={...s.value,left:v.left,top:v.top,bottom:v.bottom,width:v.width,maxHeight:v.maxHeight}}function d(){return!t.open||!t.anchorRect?!1:(l.value="bottom",S(!0),r.value=!0,!0)}function m(){r.value=!1}function f(b){!t.open||!n.value||n.value.contains(b.target)||c()}return dn(()=>{document.addEventListener("pointerdown",f)}),It(()=>{document.removeEventListener("pointerdown",f)}),{closePicker:c,initializePanel:d,panelReady:r,panelStyle:s,resetPanel:m,updatePanelPosition:S}}function eg(e){const{props:t,panelRef:n,onClose:o,onSelect:s}=e,{closePicker:r,initializePanel:l,panelReady:c,panelStyle:p,resetPanel:S,updatePanelPosition:d}=Zm({props:t,panelRef:n,onClose:o}),m=Qr({getMode:()=>String(t.query||"").trim()?"search":"tree",props:t,onSelect:s});return $e(()=>t.open,f=>{if(!f){m.resetData(),S();return}S(),t.anchorRect&&l()&&m.initializeData()},{flush:"sync"}),$e(()=>t.anchorRect,f=>{if(!(!t.open||!f)){if(!c.value){l()&&m.initializeData();return}d(!1)}},{flush:"sync"}),$e(()=>t.sessionId,()=>{m.handleSessionChange()},{flush:"sync",immediate:!0}),$e(()=>t.query,()=>{m.handleQueryChange()},{immediate:!0}),$e(m.visibleItems,()=>{m.handleVisibleItemsChange()},{immediate:!0}),{...m,closePicker:r,panelReady:c,panelStyle:p}}const tg={class:"theme-divider flex items-center justify-end gap-2 border-b border-dashed px-2.5 py-2"},ng={class:"flex shrink-0 items-center gap-2"},sg={class:"min-h-0 flex-1 overflow-y-auto p-2"},og={key:0,class:"theme-empty-state px-3 py-4 text-xs"},rg={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},ag={key:2,class:"theme-empty-state px-3 py-4 text-xs"},ig={key:3,class:"theme-empty-state px-3 py-4 text-xs"},lg={key:4,class:"theme-empty-state px-3 py-4 text-xs"},ug={key:5,class:"space-y-1"},cg={key:0,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},dg=["onClick"],fg={class:"min-w-0 flex-1"},pg=["innerHTML"],mg=["innerHTML"],gg={key:1,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},hg=["onClick"],vg={class:"min-w-0 flex-1"},yg=["innerHTML"],Sg=["innerHTML"],wg={key:6,class:"space-y-1"},xg={class:"flex items-start gap-1.5"},bg=["onClick"],kg={key:1,class:"block h-5 w-5 shrink-0"},_g=["onClick"],Tg={class:"min-w-0 flex-1"},Cg={class:"flex items-center gap-1.5"},Eg={__name:"PathMentionPicker",props:{open:{type:Boolean,default:!1},sessionId:{type:String,default:""},query:{type:String,default:""},anchorRect:{type:Object,default:null}},emits:["close","select"],setup(e,{expose:t,emit:n}){const o=e,s=n,r=q(null),{t:l}=St(),{activeKey:c,closePicker:p,collapseActiveDirectory:S,confirmActive:d,currentError:m,currentLoading:f,emitSelect:b,expandActiveDirectory:v,getDisplayName:P,getHighlightedName:ne,getHighlightedPath:y,moveActive:L,normalSearchItems:O,normalizedQuery:z,panelReady:U,panelStyle:se,recentSearchItems:A,setItemRef:G,showSearchEmptyState:ce,showTreeEmptyState:pe,toggleDirectory:I,treeItems:Q,visibleItems:le}=eg({props:o,panelRef:r,onClose:()=>s("close"),onSelect:ie=>s("select",ie)});return t({collapseActiveDirectory:S,moveActive:L,confirmActive:d,expandActiveDirectory:v}),(ie,ve)=>(g(),Ce(os,{to:"body"},[e.open&&a(U)?(g(),x("div",{key:0,ref_key:"panelRef",ref:r,class:"theme-popover fixed z-40 flex flex-col overflow-hidden rounded-sm border shadow-lg",style:kn(a(se))},[i("div",tg,[i("div",ng,[i("div",{class:Se(["theme-muted-text inline-flex h-7 w-7 items-center justify-center",a(f)?"opacity-100":"opacity-0"])},[ue(a(Ht),{class:"h-3.5 w-3.5 animate-spin"})],2),i("button",{type:"button",class:"tool-button inline-flex h-7 w-7 items-center justify-center",onClick:ve[0]||(ve[0]=(..._)=>a(p)&&a(p)(..._))},[ue(a(Tr),{class:"h-4 w-4"})])])]),i("div",sg,[e.sessionId?a(m)?(g(),x("div",rg,w(a(m)),1)):a(ce)?(g(),x("div",ag,w(a(l)("pathPicker.noResults")),1)):a(pe)?(g(),x("div",ig,w(a(l)("pathPicker.emptyDirectory")),1)):a(f)&&!a(le).length?(g(),x("div",lg,w(a(l)("pathPicker.loading")),1)):a(z)?(g(),x("div",ug,[a(A).length?(g(),x("div",cg,w(a(l)("pathPicker.recent")),1)):me("",!0),(g(!0),x(et,null,ut(a(A),_=>(g(),x("button",{key:_.path,ref_for:!0,ref:H=>a(G)(_.path,H),type:"button",class:Se(["theme-list-row focus:outline-none",a(c)===_.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:H=>a(b)(_)},[(g(),Ce(cn(_.type==="directory"?a(Dn):a(Sn)),{class:"theme-list-item-icon"})),i("div",fg,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(ne)(_)},null,8,pg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(y)(_)},null,8,mg)])],10,dg))),128)),a(z)&&a(O).length?(g(),x("div",gg,w(a(l)("pathPicker.results")),1)):me("",!0),(g(!0),x(et,null,ut(a(O),_=>(g(),x("button",{key:_.path,ref_for:!0,ref:H=>a(G)(_.path,H),type:"button",class:Se(["theme-list-row focus:outline-none",a(c)===_.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:H=>a(b)(_)},[(g(),Ce(cn(_.type==="directory"?a(Dn):a(Sn)),{class:"theme-list-item-icon"})),i("div",vg,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(ne)(_)},null,8,yg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(y)(_)},null,8,Sg)])],10,hg))),128))])):(g(),x("div",wg,[(g(!0),x(et,null,ut(a(Q),_=>(g(),x("div",{key:_.path,ref_for:!0,ref:H=>a(G)(_.path,H),class:Se(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(c)===_.path?"theme-list-item-active":_.type==="directory"&&_.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:kn({paddingLeft:`${_.depth*16+6}px`})},[i("div",xg,[_.type==="directory"?(g(),x("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:Qe(H=>a(I)(_.path),["stop"])},[_.loading?(g(),Ce(a(Ht),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),Ce(a(Er),{key:1,class:Se(["h-3.5 w-3.5 transition",_.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,bg)):(g(),x("span",kg)),i("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:H=>a(b)(_)},[(g(),Ce(cn(_.type==="directory"?a(Dn):a(Sn)),{class:Se(["h-4 w-4 shrink-0",_.type==="directory"&&_.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("div",Tg,[i("div",Cg,[i("span",{class:Se(["theme-list-item-title truncate",_.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},w(a(P)(_)),3)])])],8,_g)])],6))),128))])):(g(),x("div",og,w(a(l)("pathPicker.selectProjectFirst")),1))])],4)):me("",!0)]))}},Ag={__name:"TiptapTextBlockView",props:To,setup(e){return(t,n)=>(g(),Ce(a(Co),{"data-promptx-node":"text"},{default:Je(()=>[ue(a(Pr),{"data-promptx-node-content":"text",class:"min-h-[40px] whitespace-pre-wrap break-words border-0 bg-transparent p-0 text-[15px] leading-8 text-[var(--theme-textPrimary)] outline-none",as:"div"})]),_:1}))}},ya={__name:"TiptapSpecialBlockFrame",props:{frameClass:{type:String,default:""},headerPaddingClass:{type:String,default:"px-4 py-3"},headerClass:{type:String,default:""},selected:{type:Boolean,default:!1}},setup(e){const t=e,n=W(()=>t.selected?"ring-1 ring-inset ring-[var(--theme-borderStrong)]":""),o=W(()=>t.selected?"opacity-100":"opacity-100 sm:opacity-45 sm:group-hover:opacity-100 sm:focus-within:opacity-100");return(s,r)=>(g(),x("div",{class:Se(["overflow-hidden rounded-sm transition",[e.frameClass,n.value]])},[i("div",{class:Se(["theme-divider border-b text-xs",[e.headerPaddingClass,e.headerClass]])},[Jt(s.$slots,"header",{actionsStateClass:o.value})],2),Jt(s.$slots,"default")],2))}},kt={DOC:"doc",TEXT_BLOCK:"paragraph",IMPORTED_TEXT_BLOCK:"promptxImportedTextBlock",IMAGE_BLOCK:"promptxImageBlock",TEXT:"text",HARD_BREAK:"hardBreak"};function $g(){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))||`block-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Mn(e={}){return{...e,clientId:String((e==null?void 0:e.clientId)||(e==null?void 0:e.id)||$g()),meta:e!=null&&e.meta?{...e.meta}:{}}}function Pn(e=""){return Mn({type:$t.TEXT,content:e,meta:{}})}function hs(e){return e&&e.type!==$t.TEXT}function xn(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];if(!t.length)return[Pn("")];const n=[];return t.forEach((o,s)=>{const r=Mn(o),l=n[n.length-1];!l&&hs(r)&&n.push(Pn("")),l&&hs(l)&&hs(r)&&n.push(Pn("")),n.push(r),s===t.length-1&&hs(r)&&n.push(Pn(""))}),n}function So(e=""){const t=String(e||"").split(`
43
43
  `),n=[];return t.forEach((o,s)=>{o&&n.push({type:kt.TEXT,text:o}),s<t.length-1&&n.push({type:kt.HARD_BREAK})}),n}function Ig(e=""){return So(e)}function Pg(e=[]){if(Array.isArray(e))return e;if(typeof(e==null?void 0:e.toArray)=="function")return e.toArray();if(typeof(e==null?void 0:e.forEach)=="function"){const t=[];return e.forEach(n=>{t.push(n)}),t}return[]}function Ms(e=[]){return Pg(e).map(t=>{var o;const n=typeof(t==null?void 0:t.type)=="string"?t.type:(o=t==null?void 0:t.type)==null?void 0:o.name;return n===kt.TEXT?String(t.text||""):n===kt.HARD_BREAK?`
44
44
  `:Ms((t==null?void 0:t.content)||[])}).join("")}function Dg(e=[]){return Ms(e)}function Lg(e={}){var n,o;const t=Mn(e);return t.type===$t.IMAGE?{type:kt.IMAGE_BLOCK,attrs:{clientId:t.clientId,src:String(t.content||"")}}:t.type===$t.IMPORTED_TEXT?{type:kt.IMPORTED_TEXT_BLOCK,attrs:{clientId:t.clientId,fileName:String(((n=t.meta)==null?void 0:n.fileName)||""),collapsed:!!((o=t.meta)!=null&&o.collapsed)},content:So(t.content)}:{type:kt.TEXT_BLOCK,attrs:{clientId:t.clientId},content:So(t.content)}}function Sa(e=[]){return xn(e).map(Lg)}function vs(e=[]){return{type:kt.DOC,content:Sa(e)}}function Bg(e={}){var t,n,o,s,r,l;return(e==null?void 0:e.type)===kt.IMAGE_BLOCK?Mn({type:$t.IMAGE,content:String(((t=e.attrs)==null?void 0:t.src)||""),clientId:String(((n=e.attrs)==null?void 0:n.clientId)||""),meta:{}}):(e==null?void 0:e.type)===kt.IMPORTED_TEXT_BLOCK?Mn({type:$t.IMPORTED_TEXT,content:Ms(e.content||[]),clientId:String(((o=e.attrs)==null?void 0:o.clientId)||""),meta:{fileName:String(((s=e.attrs)==null?void 0:s.fileName)||""),collapsed:!!((r=e.attrs)!=null&&r.collapsed)}}):(e==null?void 0:e.type)===kt.TEXT_BLOCK?Mn({type:$t.TEXT,content:Ms(e.content||[]),clientId:String(((l=e.attrs)==null?void 0:l.clientId)||""),meta:{}}):null}function Mg(e=null){const n=(Array.isArray(e==null?void 0:e.content)?e.content:[]).map(Bg).filter(Boolean);return xn(n)}function Gn(e=[]){return JSON.stringify(xn(e).map(t=>{var n,o;return{type:(t==null?void 0:t.type)||"",content:String((t==null?void 0:t.content)||""),meta:{fileName:String(((n=t==null?void 0:t.meta)==null?void 0:n.fileName)||""),collapsed:!!((o=t==null?void 0:t.meta)!=null&&o.collapsed)}}}))}function Rg(e=""){const t=String(e);return{lines:t?t.split(`
45
45
  `).length:0,chars:t.length}}function Es(e){var l;const t=(l=e==null?void 0:e.view)==null?void 0:l.dom;if(!(t instanceof HTMLElement))return;const n=t.closest('[data-promptx-editor-scroll="tiptap"]'),o=n instanceof HTMLElement?n.scrollTop:null,s=n instanceof HTMLElement?n.scrollLeft:null,r=()=>{t.focus({preventScroll:!0}),n instanceof HTMLElement&&o!==null&&(n.scrollTop=o,n.scrollLeft=s??0)};if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){window.requestAnimationFrame(r);return}queueMicrotask(r)}const Ng={class:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-x-3 gap-y-1.5","data-promptx-imported-meta":""},Og=["aria-expanded"],jg={class:"theme-heading inline-flex items-center gap-1.5 text-xs font-medium leading-5"},Fg=["aria-expanded"],Ug={class:"mt-0.5 break-all text-[12px] leading-4 text-[var(--theme-textSecondary)]"},Vg=["aria-label"],zg={class:"max-h-[8.5rem] overflow-hidden whitespace-pre-wrap break-words leading-6"},Hg={key:0,class:"pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-[var(--theme-appPanelMuted)] to-transparent"},qg={key:1,class:"theme-muted-text absolute bottom-2 right-4 bg-[var(--theme-appPanelMuted)] pl-2 text-xs"},uo="tool-button inline-flex min-w-0 items-center justify-center gap-1 whitespace-nowrap px-2 py-1 text-[12px]",Kg={__name:"TiptapImportedTextBlockView",props:To,setup(e){const t=e,{t:n}=St(),o=W(()=>{var b;return Dg(((b=t.node)==null?void 0:b.content)||[])}),s=W(()=>{var b,v;return String(((v=(b=t.node)==null?void 0:b.attrs)==null?void 0:v.fileName)||n("blockEditor.unnamedFile"))}),r=W(()=>{const b=Rg(o.value);return n("blockEditor.stats",b)}),l=W(()=>n("blockEditor.fileSummary",{name:s.value,stats:r.value})),c=W(()=>{const b=String(o.value||"").replace(/\r\n/g,`
46
46
  `),v=b.split(`
47
47
  `),P=[];let ne=0;for(const O of v){const z=O.trimEnd(),U=z.length?z:"";if(!(!U&&P[P.length-1]==="")&&(P.push(U),ne+=U.length,P.length>=4||ne>=220))break}const y=P.join(`
48
- `).trim(),L=b.trim();return{text:y,truncated:P.length<v.length||y.length<L.length}}),p=`${uo} tool-button-danger-subtle`;function w(b){b.key!=="Enter"&&b.key!==" "||(b.preventDefault(),d())}function d(){var b,v,P;(P=t.updateAttributes)==null||P.call(t,{collapsed:!((v=(b=t.node)==null?void 0:b.attrs)!=null&&v.collapsed)}),Es(t.editor)}function m(){var y;const{editor:b,getPos:v,node:P}=t;if(!b||typeof v!="function"||!P)return;const ne=v();b.chain().focus().insertContentAt({from:ne,to:ne+P.nodeSize},{type:kt.TEXT_BLOCK,attrs:{clientId:String(((y=P.attrs)==null?void 0:y.clientId)||"")},content:Ig(o.value)}).run(),Es(t.editor)}function f(){var b;(b=t.deleteNode)==null||b.call(t),Es(t.editor)}return(b,v)=>(g(),Ce(a(Co),{class:"group relative","data-promptx-node":"imported_text"},{default:Je(()=>[ue(ya,{selected:b.selected,"frame-class":"dashed-panel","header-class":"theme-secondary-text border-dashed","header-padding-class":"px-3 py-2"},{header:Je(({actionsStateClass:P})=>{var ne,y,L,O;return[i("div",Ng,[i("div",{class:"min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((ne=b.node.attrs)!=null&&ne.collapsed)),onClick:d,onKeydown:w},[i("p",jg,[ue(a(Ds),{class:"h-3.5 w-3.5 shrink-0"}),an(" "+S(a(n)("blockEditor.file")),1)])],40,Og),i("div",{"data-promptx-imported-actions":"",class:Se(["col-start-2 row-start-1 flex shrink-0 flex-wrap items-center justify-end gap-1 self-start transition",P])},[i("button",{type:"button",class:Se(uo),contenteditable:"false",onClick:d},[ue(a(ko),{class:Se(["h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5",(y=b.node.attrs)!=null&&y.collapsed?"rotate-180":""])},null,8,["class"]),i("span",null,S((L=b.node.attrs)!=null&&L.collapsed?a(n)("blockEditor.expand"):a(n)("blockEditor.collapse")),1)]),i("button",{type:"button",class:Se(uo),contenteditable:"false",onClick:m},[ue(a(Ds),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,S(a(n)("blockEditor.convertToText")),1)]),i("button",{type:"button",class:Se(p),contenteditable:"false",onClick:f},[ue(a(js),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,S(a(n)("blockEditor.delete")),1)])],2),i("div",{class:"col-span-2 min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((O=b.node.attrs)!=null&&O.collapsed)),onClick:d,onKeydown:w},[i("p",Ug,S(l.value),1)],40,Fg)])]}),default:Je(()=>{var P,ne;return[Wt(i("div",{class:"theme-secondary-text relative cursor-pointer px-4 py-3 text-[12px] font-mono","data-promptx-imported-preview":"",role:"button",tabindex:"0","aria-label":a(n)("blockEditor.expand"),onClick:d,onKeydown:w},[i("div",zg,S(c.value.text||a(n)("blockEditor.emptyContent")),1),c.value.truncated?(g(),x("div",Hg)):me("",!0),c.value.truncated?(g(),x("span",qg,"...")):me("",!0)],40,Vg),[[$s,(P=b.node.attrs)==null?void 0:P.collapsed]]),Wt(ue(a(Pr),{as:"div","data-promptx-node-content":"imported_text",class:"min-h-[56px] whitespace-pre-wrap break-words px-4 py-4 font-mono text-[12px] leading-7 text-[var(--theme-textPrimary)] outline-none"},null,512),[[$s,!((ne=b.node.attrs)!=null&&ne.collapsed)]])]}),_:1},8,["selected"])]),_:1}))}},Wg={class:"flex min-w-0 items-center justify-between gap-3"},Gg={class:"theme-heading min-w-0 inline-flex items-center gap-1.5 text-xs font-medium leading-5"},Xg={class:"mx-auto flex w-full max-w-[720px] justify-center px-4 py-4"},Yg=["src","alt"],Jg="tool-button tool-button-danger-subtle inline-flex min-w-0 items-center justify-center gap-1 whitespace-nowrap px-2 py-1 text-[12px]",Qg={__name:"TiptapImageBlockView",props:To,setup(e){const t=e,{t:n}=St();function o(){var r,l;typeof window>"u"||window.dispatchEvent(new CustomEvent("promptx:tiptap-image-preview",{detail:{src:String(((l=(r=t.node)==null?void 0:r.attrs)==null?void 0:l.src)||"")}}))}function s(){var r;(r=t.deleteNode)==null||r.call(t),Es(t.editor)}return(r,l)=>(g(),Ce(a(Co),{class:"group","data-promptx-node":"image"},{default:Je(()=>[ue(ya,{selected:r.selected,"frame-class":"theme-inline-panel border","header-class":"theme-muted-text","header-padding-class":"px-3 py-2"},{header:Je(({actionsStateClass:c})=>[i("div",Wg,[i("div",Gg,[ue(a($r),{class:"h-3.5 w-3.5 shrink-0"}),an(" "+S(a(n)("blockEditor.image")),1)]),i("div",{class:Se(["shrink-0 transition",c])},[i("button",{type:"button",class:Se(Jg),contenteditable:"false",onClick:s},[ue(a(js),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,S(a(n)("blockEditor.delete")),1)])],2)])]),default:Je(()=>{var c;return[i("div",Xg,[i("button",{type:"button",class:"inline-flex cursor-zoom-in justify-center",contenteditable:"false",onClick:o},[i("img",{src:(c=r.node.attrs)==null?void 0:c.src,alt:a(n)("blockEditor.insertedImageAlt"),class:"max-h-[380px] w-auto max-w-full object-contain"},null,8,Yg)])])]}),_:1},8,["selected"])]),_:1}))}},Zg=["accept"],dr=10*1024*1024,fr=2*1024*1024,pr=8*1024*1024,eh=1500,th={__name:"TiptapBlockEditor",props:{modelValue:{type:Array,required:!0},codexSessionId:{type:String,default:""},sendBehavior:{type:String,default:"shift_enter"}},emits:["update:modelValue","upload-files","import-text-files","import-pdf-files","clear-request","file-feedback","send-request"],setup(e,{expose:t,emit:n}){const o=e,s=n,{t:r}=St(),l=new Set([".md",".markdown",".txt",".js",".mjs",".cjs",".ts",".mts",".cts",".jsx",".tsx",".vue",".json",".css",".scss",".sass",".less",".html",".htm",".xml",".svg",".yml",".yaml",".toml",".ini",".conf",".env",".py",".java",".go",".rs",".rb",".php",".sh",".bash",".zsh",".sql",".c",".cc",".cpp",".h",".hpp",".cs",".kt",".swift",".log",".csv"]),c=new Set(["application/json","application/ld+json","application/xml","application/javascript","application/x-javascript","application/typescript","application/x-typescript","application/yaml","application/x-yaml","application/toml","application/x-toml","application/x-sh","application/x-shellscript","application/sql"]),p=["image/*",".md,.markdown,.txt,.js,.mjs,.cjs,.ts,.mts,.cts,.jsx,.tsx,.vue,.json,.css,.scss,.sass,.less,.html,.htm,.xml,.svg,.yml,.yaml,.toml,.ini,.conf,.env,.py,.java,.go,.rs,.rb,.php,.sh,.bash,.zsh,.sql,.c,.cc,.cpp,.h,.hpp,.cs,.kt,.swift,.log,.csv",".pdf","text/plain","text/markdown","text/*","application/json","application/xml","application/javascript","application/typescript","application/yaml","application/x-yaml","application/toml","application/x-toml","application/x-sh","application/x-shellscript","application/sql","application/pdf"].join(","),w=q(null),d=q(null),m=q(""),f=q(Xe()),b=q(null),v=q(null),P=q(!1),ne=q(0),y=W(()=>xn(o.modelValue)),L=W(()=>y.value.filter(T=>(T==null?void 0:T.type)===$t.IMAGE&&String(T.content||"").trim()).map(T=>String(T.content||"").trim()));let O=Gn(y.value);function z(T=G.value){if(!T)return!1;const j=Mg(T.getJSON()),te=Gn(j);return te===O?!1:(O=te,s("update:modelValue",j),!0)}const U=Xa.extend({name:kt.TEXT_BLOCK,group:"block",content:"inline*",addAttributes(){return{clientId:{default:""}}},addNodeView(){return Xs(Ag)}}),se=Vo.create({name:kt.IMPORTED_TEXT_BLOCK,group:"block",content:"inline*",defining:!0,selectable:!0,draggable:!1,addAttributes(){return{clientId:{default:""},fileName:{default:""},collapsed:{default:!1}}},parseHTML(){return[{tag:'div[data-type="promptx-imported-text-block"]'}]},renderHTML({HTMLAttributes:T}){return["div",{...T,"data-type":"promptx-imported-text-block"}]},addNodeView(){return Xs(Kg)}}),A=Vo.create({name:kt.IMAGE_BLOCK,group:"block",atom:!0,selectable:!0,draggable:!1,addAttributes(){return{clientId:{default:""},src:{default:""}}},parseHTML(){return[{tag:'div[data-type="promptx-image-block"]'}]},renderHTML({HTMLAttributes:T}){return["div",{...T,"data-type":"promptx-image-block"}]},addNodeView(){return Xs(Qg)}}),G=Ya({extensions:[Ja.configure({paragraph:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,codeBlock:!1,horizontalRule:!1,listItem:!1,bold:!1,italic:!1,strike:!1,code:!1,dropcursor:!0,gapcursor:!0}),U,se,A],autofocus:!1,editorProps:{attributes:{class:"tiptap-editor min-h-full outline-none"},handleKeyDown(T,j){return xa(j,{sendBehavior:o.sendBehavior,isEditing:!0,isComposing:ge()})?(j.preventDefault(),j.stopPropagation(),s("send-request"),!0):!j.shiftKey&&!j.altKey&&(j.metaKey||j.ctrlKey)&&String(j.key||"").toLowerCase()==="k"?dt():Ct(j)}},content:vs(y.value),onCreate({editor:T}){ht(T)},onFocus({editor:T}){P.value=!0,ht(T)},onBlur(){P.value=!1},onSelectionUpdate({editor:T}){ht(T)},onUpdate({editor:T}){ne.value=Date.now(),z(T),ht(T)}});$e(G,T=>{if(!T)return;const j=xn(o.modelValue);O=Gn(j),T.commands.setContent(vs(j),!1)},{immediate:!0}),$e(()=>o.modelValue,T=>{const j=G.value;if(!j){O=Gn(xn(T));return}const te=xn(T),ye=Gn(te);ye!==O&&(O=ye,j.commands.setContent(vs(te),!1))},{deep:!0});function ce(T){const j=String(T||"").trim();j&&s("file-feedback",j)}function pe(T){const j=String((T==null?void 0:T.name)||"").trim().toLowerCase();return j.includes(".")?`.${j.split(".").pop()}`:""}function I(T,j){return String((T==null?void 0:T.name)||"").trim()||r(j)}function Q(T){const j=Math.max(0,Number(T)||0);return j>=1024*1024?`${(j/(1024*1024)).toFixed(j>=10*1024*1024?0:1)} MB`:j>=1024?`${Math.round(j/1024)} KB`:`${j} B`}function le(T){if(!T)return!1;const j=String(T.type||"").toLowerCase(),te=pe(T);return j.startsWith("text/")||l.has(te)||c.has(j)}function ie(T){if(!T)return!1;const j=String(T.name||"").toLowerCase(),te=String(T.type||"").toLowerCase();return j.endsWith(".pdf")||te==="application/pdf"}function ve(T){const j=Array.from(T||[]).filter(Boolean),te={imageFiles:[],textFiles:[],pdfFiles:[]},ye=[],Oe=[];return j.forEach(Re=>{if(Re.type.startsWith("image/")){if(Re.size>dr){Oe.push({name:I(Re,"blockEditor.unnamedImage"),limit:Q(dr)});return}te.imageFiles.push(Re);return}if(ie(Re)){if(Re.size>pr){Oe.push({name:I(Re,"blockEditor.unnamedPdf"),limit:Q(pr)});return}te.pdfFiles.push(Re);return}if(le(Re)){if(Re.size>fr){Oe.push({name:I(Re,"blockEditor.unnamedFile"),limit:Q(fr)});return}te.textFiles.push(Re);return}ye.push(I(Re,"blockEditor.unnamedFile"))}),{...te,unsupportedFiles:ye,oversizedFiles:Oe}}function _({unsupportedFiles:T=[],oversizedFiles:j=[]}={}){var te;T.length&&ce(r("blockEditor.unsupportedFiles",{names:T.slice(0,3).join("、"),extra:Math.max(0,T.length-3)})),j.length&&ce(r("blockEditor.oversizedFiles",{names:j.slice(0,2).map(ye=>ye.name).join("、"),extra:Math.max(0,j.length-2),limit:((te=j[0])==null?void 0:te.limit)||""}))}function H(T){const{imageFiles:j,textFiles:te,pdfFiles:ye,unsupportedFiles:Oe,oversizedFiles:Re}=ve(T);return _({unsupportedFiles:Oe,oversizedFiles:Re}),te.length&&s("import-text-files",te),ye.length&&s("import-pdf-files",ye),j.length&&s("upload-files",j),j.length+te.length+ye.length>0}function F(T){const j=[...T.clipboardData.items].filter(te=>te.kind==="file").map(te=>te.getAsFile()).filter(Boolean);j.length&&(T.preventDefault(),H(j))}function He(T){T.preventDefault(),H(T.dataTransfer.files)}function De(T){const j=G.value;if(!j)return;const te=T.target instanceof Element?T.target:null,ye=T.currentTarget instanceof Element?T.currentTarget:null,Oe=j.view.dom instanceof Element?j.view.dom:null;!te||!ye||!Oe||te.closest('button, input, textarea, select, a, [contenteditable="false"]')||!ye.contains(te)||te.closest("[data-promptx-node]")||!(te===ye||te===Oe||ye.contains(te))||(T.preventDefault(),Ke())}function Fe(T){H(T.target.files),T.target.value=""}function je(){var T;(T=w.value)==null||T.click()}function Ke(){const T=G.value;T&&T.chain().focus("end").run()}function tt(){var te,ye;const T=G.value;if(!T)return!1;(ye=(te=T.view.domObserver)==null?void 0:te.flush)==null||ye.call(te);const j=z(T);return j&&(ne.value=Date.now()),ht(T),j}function xe(T=[]){const j=G.value;!j||!T.length||j.chain().focus().insertContent(T).run()}function R(T=[]){xe(Sa(T))}function J(T=[]){R(T)}function fe(T=[]){R(T)}function _e(){const T=G.value;T&&T.commands.setContent(vs([Pn("")]),!0)}function ge(){var T,j;return!!((j=(T=G.value)==null?void 0:T.view)!=null&&j.composing)}function Ie(){var T;return ge()||P.value||(T=G.value)!=null&&T.isFocused?!0:Date.now()-ne.value<eh}function Ae(){var ye;const T=G.value;if(!T)return!1;const j=T.state.selection,te=j.$from.nodeAfter||j.$from.parent;return((ye=te==null?void 0:te.type)==null?void 0:ye.name)===kt.IMPORTED_TEXT_BLOCK}function Be(T){var te;const j=String(((te=T==null?void 0:T.detail)==null?void 0:te.src)||"").trim();j&&(m.value=j)}function Xe(){return{open:!1,start:-1,end:-1,query:"",trigger:"mention",blockType:"",clientId:""}}function Pe(T=null,j=null){return!T||!j?!1:T.start===j.start&&T.end===j.end&&T.query===j.query&&T.clientId===j.clientId}function it(){b.value=null}function Me(T={}){const{suppressCurrent:j=!1}=T,te=f.value;j&&te.open&&(v.value={start:te.start,end:te.end,query:te.query,clientId:te.clientId}),f.value=Xe(),it()}function Ne(){Me({suppressCurrent:!0})}function Ee(T=G.value){var Ge,Ye,nt;if(!T)return null;const j=T.state.selection;if(!j.empty)return null;const{$from:te,from:ye}=j,Oe=((Ye=(Ge=te.parent)==null?void 0:Ge.type)==null?void 0:Ye.name)||"";if(![kt.TEXT_BLOCK,kt.IMPORTED_TEXT_BLOCK].includes(Oe))return null;const Re=te.parent.textBetween(0,te.parentOffset,`
48
+ `).trim(),L=b.trim();return{text:y,truncated:P.length<v.length||y.length<L.length}}),p=`${uo} tool-button-danger-subtle`;function S(b){b.key!=="Enter"&&b.key!==" "||(b.preventDefault(),d())}function d(){var b,v,P;(P=t.updateAttributes)==null||P.call(t,{collapsed:!((v=(b=t.node)==null?void 0:b.attrs)!=null&&v.collapsed)}),Es(t.editor)}function m(){var y;const{editor:b,getPos:v,node:P}=t;if(!b||typeof v!="function"||!P)return;const ne=v();b.chain().focus().insertContentAt({from:ne,to:ne+P.nodeSize},{type:kt.TEXT_BLOCK,attrs:{clientId:String(((y=P.attrs)==null?void 0:y.clientId)||"")},content:Ig(o.value)}).run(),Es(t.editor)}function f(){var b;(b=t.deleteNode)==null||b.call(t),Es(t.editor)}return(b,v)=>(g(),Ce(a(Co),{class:"group relative","data-promptx-node":"imported_text"},{default:Je(()=>[ue(ya,{selected:b.selected,"frame-class":"dashed-panel","header-class":"theme-secondary-text border-dashed","header-padding-class":"px-3 py-2"},{header:Je(({actionsStateClass:P})=>{var ne,y,L,O;return[i("div",Ng,[i("div",{class:"min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((ne=b.node.attrs)!=null&&ne.collapsed)),onClick:d,onKeydown:S},[i("p",jg,[ue(a(Ds),{class:"h-3.5 w-3.5 shrink-0"}),an(" "+w(a(n)("blockEditor.file")),1)])],40,Og),i("div",{"data-promptx-imported-actions":"",class:Se(["col-start-2 row-start-1 flex shrink-0 flex-wrap items-center justify-end gap-1 self-start transition",P])},[i("button",{type:"button",class:Se(uo),contenteditable:"false",onClick:d},[ue(a(ko),{class:Se(["h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5",(y=b.node.attrs)!=null&&y.collapsed?"rotate-180":""])},null,8,["class"]),i("span",null,w((L=b.node.attrs)!=null&&L.collapsed?a(n)("blockEditor.expand"):a(n)("blockEditor.collapse")),1)]),i("button",{type:"button",class:Se(uo),contenteditable:"false",onClick:m},[ue(a(Ds),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,w(a(n)("blockEditor.convertToText")),1)]),i("button",{type:"button",class:Se(p),contenteditable:"false",onClick:f},[ue(a(js),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,w(a(n)("blockEditor.delete")),1)])],2),i("div",{class:"col-span-2 min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((O=b.node.attrs)!=null&&O.collapsed)),onClick:d,onKeydown:S},[i("p",Ug,w(l.value),1)],40,Fg)])]}),default:Je(()=>{var P,ne;return[Wt(i("div",{class:"theme-secondary-text relative cursor-pointer px-4 py-3 text-[12px] font-mono","data-promptx-imported-preview":"",role:"button",tabindex:"0","aria-label":a(n)("blockEditor.expand"),onClick:d,onKeydown:S},[i("div",zg,w(c.value.text||a(n)("blockEditor.emptyContent")),1),c.value.truncated?(g(),x("div",Hg)):me("",!0),c.value.truncated?(g(),x("span",qg,"...")):me("",!0)],40,Vg),[[$s,(P=b.node.attrs)==null?void 0:P.collapsed]]),Wt(ue(a(Pr),{as:"div","data-promptx-node-content":"imported_text",class:"min-h-[56px] whitespace-pre-wrap break-words px-4 py-4 font-mono text-[12px] leading-7 text-[var(--theme-textPrimary)] outline-none"},null,512),[[$s,!((ne=b.node.attrs)!=null&&ne.collapsed)]])]}),_:1},8,["selected"])]),_:1}))}},Wg={class:"flex min-w-0 items-center justify-between gap-3"},Gg={class:"theme-heading min-w-0 inline-flex items-center gap-1.5 text-xs font-medium leading-5"},Xg={class:"mx-auto flex w-full max-w-[720px] justify-center px-4 py-4"},Yg=["src","alt"],Jg="tool-button tool-button-danger-subtle inline-flex min-w-0 items-center justify-center gap-1 whitespace-nowrap px-2 py-1 text-[12px]",Qg={__name:"TiptapImageBlockView",props:To,setup(e){const t=e,{t:n}=St();function o(){var r,l;typeof window>"u"||window.dispatchEvent(new CustomEvent("promptx:tiptap-image-preview",{detail:{src:String(((l=(r=t.node)==null?void 0:r.attrs)==null?void 0:l.src)||"")}}))}function s(){var r;(r=t.deleteNode)==null||r.call(t),Es(t.editor)}return(r,l)=>(g(),Ce(a(Co),{class:"group","data-promptx-node":"image"},{default:Je(()=>[ue(ya,{selected:r.selected,"frame-class":"theme-inline-panel border","header-class":"theme-muted-text","header-padding-class":"px-3 py-2"},{header:Je(({actionsStateClass:c})=>[i("div",Wg,[i("div",Gg,[ue(a($r),{class:"h-3.5 w-3.5 shrink-0"}),an(" "+w(a(n)("blockEditor.image")),1)]),i("div",{class:Se(["shrink-0 transition",c])},[i("button",{type:"button",class:Se(Jg),contenteditable:"false",onClick:s},[ue(a(js),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,w(a(n)("blockEditor.delete")),1)])],2)])]),default:Je(()=>{var c;return[i("div",Xg,[i("button",{type:"button",class:"inline-flex cursor-zoom-in justify-center",contenteditable:"false",onClick:o},[i("img",{src:(c=r.node.attrs)==null?void 0:c.src,alt:a(n)("blockEditor.insertedImageAlt"),class:"max-h-[380px] w-auto max-w-full object-contain"},null,8,Yg)])])]}),_:1},8,["selected"])]),_:1}))}},Zg=["accept"],dr=10*1024*1024,fr=2*1024*1024,pr=8*1024*1024,eh=1500,th={__name:"TiptapBlockEditor",props:{modelValue:{type:Array,required:!0},codexSessionId:{type:String,default:""},sendBehavior:{type:String,default:"shift_enter"}},emits:["update:modelValue","upload-files","import-text-files","import-pdf-files","clear-request","file-feedback","send-request"],setup(e,{expose:t,emit:n}){const o=e,s=n,{t:r}=St(),l=new Set([".md",".markdown",".txt",".js",".mjs",".cjs",".ts",".mts",".cts",".jsx",".tsx",".vue",".json",".css",".scss",".sass",".less",".html",".htm",".xml",".svg",".yml",".yaml",".toml",".ini",".conf",".env",".py",".java",".go",".rs",".rb",".php",".sh",".bash",".zsh",".sql",".c",".cc",".cpp",".h",".hpp",".cs",".kt",".swift",".log",".csv"]),c=new Set(["application/json","application/ld+json","application/xml","application/javascript","application/x-javascript","application/typescript","application/x-typescript","application/yaml","application/x-yaml","application/toml","application/x-toml","application/x-sh","application/x-shellscript","application/sql"]),p=["image/*",".md,.markdown,.txt,.js,.mjs,.cjs,.ts,.mts,.cts,.jsx,.tsx,.vue,.json,.css,.scss,.sass,.less,.html,.htm,.xml,.svg,.yml,.yaml,.toml,.ini,.conf,.env,.py,.java,.go,.rs,.rb,.php,.sh,.bash,.zsh,.sql,.c,.cc,.cpp,.h,.hpp,.cs,.kt,.swift,.log,.csv",".pdf","text/plain","text/markdown","text/*","application/json","application/xml","application/javascript","application/typescript","application/yaml","application/x-yaml","application/toml","application/x-toml","application/x-sh","application/x-shellscript","application/sql","application/pdf"].join(","),S=q(null),d=q(null),m=q(""),f=q(Xe()),b=q(null),v=q(null),P=q(!1),ne=q(0),y=W(()=>xn(o.modelValue)),L=W(()=>y.value.filter(T=>(T==null?void 0:T.type)===$t.IMAGE&&String(T.content||"").trim()).map(T=>String(T.content||"").trim()));let O=Gn(y.value);function z(T=G.value){if(!T)return!1;const j=Mg(T.getJSON()),te=Gn(j);return te===O?!1:(O=te,s("update:modelValue",j),!0)}const U=Xa.extend({name:kt.TEXT_BLOCK,group:"block",content:"inline*",addAttributes(){return{clientId:{default:""}}},addNodeView(){return Xs(Ag)}}),se=Vo.create({name:kt.IMPORTED_TEXT_BLOCK,group:"block",content:"inline*",defining:!0,selectable:!0,draggable:!1,addAttributes(){return{clientId:{default:""},fileName:{default:""},collapsed:{default:!1}}},parseHTML(){return[{tag:'div[data-type="promptx-imported-text-block"]'}]},renderHTML({HTMLAttributes:T}){return["div",{...T,"data-type":"promptx-imported-text-block"}]},addNodeView(){return Xs(Kg)}}),A=Vo.create({name:kt.IMAGE_BLOCK,group:"block",atom:!0,selectable:!0,draggable:!1,addAttributes(){return{clientId:{default:""},src:{default:""}}},parseHTML(){return[{tag:'div[data-type="promptx-image-block"]'}]},renderHTML({HTMLAttributes:T}){return["div",{...T,"data-type":"promptx-image-block"}]},addNodeView(){return Xs(Qg)}}),G=Ya({extensions:[Ja.configure({paragraph:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,codeBlock:!1,horizontalRule:!1,listItem:!1,bold:!1,italic:!1,strike:!1,code:!1,dropcursor:!0,gapcursor:!0}),U,se,A],autofocus:!1,editorProps:{attributes:{class:"tiptap-editor min-h-full outline-none"},handleKeyDown(T,j){return xa(j,{sendBehavior:o.sendBehavior,isEditing:!0,isComposing:ge()})?(j.preventDefault(),j.stopPropagation(),s("send-request"),!0):!j.shiftKey&&!j.altKey&&(j.metaKey||j.ctrlKey)&&String(j.key||"").toLowerCase()==="k"?dt():Ct(j)}},content:vs(y.value),onCreate({editor:T}){ht(T)},onFocus({editor:T}){P.value=!0,ht(T)},onBlur(){P.value=!1},onSelectionUpdate({editor:T}){ht(T)},onUpdate({editor:T}){ne.value=Date.now(),z(T),ht(T)}});$e(G,T=>{if(!T)return;const j=xn(o.modelValue);O=Gn(j),T.commands.setContent(vs(j),!1)},{immediate:!0}),$e(()=>o.modelValue,T=>{const j=G.value;if(!j){O=Gn(xn(T));return}const te=xn(T),ye=Gn(te);ye!==O&&(O=ye,j.commands.setContent(vs(te),!1))},{deep:!0});function ce(T){const j=String(T||"").trim();j&&s("file-feedback",j)}function pe(T){const j=String((T==null?void 0:T.name)||"").trim().toLowerCase();return j.includes(".")?`.${j.split(".").pop()}`:""}function I(T,j){return String((T==null?void 0:T.name)||"").trim()||r(j)}function Q(T){const j=Math.max(0,Number(T)||0);return j>=1024*1024?`${(j/(1024*1024)).toFixed(j>=10*1024*1024?0:1)} MB`:j>=1024?`${Math.round(j/1024)} KB`:`${j} B`}function le(T){if(!T)return!1;const j=String(T.type||"").toLowerCase(),te=pe(T);return j.startsWith("text/")||l.has(te)||c.has(j)}function ie(T){if(!T)return!1;const j=String(T.name||"").toLowerCase(),te=String(T.type||"").toLowerCase();return j.endsWith(".pdf")||te==="application/pdf"}function ve(T){const j=Array.from(T||[]).filter(Boolean),te={imageFiles:[],textFiles:[],pdfFiles:[]},ye=[],Oe=[];return j.forEach(Re=>{if(Re.type.startsWith("image/")){if(Re.size>dr){Oe.push({name:I(Re,"blockEditor.unnamedImage"),limit:Q(dr)});return}te.imageFiles.push(Re);return}if(ie(Re)){if(Re.size>pr){Oe.push({name:I(Re,"blockEditor.unnamedPdf"),limit:Q(pr)});return}te.pdfFiles.push(Re);return}if(le(Re)){if(Re.size>fr){Oe.push({name:I(Re,"blockEditor.unnamedFile"),limit:Q(fr)});return}te.textFiles.push(Re);return}ye.push(I(Re,"blockEditor.unnamedFile"))}),{...te,unsupportedFiles:ye,oversizedFiles:Oe}}function _({unsupportedFiles:T=[],oversizedFiles:j=[]}={}){var te;T.length&&ce(r("blockEditor.unsupportedFiles",{names:T.slice(0,3).join("、"),extra:Math.max(0,T.length-3)})),j.length&&ce(r("blockEditor.oversizedFiles",{names:j.slice(0,2).map(ye=>ye.name).join("、"),extra:Math.max(0,j.length-2),limit:((te=j[0])==null?void 0:te.limit)||""}))}function H(T){const{imageFiles:j,textFiles:te,pdfFiles:ye,unsupportedFiles:Oe,oversizedFiles:Re}=ve(T);return _({unsupportedFiles:Oe,oversizedFiles:Re}),te.length&&s("import-text-files",te),ye.length&&s("import-pdf-files",ye),j.length&&s("upload-files",j),j.length+te.length+ye.length>0}function F(T){const j=[...T.clipboardData.items].filter(te=>te.kind==="file").map(te=>te.getAsFile()).filter(Boolean);j.length&&(T.preventDefault(),H(j))}function He(T){T.preventDefault(),H(T.dataTransfer.files)}function De(T){const j=G.value;if(!j)return;const te=T.target instanceof Element?T.target:null,ye=T.currentTarget instanceof Element?T.currentTarget:null,Oe=j.view.dom instanceof Element?j.view.dom:null;!te||!ye||!Oe||te.closest('button, input, textarea, select, a, [contenteditable="false"]')||!ye.contains(te)||te.closest("[data-promptx-node]")||!(te===ye||te===Oe||ye.contains(te))||(T.preventDefault(),Ke())}function Fe(T){H(T.target.files),T.target.value=""}function je(){var T;(T=S.value)==null||T.click()}function Ke(){const T=G.value;T&&T.chain().focus("end").run()}function tt(){var te,ye;const T=G.value;if(!T)return!1;(ye=(te=T.view.domObserver)==null?void 0:te.flush)==null||ye.call(te);const j=z(T);return j&&(ne.value=Date.now()),ht(T),j}function xe(T=[]){const j=G.value;!j||!T.length||j.chain().focus().insertContent(T).run()}function R(T=[]){xe(Sa(T))}function J(T=[]){R(T)}function fe(T=[]){R(T)}function _e(){const T=G.value;T&&T.commands.setContent(vs([Pn("")]),!0)}function ge(){var T,j;return!!((j=(T=G.value)==null?void 0:T.view)!=null&&j.composing)}function Ie(){var T;return ge()||P.value||(T=G.value)!=null&&T.isFocused?!0:Date.now()-ne.value<eh}function Ae(){var ye;const T=G.value;if(!T)return!1;const j=T.state.selection,te=j.$from.nodeAfter||j.$from.parent;return((ye=te==null?void 0:te.type)==null?void 0:ye.name)===kt.IMPORTED_TEXT_BLOCK}function Be(T){var te;const j=String(((te=T==null?void 0:T.detail)==null?void 0:te.src)||"").trim();j&&(m.value=j)}function Xe(){return{open:!1,start:-1,end:-1,query:"",trigger:"mention",blockType:"",clientId:""}}function Pe(T=null,j=null){return!T||!j?!1:T.start===j.start&&T.end===j.end&&T.query===j.query&&T.clientId===j.clientId}function it(){b.value=null}function Me(T={}){const{suppressCurrent:j=!1}=T,te=f.value;j&&te.open&&(v.value={start:te.start,end:te.end,query:te.query,clientId:te.clientId}),f.value=Xe(),it()}function Ne(){Me({suppressCurrent:!0})}function Ee(T=G.value){var Ge,Ye,nt;if(!T)return null;const j=T.state.selection;if(!j.empty)return null;const{$from:te,from:ye}=j,Oe=((Ye=(Ge=te.parent)==null?void 0:Ge.type)==null?void 0:Ye.name)||"";if(![kt.TEXT_BLOCK,kt.IMPORTED_TEXT_BLOCK].includes(Oe))return null;const Re=te.parent.textBetween(0,te.parentOffset,`
49
49
  `,"\0");return{from:ye,node:te.parent,nodeTypeName:Oe,nodeStart:te.start(),parentOffset:te.parentOffset,clientId:String(((nt=te.parent.attrs)==null?void 0:nt.clientId)||""),textBefore:Re}}function lt(T=f.value.end){const j=G.value;if(typeof T=="object"&&T!==null&&(T=f.value.end),!j||!f.value.open||T<0){it();return}try{const te=j.view.coordsAtPos(T);b.value={left:te.left,right:te.left,top:te.bottom,bottom:te.bottom,width:0,height:0}}catch{it()}}function ht(T=G.value){const j=Ee(T),te=f.value;if(te.open&&te.trigger==="shortcut"){if(!j||j.clientId!==te.clientId||j.from<te.start){Me();return}const Ye=T.state.doc.textBetween(te.start,j.from,`
50
- `,"\0");if(/\s/.test(Ye)){Me();return}v.value=null,f.value={...te,end:j.from,query:Ye},lt(j.from);return}if(!j){Me();return}const ye=j.textBefore.lastIndexOf("@");if(ye<0){Me();return}const Oe=j.textBefore.slice(ye+1);if(/\s/.test(Oe)){Me();return}const Re=j.nodeStart+ye,Ge=j.from;Pe(v.value,{start:Re,end:Ge,query:Oe,clientId:j.clientId})||(v.value=null,f.value={open:!0,start:Re,end:Ge,query:Oe,trigger:"mention",blockType:j.nodeTypeName,clientId:j.clientId},lt(Ge))}function dt(){const T=G.value,j=Ee(T);return!T||!j?!1:(v.value=null,f.value={open:!0,start:j.from,end:j.from,query:"",trigger:"shortcut",blockType:j.nodeTypeName,clientId:j.clientId},lt(j.from),!0)}function wt(T){const j=G.value,te=String((T==null?void 0:T.path)||"").trim(),ye=f.value;if(!j||!te||ye.start<0||ye.end<ye.start)return Me(),!1;const Oe=ye.trigger==="shortcut"?`${te} `:`@${te} `,Re=ye.start+Oe.length;return j.chain().focus().command(({tr:Ge,dispatch:Ye})=>(Ge.insertText(Oe,ye.start,ye.end),Ge.setSelection(Ta.create(Ge.doc,Re)),Ye==null||Ye(Ge),!0)).run(),ne.value=Date.now(),v.value=null,Me(),!0}function Ct(T){var j,te,ye,Oe,Re,Ge,Ye,nt,yt,st;if(!f.value.open)return!1;if(T.key==="Escape")return Ne(),!0;if(T.key==="ArrowDown")return!!((te=(j=d.value)==null?void 0:j.moveActive)!=null&&te.call(j,1));if(T.key==="ArrowUp")return!!((Oe=(ye=d.value)==null?void 0:ye.moveActive)!=null&&Oe.call(ye,-1));if(f.value.query&&(T.key==="ArrowLeft"||T.key==="ArrowRight"))return!1;if(T.key==="ArrowRight"){const ft=(Ge=(Re=d.value)==null?void 0:Re.expandActiveDirectory)==null?void 0:Ge.call(Re);return ft&&typeof ft.then=="function"?(ft.catch(()=>{}),!0):!!ft}return T.key==="ArrowLeft"?!!((nt=(Ye=d.value)==null?void 0:Ye.collapseActiveDirectory)!=null&&nt.call(Ye)):!T.shiftKey&&!T.altKey&&!T.metaKey&&!T.ctrlKey&&T.key==="Enter"?!!((st=(yt=d.value)==null?void 0:yt.confirmActive)!=null&&st.call(yt)):!1}return dn(()=>{window.addEventListener("promptx:tiptap-image-preview",Be),window.addEventListener("resize",lt),window.addEventListener("scroll",lt)}),It(()=>{window.removeEventListener("promptx:tiptap-image-preview",Be),window.removeEventListener("resize",lt),window.removeEventListener("scroll",lt)}),$e(()=>o.codexSessionId,()=>{Me()}),t({clearContent:_e,flushPendingInput:tt,focusEditor:Ke,insertBlocks:R,insertImportedBlocks:J,insertUploadedBlocks:fe,isComposing:ge,isEditing:Ie,isImportedBlockActive:Ae,openFilePicker:je}),(T,j)=>(g(),x("section",{class:"workbench-input-editor relative flex h-full min-h-0 flex-col overflow-hidden","data-promptx-editor":"tiptap",onDrop:He,onDragover:j[1]||(j[1]=Qe(()=>{},["prevent"])),onPaste:F},[i("input",{ref_key:"fileInputRef",ref:w,class:"hidden",type:"file",accept:a(p),multiple:"",onChange:Fe},null,40,Zg),i("div",{class:"flex-1 overflow-y-auto px-5 py-5","data-promptx-editor-scroll":"tiptap",onMousedown:De},[a(G)?(g(),Ce(a(Qa),{key:0,editor:a(G),class:"min-h-full","data-promptx-editor-content":"tiptap"},null,8,["editor"])):me("",!0)],32),ue(Or,{modelValue:m.value,"onUpdate:modelValue":j[0]||(j[0]=te=>m.value=te),images:L.value},null,8,["modelValue","images"]),ue(Eg,{ref_key:"mentionPickerRef",ref:d,open:f.value.open&&!!b.value,"session-id":e.codexSessionId,query:f.value.query,"anchor-rect":b.value,onClose:Ne,onSelect:wt},null,8,["open","session-id","query","anchor-rect"])],32))}},nh={key:0,class:"theme-muted-text flex h-full items-center px-5 py-4 text-sm"},mr={__name:"WorkbenchInputPanel",props:{codexSessionId:{type:String,default:""},sendBehavior:{type:String,default:"shift_enter"},modelValue:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1}},emits:["update:modelValue","upload-files","import-text-files","import-pdf-files","file-feedback","clear-request","send-request"],setup(e,{expose:t,emit:n}){const o=e,s=n,r=q(null),{t:l}=St(),c=W({get:()=>o.modelValue,set:y=>s("update:modelValue",y)});function p(){var y,L;(L=(y=r.value)==null?void 0:y.openFilePicker)==null||L.call(y)}function w(){var y,L;(L=(y=r.value)==null?void 0:y.focusEditor)==null||L.call(y)}function d(){var y,L;return((L=(y=r.value)==null?void 0:y.flushPendingInput)==null?void 0:L.call(y))||!1}function m(y){var L,O;(O=(L=r.value)==null?void 0:L.insertBlocks)==null||O.call(L,y)}function f(y){var L,O;(O=(L=r.value)==null?void 0:L.insertImportedBlocks)==null||O.call(L,y)}function b(y){var L,O;(O=(L=r.value)==null?void 0:L.insertUploadedBlocks)==null||O.call(L,y)}function v(){var y,L;return((L=(y=r.value)==null?void 0:y.isImportedBlockActive)==null?void 0:L.call(y))||!1}function P(){var y,L;return((L=(y=r.value)==null?void 0:y.isComposing)==null?void 0:L.call(y))||!1}function ne(){var y,L;return((L=(y=r.value)==null?void 0:y.isEditing)==null?void 0:L.call(y))||!1}return t({focusEditor:w,flushPendingInput:d,insertBlocks:m,insertImportedBlocks:f,insertUploadedBlocks:b,isComposing:P,isEditing:ne,isImportedBlockActive:v,openFilePicker:p}),(y,L)=>e.loading&&!e.modelValue.length?(g(),x("section",nh,S(a(l)("workbench.loadingTaskContent")),1)):(g(),Ce(th,{key:1,ref_key:"blockEditorRef",ref:r,modelValue:c.value,"onUpdate:modelValue":L[0]||(L[0]=O=>c.value=O),"codex-session-id":e.codexSessionId,"send-behavior":e.sendBehavior,onUploadFiles:L[1]||(L[1]=O=>s("upload-files",O)),onImportTextFiles:L[2]||(L[2]=O=>s("import-text-files",O)),onImportPdfFiles:L[3]||(L[3]=O=>s("import-pdf-files",O)),onFileFeedback:L[4]||(L[4]=O=>s("file-feedback",O)),onClearRequest:L[5]||(L[5]=O=>s("clear-request")),onSendRequest:L[6]||(L[6]=O=>s("send-request"))},null,8,["modelValue","codex-session-id","send-behavior"]))}},sh={class:"panel workbench-mobile-header-panel shrink-0 overflow-hidden"},oh={class:"workbench-panel-header workbench-mobile-header theme-divider border-b px-2.5 py-2"},rh={class:"flex items-center gap-2"},ah=["title","aria-label"],ih={class:"min-w-0 flex-1"},lh=["value","placeholder"],uh=["disabled"],ch={class:"truncate"},dh={__name:"WorkbenchMobileDetailHeader",props:{currentTaskSlug:{type:String,default:""},editingTaskTitleSlug:{type:String,default:""},title:{type:String,default:""},titleInputValue:{type:String,default:""},currentTaskAutoTitle:{type:String,default:""}},emits:["back","begin-edit","title-blur","cancel-title-edit","update:titleInputValue"],setup(e,{emit:t}){const n=t,{t:o}=St();return(s,r)=>(g(),x("section",sh,[i("div",oh,[i("div",rh,[i("button",{type:"button",class:"tool-button inline-flex h-8 w-8 shrink-0 items-center justify-center px-0 py-0 text-[11px]",title:a(o)("workbench.tasks"),"aria-label":a(o)("workbench.tasks"),onClick:r[0]||(r[0]=l=>n("back"))},[ue(a(Fa),{class:"h-3.5 w-3.5"})],8,ah),i("div",ih,[e.currentTaskSlug&&e.editingTaskTitleSlug===e.currentTaskSlug?(g(),x("input",{key:0,value:e.titleInputValue,type:"text",maxlength:"140","data-task-title-input":"current",class:"block w-full appearance-none border-0 bg-transparent p-0 text-left text-[13px] font-semibold leading-5 outline-none placeholder:text-[var(--theme-textMuted)]",placeholder:e.currentTaskAutoTitle||a(o)("workbench.untitledTask"),onInput:r[1]||(r[1]=l=>n("update:titleInputValue",l.target.value)),onKeydown:[r[2]||(r[2]=Gt(Qe(l=>l.target.blur(),["prevent"]),["enter"])),r[3]||(r[3]=Gt(Qe(l=>n("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:r[4]||(r[4]=l=>n("title-blur"))},null,40,lh)):(g(),x("button",{key:1,type:"button",class:"inline-flex w-full items-center gap-1 truncate bg-transparent p-0 text-left text-[13px] font-semibold leading-5",disabled:!e.currentTaskSlug,onClick:r[5]||(r[5]=l=>n("begin-edit"))},[i("span",ch,S(e.title||a(o)("workbench.untitledTask")),1),ue(a(Zn),{class:"h-2.5 w-2.5 shrink-0 opacity-50"})],8,uh))])])])]))}},fh={class:"workbench-sidebar-panel panel flex h-full min-h-0 flex-col overflow-hidden"},ph={class:"workbench-panel-header theme-divider border-b px-4 py-4"},mh={class:"flex items-center justify-between gap-3"},gh={class:"flex min-h-8 items-center"},hh={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},vh=["title"],yh=["disabled","title"],Sh={class:"whitespace-nowrap"},wh={class:"min-h-0 flex-1 overflow-y-auto px-3 py-3"},xh={key:0,class:"theme-empty-state px-3 py-4 text-sm"},bh=["onClick"],kh={key:0,class:"theme-selection-indicator absolute inset-y-2 left-0 w-1 rounded-full"},_h={class:"flex items-start justify-between gap-3"},Th={class:"flex min-w-0 flex-1 items-start gap-2 overflow-hidden"},Ch=["title","aria-label"],Eh={class:"min-w-0 h-5 flex-1 overflow-hidden"},Ah=["value","placeholder"],$h=["title","onClick"],Ih={class:"min-w-0 truncate"},Ph={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},Dh={class:"workbench-task-card__preview mt-2 truncate text-xs opacity-80"},Lh={class:"mt-2 flex items-center justify-between gap-3"},Bh={class:"min-w-0 text-[11px] opacity-70"},Mh={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},Rh={class:"theme-divider border-t px-3 py-3"},Nh={key:0,class:"theme-danger-text mb-3 inline-flex min-w-0 items-start gap-2 text-xs"},Oh={class:"min-w-0 break-words"},jh={class:"grid grid-cols-2 gap-2"},Fh=["disabled","title"],Uh={class:"whitespace-nowrap"},Vh=["disabled","title"],zh={class:"whitespace-nowrap"},Hh={__name:"WorkbenchTaskListPanel",props:{loadingTasks:{type:Boolean,default:!1},tasks:{type:Array,default:()=>[]},currentTaskSlug:{type:String,default:""},editingTaskTitleSlug:{type:String,default:""},draftTitle:{type:String,default:""},currentTaskAutoTitle:{type:String,default:""},creatingTask:{type:Boolean,default:!1},loadingTask:{type:Boolean,default:!1},uploading:{type:Boolean,default:!1},error:{type:String,default:""},removingTask:{type:Boolean,default:!1},isCurrentTaskSending:{type:Boolean,default:!1},mobile:{type:Boolean,default:!1}},emits:["open-settings","create-task","reorder-task","select-task","title-click","title-blur","cancel-title-edit","update:draftTitle","edit-task","delete-task"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=q([]);$e(()=>n.tasks,f=>{r.value=Array.isArray(f)?[...f]:[]},{immediate:!0});function l(f){return f.slug===n.currentTaskSlug?"workbench-task-card--active theme-card-selected":f.sending?"workbench-task-card--running theme-card-warning":"theme-card-idle-muted"}function c(){return"theme-status-warning"}function p(f){const b=new Date(f.updatedAt);return Number.isNaN(b.getTime())?"":xr(b.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function w(f){var b,v;return!!((b=f==null?void 0:f.workspaceDiffSummary)!=null&&b.supported&&((v=f==null?void 0:f.workspaceDiffSummary)!=null&&v.fileCount))}function d(f){return f.slug===n.currentTaskSlug?"theme-badge-strong":"theme-badge-muted"}function m(f){if(n.mobile)return;const b=Number(f==null?void 0:f.oldIndex),v=Number(f==null?void 0:f.newIndex);!Number.isInteger(b)||!Number.isInteger(v)||b===v||o("reorder-task",r.value.map(P=>String((P==null?void 0:P.slug)||"").trim()).filter(Boolean))}return(f,b)=>(g(),x("aside",fh,[i("div",ph,[i("div",mh,[i("div",gh,[i("div",hh,[ue(a(Ua),{class:"h-4 w-4"}),i("span",null,S(a(s)("workbench.title")),1)])]),i("button",{type:"button",class:"tool-button inline-flex items-center gap-2 whitespace-nowrap px-3 py-2 text-xs",title:a(s)("workbench.settings"),onClick:b[0]||(b[0]=v=>o("open-settings"))},[ue(a(Va),{class:"h-4 w-4"}),i("span",{class:Se(e.mobile?"whitespace-nowrap":"hidden whitespace-nowrap sm:inline")},S(a(s)("workbench.settings")),3)],8,vh)]),i("button",{type:"button",class:"tool-button tool-button-primary mt-4 inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:e.creatingTask||e.uploading,title:e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask"),onClick:b[1]||(b[1]=v=>o("create-task"))},[ue(a(Ps),{class:"h-4 w-4"}),i("span",Sh,S(e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask")),1)],8,yh)]),i("div",wh,[e.loadingTasks&&!e.tasks.length?(g(),x("div",xh,S(a(s)("workbench.loadingTasks")),1)):(g(),Ce(a(za),{key:1,modelValue:r.value,"onUpdate:modelValue":b[8]||(b[8]=v=>r.value=v),class:"space-y-2",animation:180,disabled:e.mobile||e.tasks.length<=1,handle:".task-drag-handle","ghost-class":"workbench-task-card--ghost","chosen-class":"workbench-task-card--chosen","drag-class":"workbench-task-card--dragging","fallback-tolerance":"6",onEnd:m},{default:Je(()=>[(g(!0),x(et,null,ut(r.value,v=>{var P,ne;return g(),x("article",{key:v.slug,class:Se(["workbench-task-card group relative cursor-default rounded-sm border px-3 py-3 transition",l(v)]),onClick:y=>o("select-task",v.slug)},[v.slug===e.currentTaskSlug?(g(),x("span",kh)):me("",!0),i("div",_h,[i("div",Th,[e.mobile?me("",!0):(g(),x("button",{key:0,type:"button",class:"task-drag-handle mt-0.5 inline-flex h-4 w-4 shrink-0 cursor-grab items-center justify-center rounded-sm opacity-45 transition hover:opacity-80 active:cursor-grabbing",title:a(s)("workbench.dragToReorder"),"aria-label":a(s)("workbench.dragToReorder"),tabindex:"-1",onClick:b[2]||(b[2]=Qe(()=>{},["stop"]))},[ue(a(Ha),{class:"h-3.5 w-3.5"})],8,Ch)),i("div",Eh,[v.slug===e.currentTaskSlug&&e.editingTaskTitleSlug===v.slug?(g(),x("input",{key:0,value:e.draftTitle,type:"text",maxlength:"140","data-task-title-input":"current",class:"block h-5 min-h-0 w-full appearance-none border-0 bg-transparent p-0 text-left text-sm font-semibold leading-5 outline-none placeholder:text-[var(--theme-textMuted)]",placeholder:e.currentTaskAutoTitle||a(s)("workbench.untitledTask"),onClick:b[3]||(b[3]=Qe(()=>{},["stop"])),onInput:b[4]||(b[4]=y=>o("update:draftTitle",y.target.value)),onKeydown:[b[5]||(b[5]=Gt(Qe(y=>y.target.blur(),["prevent"]),["enter"])),b[6]||(b[6]=Gt(Qe(y=>o("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:b[7]||(b[7]=y=>o("title-blur"))},null,40,Ah)):(g(),x("button",{key:1,type:"button",class:Se(["inline-flex h-5 w-full items-center gap-1.5 truncate bg-transparent p-0 text-left text-sm leading-5",v.slug===e.currentTaskSlug?"font-semibold":"font-medium"]),title:v.displayTitle,onClick:Qe(y=>o("title-click",v.slug),["stop"])},[(P=v.automation)!=null&&P.enabled?(g(),Ce(a(Is),{key:0,class:"h-3.5 w-3.5 shrink-0 opacity-70"})):me("",!0),i("span",Ih,S(v.displayTitle),1)],10,$h))])]),i("div",Ph,[v.sending?(g(),x("span",{key:0,class:Se(["inline-flex items-center gap-1.5 rounded-sm border border-dashed px-1.5 py-0.5",c()])},[b[11]||(b[11]=i("span",{class:"task-loading-dots","aria-hidden":"true"},[i("span",{class:"task-loading-dots__dot"}),i("span",{class:"task-loading-dots__dot"}),i("span",{class:"task-loading-dots__dot"})],-1)),i("span",null,S(a(s)("workbench.running")),1)],2)):me("",!0)])]),i("div",Dh,S(v.lastPromptPreview||a(s)("workbench.noMessagesYet")),1),i("div",Lh,[i("div",Bh,S(p(v)),1),i("div",Mh,[w(v)?(g(),x("span",{key:0,class:Se(["inline-flex items-center gap-1 rounded-sm border border-dashed px-1.5 py-0.5",d(v)])},[i("span",null,S(a(s)("workbench.filesCount",{count:((ne=v.workspaceDiffSummary)==null?void 0:ne.fileCount)||0})),1)],2)):me("",!0)])])],10,bh)}),128))]),_:1},8,["modelValue","disabled"]))]),i("div",Rh,[e.error?(g(),x("div",Nh,[ue(a(_o),{class:"mt-0.5 h-4 w-4 shrink-0"}),i("span",Oh,S(e.error),1)])):me("",!0),i("div",jh,[i("button",{type:"button",class:"tool-button inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:!e.currentTaskSlug||e.removingTask||e.creatingTask,title:a(s)("workbench.editTask"),onClick:b[9]||(b[9]=v=>o("edit-task"))},[ue(a(Zn),{class:"h-4 w-4"}),i("span",Uh,S(a(s)("workbench.editTask")),1)],8,Fh),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:!e.currentTaskSlug||e.removingTask||e.creatingTask||e.isCurrentTaskSending,title:e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask"),onClick:b[10]||(b[10]=v=>o("delete-task"))},[ue(a(js),{class:"h-4 w-4"}),i("span",zh,S(e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask")),1)],8,Vh)])])]))}},gr=br(Hh,[["__scopeId","data-v-2eaa6605"]]),qh={class:"min-w-0"},Kh={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Wh={class:"theme-muted-text mt-1 text-xs leading-5"},Gh={class:"theme-divider flex items-center justify-between gap-3 border-b border-dashed px-5 py-3 text-xs"},Xh={class:"theme-muted-text"},Yh={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-2 py-1"},Jh={key:0,class:"min-h-0 flex-1 overflow-y-auto px-5 py-4"},Qh={class:"space-y-3"},Zh={class:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between"},ev={class:"min-w-0 flex-1"},tv={class:"theme-heading flex flex-wrap items-center gap-2 text-sm font-medium"},nv={class:"theme-status-neutral inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-0.5 text-[11px]"},sv={class:"mt-2 whitespace-pre-wrap break-words text-sm leading-6"},ov={class:"theme-muted-text mt-3 flex flex-wrap items-center gap-2 text-[11px]"},rv={class:"rounded-sm border border-dashed px-2 py-1"},av={key:0,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},iv={key:1,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},lv={key:2,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},uv={class:"flex w-full items-center gap-2 sm:w-auto sm:shrink-0"},cv=["onClick"],dv=["onClick"],fv={key:1,class:"theme-empty-state flex min-h-0 flex-1 items-center justify-center px-6 py-10 text-sm"},pv={__name:"WorkbenchTodoDialog",props:{items:{type:Array,default:()=>[]},open:{type:Boolean,default:!1}},emits:["close","delete","use"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=W(()=>(n.items||[]).map(c=>{var v;const p=Array.isArray(c==null?void 0:c.blocks)?c.blocks:[],w=((v=p.find(P=>["text","imported_text"].includes(String((P==null?void 0:P.type)||""))&&String((P==null?void 0:P.content)||"").trim()))==null?void 0:v.content)||"",d=String(w||"").replace(/\s+/g," ").trim().slice(0,120),m=p.filter(P=>String((P==null?void 0:P.type)||"")==="image").length,f=p.filter(P=>String((P==null?void 0:P.type)||"")==="imported_text").length,b=p.filter(P=>String((P==null?void 0:P.type)||"")==="text"&&String((P==null?void 0:P.content)||"").trim()).length;return{...c,blockCount:p.length,imageCount:m,importedCount:f,preview:d||(m?s("todoDialog.imagePreview",{count:m}):s("todoDialog.noPreview")),textCount:b,timeLabel:l(c==null?void 0:c.createdAt)}}));function l(c=""){const p=Date.parse(String(c||""));if(!p)return s("todoDialog.justAdded");try{return new Intl.DateTimeFormat(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(p))}catch{return String(c||"")}}return(c,p)=>(g(),Ce(Fs,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel max-w-3xl sm:h-[40rem] sm:max-h-[86vh]","header-class":"px-5 py-4","body-class":"min-h-0 flex flex-1 flex-col overflow-hidden",onClose:p[0]||(p[0]=w=>o("close"))},{title:Je(()=>[i("div",qh,[i("div",Kh,[ue(a(Ar),{class:"h-4 w-4"}),i("span",null,S(a(s)("todoDialog.title")),1)]),i("p",Wh,S(a(s)("todoDialog.intro")),1)])]),default:Je(()=>[i("div",Gh,[i("span",Xh,S(a(s)("todoDialog.summary",{count:r.value.length})),1),i("span",Yh,S(a(s)("todoDialog.summaryHint")),1)]),r.value.length?(g(),x("div",Jh,[i("div",Qh,[(g(!0),x(et,null,ut(r.value,w=>(g(),x("article",{key:w.id,class:"theme-card-idle-muted rounded-sm border border-dashed p-4"},[i("div",Zh,[i("div",ev,[i("div",tv,[i("span",null,S(a(s)("todoDialog.itemTitle")),1),i("span",nv,[ue(a(Is),{class:"h-3.5 w-3.5"}),an(" "+S(w.timeLabel),1)])]),i("p",sv,S(w.preview),1),i("div",ov,[i("span",rv,S(a(s)("todoDialog.blockCount",{count:w.blockCount})),1),w.textCount?(g(),x("span",av,[ue(a(Ds),{class:"h-3.5 w-3.5"}),an(" "+S(a(s)("todoDialog.textCount",{count:w.textCount})),1)])):me("",!0),w.importedCount?(g(),x("span",iv,[ue(a(Ds),{class:"h-3.5 w-3.5"}),an(" "+S(a(s)("todoDialog.importedCount",{count:w.importedCount})),1)])):me("",!0),w.imageCount?(g(),x("span",lv,[ue(a($r),{class:"h-3.5 w-3.5"}),an(" "+S(a(s)("todoDialog.imageCount",{count:w.imageCount})),1)])):me("",!0)])]),i("div",uv,[i("button",{type:"button",class:"tool-button inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:d=>o("use",w.id)},[ue(a(qa),{class:"h-4 w-4"}),i("span",null,S(a(s)("todoDialog.use")),1)],8,cv),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:d=>o("delete",w.id)},[ue(a(js),{class:"h-4 w-4"}),i("span",null,S(a(s)("todoDialog.delete")),1)],8,dv)])])]))),128))])])):(g(),x("div",fv,S(a(s)("todoDialog.empty")),1))]),_:1},8,["open"]))}},mv={class:"pointer-events-none fixed inset-x-0 top-4 z-40 flex justify-center px-4"},gv={__name:"TopToast",props:{message:{type:String,default:""},type:{type:String,default:"success"}},setup(e){const t=e;function n(s="success"){return s==="warning"?"theme-status-warning":s==="error"?"theme-status-danger":s==="info"?"theme-status-info":"theme-status-success"}function o(s="success"){return s==="warning"?_o:s==="error"?Ka:s==="info"?Wa:Ga}return(s,r)=>(g(),Ce(os,{to:"body"},[i("div",mv,[ue(_r,{"enter-active-class":"transform transition duration-200 ease-out","enter-from-class":"-translate-y-3 opacity-0","enter-to-class":"translate-y-0 opacity-100","leave-active-class":"transform transition duration-150 ease-in","leave-from-class":"translate-y-0 opacity-100","leave-to-class":"-translate-y-2 opacity-0"},{default:Je(()=>[e.message?(g(),x("div",{key:0,class:Se(["app-top-toast flex max-w-md items-center gap-2 rounded-sm border px-4 py-2 text-sm shadow-[var(--theme-shadowPanel)] backdrop-blur",n(t.type)])},[(g(),Ce(cn(o(t.type)),{class:"h-4 w-4 shrink-0"})),i("span",null,S(e.message),1)],2)):me("",!0)]),_:1})])]))}};function hv(e,t=!1){const n=q(!!t);let o=null,s=()=>{};function r(l){n.value=!!l}return dn(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;o=window.matchMedia(e),r(o.matches);const l=c=>{r(c.matches)};if(typeof o.addEventListener=="function"){o.addEventListener("change",l),s=()=>o==null?void 0:o.removeEventListener("change",l);return}typeof o.addListener=="function"&&(o.addListener(l),s=()=>o==null?void 0:o.removeListener(l))}),It(()=>{s()}),{matches:n}}const vv="(max-width: 1023px)",As="promptxWorkbenchMobileView";function co(e){return(e==null?void 0:e[As])==="detail"}function yv({currentTaskSlug:e}){const{matches:t}=hv(vv),n=q("tasks"),o=q("activity");function s(m="tasks"){if(typeof window>"u")return;const f={...window.history.state||{}};m==="detail"?f[As]="detail":delete f[As],window.history.replaceState(f,"")}function r(){if(typeof window>"u")return;const m={...window.history.state||{},[As]:"detail"};window.history.pushState(m,"")}function l(m=null){if(!t.value){n.value="detail";return}if(!e.value){n.value="tasks",s("tasks");return}n.value=co(m)?"detail":"tasks"}function c(m){t.value=!!m,l(typeof window>"u"?null:window.history.state)}function p(m={}){const{pushHistory:f=!0}=m;if(n.value="detail",!!t.value){if(f){r();return}s("detail")}}function w(m={}){const{useHistory:f=!0}=m;if(!t.value){n.value="tasks";return}if(f&&typeof window<"u"&&co(window.history.state)){window.history.back();return}n.value="tasks",s("tasks")}function d(m){t.value&&(n.value=co(m.state)&&e.value?"detail":"tasks")}return dn(()=>{typeof window>"u"||window.addEventListener("popstate",d)}),It(()=>{typeof window<"u"&&window.removeEventListener("popstate",d)}),$e(t,m=>{c(m)},{immediate:!0}),$e(e,()=>{typeof window>"u"||l(window.history.state)},{flush:"post"}),{enterMobileDetail:p,isMobileLayout:t,leaveMobileDetail:w,mobileDetailTab:o,mobileView:n}}const wo="PromptX";function Sv(e=""){const t=String(a(e)||"").trim();return t?`${wo} (${t})`:wo}function wv(e=""){Ca(()=>{typeof document>"u"||(document.title=Sv(e))}),It(()=>{typeof document>"u"||(document.title=wo)})}const Rn="success";function xv(e,t){return e&&typeof e=="object"&&!Array.isArray(e)?{message:String(e.message||"").trim(),type:String(e.type||Rn).trim()||Rn,duration:Number(e.duration)>0?Number(e.duration):t}:{message:String(e||"").trim(),type:Rn,duration:t}}function bv(e=2200){const t=q(""),n=q(Rn);let o=null;function s(){o&&(window.clearTimeout(o),o=null),t.value="",n.value=Rn}function r(l,c=e){const p=xv(l,c);if(!p.message){s();return}t.value=p.message,n.value=p.type,o&&window.clearTimeout(o),o=window.setTimeout(()=>{t.value="",n.value=Rn,o=null},p.duration)}return It(()=>{o&&window.clearTimeout(o)}),{toastMessage:t,toastType:n,flashToast:r,clearToast:s}}function kv(e="",t=""){const n=String(e||"").trim();if(!n)return"";if(/^https?:\/\//i.test(n))return n;try{return new URL(n,t).toString()}catch{return n}}function _v(e=""){const t=String(e||"").replace(/\r\n/g,`
50
+ `,"\0");if(/\s/.test(Ye)){Me();return}v.value=null,f.value={...te,end:j.from,query:Ye},lt(j.from);return}if(!j){Me();return}const ye=j.textBefore.lastIndexOf("@");if(ye<0){Me();return}const Oe=j.textBefore.slice(ye+1);if(/\s/.test(Oe)){Me();return}const Re=j.nodeStart+ye,Ge=j.from;Pe(v.value,{start:Re,end:Ge,query:Oe,clientId:j.clientId})||(v.value=null,f.value={open:!0,start:Re,end:Ge,query:Oe,trigger:"mention",blockType:j.nodeTypeName,clientId:j.clientId},lt(Ge))}function dt(){const T=G.value,j=Ee(T);return!T||!j?!1:(v.value=null,f.value={open:!0,start:j.from,end:j.from,query:"",trigger:"shortcut",blockType:j.nodeTypeName,clientId:j.clientId},lt(j.from),!0)}function wt(T){const j=G.value,te=String((T==null?void 0:T.path)||"").trim(),ye=f.value;if(!j||!te||ye.start<0||ye.end<ye.start)return Me(),!1;const Oe=ye.trigger==="shortcut"?`${te} `:`@${te} `,Re=ye.start+Oe.length;return j.chain().focus().command(({tr:Ge,dispatch:Ye})=>(Ge.insertText(Oe,ye.start,ye.end),Ge.setSelection(Ta.create(Ge.doc,Re)),Ye==null||Ye(Ge),!0)).run(),ne.value=Date.now(),v.value=null,Me(),!0}function Ct(T){var j,te,ye,Oe,Re,Ge,Ye,nt,yt,st;if(!f.value.open)return!1;if(T.key==="Escape")return Ne(),!0;if(T.key==="ArrowDown")return!!((te=(j=d.value)==null?void 0:j.moveActive)!=null&&te.call(j,1));if(T.key==="ArrowUp")return!!((Oe=(ye=d.value)==null?void 0:ye.moveActive)!=null&&Oe.call(ye,-1));if(f.value.query&&(T.key==="ArrowLeft"||T.key==="ArrowRight"))return!1;if(T.key==="ArrowRight"){const ft=(Ge=(Re=d.value)==null?void 0:Re.expandActiveDirectory)==null?void 0:Ge.call(Re);return ft&&typeof ft.then=="function"?(ft.catch(()=>{}),!0):!!ft}return T.key==="ArrowLeft"?!!((nt=(Ye=d.value)==null?void 0:Ye.collapseActiveDirectory)!=null&&nt.call(Ye)):!T.shiftKey&&!T.altKey&&!T.metaKey&&!T.ctrlKey&&T.key==="Enter"?!!((st=(yt=d.value)==null?void 0:yt.confirmActive)!=null&&st.call(yt)):!1}return dn(()=>{window.addEventListener("promptx:tiptap-image-preview",Be),window.addEventListener("resize",lt),window.addEventListener("scroll",lt)}),It(()=>{window.removeEventListener("promptx:tiptap-image-preview",Be),window.removeEventListener("resize",lt),window.removeEventListener("scroll",lt)}),$e(()=>o.codexSessionId,()=>{Me()}),t({clearContent:_e,flushPendingInput:tt,focusEditor:Ke,insertBlocks:R,insertImportedBlocks:J,insertUploadedBlocks:fe,isComposing:ge,isEditing:Ie,isImportedBlockActive:Ae,openFilePicker:je}),(T,j)=>(g(),x("section",{class:"workbench-input-editor relative flex h-full min-h-0 flex-col overflow-hidden","data-promptx-editor":"tiptap",onDrop:He,onDragover:j[1]||(j[1]=Qe(()=>{},["prevent"])),onPaste:F},[i("input",{ref_key:"fileInputRef",ref:S,class:"hidden",type:"file",accept:a(p),multiple:"",onChange:Fe},null,40,Zg),i("div",{class:"flex-1 overflow-y-auto px-5 py-5","data-promptx-editor-scroll":"tiptap",onMousedown:De},[a(G)?(g(),Ce(a(Qa),{key:0,editor:a(G),class:"min-h-full","data-promptx-editor-content":"tiptap"},null,8,["editor"])):me("",!0)],32),ue(Or,{modelValue:m.value,"onUpdate:modelValue":j[0]||(j[0]=te=>m.value=te),images:L.value},null,8,["modelValue","images"]),ue(Eg,{ref_key:"mentionPickerRef",ref:d,open:f.value.open&&!!b.value,"session-id":e.codexSessionId,query:f.value.query,"anchor-rect":b.value,onClose:Ne,onSelect:wt},null,8,["open","session-id","query","anchor-rect"])],32))}},nh={key:0,class:"theme-muted-text flex h-full items-center px-5 py-4 text-sm"},mr={__name:"WorkbenchInputPanel",props:{codexSessionId:{type:String,default:""},sendBehavior:{type:String,default:"shift_enter"},modelValue:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1}},emits:["update:modelValue","upload-files","import-text-files","import-pdf-files","file-feedback","clear-request","send-request"],setup(e,{expose:t,emit:n}){const o=e,s=n,r=q(null),{t:l}=St(),c=W({get:()=>o.modelValue,set:y=>s("update:modelValue",y)});function p(){var y,L;(L=(y=r.value)==null?void 0:y.openFilePicker)==null||L.call(y)}function S(){var y,L;(L=(y=r.value)==null?void 0:y.focusEditor)==null||L.call(y)}function d(){var y,L;return((L=(y=r.value)==null?void 0:y.flushPendingInput)==null?void 0:L.call(y))||!1}function m(y){var L,O;(O=(L=r.value)==null?void 0:L.insertBlocks)==null||O.call(L,y)}function f(y){var L,O;(O=(L=r.value)==null?void 0:L.insertImportedBlocks)==null||O.call(L,y)}function b(y){var L,O;(O=(L=r.value)==null?void 0:L.insertUploadedBlocks)==null||O.call(L,y)}function v(){var y,L;return((L=(y=r.value)==null?void 0:y.isImportedBlockActive)==null?void 0:L.call(y))||!1}function P(){var y,L;return((L=(y=r.value)==null?void 0:y.isComposing)==null?void 0:L.call(y))||!1}function ne(){var y,L;return((L=(y=r.value)==null?void 0:y.isEditing)==null?void 0:L.call(y))||!1}return t({focusEditor:S,flushPendingInput:d,insertBlocks:m,insertImportedBlocks:f,insertUploadedBlocks:b,isComposing:P,isEditing:ne,isImportedBlockActive:v,openFilePicker:p}),(y,L)=>e.loading&&!e.modelValue.length?(g(),x("section",nh,w(a(l)("workbench.loadingTaskContent")),1)):(g(),Ce(th,{key:1,ref_key:"blockEditorRef",ref:r,modelValue:c.value,"onUpdate:modelValue":L[0]||(L[0]=O=>c.value=O),"codex-session-id":e.codexSessionId,"send-behavior":e.sendBehavior,onUploadFiles:L[1]||(L[1]=O=>s("upload-files",O)),onImportTextFiles:L[2]||(L[2]=O=>s("import-text-files",O)),onImportPdfFiles:L[3]||(L[3]=O=>s("import-pdf-files",O)),onFileFeedback:L[4]||(L[4]=O=>s("file-feedback",O)),onClearRequest:L[5]||(L[5]=O=>s("clear-request")),onSendRequest:L[6]||(L[6]=O=>s("send-request"))},null,8,["modelValue","codex-session-id","send-behavior"]))}},sh={class:"panel workbench-mobile-header-panel shrink-0 overflow-hidden"},oh={class:"workbench-panel-header workbench-mobile-header theme-divider border-b px-2.5 py-2"},rh={class:"flex items-center gap-2"},ah=["title","aria-label"],ih={class:"min-w-0 flex-1"},lh=["value","placeholder"],uh=["disabled"],ch={class:"truncate"},dh={__name:"WorkbenchMobileDetailHeader",props:{currentTaskSlug:{type:String,default:""},editingTaskTitleSlug:{type:String,default:""},title:{type:String,default:""},titleInputValue:{type:String,default:""},currentTaskAutoTitle:{type:String,default:""}},emits:["back","begin-edit","title-blur","cancel-title-edit","update:titleInputValue"],setup(e,{emit:t}){const n=t,{t:o}=St();return(s,r)=>(g(),x("section",sh,[i("div",oh,[i("div",rh,[i("button",{type:"button",class:"tool-button inline-flex h-8 w-8 shrink-0 items-center justify-center px-0 py-0 text-[11px]",title:a(o)("workbench.tasks"),"aria-label":a(o)("workbench.tasks"),onClick:r[0]||(r[0]=l=>n("back"))},[ue(a(Fa),{class:"h-3.5 w-3.5"})],8,ah),i("div",ih,[e.currentTaskSlug&&e.editingTaskTitleSlug===e.currentTaskSlug?(g(),x("input",{key:0,value:e.titleInputValue,type:"text",maxlength:"140","data-task-title-input":"current",class:"block w-full appearance-none border-0 bg-transparent p-0 text-left text-[13px] font-semibold leading-5 outline-none placeholder:text-[var(--theme-textMuted)]",placeholder:e.currentTaskAutoTitle||a(o)("workbench.untitledTask"),onInput:r[1]||(r[1]=l=>n("update:titleInputValue",l.target.value)),onKeydown:[r[2]||(r[2]=Gt(Qe(l=>l.target.blur(),["prevent"]),["enter"])),r[3]||(r[3]=Gt(Qe(l=>n("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:r[4]||(r[4]=l=>n("title-blur"))},null,40,lh)):(g(),x("button",{key:1,type:"button",class:"inline-flex w-full items-center gap-1 truncate bg-transparent p-0 text-left text-[13px] font-semibold leading-5",disabled:!e.currentTaskSlug,onClick:r[5]||(r[5]=l=>n("begin-edit"))},[i("span",ch,w(e.title||a(o)("workbench.untitledTask")),1),ue(a(Zn),{class:"h-2.5 w-2.5 shrink-0 opacity-50"})],8,uh))])])])]))}},fh={class:"workbench-sidebar-panel panel flex h-full min-h-0 flex-col overflow-hidden"},ph={class:"workbench-panel-header theme-divider border-b px-4 py-4"},mh={class:"flex items-center justify-between gap-3"},gh={class:"flex min-h-8 items-center"},hh={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},vh=["title"],yh=["disabled","title"],Sh={class:"whitespace-nowrap"},wh={class:"min-h-0 flex-1 overflow-y-auto px-3 py-3"},xh={key:0,class:"theme-empty-state px-3 py-4 text-sm"},bh=["onClick"],kh={key:0,class:"theme-selection-indicator absolute inset-y-2 left-0 w-1 rounded-full"},_h={class:"flex items-start justify-between gap-3"},Th={class:"flex min-w-0 flex-1 items-start gap-2 overflow-hidden"},Ch=["title","aria-label"],Eh={class:"min-w-0 h-5 flex-1 overflow-hidden"},Ah=["value","placeholder"],$h=["title","onClick"],Ih={class:"min-w-0 truncate"},Ph={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},Dh={class:"workbench-task-card__preview mt-2 truncate text-xs opacity-80"},Lh={class:"mt-2 flex items-center justify-between gap-3"},Bh={class:"min-w-0 text-[11px] opacity-70"},Mh={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},Rh={class:"theme-divider border-t px-3 py-3"},Nh={key:0,class:"theme-danger-text mb-3 inline-flex min-w-0 items-start gap-2 text-xs"},Oh={class:"min-w-0 break-words"},jh={class:"grid grid-cols-2 gap-2"},Fh=["disabled","title"],Uh={class:"whitespace-nowrap"},Vh=["disabled","title"],zh={class:"whitespace-nowrap"},Hh={__name:"WorkbenchTaskListPanel",props:{loadingTasks:{type:Boolean,default:!1},tasks:{type:Array,default:()=>[]},currentTaskSlug:{type:String,default:""},editingTaskTitleSlug:{type:String,default:""},draftTitle:{type:String,default:""},currentTaskAutoTitle:{type:String,default:""},creatingTask:{type:Boolean,default:!1},loadingTask:{type:Boolean,default:!1},uploading:{type:Boolean,default:!1},error:{type:String,default:""},removingTask:{type:Boolean,default:!1},isCurrentTaskSending:{type:Boolean,default:!1},mobile:{type:Boolean,default:!1}},emits:["open-settings","create-task","reorder-task","select-task","title-click","title-blur","cancel-title-edit","update:draftTitle","edit-task","delete-task"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=q([]);$e(()=>n.tasks,f=>{r.value=Array.isArray(f)?[...f]:[]},{immediate:!0});function l(f){return f.slug===n.currentTaskSlug?"workbench-task-card--active theme-card-selected":f.sending?"workbench-task-card--running theme-card-warning":"theme-card-idle-muted"}function c(){return"theme-status-warning"}function p(f){const b=new Date(f.updatedAt);return Number.isNaN(b.getTime())?"":xr(b.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function S(f){var b,v;return!!((b=f==null?void 0:f.workspaceDiffSummary)!=null&&b.supported&&((v=f==null?void 0:f.workspaceDiffSummary)!=null&&v.fileCount))}function d(f){return f.slug===n.currentTaskSlug?"theme-badge-strong":"theme-badge-muted"}function m(f){if(n.mobile)return;const b=Number(f==null?void 0:f.oldIndex),v=Number(f==null?void 0:f.newIndex);!Number.isInteger(b)||!Number.isInteger(v)||b===v||o("reorder-task",r.value.map(P=>String((P==null?void 0:P.slug)||"").trim()).filter(Boolean))}return(f,b)=>(g(),x("aside",fh,[i("div",ph,[i("div",mh,[i("div",gh,[i("div",hh,[ue(a(Ua),{class:"h-4 w-4"}),i("span",null,w(a(s)("workbench.title")),1)])]),i("button",{type:"button",class:"tool-button inline-flex items-center gap-2 whitespace-nowrap px-3 py-2 text-xs",title:a(s)("workbench.settings"),onClick:b[0]||(b[0]=v=>o("open-settings"))},[ue(a(Va),{class:"h-4 w-4"}),i("span",{class:Se(e.mobile?"whitespace-nowrap":"hidden whitespace-nowrap sm:inline")},w(a(s)("workbench.settings")),3)],8,vh)]),i("button",{type:"button",class:"tool-button tool-button-primary mt-4 inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:e.creatingTask||e.uploading,title:e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask"),onClick:b[1]||(b[1]=v=>o("create-task"))},[ue(a(Ps),{class:"h-4 w-4"}),i("span",Sh,w(e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask")),1)],8,yh)]),i("div",wh,[e.loadingTasks&&!e.tasks.length?(g(),x("div",xh,w(a(s)("workbench.loadingTasks")),1)):(g(),Ce(a(za),{key:1,modelValue:r.value,"onUpdate:modelValue":b[8]||(b[8]=v=>r.value=v),class:"space-y-2",animation:180,disabled:e.mobile||e.tasks.length<=1,handle:".task-drag-handle","ghost-class":"workbench-task-card--ghost","chosen-class":"workbench-task-card--chosen","drag-class":"workbench-task-card--dragging","fallback-tolerance":"6",onEnd:m},{default:Je(()=>[(g(!0),x(et,null,ut(r.value,v=>{var P,ne;return g(),x("article",{key:v.slug,class:Se(["workbench-task-card group relative cursor-default rounded-sm border px-3 py-3 transition",l(v)]),onClick:y=>o("select-task",v.slug)},[v.slug===e.currentTaskSlug?(g(),x("span",kh)):me("",!0),i("div",_h,[i("div",Th,[e.mobile?me("",!0):(g(),x("button",{key:0,type:"button",class:"task-drag-handle mt-0.5 inline-flex h-4 w-4 shrink-0 cursor-grab items-center justify-center rounded-sm opacity-45 transition hover:opacity-80 active:cursor-grabbing",title:a(s)("workbench.dragToReorder"),"aria-label":a(s)("workbench.dragToReorder"),tabindex:"-1",onClick:b[2]||(b[2]=Qe(()=>{},["stop"]))},[ue(a(Ha),{class:"h-3.5 w-3.5"})],8,Ch)),i("div",Eh,[v.slug===e.currentTaskSlug&&e.editingTaskTitleSlug===v.slug?(g(),x("input",{key:0,value:e.draftTitle,type:"text",maxlength:"140","data-task-title-input":"current",class:"block h-5 min-h-0 w-full appearance-none border-0 bg-transparent p-0 text-left text-sm font-semibold leading-5 outline-none placeholder:text-[var(--theme-textMuted)]",placeholder:e.currentTaskAutoTitle||a(s)("workbench.untitledTask"),onClick:b[3]||(b[3]=Qe(()=>{},["stop"])),onInput:b[4]||(b[4]=y=>o("update:draftTitle",y.target.value)),onKeydown:[b[5]||(b[5]=Gt(Qe(y=>y.target.blur(),["prevent"]),["enter"])),b[6]||(b[6]=Gt(Qe(y=>o("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:b[7]||(b[7]=y=>o("title-blur"))},null,40,Ah)):(g(),x("button",{key:1,type:"button",class:Se(["inline-flex h-5 w-full items-center gap-1.5 truncate bg-transparent p-0 text-left text-sm leading-5",v.slug===e.currentTaskSlug?"font-semibold":"font-medium"]),title:v.displayTitle,onClick:Qe(y=>o("title-click",v.slug),["stop"])},[(P=v.automation)!=null&&P.enabled?(g(),Ce(a(Is),{key:0,class:"h-3.5 w-3.5 shrink-0 opacity-70"})):me("",!0),i("span",Ih,w(v.displayTitle),1)],10,$h))])]),i("div",Ph,[v.sending?(g(),x("span",{key:0,class:Se(["inline-flex items-center gap-1.5 rounded-sm border border-dashed px-1.5 py-0.5",c()])},[b[11]||(b[11]=i("span",{class:"task-loading-dots","aria-hidden":"true"},[i("span",{class:"task-loading-dots__dot"}),i("span",{class:"task-loading-dots__dot"}),i("span",{class:"task-loading-dots__dot"})],-1)),i("span",null,w(a(s)("workbench.running")),1)],2)):me("",!0)])]),i("div",Dh,w(v.lastPromptPreview||a(s)("workbench.noMessagesYet")),1),i("div",Lh,[i("div",Bh,w(p(v)),1),i("div",Mh,[S(v)?(g(),x("span",{key:0,class:Se(["inline-flex items-center gap-1 rounded-sm border border-dashed px-1.5 py-0.5",d(v)])},[i("span",null,w(a(s)("workbench.filesCount",{count:((ne=v.workspaceDiffSummary)==null?void 0:ne.fileCount)||0})),1)],2)):me("",!0)])])],10,bh)}),128))]),_:1},8,["modelValue","disabled"]))]),i("div",Rh,[e.error?(g(),x("div",Nh,[ue(a(_o),{class:"mt-0.5 h-4 w-4 shrink-0"}),i("span",Oh,w(e.error),1)])):me("",!0),i("div",jh,[i("button",{type:"button",class:"tool-button inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:!e.currentTaskSlug||e.removingTask||e.creatingTask,title:a(s)("workbench.editTask"),onClick:b[9]||(b[9]=v=>o("edit-task"))},[ue(a(Zn),{class:"h-4 w-4"}),i("span",Uh,w(a(s)("workbench.editTask")),1)],8,Fh),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:!e.currentTaskSlug||e.removingTask||e.creatingTask||e.isCurrentTaskSending,title:e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask"),onClick:b[10]||(b[10]=v=>o("delete-task"))},[ue(a(js),{class:"h-4 w-4"}),i("span",zh,w(e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask")),1)],8,Vh)])])]))}},gr=br(Hh,[["__scopeId","data-v-2eaa6605"]]),qh={class:"min-w-0"},Kh={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Wh={class:"theme-muted-text mt-1 text-xs leading-5"},Gh={class:"theme-divider flex items-center justify-between gap-3 border-b border-dashed px-5 py-3 text-xs"},Xh={class:"theme-muted-text"},Yh={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-2 py-1"},Jh={key:0,class:"min-h-0 flex-1 overflow-y-auto px-5 py-4"},Qh={class:"space-y-3"},Zh={class:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between"},ev={class:"min-w-0 flex-1"},tv={class:"theme-heading flex flex-wrap items-center gap-2 text-sm font-medium"},nv={class:"theme-status-neutral inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-0.5 text-[11px]"},sv={class:"mt-2 whitespace-pre-wrap break-words text-sm leading-6"},ov={class:"theme-muted-text mt-3 flex flex-wrap items-center gap-2 text-[11px]"},rv={class:"rounded-sm border border-dashed px-2 py-1"},av={key:0,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},iv={key:1,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},lv={key:2,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},uv={class:"flex w-full items-center gap-2 sm:w-auto sm:shrink-0"},cv=["onClick"],dv=["onClick"],fv={key:1,class:"theme-empty-state flex min-h-0 flex-1 items-center justify-center px-6 py-10 text-sm"},pv={__name:"WorkbenchTodoDialog",props:{items:{type:Array,default:()=>[]},open:{type:Boolean,default:!1}},emits:["close","delete","use"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=W(()=>(n.items||[]).map(c=>{var v;const p=Array.isArray(c==null?void 0:c.blocks)?c.blocks:[],S=((v=p.find(P=>["text","imported_text"].includes(String((P==null?void 0:P.type)||""))&&String((P==null?void 0:P.content)||"").trim()))==null?void 0:v.content)||"",d=String(S||"").replace(/\s+/g," ").trim().slice(0,120),m=p.filter(P=>String((P==null?void 0:P.type)||"")==="image").length,f=p.filter(P=>String((P==null?void 0:P.type)||"")==="imported_text").length,b=p.filter(P=>String((P==null?void 0:P.type)||"")==="text"&&String((P==null?void 0:P.content)||"").trim()).length;return{...c,blockCount:p.length,imageCount:m,importedCount:f,preview:d||(m?s("todoDialog.imagePreview",{count:m}):s("todoDialog.noPreview")),textCount:b,timeLabel:l(c==null?void 0:c.createdAt)}}));function l(c=""){const p=Date.parse(String(c||""));if(!p)return s("todoDialog.justAdded");try{return new Intl.DateTimeFormat(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(p))}catch{return String(c||"")}}return(c,p)=>(g(),Ce(Fs,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-3xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"px-5 py-4","body-class":"min-h-0 flex flex-1 flex-col overflow-hidden",onClose:p[0]||(p[0]=S=>o("close"))},{title:Je(()=>[i("div",qh,[i("div",Kh,[ue(a(Ar),{class:"h-4 w-4"}),i("span",null,w(a(s)("todoDialog.title")),1)]),i("p",Wh,w(a(s)("todoDialog.intro")),1)])]),default:Je(()=>[i("div",Gh,[i("span",Xh,w(a(s)("todoDialog.summary",{count:r.value.length})),1),i("span",Yh,w(a(s)("todoDialog.summaryHint")),1)]),r.value.length?(g(),x("div",Jh,[i("div",Qh,[(g(!0),x(et,null,ut(r.value,S=>(g(),x("article",{key:S.id,class:"theme-card-idle-muted rounded-sm border border-dashed p-4"},[i("div",Zh,[i("div",ev,[i("div",tv,[i("span",null,w(a(s)("todoDialog.itemTitle")),1),i("span",nv,[ue(a(Is),{class:"h-3.5 w-3.5"}),an(" "+w(S.timeLabel),1)])]),i("p",sv,w(S.preview),1),i("div",ov,[i("span",rv,w(a(s)("todoDialog.blockCount",{count:S.blockCount})),1),S.textCount?(g(),x("span",av,[ue(a(Ds),{class:"h-3.5 w-3.5"}),an(" "+w(a(s)("todoDialog.textCount",{count:S.textCount})),1)])):me("",!0),S.importedCount?(g(),x("span",iv,[ue(a(Ds),{class:"h-3.5 w-3.5"}),an(" "+w(a(s)("todoDialog.importedCount",{count:S.importedCount})),1)])):me("",!0),S.imageCount?(g(),x("span",lv,[ue(a($r),{class:"h-3.5 w-3.5"}),an(" "+w(a(s)("todoDialog.imageCount",{count:S.imageCount})),1)])):me("",!0)])]),i("div",uv,[i("button",{type:"button",class:"tool-button inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:d=>o("use",S.id)},[ue(a(qa),{class:"h-4 w-4"}),i("span",null,w(a(s)("todoDialog.use")),1)],8,cv),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:d=>o("delete",S.id)},[ue(a(js),{class:"h-4 w-4"}),i("span",null,w(a(s)("todoDialog.delete")),1)],8,dv)])])]))),128))])])):(g(),x("div",fv,w(a(s)("todoDialog.empty")),1))]),_:1},8,["open"]))}},mv={class:"pointer-events-none fixed inset-x-0 top-4 z-40 flex justify-center px-4"},gv={__name:"TopToast",props:{message:{type:String,default:""},type:{type:String,default:"success"}},setup(e){const t=e;function n(s="success"){return s==="warning"?"theme-status-warning":s==="error"?"theme-status-danger":s==="info"?"theme-status-info":"theme-status-success"}function o(s="success"){return s==="warning"?_o:s==="error"?Ka:s==="info"?Wa:Ga}return(s,r)=>(g(),Ce(os,{to:"body"},[i("div",mv,[ue(_r,{"enter-active-class":"transform transition duration-200 ease-out","enter-from-class":"-translate-y-3 opacity-0","enter-to-class":"translate-y-0 opacity-100","leave-active-class":"transform transition duration-150 ease-in","leave-from-class":"translate-y-0 opacity-100","leave-to-class":"-translate-y-2 opacity-0"},{default:Je(()=>[e.message?(g(),x("div",{key:0,class:Se(["app-top-toast flex max-w-md items-center gap-2 rounded-sm border px-4 py-2 text-sm shadow-[var(--theme-shadowPanel)] backdrop-blur",n(t.type)])},[(g(),Ce(cn(o(t.type)),{class:"h-4 w-4 shrink-0"})),i("span",null,w(e.message),1)],2)):me("",!0)]),_:1})])]))}};function hv(e,t=!1){const n=q(!!t);let o=null,s=()=>{};function r(l){n.value=!!l}return dn(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;o=window.matchMedia(e),r(o.matches);const l=c=>{r(c.matches)};if(typeof o.addEventListener=="function"){o.addEventListener("change",l),s=()=>o==null?void 0:o.removeEventListener("change",l);return}typeof o.addListener=="function"&&(o.addListener(l),s=()=>o==null?void 0:o.removeListener(l))}),It(()=>{s()}),{matches:n}}const vv="(max-width: 1023px)",As="promptxWorkbenchMobileView";function co(e){return(e==null?void 0:e[As])==="detail"}function yv({currentTaskSlug:e}){const{matches:t}=hv(vv),n=q("tasks"),o=q("activity");function s(m="tasks"){if(typeof window>"u")return;const f={...window.history.state||{}};m==="detail"?f[As]="detail":delete f[As],window.history.replaceState(f,"")}function r(){if(typeof window>"u")return;const m={...window.history.state||{},[As]:"detail"};window.history.pushState(m,"")}function l(m=null){if(!t.value){n.value="detail";return}if(!e.value){n.value="tasks",s("tasks");return}n.value=co(m)?"detail":"tasks"}function c(m){t.value=!!m,l(typeof window>"u"?null:window.history.state)}function p(m={}){const{pushHistory:f=!0}=m;if(n.value="detail",!!t.value){if(f){r();return}s("detail")}}function S(m={}){const{useHistory:f=!0}=m;if(!t.value){n.value="tasks";return}if(f&&typeof window<"u"&&co(window.history.state)){window.history.back();return}n.value="tasks",s("tasks")}function d(m){t.value&&(n.value=co(m.state)&&e.value?"detail":"tasks")}return dn(()=>{typeof window>"u"||window.addEventListener("popstate",d)}),It(()=>{typeof window<"u"&&window.removeEventListener("popstate",d)}),$e(t,m=>{c(m)},{immediate:!0}),$e(e,()=>{typeof window>"u"||l(window.history.state)},{flush:"post"}),{enterMobileDetail:p,isMobileLayout:t,leaveMobileDetail:S,mobileDetailTab:o,mobileView:n}}const wo="PromptX";function Sv(e=""){const t=String(a(e)||"").trim();return t?`${wo} (${t})`:wo}function wv(e=""){Ca(()=>{typeof document>"u"||(document.title=Sv(e))}),It(()=>{typeof document>"u"||(document.title=wo)})}const Rn="success";function xv(e,t){return e&&typeof e=="object"&&!Array.isArray(e)?{message:String(e.message||"").trim(),type:String(e.type||Rn).trim()||Rn,duration:Number(e.duration)>0?Number(e.duration):t}:{message:String(e||"").trim(),type:Rn,duration:t}}function bv(e=2200){const t=q(""),n=q(Rn);let o=null;function s(){o&&(window.clearTimeout(o),o=null),t.value="",n.value=Rn}function r(l,c=e){const p=xv(l,c);if(!p.message){s();return}t.value=p.message,n.value=p.type,o&&window.clearTimeout(o),o=window.setTimeout(()=>{t.value="",n.value=Rn,o=null},p.duration)}return It(()=>{o&&window.clearTimeout(o)}),{toastMessage:t,toastType:n,flashToast:r,clearToast:s}}function kv(e="",t=""){const n=String(e||"").trim();if(!n)return"";if(/^https?:\/\//i.test(n))return n;try{return new URL(n,t).toString()}catch{return n}}function _v(e=""){const t=String(e||"").replace(/\r\n/g,`
51
51
  `).split(`
52
52
  `);for(;t.length&&!String(t[0]||"").trim();)t.shift();for(;t.length&&!String(t[t.length-1]||"").trim();)t.pop();return t.join(`
53
53
  `)}function Tv(e,t){const n=[];for(const[o,s]of((e==null?void 0:e.blocks)||[]).entries()){if(s.type===$t.TEXT||s.type===$t.IMPORTED_TEXT){const r=_v(s.content);r&&n.push(r,"");continue}if(s.type===$t.IMAGE){const r=kv(s.content,t);r&&n.push(r,"")}}return n.join(`
54
- `).trim()}function Cv(e,t){return Tv(e,t)}const xo="promptx:active-task-slug",Ev=150,Av=1500;function Rs(e=null){return!e||typeof e!="object"?null:{supported:!!e.supported,fileCount:Math.max(0,Number(e.fileCount)||0),additions:Math.max(0,Number(e.additions)||0),deletions:Math.max(0,Number(e.deletions)||0),statsComplete:!!e.statsComplete}}function un(e=[]){return(e||[]).map(t=>{var n,o;return{...t,clientId:String((t==null?void 0:t.clientId)||(t==null?void 0:t.id)||((o=(n=globalThis.crypto)==null?void 0:n.randomUUID)==null?void 0:o.call(n))||`block-${Date.now()}-${Math.random().toString(36).slice(2,8)}`),meta:t!=null&&t.meta?{...t.meta}:{}}})}function Nt(e=[]){return(e||[]).map(t=>({id:String((t==null?void 0:t.id)||"").trim(),createdAt:String((t==null?void 0:t.createdAt)||""),blocks:un((t==null?void 0:t.blocks)||[])}))}function hr(e={}){return{title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),blocks:un(e.blocks||[]),todoItems:Nt(e.todoItems||[])}}function wa(e=[]){return un(e).filter(t=>(t==null?void 0:t.type)===$t.IMAGE?!!String(t.content||"").trim():!!String((t==null?void 0:t.content)||"").trim())}function $v(e=[]){return wa(e).length>0}function Iv(){var t,n;const e=(n=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:n.call(t);return e?`todo-${e}`:`todo-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function vr(){return un([{type:$t.TEXT,content:"",meta:{}}])}function bo(e=[],t=16){return mi(e,t)||""}function Pv(e=[],t=120){const n=e.find(o=>((o==null?void 0:o.type)==="text"||(o==null?void 0:o.type)==="imported_text")&&String(o.content||"").trim());return String((n==null?void 0:n.content)||"").replace(/\s+/g," ").trim().slice(0,t)}function yr(e={},t=[]){const n=String((e==null?void 0:e.title)||"").trim();if(n)return n;const o=String((e==null?void 0:e.autoTitle)||"").trim();if(o)return o;const s=bo(t);if(s)return s;const r=String((e==null?void 0:e.preview)||"").trim();return r?r.slice(0,16):We("workbench.untitledTask")}function Ns(e={}){return!!(e!=null&&e.running)}function Dv(e={},t=!1){return t&&!Ns(e)?"sending":Ns(e)?"running":"idle"}function Lv(e=""){return["queued","starting","running","stopping"].includes(String(e||"").trim())}function Sr(e="",t=72){return String(e||"").replace(/\s+/g," ").trim().slice(0,t)}function Bv(e=[],t=[]){const n=Array.isArray(e)?[...e]:[],o=Array.isArray(t)?t.map(c=>String(c||"").trim()).filter(Boolean):[];if(!o.length)return n;const s=new Map(n.map(c=>{const p=String((c==null?void 0:c.slug)||"").trim();return p?[p,c]:null}).filter(Boolean)),r=o.map(c=>s.get(c)||null).filter(Boolean),l=n.filter(c=>{const p=String((c==null?void 0:c.slug)||"").trim();return p&&!o.includes(p)});return[...r,...l]}function wr(e=[],t=[]){const n=new Map((e||[]).map(s=>{const r=String((s==null?void 0:s.slug)||"").trim();return r?[r,s]:null}).filter(Boolean));return(t||[]).map(s=>{const r=String((s==null?void 0:s.slug)||"").trim(),l=String((s==null?void 0:s.codexSessionId)||"").trim();if(!r)return s;if(Object.prototype.hasOwnProperty.call(s,"workspaceDiffSummary"))return{...s,workspaceDiffSummary:Rs(s.workspaceDiffSummary)};if(!l)return{...s,workspaceDiffSummary:null};const c=n.get(r),p=String((c==null?void 0:c.codexSessionId)||"").trim();return p&&p===l?{...s,workspaceDiffSummary:Rs(c.workspaceDiffSummary)}:{...s,workspaceDiffSummary:null}})}function Mv(e=[],t=[]){const n=Array.isArray(e)?e:[],o=Array.isArray(t)?t:[];if(!o.length)return!1;if(n.length!==o.length)return!0;const s=new Map(n.map(r=>{const l=String((r==null?void 0:r.slug)||"").trim();return l?[l,r]:null}).filter(Boolean));return o.some(r=>{const l=String((r==null?void 0:r.slug)||"").trim();if(!l)return!0;const c=s.get(l);if(!c)return!0;const p=String((r==null?void 0:r.codexSessionId)||"").trim(),w=String((c==null?void 0:c.codexSessionId)||"").trim();return!!(p!==w||!!(r!=null&&r.running)!=!!(c!=null&&c.running)||p&&!Object.prototype.hasOwnProperty.call(c||{},"workspaceDiffSummary")||p&&(c==null?void 0:c.workspaceDiffSummary)==null)})}function ys(e){if(typeof window>"u")return;const t=String(e||"").trim();if(t){window.localStorage.setItem(xo,t);return}window.localStorage.removeItem(xo)}function Rv(){return typeof window>"u"?"":String(window.localStorage.getItem(xo)||"").trim()}function Nv(){if(typeof window>"u")return"";try{const e=new URL(window.location.href);return String(e.searchParams.get("task")||"").trim()}catch{return""}}function Ov(){if(!(typeof window>"u"))try{const e=new URL(window.location.href);if(!e.searchParams.has("task"))return;e.searchParams.delete("task");const t=`${e.pathname}${e.search}${e.hash}`;window.history.replaceState({},"",t||"/")}catch{}}function $n(e){const t={slug:e.slug,sortOrder:Number(e.sortOrder)||0,title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),codexRunCount:Math.max(0,Number(e.codexRunCount)||0),todoCount:Math.max(0,Number(e.todoCount)||0),running:!!e.running,preview:String(e.lastPromptPreview||""),updatedAt:e.updatedAt||e.createdAt||new Date().toISOString(),createdAt:e.createdAt||e.updatedAt||new Date().toISOString(),automation:e!=null&&e.automation?{enabled:!!e.automation.enabled,cron:String(e.automation.cron||""),nextTriggerAt:String(e.automation.nextTriggerAt||"")}:void 0,notification:e!=null&&e.notification?{enabled:!!e.notification.enabled,channelType:String(e.notification.channelType||""),triggerOn:String(e.notification.triggerOn||""),lastStatus:String(e.notification.lastStatus||""),lastSentAt:String(e.notification.lastSentAt||"")}:void 0};return Object.prototype.hasOwnProperty.call(e,"workspaceDiffSummary")&&(t.workspaceDiffSummary=Rs(e.workspaceDiffSummary)),t}function jv(e={}){const{clearToast:t=()=>{},flashToast:n=()=>{},scrollCurrentPanelToBottom:o=()=>{}}=e,s=Io(),r=oa(),l=q(null),c=q([]),p=q({}),w=q({}),d=q({}),m=q(""),f=q({title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]}),b=q(!0),v=q(!1),P=q(!1),ne=q(!1),y=q(!1),L=q(!1),O=q(""),z=q(!1),U=q("");let se=null,A=null,G=0,ce=null,pe=0,I=null,Q=0,le={};const ie=W(()=>bo(f.value.blocks)),ve=W(()=>yr({title:f.value.title,autoTitle:f.value.autoTitle,preview:Pv(f.value.blocks)},f.value.blocks));function _(E,k={}){const K=String(E||"").trim();if(!K)return"";const ae=k.summary||Ae(K),ee=k.cachedDraft===void 0?Be(K):k.cachedDraft,h=K===m.value;return Object.prototype.hasOwnProperty.call(w.value,K)?String(w.value[K]||"").trim():h?String(f.value.codexSessionId||(ae==null?void 0:ae.codexSessionId)||"").trim():String((ee==null?void 0:ee.codexSessionId)||(ae==null?void 0:ae.codexSessionId)||"").trim()}const H=W(()=>_(m.value)),F=W(()=>Dv(Ae(m.value),d.value[m.value])),He=W(()=>F.value!=="idle"),De=W(()=>c.value.some(E=>Ns(E))||Object.values(d.value).some(Boolean)),Fe=W(()=>$v(f.value.blocks)),je=W(()=>Nt(f.value.todoItems)),Ke=W(()=>ve.value||We("workbench.untitledTask")),tt=W(()=>c.value.map(E=>it(E)));function xe(E=""){return!E||!E.startsWith(s)?E:E.slice(s.length)}function R(E=""){const k=String(E||"").replace(/\r\n/g,`
54
+ `).trim()}function Cv(e,t){return Tv(e,t)}const xo="promptx:active-task-slug",Ev=150,Av=1500;function Rs(e=null){return!e||typeof e!="object"?null:{supported:!!e.supported,fileCount:Math.max(0,Number(e.fileCount)||0),additions:Math.max(0,Number(e.additions)||0),deletions:Math.max(0,Number(e.deletions)||0),statsComplete:!!e.statsComplete}}function un(e=[]){return(e||[]).map(t=>{var n,o;return{...t,clientId:String((t==null?void 0:t.clientId)||(t==null?void 0:t.id)||((o=(n=globalThis.crypto)==null?void 0:n.randomUUID)==null?void 0:o.call(n))||`block-${Date.now()}-${Math.random().toString(36).slice(2,8)}`),meta:t!=null&&t.meta?{...t.meta}:{}}})}function Nt(e=[]){return(e||[]).map(t=>({id:String((t==null?void 0:t.id)||"").trim(),createdAt:String((t==null?void 0:t.createdAt)||""),blocks:un((t==null?void 0:t.blocks)||[])}))}function hr(e={}){return{title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),blocks:un(e.blocks||[]),todoItems:Nt(e.todoItems||[])}}function wa(e=[]){return un(e).filter(t=>(t==null?void 0:t.type)===$t.IMAGE?!!String(t.content||"").trim():!!String((t==null?void 0:t.content)||"").trim())}function $v(e=[]){return wa(e).length>0}function Iv(){var t,n;const e=(n=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:n.call(t);return e?`todo-${e}`:`todo-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function vr(){return un([{type:$t.TEXT,content:"",meta:{}}])}function bo(e=[],t=16){return mi(e,t)||""}function Pv(e=[],t=120){const n=e.find(o=>((o==null?void 0:o.type)==="text"||(o==null?void 0:o.type)==="imported_text")&&String(o.content||"").trim());return String((n==null?void 0:n.content)||"").replace(/\s+/g," ").trim().slice(0,t)}function yr(e={},t=[]){const n=String((e==null?void 0:e.title)||"").trim();if(n)return n;const o=String((e==null?void 0:e.autoTitle)||"").trim();if(o)return o;const s=bo(t);if(s)return s;const r=String((e==null?void 0:e.preview)||"").trim();return r?r.slice(0,16):We("workbench.untitledTask")}function Ns(e={}){return!!(e!=null&&e.running)}function Dv(e={},t=!1){return t&&!Ns(e)?"sending":Ns(e)?"running":"idle"}function Lv(e=""){return["queued","starting","running","stopping"].includes(String(e||"").trim())}function Sr(e="",t=72){return String(e||"").replace(/\s+/g," ").trim().slice(0,t)}function Bv(e=[],t=[]){const n=Array.isArray(e)?[...e]:[],o=Array.isArray(t)?t.map(c=>String(c||"").trim()).filter(Boolean):[];if(!o.length)return n;const s=new Map(n.map(c=>{const p=String((c==null?void 0:c.slug)||"").trim();return p?[p,c]:null}).filter(Boolean)),r=o.map(c=>s.get(c)||null).filter(Boolean),l=n.filter(c=>{const p=String((c==null?void 0:c.slug)||"").trim();return p&&!o.includes(p)});return[...r,...l]}function wr(e=[],t=[]){const n=new Map((e||[]).map(s=>{const r=String((s==null?void 0:s.slug)||"").trim();return r?[r,s]:null}).filter(Boolean));return(t||[]).map(s=>{const r=String((s==null?void 0:s.slug)||"").trim(),l=String((s==null?void 0:s.codexSessionId)||"").trim();if(!r)return s;if(Object.prototype.hasOwnProperty.call(s,"workspaceDiffSummary"))return{...s,workspaceDiffSummary:Rs(s.workspaceDiffSummary)};if(!l)return{...s,workspaceDiffSummary:null};const c=n.get(r),p=String((c==null?void 0:c.codexSessionId)||"").trim();return p&&p===l?{...s,workspaceDiffSummary:Rs(c.workspaceDiffSummary)}:{...s,workspaceDiffSummary:null}})}function Mv(e=[],t=[]){const n=Array.isArray(e)?e:[],o=Array.isArray(t)?t:[];if(!o.length)return!1;if(n.length!==o.length)return!0;const s=new Map(n.map(r=>{const l=String((r==null?void 0:r.slug)||"").trim();return l?[l,r]:null}).filter(Boolean));return o.some(r=>{const l=String((r==null?void 0:r.slug)||"").trim();if(!l)return!0;const c=s.get(l);if(!c)return!0;const p=String((r==null?void 0:r.codexSessionId)||"").trim(),S=String((c==null?void 0:c.codexSessionId)||"").trim();return!!(p!==S||!!(r!=null&&r.running)!=!!(c!=null&&c.running)||p&&!Object.prototype.hasOwnProperty.call(c||{},"workspaceDiffSummary")||p&&(c==null?void 0:c.workspaceDiffSummary)==null)})}function ys(e){if(typeof window>"u")return;const t=String(e||"").trim();if(t){window.localStorage.setItem(xo,t);return}window.localStorage.removeItem(xo)}function Rv(){return typeof window>"u"?"":String(window.localStorage.getItem(xo)||"").trim()}function Nv(){if(typeof window>"u")return"";try{const e=new URL(window.location.href);return String(e.searchParams.get("task")||"").trim()}catch{return""}}function Ov(){if(!(typeof window>"u"))try{const e=new URL(window.location.href);if(!e.searchParams.has("task"))return;e.searchParams.delete("task");const t=`${e.pathname}${e.search}${e.hash}`;window.history.replaceState({},"",t||"/")}catch{}}function $n(e){const t={slug:e.slug,sortOrder:Number(e.sortOrder)||0,title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),codexRunCount:Math.max(0,Number(e.codexRunCount)||0),todoCount:Math.max(0,Number(e.todoCount)||0),running:!!e.running,preview:String(e.lastPromptPreview||""),updatedAt:e.updatedAt||e.createdAt||new Date().toISOString(),createdAt:e.createdAt||e.updatedAt||new Date().toISOString(),automation:e!=null&&e.automation?{enabled:!!e.automation.enabled,cron:String(e.automation.cron||""),nextTriggerAt:String(e.automation.nextTriggerAt||"")}:void 0,notification:e!=null&&e.notification?{enabled:!!e.notification.enabled,channelType:String(e.notification.channelType||""),triggerOn:String(e.notification.triggerOn||""),lastStatus:String(e.notification.lastStatus||""),lastSentAt:String(e.notification.lastSentAt||"")}:void 0};return Object.prototype.hasOwnProperty.call(e,"workspaceDiffSummary")&&(t.workspaceDiffSummary=Rs(e.workspaceDiffSummary)),t}function jv(e={}){const{clearToast:t=()=>{},flashToast:n=()=>{},scrollCurrentPanelToBottom:o=()=>{}}=e,s=Io(),r=oa(),l=q(null),c=q([]),p=q({}),S=q({}),d=q({}),m=q(""),f=q({title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]}),b=q(!0),v=q(!1),P=q(!1),ne=q(!1),y=q(!1),L=q(!1),O=q(""),z=q(!1),U=q("");let se=null,A=null,G=0,ce=null,pe=0,I=null,Q=0,le={};const ie=W(()=>bo(f.value.blocks)),ve=W(()=>yr({title:f.value.title,autoTitle:f.value.autoTitle,preview:Pv(f.value.blocks)},f.value.blocks));function _(E,k={}){const K=String(E||"").trim();if(!K)return"";const ae=k.summary||Ae(K),ee=k.cachedDraft===void 0?Be(K):k.cachedDraft,h=K===m.value;return Object.prototype.hasOwnProperty.call(S.value,K)?String(S.value[K]||"").trim():h?String(f.value.codexSessionId||(ae==null?void 0:ae.codexSessionId)||"").trim():String((ee==null?void 0:ee.codexSessionId)||(ae==null?void 0:ae.codexSessionId)||"").trim()}const H=W(()=>_(m.value)),F=W(()=>Dv(Ae(m.value),d.value[m.value])),He=W(()=>F.value!=="idle"),De=W(()=>c.value.some(E=>Ns(E))||Object.values(d.value).some(Boolean)),Fe=W(()=>$v(f.value.blocks)),je=W(()=>Nt(f.value.todoItems)),Ke=W(()=>ve.value||We("workbench.untitledTask")),tt=W(()=>c.value.map(E=>it(E)));function xe(E=""){return!E||!E.startsWith(s)?E:E.slice(s.length)}function R(E=""){const k=String(E||"").replace(/\r\n/g,`
55
55
  `).split(`
56
56
  `);for(;k.length&&!String(k[0]||"").trim();)k.shift();for(;k.length&&!String(k[k.length-1]||"").trim();)k.pop();return k.join(`
57
- `)}function J(E=[]){return E.map(k=>({id:Number.isInteger(Number(k==null?void 0:k.id))?Number(k.id):null,type:k==null?void 0:k.type,content:(k==null?void 0:k.type)==="image"?xe(k.content):R(k.content),meta:k!=null&&k.meta?{...k.meta}:{}}))}function fe(E=[]){return(E||[]).map(k=>({id:String((k==null?void 0:k.id)||"").trim(),createdAt:String((k==null?void 0:k.createdAt)||""),blocks:J((k==null?void 0:k.blocks)||[])}))}function _e(E=f.value.title,k=f.value.autoTitle,K=f.value.lastPromptPreview,ae=f.value.todoItems,ee=f.value.codexSessionId,h=f.value.blocks){return JSON.stringify({title:String(E||""),autoTitle:String(k||""),lastPromptPreview:String(K||""),todoItems:fe(ae),codexSessionId:String(ee||""),blocks:J(h)})}function ge(){return _e()!==U.value}function Ie(){var E,k;return!!((k=(E=l.value)==null?void 0:E.isEditing)!=null&&k.call(E))}function Ae(E){return c.value.find(k=>k.slug===E)||null}function Be(E){return E&&p.value[E]||null}function Xe(E,k=""){const K=String(E||"").trim();K&&(le={...le,[K]:String(k||"").trim()})}function Pe(E=""){var ee;const k=String(E||"").trim();if(!k)return!1;const K=String(((ee=Ae(k))==null?void 0:ee.updatedAt)||"").trim(),ae=String(le[k]||"").trim();return!!(K&&ae&&K===ae)}function it(E){const k=Be(E.slug),K=E.slug===m.value?f.value.blocks:(k==null?void 0:k.blocks)||[],ae=E.slug===m.value?f.value.title:(k==null?void 0:k.title)??E.title,ee=E.slug===m.value?f.value.autoTitle:(k==null?void 0:k.autoTitle)??E.autoTitle,h=E.slug===m.value?Nt(f.value.todoItems).length:Nt((k==null?void 0:k.todoItems)||[]).length||Number(E.todoCount||0),Y=E.slug===m.value?f.value.lastPromptPreview||E.lastPromptPreview||"":(k==null?void 0:k.lastPromptPreview)||E.lastPromptPreview||"",D=_(E.slug,{summary:E,cachedDraft:k});return{...E,title:ae,autoTitle:ee,todoCount:h,preview:Y,codexSessionId:D,sessionSelectionLocked:!!(D&&Number(E.codexRunCount||0)>0),sessionSelectionLockReason:D&&Number(E.codexRunCount||0)>0?We("taskActions.sessionLocked"):"",displayTitle:yr({title:ae,autoTitle:ee,preview:Y},K),sending:Ns(E)}}function Me(E,k={}){const{insertAtStart:K=!1}=k;if(!(E!=null&&E.slug))return;const ae=[...c.value],ee=ae.findIndex(h=>h.slug===E.slug);if(ee>=0){ae.splice(ee,1,{...ae[ee],...E}),c.value=ae;return}K?ae.unshift(E):ae.push(E),c.value=ae}function Ne(E,k){E&&(p.value={...p.value,[E]:hr(k)})}function Ee(E){return E?`${s}/api/tasks/${E}/raw`:`${s}/api/tasks/`}function lt(E=""){const k=String(E||"").trim();if(!k)return;const K=Ae(k),ae=r.getTaskRunChange(k);if(!K||!(ae!=null&&ae.status))return;const ee=Lv(ae.status);!!K.running!==ee&&Me({...K,running:ee})}function ht(E,k){d.value={...d.value,[E]:!!k}}function dt(E=c.value){const k={};(E||[]).forEach(K=>{K!=null&&K.slug&&(k[K.slug]=!!K.running)}),d.value=k}function wt(E,k){E&&(w.value={...w.value,[E]:String(k||"").trim()})}async function Ct(E,k){const K=String(E||"").trim();if(!K)return;const ae=String(k||"").trim(),ee=Ae(K),h=w.value[K]||(ee==null?void 0:ee.codexSessionId)||"";if(!!(h&&Number((ee==null?void 0:ee.codexRunCount)||0)>0)&&ae!==h){O.value=We("taskActions.sessionLocked");return}wt(K,ae);const D=Be(K);D&&Ne(K,{...D,codexSessionId:ae}),ee&&Me({...ee,codexSessionId:ae,workspaceDiffSummary:ae&&ae===h?ee.workspaceDiffSummary:null}),K===m.value&&(f.value={...f.value,codexSessionId:ae});try{await nl(K,ae)}catch(be){wt(K,h),D&&Ne(K,{...D,codexSessionId:h}),ee&&Me({...ee,codexSessionId:h}),K===m.value&&(f.value={...f.value,codexSessionId:h}),O.value=be.message}}function T(){se&&(window.clearTimeout(se),se=null)}function j(){ce&&(window.clearTimeout(ce),ce=null)}function te(){T(),!(v.value||!m.value)&&(se=window.setTimeout(()=>{Bt({auto:!0,silent:!0})},1500))}function ye(){if(!m.value)return;const E=Ae(m.value)||{slug:m.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};Me({...E,title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoCount:Nt(f.value.todoItems).length,codexSessionId:H.value,preview:String(f.value.lastPromptPreview||"")})}function Oe(E={}){const k=String((E==null?void 0:E.slug)||"").trim();if(!k)return;const K=$n(E);Me(K),Xe(k,K.updatedAt||E.updatedAt||""),k===m.value&&(Object.prototype.hasOwnProperty.call(E,"title")&&(f.value.title=String(E.title||"")),Object.prototype.hasOwnProperty.call(E,"autoTitle")&&(f.value.autoTitle=String(E.autoTitle||"")),Ne(k,{...f.value}))}function Re(E=[]){const k=new Map((E||[]).map(K=>{const ae=String((K==null?void 0:K.slug)||"").trim();return ae?[ae,Rs(K.workspaceDiffSummary)]:null}).filter(Boolean));k.size&&(c.value=c.value.map(K=>k.has(K.slug)?{...K,workspaceDiffSummary:k.get(K.slug)}:K))}async function Ge(E=c.value){const k=Array.isArray(E)?E:[],K=k.filter(ee=>String((ee==null?void 0:ee.codexSessionId)||"").trim()),ae=++pe;if(!K.length){c.value=k.map(ee=>Object.prototype.hasOwnProperty.call(ee,"workspaceDiffSummary")?ee:{...ee,workspaceDiffSummary:null});return}try{const ee=await Fi(k.length||30);if(ae!==pe)return;Re(ee.items||[])}catch{}}async function Ye(E={}){const{silent:k=!1}=E;k||(b.value=!0,O.value="");try{const K=c.value,ae=await ji(),ee=wr(K,(ae.items||[]).map($n));c.value=ee,dt(ee),Mv(K,ee)&&Ge(ee)}catch(K){k||(O.value=K.message)}finally{k||(b.value=!1)}}async function nt(E=[]){const k=Bv(c.value,E),K=c.value.map(h=>String((h==null?void 0:h.slug)||"").trim()).filter(Boolean),ae=k.map(h=>String((h==null?void 0:h.slug)||"").trim()).filter(Boolean);if(!ae.length||ae.join(",")===K.join(","))return!1;const ee=c.value;c.value=k;try{const h=await Vi(ae);Q=Date.now()+Av;const Y=wr(ee,(h.items||[]).map($n));return c.value=Y,dt(Y),!0}catch(h){return c.value=ee,O.value=h.message,!1}}async function yt(E=""){const k=String(m.value||"").trim(),K=String(E||"").trim();if(!k)return;if(!c.value.some(ee=>ee.slug===k)){if(c.value.length){await _t(c.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}m.value="",ys(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},U.value=_e("","","",[],"",[]),z.value=!1;return}K&&K!==k||K&&(Ie()||ge()||z.value||y.value||L.value||v.value||await _t(k,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function st(E=""){const k=String(E||"").trim();I===null?I=k:I!==k&&(I=""),!ce&&(ce=window.setTimeout(async()=>{const K=I;I=null,ce=null,await Ye({silent:!0}),await yt(K||"")},Ev))}async function ft(E){const k=await Br(E),K=(k.blocks||[]).map(ee=>({...ee,content:ee.type==="image"?xs(ee.content):ee.content}));return{state:{title:String(k.title||""),autoTitle:String(k.autoTitle||""),lastPromptPreview:String(k.lastPromptPreview||""),codexSessionId:String(k.codexSessionId||""),blocks:K,todoItems:Nt(k.todoItems||[])},summary:$n({...k,blocks:K}),updatedAt:String(k.updatedAt||"")}}async function _t(E,k={}){const{focusEditor:K=!1,force:ae=!1,skipIfDirtyOnApply:ee=!1,skipIfEditingOnApply:h=!1,scrollPanelToBottom:Y=!1}=k,D=String(E||"").trim();if(!D)return!1;const be=++G;v.value=!0,O.value="",t();try{const Mt=String(m.value||"").trim(),jt=Be(D),Ft=ae&&jt&&Pe(D);let Ut=ae&&!Ft?null:jt,Pt=null;if(!Ut){const mt=await ft(D);Ut=(mt==null?void 0:mt.state)||null,Pt=(mt==null?void 0:mt.summary)||null,Xe(D,(mt==null?void 0:mt.updatedAt)||(Pt==null?void 0:Pt.updatedAt)||"")}return be!==G||ee&&D===m.value&&(ge()||z.value)||h&&D===m.value&&Ie()?!1:(m.value=D,ys(D),f.value=hr(Ut),Ne(D,Ut),Pt&&Me(Pt),wt(D,Ut.codexSessionId),U.value=_e(f.value.title,f.value.autoTitle,f.value.lastPromptPreview,f.value.todoItems,f.value.codexSessionId,f.value.blocks),z.value=!1,K&&at(()=>{var mt,Xt;return(Xt=(mt=l.value)==null?void 0:mt.focusEditor)==null?void 0:Xt.call(mt)}),(Y||D!==Mt)&&o(),!0)}catch(Mt){return be===G&&(O.value=Mt.message),!1}finally{be===G&&(v.value=!1)}}async function Bt(E={}){const{auto:k=!1,silent:K=!1}=E;return m.value?_e()===U.value?!0:A||(T(),y.value=!0,O.value="",A=(async()=>{try{const ee=await Mr(m.value,{title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoItems:Nt(f.value.todoItems),codexSessionId:H.value,expiry:"none",visibility:"private",blocks:J(f.value.blocks)}),h={title:String(ee.title||""),autoTitle:String(ee.autoTitle||""),lastPromptPreview:String(ee.lastPromptPreview||""),todoItems:Nt(ee.todoItems||f.value.todoItems||[]),codexSessionId:H.value||String(ee.codexSessionId||"").trim(),blocks:un(f.value.blocks)};return Ne(m.value,h),U.value=_e(h.title,h.autoTitle,h.lastPromptPreview,h.todoItems,h.codexSessionId,h.blocks),z.value=!1,Me($n(ee)),Xe(m.value,ee.updatedAt||""),!k&&!K&&n({message:We("taskActions.taskSaved"),type:"success"}),!0}catch(ee){return O.value=ee.message,!1}finally{y.value=!1,A=null,_e()!==U.value&&(z.value=!0,te())}})(),A):!1}async function re(){return L.value?(O.value=We("taskActions.fileProcessing"),!1):A||(z.value?Bt({auto:!1,silent:!0}):!0)}async function Le(){if(!await re()&&m.value)return!1;P.value=!0,O.value="";try{const E=await Ui({title:"",expiry:"none",visibility:"private"}),k={title:String(E.title||""),autoTitle:String(E.autoTitle||""),lastPromptPreview:String(E.lastPromptPreview||""),codexSessionId:String(E.codexSessionId||""),blocks:un(E.blocks||[]),todoItems:Nt(E.todoItems||[])};return Ne(E.slug,k),Me($n(E),{insertAtStart:!0}),await _t(E.slug,{focusEditor:!0}),n({message:We("taskActions.taskCreated"),type:"success"}),!0}catch(E){return O.value=E.message,!1}finally{P.value=!1}}async function ot(E){const k=String(E||"").trim();!k||k===m.value||!await re()||await _t(k)}async function xt(){if(m.value){ne.value=!0,O.value="";try{const E=m.value;await zi(E),c.value=c.value.filter(ee=>ee.slug!==E);const k={...p.value};delete k[E],p.value=k;const K={...w.value};delete K[E],w.value=K;const ae={...d.value};delete ae[E],d.value=ae,c.value.length?await _t(c.value[0].slug,{focusEditor:!0}):(m.value="",ys(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},U.value=_e("","","",[],"",[]),z.value=!1,await Le())}catch(E){O.value=E.message}finally{ne.value=!1}}}function Et(E={}){const{silent:k=!1}=E;m.value&&(f.value={...f.value,blocks:vr()},Ne(m.value,f.value),ye(),z.value=!0,at(()=>{var K,ae;(ae=(K=l.value)==null?void 0:K.focusEditor)==null||ae.call(K)}),k||n({message:We("taskActions.taskCleared"),type:"info"}))}function pt(){if(!m.value)return!1;const E=wa(f.value.blocks);return E.length?(f.value={...f.value,blocks:vr(),todoItems:[{id:Iv(),createdAt:new Date().toISOString(),blocks:E},...Nt(f.value.todoItems)]},Ne(m.value,f.value),ye(),z.value=!0,at(()=>{var k,K;(K=(k=l.value)==null?void 0:k.focusEditor)==null||K.call(k)}),n({message:We("taskActions.todoAdded"),type:"success"}),!0):!1}function V(E=""){const k=String(E||"").trim();if(!m.value||!k)return!1;const K=Nt(f.value.todoItems).filter(ae=>ae.id!==k);return K.length===Nt(f.value.todoItems).length?!1:(f.value={...f.value,todoItems:K},Ne(m.value,f.value),ye(),z.value=!0,!0)}function X(E=""){const k=String(E||"").trim();if(!m.value||!k)return null;const K=Nt(f.value.todoItems).find(ae=>ae.id===k);return K?(f.value={...f.value,blocks:un(K.blocks),todoItems:Nt(f.value.todoItems).filter(ae=>ae.id!==k)},Ne(m.value,f.value),ye(),z.value=!0,at(()=>{var ae,ee;(ee=(ae=l.value)==null?void 0:ae.focusEditor)==null||ee.call(ae)}),K):null}async function de(){var ee;if(await Ye(),!c.value.length){await Le();return}const E=Nv();if(E){const h=await _t(E,{focusEditor:!0,force:!0});if(Ov(),h)return}const k=((ee=c.value.find(h=>!!(h!=null&&h.running)))==null?void 0:ee.slug)||"",K=Rv(),ae=k||(c.value.some(h=>h.slug===K)?K:c.value[0].slug);await _t(ae,{focusEditor:!0,force:!0})}async function he(E){var k,K,ae;L.value=!0,O.value="";try{const ee=((K=(k=l.value)==null?void 0:k.isImportedBlockActive)==null?void 0:K.call(k))||!1,h=[];for(const Y of E){const D=await Hi(Y);h.push({type:"image",content:xs(D.url),meta:{}})}(ae=l.value)==null||ae.insertUploadedBlocks(h),n({message:We("taskActions.imageInserted",{count:h.length,appended:ee}),type:"success"})}catch(ee){O.value=ee.message}finally{L.value=!1}}async function Ue(E){var k,K,ae;O.value="";try{const ee=((K=(k=l.value)==null?void 0:k.isImportedBlockActive)==null?void 0:K.call(k))||!1,h=[];for(const Y of E){const D=await Y.text();D.trim()&&h.push({type:"imported_text",content:D,meta:{fileName:Y.name||We("workbench.untitledTask"),collapsed:!0}})}if(!h.length){n({message:We("taskActions.noTextImported"),type:"warning"});return}(ae=l.value)==null||ae.insertImportedBlocks(h),n({message:We("taskActions.importedBlocksInserted",{count:h.length,appended:ee}),type:"success"})}catch{O.value=We("taskActions.textImportFailed")}}async function Tt(E){var k;L.value=!0,O.value="";try{let K=0,ae=0;for(const ee of E){const h=await qi(ee),Y=(h.blocks||[]).map(D=>({...D,content:D.type==="image"?xs(D.content):D.content}));Y.length&&((k=l.value)==null||k.insertBlocks(Y),K+=Y.length,ae+=Number(h.pageCount||0))}if(!K){n({message:We("taskActions.noPdfContent"),type:"warning"});return}n({message:We("taskActions.pdfBlocksInserted",{blockCount:K,pageCount:ae}),type:"success"})}catch(K){O.value=K.message||We("taskActions.pdfImportFailed")}finally{L.value=!1}}function qt(E){const k=E===m.value?f.value:Be(E);return k?Cv({title:String(k.title||""),blocks:J(k.blocks||[])},Ee(E)):""}function At(E){const k=E===m.value?f.value:Be(E);return k?un(J(k.blocks||[])):[]}async function Ot(E){return L.value?(O.value=We("taskActions.fileProcessingBeforeSend"),!1):E!==m.value?!0:y.value&&A?A:z.value?Bt({auto:!1,silent:!0}):!0}async function Qt(E){return await Ot(E)?qt(E):""}function nn(E,k){const K=Sr(k);!K||E!==m.value||(f.value.lastPromptPreview=K,Ne(m.value,f.value),ye())}return $e(f,()=>{if(v.value||!m.value)return;const E=bo(f.value.blocks);!String(f.value.title||"").trim()&&E&&E!==f.value.autoTitle&&(f.value.autoTitle=E),Ne(m.value,f.value),z.value=_e()!==U.value,ye(),z.value&&!y.value&&te()},{deep:!0}),$e(m,E=>{E&&ys(E)}),It(()=>{T(),j()}),$e(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<Q||(lt(r.listSyncTaskSlug.value),st(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:pt,applyTaskSettingsUpdate:Oe,buildPromptForTask:qt,getPromptBlocksForTask:At,buildPromptPreview:Sr,clearCurrentTaskContent:Et,createTaskAndSelect:Le,currentProjectSessionId:H,currentTaskSendState:F,currentTaskAutoTitle:ie,currentTaskDisplayTitle:ve,currentTaskSlug:m,draft:f,editorRef:l,error:O,handleImportPdfFiles:Tt,handleImportTextFiles:Ue,handleTaskSendingChange:ht,handleTaskSessionChange:Ct,handleUpload:he,hasCurrentDraftContent:Fe,hasAnyTaskSending:De,hasUnsavedChanges:z,initializeWorkbench:de,isCurrentTaskSending:He,loadingTask:v,loadingTasks:b,pageTitle:Ke,prepareCodexPromptForTask:Qt,currentTodoItems:je,removeTodoItem:V,removeCurrentTask:xt,reorderTaskList:nt,removingTask:ne,renderedTasks:tt,refreshTaskList:Ye,saveTask:Bt,saving:y,selectTask:ot,selectedSessionMap:w,sendingTaskMap:d,taskDraftMap:p,tasks:c,useTodoItem:X,updateLastPromptPreview:nn,uploading:L,creatingTask:P}}const Fv={class:"flex h-full min-h-0 flex-col overflow-hidden"},Uv={key:0,class:"workbench-desktop-layout grid min-h-0 flex-1 gap-4 lg:grid-cols-[260px_minmax(0,1fr)] lg:grid-rows-1"},Vv={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},zv={class:"min-h-0 min-w-0 overflow-hidden"},Hv={class:"min-h-0 min-w-0 overflow-hidden"},qv={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},Kv={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},Wv={class:"flex flex-col gap-2"},Gv={class:"min-h-0 flex-1 overflow-hidden"},Xv={key:1,class:"min-h-0 flex-1 overflow-hidden"},Yv={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},Jv={class:"workbench-mobile-tabs-panel shrink-0"},Qv={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},Zv={class:"min-h-0 flex-1 overflow-hidden"},ey={class:"h-full min-h-0"},ty={class:"h-full min-h-0"},ny={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},sy={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},oy={class:"flex flex-col gap-2"},ry={class:"min-h-0 flex-1 overflow-hidden"},ay={__name:"WorkbenchView",setup(e){const t=q(!1),n=q(!1),o=q(!1),s=q(!1),r=q(!1),l=q(!1),c=q(!1),p=q(!1),w=q(""),d=q(""),m=q(""),f=q(0),b=q("workspace"),v=q(""),{t:P}=St(),{toastMessage:ne,toastType:y,flashToast:L,clearToast:O}=bv(),{sendBehavior:z}=ba(),U=fo(()=>ze(()=>import("./TaskDiffReviewDialog-VwZmo00b.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),se=fo(()=>ze(()=>import("./WorkbenchSettingsDialog-CThWkZHd.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),A=q(null),G=q([]),ce=q({});function pe($="",Z=G.value){const we=String($||"").trim();return we&&Z.some(ke=>(ke==null?void 0:ke.engine)===we)?we:""}function I($=G.value){var Z,we;return((Z=$.find(ke=>ke==null?void 0:ke.isDefault))==null?void 0:Z.engine)||((we=$[0])==null?void 0:we.engine)||""}const Q=W({get(){const $=String(je.value||"").trim();return $?pe(ce.value[$])||I():""},set($){const Z=String(je.value||"").trim(),we=pe($);!Z||!we||(ce.value={...ce.value,[Z]:we})}});function le($){return $?A.value:null}function ie(){at(()=>{var $,Z;(Z=($=le(R.value))==null?void 0:$.scrollToBottom)==null||Z.call($)})}const{addCurrentDraftToTodo:ve,applyTaskSettingsUpdate:_,buildPromptForTask:H,getPromptBlocksForTask:F,clearCurrentTaskContent:He,createTaskAndSelect:De,creatingTask:Fe,currentProjectSessionId:je,currentTaskSendState:Ke,currentTaskAutoTitle:tt,currentTaskDisplayTitle:xe,currentTaskSlug:R,draft:J,editorRef:fe,error:_e,handleImportPdfFiles:ge,handleImportTextFiles:Ie,handleTaskSendingChange:Ae,handleTaskSessionChange:Be,handleUpload:Xe,hasCurrentDraftContent:Pe,hasUnsavedChanges:it,initializeWorkbench:Me,isCurrentTaskSending:Ne,loadingTask:Ee,loadingTasks:lt,pageTitle:ht,prepareCodexPromptForTask:dt,currentTodoItems:wt,removeTodoItem:Ct,removeCurrentTask:T,reorderTaskList:j,removingTask:te,renderedTasks:ye,saveTask:Oe,saving:Re,selectTask:Ge,updateLastPromptPreview:Ye,useTodoItem:nt,uploading:yt}=jv({clearToast:O,flashToast:L,scrollCurrentPanelToBottom:ie}),st=W(()=>ye.value.find($=>$.slug===R.value)||null),ft=W(()=>{var $,Z;return!!((Z=($=st.value)==null?void 0:$.workspaceDiffSummary)!=null&&Z.supported)}),_t=W(()=>{const $=st.value;return $?()=>dt($.slug):null}),Bt=W(()=>{const $=st.value;return $?()=>F($.slug):null}),re=W(()=>({creatingTask:Fe.value,currentTaskAutoTitle:J.value.autoTitle||tt.value,currentTaskSlug:R.value,draftTitle:J.value.title,editingTaskTitleSlug:m.value,error:_e.value,isCurrentTaskSending:Ne.value,loadingTask:Ee.value,loadingTasks:lt.value,removingTask:te.value,tasks:ye.value,uploading:yt.value})),Le=W(()=>{var $,Z,we,ke;return{buildPromptBlocks:Bt.value,buildPrompt:_t.value,diffSupported:ft.value,selectedAgentEngine:Q.value,selectedSessionId:je.value,sessionSelectionLockReason:(($=st.value)==null?void 0:$.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((Z=st.value)!=null&&Z.sessionSelectionLocked),taskSlug:((we=st.value)==null?void 0:we.slug)||"",taskRunning:!!((ke=st.value)!=null&&ke.running)}}),ot=W(()=>({codexSessionId:je.value,sendBehavior:z.value,loading:Ee.value})),xt=W(()=>({currentTaskAutoTitle:J.value.autoTitle||tt.value,currentTaskSlug:R.value,editingTaskTitleSlug:m.value,title:xe.value,titleInputValue:J.value.title})),{enterMobileDetail:Et,isMobileLayout:pt,leaveMobileDetail:V,mobileDetailTab:X,mobileView:de}=yv({currentTaskSlug:R});function he($){return $!=null&&$.sending||Number(($==null?void 0:$.codexRunCount)||0)>0?"activity":"input"}wv(ht);function Ue($="workspace",Z=""){b.value=$==="run"?"run":$==="task"?"task":"workspace",v.value=b.value==="run"?String(Z||""):"",o.value=!0,f.value+=1}function Tt(){o.value=!1}function qt(){s.value=!0}function At(){s.value=!1}function Ot(){R.value&&(r.value=!0)}function Qt(){r.value=!1}function nn(){l.value=!0}function E(){l.value=!1,k(),K()}function k(){c.value=!1,w.value=""}function K(){p.value=!1,d.value=""}function ae($){_($)}function ee($){J.value.title=$}async function h(){m.value="",it.value&&await Oe({auto:!1,silent:!0})}function Y($){$===R.value&&(m.value=$,at(()=>{var we,ke;const Z=document.querySelector('[data-task-title-input="current"]');(we=Z==null?void 0:Z.focus)==null||we.call(Z),(ke=Z==null?void 0:Z.select)==null||ke.call(Z)}))}async function D($){if(pt.value){await Un($);return}if($!==R.value){await Un($);return}Y($)}function be(){n.value=!0}function Mt(){te.value||(n.value=!1)}async function jt(){await T(),n.value=!1,pt.value&&V({useHistory:!1})}function Ft(){t.value=!0}function Ut(){t.value=!1}function Pt(){t.value=!1,He()}function mt($){const Z=st.value;Z&&Ae(Z.slug,$)}function Xt($){const Z=st.value;Z&&Be(Z.slug,$)}function Vs($={}){const Z=String(($==null?void 0:$.sessionId)||"").trim(),we=je.value;if(Z&&Z!==we)return;const ke=Array.isArray($==null?void 0:$.bindings)?$.bindings:[];G.value=ke;const u=pe(ce.value[we],ke)||pe($==null?void 0:$.selectedEngine,ke)||I(ke);u&&(Q.value=u)}$e(je,($,Z)=>{String($||"").trim()!==String(Z||"").trim()&&(G.value=[])});function Fn($){Q.value=$}function zs($){L($),!(!pt.value||!R.value)&&(X.value="activity")}async function zt(){var $,Z,we,ke,u,C,B,M;typeof document<"u"&&((Z=($=fe.value)==null?void 0:$.isComposing)!=null&&Z.call($))&&((ke=(we=document.activeElement)==null?void 0:we.blur)==null||ke.call(we)),(C=(u=fe.value)==null?void 0:u.flushPendingInput)==null||C.call(u),await at(),(M=(B=fe.value)==null?void 0:B.flushPendingInput)==null||M.call(B),await at()}async function is(){await zt(),await navigator.clipboard.writeText(H(R.value)),L({message:P("workbench.promptCopied"),type:"info"})}async function Hs(){await De()&&pt.value&&(X.value="input",Et())}async function Un($){const Z=String($||"").trim();Z&&(Z!==R.value&&await Ge(Z),pt.value&&R.value===Z&&(X.value=he(st.value),Et()))}async function ls($=[]){await j($)}async function sn(){await zt(),ve()}function Vn($={}){const Z=String(($==null?void 0:$.rangeLabel)||"").trim();if(Z)return Z;const we=Math.max(0,Number($==null?void 0:$.lineStart)||0),ke=Math.max(0,Number($==null?void 0:$.lineEnd)||0);return we&&ke&&we!==ke?`L${we}-L${ke}`:we||ke?`L${we||ke}`:""}function zn($=""){return`code-context-${String($||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function Yt($={}){const Z=String(($==null?void 0:$.filePath)||"").trim(),we=String(($==null?void 0:$.content)||"").replace(/\r\n/g,`
57
+ `)}function J(E=[]){return E.map(k=>({id:Number.isInteger(Number(k==null?void 0:k.id))?Number(k.id):null,type:k==null?void 0:k.type,content:(k==null?void 0:k.type)==="image"?xe(k.content):R(k.content),meta:k!=null&&k.meta?{...k.meta}:{}}))}function fe(E=[]){return(E||[]).map(k=>({id:String((k==null?void 0:k.id)||"").trim(),createdAt:String((k==null?void 0:k.createdAt)||""),blocks:J((k==null?void 0:k.blocks)||[])}))}function _e(E=f.value.title,k=f.value.autoTitle,K=f.value.lastPromptPreview,ae=f.value.todoItems,ee=f.value.codexSessionId,h=f.value.blocks){return JSON.stringify({title:String(E||""),autoTitle:String(k||""),lastPromptPreview:String(K||""),todoItems:fe(ae),codexSessionId:String(ee||""),blocks:J(h)})}function ge(){return _e()!==U.value}function Ie(){var E,k;return!!((k=(E=l.value)==null?void 0:E.isEditing)!=null&&k.call(E))}function Ae(E){return c.value.find(k=>k.slug===E)||null}function Be(E){return E&&p.value[E]||null}function Xe(E,k=""){const K=String(E||"").trim();K&&(le={...le,[K]:String(k||"").trim()})}function Pe(E=""){var ee;const k=String(E||"").trim();if(!k)return!1;const K=String(((ee=Ae(k))==null?void 0:ee.updatedAt)||"").trim(),ae=String(le[k]||"").trim();return!!(K&&ae&&K===ae)}function it(E){const k=Be(E.slug),K=E.slug===m.value?f.value.blocks:(k==null?void 0:k.blocks)||[],ae=E.slug===m.value?f.value.title:(k==null?void 0:k.title)??E.title,ee=E.slug===m.value?f.value.autoTitle:(k==null?void 0:k.autoTitle)??E.autoTitle,h=E.slug===m.value?Nt(f.value.todoItems).length:Nt((k==null?void 0:k.todoItems)||[]).length||Number(E.todoCount||0),Y=E.slug===m.value?f.value.lastPromptPreview||E.lastPromptPreview||"":(k==null?void 0:k.lastPromptPreview)||E.lastPromptPreview||"",D=_(E.slug,{summary:E,cachedDraft:k});return{...E,title:ae,autoTitle:ee,todoCount:h,preview:Y,codexSessionId:D,sessionSelectionLocked:!!(D&&Number(E.codexRunCount||0)>0),sessionSelectionLockReason:D&&Number(E.codexRunCount||0)>0?We("taskActions.sessionLocked"):"",displayTitle:yr({title:ae,autoTitle:ee,preview:Y},K),sending:Ns(E)}}function Me(E,k={}){const{insertAtStart:K=!1}=k;if(!(E!=null&&E.slug))return;const ae=[...c.value],ee=ae.findIndex(h=>h.slug===E.slug);if(ee>=0){ae.splice(ee,1,{...ae[ee],...E}),c.value=ae;return}K?ae.unshift(E):ae.push(E),c.value=ae}function Ne(E,k){E&&(p.value={...p.value,[E]:hr(k)})}function Ee(E){return E?`${s}/api/tasks/${E}/raw`:`${s}/api/tasks/`}function lt(E=""){const k=String(E||"").trim();if(!k)return;const K=Ae(k),ae=r.getTaskRunChange(k);if(!K||!(ae!=null&&ae.status))return;const ee=Lv(ae.status);!!K.running!==ee&&Me({...K,running:ee})}function ht(E,k){d.value={...d.value,[E]:!!k}}function dt(E=c.value){const k={};(E||[]).forEach(K=>{K!=null&&K.slug&&(k[K.slug]=!!K.running)}),d.value=k}function wt(E,k){E&&(S.value={...S.value,[E]:String(k||"").trim()})}async function Ct(E,k){const K=String(E||"").trim();if(!K)return;const ae=String(k||"").trim(),ee=Ae(K),h=S.value[K]||(ee==null?void 0:ee.codexSessionId)||"";if(!!(h&&Number((ee==null?void 0:ee.codexRunCount)||0)>0)&&ae!==h){O.value=We("taskActions.sessionLocked");return}wt(K,ae);const D=Be(K);D&&Ne(K,{...D,codexSessionId:ae}),ee&&Me({...ee,codexSessionId:ae,workspaceDiffSummary:ae&&ae===h?ee.workspaceDiffSummary:null}),K===m.value&&(f.value={...f.value,codexSessionId:ae});try{await nl(K,ae)}catch(be){wt(K,h),D&&Ne(K,{...D,codexSessionId:h}),ee&&Me({...ee,codexSessionId:h}),K===m.value&&(f.value={...f.value,codexSessionId:h}),O.value=be.message}}function T(){se&&(window.clearTimeout(se),se=null)}function j(){ce&&(window.clearTimeout(ce),ce=null)}function te(){T(),!(v.value||!m.value)&&(se=window.setTimeout(()=>{Bt({auto:!0,silent:!0})},1500))}function ye(){if(!m.value)return;const E=Ae(m.value)||{slug:m.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};Me({...E,title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoCount:Nt(f.value.todoItems).length,codexSessionId:H.value,preview:String(f.value.lastPromptPreview||"")})}function Oe(E={}){const k=String((E==null?void 0:E.slug)||"").trim();if(!k)return;const K=$n(E);Me(K),Xe(k,K.updatedAt||E.updatedAt||""),k===m.value&&(Object.prototype.hasOwnProperty.call(E,"title")&&(f.value.title=String(E.title||"")),Object.prototype.hasOwnProperty.call(E,"autoTitle")&&(f.value.autoTitle=String(E.autoTitle||"")),Ne(k,{...f.value}))}function Re(E=[]){const k=new Map((E||[]).map(K=>{const ae=String((K==null?void 0:K.slug)||"").trim();return ae?[ae,Rs(K.workspaceDiffSummary)]:null}).filter(Boolean));k.size&&(c.value=c.value.map(K=>k.has(K.slug)?{...K,workspaceDiffSummary:k.get(K.slug)}:K))}async function Ge(E=c.value){const k=Array.isArray(E)?E:[],K=k.filter(ee=>String((ee==null?void 0:ee.codexSessionId)||"").trim()),ae=++pe;if(!K.length){c.value=k.map(ee=>Object.prototype.hasOwnProperty.call(ee,"workspaceDiffSummary")?ee:{...ee,workspaceDiffSummary:null});return}try{const ee=await Fi(k.length||30);if(ae!==pe)return;Re(ee.items||[])}catch{}}async function Ye(E={}){const{silent:k=!1}=E;k||(b.value=!0,O.value="");try{const K=c.value,ae=await ji(),ee=wr(K,(ae.items||[]).map($n));c.value=ee,dt(ee),Mv(K,ee)&&Ge(ee)}catch(K){k||(O.value=K.message)}finally{k||(b.value=!1)}}async function nt(E=[]){const k=Bv(c.value,E),K=c.value.map(h=>String((h==null?void 0:h.slug)||"").trim()).filter(Boolean),ae=k.map(h=>String((h==null?void 0:h.slug)||"").trim()).filter(Boolean);if(!ae.length||ae.join(",")===K.join(","))return!1;const ee=c.value;c.value=k;try{const h=await Vi(ae);Q=Date.now()+Av;const Y=wr(ee,(h.items||[]).map($n));return c.value=Y,dt(Y),!0}catch(h){return c.value=ee,O.value=h.message,!1}}async function yt(E=""){const k=String(m.value||"").trim(),K=String(E||"").trim();if(!k)return;if(!c.value.some(ee=>ee.slug===k)){if(c.value.length){await _t(c.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}m.value="",ys(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},U.value=_e("","","",[],"",[]),z.value=!1;return}K&&K!==k||K&&(Ie()||ge()||z.value||y.value||L.value||v.value||await _t(k,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function st(E=""){const k=String(E||"").trim();I===null?I=k:I!==k&&(I=""),!ce&&(ce=window.setTimeout(async()=>{const K=I;I=null,ce=null,await Ye({silent:!0}),await yt(K||"")},Ev))}async function ft(E){const k=await Br(E),K=(k.blocks||[]).map(ee=>({...ee,content:ee.type==="image"?xs(ee.content):ee.content}));return{state:{title:String(k.title||""),autoTitle:String(k.autoTitle||""),lastPromptPreview:String(k.lastPromptPreview||""),codexSessionId:String(k.codexSessionId||""),blocks:K,todoItems:Nt(k.todoItems||[])},summary:$n({...k,blocks:K}),updatedAt:String(k.updatedAt||"")}}async function _t(E,k={}){const{focusEditor:K=!1,force:ae=!1,skipIfDirtyOnApply:ee=!1,skipIfEditingOnApply:h=!1,scrollPanelToBottom:Y=!1}=k,D=String(E||"").trim();if(!D)return!1;const be=++G;v.value=!0,O.value="",t();try{const Mt=String(m.value||"").trim(),jt=Be(D),Ft=ae&&jt&&Pe(D);let Ut=ae&&!Ft?null:jt,Pt=null;if(!Ut){const mt=await ft(D);Ut=(mt==null?void 0:mt.state)||null,Pt=(mt==null?void 0:mt.summary)||null,Xe(D,(mt==null?void 0:mt.updatedAt)||(Pt==null?void 0:Pt.updatedAt)||"")}return be!==G||ee&&D===m.value&&(ge()||z.value)||h&&D===m.value&&Ie()?!1:(m.value=D,ys(D),f.value=hr(Ut),Ne(D,Ut),Pt&&Me(Pt),wt(D,Ut.codexSessionId),U.value=_e(f.value.title,f.value.autoTitle,f.value.lastPromptPreview,f.value.todoItems,f.value.codexSessionId,f.value.blocks),z.value=!1,K&&at(()=>{var mt,Xt;return(Xt=(mt=l.value)==null?void 0:mt.focusEditor)==null?void 0:Xt.call(mt)}),(Y||D!==Mt)&&o(),!0)}catch(Mt){return be===G&&(O.value=Mt.message),!1}finally{be===G&&(v.value=!1)}}async function Bt(E={}){const{auto:k=!1,silent:K=!1}=E;return m.value?_e()===U.value?!0:A||(T(),y.value=!0,O.value="",A=(async()=>{try{const ee=await Mr(m.value,{title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoItems:Nt(f.value.todoItems),codexSessionId:H.value,expiry:"none",visibility:"private",blocks:J(f.value.blocks)}),h={title:String(ee.title||""),autoTitle:String(ee.autoTitle||""),lastPromptPreview:String(ee.lastPromptPreview||""),todoItems:Nt(ee.todoItems||f.value.todoItems||[]),codexSessionId:H.value||String(ee.codexSessionId||"").trim(),blocks:un(f.value.blocks)};return Ne(m.value,h),U.value=_e(h.title,h.autoTitle,h.lastPromptPreview,h.todoItems,h.codexSessionId,h.blocks),z.value=!1,Me($n(ee)),Xe(m.value,ee.updatedAt||""),!k&&!K&&n({message:We("taskActions.taskSaved"),type:"success"}),!0}catch(ee){return O.value=ee.message,!1}finally{y.value=!1,A=null,_e()!==U.value&&(z.value=!0,te())}})(),A):!1}async function re(){return L.value?(O.value=We("taskActions.fileProcessing"),!1):A||(z.value?Bt({auto:!1,silent:!0}):!0)}async function Le(){if(!await re()&&m.value)return!1;P.value=!0,O.value="";try{const E=await Ui({title:"",expiry:"none",visibility:"private"}),k={title:String(E.title||""),autoTitle:String(E.autoTitle||""),lastPromptPreview:String(E.lastPromptPreview||""),codexSessionId:String(E.codexSessionId||""),blocks:un(E.blocks||[]),todoItems:Nt(E.todoItems||[])};return Ne(E.slug,k),Me($n(E),{insertAtStart:!0}),await _t(E.slug,{focusEditor:!0}),n({message:We("taskActions.taskCreated"),type:"success"}),!0}catch(E){return O.value=E.message,!1}finally{P.value=!1}}async function ot(E){const k=String(E||"").trim();!k||k===m.value||!await re()||await _t(k)}async function xt(){if(m.value){ne.value=!0,O.value="";try{const E=m.value;await zi(E),c.value=c.value.filter(ee=>ee.slug!==E);const k={...p.value};delete k[E],p.value=k;const K={...S.value};delete K[E],S.value=K;const ae={...d.value};delete ae[E],d.value=ae,c.value.length?await _t(c.value[0].slug,{focusEditor:!0}):(m.value="",ys(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},U.value=_e("","","",[],"",[]),z.value=!1,await Le())}catch(E){O.value=E.message}finally{ne.value=!1}}}function Et(E={}){const{silent:k=!1}=E;m.value&&(f.value={...f.value,blocks:vr()},Ne(m.value,f.value),ye(),z.value=!0,at(()=>{var K,ae;(ae=(K=l.value)==null?void 0:K.focusEditor)==null||ae.call(K)}),k||n({message:We("taskActions.taskCleared"),type:"info"}))}function pt(){if(!m.value)return!1;const E=wa(f.value.blocks);return E.length?(f.value={...f.value,blocks:vr(),todoItems:[{id:Iv(),createdAt:new Date().toISOString(),blocks:E},...Nt(f.value.todoItems)]},Ne(m.value,f.value),ye(),z.value=!0,at(()=>{var k,K;(K=(k=l.value)==null?void 0:k.focusEditor)==null||K.call(k)}),n({message:We("taskActions.todoAdded"),type:"success"}),!0):!1}function V(E=""){const k=String(E||"").trim();if(!m.value||!k)return!1;const K=Nt(f.value.todoItems).filter(ae=>ae.id!==k);return K.length===Nt(f.value.todoItems).length?!1:(f.value={...f.value,todoItems:K},Ne(m.value,f.value),ye(),z.value=!0,!0)}function X(E=""){const k=String(E||"").trim();if(!m.value||!k)return null;const K=Nt(f.value.todoItems).find(ae=>ae.id===k);return K?(f.value={...f.value,blocks:un(K.blocks),todoItems:Nt(f.value.todoItems).filter(ae=>ae.id!==k)},Ne(m.value,f.value),ye(),z.value=!0,at(()=>{var ae,ee;(ee=(ae=l.value)==null?void 0:ae.focusEditor)==null||ee.call(ae)}),K):null}async function de(){var ee;if(await Ye(),!c.value.length){await Le();return}const E=Nv();if(E){const h=await _t(E,{focusEditor:!0,force:!0});if(Ov(),h)return}const k=((ee=c.value.find(h=>!!(h!=null&&h.running)))==null?void 0:ee.slug)||"",K=Rv(),ae=k||(c.value.some(h=>h.slug===K)?K:c.value[0].slug);await _t(ae,{focusEditor:!0,force:!0})}async function he(E){var k,K,ae;L.value=!0,O.value="";try{const ee=((K=(k=l.value)==null?void 0:k.isImportedBlockActive)==null?void 0:K.call(k))||!1,h=[];for(const Y of E){const D=await Hi(Y);h.push({type:"image",content:xs(D.url),meta:{}})}(ae=l.value)==null||ae.insertUploadedBlocks(h),n({message:We("taskActions.imageInserted",{count:h.length,appended:ee}),type:"success"})}catch(ee){O.value=ee.message}finally{L.value=!1}}async function Ue(E){var k,K,ae;O.value="";try{const ee=((K=(k=l.value)==null?void 0:k.isImportedBlockActive)==null?void 0:K.call(k))||!1,h=[];for(const Y of E){const D=await Y.text();D.trim()&&h.push({type:"imported_text",content:D,meta:{fileName:Y.name||We("workbench.untitledTask"),collapsed:!0}})}if(!h.length){n({message:We("taskActions.noTextImported"),type:"warning"});return}(ae=l.value)==null||ae.insertImportedBlocks(h),n({message:We("taskActions.importedBlocksInserted",{count:h.length,appended:ee}),type:"success"})}catch{O.value=We("taskActions.textImportFailed")}}async function Tt(E){var k;L.value=!0,O.value="";try{let K=0,ae=0;for(const ee of E){const h=await qi(ee),Y=(h.blocks||[]).map(D=>({...D,content:D.type==="image"?xs(D.content):D.content}));Y.length&&((k=l.value)==null||k.insertBlocks(Y),K+=Y.length,ae+=Number(h.pageCount||0))}if(!K){n({message:We("taskActions.noPdfContent"),type:"warning"});return}n({message:We("taskActions.pdfBlocksInserted",{blockCount:K,pageCount:ae}),type:"success"})}catch(K){O.value=K.message||We("taskActions.pdfImportFailed")}finally{L.value=!1}}function qt(E){const k=E===m.value?f.value:Be(E);return k?Cv({title:String(k.title||""),blocks:J(k.blocks||[])},Ee(E)):""}function At(E){const k=E===m.value?f.value:Be(E);return k?un(J(k.blocks||[])):[]}async function Ot(E){return L.value?(O.value=We("taskActions.fileProcessingBeforeSend"),!1):E!==m.value?!0:y.value&&A?A:z.value?Bt({auto:!1,silent:!0}):!0}async function Qt(E){return await Ot(E)?qt(E):""}function nn(E,k){const K=Sr(k);!K||E!==m.value||(f.value.lastPromptPreview=K,Ne(m.value,f.value),ye())}return $e(f,()=>{if(v.value||!m.value)return;const E=bo(f.value.blocks);!String(f.value.title||"").trim()&&E&&E!==f.value.autoTitle&&(f.value.autoTitle=E),Ne(m.value,f.value),z.value=_e()!==U.value,ye(),z.value&&!y.value&&te()},{deep:!0}),$e(m,E=>{E&&ys(E)}),It(()=>{T(),j()}),$e(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<Q||(lt(r.listSyncTaskSlug.value),st(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:pt,applyTaskSettingsUpdate:Oe,buildPromptForTask:qt,getPromptBlocksForTask:At,buildPromptPreview:Sr,clearCurrentTaskContent:Et,createTaskAndSelect:Le,currentProjectSessionId:H,currentTaskSendState:F,currentTaskAutoTitle:ie,currentTaskDisplayTitle:ve,currentTaskSlug:m,draft:f,editorRef:l,error:O,handleImportPdfFiles:Tt,handleImportTextFiles:Ue,handleTaskSendingChange:ht,handleTaskSessionChange:Ct,handleUpload:he,hasCurrentDraftContent:Fe,hasAnyTaskSending:De,hasUnsavedChanges:z,initializeWorkbench:de,isCurrentTaskSending:He,loadingTask:v,loadingTasks:b,pageTitle:Ke,prepareCodexPromptForTask:Qt,currentTodoItems:je,removeTodoItem:V,removeCurrentTask:xt,reorderTaskList:nt,removingTask:ne,renderedTasks:tt,refreshTaskList:Ye,saveTask:Bt,saving:y,selectTask:ot,selectedSessionMap:S,sendingTaskMap:d,taskDraftMap:p,tasks:c,useTodoItem:X,updateLastPromptPreview:nn,uploading:L,creatingTask:P}}const Fv={class:"flex h-full min-h-0 flex-col overflow-hidden"},Uv={key:0,class:"workbench-desktop-layout grid min-h-0 flex-1 gap-4 lg:grid-cols-[260px_minmax(0,1fr)] lg:grid-rows-1"},Vv={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},zv={class:"min-h-0 min-w-0 overflow-hidden"},Hv={class:"min-h-0 min-w-0 overflow-hidden"},qv={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},Kv={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},Wv={class:"flex flex-col gap-2"},Gv={class:"min-h-0 flex-1 overflow-hidden"},Xv={key:1,class:"min-h-0 flex-1 overflow-hidden"},Yv={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},Jv={class:"workbench-mobile-tabs-panel shrink-0"},Qv={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},Zv={class:"min-h-0 flex-1 overflow-hidden"},ey={class:"h-full min-h-0"},ty={class:"h-full min-h-0"},ny={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},sy={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},oy={class:"flex flex-col gap-2"},ry={class:"min-h-0 flex-1 overflow-hidden"},ay={__name:"WorkbenchView",setup(e){const t=q(!1),n=q(!1),o=q(!1),s=q(!1),r=q(!1),l=q(!1),c=q(!1),p=q(!1),S=q(""),d=q(""),m=q(""),f=q(0),b=q("workspace"),v=q(""),{t:P}=St(),{toastMessage:ne,toastType:y,flashToast:L,clearToast:O}=bv(),{sendBehavior:z}=ba(),U=fo(()=>ze(()=>import("./TaskDiffReviewDialog-PZ63ypA4.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),se=fo(()=>ze(()=>import("./WorkbenchSettingsDialog-sRvpVVLk.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),A=q(null),G=q([]),ce=q({});function pe($="",Z=G.value){const we=String($||"").trim();return we&&Z.some(ke=>(ke==null?void 0:ke.engine)===we)?we:""}function I($=G.value){var Z,we;return((Z=$.find(ke=>ke==null?void 0:ke.isDefault))==null?void 0:Z.engine)||((we=$[0])==null?void 0:we.engine)||""}const Q=W({get(){const $=String(je.value||"").trim();return $?pe(ce.value[$])||I():""},set($){const Z=String(je.value||"").trim(),we=pe($);!Z||!we||(ce.value={...ce.value,[Z]:we})}});function le($){return $?A.value:null}function ie(){at(()=>{var $,Z;(Z=($=le(R.value))==null?void 0:$.scrollToBottom)==null||Z.call($)})}const{addCurrentDraftToTodo:ve,applyTaskSettingsUpdate:_,buildPromptForTask:H,getPromptBlocksForTask:F,clearCurrentTaskContent:He,createTaskAndSelect:De,creatingTask:Fe,currentProjectSessionId:je,currentTaskSendState:Ke,currentTaskAutoTitle:tt,currentTaskDisplayTitle:xe,currentTaskSlug:R,draft:J,editorRef:fe,error:_e,handleImportPdfFiles:ge,handleImportTextFiles:Ie,handleTaskSendingChange:Ae,handleTaskSessionChange:Be,handleUpload:Xe,hasCurrentDraftContent:Pe,hasUnsavedChanges:it,initializeWorkbench:Me,isCurrentTaskSending:Ne,loadingTask:Ee,loadingTasks:lt,pageTitle:ht,prepareCodexPromptForTask:dt,currentTodoItems:wt,removeTodoItem:Ct,removeCurrentTask:T,reorderTaskList:j,removingTask:te,renderedTasks:ye,saveTask:Oe,saving:Re,selectTask:Ge,updateLastPromptPreview:Ye,useTodoItem:nt,uploading:yt}=jv({clearToast:O,flashToast:L,scrollCurrentPanelToBottom:ie}),st=W(()=>ye.value.find($=>$.slug===R.value)||null),ft=W(()=>{var $,Z;return!!((Z=($=st.value)==null?void 0:$.workspaceDiffSummary)!=null&&Z.supported)}),_t=W(()=>{const $=st.value;return $?()=>dt($.slug):null}),Bt=W(()=>{const $=st.value;return $?()=>F($.slug):null}),re=W(()=>({creatingTask:Fe.value,currentTaskAutoTitle:J.value.autoTitle||tt.value,currentTaskSlug:R.value,draftTitle:J.value.title,editingTaskTitleSlug:m.value,error:_e.value,isCurrentTaskSending:Ne.value,loadingTask:Ee.value,loadingTasks:lt.value,removingTask:te.value,tasks:ye.value,uploading:yt.value})),Le=W(()=>{var $,Z,we,ke;return{buildPromptBlocks:Bt.value,buildPrompt:_t.value,diffSupported:ft.value,selectedAgentEngine:Q.value,selectedSessionId:je.value,sessionSelectionLockReason:(($=st.value)==null?void 0:$.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((Z=st.value)!=null&&Z.sessionSelectionLocked),taskSlug:((we=st.value)==null?void 0:we.slug)||"",taskRunning:!!((ke=st.value)!=null&&ke.running)}}),ot=W(()=>({codexSessionId:je.value,sendBehavior:z.value,loading:Ee.value})),xt=W(()=>({currentTaskAutoTitle:J.value.autoTitle||tt.value,currentTaskSlug:R.value,editingTaskTitleSlug:m.value,title:xe.value,titleInputValue:J.value.title})),{enterMobileDetail:Et,isMobileLayout:pt,leaveMobileDetail:V,mobileDetailTab:X,mobileView:de}=yv({currentTaskSlug:R});function he($){return $!=null&&$.sending||Number(($==null?void 0:$.codexRunCount)||0)>0?"activity":"input"}wv(ht);function Ue($="workspace",Z=""){b.value=$==="run"?"run":$==="task"?"task":"workspace",v.value=b.value==="run"?String(Z||""):"",o.value=!0,f.value+=1}function Tt(){o.value=!1}function qt(){s.value=!0}function At(){s.value=!1}function Ot(){R.value&&(r.value=!0)}function Qt(){r.value=!1}function nn(){l.value=!0}function E(){l.value=!1,k(),K()}function k(){c.value=!1,S.value=""}function K(){p.value=!1,d.value=""}function ae($){_($)}function ee($){J.value.title=$}async function h(){m.value="",it.value&&await Oe({auto:!1,silent:!0})}function Y($){$===R.value&&(m.value=$,at(()=>{var we,ke;const Z=document.querySelector('[data-task-title-input="current"]');(we=Z==null?void 0:Z.focus)==null||we.call(Z),(ke=Z==null?void 0:Z.select)==null||ke.call(Z)}))}async function D($){if(pt.value){await Un($);return}if($!==R.value){await Un($);return}Y($)}function be(){n.value=!0}function Mt(){te.value||(n.value=!1)}async function jt(){await T(),n.value=!1,pt.value&&V({useHistory:!1})}function Ft(){t.value=!0}function Ut(){t.value=!1}function Pt(){t.value=!1,He()}function mt($){const Z=st.value;Z&&Ae(Z.slug,$)}function Xt($){const Z=st.value;Z&&Be(Z.slug,$)}function Vs($={}){const Z=String(($==null?void 0:$.sessionId)||"").trim(),we=je.value;if(Z&&Z!==we)return;const ke=Array.isArray($==null?void 0:$.bindings)?$.bindings:[];G.value=ke;const u=pe(ce.value[we],ke)||pe($==null?void 0:$.selectedEngine,ke)||I(ke);u&&(Q.value=u)}$e(je,($,Z)=>{String($||"").trim()!==String(Z||"").trim()&&(G.value=[])});function Fn($){Q.value=$}function zs($){L($),!(!pt.value||!R.value)&&(X.value="activity")}async function zt(){var $,Z,we,ke,u,C,B,M;typeof document<"u"&&((Z=($=fe.value)==null?void 0:$.isComposing)!=null&&Z.call($))&&((ke=(we=document.activeElement)==null?void 0:we.blur)==null||ke.call(we)),(C=(u=fe.value)==null?void 0:u.flushPendingInput)==null||C.call(u),await at(),(M=(B=fe.value)==null?void 0:B.flushPendingInput)==null||M.call(B),await at()}async function is(){await zt(),await navigator.clipboard.writeText(H(R.value)),L({message:P("workbench.promptCopied"),type:"info"})}async function Hs(){await De()&&pt.value&&(X.value="input",Et())}async function Un($){const Z=String($||"").trim();Z&&(Z!==R.value&&await Ge(Z),pt.value&&R.value===Z&&(X.value=he(st.value),Et()))}async function ls($=[]){await j($)}async function sn(){await zt(),ve()}function Vn($={}){const Z=String(($==null?void 0:$.rangeLabel)||"").trim();if(Z)return Z;const we=Math.max(0,Number($==null?void 0:$.lineStart)||0),ke=Math.max(0,Number($==null?void 0:$.lineEnd)||0);return we&&ke&&we!==ke?`L${we}-L${ke}`:we||ke?`L${we||ke}`:""}function zn($=""){return`code-context-${String($||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function Yt($={}){const Z=String(($==null?void 0:$.filePath)||"").trim(),we=String(($==null?void 0:$.content)||"").replace(/\r\n/g,`
58
58
  `).trimEnd();if(!Z||!we.trim())return null;const ke=String(($==null?void 0:$.language)||"").trim(),u=Vn($),C=String(($==null?void 0:$.source)||"").trim()==="diff"?P("workbench.codeContextSourceDiff"):P("workbench.codeContextSourceFile"),B=ke?`\`\`\`${ke}`:"```",M=[P("workbench.codeContextTitle"),P("workbench.codeContextFile",{path:Z}),u?P("workbench.codeContextRange",{range:u}):"",P("workbench.codeContextSource",{source:C}),"",B,we,"```"].filter(oe=>oe!=="");return{type:$t.IMPORTED_TEXT,content:M.join(`
59
59
  `),meta:{fileName:zn(Z),collapsed:!1}}}async function us($=[],Z="insertBlocks"){var ke,u,C,B;const we=Array.isArray($)?$.filter(Boolean):[];return we.length?(await zt(),(u=(ke=fe.value)==null?void 0:ke[Z])==null||u.call(ke,we),await at(),(B=(C=fe.value)==null?void 0:C.focusEditor)==null||B.call(C),pt.value&&R.value&&(X.value="input"),L({message:P("taskActions.insertedToEditor"),type:"success"}),!0):!1}async function Hn($={}){const Z=String(($==null?void 0:$.source)||"").trim(),we=String(($==null?void 0:$.content)||"").replace(/\r\n/g,`
60
- `).trim();if(Z==="response"){if(!we)return;await us([Pn(we)],"insertBlocks");return}const ke=Yt($);ke&&await us([ke],"insertImportedBlocks")}function Tn($){w.value=String($||"").trim(),c.value=!!w.value}function fn(){w.value&&(Ct(w.value),k())}async function cs($=d.value){const Z=String($||"").trim();return!Z||!nt(Z)?!1:(K(),E(),!0)}async function qs($){await zt();const Z=String($||"").trim();if(Z){if(!Pe.value){await cs(Z);return}d.value=Z,p.value=!0}}async function Cn(){var ke,u,C,B;const $=R.value;if(!$)return;const Z=!!((u=(ke=st.value)==null?void 0:ke.automation)!=null&&u.enabled);await zt(),Ye($,H($)),!(!await((B=(C=le($))==null?void 0:C.send)==null?void 0:B.call(C))||$!==R.value)&&(pt.value&&(X.value="activity"),Z||He({silent:!0}),await Oe({auto:!1,silent:!0}))}function Ks(){!pt.value||de.value!=="detail"||X.value!=="input"||!R.value||at(()=>{var $,Z;(Z=($=fe.value)==null?void 0:$.focusEditor)==null||Z.call($)})}function pn($){!it.value&&!yt.value&&!Re.value||($.preventDefault(),$.returnValue="")}function qn(){var $,Z;return p.value?(K(),!0):c.value?(k(),!0):t.value?(Ut(),!0):n.value?(Mt(),!0):r.value?(Qt(),!0):l.value?(E(),!0):o.value?(Tt(),!0):s.value?(At(),!0):!!((Z=($=le(R.value))==null?void 0:$.closeTopDialog)!=null&&Z.call($))}function En($){var u,C,B,M,oe;const Z=String($.key||""),we=Z.toLowerCase(),ke=$.metaKey||$.ctrlKey;if(Z==="Escape"){qn()&&($.preventDefault(),(u=$.stopImmediatePropagation)==null||u.call($));return}if(ke){if(we==="s"){$.preventDefault(),Oe({auto:!1});return}if($.shiftKey&&Z==="Backspace"){$.preventDefault(),Ft();return}if(!$.isComposing){if($.shiftKey&&$.code==="Comma"){$.preventDefault(),qt();return}if($.shiftKey&&we==="k"){$.preventDefault(),(B=(C=le(R.value))==null?void 0:C.openProjectManager)==null||B.call(C);return}if($.shiftKey&&we==="o"){$.preventDefault(),(oe=(M=le(R.value))==null?void 0:M.openSourceBrowser)==null||oe.call(M);return}$.shiftKey&&we==="d"&&($.preventDefault(),ft.value&&Ue("workspace"))}}}dn(()=>{Me(),window.addEventListener("beforeunload",pn),window.addEventListener("keydown",En)}),It(()=>{window.removeEventListener("beforeunload",pn),window.removeEventListener("keydown",En)}),$e([pt,de,X,R],([$,Z,we,ke])=>{!$||Z!=="detail"||we!=="input"||!ke||Ks()});const on={"update:draftTitle":ee,"cancel-title-edit":()=>{m.value=""},"create-task":Hs,"edit-task":Ot,"delete-task":be,"open-settings":qt,"reorder-task":ls,"select-task":Un,"title-blur":h,"title-click":D},ds={"agent-bindings-change":Vs,"insert-code-context":Hn,"open-diff":({scope:$,runId:Z})=>Ue($,Z),"project-created":()=>L({message:P("workbench.projectCreated"),type:"success"}),"selected-session-change":Xt,"update:selectedAgentEngine":Fn,"sending-change":mt,toast:zs},Kn={"clear-request":Ft,"file-feedback":$=>L({message:$,type:"warning"}),"import-pdf-files":ge,"import-text-files":Ie,"send-request":Cn,"upload-files":Xe},mn={"begin-edit":()=>Y(R.value),back:V,"cancel-title-edit":()=>{m.value=""},"title-blur":h,"update:titleInputValue":ee};return($,Z)=>(g(),x("div",Fv,[ue(gv,{message:a(ne),type:a(y)},null,8,["message","type"]),ue(ps,{open:t.value,title:a(P)("workbench.confirmClearTitle"),description:a(P)("workbench.confirmClearDescription"),"confirm-text":a(P)("workbench.confirmClearAction"),"cancel-text":a(P)("workbench.continueEditing"),onCancel:Ut,onConfirm:Pt},null,8,["open","title","description","confirm-text","cancel-text"]),ue(ps,{open:n.value,title:a(P)("workbench.confirmDeleteTitle"),description:a(P)("workbench.confirmDeleteDescription",{title:a(xe)}),"confirm-text":a(P)("workbench.confirmDeleteAction"),"cancel-text":a(P)("workbench.keepForNow"),loading:a(te),danger:"",onCancel:Mt,onConfirm:jt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),ue(ps,{open:c.value,title:a(P)("workbench.confirmDeleteTodoTitle"),description:a(P)("workbench.confirmDeleteTodoDescription"),"confirm-text":a(P)("workbench.confirmDeleteAction"),"cancel-text":a(P)("workbench.keepForNow"),danger:"",onCancel:k,onConfirm:fn},null,8,["open","title","description","confirm-text","cancel-text"]),ue(ps,{open:p.value,title:a(P)("workbench.replaceEditorTitle"),description:a(P)("workbench.replaceEditorDescription"),"confirm-text":a(P)("workbench.confirmReplaceAction"),"cancel-text":a(P)("workbench.dontReplaceYet"),onCancel:K,onConfirm:Z[0]||(Z[0]=we=>cs())},null,8,["open","title","description","confirm-text","cancel-text"]),ue(pv,{open:l.value,items:a(wt),onClose:E,onDelete:Tn,onUse:qs},null,8,["open","items"]),ue(a(U),{open:o.value,"task-slug":a(R),"task-title":a(xe),"preferred-scope":b.value,"preferred-run-id":v.value,"focus-token":f.value,onInsertCodeContext:Hn,onClose:Tt},null,8,["open","task-slug","task-title","preferred-scope","preferred-run-id","focus-token"]),ue(a(se),{open:s.value,onClose:At},null,8,["open"]),ue(ku,{open:r.value,"task-slug":a(R),"task-title":a(xe),onClose:Qt,onSaved:ae},null,8,["open","task-slug","task-title"]),a(pt)?(g(),x("div",Xv,[a(de)==="tasks"?(g(),Ce(gr,gn({key:0},re.value,{mobile:""},hn(on)),null,16)):(g(),x("div",Yv,[ue(dh,gn(xt.value,hn(mn)),null,16),i("section",Jv,[i("div",Qv,[i("button",{type:"button",class:Se(["tool-button px-3 py-1.5 text-sm",a(X)==="activity"?"tool-button-accent-subtle":""]),onClick:Z[3]||(Z[3]=we=>X.value="activity")},S(a(P)("workbench.activity")),3),i("button",{type:"button",class:Se(["tool-button px-3 py-1.5 text-sm",a(X)==="input"?"tool-button-accent-subtle":""]),onClick:Z[4]||(Z[4]=we=>X.value="input")},S(a(P)("workbench.input")),3)])]),i("div",Zv,[Wt(i("div",ey,[ue(lr,gn({ref_key:"codexPanelRef",ref:A},Le.value,{"empty-message":a(P)("workbench.selectTask")},hn(ds)),null,16,["empty-message"])],512),[[$s,a(X)==="activity"]]),Wt(i("div",ty,[i("div",ny,[i("div",sy,[i("div",oy,[ue(cr,{"can-add-todo":a(Pe),"is-current-task-sending":a(Ne),"send-state":a(Ke),"todo-count":a(wt).length,uploading:a(yt),onAddTodo:sn,onOpenFilePicker:Z[5]||(Z[5]=we=>{var ke,u;return(u=(ke=a(fe))==null?void 0:ke.openFilePicker)==null?void 0:u.call(ke)}),onClearRequest:Ft,onCopyRequest:is,onManageTodo:nn,onSendRequest:Cn},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(ur,{"agent-bindings":G.value,"selected-agent-engine":Q.value,"onUpdate:selectedAgentEngine":Fn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",ry,[ue(mr,gn({ref_key:"editorRef",ref:fe,modelValue:a(J).blocks,"onUpdate:modelValue":Z[6]||(Z[6]=we=>a(J).blocks=we)},ot.value,hn(Kn)),null,16,["modelValue"])])])],512),[[$s,a(X)==="input"]])])]))])):(g(),x("div",Uv,[ue(gr,gn(re.value,hn(on)),null,16),i("div",Vv,[i("div",zv,[st.value?(g(),Ce(lr,gn({key:0,ref_key:"codexPanelRef",ref:A},Le.value,hn(ds)),null,16)):me("",!0)]),i("div",Hv,[i("div",qv,[i("div",Kv,[i("div",Wv,[ue(cr,{"can-add-todo":a(Pe),"is-current-task-sending":a(Ne),"send-state":a(Ke),"todo-count":a(wt).length,uploading:a(yt),onAddTodo:sn,onOpenFilePicker:Z[1]||(Z[1]=we=>{var ke,u;return(u=(ke=a(fe))==null?void 0:ke.openFilePicker)==null?void 0:u.call(ke)}),onClearRequest:Ft,onCopyRequest:is,onManageTodo:nn,onSendRequest:Cn},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(ur,{"agent-bindings":G.value,"selected-agent-engine":Q.value,align:"end","onUpdate:selectedAgentEngine":Fn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",Gv,[ue(mr,gn({ref_key:"editorRef",ref:fe,modelValue:a(J).blocks,"onUpdate:modelValue":Z[2]||(Z[2]=we=>a(J).blocks=we)},ot.value,hn(Kn)),null,16,["modelValue"])])])])])]))]))}},by=Object.freeze(Object.defineProperty({__proto__:null,default:ay},Symbol.toStringTag,{value:"Module"}));export{Sy as D,bs as W,Gr as _,Yr as a,Ju as b,hv as c,en as d,Gu as e,Fs as f,vy as g,Ze as h,wy as i,Ii as j,py as k,sl as l,Gc as m,Jr as n,gy as o,ct as p,Tu as q,xy as r,hy as s,ps as t,oa as u,yy as v,Ls as w,my as x,fy as y,by as z};
60
+ `).trim();if(Z==="response"){if(!we)return;await us([Pn(we)],"insertBlocks");return}const ke=Yt($);ke&&await us([ke],"insertImportedBlocks")}function Tn($){S.value=String($||"").trim(),c.value=!!S.value}function fn(){S.value&&(Ct(S.value),k())}async function cs($=d.value){const Z=String($||"").trim();return!Z||!nt(Z)?!1:(K(),E(),!0)}async function qs($){await zt();const Z=String($||"").trim();if(Z){if(!Pe.value){await cs(Z);return}d.value=Z,p.value=!0}}async function Cn(){var ke,u,C,B;const $=R.value;if(!$)return;const Z=!!((u=(ke=st.value)==null?void 0:ke.automation)!=null&&u.enabled);await zt(),Ye($,H($)),!(!await((B=(C=le($))==null?void 0:C.send)==null?void 0:B.call(C))||$!==R.value)&&(pt.value&&(X.value="activity"),Z||He({silent:!0}),await Oe({auto:!1,silent:!0}))}function Ks(){!pt.value||de.value!=="detail"||X.value!=="input"||!R.value||at(()=>{var $,Z;(Z=($=fe.value)==null?void 0:$.focusEditor)==null||Z.call($)})}function pn($){!it.value&&!yt.value&&!Re.value||($.preventDefault(),$.returnValue="")}function qn(){var $,Z;return p.value?(K(),!0):c.value?(k(),!0):t.value?(Ut(),!0):n.value?(Mt(),!0):r.value?(Qt(),!0):l.value?(E(),!0):o.value?(Tt(),!0):s.value?(At(),!0):!!((Z=($=le(R.value))==null?void 0:$.closeTopDialog)!=null&&Z.call($))}function En($){var u,C,B,M,oe;const Z=String($.key||""),we=Z.toLowerCase(),ke=$.metaKey||$.ctrlKey;if(Z==="Escape"){qn()&&($.preventDefault(),(u=$.stopImmediatePropagation)==null||u.call($));return}if(ke){if(we==="s"){$.preventDefault(),Oe({auto:!1});return}if($.shiftKey&&Z==="Backspace"){$.preventDefault(),Ft();return}if(!$.isComposing){if($.shiftKey&&$.code==="Comma"){$.preventDefault(),qt();return}if($.shiftKey&&we==="k"){$.preventDefault(),(B=(C=le(R.value))==null?void 0:C.openProjectManager)==null||B.call(C);return}if($.shiftKey&&we==="o"){$.preventDefault(),(oe=(M=le(R.value))==null?void 0:M.openSourceBrowser)==null||oe.call(M);return}$.shiftKey&&we==="d"&&($.preventDefault(),ft.value&&Ue("workspace"))}}}dn(()=>{Me(),window.addEventListener("beforeunload",pn),window.addEventListener("keydown",En)}),It(()=>{window.removeEventListener("beforeunload",pn),window.removeEventListener("keydown",En)}),$e([pt,de,X,R],([$,Z,we,ke])=>{!$||Z!=="detail"||we!=="input"||!ke||Ks()});const on={"update:draftTitle":ee,"cancel-title-edit":()=>{m.value=""},"create-task":Hs,"edit-task":Ot,"delete-task":be,"open-settings":qt,"reorder-task":ls,"select-task":Un,"title-blur":h,"title-click":D},ds={"agent-bindings-change":Vs,"insert-code-context":Hn,"open-diff":({scope:$,runId:Z})=>Ue($,Z),"project-created":()=>L({message:P("workbench.projectCreated"),type:"success"}),"selected-session-change":Xt,"update:selectedAgentEngine":Fn,"sending-change":mt,toast:zs},Kn={"clear-request":Ft,"file-feedback":$=>L({message:$,type:"warning"}),"import-pdf-files":ge,"import-text-files":Ie,"send-request":Cn,"upload-files":Xe},mn={"begin-edit":()=>Y(R.value),back:V,"cancel-title-edit":()=>{m.value=""},"title-blur":h,"update:titleInputValue":ee};return($,Z)=>(g(),x("div",Fv,[ue(gv,{message:a(ne),type:a(y)},null,8,["message","type"]),ue(ps,{open:t.value,title:a(P)("workbench.confirmClearTitle"),description:a(P)("workbench.confirmClearDescription"),"confirm-text":a(P)("workbench.confirmClearAction"),"cancel-text":a(P)("workbench.continueEditing"),onCancel:Ut,onConfirm:Pt},null,8,["open","title","description","confirm-text","cancel-text"]),ue(ps,{open:n.value,title:a(P)("workbench.confirmDeleteTitle"),description:a(P)("workbench.confirmDeleteDescription",{title:a(xe)}),"confirm-text":a(P)("workbench.confirmDeleteAction"),"cancel-text":a(P)("workbench.keepForNow"),loading:a(te),danger:"",onCancel:Mt,onConfirm:jt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),ue(ps,{open:c.value,title:a(P)("workbench.confirmDeleteTodoTitle"),description:a(P)("workbench.confirmDeleteTodoDescription"),"confirm-text":a(P)("workbench.confirmDeleteAction"),"cancel-text":a(P)("workbench.keepForNow"),danger:"",onCancel:k,onConfirm:fn},null,8,["open","title","description","confirm-text","cancel-text"]),ue(ps,{open:p.value,title:a(P)("workbench.replaceEditorTitle"),description:a(P)("workbench.replaceEditorDescription"),"confirm-text":a(P)("workbench.confirmReplaceAction"),"cancel-text":a(P)("workbench.dontReplaceYet"),onCancel:K,onConfirm:Z[0]||(Z[0]=we=>cs())},null,8,["open","title","description","confirm-text","cancel-text"]),ue(pv,{open:l.value,items:a(wt),onClose:E,onDelete:Tn,onUse:qs},null,8,["open","items"]),ue(a(U),{open:o.value,"task-slug":a(R),"task-title":a(xe),"preferred-scope":b.value,"preferred-run-id":v.value,"focus-token":f.value,onInsertCodeContext:Hn,onClose:Tt},null,8,["open","task-slug","task-title","preferred-scope","preferred-run-id","focus-token"]),ue(a(se),{open:s.value,onClose:At},null,8,["open"]),ue(ku,{open:r.value,"task-slug":a(R),"task-title":a(xe),onClose:Qt,onSaved:ae},null,8,["open","task-slug","task-title"]),a(pt)?(g(),x("div",Xv,[a(de)==="tasks"?(g(),Ce(gr,gn({key:0},re.value,{mobile:""},hn(on)),null,16)):(g(),x("div",Yv,[ue(dh,gn(xt.value,hn(mn)),null,16),i("section",Jv,[i("div",Qv,[i("button",{type:"button",class:Se(["tool-button px-3 py-1.5 text-sm",a(X)==="activity"?"tool-button-accent-subtle":""]),onClick:Z[3]||(Z[3]=we=>X.value="activity")},w(a(P)("workbench.activity")),3),i("button",{type:"button",class:Se(["tool-button px-3 py-1.5 text-sm",a(X)==="input"?"tool-button-accent-subtle":""]),onClick:Z[4]||(Z[4]=we=>X.value="input")},w(a(P)("workbench.input")),3)])]),i("div",Zv,[Wt(i("div",ey,[ue(lr,gn({ref_key:"codexPanelRef",ref:A},Le.value,{"empty-message":a(P)("workbench.selectTask")},hn(ds)),null,16,["empty-message"])],512),[[$s,a(X)==="activity"]]),Wt(i("div",ty,[i("div",ny,[i("div",sy,[i("div",oy,[ue(cr,{"can-add-todo":a(Pe),"is-current-task-sending":a(Ne),"send-state":a(Ke),"todo-count":a(wt).length,uploading:a(yt),onAddTodo:sn,onOpenFilePicker:Z[5]||(Z[5]=we=>{var ke,u;return(u=(ke=a(fe))==null?void 0:ke.openFilePicker)==null?void 0:u.call(ke)}),onClearRequest:Ft,onCopyRequest:is,onManageTodo:nn,onSendRequest:Cn},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(ur,{"agent-bindings":G.value,"selected-agent-engine":Q.value,"onUpdate:selectedAgentEngine":Fn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",ry,[ue(mr,gn({ref_key:"editorRef",ref:fe,modelValue:a(J).blocks,"onUpdate:modelValue":Z[6]||(Z[6]=we=>a(J).blocks=we)},ot.value,hn(Kn)),null,16,["modelValue"])])])],512),[[$s,a(X)==="input"]])])]))])):(g(),x("div",Uv,[ue(gr,gn(re.value,hn(on)),null,16),i("div",Vv,[i("div",zv,[st.value?(g(),Ce(lr,gn({key:0,ref_key:"codexPanelRef",ref:A},Le.value,hn(ds)),null,16)):me("",!0)]),i("div",Hv,[i("div",qv,[i("div",Kv,[i("div",Wv,[ue(cr,{"can-add-todo":a(Pe),"is-current-task-sending":a(Ne),"send-state":a(Ke),"todo-count":a(wt).length,uploading:a(yt),onAddTodo:sn,onOpenFilePicker:Z[1]||(Z[1]=we=>{var ke,u;return(u=(ke=a(fe))==null?void 0:ke.openFilePicker)==null?void 0:u.call(ke)}),onClearRequest:Ft,onCopyRequest:is,onManageTodo:nn,onSendRequest:Cn},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(ur,{"agent-bindings":G.value,"selected-agent-engine":Q.value,align:"end","onUpdate:selectedAgentEngine":Fn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",Gv,[ue(mr,gn({ref_key:"editorRef",ref:fe,modelValue:a(J).blocks,"onUpdate:modelValue":Z[2]||(Z[2]=we=>a(J).blocks=we)},ot.value,hn(Kn)),null,16,["modelValue"])])])])])]))]))}},by=Object.freeze(Object.defineProperty({__proto__:null,default:ay},Symbol.toStringTag,{value:"Module"}));export{Sy as D,bs as W,Gr as _,Yr as a,Ju as b,hv as c,en as d,Gu as e,Fs as f,vy as g,Ze as h,wy as i,Ii as j,py as k,sl as l,Gc as m,Jr as n,gy as o,ct as p,Tu as q,xy as r,hy as s,ps as t,oa as u,yy as v,Ls as w,my as x,fy as y,by as z};