@muyichengshayu/promptx 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
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-BojVd2nD.js","assets/index-7F-RPTS_.js","assets/vendor-router-Dn8q3tJM.js","assets/index-CpVsZfVv.css","assets/vendor-ui-BglsaDbv.js","assets/vendor-markdown-9aQhqbjm.js","assets/vendor-tiptap-rwYdQb1L.js","assets/TaskDiffReviewDialog-GOruDINI.js","assets/TaskDiffReviewDialog-NsLGEda4.css","assets/WorkbenchSettingsDialog-BYYiMjvq.js"])))=>i.map(i=>d[i]);
2
- import{u as Tt,t as Ye,f as _r,_ as Ke,a as Cr,b as Er,g as qs,s as $a,c as Ia}from"./index-7F-RPTS_.js";import{w as Le,ak as Mt,aD as m,aI as Ae,aG as de,aJ as tt,aE as b,aK as nt,aL as be,aF as i,aM as nn,u as a,aN as me,aO as Ar,aP as fs,c as K,aQ as x,aR as lt,aS as pt,aT as yn,o as cn,aU as Qt,aV as In,b as j,n as dt,aW as Jt,aX as ss,aY as zo,r as ps,aC as Pa,aZ as gn,f as Da,a_ as yo,a$ as Ms,G as La,al as Ma,b0 as bn,b1 as kn}from"./vendor-misc-u-M8sNMf.js";import{X as $r,T as Ba,L as Gt,C as Ao,a as Bs,B as Ho,S as Ra,P as is,b as Ir,c as Na,A as Oa,F as jn,d as Cn,e as Pr,f as Fa,E as Ua,g as ja,h as qo,i as $o,j as Rs,k as Va,l as za,m as Ha,U as qa,W as Ka,n as Dr,o as Wa,p as Ns,q as Ks,I as Lr,r as Ga,s as Xa,t as Ya,u as Ja,G as Qa,v as Za,w as ei,x as ti,y as ni}from"./vendor-ui-BglsaDbv.js";import{M as Mr}from"./vendor-markdown-9aQhqbjm.js";import{n as Io,N as Br,a as Po,i as si,V as to,b as Ko,u as oi,c as ri,E as ai}from"./vendor-tiptap-rwYdQb1L.js";const ii="shell",li=new Set(["!","!"]),Wo="text";function Ts(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-B_F9ZWKy.js","assets/index-5LxHpYf5.js","assets/vendor-router-Dn8q3tJM.js","assets/index-CrBjB0XY.css","assets/vendor-ui-BglsaDbv.js","assets/vendor-markdown-9aQhqbjm.js","assets/vendor-tiptap-rwYdQb1L.js","assets/TaskDiffReviewDialog-CPqGk_q2.js","assets/TaskDiffReviewDialog-NsLGEda4.css","assets/WorkbenchSettingsDialog-CWl81vlG.js"])))=>i.map(i=>d[i]);
2
+ import{u as Tt,t as Ye,f as _r,_ as Ke,a as Cr,b as Er,g as qs,s as $a,c as Ia}from"./index-5LxHpYf5.js";import{w as Le,ak as Mt,aD as m,aI as Ae,aG as de,aJ as tt,aE as b,aK as nt,aL as be,aF as i,aM as nn,u as a,aN as me,aO as Ar,aP as fs,c as K,aQ as x,aR as lt,aS as pt,aT as yn,n as dt,o as cn,aU as Qt,aV as In,b as j,aW as Jt,aX as ss,aY as zo,r as ps,aC as Pa,aZ as gn,f as Da,a_ as yo,a$ as Ms,G as La,al as Ma,b0 as bn,b1 as kn}from"./vendor-misc-u-M8sNMf.js";import{X as $r,T as Ba,L as Gt,C as Ao,a as Bs,B as Ho,S as Ra,P as is,b as Ir,c as Na,A as Oa,F as jn,d as Cn,e as Pr,f as Fa,E as Ua,g as ja,h as qo,i as $o,j as Rs,k as Va,l as za,m as Ha,U as qa,W as Ka,n as Dr,o as Wa,p as Ns,q as Ks,I as Lr,r as Ga,s as Xa,t as Ya,u as Ja,G as Qa,v as Za,w as ei,x as ti,y as ni}from"./vendor-ui-BglsaDbv.js";import{M as Mr}from"./vendor-markdown-9aQhqbjm.js";import{n as Io,N as Br,a as Po,i as si,V as to,b as Ko,u as oi,c as ri,E as ai}from"./vendor-tiptap-rwYdQb1L.js";const ii="shell",li=new Set(["!","!"]),Wo="text";function Ts(e=""){return String(e||"").replace(/\r\n/g,`
3
3
  `).trim()}function ui(e=""){const t=String(e||"");return li.has(t.charAt(0))}function ci(e=""){const t=Ts(e);return t?t.charAt(0)==="!"?`!${t.slice(1)}`:t:""}function di(e={}){const n=(Array.isArray(e==null?void 0:e.promptBlocks)?e.promptBlocks:[]).filter(u=>!!Ts(u==null?void 0:u.content)),o=n.length>0,s=o?n.filter(u=>String((u==null?void 0:u.type)||"").trim()===Wo).map(u=>Ts(u==null?void 0:u.content)).filter(Boolean).join(`
4
4
 
5
5
  `).trim():Ts(e==null?void 0:e.prompt);if(!ui(s))return{mode:"",prompt:s,command:"",reason:""};if(o&&n.some(p=>String((p==null?void 0:p.type)||"").trim()!==Wo))return{mode:"",prompt:s,command:"",reason:"unsupported_blocks"};const l=ci(s).slice(1).trim();return l?{mode:ii,prompt:s,command:l,reason:""}:{mode:"",prompt:s,command:"",reason:"empty_command"}}const an={NONE:"none",LATEST:"latest",ALL:"all"};function fi(e="",t={}){const n=String(e||"").trim().toLowerCase();return n===an.ALL?an.ALL:n===an.LATEST?an.LATEST:n===an.NONE?an.NONE:t.includeEvents?an.ALL:t.includeLatestEvents?an.LATEST:an.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 Rr(e=""){const t=String(e||"").trim().toLowerCase();return t==="codex"?Vt.AGENT_EVENT:t}const kt={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"},ct={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"},pi={none:{label:"不过期",hours:null}};Object.entries(pi).map(([e,t])=>({value:e,label:t.label}));const _s={CODEX:"codex",CLAUDE_CODE:"claude-code",OPENCODE:"opencode"},Do=[{value:_s.CODEX,label:"Codex",enabled:!0},{value:_s.CLAUDE_CODE,label:"Claude Code",enabled:!0},{value:_s.OPENCODE,label:"OpenCode",enabled:!0}],Lt={TEXT:"text",IMAGE:"image",IMPORTED_TEXT:"imported_text"},mi=[{value:"local",label:"跟随本机时区"}],gi={SKIP:"skip"},hi=[{value:gi.SKIP,label:"已有运行时跳过本次"}],no={DINGTALK:"dingtalk",FEISHU:"feishu",WEBHOOK:"webhook"},vi=[{value:no.DINGTALK,label:"钉钉 Webhook"},{value:no.FEISHU,label:"飞书 Webhook"},{value:no.WEBHOOK,label:"通用 Webhook"}],so={COMPLETED:"completed",SUCCESS:"success",ERROR:"error"},yi=[{value:so.COMPLETED,label:"本次运行结束后"},{value:so.SUCCESS,label:"本次运行成功后"},{value:so.ERROR,label:"本次运行失败后"}],Si={SUMMARY:"summary"},wi=[{value:Si.SUMMARY,label:"摘要消息"}],Go={ZH_CN:"zh-CN",EN_US:"en-US"},xi=[{value:Go.ZH_CN,label:"简体中文"},{value:Go.EN_US,label:"English"}];function Os(e){var n;const t=String(e||"").trim().toLowerCase();return((n=Do.find(o=>o.value===t))==null?void 0:n.value)||_s.CODEX}function gt(e){var t;return((t=Do.find(n=>n.value===Os(e)))==null?void 0:t.label)||"Codex"}function Ly(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 bi(e=[],t=10){const n=e.find(o=>{var s;return(o.type===Lt.TEXT||o.type===Lt.IMPORTED_TEXT)&&((s=o.content)==null?void 0:s.trim())});return n?n.content.replace(/\s+/g," ").trim().slice(0,t):""}const ki={class:"min-w-0 flex-1"},Ti={key:0,class:"flex items-center gap-2"},_i=["disabled"],Ws={__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=K(()=>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 u(p){!n.open||!n.closeOnEscape||n.closeDisabled||p.key==="Escape"&&o("close")}return Le(()=>n.open,p=>{if(n.lockBodyScroll&&document.body.classList.toggle("overflow-hidden",p),p&&n.closeOnEscape){window.addEventListener("keydown",u);return}window.removeEventListener("keydown",u)},{immediate:!0}),Mt(()=>{n.lockBodyScroll&&document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",u)}),(p,w)=>(m(),Ae(fs,{to:"body"},[de(Ar,{name:"dialog-shell"},{default:tt(()=>[e.open?(m(),b("div",{key:0,class:be(["theme-modal-backdrop dialog-shell-backdrop fixed inset-0 flex",s.value]),onClick:nt(l,["self"])},[i("section",{class:be(["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?(m(),b("div",{key:0,class:be(["theme-divider flex items-start justify-between gap-4 border-b",e.headerClass])},[i("div",ki,[nn(p.$slots,"header",{},()=>[nn(p.$slots,"title")])]),p.$slots["header-actions"]||e.showClose?(m(),b("div",Ti,[nn(p.$slots,"header-actions"),e.showClose?(m(),b("button",{key:0,type:"button",class:"theme-icon-button h-8 w-8 shrink-0",disabled:e.closeDisabled,onClick:r},[de(a($r),{class:"h-4 w-4"})],8,_i)):me("",!0)])):me("",!0)],2)):me("",!0),i("div",{class:be(e.bodyClass)},[nn(p.$slots,"default")],2)],2)],2)):me("",!0)]),_:3})]))}},Ci={class:"flex items-start gap-3"},Ei={class:"theme-heading text-base font-semibold"},Ai={key:0,class:"theme-muted-text mt-1 text-sm leading-6"},$i={class:"flex justify-end gap-2 px-5 py-4"},Ii=["disabled"],Pi=["disabled"],ys={__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}=Tt(),r=K(()=>n.title||s("common.confirm")),l=K(()=>n.confirmText||s("common.confirm")),u=K(()=>n.cancelText||s("common.cancel"));return(p,w)=>(m(),Ae(Ws,{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]=c=>o("cancel"))},{title:tt(()=>[i("div",Ci,[i("span",{class:be(["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"])},[de(a(Ba),{class:"h-4 w-4"})],2),i("div",null,[i("h2",Ei,x(r.value),1),e.description?(m(),b("p",Ai,x(e.description),1)):me("",!0)])])]),default:tt(()=>[i("div",$i,[i("button",{type:"button",class:"tool-button px-4 py-2 text-sm",disabled:e.loading,onClick:w[0]||(w[0]=c=>o("cancel"))},x(u.value),9,Ii),i("button",{type:"button",class:be(["tool-button px-4 py-2 text-sm",e.danger?"tool-button-danger":"tool-button-primary"]),disabled:e.loading,onClick:w[1]||(w[1]=c=>o("confirm"))},x(e.loading?a(s)("common.processing"):l.value),11,Pi)])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},Di={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"},Li={class:"settings-nav flex gap-2 overflow-x-auto sm:flex-col sm:overflow-visible"},Mi=["onClick"],Bi={class:"min-w-0"},Ri={class:"text-sm font-medium"},Ni={class:"theme-muted-text mt-1 hidden text-xs leading-5 sm:block"},Oi={__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)=>(m(),b("aside",Di,[i("nav",Li,[(m(!0),b(lt,null,pt(e.sections,l=>(m(),b("button",{key:l.id,type:"button",class:be(["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:u=>o(l.id)},[(m(),Ae(yn(l.icon),{class:"mt-0.5 h-4 w-4 shrink-0"})),i("div",Bi,[i("div",Ri,x(l.label),1),i("p",Ni,x(l.description),1)])],10,Mi))),128))])]))}},Fi=["aria-label","disabled","onKeydown"],Ui={class:"min-w-0 flex-1"},ji={class:"theme-muted-text text-sm"},Vi={class:"flex min-h-0 w-full flex-col"},zi={class:"min-h-0 flex-1 space-y-2 overflow-y-auto p-2"},Hi=["onClick"],qi={class:"theme-empty-state px-3 py-4 text-sm"},ln={__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}=Tt(),r=j(null),l=j(null),u=j(!1),p=j(!1),w=j({}),c=K(()=>{const M=String(n.modelValue??"");return n.options.find(Y=>String(n.getOptionValue(Y)??"")===M)||null}),S=K(()=>n.placeholder||s("common.select")),h=K(()=>n.emptyText||s("common.noOptions"));function g(M){return M&&typeof M=="object"&&Object.prototype.hasOwnProperty.call(M,"label")?String(M.label||""):String(n.getOptionValue(M)??"")}function f(){n.disabled||(u.value||o("refresh-intent"),u.value=!0)}function D(){u.value=!1}function Z(){if(u.value){D();return}f()}function v(M){o("update:modelValue",String(n.getOptionValue(M)??"").trim()),D()}function L(){if(!u.value||!r.value||typeof window>"u")return;const M=r.value.getBoundingClientRect(),Y=window.innerWidth,A=window.innerHeight,X=8,pe=8,ge=160,E=360,ee=Math.max(0,A-M.bottom-pe),ce=Math.max(0,M.top-pe);p.value=ee<260&&ce>ee;const te=p.value?ce-X:ee-X,ye=Math.max(Math.min(E,Math.max(te,0)),Math.min(ge,p.value?ce:ee)),_=Math.min(M.width,Y-pe*2),U=Math.min(Math.max(pe,M.left),Math.max(pe,Y-pe-_));w.value={left:`${U}px`,top:p.value?`${M.top-X}px`:`${M.bottom+X}px`,width:`${_}px`,maxHeight:`${Math.max(ye,120)}px`,transform:p.value?"translateY(-100%)":"none"}}function F(M){var Y;!u.value||!r.value||r.value.contains(M.target)||(Y=l.value)!=null&&Y.contains(M.target)||D()}function W(M){M.key==="Escape"&&D()}return Le(()=>n.disabled,M=>{M&&D()}),Le(u,async M=>{M&&(await dt(),L())}),cn(()=>{document.addEventListener("pointerdown",F),document.addEventListener("keydown",W),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0)}),Mt(()=>{document.removeEventListener("pointerdown",F),document.removeEventListener("keydown",W),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}),(M,Y)=>(m(),b("div",{ref_key:"rootRef",ref:r,class:"relative min-w-0"},[i("button",{type:"button",class:be(["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:Z,onKeydown:[Qt(nt(f,["prevent"]),["down"]),Qt(nt(Z,["prevent"]),["enter"]),Qt(nt(Z,["prevent"]),["space"])]},[i("div",Ui,[nn(M.$slots,"trigger",{selectedOption:c.value,open:u.value,loading:e.loading,disabled:e.disabled},()=>[i("div",ji,x(c.value?g(c.value):S.value),1)])]),i("div",{class:be(["flex shrink-0 items-center gap-2",e.disabled?"text-[var(--theme-textMuted)] opacity-80":"theme-muted-text"])},[e.loading?(m(),Ae(a(Gt),{key:0,class:"h-4 w-4 animate-spin"})):me("",!0),de(a(Ao),{class:be(["h-4 w-4 transition",u.value?"rotate-180":""])},null,8,["class"])],2)],42,Fi),(m(),Ae(fs,{to:"body"},[u.value?(m(),b("div",{key:0,ref_key:"panelRef",ref:l,class:"workbench-select-panel theme-popover fixed z-[90] flex overflow-hidden rounded-sm border",style:In(w.value)},[i("div",Vi,[nn(M.$slots,"header",{loading:e.loading,options:e.options}),i("div",zi,[e.options.length?(m(!0),b(lt,{key:0},pt(e.options,A=>nn(M.$slots,"option",{key:String(e.getOptionValue(A)??""),option:A,selected:String(e.getOptionValue(A)??"")===String(e.modelValue??""),select:()=>v(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:X=>v(A)},x(g(A)),9,Hi)])),128)):nn(M.$slots,"empty",{key:1},()=>[i("div",qi,x(h.value),1)])])])],4)):me("",!0)]))],512))}},Xo={},Nr=typeof import.meta<"u"&&Xo?Xo:{};function Ki(){if(typeof window>"u")return"http://localhost:3000";const e=new URL(window.location.origin),t=String(Nr.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 Lo=(Nr.VITE_API_BASE_URL||Ki()).replace(/\/$/,"");function Mo(e={},t="errors.requestFailed"){const n=String((e==null?void 0:e.messageKey)||"").trim();if(n){const o=Ye(n);if(o&&o!==n)return o}return(e==null?void 0:e.message)||Ye(t)}async function st(e,t={}){const n=typeof t.body<"u"&&!(t.body instanceof FormData),o=await fetch(`${Lo}${e}`,{headers:{...n?{"Content-Type":"application/json"}:{},...t.headers||{}},...t});if(!o.ok){const r=await o.json().catch(()=>({}));throw new Error(Mo(r))}return o.status===204?null:(o.headers.get("content-type")||"").includes("application/json")?o.json():o.text()}function Gs(){return Lo}function Cs(e){return e?e.startsWith("http")?e:`${Lo}${e}`:""}function My(){return st("/api/meta",{cache:"no-store"})}function Wi(){return st("/api/tasks")}function Gi(e=30){const t=new URLSearchParams,n=Math.max(1,Number(e)||30);return t.set("limit",String(n)),st(`/api/tasks/workspace-diff-summaries?${t.toString()}`,{cache:"no-store"})}function Xi(e){return st("/api/tasks",{method:"POST",body:JSON.stringify(e)})}function Yi(e=[]){return st("/api/tasks/reorder",{method:"POST",body:JSON.stringify({slugs:e})})}function Or(e){return st(`/api/tasks/${e}`)}function Fr(e,t){return st(`/api/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)})}function Ji(e){return st(`/api/tasks/${e}`,{method:"DELETE"})}const Ur=Gs();async function Qi(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Ur}/api/uploads`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(Mo(o,"errors.uploadFailed"))}return n.json()}async function Zi(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Ur}/api/imports/pdf`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(Mo(o,"errors.pdfImportFailed"))}return n.json()}const el=Gs();function tl(){return st("/api/codex/sessions")}function nl(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim();n&&t.set("engine",n);const o=t.toString();return st(`/api/codex/workspaces${o?`?${o}`:""}`)}function By(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 st(`/api/codex/session-candidates${r?`?${r}`:""}`,{cache:"no-store",signal:e.signal})}function Ry(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 st(`/api/codex/directories/tree${s?`?${s}`:""}`,{cache:"no-store",signal:e.signal})}function Ny(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 st(`/api/codex/directories/search${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function sl(e){return st("/api/codex/sessions",{method:"POST",body:JSON.stringify(e)})}function ol(e,t){return st(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function rl(e){return st(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function al(e){return st(`/api/codex/sessions/${encodeURIComponent(e)}/reset`,{method:"POST"})}function il(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 st(`/api/codex/sessions/${encodeURIComponent(e)}/files/tree${r?`?${r}`:""}`,{cache:"no-store",signal:t.signal})}function ll(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 u=o.toString();return st(`/api/codex/sessions/${encodeURIComponent(e)}/files/search${u?`?${u}`:""}`,{cache:"no-store",signal:n.signal})}function ul(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 st(`/api/codex/sessions/${encodeURIComponent(e)}/files/content${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function cl(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 u=o.toString();return st(`/api/codex/sessions/${encodeURIComponent(e)}/files/content-search${u?`?${u}`:""}`,{cache:"no-store",signal:n.signal})}function dl(e,t){return st(`/api/tasks/${encodeURIComponent(e)}/codex-session`,{method:"POST",body:JSON.stringify({sessionId:t})})}function fl(e,t={}){const n=new URLSearchParams,o=Number(t.limit||20),s=fi(t.events,t);Number.isFinite(o)&&o>0&&n.set("limit",String(o)),n.set("events",s);const r=n.toString();return st(`/api/tasks/${encodeURIComponent(e)}/codex-runs${r?`?${r}`:""}`,{cache:"no-store"})}function pl(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 st(`/api/codex/runs/${encodeURIComponent(e)}/events${r?`?${r}`:""}`,{cache:"no-store"})}function Oy(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,u=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"),u||n.set("includeStats","false"),p>0&&n.set("timeoutMs",String(p));const w=n.toString();return st(`/api/tasks/${encodeURIComponent(e)}/git-diff${w?`?${w}`:""}`,{cache:"no-store"})}function Fy(e,t={}){const n=new URLSearchParams,o=t.scope==="run"?"run":t.scope==="task"?"task":"workspace",s=String(t.runId||"").trim(),r=String(t.filePath||"").trim(),l=String(t.side||"").trim()==="before"?"before":"after";n.set("scope",o),n.set("side",l),s&&n.set("runId",s),r&&n.set("filePath",r);const u=n.toString();return`${el}/api/tasks/${encodeURIComponent(e)}/git-diff/blob${u?`?${u}`:""}`}function ml(e,t){return st(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"POST",body:JSON.stringify(t)})}function gl(e){return st(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"DELETE"})}function hl(e){return st(`/api/codex/runs/${encodeURIComponent(e)}/stop`,{method:"POST"})}const vl={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},yl={class:"theme-muted-text mt-1 text-xs"},Sl={class:"min-h-0 flex flex-1 flex-col overflow-hidden sm:flex-row"},wl={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},xl={key:0,class:"theme-muted-text flex items-center gap-2 py-4 text-sm"},bl={key:1,class:"space-y-4"},kl={key:0,class:"space-y-4"},Tl={class:"theme-heading text-base font-medium"},_l={class:"theme-muted-text mt-1 text-xs leading-5"},Cl={class:"settings-section-card px-4 py-4"},El={class:"block space-y-1.5"},Al={class:"theme-muted-text text-xs"},$l=["placeholder"],Il={key:1,class:"space-y-4"},Pl={class:"flex items-start justify-between gap-3"},Dl={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Ll={class:"theme-muted-text mt-1 text-xs leading-5"},Ml={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Bl={class:"settings-section-card px-4 py-4"},Rl={class:"grid gap-4 sm:grid-cols-2"},Nl={class:"space-y-1.5 sm:col-span-2"},Ol={class:"theme-muted-text text-xs"},Fl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Ul={class:"space-y-1.5"},jl={class:"theme-muted-text text-xs"},Vl=["disabled"],zl={key:0,class:"space-y-1.5"},Hl={class:"theme-muted-text text-xs"},ql={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Kl={class:"space-y-1.5"},Wl={class:"theme-muted-text text-xs"},Gl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Xl={class:"theme-muted-text text-xs"},Yl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Jl={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},Ql={key:2,class:"space-y-4"},Zl={class:"flex items-start justify-between gap-3"},eu={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},tu={class:"theme-muted-text mt-1 text-xs leading-5"},nu={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},su={class:"settings-section-card px-4 py-4"},ou={class:"grid gap-4 sm:grid-cols-2"},ru={class:"space-y-1.5"},au={class:"theme-muted-text text-xs"},iu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},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 sm:col-span-2"},fu={class:"theme-muted-text text-xs"},pu=["placeholder","disabled"],mu={class:"space-y-1.5"},gu={class:"theme-muted-text text-xs"},hu=["placeholder","disabled"],vu={class:"space-y-1.5"},yu={class:"theme-muted-text text-xs"},Su={class:"truncate text-sm text-[var(--theme-textPrimary)]"},wu={class:"space-y-1.5"},xu={class:"theme-muted-text text-xs"},bu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},ku={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},Tu={key:0,class:"theme-danger-text"},_u={key:3,class:"theme-danger-text text-sm"},Cu={class:"theme-divider flex flex-col gap-3 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-between"},Eu={class:"theme-muted-text theme-note-text"},Au={class:"flex items-center justify-end gap-2"},$u=["disabled"],Iu=["disabled"],Pu="0 9 * * 1-5",oo="weekdays",ts="09:00",Nn="1",Du={__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}=Tt(),l=j(!1),u=j(!1),p=j(""),w=j("basic"),c=ps({title:"",automationEnabled:!1,automationMode:oo,automationTime:ts,automationWeekday:Nn,automationTimezone:"local",automationConcurrencyPolicy:"skip",automationLastTriggeredAt:"",automationNextTriggerAt:"",notificationEnabled:!1,notificationChannelType:"dingtalk",notificationWebhookUrl:"",notificationSecret:"",notificationTriggerOn:"completed",notificationLocale:"zh-CN",notificationMessageMode:"summary",notificationLastStatus:"",notificationLastError:"",notificationLastSentAt:""}),S=K(()=>String(n.taskTitle||"").trim()||r("workbench.untitledTask")),h=K(()=>[{id:"basic",label:r("taskDialog.sections.basic.label"),description:r("taskDialog.sections.basic.description"),icon:is},{id:"automation",label:r("taskDialog.sections.automation.label"),description:r("taskDialog.sections.automation.description"),icon:Bs},{id:"notification",label:r("taskDialog.sections.notification.label"),description:r("taskDialog.sections.notification.description"),icon:Ho}]),g=K(()=>[{value:"daily",label:r("taskDialog.sections.automation.modeDaily")},{value:"weekdays",label:r("taskDialog.sections.automation.modeWeekdays")},{value:"weekly",label:r("taskDialog.sections.automation.modeWeekly")}]),f=K(()=>[{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")}]),D=K(()=>mi.map(_=>({..._,label:_.value==="local"?r("taskDialog.sections.automation.timezoneLocal"):_.label}))),Z=K(()=>hi.map(_=>({..._,label:_.value==="skip"?r("taskDialog.sections.automation.concurrencySkip"):_.label}))),v=K(()=>vi.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=K(()=>yi.map(_=>({..._,label:_.value==="completed"?r("taskDialog.sections.notification.triggerCompleted"):_.value==="success"?r("taskDialog.sections.notification.triggerSuccess"):_.value==="error"?r("taskDialog.sections.notification.triggerError"):_.label}))),F=K(()=>wi.map(_=>({..._,label:_.value==="summary"?r("taskDialog.sections.notification.messageSummary"):_.label}))),W=K(()=>xi.map(_=>({..._,label:_.value==="zh-CN"?r("taskDialog.sections.notification.localeZhCn"):_.value==="en-US"?r("taskDialog.sections.notification.localeEnUs"):_.label}))),M=K(()=>c.notificationEnabled?c.notificationLastStatus==="success"?r("taskDialog.sections.notification.statusSuccess"):c.notificationLastStatus==="error"?r("taskDialog.sections.notification.statusError"):r("taskDialog.sections.notification.statusPending"):r("taskDialog.sections.notification.statusDisabled"));function Y(){c.title="",c.automationEnabled=!1,c.automationMode=oo,c.automationTime=ts,c.automationWeekday=Nn,c.automationTimezone="local",c.automationConcurrencyPolicy="skip",c.automationLastTriggeredAt="",c.automationNextTriggerAt="",c.notificationEnabled=!1,c.notificationChannelType="dingtalk",c.notificationWebhookUrl="",c.notificationSecret="",c.notificationTriggerOn="completed",c.notificationLocale=String(s.value||"zh-CN"),c.notificationMessageMode="summary",c.notificationLastStatus="",c.notificationLastError="",c.notificationLastSentAt=""}function A(_=0){return String(_).padStart(2,"0")}function X(_=""){const U=String(_||"").trim().replace(/\s+/g," ");let $=U.match(/^(\d{1,2}) (\d{1,2}) \* \* 1-5$/);return $?{mode:"weekdays",time:`${A($[2])}:${A($[1])}`,weekday:Nn}:($=U.match(/^(\d{1,2}) (\d{1,2}) \* \* \*$/),$?{mode:"daily",time:`${A($[2])}:${A($[1])}`,weekday:Nn}:($=U.match(/^(\d{1,2}) (\d{1,2}) \* \* ([0-6])$/),$?{mode:"weekly",time:`${A($[2])}:${A($[1])}`,weekday:String($[3])}:{mode:oo,time:ts,weekday:Nn}))}function pe(_=""){const $=String(_||"").trim().match(/^(\d{1,2}):(\d{2})$/);if(!$)return ts;const Me=Number($[1]),De=Number($[2]);return!Number.isInteger(Me)||!Number.isInteger(De)||Me<0||Me>23||De<0||De>59?ts:`${A(Me)}:${A(De)}`}function ge(){var Be;const _=pe(c.automationTime),[U,$]=_.split(":"),Me=Number(U),De=Number($);if(c.automationMode==="daily")return`${De} ${Me} * * *`;if(c.automationMode==="weekly"){const He=((Be=f.value.find(We=>We.value===String(c.automationWeekday||"")))==null?void 0:Be.value)||Nn;return`${De} ${Me} * * ${He}`}return`${De} ${Me} * * 1-5`}function E(_={}){var $,Me,De,Be,He,We,Ge,Te,z,ne,he,$e,oe,Ee,_e,Re;c.title=String(_.title||""),c.automationEnabled=!!(($=_.automation)!=null&&$.enabled);const U=X(((Me=_.automation)==null?void 0:Me.cron)||Pu);c.automationMode=U.mode,c.automationTime=U.time,c.automationWeekday=U.weekday,c.automationTimezone=String(((De=_.automation)==null?void 0:De.timezone)||"local"),c.automationConcurrencyPolicy=String(((Be=_.automation)==null?void 0:Be.concurrencyPolicy)||"skip"),c.automationLastTriggeredAt=String(((He=_.automation)==null?void 0:He.lastTriggeredAt)||""),c.automationNextTriggerAt=String(((We=_.automation)==null?void 0:We.nextTriggerAt)||""),c.notificationEnabled=!!((Ge=_.notification)!=null&&Ge.enabled),c.notificationChannelType=String(((Te=_.notification)==null?void 0:Te.channelType)||"dingtalk"),c.notificationWebhookUrl=String(((z=_.notification)==null?void 0:z.webhookUrl)||""),c.notificationSecret=String(((ne=_.notification)==null?void 0:ne.secret)||""),c.notificationTriggerOn=String(((he=_.notification)==null?void 0:he.triggerOn)||"completed"),c.notificationLocale=String((($e=_.notification)==null?void 0:$e.locale)||s.value||"zh-CN"),c.notificationMessageMode=String(((oe=_.notification)==null?void 0:oe.messageMode)||"summary"),c.notificationLastStatus=String(((Ee=_.notification)==null?void 0:Ee.lastStatus)||""),c.notificationLastError=String(((_e=_.notification)==null?void 0:_e.lastError)||""),c.notificationLastSentAt=String(((Re=_.notification)==null?void 0:Re.lastSentAt)||"")}async function ee(){const _=String(n.taskSlug||"").trim();if(!_){Y();return}l.value=!0,p.value="";try{const U=await Or(_);E(U)}catch(U){p.value=(U==null?void 0:U.message)||r("taskDialog.loadFailed")}finally{l.value=!1}}function ce(){return{title:c.title,automation:{enabled:c.automationEnabled,cron:ge(),timezone:c.automationTimezone,concurrencyPolicy:c.automationConcurrencyPolicy},notification:{enabled:c.notificationEnabled,channelType:c.notificationChannelType,webhookUrl:c.notificationWebhookUrl,secret:c.notificationSecret,triggerOn:c.notificationTriggerOn,locale:c.notificationLocale,messageMode:c.notificationMessageMode}}}async function te(){const _=String(n.taskSlug||"").trim();if(!(!_||l.value||u.value)){u.value=!0,p.value="";try{const U=await Fr(_,ce());E(U),o("saved",U),o("close")}catch(U){p.value=(U==null?void 0:U.message)||r("taskDialog.saveFailed")}finally{u.value=!1}}}function ye(_=""){if(!_)return r("common.notAvailable");const U=new Date(_);return Number.isNaN(U.getTime())?r("common.notAvailable"):_r(U.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return Le(()=>n.open,_=>{if(_){w.value="basic",ee();return}},{immediate:!0}),Le(()=>n.taskSlug,()=>{n.open&&ee()}),(_,U)=>(m(),Ae(Ws,{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:U[16]||(U[16]=$=>o("close"))},{title:tt(()=>[i("div",null,[i("div",vl,[de(a(is),{class:"h-4 w-4"}),i("span",null,x(a(r)("taskDialog.title")),1)]),i("p",yl,x(a(r)("taskDialog.currentTask",{title:S.value})),1)])]),default:tt(()=>[i("div",Sl,[de(Oi,{modelValue:w.value,"onUpdate:modelValue":U[0]||(U[0]=$=>w.value=$),sections:h.value},null,8,["modelValue","sections"]),i("div",wl,[l.value?(m(),b("div",xl,[de(a(Gt),{class:"h-4 w-4 animate-spin"}),i("span",null,x(a(r)("taskDialog.loading")),1)])):(m(),b("div",bl,[w.value==="basic"?(m(),b("section",kl,[i("div",null,[i("div",Tl,x(a(r)("taskDialog.sections.basic.title")),1),i("p",_l,x(a(r)("taskDialog.sections.basic.intro")),1)]),i("section",Cl,[i("label",El,[i("span",Al,x(a(r)("taskDialog.sections.basic.taskTitle")),1),Jt(i("input",{"onUpdate:modelValue":U[1]||(U[1]=$=>c.title=$),type:"text",maxlength:"140",class:"tool-input",placeholder:a(r)("taskDialog.sections.basic.taskTitlePlaceholder")},null,8,$l),[[ss,c.title]])])])])):w.value==="automation"?(m(),b("section",Il,[i("div",Pl,[i("div",null,[i("div",Dl,[de(a(Bs),{class:"h-4 w-4"}),i("span",null,x(a(r)("taskDialog.sections.automation.title")),1)]),i("p",Ll,x(a(r)("taskDialog.sections.automation.intro")),1)]),i("label",Ml,[Jt(i("input",{"onUpdate:modelValue":U[2]||(U[2]=$=>c.automationEnabled=$),type:"checkbox",class:"h-4 w-4"},null,512),[[zo,c.automationEnabled]]),i("span",null,x(a(r)("taskDialog.enabled")),1)])]),i("section",Bl,[i("div",Rl,[i("label",Nl,[i("span",Ol,x(a(r)("taskDialog.sections.automation.mode")),1),de(ln,{modelValue:c.automationMode,"onUpdate:modelValue":U[3]||(U[3]=$=>c.automationMode=$),options:g.value,disabled:!c.automationEnabled,"get-option-value":$=>$.value},{trigger:tt(({selectedOption:$})=>[i("div",Fl,x(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Ul,[i("span",jl,x(a(r)("taskDialog.sections.automation.time")),1),Jt(i("input",{"onUpdate:modelValue":U[4]||(U[4]=$=>c.automationTime=$),type:"time",class:"tool-input",disabled:!c.automationEnabled},null,8,Vl),[[ss,c.automationTime]])]),c.automationMode==="weekly"?(m(),b("label",zl,[i("span",Hl,x(a(r)("taskDialog.sections.automation.weekday")),1),de(ln,{modelValue:c.automationWeekday,"onUpdate:modelValue":U[5]||(U[5]=$=>c.automationWeekday=$),options:f.value,disabled:!c.automationEnabled,"get-option-value":$=>$.value},{trigger:tt(({selectedOption:$})=>[i("div",ql,x(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])):me("",!0),i("label",Kl,[i("span",Wl,x(a(r)("taskDialog.sections.automation.timezone")),1),de(ln,{modelValue:c.automationTimezone,"onUpdate:modelValue":U[6]||(U[6]=$=>c.automationTimezone=$),options:D.value,disabled:!c.automationEnabled,"get-option-value":$=>$.value},{trigger:tt(({selectedOption:$})=>[i("div",Gl,x(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",{class:be(["space-y-1.5",c.automationMode==="weekly"?"":"sm:col-span-2"])},[i("span",Xl,x(a(r)("taskDialog.sections.automation.concurrencyPolicy")),1),de(ln,{modelValue:c.automationConcurrencyPolicy,"onUpdate:modelValue":U[7]||(U[7]=$=>c.automationConcurrencyPolicy=$),options:Z.value,disabled:!c.automationEnabled,"get-option-value":$=>$.value},{trigger:tt(({selectedOption:$})=>[i("div",Yl,x(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])],2)]),i("div",Jl,[i("p",null,x(a(r)("taskDialog.sections.automation.lastTriggered",{value:ye(c.automationLastTriggeredAt)})),1),i("p",null,x(a(r)("taskDialog.sections.automation.nextTriggered",{value:ye(c.automationNextTriggerAt)})),1)])])])):(m(),b("section",Ql,[i("div",Zl,[i("div",null,[i("div",eu,[de(a(Ho),{class:"h-4 w-4"}),i("span",null,x(a(r)("taskDialog.sections.notification.title")),1)]),i("p",tu,x(a(r)("taskDialog.sections.notification.intro")),1)]),i("label",nu,[Jt(i("input",{"onUpdate:modelValue":U[8]||(U[8]=$=>c.notificationEnabled=$),type:"checkbox",class:"h-4 w-4"},null,512),[[zo,c.notificationEnabled]]),i("span",null,x(a(r)("taskDialog.enabled")),1)])]),i("section",su,[i("div",ou,[i("label",ru,[i("span",au,x(a(r)("taskDialog.sections.notification.channelType")),1),de(ln,{modelValue:c.notificationChannelType,"onUpdate:modelValue":U[9]||(U[9]=$=>c.notificationChannelType=$),options:v.value,disabled:!c.notificationEnabled,"get-option-value":$=>$.value},{trigger:tt(({selectedOption:$})=>[i("div",iu,x(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",lu,[i("span",uu,x(a(r)("taskDialog.sections.notification.triggerOn")),1),de(ln,{modelValue:c.notificationTriggerOn,"onUpdate:modelValue":U[10]||(U[10]=$=>c.notificationTriggerOn=$),options:L.value,disabled:!c.notificationEnabled,"get-option-value":$=>$.value},{trigger:tt(({selectedOption:$})=>[i("div",cu,x(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",du,[i("span",fu,x(a(r)("taskDialog.sections.notification.webhookUrl")),1),Jt(i("input",{"onUpdate:modelValue":U[11]||(U[11]=$=>c.notificationWebhookUrl=$),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.webhookUrlPlaceholder"),disabled:!c.notificationEnabled},null,8,pu),[[ss,c.notificationWebhookUrl]])]),i("label",mu,[i("span",gu,x(a(r)("taskDialog.sections.notification.secret")),1),Jt(i("input",{"onUpdate:modelValue":U[12]||(U[12]=$=>c.notificationSecret=$),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.secretPlaceholder"),disabled:!c.notificationEnabled},null,8,hu),[[ss,c.notificationSecret]])]),i("label",vu,[i("span",yu,x(a(r)("taskDialog.sections.notification.locale")),1),de(ln,{modelValue:c.notificationLocale,"onUpdate:modelValue":U[13]||(U[13]=$=>c.notificationLocale=$),options:W.value,disabled:!c.notificationEnabled,"get-option-value":$=>$.value},{trigger:tt(({selectedOption:$})=>[i("div",Su,x(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",wu,[i("span",xu,x(a(r)("taskDialog.sections.notification.messageMode")),1),de(ln,{modelValue:c.notificationMessageMode,"onUpdate:modelValue":U[14]||(U[14]=$=>c.notificationMessageMode=$),options:F.value,disabled:!c.notificationEnabled,"get-option-value":$=>$.value},{trigger:tt(({selectedOption:$})=>[i("div",bu,x(($==null?void 0:$.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])]),i("div",ku,[i("p",null,x(a(r)("taskDialog.sections.notification.status",{value:M.value})),1),i("p",null,x(a(r)("taskDialog.sections.notification.lastSent",{value:ye(c.notificationLastSentAt)})),1),c.notificationLastError?(m(),b("p",Tu,x(a(r)("taskDialog.sections.notification.lastError",{value:c.notificationLastError})),1)):me("",!0)])])])),p.value?(m(),b("p",_u,x(p.value),1)):me("",!0)]))])]),i("div",Cu,[i("p",Eu,x(a(r)("taskDialog.footerHint")),1),i("div",Au,[i("button",{type:"button",class:"tool-button px-3 py-2 text-sm",disabled:u.value,onClick:U[15]||(U[15]=$=>o("close"))},x(a(r)("common.cancel")),9,$u),i("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-sm",disabled:u.value||l.value,onClick:te},[u.value?(m(),Ae(a(Gt),{key:0,class:"h-4 w-4 animate-spin"})):(m(),Ae(a(Ra),{key:1,class:"h-4 w-4"})),i("span",null,x(u.value?a(r)("common.saving"):a(r)("taskDialog.saveTaskConfig")),1)],8,Iu)])])]),_:1},8,["open"]))}};function Lu(e=[]){return(Array.isArray(e)&&e.length?e:Do).filter(n=>n&&typeof n=="object").map(n=>{const o=Os(n.value);return{...n,value:o,label:String(n.label||gt(o)).trim()||gt(o),enabled:n.enabled!==!1,available:n.available!==!1}})}function Mu(e=[]){return Lu(e).filter(t=>t.enabled&&t.available)}async function Uy(){const e=await st("/api/meta",{cache:"no-store"});return Mu(e==null?void 0:e.agentEngineOptions)}function jr(e={},t={}){const{defaultLabel:n="默认",prefix:o=""}=t,s=gt(e==null?void 0:e.engine),r=`${String(o||"")}${s}`;return e!=null&&e.isDefault?`${r} · ${n}`:r}const Bu={key:0,class:"flex items-center gap-2 text-sm"},Ru={class:"min-w-0 flex-1 truncate"},Nu={class:"theme-muted-text ml-2 hidden font-mono text-[11px] sm:inline"},Ou={class:"theme-status-neutral hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex"},Fu={key:1,class:"theme-muted-text text-sm"},Uu={class:"theme-divider theme-muted-text flex items-center justify-between gap-3 border-b border-dashed px-3 py-2 text-[11px]"},ju=["onClick"],Vu={class:"flex items-center gap-3"},zu={class:"min-w-0 flex-1"},Hu={class:"flex items-center gap-2 text-sm sm:hidden"},qu={class:"min-w-0 flex-1 truncate font-medium text-[var(--theme-textPrimary)]"},Ku={class:"hidden items-center gap-2 text-sm sm:flex"},Wu={class:"min-w-0 flex-1 truncate"},Gu={class:"font-medium text-[var(--theme-textPrimary)]"},Xu={class:"theme-muted-text ml-2 font-mono text-[11px]"},Yu={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Ju={__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}=Tt();function s(c){return(c==null?void 0:c.title)||o("projectManager.untitledProject")}function r(c){return(c==null?void 0:c.cwd)||o("projectManager.notSet")}function l(c){return c!=null&&c.running?o("projectManager.running"):o("projectManager.idle")}function u(c){return c!=null&&c.running?"theme-status-warning":"theme-status-success"}function p(c){var h;const S=Math.max(0,Number((h=c==null?void 0:c.agentBindings)==null?void 0:h.length)||0);return S>1?o("projectManager.agentCount",{count:S}):gt(c==null?void 0:c.engine)}function w(c){return c?"theme-filter-active":"theme-filter-idle"}return(c,S)=>(m(),Ae(ln,{"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":h=>(h==null?void 0:h.id)||"","onUpdate:modelValue":S[0]||(S[0]=h=>n("update:modelValue",h)),onRefreshIntent:S[1]||(S[1]=h=>n("refresh-intent"))},{trigger:tt(({selectedOption:h,disabled:g})=>[h?(m(),b("div",Bu,[i("span",Ru,[i("span",{class:be(["font-medium",g?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},x(s(h)),3),i("span",Nu,x(r(h)),1)]),i("span",Ou,x(p(h)),1),i("span",{class:be(["hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex",u(h)])},x(l(h)),3)])):(m(),b("div",Fu,x(e.loading?a(o)("projectManager.syncingProjects"):a(o)("projectManager.selectProject")),1))]),header:tt(()=>[i("div",Uu,[i("span",null,x(e.loading?a(o)("projectManager.syncingLatestProjects"):a(o)("projectManager.projectCount",{count:e.sessions.length})),1),e.loading?(m(),Ae(a(Gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):me("",!0)])]),option:tt(({option:h,selected:g,select:f})=>[i("button",{type:"button",class:be(["w-full rounded-sm border border-dashed p-3 text-left transition",w(g)]),onClick:f},[i("div",Vu,[i("div",zu,[i("div",Hu,[i("span",qu,x(s(h)),1)]),i("div",Ku,[i("span",Wu,[i("span",Gu,x(s(h)),1),i("span",Xu,x(r(h)),1)]),i("span",Yu,x(p(h)),1),i("span",{class:be(["inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",u(h)])},x(l(h)),3)])]),g?(m(),Ae(a(Ir),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):me("",!0)])],10,ju)]),_:1},8,["model-value","options","loading","disabled","placeholder","empty-text","get-option-value"]))}},Qu=["disabled"],Zu=["disabled"],ec=["src","alt"],Vr={__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}=Tt(),r=j(1),l=K(()=>n.images.map(v=>String(v||"").trim()).filter(Boolean)),u=K(()=>l.value.findIndex(v=>v===n.modelValue)),p=K(()=>u.value>=0?l.value[u.value]:"");function w(){o("update:modelValue",""),r.value=1}function c(v){o("update:modelValue",String(v||"").trim()),r.value=1}function S(){u.value<=0||c(l.value[u.value-1])}function h(){u.value<0||u.value>=l.value.length-1||c(l.value[u.value+1])}function g(v){const L=Math.min(3,Math.max(.5,r.value+v));r.value=Math.round(L*100)/100}function f(){r.value=1}function D(v){p.value&&(v.preventDefault(),g(v.deltaY<0?.1:-.1))}function Z(v){var L,F;if(p.value){if((L=v.stopPropagation)==null||L.call(v),(F=v.stopImmediatePropagation)==null||F.call(v),v.key==="Escape"){v.preventDefault(),w();return}if(v.key==="ArrowLeft"){v.preventDefault(),S();return}if(v.key==="ArrowRight"){v.preventDefault(),h();return}if(v.key==="+"||v.key==="="){v.preventDefault(),g(.1);return}if(v.key==="-"){v.preventDefault(),g(-.1);return}v.key==="0"&&(v.preventDefault(),f())}}return Le(()=>n.modelValue,v=>{v||(r.value=1)}),Le(l,v=>{if(n.modelValue){if(!v.length){w();return}if(!v.includes(n.modelValue)){const L=Math.min(u.value,v.length-1);c(v[L]||v[0])}}},{immediate:!0}),cn(()=>{window.addEventListener("keydown",Z,{capture:!0})}),Mt(()=>{window.removeEventListener("keydown",Z,{capture:!0})}),(v,L)=>(m(),Ae(fs,{to:"body"},[p.value?(m(),b("div",{key:0,class:"theme-modal-backdrop image-preview-overlay fixed inset-0 z-[120] flex items-center justify-center p-6",onClick:w,onWheel:D},[i("div",{class:"absolute left-4 top-4 flex items-center gap-2",onClick:L[2]||(L[2]=nt(()=>{},["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]=F=>g(-.1))},x(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:f},x(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]=F=>g(.1))},x(a(s)("imagePreview.zoomIn")),1)]),i("div",{class:"absolute right-4 top-4 flex items-center gap-2",onClick:L[3]||(L[3]=nt(()=>{},["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:u.value<=0,onClick:S},x(a(s)("imagePreview.previous")),9,Qu),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:u.value<0||u.value>=l.value.length-1,onClick:h},x(a(s)("imagePreview.next")),9,Zu),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:w},x(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:In({transform:`scale(${r.value})`}),onClick:L[4]||(L[4]=nt(()=>{},["stop"]))},null,12,ec)],32)):me("",!0)]))}};let ro=null;const jy={maxLines:2e3,maxChars:2e5},ao={maxLines:2e3,maxChars:2e5},tc={"github-dark-default":()=>Ke(()=>import("./vendor-shiki-theme-github-dark-default-DBX58552.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),"github-light":()=>Ke(()=>import("./vendor-shiki-theme-github-light-RLAvZv0q.js"),__vite__mapDeps([4,1,2,3])).then(e=>e.default)},nc={bash:()=>Ke(()=>import("./vendor-shiki-lang-bash-zsQu0xn-.js"),__vite__mapDeps([5,1,2,3])).then(e=>e.default),c:()=>Ke(()=>import("./vendor-shiki-lang-c-BDF8vgks.js"),__vite__mapDeps([6,1,2,3])).then(e=>e.default),cpp:()=>Ke(()=>import("./vendor-shiki-lang-cpp-DyDAaXl6.js"),__vite__mapDeps([7,1,2,3])).then(e=>e.default),csharp:()=>Ke(()=>import("./vendor-shiki-lang-csharp-BWfTXJXw.js"),__vite__mapDeps([8,1,2,3])).then(e=>e.default),css:()=>Ke(()=>import("./vendor-shiki-lang-css-DbAm1fUO.js"),__vite__mapDeps([9,1,2,3])).then(e=>e.default),diff:()=>Ke(()=>import("./vendor-shiki-lang-diff-DmGC1G26.js"),__vite__mapDeps([10,1,2,3])).then(e=>e.default),dockerfile:()=>Ke(()=>import("./vendor-shiki-lang-dockerfile-3x-8396r.js"),__vite__mapDeps([11,1,2,3])).then(e=>e.default),dotenv:()=>Ke(()=>import("./vendor-shiki-lang-dotenv--IVOlX2Q.js"),__vite__mapDeps([12,1,2,3])).then(e=>e.default),fish:()=>Ke(()=>import("./vendor-shiki-lang-fish-Bpv3hhJP.js"),__vite__mapDeps([13,1,2,3])).then(e=>e.default),go:()=>Ke(()=>import("./vendor-shiki-lang-go-CIGC59jP.js"),__vite__mapDeps([14,1,2,3])).then(e=>e.default),html:()=>Ke(()=>import("./vendor-shiki-lang-html-Bt_TLLZN.js"),__vite__mapDeps([15,1,2,3])).then(e=>e.default),ini:()=>Ke(()=>import("./vendor-shiki-lang-ini-BIllfys4.js"),__vite__mapDeps([16,1,2,3])).then(e=>e.default),java:()=>Ke(()=>import("./vendor-shiki-lang-java-CXxu9crF.js"),__vite__mapDeps([17,1,2,3])).then(e=>e.default),javascript:()=>Ke(()=>import("./vendor-shiki-lang-javascript-Cha7GNZm.js"),__vite__mapDeps([18,1,2,3])).then(e=>e.default),json:()=>Ke(()=>import("./vendor-shiki-lang-json-CCZCjDUh.js"),__vite__mapDeps([19,1,2,3])).then(e=>e.default),less:()=>Ke(()=>import("./vendor-shiki-lang-less-DAToytC5.js"),__vite__mapDeps([20,1,2,3])).then(e=>e.default),markdown:()=>Ke(()=>import("./vendor-shiki-lang-markdown-C6lwMXFp.js"),__vite__mapDeps([21,1,2,3])).then(e=>e.default),python:()=>Ke(()=>import("./vendor-shiki-lang-python-Bi9rmtY7.js"),__vite__mapDeps([22,1,2,3])).then(e=>e.default),powershell:()=>Ke(()=>import("./vendor-shiki-lang-powershell-lrpuM0ez.js"),__vite__mapDeps([23,1,2,3])).then(e=>e.default),rust:()=>Ke(()=>import("./vendor-shiki-lang-rust-GTGDbY6A.js"),__vite__mapDeps([24,1,2,3])).then(e=>e.default),sass:()=>Ke(()=>import("./vendor-shiki-lang-sass-DFtHupN8.js"),__vite__mapDeps([25,1,2,3])).then(e=>e.default),scss:()=>Ke(()=>import("./vendor-shiki-lang-scss-BrfBNyyi.js"),__vite__mapDeps([26,1,2,3])).then(e=>e.default),sql:()=>Ke(()=>import("./vendor-shiki-lang-sql-H6--iFN-.js"),__vite__mapDeps([27,1,2,3])).then(e=>e.default),toml:()=>Ke(()=>import("./vendor-shiki-lang-toml-aTteTWYL.js"),__vite__mapDeps([28,1,2,3])).then(e=>e.default),tsx:()=>Ke(()=>import("./vendor-shiki-lang-tsx-DoKZm6AV.js"),__vite__mapDeps([29,1,2,3])).then(e=>e.default),typescript:()=>Ke(()=>import("./vendor-shiki-lang-typescript-B5awnqri.js"),__vite__mapDeps([30,1,2,3])).then(e=>e.default),vue:()=>Ke(()=>import("./vendor-shiki-lang-vue-CnrgQ7Z5.js"),__vite__mapDeps([31,1,2,3])).then(e=>e.default),xml:()=>Ke(()=>import("./vendor-shiki-lang-xml-Bv-TNPJt.js"),__vite__mapDeps([32,1,2,3])).then(e=>e.default),yaml:()=>Ke(()=>import("./vendor-shiki-lang-yaml-DpxUxQ6M.js"),__vite__mapDeps([33,1,2,3])).then(e=>e.default)};function zr(e=0){return Number(e)>9999?"3.4rem":"2.6rem"}function Bo(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 Ro(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 sc(e=[],t={}){const n=Bo(e);return Ro(n,{maxHighlightLines:t.maxLines,maxHighlightChars:t.maxChars})}function oc(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
@@ -36,7 +36,7 @@ ${o}`:o}function ls(e=[]){const t=e.map(n=>({label:String((n==null?void 0:n.labe
36
36
  ${B("原始错误","Raw error")}: ${o.rawMessage}`:n}function To(e,t=0){if(!e||t>4)return"";if(typeof e=="string")return Wn(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=To(e[o],t+1);if(s)return s}for(const o of Object.values(e)){const s=To(o,t+1);if(s)return s}return""}function ds(e={}){return To(e)}function ap(e={},t="Codex",n="codex"){var r,l,u,p;const o=String(e.type||"").trim(),s=e.item||{};if(!o)return{title:B(`收到 ${t} 事件`,`Received ${t} event`),detail:""};if(o===kt.THREAD_STARTED){const w=e.thread_id?B(`线程 ID: ${e.thread_id}`,`Thread ID: ${e.thread_id}`):"";return{title:B(`${t} 会话已创建`,`${t} session created`),detail:w,detailBlocks:w?[ls([{label:"ID",value:e.thread_id}])]:[]}}if(o===kt.TURN_STARTED)return{title:B(`${t} 开始执行`,`${t} started`),detail:""};if(o===kt.TURN_COMPLETED){const w=e.usage?[B(`输入 ${Nt(e.usage.input_tokens)}`,`Input ${Nt(e.usage.input_tokens)}`),e.usage.cached_input_tokens?B(`缓存 ${Nt(e.usage.cached_input_tokens)}`,`Cached ${Nt(e.usage.cached_input_tokens)}`):"",B(`输出 ${Nt(e.usage.output_tokens)}`,`Output ${Nt(e.usage.output_tokens)}`)].filter(Boolean).join(" / "):"";return{title:B(`${t} 执行完成`,`${t} completed`),detail:w,detailBlocks:e.usage?[ls([{label:B("输入","Input"),value:Nt(e.usage.input_tokens)},e.usage.cached_input_tokens?{label:B("缓存","Cached"),value:Nt(e.usage.cached_input_tokens)}:null,{label:B("输出","Output"),value:Nt(e.usage.output_tokens)}])]:[]}}if(o==="claude.system"&&!String(e.detail||"").trim())return{title:"",detail:""};if(o===kt.ERROR||o===kt.TURN_FAILED){const w=ds(e)||B(`${t} 执行失败`,`${t} failed`),c=o===kt.ERROR?jo(w):null;if(c)return{kind:"info",title:B(`网络异常,正在重试 (${c.attempt}/${c.total})`,`Network error, retrying (${c.attempt}/${c.total})`),detail:un(c.reason||c.rawMessage,n),detailBlocks:$n(un(c.reason||c.rawMessage,n),{preferMarkdown:!0})};const S=Kn(w,n);return{kind:"error",title:(S==null?void 0:S.title)||(o===kt.TURN_FAILED?B("本轮运行失败","This run failed"):B(`${t} 返回错误`,`${t} returned an error`)),detail:un(w,n),detailBlocks:$n(un(w,n),{preferMarkdown:!0})}}if(o===kt.ITEM_STARTED)return s.type===ct.REASONING?{kind:"reasoning",title:B("思考过程","Thinking"),detail:s.text||"",detailBlocks:$n(s.text||"",{preferMarkdown:!0}),groupType:"reasoning",phase:"updated"}:s.type===ct.WEB_SEARCH?{...ar(s,"started"),detailBlocks:sr(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===ct.COLLAB_TOOL_CALL?{...ir(s,"started"),detailBlocks:or(s)}:s.type===ct.FILE_CHANGE?{...lr(s,"started"),detailBlocks:rr(s)}:s.type===ct.COMMAND_EXECUTION?Fn(s).groupType==="todo"?{kind:"todo",title:B("更新待办列表","Update todo list"),detail:_n(us(s)),detailBlocks:ws(s,!1,n),groupType:"todo",phase:"started"}:{kind:"command",title:B("开始执行命令","Command started"),detail:s.command||"",detailBlocks:ws(s,!1,n),...Fn(s),phase:"started"}:s.type===ct.TODO_LIST?{kind:"todo",title:B("更新待办列表","Update todo list"),detail:_n(s.items),detailBlocks:co(s),groupType:"todo",phase:"started"}:{title:B(`开始处理 ${s.type||"未知项目"}`,`Started handling ${s.type||"unknown item"}`),detail:""};if(o===kt.ITEM_UPDATED&&s.type===ct.TODO_LIST)return{kind:"todo",title:B("更新待办列表","Update todo list"),detail:_n(s.items),detailBlocks:co(s),groupType:"todo",phase:"updated"};if(o===kt.ITEM_COMPLETED){if(s.type===ct.AGENT_MESSAGE&&s.text)return{kind:"result",title:B(`${t} 已返回结果`,`${t} returned a result`),detail:""};if(s.type===ct.WEB_SEARCH)return{...ar(s,"completed"),detailBlocks:sr(s),groupType:"web",groupTarget:String(s.query||((u=s.action)==null?void 0:u.query)||((p=s.action)==null?void 0:p.url)||"").trim(),phase:"completed"};if(s.type===ct.COLLAB_TOOL_CALL)return{...ir(s,"completed"),detailBlocks:or(s)};if(s.type===ct.FILE_CHANGE)return{...lr(s,"completed"),detailBlocks:rr(s)};if(s.type===ct.COMMAND_EXECUTION){if(Fn(s).groupType==="todo"){const S=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:S?"todo":"error",title:S?B("更新待办列表","Update todo list"):B("更新待办列表失败","Todo list update failed"),detail:_n(us(s)),detailBlocks:ws(s,!0,n),groupType:"todo",phase:"completed"}}const c=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:c?"command":"error",title:c?B("命令执行完成","Command completed"):B(`命令执行失败(exit ${s.exit_code??"?"})`,`Command failed (exit ${s.exit_code??"?"})`),detail:[s.command,ua(s.aggregated_output)].filter(Boolean).join(`
37
37
 
38
38
  `),detailBlocks:ws(s,!0,n),...Fn(s),phase:"completed"}}return s.type===ct.TODO_LIST?{kind:"todo",title:B("更新待办列表","Update todo list"),detail:_n(s.items),detailBlocks:co(s),groupType:"todo",phase:"completed"}:{title:B(`完成 ${s.type||"未知项目"}`,`Completed ${s.type||"unknown item"}`),detail:""}}return{title:B(`事件: ${o}`,`Event: ${o}`),detail:""}}function ip(e){return e.status==="queued"?B("排队中","Queued"):e.status==="starting"?B("启动中","Starting"):e.status==="stopping"?B("停止中","Stopping"):e.status==="running"?B("进行中","Running"):e.status==="error"?B("失败","Failed"):e.status==="interrupted"?B("已中断","Interrupted"):e.status==="stopped"?B("已停止","Stopped"):e.status==="stop_timeout"?B("停止超时","Stop timeout"):B("已完成","Completed")}function Sa(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?$n(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 lp(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"?Cs(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:Gn()}}function Tn(e,t,n){const o=Sa(t,n);o&&(e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120))}function up(e,t,n){var s;const o=Sa(t,n);if(o){for(let r=e.events.length-1;r>=0;r-=1){const l=B("网络异常,正在重试","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 cp(e,t={},n,o=()=>{}){var r,l,u,p,w,c,S,h,g;const s=Rr(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;Tn(e,{title:t.message||B("状态已更新","Status updated"),detail:""},n);return}if(s===Vt.STDERR){const f=Kn(t.text,e.engine);Tn(e,{kind:"error",title:(f==null?void 0:f.title)||"stderr",detail:un(t.text,e.engine)},n);return}if(s===Vt.STDOUT){Tn(e,{kind:"command",title:"stdout",detail:t.text},n);return}if(s===Vt.AGENT_EVENT){if(np(e,t.event),((r=t.event)==null?void 0:r.type)===kt.THREAD_STARTED)return;const f=ap(t.event,Ot(e),e.engine);String(f.title||"").startsWith(B("网络异常,正在重试","Network error, retrying"))?up(e,f,n):Tn(e,f,n),((l=t.event)==null?void 0:l.type)===kt.ITEM_COMPLETED&&((p=(u=t.event)==null?void 0:u.item)==null?void 0:p.type)===ct.AGENT_MESSAGE&&((c=(w=t.event)==null?void 0:w.item)!=null&&c.text)&&(e.responseMessage=t.event.item.text);const D=ds(t.event)||B(`${Ot(e)} 执行失败`,`${Ot(e)} failed`);if(!(((S=t.event)==null?void 0:S.type)==="error"?jo(D):null)&&(((h=t.event)==null?void 0:h.type)===kt.ERROR||((g=t.event)==null?void 0:g.type)===kt.TURN_FAILED)){const v=ds(t.event)||B(`${Ot(e)} 执行失败`,`${Ot(e)} failed`);e.errorMessage=un(v,e.engine),e.status="error"}return}if(s===Vt.COMPLETED){Tn(e,{kind:"result",title:B("本轮执行结束","Run finished"),detail:""},n),t.message&&(e.responseMessage=t.message);return}if(s===Vt.STOPPED){Tn(e,{title:t.message||B("执行已手动停止","Execution stopped manually"),detail:""},n);return}if(s===Vt.ERROR){const f=Kn(t.message,e.engine);Tn(e,{kind:"error",title:(f==null?void 0:f.title)||B("执行失败","Execution failed"),detail:un(t.message||B(`${Ot(e)} 执行失败`,`${Ot(e)} failed`),e.engine)},n)}}function dp(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=Kn(o,n),l=Kn(s,n);return!r&&!!l}function fp(e,t={}){e.status=t.status||"completed",e.responseMessage=String(t.responseMessage||e.responseMessage||""),e.finishedAt=String(t.finishedAt||e.finishedAt||"");const n=un(String(t.errorMessage||""),e.engine),o=String(e.errorMessage||"");return e.errorMessage=dp(t.errorMessage,o,e.engine)?o:n,e.status==="completed"&&!e.responseMessage&&(e.responseMessage=B(`本轮 ${Ot(e)} 执行已完成,没有返回额外文本。`,`${Ot(e)} completed in this run without returning additional text.`)),e}function Vo(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)||{};cp(e,r,n,o);const l=Rr(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=un(String(r.message||e.errorMessage||B(`${Ot(e)} 执行失败`,`${Ot(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 ur(e,t,n,o){const s=lp(e,t);return(e.events||[]).forEach(r=>{Vo(s,r,n,o)}),fp(s,e)}const pp=1800,cr=7200,mp=15e3,fo={clearTaskCodexRuns:gl,listCodexRunEvents:pl,listTaskCodexRuns:fl};function as(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 gp(e=[],t=!0){const n=Array.isArray(e)?e:[];return JSON.stringify(n.map(o=>as(o,t)))}function hp(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function vp(e={}){const{props:t,turns:n,sessions:o,sending:s,sendingStartedAt:r,currentRunningRunId:l,sessionError:u,supportsServerEvents:p,scheduleScrollToBottom:w,resetAutoStickToBottom:c,mergeSessionRecord:S,mergeSession:h,loadSessions:g,showProcessLogs:f}=e;let D=0,Z=0,v=null,L="",F=null,W=null,M="",Y=!!(f!=null&&f.value),A=0;const X=new Map;function pe(){return D+=1,D}function ge(){return Z+=1,Z}function E(){F&&(window.clearInterval(F),F=null)}function ee(){W&&(window.clearInterval(W),W=null)}function ce(){A=Date.now()}function te(){X.clear(),n.value=[],s.value=!1,r.value=0,l.value="",M="",L="",D=0,Z=0,c()}function ye(){const z=[...n.value].reverse().find(ne=>cs(ne.status))||null;if(l.value=(z==null?void 0:z.runId)||"",s.value=!!z,z!=null&&z.startedAt){const ne=Date.parse(String(z.startedAt||""));r.value=Number.isFinite(ne)?ne:Date.now();return}r.value=0}function _(z=null){return z?{...z}:hp()}function U(z,ne=null){if(!(ne!=null&&ne.runId)||z.eventsLoaded||!ne.eventsLoaded)return X.has(z.runId)&&(z.eventsLoading=!0),z;const he=Math.max(Math.max(0,Number(ne.lastEventSeq)||0),Math.max(0,Number(ne.eventCount)||0),Array.isArray(ne.events)?ne.events.length:0),$e=Math.max(0,Number(z.eventCount)||0);return he<$e?(X.has(z.runId)&&(z.eventsLoading=!0),z):(z.events=Array.isArray(ne.events)?[...ne.events]:[],z.eventCount=Math.max(Math.max(0,Number(z.eventCount)||0),Math.max(0,Number(ne.eventCount)||0),z.events.length),z.eventsLoaded=!0,z.eventsLoading=X.has(z.runId),z.lastEventSeq=Math.max(0,Number(ne.lastEventSeq)||0),z.summary=_(ne.summary),z)}function $(z,ne){const he=ko(n.value,z);return he?(he.eventsLoading=!!ne,n.value=[...n.value],he):null}async function Me(z,ne={}){const he=String((z==null?void 0:z.runId)||"").trim(),{force:$e=!1}=ne;if(!he)return[];const oe=ko(n.value,he)||z;if(oe!=null&&oe.eventsLoaded&&!$e)return oe.events;if(X.has(he))return X.get(he);$(he,!0);const Ee=(async()=>{var _e;try{const Re=as(oe,!!(f!=null&&f.value)),ot=await fo.listCodexRunEvents(he,{limit:5e3}),Ne=ep(n.value,he,ot,ge,Fe=>{h(Fe,{preserveRunning:!0})});if(!Ne)return Array.isArray(oe==null?void 0:oe.events)?oe.events:[];const Ze=JSON.stringify(Re)!==JSON.stringify(as(Ne,!!(f!=null&&f.value)));return n.value=[...n.value],Ze&&t.active&&((_e=n.value.at(-1))==null?void 0:_e.runId)===he&&w(),Ne.events}catch(Re){throw u.value=Re.message,Re}finally{$(he,!1),X.delete(he)}})();return X.set(he,Ee),Ee}function De(z,ne){const he=String(z||"").trim();if(!he||!ne)return!1;const $e=n.value.findIndex(ot=>ot.runId===he);if($e<0)return!1;const oe=n.value[$e],Ee=as(oe,!!(f!=null&&f.value));if(!Vo(oe,ne,ge,ot=>{h(ot,{preserveRunning:!0})}))return!0;const Re=JSON.stringify(Ee)!==JSON.stringify(as(oe,!!(f!=null&&f.value)));return n.value=[...n.value],ye(),Re&&w(),!0}function Be(){if(E(),ee(),!(!t.active||!s.value||!t.taskSlug)){if(p){W=window.setInterval(()=>{We({force:!0}).catch(()=>{});const z=Date.now();z-A<cr||(A=z,g({force:!0}).catch(()=>{}))},mp);return}F=window.setInterval(()=>{We({force:!0}).catch(()=>{});const z=Date.now();z-A<cr||(A=z,g({force:!0}).catch(()=>{}))},pp)}}function He(z=[]){const ne=[...o.value],he=new Map(n.value.filter(oe=>String((oe==null?void 0:oe.runId)||"").trim()).map(oe=>[String(oe.runId||"").trim(),oe])),$e=oe=>{if(!(oe!=null&&oe.id))return;const Ee=ne.findIndex(_e=>_e.id===oe.id);Ee>=0?ne[Ee]=S(ne[Ee],oe,{preserveRunning:!0}):ne.unshift(S(null,oe,{preserveRunning:!0}))};D=0,Z=0,n.value=[...z||[]].reverse().map(oe=>{const Ee=ur(oe,pe,ge,$e);return U(Ee,he.get(String((oe==null?void 0:oe.id)||"").trim())||null)}),o.value=ne,ye()}async function We(z={}){const{force:ne=!1,scrollToLatest:he=!1}=z,$e=String(t.taskSlug||"").trim();if(!(!$e||!t.active&&!ne))return v&&L===$e||v&&!ne||(L=$e,v=(async()=>{try{const Ee=(await fo.listTaskCodexRuns($e,{limit:30,events:"latest"})).items||[],_e=!!(f!=null&&f.value),Re=gp(Ee,_e),ot=he||M&&Y===_e&&Re!==M;He(Ee),M=Re,Y=_e,Be();const Ne=n.value.at(-1)||null;if(Ne!=null&&Ne.runId&&!Ne.eventsLoaded){const Ze=Ne.runId;Me(Ne).catch(()=>{}).finally(()=>{var Fe;he&&t.active&&((Fe=n.value.at(-1))==null?void 0:Fe.runId)===Ze&&w({force:!0})})}ot&&w({force:he})}catch(oe){u.value=oe.message}finally{v=null,L=""}})()),v}function Ge(z={}){const ne=(z==null?void 0:z.run)||null,he=(z==null?void 0:z.session)||null;if(he&&h(he,{preserveRunning:!0}),!(ne!=null&&ne.id)){ye(),w({force:!0});return}const oe=ur(ne,pe,ge,_e=>{h(_e,{preserveRunning:!0})}),Ee=n.value.findIndex(_e=>_e.runId===oe.runId);if(Ee>=0){const _e=[...n.value];_e.splice(Ee,1,oe),n.value=_e}else n.value=[...n.value,oe];ye(),w({force:!0})}async function Te(){if(!(!t.taskSlug||s.value))try{await fo.clearTaskCodexRuns(t.taskSlug),te(),w({force:!0})}catch(z){u.value=z.message}}return{applyCreatedRun:Ge,applyIncomingRunEvent:De,clearRealtimeReconcileTimer:ee,clearRunPollTimer:E,clearTurns:Te,loadTurnEvents:Me,markFallbackSessionPollNow:ce,refreshRunHistory:We,resetRunHistoryState:te,syncRunningStateFromTurns:ye,updatePollingState:Be}}const yp=1500,Sp=3e4;function wp(e={}){const{props:t,sessions:n,workspaces:o,loading:s,managerBusy:r,sending:l,stopping:u,sessionError:p,showManager:w,selectedSessionId:c,currentRunningRunId:S,supportsServerEvents:h,mergeSession:g,applyCreatedRun:f,refreshRunHistory:D,markFallbackSessionPollNow:Z,showToast:v,getActiveAgentBinding:L=null}=e;let F=null,W=null,M=0,Y=0;const A=K(()=>typeof t.buildPrompt=="function"||!!String(t.prompt||"").trim()),X=K(()=>n.value.length>0),pe=K(()=>tr(n.value,c.value)),ge=K(()=>X.value?"":Ye("projectManager.noProjects"));async function E(Te={}){const{force:z=!1}=Te;if(F)return F;const ne=Date.now();return!z&&M&&ne-M<yp?{items:n.value,workspaces:o.value}:(F=(async()=>{s.value=!0,p.value="";try{const $e=(await tl()).items||[];return n.value=$e,M=Date.now(),{items:$e,workspaces:o.value}}catch(he){throw p.value=he.message,he}finally{s.value=!1,F=null}})(),F)}async function ee(Te={}){const{force:z=!1}=Te;if(W)return W;const ne=Date.now();return!z&&Y&&ne-Y<Sp?{items:o.value}:(W=(async()=>{try{const he=await nl();return o.value=he.items||[],Y=Date.now(),{items:o.value}}finally{W=null}})(),W)}async function ce(Te={}){const{forceSessions:z=!1,forceWorkspaces:ne=!1}=Te,[he,$e]=await Promise.all([E({force:z}),ee({force:ne})]);return{items:(he==null?void 0:he.items)||n.value,workspaces:($e==null?void 0:$e.items)||o.value}}function te(Te=""){const z=String(Te||"").trim();!z||o.value.includes(z)||(o.value=[z,...o.value])}function ye(){w.value=!0,ee().catch(()=>{})}function _(){w.value=!1}function U(Te){const z=String(Te||"").trim();if(t.sessionSelectionLocked&&z&&z!==c.value){p.value=t.sessionSelectionLockReason||Ye("taskActions.sessionLocked");return}c.value=z}function $(){ce({forceSessions:!0,forceWorkspaces:!0}).catch(()=>{})}async function Me(Te){r.value=!0,p.value="";try{const z=await sl(Te);return g(z),te(z.cwd),c.value=z.id,z}catch(z){throw p.value=z.message,z}finally{r.value=!1}}async function De(Te,z){r.value=!0,p.value="";try{const ne=await ol(Te,z);return g(ne),te(ne.cwd),ne}catch(ne){throw p.value=ne.message,ne}finally{r.value=!1}}async function Be(Te){var ne;const z=String(Te||"").trim();if(!z)return{deletedSessionId:"",selectedSessionId:c.value};r.value=!0,p.value="";try{await rl(z);const he=n.value.filter(oe=>oe.id!==z);n.value=he;let $e=c.value;return c.value===z&&($e=((ne=tr(he,"")[0])==null?void 0:ne.id)||"",c.value=$e),{deletedSessionId:z,selectedSessionId:$e}}catch(he){throw p.value=he.message,he}finally{r.value=!1}}async function He(Te){const z=String(Te||"").trim();if(!z)return null;r.value=!0,p.value="";try{const ne=await al(z);return ne!=null&&ne.session&&g(ne.session),Z(),await Promise.all([D({force:!0}),E({force:!0})]),v==null||v({message:Ye("projectManager.sessionReset"),type:"success"}),ne}catch(ne){throw p.value=ne.message,ne}finally{r.value=!1}}async function We(){if(!t.taskSlug||!A.value||l.value||u.value)return!1;if(!c.value){const Te=Ye("projectManager.selectProject");return p.value=Te,v==null||v({message:Te,type:"warning"}),!1}p.value="";try{await ce({forceSessions:!0});const Te=n.value.find(Ne=>Ne.id===c.value)||null;if(!Te)return p.value=Ye("projectManager.projectMissing"),!1;if(Te.running)return p.value=Ye("sessionTurns.currentProjectRunning"),!1;const z=typeof t.buildPrompt=="function"?await t.buildPrompt():t.prompt,ne=typeof t.buildPromptBlocks=="function"?await t.buildPromptBlocks():[],he=di({prompt:z,promptBlocks:ne});if(he.reason){const Ne=he.reason==="unsupported_blocks"?Ye("sessionPanel.shellUnsupportedBlocks"):Ye("sessionPanel.shellEmptyCommand");return p.value=Ne,v==null||v({message:Ne,type:"warning"}),!1}if(!String(z||"").trim())return p.value=Ye("sessionTurns.noPromptToSend"),!1;const $e=xp(Te),oe=typeof L=="function"?L(Te):null,Ee=String((oe==null?void 0:oe.engine)||"").trim();if(Ee&&!$e.some(Ne=>Ne.engine===Ee)){const Ne=Ye("sessionPanel.agentNotEnabled");return p.value=Ne,v==null||v({message:Ne,type:"warning"}),!1}const _e=oe,Re=String(he.mode==="shell"?c.value:(_e==null?void 0:_e.sessionRecordId)||c.value).trim(),ot=await ml(t.taskSlug,{projectSessionId:c.value,sessionId:Re,displayEngine:Ee,prompt:he.mode==="shell"?he.prompt:z,promptBlocks:ne,commandMode:he.mode,command:he.command});return f(ot),typeof t.afterSend=="function"&&Promise.resolve(t.afterSend()).catch(Ne=>{console.error("[promptx] afterSend failed",Ne)}),h||(Z(),Promise.all([D({force:!0}),E({force:!0})]).catch(Ne=>{p.value=Ne.message})),!0}catch(Te){return p.value=Te.message,!1}}async function Ge(){if(!(!S.value||u.value))try{u.value=!0,await hl(S.value),h||(Z(),await Promise.all([D({force:!0}),E({force:!0})]))}catch(Te){u.value=!1,p.value=Te.message}}return{closeManager:_,handleCreateSession:Me,handleDeleteSession:Be,handleResetSession:He,handleSelectSession:U,handleSend:We,handleUpdateSession:De,hasPrompt:A,helperText:ge,loadSessions:E,loadSessionResources:ce,loadWorkspaces:ee,openManager:ye,refreshSessionsForSelection:$,sortedSessions:pe,stopSending:Ge}}function xp(e={}){return Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length?e.agentBindings:e!=null&&e.id?[{engine:bp(e.engine),sessionRecordId:e.id,sessionId:e.sessionId||"",isDefault:!0,running:!!e.running,started:!!e.started}]:[]}function bp(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"}const kp=1200,Tp=[0,80,220,500,900];function _p(e={}){const{transcriptRef:t,hasNewerMessages:n,threshold:o=48}=e;let s=0,r=[],l=!1,u=!1,p=0,w=!0,c=0,S=[],h=0,g=null;function f(){const $=typeof window<"u"?window:globalThis;return typeof($==null?void 0:$.setTimeout)!="function"||typeof($==null?void 0:$.clearTimeout)!="function"?null:{setTimeout:$.setTimeout.bind($),clearTimeout:$.clearTimeout.bind($)}}function D(){if(typeof window>"u"||!r.length){r=[];return}r.forEach($=>{window.cancelAnimationFrame($)}),r=[]}function Z(){s+=1,D()}function v(){const $=f();if(!$){S=[],h=0;return}S.forEach(Me=>{$.clearTimeout(Me)}),S=[],h&&($.clearTimeout(h),h=0)}function L(){var $;($=g==null?void 0:g.disconnect)==null||$.call(g),g=null}function F(){return c>Date.now()}function W($){u=!!$,(n==null?void 0:n.value)!==void 0&&(n.value=u)}function M(){l=!1,p+=1,w=!0,W(!1)}function Y($=t==null?void 0:t.value){return $?$.scrollHeight-$.scrollTop-$.clientHeight<=o:!0}function A(){return F()||w&&!l}function X(){w&&!l&&W(!1)}function pe(){if(w=Y(),!w){Z();return}X()}function ge(){p+=1,l=!0,c=0,v(),L(),Z()}function E(){const $=p+1;p=$,dt(()=>{$===p&&requestAnimationFrame(()=>{$===p&&(l=!1,w=Y(),X())})})}function ee(){l=!0,c=0,v(),L(),Z()}function ce(){E()}function te($={}){const{force:Me=!1}=$;Me&&M(),Z();const De=s;dt(()=>{if(!(t==null?void 0:t.value)||De!==s)return;if(!Me&&!A()){W(!0);return}const He=()=>{const Ge=t==null?void 0:t.value;!Ge||De!==s||(Ge.scrollTop=Ge.scrollHeight,w=!0,W(!1))};He(),r=[requestAnimationFrame(()=>{He(),r=[requestAnimationFrame(He)]})]})}function ye(){te({force:!0})}function _($={}){const Me=Number($.durationMs),De=Math.max(0,Number.isFinite(Me)?Me:kp),Be=f();M(),c=Date.now()+De,v(),L(),Be&&(S=Tp.map(He=>Be.setTimeout(()=>{F()&&te({force:!0})},He)),h=Be.setTimeout(()=>{c=0,h=0,v(),L()},De+40)),typeof window<"u"&&typeof window.ResizeObserver=="function"&&(g=new window.ResizeObserver(()=>{F()&&te({force:!0})}),t!=null&&t.value&&g.observe(t.value)),te({force:!0})}function U(){p+=1,c=0,v(),L(),Z()}return{cancelScheduledScrollToBottom:Z,destroy:U,handleTranscriptScroll:pe,handleTranscriptTouchEnd:ce,handleTranscriptTouchMove:ee,handleTranscriptTouchStart:ge,beginForceFollowWindow:_,isTranscriptNearBottom:Y,resetAutoStickToBottom:M,scheduleScrollToBottom:te,scrollToBottom:ye}}const Cp=150,wa="promptx:session-panel:show-process";function Ep(e){return!(e==="0"||e==="false")}function Ap(){if(typeof window>"u")return!0;try{return Ep(window.localStorage.getItem(wa))}catch{return!0}}function $p(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 Ip(e,t){const n=la(),o=j([]),s=j([]),r=j(!1),l=j(!1),u=j(!1),p=j(!1),w=j(""),c=j([]),S=j(null),h=j(0),g=j(0),f=j(!1),D=j(""),Z=j(!1),v=j(Ap()),L=typeof window<"u"&&typeof window.EventSource<"u";function F(ae=""){const Ie=typeof ae=="object"&&ae!==null?String(ae.message||"").trim():String(ae||"").trim();Ie&&t("toast",typeof ae=="object"&&ae!==null?{...ae,message:Ie}:Ie)}let W=null,M=null,Y=null,A={sessions:!1,runs:!1};const X=K({get(){return String(e.selectedSessionId||"").trim()},set(ae){t("selected-session-change",String(ae||"").trim())}}),pe=K(()=>p.value?Ye("sessionPanel.stopping"):`${Ye("projectManager.running")} (${fa(g.value)})`),ge=K(()=>o.value.find(ae=>ae.id===X.value)||null),E=K(()=>{var Ie;if(Array.isArray((Ie=ge.value)==null?void 0:Ie.agentBindings)&&ge.value.agentBindings.length)return ge.value.agentBindings;const ae=ge.value;return ae!=null&&ae.id?[{engine:ae.engine,sessionRecordId:ae.id,sessionId:ae.sessionId||"",started:!!ae.started,running:!!ae.running,isDefault:!0}]:[]}),ee=K({get(){var Ie,it;const ae=po(e.selectedAgentEngine,E.value);return ae||((Ie=E.value.find(Ct=>Ct.isDefault))==null?void 0:Ie.engine)||((it=E.value[0])==null?void 0:it.engine)||""},set(ae){const Ie=po(ae,E.value);Ie&&t("update:selectedAgentEngine",Ie)}}),ce=K(()=>E.value.find(ae=>ae.engine===ee.value)||E.value[0]||null),{beginForceFollowWindow:te,destroy:ye,handleTranscriptScroll:_,handleTranscriptTouchEnd:U,handleTranscriptTouchMove:$,handleTranscriptTouchStart:Me,resetAutoStickToBottom:De,scheduleScrollToBottom:Be,scrollToBottom:He}=_p({transcriptRef:S,hasNewerMessages:Z});function We(ae,Ie,it={}){return $p(ae,Ie,it)}function Ge(ae,Ie={}){if(!(ae!=null&&ae.id))return;const it=[...o.value],Ct=it.findIndex(Bt=>Bt.id===ae.id);Ct>=0?it[Ct]=We(it[Ct],ae,Ie):it.unshift(We(null,ae,Ie)),o.value=it}const{applyCreatedRun:Te,applyIncomingRunEvent:z,clearRealtimeReconcileTimer:ne,clearRunPollTimer:he,clearTurns:$e,loadTurnEvents:oe,markFallbackSessionPollNow:Ee,refreshRunHistory:_e,resetRunHistoryState:Re,updatePollingState:ot}=vp({props:e,turns:c,sessions:o,sending:u,sendingStartedAt:h,currentRunningRunId:D,sessionError:w,supportsServerEvents:L,scheduleScrollToBottom:Be,resetAutoStickToBottom:De,showProcessLogs:v,mergeSessionRecord:We,mergeSession:Ge,loadSessions:(...ae)=>_t(...ae)}),{closeManager:Ne,handleCreateSession:Ze,handleDeleteSession:Fe,handleResetSession:Je,handleSelectSession:Pe,handleSend:ut,handleUpdateSession:rt,helperText:Qe,loadSessions:_t,loadSessionResources:$t,loadWorkspaces:C,openManager:O,refreshSessionsForSelection:se,sortedSessions:we,stopSending:qe}=wp({props:e,sessions:o,workspaces:s,loading:r,managerBusy:l,sending:u,stopping:p,sessionError:w,showManager:f,selectedSessionId:X,currentRunningRunId:D,supportsServerEvents:L,mergeSession:Ge,applyCreatedRun:Te,refreshRunHistory:_e,markFallbackSessionPollNow:Ee,showToast:F,getActiveAgentBinding:()=>ce.value});function Oe(){W&&(window.clearInterval(W),W=null)}function at(){Oe(),h.value||(h.value=Date.now()),g.value=Math.max(0,Math.floor((Date.now()-h.value)/1e3)),W=window.setInterval(()=>{g.value=Math.max(0,Math.floor((Date.now()-h.value)/1e3))},1e3)}function Xe(){Y&&(window.clearTimeout(Y),Y=null)}function ft(){Xe();const ae=A;A={sessions:!1,runs:!1},ae.sessions&&_t({force:!0}).catch(()=>{}),ae.runs&&_e({force:!0}).catch(()=>{})}function St(ae={}){typeof window>"u"||(A={sessions:A.sessions||!!ae.sessions,runs:A.runs||!!ae.runs},!(Y||!A.sessions&&!A.runs)&&(Y=window.setTimeout(()=>{ft()},Cp)))}function It(ae){return ha(ae,{currentRunningRunId:D.value,runningElapsedSeconds:g.value,nowMs:Date.now()})}function wt(ae=""){if(!ae)return"";const Ie=new Date(ae);return Number.isNaN(Ie.getTime())?"":Ie.toLocaleTimeString(qs(),{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function zt(ae){return ae.status==="error"||ae.status==="stop_timeout"?"theme-process-error":ae.status==="interrupted"||ae.status==="stopped"?"theme-process-stopped":ae.status==="completed"?"theme-process-completed":"theme-process-running"}function Dt(){v.value=!v.value}function Ht(ae){return!!(ae.responseMessage||ae.errorMessage||ae.status==="completed")}return Le(v,ae=>{if(!(typeof window>"u"))try{window.localStorage.setItem(wa,ae?"true":"false")}catch{}},{immediate:!0}),Le(u,ae=>{ae?(h.value||(h.value=Date.now()),at()):(Oe(),h.value=0,g.value=0,p.value=!1),ot(),t("sending-change",ae)},{immediate:!0}),Le(()=>!!e.taskRunning,ae=>{!e.active||ae||!u.value||St({sessions:!0,runs:!0})}),Le(()=>e.active,ae=>{if(ae){$t({forceSessions:!0}).catch(()=>{});return}Xe(),ne(),he()},{immediate:!0}),Le(()=>e.taskSlug,()=>{Re(),f.value=!1,w.value="",e.active&&(te(),_e({force:!0,scrollToLatest:!0}).catch(()=>{}))},{immediate:!0}),Le(()=>{var ae;return[((ae=ge.value)==null?void 0:ae.id)||"",E.value.map(Ie=>Ie.engine).join(","),e.selectedAgentEngine||""].join(`
39
- `)},()=>{var V,J,ue;const ae=String(((V=ge.value)==null?void 0:V.id)||"").trim(),Ie=E.value,it=ee.value;if(t("agent-bindings-change",{sessionId:ae,bindings:Ie,selectedEngine:it}),!ae||po(e.selectedAgentEngine,Ie))return;const Bt=((J=Ie.find(fe=>fe.isDefault))==null?void 0:J.engine)||((ue=Ie[0])==null?void 0:ue.engine)||"";Bt&&t("update:selectedAgentEngine",Bt)},{immediate:!0}),Mt(()=>{Oe(),ne(),he(),Xe(),ye(),M==null||M()}),Le(()=>n.readyVersion.value,()=>{const ae=String(e.taskSlug||"").trim();!e.active&&!f.value||(f.value&&C().catch(()=>{}),St({sessions:!0,runs:!!ae}))}),Le(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!f.value||St({sessions:!0})}),Le(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||St({sessions:!0,runs:!0})}),Le(()=>String(e.taskSlug||"").trim(),ae=>{M==null||M(),M=null,ae&&(M=Bf(ae,({runId:Ie,event:it})=>{if(!e.active)return;z(Ie,it)||St({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:ce,activeAgentEngine:ee,clearTurns:$e,closeManager:Ne,formatTurnTime:wt,getProcessCardClass:zt,getProcessStatus:ip,getTurnAgentLabel:Ot,getTurnSummaryDetail:ya,getDisplayTurnSummaryItems:It,getTurnSummaryStatus:va,handleCreateSession:Ze,handleDeleteSession:Fe,handleResetSession:Je,handleSelectSession:Pe,handleSend:ut,handleUpdateSession:rt,loadTurnEvents:oe,hasTurnSummary:op,helperText:Qe,loading:r,managerBusy:l,openManager:O,refreshSessionsForSelection:se,selectedSessionId:X,sending:u,showProcessLogs:v,stopping:p,sessionError:w,shouldShowResponse:Ht,showManager:f,sortedSessions:we,stopSending:qe,toggleProcessLogs:Dt,hasNewerMessages:Z,transcriptRef:S,turns:c,workspaces:s,workingLabel:pe,sessions:o,loadSessions:_t,currentProjectAgentBindings:E,handleTranscriptScroll:_,handleTranscriptTouchEnd:U,handleTranscriptTouchMove:$,handleTranscriptTouchStart:Me,scheduleScrollToBottom:Be,scrollToBottom:He}}function po(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const Pp=8,Dp=320,Lp=10,Mp=400;function dr(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function Bp(e={}){const{turns:t,loadTurnEvents:n}=e,o=j({}),s=j({}),r=j({});function l(A){return String((A==null?void 0:A.runId)||(A==null?void 0:A.id)||"").trim()}function u(A){const X=l(A);return!!X&&X===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!cs(A==null?void 0:A.status)&&!u(A)&&p(A)>3}function c(A){return dr(A==null?void 0:A.prompt,Pp,Dp)}function S(A){return!cs(A==null?void 0:A.status)&&!u(A)&&c(A)}function h(A){return String((A==null?void 0:A.errorMessage)||(A==null?void 0:A.responseMessage)||"")}function g(A){return dr(h(A),Lp,Mp)}function f(A){return!(A!=null&&A.errorMessage)&&!u(A)&&g(A)}function D(A){return p(A)>0}function Z(A=[]){const X=new Set((A||[]).map(E=>l(E)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([E])=>X.has(E))),s.value=Object.fromEntries(Object.entries(s.value).filter(([E])=>X.has(E))),r.value=Object.fromEntries(Object.entries(r.value).filter(([E])=>X.has(E)));const pe=(A||[]).at(-1)||null,ge=l(pe);ge&&(Object.prototype.hasOwnProperty.call(o.value,ge)||(o.value={...o.value,[ge]:!1}),Object.prototype.hasOwnProperty.call(s.value,ge)||(s.value={...s.value,[ge]:!1}),Object.prototype.hasOwnProperty.call(r.value,ge)||(r.value={...r.value,[ge]:!1}))}function v(A){const X=l(A);return X?Object.prototype.hasOwnProperty.call(o.value,X)?!!o.value[X]:w(A):!1}async function L(A){const X=l(A);if(!X)return;const pe=!v(A);o.value={...o.value,[X]:pe},!pe&&D(A)&&!A.eventsLoaded&&!A.eventsLoading&&await n(A).catch(()=>{})}function F(A){const X=l(A);return X?Object.prototype.hasOwnProperty.call(s.value,X)?!!s.value[X]:S(A):!1}function W(A){const X=l(A);!X||!c(A)||(s.value={...s.value,[X]:!F(A)})}function M(A){const X=l(A);return X?Object.prototype.hasOwnProperty.call(r.value,X)?!!r.value[X]:f(A):!1}function Y(A){const X=l(A);!X||!g(A)||(r.value={...r.value,[X]:!M(A)})}return Le(t,A=>{Z(A)},{immediate:!0,deep:!0}),{canCollapsePrompt:c,canCollapseResponse:g,getTurnEventCollapseKey:l,getTurnEventCount:p,hasTurnEventHistory:D,isLatestTurn:u,isPromptCollapsed:F,isResponseCollapsed:M,isTurnEventsCollapsed:v,togglePrompt:W,toggleResponse:Y,toggleTurnEvents:L}}function Rp(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function Np(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 Op(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function mo(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 go(e="",t=[],n=[]){var l;const o=Rp(t.map(u=>u.groupTarget)),s=[];if(e==="todo"){const u=[...n].reverse().flatMap(p=>Array.isArray(p==null?void 0:p.detailBlocks)?p.detailBlocks:[]).find(p=>(p==null?void 0:p.type)==="checklist");return u?[u]:[]}if(e==="reasoning"){const u=[...t].reverse().find(p=>Array.isArray(p==null?void 0:p.detailBlocks)&&p.detailBlocks.length);return(l=u==null?void 0:u.detailBlocks)!=null&&l.length?u.detailBlocks:[]}const r=Np([{label:"类型",value:Op(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 xa(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:mo(n,e.length),detail:"",detailBlocks:go(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:mo(n,e.length),detail:"",detailBlocks:go(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:mo(n,o.length),detail:"",detailBlocks:go(n,o,o),isGrouped:!0,groupedCount:o.length}]}function Fp(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]=xa(n);if(!o)return t;const s=t.reduce((r,l,u)=>String((l==null?void 0:l.groupType)||"").trim()==="todo"?u:r,-1);return s<0?t:t.flatMap((r,l)=>String((r==null?void 0:r.groupType)||"").trim()!=="todo"?[r]:l===s?[o]:[])}function Up(e=[]){var o;const t=Fp(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 u=[r];for(;s+1<t.length&&String(((o=t[s+1])==null?void 0:o.groupType)||"").trim()===l;)u.push(t[s+1]),s+=1;n.push(...xa(u))}return n}const jp={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},Vp={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},zp={class:"flex flex-col gap-2"},Hp={class:"flex items-center gap-2"},qp=["title"],Kp={class:"flex shrink-0 items-center gap-1.5"},Wp=["aria-pressed","aria-label","title"],Gp=["disabled"],Xp={class:"hidden sm:inline"},Yp=["disabled"],Jp={class:"hidden sm:inline"},Qp=["aria-label"],Zp=["aria-pressed"],em=["aria-pressed","title","onClick"],tm={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},nm={class:"min-h-0 flex-1"},sm={key:0,class:"theme-empty-state px-4 py-6 text-sm"},om={key:1,class:"theme-empty-state px-4 py-6 text-sm"},rm=["data-turn-id","data-run-id"],am={class:"flex justify-end"},im={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)]"},lm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},um={class:"font-semibold"},cm={class:"flex items-center gap-2"},dm=["onClick"],fm={class:"relative mt-2"},pm={key:0,class:"space-y-3"},mm={key:0,class:"whitespace-pre-wrap break-words leading-7"},gm=["onClick"],hm=["src","alt"],vm={key:1,class:"whitespace-pre-wrap break-words leading-7"},ym={key:0,class:"flex min-w-0 justify-start"},Sm={class:"flex items-center justify-between gap-3 text-xs"},wm={class:"font-semibold"},xm={class:"flex items-center gap-2"},bm=["disabled","onClick"],km={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Tm={key:1,class:"mt-2 min-w-0 space-y-2"},_m={class:"text-sm font-medium leading-6"},Cm={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Em={key:3,class:"mt-2 text-xs text-current"},Am={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},$m={key:0,class:"leading-5"},Im={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},Pm={key:2,class:"mt-2 flex flex-wrap gap-2"},Dm={class:"font-medium"},Lm={key:1,class:"flex justify-start"},Mm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},Bm={class:"font-semibold"},Rm={class:"flex items-center gap-2"},Nm=["onClick"],Om=["onClick"],Fm={class:"relative mt-2"},Um={key:0,class:"whitespace-pre-wrap break-words"},jm=["innerHTML"],Vm={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"},zm=["disabled"],Hm={key:2,class:"task-loading-dots","aria-hidden":"true"},qm={__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=yo(()=>Ke(()=>import("./CodexSessionManagerDialog-BojVd2nD.js"),__vite__mapDeps([34,35,2,3,36,37,38,39,40]))),s=n,r=e,{closeManager:l,formatTurnTime:u,getProcessCardClass:p,getProcessStatus:w,getTurnAgentLabel:c,getDisplayTurnSummaryItems:S,getTurnSummaryDetail:h,getTurnSummaryStatus:g,handleCreateSession:f,handleDeleteSession:D,handleResetSession:Z,handleSelectSession:v,handleSend:L,handleTranscriptScroll:F,handleTranscriptTouchEnd:W,handleTranscriptTouchMove:M,handleTranscriptTouchStart:Y,handleUpdateSession:A,helperText:X,loadTurnEvents:pe,loading:ge,managerBusy:E,openManager:ee,refreshSessionsForSelection:ce,selectedSessionId:te,sending:ye,showProcessLogs:_,stopping:U,hasTurnSummary:$,hasNewerMessages:Me,sessionError:De,shouldShowResponse:Be,showManager:He,sortedSessions:We,stopSending:Ge,toggleProcessLogs:Te,transcriptRef:z,turns:ne,workspaces:he,sessions:$e,loadSessions:oe,currentProjectAgentBindings:Ee,scheduleScrollToBottom:_e,scrollToBottom:Re}=Ip(r,s),ot=j(null),Ne=j(!1),Ze=j(""),Fe=j(""),Je=j("all"),{t:Pe}=Tt(),{isDark:ut}=Er(),rt=K(()=>ut.value?"dark":"light"),Qe=K(()=>{const I=new Set;return(Array.isArray(Ee.value)?Ee.value:[]).filter(Q=>{const H=String((Q==null?void 0:Q.engine)||"").trim();return!H||I.has(H)?!1:(I.add(H),!0)})}),_t=K(()=>Qe.value.length>1),$t=K(()=>{const I=String(Je.value||"").trim();return!_t.value||I==="all"?ne.value:ne.value.filter(Q=>ga(Q)===I)}),{selectionAction:C,clearSelectionState:O,handleSelectionMouseUp:se}=ea({getContainer:()=>z.value,isActive:()=>!!(r.active&&ne.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:I=>[...I.querySelectorAll("[data-response-selection-root]")],getCodeLeft:I=>{var Q,H;return((H=(Q=I==null?void 0:I.getBoundingClientRect)==null?void 0:Q.call(I))==null?void 0:H.left)||0},debounceMs:72});Le([Je,()=>Qe.value.map(I=>I.engine).join(`
39
+ `)},()=>{var V,J,ue;const ae=String(((V=ge.value)==null?void 0:V.id)||"").trim(),Ie=E.value,it=ee.value;if(t("agent-bindings-change",{sessionId:ae,bindings:Ie,selectedEngine:it}),!ae||po(e.selectedAgentEngine,Ie))return;const Bt=((J=Ie.find(fe=>fe.isDefault))==null?void 0:J.engine)||((ue=Ie[0])==null?void 0:ue.engine)||"";Bt&&t("update:selectedAgentEngine",Bt)},{immediate:!0}),Mt(()=>{Oe(),ne(),he(),Xe(),ye(),M==null||M()}),Le(()=>n.readyVersion.value,()=>{const ae=String(e.taskSlug||"").trim();!e.active&&!f.value||(f.value&&C().catch(()=>{}),St({sessions:!0,runs:!!ae}))}),Le(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!f.value||St({sessions:!0})}),Le(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||St({sessions:!0,runs:!0})}),Le(()=>String(e.taskSlug||"").trim(),ae=>{M==null||M(),M=null,ae&&(M=Bf(ae,({runId:Ie,event:it})=>{if(!e.active)return;z(Ie,it)||St({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:ce,activeAgentEngine:ee,clearTurns:$e,closeManager:Ne,formatTurnTime:wt,getProcessCardClass:zt,getProcessStatus:ip,getTurnAgentLabel:Ot,getTurnSummaryDetail:ya,getDisplayTurnSummaryItems:It,getTurnSummaryStatus:va,handleCreateSession:Ze,handleDeleteSession:Fe,handleResetSession:Je,handleSelectSession:Pe,handleSend:ut,handleUpdateSession:rt,loadTurnEvents:oe,hasTurnSummary:op,helperText:Qe,loading:r,managerBusy:l,openManager:O,refreshSessionsForSelection:se,selectedSessionId:X,sending:u,showProcessLogs:v,stopping:p,sessionError:w,shouldShowResponse:Ht,showManager:f,sortedSessions:we,stopSending:qe,toggleProcessLogs:Dt,hasNewerMessages:Z,transcriptRef:S,turns:c,workspaces:s,workingLabel:pe,sessions:o,loadSessions:_t,currentProjectAgentBindings:E,handleTranscriptScroll:_,handleTranscriptTouchEnd:U,handleTranscriptTouchMove:$,handleTranscriptTouchStart:Me,scheduleScrollToBottom:Be,scrollToBottom:He}}function po(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const Pp=8,Dp=320,Lp=10,Mp=400;function dr(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function Bp(e={}){const{turns:t,loadTurnEvents:n}=e,o=j({}),s=j({}),r=j({});function l(A){return String((A==null?void 0:A.runId)||(A==null?void 0:A.id)||"").trim()}function u(A){const X=l(A);return!!X&&X===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!cs(A==null?void 0:A.status)&&!u(A)&&p(A)>3}function c(A){return dr(A==null?void 0:A.prompt,Pp,Dp)}function S(A){return!cs(A==null?void 0:A.status)&&!u(A)&&c(A)}function h(A){return String((A==null?void 0:A.errorMessage)||(A==null?void 0:A.responseMessage)||"")}function g(A){return dr(h(A),Lp,Mp)}function f(A){return!(A!=null&&A.errorMessage)&&!u(A)&&g(A)}function D(A){return p(A)>0}function Z(A=[]){const X=new Set((A||[]).map(E=>l(E)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([E])=>X.has(E))),s.value=Object.fromEntries(Object.entries(s.value).filter(([E])=>X.has(E))),r.value=Object.fromEntries(Object.entries(r.value).filter(([E])=>X.has(E)));const pe=(A||[]).at(-1)||null,ge=l(pe);ge&&(Object.prototype.hasOwnProperty.call(o.value,ge)||(o.value={...o.value,[ge]:!1}),Object.prototype.hasOwnProperty.call(s.value,ge)||(s.value={...s.value,[ge]:!1}),Object.prototype.hasOwnProperty.call(r.value,ge)||(r.value={...r.value,[ge]:!1}))}function v(A){const X=l(A);return X?Object.prototype.hasOwnProperty.call(o.value,X)?!!o.value[X]:w(A):!1}async function L(A){const X=l(A);if(!X)return;const pe=!v(A);o.value={...o.value,[X]:pe},!pe&&D(A)&&!A.eventsLoaded&&!A.eventsLoading&&await n(A).catch(()=>{})}function F(A){const X=l(A);return X?Object.prototype.hasOwnProperty.call(s.value,X)?!!s.value[X]:S(A):!1}function W(A){const X=l(A);!X||!c(A)||(s.value={...s.value,[X]:!F(A)})}function M(A){const X=l(A);return X?Object.prototype.hasOwnProperty.call(r.value,X)?!!r.value[X]:f(A):!1}function Y(A){const X=l(A);!X||!g(A)||(r.value={...r.value,[X]:!M(A)})}return Le(t,A=>{Z(A)},{immediate:!0,deep:!0}),{canCollapsePrompt:c,canCollapseResponse:g,getTurnEventCollapseKey:l,getTurnEventCount:p,hasTurnEventHistory:D,isLatestTurn:u,isPromptCollapsed:F,isResponseCollapsed:M,isTurnEventsCollapsed:v,togglePrompt:W,toggleResponse:Y,toggleTurnEvents:L}}function Rp(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function Np(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 Op(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function mo(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 go(e="",t=[],n=[]){var l;const o=Rp(t.map(u=>u.groupTarget)),s=[];if(e==="todo"){const u=[...n].reverse().flatMap(p=>Array.isArray(p==null?void 0:p.detailBlocks)?p.detailBlocks:[]).find(p=>(p==null?void 0:p.type)==="checklist");return u?[u]:[]}if(e==="reasoning"){const u=[...t].reverse().find(p=>Array.isArray(p==null?void 0:p.detailBlocks)&&p.detailBlocks.length);return(l=u==null?void 0:u.detailBlocks)!=null&&l.length?u.detailBlocks:[]}const r=Np([{label:"类型",value:Op(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 xa(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:mo(n,e.length),detail:"",detailBlocks:go(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:mo(n,e.length),detail:"",detailBlocks:go(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:mo(n,o.length),detail:"",detailBlocks:go(n,o,o),isGrouped:!0,groupedCount:o.length}]}function Fp(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]=xa(n);if(!o)return t;const s=t.reduce((r,l,u)=>String((l==null?void 0:l.groupType)||"").trim()==="todo"?u:r,-1);return s<0?t:t.flatMap((r,l)=>String((r==null?void 0:r.groupType)||"").trim()!=="todo"?[r]:l===s?[o]:[])}function Up(e=[]){var o;const t=Fp(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 u=[r];for(;s+1<t.length&&String(((o=t[s+1])==null?void 0:o.groupType)||"").trim()===l;)u.push(t[s+1]),s+=1;n.push(...xa(u))}return n}const jp={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},Vp={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},zp={class:"flex flex-col gap-2"},Hp={class:"flex items-center gap-2"},qp=["title"],Kp={class:"flex shrink-0 items-center gap-1.5"},Wp=["aria-pressed","aria-label","title"],Gp=["disabled"],Xp={class:"hidden sm:inline"},Yp=["disabled"],Jp={class:"hidden sm:inline"},Qp=["aria-label"],Zp=["aria-pressed"],em=["aria-pressed","title","onClick"],tm={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},nm={class:"min-h-0 flex-1"},sm={key:0,class:"theme-empty-state px-4 py-6 text-sm"},om={key:1,class:"theme-empty-state px-4 py-6 text-sm"},rm=["data-turn-id","data-run-id"],am={class:"flex justify-end"},im={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)]"},lm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},um={class:"font-semibold"},cm={class:"flex items-center gap-2"},dm=["onClick"],fm={class:"relative mt-2"},pm={key:0,class:"space-y-3"},mm={key:0,class:"whitespace-pre-wrap break-words leading-7"},gm=["onClick"],hm=["src","alt"],vm={key:1,class:"whitespace-pre-wrap break-words leading-7"},ym={key:0,class:"flex min-w-0 justify-start"},Sm={class:"flex items-center justify-between gap-3 text-xs"},wm={class:"font-semibold"},xm={class:"flex items-center gap-2"},bm=["disabled","onClick"],km={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Tm={key:1,class:"mt-2 min-w-0 space-y-2"},_m={class:"text-sm font-medium leading-6"},Cm={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Em={key:3,class:"mt-2 text-xs text-current"},Am={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},$m={key:0,class:"leading-5"},Im={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},Pm={key:2,class:"mt-2 flex flex-wrap gap-2"},Dm={class:"font-medium"},Lm={key:1,class:"flex justify-start"},Mm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},Bm={class:"font-semibold"},Rm={class:"flex items-center gap-2"},Nm=["onClick"],Om=["onClick"],Fm={class:"relative mt-2"},Um={key:0,class:"whitespace-pre-wrap break-words"},jm=["innerHTML"],Vm={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"},zm=["disabled"],Hm={key:2,class:"task-loading-dots","aria-hidden":"true"},qm={__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=yo(()=>Ke(()=>import("./CodexSessionManagerDialog-B_F9ZWKy.js"),__vite__mapDeps([34,35,2,3,36,37,38,39,40]))),s=n,r=e,{closeManager:l,formatTurnTime:u,getProcessCardClass:p,getProcessStatus:w,getTurnAgentLabel:c,getDisplayTurnSummaryItems:S,getTurnSummaryDetail:h,getTurnSummaryStatus:g,handleCreateSession:f,handleDeleteSession:D,handleResetSession:Z,handleSelectSession:v,handleSend:L,handleTranscriptScroll:F,handleTranscriptTouchEnd:W,handleTranscriptTouchMove:M,handleTranscriptTouchStart:Y,handleUpdateSession:A,helperText:X,loadTurnEvents:pe,loading:ge,managerBusy:E,openManager:ee,refreshSessionsForSelection:ce,selectedSessionId:te,sending:ye,showProcessLogs:_,stopping:U,hasTurnSummary:$,hasNewerMessages:Me,sessionError:De,shouldShowResponse:Be,showManager:He,sortedSessions:We,stopSending:Ge,toggleProcessLogs:Te,transcriptRef:z,turns:ne,workspaces:he,sessions:$e,loadSessions:oe,currentProjectAgentBindings:Ee,scheduleScrollToBottom:_e,scrollToBottom:Re}=Ip(r,s),ot=j(null),Ne=j(!1),Ze=j(""),Fe=j(""),Je=j("all"),{t:Pe}=Tt(),{isDark:ut}=Er(),rt=K(()=>ut.value?"dark":"light"),Qe=K(()=>{const I=new Set;return(Array.isArray(Ee.value)?Ee.value:[]).filter(Q=>{const H=String((Q==null?void 0:Q.engine)||"").trim();return!H||I.has(H)?!1:(I.add(H),!0)})}),_t=K(()=>Qe.value.length>1),$t=K(()=>{const I=String(Je.value||"").trim();return!_t.value||I==="all"?ne.value:ne.value.filter(Q=>ga(Q)===I)}),{selectionAction:C,clearSelectionState:O,handleSelectionMouseUp:se}=ea({getContainer:()=>z.value,isActive:()=>!!(r.active&&ne.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:I=>[...I.querySelectorAll("[data-response-selection-root]")],getCodeLeft:I=>{var Q,H;return((H=(Q=I==null?void 0:I.getBoundingClientRect)==null?void 0:Q.call(I))==null?void 0:H.left)||0},debounceMs:72});Le([Je,()=>Qe.value.map(I=>I.engine).join(`
40
40
  `)],()=>{Je.value!=="all"&&(Qe.value.some(I=>I.engine===Je.value)||(Je.value="all"))},{immediate:!0}),Le(Je,()=>{O({clearBrowserSelection:!0}),_e({force:!0})}),Le(()=>r.taskSlug,(I,Q)=>{!String(I||"").trim()||I===Q||(Je.value="all")});function we(I={}){if((I==null?void 0:I.kind)==="reasoning")return!0;const Q=String((I==null?void 0:I.title)||"").trim();return Q?[/^已连接项目:/,/^工作目录:/,/^项目会话已更新$/,/^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(H=>H.test(Q)):!1}function qe(I={}){return Pe("sessionPanel.promptTitleWithAgent",{agent:c(I)})}function Oe(I={}){return I.errorMessage?Pe("sessionPanel.errorSuffix",{agent:c(I)}):Pe("sessionPanel.responseSuffix",{agent:c(I)})}const{getTurnEventCount:at,hasTurnEventHistory:Xe,isTurnEventsCollapsed:ft,toggleTurnEvents:St}=Bp({turns:ne,loadTurnEvents:pe});function It(I){return String((I==null?void 0:I.runId)||(I==null?void 0:I.id)||"").trim()}function wt(I){I!=null&&I.runId&&s("open-diff",{scope:"run",runId:I.runId})}function zt(){s("open-diff",{scope:"workspace",runId:""})}const{getRenderedHtml:Dt}=bf({items:ne,themeKey:rt,getCacheKey:It,getSource:I=>String((I==null?void 0:I.responseMessage)||""),shouldRender:I=>!!(I!=null&&I.responseMessage)&&!(I!=null&&I.errorMessage),renderAsync:I=>gc(I,{isDark:ut.value,copyLabel:Pe("sessionPanel.copyCode"),copyAriaLabel:Pe("sessionPanel.copyCodeAria")}),renderFallback:I=>Jr(I),onRendered:I=>{const Q=ne.value.at(-1)||null;!r.active||!(Q!=null&&Q.runId)||Q.runId!==(I==null?void 0:I.runId)||_e()}});function Ht(I){Fe.value=String(I||"").trim()}async function ae(I){var H;if((H=navigator.clipboard)!=null&&H.writeText&&window.isSecureContext){await navigator.clipboard.writeText(I);return}const Q=document.createElement("textarea");Q.value=I,Q.setAttribute("readonly","true"),Q.style.position="fixed",Q.style.opacity="0",Q.style.pointerEvents="none",document.body.appendChild(Q),Q.select(),document.execCommand("copy"),document.body.removeChild(Q)}function Ie(I={}){const H=(Array.isArray(I==null?void 0:I.promptBlocks)?I.promptBlocks:[]).filter(Ce=>(Ce==null?void 0:Ce.type)==="text"||(Ce==null?void 0:Ce.type)==="imported_text").map(Ce=>String((Ce==null?void 0:Ce.content)||"").replace(/\u200b/g,"").trim()).filter(Boolean).join(`
41
41
 
42
42
  `);return H||String((I==null?void 0:I.prompt)||"").replace(/\u200b/g,"").trim()}function it(I={}){const Q=Ie(I);Q&&s("insert-code-context",{source:"response",content:Q})}async function Ct(I){var k,T,q,ie,re;const Q=(T=(k=I==null?void 0:I.target)==null?void 0:k.closest)==null?void 0:T.call(k,'[data-copy-code="1"]');if(!Q)return;const H=Q.closest(".codex-code-block"),Ce=(q=H==null?void 0:H.querySelector)==null?void 0:q.call(H,"pre code"),Xt=String((Ce==null?void 0:Ce.textContent)||"").replace(/\u200b/g,"");if(Xt){(ie=I.preventDefault)==null||ie.call(I),(re=I.stopPropagation)==null||re.call(I);try{await ae(Xt),s("toast",{message:Pe("sessionPanel.codeCopied"),type:"success"})}catch{s("toast",{message:Pe("errors.requestFailed"),type:"warning"})}}}function Bt(){if(!C.value.visible)return;const I=String(C.value.content||"").replace(/\u200b/g,"").trim();if(!I){O({clearBrowserSelection:!0});return}s("insert-code-context",{source:"response",content:I}),O({clearBrowserSelection:!0})}function V(I={}){if(I!=null&&I.errorMessage)return;const Q=String((I==null?void 0:I.responseMessage)||"").replace(/\u200b/g,"").trim();Q&&s("insert-code-context",{source:"response",content:Q})}const J=K(()=>ne.value.flatMap(I=>(Array.isArray(I==null?void 0:I.promptBlocks)?I.promptBlocks:[]).filter(Q=>(Q==null?void 0:Q.type)==="image").map(Q=>Q.content)));function ue(I){const H=(Array.isArray(I==null?void 0:I.events)?I.events:[]).filter(Ce=>!we(Ce));return Up(H)}function fe(I){return at(I)}function Ve(I){return I!=null&&I.eventsLoaded?fe(I)>0:Xe(I)}function Et(I){return!!(I!=null&&I.eventsLoading)}function Zt(I){return!!(I!=null&&I.eventsLoaded)&&ue(I).length>0&&!ft(I)}function mt(I){return!!(I!=null&&I.eventsLoaded)&&fe(I)>0&&ft(I)}function Ft(I){return Xe(I)&&!(I!=null&&I.eventsLoaded)&&!(I!=null&&I.eventsLoading)}function bt(I={}){return jr(I,{defaultLabel:Pe("sessionPanel.defaultAgent")})}function sn(I={}){return!tp(I)}function dn(I={}){return"bg-[var(--theme-appPanelStrong)]"}function fn(I=null){const Q=String((I==null?void 0:I.id)||"").trim();if(Q)return $e.value.find(Ce=>Ce.id===Q)||null;const H=String(te.value||"").trim();return H?$e.value.find(Ce=>Ce.id===H)||null:We.value[0]||null}function qt(I=null){const Q=fn(I);return Q!=null&&Q.cwd?(Ze.value=Q.id,Ne.value=!0,!0):!1}function Kt(){return E.value?!1:(ee(),!0)}function Pt(){var I,Q;return Ne.value?(Ne.value=!1,!0):(Q=(I=ot.value)==null?void 0:I.closeTopDialog)!=null&&Q.call(I)?!0:He.value?(l(),!0):!1}return t({closeTopDialog:Pt,openProjectManager:Kt,openSourceBrowser:qt,send:L,scrollToBottom:Re,stop:Ge}),(I,Q)=>(m(),b("section",jp,[de(xf,{open:Ne.value,session:a($e).find(H=>H.id===Ze.value)||null,onInsertCodeContext:Q[0]||(Q[0]=H=>s("insert-code-context",H)),onClose:Q[1]||(Q[1]=H=>Ne.value=!1)},null,8,["open","session"]),de(a(o),{ref_key:"managerDialogRef",ref:ot,open:a(He),sessions:a($e),workspaces:a(he),"selected-session-id":a(te),"selection-locked":e.sessionSelectionLocked,"selection-lock-reason":e.sessionSelectionLockReason,loading:a(ge),sending:a(ye),"on-refresh":a(oe),"on-create":a(f),"on-update":a(A),"on-delete":a(D),"on-reset":a(Z),onClose:a(l),onOpenSourceBrowser:Q[2]||(Q[2]=H=>qt(H)),onProjectCreated:Q[3]||(Q[3]=H=>s("project-created",H)),onSelectSession:a(v)},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",Vp,[i("div",zp,[i("div",Hp,[i("div",{class:"min-w-0 flex-1",title:a(X)||""},[de(Ju,{modelValue:a(te),"onUpdate:modelValue":Q[4]||(Q[4]=H=>Da(te)?te.value=H:null),sessions:a(We),loading:a(ge),disabled:a(ye)||a(E)||e.sessionSelectionLocked,onRefreshIntent:a(ce)},null,8,["modelValue","sessions","loading","disabled","onRefreshIntent"])],8,qp),i("div",Kp,[i("button",{type:"button",class:be(["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(Pe)("sessionPanel.hideProcessToggle"):a(Pe)("sessionPanel.showProcessToggle"),title:a(_)?a(Pe)("sessionPanel.hideProcessToggle"):a(Pe)("sessionPanel.showProcessToggle"),onClick:Q[5]||(Q[5]=(...H)=>a(Te)&&a(Te)(...H))},[a(_)?(m(),Ae(a(Ua),{key:0,class:"h-4 w-4"})):(m(),Ae(a(ja),{key:1,class:"h-4 w-4"}))],10,Wp),e.diffSupported?(m(),b("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:zt},[de(a(qo),{class:"h-4 w-4"}),Q[17]||(Q[17]=i("span",{class:"sm:hidden"},"代码",-1)),i("span",Xp,x(a(Pe)("sessionPanel.diff")),1)],8,Gp)):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(E),onClick:Q[6]||(Q[6]=(...H)=>a(ee)&&a(ee)(...H))},[de(a(is),{class:"h-4 w-4"}),Q[18]||(Q[18]=i("span",{class:"sm:hidden"},"项目",-1)),i("span",Jp,x(a(Pe)("sessionPanel.manageProjects")),1)],8,Yp)])]),_t.value?(m(),b("div",{key:0,class:"flex max-w-full items-center gap-1.5 overflow-x-auto pb-0.5","aria-label":a(Pe)("sessionPanel.agentFilter")},[i("button",{type:"button",class:be(["theme-agent-selector-button",Je.value==="all"?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Je.value==="all"?"true":"false",onClick:Q[7]||(Q[7]=H=>Je.value="all")},x(a(Pe)("sessionPanel.allAgents")),11,Zp),(m(!0),b(lt,null,pt(Qe.value,H=>(m(),b("button",{key:H.engine,type:"button",class:be(["theme-agent-selector-button",Je.value===H.engine?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Je.value===H.engine?"true":"false",title:bt(H),onClick:Ce=>Je.value=H.engine},x(bt(H)),11,em))),128))],8,Qp)):me("",!0),a(De)?(m(),b("p",tm,[de(a($o),{class:"h-4 w-4"}),i("span",null,x(a(De)),1)])):me("",!0)])]),i("div",nm,[i("div",{ref_key:"transcriptRef",ref:z,"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:Q[9]||(Q[9]=(...H)=>a(F)&&a(F)(...H)),onTouchstartPassive:Q[10]||(Q[10]=(...H)=>a(Y)&&a(Y)(...H)),onTouchmovePassive:Q[11]||(Q[11]=(...H)=>a(M)&&a(M)(...H)),onTouchendPassive:Q[12]||(Q[12]=(...H)=>a(W)&&a(W)(...H)),onTouchcancelPassive:Q[13]||(Q[13]=(...H)=>a(W)&&a(W)(...H))},[a(ne).length?$t.value.length?me("",!0):(m(),b("div",om,x(a(Pe)("sessionPanel.emptyAgentFilter")),1)):(m(),b("div",sm,x(a(Pe)("sessionPanel.empty")),1)),(m(!0),b(lt,null,pt($t.value,H=>(m(),b("div",{key:H.id,"data-promptx-turn":"1","data-turn-id":H.id,"data-run-id":H.runId||"",class:"flex min-w-0 flex-col gap-3"},[i("div",am,[i("div",im,[i("div",lm,[i("span",um,x(qe(H)),1),i("div",cm,[Ie(H)?(m(),b("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:Ce=>it(H)},[de(a(Rs),{class:"h-3 w-3"}),i("span",null,x(a(Pe)("sessionPanel.insert")),1)],8,dm)):me("",!0),i("span",null,x(a(u)(H.startedAt)),1)])]),i("div",fm,[Array.isArray(H.promptBlocks)&&H.promptBlocks.length?(m(),b("div",pm,[(m(!0),b(lt,null,pt(H.promptBlocks,(Ce,Xt)=>(m(),b(lt,{key:`${H.id}-prompt-${Xt}`},[Ce.type==="text"||Ce.type==="imported_text"?(m(),b("pre",mm,x(Ce.content),1)):(m(),b("button",{key:1,type:"button",class:"inline-flex cursor-zoom-in justify-center rounded-sm",onClick:k=>Ht(Ce.content)},[i("img",{src:Ce.content,alt:a(Pe)("sessionPanel.promptImageAlt"),class:"max-h-52 w-auto max-w-full rounded-sm object-contain shadow-sm"},null,8,hm)],8,gm))],64))),128))])):(m(),b("pre",vm,x(H.prompt),1))])])]),a(_)&&sn(H)?(m(),b("div",ym,[i("div",{class:be(["transcript-card transcript-card--process min-w-0 w-full rounded-sm px-4 py-3",a(p)(H)])},[i("div",Sm,[i("span",wm,x(a(Pe)("sessionPanel.processTitle")),1),i("div",xm,[Ve(H)?(m(),b("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:H.eventsLoading,onClick:Ce=>a(St)(H)},[Et(H)?(m(),Ae(a(Gt),{key:0,class:"h-3 w-3 animate-spin"})):a(ft)(H)?(m(),Ae(a(Ao),{key:1,class:"h-3 w-3"})):(m(),Ae(a(Va),{key:2,class:"h-3 w-3"})),i("span",null,x(H.eventsLoading?a(Pe)("sessionPanel.loading"):a(ft)(H)?`${a(Pe)("sessionPanel.expand")} (${fe(H)})`:a(Pe)("sessionPanel.collapse")),1)],8,bm)):me("",!0),i("span",null,x(a(w)(H)),1)])]),Et(H)?(m(),b("div",km,x(a(Pe)("sessionPanel.loadingEvents")),1)):Zt(H)?(m(),b("div",Tm,[(m(!0),b(lt,null,pt(ue(H),Ce=>(m(),b("div",{key:Ce.id,class:be(["transcript-event-card min-w-0 rounded-sm px-3 py-2",dn(Ce)])},[i("div",_m,x(Ce.title),1),Ce.detail||Array.isArray(Ce.detailBlocks)&&Ce.detailBlocks.length?(m(),Ae(Qc,{key:0,detail:Ce.detail,blocks:Ce.detailBlocks,kind:Ce.kind,class:"mt-2"},null,8,["detail","blocks","kind"])):me("",!0)],2))),128))])):mt(H)||Ft(H)?(m(),b("div",Cm,x(H.eventsLoaded?a(Pe)("sessionPanel.hiddenEventsLoaded",{count:fe(H)}):a(Pe)("sessionPanel.hiddenEventsLoadLater",{count:fe(H)})),1)):(m(),b("p",Em,x(["queued","starting","running","stopping"].includes(H.status)?a(Pe)("sessionPanel.waitingEvents",{agent:a(c)(H)}):a(Pe)("sessionPanel.noEvents")),1)),a($)(H)?(m(),b("div",Am,[a(g)(H)?(m(),b("div",$m,x(a(g)(H)),1)):me("",!0),a(h)(H)?(m(),b("div",Im,x(a(h)(H)),1)):me("",!0),a(S)(H).length?(m(),b("div",Pm,[(m(!0),b(lt,null,pt(a(S)(H),Ce=>(m(),b("span",{key:Ce.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,x(Ce.label),1),i("span",Dm,x(Ce.value),1)]))),128))])):me("",!0)])):me("",!0)],2)])):me("",!0),a(Be)(H)?(m(),b("div",Lm,[i("div",{class:be(["transcript-card transcript-card--response min-w-0 w-full rounded-sm px-4 py-3 text-sm leading-7",H.errorMessage?"bg-[var(--theme-dangerSoft)] text-[var(--theme-dangerText)]":"bg-[var(--theme-responseBg)] text-[var(--theme-responseText)]"])},[i("div",Mm,[i("span",Bm,x(Oe(H)),1),i("div",Rm,[e.diffSupported&&H.runId?(m(),b("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:Ce=>wt(H)},[de(a(qo),{class:"h-3 w-3"}),i("span",null,x(a(Pe)("sessionPanel.view")),1)],8,Nm)):me("",!0),H.responseMessage&&!H.errorMessage?(m(),b("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:Ce=>V(H)},[de(a(Rs),{class:"h-3 w-3"}),i("span",null,x(a(Pe)("sessionPanel.insert")),1)],8,Om)):me("",!0),i("span",null,x(a(u)(H.finishedAt||H.startedAt)),1)])]),i("div",Fm,[H.errorMessage?(m(),b("div",Um,x(H.errorMessage),1)):(m(),b("div",{key:1,class:"prose-like codex-markdown","data-response-selection-root":"1",onMouseup:Q[8]||(Q[8]=(...Ce)=>a(se)&&a(se)(...Ce)),onClick:Ct,innerHTML:a(Dt)(H)},null,40,jm))])],2)])):me("",!0)],8,rm))),128)),a(C).visible?(m(),Ae(Qr,{key:2,top:a(C).top,left:a(C).left,label:a(Pe)("sourceBrowser.insertSelection"),onClick:Bt},null,8,["top","left","label"])):me("",!0)],544),i("div",Vm,[a(Me)?(m(),b("button",{key:0,type:"button",class:be([a(ye)?"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:Q[14]||(Q[14]=(...H)=>a(Re)&&a(Re)(...H))},[de(a(za),{class:"h-3.5 w-3.5"}),i("span",null,x(a(Pe)("sessionPanel.jumpToLatest")),1)],2)):me("",!0),a(ye)?(m(),b("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(U),onClick:Q[15]||(Q[15]=(...H)=>a(Ge)&&a(Ge)(...H))},[a(U)?(m(),Ae(a(Gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(m(),Ae(a(Ha),{key:1,class:"h-3.5 w-3.5"})),i("span",null,x(a(U)?a(Pe)("sessionPanel.stopping"):a(Pe)("sessionPanel.stop")),1),a(U)?me("",!0):(m(),b("span",Hm,[...Q[19]||(Q[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,zm)):me("",!0)])]),de(Vr,{modelValue:Fe.value,"onUpdate:modelValue":Q[16]||(Q[16]=H=>Fe.value=H),images:J.value},null,8,["modelValue","images"])]))}},Km={key:0,class:"h-full min-h-0"},Wm={key:1,class:"panel theme-muted-text flex h-full items-center px-5 py-4 text-sm"},fr={__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=j(null);function r(){var S,h;return(h=(S=s.value)==null?void 0:S.send)==null?void 0:h.call(S)}function l(){var S,h;(h=(S=s.value)==null?void 0:S.stop)==null||h.call(S)}function u(){var S,h;(h=(S=s.value)==null?void 0:S.scrollToBottom)==null||h.call(S)}function p(){var S,h;return((h=(S=s.value)==null?void 0:S.openProjectManager)==null?void 0:h.call(S))||!1}function w(){var S,h;return((h=(S=s.value)==null?void 0:S.openSourceBrowser)==null?void 0:h.call(S))||!1}function c(){var S,h;return((h=(S=s.value)==null?void 0:S.closeTopDialog)==null?void 0:h.call(S))||!1}return t({closeTopDialog:c,openProjectManager:p,openSourceBrowser:w,send:r,stop:l,scrollToBottom:u}),(S,h)=>e.taskSlug?(m(),b("div",Km,[de(qm,{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:h[0]||(h[0]=g=>o("agent-bindings-change",g)),onInsertCodeContext:h[1]||(h[1]=g=>o("insert-code-context",g)),onProjectCreated:h[2]||(h[2]=g=>o("project-created",g)),onSendingChange:h[3]||(h[3]=g=>o("sending-change",g)),onSelectedSessionChange:h[4]||(h[4]=g=>o("selected-session-change",g)),"onUpdate:selectedAgentEngine":h[5]||(h[5]=g=>o("update:selectedAgentEngine",g)),onOpenDiff:h[6]||(h[6]=g=>o("open-diff",g)),onToast:h[7]||(h[7]=g=>o("toast",g))},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?(m(),b("section",Wm,x(e.emptyMessage),1)):me("",!0)}},Gm=["title"],Xm={class:"flex min-w-0 items-center gap-1.5"},Ym=["aria-pressed","title","data-agent-engine","onClick"],pr={__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}=Tt(),r=K(()=>{const c=new Set;return(Array.isArray(n.agentBindings)?n.agentBindings:[]).filter(S=>{const h=String((S==null?void 0:S.engine)||"").trim();return!h||c.has(h)?!1:(c.add(h),!0)})}),l=K(()=>r.value.length>1),u=K(()=>{var S,h;const c=String(n.selectedAgentEngine||"").trim();return r.value.some(g=>g.engine===c)?c:((S=r.value.find(g=>g.isDefault))==null?void 0:S.engine)||((h=r.value[0])==null?void 0:h.engine)||""}),p=K(()=>n.align==="end"?"sm:justify-end":n.align==="center"?"sm:justify-center":"sm:justify-start");function w(c={}){return jr(c,{prefix:"→ ",defaultLabel:s("sessionPanel.defaultAgent")})}return(c,S)=>l.value?(m(),b("div",{key:0,class:be(["flex w-full overflow-x-auto pb-0.5",p.value]),title:a(s)("editor.selectAgent"),"data-promptx-agent-targets":"",onMousedown:S[1]||(S[1]=nt(()=>{},["stop"]))},[i("div",Xm,[(m(!0),b(lt,null,pt(r.value,h=>(m(),b("button",{key:h.engine,type:"button",class:be(["theme-agent-selector-button",h.engine===u.value?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":h.engine===u.value,title:w(h),"data-agent-engine":h.engine,onMousedown:S[0]||(S[0]=nt(()=>{},["prevent"])),onClick:g=>o("update:selectedAgentEngine",h.engine)},x(w(h)),43,Ym))),128))])],42,Gm)):me("",!0)}},Jm={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":""},Qm={class:"grid w-full grid-cols-5 gap-2 sm:flex sm:w-full sm:flex-wrap sm:justify-end sm:gap-2"},Zm=["disabled","title","aria-label"],eg={class:"sr-only sm:not-sr-only sm:inline"},tg=["title","aria-label"],ng={class:"sr-only sm:not-sr-only sm:inline"},sg=["disabled","title","aria-label"],og={class:"sr-only sm:not-sr-only sm:inline"},rg=["title","aria-label"],ag={class:"sr-only sm:not-sr-only sm:inline"},ig={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"},lg=["disabled","title","aria-label"],ug={class:"sr-only sm:not-sr-only sm:inline"},mr={__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}=Tt(),r=K(()=>n.sendState==="sending"||n.sendState==="running");function l(){return n.todoCount>0?s("editor.todoWithCount",{count:n.todoCount}):s("editor.todo")}return(u,p)=>(m(),b("div",Jm,[i("div",Qm,[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]=nt(()=>{},["prevent"])),onClick:p[1]||(p[1]=w=>o("open-file-picker"))},[e.uploading?(m(),Ae(a(Gt),{key:0,class:"h-4 w-4 animate-spin"})):(m(),Ae(a(qa),{key:1,class:"h-4 w-4"})),i("span",eg,x(a(s)("editor.chooseFiles")),1)],40,Zm),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]=nt(()=>{},["prevent"])),onClick:p[3]||(p[3]=w=>o("clear-request"))},[de(a(Ka),{class:"h-4 w-4"}),i("span",ng,x(a(s)("editor.clear")),1)],40,tg),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]=nt(()=>{},["prevent"])),onClick:p[5]||(p[5]=w=>o("add-todo"))},[de(a(Rs),{class:"h-4 w-4"}),i("span",og,x(a(s)("editor.todo")),1)],40,sg),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]=nt(()=>{},["prevent"])),onClick:p[7]||(p[7]=w=>o("manage-todo"))},[de(a(Dr),{class:"h-4 w-4"}),i("span",ag,x(l()),1),e.todoCount>0?(m(),b("span",ig,x(e.todoCount>9?"9+":e.todoCount),1)):me("",!0)],40,rg),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]=nt(()=>{},["prevent"])),onClick:p[9]||(p[9]=w=>o("send-request"))},[r.value?(m(),Ae(a(Gt),{key:0,class:"h-4 w-4 animate-spin"})):(m(),Ae(a(Wa),{key:1,class:"h-4 w-4"})),i("span",ug,x(a(s)("editor.send")),1)],40,lg)])]))}};function cg(e){const{props:t,panelRef:n,onClose:o}=e,s=j({left:"12px",top:"12px",width:"560px",maxHeight:"420px"}),r=j(!1),l=j("bottom");function u(){o==null||o()}function p(g=!1){const f=window.innerWidth,D=window.innerHeight,Z=12,v=8,L=320,F=560,W=420,M=180,Y=Math.min(F,Math.max(L,f-Z*2)),A=Math.min(Y,f-Z*2),X=t.anchorRect||{left:(f-A)/2,top:D/2,bottom:D/2};let pe=X.left;pe+A>f-Z&&(pe=f-Z-A),pe<Z&&(pe=Z);const ge=Math.max(0,D-Z-(X.bottom+v)),E=Math.max(0,X.top-v-Z);g?l.value=ge>=E?"bottom":"top":l.value==="bottom"&&ge<M&&E>ge+24?l.value="top":l.value==="top"&&E<M&&ge>E+24&&(l.value="bottom");const ee=l.value,ce=ee==="bottom"?ge:E,te=Math.max(140,D-Z*2),ye=Math.min(te,Math.max(Math.min(W,ce||W),M)),_={left:`${Math.round(pe)}px`,width:`${Math.round(A)}px`,maxHeight:`${Math.round(ye)}px`,top:"auto",bottom:"auto"};return ee==="bottom"?_.top=`${Math.round(Math.max(Z,X.bottom+v))}px`:_.bottom=`${Math.round(Math.max(Z,D-X.top+v))}px`,_}function w(g=!1){const f=p(g);s.value={...s.value,left:f.left,top:f.top,bottom:f.bottom,width:f.width,maxHeight:f.maxHeight}}function c(){return!t.open||!t.anchorRect?!1:(l.value="bottom",w(!0),r.value=!0,!0)}function S(){r.value=!1}function h(g){!t.open||!n.value||n.value.contains(g.target)||u()}return cn(()=>{document.addEventListener("pointerdown",h)}),Mt(()=>{document.removeEventListener("pointerdown",h)}),{closePicker:u,initializePanel:c,panelReady:r,panelStyle:s,resetPanel:S,updatePanelPosition:w}}function dg(e){const{props:t,panelRef:n,onClose:o,onSelect:s}=e,{closePicker:r,initializePanel:l,panelReady:u,panelStyle:p,resetPanel:w,updatePanelPosition:c}=cg({props:t,panelRef:n,onClose:o}),S=na({getMode:()=>String(t.query||"").trim()?"search":"tree",props:t,onSelect:s});return Le(()=>t.open,h=>{if(!h){S.resetData(),w();return}w(),t.anchorRect&&l()&&S.initializeData()},{flush:"sync"}),Le(()=>t.anchorRect,h=>{if(!(!t.open||!h)){if(!u.value){l()&&S.initializeData();return}c(!1)}},{flush:"sync"}),Le(()=>t.sessionId,()=>{S.handleSessionChange()},{flush:"sync",immediate:!0}),Le(()=>t.query,()=>{S.handleQueryChange()},{immediate:!0}),Le(S.visibleItems,()=>{S.handleVisibleItemsChange()},{immediate:!0}),{...S,closePicker:r,panelReady:u,panelStyle:p}}const fg={class:"theme-divider flex items-center justify-end gap-2 border-b border-dashed px-2.5 py-2"},pg={class:"flex shrink-0 items-center gap-2"},mg={class:"min-h-0 flex-1 overflow-y-auto p-2"},gg={key:0,class:"theme-empty-state px-3 py-4 text-xs"},hg={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},vg={key:2,class:"theme-empty-state px-3 py-4 text-xs"},yg={key:3,class:"theme-empty-state px-3 py-4 text-xs"},Sg={key:4,class:"theme-empty-state px-3 py-4 text-xs"},wg={key:5,class:"space-y-1"},xg={key:0,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},bg=["onClick"],kg={class:"min-w-0 flex-1"},Tg=["innerHTML"],_g=["innerHTML"],Cg={key:1,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},Eg=["onClick"],Ag={class:"min-w-0 flex-1"},$g=["innerHTML"],Ig=["innerHTML"],Pg={key:6,class:"space-y-1"},Dg={class:"flex items-start gap-1.5"},Lg=["onClick"],Mg={key:1,class:"block h-5 w-5 shrink-0"},Bg=["onClick"],Rg={class:"min-w-0 flex-1"},Ng={class:"flex items-center gap-1.5"},Og={__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=j(null),{t:l}=Tt(),{activeKey:u,closePicker:p,collapseActiveDirectory:w,confirmActive:c,currentError:S,currentLoading:h,emitSelect:g,expandActiveDirectory:f,getDisplayName:D,getHighlightedName:Z,getHighlightedPath:v,moveActive:L,normalSearchItems:F,normalizedQuery:W,panelReady:M,panelStyle:Y,recentSearchItems:A,setItemRef:X,showSearchEmptyState:pe,showTreeEmptyState:ge,toggleDirectory:E,treeItems:ee,visibleItems:ce}=dg({props:o,panelRef:r,onClose:()=>s("close"),onSelect:te=>s("select",te)});return t({collapseActiveDirectory:w,moveActive:L,confirmActive:c,expandActiveDirectory:f}),(te,ye)=>(m(),Ae(fs,{to:"body"},[e.open&&a(M)?(m(),b("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:In(a(Y))},[i("div",fg,[i("div",pg,[i("div",{class:be(["theme-muted-text inline-flex h-7 w-7 items-center justify-center",a(h)?"opacity-100":"opacity-0"])},[de(a(Gt),{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:ye[0]||(ye[0]=(..._)=>a(p)&&a(p)(..._))},[de(a($r),{class:"h-4 w-4"})])])]),i("div",mg,[e.sessionId?a(S)?(m(),b("div",hg,x(a(S)),1)):a(pe)?(m(),b("div",vg,x(a(l)("pathPicker.noResults")),1)):a(ge)?(m(),b("div",yg,x(a(l)("pathPicker.emptyDirectory")),1)):a(h)&&!a(ce).length?(m(),b("div",Sg,x(a(l)("pathPicker.loading")),1)):a(W)?(m(),b("div",wg,[a(A).length?(m(),b("div",xg,x(a(l)("pathPicker.recent")),1)):me("",!0),(m(!0),b(lt,null,pt(a(A),_=>(m(),b("button",{key:_.path,ref_for:!0,ref:U=>a(X)(_.path,U),type:"button",class:be(["theme-list-row focus:outline-none",a(u)===_.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:U=>a(g)(_)},[(m(),Ae(yn(_.type==="directory"?a(jn):a(Cn)),{class:"theme-list-item-icon"})),i("div",kg,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Z)(_)},null,8,Tg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(v)(_)},null,8,_g)])],10,bg))),128)),a(W)&&a(F).length?(m(),b("div",Cg,x(a(l)("pathPicker.results")),1)):me("",!0),(m(!0),b(lt,null,pt(a(F),_=>(m(),b("button",{key:_.path,ref_for:!0,ref:U=>a(X)(_.path,U),type:"button",class:be(["theme-list-row focus:outline-none",a(u)===_.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:U=>a(g)(_)},[(m(),Ae(yn(_.type==="directory"?a(jn):a(Cn)),{class:"theme-list-item-icon"})),i("div",Ag,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Z)(_)},null,8,$g)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(v)(_)},null,8,Ig)])],10,Eg))),128))])):(m(),b("div",Pg,[(m(!0),b(lt,null,pt(a(ee),_=>(m(),b("div",{key:_.path,ref_for:!0,ref:U=>a(X)(_.path,U),class:be(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(u)===_.path?"theme-list-item-active":_.type==="directory"&&_.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:In({paddingLeft:`${_.depth*16+6}px`})},[i("div",Dg,[_.type==="directory"?(m(),b("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:nt(U=>a(E)(_.path),["stop"])},[_.loading?(m(),Ae(a(Gt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(m(),Ae(a(Pr),{key:1,class:be(["h-3.5 w-3.5 transition",_.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,Lg)):(m(),b("span",Mg)),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:U=>a(g)(_)},[(m(),Ae(yn(_.type==="directory"?a(jn):a(Cn)),{class:be(["h-4 w-4 shrink-0",_.type==="directory"&&_.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("div",Rg,[i("div",Ng,[i("span",{class:be(["theme-list-item-title truncate",_.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},x(a(D)(_)),3)])])],8,Bg)])],6))),128))])):(m(),b("div",gg,x(a(l)("pathPicker.selectProjectFirst")),1))])],4)):me("",!0)]))}},Fg={__name:"TiptapTextBlockView",props:Io,setup(e){return(t,n)=>(m(),Ae(a(Po),{"data-promptx-node":"text"},{default:tt(()=>[de(a(Br),{"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}))}},ba={__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=K(()=>t.selected?"ring-1 ring-inset ring-[var(--theme-borderStrong)]":""),o=K(()=>t.selected?"opacity-100":"opacity-100 sm:opacity-45 sm:group-hover:opacity-100 sm:focus-within:opacity-100");return(s,r)=>(m(),b("div",{class:be(["overflow-hidden rounded-sm transition",[e.frameClass,n.value]])},[i("div",{class:be(["theme-divider border-b text-xs",[e.headerPaddingClass,e.headerClass]])},[nn(s.$slots,"header",{actionsStateClass:o.value})],2),nn(s.$slots,"default")],2))}},At={DOC:"doc",TEXT_BLOCK:"paragraph",IMPORTED_TEXT_BLOCK:"promptxImportedTextBlock",IMAGE_BLOCK:"promptxImageBlock",TEXT:"text",HARD_BREAK:"hardBreak"};function Ug(){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 Hn(e={}){return{...e,clientId:String((e==null?void 0:e.clientId)||(e==null?void 0:e.id)||Ug()),meta:e!=null&&e.meta?{...e.meta}:{}}}function Un(e=""){return Hn({type:Lt.TEXT,content:e,meta:{}})}function xs(e){return e&&e.type!==Lt.TEXT}function An(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];if(!t.length)return[Un("")];const n=[];return t.forEach((o,s)=>{const r=Hn(o),l=n[n.length-1];!l&&xs(r)&&n.push(Un("")),l&&xs(l)&&xs(r)&&n.push(Un("")),n.push(r),s===t.length-1&&xs(r)&&n.push(Un(""))}),n}function _o(e=""){const t=String(e||"").split(`
@@ -54,7 +54,7 @@ ${B("原始错误","Raw error")}: ${o.rawMessage}`:n}function To(e,t=0){if(!e||t
54
54
  `).trim()}function Ov(e,t){return Nv(e,t)}const Co="promptx:active-task-slug",Fv=150,Uv=1500,Vs=500,jv=new Set(["completed","error","stopped","interrupted","stop_timeout","failed","cancelled","timeout"]);function zs(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 vn(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 jt(e=[]){return(e||[]).map(t=>({id:String((t==null?void 0:t.id)||"").trim(),createdAt:String((t==null?void 0:t.createdAt)||""),blocks:vn((t==null?void 0:t.blocks)||[])}))}function wr(e={}){return{title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),blocks:vn(e.blocks||[]),todoItems:jt(e.todoItems||[])}}function Ta(e=[]){return vn(e).filter(t=>(t==null?void 0:t.type)===Lt.IMAGE?!!String(t.content||"").trim():!!String((t==null?void 0:t.content)||"").trim())}function Vv(e=[]){return Ta(e).length>0}function zv(){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 xr(){return vn([{type:Lt.TEXT,content:"",meta:{}}])}function Eo(e=[],t=16){return bi(e,t)||""}function Hv(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 br(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=Eo(t);if(s)return s;const r=String((e==null?void 0:e.preview)||"").trim();return r?r.slice(0,16):Ye("workbench.untitledTask")}function Hs(e={}){return!!(e!=null&&e.running)}function qv(e={},t=!1){return t&&!Hs(e)?"sending":Hs(e)?"running":"idle"}function Kv(e=""){return["queued","starting","running","stopping"].includes(String(e||"").trim())}function Wv(e=""){return jv.has(String(e||"").trim())}function _a(e="",t="",n=!1){const o=String(e||"").trim();return!!(o&&o===String(t||"").trim()&&n)}function Gv(e={},t="",n={}){const o=String(t||"").trim();return!o||_a(o,n.currentTaskSlug,n.pageFocused)?{unreadMap:e,didMark:!1}:e!=null&&e[o]?{unreadMap:e,didMark:!1}:{unreadMap:{...e||{},[o]:!0},didMark:!0}}function Ca(e={},t=""){const n=String(t||"").trim();if(!n||!(e!=null&&e[n]))return e;const o={...e||{}};return delete o[n],o}function Xv(e={},t={}){return t.pageFocused?Ca(e,t.currentTaskSlug):e}function Yv(e={},t=[]){const n=new Set((t||[]).map(s=>String((s==null?void 0:s.slug)||"").trim()).filter(Boolean)),o={};return Object.entries(e||{}).forEach(([s,r])=>{n.has(s)&&r&&(o[s]=!0)}),o}function Ea(e=null){return typeof e=="string"?{status:e,taskSlug:""}:{status:String((e==null?void 0:e.status)||"").trim(),taskSlug:String((e==null?void 0:e.taskSlug)||"").trim()}}function Aa(e={},t=Vs){const n=Math.max(1,Number(t)||Vs),o=Object.entries(e||{});return o.length<=n?e:Object.fromEntries(o.slice(-n))}function Jv(e={},t=[],n=Vs){const o=new Set((t||[]).map(r=>String((r==null?void 0:r.slug)||"").trim()).filter(Boolean)),s={};return Object.entries(e||{}).forEach(([r,l])=>{const u=Ea(l);u.taskSlug&&o.has(u.taskSlug)&&(s[r]=u)}),Aa(s,n)}function Qv(e={}){const t=String(e.taskSlug||"").trim(),n=e.change||null,o=String((n==null?void 0:n.runId)||"").trim(),s=String((n==null?void 0:n.status)||"").trim(),r=e.unreadMap||{},l=e.notifiedMap||{};if(!t||!o||!Wv(s))return{unreadMap:r,notifiedMap:l,didMark:!1,didDedupe:!1};if(Ea(l[o]).status===s)return{unreadMap:r,notifiedMap:l,didMark:!1,didDedupe:!0};const p=Aa({...l,[o]:{taskSlug:t,status:s}},e.maxNotifiedRuns),w=Gv(r,t,{currentTaskSlug:e.currentTaskSlug,pageFocused:e.pageFocused});return{unreadMap:w.unreadMap,notifiedMap:p,didMark:w.didMark,didDedupe:!1}}function kr(e="",t=72){return String(e||"").replace(/\s+/g," ").trim().slice(0,t)}function Zv(e=[],t=[]){const n=Array.isArray(e)?[...e]:[],o=Array.isArray(t)?t.map(u=>String(u||"").trim()).filter(Boolean):[];if(!o.length)return n;const s=new Map(n.map(u=>{const p=String((u==null?void 0:u.slug)||"").trim();return p?[p,u]:null}).filter(Boolean)),r=o.map(u=>s.get(u)||null).filter(Boolean),l=n.filter(u=>{const p=String((u==null?void 0:u.slug)||"").trim();return p&&!o.includes(p)});return[...r,...l]}function Tr(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:zs(s.workspaceDiffSummary)};if(!l)return{...s,workspaceDiffSummary:null};const u=n.get(r),p=String((u==null?void 0:u.codexSessionId)||"").trim();return p&&p===l?{...s,workspaceDiffSummary:zs(u.workspaceDiffSummary)}:{...s,workspaceDiffSummary:null}})}function ey(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 u=s.get(l);if(!u)return!0;const p=String((r==null?void 0:r.codexSessionId)||"").trim(),w=String((u==null?void 0:u.codexSessionId)||"").trim();return!!(p!==w||!!(r!=null&&r.running)!=!!(u!=null&&u.running)||p&&!Object.prototype.hasOwnProperty.call(u||{},"workspaceDiffSummary")||p&&(u==null?void 0:u.workspaceDiffSummary)==null)})}function ks(e){if(typeof window>"u")return;const t=String(e||"").trim();if(t){window.localStorage.setItem(Co,t);return}window.localStorage.removeItem(Co)}function ty(){return typeof window>"u"?"":String(window.localStorage.getItem(Co)||"").trim()}function ny(){if(typeof window>"u")return"";try{const e=new URL(window.location.href);return String(e.searchParams.get("task")||"").trim()}catch{return""}}function sy(){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 On(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=zs(e.workspaceDiffSummary)),t}function oy(e={}){const{clearToast:t=()=>{},flashToast:n=()=>{},scrollCurrentPanelToBottom:o=()=>{}}=e,s=Gs(),r=la(),l=j(null),u=j([]),p=j({}),w=j({}),c=j({}),S=j({}),h=j({}),g=j(""),f=j({title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]}),D=j(!0),Z=j(!1),v=j(!1),L=j(!1),F=j(!1),W=j(!1),M=j(""),Y=j(!1),A=j("");let X=null,pe=null,ge=0,E=null,ee=0,ce=null,te=0,ye={};const _=K(()=>Eo(f.value.blocks)),U=K(()=>br({title:f.value.title,autoTitle:f.value.autoTitle,preview:Hv(f.value.blocks)},f.value.blocks));function $(k,T={}){const q=String(k||"").trim();if(!q)return"";const ie=T.summary||Ze(q),re=T.cachedDraft===void 0?Fe(q):T.cachedDraft,Se=q===g.value;return Object.prototype.hasOwnProperty.call(w.value,q)?String(w.value[q]||"").trim():Se?String(f.value.codexSessionId||(ie==null?void 0:ie.codexSessionId)||"").trim():String((re==null?void 0:re.codexSessionId)||(ie==null?void 0:ie.codexSessionId)||"").trim()}const Me=K(()=>$(g.value)),De=K(()=>qv(Ze(g.value),c.value[g.value])),Be=K(()=>De.value!=="idle"),He=K(()=>u.value.some(k=>Hs(k))||Object.values(c.value).some(Boolean)),We=K(()=>Object.values(S.value).some(Boolean)),Ge=j(0),Te=K(()=>Vv(f.value.blocks)),z=K(()=>jt(f.value.todoItems)),ne=K(()=>U.value||Ye("workbench.untitledTask")),he=K(()=>u.value.map(k=>ut(k)));function $e(k=""){return!k||!k.startsWith(s)?k:k.slice(s.length)}function oe(k=""){const T=String(k||"").replace(/\r\n/g,`
55
55
  `).split(`
56
56
  `);for(;T.length&&!String(T[0]||"").trim();)T.shift();for(;T.length&&!String(T[T.length-1]||"").trim();)T.pop();return T.join(`
57
- `)}function Ee(k=[]){return k.map(T=>({id:Number.isInteger(Number(T==null?void 0:T.id))?Number(T.id):null,type:T==null?void 0:T.type,content:(T==null?void 0:T.type)==="image"?$e(T.content):oe(T.content),meta:T!=null&&T.meta?{...T.meta}:{}}))}function _e(k=[]){return(k||[]).map(T=>({id:String((T==null?void 0:T.id)||"").trim(),createdAt:String((T==null?void 0:T.createdAt)||""),blocks:Ee((T==null?void 0:T.blocks)||[])}))}function Re(k=f.value.title,T=f.value.autoTitle,q=f.value.lastPromptPreview,ie=f.value.todoItems,re=f.value.codexSessionId,Se=f.value.blocks){return JSON.stringify({title:String(k||""),autoTitle:String(T||""),lastPromptPreview:String(q||""),todoItems:_e(ie),codexSessionId:String(re||""),blocks:Ee(Se)})}function ot(){return Re()!==A.value}function Ne(){var k,T;return!!((T=(k=l.value)==null?void 0:k.isEditing)!=null&&T.call(k))}function Ze(k){return u.value.find(T=>T.slug===k)||null}function Fe(k){return k&&p.value[k]||null}function Je(k,T=""){const q=String(k||"").trim();q&&(ye={...ye,[q]:String(T||"").trim()})}function Pe(k=""){var re;const T=String(k||"").trim();if(!T)return!1;const q=String(((re=Ze(T))==null?void 0:re.updatedAt)||"").trim(),ie=String(ye[T]||"").trim();return!!(q&&ie&&q===ie)}function ut(k){const T=Fe(k.slug),q=k.slug===g.value?f.value.blocks:(T==null?void 0:T.blocks)||[],ie=k.slug===g.value?f.value.title:(T==null?void 0:T.title)??k.title,re=k.slug===g.value?f.value.autoTitle:(T==null?void 0:T.autoTitle)??k.autoTitle,Se=k.slug===g.value?jt(f.value.todoItems).length:jt((T==null?void 0:T.todoItems)||[]).length||Number(k.todoCount||0),ht=k.slug===g.value?f.value.lastPromptPreview||k.lastPromptPreview||"":(T==null?void 0:T.lastPromptPreview)||k.lastPromptPreview||"",Ue=$(k.slug,{summary:k,cachedDraft:T});return{...k,title:ie,autoTitle:re,todoCount:Se,preview:ht,codexSessionId:Ue,sessionSelectionLocked:!!(Ue&&Number(k.codexRunCount||0)>0),sessionSelectionLockReason:Ue&&Number(k.codexRunCount||0)>0?Ye("taskActions.sessionLocked"):"",displayTitle:br({title:ie,autoTitle:re,preview:ht},q),sending:Hs(k),hasUnreadUpdate:!!S.value[k.slug]}}function rt(k,T={}){const{insertAtStart:q=!1}=T;if(!(k!=null&&k.slug))return;const ie=[...u.value],re=ie.findIndex(Se=>Se.slug===k.slug);if(re>=0){ie.splice(re,1,{...ie[re],...k}),u.value=ie;return}q?ie.unshift(k):ie.push(k),u.value=ie}function Qe(k,T){k&&(p.value={...p.value,[k]:wr(T)})}function _t(k){return k?`${s}/api/tasks/${k}/raw`:`${s}/api/tasks/`}function $t(k=""){const T=String(k||"").trim();if(!T)return;const q=Ze(T),ie=r.getTaskRunChange(T);if(!q||!(ie!=null&&ie.status))return;const re=Kv(ie.status);!!q.running!==re&&rt({...q,running:re})}function C(){return typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus()}function O(k=""){return _a(k,g.value,C())}function se(k=""){S.value=Ca(S.value,k)}function we(){S.value=Xv(S.value,{currentTaskSlug:g.value,pageFocused:C()})}function qe(k=[]){S.value=Yv(S.value,k),h.value=Jv(h.value,k)}function Oe(k=""){const T=String(k||"").trim();if(!T)return;const q=Qv({unreadMap:S.value,notifiedMap:h.value,taskSlug:T,change:r.getTaskRunChange(T),currentTaskSlug:g.value,pageFocused:C(),maxNotifiedRuns:Vs});S.value=q.unreadMap,h.value=q.notifiedMap,q.didMark&&(Ge.value+=1)}function at(k,T){c.value={...c.value,[k]:!!T}}function Xe(k=u.value){const T={};(k||[]).forEach(q=>{q!=null&&q.slug&&(T[q.slug]=!!q.running)}),c.value=T}function ft(k,T){k&&(w.value={...w.value,[k]:String(T||"").trim()})}async function St(k,T){const q=String(k||"").trim();if(!q)return;const ie=String(T||"").trim(),re=Ze(q),Se=w.value[q]||(re==null?void 0:re.codexSessionId)||"";if(!!(Se&&Number((re==null?void 0:re.codexRunCount)||0)>0)&&ie!==Se){M.value=Ye("taskActions.sessionLocked");return}ft(q,ie);const Ue=Fe(q);Ue&&Qe(q,{...Ue,codexSessionId:ie}),re&&rt({...re,codexSessionId:ie,workspaceDiffSummary:ie&&ie===Se?re.workspaceDiffSummary:null}),q===g.value&&(f.value={...f.value,codexSessionId:ie});try{await dl(q,ie)}catch(en){ft(q,Se),Ue&&Qe(q,{...Ue,codexSessionId:Se}),re&&rt({...re,codexSessionId:Se}),q===g.value&&(f.value={...f.value,codexSessionId:Se}),M.value=en.message}}function It(){X&&(window.clearTimeout(X),X=null)}function wt(){E&&(window.clearTimeout(E),E=null)}function zt(){It(),!(Z.value||!g.value)&&(X=window.setTimeout(()=>{fe({auto:!0,silent:!0})},1500))}function Dt(){if(!g.value)return;const k=Ze(g.value)||{slug:g.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};rt({...k,title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoCount:jt(f.value.todoItems).length,codexSessionId:Me.value,preview:String(f.value.lastPromptPreview||"")})}function Ht(k={}){const T=String((k==null?void 0:k.slug)||"").trim();if(!T)return;const q=On(k);rt(q),Je(T,q.updatedAt||k.updatedAt||""),T===g.value&&(Object.prototype.hasOwnProperty.call(k,"title")&&(f.value.title=String(k.title||"")),Object.prototype.hasOwnProperty.call(k,"autoTitle")&&(f.value.autoTitle=String(k.autoTitle||"")),Qe(T,{...f.value}))}function ae(k=[]){const T=new Map((k||[]).map(q=>{const ie=String((q==null?void 0:q.slug)||"").trim();return ie?[ie,zs(q.workspaceDiffSummary)]:null}).filter(Boolean));T.size&&(u.value=u.value.map(q=>T.has(q.slug)?{...q,workspaceDiffSummary:T.get(q.slug)}:q))}async function Ie(k=u.value){const T=Array.isArray(k)?k:[],q=T.filter(re=>String((re==null?void 0:re.codexSessionId)||"").trim()),ie=++ee;if(!q.length){u.value=T.map(re=>Object.prototype.hasOwnProperty.call(re,"workspaceDiffSummary")?re:{...re,workspaceDiffSummary:null});return}try{const re=await Gi(T.length||30);if(ie!==ee)return;ae(re.items||[])}catch{}}async function it(k={}){const{silent:T=!1}=k;T||(D.value=!0,M.value="");try{const q=u.value,ie=await Wi(),re=Tr(q,(ie.items||[]).map(On));u.value=re,qe(re),Xe(re),ey(q,re)&&Ie(re)}catch(q){T||(M.value=q.message)}finally{T||(D.value=!1)}}async function Ct(k=[]){const T=Zv(u.value,k),q=u.value.map(Se=>String((Se==null?void 0:Se.slug)||"").trim()).filter(Boolean),ie=T.map(Se=>String((Se==null?void 0:Se.slug)||"").trim()).filter(Boolean);if(!ie.length||ie.join(",")===q.join(","))return!1;const re=u.value;u.value=T;try{const Se=await Yi(ie);te=Date.now()+Uv;const ht=Tr(re,(Se.items||[]).map(On));return u.value=ht,qe(ht),Xe(ht),!0}catch(Se){return u.value=re,M.value=Se.message,!1}}async function Bt(k=""){const T=String(g.value||"").trim(),q=String(k||"").trim();if(!T)return;if(!u.value.some(re=>re.slug===T)){if(u.value.length){await ue(u.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}g.value="",ks(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=Re("","","",[],"",[]),Y.value=!1;return}q&&q!==T||q&&(Ne()||ot()||Y.value||F.value||W.value||Z.value||await ue(T,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function V(k=""){const T=String(k||"").trim();ce===null?ce=T:ce!==T&&(ce=""),!E&&(E=window.setTimeout(async()=>{const q=ce;ce=null,E=null,await it({silent:!0}),await Bt(q||"")},Fv))}async function J(k){const T=await Or(k),q=(T.blocks||[]).map(re=>({...re,content:re.type==="image"?Cs(re.content):re.content}));return{state:{title:String(T.title||""),autoTitle:String(T.autoTitle||""),lastPromptPreview:String(T.lastPromptPreview||""),codexSessionId:String(T.codexSessionId||""),blocks:q,todoItems:jt(T.todoItems||[])},summary:On({...T,blocks:q}),updatedAt:String(T.updatedAt||"")}}async function ue(k,T={}){const{focusEditor:q=!1,force:ie=!1,skipIfDirtyOnApply:re=!1,skipIfEditingOnApply:Se=!1,scrollPanelToBottom:ht=!1}=T,Ue=String(k||"").trim();if(!Ue)return!1;const en=++ge;Z.value=!0,M.value="",t();try{const Wt=String(g.value||"").trim(),Dn=Fe(Ue),Ln=ie&&Dn&&Pe(Ue);let on=ie&&!Ln?null:Dn,Ut=null;if(!on){const vt=await J(Ue);on=(vt==null?void 0:vt.state)||null,Ut=(vt==null?void 0:vt.summary)||null,Je(Ue,(vt==null?void 0:vt.updatedAt)||(Ut==null?void 0:Ut.updatedAt)||"")}return en!==ge||re&&Ue===g.value&&(ot()||Y.value)||Se&&Ue===g.value&&Ne()?!1:(g.value=Ue,ks(Ue),O(Ue)&&se(Ue),f.value=wr(on),Qe(Ue,on),Ut&&rt(Ut),ft(Ue,on.codexSessionId),A.value=Re(f.value.title,f.value.autoTitle,f.value.lastPromptPreview,f.value.todoItems,f.value.codexSessionId,f.value.blocks),Y.value=!1,q&&dt(()=>{var vt,pn;return(pn=(vt=l.value)==null?void 0:vt.focusEditor)==null?void 0:pn.call(vt)}),(ht||Ue!==Wt)&&o(),!0)}catch(Wt){return en===ge&&(M.value=Wt.message),!1}finally{en===ge&&(Z.value=!1)}}async function fe(k={}){const{auto:T=!1,silent:q=!1}=k;return g.value?Re()===A.value?!0:pe||(It(),F.value=!0,M.value="",pe=(async()=>{try{const re=await Fr(g.value,{title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoItems:jt(f.value.todoItems),codexSessionId:Me.value,expiry:"none",visibility:"private",blocks:Ee(f.value.blocks)}),Se={title:String(re.title||""),autoTitle:String(re.autoTitle||""),lastPromptPreview:String(re.lastPromptPreview||""),todoItems:jt(re.todoItems||f.value.todoItems||[]),codexSessionId:Me.value||String(re.codexSessionId||"").trim(),blocks:vn(f.value.blocks)};return Qe(g.value,Se),A.value=Re(Se.title,Se.autoTitle,Se.lastPromptPreview,Se.todoItems,Se.codexSessionId,Se.blocks),Y.value=!1,rt(On(re)),Je(g.value,re.updatedAt||""),!T&&!q&&n({message:Ye("taskActions.taskSaved"),type:"success"}),!0}catch(re){return M.value=re.message,!1}finally{F.value=!1,pe=null,Re()!==A.value&&(Y.value=!0,zt())}})(),pe):!1}async function Ve(){return W.value?(M.value=Ye("taskActions.fileProcessing"),!1):pe||(Y.value?fe({auto:!1,silent:!0}):!0)}async function Et(){if(!await Ve()&&g.value)return!1;v.value=!0,M.value="";try{const k=await Xi({title:"",expiry:"none",visibility:"private"}),T={title:String(k.title||""),autoTitle:String(k.autoTitle||""),lastPromptPreview:String(k.lastPromptPreview||""),codexSessionId:String(k.codexSessionId||""),blocks:vn(k.blocks||[]),todoItems:jt(k.todoItems||[])};return Qe(k.slug,T),rt(On(k),{insertAtStart:!0}),await ue(k.slug,{focusEditor:!0}),n({message:Ye("taskActions.taskCreated"),type:"success"}),!0}catch(k){return M.value=k.message,!1}finally{v.value=!1}}async function Zt(k){const T=String(k||"").trim();!T||T===g.value||!await Ve()||await ue(T)}async function mt(){if(g.value){L.value=!0,M.value="";try{const k=g.value;await Ji(k),u.value=u.value.filter(re=>re.slug!==k);const T={...p.value};delete T[k],p.value=T;const q={...w.value};delete q[k],w.value=q;const ie={...c.value};delete ie[k],c.value=ie,se(k),u.value.length?await ue(u.value[0].slug,{focusEditor:!0}):(g.value="",ks(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=Re("","","",[],"",[]),Y.value=!1,await Et())}catch(k){M.value=k.message}finally{L.value=!1}}}function Ft(k={}){const{silent:T=!1}=k;g.value&&(f.value={...f.value,blocks:xr()},Qe(g.value,f.value),Dt(),Y.value=!0,dt(()=>{var q,ie;(ie=(q=l.value)==null?void 0:q.focusEditor)==null||ie.call(q)}),T||n({message:Ye("taskActions.taskCleared"),type:"info"}))}function bt(){if(!g.value)return!1;const k=Ta(f.value.blocks);return k.length?(f.value={...f.value,blocks:xr(),todoItems:[{id:zv(),createdAt:new Date().toISOString(),blocks:k},...jt(f.value.todoItems)]},Qe(g.value,f.value),Dt(),Y.value=!0,dt(()=>{var T,q;(q=(T=l.value)==null?void 0:T.focusEditor)==null||q.call(T)}),n({message:Ye("taskActions.todoAdded"),type:"success"}),!0):!1}function sn(k=""){const T=String(k||"").trim();if(!g.value||!T)return!1;const q=jt(f.value.todoItems).filter(ie=>ie.id!==T);return q.length===jt(f.value.todoItems).length?!1:(f.value={...f.value,todoItems:q},Qe(g.value,f.value),Dt(),Y.value=!0,!0)}function dn(k=""){const T=String(k||"").trim();if(!g.value||!T)return null;const q=jt(f.value.todoItems).find(ie=>ie.id===T);return q?(f.value={...f.value,blocks:vn(q.blocks),todoItems:jt(f.value.todoItems).filter(ie=>ie.id!==T)},Qe(g.value,f.value),Dt(),Y.value=!0,dt(()=>{var ie,re;(re=(ie=l.value)==null?void 0:ie.focusEditor)==null||re.call(ie)}),q):null}async function fn(){var re;if(await it(),!u.value.length){await Et();return}const k=ny();if(k){const Se=await ue(k,{focusEditor:!0,force:!0});if(sy(),Se)return}const T=((re=u.value.find(Se=>!!(Se!=null&&Se.running)))==null?void 0:re.slug)||"",q=ty(),ie=T||(u.value.some(Se=>Se.slug===q)?q:u.value[0].slug);await ue(ie,{focusEditor:!0,force:!0})}async function qt(k){var T,q,ie;W.value=!0,M.value="";try{const re=((q=(T=l.value)==null?void 0:T.isImportedBlockActive)==null?void 0:q.call(T))||!1,Se=[];for(const ht of k){const Ue=await Qi(ht);Se.push({type:"image",content:Cs(Ue.url),meta:{}})}(ie=l.value)==null||ie.insertUploadedBlocks(Se),n({message:Ye("taskActions.imageInserted",{count:Se.length,appended:re}),type:"success"})}catch(re){M.value=re.message}finally{W.value=!1}}async function Kt(k){var T,q,ie;M.value="";try{const re=((q=(T=l.value)==null?void 0:T.isImportedBlockActive)==null?void 0:q.call(T))||!1,Se=[];for(const ht of k){const Ue=await ht.text();Ue.trim()&&Se.push({type:"imported_text",content:Ue,meta:{fileName:ht.name||Ye("workbench.untitledTask"),collapsed:!0}})}if(!Se.length){n({message:Ye("taskActions.noTextImported"),type:"warning"});return}(ie=l.value)==null||ie.insertImportedBlocks(Se),n({message:Ye("taskActions.importedBlocksInserted",{count:Se.length,appended:re}),type:"success"})}catch{M.value=Ye("taskActions.textImportFailed")}}async function Pt(k){var T;W.value=!0,M.value="";try{let q=0,ie=0;for(const re of k){const Se=await Zi(re),ht=(Se.blocks||[]).map(Ue=>({...Ue,content:Ue.type==="image"?Cs(Ue.content):Ue.content}));ht.length&&((T=l.value)==null||T.insertBlocks(ht),q+=ht.length,ie+=Number(Se.pageCount||0))}if(!q){n({message:Ye("taskActions.noPdfContent"),type:"warning"});return}n({message:Ye("taskActions.pdfBlocksInserted",{blockCount:q,pageCount:ie}),type:"success"})}catch(q){M.value=q.message||Ye("taskActions.pdfImportFailed")}finally{W.value=!1}}function I(k){const T=k===g.value?f.value:Fe(k);return T?Ov({title:String(T.title||""),blocks:Ee(T.blocks||[])},_t(k)):""}function Q(k){const T=k===g.value?f.value:Fe(k);return T?vn(Ee(T.blocks||[])):[]}async function H(k){return W.value?(M.value=Ye("taskActions.fileProcessingBeforeSend"),!1):k!==g.value?!0:F.value&&pe?pe:Y.value?fe({auto:!1,silent:!0}):!0}async function Ce(k){return await H(k)?I(k):""}function Xt(k,T){const q=kr(T);!q||k!==g.value||(f.value.lastPromptPreview=q,Qe(g.value,f.value),Dt())}return Le(f,()=>{if(Z.value||!g.value)return;const k=Eo(f.value.blocks);!String(f.value.title||"").trim()&&k&&k!==f.value.autoTitle&&(f.value.autoTitle=k),Qe(g.value,f.value),Y.value=Re()!==A.value,Dt(),Y.value&&!F.value&&zt()},{deep:!0}),Le(g,k=>{k&&(ks(k),we())}),cn(()=>{typeof window>"u"||(window.addEventListener("focus",we),document.addEventListener("visibilitychange",we))}),Mt(()=>{It(),wt(),typeof window<"u"&&(window.removeEventListener("focus",we),document.removeEventListener("visibilitychange",we))}),Le(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<te||(Oe(r.listSyncTaskSlug.value),$t(r.listSyncTaskSlug.value),V(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:bt,applyTaskSettingsUpdate:Ht,buildPromptForTask:I,getPromptBlocksForTask:Q,buildPromptPreview:kr,clearCurrentTaskContent:Ft,createTaskAndSelect:Et,currentProjectSessionId:Me,currentTaskSendState:De,currentTaskAutoTitle:_,currentTaskDisplayTitle:U,currentTaskSlug:g,draft:f,editorRef:l,error:M,handleImportPdfFiles:Pt,handleImportTextFiles:Kt,handleTaskSendingChange:at,handleTaskSessionChange:St,handleUpload:qt,hasCurrentDraftContent:Te,hasAnyTaskSending:He,hasUnsavedChanges:Y,hasUnreadTaskUpdates:We,initializeWorkbench:fn,isCurrentTaskSending:Be,loadingTask:Z,loadingTasks:D,pageTitle:ne,prepareCodexPromptForTask:Ce,currentTodoItems:z,removeTodoItem:sn,removeCurrentTask:mt,reorderTaskList:Ct,removingTask:L,renderedTasks:he,refreshTaskList:it,saveTask:fe,saving:F,selectTask:Zt,selectedSessionMap:w,sendingTaskMap:c,taskDraftMap:p,tasks:u,unreadNotificationVersion:Ge,useTodoItem:dn,updateLastPromptPreview:Xt,uploading:W,creatingTask:v}}const ry={class:"flex h-full min-h-0 flex-col overflow-hidden"},ay={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"},iy={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},ly={class:"min-h-0 min-w-0 overflow-hidden"},uy={class:"min-h-0 min-w-0 overflow-hidden"},cy={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},dy={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},fy={class:"flex flex-col gap-2"},py={class:"min-h-0 flex-1 overflow-hidden"},my={key:1,class:"min-h-0 flex-1 overflow-hidden"},gy={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},hy={class:"workbench-mobile-tabs-panel shrink-0"},vy={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},yy={class:"min-h-0 flex-1 overflow-hidden"},Sy={class:"h-full min-h-0"},wy={class:"h-full min-h-0"},xy={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},by={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},ky={class:"flex flex-col gap-2"},Ty={class:"min-h-0 flex-1 overflow-hidden"},_y="/sounds/notify-didi.wav?v=20260420-1",Cy=3e3,Ey={__name:"WorkbenchView",setup(e){const t=j(!1),n=j(!1),o=j(!1),s=j(!1),r=j(!1),l=j(!1),u=j(!1),p=j(!1),w=j(""),c=j(""),S=j(""),h=j(0),g=j("workspace"),f=j(""),{t:D}=Tt(),{toastMessage:Z,toastType:v,flashToast:L,clearToast:F}=Mv(),{notificationSoundEnabled:W,sendBehavior:M}=Ia(),Y=yo(()=>Ke(()=>import("./TaskDiffReviewDialog-GOruDINI.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),A=yo(()=>Ke(()=>import("./WorkbenchSettingsDialog-BYYiMjvq.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),X=j(null),pe=j([]),ge=j({});let E=null,ee=!1,ce=0;function te(y="",G=pe.value){const ve=String(y||"").trim();return ve&&G.some(xe=>(xe==null?void 0:xe.engine)===ve)?ve:""}function ye(y=pe.value){var G,ve;return((G=y.find(xe=>xe==null?void 0:xe.isDefault))==null?void 0:G.engine)||((ve=y[0])==null?void 0:ve.engine)||""}const _=K({get(){const y=String(z.value||"").trim();return y?te(ge.value[y])||ye():""},set(y){const G=String(z.value||"").trim(),ve=te(y);!G||!ve||(ge.value={...ge.value,[G]:ve})}});function U(y){return y?X.value:null}function $(){dt(()=>{var y,G;(G=(y=U(oe.value))==null?void 0:y.scrollToBottom)==null||G.call(y)})}const{addCurrentDraftToTodo:Me,applyTaskSettingsUpdate:De,buildPromptForTask:Be,getPromptBlocksForTask:He,clearCurrentTaskContent:We,createTaskAndSelect:Ge,creatingTask:Te,currentProjectSessionId:z,currentTaskSendState:ne,currentTaskAutoTitle:he,currentTaskDisplayTitle:$e,currentTaskSlug:oe,draft:Ee,editorRef:_e,error:Re,handleImportPdfFiles:ot,handleImportTextFiles:Ne,handleTaskSendingChange:Ze,handleTaskSessionChange:Fe,handleUpload:Je,hasCurrentDraftContent:Pe,hasUnsavedChanges:ut,hasUnreadTaskUpdates:rt,initializeWorkbench:Qe,isCurrentTaskSending:_t,loadingTask:$t,loadingTasks:C,pageTitle:O,prepareCodexPromptForTask:se,currentTodoItems:we,removeTodoItem:qe,removeCurrentTask:Oe,reorderTaskList:at,removingTask:Xe,renderedTasks:ft,saveTask:St,saving:It,selectTask:wt,unreadNotificationVersion:zt,updateLastPromptPreview:Dt,useTodoItem:Ht,uploading:ae}=oy({clearToast:F,flashToast:L,scrollCurrentPanelToBottom:$}),Ie=K(()=>ft.value.find(y=>y.slug===oe.value)||null),it=K(()=>rt.value?D("workbench.newMessageTitle"):O.value),Ct=K(()=>rt.value),Bt=K(()=>{var y,G;return!!((G=(y=Ie.value)==null?void 0:y.workspaceDiffSummary)!=null&&G.supported)}),V=K(()=>{const y=Ie.value;return y?()=>se(y.slug):null}),J=K(()=>{const y=Ie.value;return y?()=>He(y.slug):null}),ue=K(()=>({creatingTask:Te.value,currentTaskAutoTitle:Ee.value.autoTitle||he.value,currentTaskSlug:oe.value,draftTitle:Ee.value.title,editingTaskTitleSlug:S.value,error:Re.value,isCurrentTaskSending:_t.value,loadingTask:$t.value,loadingTasks:C.value,removingTask:Xe.value,tasks:ft.value,uploading:ae.value})),fe=K(()=>{var y,G,ve,xe;return{buildPromptBlocks:J.value,buildPrompt:V.value,diffSupported:Bt.value,selectedAgentEngine:_.value,selectedSessionId:z.value,sessionSelectionLockReason:((y=Ie.value)==null?void 0:y.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((G=Ie.value)!=null&&G.sessionSelectionLocked),taskSlug:((ve=Ie.value)==null?void 0:ve.slug)||"",taskRunning:!!((xe=Ie.value)!=null&&xe.running)}}),Ve=K(()=>({codexSessionId:z.value,sendBehavior:M.value,loading:$t.value})),Et=K(()=>({currentTaskAutoTitle:Ee.value.autoTitle||he.value,currentTaskSlug:oe.value,editingTaskTitleSlug:S.value,title:$e.value,titleInputValue:Ee.value.title})),{enterMobileDetail:Zt,isMobileLayout:mt,leaveMobileDetail:Ft,mobileDetailTab:bt,mobileView:sn}=Iv({currentTaskSlug:oe});function dn(y){return y!=null&&y.sending||Number((y==null?void 0:y.codexRunCount)||0)>0?"activity":"input"}Dv(it,{raw:Ct});function fn(){return typeof window>"u"?null:(E||(E=new Audio(_y),E.preload="auto",E.volume=.7),E)}function qt(){if(!W.value)return;const y=fn();if(!(!y||ee))try{y.muted=!0;const G=y.play();if(G&&typeof G.then=="function"){G.then(()=>{y.pause(),y.currentTime=0,y.muted=!1,ee=!0}).catch(()=>{y.muted=!1});return}y.pause(),y.currentTime=0,y.muted=!1,ee=!0}catch{y.muted=!1}}function Kt(){qt()}function Pt(){const y=fn();if(!y||!W.value)return;const G=Date.now();if(!(G-ce<Cy)){ce=G;try{y.muted=!1,y.currentTime=0,y.play().catch(()=>{})}catch{}}}function I(y="workspace",G=""){g.value=y==="run"?"run":y==="task"?"task":"workspace",f.value=g.value==="run"?String(G||""):"",o.value=!0,h.value+=1}function Q(){o.value=!1}function H(){s.value=!0}function Ce(){s.value=!1}function Xt(){oe.value&&(r.value=!0)}function k(){r.value=!1}function T(){l.value=!0}function q(){l.value=!1,ie(),re()}function ie(){u.value=!1,w.value=""}function re(){p.value=!1,c.value=""}function Se(y){De(y)}function ht(y){Ee.value.title=y}async function Ue(){S.value="",ut.value&&await St({auto:!1,silent:!0})}function en(y){y===oe.value&&(S.value=y,dt(()=>{var ve,xe;const G=document.querySelector('[data-task-title-input="current"]');(ve=G==null?void 0:G.focus)==null||ve.call(G),(xe=G==null?void 0:G.select)==null||xe.call(G)}))}async function Wt(y){if(mt.value){await Rn(y);return}if(y!==oe.value){await Rn(y);return}en(y)}function Dn(){n.value=!0}function Ln(){Xe.value||(n.value=!1)}async function on(){await Oe(),n.value=!1,mt.value&&Ft({useHistory:!1})}function Ut(){t.value=!0}function vt(){t.value=!1}function pn(){t.value=!1,We()}function Xn(y){const G=Ie.value;G&&Ze(G.slug,y)}function tn(y){const G=Ie.value;G&&Fe(G.slug,y)}function Ys(y={}){const G=String((y==null?void 0:y.sessionId)||"").trim(),ve=z.value;if(G&&G!==ve)return;const xe=Array.isArray(y==null?void 0:y.bindings)?y.bindings:[];pe.value=xe;const et=te(ge.value[ve],xe)||te(y==null?void 0:y.selectedEngine,xe)||ye(xe);et&&(_.value=et)}Le(z,(y,G)=>{String(y||"").trim()!==String(G||"").trim()&&(pe.value=[])});function Mn(y){_.value=y}function Bn(y){L(y),!(!mt.value||!oe.value)&&(bt.value="activity")}async function Yt(){var y,G,ve,xe,et,yt,Rt,rn;typeof document<"u"&&((G=(y=_e.value)==null?void 0:y.isComposing)!=null&&G.call(y))&&((xe=(ve=document.activeElement)==null?void 0:ve.blur)==null||xe.call(ve)),(yt=(et=_e.value)==null?void 0:et.flushPendingInput)==null||yt.call(et),await dt(),(rn=(Rt=_e.value)==null?void 0:Rt.flushPendingInput)==null||rn.call(Rt),await dt()}async function gs(){await Yt(),await navigator.clipboard.writeText(Be(oe.value)),L({message:D("workbench.promptCopied"),type:"info"})}async function Js(){await Ge()&&mt.value&&(bt.value="input",Zt())}async function Rn(y){const G=String(y||"").trim();G&&(G!==oe.value&&await wt(G),mt.value&&oe.value===G&&(bt.value=dn(Ie.value),Zt()))}async function Qs(y=[]){await at(y)}async function Sn(){await Yt(),Me()}function Yn(y={}){const G=String((y==null?void 0:y.rangeLabel)||"").trim();if(G)return G;const ve=Math.max(0,Number(y==null?void 0:y.lineStart)||0),xe=Math.max(0,Number(y==null?void 0:y.lineEnd)||0);return ve&&xe&&ve!==xe?`L${ve}-L${xe}`:ve||xe?`L${ve||xe}`:""}function Jn(y=""){return`code-context-${String(y||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function wn(y={}){const G=String((y==null?void 0:y.filePath)||"").trim(),ve=String((y==null?void 0:y.content)||"").replace(/\r\n/g,`
57
+ `)}function Ee(k=[]){return k.map(T=>({id:Number.isInteger(Number(T==null?void 0:T.id))?Number(T.id):null,type:T==null?void 0:T.type,content:(T==null?void 0:T.type)==="image"?$e(T.content):oe(T.content),meta:T!=null&&T.meta?{...T.meta}:{}}))}function _e(k=[]){return(k||[]).map(T=>({id:String((T==null?void 0:T.id)||"").trim(),createdAt:String((T==null?void 0:T.createdAt)||""),blocks:Ee((T==null?void 0:T.blocks)||[])}))}function Re(k=f.value.title,T=f.value.autoTitle,q=f.value.lastPromptPreview,ie=f.value.todoItems,re=f.value.codexSessionId,Se=f.value.blocks){return JSON.stringify({title:String(k||""),autoTitle:String(T||""),lastPromptPreview:String(q||""),todoItems:_e(ie),codexSessionId:String(re||""),blocks:Ee(Se)})}function ot(){return Re()!==A.value}function Ne(){var k,T;return!!((T=(k=l.value)==null?void 0:k.isEditing)!=null&&T.call(k))}function Ze(k){return u.value.find(T=>T.slug===k)||null}function Fe(k){return k&&p.value[k]||null}function Je(k,T=""){const q=String(k||"").trim();q&&(ye={...ye,[q]:String(T||"").trim()})}function Pe(k=""){var re;const T=String(k||"").trim();if(!T)return!1;const q=String(((re=Ze(T))==null?void 0:re.updatedAt)||"").trim(),ie=String(ye[T]||"").trim();return!!(q&&ie&&q===ie)}function ut(k){const T=Fe(k.slug),q=k.slug===g.value?f.value.blocks:(T==null?void 0:T.blocks)||[],ie=k.slug===g.value?f.value.title:(T==null?void 0:T.title)??k.title,re=k.slug===g.value?f.value.autoTitle:(T==null?void 0:T.autoTitle)??k.autoTitle,Se=k.slug===g.value?jt(f.value.todoItems).length:jt((T==null?void 0:T.todoItems)||[]).length||Number(k.todoCount||0),ht=k.slug===g.value?f.value.lastPromptPreview||k.lastPromptPreview||"":(T==null?void 0:T.lastPromptPreview)||k.lastPromptPreview||"",Ue=$(k.slug,{summary:k,cachedDraft:T});return{...k,title:ie,autoTitle:re,todoCount:Se,preview:ht,codexSessionId:Ue,sessionSelectionLocked:!!(Ue&&Number(k.codexRunCount||0)>0),sessionSelectionLockReason:Ue&&Number(k.codexRunCount||0)>0?Ye("taskActions.sessionLocked"):"",displayTitle:br({title:ie,autoTitle:re,preview:ht},q),sending:Hs(k),hasUnreadUpdate:!!S.value[k.slug]}}function rt(k,T={}){const{insertAtStart:q=!1}=T;if(!(k!=null&&k.slug))return;const ie=[...u.value],re=ie.findIndex(Se=>Se.slug===k.slug);if(re>=0){ie.splice(re,1,{...ie[re],...k}),u.value=ie;return}q?ie.unshift(k):ie.push(k),u.value=ie}function Qe(k,T){k&&(p.value={...p.value,[k]:wr(T)})}function _t(k){return k?`${s}/api/tasks/${k}/raw`:`${s}/api/tasks/`}function $t(k=""){const T=String(k||"").trim();if(!T)return;const q=Ze(T),ie=r.getTaskRunChange(T);if(!q||!(ie!=null&&ie.status))return;const re=Kv(ie.status);!!q.running!==re&&rt({...q,running:re})}function C(){return typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus()}function O(k=""){return _a(k,g.value,C())}function se(k=""){S.value=Ca(S.value,k)}function we(){S.value=Xv(S.value,{currentTaskSlug:g.value,pageFocused:C()})}function qe(k=[]){S.value=Yv(S.value,k),h.value=Jv(h.value,k)}function Oe(k=""){const T=String(k||"").trim();if(!T)return;const q=Qv({unreadMap:S.value,notifiedMap:h.value,taskSlug:T,change:r.getTaskRunChange(T),currentTaskSlug:g.value,pageFocused:C(),maxNotifiedRuns:Vs});S.value=q.unreadMap,h.value=q.notifiedMap,q.didMark&&(Ge.value+=1)}function at(k,T){c.value={...c.value,[k]:!!T}}function Xe(k=u.value){const T={};(k||[]).forEach(q=>{q!=null&&q.slug&&(T[q.slug]=!!q.running)}),c.value=T}function ft(k,T){k&&(w.value={...w.value,[k]:String(T||"").trim()})}async function St(k,T){const q=String(k||"").trim();if(!q)return;const ie=String(T||"").trim(),re=Ze(q),Se=w.value[q]||(re==null?void 0:re.codexSessionId)||"";if(!!(Se&&Number((re==null?void 0:re.codexRunCount)||0)>0)&&ie!==Se){M.value=Ye("taskActions.sessionLocked");return}ft(q,ie);const Ue=Fe(q);Ue&&Qe(q,{...Ue,codexSessionId:ie}),re&&rt({...re,codexSessionId:ie,workspaceDiffSummary:ie&&ie===Se?re.workspaceDiffSummary:null}),q===g.value&&(f.value={...f.value,codexSessionId:ie});try{await dl(q,ie)}catch(en){ft(q,Se),Ue&&Qe(q,{...Ue,codexSessionId:Se}),re&&rt({...re,codexSessionId:Se}),q===g.value&&(f.value={...f.value,codexSessionId:Se}),M.value=en.message}}function It(){X&&(window.clearTimeout(X),X=null)}function wt(){E&&(window.clearTimeout(E),E=null)}function zt(){It(),!(Z.value||!g.value)&&(X=window.setTimeout(()=>{fe({auto:!0,silent:!0})},1500))}function Dt(){if(!g.value)return;const k=Ze(g.value)||{slug:g.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};rt({...k,title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoCount:jt(f.value.todoItems).length,codexSessionId:Me.value,preview:String(f.value.lastPromptPreview||"")})}function Ht(k={}){const T=String((k==null?void 0:k.slug)||"").trim();if(!T)return;const q=On(k);rt(q),Je(T,q.updatedAt||k.updatedAt||""),T===g.value&&(Object.prototype.hasOwnProperty.call(k,"title")&&(f.value.title=String(k.title||"")),Object.prototype.hasOwnProperty.call(k,"autoTitle")&&(f.value.autoTitle=String(k.autoTitle||"")),Qe(T,{...f.value}))}function ae(k=[]){const T=new Map((k||[]).map(q=>{const ie=String((q==null?void 0:q.slug)||"").trim();return ie?[ie,zs(q.workspaceDiffSummary)]:null}).filter(Boolean));T.size&&(u.value=u.value.map(q=>T.has(q.slug)?{...q,workspaceDiffSummary:T.get(q.slug)}:q))}async function Ie(k=u.value){const T=Array.isArray(k)?k:[],q=T.filter(re=>String((re==null?void 0:re.codexSessionId)||"").trim()),ie=++ee;if(!q.length){u.value=T.map(re=>Object.prototype.hasOwnProperty.call(re,"workspaceDiffSummary")?re:{...re,workspaceDiffSummary:null});return}try{const re=await Gi(T.length||30);if(ie!==ee)return;ae(re.items||[])}catch{}}async function it(k={}){const{silent:T=!1}=k;T||(D.value=!0,M.value="");try{const q=u.value,ie=await Wi(),re=Tr(q,(ie.items||[]).map(On));u.value=re,qe(re),Xe(re),ey(q,re)&&Ie(re)}catch(q){T||(M.value=q.message)}finally{T||(D.value=!1)}}async function Ct(k=[]){const T=Zv(u.value,k),q=u.value.map(Se=>String((Se==null?void 0:Se.slug)||"").trim()).filter(Boolean),ie=T.map(Se=>String((Se==null?void 0:Se.slug)||"").trim()).filter(Boolean);if(!ie.length||ie.join(",")===q.join(","))return!1;const re=u.value;u.value=T;try{const Se=await Yi(ie);te=Date.now()+Uv;const ht=Tr(re,(Se.items||[]).map(On));return u.value=ht,qe(ht),Xe(ht),!0}catch(Se){return u.value=re,M.value=Se.message,!1}}async function Bt(k=""){const T=String(g.value||"").trim(),q=String(k||"").trim();if(!T)return;if(!u.value.some(re=>re.slug===T)){if(u.value.length){await ue(u.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}g.value="",ks(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=Re("","","",[],"",[]),Y.value=!1;return}q&&q!==T||q&&(Ne()||ot()||Y.value||F.value||W.value||Z.value||await ue(T,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function V(k=""){const T=String(k||"").trim();ce===null?ce=T:ce!==T&&(ce=""),!E&&(E=window.setTimeout(async()=>{const q=ce;ce=null,E=null,await it({silent:!0}),await Bt(q||"")},Fv))}async function J(k){const T=await Or(k),q=(T.blocks||[]).map(re=>({...re,content:re.type==="image"?Cs(re.content):re.content}));return{state:{title:String(T.title||""),autoTitle:String(T.autoTitle||""),lastPromptPreview:String(T.lastPromptPreview||""),codexSessionId:String(T.codexSessionId||""),blocks:q,todoItems:jt(T.todoItems||[])},summary:On({...T,blocks:q}),updatedAt:String(T.updatedAt||"")}}async function ue(k,T={}){const{focusEditor:q=!1,force:ie=!1,skipIfDirtyOnApply:re=!1,skipIfEditingOnApply:Se=!1,scrollPanelToBottom:ht=!1}=T,Ue=String(k||"").trim();if(!Ue)return!1;const en=++ge;Z.value=!0,M.value="",t();try{const Wt=String(g.value||"").trim(),Dn=Fe(Ue),Ln=ie&&Dn&&Pe(Ue);let on=ie&&!Ln?null:Dn,Ut=null;if(!on){const vt=await J(Ue);on=(vt==null?void 0:vt.state)||null,Ut=(vt==null?void 0:vt.summary)||null,Je(Ue,(vt==null?void 0:vt.updatedAt)||(Ut==null?void 0:Ut.updatedAt)||"")}return en!==ge||re&&Ue===g.value&&(ot()||Y.value)||Se&&Ue===g.value&&Ne()?!1:(g.value=Ue,ks(Ue),O(Ue)&&se(Ue),f.value=wr(on),Qe(Ue,on),Ut&&rt(Ut),ft(Ue,on.codexSessionId),A.value=Re(f.value.title,f.value.autoTitle,f.value.lastPromptPreview,f.value.todoItems,f.value.codexSessionId,f.value.blocks),Y.value=!1,q&&dt(()=>{var vt,pn;return(pn=(vt=l.value)==null?void 0:vt.focusEditor)==null?void 0:pn.call(vt)}),(ht||Ue!==Wt)&&o(),!0)}catch(Wt){return en===ge&&(M.value=Wt.message),!1}finally{en===ge&&(Z.value=!1)}}async function fe(k={}){const{auto:T=!1,silent:q=!1}=k;return g.value?Re()===A.value?!0:pe||(It(),F.value=!0,M.value="",pe=(async()=>{try{const re=await Fr(g.value,{title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoItems:jt(f.value.todoItems),codexSessionId:Me.value,expiry:"none",visibility:"private",blocks:Ee(f.value.blocks)}),Se={title:String(re.title||""),autoTitle:String(re.autoTitle||""),lastPromptPreview:String(re.lastPromptPreview||""),todoItems:jt(re.todoItems||f.value.todoItems||[]),codexSessionId:Me.value||String(re.codexSessionId||"").trim(),blocks:vn(f.value.blocks)};return Qe(g.value,Se),A.value=Re(Se.title,Se.autoTitle,Se.lastPromptPreview,Se.todoItems,Se.codexSessionId,Se.blocks),Y.value=!1,rt(On(re)),Je(g.value,re.updatedAt||""),!T&&!q&&n({message:Ye("taskActions.taskSaved"),type:"success"}),!0}catch(re){return M.value=re.message,!1}finally{F.value=!1,pe=null,Re()!==A.value&&(Y.value=!0,zt())}})(),pe):!1}async function Ve(){return W.value?(M.value=Ye("taskActions.fileProcessing"),!1):pe||(Y.value?fe({auto:!1,silent:!0}):!0)}async function Et(){if(!await Ve()&&g.value)return!1;v.value=!0,M.value="";try{const k=await Xi({title:"",expiry:"none",visibility:"private"}),T={title:String(k.title||""),autoTitle:String(k.autoTitle||""),lastPromptPreview:String(k.lastPromptPreview||""),codexSessionId:String(k.codexSessionId||""),blocks:vn(k.blocks||[]),todoItems:jt(k.todoItems||[])};return Qe(k.slug,T),rt(On(k),{insertAtStart:!0}),await ue(k.slug,{focusEditor:!0}),n({message:Ye("taskActions.taskCreated"),type:"success"}),!0}catch(k){return M.value=k.message,!1}finally{v.value=!1}}async function Zt(k){const T=String(k||"").trim();!T||T===g.value||!await Ve()||await ue(T)}async function mt(){if(g.value){L.value=!0,M.value="";try{const k=g.value;await Ji(k),u.value=u.value.filter(re=>re.slug!==k);const T={...p.value};delete T[k],p.value=T;const q={...w.value};delete q[k],w.value=q;const ie={...c.value};delete ie[k],c.value=ie,se(k),u.value.length?await ue(u.value[0].slug,{focusEditor:!0}):(g.value="",ks(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=Re("","","",[],"",[]),Y.value=!1,await Et())}catch(k){M.value=k.message}finally{L.value=!1}}}function Ft(k={}){const{silent:T=!1}=k;g.value&&(f.value={...f.value,blocks:xr()},Qe(g.value,f.value),Dt(),Y.value=!0,dt(()=>{var q,ie;(ie=(q=l.value)==null?void 0:q.focusEditor)==null||ie.call(q)}),T||n({message:Ye("taskActions.taskCleared"),type:"info"}))}function bt(){if(!g.value)return!1;const k=Ta(f.value.blocks);return k.length?(f.value={...f.value,blocks:xr(),todoItems:[{id:zv(),createdAt:new Date().toISOString(),blocks:k},...jt(f.value.todoItems)]},Qe(g.value,f.value),Dt(),Y.value=!0,dt(()=>{var T,q;(q=(T=l.value)==null?void 0:T.focusEditor)==null||q.call(T)}),n({message:Ye("taskActions.todoAdded"),type:"success"}),!0):!1}function sn(k=""){const T=String(k||"").trim();if(!g.value||!T)return!1;const q=jt(f.value.todoItems).filter(ie=>ie.id!==T);return q.length===jt(f.value.todoItems).length?!1:(f.value={...f.value,todoItems:q},Qe(g.value,f.value),Dt(),Y.value=!0,!0)}function dn(k=""){const T=String(k||"").trim();if(!g.value||!T)return null;const q=jt(f.value.todoItems).find(ie=>ie.id===T);return q?(f.value={...f.value,blocks:vn(q.blocks),todoItems:jt(f.value.todoItems).filter(ie=>ie.id!==T)},Qe(g.value,f.value),Dt(),Y.value=!0,dt(()=>{var ie,re;(re=(ie=l.value)==null?void 0:ie.focusEditor)==null||re.call(ie)}),q):null}async function fn(){var re;if(await it(),!u.value.length){await Et();return}const k=ny();if(k){const Se=await ue(k,{focusEditor:!0,force:!0});if(sy(),Se)return}const T=((re=u.value.find(Se=>!!(Se!=null&&Se.running)))==null?void 0:re.slug)||"",q=ty(),ie=T||(u.value.some(Se=>Se.slug===q)?q:u.value[0].slug);await ue(ie,{focusEditor:!0,force:!0})}async function qt(k){var T,q,ie;W.value=!0,M.value="";try{const re=((q=(T=l.value)==null?void 0:T.isImportedBlockActive)==null?void 0:q.call(T))||!1,Se=[];for(const ht of k){const Ue=await Qi(ht);Se.push({type:"image",content:Cs(Ue.url),meta:{}})}(ie=l.value)==null||ie.insertUploadedBlocks(Se),n({message:Ye("taskActions.imageInserted",{count:Se.length,appended:re}),type:"success"})}catch(re){M.value=re.message}finally{W.value=!1}}async function Kt(k){var T,q,ie;M.value="";try{const re=((q=(T=l.value)==null?void 0:T.isImportedBlockActive)==null?void 0:q.call(T))||!1,Se=[];for(const ht of k){const Ue=await ht.text();Ue.trim()&&Se.push({type:"imported_text",content:Ue,meta:{fileName:ht.name||Ye("workbench.untitledTask"),collapsed:!0}})}if(!Se.length){n({message:Ye("taskActions.noTextImported"),type:"warning"});return}(ie=l.value)==null||ie.insertImportedBlocks(Se),n({message:Ye("taskActions.importedBlocksInserted",{count:Se.length,appended:re}),type:"success"})}catch{M.value=Ye("taskActions.textImportFailed")}}async function Pt(k){var T;W.value=!0,M.value="";try{let q=0,ie=0;for(const re of k){const Se=await Zi(re),ht=(Se.blocks||[]).map(Ue=>({...Ue,content:Ue.type==="image"?Cs(Ue.content):Ue.content}));ht.length&&((T=l.value)==null||T.insertBlocks(ht),q+=ht.length,ie+=Number(Se.pageCount||0))}if(!q){n({message:Ye("taskActions.noPdfContent"),type:"warning"});return}n({message:Ye("taskActions.pdfBlocksInserted",{blockCount:q,pageCount:ie}),type:"success"})}catch(q){M.value=q.message||Ye("taskActions.pdfImportFailed")}finally{W.value=!1}}function I(k){const T=k===g.value?f.value:Fe(k);return T?Ov({title:String(T.title||""),blocks:Ee(T.blocks||[])},_t(k)):""}function Q(k){const T=k===g.value?f.value:Fe(k);return T?vn(Ee(T.blocks||[])):[]}async function H(k){return W.value?(M.value=Ye("taskActions.fileProcessingBeforeSend"),!1):k!==g.value?!0:F.value&&pe?pe:Y.value?fe({auto:!1,silent:!0}):!0}async function Ce(k){return await H(k)?I(k):""}function Xt(k,T){const q=kr(T);!q||k!==g.value||(f.value.lastPromptPreview=q,Qe(g.value,f.value),Dt())}return Le(f,()=>{if(Z.value||!g.value)return;const k=Eo(f.value.blocks);!String(f.value.title||"").trim()&&k&&k!==f.value.autoTitle&&(f.value.autoTitle=k),Qe(g.value,f.value),Y.value=Re()!==A.value,Dt(),Y.value&&!F.value&&zt()},{deep:!0}),Le(g,k=>{k&&(ks(k),we())}),cn(()=>{typeof window>"u"||(window.addEventListener("focus",we),document.addEventListener("visibilitychange",we))}),Mt(()=>{It(),wt(),typeof window<"u"&&(window.removeEventListener("focus",we),document.removeEventListener("visibilitychange",we))}),Le(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<te||(Oe(r.listSyncTaskSlug.value),$t(r.listSyncTaskSlug.value),V(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:bt,applyTaskSettingsUpdate:Ht,buildPromptForTask:I,getPromptBlocksForTask:Q,buildPromptPreview:kr,clearCurrentTaskContent:Ft,createTaskAndSelect:Et,currentProjectSessionId:Me,currentTaskSendState:De,currentTaskAutoTitle:_,currentTaskDisplayTitle:U,currentTaskSlug:g,draft:f,editorRef:l,error:M,handleImportPdfFiles:Pt,handleImportTextFiles:Kt,handleTaskSendingChange:at,handleTaskSessionChange:St,handleUpload:qt,hasCurrentDraftContent:Te,hasAnyTaskSending:He,hasUnsavedChanges:Y,hasUnreadTaskUpdates:We,initializeWorkbench:fn,isCurrentTaskSending:Be,loadingTask:Z,loadingTasks:D,pageTitle:ne,prepareCodexPromptForTask:Ce,currentTodoItems:z,removeTodoItem:sn,removeCurrentTask:mt,reorderTaskList:Ct,removingTask:L,renderedTasks:he,refreshTaskList:it,saveTask:fe,saving:F,selectTask:Zt,selectedSessionMap:w,sendingTaskMap:c,taskDraftMap:p,tasks:u,unreadNotificationVersion:Ge,useTodoItem:dn,updateLastPromptPreview:Xt,uploading:W,creatingTask:v}}const ry={class:"flex h-full min-h-0 flex-col overflow-hidden"},ay={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"},iy={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},ly={class:"min-h-0 min-w-0 overflow-hidden"},uy={class:"min-h-0 min-w-0 overflow-hidden"},cy={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},dy={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},fy={class:"flex flex-col gap-2"},py={class:"min-h-0 flex-1 overflow-hidden"},my={key:1,class:"min-h-0 flex-1 overflow-hidden"},gy={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},hy={class:"workbench-mobile-tabs-panel shrink-0"},vy={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},yy={class:"min-h-0 flex-1 overflow-hidden"},Sy={class:"h-full min-h-0"},wy={class:"h-full min-h-0"},xy={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},by={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},ky={class:"flex flex-col gap-2"},Ty={class:"min-h-0 flex-1 overflow-hidden"},_y="/sounds/notify-didi.wav?v=20260420-1",Cy=3e3,Ey={__name:"WorkbenchView",setup(e){const t=j(!1),n=j(!1),o=j(!1),s=j(!1),r=j(!1),l=j(!1),u=j(!1),p=j(!1),w=j(""),c=j(""),S=j(""),h=j(0),g=j("workspace"),f=j(""),{t:D}=Tt(),{toastMessage:Z,toastType:v,flashToast:L,clearToast:F}=Mv(),{notificationSoundEnabled:W,sendBehavior:M}=Ia(),Y=yo(()=>Ke(()=>import("./TaskDiffReviewDialog-CPqGk_q2.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),A=yo(()=>Ke(()=>import("./WorkbenchSettingsDialog-CWl81vlG.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),X=j(null),pe=j([]),ge=j({});let E=null,ee=!1,ce=0;function te(y="",G=pe.value){const ve=String(y||"").trim();return ve&&G.some(xe=>(xe==null?void 0:xe.engine)===ve)?ve:""}function ye(y=pe.value){var G,ve;return((G=y.find(xe=>xe==null?void 0:xe.isDefault))==null?void 0:G.engine)||((ve=y[0])==null?void 0:ve.engine)||""}const _=K({get(){const y=String(z.value||"").trim();return y?te(ge.value[y])||ye():""},set(y){const G=String(z.value||"").trim(),ve=te(y);!G||!ve||(ge.value={...ge.value,[G]:ve})}});function U(y){return y?X.value:null}function $(){dt(()=>{var y,G;(G=(y=U(oe.value))==null?void 0:y.scrollToBottom)==null||G.call(y)})}const{addCurrentDraftToTodo:Me,applyTaskSettingsUpdate:De,buildPromptForTask:Be,getPromptBlocksForTask:He,clearCurrentTaskContent:We,createTaskAndSelect:Ge,creatingTask:Te,currentProjectSessionId:z,currentTaskSendState:ne,currentTaskAutoTitle:he,currentTaskDisplayTitle:$e,currentTaskSlug:oe,draft:Ee,editorRef:_e,error:Re,handleImportPdfFiles:ot,handleImportTextFiles:Ne,handleTaskSendingChange:Ze,handleTaskSessionChange:Fe,handleUpload:Je,hasCurrentDraftContent:Pe,hasUnsavedChanges:ut,hasUnreadTaskUpdates:rt,initializeWorkbench:Qe,isCurrentTaskSending:_t,loadingTask:$t,loadingTasks:C,pageTitle:O,prepareCodexPromptForTask:se,currentTodoItems:we,removeTodoItem:qe,removeCurrentTask:Oe,reorderTaskList:at,removingTask:Xe,renderedTasks:ft,saveTask:St,saving:It,selectTask:wt,unreadNotificationVersion:zt,updateLastPromptPreview:Dt,useTodoItem:Ht,uploading:ae}=oy({clearToast:F,flashToast:L,scrollCurrentPanelToBottom:$}),Ie=K(()=>ft.value.find(y=>y.slug===oe.value)||null),it=K(()=>rt.value?D("workbench.newMessageTitle"):O.value),Ct=K(()=>rt.value),Bt=K(()=>{var y,G;return!!((G=(y=Ie.value)==null?void 0:y.workspaceDiffSummary)!=null&&G.supported)}),V=K(()=>{const y=Ie.value;return y?()=>se(y.slug):null}),J=K(()=>{const y=Ie.value;return y?()=>He(y.slug):null}),ue=K(()=>({creatingTask:Te.value,currentTaskAutoTitle:Ee.value.autoTitle||he.value,currentTaskSlug:oe.value,draftTitle:Ee.value.title,editingTaskTitleSlug:S.value,error:Re.value,isCurrentTaskSending:_t.value,loadingTask:$t.value,loadingTasks:C.value,removingTask:Xe.value,tasks:ft.value,uploading:ae.value})),fe=K(()=>{var y,G,ve,xe;return{buildPromptBlocks:J.value,buildPrompt:V.value,diffSupported:Bt.value,selectedAgentEngine:_.value,selectedSessionId:z.value,sessionSelectionLockReason:((y=Ie.value)==null?void 0:y.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((G=Ie.value)!=null&&G.sessionSelectionLocked),taskSlug:((ve=Ie.value)==null?void 0:ve.slug)||"",taskRunning:!!((xe=Ie.value)!=null&&xe.running)}}),Ve=K(()=>({codexSessionId:z.value,sendBehavior:M.value,loading:$t.value})),Et=K(()=>({currentTaskAutoTitle:Ee.value.autoTitle||he.value,currentTaskSlug:oe.value,editingTaskTitleSlug:S.value,title:$e.value,titleInputValue:Ee.value.title})),{enterMobileDetail:Zt,isMobileLayout:mt,leaveMobileDetail:Ft,mobileDetailTab:bt,mobileView:sn}=Iv({currentTaskSlug:oe});function dn(y){return y!=null&&y.sending||Number((y==null?void 0:y.codexRunCount)||0)>0?"activity":"input"}Dv(it,{raw:Ct});function fn(){return typeof window>"u"?null:(E||(E=new Audio(_y),E.preload="auto",E.volume=.7),E)}function qt(){if(!W.value)return;const y=fn();if(!(!y||ee))try{y.muted=!0;const G=y.play();if(G&&typeof G.then=="function"){G.then(()=>{y.pause(),y.currentTime=0,y.muted=!1,ee=!0}).catch(()=>{y.muted=!1});return}y.pause(),y.currentTime=0,y.muted=!1,ee=!0}catch{y.muted=!1}}function Kt(){qt()}function Pt(){const y=fn();if(!y||!W.value)return;const G=Date.now();if(!(G-ce<Cy)){ce=G;try{y.muted=!1,y.currentTime=0,y.play().catch(()=>{})}catch{}}}function I(y="workspace",G=""){g.value=y==="run"?"run":y==="task"?"task":"workspace",f.value=g.value==="run"?String(G||""):"",o.value=!0,h.value+=1}function Q(){o.value=!1}function H(){s.value=!0}function Ce(){s.value=!1}function Xt(){oe.value&&(r.value=!0)}function k(){r.value=!1}function T(){l.value=!0}function q(){l.value=!1,ie(),re()}function ie(){u.value=!1,w.value=""}function re(){p.value=!1,c.value=""}function Se(y){De(y)}function ht(y){Ee.value.title=y}async function Ue(){S.value="",ut.value&&await St({auto:!1,silent:!0})}function en(y){y===oe.value&&(S.value=y,dt(()=>{var ve,xe;const G=document.querySelector('[data-task-title-input="current"]');(ve=G==null?void 0:G.focus)==null||ve.call(G),(xe=G==null?void 0:G.select)==null||xe.call(G)}))}async function Wt(y){if(mt.value){await Rn(y);return}if(y!==oe.value){await Rn(y);return}en(y)}function Dn(){n.value=!0}function Ln(){Xe.value||(n.value=!1)}async function on(){await Oe(),n.value=!1,mt.value&&Ft({useHistory:!1})}function Ut(){t.value=!0}function vt(){t.value=!1}function pn(){t.value=!1,We()}function Xn(y){const G=Ie.value;G&&Ze(G.slug,y)}function tn(y){const G=Ie.value;G&&Fe(G.slug,y)}function Ys(y={}){const G=String((y==null?void 0:y.sessionId)||"").trim(),ve=z.value;if(G&&G!==ve)return;const xe=Array.isArray(y==null?void 0:y.bindings)?y.bindings:[];pe.value=xe;const et=te(ge.value[ve],xe)||te(y==null?void 0:y.selectedEngine,xe)||ye(xe);et&&(_.value=et)}Le(z,(y,G)=>{String(y||"").trim()!==String(G||"").trim()&&(pe.value=[])});function Mn(y){_.value=y}function Bn(y){L(y),!(!mt.value||!oe.value)&&(bt.value="activity")}async function Yt(){var y,G,ve,xe,et,yt,Rt,rn;typeof document<"u"&&((G=(y=_e.value)==null?void 0:y.isComposing)!=null&&G.call(y))&&((xe=(ve=document.activeElement)==null?void 0:ve.blur)==null||xe.call(ve)),(yt=(et=_e.value)==null?void 0:et.flushPendingInput)==null||yt.call(et),await dt(),(rn=(Rt=_e.value)==null?void 0:Rt.flushPendingInput)==null||rn.call(Rt),await dt()}async function gs(){await Yt(),await navigator.clipboard.writeText(Be(oe.value)),L({message:D("workbench.promptCopied"),type:"info"})}async function Js(){await Ge()&&mt.value&&(bt.value="input",Zt())}async function Rn(y){const G=String(y||"").trim();G&&(G!==oe.value&&await wt(G),mt.value&&oe.value===G&&(bt.value=dn(Ie.value),Zt()))}async function Qs(y=[]){await at(y)}async function Sn(){await Yt(),Me()}function Yn(y={}){const G=String((y==null?void 0:y.rangeLabel)||"").trim();if(G)return G;const ve=Math.max(0,Number(y==null?void 0:y.lineStart)||0),xe=Math.max(0,Number(y==null?void 0:y.lineEnd)||0);return ve&&xe&&ve!==xe?`L${ve}-L${xe}`:ve||xe?`L${ve||xe}`:""}function Jn(y=""){return`code-context-${String(y||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function wn(y={}){const G=String((y==null?void 0:y.filePath)||"").trim(),ve=String((y==null?void 0:y.content)||"").replace(/\r\n/g,`
58
58
  `).trimEnd();if(!G||!ve.trim())return null;const xe=String((y==null?void 0:y.language)||"").trim(),et=Yn(y),yt=String((y==null?void 0:y.source)||"").trim()==="diff"?D("workbench.codeContextSourceDiff"):D("workbench.codeContextSourceFile"),Rt=xe?`\`\`\`${xe}`:"```",rn=[D("workbench.codeContextTitle"),D("workbench.codeContextFile",{path:G}),et?D("workbench.codeContextRange",{range:et}):"",D("workbench.codeContextSource",{source:yt}),"",Rt,ve,"```"].filter(vs=>vs!=="");return{type:Lt.IMPORTED_TEXT,content:rn.join(`
59
59
  `),meta:{fileName:Jn(G),collapsed:!1}}}async function hs(y=[],G="insertBlocks"){var xe,et,yt,Rt;const ve=Array.isArray(y)?y.filter(Boolean):[];return ve.length?(await Yt(),(et=(xe=_e.value)==null?void 0:xe[G])==null||et.call(xe,ve),await dt(),(Rt=(yt=_e.value)==null?void 0:yt.focusEditor)==null||Rt.call(yt),mt.value&&oe.value&&(bt.value="input"),L({message:D("taskActions.insertedToEditor"),type:"success"}),!0):!1}async function Qn(y={}){const G=String((y==null?void 0:y.source)||"").trim(),ve=String((y==null?void 0:y.content)||"").replace(/\r\n/g,`
60
60
  `).trim();if(G==="response"){if(!ve)return;await hs([Un(ve)],"insertBlocks");return}const xe=wn(y);xe&&await hs([xe],"insertImportedBlocks")}function xn(y){w.value=String(y||"").trim(),u.value=!!w.value}function Zs(){w.value&&(qe(w.value),ie())}async function Zn(y=c.value){const G=String(y||"").trim();return!G||!Ht(G)?!1:(re(),q(),!0)}async function eo(y){await Yt();const G=String(y||"").trim();if(G){if(!Pe.value){await Zn(G);return}c.value=G,p.value=!0}}async function es(){var xe,et,yt,Rt;const y=oe.value;if(!y)return;const G=!!((et=(xe=Ie.value)==null?void 0:xe.automation)!=null&&et.enabled);await Yt(),Dt(y,Be(y)),!(!await((Rt=(yt=U(y))==null?void 0:yt.send)==null?void 0:Rt.call(yt))||y!==oe.value)&&(mt.value&&(bt.value="activity"),G||We({silent:!0}),await St({auto:!1,silent:!0}))}function d(){!mt.value||sn.value!=="detail"||bt.value!=="input"||!oe.value||dt(()=>{var y,G;(G=(y=_e.value)==null?void 0:y.focusEditor)==null||G.call(y)})}function P(y){!ut.value&&!ae.value&&!It.value||(y.preventDefault(),y.returnValue="")}function N(){var y,G;return p.value?(re(),!0):u.value?(ie(),!0):t.value?(vt(),!0):n.value?(Ln(),!0):r.value?(k(),!0):l.value?(q(),!0):o.value?(Q(),!0):s.value?(Ce(),!0):!!((G=(y=U(oe.value))==null?void 0:y.closeTopDialog)!=null&&G.call(y))}function R(y){var et,yt,Rt,rn,vs;const G=String(y.key||""),ve=G.toLowerCase(),xe=y.metaKey||y.ctrlKey;if(G==="Escape"){N()&&(y.preventDefault(),(et=y.stopImmediatePropagation)==null||et.call(y));return}if(xe){if(ve==="s"){y.preventDefault(),St({auto:!1});return}if(y.shiftKey&&G==="Backspace"){y.preventDefault(),Ut();return}if(!y.isComposing){if(y.shiftKey&&y.code==="Comma"){y.preventDefault(),H();return}if(y.shiftKey&&ve==="k"){y.preventDefault(),(Rt=(yt=U(oe.value))==null?void 0:yt.openProjectManager)==null||Rt.call(yt);return}if(y.shiftKey&&ve==="o"){y.preventDefault(),(vs=(rn=U(oe.value))==null?void 0:rn.openSourceBrowser)==null||vs.call(rn);return}y.shiftKey&&ve==="d"&&(y.preventDefault(),Bt.value&&I("workspace"))}}}cn(()=>{Qe(),window.addEventListener("beforeunload",P),window.addEventListener("keydown",R),window.addEventListener("pointerdown",Kt,{passive:!0})}),Mt(()=>{window.removeEventListener("beforeunload",P),window.removeEventListener("keydown",R),window.removeEventListener("pointerdown",Kt)}),Le([mt,sn,bt,oe],([y,G,ve,xe])=>{!y||G!=="detail"||ve!=="input"||!xe||d()}),Le(zt,(y,G)=>{Number(y)<=Number(G||0)||Pt()});const le={"update:draftTitle":ht,"cancel-title-edit":()=>{S.value=""},"create-task":Js,"edit-task":Xt,"delete-task":Dn,"open-settings":H,"reorder-task":Qs,"select-task":Rn,"title-blur":Ue,"title-click":Wt},ke={"agent-bindings-change":Ys,"insert-code-context":Qn,"open-diff":({scope:y,runId:G})=>I(y,G),"project-created":()=>L({message:D("workbench.projectCreated"),type:"success"}),"selected-session-change":tn,"update:selectedAgentEngine":Mn,"sending-change":Xn,toast:Bn},ze={"clear-request":Ut,"file-feedback":y=>L({message:y,type:"warning"}),"import-pdf-files":ot,"import-text-files":Ne,"send-request":es,"upload-files":Je},je={"begin-edit":()=>en(oe.value),back:Ft,"cancel-title-edit":()=>{S.value=""},"title-blur":Ue,"update:titleInputValue":ht};return(y,G)=>(m(),b("div",ry,[de(Ev,{message:a(Z),type:a(v)},null,8,["message","type"]),de(ys,{open:t.value,title:a(D)("workbench.confirmClearTitle"),description:a(D)("workbench.confirmClearDescription"),"confirm-text":a(D)("workbench.confirmClearAction"),"cancel-text":a(D)("workbench.continueEditing"),onCancel:vt,onConfirm:pn},null,8,["open","title","description","confirm-text","cancel-text"]),de(ys,{open:n.value,title:a(D)("workbench.confirmDeleteTitle"),description:a(D)("workbench.confirmDeleteDescription",{title:a($e)}),"confirm-text":a(D)("workbench.confirmDeleteAction"),"cancel-text":a(D)("workbench.keepForNow"),loading:a(Xe),danger:"",onCancel:Ln,onConfirm:on},null,8,["open","title","description","confirm-text","cancel-text","loading"]),de(ys,{open:u.value,title:a(D)("workbench.confirmDeleteTodoTitle"),description:a(D)("workbench.confirmDeleteTodoDescription"),"confirm-text":a(D)("workbench.confirmDeleteAction"),"cancel-text":a(D)("workbench.keepForNow"),danger:"",onCancel:ie,onConfirm:Zs},null,8,["open","title","description","confirm-text","cancel-text"]),de(ys,{open:p.value,title:a(D)("workbench.replaceEditorTitle"),description:a(D)("workbench.replaceEditorDescription"),"confirm-text":a(D)("workbench.confirmReplaceAction"),"cancel-text":a(D)("workbench.dontReplaceYet"),onCancel:re,onConfirm:G[0]||(G[0]=ve=>Zn())},null,8,["open","title","description","confirm-text","cancel-text"]),de(_v,{open:l.value,items:a(we),onClose:q,onDelete:xn,onUse:eo},null,8,["open","items"]),de(a(Y),{open:o.value,"task-slug":a(oe),"task-title":a($e),"preferred-scope":g.value,"preferred-run-id":f.value,"focus-token":h.value,onInsertCodeContext:Qn,onClose:Q},null,8,["open","task-slug","task-title","preferred-scope","preferred-run-id","focus-token"]),de(a(A),{open:s.value,onClose:Ce},null,8,["open"]),de(Du,{open:r.value,"task-slug":a(oe),"task-title":a($e),onClose:k,onSaved:Se},null,8,["open","task-slug","task-title"]),a(mt)?(m(),b("div",my,[a(sn)==="tasks"?(m(),Ae(Sr,bn({key:0},ue.value,{mobile:""},kn(le)),null,16)):(m(),b("div",gy,[de(bh,bn(Et.value,kn(je)),null,16),i("section",hy,[i("div",vy,[i("button",{type:"button",class:be(["tool-button px-3 py-1.5 text-sm",a(bt)==="activity"?"tool-button-accent-subtle":""]),onClick:G[3]||(G[3]=ve=>bt.value="activity")},x(a(D)("workbench.activity")),3),i("button",{type:"button",class:be(["tool-button px-3 py-1.5 text-sm",a(bt)==="input"?"tool-button-accent-subtle":""]),onClick:G[4]||(G[4]=ve=>bt.value="input")},x(a(D)("workbench.input")),3)])]),i("div",yy,[Jt(i("div",Sy,[de(fr,bn({ref_key:"codexPanelRef",ref:X},fe.value,{"empty-message":a(D)("workbench.selectTask")},kn(ke)),null,16,["empty-message"])],512),[[Ms,a(bt)==="activity"]]),Jt(i("div",wy,[i("div",xy,[i("div",by,[i("div",ky,[de(mr,{"can-add-todo":a(Pe),"is-current-task-sending":a(_t),"send-state":a(ne),"todo-count":a(we).length,uploading:a(ae),onAddTodo:Sn,onOpenFilePicker:G[5]||(G[5]=ve=>{var xe,et;return(et=(xe=a(_e))==null?void 0:xe.openFilePicker)==null?void 0:et.call(xe)}),onClearRequest:Ut,onCopyRequest:gs,onManageTodo:T,onSendRequest:es},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),de(pr,{"agent-bindings":pe.value,"selected-agent-engine":_.value,"onUpdate:selectedAgentEngine":Mn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",Ty,[de(yr,bn({ref_key:"editorRef",ref:_e,modelValue:a(Ee).blocks,"onUpdate:modelValue":G[6]||(G[6]=ve=>a(Ee).blocks=ve)},Ve.value,kn(ze)),null,16,["modelValue"])])])],512),[[Ms,a(bt)==="input"]])])]))])):(m(),b("div",ay,[de(Sr,bn(ue.value,kn(le)),null,16),i("div",iy,[i("div",ly,[Ie.value?(m(),Ae(fr,bn({key:0,ref_key:"codexPanelRef",ref:X},fe.value,kn(ke)),null,16)):me("",!0)]),i("div",uy,[i("div",cy,[i("div",dy,[i("div",fy,[de(mr,{"can-add-todo":a(Pe),"is-current-task-sending":a(_t),"send-state":a(ne),"todo-count":a(we).length,uploading:a(ae),onAddTodo:Sn,onOpenFilePicker:G[1]||(G[1]=ve=>{var xe,et;return(et=(xe=a(_e))==null?void 0:xe.openFilePicker)==null?void 0:et.call(xe)}),onClearRequest:Ut,onCopyRequest:gs,onManageTodo:T,onSendRequest:es},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),de(pr,{"agent-bindings":pe.value,"selected-agent-engine":_.value,align:"end","onUpdate:selectedAgentEngine":Mn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",py,[de(yr,bn({ref_key:"editorRef",ref:_e,modelValue:a(Ee).blocks,"onUpdate:modelValue":G[2]||(G[2]=ve=>a(Ee).blocks=ve)},Ve.value,kn(ze)),null,16,["modelValue"])])])])])]))]))}},Hy=Object.freeze(Object.defineProperty({__proto__:null,default:Ey},Symbol.toStringTag,{value:"Module"}));export{Ly as A,Hy as B,jy as D,Es as W,Vr as _,ea as a,Fy as b,Qr as c,ac as d,sc as e,Av as f,Oy as g,ln as h,Vy as i,Ws as j,st as k,fl as l,Oi as m,My as n,sd as o,ta as p,Ry as q,zy as r,Ny as s,gt as t,la as u,Mu as v,ys as w,Uy as x,Os as y,By as z};