@muyichengshayu/promptx 0.2.14 → 0.2.16

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/apps/web/dist/assets/{CodexSessionManagerDialog-DD2XtFAl.js → CodexSessionManagerDialog-D1PwOD4T.js} +1 -1
  3. package/apps/web/dist/assets/{TaskDiffReviewDialog-CGLpQQ97.js → TaskDiffReviewDialog-GKKv-IkZ.js} +1 -1
  4. package/apps/web/dist/assets/{WorkbenchSettingsDialog-DxU55X3l.js → WorkbenchSettingsDialog-IWlkg3kU.js} +1 -1
  5. package/apps/web/dist/assets/{WorkbenchView-D1oxqNr4.css → WorkbenchView-CK1snPBz.css} +1 -1
  6. package/apps/web/dist/assets/WorkbenchView-dXHPTH_M.js +58 -0
  7. package/apps/web/dist/assets/{index-BLxPFky8.js → index-DaIoquOV.js} +2 -2
  8. package/apps/web/dist/index.html +1 -1
  9. package/package.json +21 -14
  10. package/apps/runner/src/engines/claudeCodeRunner.test.js +0 -467
  11. package/apps/runner/src/engines/kimiCodeRunner.test.js +0 -127
  12. package/apps/runner/src/engines/openCodeRunner.test.js +0 -236
  13. package/apps/runner/src/engines/runnerContract.test.js +0 -449
  14. package/apps/runner/src/engines/shellRunner.test.js +0 -46
  15. package/apps/runner/src/runManager.test.js +0 -913
  16. package/apps/runner/src/serverClient.test.js +0 -93
  17. package/apps/server/src/agentSessionDiscovery.test.js +0 -572
  18. package/apps/server/src/appPaths.test.js +0 -52
  19. package/apps/server/src/assetRoutes.test.js +0 -168
  20. package/apps/server/src/codex.test.js +0 -518
  21. package/apps/server/src/codexRoutes.test.js +0 -376
  22. package/apps/server/src/codexRuns.test.js +0 -160
  23. package/apps/server/src/codexSessions.test.js +0 -369
  24. package/apps/server/src/db.test.js +0 -182
  25. package/apps/server/src/gitDiff.test.js +0 -542
  26. package/apps/server/src/gitDiffClient.test.js +0 -140
  27. package/apps/server/src/internalRoutes.test.js +0 -134
  28. package/apps/server/src/maintenance.test.js +0 -154
  29. package/apps/server/src/processControl.test.js +0 -147
  30. package/apps/server/src/relayClient.test.js +0 -478
  31. package/apps/server/src/relayConfig.test.js +0 -73
  32. package/apps/server/src/relayProtocol.test.js +0 -49
  33. package/apps/server/src/relayServer.test.js +0 -798
  34. package/apps/server/src/relayTenants.test.js +0 -137
  35. package/apps/server/src/relayUsageStore.test.js +0 -65
  36. package/apps/server/src/repository.test.js +0 -150
  37. package/apps/server/src/runDispatchService.test.js +0 -563
  38. package/apps/server/src/runEventIngest.test.js +0 -225
  39. package/apps/server/src/runRecovery.test.js +0 -73
  40. package/apps/server/src/runnerClient.test.js +0 -80
  41. package/apps/server/src/runnerDispatch.test.js +0 -136
  42. package/apps/server/src/systemConfig.test.js +0 -112
  43. package/apps/server/src/systemRoutes.test.js +0 -319
  44. package/apps/server/src/taskRoutes.test.js +0 -775
  45. package/apps/server/src/upload.test.js +0 -30
  46. package/apps/server/src/webAppRoutes.test.js +0 -67
  47. package/apps/server/src/workspaceFiles.test.js +0 -279
  48. package/apps/web/dist/assets/WorkbenchView-DnrN_wUG.js +0 -60
  49. package/packages/shared/src/dailyLogStream.test.js +0 -29
  50. package/packages/shared/src/shellCommands.test.js +0 -45
