@muyichengshayu/promptx 0.2.12 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/apps/web/dist/assets/{CodexSessionManagerDialog-BN4cweyO.js → CodexSessionManagerDialog-Dic9kMHK.js} +1 -1
- package/apps/web/dist/assets/{TaskDiffReviewDialog-B8r9DD0G.js → TaskDiffReviewDialog-CKiZdXqi.js} +1 -1
- package/apps/web/dist/assets/{WorkbenchSettingsDialog-CjNLZ7j9.js → WorkbenchSettingsDialog-CP0z90bm.js} +1 -1
- package/apps/web/dist/assets/{WorkbenchView-DlttkjeG.css → WorkbenchView-D1oxqNr4.css} +1 -1
- package/apps/web/dist/assets/{WorkbenchView-pIUuQsCk.js → WorkbenchView-noayQwj4.js} +5 -5
- package/apps/web/dist/assets/{index-Ch8uSQYT.js → index-HLkdzIYF.js} +2 -2
- package/apps/web/dist/index.html +1 -1
- package/package.json +1 -1
- package/scripts/relay-service.mjs +1 -1
|
@@ -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-
|
|
2
|
-
import{u as It,t as Ye,f as $r,_ as We,a as Pr,b as Dr,g as Ys,s as Ma,c as Ba}from"./index-
|
|
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-Dic9kMHK.js","assets/index-HLkdzIYF.js","assets/vendor-router-Dn8q3tJM.js","assets/index-BAfqUG7o.css","assets/vendor-ui-BglsaDbv.js","assets/vendor-markdown-9aQhqbjm.js","assets/vendor-tiptap-rwYdQb1L.js","assets/TaskDiffReviewDialog-CKiZdXqi.js","assets/TaskDiffReviewDialog-NsLGEda4.css","assets/WorkbenchSettingsDialog-CP0z90bm.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as It,t as Ye,f as $r,_ as We,a as Pr,b as Dr,g as Ys,s as Ma,c as Ba}from"./index-HLkdzIYF.js";import{w as Ie,ak as Ot,aD as m,aI as Ae,aG as ue,aJ as nt,aE as k,aK as st,aL as we,aF as i,aM as on,u as a,aN as pe,aO as Lr,aP as gs,c as q,aQ as b,aR as it,aS as mt,aT as Tn,n as ct,o as pn,aU as sn,aV as Rn,b as V,aW as nn,aX as os,aY as Ko,r as hs,aC as Ra,aZ as xn,f as Na,a_ as xo,a$ as Fs,G as Oa,al as Fa,b0 as An,b1 as In}from"./vendor-misc-u-M8sNMf.js";import{X as Mr,T as Ua,L as Zt,C as Po,a as Us,B as Wo,S as ja,P as cs,b as Br,c as Va,A as za,F as qn,d as Dn,e as Rr,f as Ha,E as qa,g as Ka,h as Go,i as Do,j as js,k as Wa,l as Ga,m as Xa,U as Ya,W as Ja,n as Nr,o as Qa,p as Vs,q as Js,I as Or,r as Za,s as ei,t as ti,u as ni,G as si,v as oi,w as ri,x as ai,y as ii}from"./vendor-ui-BglsaDbv.js";import{M as Fr}from"./vendor-markdown-9aQhqbjm.js";import{n as Lo,N as Ur,a as Mo,i as li,V as oo,b as Xo,u as ui,c as ci,E as di}from"./vendor-tiptap-rwYdQb1L.js";const fi="shell",pi=new Set(["!","!"]),Yo="text";function $s(e=""){return String(e||"").replace(/\r\n/g,`
|
|
3
3
|
`).trim()}function mi(e=""){const t=String(e||"");return pi.has(t.charAt(0))}function gi(e=""){const t=$s(e);return t?t.charAt(0)==="!"?`!${t.slice(1)}`:t:""}function hi(e={}){const n=(Array.isArray(e==null?void 0:e.promptBlocks)?e.promptBlocks:[]).filter(u=>!!$s(u==null?void 0:u.content)),o=n.length>0,s=o?n.filter(u=>String((u==null?void 0:u.type)||"").trim()===Yo).map(u=>$s(u==null?void 0:u.content)).filter(Boolean).join(`
|
|
4
4
|
|
|
5
5
|
`).trim():$s(e==null?void 0:e.prompt);if(!mi(s))return{mode:"",prompt:s,command:"",reason:""};if(o&&n.some(p=>String((p==null?void 0:p.type)||"").trim()!==Yo))return{mode:"",prompt:s,command:"",reason:"unsupported_blocks"};const l=gi(s).slice(1).trim();return l?{mode:fi,prompt:s,command:l,reason:""}:{mode:"",prompt:s,command:"",reason:"empty_command"}}const cn={NONE:"none",LATEST:"latest",ALL:"all"};function vi(e="",t={}){const n=String(e||"").trim().toLowerCase();return n===cn.ALL?cn.ALL:n===cn.LATEST?cn.LATEST:n===cn.NONE?cn.NONE:t.includeEvents?cn.ALL:t.includeLatestEvents?cn.LATEST:cn.NONE}const Xt={SESSION:"session",SESSION_UPDATED:"session.updated",STATUS:"status",STDOUT:"stdout",STDERR:"stderr",AGENT_EVENT:"agent_event",COMPLETED:"completed",STOPPED:"stopped",ERROR:"error"};function jr(e=""){const t=String(e||"").trim().toLowerCase();return t==="codex"?Xt.AGENT_EVENT:t}const _t={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"},ut={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"},yi={none:{label:"不过期",hours:null}};Object.entries(yi).map(([e,t])=>({value:e,label:t.label}));const rs={CODEX:"codex",CLAUDE_CODE:"claude-code",OPENCODE:"opencode",KIMI_CODE:"kimi-code"},Bo=[{value:rs.CODEX,label:"Codex",enabled:!0},{value:rs.CLAUDE_CODE,label:"Claude Code",enabled:!0},{value:rs.OPENCODE,label:"OpenCode",enabled:!0},{value:rs.KIMI_CODE,label:"Kimi Code",enabled:!0}],Nt={TEXT:"text",IMAGE:"image",IMPORTED_TEXT:"imported_text"},Si=[{value:"local",label:"跟随本机时区"}],wi={SKIP:"skip"},xi=[{value:wi.SKIP,label:"已有运行时跳过本次"}],ro={DINGTALK:"dingtalk",FEISHU:"feishu",WEBHOOK:"webhook"},bi=[{value:ro.DINGTALK,label:"钉钉 Webhook"},{value:ro.FEISHU,label:"飞书 Webhook"},{value:ro.WEBHOOK,label:"通用 Webhook"}],ao={COMPLETED:"completed",SUCCESS:"success",ERROR:"error"},ki=[{value:ao.COMPLETED,label:"本次运行结束后"},{value:ao.SUCCESS,label:"本次运行成功后"},{value:ao.ERROR,label:"本次运行失败后"}],Ti={SUMMARY:"summary"},_i=[{value:Ti.SUMMARY,label:"摘要消息"}],Jo={ZH_CN:"zh-CN",EN_US:"en-US"},Ci=[{value:Jo.ZH_CN,label:"简体中文"},{value:Jo.EN_US,label:"English"}];function zs(e){var n;const t=String(e||"").trim().toLowerCase();return((n=Bo.find(o=>o.value===t))==null?void 0:n.value)||rs.CODEX}function vt(e){var t;return((t=Bo.find(n=>n.value===zs(e)))==null?void 0:t.label)||"Codex"}function Fy(e=""){const t=String(e||"").trim();if(!t)return"";const n=/^[a-z]:[\\/]/i.test(t)||t.includes("\\");let o=t.replace(/\\/g,"/");return o.length>1&&!/^[a-z]:\/$/i.test(o)&&(o=o.replace(/\/+$/,"")),n?o.toLowerCase():o}function Ei(e=[],t=10){const n=e.find(o=>{var s;return(o.type===Nt.TEXT||o.type===Nt.IMPORTED_TEXT)&&((s=o.content)==null?void 0:s.trim())});return n?n.content.replace(/\s+/g," ").trim().slice(0,t):""}const Ai={class:"min-w-0 flex-1"},Ii={key:0,class:"flex items-center gap-2"},$i=["disabled"],Qs={__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=q(()=>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 Ie(()=>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}),Ot(()=>{n.lockBodyScroll&&document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",u)}),(p,w)=>(m(),Ae(gs,{to:"body"},[ue(Lr,{name:"dialog-shell"},{default:nt(()=>[e.open?(m(),k("div",{key:0,class:we(["theme-modal-backdrop dialog-shell-backdrop fixed inset-0 flex",s.value]),onClick:st(l,["self"])},[i("section",{class:we(["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(),k("div",{key:0,class:we(["theme-divider flex items-start justify-between gap-4 border-b",e.headerClass])},[i("div",Ai,[on(p.$slots,"header",{},()=>[on(p.$slots,"title")])]),p.$slots["header-actions"]||e.showClose?(m(),k("div",Ii,[on(p.$slots,"header-actions"),e.showClose?(m(),k("button",{key:0,type:"button",class:"theme-icon-button h-8 w-8 shrink-0",disabled:e.closeDisabled,onClick:r},[ue(a(Mr),{class:"h-4 w-4"})],8,$i)):pe("",!0)])):pe("",!0)],2)):pe("",!0),i("div",{class:we(e.bodyClass)},[on(p.$slots,"default")],2)],2)],2)):pe("",!0)]),_:3})]))}},Pi={class:"flex items-start gap-3"},Di={class:"theme-heading text-base font-semibold"},Li={key:0,class:"theme-muted-text mt-1 text-sm leading-6"},Mi={class:"flex justify-end gap-2 px-5 py-4"},Bi=["disabled"],Ri=["disabled"],Ts={__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}=It(),r=q(()=>n.title||s("common.confirm")),l=q(()=>n.confirmText||s("common.confirm")),u=q(()=>n.cancelText||s("common.cancel"));return(p,w)=>(m(),Ae(Qs,{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:nt(()=>[i("div",Pi,[i("span",{class:we(["inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-sm border border-dashed",e.danger?"theme-status-danger":"theme-status-neutral"])},[ue(a(Ua),{class:"h-4 w-4"})],2),i("div",null,[i("h2",Di,b(r.value),1),e.description?(m(),k("p",Li,b(e.description),1)):pe("",!0)])])]),default:nt(()=>[i("div",Mi,[i("button",{type:"button",class:"tool-button px-4 py-2 text-sm",disabled:e.loading,onClick:w[0]||(w[0]=c=>o("cancel"))},b(u.value),9,Bi),i("button",{type:"button",class:we(["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"))},b(e.loading?a(s)("common.processing"):l.value),11,Ri)])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},Ni={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"},Oi={class:"settings-nav flex gap-2 overflow-x-auto sm:flex-col sm:overflow-visible"},Fi=["onClick"],Ui={class:"min-w-0"},ji={class:"text-sm font-medium"},Vi={class:"theme-muted-text mt-1 hidden text-xs leading-5 sm:block"},zi={__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(),k("aside",Ni,[i("nav",Oi,[(m(!0),k(it,null,mt(e.sections,l=>(m(),k("button",{key:l.id,type:"button",class:we(["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(Tn(l.icon),{class:"mt-0.5 h-4 w-4 shrink-0"})),i("div",Ui,[i("div",ji,b(l.label),1),i("p",Vi,b(l.description),1)])],10,Fi))),128))])]))}},Hi=["aria-label","disabled","onKeydown"],qi={class:"min-w-0 flex-1"},Ki={class:"theme-muted-text text-sm"},Wi={class:"flex min-h-0 w-full flex-col"},Gi={class:"min-h-0 flex-1 space-y-2 overflow-y-auto p-2"},Xi=["onClick"],Yi={class:"theme-empty-state px-3 py-4 text-sm"},dn={__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}=It(),r=V(null),l=V(null),u=V(!1),p=V(!1),w=V({}),c=q(()=>{const M=String(n.modelValue??"");return n.options.find(J=>String(n.getOptionValue(J)??"")===M)||null}),S=q(()=>n.placeholder||s("common.select")),h=q(()=>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 P(){u.value=!1}function Z(){if(u.value){P();return}f()}function v(M){o("update:modelValue",String(n.getOptionValue(M)??"").trim()),P()}function L(){if(!u.value||!r.value||typeof window>"u")return;const M=r.value.getBoundingClientRect(),J=window.innerWidth,A=window.innerHeight,G=8,de=8,ge=160,$=360,ee=Math.max(0,A-M.bottom-de),le=Math.max(0,M.top-de);p.value=ee<260&&le>ee;const ne=p.value?le-G:ee-G,ve=Math.max(Math.min($,Math.max(ne,0)),Math.min(ge,p.value?le:ee)),_=Math.min(M.width,J-de*2),H=Math.min(Math.max(de,M.left),Math.max(de,J-de-_));w.value={left:`${H}px`,top:p.value?`${M.top-G}px`:`${M.bottom+G}px`,width:`${_}px`,maxHeight:`${Math.max(ve,120)}px`,transform:p.value?"translateY(-100%)":"none"}}function U(M){var J;!u.value||!r.value||r.value.contains(M.target)||(J=l.value)!=null&&J.contains(M.target)||P()}function K(M){M.key==="Escape"&&P()}return Ie(()=>n.disabled,M=>{M&&P()}),Ie(u,async M=>{M&&(await ct(),L())}),pn(()=>{document.addEventListener("pointerdown",U),document.addEventListener("keydown",K),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0)}),Ot(()=>{document.removeEventListener("pointerdown",U),document.removeEventListener("keydown",K),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}),(M,J)=>(m(),k("div",{ref_key:"rootRef",ref:r,class:"relative min-w-0"},[i("button",{type:"button",class:we(["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:[sn(st(f,["prevent"]),["down"]),sn(st(Z,["prevent"]),["enter"]),sn(st(Z,["prevent"]),["space"])]},[i("div",qi,[on(M.$slots,"trigger",{selectedOption:c.value,open:u.value,loading:e.loading,disabled:e.disabled},()=>[i("div",Ki,b(c.value?g(c.value):S.value),1)])]),i("div",{class:we(["flex shrink-0 items-center gap-2",e.disabled?"text-[var(--theme-textMuted)] opacity-80":"theme-muted-text"])},[e.loading?(m(),Ae(a(Zt),{key:0,class:"h-4 w-4 animate-spin"})):pe("",!0),ue(a(Po),{class:we(["h-4 w-4 transition",u.value?"rotate-180":""])},null,8,["class"])],2)],42,Hi),(m(),Ae(gs,{to:"body"},[u.value?(m(),k("div",{key:0,ref_key:"panelRef",ref:l,class:"workbench-select-panel theme-popover fixed z-[90] flex overflow-hidden rounded-sm border",style:Rn(w.value)},[i("div",Wi,[on(M.$slots,"header",{loading:e.loading,options:e.options}),i("div",Gi,[e.options.length?(m(!0),k(it,{key:0},mt(e.options,A=>on(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:G=>v(A)},b(g(A)),9,Xi)])),128)):on(M.$slots,"empty",{key:1},()=>[i("div",Yi,b(h.value),1)])])])],4)):pe("",!0)]))],512))}},Qo={},Vr=typeof import.meta<"u"&&Qo?Qo:{};function Ji(){if(typeof window>"u")return"http://localhost:3000";const e=new URL(window.location.origin),t=String(Vr.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(/\/$/,"")}function Ro(){return(Vr.VITE_API_BASE_URL||Ji()).replace(/\/$/,"")}function No(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 ot(e,t={}){const n=typeof t.body<"u"&&!(t.body instanceof FormData),o=await fetch(`${Ro()}${e}`,{headers:{...n?{"Content-Type":"application/json"}:{},...t.headers||{}},...t});if(!o.ok){const r=await o.json().catch(()=>({}));throw new Error(No(r))}return o.status===204?null:(o.headers.get("content-type")||"").includes("application/json")?o.json():o.text()}function Yn(){return Ro()}function Ps(e){if(!e)return"";if(e.startsWith("http")){try{const t=new URL(e);if(typeof window<"u"&&(t.hostname==="localhost"||t.hostname==="127.0.0.1")){const n=new URL(window.location.origin);return t.hostname=n.hostname,t.port=n.port,t.protocol=n.protocol,t.toString()}}catch{}return e}return`${Ro()}${e}`}function Uy(){return ot("/api/meta",{cache:"no-store"})}function Qi(){return ot("/api/tasks")}function Zi(e=30){const t=typeof e=="object"&&e!==null?e:{limit:e},n=new URLSearchParams,o=Math.max(1,Number(t.limit)||30);return n.set("limit",String(o)),(t.slugs||[]).forEach(s=>{const r=String(s||"").trim();r&&n.append("slug",r)}),ot(`/api/tasks/workspace-diff-summaries?${n.toString()}`,{cache:"no-store"})}function el(e){return ot("/api/tasks",{method:"POST",body:JSON.stringify(e)})}function tl(e=[]){return ot("/api/tasks/reorder",{method:"POST",body:JSON.stringify({slugs:e})})}function zr(e){return ot(`/api/tasks/${e}`)}function Hr(e,t){return ot(`/api/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)})}function nl(e){return ot(`/api/tasks/${e}`,{method:"DELETE"})}async function sl(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Yn()}/api/uploads`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(No(o,"errors.uploadFailed"))}return n.json()}async function ol(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Yn()}/api/imports/pdf`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(No(o,"errors.pdfImportFailed"))}return n.json()}const rl=Yn();function al(){return ot("/api/codex/sessions")}function il(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim();n&&t.set("engine",n);const o=t.toString();return ot(`/api/codex/workspaces${o?`?${o}`:""}`)}function jy(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 ot(`/api/codex/session-candidates${r?`?${r}`:""}`,{cache:"no-store",signal:e.signal})}function Vy(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 ot(`/api/codex/directories/tree${s?`?${s}`:""}`,{cache:"no-store",signal:e.signal})}function zy(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 ot(`/api/codex/directories/search${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function ll(e){return ot("/api/codex/sessions",{method:"POST",body:JSON.stringify(e)})}function ul(e,t){return ot(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function cl(e){return ot(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function dl(e){return ot(`/api/codex/sessions/${encodeURIComponent(e)}/reset`,{method:"POST"})}function fl(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 ot(`/api/codex/sessions/${encodeURIComponent(e)}/files/tree${r?`?${r}`:""}`,{cache:"no-store",signal:t.signal})}function pl(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 ot(`/api/codex/sessions/${encodeURIComponent(e)}/files/search${u?`?${u}`:""}`,{cache:"no-store",signal:n.signal})}function ml(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 ot(`/api/codex/sessions/${encodeURIComponent(e)}/files/content${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function gl(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 ot(`/api/codex/sessions/${encodeURIComponent(e)}/files/content-search${u?`?${u}`:""}`,{cache:"no-store",signal:n.signal})}function hl(e,t){return ot(`/api/tasks/${encodeURIComponent(e)}/codex-session`,{method:"POST",body:JSON.stringify({sessionId:t})})}function vl(e,t={}){const n=new URLSearchParams,o=Number(t.limit||20),s=vi(t.events,t);Number.isFinite(o)&&o>0&&n.set("limit",String(o)),n.set("events",s);const r=n.toString();return ot(`/api/tasks/${encodeURIComponent(e)}/codex-runs${r?`?${r}`:""}`,{cache:"no-store"})}function yl(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 ot(`/api/codex/runs/${encodeURIComponent(e)}/events${r?`?${r}`:""}`,{cache:"no-store"})}function Hy(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 ot(`/api/tasks/${encodeURIComponent(e)}/git-diff${w?`?${w}`:""}`,{cache:"no-store"})}function qy(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`${rl}/api/tasks/${encodeURIComponent(e)}/git-diff/blob${u?`?${u}`:""}`}function Sl(e,t){return ot(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"POST",body:JSON.stringify(t)})}function wl(e){return ot(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"DELETE"})}function xl(e){return ot(`/api/codex/runs/${encodeURIComponent(e)}/stop`,{method:"POST"})}const bl={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},kl={class:"theme-muted-text mt-1 text-xs"},Tl={class:"min-h-0 flex flex-1 flex-col overflow-hidden sm:flex-row"},_l={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},Cl={key:0,class:"theme-muted-text flex items-center gap-2 py-4 text-sm"},El={key:1,class:"space-y-4"},Al={key:0,class:"space-y-4"},Il={class:"theme-heading text-base font-medium"},$l={class:"theme-muted-text mt-1 text-xs leading-5"},Pl={class:"settings-section-card px-4 py-4"},Dl={class:"block space-y-1.5"},Ll={class:"theme-muted-text text-xs"},Ml=["placeholder"],Bl={key:1,class:"space-y-4"},Rl={class:"flex items-start justify-between gap-3"},Nl={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Ol={class:"theme-muted-text mt-1 text-xs leading-5"},Fl={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Ul={class:"settings-section-card px-4 py-4"},jl={class:"grid gap-4 sm:grid-cols-2"},Vl={class:"space-y-1.5 sm:col-span-2"},zl={class:"theme-muted-text text-xs"},Hl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},ql={class:"space-y-1.5"},Kl={class:"theme-muted-text text-xs"},Wl=["disabled"],Gl={key:0,class:"space-y-1.5"},Xl={class:"theme-muted-text text-xs"},Yl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Jl={class:"space-y-1.5"},Ql={class:"theme-muted-text text-xs"},Zl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},eu={class:"theme-muted-text text-xs"},tu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},nu={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},su={key:2,class:"space-y-4"},ou={class:"flex items-start justify-between gap-3"},ru={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},au={class:"theme-muted-text mt-1 text-xs leading-5"},iu={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},lu={class:"settings-section-card px-4 py-4"},uu={class:"grid gap-4 sm:grid-cols-2"},cu={class:"space-y-1.5"},du={class:"theme-muted-text text-xs"},fu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},pu={class:"space-y-1.5"},mu={class:"theme-muted-text text-xs"},gu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},hu={class:"space-y-1.5 sm:col-span-2"},vu={class:"theme-muted-text text-xs"},yu=["placeholder","disabled"],Su={class:"space-y-1.5"},wu={class:"theme-muted-text text-xs"},xu=["placeholder","disabled"],bu={class:"space-y-1.5"},ku={class:"theme-muted-text text-xs"},Tu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},_u={class:"space-y-1.5"},Cu={class:"theme-muted-text text-xs"},Eu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Au={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},Iu={key:0,class:"theme-danger-text"},$u={key:3,class:"theme-danger-text text-sm"},Pu={class:"theme-divider flex flex-col gap-3 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-between"},Du={class:"theme-muted-text theme-note-text"},Lu={class:"flex items-center justify-end gap-2"},Mu=["disabled"],Bu=["disabled"],Ru="0 9 * * 1-5",io="weekdays",ns="09:00",jn="1",Nu={__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}=It(),l=V(!1),u=V(!1),p=V(""),w=V("basic"),c=hs({title:"",automationEnabled:!1,automationMode:io,automationTime:ns,automationWeekday:jn,automationTimezone:"local",automationConcurrencyPolicy:"skip",automationLastTriggeredAt:"",automationNextTriggerAt:"",notificationEnabled:!1,notificationChannelType:"dingtalk",notificationWebhookUrl:"",notificationSecret:"",notificationTriggerOn:"completed",notificationLocale:"zh-CN",notificationMessageMode:"summary",notificationLastStatus:"",notificationLastError:"",notificationLastSentAt:""}),S=q(()=>String(n.taskTitle||"").trim()||r("workbench.untitledTask")),h=q(()=>[{id:"basic",label:r("taskDialog.sections.basic.label"),description:r("taskDialog.sections.basic.description"),icon:cs},{id:"automation",label:r("taskDialog.sections.automation.label"),description:r("taskDialog.sections.automation.description"),icon:Us},{id:"notification",label:r("taskDialog.sections.notification.label"),description:r("taskDialog.sections.notification.description"),icon:Wo}]),g=q(()=>[{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=q(()=>[{value:"1",label:r("taskDialog.sections.automation.weekday1")},{value:"2",label:r("taskDialog.sections.automation.weekday2")},{value:"3",label:r("taskDialog.sections.automation.weekday3")},{value:"4",label:r("taskDialog.sections.automation.weekday4")},{value:"5",label:r("taskDialog.sections.automation.weekday5")},{value:"6",label:r("taskDialog.sections.automation.weekday6")},{value:"0",label:r("taskDialog.sections.automation.weekday0")}]),P=q(()=>Si.map(_=>({..._,label:_.value==="local"?r("taskDialog.sections.automation.timezoneLocal"):_.label}))),Z=q(()=>xi.map(_=>({..._,label:_.value==="skip"?r("taskDialog.sections.automation.concurrencySkip"):_.label}))),v=q(()=>bi.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=q(()=>ki.map(_=>({..._,label:_.value==="completed"?r("taskDialog.sections.notification.triggerCompleted"):_.value==="success"?r("taskDialog.sections.notification.triggerSuccess"):_.value==="error"?r("taskDialog.sections.notification.triggerError"):_.label}))),U=q(()=>_i.map(_=>({..._,label:_.value==="summary"?r("taskDialog.sections.notification.messageSummary"):_.label}))),K=q(()=>Ci.map(_=>({..._,label:_.value==="zh-CN"?r("taskDialog.sections.notification.localeZhCn"):_.value==="en-US"?r("taskDialog.sections.notification.localeEnUs"):_.label}))),M=q(()=>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 J(){c.title="",c.automationEnabled=!1,c.automationMode=io,c.automationTime=ns,c.automationWeekday=jn,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 G(_=""){const H=String(_||"").trim().replace(/\s+/g," ");let E=H.match(/^(\d{1,2}) (\d{1,2}) \* \* 1-5$/);return E?{mode:"weekdays",time:`${A(E[2])}:${A(E[1])}`,weekday:jn}:(E=H.match(/^(\d{1,2}) (\d{1,2}) \* \* \*$/),E?{mode:"daily",time:`${A(E[2])}:${A(E[1])}`,weekday:jn}:(E=H.match(/^(\d{1,2}) (\d{1,2}) \* \* ([0-6])$/),E?{mode:"weekly",time:`${A(E[2])}:${A(E[1])}`,weekday:String(E[3])}:{mode:io,time:ns,weekday:jn}))}function de(_=""){const E=String(_||"").trim().match(/^(\d{1,2}):(\d{2})$/);if(!E)return ns;const Be=Number(E[1]),Pe=Number(E[2]);return!Number.isInteger(Be)||!Number.isInteger(Pe)||Be<0||Be>23||Pe<0||Pe>59?ns:`${A(Be)}:${A(Pe)}`}function ge(){var Re;const _=de(c.automationTime),[H,E]=_.split(":"),Be=Number(H),Pe=Number(E);if(c.automationMode==="daily")return`${Pe} ${Be} * * *`;if(c.automationMode==="weekly"){const Ve=((Re=f.value.find(Xe=>Xe.value===String(c.automationWeekday||"")))==null?void 0:Re.value)||jn;return`${Pe} ${Be} * * ${Ve}`}return`${Pe} ${Be} * * 1-5`}function $(_={}){var E,Be,Pe,Re,Ve,Xe,Je,Ee,W,oe,fe,$e,me,Ne,he,Me;c.title=String(_.title||""),c.automationEnabled=!!((E=_.automation)!=null&&E.enabled);const H=G(((Be=_.automation)==null?void 0:Be.cron)||Ru);c.automationMode=H.mode,c.automationTime=H.time,c.automationWeekday=H.weekday,c.automationTimezone=String(((Pe=_.automation)==null?void 0:Pe.timezone)||"local"),c.automationConcurrencyPolicy=String(((Re=_.automation)==null?void 0:Re.concurrencyPolicy)||"skip"),c.automationLastTriggeredAt=String(((Ve=_.automation)==null?void 0:Ve.lastTriggeredAt)||""),c.automationNextTriggerAt=String(((Xe=_.automation)==null?void 0:Xe.nextTriggerAt)||""),c.notificationEnabled=!!((Je=_.notification)!=null&&Je.enabled),c.notificationChannelType=String(((Ee=_.notification)==null?void 0:Ee.channelType)||"dingtalk"),c.notificationWebhookUrl=String(((W=_.notification)==null?void 0:W.webhookUrl)||""),c.notificationSecret=String(((oe=_.notification)==null?void 0:oe.secret)||""),c.notificationTriggerOn=String(((fe=_.notification)==null?void 0:fe.triggerOn)||"completed"),c.notificationLocale=String((($e=_.notification)==null?void 0:$e.locale)||s.value||"zh-CN"),c.notificationMessageMode=String(((me=_.notification)==null?void 0:me.messageMode)||"summary"),c.notificationLastStatus=String(((Ne=_.notification)==null?void 0:Ne.lastStatus)||""),c.notificationLastError=String(((he=_.notification)==null?void 0:he.lastError)||""),c.notificationLastSentAt=String(((Me=_.notification)==null?void 0:Me.lastSentAt)||"")}async function ee(){const _=String(n.taskSlug||"").trim();if(!_){J();return}l.value=!0,p.value="";try{const H=await zr(_);$(H)}catch(H){p.value=(H==null?void 0:H.message)||r("taskDialog.loadFailed")}finally{l.value=!1}}function le(){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 ne(){const _=String(n.taskSlug||"").trim();if(!(!_||l.value||u.value)){u.value=!0,p.value="";try{const H=await Hr(_,le());$(H),o("saved",H),o("close")}catch(H){p.value=(H==null?void 0:H.message)||r("taskDialog.saveFailed")}finally{u.value=!1}}}function ve(_=""){if(!_)return r("common.notAvailable");const H=new Date(_);return Number.isNaN(H.getTime())?r("common.notAvailable"):$r(H.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return Ie(()=>n.open,_=>{if(_){w.value="basic",ee();return}},{immediate:!0}),Ie(()=>n.taskSlug,()=>{n.open&&ee()}),(_,H)=>(m(),Ae(Qs,{open:e.open,"stack-level":3,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-5xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col overflow-hidden",onClose:H[16]||(H[16]=E=>o("close"))},{title:nt(()=>[i("div",null,[i("div",bl,[ue(a(cs),{class:"h-4 w-4"}),i("span",null,b(a(r)("taskDialog.title")),1)]),i("p",kl,b(a(r)("taskDialog.currentTask",{title:S.value})),1)])]),default:nt(()=>[i("div",Tl,[ue(zi,{modelValue:w.value,"onUpdate:modelValue":H[0]||(H[0]=E=>w.value=E),sections:h.value},null,8,["modelValue","sections"]),i("div",_l,[l.value?(m(),k("div",Cl,[ue(a(Zt),{class:"h-4 w-4 animate-spin"}),i("span",null,b(a(r)("taskDialog.loading")),1)])):(m(),k("div",El,[w.value==="basic"?(m(),k("section",Al,[i("div",null,[i("div",Il,b(a(r)("taskDialog.sections.basic.title")),1),i("p",$l,b(a(r)("taskDialog.sections.basic.intro")),1)]),i("section",Pl,[i("label",Dl,[i("span",Ll,b(a(r)("taskDialog.sections.basic.taskTitle")),1),nn(i("input",{"onUpdate:modelValue":H[1]||(H[1]=E=>c.title=E),type:"text",maxlength:"140",class:"tool-input",placeholder:a(r)("taskDialog.sections.basic.taskTitlePlaceholder")},null,8,Ml),[[os,c.title]])])])])):w.value==="automation"?(m(),k("section",Bl,[i("div",Rl,[i("div",null,[i("div",Nl,[ue(a(Us),{class:"h-4 w-4"}),i("span",null,b(a(r)("taskDialog.sections.automation.title")),1)]),i("p",Ol,b(a(r)("taskDialog.sections.automation.intro")),1)]),i("label",Fl,[nn(i("input",{"onUpdate:modelValue":H[2]||(H[2]=E=>c.automationEnabled=E),type:"checkbox",class:"h-4 w-4"},null,512),[[Ko,c.automationEnabled]]),i("span",null,b(a(r)("taskDialog.enabled")),1)])]),i("section",Ul,[i("div",jl,[i("label",Vl,[i("span",zl,b(a(r)("taskDialog.sections.automation.mode")),1),ue(dn,{modelValue:c.automationMode,"onUpdate:modelValue":H[3]||(H[3]=E=>c.automationMode=E),options:g.value,disabled:!c.automationEnabled,"get-option-value":E=>E.value},{trigger:nt(({selectedOption:E})=>[i("div",Hl,b((E==null?void 0:E.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",ql,[i("span",Kl,b(a(r)("taskDialog.sections.automation.time")),1),nn(i("input",{"onUpdate:modelValue":H[4]||(H[4]=E=>c.automationTime=E),type:"time",class:"tool-input",disabled:!c.automationEnabled},null,8,Wl),[[os,c.automationTime]])]),c.automationMode==="weekly"?(m(),k("label",Gl,[i("span",Xl,b(a(r)("taskDialog.sections.automation.weekday")),1),ue(dn,{modelValue:c.automationWeekday,"onUpdate:modelValue":H[5]||(H[5]=E=>c.automationWeekday=E),options:f.value,disabled:!c.automationEnabled,"get-option-value":E=>E.value},{trigger:nt(({selectedOption:E})=>[i("div",Yl,b((E==null?void 0:E.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])):pe("",!0),i("label",Jl,[i("span",Ql,b(a(r)("taskDialog.sections.automation.timezone")),1),ue(dn,{modelValue:c.automationTimezone,"onUpdate:modelValue":H[6]||(H[6]=E=>c.automationTimezone=E),options:P.value,disabled:!c.automationEnabled,"get-option-value":E=>E.value},{trigger:nt(({selectedOption:E})=>[i("div",Zl,b((E==null?void 0:E.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",{class:we(["space-y-1.5",c.automationMode==="weekly"?"":"sm:col-span-2"])},[i("span",eu,b(a(r)("taskDialog.sections.automation.concurrencyPolicy")),1),ue(dn,{modelValue:c.automationConcurrencyPolicy,"onUpdate:modelValue":H[7]||(H[7]=E=>c.automationConcurrencyPolicy=E),options:Z.value,disabled:!c.automationEnabled,"get-option-value":E=>E.value},{trigger:nt(({selectedOption:E})=>[i("div",tu,b((E==null?void 0:E.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])],2)]),i("div",nu,[i("p",null,b(a(r)("taskDialog.sections.automation.lastTriggered",{value:ve(c.automationLastTriggeredAt)})),1),i("p",null,b(a(r)("taskDialog.sections.automation.nextTriggered",{value:ve(c.automationNextTriggerAt)})),1)])])])):(m(),k("section",su,[i("div",ou,[i("div",null,[i("div",ru,[ue(a(Wo),{class:"h-4 w-4"}),i("span",null,b(a(r)("taskDialog.sections.notification.title")),1)]),i("p",au,b(a(r)("taskDialog.sections.notification.intro")),1)]),i("label",iu,[nn(i("input",{"onUpdate:modelValue":H[8]||(H[8]=E=>c.notificationEnabled=E),type:"checkbox",class:"h-4 w-4"},null,512),[[Ko,c.notificationEnabled]]),i("span",null,b(a(r)("taskDialog.enabled")),1)])]),i("section",lu,[i("div",uu,[i("label",cu,[i("span",du,b(a(r)("taskDialog.sections.notification.channelType")),1),ue(dn,{modelValue:c.notificationChannelType,"onUpdate:modelValue":H[9]||(H[9]=E=>c.notificationChannelType=E),options:v.value,disabled:!c.notificationEnabled,"get-option-value":E=>E.value},{trigger:nt(({selectedOption:E})=>[i("div",fu,b((E==null?void 0:E.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",pu,[i("span",mu,b(a(r)("taskDialog.sections.notification.triggerOn")),1),ue(dn,{modelValue:c.notificationTriggerOn,"onUpdate:modelValue":H[10]||(H[10]=E=>c.notificationTriggerOn=E),options:L.value,disabled:!c.notificationEnabled,"get-option-value":E=>E.value},{trigger:nt(({selectedOption:E})=>[i("div",gu,b((E==null?void 0:E.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",hu,[i("span",vu,b(a(r)("taskDialog.sections.notification.webhookUrl")),1),nn(i("input",{"onUpdate:modelValue":H[11]||(H[11]=E=>c.notificationWebhookUrl=E),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.webhookUrlPlaceholder"),disabled:!c.notificationEnabled},null,8,yu),[[os,c.notificationWebhookUrl]])]),i("label",Su,[i("span",wu,b(a(r)("taskDialog.sections.notification.secret")),1),nn(i("input",{"onUpdate:modelValue":H[12]||(H[12]=E=>c.notificationSecret=E),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.secretPlaceholder"),disabled:!c.notificationEnabled},null,8,xu),[[os,c.notificationSecret]])]),i("label",bu,[i("span",ku,b(a(r)("taskDialog.sections.notification.locale")),1),ue(dn,{modelValue:c.notificationLocale,"onUpdate:modelValue":H[13]||(H[13]=E=>c.notificationLocale=E),options:K.value,disabled:!c.notificationEnabled,"get-option-value":E=>E.value},{trigger:nt(({selectedOption:E})=>[i("div",Tu,b((E==null?void 0:E.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",_u,[i("span",Cu,b(a(r)("taskDialog.sections.notification.messageMode")),1),ue(dn,{modelValue:c.notificationMessageMode,"onUpdate:modelValue":H[14]||(H[14]=E=>c.notificationMessageMode=E),options:U.value,disabled:!c.notificationEnabled,"get-option-value":E=>E.value},{trigger:nt(({selectedOption:E})=>[i("div",Eu,b((E==null?void 0:E.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])]),i("div",Au,[i("p",null,b(a(r)("taskDialog.sections.notification.status",{value:M.value})),1),i("p",null,b(a(r)("taskDialog.sections.notification.lastSent",{value:ve(c.notificationLastSentAt)})),1),c.notificationLastError?(m(),k("p",Iu,b(a(r)("taskDialog.sections.notification.lastError",{value:c.notificationLastError})),1)):pe("",!0)])])])),p.value?(m(),k("p",$u,b(p.value),1)):pe("",!0)]))])]),i("div",Pu,[i("p",Du,b(a(r)("taskDialog.footerHint")),1),i("div",Lu,[i("button",{type:"button",class:"tool-button px-3 py-2 text-sm",disabled:u.value,onClick:H[15]||(H[15]=E=>o("close"))},b(a(r)("common.cancel")),9,Mu),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:ne},[u.value?(m(),Ae(a(Zt),{key:0,class:"h-4 w-4 animate-spin"})):(m(),Ae(a(ja),{key:1,class:"h-4 w-4"})),i("span",null,b(u.value?a(r)("common.saving"):a(r)("taskDialog.saveTaskConfig")),1)],8,Bu)])])]),_:1},8,["open"]))}};function Ou(e=[]){return(Array.isArray(e)&&e.length?e:Bo).filter(n=>n&&typeof n=="object").map(n=>{const o=zs(n.value);return{...n,value:o,label:String(n.label||vt(o)).trim()||vt(o),enabled:n.enabled!==!1,available:n.available!==!1}})}function Fu(e=[]){return Ou(e).filter(t=>t.enabled&&t.available)}async function Ky(){const e=await ot("/api/meta",{cache:"no-store"});return Fu(e==null?void 0:e.agentEngineOptions)}function qr(e={},t={}){const{defaultLabel:n="默认",prefix:o=""}=t,s=vt(e==null?void 0:e.engine),r=`${String(o||"")}${s}`;return e!=null&&e.isDefault?`${r} · ${n}`:r}const Uu={key:0,class:"flex items-center gap-2 text-sm"},ju={class:"min-w-0 flex-1 truncate"},Vu={class:"theme-muted-text ml-2 hidden font-mono text-[11px] sm:inline"},zu={class:"theme-status-neutral hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex"},Hu={key:1,class:"theme-muted-text text-sm"},qu={class:"theme-divider theme-muted-text flex items-center justify-between gap-3 border-b border-dashed px-3 py-2 text-[11px]"},Ku=["onClick"],Wu={class:"flex items-center gap-3"},Gu={class:"min-w-0 flex-1"},Xu={class:"flex items-center gap-2 text-sm sm:hidden"},Yu={class:"min-w-0 flex-1 truncate font-medium text-[var(--theme-textPrimary)]"},Ju={class:"hidden items-center gap-2 text-sm sm:flex"},Qu={class:"min-w-0 flex-1 truncate"},Zu={class:"font-medium text-[var(--theme-textPrimary)]"},ec={class:"theme-muted-text ml-2 font-mono text-[11px]"},tc={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},nc={__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}=It();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}):vt(c==null?void 0:c.engine)}function w(c){return c?"theme-filter-active":"theme-filter-idle"}return(c,S)=>(m(),Ae(dn,{"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:nt(({selectedOption:h,disabled:g})=>[h?(m(),k("div",Uu,[i("span",ju,[i("span",{class:we(["font-medium",g?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},b(s(h)),3),i("span",Vu,b(r(h)),1)]),i("span",zu,b(p(h)),1),i("span",{class:we(["hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex",u(h)])},b(l(h)),3)])):(m(),k("div",Hu,b(e.loading?a(o)("projectManager.syncingProjects"):a(o)("projectManager.selectProject")),1))]),header:nt(()=>[i("div",qu,[i("span",null,b(e.loading?a(o)("projectManager.syncingLatestProjects"):a(o)("projectManager.projectCount",{count:e.sessions.length})),1),e.loading?(m(),Ae(a(Zt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):pe("",!0)])]),option:nt(({option:h,selected:g,select:f})=>[i("button",{type:"button",class:we(["w-full rounded-sm border border-dashed p-3 text-left transition",w(g)]),onClick:f},[i("div",Wu,[i("div",Gu,[i("div",Xu,[i("span",Yu,b(s(h)),1)]),i("div",Ju,[i("span",Qu,[i("span",Zu,b(s(h)),1),i("span",ec,b(r(h)),1)]),i("span",tc,b(p(h)),1),i("span",{class:we(["inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",u(h)])},b(l(h)),3)])]),g?(m(),Ae(a(Br),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):pe("",!0)])],10,Ku)]),_:1},8,["model-value","options","loading","disabled","placeholder","empty-text","get-option-value"]))}},sc=["disabled"],oc=["disabled"],rc=["src","alt"],Kr={__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}=It(),r=V(1),l=q(()=>n.images.map(v=>String(v||"").trim()).filter(Boolean)),u=q(()=>l.value.findIndex(v=>v===n.modelValue)),p=q(()=>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 P(v){p.value&&(v.preventDefault(),g(v.deltaY<0?.1:-.1))}function Z(v){var L,U;if(p.value){if((L=v.stopPropagation)==null||L.call(v),(U=v.stopImmediatePropagation)==null||U.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 Ie(()=>n.modelValue,v=>{v||(r.value=1)}),Ie(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}),pn(()=>{window.addEventListener("keydown",Z,{capture:!0})}),Ot(()=>{window.removeEventListener("keydown",Z,{capture:!0})}),(v,L)=>(m(),Ae(gs,{to:"body"},[p.value?(m(),k("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:P},[i("div",{class:"absolute left-4 top-4 flex items-center gap-2",onClick:L[2]||(L[2]=st(()=>{},["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]=U=>g(-.1))},b(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},b(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]=U=>g(.1))},b(a(s)("imagePreview.zoomIn")),1)]),i("div",{class:"absolute right-4 top-4 flex items-center gap-2",onClick:L[3]||(L[3]=st(()=>{},["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},b(a(s)("imagePreview.previous")),9,sc),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},b(a(s)("imagePreview.next")),9,oc),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:w},b(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:Rn({transform:`scale(${r.value})`}),onClick:L[4]||(L[4]=st(()=>{},["stop"]))},null,12,rc)],32)):pe("",!0)]))}};let lo=null;const Wy={maxLines:2e3,maxChars:2e5},uo={maxLines:2e3,maxChars:2e5},ac={"github-dark-default":()=>We(()=>import("./vendor-shiki-theme-github-dark-default-DBX58552.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),"github-light":()=>We(()=>import("./vendor-shiki-theme-github-light-RLAvZv0q.js"),__vite__mapDeps([4,1,2,3])).then(e=>e.default)},ic={bash:()=>We(()=>import("./vendor-shiki-lang-bash-zsQu0xn-.js"),__vite__mapDeps([5,1,2,3])).then(e=>e.default),c:()=>We(()=>import("./vendor-shiki-lang-c-BDF8vgks.js"),__vite__mapDeps([6,1,2,3])).then(e=>e.default),cpp:()=>We(()=>import("./vendor-shiki-lang-cpp-DyDAaXl6.js"),__vite__mapDeps([7,1,2,3])).then(e=>e.default),csharp:()=>We(()=>import("./vendor-shiki-lang-csharp-BWfTXJXw.js"),__vite__mapDeps([8,1,2,3])).then(e=>e.default),css:()=>We(()=>import("./vendor-shiki-lang-css-DbAm1fUO.js"),__vite__mapDeps([9,1,2,3])).then(e=>e.default),diff:()=>We(()=>import("./vendor-shiki-lang-diff-DmGC1G26.js"),__vite__mapDeps([10,1,2,3])).then(e=>e.default),dockerfile:()=>We(()=>import("./vendor-shiki-lang-dockerfile-3x-8396r.js"),__vite__mapDeps([11,1,2,3])).then(e=>e.default),dotenv:()=>We(()=>import("./vendor-shiki-lang-dotenv--IVOlX2Q.js"),__vite__mapDeps([12,1,2,3])).then(e=>e.default),fish:()=>We(()=>import("./vendor-shiki-lang-fish-Bpv3hhJP.js"),__vite__mapDeps([13,1,2,3])).then(e=>e.default),go:()=>We(()=>import("./vendor-shiki-lang-go-CIGC59jP.js"),__vite__mapDeps([14,1,2,3])).then(e=>e.default),html:()=>We(()=>import("./vendor-shiki-lang-html-Bt_TLLZN.js"),__vite__mapDeps([15,1,2,3])).then(e=>e.default),ini:()=>We(()=>import("./vendor-shiki-lang-ini-BIllfys4.js"),__vite__mapDeps([16,1,2,3])).then(e=>e.default),java:()=>We(()=>import("./vendor-shiki-lang-java-CXxu9crF.js"),__vite__mapDeps([17,1,2,3])).then(e=>e.default),javascript:()=>We(()=>import("./vendor-shiki-lang-javascript-Cha7GNZm.js"),__vite__mapDeps([18,1,2,3])).then(e=>e.default),json:()=>We(()=>import("./vendor-shiki-lang-json-CCZCjDUh.js"),__vite__mapDeps([19,1,2,3])).then(e=>e.default),less:()=>We(()=>import("./vendor-shiki-lang-less-DAToytC5.js"),__vite__mapDeps([20,1,2,3])).then(e=>e.default),markdown:()=>We(()=>import("./vendor-shiki-lang-markdown-C6lwMXFp.js"),__vite__mapDeps([21,1,2,3])).then(e=>e.default),python:()=>We(()=>import("./vendor-shiki-lang-python-Bi9rmtY7.js"),__vite__mapDeps([22,1,2,3])).then(e=>e.default),powershell:()=>We(()=>import("./vendor-shiki-lang-powershell-lrpuM0ez.js"),__vite__mapDeps([23,1,2,3])).then(e=>e.default),rust:()=>We(()=>import("./vendor-shiki-lang-rust-GTGDbY6A.js"),__vite__mapDeps([24,1,2,3])).then(e=>e.default),sass:()=>We(()=>import("./vendor-shiki-lang-sass-DFtHupN8.js"),__vite__mapDeps([25,1,2,3])).then(e=>e.default),scss:()=>We(()=>import("./vendor-shiki-lang-scss-BrfBNyyi.js"),__vite__mapDeps([26,1,2,3])).then(e=>e.default),sql:()=>We(()=>import("./vendor-shiki-lang-sql-H6--iFN-.js"),__vite__mapDeps([27,1,2,3])).then(e=>e.default),toml:()=>We(()=>import("./vendor-shiki-lang-toml-aTteTWYL.js"),__vite__mapDeps([28,1,2,3])).then(e=>e.default),tsx:()=>We(()=>import("./vendor-shiki-lang-tsx-DoKZm6AV.js"),__vite__mapDeps([29,1,2,3])).then(e=>e.default),typescript:()=>We(()=>import("./vendor-shiki-lang-typescript-B5awnqri.js"),__vite__mapDeps([30,1,2,3])).then(e=>e.default),vue:()=>We(()=>import("./vendor-shiki-lang-vue-CnrgQ7Z5.js"),__vite__mapDeps([31,1,2,3])).then(e=>e.default),xml:()=>We(()=>import("./vendor-shiki-lang-xml-Bv-TNPJt.js"),__vite__mapDeps([32,1,2,3])).then(e=>e.default),yaml:()=>We(()=>import("./vendor-shiki-lang-yaml-DpxUxQ6M.js"),__vite__mapDeps([33,1,2,3])).then(e=>e.default)};function Wr(e=0){return Number(e)>9999?"3.4rem":"2.6rem"}function Oo(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 Fo(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 lc(e=[],t={}){const n=Oo(e);return Fo(n,{maxHighlightLines:t.maxLines,maxHighlightChars:t.maxChars})}function uc(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
|
|
@@ -36,7 +36,7 @@ ${o}`:o}function ds(e=[]){const t=e.map(n=>({label:String((n==null?void 0:n.labe
|
|
|
36
36
|
${B("原始错误","Raw error")}: ${o.rawMessage}`:n}function Eo(e,t=0){if(!e||t>4)return"";if(typeof e=="string")return Qn(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=Eo(e[o],t+1);if(s)return s}for(const o of Object.values(e)){const s=Eo(o,t+1);if(s)return s}return""}function ms(e={}){return Eo(e)}function dp(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===_t.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?[ds([{label:"ID",value:e.thread_id}])]:[]}}if(o===_t.TURN_STARTED)return{title:B(`${t} 开始执行`,`${t} started`),detail:""};if(o===_t.TURN_COMPLETED){const w=e.usage?[B(`输入 ${Ft(e.usage.input_tokens)}`,`Input ${Ft(e.usage.input_tokens)}`),e.usage.cached_input_tokens?B(`缓存 ${Ft(e.usage.cached_input_tokens)}`,`Cached ${Ft(e.usage.cached_input_tokens)}`):"",B(`输出 ${Ft(e.usage.output_tokens)}`,`Output ${Ft(e.usage.output_tokens)}`)].filter(Boolean).join(" / "):"";return{title:B(`${t} 执行完成`,`${t} completed`),detail:w,detailBlocks:e.usage?[ds([{label:B("输入","Input"),value:Ft(e.usage.input_tokens)},e.usage.cached_input_tokens?{label:B("缓存","Cached"),value:Ft(e.usage.cached_input_tokens)}:null,{label:B("输出","Output"),value:Ft(e.usage.output_tokens)}])]:[]}}if(o==="claude.system"&&!String(e.detail||"").trim())return{title:"",detail:""};if(o===_t.ERROR||o===_t.TURN_FAILED){const w=ms(e)||B(`${t} 执行失败`,`${t} failed`),c=o===_t.ERROR?Ho(w):null;if(c)return{kind:"info",title:B(`网络异常,正在重试 (${c.attempt}/${c.total})`,`Network error, retrying (${c.attempt}/${c.total})`),detail:fn(c.reason||c.rawMessage,n),detailBlocks:Bn(fn(c.reason||c.rawMessage,n),{preferMarkdown:!0})};const S=Jn(w,n);return{kind:"error",title:(S==null?void 0:S.title)||(o===_t.TURN_FAILED?B("本轮运行失败","This run failed"):B(`${t} 返回错误`,`${t} returned an error`)),detail:fn(w,n),detailBlocks:Bn(fn(w,n),{preferMarkdown:!0})}}if(o===_t.ITEM_STARTED)return s.type===ut.REASONING?{kind:"reasoning",title:B("思考过程","Thinking"),detail:s.text||"",detailBlocks:Bn(s.text||"",{preferMarkdown:!0}),groupType:"reasoning",phase:"updated"}:s.type===ut.WEB_SEARCH?{...ur(s,"started"),detailBlocks:ar(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===ut.COLLAB_TOOL_CALL?{...cr(s,"started"),detailBlocks:ir(s)}:s.type===ut.FILE_CHANGE?{...dr(s,"started"),detailBlocks:lr(s)}:s.type===ut.COMMAND_EXECUTION?zn(s).groupType==="todo"?{kind:"todo",title:B("更新待办列表","Update todo list"),detail:Pn(fs(s)),detailBlocks:Cs(s,!1,n),groupType:"todo",phase:"started"}:{kind:"command",title:B("开始执行命令","Command started"),detail:s.command||"",detailBlocks:Cs(s,!1,n),...zn(s),phase:"started"}:s.type===ut.TODO_LIST?{kind:"todo",title:B("更新待办列表","Update todo list"),detail:Pn(s.items),detailBlocks:mo(s),groupType:"todo",phase:"started"}:{title:B(`开始处理 ${s.type||"未知项目"}`,`Started handling ${s.type||"unknown item"}`),detail:""};if(o===_t.ITEM_UPDATED&&s.type===ut.TODO_LIST)return{kind:"todo",title:B("更新待办列表","Update todo list"),detail:Pn(s.items),detailBlocks:mo(s),groupType:"todo",phase:"updated"};if(o===_t.ITEM_COMPLETED){if(s.type===ut.AGENT_MESSAGE&&s.text)return{kind:"result",title:B(`${t} 已返回结果`,`${t} returned a result`),detail:""};if(s.type===ut.WEB_SEARCH)return{...ur(s,"completed"),detailBlocks:ar(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===ut.COLLAB_TOOL_CALL)return{...cr(s,"completed"),detailBlocks:ir(s)};if(s.type===ut.FILE_CHANGE)return{...dr(s,"completed"),detailBlocks:lr(s)};if(s.type===ut.COMMAND_EXECUTION){if(zn(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:Pn(fs(s)),detailBlocks:Cs(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,pa(s.aggregated_output)].filter(Boolean).join(`
|
|
37
37
|
|
|
38
38
|
`),detailBlocks:Cs(s,!0,n),...zn(s),phase:"completed"}}return s.type===ut.TODO_LIST?{kind:"todo",title:B("更新待办列表","Update todo list"),detail:Pn(s.items),detailBlocks:mo(s),groupType:"todo",phase:"completed"}:{title:B(`完成 ${s.type||"未知项目"}`,`Completed ${s.type||"unknown item"}`),detail:""}}return{title:B(`事件: ${o}`,`Event: ${o}`),detail:""}}function fp(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 ka(e={},t){if(typeof e=="string"){const r=e.trim();return r?{id:t(),kind:"info",title:r,detail:""}:null}const n=String(e.title||"").trim(),o=String(e.detail||"").trim(),s=Array.isArray(e.detailBlocks)&&e.detailBlocks.length?e.detailBlocks.filter(Boolean):o?Bn(o,{preferMarkdown:e.kind==="error"}):[];return!n&&!o?null:{id:t(),kind:e.kind||"info",title:n||o,detail:n?o:"",detailBlocks:s,groupType:String(e.groupType||"").trim(),groupTarget:String(e.groupTarget||"").trim(),toolName:String(e.toolName||"").trim(),phase:String(e.phase||"").trim()}}function pp(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"?Ps(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:Zn()}}function $n(e,t,n){const o=ka(t,n);o&&(e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120))}function mp(e,t,n){var s;const o=ka(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 gp(e,t={},n,o=()=>{}){var r,l,u,p,w,c,S,h,g;const s=jr(t.type);if(s===Xt.SESSION){o(t.session);return}if(s===Xt.SESSION_UPDATED){o(t.session);return}if(s===Xt.STATUS){if(t.stage==="starting"||t.stage==="resuming")return;$n(e,{title:ls(t)||B("状态已更新","Status updated"),detail:""},n);return}if(s===Xt.STDERR){const f=Jn(t.text,e.engine);$n(e,{kind:"error",title:(f==null?void 0:f.title)||"stderr",detail:fn(t.text,e.engine)},n);return}if(s===Xt.STDOUT){$n(e,{kind:"command",title:"stdout",detail:t.text},n);return}if(s===Xt.AGENT_EVENT){if(ip(e,t.event),((r=t.event)==null?void 0:r.type)===_t.THREAD_STARTED)return;const f=dp(t.event,Ut(e),e.engine);String(f.title||"").startsWith(B("网络异常,正在重试","Network error, retrying"))?mp(e,f,n):$n(e,f,n),((l=t.event)==null?void 0:l.type)===_t.ITEM_COMPLETED&&((p=(u=t.event)==null?void 0:u.item)==null?void 0:p.type)===ut.AGENT_MESSAGE&&((c=(w=t.event)==null?void 0:w.item)!=null&&c.text)&&(e.responseMessage=t.event.item.text);const P=ms(t.event)||B(`${Ut(e)} 执行失败`,`${Ut(e)} failed`);if(!(((S=t.event)==null?void 0:S.type)==="error"?Ho(P):null)&&(((h=t.event)==null?void 0:h.type)===_t.ERROR||((g=t.event)==null?void 0:g.type)===_t.TURN_FAILED)){const v=ms(t.event)||B(`${Ut(e)} 执行失败`,`${Ut(e)} failed`);e.errorMessage=fn(v,e.engine),e.status="error"}return}if(s===Xt.COMPLETED){$n(e,{kind:"result",title:B("本轮执行结束","Run finished"),detail:""},n);const f=ls(t);f&&(e.responseMessage=f);return}if(s===Xt.STOPPED){$n(e,{title:ls(t)||B("执行已手动停止","Execution stopped manually"),detail:""},n);return}if(s===Xt.ERROR){const f=ls(t),P=Jn(f,e.engine);$n(e,{kind:"error",title:(P==null?void 0:P.title)||B("执行失败","Execution failed"),detail:fn(f||B(`${Ut(e)} 执行失败`,`${Ut(e)} failed`),e.engine)},n)}}function hp(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=Jn(o,n),l=Jn(s,n);return!r&&!!l}function vp(e,t={}){e.status=t.status||"completed",e.responseMessage=String(t.responseMessage||e.responseMessage||""),e.finishedAt=String(t.finishedAt||e.finishedAt||"");const n=fn(String(t.errorMessage||""),e.engine),o=String(e.errorMessage||"");return e.errorMessage=hp(t.errorMessage,o,e.engine)?o:n,e.status==="completed"&&!e.responseMessage&&(e.responseMessage=B(`本轮 ${Ut(e)} 执行已完成,没有返回额外文本。`,`${Ut(e)} completed in this run without returning additional text.`)),e}function qo(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)||{};gp(e,r,n,o);const l=jr(r.type);return l===Xt.COMPLETED?(e.status="completed",e.finishedAt=new Date().toISOString()):l===Xt.STOPPED?(e.status="stopped",e.errorMessage="",e.finishedAt=new Date().toISOString()):l===Xt.ERROR&&(e.status="error",e.errorMessage=fn(String(ls(r)||e.errorMessage||B(`${Ut(e)} 执行失败`,`${Ut(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 fr(e,t,n,o){const s=pp(e,t);return(e.events||[]).forEach(r=>{qo(s,r,n,o)}),vp(s,e)}const yp=1800,pr=7200,Sp=15e3,go={clearTaskCodexRuns:wl,listCodexRunEvents:yl,listTaskCodexRuns:vl};function us(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 wp(e=[],t=!0){const n=Array.isArray(e)?e:[];return JSON.stringify(n.map(o=>us(o,t)))}function xp(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function bp(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 P=0,Z=0,v=null,L="",U=null,K=null,M="",J=!!(f!=null&&f.value),A=0;const G=new Map;function de(){return P+=1,P}function ge(){return Z+=1,Z}function $(){U&&(window.clearInterval(U),U=null)}function ee(){K&&(window.clearInterval(K),K=null)}function le(){A=Date.now()}function ne(){G.clear(),n.value=[],s.value=!1,r.value=0,l.value="",M="",L="",P=0,Z=0,c()}function ve(){const W=[...n.value].reverse().find(oe=>ps(oe.status))||null;if(l.value=(W==null?void 0:W.runId)||"",s.value=!!W,W!=null&&W.startedAt){const oe=Date.parse(String(W.startedAt||""));r.value=Number.isFinite(oe)?oe:Date.now();return}r.value=0}function _(W=null){return W?{...W}:xp()}function H(W,oe=null){if(!(oe!=null&&oe.runId)||W.eventsLoaded||!oe.eventsLoaded)return G.has(W.runId)&&(W.eventsLoading=!0),W;const fe=Math.max(Math.max(0,Number(oe.lastEventSeq)||0),Math.max(0,Number(oe.eventCount)||0),Array.isArray(oe.events)?oe.events.length:0),$e=Math.max(0,Number(W.eventCount)||0);return fe<$e?(G.has(W.runId)&&(W.eventsLoading=!0),W):(W.events=Array.isArray(oe.events)?[...oe.events]:[],W.eventCount=Math.max(Math.max(0,Number(W.eventCount)||0),Math.max(0,Number(oe.eventCount)||0),W.events.length),W.eventsLoaded=!0,W.eventsLoading=G.has(W.runId),W.lastEventSeq=Math.max(0,Number(oe.lastEventSeq)||0),W.summary=_(oe.summary),W)}function E(W,oe){const fe=Co(n.value,W);return fe?(fe.eventsLoading=!!oe,n.value=[...n.value],fe):null}async function Be(W,oe={}){const fe=String((W==null?void 0:W.runId)||"").trim(),{force:$e=!1}=oe;if(!fe)return[];const me=Co(n.value,fe)||W;if(me!=null&&me.eventsLoaded&&!$e)return me.events;if(G.has(fe))return G.get(fe);E(fe,!0);const Ne=(async()=>{var he;try{const Me=us(me,!!(f!=null&&f.value)),Ke=await go.listCodexRunEvents(fe,{limit:5e3}),De=rp(n.value,fe,Ke,ge,Ge=>{h(Ge,{preserveRunning:!0})});if(!De)return Array.isArray(me==null?void 0:me.events)?me.events:[];const dt=JSON.stringify(Me)!==JSON.stringify(us(De,!!(f!=null&&f.value)));return n.value=[...n.value],dt&&t.active&&((he=n.value.at(-1))==null?void 0:he.runId)===fe&&w(),De.events}catch(Me){throw u.value=Me.message,Me}finally{E(fe,!1),G.delete(fe)}})();return G.set(fe,Ne),Ne}function Pe(W,oe){const fe=String(W||"").trim();if(!fe||!oe)return!1;const $e=n.value.findIndex(Ke=>Ke.runId===fe);if($e<0)return!1;const me=n.value[$e],Ne=us(me,!!(f!=null&&f.value));if(!qo(me,oe,ge,Ke=>{h(Ke,{preserveRunning:!0})}))return!0;const Me=JSON.stringify(Ne)!==JSON.stringify(us(me,!!(f!=null&&f.value)));return n.value=[...n.value],ve(),Me&&w(),!0}function Re(){if($(),ee(),!(!t.active||!s.value||!t.taskSlug)){if(p){K=window.setInterval(()=>{Xe({force:!0}).catch(()=>{});const W=Date.now();W-A<pr||(A=W,g({force:!0}).catch(()=>{}))},Sp);return}U=window.setInterval(()=>{Xe({force:!0}).catch(()=>{});const W=Date.now();W-A<pr||(A=W,g({force:!0}).catch(()=>{}))},yp)}}function Ve(W=[]){const oe=[...o.value],fe=new Map(n.value.filter(me=>String((me==null?void 0:me.runId)||"").trim()).map(me=>[String(me.runId||"").trim(),me])),$e=me=>{if(!(me!=null&&me.id))return;const Ne=oe.findIndex(he=>he.id===me.id);Ne>=0?oe[Ne]=S(oe[Ne],me,{preserveRunning:!0}):oe.unshift(S(null,me,{preserveRunning:!0}))};P=0,Z=0,n.value=[...W||[]].reverse().map(me=>{const Ne=fr(me,de,ge,$e);return H(Ne,fe.get(String((me==null?void 0:me.id)||"").trim())||null)}),o.value=oe,ve()}async function Xe(W={}){const{force:oe=!1,scrollToLatest:fe=!1}=W,$e=String(t.taskSlug||"").trim();if(!(!$e||!t.active&&!oe))return v&&L===$e||v&&!oe||(L=$e,v=(async()=>{try{const Ne=(await go.listTaskCodexRuns($e,{limit:30,events:"latest"})).items||[],he=!!(f!=null&&f.value),Me=wp(Ne,he),Ke=fe||M&&J===he&&Me!==M;Ve(Ne),M=Me,J=he,Re();const De=n.value.at(-1)||null;if(De!=null&&De.runId&&!De.eventsLoaded){const dt=De.runId;Be(De).catch(()=>{}).finally(()=>{var Ge;fe&&t.active&&((Ge=n.value.at(-1))==null?void 0:Ge.runId)===dt&&w({force:!0})})}Ke&&w({force:fe})}catch(me){u.value=me.message}finally{v=null,L=""}})()),v}function Je(W={}){const oe=(W==null?void 0:W.run)||null,fe=(W==null?void 0:W.session)||null;if(fe&&h(fe,{preserveRunning:!0}),!(oe!=null&&oe.id)){ve(),w({force:!0});return}const me=fr(oe,de,ge,he=>{h(he,{preserveRunning:!0})}),Ne=n.value.findIndex(he=>he.runId===me.runId);if(Ne>=0){const he=[...n.value];he.splice(Ne,1,me),n.value=he}else n.value=[...n.value,me];ve(),w({force:!0})}async function Ee(){if(!(!t.taskSlug||s.value))try{await go.clearTaskCodexRuns(t.taskSlug),ne(),w({force:!0})}catch(W){u.value=W.message}}return{applyCreatedRun:Je,applyIncomingRunEvent:Pe,clearRealtimeReconcileTimer:ee,clearRunPollTimer:$,clearTurns:Ee,loadTurnEvents:Be,markFallbackSessionPollNow:le,refreshRunHistory:Xe,resetRunHistoryState:ne,syncRunningStateFromTurns:ve,updatePollingState:Re}}const kp=1500,Tp=3e4;function _p(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:P,markFallbackSessionPollNow:Z,showToast:v,getActiveAgentBinding:L=null}=e;let U=null,K=null,M=0,J=0;const A=q(()=>typeof t.buildPrompt=="function"||!!String(t.prompt||"").trim()),G=q(()=>n.value.length>0),de=q(()=>or(n.value,c.value)),ge=q(()=>G.value?"":Ye("projectManager.noProjects"));async function $(Ee={}){const{force:W=!1}=Ee;if(U)return U;const oe=Date.now();return!W&&M&&oe-M<kp?{items:n.value,workspaces:o.value}:(U=(async()=>{s.value=!0,p.value="";try{const $e=(await al()).items||[];return n.value=$e,M=Date.now(),{items:$e,workspaces:o.value}}catch(fe){throw p.value=fe.message,fe}finally{s.value=!1,U=null}})(),U)}async function ee(Ee={}){const{force:W=!1}=Ee;if(K)return K;const oe=Date.now();return!W&&J&&oe-J<Tp?{items:o.value}:(K=(async()=>{try{const fe=await il();return o.value=fe.items||[],J=Date.now(),{items:o.value}}finally{K=null}})(),K)}async function le(Ee={}){const{forceSessions:W=!1,forceWorkspaces:oe=!1}=Ee,[fe,$e]=await Promise.all([$({force:W}),ee({force:oe})]);return{items:(fe==null?void 0:fe.items)||n.value,workspaces:($e==null?void 0:$e.items)||o.value}}function ne(Ee=""){const W=String(Ee||"").trim();!W||o.value.includes(W)||(o.value=[W,...o.value])}function ve(){w.value=!0,ee().catch(()=>{})}function _(){w.value=!1}function H(Ee){const W=String(Ee||"").trim();if(t.sessionSelectionLocked&&W&&W!==c.value){p.value=t.sessionSelectionLockReason||Ye("taskActions.sessionLocked");return}c.value=W}function E(){le({forceSessions:!0,forceWorkspaces:!0}).catch(()=>{})}async function Be(Ee){r.value=!0,p.value="";try{const W=await ll(Ee);return g(W),ne(W.cwd),c.value=W.id,W}catch(W){throw p.value=W.message,W}finally{r.value=!1}}async function Pe(Ee,W){r.value=!0,p.value="";try{const oe=await ul(Ee,W);return g(oe),ne(oe.cwd),oe}catch(oe){throw p.value=oe.message,oe}finally{r.value=!1}}async function Re(Ee){var oe;const W=String(Ee||"").trim();if(!W)return{deletedSessionId:"",selectedSessionId:c.value};r.value=!0,p.value="";try{await cl(W);const fe=n.value.filter(me=>me.id!==W);n.value=fe;let $e=c.value;return c.value===W&&($e=((oe=or(fe,"")[0])==null?void 0:oe.id)||"",c.value=$e),{deletedSessionId:W,selectedSessionId:$e}}catch(fe){throw p.value=fe.message,fe}finally{r.value=!1}}async function Ve(Ee){const W=String(Ee||"").trim();if(!W)return null;r.value=!0,p.value="";try{const oe=await dl(W);return oe!=null&&oe.session&&g(oe.session),Z(),await Promise.all([P({force:!0}),$({force:!0})]),v==null||v({message:Ye("projectManager.sessionReset"),type:"success"}),oe}catch(oe){throw p.value=oe.message,oe}finally{r.value=!1}}async function Xe(){if(!t.taskSlug||!A.value||l.value||u.value)return!1;if(!c.value){const Ee=Ye("projectManager.selectProject");return p.value=Ee,v==null||v({message:Ee,type:"warning"}),!1}p.value="";try{await le({forceSessions:!0});const Ee=n.value.find(De=>De.id===c.value)||null;if(!Ee)return p.value=Ye("projectManager.projectMissing"),!1;if(Ee.running)return p.value=Ye("sessionTurns.currentProjectRunning"),!1;const W=typeof t.buildPrompt=="function"?await t.buildPrompt():t.prompt,oe=typeof t.buildPromptBlocks=="function"?await t.buildPromptBlocks():[],fe=hi({prompt:W,promptBlocks:oe});if(fe.reason){const De=fe.reason==="unsupported_blocks"?Ye("sessionPanel.shellUnsupportedBlocks"):Ye("sessionPanel.shellEmptyCommand");return p.value=De,v==null||v({message:De,type:"warning"}),!1}if(!String(W||"").trim())return p.value=Ye("sessionTurns.noPromptToSend"),!1;const $e=Cp(Ee),me=typeof L=="function"?L(Ee):null,Ne=String((me==null?void 0:me.engine)||"").trim();if(Ne&&!$e.some(De=>De.engine===Ne)){const De=Ye("sessionPanel.agentNotEnabled");return p.value=De,v==null||v({message:De,type:"warning"}),!1}const he=me,Me=String(fe.mode==="shell"?c.value:(he==null?void 0:he.sessionRecordId)||c.value).trim(),Ke=await Sl(t.taskSlug,{projectSessionId:c.value,sessionId:Me,displayEngine:Ne,prompt:fe.mode==="shell"?fe.prompt:W,promptBlocks:oe,commandMode:fe.mode,command:fe.command});return f(Ke),typeof t.afterSend=="function"&&Promise.resolve(t.afterSend()).catch(De=>{console.error("[promptx] afterSend failed",De)}),h||(Z(),Promise.all([P({force:!0}),$({force:!0})]).catch(De=>{p.value=De.message})),!0}catch(Ee){return p.value=Ee.message,!1}}async function Je(){if(!(!S.value||u.value))try{u.value=!0,await xl(S.value),h||(Z(),await Promise.all([P({force:!0}),$({force:!0})]))}catch(Ee){u.value=!1,p.value=Ee.message}}return{closeManager:_,handleCreateSession:Be,handleDeleteSession:Re,handleResetSession:Ve,handleSelectSession:H,handleSend:Xe,handleUpdateSession:Pe,hasPrompt:A,helperText:ge,loadSessions:$,loadSessionResources:le,loadWorkspaces:ee,openManager:ve,refreshSessionsForSelection:E,sortedSessions:de,stopSending:Je}}function Cp(e={}){return Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length?e.agentBindings:e!=null&&e.id?[{engine:Ep(e.engine),sessionRecordId:e.id,sessionId:e.sessionId||"",isDefault:!0,running:!!e.running,started:!!e.started}]:[]}function Ep(e=""){const t=String(e||"").trim().toLowerCase();return t==="claude"||t==="claudecode"?"claude-code":t==="opencode"||t==="open-code"?"opencode":t==="kimi"||t==="kimicode"||t==="kimi-code"?"kimi-code":t==="claude-code"?"claude-code":"codex"}const Ap=1200,Ip=[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 E=typeof window<"u"?window:globalThis;return typeof(E==null?void 0:E.setTimeout)!="function"||typeof(E==null?void 0:E.clearTimeout)!="function"?null:{setTimeout:E.setTimeout.bind(E),clearTimeout:E.clearTimeout.bind(E)}}function P(){if(typeof window>"u"||!r.length){r=[];return}r.forEach(E=>{window.cancelAnimationFrame(E)}),r=[]}function Z(){s+=1,P()}function v(){const E=f();if(!E){S=[],h=0;return}S.forEach(Be=>{E.clearTimeout(Be)}),S=[],h&&(E.clearTimeout(h),h=0)}function L(){var E;(E=g==null?void 0:g.disconnect)==null||E.call(g),g=null}function U(){return c>Date.now()}function K(E){u=!!E,(n==null?void 0:n.value)!==void 0&&(n.value=u)}function M(){l=!1,p+=1,w=!0,K(!1)}function J(E=t==null?void 0:t.value){return E?E.scrollHeight-E.scrollTop-E.clientHeight<=o:!0}function A(){return U()||w&&!l}function G(){w&&!l&&K(!1)}function de(){if(w=J(),!w){Z();return}G()}function ge(){p+=1,l=!0,c=0,v(),L(),Z()}function $(){const E=p+1;p=E,ct(()=>{E===p&&requestAnimationFrame(()=>{E===p&&(l=!1,w=J(),G())})})}function ee(){l=!0,c=0,v(),L(),Z()}function le(){$()}function ne(E={}){const{force:Be=!1}=E;Be&&M(),Z();const Pe=s;ct(()=>{if(!(t==null?void 0:t.value)||Pe!==s)return;if(!Be&&!A()){K(!0);return}const Ve=()=>{const Je=t==null?void 0:t.value;!Je||Pe!==s||(Je.scrollTop=Je.scrollHeight,w=!0,K(!1))};Ve(),r=[requestAnimationFrame(()=>{Ve(),r=[requestAnimationFrame(Ve)]})]})}function ve(){ne({force:!0})}function _(E={}){const Be=Number(E.durationMs),Pe=Math.max(0,Number.isFinite(Be)?Be:Ap),Re=f();M(),c=Date.now()+Pe,v(),L(),Re&&(S=Ip.map(Ve=>Re.setTimeout(()=>{U()&&ne({force:!0})},Ve)),h=Re.setTimeout(()=>{c=0,h=0,v(),L()},Pe+40)),typeof window<"u"&&typeof window.ResizeObserver=="function"&&(g=new window.ResizeObserver(()=>{U()&&ne({force:!0})}),t!=null&&t.value&&g.observe(t.value)),ne({force:!0})}function H(){p+=1,c=0,v(),L(),Z()}return{cancelScheduledScrollToBottom:Z,destroy:H,handleTranscriptScroll:de,handleTranscriptTouchEnd:le,handleTranscriptTouchMove:ee,handleTranscriptTouchStart:ge,beginForceFollowWindow:_,isTranscriptNearBottom:J,resetAutoStickToBottom:M,scheduleScrollToBottom:ne,scrollToBottom:ve}}const Pp=150,Ta="promptx:session-panel:show-process";function Dp(e){return!(e==="0"||e==="false")}function Lp(){if(typeof window>"u")return!0;try{return Dp(window.localStorage.getItem(Ta))}catch{return!0}}function Mp(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 Bp(e,t){const n=fa(),o=V([]),s=V([]),r=V(!1),l=V(!1),u=V(!1),p=V(!1),w=V(""),c=V([]),S=V(null),h=V(0),g=V(0),f=V(!1),P=V(""),Z=V(!1),v=V(Lp()),L=typeof window<"u"&&typeof window.EventSource<"u";function U(se=""){const Oe=typeof se=="object"&&se!==null?String(se.message||"").trim():String(se||"").trim();Oe&&t("toast",typeof se=="object"&&se!==null?{...se,message:Oe}:Oe)}let K=null,M=null,J=null,A={sessions:!1,runs:!1};const G=q({get(){return String(e.selectedSessionId||"").trim()},set(se){t("selected-session-change",String(se||"").trim())}}),de=q(()=>p.value?Ye("sessionPanel.stopping"):`${Ye("projectManager.running")} (${ha(g.value)})`),ge=q(()=>o.value.find(se=>se.id===G.value)||null),$=q(()=>{var Oe;if(Array.isArray((Oe=ge.value)==null?void 0:Oe.agentBindings)&&ge.value.agentBindings.length)return ge.value.agentBindings;const se=ge.value;return se!=null&&se.id?[{engine:se.engine,sessionRecordId:se.id,sessionId:se.sessionId||"",started:!!se.started,running:!!se.running,isDefault:!0}]:[]}),ee=q({get(){var Oe,at;const se=ho(e.selectedAgentEngine,$.value);return se||((Oe=$.value.find(Qe=>Qe.isDefault))==null?void 0:Oe.engine)||((at=$.value[0])==null?void 0:at.engine)||""},set(se){const Oe=ho(se,$.value);Oe&&t("update:selectedAgentEngine",Oe)}}),le=q(()=>$.value.find(se=>se.engine===ee.value)||$.value[0]||null),{beginForceFollowWindow:ne,destroy:ve,handleTranscriptScroll:_,handleTranscriptTouchEnd:H,handleTranscriptTouchMove:E,handleTranscriptTouchStart:Be,resetAutoStickToBottom:Pe,scheduleScrollToBottom:Re,scrollToBottom:Ve}=$p({transcriptRef:S,hasNewerMessages:Z});function Xe(se,Oe,at={}){return Mp(se,Oe,at)}function Je(se,Oe={}){if(!(se!=null&&se.id))return;const at=[...o.value],Qe=at.findIndex(jt=>jt.id===se.id);Qe>=0?at[Qe]=Xe(at[Qe],se,Oe):at.unshift(Xe(null,se,Oe)),o.value=at}const{applyCreatedRun:Ee,applyIncomingRunEvent:W,clearRealtimeReconcileTimer:oe,clearRunPollTimer:fe,clearTurns:$e,loadTurnEvents:me,markFallbackSessionPollNow:Ne,refreshRunHistory:he,resetRunHistoryState:Me,updatePollingState:Ke}=bp({props:e,turns:c,sessions:o,sending:u,sendingStartedAt:h,currentRunningRunId:P,sessionError:w,supportsServerEvents:L,scheduleScrollToBottom:Re,resetAutoStickToBottom:Pe,showProcessLogs:v,mergeSessionRecord:Xe,mergeSession:Je,loadSessions:(...se)=>yt(...se)}),{closeManager:De,handleCreateSession:dt,handleDeleteSession:Ge,handleResetSession:wt,handleSelectSession:Ct,handleSend:Ue,handleUpdateSession:_e,helperText:$t,loadSessions:yt,loadSessionResources:Ze,loadWorkspaces:C,openManager:F,refreshSessionsForSelection:te,sortedSessions:Ce,stopSending:ze}=_p({props:e,sessions:o,workspaces:s,loading:r,managerBusy:l,sending:u,stopping:p,sessionError:w,showManager:f,selectedSessionId:G,currentRunningRunId:P,supportsServerEvents:L,mergeSession:Je,applyCreatedRun:Ee,refreshRunHistory:he,markFallbackSessionPollNow:Ne,showToast:U,getActiveAgentBinding:()=>le.value});function Le(){K&&(window.clearInterval(K),K=null)}function tt(){Le(),h.value||(h.value=Date.now()),g.value=Math.max(0,Math.floor((Date.now()-h.value)/1e3)),K=window.setInterval(()=>{g.value=Math.max(0,Math.floor((Date.now()-h.value)/1e3))},1e3)}function rt(){J&&(window.clearTimeout(J),J=null)}function Et(){rt();const se=A;A={sessions:!1,runs:!1},se.sessions&&yt({force:!0}).catch(()=>{}),se.runs&&he({force:!0}).catch(()=>{})}function gt(se={}){typeof window>"u"||(A={sessions:A.sessions||!!se.sessions,runs:A.runs||!!se.runs},!(J||!A.sessions&&!A.runs)&&(J=window.setTimeout(()=>{Et()},Pp)))}function xt(se){return wa(se,{currentRunningRunId:P.value,runningElapsedSeconds:g.value,nowMs:Date.now()})}function St(se=""){if(!se)return"";const Oe=new Date(se);return Number.isNaN(Oe.getTime())?"":Oe.toLocaleTimeString(Ys(),{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Ht(se){return se.status==="error"||se.status==="stop_timeout"?"theme-process-error":se.status==="interrupted"||se.status==="stopped"?"theme-process-stopped":se.status==="completed"?"theme-process-completed":"theme-process-running"}function en(){v.value=!v.value}function qt(se){return!!(se.responseMessage||se.errorMessage||se.status==="completed")}return Ie(v,se=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ta,se?"true":"false")}catch{}},{immediate:!0}),Ie(u,se=>{se?(h.value||(h.value=Date.now()),tt()):(Le(),h.value=0,g.value=0,p.value=!1),Ke(),t("sending-change",se)},{immediate:!0}),Ie(g,(se,Oe)=>{e.active&&Oe===0&&se>0&&Re()}),Ie(()=>!!e.taskRunning,se=>{!e.active||se||!u.value||gt({sessions:!0,runs:!0})}),Ie(()=>e.active,se=>{if(se){Ze({forceSessions:!0}).catch(()=>{});return}rt(),oe(),fe()},{immediate:!0}),Ie(()=>e.taskSlug,()=>{Me(),f.value=!1,w.value="",e.active&&(ne(),he({force:!0,scrollToLatest:!0}).catch(()=>{}))},{immediate:!0}),Ie(()=>{var se;return[((se=ge.value)==null?void 0:se.id)||"",$.value.map(Oe=>Oe.engine).join(","),e.selectedAgentEngine||""].join(`
|
|
39
|
-
`)},()=>{var z,Y,ce;const se=String(((z=ge.value)==null?void 0:z.id)||"").trim(),Oe=$.value,at=ee.value;if(t("agent-bindings-change",{sessionId:se,bindings:Oe,selectedEngine:at}),!se||ho(e.selectedAgentEngine,Oe))return;const jt=((Y=Oe.find(ye=>ye.isDefault))==null?void 0:Y.engine)||((ce=Oe[0])==null?void 0:ce.engine)||"";jt&&t("update:selectedAgentEngine",jt)},{immediate:!0}),Ot(()=>{Le(),oe(),fe(),rt(),ve(),M==null||M()}),Ie(()=>n.readyVersion.value,()=>{const se=String(e.taskSlug||"").trim();!e.active&&!f.value||(f.value&&C().catch(()=>{}),gt({sessions:!0,runs:!!se}))}),Ie(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!f.value||gt({sessions:!0})}),Ie(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||gt({sessions:!0,runs:!0})}),Ie(()=>String(e.taskSlug||"").trim(),se=>{M==null||M(),M=null,se&&(M=Uf(se,({runId:Oe,event:at})=>{if(!e.active)return;W(Oe,at)||gt({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:le,activeAgentEngine:ee,clearTurns:$e,closeManager:De,formatTurnTime:St,getProcessCardClass:Ht,getProcessStatus:fp,getTurnAgentLabel:Ut,getTurnSummaryDetail:ba,getDisplayTurnSummaryItems:xt,getTurnSummaryStatus:xa,handleCreateSession:dt,handleDeleteSession:Ge,handleResetSession:wt,handleSelectSession:Ct,handleSend:Ue,handleUpdateSession:_e,loadTurnEvents:me,hasTurnSummary:up,helperText:$t,loading:r,managerBusy:l,openManager:F,refreshSessionsForSelection:te,selectedSessionId:G,sending:u,showProcessLogs:v,stopping:p,sessionError:w,shouldShowResponse:qt,showManager:f,sortedSessions:Ce,stopSending:ze,toggleProcessLogs:en,hasNewerMessages:Z,transcriptRef:S,turns:c,workspaces:s,workingLabel:de,sessions:o,loadSessions:yt,currentProjectAgentBindings:$,handleTranscriptScroll:_,handleTranscriptTouchEnd:H,handleTranscriptTouchMove:E,handleTranscriptTouchStart:Be,scheduleScrollToBottom:Re,scrollToBottom:Ve}}function ho(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const Rp=8,Np=320,Op=10,Fp=400;function mr(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function Up(e={}){const{turns:t,loadTurnEvents:n}=e,o=V({}),s=V({}),r=V({});function l(A){return String((A==null?void 0:A.runId)||(A==null?void 0:A.id)||"").trim()}function u(A){const G=l(A);return!!G&&G===l(t.value.at(-1))}function p(A){return Math.max(0,Number(A==null?void 0:A.eventCount)||0,Array.isArray(A==null?void 0:A.events)?A.events.length:0)}function w(A){return!ps(A==null?void 0:A.status)&&!u(A)&&p(A)>3}function c(A){return mr(A==null?void 0:A.prompt,Rp,Np)}function S(A){return!ps(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 mr(h(A),Op,Fp)}function f(A){return!(A!=null&&A.errorMessage)&&!u(A)&&g(A)}function P(A){return p(A)>0}function Z(A=[]){const G=new Set((A||[]).map($=>l($)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([$])=>G.has($))),s.value=Object.fromEntries(Object.entries(s.value).filter(([$])=>G.has($))),r.value=Object.fromEntries(Object.entries(r.value).filter(([$])=>G.has($)));const de=(A||[]).at(-1)||null,ge=l(de);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 G=l(A);return G?Object.prototype.hasOwnProperty.call(o.value,G)?!!o.value[G]:w(A):!1}async function L(A){const G=l(A);if(!G)return;const de=!v(A);o.value={...o.value,[G]:de},!de&&P(A)&&!A.eventsLoaded&&!A.eventsLoading&&await n(A).catch(()=>{})}function U(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(s.value,G)?!!s.value[G]:S(A):!1}function K(A){const G=l(A);!G||!c(A)||(s.value={...s.value,[G]:!U(A)})}function M(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(r.value,G)?!!r.value[G]:f(A):!1}function J(A){const G=l(A);!G||!g(A)||(r.value={...r.value,[G]:!M(A)})}return Ie(t,A=>{Z(A)},{immediate:!0,deep:!0}),{canCollapsePrompt:c,canCollapseResponse:g,getTurnEventCollapseKey:l,getTurnEventCount:p,hasTurnEventHistory:P,isLatestTurn:u,isPromptCollapsed:U,isResponseCollapsed:M,isTurnEventsCollapsed:v,togglePrompt:K,toggleResponse:J,toggleTurnEvents:L}}function jp(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function Vp(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 zp(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function vo(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 yo(e="",t=[],n=[]){var l;const o=jp(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=Vp([{label:"类型",value:zp(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 _a(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:vo(n,e.length),detail:"",detailBlocks:yo(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:vo(n,e.length),detail:"",detailBlocks:yo(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:vo(n,o.length),detail:"",detailBlocks:yo(n,o,o),isGrouped:!0,groupedCount:o.length}]}function Hp(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]=_a(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 qp(e=[]){var o;const t=Hp(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(..._a(u))}return n}const Kp={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},Wp={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},Gp={class:"flex flex-col gap-2"},Xp={class:"flex items-center gap-2"},Yp=["title"],Jp={class:"flex shrink-0 items-center gap-1.5"},Qp=["aria-pressed","aria-label","title"],Zp=["disabled"],em={class:"hidden sm:inline"},tm=["disabled"],nm={class:"hidden sm:inline"},sm=["aria-label"],om=["aria-pressed"],rm=["aria-pressed","title","onClick"],am={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},im={class:"min-h-0 flex-1"},lm={key:0,class:"theme-empty-state px-4 py-6 text-sm"},um={key:1,class:"theme-empty-state px-4 py-6 text-sm"},cm=["data-turn-id","data-run-id"],dm={class:"flex justify-end"},fm={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)]"},pm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},mm={class:"font-semibold"},gm={class:"flex items-center gap-2"},hm=["onClick"],vm={class:"relative mt-2"},ym={key:0,class:"space-y-3"},Sm={key:0,class:"whitespace-pre-wrap break-words leading-7"},wm=["onClick"],xm=["src","alt"],bm={key:1,class:"whitespace-pre-wrap break-words leading-7"},km={key:0,class:"flex min-w-0 justify-start"},Tm={class:"flex items-center justify-between gap-3 text-xs"},_m={class:"font-semibold"},Cm={class:"flex items-center gap-2"},Em=["disabled","onClick"],Am={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Im={key:1,class:"mt-2 min-w-0 space-y-2"},$m={class:"text-sm font-medium leading-6"},Pm={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Dm={key:3,class:"mt-2 text-xs text-current"},Lm={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Mm={key:0,class:"leading-5"},Bm={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},Rm={key:2,class:"mt-2 flex flex-wrap gap-2"},Nm={class:"font-medium"},Om={key:1,class:"flex justify-start"},Fm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},Um={class:"font-semibold"},jm={class:"flex items-center gap-2"},Vm=["onClick"],zm=["onClick"],Hm={class:"relative mt-2"},qm={key:0,class:"whitespace-pre-wrap break-words"},Km=["innerHTML"],Wm={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"},Gm=["disabled"],Xm={key:2,class:"task-loading-dots","aria-hidden":"true"},gr="promptx:selected-agent-filter-map",Ym={__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=xo(()=>We(()=>import("./CodexSessionManagerDialog-BN4cweyO.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:P,handleResetSession:Z,handleSelectSession:v,handleSend:L,handleTranscriptScroll:U,handleTranscriptTouchEnd:K,handleTranscriptTouchMove:M,handleTranscriptTouchStart:J,handleUpdateSession:A,helperText:G,loadTurnEvents:de,loading:ge,managerBusy:$,openManager:ee,refreshSessionsForSelection:le,selectedSessionId:ne,sending:ve,showProcessLogs:_,stopping:H,hasTurnSummary:E,hasNewerMessages:Be,sessionError:Pe,shouldShowResponse:Re,showManager:Ve,sortedSessions:Xe,stopSending:Je,toggleProcessLogs:Ee,transcriptRef:W,turns:oe,workspaces:fe,sessions:$e,loadSessions:me,currentProjectAgentBindings:Ne,scheduleScrollToBottom:he,scrollToBottom:Me}=Bp(r,s),Ke=V(null),De=V(!1),dt=V(""),Ge=V("");function wt(){try{const I=JSON.parse(window.localStorage.getItem(gr)||"{}");if(I&&typeof I=="object"&&!Array.isArray(I))return I}catch{}return{}}function Ct(I){window.localStorage.setItem(gr,JSON.stringify(I))}const Ue=V("all");Ie(Ue,I=>{const Q=String(r.taskSlug||"").trim();if(!Q)return;const j=wt();j[Q]=I,Ct(j)});const{t:_e}=It(),{isDark:$t}=Dr(),yt=q(()=>$t.value?"dark":"light"),Ze=q(()=>{const I=new Set;return(Array.isArray(Ne.value)?Ne.value:[]).filter(Q=>{const j=String((Q==null?void 0:Q.engine)||"").trim();return!j||I.has(j)?!1:(I.add(j),!0)})}),C=q(()=>Ze.value.length>1),F=q(()=>{const I=String(Ue.value||"").trim();return!C.value||I==="all"?oe.value:oe.value.filter(Q=>Sa(Q)===I)}),{selectionAction:te,clearSelectionState:Ce,handleSelectionMouseUp:ze}=oa({getContainer:()=>W.value,isActive:()=>!!(r.active&&oe.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:I=>[...I.querySelectorAll("[data-response-selection-root]")],getCodeLeft:I=>{var Q,j;return((j=(Q=I==null?void 0:I.getBoundingClientRect)==null?void 0:Q.call(I))==null?void 0:j.left)||0},debounceMs:72});Ie([Ue,()=>Ze.value.map(I=>I.engine).join(`
|
|
39
|
+
`)},()=>{var z,Y,ce;const se=String(((z=ge.value)==null?void 0:z.id)||"").trim(),Oe=$.value,at=ee.value;if(t("agent-bindings-change",{sessionId:se,bindings:Oe,selectedEngine:at}),!se||ho(e.selectedAgentEngine,Oe))return;const jt=((Y=Oe.find(ye=>ye.isDefault))==null?void 0:Y.engine)||((ce=Oe[0])==null?void 0:ce.engine)||"";jt&&t("update:selectedAgentEngine",jt)},{immediate:!0}),Ot(()=>{Le(),oe(),fe(),rt(),ve(),M==null||M()}),Ie(()=>n.readyVersion.value,()=>{const se=String(e.taskSlug||"").trim();!e.active&&!f.value||(f.value&&C().catch(()=>{}),gt({sessions:!0,runs:!!se}))}),Ie(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!f.value||gt({sessions:!0})}),Ie(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||gt({sessions:!0,runs:!0})}),Ie(()=>String(e.taskSlug||"").trim(),se=>{M==null||M(),M=null,se&&(M=Uf(se,({runId:Oe,event:at})=>{if(!e.active)return;W(Oe,at)||gt({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:le,activeAgentEngine:ee,clearTurns:$e,closeManager:De,formatTurnTime:St,getProcessCardClass:Ht,getProcessStatus:fp,getTurnAgentLabel:Ut,getTurnSummaryDetail:ba,getDisplayTurnSummaryItems:xt,getTurnSummaryStatus:xa,handleCreateSession:dt,handleDeleteSession:Ge,handleResetSession:wt,handleSelectSession:Ct,handleSend:Ue,handleUpdateSession:_e,loadTurnEvents:me,hasTurnSummary:up,helperText:$t,loading:r,managerBusy:l,openManager:F,refreshSessionsForSelection:te,selectedSessionId:G,sending:u,showProcessLogs:v,stopping:p,sessionError:w,shouldShowResponse:qt,showManager:f,sortedSessions:Ce,stopSending:ze,toggleProcessLogs:en,hasNewerMessages:Z,transcriptRef:S,turns:c,workspaces:s,workingLabel:de,sessions:o,loadSessions:yt,currentProjectAgentBindings:$,handleTranscriptScroll:_,handleTranscriptTouchEnd:H,handleTranscriptTouchMove:E,handleTranscriptTouchStart:Be,scheduleScrollToBottom:Re,scrollToBottom:Ve}}function ho(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const Rp=8,Np=320,Op=10,Fp=400;function mr(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function Up(e={}){const{turns:t,loadTurnEvents:n}=e,o=V({}),s=V({}),r=V({});function l(A){return String((A==null?void 0:A.runId)||(A==null?void 0:A.id)||"").trim()}function u(A){const G=l(A);return!!G&&G===l(t.value.at(-1))}function p(A){return Math.max(0,Number(A==null?void 0:A.eventCount)||0,Array.isArray(A==null?void 0:A.events)?A.events.length:0)}function w(A){return!ps(A==null?void 0:A.status)&&!u(A)&&p(A)>3}function c(A){return mr(A==null?void 0:A.prompt,Rp,Np)}function S(A){return!ps(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 mr(h(A),Op,Fp)}function f(A){return!(A!=null&&A.errorMessage)&&!u(A)&&g(A)}function P(A){return p(A)>0}function Z(A=[]){const G=new Set((A||[]).map($=>l($)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([$])=>G.has($))),s.value=Object.fromEntries(Object.entries(s.value).filter(([$])=>G.has($))),r.value=Object.fromEntries(Object.entries(r.value).filter(([$])=>G.has($)));const de=(A||[]).at(-1)||null,ge=l(de);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 G=l(A);return G?Object.prototype.hasOwnProperty.call(o.value,G)?!!o.value[G]:w(A):!1}async function L(A){const G=l(A);if(!G)return;const de=!v(A);o.value={...o.value,[G]:de},!de&&P(A)&&!A.eventsLoaded&&!A.eventsLoading&&await n(A).catch(()=>{})}function U(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(s.value,G)?!!s.value[G]:S(A):!1}function K(A){const G=l(A);!G||!c(A)||(s.value={...s.value,[G]:!U(A)})}function M(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(r.value,G)?!!r.value[G]:f(A):!1}function J(A){const G=l(A);!G||!g(A)||(r.value={...r.value,[G]:!M(A)})}return Ie(t,A=>{Z(A)},{immediate:!0,deep:!0}),{canCollapsePrompt:c,canCollapseResponse:g,getTurnEventCollapseKey:l,getTurnEventCount:p,hasTurnEventHistory:P,isLatestTurn:u,isPromptCollapsed:U,isResponseCollapsed:M,isTurnEventsCollapsed:v,togglePrompt:K,toggleResponse:J,toggleTurnEvents:L}}function jp(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function Vp(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 zp(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function vo(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 yo(e="",t=[],n=[]){var l;const o=jp(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=Vp([{label:"类型",value:zp(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 _a(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:vo(n,e.length),detail:"",detailBlocks:yo(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:vo(n,e.length),detail:"",detailBlocks:yo(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:vo(n,o.length),detail:"",detailBlocks:yo(n,o,o),isGrouped:!0,groupedCount:o.length}]}function Hp(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]=_a(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 qp(e=[]){var o;const t=Hp(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(..._a(u))}return n}const Kp={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},Wp={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},Gp={class:"flex flex-col gap-2"},Xp={class:"flex items-center gap-2"},Yp=["title"],Jp={class:"flex shrink-0 items-center gap-1.5"},Qp=["aria-pressed","aria-label","title"],Zp=["disabled"],em={class:"hidden sm:inline"},tm=["disabled"],nm={class:"hidden sm:inline"},sm=["aria-label"],om=["aria-pressed"],rm=["aria-pressed","title","onClick"],am={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},im={class:"min-h-0 flex-1"},lm={key:0,class:"theme-empty-state px-4 py-6 text-sm"},um={key:1,class:"theme-empty-state px-4 py-6 text-sm"},cm=["data-turn-id","data-run-id"],dm={class:"flex justify-end"},fm={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)]"},pm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},mm={class:"font-semibold"},gm={class:"flex items-center gap-2"},hm=["onClick"],vm={class:"relative mt-2"},ym={key:0,class:"space-y-3"},Sm={key:0,class:"whitespace-pre-wrap break-words leading-7"},wm=["onClick"],xm=["src","alt"],bm={key:1,class:"whitespace-pre-wrap break-words leading-7"},km={key:0,class:"flex min-w-0 justify-start"},Tm={class:"flex items-center justify-between gap-3 text-xs"},_m={class:"font-semibold"},Cm={class:"flex items-center gap-2"},Em=["disabled","onClick"],Am={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Im={key:1,class:"mt-2 min-w-0 space-y-2"},$m={class:"text-sm font-medium leading-6"},Pm={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Dm={key:3,class:"mt-2 text-xs text-current"},Lm={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},Mm={key:0,class:"leading-5"},Bm={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},Rm={key:2,class:"mt-2 flex flex-wrap gap-2"},Nm={class:"font-medium"},Om={key:1,class:"flex justify-start"},Fm={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},Um={class:"font-semibold"},jm={class:"flex items-center gap-2"},Vm=["onClick"],zm=["onClick"],Hm={class:"relative mt-2"},qm={key:0,class:"whitespace-pre-wrap break-words"},Km=["innerHTML"],Wm={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"},Gm=["disabled"],Xm={key:2,class:"task-loading-dots","aria-hidden":"true"},gr="promptx:selected-agent-filter-map",Ym={__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=xo(()=>We(()=>import("./CodexSessionManagerDialog-Dic9kMHK.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:P,handleResetSession:Z,handleSelectSession:v,handleSend:L,handleTranscriptScroll:U,handleTranscriptTouchEnd:K,handleTranscriptTouchMove:M,handleTranscriptTouchStart:J,handleUpdateSession:A,helperText:G,loadTurnEvents:de,loading:ge,managerBusy:$,openManager:ee,refreshSessionsForSelection:le,selectedSessionId:ne,sending:ve,showProcessLogs:_,stopping:H,hasTurnSummary:E,hasNewerMessages:Be,sessionError:Pe,shouldShowResponse:Re,showManager:Ve,sortedSessions:Xe,stopSending:Je,toggleProcessLogs:Ee,transcriptRef:W,turns:oe,workspaces:fe,sessions:$e,loadSessions:me,currentProjectAgentBindings:Ne,scheduleScrollToBottom:he,scrollToBottom:Me}=Bp(r,s),Ke=V(null),De=V(!1),dt=V(""),Ge=V("");function wt(){try{const I=JSON.parse(window.localStorage.getItem(gr)||"{}");if(I&&typeof I=="object"&&!Array.isArray(I))return I}catch{}return{}}function Ct(I){window.localStorage.setItem(gr,JSON.stringify(I))}const Ue=V("all");Ie(Ue,I=>{const Q=String(r.taskSlug||"").trim();if(!Q)return;const j=wt();j[Q]=I,Ct(j)});const{t:_e}=It(),{isDark:$t}=Dr(),yt=q(()=>$t.value?"dark":"light"),Ze=q(()=>{const I=new Set;return(Array.isArray(Ne.value)?Ne.value:[]).filter(Q=>{const j=String((Q==null?void 0:Q.engine)||"").trim();return!j||I.has(j)?!1:(I.add(j),!0)})}),C=q(()=>Ze.value.length>1),F=q(()=>{const I=String(Ue.value||"").trim();return!C.value||I==="all"?oe.value:oe.value.filter(Q=>Sa(Q)===I)}),{selectionAction:te,clearSelectionState:Ce,handleSelectionMouseUp:ze}=oa({getContainer:()=>W.value,isActive:()=>!!(r.active&&oe.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:I=>[...I.querySelectorAll("[data-response-selection-root]")],getCodeLeft:I=>{var Q,j;return((j=(Q=I==null?void 0:I.getBoundingClientRect)==null?void 0:Q.call(I))==null?void 0:j.left)||0},debounceMs:72});Ie([Ue,()=>Ze.value.map(I=>I.engine).join(`
|
|
40
40
|
`)],()=>{Ue.value!=="all"&&Ze.value.length&&(Ze.value.some(I=>I.engine===Ue.value)||(Ue.value="all"))},{immediate:!0}),Ie(Ue,()=>{Ce({clearBrowserSelection:!0}),he({force:!0})}),Ie(()=>r.taskSlug,(I,Q)=>{if(!String(I||"").trim()||I===Q)return;const ke=wt()[I];Ue.value=ke||"all"},{immediate:!0});function Le(I={}){const Q=String((I==null?void 0:I.title)||"").trim();return Q?[/^已连接项目:/,/^工作目录:/,/^项目会话已更新$/,/ 会话已创建$/,/^事件: claude\.system$/,/^线程 ID:/,/^Thread ID:/,/^Connected project:/,/^Working directory:/,/^Project session updated$/,/ session created$/,/^Event: claude\.system$/,/ 已返回结果$/,/ returned a result$/,/^本轮执行结束$/,/^Run finished$/].some(j=>j.test(Q)):!1}function tt(I={}){return _e("sessionPanel.promptTitleWithAgent",{agent:c(I)})}function rt(I={}){return I.errorMessage?_e("sessionPanel.errorSuffix",{agent:c(I)}):_e("sessionPanel.responseSuffix",{agent:c(I)})}const{getTurnEventCount:Et,hasTurnEventHistory:gt,isTurnEventsCollapsed:xt,toggleTurnEvents:St}=Up({turns:oe,loadTurnEvents:de});function Ht(I){return String((I==null?void 0:I.runId)||(I==null?void 0:I.id)||"").trim()}function en(I){I!=null&&I.runId&&s("open-diff",{scope:"run",runId:I.runId})}function qt(){s("open-diff",{scope:"workspace",runId:""})}const{getRenderedHtml:se}=Ef({items:oe,themeKey:yt,getCacheKey:Ht,getSource:I=>String((I==null?void 0:I.responseMessage)||""),shouldRender:I=>!!(I!=null&&I.responseMessage)&&!(I!=null&&I.errorMessage),renderAsync:I=>wc(I,{isDark:$t.value,copyLabel:_e("sessionPanel.copyCode"),copyAriaLabel:_e("sessionPanel.copyCodeAria")}),renderFallback:I=>ta(I),onRendered:I=>{const Q=oe.value.at(-1)||null;!r.active||!(Q!=null&&Q.runId)||Q.runId!==(I==null?void 0:I.runId)||he()}});function Oe(I){Ge.value=String(I||"").trim()}async function at(I){var j;if((j=navigator.clipboard)!=null&&j.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 Qe(I={}){const j=(Array.isArray(I==null?void 0:I.promptBlocks)?I.promptBlocks:[]).filter(ke=>(ke==null?void 0:ke.type)==="text"||(ke==null?void 0:ke.type)==="imported_text").map(ke=>String((ke==null?void 0:ke.content)||"").replace(/\u200b/g,"").trim()).filter(Boolean).join(`
|
|
41
41
|
|
|
42
42
|
`);return j||String((I==null?void 0:I.prompt)||"").replace(/\u200b/g,"").trim()}function jt(I={}){const Q=Qe(I);Q&&s("insert-code-context",{source:"response",content:Q})}async function z(I){var Qt,T,x,N,re;const Q=(T=(Qt=I==null?void 0:I.target)==null?void 0:Qt.closest)==null?void 0:T.call(Qt,'[data-copy-code="1"]');if(!Q)return;const j=Q.closest(".codex-code-block"),ke=(x=j==null?void 0:j.querySelector)==null?void 0:x.call(j,"pre code"),Jt=String((ke==null?void 0:ke.textContent)||"").replace(/\u200b/g,"");if(Jt){(N=I.preventDefault)==null||N.call(I),(re=I.stopPropagation)==null||re.call(I);try{await at(Jt),s("toast",{message:_e("sessionPanel.codeCopied"),type:"success"})}catch{s("toast",{message:_e("errors.requestFailed"),type:"warning"})}}}function Y(){if(!te.value.visible)return;const I=String(te.value.content||"").replace(/\u200b/g,"").trim();if(!I){Ce({clearBrowserSelection:!0});return}s("insert-code-context",{source:"response",content:I}),Ce({clearBrowserSelection:!0})}function ce(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 ye=q(()=>oe.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 He(I){const j=(Array.isArray(I==null?void 0:I.events)?I.events:[]).filter(ke=>!Le(ke));return qp(j)}function lt(I){return Et(I)}function Kt(I){return I!=null&&I.eventsLoaded?lt(I)>0:gt(I)}function Lt(I){return!!(I!=null&&I.eventsLoading)}function Mt(I){return!!(I!=null&&I.eventsLoaded)&&He(I).length>0&&!xt(I)}function Bt(I){return!!(I!=null&&I.eventsLoaded)&<(I)>0&&xt(I)}function mn(I){return gt(I)&&!(I!=null&&I.eventsLoaded)&&!(I!=null&&I.eventsLoading)}function bt(I={}){return qr(I,{defaultLabel:_e("sessionPanel.defaultAgent")})}function rn(I={}){return!ap(I)}function tn(I={}){return"bg-[var(--theme-appPanelStrong)]"}function Yt(I=null){const Q=String((I==null?void 0:I.id)||"").trim();if(Q)return $e.value.find(ke=>ke.id===Q)||null;const j=String(ne.value||"").trim();return j?$e.value.find(ke=>ke.id===j)||null:Xe.value[0]||null}function Pt(I=null){const Q=Yt(I);return Q!=null&&Q.cwd?(dt.value=Q.id,De.value=!0,!0):!1}function gn(){return $.value?!1:(ee(),!0)}function hn(){var I,Q;return De.value?(De.value=!1,!0):(Q=(I=Ke.value)==null?void 0:I.closeTopDialog)!=null&&Q.call(I)?!0:Ve.value?(l(),!0):!1}return t({closeTopDialog:hn,openProjectManager:gn,openSourceBrowser:Pt,send:L,scrollToBottom:Me,stop:Je}),(I,Q)=>(m(),k("section",Kp,[ue(Cf,{open:De.value,session:a($e).find(j=>j.id===dt.value)||null,onInsertCodeContext:Q[0]||(Q[0]=j=>s("insert-code-context",j)),onClose:Q[1]||(Q[1]=j=>De.value=!1)},null,8,["open","session"]),ue(a(o),{ref_key:"managerDialogRef",ref:Ke,open:a(Ve),sessions:a($e),workspaces:a(fe),"selected-session-id":a(ne),"selection-locked":e.sessionSelectionLocked,"selection-lock-reason":e.sessionSelectionLockReason,loading:a(ge),sending:a(ve),"on-refresh":a(me),"on-create":a(f),"on-update":a(A),"on-delete":a(P),"on-reset":a(Z),onClose:a(l),onOpenSourceBrowser:Q[2]||(Q[2]=j=>Pt(j)),onProjectCreated:Q[3]||(Q[3]=j=>s("project-created",j)),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",Wp,[i("div",Gp,[i("div",Xp,[i("div",{class:"min-w-0 flex-1",title:a(G)||""},[ue(nc,{modelValue:a(ne),"onUpdate:modelValue":Q[4]||(Q[4]=j=>Na(ne)?ne.value=j:null),sessions:a(Xe),loading:a(ge),disabled:a(ve)||a($)||e.sessionSelectionLocked,onRefreshIntent:a(le)},null,8,["modelValue","sessions","loading","disabled","onRefreshIntent"])],8,Yp),i("div",Jp,[i("button",{type:"button",class:we(["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(_e)("sessionPanel.hideProcessToggle"):a(_e)("sessionPanel.showProcessToggle"),title:a(_)?a(_e)("sessionPanel.hideProcessToggle"):a(_e)("sessionPanel.showProcessToggle"),onClick:Q[5]||(Q[5]=(...j)=>a(Ee)&&a(Ee)(...j))},[a(_)?(m(),Ae(a(qa),{key:0,class:"h-4 w-4"})):(m(),Ae(a(Ka),{key:1,class:"h-4 w-4"}))],10,Qp),e.diffSupported?(m(),k("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:qt},[ue(a(Go),{class:"h-4 w-4"}),Q[17]||(Q[17]=i("span",{class:"sm:hidden"},"代码",-1)),i("span",em,b(a(_e)("sessionPanel.diff")),1)],8,Zp)):pe("",!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($),onClick:Q[6]||(Q[6]=(...j)=>a(ee)&&a(ee)(...j))},[ue(a(cs),{class:"h-4 w-4"}),Q[18]||(Q[18]=i("span",{class:"sm:hidden"},"项目",-1)),i("span",nm,b(a(_e)("sessionPanel.manageProjects")),1)],8,tm)])]),C.value?(m(),k("div",{key:0,class:"flex max-w-full items-center gap-1.5 overflow-x-auto pb-0.5","aria-label":a(_e)("sessionPanel.agentFilter")},[i("button",{type:"button",class:we(["theme-agent-selector-button",Ue.value==="all"?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Ue.value==="all"?"true":"false",onClick:Q[7]||(Q[7]=j=>Ue.value="all")},b(a(_e)("sessionPanel.allAgents")),11,om),(m(!0),k(it,null,mt(Ze.value,j=>(m(),k("button",{key:j.engine,type:"button",class:we(["theme-agent-selector-button",Ue.value===j.engine?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Ue.value===j.engine?"true":"false",title:bt(j),onClick:ke=>Ue.value=j.engine},b(bt(j)),11,rm))),128))],8,sm)):pe("",!0),a(Pe)?(m(),k("p",am,[ue(a(Do),{class:"h-4 w-4"}),i("span",null,b(a(Pe)),1)])):pe("",!0)])]),i("div",im,[i("div",{ref_key:"transcriptRef",ref:W,"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]=(...j)=>a(U)&&a(U)(...j)),onTouchstartPassive:Q[10]||(Q[10]=(...j)=>a(J)&&a(J)(...j)),onTouchmovePassive:Q[11]||(Q[11]=(...j)=>a(M)&&a(M)(...j)),onTouchendPassive:Q[12]||(Q[12]=(...j)=>a(K)&&a(K)(...j)),onTouchcancelPassive:Q[13]||(Q[13]=(...j)=>a(K)&&a(K)(...j))},[a(oe).length?F.value.length?pe("",!0):(m(),k("div",um,b(a(_e)("sessionPanel.emptyAgentFilter")),1)):(m(),k("div",lm,b(a(_e)("sessionPanel.empty")),1)),(m(!0),k(it,null,mt(F.value,j=>(m(),k("div",{key:j.id,"data-promptx-turn":"1","data-turn-id":j.id,"data-run-id":j.runId||"",class:"flex min-w-0 flex-col gap-3"},[i("div",dm,[i("div",fm,[i("div",pm,[i("span",mm,b(tt(j)),1),i("div",gm,[Qe(j)?(m(),k("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:ke=>jt(j)},[ue(a(js),{class:"h-3 w-3"}),i("span",null,b(a(_e)("sessionPanel.insert")),1)],8,hm)):pe("",!0),i("span",null,b(a(u)(j.startedAt)),1)])]),i("div",vm,[Array.isArray(j.promptBlocks)&&j.promptBlocks.length?(m(),k("div",ym,[(m(!0),k(it,null,mt(j.promptBlocks,(ke,Jt)=>(m(),k(it,{key:`${j.id}-prompt-${Jt}`},[ke.type==="text"||ke.type==="imported_text"?(m(),k("pre",Sm,b(ke.content),1)):(m(),k("button",{key:1,type:"button",class:"inline-flex cursor-zoom-in justify-center rounded-sm",onClick:Qt=>Oe(ke.content)},[i("img",{src:ke.content,alt:a(_e)("sessionPanel.promptImageAlt"),class:"max-h-52 w-auto max-w-full rounded-sm object-contain shadow-sm"},null,8,xm)],8,wm))],64))),128))])):(m(),k("pre",bm,b(j.prompt),1))])])]),a(_)&&rn(j)?(m(),k("div",km,[i("div",{class:we(["transcript-card transcript-card--process min-w-0 w-full rounded-sm px-4 py-3",a(p)(j)])},[i("div",Tm,[i("span",_m,b(a(_e)("sessionPanel.processTitle")),1),i("div",Cm,[Kt(j)?(m(),k("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:j.eventsLoading,onClick:ke=>a(St)(j)},[Lt(j)?(m(),Ae(a(Zt),{key:0,class:"h-3 w-3 animate-spin"})):a(xt)(j)?(m(),Ae(a(Po),{key:1,class:"h-3 w-3"})):(m(),Ae(a(Wa),{key:2,class:"h-3 w-3"})),i("span",null,b(j.eventsLoading?a(_e)("sessionPanel.loading"):a(xt)(j)?`${a(_e)("sessionPanel.expand")} (${lt(j)})`:a(_e)("sessionPanel.collapse")),1)],8,Em)):pe("",!0),i("span",null,b(a(w)(j)),1)])]),Lt(j)?(m(),k("div",Am,b(a(_e)("sessionPanel.loadingEvents")),1)):Mt(j)?(m(),k("div",Im,[(m(!0),k(it,null,mt(He(j),ke=>(m(),k("div",{key:ke.id,class:we(["transcript-event-card min-w-0 rounded-sm px-3 py-2",tn(ke)])},[i("div",$m,b(ke.title),1),ke.detail||Array.isArray(ke.detailBlocks)&&ke.detailBlocks.length?(m(),Ae(sd,{key:0,detail:ke.detail,blocks:ke.detailBlocks,kind:ke.kind,class:"mt-2"},null,8,["detail","blocks","kind"])):pe("",!0)],2))),128))])):Bt(j)||mn(j)?(m(),k("div",Pm,b(j.eventsLoaded?a(_e)("sessionPanel.hiddenEventsLoaded",{count:lt(j)}):a(_e)("sessionPanel.hiddenEventsLoadLater",{count:lt(j)})),1)):(m(),k("p",Dm,b(["queued","starting","running","stopping"].includes(j.status)?a(_e)("sessionPanel.waitingEvents",{agent:a(c)(j)}):a(_e)("sessionPanel.noEvents")),1)),a(E)(j)?(m(),k("div",Lm,[a(g)(j)?(m(),k("div",Mm,b(a(g)(j)),1)):pe("",!0),a(h)(j)?(m(),k("div",Bm,b(a(h)(j)),1)):pe("",!0),a(S)(j).length?(m(),k("div",Rm,[(m(!0),k(it,null,mt(a(S)(j),ke=>(m(),k("span",{key:ke.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,b(ke.label),1),i("span",Nm,b(ke.value),1)]))),128))])):pe("",!0)])):pe("",!0)],2)])):pe("",!0),a(Re)(j)?(m(),k("div",Om,[i("div",{class:we(["transcript-card transcript-card--response min-w-0 w-full rounded-sm px-4 py-3 text-sm leading-7",j.errorMessage?"bg-[var(--theme-dangerSoft)] text-[var(--theme-dangerText)]":"bg-[var(--theme-responseBg)] text-[var(--theme-responseText)]"])},[i("div",Fm,[i("span",Um,b(rt(j)),1),i("div",jm,[e.diffSupported&&j.runId?(m(),k("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:ke=>en(j)},[ue(a(Go),{class:"h-3 w-3"}),i("span",null,b(a(_e)("sessionPanel.view")),1)],8,Vm)):pe("",!0),j.responseMessage&&!j.errorMessage?(m(),k("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:ke=>ce(j)},[ue(a(js),{class:"h-3 w-3"}),i("span",null,b(a(_e)("sessionPanel.insert")),1)],8,zm)):pe("",!0),i("span",null,b(a(u)(j.finishedAt||j.startedAt)),1)])]),i("div",Hm,[j.errorMessage?(m(),k("div",qm,b(j.errorMessage),1)):(m(),k("div",{key:1,class:"prose-like codex-markdown","data-response-selection-root":"1",onMouseup:Q[8]||(Q[8]=(...ke)=>a(ze)&&a(ze)(...ke)),onClick:z,innerHTML:a(se)(j)},null,40,Km))])],2)])):pe("",!0)],8,cm))),128)),a(te).visible?(m(),Ae(na,{key:2,top:a(te).top,left:a(te).left,label:a(_e)("sourceBrowser.insertSelection"),onClick:Y},null,8,["top","left","label"])):pe("",!0)],544),i("div",Wm,[a(Be)?(m(),k("button",{key:0,type:"button",class:we([a(ve)?"mb-10 sm:mb-8":"","tool-button pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur"]),onClick:Q[14]||(Q[14]=(...j)=>a(Me)&&a(Me)(...j))},[ue(a(Ga),{class:"h-3.5 w-3.5"}),i("span",null,b(a(_e)("sessionPanel.jumpToLatest")),1)],2)):pe("",!0),a(ve)?(m(),k("button",{key:1,type:"button",class:"tool-button tool-button-warning-subtle pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur",disabled:a(H),onClick:Q[15]||(Q[15]=(...j)=>a(Je)&&a(Je)(...j))},[a(H)?(m(),Ae(a(Zt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(m(),Ae(a(Xa),{key:1,class:"h-3.5 w-3.5"})),i("span",null,b(a(H)?a(_e)("sessionPanel.stopping"):a(_e)("sessionPanel.stop")),1),a(H)?pe("",!0):(m(),k("span",Xm,[...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,Gm)):pe("",!0)])]),ue(Kr,{modelValue:Ge.value,"onUpdate:modelValue":Q[16]||(Q[16]=j=>Ge.value=j),images:ye.value},null,8,["modelValue","images"])]))}},Jm={key:0,class:"h-full min-h-0"},Qm={key:1,class:"panel theme-muted-text flex h-full items-center px-5 py-4 text-sm"},hr={__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=V(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(),k("div",Jm,[ue(Ym,{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(),k("section",Qm,b(e.emptyMessage),1)):pe("",!0)}},Zm=["title"],eg={class:"flex min-w-0 items-center gap-1.5"},tg=["aria-pressed","title","data-agent-engine","onClick"],vr={__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}=It(),r=q(()=>{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=q(()=>r.value.length>1),u=q(()=>{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=q(()=>n.align==="end"?"sm:justify-end":n.align==="center"?"sm:justify-center":"sm:justify-start");function w(c={}){return qr(c,{prefix:"→ ",defaultLabel:s("sessionPanel.defaultAgent")})}return(c,S)=>l.value?(m(),k("div",{key:0,class:we(["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]=st(()=>{},["stop"]))},[i("div",eg,[(m(!0),k(it,null,mt(r.value,h=>(m(),k("button",{key:h.engine,type:"button",class:we(["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]=st(()=>{},["prevent"])),onClick:g=>o("update:selectedAgentEngine",h.engine)},b(w(h)),43,tg))),128))])],42,Zm)):pe("",!0)}},ng={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":""},sg={class:"grid w-full grid-cols-5 gap-2 sm:flex sm:w-full sm:flex-wrap sm:justify-end sm:gap-2"},og=["disabled","title","aria-label"],rg={class:"sr-only sm:not-sr-only sm:inline"},ag=["title","aria-label"],ig={class:"sr-only sm:not-sr-only sm:inline"},lg=["disabled","title","aria-label"],ug={class:"sr-only sm:not-sr-only sm:inline"},cg=["title","aria-label"],dg={class:"sr-only sm:not-sr-only sm:inline"},fg={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"},pg=["disabled","title","aria-label"],mg={class:"sr-only sm:not-sr-only sm:inline"},yr={__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}=It(),r=q(()=>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(),k("div",ng,[i("div",sg,[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]=st(()=>{},["prevent"])),onClick:p[1]||(p[1]=w=>o("open-file-picker"))},[e.uploading?(m(),Ae(a(Zt),{key:0,class:"h-4 w-4 animate-spin"})):(m(),Ae(a(Ya),{key:1,class:"h-4 w-4"})),i("span",rg,b(a(s)("editor.chooseFiles")),1)],40,og),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]=st(()=>{},["prevent"])),onClick:p[3]||(p[3]=w=>o("clear-request"))},[ue(a(Ja),{class:"h-4 w-4"}),i("span",ig,b(a(s)("editor.clear")),1)],40,ag),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]=st(()=>{},["prevent"])),onClick:p[5]||(p[5]=w=>o("add-todo"))},[ue(a(js),{class:"h-4 w-4"}),i("span",ug,b(a(s)("editor.todo")),1)],40,lg),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]=st(()=>{},["prevent"])),onClick:p[7]||(p[7]=w=>o("manage-todo"))},[ue(a(Nr),{class:"h-4 w-4"}),i("span",dg,b(l()),1),e.todoCount>0?(m(),k("span",fg,b(e.todoCount>9?"9+":e.todoCount),1)):pe("",!0)],40,cg),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]=st(()=>{},["prevent"])),onClick:p[9]||(p[9]=w=>o("send-request"))},[r.value?(m(),Ae(a(Zt),{key:0,class:"h-4 w-4 animate-spin"})):(m(),Ae(a(Qa),{key:1,class:"h-4 w-4"})),i("span",mg,b(a(s)("editor.send")),1)],40,pg)])]))}};function gg(e){const{props:t,panelRef:n,onClose:o}=e,s=V({left:"12px",top:"12px",width:"560px",maxHeight:"420px"}),r=V(!1),l=V("bottom");function u(){o==null||o()}function p(g=!1){const f=window.innerWidth,P=window.innerHeight,Z=12,v=8,L=320,U=560,K=420,M=180,J=Math.min(U,Math.max(L,f-Z*2)),A=Math.min(J,f-Z*2),G=t.anchorRect||{left:(f-A)/2,top:P/2,bottom:P/2};let de=G.left;de+A>f-Z&&(de=f-Z-A),de<Z&&(de=Z);const ge=Math.max(0,P-Z-(G.bottom+v)),$=Math.max(0,G.top-v-Z);g?l.value=ge>=$?"bottom":"top":l.value==="bottom"&&ge<M&&$>ge+24?l.value="top":l.value==="top"&&$<M&&ge>$+24&&(l.value="bottom");const ee=l.value,le=ee==="bottom"?ge:$,ne=Math.max(140,P-Z*2),ve=Math.min(ne,Math.max(Math.min(K,le||K),M)),_={left:`${Math.round(de)}px`,width:`${Math.round(A)}px`,maxHeight:`${Math.round(ve)}px`,top:"auto",bottom:"auto"};return ee==="bottom"?_.top=`${Math.round(Math.max(Z,G.bottom+v))}px`:_.bottom=`${Math.round(Math.max(Z,P-G.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 pn(()=>{document.addEventListener("pointerdown",h)}),Ot(()=>{document.removeEventListener("pointerdown",h)}),{closePicker:u,initializePanel:c,panelReady:r,panelStyle:s,resetPanel:S,updatePanelPosition:w}}function hg(e){const{props:t,panelRef:n,onClose:o,onSelect:s}=e,{closePicker:r,initializePanel:l,panelReady:u,panelStyle:p,resetPanel:w,updatePanelPosition:c}=gg({props:t,panelRef:n,onClose:o}),S=aa({getMode:()=>String(t.query||"").trim()?"search":"tree",props:t,onSelect:s});return Ie(()=>t.open,h=>{if(!h){S.resetData(),w();return}w(),t.anchorRect&&l()&&S.initializeData()},{flush:"sync"}),Ie(()=>t.anchorRect,h=>{if(!(!t.open||!h)){if(!u.value){l()&&S.initializeData();return}c(!1)}},{flush:"sync"}),Ie(()=>t.sessionId,()=>{S.handleSessionChange()},{flush:"sync",immediate:!0}),Ie(()=>t.query,()=>{S.handleQueryChange()},{immediate:!0}),Ie(S.visibleItems,()=>{S.handleVisibleItemsChange()},{immediate:!0}),{...S,closePicker:r,panelReady:u,panelStyle:p}}const vg={class:"theme-divider flex items-center justify-end gap-2 border-b border-dashed px-2.5 py-2"},yg={class:"flex shrink-0 items-center gap-2"},Sg={class:"min-h-0 flex-1 overflow-y-auto p-2"},wg={key:0,class:"theme-empty-state px-3 py-4 text-xs"},xg={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},bg={key:2,class:"theme-empty-state px-3 py-4 text-xs"},kg={key:3,class:"theme-empty-state px-3 py-4 text-xs"},Tg={key:4,class:"theme-empty-state px-3 py-4 text-xs"},_g={key:5,class:"space-y-1"},Cg={key:0,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},Eg=["onClick"],Ag={class:"min-w-0 flex-1"},Ig=["innerHTML"],$g=["innerHTML"],Pg={key:1,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},Dg=["onClick"],Lg={class:"min-w-0 flex-1"},Mg=["innerHTML"],Bg=["innerHTML"],Rg={key:6,class:"space-y-1"},Ng={class:"flex items-start gap-1.5"},Og=["onClick"],Fg={key:1,class:"block h-5 w-5 shrink-0"},Ug=["onClick"],jg={class:"min-w-0 flex-1"},Vg={class:"flex items-center gap-1.5"},zg={__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=V(null),{t:l}=It(),{activeKey:u,closePicker:p,collapseActiveDirectory:w,confirmActive:c,currentError:S,currentLoading:h,emitSelect:g,expandActiveDirectory:f,getDisplayName:P,getHighlightedName:Z,getHighlightedPath:v,moveActive:L,normalSearchItems:U,normalizedQuery:K,panelReady:M,panelStyle:J,recentSearchItems:A,setItemRef:G,showSearchEmptyState:de,showTreeEmptyState:ge,toggleDirectory:$,treeItems:ee,visibleItems:le}=hg({props:o,panelRef:r,onClose:()=>s("close"),onSelect:ne=>s("select",ne)});return t({collapseActiveDirectory:w,moveActive:L,confirmActive:c,expandActiveDirectory:f}),(ne,ve)=>(m(),Ae(gs,{to:"body"},[e.open&&a(M)?(m(),k("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:Rn(a(J))},[i("div",vg,[i("div",yg,[i("div",{class:we(["theme-muted-text inline-flex h-7 w-7 items-center justify-center",a(h)?"opacity-100":"opacity-0"])},[ue(a(Zt),{class:"h-3.5 w-3.5 animate-spin"})],2),i("button",{type:"button",class:"tool-button inline-flex h-7 w-7 items-center justify-center",onClick:ve[0]||(ve[0]=(..._)=>a(p)&&a(p)(..._))},[ue(a(Mr),{class:"h-4 w-4"})])])]),i("div",Sg,[e.sessionId?a(S)?(m(),k("div",xg,b(a(S)),1)):a(de)?(m(),k("div",bg,b(a(l)("pathPicker.noResults")),1)):a(ge)?(m(),k("div",kg,b(a(l)("pathPicker.emptyDirectory")),1)):a(h)&&!a(le).length?(m(),k("div",Tg,b(a(l)("pathPicker.loading")),1)):a(K)?(m(),k("div",_g,[a(A).length?(m(),k("div",Cg,b(a(l)("pathPicker.recent")),1)):pe("",!0),(m(!0),k(it,null,mt(a(A),_=>(m(),k("button",{key:_.path,ref_for:!0,ref:H=>a(G)(_.path,H),type:"button",class:we(["theme-list-row focus:outline-none",a(u)===_.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:H=>a(g)(_)},[(m(),Ae(Tn(_.type==="directory"?a(qn):a(Dn)),{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,Ig)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(v)(_)},null,8,$g)])],10,Eg))),128)),a(K)&&a(U).length?(m(),k("div",Pg,b(a(l)("pathPicker.results")),1)):pe("",!0),(m(!0),k(it,null,mt(a(U),_=>(m(),k("button",{key:_.path,ref_for:!0,ref:H=>a(G)(_.path,H),type:"button",class:we(["theme-list-row focus:outline-none",a(u)===_.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:H=>a(g)(_)},[(m(),Ae(Tn(_.type==="directory"?a(qn):a(Dn)),{class:"theme-list-item-icon"})),i("div",Lg,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Z)(_)},null,8,Mg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(v)(_)},null,8,Bg)])],10,Dg))),128))])):(m(),k("div",Rg,[(m(!0),k(it,null,mt(a(ee),_=>(m(),k("div",{key:_.path,ref_for:!0,ref:H=>a(G)(_.path,H),class:we(["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:Rn({paddingLeft:`${_.depth*16+6}px`})},[i("div",Ng,[_.type==="directory"?(m(),k("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:st(H=>a($)(_.path),["stop"])},[_.loading?(m(),Ae(a(Zt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(m(),Ae(a(Rr),{key:1,class:we(["h-3.5 w-3.5 transition",_.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,Og)):(m(),k("span",Fg)),i("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left",onClick:H=>a(g)(_)},[(m(),Ae(Tn(_.type==="directory"?a(qn):a(Dn)),{class:we(["h-4 w-4 shrink-0",_.type==="directory"&&_.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("div",jg,[i("div",Vg,[i("span",{class:we(["theme-list-item-title truncate",_.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},b(a(P)(_)),3)])])],8,Ug)])],6))),128))])):(m(),k("div",wg,b(a(l)("pathPicker.selectProjectFirst")),1))])],4)):pe("",!0)]))}},Hg={__name:"TiptapTextBlockView",props:Lo,setup(e){return(t,n)=>(m(),Ae(a(Mo),{"data-promptx-node":"text"},{default:nt(()=>[ue(a(Ur),{"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}))}},Ca={__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=q(()=>t.selected?"ring-1 ring-inset ring-[var(--theme-borderStrong)]":""),o=q(()=>t.selected?"opacity-100":"opacity-100 sm:opacity-45 sm:group-hover:opacity-100 sm:focus-within:opacity-100");return(s,r)=>(m(),k("div",{class:we(["overflow-hidden rounded-sm transition",[e.frameClass,n.value]])},[i("div",{class:we(["theme-divider border-b text-xs",[e.headerPaddingClass,e.headerClass]])},[on(s.$slots,"header",{actionsStateClass:o.value})],2),on(s.$slots,"default")],2))}},Dt={DOC:"doc",TEXT_BLOCK:"paragraph",IMPORTED_TEXT_BLOCK:"promptxImportedTextBlock",IMAGE_BLOCK:"promptxImageBlock",TEXT:"text",HARD_BREAK:"hardBreak"};function qg(){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 Gn(e={}){return{...e,clientId:String((e==null?void 0:e.clientId)||(e==null?void 0:e.id)||qg()),meta:e!=null&&e.meta?{...e.meta}:{}}}function Hn(e=""){return Gn({type:Nt.TEXT,content:e,meta:{}})}function Es(e){return e&&e.type!==Nt.TEXT}function Mn(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];if(!t.length)return[Hn("")];const n=[];return t.forEach((o,s)=>{const r=Gn(o),l=n[n.length-1];!l&&Es(r)&&n.push(Hn("")),l&&Es(l)&&Es(r)&&n.push(Hn("")),n.push(r),s===t.length-1&&Es(r)&&n.push(Hn(""))}),n}function Ao(e=""){const t=String(e||"").split(`
|
|
@@ -47,14 +47,14 @@ ${B("原始错误","Raw error")}: ${o.rawMessage}`:n}function Eo(e,t=0){if(!e||t
|
|
|
47
47
|
`),P=[];let Z=0;for(const U of f){const K=U.trimEnd(),M=K.length?K:"";if(!(!M&&P[P.length-1]==="")&&(P.push(M),Z+=M.length,P.length>=4||Z>=220))break}const v=P.join(`
|
|
48
48
|
`).trim(),L=g.trim();return{text:v,truncated:P.length<f.length||v.length<L.length}}),p=`${So} tool-button-danger-subtle`;function w(g){g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),c())}function c(){var g,f,P;(P=t.updateAttributes)==null||P.call(t,{collapsed:!((f=(g=t.node)==null?void 0:g.attrs)!=null&&f.collapsed)}),Ns(t.editor)}function S(){var v;const{editor:g,getPos:f,node:P}=t;if(!g||typeof f!="function"||!P)return;const Z=f();g.chain().focus().insertContentAt({from:Z,to:Z+P.nodeSize},{type:Dt.TEXT_BLOCK,attrs:{clientId:String(((v=P.attrs)==null?void 0:v.clientId)||"")},content:Kg(o.value)}).run(),Ns(t.editor)}function h(){var g;(g=t.deleteNode)==null||g.call(t),Ns(t.editor)}return(g,f)=>(m(),Ae(a(Mo),{class:"group relative","data-promptx-node":"imported_text"},{default:nt(()=>[ue(Ca,{selected:g.selected,"frame-class":"dashed-panel","header-class":"theme-secondary-text border-dashed","header-padding-class":"px-3 py-2"},{header:nt(({actionsStateClass:P})=>{var Z,v,L,U;return[i("div",Zg,[i("div",{class:"min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((Z=g.node.attrs)!=null&&Z.collapsed)),onClick:c,onKeydown:w},[i("p",th,[ue(a(Vs),{class:"h-3.5 w-3.5 shrink-0"}),xn(" "+b(a(n)("blockEditor.file")),1)])],40,eh),i("div",{"data-promptx-imported-actions":"",class:we(["col-start-2 row-start-1 flex shrink-0 flex-wrap items-center justify-end gap-1 self-start transition",P])},[i("button",{type:"button",class:we(So),contenteditable:"false",onClick:c},[ue(a(Po),{class:we(["h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5",(v=g.node.attrs)!=null&&v.collapsed?"rotate-180":""])},null,8,["class"]),i("span",null,b((L=g.node.attrs)!=null&&L.collapsed?a(n)("blockEditor.expand"):a(n)("blockEditor.collapse")),1)]),i("button",{type:"button",class:we(So),contenteditable:"false",onClick:S},[ue(a(Vs),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,b(a(n)("blockEditor.convertToText")),1)]),i("button",{type:"button",class:we(p),contenteditable:"false",onClick:h},[ue(a(Js),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,b(a(n)("blockEditor.delete")),1)])],2),i("div",{class:"col-span-2 min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((U=g.node.attrs)!=null&&U.collapsed)),onClick:c,onKeydown:w},[i("p",sh,b(l.value),1)],40,nh)])]}),default:nt(()=>{var P,Z;return[nn(i("div",{class:"theme-secondary-text relative cursor-pointer px-4 py-3 text-[12px] font-mono","data-promptx-imported-preview":"",role:"button",tabindex:"0","aria-label":a(n)("blockEditor.expand"),onClick:c,onKeydown:w},[i("div",rh,b(u.value.text||a(n)("blockEditor.emptyContent")),1),u.value.truncated?(m(),k("div",ah)):pe("",!0),u.value.truncated?(m(),k("span",ih,"...")):pe("",!0)],40,oh),[[Fs,(P=g.node.attrs)==null?void 0:P.collapsed]]),nn(ue(a(Ur),{as:"div","data-promptx-node-content":"imported_text",class:"min-h-[56px] whitespace-pre-wrap break-words px-4 py-4 font-mono text-[12px] leading-7 text-[var(--theme-textPrimary)] outline-none"},null,512),[[Fs,!((Z=g.node.attrs)!=null&&Z.collapsed)]])]}),_:1},8,["selected"])]),_:1}))}},uh={class:"flex min-w-0 items-center justify-between gap-3"},ch={class:"theme-heading min-w-0 inline-flex items-center gap-1.5 text-xs font-medium leading-5"},dh={class:"mx-auto flex w-full max-w-[720px] justify-center px-4 py-4"},fh=["src","alt"],ph="tool-button tool-button-danger-subtle inline-flex min-w-0 items-center justify-center gap-1 whitespace-nowrap px-2 py-1 text-[12px]",mh={__name:"TiptapImageBlockView",props:Lo,setup(e){const t=e,{t:n}=It();function o(){var r,l;typeof window>"u"||window.dispatchEvent(new CustomEvent("promptx:tiptap-image-preview",{detail:{src:String(((l=(r=t.node)==null?void 0:r.attrs)==null?void 0:l.src)||"")}}))}function s(){var r;(r=t.deleteNode)==null||r.call(t),Ns(t.editor)}return(r,l)=>(m(),Ae(a(Mo),{class:"group","data-promptx-node":"image"},{default:nt(()=>[ue(Ca,{selected:r.selected,"frame-class":"theme-inline-panel border","header-class":"theme-muted-text","header-padding-class":"px-3 py-2"},{header:nt(({actionsStateClass:u})=>[i("div",uh,[i("div",ch,[ue(a(Or),{class:"h-3.5 w-3.5 shrink-0"}),xn(" "+b(a(n)("blockEditor.image")),1)]),i("div",{class:we(["shrink-0 transition",u])},[i("button",{type:"button",class:we(ph),contenteditable:"false",onClick:s},[ue(a(Js),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,b(a(n)("blockEditor.delete")),1)])],2)])]),default:nt(()=>{var u;return[i("div",dh,[i("button",{type:"button",class:"inline-flex cursor-zoom-in justify-center",contenteditable:"false",onClick:o},[i("img",{src:(u=r.node.attrs)==null?void 0:u.src,alt:a(n)("blockEditor.insertedImageAlt"),class:"max-h-[380px] w-auto max-w-full object-contain"},null,8,fh)])])]}),_:1},8,["selected"])]),_:1}))}},gh=["accept"],Sr=10*1024*1024,wr=2*1024*1024,xr=8*1024*1024,hh=1500,vh={__name:"TiptapBlockEditor",props:{modelValue:{type:Array,required:!0},codexSessionId:{type:String,default:""},sendBehavior:{type:String,default:"shift_enter"}},emits:["update:modelValue","upload-files","import-text-files","import-pdf-files","clear-request","file-feedback","send-request"],setup(e,{expose:t,emit:n}){const o=e,s=n,{t:r}=It(),l=new Set([".md",".markdown",".txt",".js",".mjs",".cjs",".ts",".mts",".cts",".jsx",".tsx",".vue",".json",".css",".scss",".sass",".less",".html",".htm",".xml",".svg",".yml",".yaml",".toml",".ini",".conf",".env",".py",".java",".go",".rs",".rb",".php",".sh",".bash",".zsh",".sql",".c",".cc",".cpp",".h",".hpp",".cs",".kt",".swift",".log",".csv"]),u=new Set(["application/json","application/ld+json","application/xml","application/javascript","application/x-javascript","application/typescript","application/x-typescript","application/yaml","application/x-yaml","application/toml","application/x-toml","application/x-sh","application/x-shellscript","application/sql"]),p=["image/*",".md,.markdown,.txt,.js,.mjs,.cjs,.ts,.mts,.cts,.jsx,.tsx,.vue,.json,.css,.scss,.sass,.less,.html,.htm,.xml,.svg,.yml,.yaml,.toml,.ini,.conf,.env,.py,.java,.go,.rs,.rb,.php,.sh,.bash,.zsh,.sql,.c,.cc,.cpp,.h,.hpp,.cs,.kt,.swift,.log,.csv",".pdf","text/plain","text/markdown","text/*","application/json","application/xml","application/javascript","application/typescript","application/yaml","application/x-yaml","application/toml","application/x-toml","application/x-sh","application/x-shellscript","application/sql","application/pdf"].join(","),w=V(null),c=V(null),S=V(""),h=V(Ke()),g=V(null),f=V(null),P=V(!1),Z=V(0),v=q(()=>Mn(o.modelValue)),L=q(()=>v.value.filter(C=>(C==null?void 0:C.type)===Nt.IMAGE&&String(C.content||"").trim()).map(C=>String(C.content||"").trim()));let U=ss(v.value);function K(C=G.value){if(!C)return!1;const F=Jg(C.getJSON()),te=ss(F);return te===U?!1:(U=te,s("update:modelValue",F),!0)}const M=li.extend({name:Dt.TEXT_BLOCK,group:"block",content:"inline*",addAttributes(){return{clientId:{default:""}}},addNodeView(){return oo(Hg)}}),J=Xo.create({name:Dt.IMPORTED_TEXT_BLOCK,group:"block",content:"inline*",defining:!0,selectable:!0,draggable:!1,addAttributes(){return{clientId:{default:""},fileName:{default:""},collapsed:{default:!1}}},parseHTML(){return[{tag:'div[data-type="promptx-imported-text-block"]'}]},renderHTML({HTMLAttributes:C}){return["div",{...C,"data-type":"promptx-imported-text-block"}]},addNodeView(){return oo(lh)}}),A=Xo.create({name:Dt.IMAGE_BLOCK,group:"block",atom:!0,selectable:!0,draggable:!1,addAttributes(){return{clientId:{default:""},src:{default:""}}},parseHTML(){return[{tag:'div[data-type="promptx-image-block"]'}]},renderHTML({HTMLAttributes:C}){return["div",{...C,"data-type":"promptx-image-block"}]},addNodeView(){return oo(mh)}}),G=ui({extensions:[ci.configure({paragraph:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,codeBlock:!1,horizontalRule:!1,listItem:!1,bold:!1,italic:!1,strike:!1,code:!1,dropcursor:!0,gapcursor:!0}),M,J,A],autofocus:!1,editorProps:{attributes:{class:"tiptap-editor min-h-full outline-none"},handleKeyDown(C,F){return Ma(F,{sendBehavior:o.sendBehavior,isEditing:!0,isComposing:me()})?(F.preventDefault(),F.stopPropagation(),s("send-request"),!0):!F.shiftKey&&!F.altKey&&(F.metaKey||F.ctrlKey)&&String(F.key||"").toLowerCase()==="k"?$t():Ze(F)}},content:As(v.value),onCreate({editor:C}){_e(C)},onFocus({editor:C}){P.value=!0,_e(C)},onBlur(){P.value=!1},onSelectionUpdate({editor:C}){_e(C)},onUpdate({editor:C}){Z.value=Date.now(),K(C),_e(C)}});Ie(G,C=>{if(!C)return;const F=Mn(o.modelValue);U=ss(F),C.commands.setContent(As(F),!1)},{immediate:!0}),Ie(()=>o.modelValue,C=>{const F=G.value;if(!F){U=ss(Mn(C));return}const te=Mn(C),Ce=ss(te);Ce!==U&&(U=Ce,F.commands.setContent(As(te),!1))},{deep:!0});function de(C){const F=String(C||"").trim();F&&s("file-feedback",F)}function ge(C){const F=String((C==null?void 0:C.name)||"").trim().toLowerCase();return F.includes(".")?`.${F.split(".").pop()}`:""}function $(C,F){return String((C==null?void 0:C.name)||"").trim()||r(F)}function ee(C){const F=Math.max(0,Number(C)||0);return F>=1024*1024?`${(F/(1024*1024)).toFixed(F>=10*1024*1024?0:1)} MB`:F>=1024?`${Math.round(F/1024)} KB`:`${F} B`}function le(C){if(!C)return!1;const F=String(C.type||"").toLowerCase(),te=ge(C);return F.startsWith("text/")||l.has(te)||u.has(F)}function ne(C){if(!C)return!1;const F=String(C.name||"").toLowerCase(),te=String(C.type||"").toLowerCase();return F.endsWith(".pdf")||te==="application/pdf"}function ve(C){const F=Array.from(C||[]).filter(Boolean),te={imageFiles:[],textFiles:[],pdfFiles:[]},Ce=[],ze=[];return F.forEach(Le=>{if(Le.type.startsWith("image/")){if(Le.size>Sr){ze.push({name:$(Le,"blockEditor.unnamedImage"),limit:ee(Sr)});return}te.imageFiles.push(Le);return}if(ne(Le)){if(Le.size>xr){ze.push({name:$(Le,"blockEditor.unnamedPdf"),limit:ee(xr)});return}te.pdfFiles.push(Le);return}if(le(Le)){if(Le.size>wr){ze.push({name:$(Le,"blockEditor.unnamedFile"),limit:ee(wr)});return}te.textFiles.push(Le);return}Ce.push($(Le,"blockEditor.unnamedFile"))}),{...te,unsupportedFiles:Ce,oversizedFiles:ze}}function _({unsupportedFiles:C=[],oversizedFiles:F=[]}={}){var te;C.length&&de(r("blockEditor.unsupportedFiles",{names:C.slice(0,3).join("、"),extra:Math.max(0,C.length-3)})),F.length&&de(r("blockEditor.oversizedFiles",{names:F.slice(0,2).map(Ce=>Ce.name).join("、"),extra:Math.max(0,F.length-2),limit:((te=F[0])==null?void 0:te.limit)||""}))}function H(C){const{imageFiles:F,textFiles:te,pdfFiles:Ce,unsupportedFiles:ze,oversizedFiles:Le}=ve(C);return _({unsupportedFiles:ze,oversizedFiles:Le}),te.length&&s("import-text-files",te),Ce.length&&s("import-pdf-files",Ce),F.length&&s("upload-files",F),F.length+te.length+Ce.length>0}function E(C){const F=[...C.clipboardData.items].filter(te=>te.kind==="file").map(te=>te.getAsFile()).filter(Boolean);F.length&&(C.preventDefault(),H(F))}function Be(C){C.preventDefault(),H(C.dataTransfer.files)}function Pe(C){const F=G.value;if(!F)return;const te=C.target instanceof Element?C.target:null,Ce=C.currentTarget instanceof Element?C.currentTarget:null,ze=F.view.dom instanceof Element?F.view.dom:null;!te||!Ce||!ze||te.closest('button, input, textarea, select, a, [contenteditable="false"]')||!Ce.contains(te)||te.closest("[data-promptx-node]")||!(te===Ce||te===ze||Ce.contains(te))||(C.preventDefault(),Xe())}function Re(C){H(C.target.files),C.target.value=""}function Ve(){var C;(C=w.value)==null||C.click()}function Xe(){const C=G.value;C&&C.chain().focus("end").run()}function Je(){var te,Ce;const C=G.value;if(!C)return!1;(Ce=(te=C.view.domObserver)==null?void 0:te.flush)==null||Ce.call(te);const F=K(C);return F&&(Z.value=Date.now()),_e(C),F}function Ee(C=[]){const F=G.value;!F||!C.length||F.chain().focus().insertContent(C).run()}function W(C=[]){Ee(Ea(C))}function oe(C=[]){W(C)}function fe(C=[]){W(C)}function $e(){const C=G.value;C&&C.commands.setContent(As([Hn("")]),!0)}function me(){var C,F;return!!((F=(C=G.value)==null?void 0:C.view)!=null&&F.composing)}function Ne(){var C;return me()||P.value||(C=G.value)!=null&&C.isFocused?!0:Date.now()-Z.value<hh}function he(){var Ce;const C=G.value;if(!C)return!1;const F=C.state.selection,te=F.$from.nodeAfter||F.$from.parent;return((Ce=te==null?void 0:te.type)==null?void 0:Ce.name)===Dt.IMPORTED_TEXT_BLOCK}function Me(C){var te;const F=String(((te=C==null?void 0:C.detail)==null?void 0:te.src)||"").trim();F&&(S.value=F)}function Ke(){return{open:!1,start:-1,end:-1,query:"",trigger:"mention",blockType:"",clientId:""}}function De(C=null,F=null){return!C||!F?!1:C.start===F.start&&C.end===F.end&&C.query===F.query&&C.clientId===F.clientId}function dt(){g.value=null}function Ge(C={}){const{suppressCurrent:F=!1}=C,te=h.value;F&&te.open&&(f.value={start:te.start,end:te.end,query:te.query,clientId:te.clientId}),h.value=Ke(),dt()}function wt(){Ge({suppressCurrent:!0})}function Ct(C=G.value){var tt,rt,Et;if(!C)return null;const F=C.state.selection;if(!F.empty)return null;const{$from:te,from:Ce}=F,ze=((rt=(tt=te.parent)==null?void 0:tt.type)==null?void 0:rt.name)||"";if(![Dt.TEXT_BLOCK,Dt.IMPORTED_TEXT_BLOCK].includes(ze))return null;const Le=te.parent.textBetween(0,te.parentOffset,`
|
|
49
49
|
`,"\0");return{from:Ce,node:te.parent,nodeTypeName:ze,nodeStart:te.start(),parentOffset:te.parentOffset,clientId:String(((Et=te.parent.attrs)==null?void 0:Et.clientId)||""),textBefore:Le}}function Ue(C=h.value.end){const F=G.value;if(typeof C=="object"&&C!==null&&(C=h.value.end),!F||!h.value.open||C<0){dt();return}try{const te=F.view.coordsAtPos(C);g.value={left:te.left,right:te.left,top:te.bottom,bottom:te.bottom,width:0,height:0}}catch{dt()}}function _e(C=G.value){const F=Ct(C),te=h.value;if(te.open&&te.trigger==="shortcut"){if(!F||F.clientId!==te.clientId||F.from<te.start){Ge();return}const rt=C.state.doc.textBetween(te.start,F.from,`
|
|
50
|
-
`,"\0");if(/\s/.test(rt)){Ge();return}f.value=null,h.value={...te,end:F.from,query:rt},Ue(F.from);return}if(!F){Ge();return}const Ce=F.textBefore.lastIndexOf("@");if(Ce<0){Ge();return}const ze=F.textBefore.slice(Ce+1);if(/\s/.test(ze)){Ge();return}const Le=F.nodeStart+Ce,tt=F.from;De(f.value,{start:Le,end:tt,query:ze,clientId:F.clientId})||(f.value=null,h.value={open:!0,start:Le,end:tt,query:ze,trigger:"mention",blockType:F.nodeTypeName,clientId:F.clientId},Ue(tt))}function $t(){const C=G.value,F=Ct(C);return!C||!F?!1:(f.value=null,h.value={open:!0,start:F.from,end:F.from,query:"",trigger:"shortcut",blockType:F.nodeTypeName,clientId:F.clientId},Ue(F.from),!0)}function yt(C){const F=G.value,te=String((C==null?void 0:C.path)||"").trim(),Ce=h.value;if(!F||!te||Ce.start<0||Ce.end<Ce.start)return Ge(),!1;const ze=Ce.trigger==="shortcut"?`${te} `:`@${te} `,Le=Ce.start+ze.length;return F.chain().focus().command(({tr:tt,dispatch:rt})=>(tt.insertText(ze,Ce.start,Ce.end),tt.setSelection(Oa.create(tt.doc,Le)),rt==null||rt(tt),!0)).run(),Z.value=Date.now(),f.value=null,Ge(),!0}function Ze(C){var F,te,Ce,ze,Le,tt,rt,Et,gt,xt;if(!h.value.open)return!1;if(C.key==="Escape")return wt(),!0;if(C.key==="ArrowDown")return!!((te=(F=c.value)==null?void 0:F.moveActive)!=null&&te.call(F,1));if(C.key==="ArrowUp")return!!((ze=(Ce=c.value)==null?void 0:Ce.moveActive)!=null&&ze.call(Ce,-1));if(h.value.query&&(C.key==="ArrowLeft"||C.key==="ArrowRight"))return!1;if(C.key==="ArrowRight"){const St=(tt=(Le=c.value)==null?void 0:Le.expandActiveDirectory)==null?void 0:tt.call(Le);return St&&typeof St.then=="function"?(St.catch(()=>{}),!0):!!St}return C.key==="ArrowLeft"?!!((Et=(rt=c.value)==null?void 0:rt.collapseActiveDirectory)!=null&&Et.call(rt)):!C.shiftKey&&!C.altKey&&!C.metaKey&&!C.ctrlKey&&C.key==="Enter"?!!((xt=(gt=c.value)==null?void 0:gt.confirmActive)!=null&&xt.call(gt)):!1}return pn(()=>{window.addEventListener("promptx:tiptap-image-preview",Me),window.addEventListener("resize",Ue),window.addEventListener("scroll",Ue)}),Ot(()=>{window.removeEventListener("promptx:tiptap-image-preview",Me),window.removeEventListener("resize",Ue),window.removeEventListener("scroll",Ue)}),Ie(()=>o.codexSessionId,()=>{Ge()}),t({clearContent:$e,flushPendingInput:Je,focusEditor:Xe,insertBlocks:W,insertImportedBlocks:oe,insertUploadedBlocks:fe,isComposing:me,isEditing:Ne,isImportedBlockActive:he,openFilePicker:Ve}),(C,F)=>(m(),k("section",{class:"workbench-input-editor relative flex h-full min-h-0 flex-col overflow-hidden","data-promptx-editor":"tiptap",onDrop:Be,onDragover:F[1]||(F[1]=st(()=>{},["prevent"])),onPaste:E},[i("input",{ref_key:"fileInputRef",ref:w,class:"hidden",type:"file",accept:a(p),multiple:"",onChange:Re},null,40,gh),i("div",{class:"flex-1 overflow-y-auto px-5 py-5","data-promptx-editor-scroll":"tiptap",onMousedown:Pe},[a(G)?(m(),Ae(a(di),{key:0,editor:a(G),class:"min-h-full","data-promptx-editor-content":"tiptap"},null,8,["editor"])):pe("",!0)],32),ue(Kr,{modelValue:S.value,"onUpdate:modelValue":F[0]||(F[0]=te=>S.value=te),images:L.value},null,8,["modelValue","images"]),ue(zg,{ref_key:"mentionPickerRef",ref:c,open:h.value.open&&!!g.value,"session-id":e.codexSessionId,query:h.value.query,"anchor-rect":g.value,onClose:wt,onSelect:yt},null,8,["open","session-id","query","anchor-rect"])],32))}},yh={key:0,class:"theme-muted-text flex h-full items-center px-5 py-4 text-sm"},br={__name:"WorkbenchInputPanel",props:{codexSessionId:{type:String,default:""},sendBehavior:{type:String,default:"shift_enter"},modelValue:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1}},emits:["update:modelValue","upload-files","import-text-files","import-pdf-files","file-feedback","clear-request","send-request"],setup(e,{expose:t,emit:n}){const o=e,s=n,r=V(null),{t:l}=It(),u=q({get:()=>o.modelValue,set:v=>s("update:modelValue",v)});function p(){var v,L;(L=(v=r.value)==null?void 0:v.openFilePicker)==null||L.call(v)}function w(){var v,L;(L=(v=r.value)==null?void 0:v.focusEditor)==null||L.call(v)}function c(){var v,L;return((L=(v=r.value)==null?void 0:v.flushPendingInput)==null?void 0:L.call(v))||!1}function S(v){var L,U;(U=(L=r.value)==null?void 0:L.insertBlocks)==null||U.call(L,v)}function h(v){var L,U;(U=(L=r.value)==null?void 0:L.insertImportedBlocks)==null||U.call(L,v)}function g(v){var L,U;(U=(L=r.value)==null?void 0:L.insertUploadedBlocks)==null||U.call(L,v)}function f(){var v,L;return((L=(v=r.value)==null?void 0:v.isImportedBlockActive)==null?void 0:L.call(v))||!1}function P(){var v,L;return((L=(v=r.value)==null?void 0:v.isComposing)==null?void 0:L.call(v))||!1}function Z(){var v,L;return((L=(v=r.value)==null?void 0:v.isEditing)==null?void 0:L.call(v))||!1}return t({focusEditor:w,flushPendingInput:c,insertBlocks:S,insertImportedBlocks:h,insertUploadedBlocks:g,isComposing:P,isEditing:Z,isImportedBlockActive:f,openFilePicker:p}),(v,L)=>e.loading&&!e.modelValue.length?(m(),k("section",yh,b(a(l)("workbench.loadingTaskContent")),1)):(m(),Ae(vh,{key:1,ref_key:"blockEditorRef",ref:r,modelValue:u.value,"onUpdate:modelValue":L[0]||(L[0]=U=>u.value=U),"codex-session-id":e.codexSessionId,"send-behavior":e.sendBehavior,onUploadFiles:L[1]||(L[1]=U=>s("upload-files",U)),onImportTextFiles:L[2]||(L[2]=U=>s("import-text-files",U)),onImportPdfFiles:L[3]||(L[3]=U=>s("import-pdf-files",U)),onFileFeedback:L[4]||(L[4]=U=>s("file-feedback",U)),onClearRequest:L[5]||(L[5]=U=>s("clear-request")),onSendRequest:L[6]||(L[6]=U=>s("send-request"))},null,8,["modelValue","codex-session-id","send-behavior"]))}},Sh={class:"panel workbench-mobile-header-panel shrink-0 overflow-hidden"},wh={class:"workbench-panel-header workbench-mobile-header theme-divider border-b px-2.5 py-2"},xh={class:"flex items-center gap-2"},bh=["title","aria-label"],kh={class:"min-w-0 flex-1"},Th=["value","placeholder"],_h=["disabled"],Ch={class:"truncate"},Eh={__name:"WorkbenchMobileDetailHeader",props:{currentTaskSlug:{type:String,default:""},editingTaskTitleSlug:{type:String,default:""},title:{type:String,default:""},titleInputValue:{type:String,default:""},currentTaskAutoTitle:{type:String,default:""}},emits:["back","begin-edit","title-blur","cancel-title-edit","update:titleInputValue"],setup(e,{emit:t}){const n=t,{t:o}=It();return(s,r)=>(m(),k("section",Sh,[i("div",wh,[i("div",xh,[i("button",{type:"button",class:"tool-button inline-flex h-8 w-8 shrink-0 items-center justify-center px-0 py-0 text-[11px]",title:a(o)("workbench.tasks"),"aria-label":a(o)("workbench.tasks"),onClick:r[0]||(r[0]=l=>n("back"))},[ue(a(Za),{class:"h-3.5 w-3.5"})],8,bh),i("div",kh,[e.currentTaskSlug&&e.editingTaskTitleSlug===e.currentTaskSlug?(m(),k("input",{key:0,value:e.titleInputValue,type:"text",maxlength:"140","data-task-title-input":"current",class:"block w-full appearance-none border-0 bg-transparent p-0 text-left text-[13px] font-semibold leading-5 outline-none placeholder:text-[var(--theme-textMuted)]",placeholder:e.currentTaskAutoTitle||a(o)("workbench.untitledTask"),onInput:r[1]||(r[1]=l=>n("update:titleInputValue",l.target.value)),onKeydown:[r[2]||(r[2]=sn(st(l=>l.target.blur(),["prevent"]),["enter"])),r[3]||(r[3]=sn(st(l=>n("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:r[4]||(r[4]=l=>n("title-blur"))},null,40,Th)):(m(),k("button",{key:1,type:"button",class:"inline-flex w-full items-center gap-1 truncate bg-transparent p-0 text-left text-[13px] font-semibold leading-5",disabled:!e.currentTaskSlug,onClick:r[5]||(r[5]=l=>n("begin-edit"))},[i("span",Ch,b(e.title||a(o)("workbench.untitledTask")),1),ue(a(cs),{class:"h-2.5 w-2.5 shrink-0 opacity-50"})],8,_h))])])])]))}},Ah={class:"workbench-sidebar-panel panel flex h-full min-h-0 flex-col overflow-hidden"},Ih={class:"workbench-panel-header theme-divider border-b px-4 py-4"},$h={class:"flex items-center justify-between gap-3"},Ph={class:"flex min-h-8 items-center"},Dh={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Lh=["title"],Mh=["disabled","title"],Bh={class:"whitespace-nowrap"},Rh={class:"min-h-0 flex-1 overflow-y-auto px-3 py-3"},Nh={key:0,class:"theme-empty-state px-3 py-4 text-sm"},Oh=["onClick"],Fh={key:0,class:"theme-selection-indicator absolute inset-y-2 left-0 w-1 rounded-full"},Uh={key:1,class:"absolute right-2 top-2 h-2.5 w-2.5 rounded-full bg-[var(--theme-danger)] shadow-[0_0_0_2px_var(--theme-appPanel)]","aria-hidden":"true"},jh={class:"flex items-start justify-between gap-3"},Vh={class:"flex min-w-0 flex-1 items-start gap-2 overflow-hidden"},zh=["title","aria-label"],Hh={class:"min-w-0 h-5 flex-1 overflow-hidden"},qh=["value","placeholder"],Kh=["title","onClick"],Wh={class:"min-w-0 truncate"},Gh={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},Xh={class:"workbench-task-card__preview mt-2 truncate text-xs opacity-80"},Yh={class:"mt-2 flex items-center justify-between gap-3"},Jh={class:"min-w-0 text-[11px] opacity-70"},Qh={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},Zh={class:"theme-divider border-t px-3 py-3"},ev={key:0,class:"theme-danger-text mb-3 inline-flex min-w-0 items-start gap-2 text-xs"},tv={class:"min-w-0 break-words"},nv={class:"grid grid-cols-2 gap-2"},sv=["disabled","title"],ov={class:"whitespace-nowrap"},rv=["disabled","title"],av={class:"whitespace-nowrap"},iv={__name:"WorkbenchTaskListPanel",props:{loadingTasks:{type:Boolean,default:!1},tasks:{type:Array,default:()=>[]},currentTaskSlug:{type:String,default:""},editingTaskTitleSlug:{type:String,default:""},draftTitle:{type:String,default:""},currentTaskAutoTitle:{type:String,default:""},creatingTask:{type:Boolean,default:!1},loadingTask:{type:Boolean,default:!1},uploading:{type:Boolean,default:!1},error:{type:String,default:""},removingTask:{type:Boolean,default:!1},isCurrentTaskSending:{type:Boolean,default:!1},mobile:{type:Boolean,default:!1}},emits:["open-settings","create-task","reorder-task","select-task","title-click","title-blur","cancel-title-edit","update:draftTitle","edit-task","delete-task"],setup(e,{emit:t}){const n=e,o=t,{t:s}=It(),r=V([]);Ie(()=>n.tasks,h=>{r.value=Array.isArray(h)?[...h]:[]},{immediate:!0});function l(h){return h.slug===n.currentTaskSlug?"workbench-task-card--active theme-card-selected":h.sending?"workbench-task-card--running theme-card-warning":"theme-card-idle-muted"}function u(){return"theme-status-warning"}function p(h){const g=new Date(h.updatedAt);return Number.isNaN(g.getTime())?"":$r(g.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function w(h){var g,f;return!!((g=h==null?void 0:h.workspaceDiffSummary)!=null&&g.supported&&((f=h==null?void 0:h.workspaceDiffSummary)!=null&&f.fileCount))}function c(h){return h.slug===n.currentTaskSlug?"theme-badge-strong":"theme-badge-muted"}function S(h){if(n.mobile)return;const g=Number(h==null?void 0:h.oldIndex),f=Number(h==null?void 0:h.newIndex);!Number.isInteger(g)||!Number.isInteger(f)||g===f||o("reorder-task",r.value.map(P=>String((P==null?void 0:P.slug)||"").trim()).filter(Boolean))}return(h,g)=>(m(),k("aside",Ah,[i("div",Ih,[i("div",$h,[i("div",Ph,[i("div",Dh,[ue(a(ei),{class:"h-4 w-4"}),i("span",null,b(a(s)("workbench.title")),1)])]),i("button",{type:"button",class:"tool-button inline-flex items-center gap-2 whitespace-nowrap px-3 py-2 text-xs",title:a(s)("workbench.settings"),onClick:g[0]||(g[0]=f=>o("open-settings"))},[ue(a(ti),{class:"h-4 w-4"}),i("span",{class:we(e.mobile?"whitespace-nowrap":"hidden whitespace-nowrap sm:inline")},b(a(s)("workbench.settings")),3)],8,Lh)]),i("button",{type:"button",class:"tool-button tool-button-primary mt-4 inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:e.creatingTask||e.uploading,title:e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask"),onClick:g[1]||(g[1]=f=>o("create-task"))},[ue(a(js),{class:"h-4 w-4"}),i("span",Bh,b(e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask")),1)],8,Mh)]),i("div",Rh,[e.loadingTasks&&!e.tasks.length?(m(),k("div",Nh,b(a(s)("workbench.loadingTasks")),1)):(m(),Ae(a(ni),{key:1,modelValue:r.value,"onUpdate:modelValue":g[8]||(g[8]=f=>r.value=f),class:"space-y-2",animation:180,disabled:e.mobile||e.tasks.length<=1,handle:".task-drag-handle","ghost-class":"workbench-task-card--ghost","chosen-class":"workbench-task-card--chosen","drag-class":"workbench-task-card--dragging","fallback-tolerance":"6",onEnd:S},{default:nt(()=>[(m(!0),k(it,null,mt(r.value,f=>{var P,Z;return m(),k("article",{key:f.slug,class:we(["workbench-task-card group relative cursor-default rounded-sm border px-3 py-3 transition",l(f)]),onClick:v=>o("select-task",f.slug)},[f.slug===e.currentTaskSlug?(m(),k("span",Fh)):pe("",!0),f.hasUnreadUpdate?(m(),k("span",Uh)):pe("",!0),i("div",jh,[i("div",Vh,[e.mobile?pe("",!0):(m(),k("button",{key:0,type:"button",class:"task-drag-handle mt-0.5 inline-flex h-4 w-4 shrink-0 cursor-grab items-center justify-center rounded-sm opacity-45 transition hover:opacity-80 active:cursor-grabbing",title:a(s)("workbench.dragToReorder"),"aria-label":a(s)("workbench.dragToReorder"),tabindex:"-1",onClick:g[2]||(g[2]=st(()=>{},["stop"]))},[ue(a(si),{class:"h-3.5 w-3.5"})],8,zh)),i("div",Hh,[f.slug===e.currentTaskSlug&&e.editingTaskTitleSlug===f.slug?(m(),k("input",{key:0,value:e.draftTitle,type:"text",maxlength:"140","data-task-title-input":"current",class:"block h-5 min-h-0 w-full appearance-none border-0 bg-transparent p-0 text-left text-sm font-semibold leading-5 outline-none placeholder:text-[var(--theme-textMuted)]",placeholder:e.currentTaskAutoTitle||a(s)("workbench.untitledTask"),onClick:g[3]||(g[3]=st(()=>{},["stop"])),onInput:g[4]||(g[4]=v=>o("update:draftTitle",v.target.value)),onKeydown:[g[5]||(g[5]=sn(st(v=>v.target.blur(),["prevent"]),["enter"])),g[6]||(g[6]=sn(st(v=>o("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:g[7]||(g[7]=v=>o("title-blur"))},null,40,qh)):(m(),k("button",{key:1,type:"button",class:we(["inline-flex h-5 w-full items-center gap-1.5 truncate bg-transparent p-0 text-left text-sm leading-5",f.slug===e.currentTaskSlug?"font-semibold":"font-medium"]),title:f.displayTitle,onClick:st(v=>o("title-click",f.slug),["stop"])},[(P=f.automation)!=null&&P.enabled?(m(),Ae(a(Us),{key:0,class:"h-3.5 w-3.5 shrink-0 opacity-70"})):pe("",!0),i("span",Wh,b(f.displayTitle),1)],10,Kh))])]),i("div",Gh,[f.sending?(m(),k("span",{key:0,class:we(["inline-flex items-center gap-1.5 rounded-sm border border-dashed px-1.5 py-0.5",u()])},[g[11]||(g[11]=i("span",{class:"task-loading-dots","aria-hidden":"true"},[i("span",{class:"task-loading-dots__dot"}),i("span",{class:"task-loading-dots__dot"}),i("span",{class:"task-loading-dots__dot"})],-1)),i("span",null,b(a(s)("workbench.running")),1)],2)):pe("",!0)])]),i("div",Xh,b(f.lastPromptPreview||a(s)("workbench.noMessagesYet")),1),i("div",Yh,[i("div",Jh,b(p(f)),1),i("div",Qh,[w(f)?(m(),k("span",{key:0,class:we(["inline-flex items-center gap-1 rounded-sm border border-dashed px-1.5 py-0.5",c(f)])},[i("span",null,b(a(s)("workbench.filesCount",{count:((Z=f.workspaceDiffSummary)==null?void 0:Z.fileCount)||0})),1)],2)):pe("",!0)])])],10,Oh)}),128))]),_:1},8,["modelValue","disabled"]))]),i("div",Zh,[e.error?(m(),k("div",ev,[ue(a(Do),{class:"mt-0.5 h-4 w-4 shrink-0"}),i("span",tv,b(e.error),1)])):pe("",!0),i("div",nv,[i("button",{type:"button",class:"tool-button inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:!e.currentTaskSlug||e.removingTask||e.creatingTask,title:a(s)("workbench.editTask"),onClick:g[9]||(g[9]=f=>o("edit-task"))},[ue(a(cs),{class:"h-4 w-4"}),i("span",ov,b(a(s)("workbench.editTask")),1)],8,sv),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:!e.currentTaskSlug||e.removingTask||e.creatingTask||e.isCurrentTaskSending,title:e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask"),onClick:g[10]||(g[10]=f=>o("delete-task"))},[ue(a(Js),{class:"h-4 w-4"}),i("span",av,b(e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask")),1)],8,rv)])])]))}},kr=Pr(iv,[["__scopeId","data-v-5203468b"]]),lv={class:"min-w-0"},uv={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},cv={class:"theme-muted-text mt-1 text-xs leading-5"},dv={class:"theme-divider flex items-center justify-between gap-3 border-b border-dashed px-5 py-3 text-xs"},fv={class:"theme-muted-text"},pv={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-2 py-1"},mv={key:0,class:"min-h-0 flex-1 overflow-y-auto px-5 py-4"},gv={class:"space-y-3"},hv={class:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between"},vv={class:"min-w-0 flex-1"},yv={class:"theme-heading flex flex-wrap items-center gap-2 text-sm font-medium"},Sv={class:"theme-status-neutral inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-0.5 text-[11px]"},wv={class:"mt-2 whitespace-pre-wrap break-words text-sm leading-6"},xv={class:"theme-muted-text mt-3 flex flex-wrap items-center gap-2 text-[11px]"},bv={class:"rounded-sm border border-dashed px-2 py-1"},kv={key:0,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},Tv={key:1,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},_v={key:2,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},Cv={class:"flex w-full items-center gap-2 sm:w-auto sm:shrink-0"},Ev=["onClick"],Av=["onClick"],Iv={key:1,class:"theme-empty-state flex min-h-0 flex-1 items-center justify-center px-6 py-10 text-sm"},$v={__name:"WorkbenchTodoDialog",props:{items:{type:Array,default:()=>[]},open:{type:Boolean,default:!1}},emits:["close","delete","use"],setup(e,{emit:t}){const n=e,o=t,{t:s}=It(),r=q(()=>(n.items||[]).map(u=>{var f;const p=Array.isArray(u==null?void 0:u.blocks)?u.blocks:[],w=((f=p.find(P=>["text","imported_text"].includes(String((P==null?void 0:P.type)||""))&&String((P==null?void 0:P.content)||"").trim()))==null?void 0:f.content)||"",c=String(w||"").replace(/\s+/g," ").trim().slice(0,120),S=p.filter(P=>String((P==null?void 0:P.type)||"")==="image").length,h=p.filter(P=>String((P==null?void 0:P.type)||"")==="imported_text").length,g=p.filter(P=>String((P==null?void 0:P.type)||"")==="text"&&String((P==null?void 0:P.content)||"").trim()).length;return{...u,blockCount:p.length,imageCount:S,importedCount:h,preview:c||(S?s("todoDialog.imagePreview",{count:S}):s("todoDialog.noPreview")),textCount:g,timeLabel:l(u==null?void 0:u.createdAt)}}));function l(u=""){const p=Date.parse(String(u||""));if(!p)return s("todoDialog.justAdded");try{return new Intl.DateTimeFormat(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(p))}catch{return String(u||"")}}return(u,p)=>(m(),Ae(Qs,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-3xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"px-5 py-4","body-class":"min-h-0 flex flex-1 flex-col overflow-hidden",onClose:p[0]||(p[0]=w=>o("close"))},{title:nt(()=>[i("div",lv,[i("div",uv,[ue(a(Nr),{class:"h-4 w-4"}),i("span",null,b(a(s)("todoDialog.title")),1)]),i("p",cv,b(a(s)("todoDialog.intro")),1)])]),default:nt(()=>[i("div",dv,[i("span",fv,b(a(s)("todoDialog.summary",{count:r.value.length})),1),i("span",pv,b(a(s)("todoDialog.summaryHint")),1)]),r.value.length?(m(),k("div",mv,[i("div",gv,[(m(!0),k(it,null,mt(r.value,w=>(m(),k("article",{key:w.id,class:"theme-card-idle-muted rounded-sm border border-dashed p-4"},[i("div",hv,[i("div",vv,[i("div",yv,[i("span",null,b(a(s)("todoDialog.itemTitle")),1),i("span",Sv,[ue(a(Us),{class:"h-3.5 w-3.5"}),xn(" "+b(w.timeLabel),1)])]),i("p",wv,b(w.preview),1),i("div",xv,[i("span",bv,b(a(s)("todoDialog.blockCount",{count:w.blockCount})),1),w.textCount?(m(),k("span",kv,[ue(a(Vs),{class:"h-3.5 w-3.5"}),xn(" "+b(a(s)("todoDialog.textCount",{count:w.textCount})),1)])):pe("",!0),w.importedCount?(m(),k("span",Tv,[ue(a(Vs),{class:"h-3.5 w-3.5"}),xn(" "+b(a(s)("todoDialog.importedCount",{count:w.importedCount})),1)])):pe("",!0),w.imageCount?(m(),k("span",_v,[ue(a(Or),{class:"h-3.5 w-3.5"}),xn(" "+b(a(s)("todoDialog.imageCount",{count:w.imageCount})),1)])):pe("",!0)])]),i("div",Cv,[i("button",{type:"button",class:"tool-button inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:c=>o("use",w.id)},[ue(a(oi),{class:"h-4 w-4"}),i("span",null,b(a(s)("todoDialog.use")),1)],8,Ev),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:c=>o("delete",w.id)},[ue(a(Js),{class:"h-4 w-4"}),i("span",null,b(a(s)("todoDialog.delete")),1)],8,Av)])])]))),128))])])):(m(),k("div",Iv,b(a(s)("todoDialog.empty")),1))]),_:1},8,["open"]))}},Pv={class:"pointer-events-none fixed inset-x-0 top-4 z-40 flex justify-center px-4"},Dv={__name:"TopToast",props:{message:{type:String,default:""},type:{type:String,default:"success"}},setup(e){const t=e;function n(s="success"){return s==="warning"?"theme-status-warning":s==="error"?"theme-status-danger":s==="info"?"theme-status-info":"theme-status-success"}function o(s="success"){return s==="warning"?Do:s==="error"?ri:s==="info"?ai:ii}return(s,r)=>(m(),Ae(gs,{to:"body"},[i("div",Pv,[ue(Lr,{"enter-active-class":"transform transition duration-200 ease-out","enter-from-class":"-translate-y-3 opacity-0","enter-to-class":"translate-y-0 opacity-100","leave-active-class":"transform transition duration-150 ease-in","leave-from-class":"translate-y-0 opacity-100","leave-to-class":"-translate-y-2 opacity-0"},{default:nt(()=>[e.message?(m(),k("div",{key:0,class:we(["app-top-toast flex max-w-md items-center gap-2 rounded-sm border px-4 py-2 text-sm shadow-[var(--theme-shadowPanel)] backdrop-blur",n(t.type)])},[(m(),Ae(Tn(o(t.type)),{class:"h-4 w-4 shrink-0"})),i("span",null,b(e.message),1)],2)):pe("",!0)]),_:1})])]))}};function Lv(e,t=!1){const n=V(!!t);let o=null,s=()=>{};function r(l){n.value=!!l}return pn(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;o=window.matchMedia(e),r(o.matches);const l=u=>{r(u.matches)};if(typeof o.addEventListener=="function"){o.addEventListener("change",l),s=()=>o==null?void 0:o.removeEventListener("change",l);return}typeof o.addListener=="function"&&(o.addListener(l),s=()=>o==null?void 0:o.removeListener(l))}),Ot(()=>{s()}),{matches:n}}const Mv="(max-width: 1023px)",Os="promptxWorkbenchMobileView";function wo(e){return(e==null?void 0:e[Os])==="detail"}function Bv({currentTaskSlug:e}){const{matches:t}=Lv(Mv),n=V("tasks"),o=V("activity");function s(S="tasks"){if(typeof window>"u")return;const h={...window.history.state||{}};S==="detail"?h[Os]="detail":delete h[Os],window.history.replaceState(h,"")}function r(){if(typeof window>"u")return;const S={...window.history.state||{},[Os]:"detail"};window.history.pushState(S,"")}function l(S=null){if(!t.value){n.value="detail";return}if(!e.value){n.value="tasks",s("tasks");return}n.value=wo(S)?"detail":"tasks"}function u(S){t.value=!!S,l(typeof window>"u"?null:window.history.state)}function p(S={}){const{pushHistory:h=!0}=S;if(n.value="detail",!!t.value){if(h){r();return}s("detail")}}function w(S={}){const{useHistory:h=!0}=S;if(!t.value){n.value="tasks";return}if(h&&typeof window<"u"&&wo(window.history.state)){window.history.back();return}n.value="tasks",s("tasks")}function c(S){t.value&&(n.value=wo(S.state)&&e.value?"detail":"tasks")}return pn(()=>{typeof window>"u"||window.addEventListener("popstate",c)}),Ot(()=>{typeof window<"u"&&window.removeEventListener("popstate",c)}),Ie(t,S=>{u(S)},{immediate:!0}),Ie(e,()=>{typeof window>"u"||l(window.history.state)},{flush:"post"}),{enterMobileDetail:p,isMobileLayout:t,leaveMobileDetail:w,mobileDetailTab:o,mobileView:n}}const Ks="PromptX";function Rv(e=""){const t=String(a(e)||"").trim();return t?`${Ks} (${t})`:Ks}function Nv(e="",t={}){Fa(()=>{if(typeof document>"u")return;const o=String(a(e)||"").trim();document.title=a(t.raw)?o||Ks:Rv(o)}),Ot(()=>{typeof document>"u"||(document.title=Ks)})}const Xn="success";function Ov(e,t){return e&&typeof e=="object"&&!Array.isArray(e)?{message:String(e.message||"").trim(),type:String(e.type||Xn).trim()||Xn,duration:Number(e.duration)>0?Number(e.duration):t}:{message:String(e||"").trim(),type:Xn,duration:t}}function Fv(e=2200){const t=V(""),n=V(Xn);let o=null;function s(){o&&(window.clearTimeout(o),o=null),t.value="",n.value=Xn}function r(l,u=e){const p=Ov(l,u);if(!p.message){s();return}t.value=p.message,n.value=p.type,o&&window.clearTimeout(o),o=window.setTimeout(()=>{t.value="",n.value=Xn,o=null},p.duration)}return Ot(()=>{o&&window.clearTimeout(o)}),{toastMessage:t,toastType:n,flashToast:r,clearToast:s}}function Uv(e="",t=""){const n=String(e||"").trim();if(!n)return"";if(/^https?:\/\//i.test(n))return n;try{return new URL(n,t).toString()}catch{return n}}function jv(e=""){const t=String(e||"").replace(/\r\n/g,`
|
|
50
|
+
`,"\0");if(/\s/.test(rt)){Ge();return}f.value=null,h.value={...te,end:F.from,query:rt},Ue(F.from);return}if(!F){Ge();return}const Ce=F.textBefore.lastIndexOf("@");if(Ce<0){Ge();return}const ze=F.textBefore.slice(Ce+1);if(/\s/.test(ze)){Ge();return}const Le=F.nodeStart+Ce,tt=F.from;De(f.value,{start:Le,end:tt,query:ze,clientId:F.clientId})||(f.value=null,h.value={open:!0,start:Le,end:tt,query:ze,trigger:"mention",blockType:F.nodeTypeName,clientId:F.clientId},Ue(tt))}function $t(){const C=G.value,F=Ct(C);return!C||!F?!1:(f.value=null,h.value={open:!0,start:F.from,end:F.from,query:"",trigger:"shortcut",blockType:F.nodeTypeName,clientId:F.clientId},Ue(F.from),!0)}function yt(C){const F=G.value,te=String((C==null?void 0:C.path)||"").trim(),Ce=h.value;if(!F||!te||Ce.start<0||Ce.end<Ce.start)return Ge(),!1;const ze=Ce.trigger==="shortcut"?`${te} `:`@${te} `,Le=Ce.start+ze.length;return F.chain().focus().command(({tr:tt,dispatch:rt})=>(tt.insertText(ze,Ce.start,Ce.end),tt.setSelection(Oa.create(tt.doc,Le)),rt==null||rt(tt),!0)).run(),Z.value=Date.now(),f.value=null,Ge(),!0}function Ze(C){var F,te,Ce,ze,Le,tt,rt,Et,gt,xt;if(!h.value.open)return!1;if(C.key==="Escape")return wt(),!0;if(C.key==="ArrowDown")return!!((te=(F=c.value)==null?void 0:F.moveActive)!=null&&te.call(F,1));if(C.key==="ArrowUp")return!!((ze=(Ce=c.value)==null?void 0:Ce.moveActive)!=null&&ze.call(Ce,-1));if(h.value.query&&(C.key==="ArrowLeft"||C.key==="ArrowRight"))return!1;if(C.key==="ArrowRight"){const St=(tt=(Le=c.value)==null?void 0:Le.expandActiveDirectory)==null?void 0:tt.call(Le);return St&&typeof St.then=="function"?(St.catch(()=>{}),!0):!!St}return C.key==="ArrowLeft"?!!((Et=(rt=c.value)==null?void 0:rt.collapseActiveDirectory)!=null&&Et.call(rt)):!C.shiftKey&&!C.altKey&&!C.metaKey&&!C.ctrlKey&&C.key==="Enter"?!!((xt=(gt=c.value)==null?void 0:gt.confirmActive)!=null&&xt.call(gt)):!1}return pn(()=>{window.addEventListener("promptx:tiptap-image-preview",Me),window.addEventListener("resize",Ue),window.addEventListener("scroll",Ue)}),Ot(()=>{window.removeEventListener("promptx:tiptap-image-preview",Me),window.removeEventListener("resize",Ue),window.removeEventListener("scroll",Ue)}),Ie(()=>o.codexSessionId,()=>{Ge()}),t({clearContent:$e,flushPendingInput:Je,focusEditor:Xe,insertBlocks:W,insertImportedBlocks:oe,insertUploadedBlocks:fe,isComposing:me,isEditing:Ne,isImportedBlockActive:he,openFilePicker:Ve}),(C,F)=>(m(),k("section",{class:"workbench-input-editor relative flex h-full min-h-0 flex-col overflow-hidden","data-promptx-editor":"tiptap",onDrop:Be,onDragover:F[1]||(F[1]=st(()=>{},["prevent"])),onPaste:E},[i("input",{ref_key:"fileInputRef",ref:w,class:"hidden",type:"file",accept:a(p),multiple:"",onChange:Re},null,40,gh),i("div",{class:"flex-1 overflow-y-auto px-5 py-5","data-promptx-editor-scroll":"tiptap",onMousedown:Pe},[a(G)?(m(),Ae(a(di),{key:0,editor:a(G),class:"min-h-full","data-promptx-editor-content":"tiptap"},null,8,["editor"])):pe("",!0)],32),ue(Kr,{modelValue:S.value,"onUpdate:modelValue":F[0]||(F[0]=te=>S.value=te),images:L.value},null,8,["modelValue","images"]),ue(zg,{ref_key:"mentionPickerRef",ref:c,open:h.value.open&&!!g.value,"session-id":e.codexSessionId,query:h.value.query,"anchor-rect":g.value,onClose:wt,onSelect:yt},null,8,["open","session-id","query","anchor-rect"])],32))}},yh={key:0,class:"theme-muted-text flex h-full items-center px-5 py-4 text-sm"},br={__name:"WorkbenchInputPanel",props:{codexSessionId:{type:String,default:""},sendBehavior:{type:String,default:"shift_enter"},modelValue:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1}},emits:["update:modelValue","upload-files","import-text-files","import-pdf-files","file-feedback","clear-request","send-request"],setup(e,{expose:t,emit:n}){const o=e,s=n,r=V(null),{t:l}=It(),u=q({get:()=>o.modelValue,set:v=>s("update:modelValue",v)});function p(){var v,L;(L=(v=r.value)==null?void 0:v.openFilePicker)==null||L.call(v)}function w(){var v,L;(L=(v=r.value)==null?void 0:v.focusEditor)==null||L.call(v)}function c(){var v,L;return((L=(v=r.value)==null?void 0:v.flushPendingInput)==null?void 0:L.call(v))||!1}function S(v){var L,U;(U=(L=r.value)==null?void 0:L.insertBlocks)==null||U.call(L,v)}function h(v){var L,U;(U=(L=r.value)==null?void 0:L.insertImportedBlocks)==null||U.call(L,v)}function g(v){var L,U;(U=(L=r.value)==null?void 0:L.insertUploadedBlocks)==null||U.call(L,v)}function f(){var v,L;return((L=(v=r.value)==null?void 0:v.isImportedBlockActive)==null?void 0:L.call(v))||!1}function P(){var v,L;return((L=(v=r.value)==null?void 0:v.isComposing)==null?void 0:L.call(v))||!1}function Z(){var v,L;return((L=(v=r.value)==null?void 0:v.isEditing)==null?void 0:L.call(v))||!1}return t({focusEditor:w,flushPendingInput:c,insertBlocks:S,insertImportedBlocks:h,insertUploadedBlocks:g,isComposing:P,isEditing:Z,isImportedBlockActive:f,openFilePicker:p}),(v,L)=>e.loading&&!e.modelValue.length?(m(),k("section",yh,b(a(l)("workbench.loadingTaskContent")),1)):(m(),Ae(vh,{key:1,ref_key:"blockEditorRef",ref:r,modelValue:u.value,"onUpdate:modelValue":L[0]||(L[0]=U=>u.value=U),"codex-session-id":e.codexSessionId,"send-behavior":e.sendBehavior,onUploadFiles:L[1]||(L[1]=U=>s("upload-files",U)),onImportTextFiles:L[2]||(L[2]=U=>s("import-text-files",U)),onImportPdfFiles:L[3]||(L[3]=U=>s("import-pdf-files",U)),onFileFeedback:L[4]||(L[4]=U=>s("file-feedback",U)),onClearRequest:L[5]||(L[5]=U=>s("clear-request")),onSendRequest:L[6]||(L[6]=U=>s("send-request"))},null,8,["modelValue","codex-session-id","send-behavior"]))}},Sh={class:"panel workbench-mobile-header-panel shrink-0 overflow-hidden"},wh={class:"workbench-panel-header workbench-mobile-header theme-divider border-b px-2.5 py-2"},xh={class:"flex items-center gap-2"},bh=["title","aria-label"],kh={class:"min-w-0 flex-1"},Th=["value","placeholder"],_h=["disabled"],Ch={class:"truncate"},Eh={__name:"WorkbenchMobileDetailHeader",props:{currentTaskSlug:{type:String,default:""},editingTaskTitleSlug:{type:String,default:""},title:{type:String,default:""},titleInputValue:{type:String,default:""},currentTaskAutoTitle:{type:String,default:""}},emits:["back","begin-edit","title-blur","cancel-title-edit","update:titleInputValue"],setup(e,{emit:t}){const n=t,{t:o}=It();return(s,r)=>(m(),k("section",Sh,[i("div",wh,[i("div",xh,[i("button",{type:"button",class:"tool-button inline-flex h-8 w-8 shrink-0 items-center justify-center px-0 py-0 text-[11px]",title:a(o)("workbench.tasks"),"aria-label":a(o)("workbench.tasks"),onClick:r[0]||(r[0]=l=>n("back"))},[ue(a(Za),{class:"h-3.5 w-3.5"})],8,bh),i("div",kh,[e.currentTaskSlug&&e.editingTaskTitleSlug===e.currentTaskSlug?(m(),k("input",{key:0,value:e.titleInputValue,type:"text",maxlength:"140","data-task-title-input":"current",class:"block w-full appearance-none border-0 bg-transparent p-0 text-left text-[13px] font-semibold leading-5 outline-none placeholder:text-[var(--theme-textMuted)]",placeholder:e.currentTaskAutoTitle||a(o)("workbench.untitledTask"),onInput:r[1]||(r[1]=l=>n("update:titleInputValue",l.target.value)),onKeydown:[r[2]||(r[2]=sn(st(l=>l.target.blur(),["prevent"]),["enter"])),r[3]||(r[3]=sn(st(l=>n("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:r[4]||(r[4]=l=>n("title-blur"))},null,40,Th)):(m(),k("button",{key:1,type:"button",class:"inline-flex w-full items-center gap-1 truncate bg-transparent p-0 text-left text-[13px] font-semibold leading-5",disabled:!e.currentTaskSlug,onClick:r[5]||(r[5]=l=>n("begin-edit"))},[i("span",Ch,b(e.title||a(o)("workbench.untitledTask")),1),ue(a(cs),{class:"h-2.5 w-2.5 shrink-0 opacity-50"})],8,_h))])])])]))}},Ah={class:"workbench-sidebar-panel panel flex h-full min-h-0 flex-col overflow-hidden"},Ih={class:"workbench-panel-header theme-divider border-b px-4 py-4"},$h={class:"flex items-center justify-between gap-3"},Ph={class:"flex min-h-8 items-center"},Dh={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Lh=["title"],Mh=["disabled","title"],Bh={class:"whitespace-nowrap"},Rh={class:"min-h-0 flex-1 overflow-y-auto px-3 py-3"},Nh={key:0,class:"theme-empty-state px-3 py-4 text-sm"},Oh=["onClick"],Fh={key:0,class:"theme-selection-indicator absolute inset-y-2 left-0 w-1 rounded-full"},Uh={key:1,class:"absolute right-2 top-2 h-2.5 w-2.5 rounded-full bg-[var(--theme-danger)] shadow-[0_0_0_2px_var(--theme-appPanel)]","aria-hidden":"true"},jh={class:"flex items-start justify-between gap-3"},Vh={class:"flex min-w-0 flex-1 items-start gap-2 overflow-hidden"},zh=["title","aria-label"],Hh={class:"flex h-5 min-w-0 flex-1 items-center"},qh=["value","placeholder"],Kh=["title","onClick"],Wh={class:"min-w-0 truncate"},Gh={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},Xh={class:"workbench-task-card__preview mt-2 truncate text-xs opacity-80"},Yh={class:"mt-2 flex items-center justify-between gap-3"},Jh={class:"min-w-0 text-[11px] opacity-70"},Qh={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},Zh={class:"theme-divider border-t px-3 py-3"},ev={key:0,class:"theme-danger-text mb-3 inline-flex min-w-0 items-start gap-2 text-xs"},tv={class:"min-w-0 break-words"},nv={class:"grid grid-cols-2 gap-2"},sv=["disabled","title"],ov={class:"whitespace-nowrap"},rv=["disabled","title"],av={class:"whitespace-nowrap"},iv={__name:"WorkbenchTaskListPanel",props:{loadingTasks:{type:Boolean,default:!1},tasks:{type:Array,default:()=>[]},currentTaskSlug:{type:String,default:""},editingTaskTitleSlug:{type:String,default:""},draftTitle:{type:String,default:""},currentTaskAutoTitle:{type:String,default:""},creatingTask:{type:Boolean,default:!1},loadingTask:{type:Boolean,default:!1},uploading:{type:Boolean,default:!1},error:{type:String,default:""},removingTask:{type:Boolean,default:!1},isCurrentTaskSending:{type:Boolean,default:!1},mobile:{type:Boolean,default:!1}},emits:["open-settings","create-task","reorder-task","select-task","title-click","title-blur","cancel-title-edit","update:draftTitle","edit-task","delete-task"],setup(e,{emit:t}){const n=e,o=t,{t:s}=It(),r=V([]);Ie(()=>n.tasks,h=>{r.value=Array.isArray(h)?[...h]:[]},{immediate:!0});function l(h){return h.slug===n.currentTaskSlug?"workbench-task-card--active theme-card-selected":h.sending?"workbench-task-card--running theme-card-warning":"theme-card-idle-muted"}function u(){return"theme-status-warning"}function p(h){const g=new Date(h.updatedAt);return Number.isNaN(g.getTime())?"":$r(g.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function w(h){var g,f;return!!((g=h==null?void 0:h.workspaceDiffSummary)!=null&&g.supported&&((f=h==null?void 0:h.workspaceDiffSummary)!=null&&f.fileCount))}function c(h){return h.slug===n.currentTaskSlug?"theme-badge-strong":"theme-badge-muted"}function S(h){if(n.mobile)return;const g=Number(h==null?void 0:h.oldIndex),f=Number(h==null?void 0:h.newIndex);!Number.isInteger(g)||!Number.isInteger(f)||g===f||o("reorder-task",r.value.map(P=>String((P==null?void 0:P.slug)||"").trim()).filter(Boolean))}return(h,g)=>(m(),k("aside",Ah,[i("div",Ih,[i("div",$h,[i("div",Ph,[i("div",Dh,[ue(a(ei),{class:"h-4 w-4"}),i("span",null,b(a(s)("workbench.title")),1)])]),i("button",{type:"button",class:"tool-button inline-flex items-center gap-2 whitespace-nowrap px-3 py-2 text-xs",title:a(s)("workbench.settings"),onClick:g[0]||(g[0]=f=>o("open-settings"))},[ue(a(ti),{class:"h-4 w-4"}),i("span",{class:we(e.mobile?"whitespace-nowrap":"hidden whitespace-nowrap sm:inline")},b(a(s)("workbench.settings")),3)],8,Lh)]),i("button",{type:"button",class:"tool-button tool-button-primary mt-4 inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:e.creatingTask||e.uploading,title:e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask"),onClick:g[1]||(g[1]=f=>o("create-task"))},[ue(a(js),{class:"h-4 w-4"}),i("span",Bh,b(e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask")),1)],8,Mh)]),i("div",Rh,[e.loadingTasks&&!e.tasks.length?(m(),k("div",Nh,b(a(s)("workbench.loadingTasks")),1)):(m(),Ae(a(ni),{key:1,modelValue:r.value,"onUpdate:modelValue":g[8]||(g[8]=f=>r.value=f),class:"space-y-2",animation:180,disabled:e.mobile||e.tasks.length<=1,handle:".task-drag-handle","ghost-class":"workbench-task-card--ghost","chosen-class":"workbench-task-card--chosen","drag-class":"workbench-task-card--dragging","fallback-tolerance":"6",onEnd:S},{default:nt(()=>[(m(!0),k(it,null,mt(r.value,f=>{var P,Z;return m(),k("article",{key:f.slug,class:we(["workbench-task-card group relative cursor-default rounded-sm border px-3 py-3 transition",l(f)]),onClick:v=>o("select-task",f.slug)},[f.slug===e.currentTaskSlug?(m(),k("span",Fh)):pe("",!0),f.hasUnreadUpdate?(m(),k("span",Uh)):pe("",!0),i("div",jh,[i("div",Vh,[e.mobile?pe("",!0):(m(),k("button",{key:0,type:"button",class:"task-drag-handle mt-0.5 inline-flex h-4 w-4 shrink-0 cursor-grab items-center justify-center rounded-sm opacity-45 transition hover:opacity-80 active:cursor-grabbing",title:a(s)("workbench.dragToReorder"),"aria-label":a(s)("workbench.dragToReorder"),tabindex:"-1",onClick:g[2]||(g[2]=st(()=>{},["stop"]))},[ue(a(si),{class:"h-3.5 w-3.5"})],8,zh)),i("div",Hh,[f.slug===e.currentTaskSlug&&e.editingTaskTitleSlug===f.slug?(m(),k("input",{key:0,value:e.draftTitle,type:"text",maxlength:"140","data-task-title-input":"current",class:"flex h-5 w-full items-center appearance-none border-0 bg-transparent p-0 text-left text-sm font-semibold leading-5 outline-none placeholder:text-[var(--theme-textMuted)]",placeholder:e.currentTaskAutoTitle||a(s)("workbench.untitledTask"),onClick:g[3]||(g[3]=st(()=>{},["stop"])),onInput:g[4]||(g[4]=v=>o("update:draftTitle",v.target.value)),onKeydown:[g[5]||(g[5]=sn(st(v=>v.target.blur(),["prevent"]),["enter"])),g[6]||(g[6]=sn(st(v=>o("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:g[7]||(g[7]=v=>o("title-blur"))},null,40,qh)):(m(),k("button",{key:1,type:"button",class:we(["inline-flex h-5 w-full items-center gap-1.5 truncate bg-transparent p-0 text-left text-sm leading-5",f.slug===e.currentTaskSlug?"font-semibold":"font-medium"]),title:f.displayTitle,onClick:st(v=>o("title-click",f.slug),["stop"])},[(P=f.automation)!=null&&P.enabled?(m(),Ae(a(Us),{key:0,class:"h-3.5 w-3.5 shrink-0 opacity-70"})):pe("",!0),i("span",Wh,b(f.displayTitle),1)],10,Kh))])]),i("div",Gh,[f.sending?(m(),k("span",{key:0,class:we(["inline-flex items-center gap-1.5 rounded-sm border border-dashed px-1.5 py-0.5",u()])},[g[11]||(g[11]=i("span",{class:"task-loading-dots","aria-hidden":"true"},[i("span",{class:"task-loading-dots__dot"}),i("span",{class:"task-loading-dots__dot"}),i("span",{class:"task-loading-dots__dot"})],-1)),i("span",null,b(a(s)("workbench.running")),1)],2)):pe("",!0)])]),i("div",Xh,b(f.lastPromptPreview||a(s)("workbench.noMessagesYet")),1),i("div",Yh,[i("div",Jh,b(p(f)),1),i("div",Qh,[w(f)?(m(),k("span",{key:0,class:we(["inline-flex items-center gap-1 rounded-sm border border-dashed px-1.5 py-0.5",c(f)])},[i("span",null,b(a(s)("workbench.filesCount",{count:((Z=f.workspaceDiffSummary)==null?void 0:Z.fileCount)||0})),1)],2)):pe("",!0)])])],10,Oh)}),128))]),_:1},8,["modelValue","disabled"]))]),i("div",Zh,[e.error?(m(),k("div",ev,[ue(a(Do),{class:"mt-0.5 h-4 w-4 shrink-0"}),i("span",tv,b(e.error),1)])):pe("",!0),i("div",nv,[i("button",{type:"button",class:"tool-button inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:!e.currentTaskSlug||e.removingTask||e.creatingTask,title:a(s)("workbench.editTask"),onClick:g[9]||(g[9]=f=>o("edit-task"))},[ue(a(cs),{class:"h-4 w-4"}),i("span",ov,b(a(s)("workbench.editTask")),1)],8,sv),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex w-full items-center justify-center gap-2 whitespace-nowrap px-3 py-2 text-sm",disabled:!e.currentTaskSlug||e.removingTask||e.creatingTask||e.isCurrentTaskSending,title:e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask"),onClick:g[10]||(g[10]=f=>o("delete-task"))},[ue(a(Js),{class:"h-4 w-4"}),i("span",av,b(e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask")),1)],8,rv)])])]))}},kr=Pr(iv,[["__scopeId","data-v-200c2c76"]]),lv={class:"min-w-0"},uv={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},cv={class:"theme-muted-text mt-1 text-xs leading-5"},dv={class:"theme-divider flex items-center justify-between gap-3 border-b border-dashed px-5 py-3 text-xs"},fv={class:"theme-muted-text"},pv={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-2 py-1"},mv={key:0,class:"min-h-0 flex-1 overflow-y-auto px-5 py-4"},gv={class:"space-y-3"},hv={class:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between"},vv={class:"min-w-0 flex-1"},yv={class:"theme-heading flex flex-wrap items-center gap-2 text-sm font-medium"},Sv={class:"theme-status-neutral inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-0.5 text-[11px]"},wv={class:"mt-2 whitespace-pre-wrap break-words text-sm leading-6"},xv={class:"theme-muted-text mt-3 flex flex-wrap items-center gap-2 text-[11px]"},bv={class:"rounded-sm border border-dashed px-2 py-1"},kv={key:0,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},Tv={key:1,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},_v={key:2,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},Cv={class:"flex w-full items-center gap-2 sm:w-auto sm:shrink-0"},Ev=["onClick"],Av=["onClick"],Iv={key:1,class:"theme-empty-state flex min-h-0 flex-1 items-center justify-center px-6 py-10 text-sm"},$v={__name:"WorkbenchTodoDialog",props:{items:{type:Array,default:()=>[]},open:{type:Boolean,default:!1}},emits:["close","delete","use"],setup(e,{emit:t}){const n=e,o=t,{t:s}=It(),r=q(()=>(n.items||[]).map(u=>{var f;const p=Array.isArray(u==null?void 0:u.blocks)?u.blocks:[],w=((f=p.find(P=>["text","imported_text"].includes(String((P==null?void 0:P.type)||""))&&String((P==null?void 0:P.content)||"").trim()))==null?void 0:f.content)||"",c=String(w||"").replace(/\s+/g," ").trim().slice(0,120),S=p.filter(P=>String((P==null?void 0:P.type)||"")==="image").length,h=p.filter(P=>String((P==null?void 0:P.type)||"")==="imported_text").length,g=p.filter(P=>String((P==null?void 0:P.type)||"")==="text"&&String((P==null?void 0:P.content)||"").trim()).length;return{...u,blockCount:p.length,imageCount:S,importedCount:h,preview:c||(S?s("todoDialog.imagePreview",{count:S}):s("todoDialog.noPreview")),textCount:g,timeLabel:l(u==null?void 0:u.createdAt)}}));function l(u=""){const p=Date.parse(String(u||""));if(!p)return s("todoDialog.justAdded");try{return new Intl.DateTimeFormat(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(p))}catch{return String(u||"")}}return(u,p)=>(m(),Ae(Qs,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] max-w-3xl sm:h-[96vh] sm:max-h-[96vh]","header-class":"px-5 py-4","body-class":"min-h-0 flex flex-1 flex-col overflow-hidden",onClose:p[0]||(p[0]=w=>o("close"))},{title:nt(()=>[i("div",lv,[i("div",uv,[ue(a(Nr),{class:"h-4 w-4"}),i("span",null,b(a(s)("todoDialog.title")),1)]),i("p",cv,b(a(s)("todoDialog.intro")),1)])]),default:nt(()=>[i("div",dv,[i("span",fv,b(a(s)("todoDialog.summary",{count:r.value.length})),1),i("span",pv,b(a(s)("todoDialog.summaryHint")),1)]),r.value.length?(m(),k("div",mv,[i("div",gv,[(m(!0),k(it,null,mt(r.value,w=>(m(),k("article",{key:w.id,class:"theme-card-idle-muted rounded-sm border border-dashed p-4"},[i("div",hv,[i("div",vv,[i("div",yv,[i("span",null,b(a(s)("todoDialog.itemTitle")),1),i("span",Sv,[ue(a(Us),{class:"h-3.5 w-3.5"}),xn(" "+b(w.timeLabel),1)])]),i("p",wv,b(w.preview),1),i("div",xv,[i("span",bv,b(a(s)("todoDialog.blockCount",{count:w.blockCount})),1),w.textCount?(m(),k("span",kv,[ue(a(Vs),{class:"h-3.5 w-3.5"}),xn(" "+b(a(s)("todoDialog.textCount",{count:w.textCount})),1)])):pe("",!0),w.importedCount?(m(),k("span",Tv,[ue(a(Vs),{class:"h-3.5 w-3.5"}),xn(" "+b(a(s)("todoDialog.importedCount",{count:w.importedCount})),1)])):pe("",!0),w.imageCount?(m(),k("span",_v,[ue(a(Or),{class:"h-3.5 w-3.5"}),xn(" "+b(a(s)("todoDialog.imageCount",{count:w.imageCount})),1)])):pe("",!0)])]),i("div",Cv,[i("button",{type:"button",class:"tool-button inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:c=>o("use",w.id)},[ue(a(oi),{class:"h-4 w-4"}),i("span",null,b(a(s)("todoDialog.use")),1)],8,Ev),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:c=>o("delete",w.id)},[ue(a(Js),{class:"h-4 w-4"}),i("span",null,b(a(s)("todoDialog.delete")),1)],8,Av)])])]))),128))])])):(m(),k("div",Iv,b(a(s)("todoDialog.empty")),1))]),_:1},8,["open"]))}},Pv={class:"pointer-events-none fixed inset-x-0 top-4 z-40 flex justify-center px-4"},Dv={__name:"TopToast",props:{message:{type:String,default:""},type:{type:String,default:"success"}},setup(e){const t=e;function n(s="success"){return s==="warning"?"theme-status-warning":s==="error"?"theme-status-danger":s==="info"?"theme-status-info":"theme-status-success"}function o(s="success"){return s==="warning"?Do:s==="error"?ri:s==="info"?ai:ii}return(s,r)=>(m(),Ae(gs,{to:"body"},[i("div",Pv,[ue(Lr,{"enter-active-class":"transform transition duration-200 ease-out","enter-from-class":"-translate-y-3 opacity-0","enter-to-class":"translate-y-0 opacity-100","leave-active-class":"transform transition duration-150 ease-in","leave-from-class":"translate-y-0 opacity-100","leave-to-class":"-translate-y-2 opacity-0"},{default:nt(()=>[e.message?(m(),k("div",{key:0,class:we(["app-top-toast flex max-w-md items-center gap-2 rounded-sm border px-4 py-2 text-sm shadow-[var(--theme-shadowPanel)] backdrop-blur",n(t.type)])},[(m(),Ae(Tn(o(t.type)),{class:"h-4 w-4 shrink-0"})),i("span",null,b(e.message),1)],2)):pe("",!0)]),_:1})])]))}};function Lv(e,t=!1){const n=V(!!t);let o=null,s=()=>{};function r(l){n.value=!!l}return pn(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;o=window.matchMedia(e),r(o.matches);const l=u=>{r(u.matches)};if(typeof o.addEventListener=="function"){o.addEventListener("change",l),s=()=>o==null?void 0:o.removeEventListener("change",l);return}typeof o.addListener=="function"&&(o.addListener(l),s=()=>o==null?void 0:o.removeListener(l))}),Ot(()=>{s()}),{matches:n}}const Mv="(max-width: 1023px)",Os="promptxWorkbenchMobileView";function wo(e){return(e==null?void 0:e[Os])==="detail"}function Bv({currentTaskSlug:e}){const{matches:t}=Lv(Mv),n=V("tasks"),o=V("activity");function s(S="tasks"){if(typeof window>"u")return;const h={...window.history.state||{}};S==="detail"?h[Os]="detail":delete h[Os],window.history.replaceState(h,"")}function r(){if(typeof window>"u")return;const S={...window.history.state||{},[Os]:"detail"};window.history.pushState(S,"")}function l(S=null){if(!t.value){n.value="detail";return}if(!e.value){n.value="tasks",s("tasks");return}n.value=wo(S)?"detail":"tasks"}function u(S){t.value=!!S,l(typeof window>"u"?null:window.history.state)}function p(S={}){const{pushHistory:h=!0}=S;if(n.value="detail",!!t.value){if(h){r();return}s("detail")}}function w(S={}){const{useHistory:h=!0}=S;if(!t.value){n.value="tasks";return}if(h&&typeof window<"u"&&wo(window.history.state)){window.history.back();return}n.value="tasks",s("tasks")}function c(S){t.value&&(n.value=wo(S.state)&&e.value?"detail":"tasks")}return pn(()=>{typeof window>"u"||window.addEventListener("popstate",c)}),Ot(()=>{typeof window<"u"&&window.removeEventListener("popstate",c)}),Ie(t,S=>{u(S)},{immediate:!0}),Ie(e,()=>{typeof window>"u"||l(window.history.state)},{flush:"post"}),{enterMobileDetail:p,isMobileLayout:t,leaveMobileDetail:w,mobileDetailTab:o,mobileView:n}}const Ks="PromptX";function Rv(e=""){const t=String(a(e)||"").trim();return t?`${Ks} (${t})`:Ks}function Nv(e="",t={}){Fa(()=>{if(typeof document>"u")return;const o=String(a(e)||"").trim();document.title=a(t.raw)?o||Ks:Rv(o)}),Ot(()=>{typeof document>"u"||(document.title=Ks)})}const Xn="success";function Ov(e,t){return e&&typeof e=="object"&&!Array.isArray(e)?{message:String(e.message||"").trim(),type:String(e.type||Xn).trim()||Xn,duration:Number(e.duration)>0?Number(e.duration):t}:{message:String(e||"").trim(),type:Xn,duration:t}}function Fv(e=2200){const t=V(""),n=V(Xn);let o=null;function s(){o&&(window.clearTimeout(o),o=null),t.value="",n.value=Xn}function r(l,u=e){const p=Ov(l,u);if(!p.message){s();return}t.value=p.message,n.value=p.type,o&&window.clearTimeout(o),o=window.setTimeout(()=>{t.value="",n.value=Xn,o=null},p.duration)}return Ot(()=>{o&&window.clearTimeout(o)}),{toastMessage:t,toastType:n,flashToast:r,clearToast:s}}function Uv(e="",t=""){const n=String(e||"").trim();if(!n)return"";if(/^https?:\/\//i.test(n))return n;try{return new URL(n,t).toString()}catch{return n}}function jv(e=""){const t=String(e||"").replace(/\r\n/g,`
|
|
51
51
|
`).split(`
|
|
52
52
|
`);for(;t.length&&!String(t[0]||"").trim();)t.shift();for(;t.length&&!String(t[t.length-1]||"").trim();)t.pop();return t.join(`
|
|
53
53
|
`)}function Vv(e,t){const n=[];for(const[o,s]of((e==null?void 0:e.blocks)||[]).entries()){if(s.type===Nt.TEXT||s.type===Nt.IMPORTED_TEXT){const r=jv(s.content);r&&n.push(r,"");continue}if(s.type===Nt.IMAGE){const r=Uv(s.content,t);r&&n.push(r,"")}}return n.join(`
|
|
54
54
|
`).trim()}function zv(e,t){return Vv(e,t)}const Io="promptx:active-task-slug",Hv=150,qv=1500,Kv=800,Ws=500,Wv=new Set(["completed","error","stopped","interrupted","stop_timeout","failed","cancelled","timeout"]);function Gs(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 kn(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 zt(e=[]){return(e||[]).map(t=>({id:String((t==null?void 0:t.id)||"").trim(),createdAt:String((t==null?void 0:t.createdAt)||""),blocks:kn((t==null?void 0:t.blocks)||[])}))}function Tr(e={}){return{title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),blocks:kn(e.blocks||[]),todoItems:zt(e.todoItems||[])}}function Aa(e=[]){return kn(e).filter(t=>(t==null?void 0:t.type)===Nt.IMAGE?!!String(t.content||"").trim():!!String((t==null?void 0:t.content)||"").trim())}function Gv(e=[]){return Aa(e).length>0}function Xv(){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 _r(){return kn([{type:Nt.TEXT,content:"",meta:{}}])}function $o(e=[],t=16){return Ei(e,t)||""}function Yv(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 Cr(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=$o(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 Xs(e={}){return!!(e!=null&&e.running)}function Jv(e={},t=!1){return t&&!Xs(e)?"sending":Xs(e)?"running":"idle"}function Qv(e=""){return["queued","starting","running","stopping"].includes(String(e||"").trim())}function Ia(e=""){return Wv.has(String(e||"").trim())}function Zv(e={},t={}){return!!(String((e==null?void 0:e.codexSessionId)||"").trim()&&Ia(t==null?void 0:t.status))}function $a(e="",t="",n=!1){const o=String(e||"").trim();return!!(o&&o===String(t||"").trim()&&n)}function ey(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 Pa(e={},t=""){const n=String(t||"").trim();if(!n||!(e!=null&&e[n]))return e;const o={...e||{}};return delete o[n],o}function ty(e={},t={}){return t.pageFocused?Pa(e,t.currentTaskSlug):e}function ny(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 Da(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 La(e={},t=Ws){const n=Math.max(1,Number(t)||Ws),o=Object.entries(e||{});return o.length<=n?e:Object.fromEntries(o.slice(-n))}function sy(e={},t=[],n=Ws){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=Da(l);u.taskSlug&&o.has(u.taskSlug)&&(s[r]=u)}),La(s,n)}function oy(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||!Ia(s))return{unreadMap:r,notifiedMap:l,didMark:!1,didDedupe:!1};if(Da(l[o]).status===s)return{unreadMap:r,notifiedMap:l,didMark:!1,didDedupe:!0};const p=La({...l,[o]:{taskSlug:t,status:s}},e.maxNotifiedRuns),w=ey(r,t,{currentTaskSlug:e.currentTaskSlug,pageFocused:e.pageFocused});return{unreadMap:w.unreadMap,notifiedMap:p,didMark:w.didMark,didDedupe:!1}}function Er(e="",t=72){return String(e||"").replace(/\s+/g," ").trim().slice(0,t)}function ry(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 Ar(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:Gs(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:Gs(u.workspaceDiffSummary)}:{...s,workspaceDiffSummary:null}})}function ay(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 Is(e){if(typeof window>"u")return;const t=String(e||"").trim();if(t){window.localStorage.setItem(Io,t);return}window.localStorage.removeItem(Io)}function iy(){return typeof window>"u"?"":String(window.localStorage.getItem(Io)||"").trim()}function ly(){if(typeof window>"u")return"";try{const e=new URL(window.location.href);return String(e.searchParams.get("task")||"").trim()}catch{return""}}function uy(){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 Vn(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=Gs(e.workspaceDiffSummary)),t}function cy(e={}){const{clearToast:t=()=>{},flashToast:n=()=>{},scrollCurrentPanelToBottom:o=()=>{}}=e,s=Yn(),r=fa(),l=V(null),u=V([]),p=V({}),w=V({}),c=V({}),S=V({}),h=V({}),g=V(""),f=V({title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]}),P=V(!0),Z=V(!1),v=V(!1),L=V(!1),U=V(!1),K=V(!1),M=V(""),J=V(!1),A=V("");let G=null,de=null,ge=0,$=null,ee=0,le=null;const ne=new Set;let ve=null,_=0,H={};const E=q(()=>$o(f.value.blocks)),Be=q(()=>Cr({title:f.value.title,autoTitle:f.value.autoTitle,preview:Yv(f.value.blocks)},f.value.blocks));function Pe(T,x={}){const N=String(T||"").trim();if(!N)return"";const re=x.summary||wt(N),ie=x.cachedDraft===void 0?Ct(N):x.cachedDraft,Se=N===g.value;return Object.prototype.hasOwnProperty.call(w.value,N)?String(w.value[N]||"").trim():Se?String(f.value.codexSessionId||(re==null?void 0:re.codexSessionId)||"").trim():String((ie==null?void 0:ie.codexSessionId)||(re==null?void 0:re.codexSessionId)||"").trim()}const Re=q(()=>Pe(g.value)),Ve=q(()=>Jv(wt(g.value),c.value[g.value])),Xe=q(()=>Ve.value!=="idle"),Je=q(()=>u.value.some(T=>Xs(T))||Object.values(c.value).some(Boolean)),Ee=q(()=>Object.values(S.value).some(Boolean)),W=V(0),oe=q(()=>Gv(f.value.blocks)),fe=q(()=>zt(f.value.todoItems)),$e=q(()=>Be.value||Ye("workbench.untitledTask")),me=q(()=>u.value.map(T=>$t(T)));function Ne(T=""){const x=String(T||"").trim();if(!x||x.startsWith("/uploads/"))return x;const N=Yn();if(N&&x.startsWith(N))return x.slice(N.length);if(/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?\/uploads\//.test(x)){const re=x.match(/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?(\/uploads\/.*)$/);if(re)return re[3]}return x}function he(T=""){const x=String(T||"").replace(/\r\n/g,`
|
|
55
55
|
`).split(`
|
|
56
56
|
`);for(;x.length&&!String(x[0]||"").trim();)x.shift();for(;x.length&&!String(x[x.length-1]||"").trim();)x.pop();return x.join(`
|
|
57
|
-
`)}function Me(T=[]){return T.map(x=>({id:Number.isInteger(Number(x==null?void 0:x.id))?Number(x.id):null,type:x==null?void 0:x.type,content:(x==null?void 0:x.type)==="image"?Ne(x.content):he(x.content),meta:x!=null&&x.meta?{...x.meta}:{}}))}function Ke(T=[]){return(T||[]).map(x=>({id:String((x==null?void 0:x.id)||"").trim(),createdAt:String((x==null?void 0:x.createdAt)||""),blocks:Me((x==null?void 0:x.blocks)||[])}))}function De(T=f.value.title,x=f.value.autoTitle,N=f.value.lastPromptPreview,re=f.value.todoItems,ie=f.value.codexSessionId,Se=f.value.blocks){return JSON.stringify({title:String(T||""),autoTitle:String(x||""),lastPromptPreview:String(N||""),todoItems:Ke(re),codexSessionId:String(ie||""),blocks:Me(Se)})}function dt(){return De()!==A.value}function Ge(){var T,x;return!!((x=(T=l.value)==null?void 0:T.isEditing)!=null&&x.call(T))}function wt(T){return u.value.find(x=>x.slug===T)||null}function Ct(T){return T&&p.value[T]||null}function Ue(T,x=""){const N=String(T||"").trim();N&&(H={...H,[N]:String(x||"").trim()})}function _e(T=""){var ie;const x=String(T||"").trim();if(!x)return!1;const N=String(((ie=wt(x))==null?void 0:ie.updatedAt)||"").trim(),re=String(H[x]||"").trim();return!!(N&&re&&N===re)}function $t(T){const x=Ct(T.slug),N=T.slug===g.value?f.value.blocks:(x==null?void 0:x.blocks)||[],re=T.slug===g.value?f.value.title:(x==null?void 0:x.title)??T.title,ie=T.slug===g.value?f.value.autoTitle:(x==null?void 0:x.autoTitle)??T.autoTitle,Se=T.slug===g.value?zt(f.value.todoItems).length:zt((x==null?void 0:x.todoItems)||[]).length||Number(T.todoCount||0),et=T.slug===g.value?f.value.lastPromptPreview||T.lastPromptPreview||"":(x==null?void 0:x.lastPromptPreview)||T.lastPromptPreview||"",Fe=Pe(T.slug,{summary:T,cachedDraft:x});return{...T,title:re,autoTitle:ie,todoCount:Se,preview:et,codexSessionId:Fe,sessionSelectionLocked:!!(Fe&&Number(T.codexRunCount||0)>0),sessionSelectionLockReason:Fe&&Number(T.codexRunCount||0)>0?Ye("taskActions.sessionLocked"):"",displayTitle:Cr({title:re,autoTitle:ie,preview:et},N),sending:Xs(T),hasUnreadUpdate:!!S.value[T.slug]}}function yt(T,x={}){const{insertAtStart:N=!1}=x;if(!(T!=null&&T.slug))return;const re=[...u.value],ie=re.findIndex(Se=>Se.slug===T.slug);if(ie>=0){re.splice(ie,1,{...re[ie],...T}),u.value=re;return}N?re.unshift(T):re.push(T),u.value=re}function Ze(T,x){T&&(p.value={...p.value,[T]:Tr(x)})}function C(T){return T?`${s}/api/tasks/${T}/raw`:`${s}/api/tasks/`}function F(T=""){const x=String(T||"").trim();if(!x)return;const N=wt(x),re=r.getTaskRunChange(x);if(!N||!(re!=null&&re.status))return;const ie=Qv(re.status);!!N.running!==ie&&yt({...N,running:ie})}function te(){return typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus()}function Ce(T=""){return $a(T,g.value,te())}function ze(T=""){S.value=Pa(S.value,T)}function Le(){S.value=ty(S.value,{currentTaskSlug:g.value,pageFocused:te()})}function tt(T=[]){S.value=ny(S.value,T),h.value=sy(h.value,T)}function rt(T=""){const x=String(T||"").trim();if(!x)return;const N=oy({unreadMap:S.value,notifiedMap:h.value,taskSlug:x,change:r.getTaskRunChange(x),currentTaskSlug:g.value,pageFocused:te(),maxNotifiedRuns:Ws});S.value=N.unreadMap,h.value=N.notifiedMap,N.didMark&&(W.value+=1)}function Et(T,x){c.value={...c.value,[T]:!!x}}function gt(T=u.value){const x={};(T||[]).forEach(N=>{N!=null&&N.slug&&(x[N.slug]=!!N.running)}),c.value=x}function xt(T,x){T&&(w.value={...w.value,[T]:String(x||"").trim()})}async function St(T,x){const N=String(T||"").trim();if(!N)return;const re=String(x||"").trim(),ie=wt(N),Se=w.value[N]||(ie==null?void 0:ie.codexSessionId)||"";if(!!(Se&&Number((ie==null?void 0:ie.codexRunCount)||0)>0)&&re!==Se){M.value=Ye("taskActions.sessionLocked");return}xt(N,re);const Fe=Ct(N);Fe&&Ze(N,{...Fe,codexSessionId:re}),ie&&yt({...ie,codexSessionId:re,workspaceDiffSummary:re&&re===Se?ie.workspaceDiffSummary:null}),N===g.value&&(f.value={...f.value,codexSessionId:re});try{await hl(N,re)}catch(an){xt(N,Se),Fe&&Ze(N,{...Fe,codexSessionId:Se}),ie&&yt({...ie,codexSessionId:Se}),N===g.value&&(f.value={...f.value,codexSessionId:Se}),M.value=an.message}}function Ht(){G&&(window.clearTimeout(G),G=null)}function en(){$&&(window.clearTimeout($),$=null)}function qt(){Ht(),!(Z.value||!g.value)&&(G=window.setTimeout(()=>{Kt({auto:!0,silent:!0})},1500))}function se(){if(!g.value)return;const T=wt(g.value)||{slug:g.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};yt({...T,title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoCount:zt(f.value.todoItems).length,codexSessionId:Re.value,preview:String(f.value.lastPromptPreview||"")})}function Oe(T={}){const x=String((T==null?void 0:T.slug)||"").trim();if(!x)return;const N=Vn(T);yt(N),Ue(x,N.updatedAt||T.updatedAt||""),x===g.value&&(Object.prototype.hasOwnProperty.call(T,"title")&&(f.value.title=String(T.title||"")),Object.prototype.hasOwnProperty.call(T,"autoTitle")&&(f.value.autoTitle=String(T.autoTitle||"")),Ze(x,{...f.value}))}function at(T=[]){const x=new Map((T||[]).map(N=>{const re=String((N==null?void 0:N.slug)||"").trim();return re?[re,Gs(N.workspaceDiffSummary)]:null}).filter(Boolean));x.size&&(u.value=u.value.map(N=>x.has(N.slug)?{...N,workspaceDiffSummary:x.get(N.slug)}:N))}async function Qe(T=u.value){const x=Array.isArray(T)?T:[],N=x.filter(ie=>String((ie==null?void 0:ie.codexSessionId)||"").trim()),re=++ee;if(!N.length){u.value=x.map(ie=>Object.prototype.hasOwnProperty.call(ie,"workspaceDiffSummary")?ie:{...ie,workspaceDiffSummary:null});return}try{const ie=await Zi({limit:x.length||30,slugs:N.map(Se=>Se.slug)});if(re!==ee)return;at(ie.items||[])}catch{}}function jt(T=""){const x=String(T||"").trim();if(!x)return;const N=r.getTaskRunChange(x),ie=u.value.find(Se=>Se.slug===x);Zv(ie,N)&&(ne.add(x),le&&window.clearTimeout(le),le=window.setTimeout(()=>{le=null;const Se=new Set(ne);ne.clear();const et=u.value.filter(Fe=>Se.has(Fe.slug));Qe(et)},Kv))}async function z(T={}){const{silent:x=!1}=T;x||(P.value=!0,M.value="");try{const N=u.value,re=await Qi(),ie=Ar(N,(re.items||[]).map(Vn));u.value=ie,tt(ie),gt(ie),ay(N,ie)&&Qe(ie)}catch(N){x||(M.value=N.message)}finally{x||(P.value=!1)}}async function Y(T=[]){const x=ry(u.value,T),N=u.value.map(Se=>String((Se==null?void 0:Se.slug)||"").trim()).filter(Boolean),re=x.map(Se=>String((Se==null?void 0:Se.slug)||"").trim()).filter(Boolean);if(!re.length||re.join(",")===N.join(","))return!1;const ie=u.value;u.value=x;try{const Se=await tl(re);_=Date.now()+qv;const et=Ar(ie,(Se.items||[]).map(Vn));return u.value=et,tt(et),gt(et),!0}catch(Se){return u.value=ie,M.value=Se.message,!1}}async function ce(T=""){const x=String(g.value||"").trim(),N=String(T||"").trim();if(!x)return;if(!u.value.some(ie=>ie.slug===x)){if(u.value.length){await lt(u.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}g.value="",Is(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=De("","","",[],"",[]),J.value=!1;return}N&&N!==x||N&&(Ge()||dt()||J.value||U.value||K.value||Z.value||await lt(x,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function ye(T=""){const x=String(T||"").trim();ve===null?ve=x:ve!==x&&(ve=""),!$&&($=window.setTimeout(async()=>{const N=ve;ve=null,$=null,await z({silent:!0}),await ce(N||"")},Hv))}async function He(T){const x=await zr(T),N=(x.blocks||[]).map(ie=>({...ie,content:ie.type==="image"?Ps(ie.content):ie.content}));return{state:{title:String(x.title||""),autoTitle:String(x.autoTitle||""),lastPromptPreview:String(x.lastPromptPreview||""),codexSessionId:String(x.codexSessionId||""),blocks:N,todoItems:zt(x.todoItems||[])},summary:Vn({...x,blocks:N}),updatedAt:String(x.updatedAt||"")}}async function lt(T,x={}){const{focusEditor:N=!1,force:re=!1,skipIfDirtyOnApply:ie=!1,skipIfEditingOnApply:Se=!1,scrollPanelToBottom:et=!1}=x,Fe=String(T||"").trim();if(!Fe)return!1;const an=++ge;Z.value=!0,M.value="",t();try{const _n=String(g.value||"").trim(),vn=Ct(Fe),ln=re&&vn&&_e(Fe);let Vt=re&&!ln?null:vn,Wt=null;if(!Vt){const ft=await He(Fe);Vt=(ft==null?void 0:ft.state)||null,Wt=(ft==null?void 0:ft.summary)||null,Ue(Fe,(ft==null?void 0:ft.updatedAt)||(Wt==null?void 0:Wt.updatedAt)||"")}return an!==ge||ie&&Fe===g.value&&(dt()||J.value)||Se&&Fe===g.value&&Ge()?!1:(g.value=Fe,Is(Fe),Ce(Fe)&&ze(Fe),f.value=Tr(Vt),Ze(Fe,Vt),Wt&&yt(Wt),xt(Fe,Vt.codexSessionId),A.value=De(f.value.title,f.value.autoTitle,f.value.lastPromptPreview,f.value.todoItems,f.value.codexSessionId,f.value.blocks),J.value=!1,N&&ct(()=>{var ft,On;return(On=(ft=l.value)==null?void 0:ft.focusEditor)==null?void 0:On.call(ft)}),(et||Fe!==_n)&&o(),!0)}catch(_n){return an===ge&&(M.value=_n.message),!1}finally{an===ge&&(Z.value=!1)}}async function Kt(T={}){const{auto:x=!1,silent:N=!1}=T;return g.value?De()===A.value?!0:de||(Ht(),U.value=!0,M.value="",de=(async()=>{try{const ie=await Hr(g.value,{title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoItems:zt(f.value.todoItems),codexSessionId:Re.value,expiry:"none",visibility:"private",blocks:Me(f.value.blocks)}),Se={title:String(ie.title||""),autoTitle:String(ie.autoTitle||""),lastPromptPreview:String(ie.lastPromptPreview||""),todoItems:zt(ie.todoItems||f.value.todoItems||[]),codexSessionId:Re.value||String(ie.codexSessionId||"").trim(),blocks:kn(f.value.blocks)};return Ze(g.value,Se),A.value=De(Se.title,Se.autoTitle,Se.lastPromptPreview,Se.todoItems,Se.codexSessionId,Se.blocks),J.value=!1,yt(Vn(ie)),Ue(g.value,ie.updatedAt||""),!x&&!N&&n({message:Ye("taskActions.taskSaved"),type:"success"}),!0}catch(ie){return M.value=ie.message,!1}finally{U.value=!1,de=null,De()!==A.value&&(J.value=!0,qt())}})(),de):!1}async function Lt(){return K.value?(M.value=Ye("taskActions.fileProcessing"),!1):de||(J.value?Kt({auto:!1,silent:!0}):!0)}async function Mt(){if(!await Lt()&&g.value)return!1;v.value=!0,M.value="";try{const T=await el({title:"",expiry:"none",visibility:"private"}),x={title:String(T.title||""),autoTitle:String(T.autoTitle||""),lastPromptPreview:String(T.lastPromptPreview||""),codexSessionId:String(T.codexSessionId||""),blocks:kn(T.blocks||[]),todoItems:zt(T.todoItems||[])};return Ze(T.slug,x),yt(Vn(T),{insertAtStart:!0}),await lt(T.slug,{focusEditor:!0}),n({message:Ye("taskActions.taskCreated"),type:"success"}),!0}catch(T){return M.value=T.message,!1}finally{v.value=!1}}async function Bt(T){const x=String(T||"").trim();!x||x===g.value||!await Lt()||await lt(x)}async function mn(){if(g.value){L.value=!0,M.value="";try{const T=g.value;await nl(T),u.value=u.value.filter(ie=>ie.slug!==T);const x={...p.value};delete x[T],p.value=x;const N={...w.value};delete N[T],w.value=N;const re={...c.value};delete re[T],c.value=re,ze(T),u.value.length?await lt(u.value[0].slug,{focusEditor:!0}):(g.value="",Is(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=De("","","",[],"",[]),J.value=!1,await Mt())}catch(T){M.value=T.message}finally{L.value=!1}}}function bt(T={}){const{silent:x=!1}=T;g.value&&(f.value={...f.value,blocks:_r()},Ze(g.value,f.value),se(),J.value=!0,ct(()=>{var N,re;(re=(N=l.value)==null?void 0:N.focusEditor)==null||re.call(N)}),x||n({message:Ye("taskActions.taskCleared"),type:"info"}))}function rn(){if(!g.value)return!1;const T=Aa(f.value.blocks);return T.length?(f.value={...f.value,blocks:_r(),todoItems:[{id:Xv(),createdAt:new Date().toISOString(),blocks:T},...zt(f.value.todoItems)]},Ze(g.value,f.value),se(),J.value=!0,ct(()=>{var x,N;(N=(x=l.value)==null?void 0:x.focusEditor)==null||N.call(x)}),n({message:Ye("taskActions.todoAdded"),type:"success"}),!0):!1}function tn(T=""){const x=String(T||"").trim();if(!g.value||!x)return!1;const N=zt(f.value.todoItems).filter(re=>re.id!==x);return N.length===zt(f.value.todoItems).length?!1:(f.value={...f.value,todoItems:N},Ze(g.value,f.value),se(),J.value=!0,!0)}function Yt(T=""){const x=String(T||"").trim();if(!g.value||!x)return null;const N=zt(f.value.todoItems).find(re=>re.id===x);return N?(f.value={...f.value,blocks:kn(N.blocks),todoItems:zt(f.value.todoItems).filter(re=>re.id!==x)},Ze(g.value,f.value),se(),J.value=!0,ct(()=>{var re,ie;(ie=(re=l.value)==null?void 0:re.focusEditor)==null||ie.call(re)}),N):null}async function Pt(){var ie;if(await z(),!u.value.length){await Mt();return}const T=ly();if(T){const Se=await lt(T,{focusEditor:!0,force:!0});if(uy(),Se)return}const x=((ie=u.value.find(Se=>!!(Se!=null&&Se.running)))==null?void 0:ie.slug)||"",N=iy(),re=x||(u.value.some(Se=>Se.slug===N)?N:u.value[0].slug);await lt(re,{focusEditor:!0,force:!0})}async function gn(T){var x,N,re;K.value=!0,M.value="";try{const ie=((N=(x=l.value)==null?void 0:x.isImportedBlockActive)==null?void 0:N.call(x))||!1,Se=[];for(const et of T){const Fe=await sl(et);Se.push({type:"image",content:Ps(Fe.url),meta:{}})}(re=l.value)==null||re.insertUploadedBlocks(Se),n({message:Ye("taskActions.imageInserted",{count:Se.length,appended:ie}),type:"success"})}catch(ie){M.value=ie.message}finally{K.value=!1}}async function hn(T){var x,N,re;M.value="";try{const ie=((N=(x=l.value)==null?void 0:x.isImportedBlockActive)==null?void 0:N.call(x))||!1,Se=[];for(const et of T){const Fe=await et.text();Fe.trim()&&Se.push({type:"imported_text",content:Fe,meta:{fileName:et.name||Ye("workbench.untitledTask"),collapsed:!0}})}if(!Se.length){n({message:Ye("taskActions.noTextImported"),type:"warning"});return}(re=l.value)==null||re.insertImportedBlocks(Se),n({message:Ye("taskActions.importedBlocksInserted",{count:Se.length,appended:ie}),type:"success"})}catch{M.value=Ye("taskActions.textImportFailed")}}async function I(T){var x;K.value=!0,M.value="";try{let N=0,re=0;for(const ie of T){const Se=await ol(ie),et=(Se.blocks||[]).map(Fe=>({...Fe,content:Fe.type==="image"?Ps(Fe.content):Fe.content}));et.length&&((x=l.value)==null||x.insertBlocks(et),N+=et.length,re+=Number(Se.pageCount||0))}if(!N){n({message:Ye("taskActions.noPdfContent"),type:"warning"});return}n({message:Ye("taskActions.pdfBlocksInserted",{blockCount:N,pageCount:re}),type:"success"})}catch(N){M.value=N.message||Ye("taskActions.pdfImportFailed")}finally{K.value=!1}}function Q(T){const x=T===g.value?f.value:Ct(T);return x?zv({title:String(x.title||""),blocks:Me(x.blocks||[])},C(T)):""}function j(T){const x=T===g.value?f.value:Ct(T);return x?kn(Me(x.blocks||[])):[]}async function ke(T){return K.value?(M.value=Ye("taskActions.fileProcessingBeforeSend"),!1):T!==g.value?!0:U.value&&de?de:J.value?Kt({auto:!1,silent:!0}):!0}async function Jt(T){return await ke(T)?Q(T):""}function Qt(T,x){const N=Er(x);!N||T!==g.value||(f.value.lastPromptPreview=N,Ze(g.value,f.value),se())}return Ie(f,()=>{if(Z.value||!g.value)return;const T=$o(f.value.blocks);!String(f.value.title||"").trim()&&T&&T!==f.value.autoTitle&&(f.value.autoTitle=T),Ze(g.value,f.value),J.value=De()!==A.value,se(),J.value&&!U.value&&qt()},{deep:!0}),Ie(g,T=>{T&&(Is(T),Le())}),pn(()=>{typeof window>"u"||(window.addEventListener("focus",Le),document.addEventListener("visibilitychange",Le))}),Ot(()=>{Ht(),en(),le&&(window.clearTimeout(le),le=null),ne.clear(),typeof window<"u"&&(window.removeEventListener("focus",Le),document.removeEventListener("visibilitychange",Le))}),Ie(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<_||(rt(r.listSyncTaskSlug.value),F(r.listSyncTaskSlug.value),jt(r.listSyncTaskSlug.value),ye(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:rn,applyTaskSettingsUpdate:Oe,buildPromptForTask:Q,getPromptBlocksForTask:j,buildPromptPreview:Er,clearCurrentTaskContent:bt,createTaskAndSelect:Mt,currentProjectSessionId:Re,currentTaskSendState:Ve,currentTaskAutoTitle:E,currentTaskDisplayTitle:Be,currentTaskSlug:g,draft:f,editorRef:l,error:M,handleImportPdfFiles:I,handleImportTextFiles:hn,handleTaskSendingChange:Et,handleTaskSessionChange:St,handleUpload:gn,hasCurrentDraftContent:oe,hasAnyTaskSending:Je,hasUnsavedChanges:J,hasUnreadTaskUpdates:Ee,initializeWorkbench:Pt,isCurrentTaskSending:Xe,loadingTask:Z,loadingTasks:P,pageTitle:$e,prepareCodexPromptForTask:Jt,currentTodoItems:fe,removeTodoItem:tn,removeCurrentTask:mn,reorderTaskList:Y,removingTask:L,renderedTasks:me,refreshTaskList:z,saveTask:Kt,saving:U,selectTask:Bt,selectedSessionMap:w,sendingTaskMap:c,taskDraftMap:p,tasks:u,unreadNotificationVersion:W,useTodoItem:Yt,updateLastPromptPreview:Qt,uploading:K,creatingTask:v}}const dy={class:"flex h-full min-h-0 flex-col overflow-hidden"},fy={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"},py={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},my={class:"min-h-0 min-w-0 overflow-hidden"},gy={class:"min-h-0 min-w-0 overflow-hidden"},hy={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},vy={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},yy={class:"flex flex-col gap-2"},Sy={class:"min-h-0 flex-1 overflow-hidden"},wy={key:1,class:"min-h-0 flex-1 overflow-hidden"},xy={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},by={class:"workbench-mobile-tabs-panel shrink-0"},ky={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},Ty={class:"min-h-0 flex-1 overflow-hidden"},_y={class:"h-full min-h-0"},Cy={class:"h-full min-h-0"},Ey={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},Ay={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},Iy={class:"flex flex-col gap-2"},$y={class:"min-h-0 flex-1 overflow-hidden"},Py="/sounds/notify-didi.wav?v=20260420-1",Dy=3e3,Ir="promptx:selected-agent-engine-map",Ly={__name:"WorkbenchView",setup(e){const t=V(!1),n=V(!1),o=V(!1),s=V(!1),r=V(!1),l=V(!1),u=V(!1),p=V(!1),w=V(""),c=V(""),S=V(""),h=V(0),g=V("workspace"),f=V(""),{t:P}=It(),{toastMessage:Z,toastType:v,flashToast:L,clearToast:U}=Fv(),{notificationSoundEnabled:K,sendBehavior:M}=Ba(),J=xo(()=>We(()=>import("./TaskDiffReviewDialog-B8r9DD0G.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),A=xo(()=>We(()=>import("./WorkbenchSettingsDialog-CjNLZ7j9.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),G=V(null),de=V([]);function ge(){try{const y=JSON.parse(window.localStorage.getItem(Ir)||"{}");if(y&&typeof y=="object"&&!Array.isArray(y))return y}catch{}return{}}function $(y){window.localStorage.setItem(Ir,JSON.stringify(y))}const ee=V(ge());let le=null,ne=!1,ve=0;function _(y="",X=de.value){const xe=String(y||"").trim();return xe&&X.some(be=>(be==null?void 0:be.engine)===xe)?xe:""}function H(y=de.value){var X,xe;return((X=y.find(be=>be==null?void 0:be.isDefault))==null?void 0:X.engine)||((xe=y[0])==null?void 0:xe.engine)||""}const E=q({get(){const y=String(he.value||"").trim();if(!y)return"";const X=String(ee.value[y]||"").trim();return X||H()},set(y){const X=String(he.value||"").trim(),xe=String(y||"").trim();!X||!xe||(ee.value={...ee.value,[X]:xe},$(ee.value))}});function Be(y){return y?G.value:null}function Pe(){ct(()=>{var y,X;(X=(y=Be(he.value))==null?void 0:y.scrollToBottom)==null||X.call(y)})}const{addCurrentDraftToTodo:Re,applyTaskSettingsUpdate:Ve,buildPromptForTask:Xe,getPromptBlocksForTask:Je,clearCurrentTaskContent:Ee,createTaskAndSelect:W,creatingTask:oe,currentProjectSessionId:fe,currentTaskSendState:$e,currentTaskAutoTitle:me,currentTaskDisplayTitle:Ne,currentTaskSlug:he,draft:Me,editorRef:Ke,error:De,handleImportPdfFiles:dt,handleImportTextFiles:Ge,handleTaskSendingChange:wt,handleTaskSessionChange:Ct,handleUpload:Ue,hasCurrentDraftContent:_e,hasUnsavedChanges:$t,hasUnreadTaskUpdates:yt,initializeWorkbench:Ze,isCurrentTaskSending:C,loadingTask:F,loadingTasks:te,pageTitle:Ce,prepareCodexPromptForTask:ze,currentTodoItems:Le,removeTodoItem:tt,removeCurrentTask:rt,reorderTaskList:Et,removingTask:gt,renderedTasks:xt,saveTask:St,saving:Ht,selectTask:en,unreadNotificationVersion:qt,updateLastPromptPreview:se,useTodoItem:Oe,uploading:at}=cy({clearToast:U,flashToast:L,scrollCurrentPanelToBottom:Pe}),Qe=q(()=>xt.value.find(y=>y.slug===he.value)||null),jt=q(()=>yt.value?P("workbench.newMessageTitle"):Ce.value),z=q(()=>yt.value),Y=q(()=>{var y,X;return!!((X=(y=Qe.value)==null?void 0:y.workspaceDiffSummary)!=null&&X.supported)}),ce=q(()=>{const y=Qe.value;return y?()=>ze(y.slug):null}),ye=q(()=>{const y=Qe.value;return y?()=>Je(y.slug):null}),He=q(()=>({creatingTask:oe.value,currentTaskAutoTitle:Me.value.autoTitle||me.value,currentTaskSlug:he.value,draftTitle:Me.value.title,editingTaskTitleSlug:S.value,error:De.value,isCurrentTaskSending:C.value,loadingTask:F.value,loadingTasks:te.value,removingTask:gt.value,tasks:xt.value,uploading:at.value})),lt=q(()=>{var y,X,xe,be;return{buildPromptBlocks:ye.value,buildPrompt:ce.value,diffSupported:Y.value,selectedAgentEngine:E.value,selectedSessionId:fe.value,sessionSelectionLockReason:((y=Qe.value)==null?void 0:y.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((X=Qe.value)!=null&&X.sessionSelectionLocked),taskSlug:((xe=Qe.value)==null?void 0:xe.slug)||"",taskRunning:!!((be=Qe.value)!=null&&be.running)}}),Kt=q(()=>({codexSessionId:fe.value,sendBehavior:M.value,loading:F.value})),Lt=q(()=>({currentTaskAutoTitle:Me.value.autoTitle||me.value,currentTaskSlug:he.value,editingTaskTitleSlug:S.value,title:Ne.value,titleInputValue:Me.value.title})),{enterMobileDetail:Mt,isMobileLayout:Bt,leaveMobileDetail:mn,mobileDetailTab:bt,mobileView:rn}=Bv({currentTaskSlug:he});function tn(y){return y!=null&&y.sending||Number((y==null?void 0:y.codexRunCount)||0)>0?"activity":"input"}Nv(jt,{raw:z});function Yt(){return typeof window>"u"?null:(le||(le=new Audio(Py),le.preload="auto",le.volume=.7),le)}function Pt(){if(!K.value)return;const y=Yt();if(!(!y||ne))try{y.muted=!0;const X=y.play();if(X&&typeof X.then=="function"){X.then(()=>{y.pause(),y.currentTime=0,y.muted=!1,ne=!0}).catch(()=>{y.muted=!1});return}y.pause(),y.currentTime=0,y.muted=!1,ne=!0}catch{y.muted=!1}}function gn(){Pt()}function hn(){const y=Yt();if(!y||!K.value)return;const X=Date.now();if(!(X-ve<Dy)){ve=X;try{y.muted=!1,y.currentTime=0,y.play().catch(()=>{})}catch{}}}function I(y="workspace",X=""){g.value=y==="run"?"run":y==="task"?"task":"workspace",f.value=g.value==="run"?String(X||""):"",o.value=!0,h.value+=1}function Q(){o.value=!1}function j(){s.value=!0}function ke(){s.value=!1}function Jt(){he.value&&(r.value=!0)}function Qt(){r.value=!1}function T(){l.value=!0}function x(){l.value=!1,N(),re()}function N(){u.value=!1,w.value=""}function re(){p.value=!1,c.value=""}function ie(y){Ve(y)}function Se(y){Me.value.title=y}async function et(){S.value="",$t.value&&await St({auto:!1,silent:!0})}function Fe(y){y===he.value&&(S.value=y,ct(()=>{var xe,be;const X=document.querySelector('[data-task-title-input="current"]');(xe=X==null?void 0:X.focus)==null||xe.call(X),(be=X==null?void 0:X.select)==null||be.call(X)}))}async function an(y){if(Bt.value){await yn(y);return}if(y!==he.value){await yn(y);return}Fe(y)}function _n(){n.value=!0}function vn(){gt.value||(n.value=!1)}async function ln(){await rt(),n.value=!1,Bt.value&&mn({useHistory:!1})}function Vt(){t.value=!0}function Wt(){t.value=!1}function ft(){t.value=!1,Ee()}function On(y){const X=Qe.value;X&&wt(X.slug,y)}function ys(y){const X=Qe.value;X&&Ct(X.slug,y)}function Fn(y={}){const X=String((y==null?void 0:y.sessionId)||"").trim(),xe=fe.value;if(X&&X!==xe)return;const be=Array.isArray(y==null?void 0:y.bindings)?y.bindings:[];de.value=be;const pt=String(he.value||"").trim();if(!pt)return;const ht=String(ee.value[pt]||"").trim();if(ht&&be.some(Gt=>(Gt==null?void 0:Gt.engine)===ht)){E.value!==ht&&(E.value=ht);return}const At=_(y==null?void 0:y.selectedEngine,be)||H(be);At&&E.value!==At&&(E.value=At)}Ie(fe,(y,X)=>{String(y||"").trim()!==String(X||"").trim()&&(de.value=[])});function un(y){E.value=y}function eo(y){L(y),!(!Bt.value||!he.value)&&(bt.value="activity")}async function Cn(){var y,X,xe,be,pt,ht,At,Gt;typeof document<"u"&&((X=(y=Ke.value)==null?void 0:y.isComposing)!=null&&X.call(y))&&((be=(xe=document.activeElement)==null?void 0:xe.blur)==null||be.call(xe)),(ht=(pt=Ke.value)==null?void 0:pt.flushPendingInput)==null||ht.call(pt),await ct(),(Gt=(At=Ke.value)==null?void 0:At.flushPendingInput)==null||Gt.call(At),await ct()}async function es(){await Cn(),await navigator.clipboard.writeText(Xe(he.value)),L({message:P("workbench.promptCopied"),type:"info"})}async function to(){await W()&&Bt.value&&(bt.value="input",Mt())}async function yn(y){const X=String(y||"").trim();X&&(X!==he.value&&await en(X),Bt.value&&he.value===X&&(bt.value=tn(Qe.value),Mt()))}async function ts(y=[]){await Et(y)}async function Un(){await Cn(),Re()}function En(y={}){const X=String((y==null?void 0:y.rangeLabel)||"").trim();if(X)return X;const xe=Math.max(0,Number(y==null?void 0:y.lineStart)||0),be=Math.max(0,Number(y==null?void 0:y.lineEnd)||0);return xe&&be&&xe!==be?`L${xe}-L${be}`:xe||be?`L${xe||be}`:""}function no(y=""){return`code-context-${String(y||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function Ss(y={}){const X=String((y==null?void 0:y.filePath)||"").trim(),xe=String((y==null?void 0:y.content)||"").replace(/\r\n/g,`
|
|
57
|
+
`)}function Me(T=[]){return T.map(x=>({id:Number.isInteger(Number(x==null?void 0:x.id))?Number(x.id):null,type:x==null?void 0:x.type,content:(x==null?void 0:x.type)==="image"?Ne(x.content):he(x.content),meta:x!=null&&x.meta?{...x.meta}:{}}))}function Ke(T=[]){return(T||[]).map(x=>({id:String((x==null?void 0:x.id)||"").trim(),createdAt:String((x==null?void 0:x.createdAt)||""),blocks:Me((x==null?void 0:x.blocks)||[])}))}function De(T=f.value.title,x=f.value.autoTitle,N=f.value.lastPromptPreview,re=f.value.todoItems,ie=f.value.codexSessionId,Se=f.value.blocks){return JSON.stringify({title:String(T||""),autoTitle:String(x||""),lastPromptPreview:String(N||""),todoItems:Ke(re),codexSessionId:String(ie||""),blocks:Me(Se)})}function dt(){return De()!==A.value}function Ge(){var T,x;return!!((x=(T=l.value)==null?void 0:T.isEditing)!=null&&x.call(T))}function wt(T){return u.value.find(x=>x.slug===T)||null}function Ct(T){return T&&p.value[T]||null}function Ue(T,x=""){const N=String(T||"").trim();N&&(H={...H,[N]:String(x||"").trim()})}function _e(T=""){var ie;const x=String(T||"").trim();if(!x)return!1;const N=String(((ie=wt(x))==null?void 0:ie.updatedAt)||"").trim(),re=String(H[x]||"").trim();return!!(N&&re&&N===re)}function $t(T){const x=Ct(T.slug),N=T.slug===g.value?f.value.blocks:(x==null?void 0:x.blocks)||[],re=T.slug===g.value?f.value.title:(x==null?void 0:x.title)??T.title,ie=T.slug===g.value?f.value.autoTitle:(x==null?void 0:x.autoTitle)??T.autoTitle,Se=T.slug===g.value?zt(f.value.todoItems).length:zt((x==null?void 0:x.todoItems)||[]).length||Number(T.todoCount||0),et=T.slug===g.value?f.value.lastPromptPreview||T.lastPromptPreview||"":(x==null?void 0:x.lastPromptPreview)||T.lastPromptPreview||"",Fe=Pe(T.slug,{summary:T,cachedDraft:x});return{...T,title:re,autoTitle:ie,todoCount:Se,preview:et,codexSessionId:Fe,sessionSelectionLocked:!!(Fe&&Number(T.codexRunCount||0)>0),sessionSelectionLockReason:Fe&&Number(T.codexRunCount||0)>0?Ye("taskActions.sessionLocked"):"",displayTitle:Cr({title:re,autoTitle:ie,preview:et},N),sending:Xs(T),hasUnreadUpdate:!!S.value[T.slug]}}function yt(T,x={}){const{insertAtStart:N=!1}=x;if(!(T!=null&&T.slug))return;const re=[...u.value],ie=re.findIndex(Se=>Se.slug===T.slug);if(ie>=0){re.splice(ie,1,{...re[ie],...T}),u.value=re;return}N?re.unshift(T):re.push(T),u.value=re}function Ze(T,x){T&&(p.value={...p.value,[T]:Tr(x)})}function C(T){return T?`${s}/api/tasks/${T}/raw`:`${s}/api/tasks/`}function F(T=""){const x=String(T||"").trim();if(!x)return;const N=wt(x),re=r.getTaskRunChange(x);if(!N||!(re!=null&&re.status))return;const ie=Qv(re.status);!!N.running!==ie&&yt({...N,running:ie})}function te(){return typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus()}function Ce(T=""){return $a(T,g.value,te())}function ze(T=""){S.value=Pa(S.value,T)}function Le(){S.value=ty(S.value,{currentTaskSlug:g.value,pageFocused:te()})}function tt(T=[]){S.value=ny(S.value,T),h.value=sy(h.value,T)}function rt(T=""){const x=String(T||"").trim();if(!x)return;const N=oy({unreadMap:S.value,notifiedMap:h.value,taskSlug:x,change:r.getTaskRunChange(x),currentTaskSlug:g.value,pageFocused:te(),maxNotifiedRuns:Ws});S.value=N.unreadMap,h.value=N.notifiedMap,N.didMark&&(W.value+=1)}function Et(T,x){c.value={...c.value,[T]:!!x}}function gt(T=u.value){const x={};(T||[]).forEach(N=>{N!=null&&N.slug&&(x[N.slug]=!!N.running)}),c.value=x}function xt(T,x){T&&(w.value={...w.value,[T]:String(x||"").trim()})}async function St(T,x){const N=String(T||"").trim();if(!N)return;const re=String(x||"").trim(),ie=wt(N),Se=w.value[N]||(ie==null?void 0:ie.codexSessionId)||"";if(!!(Se&&Number((ie==null?void 0:ie.codexRunCount)||0)>0)&&re!==Se){M.value=Ye("taskActions.sessionLocked");return}xt(N,re);const Fe=Ct(N);Fe&&Ze(N,{...Fe,codexSessionId:re}),ie&&yt({...ie,codexSessionId:re,workspaceDiffSummary:re&&re===Se?ie.workspaceDiffSummary:null}),N===g.value&&(f.value={...f.value,codexSessionId:re});try{await hl(N,re)}catch(an){xt(N,Se),Fe&&Ze(N,{...Fe,codexSessionId:Se}),ie&&yt({...ie,codexSessionId:Se}),N===g.value&&(f.value={...f.value,codexSessionId:Se}),M.value=an.message}}function Ht(){G&&(window.clearTimeout(G),G=null)}function en(){$&&(window.clearTimeout($),$=null)}function qt(){Ht(),!(Z.value||!g.value)&&(G=window.setTimeout(()=>{Kt({auto:!0,silent:!0})},1500))}function se(){if(!g.value)return;const T=wt(g.value)||{slug:g.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};yt({...T,title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoCount:zt(f.value.todoItems).length,codexSessionId:Re.value,preview:String(f.value.lastPromptPreview||"")})}function Oe(T={}){const x=String((T==null?void 0:T.slug)||"").trim();if(!x)return;const N=Vn(T);yt(N),Ue(x,N.updatedAt||T.updatedAt||""),x===g.value&&(Object.prototype.hasOwnProperty.call(T,"title")&&(f.value.title=String(T.title||"")),Object.prototype.hasOwnProperty.call(T,"autoTitle")&&(f.value.autoTitle=String(T.autoTitle||"")),Ze(x,{...f.value}))}function at(T=[]){const x=new Map((T||[]).map(N=>{const re=String((N==null?void 0:N.slug)||"").trim();return re?[re,Gs(N.workspaceDiffSummary)]:null}).filter(Boolean));x.size&&(u.value=u.value.map(N=>x.has(N.slug)?{...N,workspaceDiffSummary:x.get(N.slug)}:N))}async function Qe(T=u.value){const x=Array.isArray(T)?T:[],N=x.filter(ie=>String((ie==null?void 0:ie.codexSessionId)||"").trim()),re=++ee;if(!N.length){u.value=x.map(ie=>Object.prototype.hasOwnProperty.call(ie,"workspaceDiffSummary")?ie:{...ie,workspaceDiffSummary:null});return}try{const ie=await Zi({limit:x.length||30,slugs:N.map(Se=>Se.slug)});if(re!==ee)return;at(ie.items||[])}catch{}}function jt(T=""){const x=String(T||"").trim();if(!x)return;const N=r.getTaskRunChange(x),ie=u.value.find(Se=>Se.slug===x);Zv(ie,N)&&(ne.add(x),le&&window.clearTimeout(le),le=window.setTimeout(()=>{le=null;const Se=new Set(ne);ne.clear();const et=u.value.filter(Fe=>Se.has(Fe.slug));Qe(et)},Kv))}async function z(T={}){const{silent:x=!1}=T;x||(P.value=!0,M.value="");try{const N=u.value,re=await Qi(),ie=Ar(N,(re.items||[]).map(Vn));u.value=ie,tt(ie),gt(ie),ay(N,ie)&&Qe(ie)}catch(N){x||(M.value=N.message)}finally{x||(P.value=!1)}}async function Y(T=[]){const x=ry(u.value,T),N=u.value.map(Se=>String((Se==null?void 0:Se.slug)||"").trim()).filter(Boolean),re=x.map(Se=>String((Se==null?void 0:Se.slug)||"").trim()).filter(Boolean);if(!re.length||re.join(",")===N.join(","))return!1;const ie=u.value;u.value=x;try{const Se=await tl(re);_=Date.now()+qv;const et=Ar(ie,(Se.items||[]).map(Vn));return u.value=et,tt(et),gt(et),!0}catch(Se){return u.value=ie,M.value=Se.message,!1}}async function ce(T=""){const x=String(g.value||"").trim(),N=String(T||"").trim();if(!x)return;if(!u.value.some(ie=>ie.slug===x)){if(u.value.length){await lt(u.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}g.value="",Is(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=De("","","",[],"",[]),J.value=!1;return}N&&N!==x||N&&(Ge()||dt()||J.value||U.value||K.value||Z.value||await lt(x,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function ye(T=""){const x=String(T||"").trim();ve===null?ve=x:ve!==x&&(ve=""),!$&&($=window.setTimeout(async()=>{const N=ve;ve=null,$=null,await z({silent:!0}),await ce(N||"")},Hv))}async function He(T){const x=await zr(T),N=(x.blocks||[]).map(ie=>({...ie,content:ie.type==="image"?Ps(ie.content):ie.content}));return{state:{title:String(x.title||""),autoTitle:String(x.autoTitle||""),lastPromptPreview:String(x.lastPromptPreview||""),codexSessionId:String(x.codexSessionId||""),blocks:N,todoItems:zt(x.todoItems||[])},summary:Vn({...x,blocks:N}),updatedAt:String(x.updatedAt||"")}}async function lt(T,x={}){const{focusEditor:N=!1,force:re=!1,skipIfDirtyOnApply:ie=!1,skipIfEditingOnApply:Se=!1,scrollPanelToBottom:et=!1}=x,Fe=String(T||"").trim();if(!Fe)return!1;const an=++ge;Z.value=!0,M.value="",t();try{const _n=String(g.value||"").trim(),vn=Ct(Fe),ln=re&&vn&&_e(Fe);let Vt=re&&!ln?null:vn,Wt=null;if(!Vt){const ft=await He(Fe);Vt=(ft==null?void 0:ft.state)||null,Wt=(ft==null?void 0:ft.summary)||null,Ue(Fe,(ft==null?void 0:ft.updatedAt)||(Wt==null?void 0:Wt.updatedAt)||"")}return an!==ge||ie&&Fe===g.value&&(dt()||J.value)||Se&&Fe===g.value&&Ge()?!1:(g.value=Fe,Is(Fe),Ce(Fe)&&ze(Fe),f.value=Tr(Vt),Ze(Fe,Vt),Wt&&yt(Wt),xt(Fe,Vt.codexSessionId),A.value=De(f.value.title,f.value.autoTitle,f.value.lastPromptPreview,f.value.todoItems,f.value.codexSessionId,f.value.blocks),J.value=!1,N&&ct(()=>{var ft,On;return(On=(ft=l.value)==null?void 0:ft.focusEditor)==null?void 0:On.call(ft)}),(et||Fe!==_n)&&o(),!0)}catch(_n){return an===ge&&(M.value=_n.message),!1}finally{an===ge&&(Z.value=!1)}}async function Kt(T={}){const{auto:x=!1,silent:N=!1}=T;return g.value?De()===A.value?!0:de||(Ht(),U.value=!0,M.value="",de=(async()=>{try{const ie=await Hr(g.value,{title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoItems:zt(f.value.todoItems),codexSessionId:Re.value,expiry:"none",visibility:"private",blocks:Me(f.value.blocks)}),Se={title:String(ie.title||""),autoTitle:String(ie.autoTitle||""),lastPromptPreview:String(ie.lastPromptPreview||""),todoItems:zt(ie.todoItems||f.value.todoItems||[]),codexSessionId:Re.value||String(ie.codexSessionId||"").trim(),blocks:kn(f.value.blocks)};return Ze(g.value,Se),A.value=De(Se.title,Se.autoTitle,Se.lastPromptPreview,Se.todoItems,Se.codexSessionId,Se.blocks),J.value=!1,yt(Vn(ie)),Ue(g.value,ie.updatedAt||""),!x&&!N&&n({message:Ye("taskActions.taskSaved"),type:"success"}),!0}catch(ie){return M.value=ie.message,!1}finally{U.value=!1,de=null,De()!==A.value&&(J.value=!0,qt())}})(),de):!1}async function Lt(){return K.value?(M.value=Ye("taskActions.fileProcessing"),!1):de||(J.value?Kt({auto:!1,silent:!0}):!0)}async function Mt(){if(!await Lt()&&g.value)return!1;v.value=!0,M.value="";try{const T=await el({title:"",expiry:"none",visibility:"private"}),x={title:String(T.title||""),autoTitle:String(T.autoTitle||""),lastPromptPreview:String(T.lastPromptPreview||""),codexSessionId:String(T.codexSessionId||""),blocks:kn(T.blocks||[]),todoItems:zt(T.todoItems||[])};return Ze(T.slug,x),yt(Vn(T),{insertAtStart:!0}),await lt(T.slug,{focusEditor:!0}),n({message:Ye("taskActions.taskCreated"),type:"success"}),!0}catch(T){return M.value=T.message,!1}finally{v.value=!1}}async function Bt(T){const x=String(T||"").trim();!x||x===g.value||!await Lt()||await lt(x)}async function mn(){if(g.value){L.value=!0,M.value="";try{const T=g.value;await nl(T),u.value=u.value.filter(ie=>ie.slug!==T);const x={...p.value};delete x[T],p.value=x;const N={...w.value};delete N[T],w.value=N;const re={...c.value};delete re[T],c.value=re,ze(T),u.value.length?await lt(u.value[0].slug,{focusEditor:!0}):(g.value="",Is(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},A.value=De("","","",[],"",[]),J.value=!1,await Mt())}catch(T){M.value=T.message}finally{L.value=!1}}}function bt(T={}){const{silent:x=!1}=T;g.value&&(f.value={...f.value,blocks:_r()},Ze(g.value,f.value),se(),J.value=!0,ct(()=>{var N,re;(re=(N=l.value)==null?void 0:N.focusEditor)==null||re.call(N)}),x||n({message:Ye("taskActions.taskCleared"),type:"info"}))}function rn(){if(!g.value)return!1;const T=Aa(f.value.blocks);return T.length?(f.value={...f.value,blocks:_r(),todoItems:[{id:Xv(),createdAt:new Date().toISOString(),blocks:T},...zt(f.value.todoItems)]},Ze(g.value,f.value),se(),J.value=!0,ct(()=>{var x,N;(N=(x=l.value)==null?void 0:x.focusEditor)==null||N.call(x)}),n({message:Ye("taskActions.todoAdded"),type:"success"}),!0):!1}function tn(T=""){const x=String(T||"").trim();if(!g.value||!x)return!1;const N=zt(f.value.todoItems).filter(re=>re.id!==x);return N.length===zt(f.value.todoItems).length?!1:(f.value={...f.value,todoItems:N},Ze(g.value,f.value),se(),J.value=!0,!0)}function Yt(T=""){const x=String(T||"").trim();if(!g.value||!x)return null;const N=zt(f.value.todoItems).find(re=>re.id===x);return N?(f.value={...f.value,blocks:kn(N.blocks),todoItems:zt(f.value.todoItems).filter(re=>re.id!==x)},Ze(g.value,f.value),se(),J.value=!0,ct(()=>{var re,ie;(ie=(re=l.value)==null?void 0:re.focusEditor)==null||ie.call(re)}),N):null}async function Pt(){var ie;if(await z(),!u.value.length){await Mt();return}const T=ly();if(T){const Se=await lt(T,{focusEditor:!0,force:!0});if(uy(),Se)return}const x=((ie=u.value.find(Se=>!!(Se!=null&&Se.running)))==null?void 0:ie.slug)||"",N=iy(),re=x||(u.value.some(Se=>Se.slug===N)?N:u.value[0].slug);await lt(re,{focusEditor:!0,force:!0})}async function gn(T){var x,N,re;K.value=!0,M.value="";try{const ie=((N=(x=l.value)==null?void 0:x.isImportedBlockActive)==null?void 0:N.call(x))||!1,Se=[];for(const et of T){const Fe=await sl(et);Se.push({type:"image",content:Ps(Fe.url),meta:{}})}(re=l.value)==null||re.insertUploadedBlocks(Se),n({message:Ye("taskActions.imageInserted",{count:Se.length,appended:ie}),type:"success"})}catch(ie){M.value=ie.message}finally{K.value=!1}}async function hn(T){var x,N,re;M.value="";try{const ie=((N=(x=l.value)==null?void 0:x.isImportedBlockActive)==null?void 0:N.call(x))||!1,Se=[];for(const et of T){const Fe=await et.text();Fe.trim()&&Se.push({type:"imported_text",content:Fe,meta:{fileName:et.name||Ye("workbench.untitledTask"),collapsed:!0}})}if(!Se.length){n({message:Ye("taskActions.noTextImported"),type:"warning"});return}(re=l.value)==null||re.insertImportedBlocks(Se),n({message:Ye("taskActions.importedBlocksInserted",{count:Se.length,appended:ie}),type:"success"})}catch{M.value=Ye("taskActions.textImportFailed")}}async function I(T){var x;K.value=!0,M.value="";try{let N=0,re=0;for(const ie of T){const Se=await ol(ie),et=(Se.blocks||[]).map(Fe=>({...Fe,content:Fe.type==="image"?Ps(Fe.content):Fe.content}));et.length&&((x=l.value)==null||x.insertBlocks(et),N+=et.length,re+=Number(Se.pageCount||0))}if(!N){n({message:Ye("taskActions.noPdfContent"),type:"warning"});return}n({message:Ye("taskActions.pdfBlocksInserted",{blockCount:N,pageCount:re}),type:"success"})}catch(N){M.value=N.message||Ye("taskActions.pdfImportFailed")}finally{K.value=!1}}function Q(T){const x=T===g.value?f.value:Ct(T);return x?zv({title:String(x.title||""),blocks:Me(x.blocks||[])},C(T)):""}function j(T){const x=T===g.value?f.value:Ct(T);return x?kn(Me(x.blocks||[])):[]}async function ke(T){return K.value?(M.value=Ye("taskActions.fileProcessingBeforeSend"),!1):T!==g.value?!0:U.value&&de?de:J.value?Kt({auto:!1,silent:!0}):!0}async function Jt(T){return await ke(T)?Q(T):""}function Qt(T,x){const N=Er(x);!N||T!==g.value||(f.value.lastPromptPreview=N,Ze(g.value,f.value),se())}return Ie(f,()=>{if(Z.value||!g.value)return;const T=$o(f.value.blocks);!String(f.value.title||"").trim()&&T&&T!==f.value.autoTitle&&(f.value.autoTitle=T),Ze(g.value,f.value),J.value=De()!==A.value,se(),J.value&&!U.value&&qt()},{deep:!0}),Ie(g,T=>{T&&(Is(T),Le())}),pn(()=>{typeof window>"u"||(window.addEventListener("focus",Le),document.addEventListener("visibilitychange",Le))}),Ot(()=>{Ht(),en(),le&&(window.clearTimeout(le),le=null),ne.clear(),typeof window<"u"&&(window.removeEventListener("focus",Le),document.removeEventListener("visibilitychange",Le))}),Ie(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<_||(rt(r.listSyncTaskSlug.value),F(r.listSyncTaskSlug.value),jt(r.listSyncTaskSlug.value),ye(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:rn,applyTaskSettingsUpdate:Oe,buildPromptForTask:Q,getPromptBlocksForTask:j,buildPromptPreview:Er,clearCurrentTaskContent:bt,createTaskAndSelect:Mt,currentProjectSessionId:Re,currentTaskSendState:Ve,currentTaskAutoTitle:E,currentTaskDisplayTitle:Be,currentTaskSlug:g,draft:f,editorRef:l,error:M,handleImportPdfFiles:I,handleImportTextFiles:hn,handleTaskSendingChange:Et,handleTaskSessionChange:St,handleUpload:gn,hasCurrentDraftContent:oe,hasAnyTaskSending:Je,hasUnsavedChanges:J,hasUnreadTaskUpdates:Ee,initializeWorkbench:Pt,isCurrentTaskSending:Xe,loadingTask:Z,loadingTasks:P,pageTitle:$e,prepareCodexPromptForTask:Jt,currentTodoItems:fe,removeTodoItem:tn,removeCurrentTask:mn,reorderTaskList:Y,removingTask:L,renderedTasks:me,refreshTaskList:z,saveTask:Kt,saving:U,selectTask:Bt,selectedSessionMap:w,sendingTaskMap:c,taskDraftMap:p,tasks:u,unreadNotificationVersion:W,useTodoItem:Yt,updateLastPromptPreview:Qt,uploading:K,creatingTask:v}}const dy={class:"flex h-full min-h-0 flex-col overflow-hidden"},fy={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"},py={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},my={class:"min-h-0 min-w-0 overflow-hidden"},gy={class:"min-h-0 min-w-0 overflow-hidden"},hy={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},vy={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},yy={class:"flex flex-col gap-2"},Sy={class:"min-h-0 flex-1 overflow-hidden"},wy={key:1,class:"min-h-0 flex-1 overflow-hidden"},xy={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},by={class:"workbench-mobile-tabs-panel shrink-0"},ky={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},Ty={class:"min-h-0 flex-1 overflow-hidden"},_y={class:"h-full min-h-0"},Cy={class:"h-full min-h-0"},Ey={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},Ay={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},Iy={class:"flex flex-col gap-2"},$y={class:"min-h-0 flex-1 overflow-hidden"},Py="/sounds/notify-didi.wav?v=20260420-1",Dy=3e3,Ir="promptx:selected-agent-engine-map",Ly={__name:"WorkbenchView",setup(e){const t=V(!1),n=V(!1),o=V(!1),s=V(!1),r=V(!1),l=V(!1),u=V(!1),p=V(!1),w=V(""),c=V(""),S=V(""),h=V(0),g=V("workspace"),f=V(""),{t:P}=It(),{toastMessage:Z,toastType:v,flashToast:L,clearToast:U}=Fv(),{notificationSoundEnabled:K,sendBehavior:M}=Ba(),J=xo(()=>We(()=>import("./TaskDiffReviewDialog-CKiZdXqi.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),A=xo(()=>We(()=>import("./WorkbenchSettingsDialog-CP0z90bm.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),G=V(null),de=V([]);function ge(){try{const y=JSON.parse(window.localStorage.getItem(Ir)||"{}");if(y&&typeof y=="object"&&!Array.isArray(y))return y}catch{}return{}}function $(y){window.localStorage.setItem(Ir,JSON.stringify(y))}const ee=V(ge());let le=null,ne=!1,ve=0;function _(y="",X=de.value){const xe=String(y||"").trim();return xe&&X.some(be=>(be==null?void 0:be.engine)===xe)?xe:""}function H(y=de.value){var X,xe;return((X=y.find(be=>be==null?void 0:be.isDefault))==null?void 0:X.engine)||((xe=y[0])==null?void 0:xe.engine)||""}const E=q({get(){const y=String(he.value||"").trim();if(!y)return"";const X=String(ee.value[y]||"").trim();return X||H()},set(y){const X=String(he.value||"").trim(),xe=String(y||"").trim();!X||!xe||(ee.value={...ee.value,[X]:xe},$(ee.value))}});function Be(y){return y?G.value:null}function Pe(){ct(()=>{var y,X;(X=(y=Be(he.value))==null?void 0:y.scrollToBottom)==null||X.call(y)})}const{addCurrentDraftToTodo:Re,applyTaskSettingsUpdate:Ve,buildPromptForTask:Xe,getPromptBlocksForTask:Je,clearCurrentTaskContent:Ee,createTaskAndSelect:W,creatingTask:oe,currentProjectSessionId:fe,currentTaskSendState:$e,currentTaskAutoTitle:me,currentTaskDisplayTitle:Ne,currentTaskSlug:he,draft:Me,editorRef:Ke,error:De,handleImportPdfFiles:dt,handleImportTextFiles:Ge,handleTaskSendingChange:wt,handleTaskSessionChange:Ct,handleUpload:Ue,hasCurrentDraftContent:_e,hasUnsavedChanges:$t,hasUnreadTaskUpdates:yt,initializeWorkbench:Ze,isCurrentTaskSending:C,loadingTask:F,loadingTasks:te,pageTitle:Ce,prepareCodexPromptForTask:ze,currentTodoItems:Le,removeTodoItem:tt,removeCurrentTask:rt,reorderTaskList:Et,removingTask:gt,renderedTasks:xt,saveTask:St,saving:Ht,selectTask:en,unreadNotificationVersion:qt,updateLastPromptPreview:se,useTodoItem:Oe,uploading:at}=cy({clearToast:U,flashToast:L,scrollCurrentPanelToBottom:Pe}),Qe=q(()=>xt.value.find(y=>y.slug===he.value)||null),jt=q(()=>yt.value?P("workbench.newMessageTitle"):Ce.value),z=q(()=>yt.value),Y=q(()=>{var y,X;return!!((X=(y=Qe.value)==null?void 0:y.workspaceDiffSummary)!=null&&X.supported)}),ce=q(()=>{const y=Qe.value;return y?()=>ze(y.slug):null}),ye=q(()=>{const y=Qe.value;return y?()=>Je(y.slug):null}),He=q(()=>({creatingTask:oe.value,currentTaskAutoTitle:Me.value.autoTitle||me.value,currentTaskSlug:he.value,draftTitle:Me.value.title,editingTaskTitleSlug:S.value,error:De.value,isCurrentTaskSending:C.value,loadingTask:F.value,loadingTasks:te.value,removingTask:gt.value,tasks:xt.value,uploading:at.value})),lt=q(()=>{var y,X,xe,be;return{buildPromptBlocks:ye.value,buildPrompt:ce.value,diffSupported:Y.value,selectedAgentEngine:E.value,selectedSessionId:fe.value,sessionSelectionLockReason:((y=Qe.value)==null?void 0:y.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((X=Qe.value)!=null&&X.sessionSelectionLocked),taskSlug:((xe=Qe.value)==null?void 0:xe.slug)||"",taskRunning:!!((be=Qe.value)!=null&&be.running)}}),Kt=q(()=>({codexSessionId:fe.value,sendBehavior:M.value,loading:F.value})),Lt=q(()=>({currentTaskAutoTitle:Me.value.autoTitle||me.value,currentTaskSlug:he.value,editingTaskTitleSlug:S.value,title:Ne.value,titleInputValue:Me.value.title})),{enterMobileDetail:Mt,isMobileLayout:Bt,leaveMobileDetail:mn,mobileDetailTab:bt,mobileView:rn}=Bv({currentTaskSlug:he});function tn(y){return y!=null&&y.sending||Number((y==null?void 0:y.codexRunCount)||0)>0?"activity":"input"}Nv(jt,{raw:z});function Yt(){return typeof window>"u"?null:(le||(le=new Audio(Py),le.preload="auto",le.volume=.7),le)}function Pt(){if(!K.value)return;const y=Yt();if(!(!y||ne))try{y.muted=!0;const X=y.play();if(X&&typeof X.then=="function"){X.then(()=>{y.pause(),y.currentTime=0,y.muted=!1,ne=!0}).catch(()=>{y.muted=!1});return}y.pause(),y.currentTime=0,y.muted=!1,ne=!0}catch{y.muted=!1}}function gn(){Pt()}function hn(){const y=Yt();if(!y||!K.value)return;const X=Date.now();if(!(X-ve<Dy)){ve=X;try{y.muted=!1,y.currentTime=0,y.play().catch(()=>{})}catch{}}}function I(y="workspace",X=""){g.value=y==="run"?"run":y==="task"?"task":"workspace",f.value=g.value==="run"?String(X||""):"",o.value=!0,h.value+=1}function Q(){o.value=!1}function j(){s.value=!0}function ke(){s.value=!1}function Jt(){he.value&&(r.value=!0)}function Qt(){r.value=!1}function T(){l.value=!0}function x(){l.value=!1,N(),re()}function N(){u.value=!1,w.value=""}function re(){p.value=!1,c.value=""}function ie(y){Ve(y)}function Se(y){Me.value.title=y}async function et(){S.value="",$t.value&&await St({auto:!1,silent:!0})}function Fe(y){y===he.value&&(S.value=y,ct(()=>{var xe,be;const X=document.querySelector('[data-task-title-input="current"]');(xe=X==null?void 0:X.focus)==null||xe.call(X),(be=X==null?void 0:X.select)==null||be.call(X)}))}async function an(y){if(Bt.value){await yn(y);return}if(y!==he.value){await yn(y);return}Fe(y)}function _n(){n.value=!0}function vn(){gt.value||(n.value=!1)}async function ln(){await rt(),n.value=!1,Bt.value&&mn({useHistory:!1})}function Vt(){t.value=!0}function Wt(){t.value=!1}function ft(){t.value=!1,Ee()}function On(y){const X=Qe.value;X&&wt(X.slug,y)}function ys(y){const X=Qe.value;X&&Ct(X.slug,y)}function Fn(y={}){const X=String((y==null?void 0:y.sessionId)||"").trim(),xe=fe.value;if(X&&X!==xe)return;const be=Array.isArray(y==null?void 0:y.bindings)?y.bindings:[];de.value=be;const pt=String(he.value||"").trim();if(!pt)return;const ht=String(ee.value[pt]||"").trim();if(ht&&be.some(Gt=>(Gt==null?void 0:Gt.engine)===ht)){E.value!==ht&&(E.value=ht);return}const At=_(y==null?void 0:y.selectedEngine,be)||H(be);At&&E.value!==At&&(E.value=At)}Ie(fe,(y,X)=>{String(y||"").trim()!==String(X||"").trim()&&(de.value=[])});function un(y){E.value=y}function eo(y){L(y),!(!Bt.value||!he.value)&&(bt.value="activity")}async function Cn(){var y,X,xe,be,pt,ht,At,Gt;typeof document<"u"&&((X=(y=Ke.value)==null?void 0:y.isComposing)!=null&&X.call(y))&&((be=(xe=document.activeElement)==null?void 0:xe.blur)==null||be.call(xe)),(ht=(pt=Ke.value)==null?void 0:pt.flushPendingInput)==null||ht.call(pt),await ct(),(Gt=(At=Ke.value)==null?void 0:At.flushPendingInput)==null||Gt.call(At),await ct()}async function es(){await Cn(),await navigator.clipboard.writeText(Xe(he.value)),L({message:P("workbench.promptCopied"),type:"info"})}async function to(){await W()&&Bt.value&&(bt.value="input",Mt())}async function yn(y){const X=String(y||"").trim();X&&(X!==he.value&&await en(X),Bt.value&&he.value===X&&(bt.value=tn(Qe.value),Mt()))}async function ts(y=[]){await Et(y)}async function Un(){await Cn(),Re()}function En(y={}){const X=String((y==null?void 0:y.rangeLabel)||"").trim();if(X)return X;const xe=Math.max(0,Number(y==null?void 0:y.lineStart)||0),be=Math.max(0,Number(y==null?void 0:y.lineEnd)||0);return xe&&be&&xe!==be?`L${xe}-L${be}`:xe||be?`L${xe||be}`:""}function no(y=""){return`code-context-${String(y||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function Ss(y={}){const X=String((y==null?void 0:y.filePath)||"").trim(),xe=String((y==null?void 0:y.content)||"").replace(/\r\n/g,`
|
|
58
58
|
`).trimEnd();if(!X||!xe.trim())return null;const be=String((y==null?void 0:y.language)||"").trim(),pt=En(y),ht=String((y==null?void 0:y.source)||"").trim()==="diff"?P("workbench.codeContextSourceDiff"):P("workbench.codeContextSourceFile"),At=be?`\`\`\`${be}`:"```",Gt=[P("workbench.codeContextTitle"),P("workbench.codeContextFile",{path:X}),pt?P("workbench.codeContextRange",{range:pt}):"",P("workbench.codeContextSource",{source:ht}),"",At,xe,"```"].filter(ks=>ks!=="");return{type:Nt.IMPORTED_TEXT,content:Gt.join(`
|
|
59
59
|
`),meta:{fileName:no(X),collapsed:!1}}}async function Sn(y=[],X="insertBlocks"){var be,pt,ht,At;const xe=Array.isArray(y)?y.filter(Boolean):[];return xe.length?(await Cn(),(pt=(be=Ke.value)==null?void 0:be[X])==null||pt.call(be,xe),await ct(),(At=(ht=Ke.value)==null?void 0:ht.focusEditor)==null||At.call(ht),Bt.value&&he.value&&(bt.value="input"),L({message:P("taskActions.insertedToEditor"),type:"success"}),!0):!1}async function ws(y={}){const X=String((y==null?void 0:y.source)||"").trim(),xe=String((y==null?void 0:y.content)||"").replace(/\r\n/g,`
|
|
60
60
|
`).trim();if(X==="response"){if(!xe)return;await Sn([Hn(xe)],"insertBlocks");return}const be=Ss(y);be&&await Sn([be],"insertImportedBlocks")}function xs(y){w.value=String(y||"").trim(),u.value=!!w.value}function so(){w.value&&(tt(w.value),N())}async function bs(y=c.value){const X=String(y||"").trim();return!X||!Oe(X)?!1:(re(),x(),!0)}async function d(y){await Cn();const X=String(y||"").trim();if(X){if(!_e.value){await bs(X);return}c.value=X,p.value=!0}}async function D(){var be,pt,ht,At;const y=he.value;if(!y)return;const X=!!((pt=(be=Qe.value)==null?void 0:be.automation)!=null&&pt.enabled);await Cn(),se(y,Xe(y)),!(!await((At=(ht=Be(y))==null?void 0:ht.send)==null?void 0:At.call(ht))||y!==he.value)&&(Bt.value&&(bt.value="activity"),X||Ee({silent:!0}),await St({auto:!1,silent:!0}))}function O(){!Bt.value||rn.value!=="detail"||bt.value!=="input"||!he.value||ct(()=>{var y,X;(X=(y=Ke.value)==null?void 0:y.focusEditor)==null||X.call(y)})}function R(y){!$t.value&&!at.value&&!Ht.value||(y.preventDefault(),y.returnValue="")}function ae(){var y,X;return p.value?(re(),!0):u.value?(N(),!0):t.value?(Wt(),!0):n.value?(vn(),!0):r.value?(Qt(),!0):l.value?(x(),!0):o.value?(Q(),!0):s.value?(ke(),!0):!!((X=(y=Be(he.value))==null?void 0:y.closeTopDialog)!=null&&X.call(y))}function Te(y){var pt,ht,At,Gt,ks;const X=String(y.key||""),xe=X.toLowerCase(),be=y.metaKey||y.ctrlKey;if(X==="Escape"){ae()&&(y.preventDefault(),(pt=y.stopImmediatePropagation)==null||pt.call(y));return}if(be){if(xe==="s"){y.preventDefault(),St({auto:!1});return}if(y.shiftKey&&X==="Backspace"){y.preventDefault(),Vt();return}if(!y.isComposing){if(y.shiftKey&&y.code==="Comma"){y.preventDefault(),j();return}if(y.shiftKey&&xe==="k"){y.preventDefault(),(At=(ht=Be(he.value))==null?void 0:ht.openProjectManager)==null||At.call(ht);return}if(y.shiftKey&&xe==="o"){y.preventDefault(),(ks=(Gt=Be(he.value))==null?void 0:Gt.openSourceBrowser)==null||ks.call(Gt);return}y.shiftKey&&xe==="d"&&(y.preventDefault(),Y.value&&I("workspace"))}}}pn(()=>{Ze(),window.addEventListener("beforeunload",R),window.addEventListener("keydown",Te),window.addEventListener("pointerdown",gn,{passive:!0})}),Ot(()=>{window.removeEventListener("beforeunload",R),window.removeEventListener("keydown",Te),window.removeEventListener("pointerdown",gn)}),Ie([Bt,rn,bt,he],([y,X,xe,be])=>{!y||X!=="detail"||xe!=="input"||!be||O()}),Ie(qt,(y,X)=>{Number(y)<=Number(X||0)||hn()});const qe={"update:draftTitle":Se,"cancel-title-edit":()=>{S.value=""},"create-task":to,"edit-task":Jt,"delete-task":_n,"open-settings":j,"reorder-task":ts,"select-task":yn,"title-blur":et,"title-click":an},je={"agent-bindings-change":Fn,"insert-code-context":ws,"open-diff":({scope:y,runId:X})=>I(y,X),"project-created":()=>L({message:P("workbench.projectCreated"),type:"success"}),"selected-session-change":ys,"update:selectedAgentEngine":un,"sending-change":On,toast:eo},kt={"clear-request":Vt,"file-feedback":y=>L({message:y,type:"warning"}),"import-pdf-files":dt,"import-text-files":Ge,"send-request":D,"upload-files":Ue},Rt={"begin-edit":()=>Fe(he.value),back:mn,"cancel-title-edit":()=>{S.value=""},"title-blur":et,"update:titleInputValue":Se};return(y,X)=>(m(),k("div",dy,[ue(Dv,{message:a(Z),type:a(v)},null,8,["message","type"]),ue(Ts,{open:t.value,title:a(P)("workbench.confirmClearTitle"),description:a(P)("workbench.confirmClearDescription"),"confirm-text":a(P)("workbench.confirmClearAction"),"cancel-text":a(P)("workbench.continueEditing"),onCancel:Wt,onConfirm:ft},null,8,["open","title","description","confirm-text","cancel-text"]),ue(Ts,{open:n.value,title:a(P)("workbench.confirmDeleteTitle"),description:a(P)("workbench.confirmDeleteDescription",{title:a(Ne)}),"confirm-text":a(P)("workbench.confirmDeleteAction"),"cancel-text":a(P)("workbench.keepForNow"),loading:a(gt),danger:"",onCancel:vn,onConfirm:ln},null,8,["open","title","description","confirm-text","cancel-text","loading"]),ue(Ts,{open:u.value,title:a(P)("workbench.confirmDeleteTodoTitle"),description:a(P)("workbench.confirmDeleteTodoDescription"),"confirm-text":a(P)("workbench.confirmDeleteAction"),"cancel-text":a(P)("workbench.keepForNow"),danger:"",onCancel:N,onConfirm:so},null,8,["open","title","description","confirm-text","cancel-text"]),ue(Ts,{open:p.value,title:a(P)("workbench.replaceEditorTitle"),description:a(P)("workbench.replaceEditorDescription"),"confirm-text":a(P)("workbench.confirmReplaceAction"),"cancel-text":a(P)("workbench.dontReplaceYet"),onCancel:re,onConfirm:X[0]||(X[0]=xe=>bs())},null,8,["open","title","description","confirm-text","cancel-text"]),ue($v,{open:l.value,items:a(Le),onClose:x,onDelete:xs,onUse:d},null,8,["open","items"]),ue(a(J),{open:o.value,"task-slug":a(he),"task-title":a(Ne),"preferred-scope":g.value,"preferred-run-id":f.value,"focus-token":h.value,onInsertCodeContext:ws,onClose:Q},null,8,["open","task-slug","task-title","preferred-scope","preferred-run-id","focus-token"]),ue(a(A),{open:s.value,onClose:ke},null,8,["open"]),ue(Nu,{open:r.value,"task-slug":a(he),"task-title":a(Ne),onClose:Qt,onSaved:ie},null,8,["open","task-slug","task-title"]),a(Bt)?(m(),k("div",wy,[a(rn)==="tasks"?(m(),Ae(kr,An({key:0},He.value,{mobile:""},In(qe)),null,16)):(m(),k("div",xy,[ue(Eh,An(Lt.value,In(Rt)),null,16),i("section",by,[i("div",ky,[i("button",{type:"button",class:we(["tool-button px-3 py-1.5 text-sm",a(bt)==="activity"?"tool-button-accent-subtle":""]),onClick:X[3]||(X[3]=xe=>bt.value="activity")},b(a(P)("workbench.activity")),3),i("button",{type:"button",class:we(["tool-button px-3 py-1.5 text-sm",a(bt)==="input"?"tool-button-accent-subtle":""]),onClick:X[4]||(X[4]=xe=>bt.value="input")},b(a(P)("workbench.input")),3)])]),i("div",Ty,[nn(i("div",_y,[ue(hr,An({ref_key:"codexPanelRef",ref:G},lt.value,{"empty-message":a(P)("workbench.selectTask")},In(je)),null,16,["empty-message"])],512),[[Fs,a(bt)==="activity"]]),nn(i("div",Cy,[i("div",Ey,[i("div",Ay,[i("div",Iy,[ue(yr,{"can-add-todo":a(_e),"is-current-task-sending":a(C),"send-state":a($e),"todo-count":a(Le).length,uploading:a(at),onAddTodo:Un,onOpenFilePicker:X[5]||(X[5]=xe=>{var be,pt;return(pt=(be=a(Ke))==null?void 0:be.openFilePicker)==null?void 0:pt.call(be)}),onClearRequest:Vt,onCopyRequest:es,onManageTodo:T,onSendRequest:D},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(vr,{"agent-bindings":de.value,"selected-agent-engine":E.value,"onUpdate:selectedAgentEngine":un},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",$y,[ue(br,An({ref_key:"editorRef",ref:Ke,modelValue:a(Me).blocks,"onUpdate:modelValue":X[6]||(X[6]=xe=>a(Me).blocks=xe)},Kt.value,In(kt)),null,16,["modelValue"])])])],512),[[Fs,a(bt)==="input"]])])]))])):(m(),k("div",fy,[ue(kr,An(He.value,In(qe)),null,16),i("div",py,[i("div",my,[Qe.value?(m(),Ae(hr,An({key:0,ref_key:"codexPanelRef",ref:G},lt.value,In(je)),null,16)):pe("",!0)]),i("div",gy,[i("div",hy,[i("div",vy,[i("div",yy,[ue(yr,{"can-add-todo":a(_e),"is-current-task-sending":a(C),"send-state":a($e),"todo-count":a(Le).length,uploading:a(at),onAddTodo:Un,onOpenFilePicker:X[1]||(X[1]=xe=>{var be,pt;return(pt=(be=a(Ke))==null?void 0:be.openFilePicker)==null?void 0:pt.call(be)}),onClearRequest:Vt,onCopyRequest:es,onManageTodo:T,onSendRequest:D},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(vr,{"agent-bindings":de.value,"selected-agent-engine":E.value,align:"end","onUpdate:selectedAgentEngine":un},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",Sy,[ue(br,An({ref_key:"editorRef",ref:Ke,modelValue:a(Me).blocks,"onUpdate:modelValue":X[2]||(X[2]=xe=>a(Me).blocks=xe)},Kt.value,In(kt)),null,16,["modelValue"])])])])])]))]))}},Yy=Object.freeze(Object.defineProperty({__proto__:null,default:Ly},Symbol.toStringTag,{value:"Module"}));export{Fy as A,Yy as B,Wy as D,Ds as W,Kr as _,oa as a,qy as b,na as c,dc as d,lc as e,Lv as f,Hy as g,dn as h,Gy as i,Qs as j,ot as k,vl as l,zi as m,Uy as n,ld as o,ra as p,Vy as q,Xy as r,zy as s,vt as t,fa as u,Fu as v,Ts as w,Ky as x,zs as y,jy as z};
|