@@ -0,0 +1,58 @@
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-D1PwOD4T.js","assets/index-DaIoquOV.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-GKKv-IkZ.js","assets/TaskDiffReviewDialog-NsLGEda4.css","assets/WorkbenchSettingsDialog-IWlkg3kU.js"])))=>i.map(i=>d[i]);
2
+ import{u as At,t as Xe,f as $r,_ as Ke,a as Pr,b as Dr,g as Xs,s as Ma,c as Ba}from"./index-DaIoquOV.js";import{w as Ae,ak as Nt,aD as h,aI as Ee,aG as ue,aJ as Ze,aE as k,aK as et,aL as xe,aF as i,aM as on,u as a,aN as fe,aO as Lr,aP as ys,c as G,aQ as b,aR as rt,aS as ct,aT as bn,n as it,o as fn,aU as en,aV as Bn,b as z,aW as Zt,aX as is,aY as Ko,r as Ss,aC as Ra,aZ as Sn,f as Na,a_ as xo,a$ as Os,G as Oa,al as Fa,b0 as En,b1 as An}from"./vendor-misc-u-M8sNMf.js";import{X as Mr,T as Ua,L as Xt,C as Po,a as Fs,B as Wo,S as ja,P as ps,b as Br,c as Va,A as za,F as Hn,d as Pn,e as Rr,f as Ha,E as qa,g as Ka,h as Go,i as Do,j as Us,k as Wa,l as Ga,m as Xa,U as Ya,W as Ja,n as Nr,o as Qa,p as js,q as Ys,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 Is(e=""){return String(e||"").replace(/\r\n/g,`
3
+ `).trim()}function mi(e=""){const t=String(e||"");return pi.has(t.charAt(0))}function gi(e=""){const t=Is(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=>!!Is(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=>Is(u==null?void 0:u.content)).filter(Boolean).join(`
4
+
5
+ `).trim():Is(e==null?void 0:e.prompt);if(!mi(s))return{mode:"",prompt:s,command:"",reason:""};if(o&&n.some(m=>String((m==null?void 0:m.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 un={NONE:"none",LATEST:"latest",ALL:"all"};function vi(e="",t={}){const n=String(e||"").trim().toLowerCase();return n===un.ALL?un.ALL:n===un.LATEST?un.LATEST:n===un.NONE?un.NONE:t.includeEvents?un.ALL:t.includeLatestEvents?un.LATEST:un.NONE}const Wt={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"?Wt.AGENT_EVENT:t}const bt={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"},at={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 ls={CODEX:"codex",CLAUDE_CODE:"claude-code",OPENCODE:"opencode",KIMI_CODE:"kimi-code"},Bo=[{value:ls.CODEX,label:"Codex",enabled:!0},{value:ls.CLAUDE_CODE,label:"Claude Code",enabled:!0},{value:ls.OPENCODE,label:"OpenCode",enabled:!0},{value:ls.KIMI_CODE,label:"Kimi Code",enabled:!0}],kt={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 Vs(e){var n;const t=String(e||"").trim().toLowerCase();return((n=Bo.find(o=>o.value===t))==null?void 0:n.value)||ls.CODEX}function pt(e){var t;return((t=Bo.find(n=>n.value===Vs(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===kt.TEXT||o.type===kt.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"],Js={__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=G(()=>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(m){!n.open||!n.closeOnEscape||n.closeDisabled||m.key==="Escape"&&o("close")}return Ae(()=>n.open,m=>{if(n.lockBodyScroll&&document.body.classList.toggle("overflow-hidden",m),m&&n.closeOnEscape){window.addEventListener("keydown",u);return}window.removeEventListener("keydown",u)},{immediate:!0}),Nt(()=>{n.lockBodyScroll&&document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",u)}),(m,x)=>(h(),Ee(ys,{to:"body"},[ue(Lr,{name:"dialog-shell"},{default:Ze(()=>[e.open?(h(),k("div",{key:0,class:xe(["theme-modal-backdrop dialog-shell-backdrop fixed inset-0 flex",s.value]),onClick:et(l,["self"])},[i("section",{class:xe(["panel dialog-shell-panel flex min-h-0 w-full flex-col overflow-hidden",e.panelClass])},[m.$slots.title||m.$slots.header||m.$slots["header-actions"]||e.showClose?(h(),k("div",{key:0,class:xe(["theme-divider flex items-start justify-between gap-4 border-b",e.headerClass])},[i("div",Ai,[on(m.$slots,"header",{},()=>[on(m.$slots,"title")])]),m.$slots["header-actions"]||e.showClose?(h(),k("div",Ii,[on(m.$slots,"header-actions"),e.showClose?(h(),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)):fe("",!0)])):fe("",!0)],2)):fe("",!0),i("div",{class:xe(e.bodyClass)},[on(m.$slots,"default")],2)],2)],2)):fe("",!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"],ks={__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}=At(),r=G(()=>n.title||s("common.confirm")),l=G(()=>n.confirmText||s("common.confirm")),u=G(()=>n.cancelText||s("common.cancel"));return(m,x)=>(h(),Ee(Js,{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:x[2]||(x[2]=c=>o("cancel"))},{title:Ze(()=>[i("div",Pi,[i("span",{class:xe(["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?(h(),k("p",Li,b(e.description),1)):fe("",!0)])])]),default:Ze(()=>[i("div",Mi,[i("button",{type:"button",class:"tool-button px-4 py-2 text-sm",disabled:e.loading,onClick:x[0]||(x[0]=c=>o("cancel"))},b(u.value),9,Bi),i("button",{type:"button",class:xe(["tool-button px-4 py-2 text-sm",e.danger?"tool-button-danger":"tool-button-primary"]),disabled:e.loading,onClick:x[1]||(x[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)=>(h(),k("aside",Ni,[i("nav",Oi,[(h(!0),k(rt,null,ct(e.sections,l=>(h(),k("button",{key:l.id,type:"button",class:xe(["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)},[(h(),Ee(bn(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"},cn={__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}=At(),r=z(null),l=z(null),u=z(!1),m=z(!1),x=z({}),c=G(()=>{const R=String(n.modelValue??"");return n.options.find(te=>String(n.getOptionValue(te)??"")===R)||null}),T=G(()=>n.placeholder||s("common.select")),v=G(()=>n.emptyText||s("common.noOptions"));function g(R){return R&&typeof R=="object"&&Object.prototype.hasOwnProperty.call(R,"label")?String(R.label||""):String(n.getOptionValue(R)??"")}function p(){n.disabled||(u.value||o("refresh-intent"),u.value=!0)}function $(){u.value=!1}function Z(){if(u.value){$();return}p()}function S(R){o("update:modelValue",String(n.getOptionValue(R)??"").trim()),$()}function B(){if(!u.value||!r.value||typeof window>"u")return;const R=r.value.getBoundingClientRect(),te=window.innerWidth,E=window.innerHeight,Y=8,pe=8,ge=160,P=360,ee=Math.max(0,E-R.bottom-pe),le=Math.max(0,R.top-pe);m.value=ee<260&&le>ee;const Q=m.value?le-Y:ee-Y,he=Math.max(Math.min(P,Math.max(Q,0)),Math.min(ge,m.value?le:ee)),A=Math.min(R.width,te-pe*2),X=Math.min(Math.max(pe,R.left),Math.max(pe,te-pe-A));x.value={left:`${X}px`,top:m.value?`${R.top-Y}px`:`${R.bottom+Y}px`,width:`${A}px`,maxHeight:`${Math.max(he,120)}px`,transform:m.value?"translateY(-100%)":"none"}}function K(R){var te;!u.value||!r.value||r.value.contains(R.target)||(te=l.value)!=null&&te.contains(R.target)||$()}function j(R){R.key==="Escape"&&$()}return Ae(()=>n.disabled,R=>{R&&$()}),Ae(u,async R=>{R&&(await it(),B())}),fn(()=>{document.addEventListener("pointerdown",K),document.addEventListener("keydown",j),window.addEventListener("resize",B),window.addEventListener("scroll",B,!0)}),Nt(()=>{document.removeEventListener("pointerdown",K),document.removeEventListener("keydown",j),window.removeEventListener("resize",B),window.removeEventListener("scroll",B,!0)}),(R,te)=>(h(),k("div",{ref_key:"rootRef",ref:r,class:"relative min-w-0"},[i("button",{type:"button",class:xe(["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:[en(et(p,["prevent"]),["down"]),en(et(Z,["prevent"]),["enter"]),en(et(Z,["prevent"]),["space"])]},[i("div",qi,[on(R.$slots,"trigger",{selectedOption:c.value,open:u.value,loading:e.loading,disabled:e.disabled},()=>[i("div",Ki,b(c.value?g(c.value):T.value),1)])]),i("div",{class:xe(["flex shrink-0 items-center gap-2",e.disabled?"text-[var(--theme-textMuted)] opacity-80":"theme-muted-text"])},[e.loading?(h(),Ee(a(Xt),{key:0,class:"h-4 w-4 animate-spin"})):fe("",!0),ue(a(Po),{class:xe(["h-4 w-4 transition",u.value?"rotate-180":""])},null,8,["class"])],2)],42,Hi),(h(),Ee(ys,{to:"body"},[u.value?(h(),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:Bn(x.value)},[i("div",Wi,[on(R.$slots,"header",{loading:e.loading,options:e.options}),i("div",Gi,[e.options.length?(h(!0),k(rt,{key:0},ct(e.options,E=>on(R.$slots,"option",{key:String(e.getOptionValue(E)??""),option:E,selected:String(e.getOptionValue(E)??"")===String(e.modelValue??""),select:()=>S(E)},()=>[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:Y=>S(E)},b(g(E)),9,Xi)])),128)):on(R.$slots,"empty",{key:1},()=>[i("div",Yi,b(v.value),1)])])])],4)):fe("",!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=Xe(n);if(o&&o!==n)return o}return(e==null?void 0:e.message)||Xe(t)}async function tt(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 Xn(){return Ro()}function $s(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 tt("/api/meta",{cache:"no-store"})}function Qi(){return tt("/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)}),tt(`/api/tasks/workspace-diff-summaries?${n.toString()}`,{cache:"no-store"})}function el(e){return tt("/api/tasks",{method:"POST",body:JSON.stringify(e)})}function tl(e=[]){return tt("/api/tasks/reorder",{method:"POST",body:JSON.stringify({slugs:e})})}function zr(e){return tt(`/api/tasks/${e}`)}function Hr(e,t){return tt(`/api/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)})}function nl(e){return tt(`/api/tasks/${e}`,{method:"DELETE"})}async function sl(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Xn()}/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(`${Xn()}/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=Xn();function al(){return tt("/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 tt(`/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 tt(`/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 tt(`/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 tt(`/api/codex/directories/search${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function ll(e){return tt("/api/codex/sessions",{method:"POST",body:JSON.stringify(e)})}function ul(e,t){return tt(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function cl(e){return tt(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function dl(e){return tt(`/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 tt(`/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 tt(`/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 tt(`/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 tt(`/api/codex/sessions/${encodeURIComponent(e)}/files/content-search${u?`?${u}`:""}`,{cache:"no-store",signal:n.signal})}function hl(e,t){return tt(`/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 tt(`/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 tt(`/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,m=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"),m>0&&n.set("timeoutMs",String(m));const x=n.toString();return tt(`/api/tasks/${encodeURIComponent(e)}/git-diff${x?`?${x}`:""}`,{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 tt(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"POST",body:JSON.stringify(t)})}function wl(e){return tt(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"DELETE"})}function xl(e){return tt(`/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",rs="09:00",Un="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}=At(),l=z(!1),u=z(!1),m=z(""),x=z("basic"),c=Ss({title:"",automationEnabled:!1,automationMode:io,automationTime:rs,automationWeekday:Un,automationTimezone:"local",automationConcurrencyPolicy:"skip",automationLastTriggeredAt:"",automationNextTriggerAt:"",notificationEnabled:!1,notificationChannelType:"dingtalk",notificationWebhookUrl:"",notificationSecret:"",notificationTriggerOn:"completed",notificationLocale:"zh-CN",notificationMessageMode:"summary",notificationLastStatus:"",notificationLastError:"",notificationLastSentAt:""}),T=G(()=>String(n.taskTitle||"").trim()||r("workbench.untitledTask")),v=G(()=>[{id:"basic",label:r("taskDialog.sections.basic.label"),description:r("taskDialog.sections.basic.description"),icon:ps},{id:"automation",label:r("taskDialog.sections.automation.label"),description:r("taskDialog.sections.automation.description"),icon:Fs},{id:"notification",label:r("taskDialog.sections.notification.label"),description:r("taskDialog.sections.notification.description"),icon:Wo}]),g=G(()=>[{value:"daily",label:r("taskDialog.sections.automation.modeDaily")},{value:"weekdays",label:r("taskDialog.sections.automation.modeWeekdays")},{value:"weekly",label:r("taskDialog.sections.automation.modeWeekly")}]),p=G(()=>[{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")}]),$=G(()=>Si.map(A=>({...A,label:A.value==="local"?r("taskDialog.sections.automation.timezoneLocal"):A.label}))),Z=G(()=>xi.map(A=>({...A,label:A.value==="skip"?r("taskDialog.sections.automation.concurrencySkip"):A.label}))),S=G(()=>bi.map(A=>({...A,label:A.value==="dingtalk"?r("taskDialog.sections.notification.channelDingtalk"):A.value==="feishu"?r("taskDialog.sections.notification.channelFeishu"):A.value==="webhook"?r("taskDialog.sections.notification.channelWebhook"):A.label}))),B=G(()=>ki.map(A=>({...A,label:A.value==="completed"?r("taskDialog.sections.notification.triggerCompleted"):A.value==="success"?r("taskDialog.sections.notification.triggerSuccess"):A.value==="error"?r("taskDialog.sections.notification.triggerError"):A.label}))),K=G(()=>_i.map(A=>({...A,label:A.value==="summary"?r("taskDialog.sections.notification.messageSummary"):A.label}))),j=G(()=>Ci.map(A=>({...A,label:A.value==="zh-CN"?r("taskDialog.sections.notification.localeZhCn"):A.value==="en-US"?r("taskDialog.sections.notification.localeEnUs"):A.label}))),R=G(()=>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 te(){c.title="",c.automationEnabled=!1,c.automationMode=io,c.automationTime=rs,c.automationWeekday=Un,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 E(A=0){return String(A).padStart(2,"0")}function Y(A=""){const X=String(A||"").trim().replace(/\s+/g," ");let I=X.match(/^(\d{1,2}) (\d{1,2}) \* \* 1-5$/);return I?{mode:"weekdays",time:`${E(I[2])}:${E(I[1])}`,weekday:Un}:(I=X.match(/^(\d{1,2}) (\d{1,2}) \* \* \*$/),I?{mode:"daily",time:`${E(I[2])}:${E(I[1])}`,weekday:Un}:(I=X.match(/^(\d{1,2}) (\d{1,2}) \* \* ([0-6])$/),I?{mode:"weekly",time:`${E(I[2])}:${E(I[1])}`,weekday:String(I[3])}:{mode:io,time:rs,weekday:Un}))}function pe(A=""){const I=String(A||"").trim().match(/^(\d{1,2}):(\d{2})$/);if(!I)return rs;const _e=Number(I[1]),Me=Number(I[2]);return!Number.isInteger(_e)||!Number.isInteger(Me)||_e<0||_e>23||Me<0||Me>59?rs:`${E(_e)}:${E(Me)}`}function ge(){var Re;const A=pe(c.automationTime),[X,I]=A.split(":"),_e=Number(X),Me=Number(I);if(c.automationMode==="daily")return`${Me} ${_e} * * *`;if(c.automationMode==="weekly"){const Ne=((Re=p.value.find(Ve=>Ve.value===String(c.automationWeekday||"")))==null?void 0:Re.value)||Un;return`${Me} ${_e} * * ${Ne}`}return`${Me} ${_e} * * 1-5`}function P(A={}){var I,_e,Me,Re,Ne,Ve,Ge,Te,W,ae,de,$e,ye,Le,me,De;c.title=String(A.title||""),c.automationEnabled=!!((I=A.automation)!=null&&I.enabled);const X=Y(((_e=A.automation)==null?void 0:_e.cron)||Ru);c.automationMode=X.mode,c.automationTime=X.time,c.automationWeekday=X.weekday,c.automationTimezone=String(((Me=A.automation)==null?void 0:Me.timezone)||"local"),c.automationConcurrencyPolicy=String(((Re=A.automation)==null?void 0:Re.concurrencyPolicy)||"skip"),c.automationLastTriggeredAt=String(((Ne=A.automation)==null?void 0:Ne.lastTriggeredAt)||""),c.automationNextTriggerAt=String(((Ve=A.automation)==null?void 0:Ve.nextTriggerAt)||""),c.notificationEnabled=!!((Ge=A.notification)!=null&&Ge.enabled),c.notificationChannelType=String(((Te=A.notification)==null?void 0:Te.channelType)||"dingtalk"),c.notificationWebhookUrl=String(((W=A.notification)==null?void 0:W.webhookUrl)||""),c.notificationSecret=String(((ae=A.notification)==null?void 0:ae.secret)||""),c.notificationTriggerOn=String(((de=A.notification)==null?void 0:de.triggerOn)||"completed"),c.notificationLocale=String((($e=A.notification)==null?void 0:$e.locale)||s.value||"zh-CN"),c.notificationMessageMode=String(((ye=A.notification)==null?void 0:ye.messageMode)||"summary"),c.notificationLastStatus=String(((Le=A.notification)==null?void 0:Le.lastStatus)||""),c.notificationLastError=String(((me=A.notification)==null?void 0:me.lastError)||""),c.notificationLastSentAt=String(((De=A.notification)==null?void 0:De.lastSentAt)||"")}async function ee(){const A=String(n.taskSlug||"").trim();if(!A){te();return}l.value=!0,m.value="";try{const X=await zr(A);P(X)}catch(X){m.value=(X==null?void 0:X.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 Q(){const A=String(n.taskSlug||"").trim();if(!(!A||l.value||u.value)){u.value=!0,m.value="";try{const X=await Hr(A,le());P(X),o("saved",X),o("close")}catch(X){m.value=(X==null?void 0:X.message)||r("taskDialog.saveFailed")}finally{u.value=!1}}}function he(A=""){if(!A)return r("common.notAvailable");const X=new Date(A);return Number.isNaN(X.getTime())?r("common.notAvailable"):$r(X.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return Ae(()=>n.open,A=>{if(A){x.value="basic",ee();return}},{immediate:!0}),Ae(()=>n.taskSlug,()=>{n.open&&ee()}),(A,X)=>(h(),Ee(Js,{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:X[16]||(X[16]=I=>o("close"))},{title:Ze(()=>[i("div",null,[i("div",bl,[ue(a(ps),{class:"h-4 w-4"}),i("span",null,b(a(r)("taskDialog.title")),1)]),i("p",kl,b(a(r)("taskDialog.currentTask",{title:T.value})),1)])]),default:Ze(()=>[i("div",Tl,[ue(zi,{modelValue:x.value,"onUpdate:modelValue":X[0]||(X[0]=I=>x.value=I),sections:v.value},null,8,["modelValue","sections"]),i("div",_l,[l.value?(h(),k("div",Cl,[ue(a(Xt),{class:"h-4 w-4 animate-spin"}),i("span",null,b(a(r)("taskDialog.loading")),1)])):(h(),k("div",El,[x.value==="basic"?(h(),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),Zt(i("input",{"onUpdate:modelValue":X[1]||(X[1]=I=>c.title=I),type:"text",maxlength:"140",class:"tool-input",placeholder:a(r)("taskDialog.sections.basic.taskTitlePlaceholder")},null,8,Ml),[[is,c.title]])])])])):x.value==="automation"?(h(),k("section",Bl,[i("div",Rl,[i("div",null,[i("div",Nl,[ue(a(Fs),{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,[Zt(i("input",{"onUpdate:modelValue":X[2]||(X[2]=I=>c.automationEnabled=I),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(cn,{modelValue:c.automationMode,"onUpdate:modelValue":X[3]||(X[3]=I=>c.automationMode=I),options:g.value,disabled:!c.automationEnabled,"get-option-value":I=>I.value},{trigger:Ze(({selectedOption:I})=>[i("div",Hl,b((I==null?void 0:I.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),Zt(i("input",{"onUpdate:modelValue":X[4]||(X[4]=I=>c.automationTime=I),type:"time",class:"tool-input",disabled:!c.automationEnabled},null,8,Wl),[[is,c.automationTime]])]),c.automationMode==="weekly"?(h(),k("label",Gl,[i("span",Xl,b(a(r)("taskDialog.sections.automation.weekday")),1),ue(cn,{modelValue:c.automationWeekday,"onUpdate:modelValue":X[5]||(X[5]=I=>c.automationWeekday=I),options:p.value,disabled:!c.automationEnabled,"get-option-value":I=>I.value},{trigger:Ze(({selectedOption:I})=>[i("div",Yl,b((I==null?void 0:I.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])):fe("",!0),i("label",Jl,[i("span",Ql,b(a(r)("taskDialog.sections.automation.timezone")),1),ue(cn,{modelValue:c.automationTimezone,"onUpdate:modelValue":X[6]||(X[6]=I=>c.automationTimezone=I),options:$.value,disabled:!c.automationEnabled,"get-option-value":I=>I.value},{trigger:Ze(({selectedOption:I})=>[i("div",Zl,b((I==null?void 0:I.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",{class:xe(["space-y-1.5",c.automationMode==="weekly"?"":"sm:col-span-2"])},[i("span",eu,b(a(r)("taskDialog.sections.automation.concurrencyPolicy")),1),ue(cn,{modelValue:c.automationConcurrencyPolicy,"onUpdate:modelValue":X[7]||(X[7]=I=>c.automationConcurrencyPolicy=I),options:Z.value,disabled:!c.automationEnabled,"get-option-value":I=>I.value},{trigger:Ze(({selectedOption:I})=>[i("div",tu,b((I==null?void 0:I.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:he(c.automationLastTriggeredAt)})),1),i("p",null,b(a(r)("taskDialog.sections.automation.nextTriggered",{value:he(c.automationNextTriggerAt)})),1)])])])):(h(),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,[Zt(i("input",{"onUpdate:modelValue":X[8]||(X[8]=I=>c.notificationEnabled=I),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(cn,{modelValue:c.notificationChannelType,"onUpdate:modelValue":X[9]||(X[9]=I=>c.notificationChannelType=I),options:S.value,disabled:!c.notificationEnabled,"get-option-value":I=>I.value},{trigger:Ze(({selectedOption:I})=>[i("div",fu,b((I==null?void 0:I.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(cn,{modelValue:c.notificationTriggerOn,"onUpdate:modelValue":X[10]||(X[10]=I=>c.notificationTriggerOn=I),options:B.value,disabled:!c.notificationEnabled,"get-option-value":I=>I.value},{trigger:Ze(({selectedOption:I})=>[i("div",gu,b((I==null?void 0:I.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),Zt(i("input",{"onUpdate:modelValue":X[11]||(X[11]=I=>c.notificationWebhookUrl=I),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.webhookUrlPlaceholder"),disabled:!c.notificationEnabled},null,8,yu),[[is,c.notificationWebhookUrl]])]),i("label",Su,[i("span",wu,b(a(r)("taskDialog.sections.notification.secret")),1),Zt(i("input",{"onUpdate:modelValue":X[12]||(X[12]=I=>c.notificationSecret=I),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.secretPlaceholder"),disabled:!c.notificationEnabled},null,8,xu),[[is,c.notificationSecret]])]),i("label",bu,[i("span",ku,b(a(r)("taskDialog.sections.notification.locale")),1),ue(cn,{modelValue:c.notificationLocale,"onUpdate:modelValue":X[13]||(X[13]=I=>c.notificationLocale=I),options:j.value,disabled:!c.notificationEnabled,"get-option-value":I=>I.value},{trigger:Ze(({selectedOption:I})=>[i("div",Tu,b((I==null?void 0:I.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(cn,{modelValue:c.notificationMessageMode,"onUpdate:modelValue":X[14]||(X[14]=I=>c.notificationMessageMode=I),options:K.value,disabled:!c.notificationEnabled,"get-option-value":I=>I.value},{trigger:Ze(({selectedOption:I})=>[i("div",Eu,b((I==null?void 0:I.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:R.value})),1),i("p",null,b(a(r)("taskDialog.sections.notification.lastSent",{value:he(c.notificationLastSentAt)})),1),c.notificationLastError?(h(),k("p",Iu,b(a(r)("taskDialog.sections.notification.lastError",{value:c.notificationLastError})),1)):fe("",!0)])])])),m.value?(h(),k("p",$u,b(m.value),1)):fe("",!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:X[15]||(X[15]=I=>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:Q},[u.value?(h(),Ee(a(Xt),{key:0,class:"h-4 w-4 animate-spin"})):(h(),Ee(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=Vs(n.value);return{...n,value:o,label:String(n.label||pt(o)).trim()||pt(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 tt("/api/meta",{cache:"no-store"});return Fu(e==null?void 0:e.agentEngineOptions)}function qr(e={},t={}){const{defaultLabel:n="默认",prefix:o=""}=t,s=pt(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}=At();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 m(c){var v;const T=Math.max(0,Number((v=c==null?void 0:c.agentBindings)==null?void 0:v.length)||0);return T>1?o("projectManager.agentCount",{count:T}):pt(c==null?void 0:c.engine)}function x(c){return c?"theme-filter-active":"theme-filter-idle"}return(c,T)=>(h(),Ee(cn,{"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":v=>(v==null?void 0:v.id)||"","onUpdate:modelValue":T[0]||(T[0]=v=>n("update:modelValue",v)),onRefreshIntent:T[1]||(T[1]=v=>n("refresh-intent"))},{trigger:Ze(({selectedOption:v,disabled:g})=>[v?(h(),k("div",Uu,[i("span",ju,[i("span",{class:xe(["font-medium",g?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},b(s(v)),3),i("span",Vu,b(r(v)),1)]),i("span",zu,b(m(v)),1),i("span",{class:xe(["hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex",u(v)])},b(l(v)),3)])):(h(),k("div",Hu,b(e.loading?a(o)("projectManager.syncingProjects"):a(o)("projectManager.selectProject")),1))]),header:Ze(()=>[i("div",qu,[i("span",null,b(e.loading?a(o)("projectManager.syncingLatestProjects"):a(o)("projectManager.projectCount",{count:e.sessions.length})),1),e.loading?(h(),Ee(a(Xt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):fe("",!0)])]),option:Ze(({option:v,selected:g,select:p})=>[i("button",{type:"button",class:xe(["w-full rounded-sm border border-dashed p-3 text-left transition",x(g)]),onClick:p},[i("div",Wu,[i("div",Gu,[i("div",Xu,[i("span",Yu,b(s(v)),1)]),i("div",Ju,[i("span",Qu,[i("span",Zu,b(s(v)),1),i("span",ec,b(r(v)),1)]),i("span",tc,b(m(v)),1),i("span",{class:xe(["inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",u(v)])},b(l(v)),3)])]),g?(h(),Ee(a(Br),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):fe("",!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}=At(),r=z(1),l=G(()=>n.images.map(S=>String(S||"").trim()).filter(Boolean)),u=G(()=>l.value.findIndex(S=>S===n.modelValue)),m=G(()=>u.value>=0?l.value[u.value]:"");function x(){o("update:modelValue",""),r.value=1}function c(S){o("update:modelValue",String(S||"").trim()),r.value=1}function T(){u.value<=0||c(l.value[u.value-1])}function v(){u.value<0||u.value>=l.value.length-1||c(l.value[u.value+1])}function g(S){const B=Math.min(3,Math.max(.5,r.value+S));r.value=Math.round(B*100)/100}function p(){r.value=1}function $(S){m.value&&(S.preventDefault(),g(S.deltaY<0?.1:-.1))}function Z(S){var B,K;if(m.value){if((B=S.stopPropagation)==null||B.call(S),(K=S.stopImmediatePropagation)==null||K.call(S),S.key==="Escape"){S.preventDefault(),x();return}if(S.key==="ArrowLeft"){S.preventDefault(),T();return}if(S.key==="ArrowRight"){S.preventDefault(),v();return}if(S.key==="+"||S.key==="="){S.preventDefault(),g(.1);return}if(S.key==="-"){S.preventDefault(),g(-.1);return}S.key==="0"&&(S.preventDefault(),p())}}return Ae(()=>n.modelValue,S=>{S||(r.value=1)}),Ae(l,S=>{if(n.modelValue){if(!S.length){x();return}if(!S.includes(n.modelValue)){const B=Math.min(u.value,S.length-1);c(S[B]||S[0])}}},{immediate:!0}),fn(()=>{window.addEventListener("keydown",Z,{capture:!0})}),Nt(()=>{window.removeEventListener("keydown",Z,{capture:!0})}),(S,B)=>(h(),Ee(ys,{to:"body"},[m.value?(h(),k("div",{key:0,class:"theme-modal-backdrop image-preview-overlay fixed inset-0 z-[120] flex items-center justify-center p-6",onClick:x,onWheel:$},[i("div",{class:"absolute left-4 top-4 flex items-center gap-2",onClick:B[2]||(B[2]=et(()=>{},["stop"]))},[i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:B[0]||(B[0]=K=>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:p},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:B[1]||(B[1]=K=>g(.1))},b(a(s)("imagePreview.zoomIn")),1)]),i("div",{class:"absolute right-4 top-4 flex items-center gap-2",onClick:B[3]||(B[3]=et(()=>{},["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:T},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:v},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:x},b(a(s)("imagePreview.close")),1)]),i("img",{src:m.value,alt:a(s)("imagePreview.alt"),class:"image-preview-overlay__image max-h-[90vh] max-w-[90vw] object-contain shadow-2xl transition-transform",style:Bn({transform:`scale(${r.value})`}),onClick:B[4]||(B[4]=et(()=>{},["stop"]))},null,12,rc)],32)):fe("",!0)]))}};let lo=null;const Wy={maxLines:2e3,maxChars:2e5},uo={maxLines:2e3,maxChars:2e5},ac={"github-dark-default":()=>Ke(()=>import("./vendor-shiki-theme-github-dark-default-DBX58552.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),"github-light":()=>Ke(()=>import("./vendor-shiki-theme-github-light-RLAvZv0q.js"),__vite__mapDeps([4,1,2,3])).then(e=>e.default)},ic={bash:()=>Ke(()=>import("./vendor-shiki-lang-bash-zsQu0xn-.js"),__vite__mapDeps([5,1,2,3])).then(e=>e.default),c:()=>Ke(()=>import("./vendor-shiki-lang-c-BDF8vgks.js"),__vite__mapDeps([6,1,2,3])).then(e=>e.default),cpp:()=>Ke(()=>import("./vendor-shiki-lang-cpp-DyDAaXl6.js"),__vite__mapDeps([7,1,2,3])).then(e=>e.default),csharp:()=>Ke(()=>import("./vendor-shiki-lang-csharp-BWfTXJXw.js"),__vite__mapDeps([8,1,2,3])).then(e=>e.default),css:()=>Ke(()=>import("./vendor-shiki-lang-css-DbAm1fUO.js"),__vite__mapDeps([9,1,2,3])).then(e=>e.default),diff:()=>Ke(()=>import("./vendor-shiki-lang-diff-DmGC1G26.js"),__vite__mapDeps([10,1,2,3])).then(e=>e.default),dockerfile:()=>Ke(()=>import("./vendor-shiki-lang-dockerfile-3x-8396r.js"),__vite__mapDeps([11,1,2,3])).then(e=>e.default),dotenv:()=>Ke(()=>import("./vendor-shiki-lang-dotenv--IVOlX2Q.js"),__vite__mapDeps([12,1,2,3])).then(e=>e.default),fish:()=>Ke(()=>import("./vendor-shiki-lang-fish-Bpv3hhJP.js"),__vite__mapDeps([13,1,2,3])).then(e=>e.default),go:()=>Ke(()=>import("./vendor-shiki-lang-go-CIGC59jP.js"),__vite__mapDeps([14,1,2,3])).then(e=>e.default),html:()=>Ke(()=>import("./vendor-shiki-lang-html-Bt_TLLZN.js"),__vite__mapDeps([15,1,2,3])).then(e=>e.default),ini:()=>Ke(()=>import("./vendor-shiki-lang-ini-BIllfys4.js"),__vite__mapDeps([16,1,2,3])).then(e=>e.default),java:()=>Ke(()=>import("./vendor-shiki-lang-java-CXxu9crF.js"),__vite__mapDeps([17,1,2,3])).then(e=>e.default),javascript:()=>Ke(()=>import("./vendor-shiki-lang-javascript-Cha7GNZm.js"),__vite__mapDeps([18,1,2,3])).then(e=>e.default),json:()=>Ke(()=>import("./vendor-shiki-lang-json-CCZCjDUh.js"),__vite__mapDeps([19,1,2,3])).then(e=>e.default),less:()=>Ke(()=>import("./vendor-shiki-lang-less-DAToytC5.js"),__vite__mapDeps([20,1,2,3])).then(e=>e.default),markdown:()=>Ke(()=>import("./vendor-shiki-lang-markdown-C6lwMXFp.js"),__vite__mapDeps([21,1,2,3])).then(e=>e.default),python:()=>Ke(()=>import("./vendor-shiki-lang-python-Bi9rmtY7.js"),__vite__mapDeps([22,1,2,3])).then(e=>e.default),powershell:()=>Ke(()=>import("./vendor-shiki-lang-powershell-lrpuM0ez.js"),__vite__mapDeps([23,1,2,3])).then(e=>e.default),rust:()=>Ke(()=>import("./vendor-shiki-lang-rust-GTGDbY6A.js"),__vite__mapDeps([24,1,2,3])).then(e=>e.default),sass:()=>Ke(()=>import("./vendor-shiki-lang-sass-DFtHupN8.js"),__vite__mapDeps([25,1,2,3])).then(e=>e.default),scss:()=>Ke(()=>import("./vendor-shiki-lang-scss-BrfBNyyi.js"),__vite__mapDeps([26,1,2,3])).then(e=>e.default),sql:()=>Ke(()=>import("./vendor-shiki-lang-sql-H6--iFN-.js"),__vite__mapDeps([27,1,2,3])).then(e=>e.default),toml:()=>Ke(()=>import("./vendor-shiki-lang-toml-aTteTWYL.js"),__vite__mapDeps([28,1,2,3])).then(e=>e.default),tsx:()=>Ke(()=>import("./vendor-shiki-lang-tsx-DoKZm6AV.js"),__vite__mapDeps([29,1,2,3])).then(e=>e.default),typescript:()=>Ke(()=>import("./vendor-shiki-lang-typescript-B5awnqri.js"),__vite__mapDeps([30,1,2,3])).then(e=>e.default),vue:()=>Ke(()=>import("./vendor-shiki-lang-vue-CnrgQ7Z5.js"),__vite__mapDeps([31,1,2,3])).then(e=>e.default),xml:()=>Ke(()=>import("./vendor-shiki-lang-xml-Bv-TNPJt.js"),__vite__mapDeps([32,1,2,3])).then(e=>e.default),yaml:()=>Ke(()=>import("./vendor-shiki-lang-yaml-DpxUxQ6M.js"),__vite__mapDeps([33,1,2,3])).then(e=>e.default)};function 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,`
6
+ `);return lc(n?n.split(`
7
+ `):[],t)}async function Gr(){return lo||(lo=Promise.all([Ke(()=>import("./vendor-shiki-core-1BqeTDsZ.js").then(e=>e.F),__vite__mapDeps([1,2,3])),Ke(()=>import("./vendor-shiki-core-1BqeTDsZ.js").then(e=>e.G),__vite__mapDeps([1,2,3]))]).then(async([e,t])=>e.createHighlighterCore({engine:t.createJavaScriptRegexEngine(),langs:[],themes:[]}))),lo}async function Xr(e,t){if(!t||e.getLoadedThemes().includes(t))return;const n=ac[t];n&&await e.loadTheme(await n())}async function Yr(e,t){if(!t||e.getLoadedLanguages().includes(t))return;const n=ic[t];n&&await e.loadLanguage(await n())}function qn(e=""){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const cc={bash:"bash",c:"c",cpp:"cpp",cs:"csharp",csharp:"csharp",csh:"bash",css:"css",diff:"diff",dockerfile:"dockerfile",dotenv:"dotenv",env:"dotenv",fish:"fish",go:"go",html:"html",ini:"ini",java:"java",js:"javascript",javascript:"javascript",json:"json",jsx:"tsx",less:"less",md:"markdown",markdown:"markdown",powershell:"powershell",ps1:"powershell",pwsh:"powershell",python:"python",react:"tsx",rust:"rust",sass:"sass",scss:"scss",sh:"bash",shell:"bash",sql:"sql",svg:"html",text:"",toml:"toml",ts:"typescript",typescript:"typescript",tsx:"tsx",vue:"vue",xml:"xml",yaml:"yaml",yml:"yaml",zsh:"bash"};function Qs(e=""){const t=String(e||"").trim().toLowerCase();return t?cc[t]||t:""}function Gy(e="",t=""){const n=Qs(t);if(n)return n;const o=String(e||"").trim().toLowerCase();if(!o)return"";const s=o.split("/").pop()||"",r=s.includes(".")?s.slice(s.lastIndexOf(".")):"",l={".c":"c",".cc":"cpp",".conf":"ini",".cpp":"cpp",".cs":"csharp",".csh":"bash",".css":"css",".diff":"diff",".env":"dotenv",".fish":"fish",".go":"go",".htm":"html",".html":"html",".ini":"ini",".java":"java",".js":"javascript",".json":"json",".jsx":"tsx",".less":"less",".md":"markdown",".ps1":"powershell",".py":"python",".rs":"rust",".sass":"sass",".scss":"scss",".sh":"bash",".sql":"sql",".svg":"html",".toml":"toml",".ts":"typescript",".tsx":"tsx",".vue":"vue",".xml":"xml",".yaml":"yaml",".yml":"yaml",".zsh":"bash"};return s===".env"?"dotenv":s==="dockerfile"?"dockerfile":s==="makefile"?"":l[r]||""}function Jr(e){const t=[];e!=null&&e.color&&t.push(`color:${e.color}`),(e==null?void 0:e.fontStyle)&1&&t.push("font-style:italic"),(e==null?void 0:e.fontStyle)&2&&t.push("font-weight:600"),(e==null?void 0:e.fontStyle)&4&&t.push("text-decoration:underline");const n=qn((e==null?void 0:e.content)||"");return`<span${t.length?` style="${t.join(";")}"`:""}>${n}</span>`}function Qr(e=[],t={}){const n=Math.max(1,Number(t.startLine)||1);return{html:e.map((o,s)=>`<tr class="source-code-view__line" data-line="${n+s}"><td class="source-code-view__gutter" data-line="${n+s}">${n+s}</td><td class="source-code-view__code"><span class="source-code-view__line-inner">${o}</span></td></tr>`).join(""),lineCount:e.length,bg:t.bg||"",fg:t.fg||"",gutterWidth:Wr(e.length)}}function Xy(e=[]){return(Array.isArray(e)?e.map(n=>String(n??"")):[]).map(n=>n?qn(n):"&#8203;")}function co(e=""){const t=String(e||"").replace(/\r\n/g,`
8
+ `);return Qr(t.split(`
9
+ `).map(n=>n?qn(n):"&#8203;"),{})}async function dc(e=[],t={}){const n=Oo(e),o=n.lines,s=t.isDark?"github-dark-default":"github-light",r=Qs(t.language);if(!o.length)return[];if(Fo(n,t))return o.map(l=>l?qn(l):"&#8203;");if(!r)return o.map(l=>l?qn(l):"&#8203;");try{const l=await Gr();return await Xr(l,s),await Yr(l,r),(await l.codeToTokens(o.join(`
10
+ `),{lang:r,theme:s})).tokens.map(m=>m.length?m.map(Jr).join(""):"&#8203;")}catch{return o.map(l=>l?qn(l):"&#8203;")}}async function fc(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
11
+ `),o=t.isDark?"github-dark-default":"github-light",s=Qs(t.language),r=n?n.split(`
12
+ `):[],l=Oo(r);if(!n)return{html:"",lineCount:0,bg:"",fg:"",gutterWidth:Wr(0)};if(Fo(l,t)||!s)return co(n);try{const u=await Gr();await Xr(u,o),await Yr(u,s);const m=await u.codeToTokens(n,{lang:s,theme:o});return Qr(m.tokens.map(x=>x.length?x.map(Jr).join(""):"&#8203;"),{bg:m.bg||"",fg:m.fg||""})}catch{return co(n)}}const pc=new Fr,mc="__PROMPTX_FENCE__";function Zr(e=""){return String(e||"").trim().toLowerCase()}function Ts(e=""){return pc.utils.escapeHtml(String(e||""))}function gc(e=""){const t=Zr(e);return t?["js","javascript"].includes(t)?"JavaScript":["jsx","react"].includes(t)?"React":["ts","typescript"].includes(t)?"TypeScript":t==="tsx"?"TSX":["sh","shell","zsh","bash","csh"].includes(t)?"Bash":t==="fish"?"Fish":["ps1","pwsh","powershell"].includes(t)?"PowerShell":t==="md"?"Markdown":t==="html"?"HTML":t==="vue"?"Vue":t==="svg"?"SVG":t==="json"?"JSON":t==="sql"?"SQL":t==="scss"?"SCSS":t==="sass"?"Sass":t==="less"?"Less":t==="toml"?"TOML":t==="ini"?"INI":["env","dotenv"].includes(t)?".env":["cs","csharp"].includes(t)?"C#":t.charAt(0).toUpperCase()+t.slice(1):""}function ea(e={}){const t=new Fr({html:!1,breaks:!0,linkify:!0,typographer:!1}),n=t.renderer.rules.link_open,o=t.renderer.rules.table_open,s=t.renderer.rules.table_close,r=t.renderer.rules.fence;return t.renderer.rules.link_open=(l,u,m,x,c)=>{const T=l[u];return T.attrSet("target","_blank"),T.attrSet("rel","noreferrer noopener"),typeof n=="function"?n(l,u,m,x,c):c.renderToken(l,u,m)},t.renderer.rules.table_open=(l,u,m,x,c)=>`<div class="codex-table-wrap">${typeof o=="function"?o(l,u,m,x,c):c.renderToken(l,u,m)}`,t.renderer.rules.table_close=(l,u,m,x,c)=>`${typeof s=="function"?s(l,u,m,x,c):c.renderToken(l,u,m)}</div>`,e.captureFences?t.renderer.rules.fence=(l,u,m,x={},c)=>{const T=l[u],v=Array.isArray(x.__promptxFences)?x.__promptxFences:[],g=v.length,p=`${mc}${g}__`;return v.push({content:String((T==null?void 0:T.content)||""),language:String((T==null?void 0:T.info)||"").trim().split(/\s+/)[0]||"",placeholder:p}),x.__promptxFences=v,p}:typeof r=="function"&&(t.renderer.rules.fence=r),t}const hc=ea({captureFences:!0}),vc=ea();async function yc(e="",t="",n={}){const o=String(e||"").replace(/\r\n/g,`
13
+ `),s=Zr(t),r=Qs(s),u=(await dc(o.split(`
14
+ `),{isDark:!!n.isDark,language:r||s})).join(`
15
+ `),m=s?` class="language-${Ts(s)}"`:"",x=gc(t),c=Ts(String(n.copyLabel||"Copy")),T=Ts(String(n.copyAriaLabel||c)),g=`<div class="codex-code-block__header">${x?`<span class="codex-code-block__language">${Ts(x)}</span>`:'<span class="codex-code-block__language-placeholder" aria-hidden="true"></span>'}<button type="button" class="codex-code-block__copy" data-copy-code="1" aria-label="${T}">${c}</button></div>`;return`<div class="${x?"codex-code-block codex-code-block--labeled":"codex-code-block"}">${g}<pre><code${m}>${u}</code></pre></div>`}async function Sc(e="",t=[],n={}){if(!Array.isArray(t)||!t.length)return e;const o=await Promise.all(t.map(s=>yc(s.content,s.language,n)));return t.reduce((s,r,l)=>s.replace(r.placeholder,o[l]||r.placeholder),e)}async function wc(e="",t={}){const n=String(e||"").trim();if(!n)return"";const o={},s=hc.render(n,o);return Sc(s,o.__promptxFences||[],t)}function ta(e=""){const t=String(e||"").trim();return t?vc.render(t):""}function xc(e=""){let t=5381;for(const n of String(e||""))t=(t<<5)+t+n.charCodeAt(0),t|=0;return String(t>>>0)}function Zo(e={}){const t=String((e==null?void 0:e.id)||"").trim();return t?`id:${t}`:`${(e==null?void 0:e.type)||"block"}:${xc(JSON.stringify(e||{}))}`}function bc(e=[]){const t=Array.isArray(e)?e:[],n=t.reduce((s,r)=>{const l=Zo(r);return s.set(l,(s.get(l)||0)+1),s},new Map),o=new Map;return t.map(s=>{const r=Zo(s),l=(o.get(r)||0)+1;return o.set(r,l),{key:`${r}:${l}`,signature:r,occurrence:l,duplicateCount:n.get(r)||1}})}const kc={key:0,class:"process-detail min-w-0 w-full max-w-full space-y-2"},Tc={key:0,class:"process-detail-meta"},_c={key:0,class:"process-detail-meta__label"},Cc={key:1,class:"process-detail-panel"},Ec={class:"space-y-1.5"},Ac={key:1,class:"process-detail-checklist__dot"},Ic={key:0,class:"process-detail-footnote"},$c={key:0},Pc={key:2,class:"process-detail-panel"},Dc={class:"process-detail-directory__heading"},Lc={key:0,class:"font-medium"},Mc={key:1,class:"process-detail-directory__type"},Bc={class:"process-detail-directory__list"},Rc={key:0,class:"process-detail-footnote"},Nc={key:0},Oc={key:3,class:"process-detail-panel"},Fc={class:"list-disc min-w-0 w-full max-w-full space-y-1.5 pl-5"},Uc={key:0,class:"process-detail-footnote"},jc={key:4,class:"process-detail-panel"},Vc={class:"space-y-1.5"},zc={class:"process-detail-filechange__kind"},Hc={class:"process-detail-filechange__path process-detail-mobile-code-scroll"},qc={key:5,class:"process-detail-panel"},Kc={class:"space-y-2"},Wc={class:"flex min-w-0 items-center gap-2 text-xs leading-5"},Gc={class:"min-w-0 flex flex-1 items-center gap-2"},Xc={class:"shrink-0 font-medium text-[var(--theme-textPrimary)]"},Yc=["title"],Jc=["onClick"],Qc={class:"process-detail-directory__type shrink-0"},Zc={key:0,class:"mt-2 border-l border-dashed border-[var(--theme-borderDefault)] pl-3"},ed={key:1,class:"whitespace-pre-wrap break-words text-xs leading-5"},td=["innerHTML"],nd={key:7,class:"process-detail-text"},sd=Object.assign({name:"ProcessDetailRenderer"},{__name:"ProcessDetailRenderer",props:{blocks:{type:Array,default:()=>[]},kind:{type:String,default:""},detail:{type:String,default:""}},setup(e){const t=e,{t:n}=At(),o=z(new Set),s=G(()=>{const P=Array.isArray(t.blocks)?t.blocks.filter(Boolean):[];return P.length?P:String(t.detail||"").trim()?[{type:"text",text:String(t.detail||"").trim()}]:[]}),r=G(()=>bc(s.value)),l=G(()=>r.value.map(P=>P.key));Ae(s,(P=[])=>{const ee=new Set;P.forEach((le,Q)=>{(le==null?void 0:le.type)==="sub_agent_list"&&(Array.isArray(le.items)?le.items:[]).forEach((he,A)=>{ee.add(te(Q,he,A))})}),o.value=new Set([...o.value].filter(le=>ee.has(le)))},{immediate:!0});function u(P=""){return ta(String(P||""))}function m(P=""){const ee=String(P||"").trim();return n(ee==="create"?"processDetail.changeCreate":ee==="delete"?"processDetail.changeDelete":ee==="update"?"processDetail.changeUpdate":"processDetail.changeGeneric")}function x(P={}){const ee=String((P==null?void 0:P.label)||"").trim().toLowerCase(),le=String((P==null?void 0:P.value)||"").trim();return le?le.length>56||["命令","command","目标","target","url","路径","path"].includes(ee)&&le.length>28?!0:le.includes(" ")&&le.length>36:!1}function c(P={},ee=[]){const le=String((P==null?void 0:P.label)||"").trim().toLowerCase();return["命令","command"].includes(le)?Array.isArray(ee)&&ee.length===1:!1}function T(P={}){const ee=String((P==null?void 0:P.label)||"").trim().toLowerCase();return["命令","command","路径","path","url","目标","target"].includes(ee)}function v(P={}){return P!=null&&P.completed?"completed":String((P==null?void 0:P.status)||"").trim().toLowerCase()==="in_progress"?"in_progress":"pending"}function g(P=0){return n("processDetail.hiddenItems",{count:P})}function p(P=0){return n("processDetail.directorySummary",{count:P})}function $(P=0){return n("processDetail.directoryHidden",{count:P})}function Z(P=0){return l.value[P]||`block-${P}`}function S(P=""){const ee=String(P||"").trim().toLowerCase();return n(ee==="completed"?"processDetail.subAgentCompleted":ee==="failed"?"processDetail.subAgentFailed":ee==="running"?"processDetail.subAgentRunning":ee==="pending_init"?"processDetail.subAgentPending":"processDetail.subAgentUnknown")}function B(P={}){return String((P==null?void 0:P.title)||(P==null?void 0:P.target)||(P==null?void 0:P.id)||"").trim()}function K(P={}){const ee=B(P),le=[],Q=String((P==null?void 0:P.role)||"").trim(),he=String((P==null?void 0:P.target)||"").trim(),A=String((P==null?void 0:P.model)||"").trim();return Q&&Q.toLowerCase()!=="default"&&le.push(Q),he&&he!==ee&&le.push(he),A&&le.push(A),le.join(" · ")}function j(P={}){return!!String((P==null?void 0:P.message)||"").trim()}function R(P={}){const ee=String((P==null?void 0:P.message)||"").replace(/\s+/g," ").trim();return ee||K(P)}function te(P=0,ee={},le=0){return`${Z(P)}:sub-agent:${String((ee==null?void 0:ee.id)||(ee==null?void 0:ee.target)||(ee==null?void 0:ee.title)||le)}`}function E(P=0,ee={},le=0){return o.value.has(te(P,ee,le))}function Y(P=0,ee={},le=0){const Q=te(P,ee,le),he=new Set(o.value);he.has(Q)?he.delete(Q):he.add(Q),o.value=he}function pe(P={}){return Array.isArray(P==null?void 0:P.messageBlocks)?P.messageBlocks.filter(Boolean):[]}function ge(P={}){return pe(P).some(le=>!["text","markdown"].includes(String((le==null?void 0:le.type)||"").trim()))}return(P,ee)=>{const le=Ra("ProcessDetailRenderer",!0);return s.value.length?(h(),k("div",kc,[(h(!0),k(rt,null,ct(s.value,(Q,he)=>(h(),k(rt,{key:l.value[he]||`${Q.type}-${he}`},[Q.type==="meta"?(h(),k("div",Tc,[(h(!0),k(rt,null,ct(Q.items||[],(A,X)=>(h(),k("div",{key:`${he}-meta-${X}`,class:xe(["process-detail-meta__item",{"process-detail-meta__item--long":x(A),"process-detail-meta__item--value-only":c(A,Q.items)}])},[c(A,Q.items)?fe("",!0):(h(),k("span",_c,b(A.label),1)),i("span",{class:xe(["process-detail-meta__value",{"process-detail-mobile-code-scroll":x(A),"process-detail-meta__value--mono":T(A)}])},b(A.value),3)],2))),128))])):Q.type==="checklist"?(h(),k("div",Cc,[i("div",Ec,[(h(!0),k(rt,null,ct(Q.items||[],(A,X)=>(h(),k("div",{key:`${he}-check-${X}`,class:"process-detail-checklist__item"},[i("span",{class:xe(["process-detail-checklist__icon",`is-${v(A)}`])},[v(A)==="completed"?(h(),Ee(a(Br),{key:0,class:"h-3 w-3"})):v(A)==="in_progress"?(h(),k("span",Ac)):fe("",!0)],2),i("span",{class:xe(v(A)==="completed"?"line-through":"")},b(A.text),3)]))),128))]),Q.totalCount?(h(),k("div",Ic,[Sn(b(`已完成 ${(Q.items||[]).filter(A=>A.completed).length} / ${Q.totalCount}`)+" ",1),Q.hiddenCount?(h(),k("span",$c,b(`,还有 ${Q.hiddenCount} 项`),1)):fe("",!0)])):fe("",!0)])):Q.type==="directory_list"?(h(),k("div",Pc,[i("div",Dc,[Q.path?(h(),k("span",Lc,b(Q.path),1)):fe("",!0),Q.entryType?(h(),k("span",Mc,b(Q.entryType),1)):fe("",!0)]),i("div",Bc,[(h(!0),k(rt,null,ct(Q.entries||[],(A,X)=>(h(),k("div",{key:`${he}-entry-${X}`,class:"process-detail-directory__item"},b(A),1))),128))]),Q.totalCount?(h(),k("div",Rc,[Sn(b(p(Q.totalCount))+" ",1),Q.hiddenCount?(h(),k("span",Nc,b($(Q.hiddenCount)),1)):fe("",!0)])):fe("",!0)])):Q.type==="bullet_list"?(h(),k("div",Oc,[i("ul",Fc,[(h(!0),k(rt,null,ct(Q.items||[],(A,X)=>(h(),k("li",{key:`${he}-bullet-${X}`,class:"min-w-0 w-full max-w-full break-words [overflow-wrap:anywhere]"},b(A),1))),128))]),Q.hiddenCount?(h(),k("div",Uc,b(g(Q.hiddenCount)),1)):fe("",!0)])):Q.type==="file_changes"?(h(),k("div",jc,[i("div",Vc,[(h(!0),k(rt,null,ct(Q.items||[],(A,X)=>(h(),k("div",{key:`${he}-change-${X}`,class:"process-detail-filechange__item"},[i("span",zc,b(m(A.kind)),1),i("span",Hc,b(A.path),1)]))),128))])])):Q.type==="sub_agent_list"?(h(),k("div",qc,[i("div",Kc,[(h(!0),k(rt,null,ct(Q.items||[],(A,X)=>(h(),k("div",{key:`${he}-sub-agent-${X}`,class:"min-w-0"},[i("div",Wc,[i("div",Gc,[i("span",Xc,b(B(A)),1),R(A)?(h(),k("span",{key:0,class:"process-detail-subagent__preview min-w-0 flex-1",title:R(A)},b(R(A)),9,Yc)):fe("",!0)]),j(A)?(h(),k("button",{key:0,type:"button",class:"shrink-0 text-[11px] underline decoration-dashed underline-offset-2",onClick:I=>Y(he,A,X)},b(E(he,A,X)?a(n)("common.collapse"):a(n)("common.expand")),9,Jc)):fe("",!0),i("span",Qc,b(S(A.status)),1)]),j(A)&&E(he,A,X)?(h(),k("div",Zc,[ge(A)?(h(),Ee(le,{key:0,blocks:pe(A),kind:"sub-agent-message"},null,8,["blocks"])):(h(),k("pre",ed,b(A.message),1))])):fe("",!0)]))),128))])])):Q.type==="markdown"?(h(),k("div",{key:6,class:xe(["codex-markdown process-detail-markdown",{"process-detail-markdown--reasoning":t.kind==="reasoning"}]),innerHTML:u(Q.text)},null,10,td)):(h(),k("pre",nd,b(Q.text),1))],64))),128))])):fe("",!0)}}}),na={__name:"SelectionInsertButton",props:{label:{type:String,default:""},top:{type:Number,default:0},left:{type:Number,default:0}},emits:["click"],setup(e,{emit:t}){function n(s){var r,l;typeof(s==null?void 0:s.button)=="number"&&s.button!==0||((r=s==null?void 0:s.preventDefault)==null||r.call(s),(l=s==null?void 0:s.stopPropagation)==null||l.call(s),o("click"))}const o=t;return(s,r)=>(h(),k("button",{type:"button",class:"tool-button tool-button-primary absolute z-20 inline-flex items-center gap-2 px-3 py-1.5 text-xs shadow-sm",style:Bn({top:`${e.top}px`,left:`${e.left}px`}),onPointerdown:n,onKeydown:[r[0]||(r[0]=en(et(l=>o("click"),["prevent"]),["enter"])),r[1]||(r[1]=en(et(l=>o("click"),["prevent"]),["space"]))]},b(e.label),37))}},sa=96,er=34,yn=8,od=72;function rd(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement||null:null}function tr(e,t,n){var r;const o=rd(e);if(!o||!n)return null;const s=(r=o.closest)==null?void 0:r.call(o,t);return s&&n.contains(s)?s:null}function ad(e){const t=(e==null?void 0:e.commonAncestorContainer)||null;return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentNode||null:null}function id(e,t,{codeLeft:n=0,buttonWidth:o=sa,scrollTop:s=0,scrollLeft:r=0,clientWidth:l=0,clientHeight:u=0}={}){const x=Math.max(e.left||0,Number(n)||0)-t.left+r,c=r+yn,T=r+Math.max(yn,l-o-yn),v=Math.max(c,Math.min(T,x||r+yn)),g=e.bottom-t.top+s+yn,p=e.top-t.top+s-er-yn,$=s+yn,Z=s+u-yn;return{top:g+er<=Z?g:Math.max($,p),left:v}}function oa(e={}){const t=z([]),n=z({visible:!1,top:0,left:0,content:""});let o=null,s=0;function r(){var j;return typeof e.getContainer=="function"?e.getContainer():((j=e.containerRef)==null?void 0:j.value)||null}function l(){return typeof e.getPositionContainer=="function"?e.getPositionContainer():r()}function u(){o&&(window.clearTimeout(o),o=null)}function m(){s&&(window.cancelAnimationFrame(s),s=0)}function x(j=[]){var R;t.value=j,(R=e.onSelectedRowsChange)==null||R.call(e,j)}function c({clearBrowserSelection:j=!1}={}){var R,te,E,Y;u(),m(),j&&((E=(te=(R=window.getSelection)==null?void 0:R.call(window))==null?void 0:te.removeAllRanges)==null||E.call(te)),n.value={visible:!1,top:0,left:0,content:""},x([]),(Y=e.onClear)==null||Y.call(e)}function T(j){return j?typeof e.getOrderedRowElements=="function"?e.getOrderedRowElements(j).filter(Boolean):[...j.querySelectorAll(String(e.rowSelector||""))]:[]}function v(j){var R;return((R=e.mapRowElement)==null?void 0:R.call(e,j))??j}function g(j,R,te){const E=String(e.rowSelector||"").trim(),Y=T(te);if(!E||!Y.length)return[];const pe=tr(j.anchorNode,E,te),ge=tr(j.focusNode,E,te);if(pe&&ge){const P=Y.indexOf(pe),ee=Y.indexOf(ge);if(P>=0&&ee>=0){const[le,Q]=P<=ee?[P,ee]:[ee,P];return Y.slice(le,Q+1)}}return Y.filter(P=>{try{return R.intersectsNode(P)}catch{return!1}})}function p(){var X,I,_e;const j=(X=window.getSelection)==null?void 0:X.call(window),R=r(),te=l();if(!(typeof e.isActive=="function"?e.isActive():!0)||!j||j.rangeCount<1||j.isCollapsed||!R||!te){c();return}const Y=j.getRangeAt(0),pe=ad(Y);if(!pe||!R.contains(pe)){c();return}const ge=String(j.toString()||"").replace(/\u200b/g,"");if(!ge.trim()){c();return}const P=g(j,Y,R);if(!P.length){c();return}const ee=P.map(Me=>v(Me)).filter(Me=>Me!==null&&typeof Me<"u");if(!ee.length){c();return}const le=Y.getBoundingClientRect(),Q=(I=te.getBoundingClientRect)==null?void 0:I.call(te);if(!Q){c();return}const he=((_e=e.getCodeLeft)==null?void 0:_e.call(e,P[0]))||le.left,A=id(le,Q,{codeLeft:he,buttonWidth:Number(e.buttonWidth||sa),scrollTop:Number(te.scrollTop||0),scrollLeft:Number(te.scrollLeft||0),clientWidth:Number(te.clientWidth||0),clientHeight:Number(te.clientHeight||0)});n.value={visible:!0,top:A.top,left:A.left,content:ge},x(ee)}function $(){u(),o=window.setTimeout(()=>{o=null,p()},Number(e.debounceMs||od))}function Z(){$()}function S(){$()}function B(){!n.value.visible||s||(s=window.requestAnimationFrame(()=>{s=0,p()}))}function K(){B()}return fn(()=>{var j,R,te,E;document.addEventListener("selectionchange",S),document.addEventListener("mouseup",S),document.addEventListener("scroll",K,!0),window.addEventListener("resize",K),(R=(j=window.visualViewport)==null?void 0:j.addEventListener)==null||R.call(j,"resize",K),(E=(te=window.visualViewport)==null?void 0:te.addEventListener)==null||E.call(te,"scroll",K)}),Nt(()=>{var j,R,te,E;c({clearBrowserSelection:!0}),document.removeEventListener("selectionchange",S),document.removeEventListener("mouseup",S),document.removeEventListener("scroll",K,!0),window.removeEventListener("resize",K),(R=(j=window.visualViewport)==null?void 0:j.removeEventListener)==null||R.call(j,"resize",K),(E=(te=window.visualViewport)==null?void 0:te.removeEventListener)==null||E.call(te,"scroll",K)}),{selectedRows:t,selectionAction:n,clearSelectionState:c,clearScheduledSelectionUpdate:u,handleSelectionMouseUp:Z,scheduleSelectionUpdate:$,updateSelectionActionFromDom:p}}const ld=250,ud=350,cd=180,Ps=2;function ra(e){return(e==null?void 0:e.name)==="AbortError"}const fo="promptx:codex-recent-paths",dd=12;function aa(e){const{getMode:t,props:n,onSelect:o}=e,s=z([]),r=z(!1),l=z(""),u=z([]),m=z(!1),x=z(""),c=z([]),T=z([]),v=z("tree"),g=z(""),p=new Map;let $=null,Z=0,S=0,B=null;const K=G(()=>String(n.query||"").trim()),j=G(()=>Math.max(1,Number(e.minimumQueryLength)||Ps)),R=G(()=>K.value.length>=j.value),te=G(()=>typeof t=="function"),E=G(()=>te.value?String((t==null?void 0:t())||"").trim()==="search"?"search":"tree":v.value),Y=G(()=>Ge(s.value)),pe=G(()=>String(n.sessionId||"").trim()),ge=G(()=>pe.value?`promptx:codex-tree-expanded:${pe.value}`:""),P=G(()=>{if(!K.value)return c.value;const H=new Set(u.value.map(J=>J.path));return c.value.filter(J=>H.has(J.path))}),ee=G(()=>{const H=new Set(P.value.map(J=>J.path));return u.value.filter(J=>!H.has(J.path))}),le=G(()=>K.value?[...P.value,...ee.value]:c.value),Q=G(()=>E.value==="search"?le.value:Y.value),he=G(()=>E.value==="search"?m.value:r.value),A=G(()=>E.value==="search"?x.value:l.value),X=G(()=>E.value==="search"&&!!n.sessionId&&R.value&&!m.value&&!x.value&&!le.value.length),I=G(()=>E.value==="search"&&!!n.sessionId&&!!K.value&&!R.value&&!m.value&&!x.value),_e=G(()=>E.value==="tree"&&!!n.sessionId&&!r.value&&!l.value&&!Y.value.length);function Me(H,J){if(!H||typeof window>"u")return J;try{const ce=window.localStorage.getItem(H);return ce?JSON.parse(ce):J}catch{return J}}function Re(H,J){if(!(!H||typeof window>"u"))try{window.localStorage.setItem(H,JSON.stringify(J))}catch{}}function Ne(H=[]){return[...H].sort((J,ce)=>{const ve=+(J.type!=="directory")-+(ce.type!=="directory");return ve||String(J.path||J.name||"").localeCompare(String(ce.path||ce.name||""),"zh-CN")})}function Ve(H){return{...H,children:[],expanded:!1,loaded:!1,loading:!1}}function Ge(H=[],J=0,ce=[]){return H.forEach(ve=>{ce.push({...ve,depth:J}),ve.type==="directory"&&ve.expanded&&ve.children.length&&Ge(ve.children,J+1,ce)}),ce}function Te(H,J=s.value){for(const ce of J){if(ce.path===H)return ce;if(ce.children.length){const ve=Te(H,ce.children);if(ve)return ve}}return null}function W(){s.value=[...s.value]}function ae(){$&&(window.clearTimeout($),$=null),B&&(B.abort(),B=null)}function de(H=s.value,J=[]){return H.forEach(ce=>{ce.type==="directory"&&ce.expanded&&(J.push(ce.path),ce.children.length&&de(ce.children,J))}),J}function $e(){if(!ge.value)return;const H=[...new Set(de())];T.value=H,Re(ge.value,H)}function ye(){T.value=ge.value?Me(ge.value,[]).filter(Boolean):[]}function Le(H=s.value,J=new Set){if(!J.size)return!1;const ce=H.filter(ve=>ve.type==="directory"&&ve.hasChildren).map(ve=>ve.path);return!ce.length||ce.length!==J.size?!1:ce.every(ve=>J.has(ve))}function me(){const H=Me(fo,[]);if(!Array.isArray(H)||!pe.value){c.value=[];return}c.value=H.filter(J=>J&&J.sessionId===pe.value&&J.path).sort((J,ce)=>Number(ce.usedAt||0)-Number(J.usedAt||0)).slice(0,dd)}function De(H){return H.name||H.path||"."}function ze(H){return H.path||"."}function Ie(H){if(!pe.value||!(H!=null&&H.path))return;const J={sessionId:pe.value,path:H.path,name:H.name||De(H),type:H.type||"file",usedAt:Date.now()},ce=Me(fo,[]),ve=[J];Array.isArray(ce)&&ce.forEach(qe=>{!(qe!=null&&qe.path)||!(qe!=null&&qe.sessionId)||qe.sessionId===J.sessionId&&qe.path===J.path||ve.push(qe)}),Re(fo,ve.slice(0,40)),me()}function gt(H=""){const J=String(H||"").trim();return!J||!J.includes("/")?"":J.slice(0,J.lastIndexOf("/"))}function We(){const H=Q.value;if(!H.length)return-1;const J=H.findIndex(ce=>ce.path===g.value);return J>=0?J:0}function lt(){const H=Q.value,J=We();return J<0||!H.length?null:H[J]||null}function ht(){const H=Q.value;if(!H.length){g.value="";return}H.some(J=>J.path===g.value)||(g.value=H[0].path)}function vt(H,J){if(J){p.set(H,J);return}p.delete(H)}function Oe(){var J;const H=p.get(g.value);(J=H==null?void 0:H.scrollIntoView)==null||J.call(H,{block:"nearest"})}function Ce(H=""){return String(H||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function dt(H="",J=""){const ce=String(H||""),ve=String(J||"").trim().toLowerCase();if(!ce||!ve)return null;const qe=ce.toLowerCase(),ft=qe.indexOf(ve);if(ft>=0)return{start:ft,end:ft+ve.length};const Ot=ve.split(/[\\/\s_.-]+/).filter(Boolean).sort((Vt,$t)=>$t.length-Vt.length);for(const Vt of Ot){if(Vt.length<2)continue;const $t=qe.indexOf(Vt);if($t>=0)return{start:$t,end:$t+Vt.length}}return null}function ut(H="",J=""){const ce=String(H||""),ve=dt(ce,J);return ve?`${Ce(ce.slice(0,ve.start))}<mark class="theme-search-highlight">${Ce(ce.slice(ve.start,ve.end))}</mark>${Ce(ce.slice(ve.end))}`:Ce(ce)}function D(H){return ut(De(H),K.value)}function N(H){return ut(ze(H),K.value)}async function se(H="",J={}){if(!n.sessionId){s.value=[],l.value="",r.value=!1;return}const ce=!H,ve=ce?null:Te(H);if(!(!ce&&!ve)&&!(!J.force&&(ce&&s.value.length||!ce&&ve.loaded))){ce?(r.value=!0,l.value=""):(ve.loading=!0,l.value="",W());try{const qe=await fl(n.sessionId,{path:H,refreshToken:J.refreshToken||""}),ft=Ne(qe.items||[]).map(Ve);if(ce){s.value=ft;return}ve.children=ft,ve.loaded=!0}catch(qe){l.value=qe.message}finally{ce?r.value=!1:(ve.loading=!1,W())}}}async function be(H=s.value,J=new Set,ce={}){for(const ve of H)ve.type!=="directory"||!J.has(ve.path)||(ve.expanded=!0,W(),await se(ve.path,ce),ve.children.length&&await be(ve.children,J,ce))}async function Fe(H={}){await se("",H);const J=new Set(T.value),ce=Le(s.value,J),ve=J.size>0&&!ce;ce&&(T.value=[],Re(ge.value,[]),J.clear());for(const qe of s.value)qe.type!=="directory"||!qe.hasChildren||(qe.expanded=ve?J.has(qe.path):!1);if(W(),ve){await be(s.value,J,H);return}}async function Pe(H){if(E.value!=="tree")return;const J=Te(H);if(!(!J||J.type!=="directory")){if(!J.loaded&&!J.loading){J.expanded=!0,W(),await se(J.path),$e();return}J.expanded=!J.expanded,W(),$e()}}function Qe(H){return H!=null&&H.path?(Ie(H),o==null||o(H),!0):!1}async function nt(H={}){const J=K.value;Z+=1;const ce=Z,ve=H.refreshToken||"";if(ae(),!n.open||!n.sessionId||!J||!R.value){m.value=!1,x.value="",u.value=[];return}B=new AbortController;try{const qe=await pl(n.sessionId,J,{limit:80,refreshToken:ve,signal:B.signal});if(ce!==Z)return;u.value=qe.items||[]}catch(qe){if(ra(qe)||ce!==Z)return;x.value=qe.message,u.value=[]}finally{ce===Z&&(B=null),ce===Z&&(m.value=!1)}}function Tt(H={}){if(ae(),!n.open||!n.sessionId||!K.value||!R.value){m.value=!1,x.value="",u.value=[];return}m.value=!0,x.value="",$=window.setTimeout(()=>{$=null,nt(H)},ld)}function mt(){if(!n.sessionId){s.value=[],l.value="",r.value=!1,u.value=[],x.value="",m.value=!1;return}S=Date.now(),s.value=[],l.value="",u.value=[],x.value="",Fe({force:!0,refreshToken:S}),Tt({refreshToken:S})}function _t(){if(te.value)return!1;const H=K.value?"search":"tree";return v.value===H?!1:(v.value=H,!0)}function yt(){me(),ye(),_t(),mt()}function It(){ae(),u.value=[],x.value="",m.value=!1}function Yt(H){const J=Q.value;if(!J.length)return!1;const ce=We(),ve=ce<0?0:(ce+H+J.length)%J.length;return g.value=J[ve].path,it(Oe),!0}async function Gt(){if(E.value!=="tree")return!1;const H=lt();if(!H||H.type!=="directory")return!1;if(!H.expanded)return await Pe(H.path),g.value=H.path,!0;const J=Q.value,ce=We(),ve=J[ce+1];return ve&&gt(ve.path)===H.path?(g.value=ve.path,!0):!1}function re(){if(E.value!=="tree")return!1;const H=lt();if(!H)return!1;if(H.type==="directory"&&H.expanded){const ce=Te(H.path);return ce&&(ce.expanded=!1,W(),$e()),g.value=H.path,!0}const J=gt(H.path);return J?(g.value=J,!0):!1}function Be(){const H=Q.value;return H.length?Qe(H[We()]):!1}function ot(){s.value=[],l.value="",r.value=!1,u.value=[],x.value="",m.value=!1,me(),ye(),n.sessionId&&n.open&&(Fe({force:!0}),Tt())}function Je(){_t(),Tt()}function Lt(){ht(),it(Oe)}return Nt(()=>{ae()}),{activeKey:g,collapseActiveDirectory:re,confirmActive:Be,currentError:A,currentLoading:he,emitSelect:Qe,expandActiveDirectory:Gt,getDisplayName:De,getHighlightedName:D,getHighlightedPath:N,handleQueryChange:Je,handleSessionChange:ot,handleVisibleItemsChange:Lt,initializeData:yt,moveActive:Yt,normalSearchItems:ee,normalizedQuery:K,recentSearchItems:P,resetData:It,setItemRef:vt,showSearchPromptState:I,showSearchEmptyState:X,showTreeEmptyState:_e,toggleDirectory:Pe,treeItems:Y,visibleItems:Q}}const fd={class:"min-w-0"},pd={class:"theme-heading truncate text-sm font-medium"},md={class:"source-browser-layout grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[21rem_minmax(0,1fr)]"},gd={class:"theme-divider border-b px-4 py-3"},hd={class:"block"},vd={class:"sr-only"},yd={class:"relative"},Sd=["placeholder","onKeydown"],wd=["title","aria-label"],xd={class:"min-h-0 flex-1 overflow-y-auto p-2"},bd={key:0,class:"theme-empty-state px-3 py-4 text-[12px]"},kd={key:1,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},Td={key:2,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},_d={key:3,class:"theme-empty-state px-3 py-4 text-[12px]"},Cd={key:4,class:"theme-empty-state px-3 py-4 text-[12px]"},Ed={key:5,class:"theme-empty-state px-3 py-4 text-[12px]"},Ad={key:6,class:"theme-empty-state px-3 py-4 text-[12px]"},Id={key:7,class:"theme-empty-state px-3 py-4 text-[12px]"},$d={key:8,class:"theme-empty-state px-3 py-4 text-[12px]"},Pd={key:9,class:"theme-empty-state px-3 py-4 text-[12px]"},Dd={key:10,class:"theme-empty-state px-3 py-4 text-[12px]"},Ld={key:11,class:"space-y-1"},Md={key:0,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},Bd=["onClick"],Rd={class:"min-w-0 flex-1"},Nd=["innerHTML"],Od=["innerHTML"],Fd={key:1,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},Ud=["onClick"],jd={class:"min-w-0 flex-1"},Vd=["innerHTML"],zd=["innerHTML"],Hd={key:12,class:"space-y-3"},qd={class:"theme-divider flex items-start gap-2.5 border-b px-3 py-2.5"},Kd={class:"min-w-0 flex-1"},Wd={class:"theme-list-item-title theme-list-item-title--strong break-all"},Gd={key:0,class:"theme-list-item-meta truncate"},Xd={class:"theme-list-item-meta shrink-0 pt-0.5"},Yd={class:"space-y-1 px-2 py-2"},Jd=["onClick"],Qd=["innerHTML"],Zd={key:0,class:"theme-muted-text px-1 text-[12px]"},ef={key:13,class:"space-y-1"},tf=["onClick"],nf={class:"flex items-start gap-1.5"},sf=["onClick"],of={key:1,class:"block h-5 w-5 shrink-0"},rf=["onClick"],af={class:"flex min-h-0 flex-col overflow-hidden"},lf={class:"theme-divider border-b px-4 py-2"},uf={class:"flex items-center justify-between gap-3"},cf={class:"min-w-0"},df={key:0,class:"theme-muted-text truncate text-[12px]"},ff={key:1,class:"theme-muted-text mt-1 text-[11px]"},pf={class:"min-h-0 flex-1 overflow-auto px-4 py-3"},mf={key:0,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},gf={key:1,class:"theme-status-danger rounded-sm border px-4 py-3 text-[12px]"},hf={key:2,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},vf={key:3,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},yf={key:4,class:"source-browser-image-wrap flex h-full min-h-[12rem] items-center justify-center overflow-hidden rounded-sm border p-4"},Sf=["src","alt"],wf={key:5,class:"theme-empty-state flex h-full min-h-[12rem] flex-col items-center justify-center gap-3 text-[12px]"},xf={class:"source-code-view"},bf={class:"source-code-view__table"},kf=["innerHTML"],Tf=20,_f={__name:"CodexSessionSourceBrowserDialog",props:{open:{type:Boolean,default:!1},session:{type:Object,default:null},initialSearchQuery:{type:String,default:""}},emits:["close","insert-code-context"],setup(e,{expose:t,emit:n}){const o=e,s=n,{t:r}=At(),{isDark:l}=Dr(),u=Ss({open:!1,sessionId:"",query:""}),m=z(""),x=z(""),c=z(!1),T=z(""),v=z(null),g=z(""),p=z("path"),$=z([]),Z=z(!1),S=z(""),B=z(""),K=z(!1),j=z(""),R=new Map,te=z(null),E=z(null),Y=z(0),pe=z([]),ge=z("");let P=0,ee=0,le=null,Q=null;const he=ud,A=cd;let X=null;const I=new Map,_e=G(()=>{var d;return String(((d=o.session)==null?void 0:d.id)||"").trim()}),Me=G(()=>{var d;return String(((d=o.session)==null?void 0:d.cwd)||"").trim()}),Re=G(()=>p.value!=="content"),Ne=G(()=>p.value==="content"),Ve=G(()=>String(g.value||"").trim()),Ge=G(()=>Ve.value.length>=Ps),Te=G(()=>{var d;return((d=v.value)==null?void 0:d.name)||m.value||""}),W=G(()=>{var d;return((d=v.value)==null?void 0:d.path)||m.value||""}),ae=G(()=>{var d;return C(((d=v.value)==null?void 0:d.size)||0)}),de=G(()=>{var M,U;const d=[];return(W.value||Te.value)&&d.push(W.value||Te.value),(M=v.value)!=null&&M.size&&d.push(ae.value),(U=v.value)!=null&&U.truncated&&d.push(r("sourceBrowser.truncated")),d.join(" ")}),$e=G(()=>{var d;return!!((d=v.value)!=null&&d.previewUrl)}),ye=G(()=>{var d,M;return!!((d=v.value)!=null&&d.binary&&!((M=v.value)!=null&&M.previewUrl))}),Le=G(()=>!!(v.value&&!v.value.binary&&!v.value.previewUrl)),me=z(""),De=z(""),ze=z(""),Ie=z("2.6rem"),{selectedRows:gt,selectionAction:We,clearSelectionState:lt,handleSelectionMouseUp:ht,updateSelectionActionFromDom:vt}=oa({getContainer:()=>E.value,isActive:()=>o.open&&Le.value,rowSelector:".source-code-view__line",mapRowElement:d=>{var U;const M=Number(((U=d==null?void 0:d.getAttribute)==null?void 0:U.call(d,"data-line"))||0);return M>0?M:null},getCodeLeft:d=>{var ke,He,je;const M=(ke=d==null?void 0:d.querySelector)==null?void 0:ke.call(d,".source-code-view__code");if(!M)return 0;const U=(He=M.getBoundingClientRect)==null?void 0:He.call(M),F=(je=window.getComputedStyle)==null?void 0:je.call(window,M),ie=Number.parseFloat((F==null?void 0:F.paddingLeft)||"0")||0;return((U==null?void 0:U.left)||0)+ie},debounceMs:72}),Oe=G(()=>[...new Set(gt.value)].map(d=>Number(d)||0).filter(d=>d>0).sort((d,M)=>d-M)),Ce=G(()=>{var U;const d=String(((U=v.value)==null?void 0:U.content)||"").replace(/\r\n/g,`
16
+ `),M=d?d.split(`
17
+ `):[];return[...Oe.value].sort((F,ie)=>F-ie).map(F=>({lineNumber:F,content:String(M[F-1]||"")})).filter(F=>F.lineNumber>0)}),dt=G(()=>Ce.value.length>0),ut=G(()=>Ne.value?r("sourceBrowser.contentSearchPlaceholder"):r("sourceBrowser.searchPlaceholder")),D=G(()=>Ne.value?r("sourceBrowser.searchModeContent"):r("sourceBrowser.searchModePath")),N=G(()=>!!Ve.value),se=G(()=>N.value?"search":"tree"),be=G(()=>N.value&&Ne.value?Z.value:Be.value),Fe=G(()=>Re.value&&pn.value),Pe=G(()=>Re.value&&Mt.value),Qe=G(()=>N.value&&Ne.value&&!Ge.value&&!Z.value&&!S.value),nt=G(()=>N.value&&Ne.value&&Ge.value&&!!B.value&&!Z.value&&!S.value&&!$.value.length),Tt=G(()=>N.value&&Ne.value&&Ge.value&&!Z.value&&!S.value&&!B.value&&!$.value.length),mt=G(()=>{const d=[],M=new Map;return $.value.forEach(U=>{const F=String((U==null?void 0:U.path)||"").trim();if(!F)return;let ie=M.get(F);ie||(ie={path:F,name:String((U==null?void 0:U.name)||F.split("/").pop()||F),items:[]},M.set(F,ie),d.push(ie)),ie.items.push(U)}),d}),_t=G(()=>$.value.map(d=>Pt(d)).join("|")),yt=G(()=>Ht.value.map(d=>{const M=String((d==null?void 0:d.path)||"").trim(),U=d!=null&&d.expanded?1:0,F=d!=null&&d.loading?1:0;return`${M}:${U}:${F}`}).join("|")),{activeKey:It,collapseActiveDirectory:Yt,expandActiveDirectory:Gt,currentError:re,currentLoading:Be,getDisplayName:ot,getHighlightedName:Je,getHighlightedPath:Lt,handleQueryChange:H,handleSessionChange:J,handleVisibleItemsChange:ce,initializeData:ve,moveActive:qe,normalSearchItems:ft,recentSearchItems:Ot,resetData:Vt,setItemRef:$t,showSearchPromptState:Mt,showSearchEmptyState:pn,showTreeEmptyState:Ct,toggleDirectory:tn,treeItems:kn,visibleItems:Ht}=aa({getMode:()=>se.value,props:u,onSelect:_n});function Ft(d=""){return String(d||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Pt(d){return`${(d==null?void 0:d.path)||""}:${(d==null?void 0:d.line)||0}:${(d==null?void 0:d.column)||0}`}function mn(d,M){if(M){R.set(d,M);return}R.delete(d)}function rn(){var M;const d=R.get(j.value);(M=d==null?void 0:d.scrollIntoView)==null||M.call(d,{block:"nearest"})}function an(d="",M=""){const U=String(d||""),F=String(M||"").trim();if(!U||!F)return Ft(U);const ie=U.toLowerCase(),ke=F.toLowerCase(),He=ie.indexOf(ke);if(He<0)return Ft(U);const je=He+ke.length;return`${Ft(U.slice(0,He))}<mark class="theme-search-highlight">${Ft(U.slice(He,je))}</mark>${Ft(U.slice(je))}`}function gn(d="",M=""){const U=String(d||""),F=String(M||"").trim();if(!U||!F)return[];const ie=U.toLowerCase(),ke=F.toLowerCase(),He=[];let je=0;for(;je<ie.length;){const y=ie.indexOf(ke,je);if(y<0)break;He.push({start:y,end:y+ke.length}),je=y+ke.length}return He}function nn(d,M,U){if(!d)return null;if(d.nodeType===Node.TEXT_NODE){const ie=d.textContent||"",ke=U.offset,He=ke+ie.length;if(U.offset=He,!ie)return document.createTextNode("");const je=M.filter(Se=>Se.start<He&&Se.end>ke);if(!je.length)return document.createTextNode(ie);const y=document.createDocumentFragment();let q=0;return je.forEach(Se=>{const we=Math.max(0,Se.start-ke),Ye=Math.min(ie.length,Se.end-ke);if(we>q&&y.appendChild(document.createTextNode(ie.slice(q,we))),Ye>we){const st=document.createElement("mark");st.className="source-code-view__search-hit",st.textContent=ie.slice(we,Ye),y.appendChild(st)}q=Math.max(q,Ye)}),q<ie.length&&y.appendChild(document.createTextNode(ie.slice(q))),y}if(d.nodeType!==Node.ELEMENT_NODE)return d.cloneNode(!0);const F=d.cloneNode(!1);return Array.from(d.childNodes||[]).forEach(ie=>{const ke=nn(ie,M,U);ke&&F.appendChild(ke)}),F}function hn(d=E.value){var M,U,F;d&&((F=(U=(M=d.querySelectorAll)==null?void 0:M.call(d,".source-code-view__line-inner[data-original-html]"))==null?void 0:U.forEach)==null||F.call(U,ie=>{const ke=ie.dataset.originalHtml;typeof ke=="string"&&(ie.innerHTML=ke)}))}function sn(){var U,F,ie;const d=E.value,M=String(ge.value||"").trim();d&&(hn(d),M&&((ie=(F=(U=d.querySelectorAll)==null?void 0:U.call(d,".source-code-view__line.is-match .source-code-view__line-inner"))==null?void 0:F.forEach)==null||ie.call(F,ke=>{ke.dataset.originalHtml||(ke.dataset.originalHtml=ke.innerHTML);const He=gn(ke.textContent||"",M);if(!He.length)return;const je=document.createDocumentFragment(),y={offset:0};Array.from(ke.childNodes||[]).forEach(q=>{const Se=nn(q,He,y);Se&&je.appendChild(Se)}),ke.replaceChildren(je)})))}function C(d=0){const M=Math.max(0,Number(d)||0);return M<1024?`${M} B`:M<1024*1024?`${(M/1024).toFixed(M<10*1024?1:0)} KB`:`${(M/(1024*1024)).toFixed(1)} MB`}function w(){var M,U,F;const d=E.value;d&&(hn(d),(F=(U=(M=d.querySelectorAll)==null?void 0:M.call(d,".source-code-view__line.is-match, .source-code-view__line.is-focus-match"))==null?void 0:U.forEach)==null||F.call(U,ie=>ie.classList.remove("is-match","is-focus-match")))}function V(){var M,U,F;const d=E.value;d&&((F=(U=(M=d.querySelectorAll)==null?void 0:M.call(d,".source-code-view__line.is-selected"))==null?void 0:U.forEach)==null||F.call(U,ie=>ie.classList.remove("is-selected")))}function oe(){V();const d=E.value;!d||!Oe.value.length||Oe.value.forEach(M=>{var ie,ke;const U=d.querySelector(`.source-code-view__gutter[data-line="${M}"]`),F=(ie=U==null?void 0:U.closest)==null?void 0:ie.call(U,"tr");(ke=F==null?void 0:F.classList)==null||ke.add("is-selected")})}function f(){if(!Oe.value.length)return"";const d=[...Oe.value].sort((M,U)=>M-U);return d[0]===d[d.length-1]?`L${d[0]}`:`L${d[0]}-${d[d.length-1]}`}function _(){var M,U,F,ie;if(!v.value||!dt.value)return;const d=Ce.value.map(ke=>ke.lineNumber);s("insert-code-context",{source:"source",filePath:W.value,language:String(((M=v.value)==null?void 0:M.language)||""),rangeLabel:f(),lineStart:Math.min(...d),lineEnd:Math.max(...d),content:String(We.value.content||"").trim()||Ce.value.map(ke=>ke.content).join(`
18
+ `)}),(ie=(F=(U=window.getSelection)==null?void 0:U.call(window))==null?void 0:F.removeAllRanges)==null||ie.call(F),lt(),s("close")}function L(d){var He,je,y,q;const M=(He=window.getSelection)==null?void 0:He.call(window),U=E.value;if(!M||M.rangeCount<1||M.isCollapsed||!U)return;vt();const ie=M.getRangeAt(0).commonAncestorContainer;if(!U.contains((ie==null?void 0:ie.nodeType)===1?ie:ie==null?void 0:ie.parentNode))return;const ke=String(M.toString()||"").replace(/\u200b/g,"");ke&&((y=(je=d==null?void 0:d.clipboardData)==null?void 0:je.setData)==null||y.call(je,"text/plain",ke),(q=d==null?void 0:d.preventDefault)==null||q.call(d))}function ne(){X&&(window.clearTimeout(X),X=null)}function Ue(){I.clear()}function Bt(d=""){const M=String(d||"").trim();if(!M||!I.has(M))return null;const U=I.get(M);return I.delete(M),I.set(M,U),U}function qt(d="",M=null){const U=String(d||"").trim();if(!(!U||!M))for(I.delete(U),I.set(U,M);I.size>Tf;){const F=I.keys().next().value;if(!F)break;I.delete(F)}}function ln(d){ne(),X=window.setTimeout(()=>{X=null,d==null||d()},A)}function wt(){it(()=>{var d,M;(M=(d=te.value)==null?void 0:d.focus)==null||M.call(d)})}function Rt(d=""){const M=String(d||"").trim();return M?(p.value="path",Jt(),g.value=M,u.query=M,wt(),!0):!1}function xt(d){var M,U,F;if((M=d==null?void 0:d.preventDefault)==null||M.call(d),Ve.value){(U=d==null?void 0:d.stopPropagation)==null||U.call(d),g.value="";return}(F=d==null?void 0:d.stopPropagation)==null||F.call(d),s("close")}function vn(){ne(),P+=1,Ue(),m.value="",x.value="",c.value=!1,T.value="",v.value=null,me.value="",De.value="",ze.value="",Ie.value="2.6rem",Y.value=0,pe.value=[],ge.value="",lt(),w()}function Jt(){ee+=1,le&&(window.clearTimeout(le),le=null),Q&&(Q.abort(),Q=null),$.value=[],Z.value=!1,S.value="",B.value="",K.value=!1,j.value="",pe.value=[],ge.value="",w()}function Zs(){if(le&&(window.clearTimeout(le),le=null),!o.open||!_e.value||!Ne.value)return;if(!Ve.value||!Ge.value){Jt();return}Z.value=!0,S.value="",le=window.setTimeout(()=>{le=null,ns()},he)}function Nn(d=1){const M=$.value;if(!M.length)return!1;const U=M.findIndex(ie=>Pt(ie)===j.value),F=U<0?0:(U+d+M.length)%M.length;return j.value=Pt(M[F]),it(rn),!0}function On(){return Ht.value.length&&(Ht.value.find(d=>d.path===It.value)||Ht.value[0])||null}function Qt(d,M={}){return d?(It.value=(d==null?void 0:d.path)||"",j.value="",m.value=String((d==null?void 0:d.path)||"").trim(),x.value=String((d==null?void 0:d.type)||"").trim(),T.value="",Y.value=0,pe.value=[],ge.value="",(d==null?void 0:d.type)==="directory"?(ne(),v.value=null,M.toggleDirectory&&!N.value&&tn(d.path),!0):M.previewMode==="debounced"?(ln(()=>es(d==null?void 0:d.path)),!0):(ne(),es(d==null?void 0:d.path),!0)):!1}function xs(){const d=$.value;if(!d.length)return!1;const M=d.find(U=>Pt(U)===j.value)||d[0];return Cn(M),!0}function eo(d){const M=String((d==null?void 0:d.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(M)&&!(N.value&&(M==="ArrowLeft"||M==="ArrowRight"))){if(Ne.value&&N.value){if(M==="ArrowDown"){if(d.preventDefault(),Nn(1)){const U=$.value,F=U.find(ie=>Pt(ie)===j.value)||U[0];Cn(F,{previewMode:"debounced"})}return}if(M==="ArrowUp"){if(d.preventDefault(),Nn(-1)){const U=$.value,F=U.find(ie=>Pt(ie)===j.value)||U[0];Cn(F,{previewMode:"debounced"})}return}if(M==="Enter"){d.preventDefault(),xs();return}M==="Escape"&&xt(d);return}if(M==="ArrowDown"){d.preventDefault(),qe(1)&&it(()=>{Qt(On(),{previewMode:"debounced"})});return}if(M==="ArrowUp"){d.preventDefault(),qe(-1)&&it(()=>{Qt(On(),{previewMode:"debounced"})});return}if(M==="ArrowRight"){d.preventDefault(),Gt();return}if(M==="ArrowLeft"){d.preventDefault(),Yt();return}if(M==="Enter"){d.preventDefault(),Qt(On(),{toggleDirectory:!0});return}M==="Escape"&&xt(d)}}async function Fn(){const d=Ne.value?"path":"content";if(p.value=d,!Ve.value){d==="content"?Jt():(Jt(),u.query="");return}if(d==="content"){u.query="",ns();return}Jt(),u.query=g.value}function to(d){var M;d.preventDefault(),(M=d.stopPropagation)==null||M.call(d),Fn().finally(()=>{wt()})}async function Tn(){var ke;if(await it(),w(),!E.value)return;const d=[...new Set(pe.value.map(He=>Math.max(0,Number(He)||0)).filter(He=>He>0))],M=Math.max(0,Number(Y.value)||0);if(d.forEach(He=>{var q,Se;const je=E.value.querySelector(`.source-code-view__gutter[data-line="${He}"]`),y=(q=je==null?void 0:je.closest)==null?void 0:q.call(je,"tr");(Se=y==null?void 0:y.classList)==null||Se.add("is-match")}),sn(),!M){oe();return}const U=M,F=E.value.querySelector(`.source-code-view__gutter[data-line="${U}"]`),ie=(ke=F==null?void 0:F.closest)==null?void 0:ke.call(F,"tr");if(!ie){oe();return}ie.classList.add("is-match","is-focus-match"),sn(),ie.scrollIntoView({block:"center",inline:"nearest"}),oe()}async function Zn(){var ke,He,je;if(!Le.value){me.value="",De.value="",ze.value="";return}const d=P,M=String(((ke=v.value)==null?void 0:ke.content)||"").replace(/\r\n/g,`
19
+ `),U=((He=v.value)==null?void 0:He.language)||"",F=uc(M,uo),ie=await fc(((je=v.value)==null?void 0:je.content)||"",{isDark:l.value,language:U,maxHighlightLines:uo.maxLines,maxHighlightChars:uo.maxChars});d===P&&(me.value=ie.html,De.value=F?"":ie.bg||"",ze.value=F?"":ie.fg||"",Ie.value=ie.gutterWidth||"2.6rem",await it(),oe())}async function es(d="",M={}){var He;const U=String(d||"").trim();if(!_e.value||!U)return;Y.value=Math.max(0,Number(M.focusLine)||0),lt();const F=String(((He=v.value)==null?void 0:He.path)||"").trim();if(!M.forceReload&&F===U&&!c.value&&!T.value){await Tn();return}if(!M.forceReload&&c.value&&m.value===U)return;P+=1;const ie=P;T.value="";const ke=M.forceReload?null:Bt(U);if(ke){c.value=!1,v.value=ke,await Zn(),ie===P&&Le.value&&await Tn();return}c.value=!0;try{const je=await ml(_e.value,{path:U,limit:204800,refreshToken:String(Date.now())});if(ie!==P)return;v.value=je,qt(U,je),await Zn()}catch(je){if(ie!==P)return;v.value=null,T.value=(je==null?void 0:je.message)||r("sourceBrowser.previewFailed")}finally{ie===P&&(c.value=!1,Le.value&&await Tn())}}function _n(d){Qt(d,{toggleDirectory:!0}),it(wt)}function ts(d,M){var U,F;(F=(U=d==null?void 0:d.currentTarget)==null?void 0:U.focus)==null||F.call(U),_n(M)}async function ns(){const d=Ve.value;if(!o.open||!_e.value)return;ee+=1;const M=ee;if(!d||!Ge.value){Jt();return}Q&&(Q.abort(),Q=null),Z.value=!0,S.value="",$.value=[],K.value=!1,j.value="",Q=new AbortController;try{const U=await gl(_e.value,d,{limit:80,refreshToken:String(Date.now()),signal:Q.signal});if(M!==ee)return;B.value=d,$.value=Array.isArray(U.items)?U.items:[],K.value=!!U.truncated,j.value=$.value[0]?Pt($.value[0]):"",$.value[0]&&Cn($.value[0],{previewMode:"debounced"})}catch(U){if(ra(U)||M!==ee)return;B.value=d,$.value=[],S.value=(U==null?void 0:U.message)||r("sourceBrowser.contentSearchFailed")}finally{M===ee&&(Q=null),M===ee&&(Z.value=!1)}}function Cn(d,M={}){j.value=Pt(d),It.value=(d==null?void 0:d.path)||"",m.value=String((d==null?void 0:d.path)||"").trim(),x.value="file",T.value="",ge.value=B.value||Ve.value,pe.value=$.value.filter(F=>(F==null?void 0:F.path)===(d==null?void 0:d.path)).map(F=>Number((F==null?void 0:F.line)||0)).filter(F=>F>0);const U=()=>es(d==null?void 0:d.path,{focusLine:d==null?void 0:d.line});if(M.previewMode==="debounced"){ln(U),it(wt);return}ne(),U(),it(wt)}function no(d){const M=String((d==null?void 0:d.path)||"").trim();if(!M)return"";const U=M.split("/");return U[U.length-1]||M}function ss(d){const M=String((d==null?void 0:d.path)||"").trim();return!M||!M.includes("/")?"":M.slice(0,M.lastIndexOf("/"))}function so(d){return`${Array.isArray(d==null?void 0:d.items)?d.items.length:0} 处`}function os(d){const M=B.value||Ve.value;return an((d==null?void 0:d.preview)||"",M)}return Ae(()=>o.open,d=>{var M,U,F,ie,ke,He;if(u.open=d,d){(F=(U=(M=window.getSelection)==null?void 0:M.call(window))==null?void 0:U.removeAllRanges)==null||F.call(U),u.sessionId=_e.value,g.value="",p.value="path",u.query="",vn(),Jt(),ve(),Rt(o.initialSearchQuery)||wt();return}(He=(ke=(ie=window.getSelection)==null?void 0:ie.call(window))==null?void 0:ke.removeAllRanges)==null||He.call(ke),g.value="",p.value="path",vn(),Jt(),Vt()},{immediate:!0}),Ae(_e,d=>{u.sessionId=d,o.open&&(vn(),Jt(),J())}),Ae(()=>o.initialSearchQuery,d=>{o.open&&Rt(d)}),Ae(g,d=>{if(Re.value){u.query=d;return}String(d||"").trim()!==String(B.value||"").trim()&&(ge.value="",sn()),Zs()}),Ae(()=>u.query,()=>{Re.value&&H()}),Ae(_t,()=>{it(rn)}),Ae(yt,()=>{ce(),!(!N.value||!Re.value)&&it(()=>{const d=On();d&&Qt(d,{previewMode:"debounced"})})}),Ae(l,async()=>{!o.open||!Le.value||(await Zn(),await Tn())}),Ae(Oe,()=>{oe()}),Nt(()=>{var d,M,U;(U=(M=(d=window.getSelection)==null?void 0:d.call(window))==null?void 0:M.removeAllRanges)==null||U.call(M),lt({clearBrowserSelection:!0}),ne()}),t({applyPathSearch:Rt}),(d,M)=>(h(),Ee(Js,{open:e.open,"stack-level":2,"panel-class":"settings-dialog-panel h-[calc(100dvh-1rem)] sm:h-[96vh] sm:max-h-[96vh] sm:w-[90vw] sm:max-w-[90vw]","header-class":"settings-dialog-header px-5 py-3.5","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col overflow-hidden",onClose:M[2]||(M[2]=U=>s("close"))},{title:Ze(()=>[i("div",fd,[i("div",pd,b(Me.value||a(r)("sourceBrowser.title")),1)])]),default:Ze(()=>{var U;return[i("div",md,[i("aside",{class:"theme-divider flex min-h-0 flex-col border-b md:border-b-0 md:border-r",onKeydown:eo},[i("div",gd,[i("label",hd,[i("span",vd,b(a(r)("sourceBrowser.searchLabel")),1),i("div",yd,[ue(a(Va),{class:"theme-muted-text pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),Zt(i("input",{ref_key:"searchInputRef",ref:te,"onUpdate:modelValue":M[0]||(M[0]=F=>g.value=F),type:"text",class:"tool-input w-full pl-9 pr-18 text-[12px]",placeholder:ut.value,onKeydown:[en(xt,["esc"]),en(et(to,["prevent"]),["tab"])]},null,40,Sd),[[is,g.value]]),be.value?(h(),Ee(a(Xt),{key:0,class:"theme-muted-text pointer-events-none absolute right-10 top-1/2 h-4 w-4 -translate-y-1/2 animate-spin"})):fe("",!0),i("button",{type:"button",class:"tool-button absolute right-1.5 top-1/2 inline-flex h-7 w-7 -translate-y-1/2 items-center justify-center px-0",title:D.value,"aria-label":D.value,onClick:et(Fn,["stop","prevent"])},[ue(a(za),{class:"h-3.5 w-3.5"})],8,wd)])])]),i("div",xd,[_e.value?N.value&&Ne.value&&S.value?(h(),k("div",kd,b(S.value),1)):a(re)?(h(),k("div",Td,b(a(re)),1)):Pe.value?(h(),k("div",_d,b(a(r)("sourceBrowser.searchMinKeywordHint",{count:a(Ps)})),1)):Fe.value?(h(),k("div",Cd,b(a(r)("sourceBrowser.searchEmpty")),1)):Qe.value?(h(),k("div",Ed,b(a(r)("sourceBrowser.searchMinKeywordHint",{count:a(Ps)})),1)):Tt.value?(h(),k("div",Ad,b(a(r)("sourceBrowser.contentSearchPrompt")),1)):nt.value?(h(),k("div",Id,b(a(r)("sourceBrowser.contentSearchEmpty")),1)):a(Ct)?(h(),k("div",$d,b(a(r)("sourceBrowser.treeEmpty")),1)):N.value&&Ne.value&&Z.value&&!$.value.length?(h(),k("div",Pd,b(a(r)("sourceBrowser.contentSearching")),1)):a(Be)&&!a(Ht).length?(h(),k("div",Dd,b(a(r)("sourceBrowser.loadingFiles")),1)):N.value&&Re.value?(h(),k("div",Ld,[a(Ot).length?(h(),k("div",Md,b(a(r)("sourceBrowser.recent")),1)):fe("",!0),(h(!0),k(rt,null,ct(a(Ot),F=>(h(),k("button",{key:`recent-${F.path}`,ref_for:!0,ref:ie=>a($t)(F.path,ie),type:"button",class:xe(["theme-list-row focus:outline-none",a(It)===F.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:ie=>_n(F)},[(h(),Ee(bn(F.type==="directory"?a(Hn):a(Pn)),{class:"theme-list-item-icon"})),i("div",Rd,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Je)(F)},null,8,Nd)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Lt)(F)},null,8,Od)])],10,Bd))),128)),u.query.trim()&&a(ft).length?(h(),k("div",Fd,b(a(r)("sourceBrowser.results")),1)):fe("",!0),(h(!0),k(rt,null,ct(a(ft),F=>(h(),k("button",{key:`result-${F.path}`,ref_for:!0,ref:ie=>a($t)(F.path,ie),type:"button",class:xe(["theme-list-row focus:outline-none",a(It)===F.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:ie=>_n(F)},[(h(),Ee(bn(F.type==="directory"?a(Hn):a(Pn)),{class:"theme-list-item-icon"})),i("div",jd,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Je)(F)},null,8,Vd)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Lt)(F)},null,8,zd)])],10,Ud))),128))])):N.value?(h(),k("div",Hd,[(h(!0),k(rt,null,ct(mt.value,F=>(h(),k("div",{key:F.path,class:"rounded-sm border border-[var(--theme-borderDefault)] bg-[var(--theme-panel)]"},[i("div",qd,[ue(a(Pn),{class:"theme-list-item-icon"}),i("div",Kd,[i("div",Wd,b(no(F)),1),ss(F)?(h(),k("div",Gd,b(ss(F)),1)):fe("",!0)]),i("div",Xd,b(so(F)),1)]),i("div",Yd,[(h(!0),k(rt,null,ct(F.items,ie=>(h(),k("button",{key:Pt(ie),ref_for:!0,ref:ke=>mn(Pt(ie),ke),type:"button",class:xe(["theme-list-row gap-0 focus:outline-none",j.value===Pt(ie)?"theme-list-item-active":"theme-list-item-hover"]),onClick:ke=>Cn(ie)},[i("div",{class:"theme-list-item-title min-w-0 flex-1 break-words leading-[1.45rem]",innerHTML:os(ie)},null,8,Qd)],10,Jd))),128))])]))),128)),K.value?(h(),k("div",Zd,b(a(r)("sourceBrowser.contentSearchTruncated")),1)):fe("",!0)])):(h(),k("div",ef,[(h(!0),k(rt,null,ct(a(kn),F=>(h(),k("div",{key:F.path,ref_for:!0,ref:ie=>a($t)(F.path,ie),class:xe(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(It)===F.path?"theme-list-item-active":F.type==="directory"&&F.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Bn({paddingLeft:`${F.depth*16+6}px`}),tabindex:"-1",onClick:ie=>ts(ie,F)},[i("div",nf,[F.type==="directory"?(h(),k("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:et(ie=>a(tn)(F.path),["stop"])},[F.loading?(h(),Ee(a(Xt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),Ee(a(Rr),{key:1,class:xe(["h-3.5 w-3.5 transition",F.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,sf)):(h(),k("span",of)),i("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left outline-none focus:outline-none",onClick:et(ie=>_n(F),["stop"])},[(h(),Ee(bn(F.type==="directory"?a(Hn):a(Pn)),{class:xe(["h-4 w-4 shrink-0",F.type==="directory"&&F.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("span",{class:xe(["theme-list-item-title min-w-0 flex-1 truncate",F.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},b(a(ot)(F)),3)],8,rf)])],14,tf))),128))])):(h(),k("div",bd,b(a(r)("sourceBrowser.noProject")),1))])],32),i("section",af,[i("div",lf,[i("div",uf,[i("div",cf,[de.value?(h(),k("p",df,b(de.value),1)):fe("",!0),Le.value?(h(),k("p",ff,b(a(r)("sourceBrowser.selectCodeLineHint")),1)):fe("",!0)])])]),i("div",pf,[c.value?(h(),k("div",mf,[i("span",null,b(a(r)("sourceBrowser.previewLoading")),1)])):T.value?(h(),k("div",gf,b(T.value),1)):x.value==="directory"?(h(),k("div",hf,b(a(r)("sourceBrowser.selectFileHint")),1)):m.value?$e.value?(h(),k("div",yf,[i("img",{src:v.value.previewUrl,alt:Te.value,class:"source-browser-image object-contain"},null,8,Sf)])):ye.value?(h(),k("div",wf,[ue(a(Ha),{class:"h-8 w-8"}),i("span",null,b((U=v.value)!=null&&U.tooLarge?a(r)("sourceBrowser.binaryTooLarge"):a(r)("sourceBrowser.binaryUnsupported")),1)])):Le.value?(h(),k("div",{key:6,ref_key:"previewContainerRef",ref:E,class:"source-browser-code relative rounded-sm border",style:Bn({"--source-code-bg":De.value||"var(--theme-panel)","--source-code-fg":ze.value||"var(--theme-textPrimary)","--source-code-gutter-width":Ie.value}),onCopy:L,onMouseup:M[1]||(M[1]=(...F)=>a(ht)&&a(ht)(...F))},[i("div",xf,[i("table",bf,[i("tbody",{innerHTML:me.value},null,8,kf)])]),e.open&&a(We).visible?(h(),Ee(na,{key:0,top:a(We).top,left:a(We).left,label:a(r)("sourceBrowser.insertSelection"),onClick:_},null,8,["top","left","label"])):fe("",!0)],36)):fe("",!0):(h(),k("div",vf,b(a(r)("sourceBrowser.selectFile")),1))])])])]}),_:1},8,["open"]))}},Cf=Pr(_f,[["__scopeId","data-v-f17d487a"]]);function Ef(e={}){const{items:t,themeKey:n,getCacheKey:o=S=>String((S==null?void 0:S.id)||"").trim(),getSource:s=S=>String((S==null?void 0:S.content)||""),shouldRender:r=()=>!0,renderAsync:l=async S=>S,renderFallback:u=S=>S,onRendered:m=null}=e,x=new Map,c=new Map,T=z(0),v=G(()=>(Array.isArray(t==null?void 0:t.value)?t.value:[]).map(S=>{const B=!!r(S),K=String(o(S)||"").trim(),j=B?String(s(S)||""):"";return{item:S,active:B,cacheKey:K,source:j}}));function g(S){if(T.value,!r(S))return"";const B=String(s(S)||""),K=String(o(S)||"").trim(),j=String((n==null?void 0:n.value)||"");if(!K)return u(B,S);const R=x.get(K);return(R==null?void 0:R.source)===B&&(R==null?void 0:R.theme)===j?R.html:u(B,S)}async function p(S){if(!r(S))return;const B=String(s(S)||""),K=String(o(S)||"").trim();if(!K)return;const j=String((n==null?void 0:n.value)||""),R=x.get(K);if((R==null?void 0:R.source)===B&&(R==null?void 0:R.theme)===j)return;const te=Symbol(K);c.set(K,te);try{const E=await l(B,S,{themeKey:j});if(c.get(K)!==te)return;x.set(K,{source:B,theme:j,html:E}),T.value+=1,m==null||m(S,{cacheKey:K,source:B,themeKey:j})}catch{}finally{c.get(K)===te&&c.delete(K)}}function $(S=[]){S.forEach(B=>{B!=null&&B.item&&p(B.item)})}function Z(S=[]){const B=new Set((Array.isArray(S)?S:[]).filter(j=>j==null?void 0:j.active).map(j=>String((j==null?void 0:j.cacheKey)||"").trim()).filter(Boolean));let K=!1;for(const j of x.keys())B.has(j)||(x.delete(j),K=!0);for(const j of c.keys())B.has(j)||c.delete(j);K&&(T.value+=1)}return Ae(v,()=>{Z(v.value||[]),$(v.value||[])},{immediate:!0}),Ae(n,()=>{$(v.value||[])}),Nt(()=>{c.clear()}),{getRenderedHtml:g}}const Af=`${Xn()}/api/events/stream`,Kn=new Set;let Dn=null,Ds=null;function bo(){Ds&&(window.clearTimeout(Ds),Ds=null)}function ia(){Dn&&(Dn.close(),Dn=null)}function If(e){Kn.forEach(t=>{try{t(e)}catch{}})}function la(){typeof window>"u"||typeof window.EventSource>"u"||Dn||!Kn.size||(bo(),Dn=new window.EventSource(Af),Dn.onmessage=e=>{try{const t=JSON.parse(String(e.data||"{}"));if(!(t!=null&&t.type))return;If(t)}catch{}},Dn.onerror=()=>{ia(),Kn.size&&(bo(),Ds=window.setTimeout(()=>{la()},1500))})}function $f(e){return typeof e!="function"?()=>{}:(Kn.add(e),la(),()=>{Kn.delete(e),!Kn.size&&(bo(),ia())})}const ua=z(0),ko=z(0),Ls=z(""),us=z(""),Ms=z(0),ca=Ss({}),To=Ss({}),_o=Ss({}),cs=new Map;let nr=!1;const Pf=new Set(["created","updated","deleted","reordered","session-linked","session-cleared"]),Df=new Set(["completed","error","stopped","interrupted","stop_timeout","failed","cancelled","timeout"]);function po(e,t=""){const n=String(t||"").trim();n&&(e[n]=Math.max(0,Number(e[n])||0)+1)}function Lf(e={}){const t=String(e.type||"").trim(),n=String(e.reason||"").trim();return{updatesTaskList:t==="runs.changed"||t==="tasks.changed"&&Pf.has(n),updatesSessions:t==="ready"||t==="runs.changed"||t==="sessions.changed",updatesTaskRuns:t==="runs.changed",updatesTaskDiff:t==="runs.changed"||t==="tasks.changed"&&(n==="session-linked"||n==="session-cleared")}}function Mf(e=null,t=null){const n=String((e==null?void 0:e.runId)||"").trim(),o=String((e==null?void 0:e.status)||"").trim(),s=String((t==null?void 0:t.runId)||"").trim(),r=String((t==null?void 0:t.status)||"").trim();return!n||!s||n!==s||!o||o!==r?!1:Df.has(r)}function Bf(e="",t={}){const n=String(e||"").trim();if(!n)return;const o=cs.get(n);o!=null&&o.size&&o.forEach(s=>{try{s(t)}catch{}})}function Rf(e={}){const t=String(e.type||"").trim(),n=String(e.taskSlug||"").trim(),o=Lf(e);if(t){if(t==="ready"){ua.value+=1,Ls.value="",us.value="",Ms.value+=1;return}if(t==="tasks.changed"){Ls.value=n,us.value=String(e.reason||"").trim(),o.updatesTaskList&&(ko.value+=1),o.updatesTaskDiff&&po(To,n);return}if(t==="runs.changed"){Ls.value=n,us.value="";const s={runId:String(e.runId||"").trim(),status:String(e.status||"").trim(),sentAt:String(e.sentAt||"").trim()},r=n&&_o[n]||null,l=Mf(r,s);n&&(_o[n]=s),o.updatesTaskList&&!l&&(ko.value+=1),o.updatesSessions&&(Ms.value+=1),o.updatesTaskRuns&&po(ca,n),o.updatesTaskDiff&&!l&&po(To,n);return}if(t==="sessions.changed"){us.value="",o.updatesSessions&&(Ms.value+=1);return}t==="run.event"&&Bf(n,{taskSlug:n,runId:String(e.runId||"").trim(),event:e.event||null})}}function da(){nr||typeof window>"u"||($f(e=>{Rf(e)}),nr=!0)}function Nf(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(ca[t])||0):0}function Of(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(To[t])||0):0}function Ff(e=""){const t=String(e||"").trim();return t&&_o[t]||null}function Uf(e="",t){const n=String(e||"").trim();if(!n||typeof t!="function")return()=>{};da();const o=cs.get(n)||new Set;return o.add(t),cs.set(n,o),()=>{const s=cs.get(n);s&&(s.delete(t),s.size||cs.delete(n))}}function fa(){return da(),{readyVersion:ua,listSyncVersion:ko,listSyncTaskSlug:Ls,listSyncReason:us,sessionsSyncVersion:Ms,getTaskRunSyncVersion:Nf,getTaskRunChange:Ff,getTaskDiffSyncVersion:Of}}const jf=/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)/g,Vf=/\u001B\[[0-?]*[ -/]*[@-~]/g,zf=/\u001B[@-_]/g,Hf=/[\u0000-\u0008\u000B-\u001A\u001C-\u001F\u007F]/g;function qf(e=""){let t="";for(const n of String(e||"")){if(n==="\b"||n===""){t=t.slice(0,-1);continue}t+=n}return t}function Jn(e=""){return qf(String(e||"")).replace(jf,"").replace(Vf,"").replace(zf,"").replace(/\r\n/g,`
20
+ `).replace(/\r/g,`
21
+ `).replace(Hf,"")}function ws(e=""){return Jn(e)}function Rn(e=""){return String(e||"").replace(/^(?:[ \t]*\n)+/,"").replace(/(?:\n[ \t]*)+$/,"")}function Uo(e=[],t=12){const n=Array.isArray(e)?e:[];return n.length<=t?{items:n,hiddenCount:0}:{items:n.slice(0,t),hiddenCount:n.length-t}}function Kf(e=""){const t=Rn(ws(e));if(!t.trim())return null;const n=t.split(`
22
+ `),o=String(n[0]||"").trim();if(!o)return null;const s=o.match(/^([A-Za-z][A-Za-z0-9 _/-]{1,24}):\s*(.+)$/);if(!s)return null;const r=s[1].trim().toLowerCase();if(!new Set(["read","grep","glob","find","ls","dir","tree","list","path","file","command"]).has(r))return null;const u=Rn(n.slice(1).join(`
23
+ `));return{meta:{type:"meta",items:[{label:s[1].trim(),value:s[2].trim()}]},rest:u}}function Wf(e="",t={}){const n=Rn(ws(e));if(!n.trim()||!n.includes("<path>")||!n.includes("<entries>"))return null;const o=n.match(/<path>([\s\S]*?)<\/path>/i),s=n.match(/<type>([\s\S]*?)<\/type>/i),r=n.match(/<entries>([\s\S]*?)<\/entries>/i);if(!o&&!r)return null;const l=String((r==null?void 0:r[1])||"").split(`
24
+ `).map(x=>x.trim()).filter(Boolean).filter(x=>!/^\(\d+\s+entries?\)$/i.test(x)),{items:u,hiddenCount:m}=Uo(l,t.maxItems??12);return{type:"directory_list",path:String((o==null?void 0:o[1])||"").trim(),entryType:String((s==null?void 0:s[1])||"").trim(),entries:u,totalCount:l.length,hiddenCount:m}}function Gf(e="",t={}){const n=Rn(ws(e));if(!n.trim())return null;const o=n.split(`
25
+ `).map(u=>u.trimEnd()),s=o.map(u=>{const m=u.match(/^\s*\[([ xX])\]\s+(.+)$/);return m?{completed:m[1].toLowerCase()==="x",text:m[2].trim()}:null}).filter(Boolean);if(!s.length||s.length<Math.ceil(o.filter(Boolean).length*.6))return null;const{items:r,hiddenCount:l}=Uo(s,t.maxItems??12);return{type:"checklist",items:r,totalCount:s.length,hiddenCount:l}}function Xf(e="",t={}){const n=Rn(ws(e));if(!n.trim())return null;const o=n.split(`
26
+ `),s=o.map(u=>{const m=u.match(/^[-*]\s+(.+)$/);return m?m[1].trim():null}).filter(Boolean);if(s.length<2||s.length<Math.ceil(o.filter(Boolean).length*.6))return null;const{items:r,hiddenCount:l}=Uo(s,t.maxItems??12);return{type:"bullet_list",items:r,totalCount:s.length,hiddenCount:l}}function Yf(e="",t={}){return{type:t.preferMarkdown?"markdown":"text",text:e}}function Jf(e=[]){return e.reduce((t,n)=>{const o=t[t.length-1];return o&&n&&o.type===n.type&&["text","markdown"].includes(n.type)?(o.text=`${o.text}
27
+
28
+ ${n.text}`,t):(t.push(n),t)},[])}function Qf(e="",t={}){const n=String(e||"").split(/\n{2,}/).map(l=>Rn(l)).filter(l=>l.trim());if(n.length<2)return null;const o=Jf(n.flatMap(l=>jo(l,{...t,_disableMixedSegmentation:!0}))),s=o.some(l=>!["text","markdown"].includes(l==null?void 0:l.type)),r=o.some(l=>["text","markdown"].includes(l==null?void 0:l.type));return s&&r?o:null}function jo(e="",t={}){const n=Rn(ws(e));if(!n.trim())return[];const o=Kf(n);if(o!=null&&o.rest){const u=jo(o.rest,t);return[o.meta,...u.length?u:[{type:"text",text:o.rest}]]}const s=Wf(n,t);if(s)return[s];const r=Gf(n,t);if(r)return[r];const l=Xf(n,t);if(l)return[l];if(!t._disableMixedSegmentation){const u=Qf(n,t);if(u!=null&&u.length)return u}return[Yf(n,t)]}const Zf=new Set(["queued","starting","running","stopping"]);function wn(){return Xs()==="en-US"}function O(e,t){return wn()?t:e}function ds(e={}){const t=String((e==null?void 0:e.messageKey)||"").trim();if(t){const n=e!=null&&e.messageParams&&typeof e.messageParams=="object"?e.messageParams:{},o=Xe(t,n);if(o&&o!==t)return o}return String((e==null?void 0:e.message)||"").trim()}function sr(e=""){const t=Date.parse(String(e||""));return Number.isFinite(t)?t:0}function or(e=[],t=""){return[...e].sort((n,o)=>{const s=+!!(o!=null&&o.running)-+!!(n!=null&&n.running);if(s)return s;const r=+((o==null?void 0:o.id)===t)-+((n==null?void 0:n.id)===t);if(r)return r;const l=sr(o.updatedAt)-sr(n.updatedAt);return l||String(n.title||n.cwd||n.id).localeCompare(String(o.title||o.cwd||o.id),Xs())})}function pa(e="",t=24,n=2400){const o=Jn(e).trim();if(!o)return"";const s=o.split(`
29
+ `);let r=s.slice(0,t).join(`
30
+ `);return r.length>n&&(r=`${r.slice(0,n).trimEnd()}...`),s.length>t?`${r}
31
+ ...`:r}function $n(e=[]){const t=Array.isArray(e)?e:[];return t.length?t.map(n=>{const o=String((n==null?void 0:n.status)||"").trim().toLowerCase();return`${n.completed?"[x]":o==="in_progress"?"[-]":"[ ]"} ${n.text||O("未命名任务","Untitled Task")}`}).join(`
32
+ `):""}function Ut(e=0){const t=Number(e||0);return Number.isFinite(t)?t.toLocaleString(Xs()):"0"}function Vo(e=""){return String(e||"").trim().toLowerCase()==="shell"}function ep(e=""){return Vo(e)?O("Shell","Shell"):pt(e)}function tp(e=""){const t=String(e||"").trim().toLowerCase();return["completed","complete","succeeded","success","done"].includes(t)?"completed":["failed","error","errored","cancelled","canceled","stopped"].includes(t)?"failed":["running","in_progress","in-progress"].includes(t)?"running":["pending_init","pending"].includes(t)?"pending_init":t||"pending_init"}function ma(e={}){const t=[],n=o=>{const s=String(o||"").trim();!s||t.includes(s)||t.push(s)};return(Array.isArray(e.receiver_thread_ids)?e.receiver_thread_ids:[]).forEach(n),e.agents_states&&typeof e.agents_states=="object"&&Object.keys(e.agents_states).forEach(n),t}function zs(e={}){return ma(e).length}function ga(e={}){const t=ma(e),n=e.agents_states&&typeof e.agents_states=="object"?e.agents_states:{};return t.map(o=>{const s=n[o]&&typeof n[o]=="object"?n[o]:{},r=String(s.message||s.result||"").trim();return{id:o,status:tp(s.status),title:String(s.title||s.description||s.name||"").trim(),role:String(s.role||s.subagent_type||s.agent||"").trim(),target:String(s.target||s.path||"").trim(),model:String(s.model||"").trim(),message:r,messageBlocks:r?Mn(r):[]}})}function np(e={},t=120){const n=ga(e).map(o=>o.message).filter(Boolean);return St(n.join(wn()?" | ":"|"),t)}function ha(e=0){const t=Math.max(0,Math.floor(Number(e)||0));if(t<66)return`${t}s`;const n=Math.floor(t/3600),o=Math.floor(t%3600/60),s=t%60;return n>0?wn()?`${n}h ${o}m ${s}s`:`${n}小时${o}分${s}秒`:wn()?`${o}m ${s}s`:`${o}分${s}秒`}function St(e="",t=140){const n=String(e||"").replace(/\s+/g," ").trim();return n?n.length<=t?n:`${n.slice(0,t)}...`:""}function va(e="",t=[]){const n=t.filter(Boolean);if(!n.length)return"";const o=n.map(s=>`- ${s}`).join(`
33
+ `);return e?`${e}
34
+ ${o}`:o}function ms(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 sp(e=""){const t=String(e||"").trim().toLowerCase();return["done","completed","complete","checked"].includes(t)?"completed":["in_progress","in-progress","active","doing","running"].includes(t)?"in_progress":"pending"}function op(e={}){return[e==null?void 0:e.text,e==null?void 0:e.content,e==null?void 0:e.title,e==null?void 0:e.label,e==null?void 0:e.activeForm].map(n=>String(n||"").trim()).find(Boolean)||O("未命名任务","Untitled Task")}function Bs(e=[]){return(Array.isArray(e)?e:[]).map(t=>{if(!t||typeof t!="object")return null;const n=sp(t.status??(t.completed?"completed":"pending"));return{completed:n==="completed",status:n,text:op(t)}}).filter(Boolean)}function rr(e){const t=String(e||"").trim();if(!t)return[];try{const n=JSON.parse(t);if(Array.isArray(n))return Bs(n);if(n&&typeof n=="object"){if(Array.isArray(n.todos))return Bs(n.todos);if(Array.isArray(n.items))return Bs(n.items)}}catch{return[]}return[]}function ya(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];return t.length?{type:"checklist",items:t,totalCount:t.length,hiddenCount:0}:null}function zo(e=""){var x;const t=String(e||"").trim(),n=t.indexOf(":"),o=n>0&&n<=24,s=o?t.slice(0,n).trim():"",r=o?t.slice(n+1).trim():t,l=s.toLowerCase(),m=o?((x=Object.entries({shell:["bash","shell","sh","terminal","cmd","powershell"],read:["read","open","view","cat"],grep:["grep","rg","search","find"],list:["glob","ls","dir","tree","list"],web:["websearch","web_search","webfetch","fetch","browse","open_page"],todo:["todowrite","todo","tasklist","tasks"],edit:["edit","multiedit","write","patch","apply_patch","replace","create"]}).find(([,c])=>c.includes(l)))==null?void 0:x[0])||"generic":"shell";return{raw:t,toolName:s,normalizedTool:l,subject:r,category:m}}function gs(e={},t=null){const n=t||zo(e.command);if(n.category!=="todo")return[];const o=rr(e.aggregated_output);return o.length?o:rr(n.subject)}function Mn(e="",t={}){return jo(Jn(e),t)}function ar(e={}){const t=e.action||{},n=String(e.query||t.query||"").trim(),o=Array.isArray(t.queries)?t.queries.map(u=>String(u||"").trim()).filter(Boolean):[],s=String(t.url||"").trim(),r=[],l=ms([n?{label:O("关键词","Query"),value:n}:null,s?{label:"URL",value:s}:null]);return l&&r.push(l),o.length>1&&r.push({type:"bullet_list",items:o,totalCount:o.length,hiddenCount:0}),r}function ir(e={}){const t=String(e.tool||"").trim(),n=zs(e),o=String(e.prompt||"").trim(),s=ga(e),r=[],l=[t?{label:O("工具","Tool"),value:t}:null,n?{label:O("子代理","Sub-agent"),value:String(n)}:null],u=ms(l);return u&&r.push(u),s.length&&r.push({type:"sub_agent_list",items:s,totalCount:s.length,hiddenCount:0}),o&&r.push(...Mn(o,{preferMarkdown:!0})),r}function lr(e={}){const t=Array.isArray(e.changes)?e.changes:[];return t.length?[{type:"file_changes",items:t.map(n=>({kind:String((n==null?void 0:n.kind)||"").trim(),path:String((n==null?void 0:n.path)||"").trim()})),totalCount:t.length,hiddenCount:0}]:[]}function _s(e={},t=!1,n="codex"){const o=[],s=zo(e.command),r=gs(e,s),l=ya(r),u=typeof e.exit_code=="number",m=u?e.exit_code===0:e.status==="completed",x=ms([s.toolName?{label:O("工具","Tool"),value:s.toolName}:null,l||s.category!=="shell"?null:s.subject?{label:O("命令","Command"),value:s.subject}:e.command?{label:O("命令","Command"),value:e.command}:null,n&&n!=="codex"?{label:O("引擎","Engine"),value:ep(n)}:null,u&&!m?{label:O("退出码","Exit code"),value:String(e.exit_code)}:null]);if(x&&o.push(x),l&&o.push(l),t){if(l)return o;const c=pa(e.aggregated_output);c&&o.push(...Mn(c,{preferMarkdown:s.category==="web"||s.category==="edit"}))}return o}function Vn(e={}){const t=zo(e.command);return{groupType:["read","grep","list","web","todo"].includes(t.category)?t.category:"",groupTarget:t.subject||e.command||"",toolName:t.toolName||""}}function mo(e={}){const t=Array.isArray(e.items)?Bs(e.items):[];return t.length?[ya(t)]:[]}function Qn(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function Co(e=[],t=""){const n=String(t||"").trim();return n&&(Array.isArray(e)?e:[]).find(o=>(o==null?void 0:o.runId)===n)||null}function rp(e,t,n,o,s){const r=Co(e,t);return r?(r.events=[],r.lastEventSeq=0,r.summary=Qn(),((n==null?void 0:n.items)||[]).forEach(l=>{qo(r,l,o,s)}),r.eventCount=Math.max(Math.max(0,Number(r.eventCount)||0),Array.isArray(n==null?void 0:n.items)?n.items.length:0,Math.max(0,Number(r.lastEventSeq)||0)),r.eventsLoaded=!0,r.eventsLoading=!1,r):null}function Sa(e={}){const t=String((e==null?void 0:e.displayEngine)||"").trim();return t?Vs(t):Vo(e==null?void 0:e.engine)?"codex":Vs(e==null?void 0:e.engine)}function jt(e={}){return pt(Sa(e))}function ap(e={}){return Vo(e==null?void 0:e.engine)}function hs(e=""){return Zf.has(String(e||"").trim())}function Ho(e=""){const t=String(e||"").trim();if(!t)return null;const n=t.match(/^Reconnecting\.\.\.\s*(\d+)\/(\d+)\s*\(([\s\S]+)\)$/i);return n?{attempt:Number(n[1]||0),total:Number(n[2]||0),reason:String(n[3]||"").trim(),rawMessage:t}:null}function ur(e={},t="completed"){const n=e.action||{},o=String(n.type||"").trim(),s=String(e.query||n.query||"").trim(),r=Array.isArray(n.queries)?n.queries.map(u=>String(u||"").trim()).filter(Boolean):[],l=String(n.url||s||"").trim();return o==="search"?{kind:"command",title:t==="started"?O("正在搜索网页","Searching the web"):O("已搜索网页","Web search completed"),detail:va(s?O(`关键词:${s}`,`Query: ${s}`):"",r.length>1?r:[])}:o==="open_page"?{kind:"command",title:t==="started"?O("正在打开网页","Opening page"):O("已打开网页","Page opened"),detail:l}:{kind:"command",title:t==="started"?O("准备网页检索","Preparing web search"):O("网页检索已更新","Web search updated"),detail:s}}function cr(e={},t="completed"){const n=String(e.tool||"").trim(),o=zs(e),s=St(e.prompt);return n==="spawn_agent"?{kind:"todo",title:t==="started"?O("正在启动子代理","Starting sub-agent"):O(`已启动 ${o||1} 个子代理`,`Started ${o||1} sub-agent(s)`),detail:s?O(`任务:${s}`,`Task: ${s}`):""}:n==="wait"?{kind:"todo",title:t==="started"?o?O(`等待 ${o} 个子代理返回结果`,`Waiting for ${o} sub-agent result(s)`):O("等待子代理返回结果","Waiting for sub-agent results"):O("子代理结果已汇总","Sub-agent results aggregated"),detail:s?O(`等待内容:${s}`,`Waiting on: ${s}`):""}:{kind:"todo",title:t==="started"?O(`正在执行协作工具:${n||"未知工具"}`,`Running collaboration tool: ${n||"Unknown tool"}`):O(`协作工具完成:${n||"未知工具"}`,`Collaboration tool completed: ${n||"Unknown tool"}`),detail:s?O(`任务:${s}`,`Task: ${s}`):""}}function dr(e={},t="completed"){const n=Array.isArray(e.changes)?e.changes:[],o={create:O("新增","Added"),update:O("更新","Updated"),delete:O("删除","Deleted")};return{kind:"command",title:t==="started"?O("正在整理文件变更","Collecting file changes"):O(`已记录 ${n.length||0} 个文件改动`,`Recorded ${n.length||0} file change(s)`),detail:va("",n.map(s=>{const r=String((s==null?void 0:s.path)||"").trim();return`${o[String((s==null?void 0:s.kind)||"").trim()]||O("变更","Changed")} ${r||O("未命名文件","Unnamed file")}`}))}}function ip(e,t={}){var l,u,m,x,c,T,v,g;e!=null&&e.summary||(e.summary=Qn());const n=e.summary,o=jt(e),s=String(t.type||"").trim(),r=t.item||{};if(s===bt.TURN_STARTED){n.currentActivity=O("正在分析任务","Analyzing task"),n.latestActivity=O(`${o} 开始执行`,`${o} started`),n.latestDetail="";return}if(s===bt.TURN_COMPLETED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=O(`${o} 执行完成`,`${o} completed`),n.latestDetail="";return}if(s===bt.TURN_FAILED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=O("本轮运行失败","This run failed"),n.latestDetail="";return}if(s===bt.ERROR){const p=Ho(vs(t));if(p){n.currentActivity=O(`网络异常,正在重试 (${p.attempt}/${p.total})`,`Network error, retrying (${p.attempt}/${p.total})`),n.latestActivity=n.currentActivity,n.latestDetail=St(p.reason,120);return}n.currentActivity="",n.latestActivity=O(`${o} 返回错误`,`${o} returned an error`),n.latestDetail=St(vs(t),120);return}if(s===bt.ITEM_STARTED){if(r.type===at.REASONING){n.currentActivity=O("正在思考","Thinking"),n.latestActivity=O("正在思考","Thinking"),n.latestDetail=St(r.text,120);return}if(r.type===at.COMMAND_EXECUTION){if(Vn(r).groupType==="todo"){const $=$n(gs(r));n.currentActivity=O("正在更新待办列表","Updating todo list"),n.latestActivity=O("正在更新待办列表","Updating todo list"),n.latestDetail=St($,120);return}n.currentActivity=O("正在执行命令","Running command"),n.latestActivity=O("开始执行命令","Command started"),n.latestDetail=St(r.command,120);return}if(r.type===at.WEB_SEARCH){n.currentActivity=((l=r.action)==null?void 0:l.type)==="open_page"?O("正在打开网页","Opening page"):O("正在搜索网页","Searching the web"),n.latestActivity=n.currentActivity,n.latestDetail=St(((u=r.action)==null?void 0:u.type)==="open_page"?((m=r.action)==null?void 0:m.url)||r.query:r.query||((x=r.action)==null?void 0:x.query),120);return}if(r.type===at.COLLAB_TOOL_CALL){if(r.tool==="wait"){const p=zs(r);n.waitingAgentCount=p,n.currentActivity=p?O(`等待 ${p} 个子代理返回结果`,`Waiting for ${p} sub-agent result(s)`):O("等待子代理返回结果","Waiting for sub-agent results"),n.latestActivity=n.currentActivity,n.latestDetail=St(r.prompt,120);return}if(r.tool==="spawn_agent"){n.currentActivity=O("正在启动子代理","Starting sub-agent"),n.latestActivity=O("正在启动子代理","Starting sub-agent"),n.latestDetail=St(r.prompt,120);return}}if(r.type===at.FILE_CHANGE){n.currentActivity=O("正在整理文件变更","Collecting file changes"),n.latestActivity=O("正在整理文件变更","Collecting file changes"),n.latestDetail=St((r.changes||[]).map(p=>p==null?void 0:p.path).filter(Boolean).join(wn()?", ":","),120);return}r.type===at.TODO_LIST&&(n.currentActivity=O("正在规划执行步骤","Planning steps"),n.latestActivity=O("正在规划执行步骤","Planning steps"),n.latestDetail=St((r.items||[]).map(p=>p==null?void 0:p.text).filter(Boolean).join(wn()?"; ":";"),120));return}if(s===bt.ITEM_COMPLETED){if(r.type===at.COMMAND_EXECUTION){if(Vn(r).groupType==="todo"){n.currentActivity="",n.latestActivity=O("待办列表已更新","Todo list updated"),n.latestDetail=St($n(gs(r)),120);return}n.commandCount+=1,n.currentActivity="",n.latestActivity=O("命令执行完成","Command completed"),n.latestDetail=St(r.command,120);return}if(r.type===at.WEB_SEARCH){n.webSearchCount+=1,n.currentActivity="",n.latestActivity=((c=r.action)==null?void 0:c.type)==="open_page"?O("已打开网页","Page opened"):O("已搜索网页","Web search completed"),n.latestDetail=St(((T=r.action)==null?void 0:T.type)==="open_page"?((v=r.action)==null?void 0:v.url)||r.query:r.query||((g=r.action)==null?void 0:g.query),120);return}if(r.type===at.COLLAB_TOOL_CALL){if(r.tool==="spawn_agent"){const p=zs(r);n.subAgentCount+=p,n.currentActivity="",n.latestActivity=p?O(`已启动 ${p} 个子代理`,`Started ${p} sub-agent(s)`):O("已启动子代理","Started sub-agent"),n.latestDetail=St(r.prompt,120);return}if(r.tool==="wait"){n.waitingAgentCount=0,n.currentActivity="",n.latestActivity=O("子代理结果已汇总","Sub-agent results aggregated"),n.latestDetail=np(r,120)||St(r.prompt,120);return}n.currentActivity="",n.latestActivity=O(`协作工具完成:${r.tool||"未知工具"}`,`Collaboration tool completed: ${r.tool||"Unknown tool"}`),n.latestDetail=St(r.prompt,120);return}if(r.type===at.FILE_CHANGE){const p=Array.isArray(r.changes)?r.changes:[];n.fileChangeCount+=p.length,n.currentActivity="",n.latestActivity=p.length?O(`已记录 ${p.length} 个文件改动`,`Recorded ${p.length} file change(s)`):O("已记录文件改动","Recorded file changes"),n.latestDetail=St(p.map($=>$==null?void 0:$.path).filter(Boolean).join(wn()?", ":","),120);return}if(r.type===at.TODO_LIST){n.currentActivity="",n.latestActivity=O("待办列表已更新","Todo list updated"),n.latestDetail=St((r.items||[]).map(p=>p==null?void 0:p.text).filter(Boolean).join(wn()?"; ":";"),120);return}r.type===at.AGENT_MESSAGE&&(n.currentActivity="",n.latestActivity=O(`${o} 已返回结果`,`${o} returned a result`),n.latestDetail=St(r.text,120))}}function lp(e={},t={}){const n=Date.parse(String(e.startedAt||""));if(!Number.isFinite(n))return 0;if(hs(e.status)){if(t.currentRunningRunId&&String(t.currentRunningRunId)===String(e.runId||"")&&Number.isFinite(Number(t.runningElapsedSeconds)))return Math.max(0,Math.floor(Number(t.runningElapsedSeconds)||0));const s=Number(t.nowMs)||Date.now();return Math.max(0,Math.floor((s-n)/1e3))}const o=Date.parse(String(e.finishedAt||""));return Number.isFinite(o)&&o>=n?Math.max(0,Math.floor((o-n)/1e3)):0}function wa(e={},t={}){const n=e.summary||Qn(),o=[],s=lp(e,t);return s>0&&o.push({key:"elapsed",label:O("耗时","Elapsed"),value:ha(s)}),n.webSearchCount&&o.push({key:"web",label:O("网页","Web"),value:Ut(n.webSearchCount)}),n.commandCount&&o.push({key:"command",label:O("命令","Command"),value:Ut(n.commandCount)}),n.fileChangeCount&&o.push({key:"file",label:O("改动","Changes"),value:Ut(n.fileChangeCount)}),n.subAgentCount&&o.push({key:"agent",label:O("子代理","Sub-agent"),value:Ut(n.subAgentCount)}),o}function xa(e={}){const t=e.summary||Qn();return t.waitingAgentCount>0?O(`当前:等待 ${Ut(t.waitingAgentCount)} 个子代理返回结果`,`Current: waiting for ${Ut(t.waitingAgentCount)} sub-agent result(s)`):t.currentActivity?O(`当前:${t.currentActivity}`,`Current: ${t.currentActivity}`):t.latestActivity?O(`最近:${t.latestActivity}`,`Latest: ${t.latestActivity}`):hs(e.status)?O(`当前:正在等待 ${jt(e)} 返回更多事件`,`Current: waiting for more events from ${jt(e)}`):""}function ba(e={}){const t=e.summary||Qn();return String(t.latestDetail||"").trim()}function up(e={}){return!!(wa(e).length||xa(e)||ba(e))}const cp=[{type:"startup_config",title:e=>O(`${pt(e)} 启动配置冲突`,`${pt(e)} startup config conflict`),summary:e=>O(`${pt(e)} 当前启动参数可能与本机包装脚本、别名或外部环境配置冲突,请检查 CLI 启动方式。`,`${pt(e)} startup arguments may conflict with your local wrapper script, alias, or external environment configuration. Please check how the CLI is launched.`),patterns:[/not inside a trusted directory/i,/do you trust the contents of this directory/i,/trusted directory/i,/skip-git-repo-check/i,/prompt injection/i,/目录.*信任/,/可信目录/]},{type:"billing",title:O("额度或账单异常","Quota or billing issue"),summary:e=>O(`${pt(e)} 可能因为额度不足、欠费或账单限制而无法继续执行。`,`${pt(e)} may be unable to continue due to quota exhaustion, billing issues, or account limits.`),patterns:[/insufficient_quota/i,/exceeded your current quota/i,/\bquota\b/i,/\bbilling\b/i,/credit balance/i,/payment required/i,/余额不足/,/欠费/,/账单/,/充值/]},{type:"permission",title:O("权限不足","Insufficient permissions"),summary:e=>O(`${pt(e)} 当前权限不够,无法访问所需文件、命令或资源。`,`${pt(e)} does not currently have permission to access the required files, commands, or resources.`),patterns:[/permission denied/i,/insufficient permissions?/i,/forbidden/i,/unauthorized/i,/authentication_failed/i,/invalid token/i,/invalid api key/i,/\b401\b/,/access denied/i,/not allowed/i,/权限不足/,/没有权限/,/无权/,/拒绝访问/,/无效的令牌/]},{type:"rate_limit",title:O("请求过于频繁","Too many requests"),summary:e=>O(`${pt(e)} 可能触发了限流,请稍后再试。`,`${pt(e)} may have hit a rate limit. Please try again later.`),patterns:[/rate limit/i,/too many requests/i,/\b429\b/,/请求过于频繁/,/限流/]},{type:"context_limit",title:O("上下文过长","Context too long"),summary:O("这次发送的内容可能过长,超过了模型可处理的上下文限制。","The content sent in this run may be too long and exceed the model context limit."),patterns:[/context length/i,/maximum context length/i,/context_length_exceeded/i,/token limit/i,/prompt is too long/i,/上下文过长/,/超过.*token/i,/超出.*上下文/]},{type:"model_unavailable",title:O("模型或服务暂不可用","Model or service unavailable"),summary:e=>O(`${pt(e)} 背后的模型或服务当前不可用,请稍后重试。`,`The model or service behind ${pt(e)} is currently unavailable. Please try again later.`),patterns:[/model .*not found/i,/model .*unavailable/i,/service unavailable/i,/server error/i,/overloaded/i,/\b503\b/,/模型不可用/,/服务不可用/]},{type:"network",title:O("网络连接异常","Network connection issue"),summary:e=>O(`${pt(e)} 在请求过程中遇到了网络问题或连接超时。`,`${pt(e)} encountered a network problem or timeout while making the request.`),patterns:[/timed out/i,/\btimeout\b/i,/stream disconnected/i,/error sending request/i,/connection reset/i,/connection closed/i,/socket hang up/i,/network error/i,/fetch failed/i,/econnreset/i,/econnrefused/i,/enotfound/i,/network is unreachable/i,/temporary failure in name resolution/i,/网络异常/,/连接超时/]},{type:"cli_missing",title:e=>O(`${pt(e)} CLI 不可用`,`${pt(e)} CLI unavailable`),summary:e=>O(`当前环境没有正确安装或配置 ${pt(e)} CLI。`,`${pt(e)} CLI is not correctly installed or configured in the current environment.`),patterns:[/找不到 Codex CLI/,/找不到 Claude Code CLI/,/找不到 OpenCode CLI/,/找不到 Kimi Code CLI/,/codex --version/i,/claude --version/i,/opencode --version/i,/kimi --version/i,/enoent/i,/not recognized as an internal or external command/i,/command not found/i]}];function Yn(e="",t="codex"){const n=Jn(e).trim();if(!n)return null;const o=cp.find(s=>s.patterns.some(r=>r.test(n)));return o?{type:o.type,title:typeof o.title=="function"?o.title(t):o.title,summary:typeof o.summary=="function"?o.summary(t):o.summary,rawMessage:n}:null}function dn(e="",t="codex"){const n=Jn(e).trim();if(!n)return"";const o=Yn(n,t);return o?`${o.summary}
35
+
36
+ ${O("原始错误","Raw error")}: ${o.rawMessage}`:n}function Eo(e,t=0){if(!e||t>4)return"";if(typeof e=="string")return Jn(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 vs(e={}){return Eo(e)}function dp(e={},t="Codex",n="codex"){var r,l,u,m;const o=String(e.type||"").trim(),s=e.item||{};if(!o)return{title:O(`收到 ${t} 事件`,`Received ${t} event`),detail:""};if(o===bt.THREAD_STARTED){const x=e.thread_id?O(`线程 ID: ${e.thread_id}`,`Thread ID: ${e.thread_id}`):"";return{title:O(`${t} 会话已创建`,`${t} session created`),detail:x,detailBlocks:x?[ms([{label:"ID",value:e.thread_id}])]:[]}}if(o===bt.TURN_STARTED)return{title:O(`${t} 开始执行`,`${t} started`),detail:""};if(o===bt.TURN_COMPLETED){const x=e.usage?[O(`输入 ${Ut(e.usage.input_tokens)}`,`Input ${Ut(e.usage.input_tokens)}`),e.usage.cached_input_tokens?O(`缓存 ${Ut(e.usage.cached_input_tokens)}`,`Cached ${Ut(e.usage.cached_input_tokens)}`):"",O(`输出 ${Ut(e.usage.output_tokens)}`,`Output ${Ut(e.usage.output_tokens)}`)].filter(Boolean).join(" / "):"";return{title:O(`${t} 执行完成`,`${t} completed`),detail:x,detailBlocks:e.usage?[ms([{label:O("输入","Input"),value:Ut(e.usage.input_tokens)},e.usage.cached_input_tokens?{label:O("缓存","Cached"),value:Ut(e.usage.cached_input_tokens)}:null,{label:O("输出","Output"),value:Ut(e.usage.output_tokens)}])]:[]}}if(o==="claude.system"&&!String(e.detail||"").trim())return{title:"",detail:""};if(o===bt.ERROR||o===bt.TURN_FAILED){const x=vs(e)||O(`${t} 执行失败`,`${t} failed`),c=o===bt.ERROR?Ho(x):null;if(c)return{kind:"info",title:O(`网络异常,正在重试 (${c.attempt}/${c.total})`,`Network error, retrying (${c.attempt}/${c.total})`),detail:dn(c.reason||c.rawMessage,n),detailBlocks:Mn(dn(c.reason||c.rawMessage,n),{preferMarkdown:!0})};const T=Yn(x,n);return{kind:"error",title:(T==null?void 0:T.title)||(o===bt.TURN_FAILED?O("本轮运行失败","This run failed"):O(`${t} 返回错误`,`${t} returned an error`)),detail:dn(x,n),detailBlocks:Mn(dn(x,n),{preferMarkdown:!0})}}if(o===bt.ITEM_STARTED)return s.type===at.REASONING?{kind:"reasoning",title:O("思考过程","Thinking"),detail:s.text||"",detailBlocks:Mn(s.text||"",{preferMarkdown:!0}),groupType:"reasoning",phase:"updated"}:s.type===at.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===at.COLLAB_TOOL_CALL?{...cr(s,"started"),detailBlocks:ir(s)}:s.type===at.FILE_CHANGE?{...dr(s,"started"),detailBlocks:lr(s)}:s.type===at.COMMAND_EXECUTION?Vn(s).groupType==="todo"?{kind:"todo",title:O("更新待办列表","Update todo list"),detail:$n(gs(s)),detailBlocks:_s(s,!1,n),groupType:"todo",phase:"started"}:{kind:"command",title:O("开始执行命令","Command started"),detail:s.command||"",detailBlocks:_s(s,!1,n),...Vn(s),phase:"started"}:s.type===at.TODO_LIST?{kind:"todo",title:O("更新待办列表","Update todo list"),detail:$n(s.items),detailBlocks:mo(s),groupType:"todo",phase:"started"}:{title:O(`开始处理 ${s.type||"未知项目"}`,`Started handling ${s.type||"unknown item"}`),detail:""};if(o===bt.ITEM_UPDATED&&s.type===at.TODO_LIST)return{kind:"todo",title:O("更新待办列表","Update todo list"),detail:$n(s.items),detailBlocks:mo(s),groupType:"todo",phase:"updated"};if(o===bt.ITEM_COMPLETED){if(s.type===at.AGENT_MESSAGE&&s.text)return{kind:"result",title:O(`${t} 已返回结果`,`${t} returned a result`),detail:""};if(s.type===at.WEB_SEARCH)return{...ur(s,"completed"),detailBlocks:ar(s),groupType:"web",groupTarget:String(s.query||((u=s.action)==null?void 0:u.query)||((m=s.action)==null?void 0:m.url)||"").trim(),phase:"completed"};if(s.type===at.COLLAB_TOOL_CALL)return{...cr(s,"completed"),detailBlocks:ir(s)};if(s.type===at.FILE_CHANGE)return{...dr(s,"completed"),detailBlocks:lr(s)};if(s.type===at.COMMAND_EXECUTION){if(Vn(s).groupType==="todo"){const T=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:T?"todo":"error",title:T?O("更新待办列表","Update todo list"):O("更新待办列表失败","Todo list update failed"),detail:$n(gs(s)),detailBlocks:_s(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?O("命令执行完成","Command completed"):O(`命令执行失败(exit ${s.exit_code??"?"})`,`Command failed (exit ${s.exit_code??"?"})`),detail:[s.command,pa(s.aggregated_output)].filter(Boolean).join(`
37
+
38
+ `),detailBlocks:_s(s,!0,n),...Vn(s),phase:"completed"}}return s.type===at.TODO_LIST?{kind:"todo",title:O("更新待办列表","Update todo list"),detail:$n(s.items),detailBlocks:mo(s),groupType:"todo",phase:"completed"}:{title:O(`完成 ${s.type||"未知项目"}`,`Completed ${s.type||"unknown item"}`),detail:""}}return{title:O(`事件: ${o}`,`Event: ${o}`),detail:""}}function fp(e){return e.status==="queued"?O("排队中","Queued"):e.status==="starting"?O("启动中","Starting"):e.status==="stopping"?O("停止中","Stopping"):e.status==="running"?O("进行中","Running"):e.status==="error"?O("失败","Failed"):e.status==="interrupted"?O("已中断","Interrupted"):e.status==="stopped"?O("已停止","Stopped"):e.status==="stop_timeout"?O("停止超时","Stop timeout"):O("已完成","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?Mn(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"?$s(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:Qn()}}function In(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=O("网络异常,正在重试","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,m,x,c,T,v,g;const s=jr(t.type);if(s===Wt.SESSION){o(t.session);return}if(s===Wt.SESSION_UPDATED){o(t.session);return}if(s===Wt.STATUS){if(t.stage==="starting"||t.stage==="resuming")return;In(e,{title:ds(t)||O("状态已更新","Status updated"),detail:""},n);return}if(s===Wt.STDERR){const p=Yn(t.text,e.engine);In(e,{kind:"error",title:(p==null?void 0:p.title)||"stderr",detail:dn(t.text,e.engine)},n);return}if(s===Wt.STDOUT){In(e,{kind:"command",title:"stdout",detail:t.text},n);return}if(s===Wt.AGENT_EVENT){if(ip(e,t.event),((r=t.event)==null?void 0:r.type)===bt.THREAD_STARTED)return;const p=dp(t.event,jt(e),e.engine);String(p.title||"").startsWith(O("网络异常,正在重试","Network error, retrying"))?mp(e,p,n):In(e,p,n),((l=t.event)==null?void 0:l.type)===bt.ITEM_COMPLETED&&((m=(u=t.event)==null?void 0:u.item)==null?void 0:m.type)===at.AGENT_MESSAGE&&((c=(x=t.event)==null?void 0:x.item)!=null&&c.text)&&(e.responseMessage=t.event.item.text);const $=vs(t.event)||O(`${jt(e)} 执行失败`,`${jt(e)} failed`);if(!(((T=t.event)==null?void 0:T.type)==="error"?Ho($):null)&&(((v=t.event)==null?void 0:v.type)===bt.ERROR||((g=t.event)==null?void 0:g.type)===bt.TURN_FAILED)){const S=vs(t.event)||O(`${jt(e)} 执行失败`,`${jt(e)} failed`);e.errorMessage=dn(S,e.engine),e.status="error"}return}if(s===Wt.COMPLETED){In(e,{kind:"result",title:O("本轮执行结束","Run finished"),detail:""},n);const p=ds(t);p&&(e.responseMessage=p);return}if(s===Wt.STOPPED){In(e,{title:ds(t)||O("执行已手动停止","Execution stopped manually"),detail:""},n);return}if(s===Wt.ERROR){const p=ds(t),$=Yn(p,e.engine);In(e,{kind:"error",title:($==null?void 0:$.title)||O("执行失败","Execution failed"),detail:dn(p||O(`${jt(e)} 执行失败`,`${jt(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=Yn(o,n),l=Yn(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=dn(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=O(`本轮 ${jt(e)} 执行已完成,没有返回额外文本。`,`${jt(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===Wt.COMPLETED?(e.status="completed",e.finishedAt=new Date().toISOString()):l===Wt.STOPPED?(e.status="stopped",e.errorMessage="",e.finishedAt=new Date().toISOString()):l===Wt.ERROR&&(e.status="error",e.errorMessage=dn(String(ds(r)||e.errorMessage||O(`${jt(e)} 执行失败`,`${jt(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 fs(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=>fs(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:m,scheduleScrollToBottom:x,resetAutoStickToBottom:c,mergeSessionRecord:T,mergeSession:v,loadSessions:g,showProcessLogs:p}=e;let $=0,Z=0,S=null,B="",K=null,j=null,R="",te=!!(p!=null&&p.value),E=0;const Y=new Map;function pe(){return $+=1,$}function ge(){return Z+=1,Z}function P(){K&&(window.clearInterval(K),K=null)}function ee(){j&&(window.clearInterval(j),j=null)}function le(){E=Date.now()}function Q(){Y.clear(),n.value=[],s.value=!1,r.value=0,l.value="",R="",B="",$=0,Z=0,c()}function he(){const W=[...n.value].reverse().find(ae=>hs(ae.status))||null;if(l.value=(W==null?void 0:W.runId)||"",s.value=!!W,W!=null&&W.startedAt){const ae=Date.parse(String(W.startedAt||""));r.value=Number.isFinite(ae)?ae:Date.now();return}r.value=0}function A(W=null){return W?{...W}:xp()}function X(W,ae=null){if(!(ae!=null&&ae.runId)||W.eventsLoaded||!ae.eventsLoaded)return Y.has(W.runId)&&(W.eventsLoading=!0),W;const de=Math.max(Math.max(0,Number(ae.lastEventSeq)||0),Math.max(0,Number(ae.eventCount)||0),Array.isArray(ae.events)?ae.events.length:0),$e=Math.max(0,Number(W.eventCount)||0);return de<$e?(Y.has(W.runId)&&(W.eventsLoading=!0),W):(W.events=Array.isArray(ae.events)?[...ae.events]:[],W.eventCount=Math.max(Math.max(0,Number(W.eventCount)||0),Math.max(0,Number(ae.eventCount)||0),W.events.length),W.eventsLoaded=!0,W.eventsLoading=Y.has(W.runId),W.lastEventSeq=Math.max(0,Number(ae.lastEventSeq)||0),W.summary=A(ae.summary),W)}function I(W,ae){const de=Co(n.value,W);return de?(de.eventsLoading=!!ae,n.value=[...n.value],de):null}async function _e(W,ae={}){const de=String((W==null?void 0:W.runId)||"").trim(),{force:$e=!1}=ae;if(!de)return[];const ye=Co(n.value,de)||W;if(ye!=null&&ye.eventsLoaded&&!$e)return ye.events;if(Y.has(de))return Y.get(de);I(de,!0);const Le=(async()=>{var me;try{const De=fs(ye,!!(p!=null&&p.value)),ze=await go.listCodexRunEvents(de,{limit:5e3}),Ie=rp(n.value,de,ze,ge,We=>{v(We,{preserveRunning:!0})});if(!Ie)return Array.isArray(ye==null?void 0:ye.events)?ye.events:[];const gt=JSON.stringify(De)!==JSON.stringify(fs(Ie,!!(p!=null&&p.value)));return n.value=[...n.value],gt&&t.active&&((me=n.value.at(-1))==null?void 0:me.runId)===de&&x(),Ie.events}catch(De){throw u.value=De.message,De}finally{I(de,!1),Y.delete(de)}})();return Y.set(de,Le),Le}function Me(W,ae){const de=String(W||"").trim();if(!de||!ae)return!1;const $e=n.value.findIndex(ze=>ze.runId===de);if($e<0)return!1;const ye=n.value[$e],Le=fs(ye,!!(p!=null&&p.value));if(!qo(ye,ae,ge,ze=>{v(ze,{preserveRunning:!0})}))return!0;const De=JSON.stringify(Le)!==JSON.stringify(fs(ye,!!(p!=null&&p.value)));return n.value=[...n.value],he(),De&&x(),!0}function Re(){if(P(),ee(),!(!t.active||!s.value||!t.taskSlug)){if(m){j=window.setInterval(()=>{Ve({force:!0}).catch(()=>{});const W=Date.now();W-E<pr||(E=W,g({force:!0}).catch(()=>{}))},Sp);return}K=window.setInterval(()=>{Ve({force:!0}).catch(()=>{});const W=Date.now();W-E<pr||(E=W,g({force:!0}).catch(()=>{}))},yp)}}function Ne(W=[]){const ae=[...o.value],de=new Map(n.value.filter(ye=>String((ye==null?void 0:ye.runId)||"").trim()).map(ye=>[String(ye.runId||"").trim(),ye])),$e=ye=>{if(!(ye!=null&&ye.id))return;const Le=ae.findIndex(me=>me.id===ye.id);Le>=0?ae[Le]=T(ae[Le],ye,{preserveRunning:!0}):ae.unshift(T(null,ye,{preserveRunning:!0}))};$=0,Z=0,n.value=[...W||[]].reverse().map(ye=>{const Le=fr(ye,pe,ge,$e);return X(Le,de.get(String((ye==null?void 0:ye.id)||"").trim())||null)}),o.value=ae,he()}async function Ve(W={}){const{force:ae=!1,scrollToLatest:de=!1}=W,$e=String(t.taskSlug||"").trim();if(!(!$e||!t.active&&!ae))return S&&B===$e||S&&!ae||(B=$e,S=(async()=>{try{const Le=(await go.listTaskCodexRuns($e,{limit:30,events:"latest"})).items||[],me=!!(p!=null&&p.value),De=wp(Le,me),ze=de||R&&te===me&&De!==R;Ne(Le),R=De,te=me,Re();const Ie=n.value.at(-1)||null;if(Ie!=null&&Ie.runId&&!Ie.eventsLoaded){const gt=Ie.runId;_e(Ie).catch(()=>{}).finally(()=>{var We;de&&t.active&&((We=n.value.at(-1))==null?void 0:We.runId)===gt&&x({force:!0})})}ze&&x({force:de})}catch(ye){u.value=ye.message}finally{S=null,B=""}})()),S}function Ge(W={}){const ae=(W==null?void 0:W.run)||null,de=(W==null?void 0:W.session)||null;if(de&&v(de,{preserveRunning:!0}),!(ae!=null&&ae.id)){he(),x({force:!0});return}const ye=fr(ae,pe,ge,me=>{v(me,{preserveRunning:!0})}),Le=n.value.findIndex(me=>me.runId===ye.runId);if(Le>=0){const me=[...n.value];me.splice(Le,1,ye),n.value=me}else n.value=[...n.value,ye];he(),x({force:!0})}async function Te(){if(!(!t.taskSlug||s.value))try{await go.clearTaskCodexRuns(t.taskSlug),Q(),x({force:!0})}catch(W){u.value=W.message}}return{applyCreatedRun:Ge,applyIncomingRunEvent:Me,clearRealtimeReconcileTimer:ee,clearRunPollTimer:P,clearTurns:Te,loadTurnEvents:_e,markFallbackSessionPollNow:le,refreshRunHistory:Ve,resetRunHistoryState:Q,syncRunningStateFromTurns:he,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:m,showManager:x,selectedSessionId:c,currentRunningRunId:T,supportsServerEvents:v,mergeSession:g,applyCreatedRun:p,refreshRunHistory:$,markFallbackSessionPollNow:Z,showToast:S,getActiveAgentBinding:B=null}=e;let K=null,j=null,R=0,te=0;const E=G(()=>typeof t.buildPrompt=="function"||!!String(t.prompt||"").trim()),Y=G(()=>n.value.length>0),pe=G(()=>or(n.value,c.value)),ge=G(()=>Y.value?"":Xe("projectManager.noProjects"));async function P(Te={}){const{force:W=!1}=Te;if(K)return K;const ae=Date.now();return!W&&R&&ae-R<kp?{items:n.value,workspaces:o.value}:(K=(async()=>{s.value=!0,m.value="";try{const $e=(await al()).items||[];return n.value=$e,R=Date.now(),{items:$e,workspaces:o.value}}catch(de){throw m.value=de.message,de}finally{s.value=!1,K=null}})(),K)}async function ee(Te={}){const{force:W=!1}=Te;if(j)return j;const ae=Date.now();return!W&&te&&ae-te<Tp?{items:o.value}:(j=(async()=>{try{const de=await il();return o.value=de.items||[],te=Date.now(),{items:o.value}}finally{j=null}})(),j)}async function le(Te={}){const{forceSessions:W=!1,forceWorkspaces:ae=!1}=Te,[de,$e]=await Promise.all([P({force:W}),ee({force:ae})]);return{items:(de==null?void 0:de.items)||n.value,workspaces:($e==null?void 0:$e.items)||o.value}}function Q(Te=""){const W=String(Te||"").trim();!W||o.value.includes(W)||(o.value=[W,...o.value])}function he(){x.value=!0,ee().catch(()=>{})}function A(){x.value=!1}function X(Te){const W=String(Te||"").trim();if(t.sessionSelectionLocked&&W&&W!==c.value){m.value=t.sessionSelectionLockReason||Xe("taskActions.sessionLocked");return}c.value=W}function I(){le({forceSessions:!0,forceWorkspaces:!0}).catch(()=>{})}async function _e(Te){r.value=!0,m.value="";try{const W=await ll(Te);return g(W),Q(W.cwd),c.value=W.id,W}catch(W){throw m.value=W.message,W}finally{r.value=!1}}async function Me(Te,W){r.value=!0,m.value="";try{const ae=await ul(Te,W);return g(ae),Q(ae.cwd),ae}catch(ae){throw m.value=ae.message,ae}finally{r.value=!1}}async function Re(Te){var ae;const W=String(Te||"").trim();if(!W)return{deletedSessionId:"",selectedSessionId:c.value};r.value=!0,m.value="";try{await cl(W);const de=n.value.filter(ye=>ye.id!==W);n.value=de;let $e=c.value;return c.value===W&&($e=((ae=or(de,"")[0])==null?void 0:ae.id)||"",c.value=$e),{deletedSessionId:W,selectedSessionId:$e}}catch(de){throw m.value=de.message,de}finally{r.value=!1}}async function Ne(Te){const W=String(Te||"").trim();if(!W)return null;r.value=!0,m.value="";try{const ae=await dl(W);return ae!=null&&ae.session&&g(ae.session),Z(),await Promise.all([$({force:!0}),P({force:!0})]),S==null||S({message:Xe("projectManager.sessionReset"),type:"success"}),ae}catch(ae){throw m.value=ae.message,ae}finally{r.value=!1}}async function Ve(){if(!t.taskSlug||!E.value||l.value||u.value)return!1;if(!c.value){const Te=Xe("projectManager.selectProject");return m.value=Te,S==null||S({message:Te,type:"warning"}),!1}m.value="";try{await le({forceSessions:!0});const Te=n.value.find(Ie=>Ie.id===c.value)||null;if(!Te)return m.value=Xe("projectManager.projectMissing"),!1;if(Te.running)return m.value=Xe("sessionTurns.currentProjectRunning"),!1;const W=typeof t.buildPrompt=="function"?await t.buildPrompt():t.prompt,ae=typeof t.buildPromptBlocks=="function"?await t.buildPromptBlocks():[],de=hi({prompt:W,promptBlocks:ae});if(de.reason){const Ie=de.reason==="unsupported_blocks"?Xe("sessionPanel.shellUnsupportedBlocks"):Xe("sessionPanel.shellEmptyCommand");return m.value=Ie,S==null||S({message:Ie,type:"warning"}),!1}if(!String(W||"").trim())return m.value=Xe("sessionTurns.noPromptToSend"),!1;const $e=Cp(Te),ye=typeof B=="function"?B(Te):null,Le=String((ye==null?void 0:ye.engine)||"").trim();if(Le&&!$e.some(Ie=>Ie.engine===Le)){const Ie=Xe("sessionPanel.agentNotEnabled");return m.value=Ie,S==null||S({message:Ie,type:"warning"}),!1}const me=ye,De=String(de.mode==="shell"?c.value:(me==null?void 0:me.sessionRecordId)||c.value).trim(),ze=await Sl(t.taskSlug,{projectSessionId:c.value,sessionId:De,displayEngine:Le,prompt:de.mode==="shell"?de.prompt:W,promptBlocks:ae,commandMode:de.mode,command:de.command});return p(ze),typeof t.afterSend=="function"&&Promise.resolve(t.afterSend()).catch(Ie=>{console.error("[promptx] afterSend failed",Ie)}),v||(Z(),Promise.all([$({force:!0}),P({force:!0})]).catch(Ie=>{m.value=Ie.message})),!0}catch(Te){return m.value=Te.message,!1}}async function Ge(){if(!(!T.value||u.value))try{u.value=!0,await xl(T.value),v||(Z(),await Promise.all([$({force:!0}),P({force:!0})]))}catch(Te){u.value=!1,m.value=Te.message}}return{closeManager:A,handleCreateSession:_e,handleDeleteSession:Re,handleResetSession:Ne,handleSelectSession:X,handleSend:Ve,handleUpdateSession:Me,hasPrompt:E,helperText:ge,loadSessions:P,loadSessionResources:le,loadWorkspaces:ee,openManager:he,refreshSessionsForSelection:I,sortedSessions:pe,stopSending:Ge}}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,m=0,x=!0,c=0,T=[],v=0,g=null;function p(){const I=typeof window<"u"?window:globalThis;return typeof(I==null?void 0:I.setTimeout)!="function"||typeof(I==null?void 0:I.clearTimeout)!="function"?null:{setTimeout:I.setTimeout.bind(I),clearTimeout:I.clearTimeout.bind(I)}}function $(){if(typeof window>"u"||!r.length){r=[];return}r.forEach(I=>{window.cancelAnimationFrame(I)}),r=[]}function Z(){s+=1,$()}function S(){const I=p();if(!I){T=[],v=0;return}T.forEach(_e=>{I.clearTimeout(_e)}),T=[],v&&(I.clearTimeout(v),v=0)}function B(){var I;(I=g==null?void 0:g.disconnect)==null||I.call(g),g=null}function K(){return c>Date.now()}function j(I){u=!!I,(n==null?void 0:n.value)!==void 0&&(n.value=u)}function R(){l=!1,m+=1,x=!0,j(!1)}function te(I=t==null?void 0:t.value){return I?I.scrollHeight-I.scrollTop-I.clientHeight<=o:!0}function E(){return K()||x&&!l}function Y(){x&&!l&&j(!1)}function pe(){if(x=te(),!x){Z();return}Y()}function ge(){m+=1,l=!0,c=0,S(),B(),Z()}function P(){const I=m+1;m=I,it(()=>{I===m&&requestAnimationFrame(()=>{I===m&&(l=!1,x=te(),Y())})})}function ee(){l=!0,c=0,S(),B(),Z()}function le(){P()}function Q(I={}){const{force:_e=!1}=I;_e&&R(),Z();const Me=s;it(()=>{if(!(t==null?void 0:t.value)||Me!==s)return;if(!_e&&!E()){j(!0);return}const Ne=()=>{const Ge=t==null?void 0:t.value;!Ge||Me!==s||(Ge.scrollTop=Ge.scrollHeight,x=!0,j(!1))};Ne(),r=[requestAnimationFrame(()=>{Ne(),r=[requestAnimationFrame(Ne)]})]})}function he(){Q({force:!0})}function A(I={}){const _e=Number(I.durationMs),Me=Math.max(0,Number.isFinite(_e)?_e:Ap),Re=p();R(),c=Date.now()+Me,S(),B(),Re&&(T=Ip.map(Ne=>Re.setTimeout(()=>{K()&&Q({force:!0})},Ne)),v=Re.setTimeout(()=>{c=0,v=0,S(),B()},Me+40)),typeof window<"u"&&typeof window.ResizeObserver=="function"&&(g=new window.ResizeObserver(()=>{K()&&Q({force:!0})}),t!=null&&t.value&&g.observe(t.value)),Q({force:!0})}function X(){m+=1,c=0,S(),B(),Z()}return{cancelScheduledScrollToBottom:Z,destroy:X,handleTranscriptScroll:pe,handleTranscriptTouchEnd:le,handleTranscriptTouchMove:ee,handleTranscriptTouchStart:ge,beginForceFollowWindow:A,isTranscriptNearBottom:te,resetAutoStickToBottom:R,scheduleScrollToBottom:Q,scrollToBottom:he}}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=z([]),s=z([]),r=z(!1),l=z(!1),u=z(!1),m=z(!1),x=z(""),c=z([]),T=z(null),v=z(0),g=z(0),p=z(!1),$=z(""),Z=z(!1),S=z(Lp()),B=typeof window<"u"&&typeof window.EventSource<"u";function K(re=""){const Be=typeof re=="object"&&re!==null?String(re.message||"").trim():String(re||"").trim();Be&&t("toast",typeof re=="object"&&re!==null?{...re,message:Be}:Be)}let j=null,R=null,te=null,E={sessions:!1,runs:!1};const Y=G({get(){return String(e.selectedSessionId||"").trim()},set(re){t("selected-session-change",String(re||"").trim())}}),pe=G(()=>m.value?Xe("sessionPanel.stopping"):`${Xe("projectManager.running")} (${ha(g.value)})`),ge=G(()=>o.value.find(re=>re.id===Y.value)||null),P=G(()=>{var Be;if(Array.isArray((Be=ge.value)==null?void 0:Be.agentBindings)&&ge.value.agentBindings.length)return ge.value.agentBindings;const re=ge.value;return re!=null&&re.id?[{engine:re.engine,sessionRecordId:re.id,sessionId:re.sessionId||"",started:!!re.started,running:!!re.running,isDefault:!0}]:[]}),ee=G({get(){var Be,ot;const re=ho(e.selectedAgentEngine,P.value);return re||((Be=P.value.find(Je=>Je.isDefault))==null?void 0:Be.engine)||((ot=P.value[0])==null?void 0:ot.engine)||""},set(re){const Be=ho(re,P.value);Be&&t("update:selectedAgentEngine",Be)}}),le=G(()=>P.value.find(re=>re.engine===ee.value)||P.value[0]||null),{beginForceFollowWindow:Q,destroy:he,handleTranscriptScroll:A,handleTranscriptTouchEnd:X,handleTranscriptTouchMove:I,handleTranscriptTouchStart:_e,resetAutoStickToBottom:Me,scheduleScrollToBottom:Re,scrollToBottom:Ne}=$p({transcriptRef:T,hasNewerMessages:Z});function Ve(re,Be,ot={}){return Mp(re,Be,ot)}function Ge(re,Be={}){if(!(re!=null&&re.id))return;const ot=[...o.value],Je=ot.findIndex(Lt=>Lt.id===re.id);Je>=0?ot[Je]=Ve(ot[Je],re,Be):ot.unshift(Ve(null,re,Be)),o.value=ot}const{applyCreatedRun:Te,applyIncomingRunEvent:W,clearRealtimeReconcileTimer:ae,clearRunPollTimer:de,clearTurns:$e,loadTurnEvents:ye,markFallbackSessionPollNow:Le,refreshRunHistory:me,resetRunHistoryState:De,updatePollingState:ze}=bp({props:e,turns:c,sessions:o,sending:u,sendingStartedAt:v,currentRunningRunId:$,sessionError:x,supportsServerEvents:B,scheduleScrollToBottom:Re,resetAutoStickToBottom:Me,showProcessLogs:S,mergeSessionRecord:Ve,mergeSession:Ge,loadSessions:(...re)=>dt(...re)}),{closeManager:Ie,handleCreateSession:gt,handleDeleteSession:We,handleResetSession:lt,handleSelectSession:ht,handleSend:vt,handleUpdateSession:Oe,helperText:Ce,loadSessions:dt,loadSessionResources:ut,loadWorkspaces:D,openManager:N,refreshSessionsForSelection:se,sortedSessions:be,stopSending:Fe}=_p({props:e,sessions:o,workspaces:s,loading:r,managerBusy:l,sending:u,stopping:m,sessionError:x,showManager:p,selectedSessionId:Y,currentRunningRunId:$,supportsServerEvents:B,mergeSession:Ge,applyCreatedRun:Te,refreshRunHistory:me,markFallbackSessionPollNow:Le,showToast:K,getActiveAgentBinding:()=>le.value});function Pe(){j&&(window.clearInterval(j),j=null)}function Qe(){Pe(),v.value||(v.value=Date.now()),g.value=Math.max(0,Math.floor((Date.now()-v.value)/1e3)),j=window.setInterval(()=>{g.value=Math.max(0,Math.floor((Date.now()-v.value)/1e3))},1e3)}function nt(){te&&(window.clearTimeout(te),te=null)}function Tt(){nt();const re=E;E={sessions:!1,runs:!1},re.sessions&&dt({force:!0}).catch(()=>{}),re.runs&&me({force:!0}).catch(()=>{})}function mt(re={}){typeof window>"u"||(E={sessions:E.sessions||!!re.sessions,runs:E.runs||!!re.runs},!(te||!E.sessions&&!E.runs)&&(te=window.setTimeout(()=>{Tt()},Pp)))}function _t(re){return wa(re,{currentRunningRunId:$.value,runningElapsedSeconds:g.value,nowMs:Date.now()})}function yt(re=""){if(!re)return"";const Be=new Date(re);return Number.isNaN(Be.getTime())?"":Be.toLocaleTimeString(Xs(),{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function It(re){return re.status==="error"||re.status==="stop_timeout"?"theme-process-error":re.status==="interrupted"||re.status==="stopped"?"theme-process-stopped":re.status==="completed"?"theme-process-completed":"theme-process-running"}function Yt(){S.value=!S.value}function Gt(re){return!!(re.responseMessage||re.errorMessage||re.status==="completed")}return Ae(S,re=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ta,re?"true":"false")}catch{}},{immediate:!0}),Ae(u,re=>{re?(v.value||(v.value=Date.now()),Qe()):(Pe(),v.value=0,g.value=0,m.value=!1),ze(),t("sending-change",re)},{immediate:!0}),Ae(g,(re,Be)=>{e.active&&Be===0&&re>0&&Re()}),Ae(()=>!!e.taskRunning,re=>{!e.active||re||!u.value||mt({sessions:!0,runs:!0})}),Ae(()=>e.active,re=>{if(re){ut({forceSessions:!0}).catch(()=>{});return}nt(),ae(),de()},{immediate:!0}),Ae(()=>e.taskSlug,()=>{De(),p.value=!1,x.value="",e.active&&(Q(),me({force:!0,scrollToLatest:!0}).catch(()=>{}))},{immediate:!0}),Ae(()=>{var re;return[((re=ge.value)==null?void 0:re.id)||"",P.value.map(Be=>Be.engine).join(","),e.selectedAgentEngine||""].join(`
39
+ `)},()=>{var H,J,ce;const re=String(((H=ge.value)==null?void 0:H.id)||"").trim(),Be=P.value,ot=ee.value;if(t("agent-bindings-change",{sessionId:re,bindings:Be,selectedEngine:ot}),!re||ho(e.selectedAgentEngine,Be))return;const Lt=((J=Be.find(ve=>ve.isDefault))==null?void 0:J.engine)||((ce=Be[0])==null?void 0:ce.engine)||"";Lt&&t("update:selectedAgentEngine",Lt)},{immediate:!0}),Nt(()=>{Pe(),ae(),de(),nt(),he(),R==null||R()}),Ae(()=>n.readyVersion.value,()=>{const re=String(e.taskSlug||"").trim();!e.active&&!p.value||(p.value&&D().catch(()=>{}),mt({sessions:!0,runs:!!re}))}),Ae(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!p.value||mt({sessions:!0})}),Ae(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||mt({sessions:!0,runs:!0})}),Ae(()=>String(e.taskSlug||"").trim(),re=>{R==null||R(),R=null,re&&(R=Uf(re,({runId:Be,event:ot})=>{if(!e.active)return;W(Be,ot)||mt({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:le,activeAgentEngine:ee,clearTurns:$e,closeManager:Ie,formatTurnTime:yt,getProcessCardClass:It,getProcessStatus:fp,getTurnAgentLabel:jt,getTurnSummaryDetail:ba,getDisplayTurnSummaryItems:_t,getTurnSummaryStatus:xa,handleCreateSession:gt,handleDeleteSession:We,handleResetSession:lt,handleSelectSession:ht,handleSend:vt,handleUpdateSession:Oe,loadTurnEvents:ye,hasTurnSummary:up,helperText:Ce,loading:r,managerBusy:l,openManager:N,refreshSessionsForSelection:se,selectedSessionId:Y,sending:u,showProcessLogs:S,stopping:m,sessionError:x,shouldShowResponse:Gt,showManager:p,sortedSessions:be,stopSending:Fe,toggleProcessLogs:Yt,hasNewerMessages:Z,transcriptRef:T,turns:c,workspaces:s,workingLabel:pe,sessions:o,loadSessions:dt,currentProjectAgentBindings:P,handleTranscriptScroll:A,handleTranscriptTouchEnd:X,handleTranscriptTouchMove:I,handleTranscriptTouchStart:_e,scheduleScrollToBottom:Re,scrollToBottom:Ne}}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=z({}),s=z({}),r=z({});function l(E){return String((E==null?void 0:E.runId)||(E==null?void 0:E.id)||"").trim()}function u(E){const Y=l(E);return!!Y&&Y===l(t.value.at(-1))}function m(E){return Math.max(0,Number(E==null?void 0:E.eventCount)||0,Array.isArray(E==null?void 0:E.events)?E.events.length:0)}function x(E){return!hs(E==null?void 0:E.status)&&!u(E)&&m(E)>3}function c(E){return mr(E==null?void 0:E.prompt,Rp,Np)}function T(E){return!hs(E==null?void 0:E.status)&&!u(E)&&c(E)}function v(E){return String((E==null?void 0:E.errorMessage)||(E==null?void 0:E.responseMessage)||"")}function g(E){return mr(v(E),Op,Fp)}function p(E){return!(E!=null&&E.errorMessage)&&!u(E)&&g(E)}function $(E){return m(E)>0}function Z(E=[]){const Y=new Set((E||[]).map(P=>l(P)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([P])=>Y.has(P))),s.value=Object.fromEntries(Object.entries(s.value).filter(([P])=>Y.has(P))),r.value=Object.fromEntries(Object.entries(r.value).filter(([P])=>Y.has(P)));const pe=(E||[]).at(-1)||null,ge=l(pe);ge&&(Object.prototype.hasOwnProperty.call(o.value,ge)||(o.value={...o.value,[ge]:!1}),Object.prototype.hasOwnProperty.call(s.value,ge)||(s.value={...s.value,[ge]:!1}),Object.prototype.hasOwnProperty.call(r.value,ge)||(r.value={...r.value,[ge]:!1}))}function S(E){const Y=l(E);return Y?Object.prototype.hasOwnProperty.call(o.value,Y)?!!o.value[Y]:x(E):!1}async function B(E){const Y=l(E);if(!Y)return;const pe=!S(E);o.value={...o.value,[Y]:pe},!pe&&$(E)&&!E.eventsLoaded&&!E.eventsLoading&&await n(E).catch(()=>{})}function K(E){const Y=l(E);return Y?Object.prototype.hasOwnProperty.call(s.value,Y)?!!s.value[Y]:T(E):!1}function j(E){const Y=l(E);!Y||!c(E)||(s.value={...s.value,[Y]:!K(E)})}function R(E){const Y=l(E);return Y?Object.prototype.hasOwnProperty.call(r.value,Y)?!!r.value[Y]:p(E):!1}function te(E){const Y=l(E);!Y||!g(E)||(r.value={...r.value,[Y]:!R(E)})}return Ae(t,E=>{Z(E)},{immediate:!0,deep:!0}),{canCollapsePrompt:c,canCollapseResponse:g,getTurnEventCollapseKey:l,getTurnEventCount:m,hasTurnEventHistory:$,isLatestTurn:u,isPromptCollapsed:K,isResponseCollapsed:R,isTurnEventsCollapsed:S,togglePrompt:j,toggleResponse:te,toggleTurnEvents:B}}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(m=>Array.isArray(m==null?void 0:m.detailBlocks)?m.detailBlocks:[]).find(m=>(m==null?void 0:m.type)==="checklist");return u?[u]:[]}if(e==="reasoning"){const u=[...t].reverse().find(m=>Array.isArray(m==null?void 0:m.detailBlocks)&&m.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(()=>Ke(()=>import("./CodexSessionManagerDialog-D1PwOD4T.js"),__vite__mapDeps([34,35,2,3,36,37,38,39,40]))),s=n,r=e,{closeManager:l,formatTurnTime:u,getProcessCardClass:m,getProcessStatus:x,getTurnAgentLabel:c,getDisplayTurnSummaryItems:T,getTurnSummaryDetail:v,getTurnSummaryStatus:g,handleCreateSession:p,handleDeleteSession:$,handleResetSession:Z,handleSelectSession:S,handleSend:B,handleTranscriptScroll:K,handleTranscriptTouchEnd:j,handleTranscriptTouchMove:R,handleTranscriptTouchStart:te,handleUpdateSession:E,helperText:Y,loadTurnEvents:pe,loading:ge,managerBusy:P,openManager:ee,refreshSessionsForSelection:le,selectedSessionId:Q,sending:he,showProcessLogs:A,stopping:X,hasTurnSummary:I,hasNewerMessages:_e,sessionError:Me,shouldShowResponse:Re,showManager:Ne,sortedSessions:Ve,stopSending:Ge,toggleProcessLogs:Te,transcriptRef:W,turns:ae,workspaces:de,sessions:$e,loadSessions:ye,currentProjectAgentBindings:Le,scheduleScrollToBottom:me,scrollToBottom:De}=Bp(r,s),ze=z(null),Ie=z(!1),gt=z(""),We=z(""),lt=z("");function ht(){try{const f=JSON.parse(window.localStorage.getItem(gr)||"{}");if(f&&typeof f=="object"&&!Array.isArray(f))return f}catch{}return{}}function vt(f){window.localStorage.setItem(gr,JSON.stringify(f))}const Oe=z("all");Ae(Oe,f=>{const _=String(r.taskSlug||"").trim();if(!_)return;const L=ht();L[_]=f,vt(L)});const{t:Ce}=At(),{isDark:dt}=Dr(),ut=G(()=>dt.value?"dark":"light"),D=G(()=>{const f=new Set;return(Array.isArray(Le.value)?Le.value:[]).filter(_=>{const L=String((_==null?void 0:_.engine)||"").trim();return!L||f.has(L)?!1:(f.add(L),!0)})}),N=G(()=>D.value.length>1),se=G(()=>{const f=String(Oe.value||"").trim();return!N.value||f==="all"?ae.value:ae.value.filter(_=>Sa(_)===f)}),{selectionAction:be,clearSelectionState:Fe,handleSelectionMouseUp:Pe}=oa({getContainer:()=>W.value,isActive:()=>!!(r.active&&ae.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:f=>[...f.querySelectorAll("[data-response-selection-root]")],getCodeLeft:f=>{var _,L;return((L=(_=f==null?void 0:f.getBoundingClientRect)==null?void 0:_.call(f))==null?void 0:L.left)||0},debounceMs:72});Ae([Oe,()=>D.value.map(f=>f.engine).join(`
40
+ `)],()=>{Oe.value!=="all"&&D.value.length&&(D.value.some(f=>f.engine===Oe.value)||(Oe.value="all"))},{immediate:!0}),Ae(Oe,()=>{Fe({clearBrowserSelection:!0}),me({force:!0})}),Ae(()=>r.taskSlug,(f,_)=>{if(!String(f||"").trim()||f===_)return;const ne=ht()[f];Oe.value=ne||"all"},{immediate:!0});function Qe(f={}){const _=String((f==null?void 0:f.title)||"").trim();return _?[/^已连接项目:/,/^工作目录:/,/^项目会话已更新$/,/ 会话已创建$/,/^事件: claude\.system$/,/^线程 ID:/,/^Thread ID:/,/^Connected project:/,/^Working directory:/,/^Project session updated$/,/ session created$/,/^Event: claude\.system$/,/ 已返回结果$/,/ returned a result$/,/^本轮执行结束$/,/^Run finished$/].some(L=>L.test(_)):!1}function nt(f={}){return Ce("sessionPanel.promptTitleWithAgent",{agent:c(f)})}function Tt(f={}){return f.errorMessage?Ce("sessionPanel.errorSuffix",{agent:c(f)}):Ce("sessionPanel.responseSuffix",{agent:c(f)})}const{getTurnEventCount:mt,hasTurnEventHistory:_t,isTurnEventsCollapsed:yt,toggleTurnEvents:It}=Up({turns:ae,loadTurnEvents:pe});function Yt(f){return String((f==null?void 0:f.runId)||(f==null?void 0:f.id)||"").trim()}function Gt(f){f!=null&&f.runId&&s("open-diff",{scope:"run",runId:f.runId})}function re(){s("open-diff",{scope:"workspace",runId:""})}const{getRenderedHtml:Be}=Ef({items:ae,themeKey:ut,getCacheKey:Yt,getSource:f=>String((f==null?void 0:f.responseMessage)||""),shouldRender:f=>!!(f!=null&&f.responseMessage)&&!(f!=null&&f.errorMessage),renderAsync:f=>wc(f,{isDark:dt.value,copyLabel:Ce("sessionPanel.copyCode"),copyAriaLabel:Ce("sessionPanel.copyCodeAria")}),renderFallback:f=>ta(f),onRendered:f=>{const _=ae.value.at(-1)||null;!r.active||!(_!=null&&_.runId)||_.runId!==(f==null?void 0:f.runId)||me()}});function ot(f){lt.value=String(f||"").trim()}async function Je(f){var L;if((L=navigator.clipboard)!=null&&L.writeText&&window.isSecureContext){await navigator.clipboard.writeText(f);return}const _=document.createElement("textarea");_.value=f,_.setAttribute("readonly","true"),_.style.position="fixed",_.style.opacity="0",_.style.pointerEvents="none",document.body.appendChild(_),_.select(),document.execCommand("copy"),document.body.removeChild(_)}function Lt(f={}){const L=(Array.isArray(f==null?void 0:f.promptBlocks)?f.promptBlocks:[]).filter(Ue=>(Ue==null?void 0:Ue.type)===kt.TEXT||(Ue==null?void 0:Ue.type)===kt.IMPORTED_TEXT||(Ue==null?void 0:Ue.type)===kt.IMAGE).map(Ue=>({type:Ue.type,content:String((Ue==null?void 0:Ue.content)||"").replace(/\u200b/g,"").trim(),meta:Ue!=null&&Ue.meta?{...Ue.meta}:{}})).filter(Ue=>Ue.content);if(L.length)return L;const ne=String((f==null?void 0:f.prompt)||"").replace(/\u200b/g,"").trim();return ne?[{type:kt.TEXT,content:ne,meta:{}}]:[]}function H(f={}){return Lt(f).length>0}function J(f={}){const _=Lt(f);_.length&&s("insert-code-context",{source:"response",blocks:_})}async function ce(f){var Bt,qt,ln,wt,Rt;const _=(qt=(Bt=f==null?void 0:f.target)==null?void 0:Bt.closest)==null?void 0:qt.call(Bt,'[data-copy-code="1"]');if(!_)return!1;const L=_.closest(".codex-code-block"),ne=(ln=L==null?void 0:L.querySelector)==null?void 0:ln.call(L,"pre code"),Ue=String((ne==null?void 0:ne.textContent)||"").replace(/\u200b/g,"");if(!Ue)return!1;(wt=f.preventDefault)==null||wt.call(f),(Rt=f.stopPropagation)==null||Rt.call(f);try{return await Je(Ue),s("toast",{message:Ce("sessionPanel.codeCopied"),type:"success"}),!0}catch{return s("toast",{message:Ce("errors.requestFailed"),type:"warning"}),!0}}function ve(f=""){return String(f||"").trim().split(/[?#]/)[0].replace(/:(\d+)(?::\d+)?$/,"")}function qe(f=""){const _=String(f||"").trim();try{return decodeURI(_)}catch{return _}}function ft(f=""){return qe(f).replace(/\\/g,"/").replace(/\/+/g,"/").trim()}function Ot(f=""){const _=ft(f).replace(/^\.\//,"").split("/").filter(Boolean);return!_.length||_.some(L=>L==="."||L==="..")?"":_.join("/")}function Vt(f=""){const _=String(f||"").trim();if(!_||_.startsWith("#")||_.startsWith("//"))return"";if(/^(?:https?:|mailto:|tel:|data:|blob:|javascript:)/i.test(_))try{const L=new URL(_);return L.origin!==window.location.origin?"":ve(L.pathname)}catch{return""}return ve(_)}function $t(f=""){const _=C(),L=ft((_==null?void 0:_.cwd)||"").replace(/\/$/,""),ne=ft(Vt(f));return!L||!ne?"":ne.startsWith("/")?ne===L||!ne.startsWith(`${L}/`)?"":Ot(ne.slice(L.length+1)):Ot(ne)}function Mt(f){var ne,Ue,Bt,qt;const _=(Ue=(ne=f==null?void 0:f.target)==null?void 0:ne.closest)==null?void 0:Ue.call(ne,".codex-markdown a[href]");if(!_)return!1;const L=$t(_.getAttribute("href")||"");return L?((Bt=f.preventDefault)==null||Bt.call(f),(qt=f.stopPropagation)==null||qt.call(f),w(null,{searchQuery:L})||s("toast",{message:Ce("sourceBrowser.noProject"),type:"warning"}),!0):!1}function pn(f){Mt(f)||ce(f)}function Ct(){if(!be.value.visible)return;const f=String(be.value.content||"").replace(/\u200b/g,"").trim();if(!f){Fe({clearBrowserSelection:!0});return}s("insert-code-context",{source:"response",content:f}),Fe({clearBrowserSelection:!0})}function tn(f={}){if(f!=null&&f.errorMessage)return;const _=String((f==null?void 0:f.responseMessage)||"").replace(/\u200b/g,"").trim();_&&s("insert-code-context",{source:"response",content:_})}const kn=G(()=>ae.value.flatMap(f=>(Array.isArray(f==null?void 0:f.promptBlocks)?f.promptBlocks:[]).filter(_=>(_==null?void 0:_.type)==="image").map(_=>_.content)));function Ht(f){const L=(Array.isArray(f==null?void 0:f.events)?f.events:[]).filter(ne=>!Qe(ne));return qp(L)}function Ft(f){return mt(f)}function Pt(f){return f!=null&&f.eventsLoaded?Ft(f)>0:_t(f)}function mn(f){return!!(f!=null&&f.eventsLoading)}function rn(f){return!!(f!=null&&f.eventsLoaded)&&Ht(f).length>0&&!yt(f)}function an(f){return!!(f!=null&&f.eventsLoaded)&&Ft(f)>0&&yt(f)}function gn(f){return _t(f)&&!(f!=null&&f.eventsLoaded)&&!(f!=null&&f.eventsLoading)}function nn(f={}){return qr(f,{defaultLabel:Ce("sessionPanel.defaultAgent")})}function hn(f={}){return!ap(f)}function sn(f={}){return"bg-[var(--theme-appPanelStrong)]"}function C(f=null){const _=String((f==null?void 0:f.id)||"").trim();if(_)return $e.value.find(ne=>ne.id===_)||null;const L=String(Q.value||"").trim();return L?$e.value.find(ne=>ne.id===L)||null:Ve.value[0]||null}function w(f=null,_={}){const L=C(f);return L!=null&&L.cwd?(gt.value=L.id,We.value=String(_.searchQuery||"").trim(),Ie.value=!0,!0):!1}function V(){return P.value?!1:(ee(),!0)}function oe(){var f,_;return Ie.value?(Ie.value=!1,!0):(_=(f=ze.value)==null?void 0:f.closeTopDialog)!=null&&_.call(f)?!0:Ne.value?(l(),!0):!1}return t({closeTopDialog:oe,openProjectManager:V,openSourceBrowser:w,send:B,scrollToBottom:De,stop:Ge}),(f,_)=>(h(),k("section",Kp,[ue(Cf,{open:Ie.value,session:a($e).find(L=>L.id===gt.value)||null,"initial-search-query":We.value,onInsertCodeContext:_[0]||(_[0]=L=>s("insert-code-context",L)),onClose:_[1]||(_[1]=L=>Ie.value=!1)},null,8,["open","session","initial-search-query"]),ue(a(o),{ref_key:"managerDialogRef",ref:ze,open:a(Ne),sessions:a($e),workspaces:a(de),"selected-session-id":a(Q),"selection-locked":e.sessionSelectionLocked,"selection-lock-reason":e.sessionSelectionLockReason,loading:a(ge),sending:a(he),"on-refresh":a(ye),"on-create":a(p),"on-update":a(E),"on-delete":a($),"on-reset":a(Z),onClose:a(l),onOpenSourceBrowser:_[2]||(_[2]=L=>w(L)),onProjectCreated:_[3]||(_[3]=L=>s("project-created",L)),onSelectSession:a(S)},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(Y)||""},[ue(nc,{modelValue:a(Q),"onUpdate:modelValue":_[4]||(_[4]=L=>Na(Q)?Q.value=L:null),sessions:a(Ve),loading:a(ge),disabled:a(he)||a(P)||e.sessionSelectionLocked,onRefreshIntent:a(le)},null,8,["modelValue","sessions","loading","disabled","onRefreshIntent"])],8,Yp),i("div",Jp,[i("button",{type:"button",class:xe(["tool-button inline-flex h-9 w-9 items-center justify-center whitespace-nowrap px-0 py-0 text-xs",a(A)?"tool-button-accent-subtle":""]),"aria-pressed":a(A)?"true":"false","aria-label":a(A)?a(Ce)("sessionPanel.hideProcessToggle"):a(Ce)("sessionPanel.showProcessToggle"),title:a(A)?a(Ce)("sessionPanel.hideProcessToggle"):a(Ce)("sessionPanel.showProcessToggle"),onClick:_[5]||(_[5]=(...L)=>a(Te)&&a(Te)(...L))},[a(A)?(h(),Ee(a(qa),{key:0,class:"h-4 w-4"})):(h(),Ee(a(Ka),{key:1,class:"h-4 w-4"}))],10,Qp),e.diffSupported?(h(),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:re},[ue(a(Go),{class:"h-4 w-4"}),_[17]||(_[17]=i("span",{class:"sm:hidden"},"代码",-1)),i("span",em,b(a(Ce)("sessionPanel.diff")),1)],8,Zp)):fe("",!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(P),onClick:_[6]||(_[6]=(...L)=>a(ee)&&a(ee)(...L))},[ue(a(ps),{class:"h-4 w-4"}),_[18]||(_[18]=i("span",{class:"sm:hidden"},"项目",-1)),i("span",nm,b(a(Ce)("sessionPanel.manageProjects")),1)],8,tm)])]),N.value?(h(),k("div",{key:0,class:"flex max-w-full items-center gap-1.5 overflow-x-auto pb-0.5","aria-label":a(Ce)("sessionPanel.agentFilter")},[i("button",{type:"button",class:xe(["theme-agent-selector-button",Oe.value==="all"?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Oe.value==="all"?"true":"false",onClick:_[7]||(_[7]=L=>Oe.value="all")},b(a(Ce)("sessionPanel.allAgents")),11,om),(h(!0),k(rt,null,ct(D.value,L=>(h(),k("button",{key:L.engine,type:"button",class:xe(["theme-agent-selector-button",Oe.value===L.engine?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Oe.value===L.engine?"true":"false",title:nn(L),onClick:ne=>Oe.value=L.engine},b(nn(L)),11,rm))),128))],8,sm)):fe("",!0),a(Me)?(h(),k("p",am,[ue(a(Do),{class:"h-4 w-4"}),i("span",null,b(a(Me)),1)])):fe("",!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:_[9]||(_[9]=(...L)=>a(K)&&a(K)(...L)),onTouchstartPassive:_[10]||(_[10]=(...L)=>a(te)&&a(te)(...L)),onTouchmovePassive:_[11]||(_[11]=(...L)=>a(R)&&a(R)(...L)),onTouchendPassive:_[12]||(_[12]=(...L)=>a(j)&&a(j)(...L)),onTouchcancelPassive:_[13]||(_[13]=(...L)=>a(j)&&a(j)(...L))},[a(ae).length?se.value.length?fe("",!0):(h(),k("div",um,b(a(Ce)("sessionPanel.emptyAgentFilter")),1)):(h(),k("div",lm,b(a(Ce)("sessionPanel.empty")),1)),(h(!0),k(rt,null,ct(se.value,L=>(h(),k("div",{key:L.id,"data-promptx-turn":"1","data-turn-id":L.id,"data-run-id":L.runId||"",class:"flex min-w-0 flex-col gap-3"},[i("div",dm,[i("div",fm,[i("div",pm,[i("span",mm,b(nt(L)),1),i("div",gm,[H(L)?(h(),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:ne=>J(L)},[ue(a(Us),{class:"h-3 w-3"}),i("span",null,b(a(Ce)("sessionPanel.insert")),1)],8,hm)):fe("",!0),i("span",null,b(a(u)(L.startedAt)),1)])]),i("div",vm,[Array.isArray(L.promptBlocks)&&L.promptBlocks.length?(h(),k("div",ym,[(h(!0),k(rt,null,ct(L.promptBlocks,(ne,Ue)=>(h(),k(rt,{key:`${L.id}-prompt-${Ue}`},[ne.type==="text"||ne.type==="imported_text"?(h(),k("pre",Sm,b(ne.content),1)):(h(),k("button",{key:1,type:"button",class:"inline-flex cursor-zoom-in justify-center rounded-sm",onClick:Bt=>ot(ne.content)},[i("img",{src:ne.content,alt:a(Ce)("sessionPanel.promptImageAlt"),class:"max-h-52 w-auto max-w-full rounded-sm object-contain shadow-sm"},null,8,xm)],8,wm))],64))),128))])):(h(),k("pre",bm,b(L.prompt),1))])])]),a(A)&&hn(L)?(h(),k("div",km,[i("div",{class:xe(["transcript-card transcript-card--process min-w-0 w-full rounded-sm px-4 py-3",a(m)(L)])},[i("div",Tm,[i("span",_m,b(a(Ce)("sessionPanel.processTitle")),1),i("div",Cm,[Pt(L)?(h(),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:L.eventsLoading,onClick:ne=>a(It)(L)},[mn(L)?(h(),Ee(a(Xt),{key:0,class:"h-3 w-3 animate-spin"})):a(yt)(L)?(h(),Ee(a(Po),{key:1,class:"h-3 w-3"})):(h(),Ee(a(Wa),{key:2,class:"h-3 w-3"})),i("span",null,b(L.eventsLoading?a(Ce)("sessionPanel.loading"):a(yt)(L)?`${a(Ce)("sessionPanel.expand")} (${Ft(L)})`:a(Ce)("sessionPanel.collapse")),1)],8,Em)):fe("",!0),i("span",null,b(a(x)(L)),1)])]),mn(L)?(h(),k("div",Am,b(a(Ce)("sessionPanel.loadingEvents")),1)):rn(L)?(h(),k("div",Im,[(h(!0),k(rt,null,ct(Ht(L),ne=>(h(),k("div",{key:ne.id,class:xe(["transcript-event-card min-w-0 rounded-sm px-3 py-2",sn(ne)])},[i("div",$m,b(ne.title),1),ne.detail||Array.isArray(ne.detailBlocks)&&ne.detailBlocks.length?(h(),Ee(sd,{key:0,detail:ne.detail,blocks:ne.detailBlocks,kind:ne.kind,class:"mt-2"},null,8,["detail","blocks","kind"])):fe("",!0)],2))),128))])):an(L)||gn(L)?(h(),k("div",Pm,b(L.eventsLoaded?a(Ce)("sessionPanel.hiddenEventsLoaded",{count:Ft(L)}):a(Ce)("sessionPanel.hiddenEventsLoadLater",{count:Ft(L)})),1)):(h(),k("p",Dm,b(["queued","starting","running","stopping"].includes(L.status)?a(Ce)("sessionPanel.waitingEvents",{agent:a(c)(L)}):a(Ce)("sessionPanel.noEvents")),1)),a(I)(L)?(h(),k("div",Lm,[a(g)(L)?(h(),k("div",Mm,b(a(g)(L)),1)):fe("",!0),a(v)(L)?(h(),k("div",Bm,b(a(v)(L)),1)):fe("",!0),a(T)(L).length?(h(),k("div",Rm,[(h(!0),k(rt,null,ct(a(T)(L),ne=>(h(),k("span",{key:ne.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(ne.label),1),i("span",Nm,b(ne.value),1)]))),128))])):fe("",!0)])):fe("",!0)],2)])):fe("",!0),a(Re)(L)?(h(),k("div",Om,[i("div",{class:xe(["transcript-card transcript-card--response min-w-0 w-full rounded-sm px-4 py-3 text-sm leading-7",L.errorMessage?"bg-[var(--theme-dangerSoft)] text-[var(--theme-dangerText)]":"bg-[var(--theme-responseBg)] text-[var(--theme-responseText)]"])},[i("div",Fm,[i("span",Um,b(Tt(L)),1),i("div",jm,[e.diffSupported&&L.runId?(h(),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:ne=>Gt(L)},[ue(a(Go),{class:"h-3 w-3"}),i("span",null,b(a(Ce)("sessionPanel.view")),1)],8,Vm)):fe("",!0),L.responseMessage&&!L.errorMessage?(h(),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:ne=>tn(L)},[ue(a(Us),{class:"h-3 w-3"}),i("span",null,b(a(Ce)("sessionPanel.insert")),1)],8,zm)):fe("",!0),i("span",null,b(a(u)(L.finishedAt||L.startedAt)),1)])]),i("div",Hm,[L.errorMessage?(h(),k("div",qm,b(L.errorMessage),1)):(h(),k("div",{key:1,class:"prose-like codex-markdown","data-response-selection-root":"1",onMouseup:_[8]||(_[8]=(...ne)=>a(Pe)&&a(Pe)(...ne)),onClick:pn,innerHTML:a(Be)(L)},null,40,Km))])],2)])):fe("",!0)],8,cm))),128)),a(be).visible?(h(),Ee(na,{key:2,top:a(be).top,left:a(be).left,label:a(Ce)("sourceBrowser.insertSelection"),onClick:Ct},null,8,["top","left","label"])):fe("",!0)],544),i("div",Wm,[a(_e)?(h(),k("button",{key:0,type:"button",class:xe([a(he)?"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:_[14]||(_[14]=(...L)=>a(De)&&a(De)(...L))},[ue(a(Ga),{class:"h-3.5 w-3.5"}),i("span",null,b(a(Ce)("sessionPanel.jumpToLatest")),1)],2)):fe("",!0),a(he)?(h(),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(X),onClick:_[15]||(_[15]=(...L)=>a(Ge)&&a(Ge)(...L))},[a(X)?(h(),Ee(a(Xt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),Ee(a(Xa),{key:1,class:"h-3.5 w-3.5"})),i("span",null,b(a(X)?a(Ce)("sessionPanel.stopping"):a(Ce)("sessionPanel.stop")),1),a(X)?fe("",!0):(h(),k("span",Xm,[..._[19]||(_[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)):fe("",!0)])]),ue(Kr,{modelValue:lt.value,"onUpdate:modelValue":_[16]||(_[16]=L=>lt.value=L),images:kn.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=z(null);function r(){var T,v;return(v=(T=s.value)==null?void 0:T.send)==null?void 0:v.call(T)}function l(){var T,v;(v=(T=s.value)==null?void 0:T.stop)==null||v.call(T)}function u(){var T,v;(v=(T=s.value)==null?void 0:T.scrollToBottom)==null||v.call(T)}function m(){var T,v;return((v=(T=s.value)==null?void 0:T.openProjectManager)==null?void 0:v.call(T))||!1}function x(){var T,v;return((v=(T=s.value)==null?void 0:T.openSourceBrowser)==null?void 0:v.call(T))||!1}function c(){var T,v;return((v=(T=s.value)==null?void 0:T.closeTopDialog)==null?void 0:v.call(T))||!1}return t({closeTopDialog:c,openProjectManager:m,openSourceBrowser:x,send:r,stop:l,scrollToBottom:u}),(T,v)=>e.taskSlug?(h(),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:v[0]||(v[0]=g=>o("agent-bindings-change",g)),onInsertCodeContext:v[1]||(v[1]=g=>o("insert-code-context",g)),onProjectCreated:v[2]||(v[2]=g=>o("project-created",g)),onSendingChange:v[3]||(v[3]=g=>o("sending-change",g)),onSelectedSessionChange:v[4]||(v[4]=g=>o("selected-session-change",g)),"onUpdate:selectedAgentEngine":v[5]||(v[5]=g=>o("update:selectedAgentEngine",g)),onOpenDiff:v[6]||(v[6]=g=>o("open-diff",g)),onToast:v[7]||(v[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?(h(),k("section",Qm,b(e.emptyMessage),1)):fe("",!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}=At(),r=G(()=>{const c=new Set;return(Array.isArray(n.agentBindings)?n.agentBindings:[]).filter(T=>{const v=String((T==null?void 0:T.engine)||"").trim();return!v||c.has(v)?!1:(c.add(v),!0)})}),l=G(()=>r.value.length>1),u=G(()=>{var T,v;const c=String(n.selectedAgentEngine||"").trim();return r.value.some(g=>g.engine===c)?c:((T=r.value.find(g=>g.isDefault))==null?void 0:T.engine)||((v=r.value[0])==null?void 0:v.engine)||""}),m=G(()=>n.align==="end"?"sm:justify-end":n.align==="center"?"sm:justify-center":"sm:justify-start");function x(c={}){return qr(c,{prefix:"→ ",defaultLabel:s("sessionPanel.defaultAgent")})}return(c,T)=>l.value?(h(),k("div",{key:0,class:xe(["flex w-full overflow-x-auto pb-0.5",m.value]),title:a(s)("editor.selectAgent"),"data-promptx-agent-targets":"",onMousedown:T[1]||(T[1]=et(()=>{},["stop"]))},[i("div",eg,[(h(!0),k(rt,null,ct(r.value,v=>(h(),k("button",{key:v.engine,type:"button",class:xe(["theme-agent-selector-button",v.engine===u.value?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":v.engine===u.value,title:x(v),"data-agent-engine":v.engine,onMousedown:T[0]||(T[0]=et(()=>{},["prevent"])),onClick:g=>o("update:selectedAgentEngine",v.engine)},b(x(v)),43,tg))),128))])],42,Zm)):fe("",!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}=At(),r=G(()=>n.sendState==="sending"||n.sendState==="running");function l(){return n.todoCount>0?s("editor.todoWithCount",{count:n.todoCount}):s("editor.todo")}return(u,m)=>(h(),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:m[0]||(m[0]=et(()=>{},["prevent"])),onClick:m[1]||(m[1]=x=>o("open-file-picker"))},[e.uploading?(h(),Ee(a(Xt),{key:0,class:"h-4 w-4 animate-spin"})):(h(),Ee(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:m[2]||(m[2]=et(()=>{},["prevent"])),onClick:m[3]||(m[3]=x=>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:m[4]||(m[4]=et(()=>{},["prevent"])),onClick:m[5]||(m[5]=x=>o("add-todo"))},[ue(a(Us),{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:m[6]||(m[6]=et(()=>{},["prevent"])),onClick:m[7]||(m[7]=x=>o("manage-todo"))},[ue(a(Nr),{class:"h-4 w-4"}),i("span",dg,b(l()),1),e.todoCount>0?(h(),k("span",fg,b(e.todoCount>9?"9+":e.todoCount),1)):fe("",!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:m[8]||(m[8]=et(()=>{},["prevent"])),onClick:m[9]||(m[9]=x=>o("send-request"))},[r.value?(h(),Ee(a(Xt),{key:0,class:"h-4 w-4 animate-spin"})):(h(),Ee(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=z({left:"12px",top:"12px",width:"560px",maxHeight:"420px"}),r=z(!1),l=z("bottom");function u(){o==null||o()}function m(g=!1){const p=window.innerWidth,$=window.innerHeight,Z=12,S=8,B=320,K=560,j=420,R=180,te=Math.min(K,Math.max(B,p-Z*2)),E=Math.min(te,p-Z*2),Y=t.anchorRect||{left:(p-E)/2,top:$/2,bottom:$/2};let pe=Y.left;pe+E>p-Z&&(pe=p-Z-E),pe<Z&&(pe=Z);const ge=Math.max(0,$-Z-(Y.bottom+S)),P=Math.max(0,Y.top-S-Z);g?l.value=ge>=P?"bottom":"top":l.value==="bottom"&&ge<R&&P>ge+24?l.value="top":l.value==="top"&&P<R&&ge>P+24&&(l.value="bottom");const ee=l.value,le=ee==="bottom"?ge:P,Q=Math.max(140,$-Z*2),he=Math.min(Q,Math.max(Math.min(j,le||j),R)),A={left:`${Math.round(pe)}px`,width:`${Math.round(E)}px`,maxHeight:`${Math.round(he)}px`,top:"auto",bottom:"auto"};return ee==="bottom"?A.top=`${Math.round(Math.max(Z,Y.bottom+S))}px`:A.bottom=`${Math.round(Math.max(Z,$-Y.top+S))}px`,A}function x(g=!1){const p=m(g);s.value={...s.value,left:p.left,top:p.top,bottom:p.bottom,width:p.width,maxHeight:p.maxHeight}}function c(){return!t.open||!t.anchorRect?!1:(l.value="bottom",x(!0),r.value=!0,!0)}function T(){r.value=!1}function v(g){!t.open||!n.value||n.value.contains(g.target)||u()}return fn(()=>{document.addEventListener("pointerdown",v)}),Nt(()=>{document.removeEventListener("pointerdown",v)}),{closePicker:u,initializePanel:c,panelReady:r,panelStyle:s,resetPanel:T,updatePanelPosition:x}}function hg(e){const{props:t,panelRef:n,onClose:o,onSelect:s}=e,{closePicker:r,initializePanel:l,panelReady:u,panelStyle:m,resetPanel:x,updatePanelPosition:c}=gg({props:t,panelRef:n,onClose:o}),T=aa({getMode:()=>String(t.query||"").trim()?"search":"tree",props:t,onSelect:s});return Ae(()=>t.open,v=>{if(!v){T.resetData(),x();return}x(),t.anchorRect&&l()&&T.initializeData()},{flush:"sync"}),Ae(()=>t.anchorRect,v=>{if(!(!t.open||!v)){if(!u.value){l()&&T.initializeData();return}c(!1)}},{flush:"sync"}),Ae(()=>t.sessionId,()=>{T.handleSessionChange()},{flush:"sync",immediate:!0}),Ae(()=>t.query,()=>{T.handleQueryChange()},{immediate:!0}),Ae(T.visibleItems,()=>{T.handleVisibleItemsChange()},{immediate:!0}),{...T,closePicker:r,panelReady:u,panelStyle:m}}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=z(null),{t:l}=At(),{activeKey:u,closePicker:m,collapseActiveDirectory:x,confirmActive:c,currentError:T,currentLoading:v,emitSelect:g,expandActiveDirectory:p,getDisplayName:$,getHighlightedName:Z,getHighlightedPath:S,moveActive:B,normalSearchItems:K,normalizedQuery:j,panelReady:R,panelStyle:te,recentSearchItems:E,setItemRef:Y,showSearchEmptyState:pe,showTreeEmptyState:ge,toggleDirectory:P,treeItems:ee,visibleItems:le}=hg({props:o,panelRef:r,onClose:()=>s("close"),onSelect:Q=>s("select",Q)});return t({collapseActiveDirectory:x,moveActive:B,confirmActive:c,expandActiveDirectory:p}),(Q,he)=>(h(),Ee(ys,{to:"body"},[e.open&&a(R)?(h(),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:Bn(a(te))},[i("div",vg,[i("div",yg,[i("div",{class:xe(["theme-muted-text inline-flex h-7 w-7 items-center justify-center",a(v)?"opacity-100":"opacity-0"])},[ue(a(Xt),{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:he[0]||(he[0]=(...A)=>a(m)&&a(m)(...A))},[ue(a(Mr),{class:"h-4 w-4"})])])]),i("div",Sg,[e.sessionId?a(T)?(h(),k("div",xg,b(a(T)),1)):a(pe)?(h(),k("div",bg,b(a(l)("pathPicker.noResults")),1)):a(ge)?(h(),k("div",kg,b(a(l)("pathPicker.emptyDirectory")),1)):a(v)&&!a(le).length?(h(),k("div",Tg,b(a(l)("pathPicker.loading")),1)):a(j)?(h(),k("div",_g,[a(E).length?(h(),k("div",Cg,b(a(l)("pathPicker.recent")),1)):fe("",!0),(h(!0),k(rt,null,ct(a(E),A=>(h(),k("button",{key:A.path,ref_for:!0,ref:X=>a(Y)(A.path,X),type:"button",class:xe(["theme-list-row focus:outline-none",a(u)===A.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:X=>a(g)(A)},[(h(),Ee(bn(A.type==="directory"?a(Hn):a(Pn)),{class:"theme-list-item-icon"})),i("div",Ag,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Z)(A)},null,8,Ig)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(S)(A)},null,8,$g)])],10,Eg))),128)),a(j)&&a(K).length?(h(),k("div",Pg,b(a(l)("pathPicker.results")),1)):fe("",!0),(h(!0),k(rt,null,ct(a(K),A=>(h(),k("button",{key:A.path,ref_for:!0,ref:X=>a(Y)(A.path,X),type:"button",class:xe(["theme-list-row focus:outline-none",a(u)===A.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:X=>a(g)(A)},[(h(),Ee(bn(A.type==="directory"?a(Hn):a(Pn)),{class:"theme-list-item-icon"})),i("div",Lg,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Z)(A)},null,8,Mg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(S)(A)},null,8,Bg)])],10,Dg))),128))])):(h(),k("div",Rg,[(h(!0),k(rt,null,ct(a(ee),A=>(h(),k("div",{key:A.path,ref_for:!0,ref:X=>a(Y)(A.path,X),class:xe(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(u)===A.path?"theme-list-item-active":A.type==="directory"&&A.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:Bn({paddingLeft:`${A.depth*16+6}px`})},[i("div",Ng,[A.type==="directory"?(h(),k("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:et(X=>a(P)(A.path),["stop"])},[A.loading?(h(),Ee(a(Xt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(h(),Ee(a(Rr),{key:1,class:xe(["h-3.5 w-3.5 transition",A.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,Og)):(h(),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:X=>a(g)(A)},[(h(),Ee(bn(A.type==="directory"?a(Hn):a(Pn)),{class:xe(["h-4 w-4 shrink-0",A.type==="directory"&&A.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("div",jg,[i("div",Vg,[i("span",{class:xe(["theme-list-item-title truncate",A.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},b(a($)(A)),3)])])],8,Ug)])],6))),128))])):(h(),k("div",wg,b(a(l)("pathPicker.selectProjectFirst")),1))])],4)):fe("",!0)]))}},Hg={__name:"TiptapTextBlockView",props:Lo,setup(e){return(t,n)=>(h(),Ee(a(Mo),{"data-promptx-node":"text"},{default:Ze(()=>[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=G(()=>t.selected?"ring-1 ring-inset ring-[var(--theme-borderStrong)]":""),o=G(()=>t.selected?"opacity-100":"opacity-100 sm:opacity-45 sm:group-hover:opacity-100 sm:focus-within:opacity-100");return(s,r)=>(h(),k("div",{class:xe(["overflow-hidden rounded-sm transition",[e.frameClass,n.value]])},[i("div",{class:xe(["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 Wn(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 zn(e=""){return Wn({type:kt.TEXT,content:e,meta:{}})}function Cs(e){return e&&e.type!==kt.TEXT}function Ln(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];if(!t.length)return[zn("")];const n=[];return t.forEach((o,s)=>{const r=Wn(o),l=n[n.length-1];!l&&Cs(r)&&n.push(zn("")),l&&Cs(l)&&Cs(r)&&n.push(zn("")),n.push(r),s===t.length-1&&Cs(r)&&n.push(zn(""))}),n}function Ao(e=""){const t=String(e||"").split(`
41
+ `),n=[];return t.forEach((o,s)=>{o&&n.push({type:Dt.TEXT,text:o}),s<t.length-1&&n.push({type:Dt.HARD_BREAK})}),n}function Kg(e=""){return Ao(e)}function Wg(e=[]){if(Array.isArray(e))return e;if(typeof(e==null?void 0:e.toArray)=="function")return e.toArray();if(typeof(e==null?void 0:e.forEach)=="function"){const t=[];return e.forEach(n=>{t.push(n)}),t}return[]}function Hs(e=[]){return Wg(e).map(t=>{var o;const n=typeof(t==null?void 0:t.type)=="string"?t.type:(o=t==null?void 0:t.type)==null?void 0:o.name;return n===Dt.TEXT?String(t.text||""):n===Dt.HARD_BREAK?`
42
+ `:Hs((t==null?void 0:t.content)||[])}).join("")}function Gg(e=[]){return Hs(e)}function Xg(e={}){var n,o;const t=Wn(e);return t.type===kt.IMAGE?{type:Dt.IMAGE_BLOCK,attrs:{clientId:t.clientId,src:String(t.content||"")}}:t.type===kt.IMPORTED_TEXT?{type:Dt.IMPORTED_TEXT_BLOCK,attrs:{clientId:t.clientId,fileName:String(((n=t.meta)==null?void 0:n.fileName)||""),collapsed:!!((o=t.meta)!=null&&o.collapsed)},content:Ao(t.content)}:{type:Dt.TEXT_BLOCK,attrs:{clientId:t.clientId},content:Ao(t.content)}}function Ea(e=[]){return Ln(e).map(Xg)}function Es(e=[]){return{type:Dt.DOC,content:Ea(e)}}function Yg(e={}){var t,n,o,s,r,l;return(e==null?void 0:e.type)===Dt.IMAGE_BLOCK?Wn({type:kt.IMAGE,content:String(((t=e.attrs)==null?void 0:t.src)||""),clientId:String(((n=e.attrs)==null?void 0:n.clientId)||""),meta:{}}):(e==null?void 0:e.type)===Dt.IMPORTED_TEXT_BLOCK?Wn({type:kt.IMPORTED_TEXT,content:Hs(e.content||[]),clientId:String(((o=e.attrs)==null?void 0:o.clientId)||""),meta:{fileName:String(((s=e.attrs)==null?void 0:s.fileName)||""),collapsed:!!((r=e.attrs)!=null&&r.collapsed)}}):(e==null?void 0:e.type)===Dt.TEXT_BLOCK?Wn({type:kt.TEXT,content:Hs(e.content||[]),clientId:String(((l=e.attrs)==null?void 0:l.clientId)||""),meta:{}}):null}function Jg(e=null){const n=(Array.isArray(e==null?void 0:e.content)?e.content:[]).map(Yg).filter(Boolean);return Ln(n)}function as(e=[]){return JSON.stringify(Ln(e).map(t=>{var n,o;return{type:(t==null?void 0:t.type)||"",content:String((t==null?void 0:t.content)||""),meta:{fileName:String(((n=t==null?void 0:t.meta)==null?void 0:n.fileName)||""),collapsed:!!((o=t==null?void 0:t.meta)!=null&&o.collapsed)}}}))}function Qg(e=""){const t=String(e);return{lines:t?t.split(`
43
+ `).length:0,chars:t.length}}function Rs(e){var l;const t=(l=e==null?void 0:e.view)==null?void 0:l.dom;if(!(t instanceof HTMLElement))return;const n=t.closest('[data-promptx-editor-scroll="tiptap"]'),o=n instanceof HTMLElement?n.scrollTop:null,s=n instanceof HTMLElement?n.scrollLeft:null,r=()=>{t.focus({preventScroll:!0}),n instanceof HTMLElement&&o!==null&&(n.scrollTop=o,n.scrollLeft=s??0)};if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){window.requestAnimationFrame(r);return}queueMicrotask(r)}const Zg={class:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-x-3 gap-y-1.5","data-promptx-imported-meta":""},eh=["aria-expanded"],th={class:"theme-heading inline-flex items-center gap-1.5 text-xs font-medium leading-5"},nh=["aria-expanded"],sh={class:"mt-0.5 break-all text-[12px] leading-4 text-[var(--theme-textSecondary)]"},oh=["aria-label"],rh={class:"max-h-[8.5rem] overflow-hidden whitespace-pre-wrap break-words leading-6"},ah={key:0,class:"pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-[var(--theme-appPanelMuted)] to-transparent"},ih={key:1,class:"theme-muted-text absolute bottom-2 right-4 bg-[var(--theme-appPanelMuted)] pl-2 text-xs"},So="tool-button inline-flex min-w-0 items-center justify-center gap-1 whitespace-nowrap px-2 py-1 text-[12px]",lh={__name:"TiptapImportedTextBlockView",props:Lo,setup(e){const t=e,{t:n}=At(),o=G(()=>{var g;return Gg(((g=t.node)==null?void 0:g.content)||[])}),s=G(()=>{var g,p;return String(((p=(g=t.node)==null?void 0:g.attrs)==null?void 0:p.fileName)||n("blockEditor.unnamedFile"))}),r=G(()=>{const g=Qg(o.value);return n("blockEditor.stats",g)}),l=G(()=>n("blockEditor.fileSummary",{name:s.value,stats:r.value})),u=G(()=>{const g=String(o.value||"").replace(/\r\n/g,`
44
+ `),p=g.split(`
45
+ `),$=[];let Z=0;for(const K of p){const j=K.trimEnd(),R=j.length?j:"";if(!(!R&&$[$.length-1]==="")&&($.push(R),Z+=R.length,$.length>=4||Z>=220))break}const S=$.join(`
46
+ `).trim(),B=g.trim();return{text:S,truncated:$.length<p.length||S.length<B.length}}),m=`${So} tool-button-danger-subtle`;function x(g){g.key!=="Enter"&&g.key!==" "||(g.preventDefault(),c())}function c(){var g,p,$;($=t.updateAttributes)==null||$.call(t,{collapsed:!((p=(g=t.node)==null?void 0:g.attrs)!=null&&p.collapsed)}),Rs(t.editor)}function T(){var S;const{editor:g,getPos:p,node:$}=t;if(!g||typeof p!="function"||!$)return;const Z=p();g.chain().focus().insertContentAt({from:Z,to:Z+$.nodeSize},{type:Dt.TEXT_BLOCK,attrs:{clientId:String(((S=$.attrs)==null?void 0:S.clientId)||"")},content:Kg(o.value)}).run(),Rs(t.editor)}function v(){var g;(g=t.deleteNode)==null||g.call(t),Rs(t.editor)}return(g,p)=>(h(),Ee(a(Mo),{class:"group relative","data-promptx-node":"imported_text"},{default:Ze(()=>[ue(Ca,{selected:g.selected,"frame-class":"dashed-panel","header-class":"theme-secondary-text border-dashed","header-padding-class":"px-3 py-2"},{header:Ze(({actionsStateClass:$})=>{var Z,S,B,K;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:x},[i("p",th,[ue(a(js),{class:"h-3.5 w-3.5 shrink-0"}),Sn(" "+b(a(n)("blockEditor.file")),1)])],40,eh),i("div",{"data-promptx-imported-actions":"",class:xe(["col-start-2 row-start-1 flex shrink-0 flex-wrap items-center justify-end gap-1 self-start transition",$])},[i("button",{type:"button",class:xe(So),contenteditable:"false",onClick:c},[ue(a(Po),{class:xe(["h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5",(S=g.node.attrs)!=null&&S.collapsed?"rotate-180":""])},null,8,["class"]),i("span",null,b((B=g.node.attrs)!=null&&B.collapsed?a(n)("blockEditor.expand"):a(n)("blockEditor.collapse")),1)]),i("button",{type:"button",class:xe(So),contenteditable:"false",onClick:T},[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.convertToText")),1)]),i("button",{type:"button",class:xe(m),contenteditable:"false",onClick:v},[ue(a(Ys),{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(!((K=g.node.attrs)!=null&&K.collapsed)),onClick:c,onKeydown:x},[i("p",sh,b(l.value),1)],40,nh)])]}),default:Ze(()=>{var $,Z;return[Zt(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:x},[i("div",rh,b(u.value.text||a(n)("blockEditor.emptyContent")),1),u.value.truncated?(h(),k("div",ah)):fe("",!0),u.value.truncated?(h(),k("span",ih,"...")):fe("",!0)],40,oh),[[Os,($=g.node.attrs)==null?void 0:$.collapsed]]),Zt(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),[[Os,!((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}=At();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),Rs(t.editor)}return(r,l)=>(h(),Ee(a(Mo),{class:"group","data-promptx-node":"image"},{default:Ze(()=>[ue(Ca,{selected:r.selected,"frame-class":"theme-inline-panel border","header-class":"theme-muted-text","header-padding-class":"px-3 py-2"},{header:Ze(({actionsStateClass:u})=>[i("div",uh,[i("div",ch,[ue(a(Or),{class:"h-3.5 w-3.5 shrink-0"}),Sn(" "+b(a(n)("blockEditor.image")),1)]),i("div",{class:xe(["shrink-0 transition",u])},[i("button",{type:"button",class:xe(ph),contenteditable:"false",onClick:s},[ue(a(Ys),{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:Ze(()=>{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}=At(),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"]),m=["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(","),x=z(null),c=z(null),T=z(""),v=z(ze()),g=z(null),p=z(null),$=z(!1),Z=z(0),S=G(()=>Ln(o.modelValue)),B=G(()=>S.value.filter(D=>(D==null?void 0:D.type)===kt.IMAGE&&String(D.content||"").trim()).map(D=>String(D.content||"").trim()));let K=as(S.value);function j(D=Y.value){if(!D)return!1;const N=Jg(D.getJSON()),se=as(N);return se===K?!1:(K=se,s("update:modelValue",N),!0)}const R=li.extend({name:Dt.TEXT_BLOCK,group:"block",content:"inline*",addAttributes(){return{clientId:{default:""}}},addNodeView(){return oo(Hg)}}),te=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:D}){return["div",{...D,"data-type":"promptx-imported-text-block"}]},addNodeView(){return oo(lh)}}),E=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:D}){return["div",{...D,"data-type":"promptx-image-block"}]},addNodeView(){return oo(mh)}}),Y=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}),R,te,E],autofocus:!1,editorProps:{attributes:{class:"tiptap-editor min-h-full outline-none"},handleKeyDown(D,N){return Ma(N,{sendBehavior:o.sendBehavior,isEditing:!0,isComposing:ye()})?(N.preventDefault(),N.stopPropagation(),s("send-request"),!0):!N.shiftKey&&!N.altKey&&(N.metaKey||N.ctrlKey)&&String(N.key||"").toLowerCase()==="k"?Ce():ut(N)}},content:Es(S.value),onCreate({editor:D}){Oe(D)},onFocus({editor:D}){$.value=!0,Oe(D)},onBlur(){$.value=!1},onSelectionUpdate({editor:D}){Oe(D)},onUpdate({editor:D}){Z.value=Date.now(),j(D),Oe(D)}});Ae(Y,D=>{if(!D)return;const N=Ln(o.modelValue);K=as(N),D.commands.setContent(Es(N),!1)},{immediate:!0}),Ae(()=>o.modelValue,D=>{const N=Y.value;if(!N){K=as(Ln(D));return}const se=Ln(D),be=as(se);be!==K&&(K=be,N.commands.setContent(Es(se),!1))},{deep:!0});function pe(D){const N=String(D||"").trim();N&&s("file-feedback",N)}function ge(D){const N=String((D==null?void 0:D.name)||"").trim().toLowerCase();return N.includes(".")?`.${N.split(".").pop()}`:""}function P(D,N){return String((D==null?void 0:D.name)||"").trim()||r(N)}function ee(D){const N=Math.max(0,Number(D)||0);return N>=1024*1024?`${(N/(1024*1024)).toFixed(N>=10*1024*1024?0:1)} MB`:N>=1024?`${Math.round(N/1024)} KB`:`${N} B`}function le(D){if(!D)return!1;const N=String(D.type||"").toLowerCase(),se=ge(D);return N.startsWith("text/")||l.has(se)||u.has(N)}function Q(D){if(!D)return!1;const N=String(D.name||"").toLowerCase(),se=String(D.type||"").toLowerCase();return N.endsWith(".pdf")||se==="application/pdf"}function he(D){const N=Array.from(D||[]).filter(Boolean),se={imageFiles:[],textFiles:[],pdfFiles:[]},be=[],Fe=[];return N.forEach(Pe=>{if(Pe.type.startsWith("image/")){if(Pe.size>Sr){Fe.push({name:P(Pe,"blockEditor.unnamedImage"),limit:ee(Sr)});return}se.imageFiles.push(Pe);return}if(Q(Pe)){if(Pe.size>xr){Fe.push({name:P(Pe,"blockEditor.unnamedPdf"),limit:ee(xr)});return}se.pdfFiles.push(Pe);return}if(le(Pe)){if(Pe.size>wr){Fe.push({name:P(Pe,"blockEditor.unnamedFile"),limit:ee(wr)});return}se.textFiles.push(Pe);return}be.push(P(Pe,"blockEditor.unnamedFile"))}),{...se,unsupportedFiles:be,oversizedFiles:Fe}}function A({unsupportedFiles:D=[],oversizedFiles:N=[]}={}){var se;D.length&&pe(r("blockEditor.unsupportedFiles",{names:D.slice(0,3).join("、"),extra:Math.max(0,D.length-3)})),N.length&&pe(r("blockEditor.oversizedFiles",{names:N.slice(0,2).map(be=>be.name).join("、"),extra:Math.max(0,N.length-2),limit:((se=N[0])==null?void 0:se.limit)||""}))}function X(D){const{imageFiles:N,textFiles:se,pdfFiles:be,unsupportedFiles:Fe,oversizedFiles:Pe}=he(D);return A({unsupportedFiles:Fe,oversizedFiles:Pe}),se.length&&s("import-text-files",se),be.length&&s("import-pdf-files",be),N.length&&s("upload-files",N),N.length+se.length+be.length>0}function I(D){const N=[...D.clipboardData.items].filter(se=>se.kind==="file").map(se=>se.getAsFile()).filter(Boolean);N.length&&(D.preventDefault(),X(N))}function _e(D){D.preventDefault(),X(D.dataTransfer.files)}function Me(D){const N=Y.value;if(!N)return;const se=D.target instanceof Element?D.target:null,be=D.currentTarget instanceof Element?D.currentTarget:null,Fe=N.view.dom instanceof Element?N.view.dom:null;!se||!be||!Fe||se.closest('button, input, textarea, select, a, [contenteditable="false"]')||!be.contains(se)||se.closest("[data-promptx-node]")||!(se===be||se===Fe||be.contains(se))||(D.preventDefault(),Ve())}function Re(D){X(D.target.files),D.target.value=""}function Ne(){var D;(D=x.value)==null||D.click()}function Ve(){const D=Y.value;D&&D.chain().focus("end").run()}function Ge(){var se,be;const D=Y.value;if(!D)return!1;(be=(se=D.view.domObserver)==null?void 0:se.flush)==null||be.call(se);const N=j(D);return N&&(Z.value=Date.now()),Oe(D),N}function Te(D=[]){const N=Y.value;!N||!D.length||N.chain().focus().insertContent(D).run()}function W(D=[]){Te(Ea(D))}function ae(D=[]){W(D)}function de(D=[]){W(D)}function $e(){const D=Y.value;D&&D.commands.setContent(Es([zn("")]),!0)}function ye(){var D,N;return!!((N=(D=Y.value)==null?void 0:D.view)!=null&&N.composing)}function Le(){var D;return ye()||$.value||(D=Y.value)!=null&&D.isFocused?!0:Date.now()-Z.value<hh}function me(){var be;const D=Y.value;if(!D)return!1;const N=D.state.selection,se=N.$from.nodeAfter||N.$from.parent;return((be=se==null?void 0:se.type)==null?void 0:be.name)===Dt.IMPORTED_TEXT_BLOCK}function De(D){var se;const N=String(((se=D==null?void 0:D.detail)==null?void 0:se.src)||"").trim();N&&(T.value=N)}function ze(){return{open:!1,start:-1,end:-1,query:"",trigger:"mention",blockType:"",clientId:""}}function Ie(D=null,N=null){return!D||!N?!1:D.start===N.start&&D.end===N.end&&D.query===N.query&&D.clientId===N.clientId}function gt(){g.value=null}function We(D={}){const{suppressCurrent:N=!1}=D,se=v.value;N&&se.open&&(p.value={start:se.start,end:se.end,query:se.query,clientId:se.clientId}),v.value=ze(),gt()}function lt(){We({suppressCurrent:!0})}function ht(D=Y.value){var Qe,nt,Tt;if(!D)return null;const N=D.state.selection;if(!N.empty)return null;const{$from:se,from:be}=N,Fe=((nt=(Qe=se.parent)==null?void 0:Qe.type)==null?void 0:nt.name)||"";if(![Dt.TEXT_BLOCK,Dt.IMPORTED_TEXT_BLOCK].includes(Fe))return null;const Pe=se.parent.textBetween(0,se.parentOffset,`
47
+ `,"\0");return{from:be,node:se.parent,nodeTypeName:Fe,nodeStart:se.start(),parentOffset:se.parentOffset,clientId:String(((Tt=se.parent.attrs)==null?void 0:Tt.clientId)||""),textBefore:Pe}}function vt(D=v.value.end){const N=Y.value;if(typeof D=="object"&&D!==null&&(D=v.value.end),!N||!v.value.open||D<0){gt();return}try{const se=N.view.coordsAtPos(D);g.value={left:se.left,right:se.left,top:se.bottom,bottom:se.bottom,width:0,height:0}}catch{gt()}}function Oe(D=Y.value){const N=ht(D),se=v.value;if(se.open&&se.trigger==="shortcut"){if(!N||N.clientId!==se.clientId||N.from<se.start){We();return}const nt=D.state.doc.textBetween(se.start,N.from,`
48
+ `,"\0");if(/\s/.test(nt)){We();return}p.value=null,v.value={...se,end:N.from,query:nt},vt(N.from);return}if(!N){We();return}const be=N.textBefore.lastIndexOf("@");if(be<0){We();return}const Fe=N.textBefore.slice(be+1);if(/\s/.test(Fe)){We();return}const Pe=N.nodeStart+be,Qe=N.from;Ie(p.value,{start:Pe,end:Qe,query:Fe,clientId:N.clientId})||(p.value=null,v.value={open:!0,start:Pe,end:Qe,query:Fe,trigger:"mention",blockType:N.nodeTypeName,clientId:N.clientId},vt(Qe))}function Ce(){const D=Y.value,N=ht(D);return!D||!N?!1:(p.value=null,v.value={open:!0,start:N.from,end:N.from,query:"",trigger:"shortcut",blockType:N.nodeTypeName,clientId:N.clientId},vt(N.from),!0)}function dt(D){const N=Y.value,se=String((D==null?void 0:D.path)||"").trim(),be=v.value;if(!N||!se||be.start<0||be.end<be.start)return We(),!1;const Fe=be.trigger==="shortcut"?`${se} `:`@${se} `,Pe=be.start+Fe.length;return N.chain().focus().command(({tr:Qe,dispatch:nt})=>(Qe.insertText(Fe,be.start,be.end),Qe.setSelection(Oa.create(Qe.doc,Pe)),nt==null||nt(Qe),!0)).run(),Z.value=Date.now(),p.value=null,We(),!0}function ut(D){var N,se,be,Fe,Pe,Qe,nt,Tt,mt,_t;if(!v.value.open)return!1;if(D.key==="Escape")return lt(),!0;if(D.key==="ArrowDown")return!!((se=(N=c.value)==null?void 0:N.moveActive)!=null&&se.call(N,1));if(D.key==="ArrowUp")return!!((Fe=(be=c.value)==null?void 0:be.moveActive)!=null&&Fe.call(be,-1));if(v.value.query&&(D.key==="ArrowLeft"||D.key==="ArrowRight"))return!1;if(D.key==="ArrowRight"){const yt=(Qe=(Pe=c.value)==null?void 0:Pe.expandActiveDirectory)==null?void 0:Qe.call(Pe);return yt&&typeof yt.then=="function"?(yt.catch(()=>{}),!0):!!yt}return D.key==="ArrowLeft"?!!((Tt=(nt=c.value)==null?void 0:nt.collapseActiveDirectory)!=null&&Tt.call(nt)):!D.shiftKey&&!D.altKey&&!D.metaKey&&!D.ctrlKey&&D.key==="Enter"?!!((_t=(mt=c.value)==null?void 0:mt.confirmActive)!=null&&_t.call(mt)):!1}return fn(()=>{window.addEventListener("promptx:tiptap-image-preview",De),window.addEventListener("resize",vt),window.addEventListener("scroll",vt)}),Nt(()=>{window.removeEventListener("promptx:tiptap-image-preview",De),window.removeEventListener("resize",vt),window.removeEventListener("scroll",vt)}),Ae(()=>o.codexSessionId,()=>{We()}),t({clearContent:$e,flushPendingInput:Ge,focusEditor:Ve,insertBlocks:W,insertImportedBlocks:ae,insertUploadedBlocks:de,isComposing:ye,isEditing:Le,isImportedBlockActive:me,openFilePicker:Ne}),(D,N)=>(h(),k("section",{class:"workbench-input-editor relative flex h-full min-h-0 flex-col overflow-hidden","data-promptx-editor":"tiptap",onDrop:_e,onDragover:N[1]||(N[1]=et(()=>{},["prevent"])),onPaste:I},[i("input",{ref_key:"fileInputRef",ref:x,class:"hidden",type:"file",accept:a(m),multiple:"",onChange:Re},null,40,gh),i("div",{class:"flex-1 overflow-y-auto px-5 py-5","data-promptx-editor-scroll":"tiptap",onMousedown:Me},[a(Y)?(h(),Ee(a(di),{key:0,editor:a(Y),class:"min-h-full","data-promptx-editor-content":"tiptap"},null,8,["editor"])):fe("",!0)],32),ue(Kr,{modelValue:T.value,"onUpdate:modelValue":N[0]||(N[0]=se=>T.value=se),images:B.value},null,8,["modelValue","images"]),ue(zg,{ref_key:"mentionPickerRef",ref:c,open:v.value.open&&!!g.value,"session-id":e.codexSessionId,query:v.value.query,"anchor-rect":g.value,onClose:lt,onSelect:dt},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=z(null),{t:l}=At(),u=G({get:()=>o.modelValue,set:S=>s("update:modelValue",S)});function m(){var S,B;(B=(S=r.value)==null?void 0:S.openFilePicker)==null||B.call(S)}function x(){var S,B;(B=(S=r.value)==null?void 0:S.focusEditor)==null||B.call(S)}function c(){var S,B;return((B=(S=r.value)==null?void 0:S.flushPendingInput)==null?void 0:B.call(S))||!1}function T(S){var B,K;(K=(B=r.value)==null?void 0:B.insertBlocks)==null||K.call(B,S)}function v(S){var B,K;(K=(B=r.value)==null?void 0:B.insertImportedBlocks)==null||K.call(B,S)}function g(S){var B,K;(K=(B=r.value)==null?void 0:B.insertUploadedBlocks)==null||K.call(B,S)}function p(){var S,B;return((B=(S=r.value)==null?void 0:S.isImportedBlockActive)==null?void 0:B.call(S))||!1}function $(){var S,B;return((B=(S=r.value)==null?void 0:S.isComposing)==null?void 0:B.call(S))||!1}function Z(){var S,B;return((B=(S=r.value)==null?void 0:S.isEditing)==null?void 0:B.call(S))||!1}return t({focusEditor:x,flushPendingInput:c,insertBlocks:T,insertImportedBlocks:v,insertUploadedBlocks:g,isComposing:$,isEditing:Z,isImportedBlockActive:p,openFilePicker:m}),(S,B)=>e.loading&&!e.modelValue.length?(h(),k("section",yh,b(a(l)("workbench.loadingTaskContent")),1)):(h(),Ee(vh,{key:1,ref_key:"blockEditorRef",ref:r,modelValue:u.value,"onUpdate:modelValue":B[0]||(B[0]=K=>u.value=K),"codex-session-id":e.codexSessionId,"send-behavior":e.sendBehavior,onUploadFiles:B[1]||(B[1]=K=>s("upload-files",K)),onImportTextFiles:B[2]||(B[2]=K=>s("import-text-files",K)),onImportPdfFiles:B[3]||(B[3]=K=>s("import-pdf-files",K)),onFileFeedback:B[4]||(B[4]=K=>s("file-feedback",K)),onClearRequest:B[5]||(B[5]=K=>s("clear-request")),onSendRequest:B[6]||(B[6]=K=>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}=At();return(s,r)=>(h(),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?(h(),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]=en(et(l=>l.target.blur(),["prevent"]),["enter"])),r[3]||(r[3]=en(et(l=>n("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:r[4]||(r[4]=l=>n("title-blur"))},null,40,Th)):(h(),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(ps),{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}=At(),r=z([]);Ae(()=>n.tasks,v=>{r.value=Array.isArray(v)?[...v]:[]},{immediate:!0});function l(v){return v.slug===n.currentTaskSlug?"workbench-task-card--active theme-card-selected":v.sending?"workbench-task-card--running theme-card-warning":"theme-card-idle-muted"}function u(){return"theme-status-warning"}function m(v){const g=new Date(v.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 x(v){var g,p;return!!((g=v==null?void 0:v.workspaceDiffSummary)!=null&&g.supported&&((p=v==null?void 0:v.workspaceDiffSummary)!=null&&p.fileCount))}function c(v){return v.slug===n.currentTaskSlug?"theme-badge-strong":"theme-badge-muted"}function T(v){if(n.mobile)return;const g=Number(v==null?void 0:v.oldIndex),p=Number(v==null?void 0:v.newIndex);!Number.isInteger(g)||!Number.isInteger(p)||g===p||o("reorder-task",r.value.map($=>String(($==null?void 0:$.slug)||"").trim()).filter(Boolean))}return(v,g)=>(h(),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]=p=>o("open-settings"))},[ue(a(ti),{class:"h-4 w-4"}),i("span",{class:xe(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]=p=>o("create-task"))},[ue(a(Us),{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?(h(),k("div",Nh,b(a(s)("workbench.loadingTasks")),1)):(h(),Ee(a(ni),{key:1,modelValue:r.value,"onUpdate:modelValue":g[8]||(g[8]=p=>r.value=p),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:T},{default:Ze(()=>[(h(!0),k(rt,null,ct(r.value,p=>{var $,Z;return h(),k("article",{key:p.slug,class:xe(["workbench-task-card group relative cursor-default rounded-sm border px-3 py-3 transition",l(p)]),onClick:S=>o("select-task",p.slug)},[p.slug===e.currentTaskSlug?(h(),k("span",Fh)):fe("",!0),p.hasUnreadUpdate?(h(),k("span",Uh)):fe("",!0),i("div",jh,[i("div",Vh,[e.mobile?fe("",!0):(h(),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]=et(()=>{},["stop"]))},[ue(a(si),{class:"h-3.5 w-3.5"})],8,zh)),i("div",Hh,[p.slug===e.currentTaskSlug&&e.editingTaskTitleSlug===p.slug?(h(),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]=et(()=>{},["stop"])),onInput:g[4]||(g[4]=S=>o("update:draftTitle",S.target.value)),onKeydown:[g[5]||(g[5]=en(et(S=>S.target.blur(),["prevent"]),["enter"])),g[6]||(g[6]=en(et(S=>o("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:g[7]||(g[7]=S=>o("title-blur"))},null,40,qh)):(h(),k("button",{key:1,type:"button",class:xe(["inline-flex h-5 w-full items-center gap-1.5 truncate bg-transparent p-0 text-left text-sm leading-5",p.slug===e.currentTaskSlug?"font-semibold":"font-medium"]),title:p.displayTitle,onClick:et(S=>o("title-click",p.slug),["stop"])},[($=p.automation)!=null&&$.enabled?(h(),Ee(a(Fs),{key:0,class:"h-3.5 w-3.5 shrink-0 opacity-70"})):fe("",!0),i("span",Wh,b(p.displayTitle),1)],10,Kh))])]),i("div",Gh,[p.sending?(h(),k("span",{key:0,class:xe(["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)):fe("",!0)])]),i("div",Xh,b(p.lastPromptPreview||a(s)("workbench.noMessagesYet")),1),i("div",Yh,[i("div",Jh,b(m(p)),1),i("div",Qh,[x(p)?(h(),k("span",{key:0,class:xe(["inline-flex items-center gap-1 rounded-sm border border-dashed px-1.5 py-0.5",c(p)])},[i("span",null,b(a(s)("workbench.filesCount",{count:((Z=p.workspaceDiffSummary)==null?void 0:Z.fileCount)||0})),1)],2)):fe("",!0)])])],10,Oh)}),128))]),_:1},8,["modelValue","disabled"]))]),i("div",Zh,[e.error?(h(),k("div",ev,[ue(a(Do),{class:"mt-0.5 h-4 w-4 shrink-0"}),i("span",tv,b(e.error),1)])):fe("",!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]=p=>o("edit-task"))},[ue(a(ps),{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]=p=>o("delete-task"))},[ue(a(Ys),{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}=At(),r=G(()=>(n.items||[]).map(u=>{var p;const m=Array.isArray(u==null?void 0:u.blocks)?u.blocks:[],x=((p=m.find($=>["text","imported_text"].includes(String(($==null?void 0:$.type)||""))&&String(($==null?void 0:$.content)||"").trim()))==null?void 0:p.content)||"",c=String(x||"").replace(/\s+/g," ").trim().slice(0,120),T=m.filter($=>String(($==null?void 0:$.type)||"")==="image").length,v=m.filter($=>String(($==null?void 0:$.type)||"")==="imported_text").length,g=m.filter($=>String(($==null?void 0:$.type)||"")==="text"&&String(($==null?void 0:$.content)||"").trim()).length;return{...u,blockCount:m.length,imageCount:T,importedCount:v,preview:c||(T?s("todoDialog.imagePreview",{count:T}):s("todoDialog.noPreview")),textCount:g,timeLabel:l(u==null?void 0:u.createdAt)}}));function l(u=""){const m=Date.parse(String(u||""));if(!m)return s("todoDialog.justAdded");try{return new Intl.DateTimeFormat(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(m))}catch{return String(u||"")}}return(u,m)=>(h(),Ee(Js,{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:m[0]||(m[0]=x=>o("close"))},{title:Ze(()=>[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:Ze(()=>[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?(h(),k("div",mv,[i("div",gv,[(h(!0),k(rt,null,ct(r.value,x=>(h(),k("article",{key:x.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(Fs),{class:"h-3.5 w-3.5"}),Sn(" "+b(x.timeLabel),1)])]),i("p",wv,b(x.preview),1),i("div",xv,[i("span",bv,b(a(s)("todoDialog.blockCount",{count:x.blockCount})),1),x.textCount?(h(),k("span",kv,[ue(a(js),{class:"h-3.5 w-3.5"}),Sn(" "+b(a(s)("todoDialog.textCount",{count:x.textCount})),1)])):fe("",!0),x.importedCount?(h(),k("span",Tv,[ue(a(js),{class:"h-3.5 w-3.5"}),Sn(" "+b(a(s)("todoDialog.importedCount",{count:x.importedCount})),1)])):fe("",!0),x.imageCount?(h(),k("span",_v,[ue(a(Or),{class:"h-3.5 w-3.5"}),Sn(" "+b(a(s)("todoDialog.imageCount",{count:x.imageCount})),1)])):fe("",!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",x.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",x.id)},[ue(a(Ys),{class:"h-4 w-4"}),i("span",null,b(a(s)("todoDialog.delete")),1)],8,Av)])])]))),128))])])):(h(),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)=>(h(),Ee(ys,{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:Ze(()=>[e.message?(h(),k("div",{key:0,class:xe(["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)])},[(h(),Ee(bn(o(t.type)),{class:"h-4 w-4 shrink-0"})),i("span",null,b(e.message),1)],2)):fe("",!0)]),_:1})])]))}};function Lv(e,t=!1){const n=z(!!t);let o=null,s=()=>{};function r(l){n.value=!!l}return fn(()=>{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))}),Nt(()=>{s()}),{matches:n}}const Mv="(max-width: 1023px)",Ns="promptxWorkbenchMobileView";function wo(e){return(e==null?void 0:e[Ns])==="detail"}function Bv({currentTaskSlug:e}){const{matches:t}=Lv(Mv),n=z("tasks"),o=z("activity");function s(T="tasks"){if(typeof window>"u")return;const v={...window.history.state||{}};T==="detail"?v[Ns]="detail":delete v[Ns],window.history.replaceState(v,"")}function r(){if(typeof window>"u")return;const T={...window.history.state||{},[Ns]:"detail"};window.history.pushState(T,"")}function l(T=null){if(!t.value){n.value="detail";return}if(!e.value){n.value="tasks",s("tasks");return}n.value=wo(T)?"detail":"tasks"}function u(T){t.value=!!T,l(typeof window>"u"?null:window.history.state)}function m(T={}){const{pushHistory:v=!0}=T;if(n.value="detail",!!t.value){if(v){r();return}s("detail")}}function x(T={}){const{useHistory:v=!0}=T;if(!t.value){n.value="tasks";return}if(v&&typeof window<"u"&&wo(window.history.state)){window.history.back();return}n.value="tasks",s("tasks")}function c(T){t.value&&(n.value=wo(T.state)&&e.value?"detail":"tasks")}return fn(()=>{typeof window>"u"||window.addEventListener("popstate",c)}),Nt(()=>{typeof window<"u"&&window.removeEventListener("popstate",c)}),Ae(t,T=>{u(T)},{immediate:!0}),Ae(e,()=>{typeof window>"u"||l(window.history.state)},{flush:"post"}),{enterMobileDetail:m,isMobileLayout:t,leaveMobileDetail:x,mobileDetailTab:o,mobileView:n}}const qs="PromptX";function Rv(e=""){const t=String(a(e)||"").trim();return t?`${qs} (${t})`:qs}function Nv(e="",t={}){Fa(()=>{if(typeof document>"u")return;const o=String(a(e)||"").trim();document.title=a(t.raw)?o||qs:Rv(o)}),Nt(()=>{typeof document>"u"||(document.title=qs)})}const Gn="success";function Ov(e,t){return e&&typeof e=="object"&&!Array.isArray(e)?{message:String(e.message||"").trim(),type:String(e.type||Gn).trim()||Gn,duration:Number(e.duration)>0?Number(e.duration):t}:{message:String(e||"").trim(),type:Gn,duration:t}}function Fv(e=2200){const t=z(""),n=z(Gn);let o=null;function s(){o&&(window.clearTimeout(o),o=null),t.value="",n.value=Gn}function r(l,u=e){const m=Ov(l,u);if(!m.message){s();return}t.value=m.message,n.value=m.type,o&&window.clearTimeout(o),o=window.setTimeout(()=>{t.value="",n.value=Gn,o=null},m.duration)}return Nt(()=>{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,`
49
+ `).split(`
50
+ `);for(;t.length&&!String(t[0]||"").trim();)t.shift();for(;t.length&&!String(t[t.length-1]||"").trim();)t.pop();return t.join(`
51
+ `)}function Vv(e,t){const n=[];for(const[o,s]of((e==null?void 0:e.blocks)||[]).entries()){if(s.type===kt.TEXT||s.type===kt.IMPORTED_TEXT){const r=jv(s.content);r&&n.push(r,"");continue}if(s.type===kt.IMAGE){const r=Uv(s.content,t);r&&n.push(r,"")}}return n.join(`
52
+ `).trim()}function zv(e,t){return Vv(e,t)}const Io="promptx:active-task-slug",Hv=150,qv=1500,Kv=800,Ks=500,Wv=new Set(["completed","error","stopped","interrupted","stop_timeout","failed","cancelled","timeout"]);function Ws(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 xn(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:xn((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:xn(e.blocks||[]),todoItems:zt(e.todoItems||[])}}function Aa(e=[]){return xn(e).filter(t=>(t==null?void 0:t.type)===kt.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 xn([{type:kt.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):Xe("workbench.untitledTask")}function Gs(e={}){return!!(e!=null&&e.running)}function Jv(e={},t=!1){return t&&!Gs(e)?"sending":Gs(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=Ks){const n=Math.max(1,Number(t)||Ks),o=Object.entries(e||{});return o.length<=n?e:Object.fromEntries(o.slice(-n))}function sy(e={},t=[],n=Ks){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 m=La({...l,[o]:{taskSlug:t,status:s}},e.maxNotifiedRuns),x=ey(r,t,{currentTaskSlug:e.currentTaskSlug,pageFocused:e.pageFocused});return{unreadMap:x.unreadMap,notifiedMap:m,didMark:x.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 m=String((u==null?void 0:u.slug)||"").trim();return m?[m,u]:null}).filter(Boolean)),r=o.map(u=>s.get(u)||null).filter(Boolean),l=n.filter(u=>{const m=String((u==null?void 0:u.slug)||"").trim();return m&&!o.includes(m)});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:Ws(s.workspaceDiffSummary)};if(!l)return{...s,workspaceDiffSummary:null};const u=n.get(r),m=String((u==null?void 0:u.codexSessionId)||"").trim();return m&&m===l?{...s,workspaceDiffSummary:Ws(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 m=String((r==null?void 0:r.codexSessionId)||"").trim(),x=String((u==null?void 0:u.codexSessionId)||"").trim();return!!(m!==x||!!(r!=null&&r.running)!=!!(u!=null&&u.running)||m&&!Object.prototype.hasOwnProperty.call(u||{},"workspaceDiffSummary")||m&&(u==null?void 0:u.workspaceDiffSummary)==null)})}function As(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 jn(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=Ws(e.workspaceDiffSummary)),t}function cy(e={}){const{clearToast:t=()=>{},flashToast:n=()=>{},scrollCurrentPanelToBottom:o=()=>{}}=e,s=Xn(),r=fa(),l=z(null),u=z([]),m=z({}),x=z({}),c=z({}),T=z({}),v=z({}),g=z(""),p=z({title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]}),$=z(!0),Z=z(!1),S=z(!1),B=z(!1),K=z(!1),j=z(!1),R=z(""),te=z(!1),E=z("");let Y=null,pe=null,ge=0,P=null,ee=0,le=null;const Q=new Set;let he=null,A=0,X={};const I=G(()=>$o(p.value.blocks)),_e=G(()=>Cr({title:p.value.title,autoTitle:p.value.autoTitle,preview:Yv(p.value.blocks)},p.value.blocks));function Me(C,w={}){const V=String(C||"").trim();if(!V)return"";const oe=w.summary||lt(V),f=w.cachedDraft===void 0?ht(V):w.cachedDraft,_=V===g.value;return Object.prototype.hasOwnProperty.call(x.value,V)?String(x.value[V]||"").trim():_?String(p.value.codexSessionId||(oe==null?void 0:oe.codexSessionId)||"").trim():String((f==null?void 0:f.codexSessionId)||(oe==null?void 0:oe.codexSessionId)||"").trim()}const Re=G(()=>Me(g.value)),Ne=G(()=>Jv(lt(g.value),c.value[g.value])),Ve=G(()=>Ne.value!=="idle"),Ge=G(()=>u.value.some(C=>Gs(C))||Object.values(c.value).some(Boolean)),Te=G(()=>Object.values(T.value).some(Boolean)),W=z(0),ae=G(()=>Gv(p.value.blocks)),de=G(()=>zt(p.value.todoItems)),$e=G(()=>_e.value||Xe("workbench.untitledTask")),ye=G(()=>u.value.map(C=>Ce(C)));function Le(C=""){const w=String(C||"").trim();if(!w||w.startsWith("/uploads/"))return w;const V=Xn();if(V&&w.startsWith(V))return w.slice(V.length);if(/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?\/uploads\//.test(w)){const oe=w.match(/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?(\/uploads\/.*)$/);if(oe)return oe[3]}return w}function me(C=""){const w=String(C||"").replace(/\r\n/g,`
53
+ `).split(`
54
+ `);for(;w.length&&!String(w[0]||"").trim();)w.shift();for(;w.length&&!String(w[w.length-1]||"").trim();)w.pop();return w.join(`
55
+ `)}function De(C=[]){return C.map(w=>({id:Number.isInteger(Number(w==null?void 0:w.id))?Number(w.id):null,type:w==null?void 0:w.type,content:(w==null?void 0:w.type)==="image"?Le(w.content):me(w.content),meta:w!=null&&w.meta?{...w.meta}:{}}))}function ze(C=[]){return(C||[]).map(w=>({id:String((w==null?void 0:w.id)||"").trim(),createdAt:String((w==null?void 0:w.createdAt)||""),blocks:De((w==null?void 0:w.blocks)||[])}))}function Ie(C=p.value.title,w=p.value.autoTitle,V=p.value.lastPromptPreview,oe=p.value.todoItems,f=p.value.codexSessionId,_=p.value.blocks){return JSON.stringify({title:String(C||""),autoTitle:String(w||""),lastPromptPreview:String(V||""),todoItems:ze(oe),codexSessionId:String(f||""),blocks:De(_)})}function gt(){return Ie()!==E.value}function We(){var C,w;return!!((w=(C=l.value)==null?void 0:C.isEditing)!=null&&w.call(C))}function lt(C){return u.value.find(w=>w.slug===C)||null}function ht(C){return C&&m.value[C]||null}function vt(C,w=""){const V=String(C||"").trim();V&&(X={...X,[V]:String(w||"").trim()})}function Oe(C=""){var f;const w=String(C||"").trim();if(!w)return!1;const V=String(((f=lt(w))==null?void 0:f.updatedAt)||"").trim(),oe=String(X[w]||"").trim();return!!(V&&oe&&V===oe)}function Ce(C){const w=ht(C.slug),V=C.slug===g.value?p.value.blocks:(w==null?void 0:w.blocks)||[],oe=C.slug===g.value?p.value.title:(w==null?void 0:w.title)??C.title,f=C.slug===g.value?p.value.autoTitle:(w==null?void 0:w.autoTitle)??C.autoTitle,_=C.slug===g.value?zt(p.value.todoItems).length:zt((w==null?void 0:w.todoItems)||[]).length||Number(C.todoCount||0),L=C.slug===g.value?p.value.lastPromptPreview||C.lastPromptPreview||"":(w==null?void 0:w.lastPromptPreview)||C.lastPromptPreview||"",ne=Me(C.slug,{summary:C,cachedDraft:w});return{...C,title:oe,autoTitle:f,todoCount:_,preview:L,codexSessionId:ne,sessionSelectionLocked:!!(ne&&Number(C.codexRunCount||0)>0),sessionSelectionLockReason:ne&&Number(C.codexRunCount||0)>0?Xe("taskActions.sessionLocked"):"",displayTitle:Cr({title:oe,autoTitle:f,preview:L},V),sending:Gs(C),hasUnreadUpdate:!!T.value[C.slug]}}function dt(C,w={}){const{insertAtStart:V=!1}=w;if(!(C!=null&&C.slug))return;const oe=[...u.value],f=oe.findIndex(_=>_.slug===C.slug);if(f>=0){oe.splice(f,1,{...oe[f],...C}),u.value=oe;return}V?oe.unshift(C):oe.push(C),u.value=oe}function ut(C,w){C&&(m.value={...m.value,[C]:Tr(w)})}function D(C){return C?`${s}/api/tasks/${C}/raw`:`${s}/api/tasks/`}function N(C=""){const w=String(C||"").trim();if(!w)return;const V=lt(w),oe=r.getTaskRunChange(w);if(!V||!(oe!=null&&oe.status))return;const f=Qv(oe.status);!!V.running!==f&&dt({...V,running:f})}function se(){return typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus()}function be(C=""){return $a(C,g.value,se())}function Fe(C=""){T.value=Pa(T.value,C)}function Pe(){T.value=ty(T.value,{currentTaskSlug:g.value,pageFocused:se()})}function Qe(C=[]){T.value=ny(T.value,C),v.value=sy(v.value,C)}function nt(C=""){const w=String(C||"").trim();if(!w)return;const V=oy({unreadMap:T.value,notifiedMap:v.value,taskSlug:w,change:r.getTaskRunChange(w),currentTaskSlug:g.value,pageFocused:se(),maxNotifiedRuns:Ks});T.value=V.unreadMap,v.value=V.notifiedMap,V.didMark&&(W.value+=1)}function Tt(C,w){c.value={...c.value,[C]:!!w}}function mt(C=u.value){const w={};(C||[]).forEach(V=>{V!=null&&V.slug&&(w[V.slug]=!!V.running)}),c.value=w}function _t(C,w){C&&(x.value={...x.value,[C]:String(w||"").trim()})}async function yt(C,w){const V=String(C||"").trim();if(!V)return;const oe=String(w||"").trim(),f=lt(V),_=x.value[V]||(f==null?void 0:f.codexSessionId)||"";if(!!(_&&Number((f==null?void 0:f.codexRunCount)||0)>0)&&oe!==_){R.value=Xe("taskActions.sessionLocked");return}_t(V,oe);const ne=ht(V);ne&&ut(V,{...ne,codexSessionId:oe}),f&&dt({...f,codexSessionId:oe,workspaceDiffSummary:oe&&oe===_?f.workspaceDiffSummary:null}),V===g.value&&(p.value={...p.value,codexSessionId:oe});try{await hl(V,oe)}catch(Ue){_t(V,_),ne&&ut(V,{...ne,codexSessionId:_}),f&&dt({...f,codexSessionId:_}),V===g.value&&(p.value={...p.value,codexSessionId:_}),R.value=Ue.message}}function It(){Y&&(window.clearTimeout(Y),Y=null)}function Yt(){P&&(window.clearTimeout(P),P=null)}function Gt(){It(),!(Z.value||!g.value)&&(Y=window.setTimeout(()=>{Ot({auto:!0,silent:!0})},1500))}function re(){if(!g.value)return;const C=lt(g.value)||{slug:g.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};dt({...C,title:String(p.value.title||""),autoTitle:String(p.value.autoTitle||""),lastPromptPreview:String(p.value.lastPromptPreview||""),todoCount:zt(p.value.todoItems).length,codexSessionId:Re.value,preview:String(p.value.lastPromptPreview||"")})}function Be(C={}){const w=String((C==null?void 0:C.slug)||"").trim();if(!w)return;const V=jn(C);dt(V),vt(w,V.updatedAt||C.updatedAt||""),w===g.value&&(Object.prototype.hasOwnProperty.call(C,"title")&&(p.value.title=String(C.title||"")),Object.prototype.hasOwnProperty.call(C,"autoTitle")&&(p.value.autoTitle=String(C.autoTitle||"")),ut(w,{...p.value}))}function ot(C=[]){const w=new Map((C||[]).map(V=>{const oe=String((V==null?void 0:V.slug)||"").trim();return oe?[oe,Ws(V.workspaceDiffSummary)]:null}).filter(Boolean));w.size&&(u.value=u.value.map(V=>w.has(V.slug)?{...V,workspaceDiffSummary:w.get(V.slug)}:V))}async function Je(C=u.value){const w=Array.isArray(C)?C:[],V=w.filter(f=>String((f==null?void 0:f.codexSessionId)||"").trim()),oe=++ee;if(!V.length){u.value=w.map(f=>Object.prototype.hasOwnProperty.call(f,"workspaceDiffSummary")?f:{...f,workspaceDiffSummary:null});return}try{const f=await Zi({limit:w.length||30,slugs:V.map(_=>_.slug)});if(oe!==ee)return;ot(f.items||[])}catch{}}function Lt(C=""){const w=String(C||"").trim();if(!w)return;const V=r.getTaskRunChange(w),f=u.value.find(_=>_.slug===w);Zv(f,V)&&(Q.add(w),le&&window.clearTimeout(le),le=window.setTimeout(()=>{le=null;const _=new Set(Q);Q.clear();const L=u.value.filter(ne=>_.has(ne.slug));Je(L)},Kv))}async function H(C={}){const{silent:w=!1}=C;w||($.value=!0,R.value="");try{const V=u.value,oe=await Qi(),f=Ar(V,(oe.items||[]).map(jn));u.value=f,Qe(f),mt(f),ay(V,f)&&Je(f)}catch(V){w||(R.value=V.message)}finally{w||($.value=!1)}}async function J(C=[]){const w=ry(u.value,C),V=u.value.map(_=>String((_==null?void 0:_.slug)||"").trim()).filter(Boolean),oe=w.map(_=>String((_==null?void 0:_.slug)||"").trim()).filter(Boolean);if(!oe.length||oe.join(",")===V.join(","))return!1;const f=u.value;u.value=w;try{const _=await tl(oe);A=Date.now()+qv;const L=Ar(f,(_.items||[]).map(jn));return u.value=L,Qe(L),mt(L),!0}catch(_){return u.value=f,R.value=_.message,!1}}async function ce(C=""){const w=String(g.value||"").trim(),V=String(C||"").trim();if(!w)return;if(!u.value.some(f=>f.slug===w)){if(u.value.length){await ft(u.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}g.value="",As(""),p.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},E.value=Ie("","","",[],"",[]),te.value=!1;return}V&&V!==w||V&&(We()||gt()||te.value||K.value||j.value||Z.value||await ft(w,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function ve(C=""){const w=String(C||"").trim();he===null?he=w:he!==w&&(he=""),!P&&(P=window.setTimeout(async()=>{const V=he;he=null,P=null,await H({silent:!0}),await ce(V||"")},Hv))}async function qe(C){const w=await zr(C),V=(w.blocks||[]).map(f=>({...f,content:f.type==="image"?$s(f.content):f.content}));return{state:{title:String(w.title||""),autoTitle:String(w.autoTitle||""),lastPromptPreview:String(w.lastPromptPreview||""),codexSessionId:String(w.codexSessionId||""),blocks:V,todoItems:zt(w.todoItems||[])},summary:jn({...w,blocks:V}),updatedAt:String(w.updatedAt||"")}}async function ft(C,w={}){const{focusEditor:V=!1,force:oe=!1,skipIfDirtyOnApply:f=!1,skipIfEditingOnApply:_=!1,scrollPanelToBottom:L=!1}=w,ne=String(C||"").trim();if(!ne)return!1;const Ue=++ge;Z.value=!0,R.value="",t();try{const Bt=String(g.value||"").trim(),qt=ht(ne),ln=oe&&qt&&Oe(ne);let wt=oe&&!ln?null:qt,Rt=null;if(!wt){const xt=await qe(ne);wt=(xt==null?void 0:xt.state)||null,Rt=(xt==null?void 0:xt.summary)||null,vt(ne,(xt==null?void 0:xt.updatedAt)||(Rt==null?void 0:Rt.updatedAt)||"")}return Ue!==ge||f&&ne===g.value&&(gt()||te.value)||_&&ne===g.value&&We()?!1:(g.value=ne,As(ne),be(ne)&&Fe(ne),p.value=Tr(wt),ut(ne,wt),Rt&&dt(Rt),_t(ne,wt.codexSessionId),E.value=Ie(p.value.title,p.value.autoTitle,p.value.lastPromptPreview,p.value.todoItems,p.value.codexSessionId,p.value.blocks),te.value=!1,V&&it(()=>{var xt,vn;return(vn=(xt=l.value)==null?void 0:xt.focusEditor)==null?void 0:vn.call(xt)}),(L||ne!==Bt)&&o(),!0)}catch(Bt){return Ue===ge&&(R.value=Bt.message),!1}finally{Ue===ge&&(Z.value=!1)}}async function Ot(C={}){const{auto:w=!1,silent:V=!1}=C;return g.value?Ie()===E.value?!0:pe||(It(),K.value=!0,R.value="",pe=(async()=>{try{const f=await Hr(g.value,{title:String(p.value.title||""),autoTitle:String(p.value.autoTitle||""),lastPromptPreview:String(p.value.lastPromptPreview||""),todoItems:zt(p.value.todoItems),codexSessionId:Re.value,expiry:"none",visibility:"private",blocks:De(p.value.blocks)}),_={title:String(f.title||""),autoTitle:String(f.autoTitle||""),lastPromptPreview:String(f.lastPromptPreview||""),todoItems:zt(f.todoItems||p.value.todoItems||[]),codexSessionId:Re.value||String(f.codexSessionId||"").trim(),blocks:xn(p.value.blocks)};return ut(g.value,_),E.value=Ie(_.title,_.autoTitle,_.lastPromptPreview,_.todoItems,_.codexSessionId,_.blocks),te.value=!1,dt(jn(f)),vt(g.value,f.updatedAt||""),!w&&!V&&n({message:Xe("taskActions.taskSaved"),type:"success"}),!0}catch(f){return R.value=f.message,!1}finally{K.value=!1,pe=null,Ie()!==E.value&&(te.value=!0,Gt())}})(),pe):!1}async function Vt(){return j.value?(R.value=Xe("taskActions.fileProcessing"),!1):pe||(te.value?Ot({auto:!1,silent:!0}):!0)}async function $t(){if(!await Vt()&&g.value)return!1;S.value=!0,R.value="";try{const C=await el({title:"",expiry:"none",visibility:"private"}),w={title:String(C.title||""),autoTitle:String(C.autoTitle||""),lastPromptPreview:String(C.lastPromptPreview||""),codexSessionId:String(C.codexSessionId||""),blocks:xn(C.blocks||[]),todoItems:zt(C.todoItems||[])};return ut(C.slug,w),dt(jn(C),{insertAtStart:!0}),await ft(C.slug,{focusEditor:!0}),n({message:Xe("taskActions.taskCreated"),type:"success"}),!0}catch(C){return R.value=C.message,!1}finally{S.value=!1}}async function Mt(C){const w=String(C||"").trim();!w||w===g.value||!await Vt()||await ft(w)}async function pn(){if(g.value){B.value=!0,R.value="";try{const C=g.value;await nl(C),u.value=u.value.filter(f=>f.slug!==C);const w={...m.value};delete w[C],m.value=w;const V={...x.value};delete V[C],x.value=V;const oe={...c.value};delete oe[C],c.value=oe,Fe(C),u.value.length?await ft(u.value[0].slug,{focusEditor:!0}):(g.value="",As(""),p.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},E.value=Ie("","","",[],"",[]),te.value=!1,await $t())}catch(C){R.value=C.message}finally{B.value=!1}}}function Ct(C={}){const{silent:w=!1}=C;g.value&&(p.value={...p.value,blocks:_r()},ut(g.value,p.value),re(),te.value=!0,it(()=>{var V,oe;(oe=(V=l.value)==null?void 0:V.focusEditor)==null||oe.call(V)}),w||n({message:Xe("taskActions.taskCleared"),type:"info"}))}function tn(){if(!g.value)return!1;const C=Aa(p.value.blocks);return C.length?(p.value={...p.value,blocks:_r(),todoItems:[{id:Xv(),createdAt:new Date().toISOString(),blocks:C},...zt(p.value.todoItems)]},ut(g.value,p.value),re(),te.value=!0,it(()=>{var w,V;(V=(w=l.value)==null?void 0:w.focusEditor)==null||V.call(w)}),n({message:Xe("taskActions.todoAdded"),type:"success"}),!0):!1}function kn(C=""){const w=String(C||"").trim();if(!g.value||!w)return!1;const V=zt(p.value.todoItems).filter(oe=>oe.id!==w);return V.length===zt(p.value.todoItems).length?!1:(p.value={...p.value,todoItems:V},ut(g.value,p.value),re(),te.value=!0,!0)}function Ht(C=""){const w=String(C||"").trim();if(!g.value||!w)return null;const V=zt(p.value.todoItems).find(oe=>oe.id===w);return V?(p.value={...p.value,blocks:xn(V.blocks),todoItems:zt(p.value.todoItems).filter(oe=>oe.id!==w)},ut(g.value,p.value),re(),te.value=!0,it(()=>{var oe,f;(f=(oe=l.value)==null?void 0:oe.focusEditor)==null||f.call(oe)}),V):null}async function Ft(){var f;if(await H(),!u.value.length){await $t();return}const C=ly();if(C){const _=await ft(C,{focusEditor:!0,force:!0});if(uy(),_)return}const w=((f=u.value.find(_=>!!(_!=null&&_.running)))==null?void 0:f.slug)||"",V=iy(),oe=w||(u.value.some(_=>_.slug===V)?V:u.value[0].slug);await ft(oe,{focusEditor:!0,force:!0})}async function Pt(C){var w,V,oe;j.value=!0,R.value="";try{const f=((V=(w=l.value)==null?void 0:w.isImportedBlockActive)==null?void 0:V.call(w))||!1,_=[];for(const L of C){const ne=await sl(L);_.push({type:"image",content:$s(ne.url),meta:{}})}(oe=l.value)==null||oe.insertUploadedBlocks(_),n({message:Xe("taskActions.imageInserted",{count:_.length,appended:f}),type:"success"})}catch(f){R.value=f.message}finally{j.value=!1}}async function mn(C){var w,V,oe;R.value="";try{const f=((V=(w=l.value)==null?void 0:w.isImportedBlockActive)==null?void 0:V.call(w))||!1,_=[];for(const L of C){const ne=await L.text();ne.trim()&&_.push({type:"imported_text",content:ne,meta:{fileName:L.name||Xe("workbench.untitledTask"),collapsed:!0}})}if(!_.length){n({message:Xe("taskActions.noTextImported"),type:"warning"});return}(oe=l.value)==null||oe.insertImportedBlocks(_),n({message:Xe("taskActions.importedBlocksInserted",{count:_.length,appended:f}),type:"success"})}catch{R.value=Xe("taskActions.textImportFailed")}}async function rn(C){var w;j.value=!0,R.value="";try{let V=0,oe=0;for(const f of C){const _=await ol(f),L=(_.blocks||[]).map(ne=>({...ne,content:ne.type==="image"?$s(ne.content):ne.content}));L.length&&((w=l.value)==null||w.insertBlocks(L),V+=L.length,oe+=Number(_.pageCount||0))}if(!V){n({message:Xe("taskActions.noPdfContent"),type:"warning"});return}n({message:Xe("taskActions.pdfBlocksInserted",{blockCount:V,pageCount:oe}),type:"success"})}catch(V){R.value=V.message||Xe("taskActions.pdfImportFailed")}finally{j.value=!1}}function an(C){const w=C===g.value?p.value:ht(C);return w?zv({title:String(w.title||""),blocks:De(w.blocks||[])},D(C)):""}function gn(C){const w=C===g.value?p.value:ht(C);return w?xn(De(w.blocks||[])):[]}async function nn(C){return j.value?(R.value=Xe("taskActions.fileProcessingBeforeSend"),!1):C!==g.value?!0:K.value&&pe?pe:te.value?Ot({auto:!1,silent:!0}):!0}async function hn(C){return await nn(C)?an(C):""}function sn(C,w){const V=Er(w);!V||C!==g.value||(p.value.lastPromptPreview=V,ut(g.value,p.value),re())}return Ae(p,()=>{if(Z.value||!g.value)return;const C=$o(p.value.blocks);!String(p.value.title||"").trim()&&C&&C!==p.value.autoTitle&&(p.value.autoTitle=C),ut(g.value,p.value),te.value=Ie()!==E.value,re(),te.value&&!K.value&&Gt()},{deep:!0}),Ae(g,C=>{C&&(As(C),Pe())}),fn(()=>{typeof window>"u"||(window.addEventListener("focus",Pe),document.addEventListener("visibilitychange",Pe))}),Nt(()=>{It(),Yt(),le&&(window.clearTimeout(le),le=null),Q.clear(),typeof window<"u"&&(window.removeEventListener("focus",Pe),document.removeEventListener("visibilitychange",Pe))}),Ae(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<A||(nt(r.listSyncTaskSlug.value),N(r.listSyncTaskSlug.value),Lt(r.listSyncTaskSlug.value),ve(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:tn,applyTaskSettingsUpdate:Be,buildPromptForTask:an,getPromptBlocksForTask:gn,buildPromptPreview:Er,clearCurrentTaskContent:Ct,createTaskAndSelect:$t,currentProjectSessionId:Re,currentTaskSendState:Ne,currentTaskAutoTitle:I,currentTaskDisplayTitle:_e,currentTaskSlug:g,draft:p,editorRef:l,error:R,handleImportPdfFiles:rn,handleImportTextFiles:mn,handleTaskSendingChange:Tt,handleTaskSessionChange:yt,handleUpload:Pt,hasCurrentDraftContent:ae,hasAnyTaskSending:Ge,hasUnsavedChanges:te,hasUnreadTaskUpdates:Te,initializeWorkbench:Ft,isCurrentTaskSending:Ve,loadingTask:Z,loadingTasks:$,pageTitle:$e,prepareCodexPromptForTask:hn,currentTodoItems:de,removeTodoItem:kn,removeCurrentTask:pn,reorderTaskList:J,removingTask:B,renderedTasks:ye,refreshTaskList:H,saveTask:Ot,saving:K,selectTask:Mt,selectedSessionMap:x,sendingTaskMap:c,taskDraftMap:m,tasks:u,unreadNotificationVersion:W,useTodoItem:Ht,updateLastPromptPreview:sn,uploading:j,creatingTask:S}}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=z(!1),n=z(!1),o=z(!1),s=z(!1),r=z(!1),l=z(!1),u=z(!1),m=z(!1),x=z(""),c=z(""),T=z(""),v=z(0),g=z("workspace"),p=z(""),{t:$}=At(),{toastMessage:Z,toastType:S,flashToast:B,clearToast:K}=Fv(),{notificationSoundEnabled:j,sendBehavior:R}=Ba(),te=xo(()=>Ke(()=>import("./TaskDiffReviewDialog-GKKv-IkZ.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),E=xo(()=>Ke(()=>import("./WorkbenchSettingsDialog-IWlkg3kU.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),Y=z(null),pe=z([]);function ge(){try{const y=JSON.parse(window.localStorage.getItem(Ir)||"{}");if(y&&typeof y=="object"&&!Array.isArray(y))return y}catch{}return{}}function P(y){window.localStorage.setItem(Ir,JSON.stringify(y))}const ee=z(ge());let le=null,Q=!1,he=0;function A(y="",q=pe.value){const Se=String(y||"").trim();return Se&&q.some(we=>(we==null?void 0:we.engine)===Se)?Se:""}function X(y=pe.value){var q,Se;return((q=y.find(we=>we==null?void 0:we.isDefault))==null?void 0:q.engine)||((Se=y[0])==null?void 0:Se.engine)||""}const I=G({get(){const y=String(me.value||"").trim();if(!y)return"";const q=String(ee.value[y]||"").trim();return q||X()},set(y){const q=String(me.value||"").trim(),Se=String(y||"").trim();!q||!Se||(ee.value={...ee.value,[q]:Se},P(ee.value))}});function _e(y){return y?Y.value:null}function Me(){it(()=>{var y,q;(q=(y=_e(me.value))==null?void 0:y.scrollToBottom)==null||q.call(y)})}const{addCurrentDraftToTodo:Re,applyTaskSettingsUpdate:Ne,buildPromptForTask:Ve,getPromptBlocksForTask:Ge,clearCurrentTaskContent:Te,createTaskAndSelect:W,creatingTask:ae,currentProjectSessionId:de,currentTaskSendState:$e,currentTaskAutoTitle:ye,currentTaskDisplayTitle:Le,currentTaskSlug:me,draft:De,editorRef:ze,error:Ie,handleImportPdfFiles:gt,handleImportTextFiles:We,handleTaskSendingChange:lt,handleTaskSessionChange:ht,handleUpload:vt,hasCurrentDraftContent:Oe,hasUnsavedChanges:Ce,hasUnreadTaskUpdates:dt,initializeWorkbench:ut,isCurrentTaskSending:D,loadingTask:N,loadingTasks:se,pageTitle:be,prepareCodexPromptForTask:Fe,currentTodoItems:Pe,removeTodoItem:Qe,removeCurrentTask:nt,reorderTaskList:Tt,removingTask:mt,renderedTasks:_t,saveTask:yt,saving:It,selectTask:Yt,unreadNotificationVersion:Gt,updateLastPromptPreview:re,useTodoItem:Be,uploading:ot}=cy({clearToast:K,flashToast:B,scrollCurrentPanelToBottom:Me}),Je=G(()=>_t.value.find(y=>y.slug===me.value)||null),Lt=G(()=>dt.value?$("workbench.newMessageTitle"):be.value),H=G(()=>dt.value),J=G(()=>{var y,q;return!!((q=(y=Je.value)==null?void 0:y.workspaceDiffSummary)!=null&&q.supported)}),ce=G(()=>{const y=Je.value;return y?()=>Fe(y.slug):null}),ve=G(()=>{const y=Je.value;return y?()=>Ge(y.slug):null}),qe=G(()=>({creatingTask:ae.value,currentTaskAutoTitle:De.value.autoTitle||ye.value,currentTaskSlug:me.value,draftTitle:De.value.title,editingTaskTitleSlug:T.value,error:Ie.value,isCurrentTaskSending:D.value,loadingTask:N.value,loadingTasks:se.value,removingTask:mt.value,tasks:_t.value,uploading:ot.value})),ft=G(()=>{var y,q,Se,we;return{buildPromptBlocks:ve.value,buildPrompt:ce.value,diffSupported:J.value,selectedAgentEngine:I.value,selectedSessionId:de.value,sessionSelectionLockReason:((y=Je.value)==null?void 0:y.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((q=Je.value)!=null&&q.sessionSelectionLocked),taskSlug:((Se=Je.value)==null?void 0:Se.slug)||"",taskRunning:!!((we=Je.value)!=null&&we.running)}}),Ot=G(()=>({codexSessionId:de.value,sendBehavior:R.value,loading:N.value})),Vt=G(()=>({currentTaskAutoTitle:De.value.autoTitle||ye.value,currentTaskSlug:me.value,editingTaskTitleSlug:T.value,title:Le.value,titleInputValue:De.value.title})),{enterMobileDetail:$t,isMobileLayout:Mt,leaveMobileDetail:pn,mobileDetailTab:Ct,mobileView:tn}=Bv({currentTaskSlug:me});function kn(y){return y!=null&&y.sending||Number((y==null?void 0:y.codexRunCount)||0)>0?"activity":"input"}Nv(Lt,{raw:H});function Ht(){return typeof window>"u"?null:(le||(le=new Audio(Py),le.preload="auto",le.volume=.7),le)}function Ft(){if(!j.value)return;const y=Ht();if(!(!y||Q))try{y.muted=!0;const q=y.play();if(q&&typeof q.then=="function"){q.then(()=>{y.pause(),y.currentTime=0,y.muted=!1,Q=!0}).catch(()=>{y.muted=!1});return}y.pause(),y.currentTime=0,y.muted=!1,Q=!0}catch{y.muted=!1}}function Pt(){Ft()}function mn(){const y=Ht();if(!y||!j.value)return;const q=Date.now();if(!(q-he<Dy)){he=q;try{y.muted=!1,y.currentTime=0,y.play().catch(()=>{})}catch{}}}function rn(y="workspace",q=""){g.value=y==="run"?"run":y==="task"?"task":"workspace",p.value=g.value==="run"?String(q||""):"",o.value=!0,v.value+=1}function an(){o.value=!1}function gn(){s.value=!0}function nn(){s.value=!1}function hn(){me.value&&(r.value=!0)}function sn(){r.value=!1}function C(){l.value=!0}function w(){l.value=!1,V(),oe()}function V(){u.value=!1,x.value=""}function oe(){m.value=!1,c.value=""}function f(y){Ne(y)}function _(y){De.value.title=y}async function L(){T.value="",Ce.value&&await yt({auto:!1,silent:!0})}function ne(y){y===me.value&&(T.value=y,it(()=>{var Se,we;const q=document.querySelector('[data-task-title-input="current"]');(Se=q==null?void 0:q.focus)==null||Se.call(q),(we=q==null?void 0:q.select)==null||we.call(q)}))}async function Ue(y){if(Mt.value){await Fn(y);return}if(y!==me.value){await Fn(y);return}ne(y)}function Bt(){n.value=!0}function qt(){mt.value||(n.value=!1)}async function ln(){await nt(),n.value=!1,Mt.value&&pn({useHistory:!1})}function wt(){t.value=!0}function Rt(){t.value=!1}function xt(){t.value=!1,Te()}function vn(y){const q=Je.value;q&&lt(q.slug,y)}function Jt(y){const q=Je.value;q&&ht(q.slug,y)}function Zs(y={}){const q=String((y==null?void 0:y.sessionId)||"").trim(),Se=de.value;if(q&&q!==Se)return;const we=Array.isArray(y==null?void 0:y.bindings)?y.bindings:[];pe.value=we;const Ye=String(me.value||"").trim();if(!Ye)return;const st=String(ee.value[Ye]||"").trim();if(st&&we.some(Kt=>(Kt==null?void 0:Kt.engine)===st)){I.value!==st&&(I.value=st);return}const Et=A(y==null?void 0:y.selectedEngine,we)||X(we);Et&&I.value!==Et&&(I.value=Et)}Ae(de,(y,q)=>{String(y||"").trim()!==String(q||"").trim()&&(pe.value=[])});function Nn(y){I.value=y}function On(y){B(y),!(!Mt.value||!me.value)&&(Ct.value="activity")}async function Qt(){var y,q,Se,we,Ye,st,Et,Kt;typeof document<"u"&&((q=(y=ze.value)==null?void 0:y.isComposing)!=null&&q.call(y))&&((we=(Se=document.activeElement)==null?void 0:Se.blur)==null||we.call(Se)),(st=(Ye=ze.value)==null?void 0:Ye.flushPendingInput)==null||st.call(Ye),await it(),(Kt=(Et=ze.value)==null?void 0:Et.flushPendingInput)==null||Kt.call(Et),await it()}async function xs(){await Qt(),await navigator.clipboard.writeText(Ve(me.value)),B({message:$("workbench.promptCopied"),type:"info"})}async function eo(){await W()&&Mt.value&&(Ct.value="input",$t())}async function Fn(y){const q=String(y||"").trim();q&&(q!==me.value&&await Yt(q),Mt.value&&me.value===q&&(Ct.value=kn(Je.value),$t()))}async function to(y=[]){await Tt(y)}async function Tn(){await Qt(),Re()}function Zn(y={}){const q=String((y==null?void 0:y.rangeLabel)||"").trim();if(q)return q;const Se=Math.max(0,Number(y==null?void 0:y.lineStart)||0),we=Math.max(0,Number(y==null?void 0:y.lineEnd)||0);return Se&&we&&Se!==we?`L${Se}-L${we}`:Se||we?`L${Se||we}`:""}function es(y=""){return`code-context-${String(y||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function _n(y={}){const q=String((y==null?void 0:y.filePath)||"").trim(),Se=String((y==null?void 0:y.content)||"").replace(/\r\n/g,`
56
+ `).trimEnd();if(!q||!Se.trim())return null;const we=String((y==null?void 0:y.language)||"").trim(),Ye=Zn(y),st=String((y==null?void 0:y.source)||"").trim()==="diff"?$("workbench.codeContextSourceDiff"):$("workbench.codeContextSourceFile"),Et=we?`\`\`\`${we}`:"```",Kt=[$("workbench.codeContextTitle"),$("workbench.codeContextFile",{path:q}),Ye?$("workbench.codeContextRange",{range:Ye}):"",$("workbench.codeContextSource",{source:st}),"",Et,Se,"```"].filter(bs=>bs!=="");return{type:kt.IMPORTED_TEXT,content:Kt.join(`
57
+ `),meta:{fileName:es(q),collapsed:!1}}}async function ts(y=[],q="insertBlocks"){var we,Ye,st,Et;const Se=Array.isArray(y)?y.filter(Boolean):[];return Se.length?(await Qt(),(Ye=(we=ze.value)==null?void 0:we[q])==null||Ye.call(we,Se),await it(),(Et=(st=ze.value)==null?void 0:st.focusEditor)==null||Et.call(st),Mt.value&&me.value&&(Ct.value="input"),B({message:$("taskActions.insertedToEditor"),type:"success"}),!0):!1}async function ns(y={}){const q=String((y==null?void 0:y.source)||"").trim(),Se=Array.isArray(y==null?void 0:y.blocks)?y.blocks.filter(Boolean):[],we=String((y==null?void 0:y.content)||"").replace(/\r\n/g,`
58
+ `).trim();if(q==="response"){if(Se.length){await ts(Se,"insertBlocks");return}if(!we)return;await ts([zn(we)],"insertBlocks");return}const Ye=_n(y);Ye&&await ts([Ye],"insertImportedBlocks")}function Cn(y){x.value=String(y||"").trim(),u.value=!!x.value}function no(){x.value&&(Qe(x.value),V())}async function ss(y=c.value){const q=String(y||"").trim();return!q||!Be(q)?!1:(oe(),w(),!0)}async function so(y){await Qt();const q=String(y||"").trim();if(q){if(!Oe.value){await ss(q);return}c.value=q,m.value=!0}}async function os(){var we,Ye,st,Et;const y=me.value;if(!y)return;const q=!!((Ye=(we=Je.value)==null?void 0:we.automation)!=null&&Ye.enabled);await Qt(),re(y,Ve(y)),!(!await((Et=(st=_e(y))==null?void 0:st.send)==null?void 0:Et.call(st))||y!==me.value)&&(Mt.value&&(Ct.value="activity"),q||Te({silent:!0}),await yt({auto:!1,silent:!0}))}function d(){!Mt.value||tn.value!=="detail"||Ct.value!=="input"||!me.value||it(()=>{var y,q;(q=(y=ze.value)==null?void 0:y.focusEditor)==null||q.call(y)})}function M(y){!Ce.value&&!ot.value&&!It.value||(y.preventDefault(),y.returnValue="")}function U(){var y,q;return m.value?(oe(),!0):u.value?(V(),!0):t.value?(Rt(),!0):n.value?(qt(),!0):r.value?(sn(),!0):l.value?(w(),!0):o.value?(an(),!0):s.value?(nn(),!0):!!((q=(y=_e(me.value))==null?void 0:y.closeTopDialog)!=null&&q.call(y))}function F(y){var Ye,st,Et,Kt,bs;const q=String(y.key||""),Se=q.toLowerCase(),we=y.metaKey||y.ctrlKey;if(q==="Escape"){U()&&(y.preventDefault(),(Ye=y.stopImmediatePropagation)==null||Ye.call(y));return}if(we){if(Se==="s"){y.preventDefault(),yt({auto:!1});return}if(y.shiftKey&&q==="Backspace"){y.preventDefault(),wt();return}if(!y.isComposing){if(y.shiftKey&&y.code==="Comma"){y.preventDefault(),gn();return}if(y.shiftKey&&Se==="k"){y.preventDefault(),(Et=(st=_e(me.value))==null?void 0:st.openProjectManager)==null||Et.call(st);return}if(y.shiftKey&&Se==="o"){y.preventDefault(),(bs=(Kt=_e(me.value))==null?void 0:Kt.openSourceBrowser)==null||bs.call(Kt);return}y.shiftKey&&Se==="d"&&(y.preventDefault(),J.value&&rn("workspace"))}}}fn(()=>{ut(),window.addEventListener("beforeunload",M),window.addEventListener("keydown",F),window.addEventListener("pointerdown",Pt,{passive:!0})}),Nt(()=>{window.removeEventListener("beforeunload",M),window.removeEventListener("keydown",F),window.removeEventListener("pointerdown",Pt)}),Ae([Mt,tn,Ct,me],([y,q,Se,we])=>{!y||q!=="detail"||Se!=="input"||!we||d()}),Ae(Gt,(y,q)=>{Number(y)<=Number(q||0)||mn()});const ie={"update:draftTitle":_,"cancel-title-edit":()=>{T.value=""},"create-task":eo,"edit-task":hn,"delete-task":Bt,"open-settings":gn,"reorder-task":to,"select-task":Fn,"title-blur":L,"title-click":Ue},ke={"agent-bindings-change":Zs,"insert-code-context":ns,"open-diff":({scope:y,runId:q})=>rn(y,q),"project-created":()=>B({message:$("workbench.projectCreated"),type:"success"}),"selected-session-change":Jt,"update:selectedAgentEngine":Nn,"sending-change":vn,toast:On},He={"clear-request":wt,"file-feedback":y=>B({message:y,type:"warning"}),"import-pdf-files":gt,"import-text-files":We,"send-request":os,"upload-files":vt},je={"begin-edit":()=>ne(me.value),back:pn,"cancel-title-edit":()=>{T.value=""},"title-blur":L,"update:titleInputValue":_};return(y,q)=>(h(),k("div",dy,[ue(Dv,{message:a(Z),type:a(S)},null,8,["message","type"]),ue(ks,{open:t.value,title:a($)("workbench.confirmClearTitle"),description:a($)("workbench.confirmClearDescription"),"confirm-text":a($)("workbench.confirmClearAction"),"cancel-text":a($)("workbench.continueEditing"),onCancel:Rt,onConfirm:xt},null,8,["open","title","description","confirm-text","cancel-text"]),ue(ks,{open:n.value,title:a($)("workbench.confirmDeleteTitle"),description:a($)("workbench.confirmDeleteDescription",{title:a(Le)}),"confirm-text":a($)("workbench.confirmDeleteAction"),"cancel-text":a($)("workbench.keepForNow"),loading:a(mt),danger:"",onCancel:qt,onConfirm:ln},null,8,["open","title","description","confirm-text","cancel-text","loading"]),ue(ks,{open:u.value,title:a($)("workbench.confirmDeleteTodoTitle"),description:a($)("workbench.confirmDeleteTodoDescription"),"confirm-text":a($)("workbench.confirmDeleteAction"),"cancel-text":a($)("workbench.keepForNow"),danger:"",onCancel:V,onConfirm:no},null,8,["open","title","description","confirm-text","cancel-text"]),ue(ks,{open:m.value,title:a($)("workbench.replaceEditorTitle"),description:a($)("workbench.replaceEditorDescription"),"confirm-text":a($)("workbench.confirmReplaceAction"),"cancel-text":a($)("workbench.dontReplaceYet"),onCancel:oe,onConfirm:q[0]||(q[0]=Se=>ss())},null,8,["open","title","description","confirm-text","cancel-text"]),ue($v,{open:l.value,items:a(Pe),onClose:w,onDelete:Cn,onUse:so},null,8,["open","items"]),ue(a(te),{open:o.value,"task-slug":a(me),"task-title":a(Le),"preferred-scope":g.value,"preferred-run-id":p.value,"focus-token":v.value,onInsertCodeContext:ns,onClose:an},null,8,["open","task-slug","task-title","preferred-scope","preferred-run-id","focus-token"]),ue(a(E),{open:s.value,onClose:nn},null,8,["open"]),ue(Nu,{open:r.value,"task-slug":a(me),"task-title":a(Le),onClose:sn,onSaved:f},null,8,["open","task-slug","task-title"]),a(Mt)?(h(),k("div",wy,[a(tn)==="tasks"?(h(),Ee(kr,En({key:0},qe.value,{mobile:""},An(ie)),null,16)):(h(),k("div",xy,[ue(Eh,En(Vt.value,An(je)),null,16),i("section",by,[i("div",ky,[i("button",{type:"button",class:xe(["tool-button px-3 py-1.5 text-sm",a(Ct)==="activity"?"tool-button-accent-subtle":""]),onClick:q[3]||(q[3]=Se=>Ct.value="activity")},b(a($)("workbench.activity")),3),i("button",{type:"button",class:xe(["tool-button px-3 py-1.5 text-sm",a(Ct)==="input"?"tool-button-accent-subtle":""]),onClick:q[4]||(q[4]=Se=>Ct.value="input")},b(a($)("workbench.input")),3)])]),i("div",Ty,[Zt(i("div",_y,[ue(hr,En({ref_key:"codexPanelRef",ref:Y},ft.value,{"empty-message":a($)("workbench.selectTask")},An(ke)),null,16,["empty-message"])],512),[[Os,a(Ct)==="activity"]]),Zt(i("div",Cy,[i("div",Ey,[i("div",Ay,[i("div",Iy,[ue(yr,{"can-add-todo":a(Oe),"is-current-task-sending":a(D),"send-state":a($e),"todo-count":a(Pe).length,uploading:a(ot),onAddTodo:Tn,onOpenFilePicker:q[5]||(q[5]=Se=>{var we,Ye;return(Ye=(we=a(ze))==null?void 0:we.openFilePicker)==null?void 0:Ye.call(we)}),onClearRequest:wt,onCopyRequest:xs,onManageTodo:C,onSendRequest:os},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(vr,{"agent-bindings":pe.value,"selected-agent-engine":I.value,"onUpdate:selectedAgentEngine":Nn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",$y,[ue(br,En({ref_key:"editorRef",ref:ze,modelValue:a(De).blocks,"onUpdate:modelValue":q[6]||(q[6]=Se=>a(De).blocks=Se)},Ot.value,An(He)),null,16,["modelValue"])])])],512),[[Os,a(Ct)==="input"]])])]))])):(h(),k("div",fy,[ue(kr,En(qe.value,An(ie)),null,16),i("div",py,[i("div",my,[Je.value?(h(),Ee(hr,En({key:0,ref_key:"codexPanelRef",ref:Y},ft.value,An(ke)),null,16)):fe("",!0)]),i("div",gy,[i("div",hy,[i("div",vy,[i("div",yy,[ue(yr,{"can-add-todo":a(Oe),"is-current-task-sending":a(D),"send-state":a($e),"todo-count":a(Pe).length,uploading:a(ot),onAddTodo:Tn,onOpenFilePicker:q[1]||(q[1]=Se=>{var we,Ye;return(Ye=(we=a(ze))==null?void 0:we.openFilePicker)==null?void 0:Ye.call(we)}),onClearRequest:wt,onCopyRequest:xs,onManageTodo:C,onSendRequest:os},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(vr,{"agent-bindings":pe.value,"selected-agent-engine":I.value,align:"end","onUpdate:selectedAgentEngine":Nn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",Sy,[ue(br,En({ref_key:"editorRef",ref:ze,modelValue:a(De).blocks,"onUpdate:modelValue":q[2]||(q[2]=Se=>a(De).blocks=Se)},Ot.value,An(He)),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,Ps 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,cn as h,Gy as i,Js as j,tt 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,pt as t,fa as u,Fu as v,ks as w,Ky as x,Vs as y,jy as z};