@muyichengshayu/promptx 0.2.17 → 0.2.18

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.
@@ -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-D_72LIMv.js","assets/index-Bt9T2IKp.js","assets/vendor-router-Dn8q3tJM.js","assets/index-DaJU954y.css","assets/vendor-ui-BglsaDbv.js","assets/vendor-markdown-9aQhqbjm.js","assets/vendor-tiptap-rwYdQb1L.js","assets/TaskDiffReviewDialog-CoQgN73y.js","assets/TaskDiffReviewDialog-NsLGEda4.css","assets/WorkbenchSettingsDialog-Bw-fcsXi.js"])))=>i.map(i=>d[i]);
2
+ import{u as Et,t as Ge,f as Kr,_ as He,a as Wr,b as Gr,g as ro,s as Ja,c as Qa}from"./index-Bt9T2IKp.js";import{w as Pe,ak as Mt,aD as g,aI as Ae,aG as ue,aJ as st,aE as b,aK as ot,aL as be,aF as i,aM as sn,u as a,aN as de,aO as Xr,aP as _s,c as q,aQ as x,aR as it,aS as pt,aT as En,n as ct,o as pn,aU as en,aV as An,b as j,aW as Zt,aX as ms,aY as ir,r as Cs,aC as Za,aZ as Tn,f as ei,a_ as Bo,a$ as Gs,G as ti,al as ni,b0 as Dn,b1 as Ln}from"./vendor-misc-u-M8sNMf.js";import{X as Yr,T as si,L as Xt,C as Ko,a as Xs,B as lr,S as oi,P as ws,b as Jr,c as ri,A as ai,F as Gn,d as Rn,e as Qr,f as ii,E as li,g as ui,h as ur,i as Wo,j as Ys,k as ci,l as di,m as fi,U as pi,W as mi,n as Zr,o as gi,p as Js,q as ao,I as ea,r as hi,s as vi,t as yi,u as Si,G as wi,v as xi,w as bi,x as ki,y as Ti}from"./vendor-ui-BglsaDbv.js";import{M as ta}from"./vendor-markdown-9aQhqbjm.js";import{n as Go,N as na,a as Xo,i as _i,V as So,b as cr,u as Ci,c as Ei,E as Ai}from"./vendor-tiptap-rwYdQb1L.js";const Ii="shell",$i=new Set(["!","!"]),dr="text";function Fs(e=""){return String(e||"").replace(/\r\n/g,`
3
+ `).trim()}function Pi(e=""){const t=String(e||"");return $i.has(t.charAt(0))}function Di(e=""){const t=Fs(e);return t?t.charAt(0)==="!"?`!${t.slice(1)}`:t:""}function Li(e={}){const n=(Array.isArray(e==null?void 0:e.promptBlocks)?e.promptBlocks:[]).filter(u=>!!Fs(u==null?void 0:u.content)),o=n.length>0,s=o?n.filter(u=>String((u==null?void 0:u.type)||"").trim()===dr).map(u=>Fs(u==null?void 0:u.content)).filter(Boolean).join(`
4
+
5
+ `).trim():Fs(e==null?void 0:e.prompt);if(!Pi(s))return{mode:"",prompt:s,command:"",reason:""};if(o&&n.some(m=>String((m==null?void 0:m.type)||"").trim()!==dr))return{mode:"",prompt:s,command:"",reason:"unsupported_blocks"};const l=Di(s).slice(1).trim();return l?{mode:Ii,prompt:s,command:l,reason:""}:{mode:"",prompt:s,command:"",reason:"empty_command"}}const cn={NONE:"none",LATEST:"latest",ALL:"all"};function Mi(e="",t={}){const n=String(e||"").trim().toLowerCase();return n===cn.ALL?cn.ALL:n===cn.LATEST?cn.LATEST:n===cn.NONE?cn.NONE:t.includeEvents?cn.ALL:t.includeLatestEvents?cn.LATEST:cn.NONE}const Gt={SESSION:"session",SESSION_UPDATED:"session.updated",STATUS:"status",STDOUT:"stdout",STDERR:"stderr",AGENT_EVENT:"agent_event",COMPLETED:"completed",STOPPED:"stopped",ERROR:"error"};function sa(e=""){const t=String(e||"").trim().toLowerCase();return t==="codex"?Gt.AGENT_EVENT:t}const kt={THREAD_STARTED:"thread.started",TURN_STARTED:"turn.started",TURN_COMPLETED:"turn.completed",TURN_FAILED:"turn.failed",ERROR:"error",ITEM_STARTED:"item.started",ITEM_UPDATED:"item.updated",ITEM_COMPLETED:"item.completed"},ut={REASONING:"reasoning",WEB_SEARCH:"web_search",COLLAB_TOOL_CALL:"collab_tool_call",FILE_CHANGE:"file_change",COMMAND_EXECUTION:"command_execution",TODO_LIST:"todo_list",AGENT_MESSAGE:"agent_message"},Bi={none:{label:"不过期",hours:null}};Object.entries(Bi).map(([e,t])=>({value:e,label:t.label}));const gs={CODEX:"codex",CLAUDE_CODE:"claude-code",OPENCODE:"opencode",KIMI_CODE:"kimi-code"},Yo=[{value:gs.CODEX,label:"Codex",enabled:!0},{value:gs.CLAUDE_CODE,label:"Claude Code",enabled:!0},{value:gs.OPENCODE,label:"OpenCode",enabled:!0},{value:gs.KIMI_CODE,label:"Kimi Code",enabled:!0}],Tt={TEXT:"text",IMAGE:"image",IMPORTED_TEXT:"imported_text"},Ri=[{value:"local",label:"跟随本机时区"}],Ni={SKIP:"skip"},Oi=[{value:Ni.SKIP,label:"已有运行时跳过本次"}],wo={DINGTALK:"dingtalk",FEISHU:"feishu",WEBHOOK:"webhook"},Fi=[{value:wo.DINGTALK,label:"钉钉 Webhook"},{value:wo.FEISHU,label:"飞书 Webhook"},{value:wo.WEBHOOK,label:"通用 Webhook"}],xo={COMPLETED:"completed",SUCCESS:"success",ERROR:"error"},Ui=[{value:xo.COMPLETED,label:"本次运行结束后"},{value:xo.SUCCESS,label:"本次运行成功后"},{value:xo.ERROR,label:"本次运行失败后"}],ji={SUMMARY:"summary"},Vi=[{value:ji.SUMMARY,label:"摘要消息"}],fr={ZH_CN:"zh-CN",EN_US:"en-US"},zi=[{value:fr.ZH_CN,label:"简体中文"},{value:fr.EN_US,label:"English"}];function Qs(e){var n;const t=String(e||"").trim().toLowerCase();return((n=Yo.find(o=>o.value===t))==null?void 0:n.value)||gs.CODEX}function ht(e){var t;return((t=Yo.find(n=>n.value===Qs(e)))==null?void 0:t.label)||"Codex"}function dS(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 Hi(e=[],t=10){const n=e.find(o=>{var s;return(o.type===Tt.TEXT||o.type===Tt.IMPORTED_TEXT)&&((s=o.content)==null?void 0:s.trim())});return n?n.content.replace(/\s+/g," ").trim().slice(0,t):""}const qi={class:"min-w-0 flex-1"},Ki={key:0,class:"flex items-center gap-2"},Wi=["disabled"],io={__name:"DialogShell",props:{open:{type:Boolean,default:!1},backdropClass:{type:String,default:""},stackLevel:{type:Number,default:0},panelClass:{type:String,default:""},headerClass:{type:String,default:"px-4 py-4 sm:px-5"},bodyClass:{type:String,default:"min-h-0 flex-1"},showClose:{type:Boolean,default:!0},closeDisabled:{type:Boolean,default:!1},closeOnBackdrop:{type:Boolean,default:!0},closeOnEscape:{type:Boolean,default:!0},lockBodyScroll:{type:Boolean,default:!0}},emits:["close"],setup(e,{emit:t}){const n=e,o=t,s=q(()=>n.backdropClass?n.backdropClass:`${n.stackLevel>=4?"z-[90]":n.stackLevel===3?"z-[75]":n.stackLevel===2?"z-[70]":n.stackLevel===1?"z-[60]":"z-50"} items-end justify-center px-0 py-0 sm:items-center sm:px-4 sm:py-6`);function r(){n.closeDisabled||o("close")}function l(){!n.closeOnBackdrop||n.closeDisabled||o("close")}function u(m){!n.open||!n.closeOnEscape||n.closeDisabled||m.key==="Escape"&&o("close")}return Pe(()=>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}),Mt(()=>{n.lockBodyScroll&&document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",u)}),(m,k)=>(g(),Ae(_s,{to:"body"},[ue(Xr,{name:"dialog-shell"},{default:st(()=>[e.open?(g(),b("div",{key:0,class:be(["theme-modal-backdrop dialog-shell-backdrop fixed inset-0 flex",s.value]),onClick:ot(l,["self"])},[i("section",{class:be(["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?(g(),b("div",{key:0,class:be(["theme-divider flex items-start justify-between gap-4 border-b",e.headerClass])},[i("div",qi,[sn(m.$slots,"header",{},()=>[sn(m.$slots,"title")])]),m.$slots["header-actions"]||e.showClose?(g(),b("div",Ki,[sn(m.$slots,"header-actions"),e.showClose?(g(),b("button",{key:0,type:"button",class:"theme-icon-button h-8 w-8 shrink-0",disabled:e.closeDisabled,onClick:r},[ue(a(Yr),{class:"h-4 w-4"})],8,Wi)):de("",!0)])):de("",!0)],2)):de("",!0),i("div",{class:be(e.bodyClass)},[sn(m.$slots,"default")],2)],2)],2)):de("",!0)]),_:3})]))}},Gi={class:"flex items-start gap-3"},Xi={class:"theme-heading text-base font-semibold"},Yi={key:0,class:"theme-muted-text mt-1 text-sm leading-6"},Ji={class:"flex justify-end gap-2 px-5 py-4"},Qi=["disabled"],Zi=["disabled"],Ls={__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}=Et(),r=q(()=>n.title||s("common.confirm")),l=q(()=>n.confirmText||s("common.confirm")),u=q(()=>n.cancelText||s("common.cancel"));return(m,k)=>(g(),Ae(io,{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:k[2]||(k[2]=d=>o("cancel"))},{title:st(()=>[i("div",Gi,[i("span",{class:be(["inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-sm border border-dashed",e.danger?"theme-status-danger":"theme-status-neutral"])},[ue(a(si),{class:"h-4 w-4"})],2),i("div",null,[i("h2",Xi,x(r.value),1),e.description?(g(),b("p",Yi,x(e.description),1)):de("",!0)])])]),default:st(()=>[i("div",Ji,[i("button",{type:"button",class:"tool-button px-4 py-2 text-sm",disabled:e.loading,onClick:k[0]||(k[0]=d=>o("cancel"))},x(u.value),9,Qi),i("button",{type:"button",class:be(["tool-button px-4 py-2 text-sm",e.danger?"tool-button-danger":"tool-button-primary"]),disabled:e.loading,onClick:k[1]||(k[1]=d=>o("confirm"))},x(e.loading?a(s)("common.processing"):l.value),11,Zi)])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},el={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"},tl={class:"settings-nav flex gap-2 overflow-x-auto sm:flex-col sm:overflow-visible"},nl=["onClick"],sl={class:"min-w-0"},ol={class:"text-sm font-medium"},rl={class:"theme-muted-text mt-1 hidden text-xs leading-5 sm:block"},al={__name:"DialogSideNav",props:{modelValue:{type:String,default:""},sections:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(e,{emit:t}){const n=t;function o(s=""){n("update:modelValue",String(s||""))}return(s,r)=>(g(),b("aside",el,[i("nav",tl,[(g(!0),b(it,null,pt(e.sections,l=>(g(),b("button",{key:l.id,type:"button",class:be(["settings-nav__item flex min-w-0 items-start gap-3 rounded-sm border px-3 py-3 text-left transition sm:w-full",e.modelValue===l.id?"theme-card-selected":"theme-card-idle-muted border-dashed hover:border-[var(--theme-borderStrong)] hover:bg-[var(--theme-appPanelStrong)]"]),onClick:u=>o(l.id)},[(g(),Ae(En(l.icon),{class:"mt-0.5 h-4 w-4 shrink-0"})),i("div",sl,[i("div",ol,x(l.label),1),i("p",rl,x(l.description),1)])],10,nl))),128))])]))}},il=["aria-label","disabled","onKeydown"],ll={class:"min-w-0 flex-1"},ul={class:"theme-muted-text text-sm"},cl={class:"flex min-h-0 w-full flex-col"},dl={class:"min-h-0 flex-1 space-y-2 overflow-y-auto p-2"},fl=["onClick"],pl={class:"theme-empty-state px-3 py-4 text-sm"},dn={__name:"WorkbenchSelect",props:{modelValue:{type:[String,Number],default:""},options:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:""},emptyText:{type:String,default:""},ariaLabel:{type:String,default:""},getOptionValue:{type:Function,default:e=>(e==null?void 0:e.id)??(e==null?void 0:e.value)??""},triggerClass:{type:String,default:""}},emits:["update:modelValue","refresh-intent"],setup(e,{emit:t}){const n=e,o=t,{t:s}=Et(),r=j(null),l=j(null),u=j(!1),m=j(!1),k=j({}),d=q(()=>{const N=String(n.modelValue??"");return n.options.find(se=>String(n.getOptionValue(se)??"")===N)||null}),T=q(()=>n.placeholder||s("common.select")),v=q(()=>n.emptyText||s("common.noOptions"));function h(N){return N&&typeof N=="object"&&Object.prototype.hasOwnProperty.call(N,"label")?String(N.label||""):String(n.getOptionValue(N)??"")}function p(){n.disabled||(u.value||o("refresh-intent"),u.value=!0)}function $(){u.value=!1}function ee(){if(u.value){$();return}p()}function y(N){o("update:modelValue",String(n.getOptionValue(N)??"").trim()),$()}function B(){if(!u.value||!r.value||typeof window>"u")return;const N=r.value.getBoundingClientRect(),se=window.innerWidth,I=window.innerHeight,X=8,ge=8,ye=160,D=360,ne=Math.max(0,I-N.bottom-ge),le=Math.max(0,N.top-ge);m.value=ne<260&&le>ne;const te=m.value?le-X:ne-X,ve=Math.max(Math.min(D,Math.max(te,0)),Math.min(ye,m.value?le:ne)),C=Math.min(N.width,se-ge*2),W=Math.min(Math.max(ge,N.left),Math.max(ge,se-ge-C));k.value={left:`${W}px`,top:m.value?`${N.top-X}px`:`${N.bottom+X}px`,width:`${C}px`,maxHeight:`${Math.max(ve,120)}px`,transform:m.value?"translateY(-100%)":"none"}}function K(N){var se;!u.value||!r.value||r.value.contains(N.target)||(se=l.value)!=null&&se.contains(N.target)||$()}function V(N){N.key==="Escape"&&$()}return Pe(()=>n.disabled,N=>{N&&$()}),Pe(u,async N=>{N&&(await ct(),B())}),pn(()=>{document.addEventListener("pointerdown",K),document.addEventListener("keydown",V),window.addEventListener("resize",B),window.addEventListener("scroll",B,!0)}),Mt(()=>{document.removeEventListener("pointerdown",K),document.removeEventListener("keydown",V),window.removeEventListener("resize",B),window.removeEventListener("scroll",B,!0)}),(N,se)=>(g(),b("div",{ref_key:"rootRef",ref:r,class:"relative min-w-0"},[i("button",{type:"button",class:be(["workbench-select-trigger flex w-full items-center gap-3 rounded-sm border px-3 py-2 text-left transition focus:outline-none focus:ring-2",[n.triggerClass,e.disabled?"cursor-not-allowed border-[color-mix(in_srgb,var(--theme-borderDefault)_88%,var(--theme-textMuted))] bg-[color-mix(in_srgb,var(--theme-appPanelMuted)_82%,var(--theme-appBg))] text-[var(--theme-textMuted)]":"theme-input-shell text-[var(--theme-textPrimary)] hover:border-[var(--theme-borderStrong)] focus:border-[var(--theme-borderStrong)] focus:ring-[var(--theme-focusRing)]"]]),"aria-label":n.ariaLabel||void 0,disabled:e.disabled,onClick:ee,onKeydown:[en(ot(p,["prevent"]),["down"]),en(ot(ee,["prevent"]),["enter"]),en(ot(ee,["prevent"]),["space"])]},[i("div",ll,[sn(N.$slots,"trigger",{selectedOption:d.value,open:u.value,loading:e.loading,disabled:e.disabled},()=>[i("div",ul,x(d.value?h(d.value):T.value),1)])]),i("div",{class:be(["flex shrink-0 items-center gap-2",e.disabled?"text-[var(--theme-textMuted)] opacity-80":"theme-muted-text"])},[e.loading?(g(),Ae(a(Xt),{key:0,class:"h-4 w-4 animate-spin"})):de("",!0),ue(a(Ko),{class:be(["h-4 w-4 transition",u.value?"rotate-180":""])},null,8,["class"])],2)],42,il),(g(),Ae(_s,{to:"body"},[u.value?(g(),b("div",{key:0,ref_key:"panelRef",ref:l,class:"workbench-select-panel theme-popover fixed z-[90] flex overflow-hidden rounded-sm border",style:An(k.value)},[i("div",cl,[sn(N.$slots,"header",{loading:e.loading,options:e.options}),i("div",dl,[e.options.length?(g(!0),b(it,{key:0},pt(e.options,I=>sn(N.$slots,"option",{key:String(e.getOptionValue(I)??""),option:I,selected:String(e.getOptionValue(I)??"")===String(e.modelValue??""),select:()=>y(I)},()=>[i("button",{type:"button",class:"workbench-select-option theme-filter-idle w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm",onClick:X=>y(I)},x(h(I)),9,fl)])),128)):sn(N.$slots,"empty",{key:1},()=>[i("div",pl,x(v.value),1)])])])],4)):de("",!0)]))],512))}},pr={},oa=typeof import.meta<"u"&&pr?pr:{};function ml(){if(typeof window>"u")return"http://localhost:3000";const e=new URL(window.location.origin),t=String(oa.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 Jo(){return(oa.VITE_API_BASE_URL||ml()).replace(/\/$/,"")}function Qo(e={},t="errors.requestFailed"){const n=String((e==null?void 0:e.messageKey)||"").trim();if(n){const o=Ge(n);if(o&&o!==n)return o}return(e==null?void 0:e.message)||Ge(t)}async function Ze(e,t={}){const n=typeof t.body<"u"&&!(t.body instanceof FormData),o=await fetch(`${Jo()}${e}`,{headers:{...n?{"Content-Type":"application/json"}:{},...t.headers||{}},...t});if(!o.ok){const r=await o.json().catch(()=>({}));throw new Error(Qo(r))}return o.status===204?null:(o.headers.get("content-type")||"").includes("application/json")?o.json():o.text()}function Zn(){return Jo()}function Us(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`${Jo()}${e}`}function fS(){return Ze("/api/meta",{cache:"no-store"})}function gl(){return Ze("/api/tasks")}function hl(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)}),Ze(`/api/tasks/workspace-diff-summaries?${n.toString()}`,{cache:"no-store"})}function vl(e){return Ze("/api/tasks",{method:"POST",body:JSON.stringify(e)})}function yl(e=[]){return Ze("/api/tasks/reorder",{method:"POST",body:JSON.stringify({slugs:e})})}function ra(e){return Ze(`/api/tasks/${e}`)}function aa(e,t){return Ze(`/api/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)})}function Sl(e){return Ze(`/api/tasks/${e}`,{method:"DELETE"})}async function wl(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Zn()}/api/uploads`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(Qo(o,"errors.uploadFailed"))}return n.json()}async function xl(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Zn()}/api/imports/pdf`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error(Qo(o,"errors.pdfImportFailed"))}return n.json()}const bl=Zn();function kl(){return Ze("/api/codex/sessions")}function Tl(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim();n&&t.set("engine",n);const o=t.toString();return Ze(`/api/codex/workspaces${o?`?${o}`:""}`)}function pS(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim(),o=String(e.cwd||"").trim(),s=Number(e.limit||0);n&&t.set("engine",n),o&&t.set("cwd",o),Number.isFinite(s)&&s>0&&t.set("limit",String(s));const r=t.toString();return Ze(`/api/codex/session-candidates${r?`?${r}`:""}`,{cache:"no-store",signal:e.signal})}function mS(e={}){const t=new URLSearchParams,n=String(e.path||"").trim(),o=Number(e.limit||0);n&&t.set("path",n),Number.isFinite(o)&&o>0&&t.set("limit",String(o));const s=t.toString();return Ze(`/api/codex/directories/tree${s?`?${s}`:""}`,{cache:"no-store",signal:e.signal})}function gS(e,t={}){const n=new URLSearchParams,o=String(e||"").trim(),s=String(t.path||"").trim(),r=Number(t.limit||0);o&&n.set("q",o),s&&n.set("path",s),Number.isFinite(r)&&r>0&&n.set("limit",String(r));const l=n.toString();return Ze(`/api/codex/directories/search${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function _l(e){return Ze("/api/codex/sessions",{method:"POST",body:JSON.stringify(e)})}function Cl(e,t){return Ze(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function El(e){return Ze(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function Al(e){return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/reset`,{method:"POST"})}function Il(e,t={}){const n=new URLSearchParams,o=String(t.path||"").trim(),s=String(t.refreshToken||"").trim();o&&n.set("path",o),s&&n.set("_",s);const r=n.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/tree${r?`?${r}`:""}`,{cache:"no-store",signal:t.signal})}function $l(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 Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/search${u?`?${u}`:""}`,{cache:"no-store",signal:n.signal})}function Pl(e,t={}){const n=new URLSearchParams,o=String(t.path||"").trim(),s=Number(t.limit||0),r=String(t.refreshToken||"").trim();o&&n.set("path",o),Number.isFinite(s)&&s>0&&n.set("limit",String(s)),r&&n.set("_",r);const l=n.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/content${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function Dl(e,t={}){const n=new URLSearchParams,o=String(t.path||"").trim(),s=String(t.refreshToken||"").trim();o&&n.set("path",o),s&&n.set("_",s);const r=n.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/blame${r?`?${r}`:""}`,{cache:"no-store",signal:t.signal})}function Ll(e,t,n={}){const o=new URLSearchParams,s=String(t||"").trim(),r=Number(n.limit||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 Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/content-search${u?`?${u}`:""}`,{cache:"no-store",signal:n.signal})}function Ml(e,t){return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-session`,{method:"POST",body:JSON.stringify({sessionId:t})})}function Bl(e,t={}){const n=new URLSearchParams,o=Number(t.limit||20),s=Mi(t.events,t);Number.isFinite(o)&&o>0&&n.set("limit",String(o)),n.set("events",s);const r=n.toString();return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-runs${r?`?${r}`:""}`,{cache:"no-store"})}function Rl(e,t={}){const n=new URLSearchParams,o=Math.max(0,Number(t.afterSeq)||0),s=Math.max(1,Number(t.limit)||5e3);o>0&&n.set("afterSeq",String(o)),s>0&&n.set("limit",String(s));const r=n.toString();return Ze(`/api/codex/runs/${encodeURIComponent(e)}/events${r?`?${r}`:""}`,{cache:"no-store"})}function hS(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 k=n.toString();return Ze(`/api/tasks/${encodeURIComponent(e)}/git-diff${k?`?${k}`:""}`,{cache:"no-store"})}function vS(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`${bl}/api/tasks/${encodeURIComponent(e)}/git-diff/blob${u?`?${u}`:""}`}function Nl(e,t){return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"POST",body:JSON.stringify(t)})}function Ol(e){return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"DELETE"})}function Fl(e){return Ze(`/api/codex/runs/${encodeURIComponent(e)}/stop`,{method:"POST"})}const Ul={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},jl={class:"theme-muted-text mt-1 text-xs"},Vl={class:"min-h-0 flex flex-1 flex-col overflow-hidden sm:flex-row"},zl={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},Hl={key:0,class:"theme-muted-text flex items-center gap-2 py-4 text-sm"},ql={key:1,class:"space-y-4"},Kl={key:0,class:"space-y-4"},Wl={class:"theme-heading text-base font-medium"},Gl={class:"theme-muted-text mt-1 text-xs leading-5"},Xl={class:"settings-section-card px-4 py-4"},Yl={class:"block space-y-1.5"},Jl={class:"theme-muted-text text-xs"},Ql=["placeholder"],Zl={key:1,class:"space-y-4"},eu={class:"flex items-start justify-between gap-3"},tu={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},nu={class:"theme-muted-text mt-1 text-xs leading-5"},su={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},ou={class:"settings-section-card px-4 py-4"},ru={class:"grid gap-4 sm:grid-cols-2"},au={class:"space-y-1.5 sm:col-span-2"},iu={class:"theme-muted-text text-xs"},lu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},uu={class:"space-y-1.5"},cu={class:"theme-muted-text text-xs"},du=["disabled"],fu={key:0,class:"space-y-1.5"},pu={class:"theme-muted-text text-xs"},mu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},gu={class:"space-y-1.5"},hu={class:"theme-muted-text text-xs"},vu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},yu={class:"theme-muted-text text-xs"},Su={class:"truncate text-sm text-[var(--theme-textPrimary)]"},wu={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},xu={key:2,class:"space-y-4"},bu={class:"flex items-start justify-between gap-3"},ku={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Tu={class:"theme-muted-text mt-1 text-xs leading-5"},_u={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Cu={class:"settings-section-card px-4 py-4"},Eu={class:"grid gap-4 sm:grid-cols-2"},Au={class:"space-y-1.5"},Iu={class:"theme-muted-text text-xs"},$u={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Pu={class:"space-y-1.5"},Du={class:"theme-muted-text text-xs"},Lu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Mu={class:"space-y-1.5 sm:col-span-2"},Bu={class:"theme-muted-text text-xs"},Ru=["placeholder","disabled"],Nu={class:"space-y-1.5"},Ou={class:"theme-muted-text text-xs"},Fu=["placeholder","disabled"],Uu={class:"space-y-1.5"},ju={class:"theme-muted-text text-xs"},Vu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},zu={class:"space-y-1.5"},Hu={class:"theme-muted-text text-xs"},qu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Ku={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},Wu={key:0,class:"theme-danger-text"},Gu={key:3,class:"theme-danger-text text-sm"},Xu={class:"theme-divider flex flex-col gap-3 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-between"},Yu={class:"theme-muted-text theme-note-text"},Ju={class:"flex items-center justify-end gap-2"},Qu=["disabled"],Zu=["disabled"],ec="0 9 * * 1-5",bo="weekdays",fs="09:00",Hn="1",tc={__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}=Et(),l=j(!1),u=j(!1),m=j(""),k=j("basic"),d=Cs({title:"",automationEnabled:!1,automationMode:bo,automationTime:fs,automationWeekday:Hn,automationTimezone:"local",automationConcurrencyPolicy:"skip",automationLastTriggeredAt:"",automationNextTriggerAt:"",notificationEnabled:!1,notificationChannelType:"dingtalk",notificationWebhookUrl:"",notificationSecret:"",notificationTriggerOn:"completed",notificationLocale:"zh-CN",notificationMessageMode:"summary",notificationLastStatus:"",notificationLastError:"",notificationLastSentAt:""}),T=q(()=>String(n.taskTitle||"").trim()||r("workbench.untitledTask")),v=q(()=>[{id:"basic",label:r("taskDialog.sections.basic.label"),description:r("taskDialog.sections.basic.description"),icon:ws},{id:"automation",label:r("taskDialog.sections.automation.label"),description:r("taskDialog.sections.automation.description"),icon:Xs},{id:"notification",label:r("taskDialog.sections.notification.label"),description:r("taskDialog.sections.notification.description"),icon:lr}]),h=q(()=>[{value:"daily",label:r("taskDialog.sections.automation.modeDaily")},{value:"weekdays",label:r("taskDialog.sections.automation.modeWeekdays")},{value:"weekly",label:r("taskDialog.sections.automation.modeWeekly")}]),p=q(()=>[{value:"1",label:r("taskDialog.sections.automation.weekday1")},{value:"2",label:r("taskDialog.sections.automation.weekday2")},{value:"3",label:r("taskDialog.sections.automation.weekday3")},{value:"4",label:r("taskDialog.sections.automation.weekday4")},{value:"5",label:r("taskDialog.sections.automation.weekday5")},{value:"6",label:r("taskDialog.sections.automation.weekday6")},{value:"0",label:r("taskDialog.sections.automation.weekday0")}]),$=q(()=>Ri.map(C=>({...C,label:C.value==="local"?r("taskDialog.sections.automation.timezoneLocal"):C.label}))),ee=q(()=>Oi.map(C=>({...C,label:C.value==="skip"?r("taskDialog.sections.automation.concurrencySkip"):C.label}))),y=q(()=>Fi.map(C=>({...C,label:C.value==="dingtalk"?r("taskDialog.sections.notification.channelDingtalk"):C.value==="feishu"?r("taskDialog.sections.notification.channelFeishu"):C.value==="webhook"?r("taskDialog.sections.notification.channelWebhook"):C.label}))),B=q(()=>Ui.map(C=>({...C,label:C.value==="completed"?r("taskDialog.sections.notification.triggerCompleted"):C.value==="success"?r("taskDialog.sections.notification.triggerSuccess"):C.value==="error"?r("taskDialog.sections.notification.triggerError"):C.label}))),K=q(()=>Vi.map(C=>({...C,label:C.value==="summary"?r("taskDialog.sections.notification.messageSummary"):C.label}))),V=q(()=>zi.map(C=>({...C,label:C.value==="zh-CN"?r("taskDialog.sections.notification.localeZhCn"):C.value==="en-US"?r("taskDialog.sections.notification.localeEnUs"):C.label}))),N=q(()=>d.notificationEnabled?d.notificationLastStatus==="success"?r("taskDialog.sections.notification.statusSuccess"):d.notificationLastStatus==="error"?r("taskDialog.sections.notification.statusError"):r("taskDialog.sections.notification.statusPending"):r("taskDialog.sections.notification.statusDisabled"));function se(){d.title="",d.automationEnabled=!1,d.automationMode=bo,d.automationTime=fs,d.automationWeekday=Hn,d.automationTimezone="local",d.automationConcurrencyPolicy="skip",d.automationLastTriggeredAt="",d.automationNextTriggerAt="",d.notificationEnabled=!1,d.notificationChannelType="dingtalk",d.notificationWebhookUrl="",d.notificationSecret="",d.notificationTriggerOn="completed",d.notificationLocale=String(s.value||"zh-CN"),d.notificationMessageMode="summary",d.notificationLastStatus="",d.notificationLastError="",d.notificationLastSentAt=""}function I(C=0){return String(C).padStart(2,"0")}function X(C=""){const W=String(C||"").trim().replace(/\s+/g," ");let P=W.match(/^(\d{1,2}) (\d{1,2}) \* \* 1-5$/);return P?{mode:"weekdays",time:`${I(P[2])}:${I(P[1])}`,weekday:Hn}:(P=W.match(/^(\d{1,2}) (\d{1,2}) \* \* \*$/),P?{mode:"daily",time:`${I(P[2])}:${I(P[1])}`,weekday:Hn}:(P=W.match(/^(\d{1,2}) (\d{1,2}) \* \* ([0-6])$/),P?{mode:"weekly",time:`${I(P[2])}:${I(P[1])}`,weekday:String(P[3])}:{mode:bo,time:fs,weekday:Hn}))}function ge(C=""){const P=String(C||"").trim().match(/^(\d{1,2}):(\d{2})$/);if(!P)return fs;const Ee=Number(P[1]),Ie=Number(P[2]);return!Number.isInteger(Ee)||!Number.isInteger(Ie)||Ee<0||Ee>23||Ie<0||Ie>59?fs:`${I(Ee)}:${I(Ie)}`}function ye(){var Be;const C=ge(d.automationTime),[W,P]=C.split(":"),Ee=Number(W),Ie=Number(P);if(d.automationMode==="daily")return`${Ie} ${Ee} * * *`;if(d.automationMode==="weekly"){const Ye=((Be=p.value.find(Je=>Je.value===String(d.automationWeekday||"")))==null?void 0:Be.value)||Hn;return`${Ie} ${Ee} * * ${Ye}`}return`${Ie} ${Ee} * * 1-5`}function D(C={}){var P,Ee,Ie,Be,Ye,Je,Ke,we,H,Z,me,_e,fe,Le,he,Me;d.title=String(C.title||""),d.automationEnabled=!!((P=C.automation)!=null&&P.enabled);const W=X(((Ee=C.automation)==null?void 0:Ee.cron)||ec);d.automationMode=W.mode,d.automationTime=W.time,d.automationWeekday=W.weekday,d.automationTimezone=String(((Ie=C.automation)==null?void 0:Ie.timezone)||"local"),d.automationConcurrencyPolicy=String(((Be=C.automation)==null?void 0:Be.concurrencyPolicy)||"skip"),d.automationLastTriggeredAt=String(((Ye=C.automation)==null?void 0:Ye.lastTriggeredAt)||""),d.automationNextTriggerAt=String(((Je=C.automation)==null?void 0:Je.nextTriggerAt)||""),d.notificationEnabled=!!((Ke=C.notification)!=null&&Ke.enabled),d.notificationChannelType=String(((we=C.notification)==null?void 0:we.channelType)||"dingtalk"),d.notificationWebhookUrl=String(((H=C.notification)==null?void 0:H.webhookUrl)||""),d.notificationSecret=String(((Z=C.notification)==null?void 0:Z.secret)||""),d.notificationTriggerOn=String(((me=C.notification)==null?void 0:me.triggerOn)||"completed"),d.notificationLocale=String(((_e=C.notification)==null?void 0:_e.locale)||s.value||"zh-CN"),d.notificationMessageMode=String(((fe=C.notification)==null?void 0:fe.messageMode)||"summary"),d.notificationLastStatus=String(((Le=C.notification)==null?void 0:Le.lastStatus)||""),d.notificationLastError=String(((he=C.notification)==null?void 0:he.lastError)||""),d.notificationLastSentAt=String(((Me=C.notification)==null?void 0:Me.lastSentAt)||"")}async function ne(){const C=String(n.taskSlug||"").trim();if(!C){se();return}l.value=!0,m.value="";try{const W=await ra(C);D(W)}catch(W){m.value=(W==null?void 0:W.message)||r("taskDialog.loadFailed")}finally{l.value=!1}}function le(){return{title:d.title,automation:{enabled:d.automationEnabled,cron:ye(),timezone:d.automationTimezone,concurrencyPolicy:d.automationConcurrencyPolicy},notification:{enabled:d.notificationEnabled,channelType:d.notificationChannelType,webhookUrl:d.notificationWebhookUrl,secret:d.notificationSecret,triggerOn:d.notificationTriggerOn,locale:d.notificationLocale,messageMode:d.notificationMessageMode}}}async function te(){const C=String(n.taskSlug||"").trim();if(!(!C||l.value||u.value)){u.value=!0,m.value="";try{const W=await aa(C,le());D(W),o("saved",W),o("close")}catch(W){m.value=(W==null?void 0:W.message)||r("taskDialog.saveFailed")}finally{u.value=!1}}}function ve(C=""){if(!C)return r("common.notAvailable");const W=new Date(C);return Number.isNaN(W.getTime())?r("common.notAvailable"):Kr(W.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return Pe(()=>n.open,C=>{if(C){k.value="basic",ne();return}},{immediate:!0}),Pe(()=>n.taskSlug,()=>{n.open&&ne()}),(C,W)=>(g(),Ae(io,{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:W[16]||(W[16]=P=>o("close"))},{title:st(()=>[i("div",null,[i("div",Ul,[ue(a(ws),{class:"h-4 w-4"}),i("span",null,x(a(r)("taskDialog.title")),1)]),i("p",jl,x(a(r)("taskDialog.currentTask",{title:T.value})),1)])]),default:st(()=>[i("div",Vl,[ue(al,{modelValue:k.value,"onUpdate:modelValue":W[0]||(W[0]=P=>k.value=P),sections:v.value},null,8,["modelValue","sections"]),i("div",zl,[l.value?(g(),b("div",Hl,[ue(a(Xt),{class:"h-4 w-4 animate-spin"}),i("span",null,x(a(r)("taskDialog.loading")),1)])):(g(),b("div",ql,[k.value==="basic"?(g(),b("section",Kl,[i("div",null,[i("div",Wl,x(a(r)("taskDialog.sections.basic.title")),1),i("p",Gl,x(a(r)("taskDialog.sections.basic.intro")),1)]),i("section",Xl,[i("label",Yl,[i("span",Jl,x(a(r)("taskDialog.sections.basic.taskTitle")),1),Zt(i("input",{"onUpdate:modelValue":W[1]||(W[1]=P=>d.title=P),type:"text",maxlength:"140",class:"tool-input",placeholder:a(r)("taskDialog.sections.basic.taskTitlePlaceholder")},null,8,Ql),[[ms,d.title]])])])])):k.value==="automation"?(g(),b("section",Zl,[i("div",eu,[i("div",null,[i("div",tu,[ue(a(Xs),{class:"h-4 w-4"}),i("span",null,x(a(r)("taskDialog.sections.automation.title")),1)]),i("p",nu,x(a(r)("taskDialog.sections.automation.intro")),1)]),i("label",su,[Zt(i("input",{"onUpdate:modelValue":W[2]||(W[2]=P=>d.automationEnabled=P),type:"checkbox",class:"h-4 w-4"},null,512),[[ir,d.automationEnabled]]),i("span",null,x(a(r)("taskDialog.enabled")),1)])]),i("section",ou,[i("div",ru,[i("label",au,[i("span",iu,x(a(r)("taskDialog.sections.automation.mode")),1),ue(dn,{modelValue:d.automationMode,"onUpdate:modelValue":W[3]||(W[3]=P=>d.automationMode=P),options:h.value,disabled:!d.automationEnabled,"get-option-value":P=>P.value},{trigger:st(({selectedOption:P})=>[i("div",lu,x((P==null?void 0:P.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",uu,[i("span",cu,x(a(r)("taskDialog.sections.automation.time")),1),Zt(i("input",{"onUpdate:modelValue":W[4]||(W[4]=P=>d.automationTime=P),type:"time",class:"tool-input",disabled:!d.automationEnabled},null,8,du),[[ms,d.automationTime]])]),d.automationMode==="weekly"?(g(),b("label",fu,[i("span",pu,x(a(r)("taskDialog.sections.automation.weekday")),1),ue(dn,{modelValue:d.automationWeekday,"onUpdate:modelValue":W[5]||(W[5]=P=>d.automationWeekday=P),options:p.value,disabled:!d.automationEnabled,"get-option-value":P=>P.value},{trigger:st(({selectedOption:P})=>[i("div",mu,x((P==null?void 0:P.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])):de("",!0),i("label",gu,[i("span",hu,x(a(r)("taskDialog.sections.automation.timezone")),1),ue(dn,{modelValue:d.automationTimezone,"onUpdate:modelValue":W[6]||(W[6]=P=>d.automationTimezone=P),options:$.value,disabled:!d.automationEnabled,"get-option-value":P=>P.value},{trigger:st(({selectedOption:P})=>[i("div",vu,x((P==null?void 0:P.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",{class:be(["space-y-1.5",d.automationMode==="weekly"?"":"sm:col-span-2"])},[i("span",yu,x(a(r)("taskDialog.sections.automation.concurrencyPolicy")),1),ue(dn,{modelValue:d.automationConcurrencyPolicy,"onUpdate:modelValue":W[7]||(W[7]=P=>d.automationConcurrencyPolicy=P),options:ee.value,disabled:!d.automationEnabled,"get-option-value":P=>P.value},{trigger:st(({selectedOption:P})=>[i("div",Su,x((P==null?void 0:P.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])],2)]),i("div",wu,[i("p",null,x(a(r)("taskDialog.sections.automation.lastTriggered",{value:ve(d.automationLastTriggeredAt)})),1),i("p",null,x(a(r)("taskDialog.sections.automation.nextTriggered",{value:ve(d.automationNextTriggerAt)})),1)])])])):(g(),b("section",xu,[i("div",bu,[i("div",null,[i("div",ku,[ue(a(lr),{class:"h-4 w-4"}),i("span",null,x(a(r)("taskDialog.sections.notification.title")),1)]),i("p",Tu,x(a(r)("taskDialog.sections.notification.intro")),1)]),i("label",_u,[Zt(i("input",{"onUpdate:modelValue":W[8]||(W[8]=P=>d.notificationEnabled=P),type:"checkbox",class:"h-4 w-4"},null,512),[[ir,d.notificationEnabled]]),i("span",null,x(a(r)("taskDialog.enabled")),1)])]),i("section",Cu,[i("div",Eu,[i("label",Au,[i("span",Iu,x(a(r)("taskDialog.sections.notification.channelType")),1),ue(dn,{modelValue:d.notificationChannelType,"onUpdate:modelValue":W[9]||(W[9]=P=>d.notificationChannelType=P),options:y.value,disabled:!d.notificationEnabled,"get-option-value":P=>P.value},{trigger:st(({selectedOption:P})=>[i("div",$u,x((P==null?void 0:P.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Pu,[i("span",Du,x(a(r)("taskDialog.sections.notification.triggerOn")),1),ue(dn,{modelValue:d.notificationTriggerOn,"onUpdate:modelValue":W[10]||(W[10]=P=>d.notificationTriggerOn=P),options:B.value,disabled:!d.notificationEnabled,"get-option-value":P=>P.value},{trigger:st(({selectedOption:P})=>[i("div",Lu,x((P==null?void 0:P.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Mu,[i("span",Bu,x(a(r)("taskDialog.sections.notification.webhookUrl")),1),Zt(i("input",{"onUpdate:modelValue":W[11]||(W[11]=P=>d.notificationWebhookUrl=P),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.webhookUrlPlaceholder"),disabled:!d.notificationEnabled},null,8,Ru),[[ms,d.notificationWebhookUrl]])]),i("label",Nu,[i("span",Ou,x(a(r)("taskDialog.sections.notification.secret")),1),Zt(i("input",{"onUpdate:modelValue":W[12]||(W[12]=P=>d.notificationSecret=P),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.secretPlaceholder"),disabled:!d.notificationEnabled},null,8,Fu),[[ms,d.notificationSecret]])]),i("label",Uu,[i("span",ju,x(a(r)("taskDialog.sections.notification.locale")),1),ue(dn,{modelValue:d.notificationLocale,"onUpdate:modelValue":W[13]||(W[13]=P=>d.notificationLocale=P),options:V.value,disabled:!d.notificationEnabled,"get-option-value":P=>P.value},{trigger:st(({selectedOption:P})=>[i("div",Vu,x((P==null?void 0:P.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",zu,[i("span",Hu,x(a(r)("taskDialog.sections.notification.messageMode")),1),ue(dn,{modelValue:d.notificationMessageMode,"onUpdate:modelValue":W[14]||(W[14]=P=>d.notificationMessageMode=P),options:K.value,disabled:!d.notificationEnabled,"get-option-value":P=>P.value},{trigger:st(({selectedOption:P})=>[i("div",qu,x((P==null?void 0:P.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])]),i("div",Ku,[i("p",null,x(a(r)("taskDialog.sections.notification.status",{value:N.value})),1),i("p",null,x(a(r)("taskDialog.sections.notification.lastSent",{value:ve(d.notificationLastSentAt)})),1),d.notificationLastError?(g(),b("p",Wu,x(a(r)("taskDialog.sections.notification.lastError",{value:d.notificationLastError})),1)):de("",!0)])])])),m.value?(g(),b("p",Gu,x(m.value),1)):de("",!0)]))])]),i("div",Xu,[i("p",Yu,x(a(r)("taskDialog.footerHint")),1),i("div",Ju,[i("button",{type:"button",class:"tool-button px-3 py-2 text-sm",disabled:u.value,onClick:W[15]||(W[15]=P=>o("close"))},x(a(r)("common.cancel")),9,Qu),i("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-sm",disabled:u.value||l.value,onClick:te},[u.value?(g(),Ae(a(Xt),{key:0,class:"h-4 w-4 animate-spin"})):(g(),Ae(a(oi),{key:1,class:"h-4 w-4"})),i("span",null,x(u.value?a(r)("common.saving"):a(r)("taskDialog.saveTaskConfig")),1)],8,Zu)])])]),_:1},8,["open"]))}};function nc(e=[]){return(Array.isArray(e)&&e.length?e:Yo).filter(n=>n&&typeof n=="object").map(n=>{const o=Qs(n.value);return{...n,value:o,label:String(n.label||ht(o)).trim()||ht(o),enabled:n.enabled!==!1,available:n.available!==!1}})}function sc(e=[]){return nc(e).filter(t=>t.enabled&&t.available)}async function yS(){const e=await Ze("/api/meta",{cache:"no-store"});return sc(e==null?void 0:e.agentEngineOptions)}function ia(e={},t={}){const{defaultLabel:n="默认",prefix:o=""}=t,s=ht(e==null?void 0:e.engine),r=`${String(o||"")}${s}`;return e!=null&&e.isDefault?`${r} · ${n}`:r}const oc={key:0,class:"flex items-center gap-2 text-sm"},rc={class:"min-w-0 flex-1 truncate"},ac={class:"theme-muted-text ml-2 hidden font-mono text-[11px] sm:inline"},ic={class:"theme-status-neutral hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex"},lc={key:1,class:"theme-muted-text text-sm"},uc={class:"theme-divider theme-muted-text flex items-center justify-between gap-3 border-b border-dashed px-3 py-2 text-[11px]"},cc=["onClick"],dc={class:"flex items-center gap-3"},fc={class:"min-w-0 flex-1"},pc={class:"flex items-center gap-2 text-sm sm:hidden"},mc={class:"min-w-0 flex-1 truncate font-medium text-[var(--theme-textPrimary)]"},gc={class:"hidden items-center gap-2 text-sm sm:flex"},hc={class:"min-w-0 flex-1 truncate"},vc={class:"font-medium text-[var(--theme-textPrimary)]"},yc={class:"theme-muted-text ml-2 font-mono text-[11px]"},Sc={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},wc={__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}=Et();function s(d){return(d==null?void 0:d.title)||o("projectManager.untitledProject")}function r(d){return(d==null?void 0:d.cwd)||o("projectManager.notSet")}function l(d){return d!=null&&d.running?o("projectManager.running"):o("projectManager.idle")}function u(d){return d!=null&&d.running?"theme-status-warning":"theme-status-success"}function m(d){var v;const T=Math.max(0,Number((v=d==null?void 0:d.agentBindings)==null?void 0:v.length)||0);return T>1?o("projectManager.agentCount",{count:T}):ht(d==null?void 0:d.engine)}function k(d){return d?"theme-filter-active":"theme-filter-idle"}return(d,T)=>(g(),Ae(dn,{"model-value":e.modelValue,options:e.sessions,loading:e.loading,disabled:e.disabled,"trigger-class":"h-9",placeholder:a(o)("projectManager.selectProject"),"empty-text":a(o)("projectManager.noProjectsInSelect"),"get-option-value":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:st(({selectedOption:v,disabled:h})=>[v?(g(),b("div",oc,[i("span",rc,[i("span",{class:be(["font-medium",h?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},x(s(v)),3),i("span",ac,x(r(v)),1)]),i("span",ic,x(m(v)),1),i("span",{class:be(["hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex",u(v)])},x(l(v)),3)])):(g(),b("div",lc,x(e.loading?a(o)("projectManager.syncingProjects"):a(o)("projectManager.selectProject")),1))]),header:st(()=>[i("div",uc,[i("span",null,x(e.loading?a(o)("projectManager.syncingLatestProjects"):a(o)("projectManager.projectCount",{count:e.sessions.length})),1),e.loading?(g(),Ae(a(Xt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):de("",!0)])]),option:st(({option:v,selected:h,select:p})=>[i("button",{type:"button",class:be(["w-full rounded-sm border border-dashed p-3 text-left transition",k(h)]),onClick:p},[i("div",dc,[i("div",fc,[i("div",pc,[i("span",mc,x(s(v)),1)]),i("div",gc,[i("span",hc,[i("span",vc,x(s(v)),1),i("span",yc,x(r(v)),1)]),i("span",Sc,x(m(v)),1),i("span",{class:be(["inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",u(v)])},x(l(v)),3)])]),h?(g(),Ae(a(Jr),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):de("",!0)])],10,cc)]),_:1},8,["model-value","options","loading","disabled","placeholder","empty-text","get-option-value"]))}},xc=["disabled"],bc=["disabled"],kc=["src","alt"],la={__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}=Et(),r=j(1),l=q(()=>n.images.map(y=>String(y||"").trim()).filter(Boolean)),u=q(()=>l.value.findIndex(y=>y===n.modelValue)),m=q(()=>u.value>=0?l.value[u.value]:"");function k(){o("update:modelValue",""),r.value=1}function d(y){o("update:modelValue",String(y||"").trim()),r.value=1}function T(){u.value<=0||d(l.value[u.value-1])}function v(){u.value<0||u.value>=l.value.length-1||d(l.value[u.value+1])}function h(y){const B=Math.min(3,Math.max(.5,r.value+y));r.value=Math.round(B*100)/100}function p(){r.value=1}function $(y){m.value&&(y.preventDefault(),h(y.deltaY<0?.1:-.1))}function ee(y){var B,K;if(m.value){if((B=y.stopPropagation)==null||B.call(y),(K=y.stopImmediatePropagation)==null||K.call(y),y.key==="Escape"){y.preventDefault(),k();return}if(y.key==="ArrowLeft"){y.preventDefault(),T();return}if(y.key==="ArrowRight"){y.preventDefault(),v();return}if(y.key==="+"||y.key==="="){y.preventDefault(),h(.1);return}if(y.key==="-"){y.preventDefault(),h(-.1);return}y.key==="0"&&(y.preventDefault(),p())}}return Pe(()=>n.modelValue,y=>{y||(r.value=1)}),Pe(l,y=>{if(n.modelValue){if(!y.length){k();return}if(!y.includes(n.modelValue)){const B=Math.min(u.value,y.length-1);d(y[B]||y[0])}}},{immediate:!0}),pn(()=>{window.addEventListener("keydown",ee,{capture:!0})}),Mt(()=>{window.removeEventListener("keydown",ee,{capture:!0})}),(y,B)=>(g(),Ae(_s,{to:"body"},[m.value?(g(),b("div",{key:0,class:"theme-modal-backdrop image-preview-overlay fixed inset-0 z-[120] flex items-center justify-center p-6",onClick:k,onWheel:$},[i("div",{class:"absolute left-4 top-4 flex items-center gap-2",onClick:B[2]||(B[2]=ot(()=>{},["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=>h(-.1))},x(a(s)("imagePreview.zoomOut")),1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:p},x(Math.round(r.value*100))+"% ",1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:B[1]||(B[1]=K=>h(.1))},x(a(s)("imagePreview.zoomIn")),1)]),i("div",{class:"absolute right-4 top-4 flex items-center gap-2",onClick:B[3]||(B[3]=ot(()=>{},["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},x(a(s)("imagePreview.previous")),9,xc),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},x(a(s)("imagePreview.next")),9,bc),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:k},x(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:An({transform:`scale(${r.value})`}),onClick:B[4]||(B[4]=ot(()=>{},["stop"]))},null,12,kc)],32)):de("",!0)]))}};let ko=null;const SS={maxLines:2e3,maxChars:2e5},To={maxLines:2e3,maxChars:2e5},Tc={"github-dark-default":()=>He(()=>import("./vendor-shiki-theme-github-dark-default-DBX58552.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),"github-light":()=>He(()=>import("./vendor-shiki-theme-github-light-RLAvZv0q.js"),__vite__mapDeps([4,1,2,3])).then(e=>e.default)},_c={bash:()=>He(()=>import("./vendor-shiki-lang-bash-zsQu0xn-.js"),__vite__mapDeps([5,1,2,3])).then(e=>e.default),c:()=>He(()=>import("./vendor-shiki-lang-c-BDF8vgks.js"),__vite__mapDeps([6,1,2,3])).then(e=>e.default),cpp:()=>He(()=>import("./vendor-shiki-lang-cpp-DyDAaXl6.js"),__vite__mapDeps([7,1,2,3])).then(e=>e.default),csharp:()=>He(()=>import("./vendor-shiki-lang-csharp-BWfTXJXw.js"),__vite__mapDeps([8,1,2,3])).then(e=>e.default),css:()=>He(()=>import("./vendor-shiki-lang-css-DbAm1fUO.js"),__vite__mapDeps([9,1,2,3])).then(e=>e.default),diff:()=>He(()=>import("./vendor-shiki-lang-diff-DmGC1G26.js"),__vite__mapDeps([10,1,2,3])).then(e=>e.default),dockerfile:()=>He(()=>import("./vendor-shiki-lang-dockerfile-3x-8396r.js"),__vite__mapDeps([11,1,2,3])).then(e=>e.default),dotenv:()=>He(()=>import("./vendor-shiki-lang-dotenv--IVOlX2Q.js"),__vite__mapDeps([12,1,2,3])).then(e=>e.default),fish:()=>He(()=>import("./vendor-shiki-lang-fish-Bpv3hhJP.js"),__vite__mapDeps([13,1,2,3])).then(e=>e.default),go:()=>He(()=>import("./vendor-shiki-lang-go-CIGC59jP.js"),__vite__mapDeps([14,1,2,3])).then(e=>e.default),html:()=>He(()=>import("./vendor-shiki-lang-html-Bt_TLLZN.js"),__vite__mapDeps([15,1,2,3])).then(e=>e.default),ini:()=>He(()=>import("./vendor-shiki-lang-ini-BIllfys4.js"),__vite__mapDeps([16,1,2,3])).then(e=>e.default),java:()=>He(()=>import("./vendor-shiki-lang-java-CXxu9crF.js"),__vite__mapDeps([17,1,2,3])).then(e=>e.default),javascript:()=>He(()=>import("./vendor-shiki-lang-javascript-Cha7GNZm.js"),__vite__mapDeps([18,1,2,3])).then(e=>e.default),json:()=>He(()=>import("./vendor-shiki-lang-json-CCZCjDUh.js"),__vite__mapDeps([19,1,2,3])).then(e=>e.default),less:()=>He(()=>import("./vendor-shiki-lang-less-DAToytC5.js"),__vite__mapDeps([20,1,2,3])).then(e=>e.default),markdown:()=>He(()=>import("./vendor-shiki-lang-markdown-C6lwMXFp.js"),__vite__mapDeps([21,1,2,3])).then(e=>e.default),python:()=>He(()=>import("./vendor-shiki-lang-python-Bi9rmtY7.js"),__vite__mapDeps([22,1,2,3])).then(e=>e.default),powershell:()=>He(()=>import("./vendor-shiki-lang-powershell-lrpuM0ez.js"),__vite__mapDeps([23,1,2,3])).then(e=>e.default),rust:()=>He(()=>import("./vendor-shiki-lang-rust-GTGDbY6A.js"),__vite__mapDeps([24,1,2,3])).then(e=>e.default),sass:()=>He(()=>import("./vendor-shiki-lang-sass-DFtHupN8.js"),__vite__mapDeps([25,1,2,3])).then(e=>e.default),scss:()=>He(()=>import("./vendor-shiki-lang-scss-BrfBNyyi.js"),__vite__mapDeps([26,1,2,3])).then(e=>e.default),sql:()=>He(()=>import("./vendor-shiki-lang-sql-H6--iFN-.js"),__vite__mapDeps([27,1,2,3])).then(e=>e.default),toml:()=>He(()=>import("./vendor-shiki-lang-toml-aTteTWYL.js"),__vite__mapDeps([28,1,2,3])).then(e=>e.default),tsx:()=>He(()=>import("./vendor-shiki-lang-tsx-DoKZm6AV.js"),__vite__mapDeps([29,1,2,3])).then(e=>e.default),typescript:()=>He(()=>import("./vendor-shiki-lang-typescript-B5awnqri.js"),__vite__mapDeps([30,1,2,3])).then(e=>e.default),vue:()=>He(()=>import("./vendor-shiki-lang-vue-CnrgQ7Z5.js"),__vite__mapDeps([31,1,2,3])).then(e=>e.default),xml:()=>He(()=>import("./vendor-shiki-lang-xml-Bv-TNPJt.js"),__vite__mapDeps([32,1,2,3])).then(e=>e.default),yaml:()=>He(()=>import("./vendor-shiki-lang-yaml-DpxUxQ6M.js"),__vite__mapDeps([33,1,2,3])).then(e=>e.default)};function ua(e=0){return Number(e)>9999?"3.4rem":"2.6rem"}function Zo(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 er(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 Cc(e=[],t={}){const n=Zo(e);return er(n,{maxHighlightLines:t.maxLines,maxHighlightChars:t.maxChars})}function Ec(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
6
+ `);return Cc(n?n.split(`
7
+ `):[],t)}async function ca(){return ko||(ko=Promise.all([He(()=>import("./vendor-shiki-core-1BqeTDsZ.js").then(e=>e.F),__vite__mapDeps([1,2,3])),He(()=>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:[]}))),ko}async function da(e,t){if(!t||e.getLoadedThemes().includes(t))return;const n=Tc[t];n&&await e.loadTheme(await n())}async function fa(e,t){if(!t||e.getLoadedLanguages().includes(t))return;const n=_c[t];n&&await e.loadLanguage(await n())}function Xn(e=""){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Ac={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 lo(e=""){const t=String(e||"").trim().toLowerCase();return t?Ac[t]||t:""}function wS(e="",t=""){const n=lo(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 pa(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=Xn((e==null?void 0:e.content)||"");return`<span${t.length?` style="${t.join(";")}"`:""}>${n}</span>`}function ma(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:ua(e.length)}}function xS(e=[]){return(Array.isArray(e)?e.map(n=>String(n??"")):[]).map(n=>n?Xn(n):"&#8203;")}function _o(e=""){const t=String(e||"").replace(/\r\n/g,`
8
+ `);return ma(t.split(`
9
+ `).map(n=>n?Xn(n):"&#8203;"),{})}async function Ic(e=[],t={}){const n=Zo(e),o=n.lines,s=t.isDark?"github-dark-default":"github-light",r=lo(t.language);if(!o.length)return[];if(er(n,t))return o.map(l=>l?Xn(l):"&#8203;");if(!r)return o.map(l=>l?Xn(l):"&#8203;");try{const l=await ca();return await da(l,s),await fa(l,r),(await l.codeToTokens(o.join(`
10
+ `),{lang:r,theme:s})).tokens.map(m=>m.length?m.map(pa).join(""):"&#8203;")}catch{return o.map(l=>l?Xn(l):"&#8203;")}}async function $c(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
11
+ `),o=t.isDark?"github-dark-default":"github-light",s=lo(t.language),r=n?n.split(`
12
+ `):[],l=Zo(r);if(!n)return{html:"",lineCount:0,bg:"",fg:"",gutterWidth:ua(0)};if(er(l,t)||!s)return _o(n);try{const u=await ca();await da(u,o),await fa(u,s);const m=await u.codeToTokens(n,{lang:s,theme:o});return ma(m.tokens.map(k=>k.length?k.map(pa).join(""):"&#8203;"),{bg:m.bg||"",fg:m.fg||""})}catch{return _o(n)}}const Pc=new ta,Dc="__PROMPTX_FENCE__";function ga(e=""){return String(e||"").trim().toLowerCase()}function Ms(e=""){return Pc.utils.escapeHtml(String(e||""))}function Lc(e=""){const t=ga(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 ha(e={}){const t=new ta({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,k,d)=>{const T=l[u];return T.attrSet("target","_blank"),T.attrSet("rel","noreferrer noopener"),typeof n=="function"?n(l,u,m,k,d):d.renderToken(l,u,m)},t.renderer.rules.table_open=(l,u,m,k,d)=>`<div class="codex-table-wrap">${typeof o=="function"?o(l,u,m,k,d):d.renderToken(l,u,m)}`,t.renderer.rules.table_close=(l,u,m,k,d)=>`${typeof s=="function"?s(l,u,m,k,d):d.renderToken(l,u,m)}</div>`,e.captureFences?t.renderer.rules.fence=(l,u,m,k={},d)=>{const T=l[u],v=Array.isArray(k.__promptxFences)?k.__promptxFences:[],h=v.length,p=`${Dc}${h}__`;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}),k.__promptxFences=v,p}:typeof r=="function"&&(t.renderer.rules.fence=r),t}const Mc=ha({captureFences:!0}),Bc=ha();async function Rc(e="",t="",n={}){const o=String(e||"").replace(/\r\n/g,`
13
+ `),s=ga(t),r=lo(s),u=(await Ic(o.split(`
14
+ `),{isDark:!!n.isDark,language:r||s})).join(`
15
+ `),m=s?` class="language-${Ms(s)}"`:"",k=Lc(t),d=Ms(String(n.copyLabel||"Copy")),T=Ms(String(n.copyAriaLabel||d)),h=`<div class="codex-code-block__header">${k?`<span class="codex-code-block__language">${Ms(k)}</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}">${d}</button></div>`;return`<div class="${k?"codex-code-block codex-code-block--labeled":"codex-code-block"}">${h}<pre><code${m}>${u}</code></pre></div>`}async function Nc(e="",t=[],n={}){if(!Array.isArray(t)||!t.length)return e;const o=await Promise.all(t.map(s=>Rc(s.content,s.language,n)));return t.reduce((s,r,l)=>s.replace(r.placeholder,o[l]||r.placeholder),e)}async function Oc(e="",t={}){const n=String(e||"").trim();if(!n)return"";const o={},s=Mc.render(n,o);return Nc(s,o.__promptxFences||[],t)}function va(e=""){const t=String(e||"").trim();return t?Bc.render(t):""}function Fc(e=""){let t=5381;for(const n of String(e||""))t=(t<<5)+t+n.charCodeAt(0),t|=0;return String(t>>>0)}function mr(e={}){const t=String((e==null?void 0:e.id)||"").trim();return t?`id:${t}`:`${(e==null?void 0:e.type)||"block"}:${Fc(JSON.stringify(e||{}))}`}function Uc(e=[]){const t=Array.isArray(e)?e:[],n=t.reduce((s,r)=>{const l=mr(r);return s.set(l,(s.get(l)||0)+1),s},new Map),o=new Map;return t.map(s=>{const r=mr(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 jc={key:0,class:"process-detail min-w-0 w-full max-w-full space-y-2"},Vc={key:0,class:"process-detail-meta"},zc={key:0,class:"process-detail-meta__label"},Hc={key:1,class:"process-detail-panel"},qc={class:"space-y-1.5"},Kc={key:1,class:"process-detail-checklist__dot"},Wc={key:0,class:"process-detail-footnote"},Gc={key:0},Xc={key:2,class:"process-detail-panel"},Yc={class:"process-detail-directory__heading"},Jc={key:0,class:"font-medium"},Qc={key:1,class:"process-detail-directory__type"},Zc={class:"process-detail-directory__list"},ed={key:0,class:"process-detail-footnote"},td={key:0},nd={key:3,class:"process-detail-panel"},sd={class:"list-disc min-w-0 w-full max-w-full space-y-1.5 pl-5"},od={key:0,class:"process-detail-footnote"},rd={key:4,class:"process-detail-panel"},ad={class:"space-y-1.5"},id={class:"process-detail-filechange__kind"},ld={class:"process-detail-filechange__path process-detail-mobile-code-scroll"},ud={key:5,class:"process-detail-panel"},cd={class:"space-y-2"},dd={class:"flex min-w-0 items-center gap-2 text-xs leading-5"},fd={class:"min-w-0 flex flex-1 items-center gap-2"},pd={class:"shrink-0 font-medium text-[var(--theme-textPrimary)]"},md=["title"],gd=["onClick"],hd={class:"process-detail-directory__type shrink-0"},vd={key:0,class:"mt-2 border-l border-dashed border-[var(--theme-borderDefault)] pl-3"},yd={key:1,class:"whitespace-pre-wrap break-words text-xs leading-5"},Sd=["innerHTML"],wd={key:7,class:"process-detail-text"},xd=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}=Et(),o=j(new Set),s=q(()=>{const D=Array.isArray(t.blocks)?t.blocks.filter(Boolean):[];return D.length?D:String(t.detail||"").trim()?[{type:"text",text:String(t.detail||"").trim()}]:[]}),r=q(()=>Uc(s.value)),l=q(()=>r.value.map(D=>D.key));Pe(s,(D=[])=>{const ne=new Set;D.forEach((le,te)=>{(le==null?void 0:le.type)==="sub_agent_list"&&(Array.isArray(le.items)?le.items:[]).forEach((ve,C)=>{ne.add(se(te,ve,C))})}),o.value=new Set([...o.value].filter(le=>ne.has(le)))},{immediate:!0});function u(D=""){return va(String(D||""))}function m(D=""){const ne=String(D||"").trim();return n(ne==="create"?"processDetail.changeCreate":ne==="delete"?"processDetail.changeDelete":ne==="update"?"processDetail.changeUpdate":"processDetail.changeGeneric")}function k(D={}){const ne=String((D==null?void 0:D.label)||"").trim().toLowerCase(),le=String((D==null?void 0:D.value)||"").trim();return le?le.length>56||["命令","command","目标","target","url","路径","path"].includes(ne)&&le.length>28?!0:le.includes(" ")&&le.length>36:!1}function d(D={},ne=[]){const le=String((D==null?void 0:D.label)||"").trim().toLowerCase();return["命令","command"].includes(le)?Array.isArray(ne)&&ne.length===1:!1}function T(D={}){const ne=String((D==null?void 0:D.label)||"").trim().toLowerCase();return["命令","command","路径","path","url","目标","target"].includes(ne)}function v(D={}){return D!=null&&D.completed?"completed":String((D==null?void 0:D.status)||"").trim().toLowerCase()==="in_progress"?"in_progress":"pending"}function h(D=0){return n("processDetail.hiddenItems",{count:D})}function p(D=0){return n("processDetail.directorySummary",{count:D})}function $(D=0){return n("processDetail.directoryHidden",{count:D})}function ee(D=0){return l.value[D]||`block-${D}`}function y(D=""){const ne=String(D||"").trim().toLowerCase();return n(ne==="completed"?"processDetail.subAgentCompleted":ne==="failed"?"processDetail.subAgentFailed":ne==="running"?"processDetail.subAgentRunning":ne==="pending_init"?"processDetail.subAgentPending":"processDetail.subAgentUnknown")}function B(D={}){return String((D==null?void 0:D.title)||(D==null?void 0:D.target)||(D==null?void 0:D.id)||"").trim()}function K(D={}){const ne=B(D),le=[],te=String((D==null?void 0:D.role)||"").trim(),ve=String((D==null?void 0:D.target)||"").trim(),C=String((D==null?void 0:D.model)||"").trim();return te&&te.toLowerCase()!=="default"&&le.push(te),ve&&ve!==ne&&le.push(ve),C&&le.push(C),le.join(" · ")}function V(D={}){return!!String((D==null?void 0:D.message)||"").trim()}function N(D={}){const ne=String((D==null?void 0:D.message)||"").replace(/\s+/g," ").trim();return ne||K(D)}function se(D=0,ne={},le=0){return`${ee(D)}:sub-agent:${String((ne==null?void 0:ne.id)||(ne==null?void 0:ne.target)||(ne==null?void 0:ne.title)||le)}`}function I(D=0,ne={},le=0){return o.value.has(se(D,ne,le))}function X(D=0,ne={},le=0){const te=se(D,ne,le),ve=new Set(o.value);ve.has(te)?ve.delete(te):ve.add(te),o.value=ve}function ge(D={}){return Array.isArray(D==null?void 0:D.messageBlocks)?D.messageBlocks.filter(Boolean):[]}function ye(D={}){return ge(D).some(le=>!["text","markdown"].includes(String((le==null?void 0:le.type)||"").trim()))}return(D,ne)=>{const le=Za("ProcessDetailRenderer",!0);return s.value.length?(g(),b("div",jc,[(g(!0),b(it,null,pt(s.value,(te,ve)=>(g(),b(it,{key:l.value[ve]||`${te.type}-${ve}`},[te.type==="meta"?(g(),b("div",Vc,[(g(!0),b(it,null,pt(te.items||[],(C,W)=>(g(),b("div",{key:`${ve}-meta-${W}`,class:be(["process-detail-meta__item",{"process-detail-meta__item--long":k(C),"process-detail-meta__item--value-only":d(C,te.items)}])},[d(C,te.items)?de("",!0):(g(),b("span",zc,x(C.label),1)),i("span",{class:be(["process-detail-meta__value",{"process-detail-mobile-code-scroll":k(C),"process-detail-meta__value--mono":T(C)}])},x(C.value),3)],2))),128))])):te.type==="checklist"?(g(),b("div",Hc,[i("div",qc,[(g(!0),b(it,null,pt(te.items||[],(C,W)=>(g(),b("div",{key:`${ve}-check-${W}`,class:"process-detail-checklist__item"},[i("span",{class:be(["process-detail-checklist__icon",`is-${v(C)}`])},[v(C)==="completed"?(g(),Ae(a(Jr),{key:0,class:"h-3 w-3"})):v(C)==="in_progress"?(g(),b("span",Kc)):de("",!0)],2),i("span",{class:be(v(C)==="completed"?"line-through":"")},x(C.text),3)]))),128))]),te.totalCount?(g(),b("div",Wc,[Tn(x(`已完成 ${(te.items||[]).filter(C=>C.completed).length} / ${te.totalCount}`)+" ",1),te.hiddenCount?(g(),b("span",Gc,x(`,还有 ${te.hiddenCount} 项`),1)):de("",!0)])):de("",!0)])):te.type==="directory_list"?(g(),b("div",Xc,[i("div",Yc,[te.path?(g(),b("span",Jc,x(te.path),1)):de("",!0),te.entryType?(g(),b("span",Qc,x(te.entryType),1)):de("",!0)]),i("div",Zc,[(g(!0),b(it,null,pt(te.entries||[],(C,W)=>(g(),b("div",{key:`${ve}-entry-${W}`,class:"process-detail-directory__item"},x(C),1))),128))]),te.totalCount?(g(),b("div",ed,[Tn(x(p(te.totalCount))+" ",1),te.hiddenCount?(g(),b("span",td,x($(te.hiddenCount)),1)):de("",!0)])):de("",!0)])):te.type==="bullet_list"?(g(),b("div",nd,[i("ul",sd,[(g(!0),b(it,null,pt(te.items||[],(C,W)=>(g(),b("li",{key:`${ve}-bullet-${W}`,class:"min-w-0 w-full max-w-full break-words [overflow-wrap:anywhere]"},x(C),1))),128))]),te.hiddenCount?(g(),b("div",od,x(h(te.hiddenCount)),1)):de("",!0)])):te.type==="file_changes"?(g(),b("div",rd,[i("div",ad,[(g(!0),b(it,null,pt(te.items||[],(C,W)=>(g(),b("div",{key:`${ve}-change-${W}`,class:"process-detail-filechange__item"},[i("span",id,x(m(C.kind)),1),i("span",ld,x(C.path),1)]))),128))])])):te.type==="sub_agent_list"?(g(),b("div",ud,[i("div",cd,[(g(!0),b(it,null,pt(te.items||[],(C,W)=>(g(),b("div",{key:`${ve}-sub-agent-${W}`,class:"min-w-0"},[i("div",dd,[i("div",fd,[i("span",pd,x(B(C)),1),N(C)?(g(),b("span",{key:0,class:"process-detail-subagent__preview min-w-0 flex-1",title:N(C)},x(N(C)),9,md)):de("",!0)]),V(C)?(g(),b("button",{key:0,type:"button",class:"shrink-0 text-[11px] underline decoration-dashed underline-offset-2",onClick:P=>X(ve,C,W)},x(I(ve,C,W)?a(n)("common.collapse"):a(n)("common.expand")),9,gd)):de("",!0),i("span",hd,x(y(C.status)),1)]),V(C)&&I(ve,C,W)?(g(),b("div",vd,[ye(C)?(g(),Ae(le,{key:0,blocks:ge(C),kind:"sub-agent-message"},null,8,["blocks"])):(g(),b("pre",yd,x(C.message),1))])):de("",!0)]))),128))])])):te.type==="markdown"?(g(),b("div",{key:6,class:be(["codex-markdown process-detail-markdown",{"process-detail-markdown--reasoning":t.kind==="reasoning"}]),innerHTML:u(te.text)},null,10,Sd)):(g(),b("pre",wd,x(te.text),1))],64))),128))])):de("",!0)}}}),ya={__name:"SelectionInsertButton",props:{label:{type:String,default:""},top:{type:Number,default:0},left:{type:Number,default:0}},emits:["click"],setup(e,{emit:t}){function n(s){var r,l;typeof(s==null?void 0:s.button)=="number"&&s.button!==0||((r=s==null?void 0:s.preventDefault)==null||r.call(s),(l=s==null?void 0:s.stopPropagation)==null||l.call(s),o("click"))}const o=t;return(s,r)=>(g(),b("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:An({top:`${e.top}px`,left:`${e.left}px`}),onPointerdown:n,onKeydown:[r[0]||(r[0]=en(ot(l=>o("click"),["prevent"]),["enter"])),r[1]||(r[1]=en(ot(l=>o("click"),["prevent"]),["space"]))]},x(e.label),37))}},Sa=96,gr=34,kn=8,bd=72;function kd(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement||null:null}function hr(e,t,n){var r;const o=kd(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 Td(e){const t=(e==null?void 0:e.commonAncestorContainer)||null;return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentNode||null:null}function _d(e,t,{codeLeft:n=0,buttonWidth:o=Sa,scrollTop:s=0,scrollLeft:r=0,clientWidth:l=0,clientHeight:u=0}={}){const k=Math.max(e.left||0,Number(n)||0)-t.left+r,d=r+kn,T=r+Math.max(kn,l-o-kn),v=Math.max(d,Math.min(T,k||r+kn)),h=e.bottom-t.top+s+kn,p=e.top-t.top+s-gr-kn,$=s+kn,ee=s+u-kn;return{top:h+gr<=ee?h:Math.max($,p),left:v}}function wa(e={}){const t=j([]),n=j({visible:!1,top:0,left:0,content:""});let o=null,s=0;function r(){var V;return typeof e.getContainer=="function"?e.getContainer():((V=e.containerRef)==null?void 0:V.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 k(V=[]){var N;t.value=V,(N=e.onSelectedRowsChange)==null||N.call(e,V)}function d({clearBrowserSelection:V=!1}={}){var N,se,I,X;u(),m(),V&&((I=(se=(N=window.getSelection)==null?void 0:N.call(window))==null?void 0:se.removeAllRanges)==null||I.call(se)),n.value={visible:!1,top:0,left:0,content:""},k([]),(X=e.onClear)==null||X.call(e)}function T(V){return V?typeof e.getOrderedRowElements=="function"?e.getOrderedRowElements(V).filter(Boolean):[...V.querySelectorAll(String(e.rowSelector||""))]:[]}function v(V){var N;return((N=e.mapRowElement)==null?void 0:N.call(e,V))??V}function h(V,N,se){const I=String(e.rowSelector||"").trim(),X=T(se);if(!I||!X.length)return[];const ge=hr(V.anchorNode,I,se),ye=hr(V.focusNode,I,se);if(ge&&ye){const D=X.indexOf(ge),ne=X.indexOf(ye);if(D>=0&&ne>=0){const[le,te]=D<=ne?[D,ne]:[ne,D];return X.slice(le,te+1)}}return X.filter(D=>{try{return N.intersectsNode(D)}catch{return!1}})}function p(){var W,P,Ee;const V=(W=window.getSelection)==null?void 0:W.call(window),N=r(),se=l();if(!(typeof e.isActive=="function"?e.isActive():!0)||!V||V.rangeCount<1||V.isCollapsed||!N||!se){d();return}const X=V.getRangeAt(0),ge=Td(X);if(!ge||!N.contains(ge)){d();return}const ye=String(V.toString()||"").replace(/\u200b/g,"");if(!ye.trim()){d();return}const D=h(V,X,N);if(!D.length){d();return}const ne=D.map(Ie=>v(Ie)).filter(Ie=>Ie!==null&&typeof Ie<"u");if(!ne.length){d();return}const le=X.getBoundingClientRect(),te=(P=se.getBoundingClientRect)==null?void 0:P.call(se);if(!te){d();return}const ve=((Ee=e.getCodeLeft)==null?void 0:Ee.call(e,D[0]))||le.left,C=_d(le,te,{codeLeft:ve,buttonWidth:Number(e.buttonWidth||Sa),scrollTop:Number(se.scrollTop||0),scrollLeft:Number(se.scrollLeft||0),clientWidth:Number(se.clientWidth||0),clientHeight:Number(se.clientHeight||0)});n.value={visible:!0,top:C.top,left:C.left,content:ye},k(ne)}function $(){u(),o=window.setTimeout(()=>{o=null,p()},Number(e.debounceMs||bd))}function ee(){$()}function y(){$()}function B(){!n.value.visible||s||(s=window.requestAnimationFrame(()=>{s=0,p()}))}function K(){B()}return pn(()=>{var V,N,se,I;document.addEventListener("selectionchange",y),document.addEventListener("mouseup",y),document.addEventListener("scroll",K,!0),window.addEventListener("resize",K),(N=(V=window.visualViewport)==null?void 0:V.addEventListener)==null||N.call(V,"resize",K),(I=(se=window.visualViewport)==null?void 0:se.addEventListener)==null||I.call(se,"scroll",K)}),Mt(()=>{var V,N,se,I;d({clearBrowserSelection:!0}),document.removeEventListener("selectionchange",y),document.removeEventListener("mouseup",y),document.removeEventListener("scroll",K,!0),window.removeEventListener("resize",K),(N=(V=window.visualViewport)==null?void 0:V.removeEventListener)==null||N.call(V,"resize",K),(I=(se=window.visualViewport)==null?void 0:se.removeEventListener)==null||I.call(se,"scroll",K)}),{selectedRows:t,selectionAction:n,clearSelectionState:d,clearScheduledSelectionUpdate:u,handleSelectionMouseUp:ee,scheduleSelectionUpdate:$,updateSelectionActionFromDom:p}}const Cd=250,Ed=350,Ad=180,js=2;function Ro(e){return(e==null?void 0:e.name)==="AbortError"}const Co="promptx:codex-recent-paths",Id=12;function xa(e){const{getMode:t,props:n,onSelect:o}=e,s=j([]),r=j(!1),l=j(""),u=j([]),m=j(!1),k=j(""),d=j([]),T=j([]),v=j("tree"),h=j(""),p=new Map;let $=null,ee=0,y=0,B=null;const K=q(()=>String(n.query||"").trim()),V=q(()=>Math.max(1,Number(e.minimumQueryLength)||js)),N=q(()=>K.value.length>=V.value),se=q(()=>typeof t=="function"),I=q(()=>se.value?String((t==null?void 0:t())||"").trim()==="search"?"search":"tree":v.value),X=q(()=>Ke(s.value)),ge=q(()=>String(n.sessionId||"").trim()),ye=q(()=>ge.value?`promptx:codex-tree-expanded:${ge.value}`:""),D=q(()=>{if(!K.value)return d.value;const z=new Set(u.value.map(Q=>Q.path));return d.value.filter(Q=>z.has(Q.path))}),ne=q(()=>{const z=new Set(D.value.map(Q=>Q.path));return u.value.filter(Q=>!z.has(Q.path))}),le=q(()=>K.value?[...D.value,...ne.value]:d.value),te=q(()=>I.value==="search"?le.value:X.value),ve=q(()=>I.value==="search"?m.value:r.value),C=q(()=>I.value==="search"?k.value:l.value),W=q(()=>I.value==="search"&&!!n.sessionId&&N.value&&!m.value&&!k.value&&!le.value.length),P=q(()=>I.value==="search"&&!!n.sessionId&&!!K.value&&!N.value&&!m.value&&!k.value),Ee=q(()=>I.value==="tree"&&!!n.sessionId&&!r.value&&!l.value&&!X.value.length);function Ie(z,Q){if(!z||typeof window>"u")return Q;try{const ce=window.localStorage.getItem(z);return ce?JSON.parse(ce):Q}catch{return Q}}function Be(z,Q){if(!(!z||typeof window>"u"))try{window.localStorage.setItem(z,JSON.stringify(Q))}catch{}}function Ye(z=[]){return[...z].sort((Q,ce)=>{const Se=+(Q.type!=="directory")-+(ce.type!=="directory");return Se||String(Q.path||Q.name||"").localeCompare(String(ce.path||ce.name||""),"zh-CN")})}function Je(z){return{...z,children:[],expanded:!1,loaded:!1,loading:!1}}function Ke(z=[],Q=0,ce=[]){return z.forEach(Se=>{ce.push({...Se,depth:Q}),Se.type==="directory"&&Se.expanded&&Se.children.length&&Ke(Se.children,Q+1,ce)}),ce}function we(z,Q=s.value){for(const ce of Q){if(ce.path===z)return ce;if(ce.children.length){const Se=we(z,ce.children);if(Se)return Se}}return null}function H(){s.value=[...s.value]}function Z(){$&&(window.clearTimeout($),$=null),B&&(B.abort(),B=null)}function me(z=s.value,Q=[]){return z.forEach(ce=>{ce.type==="directory"&&ce.expanded&&(Q.push(ce.path),ce.children.length&&me(ce.children,Q))}),Q}function _e(){if(!ye.value)return;const z=[...new Set(me())];T.value=z,Be(ye.value,z)}function fe(){T.value=ye.value?Ie(ye.value,[]).filter(Boolean):[]}function Le(z=s.value,Q=new Set){if(!Q.size)return!1;const ce=z.filter(Se=>Se.type==="directory"&&Se.hasChildren).map(Se=>Se.path);return!ce.length||ce.length!==Q.size?!1:ce.every(Se=>Q.has(Se))}function he(){const z=Ie(Co,[]);if(!Array.isArray(z)||!ge.value){d.value=[];return}d.value=z.filter(Q=>Q&&Q.sessionId===ge.value&&Q.path).sort((Q,ce)=>Number(ce.usedAt||0)-Number(Q.usedAt||0)).slice(0,Id)}function Me(z){return z.name||z.path||"."}function je(z){return z.path||"."}function De(z){if(!ge.value||!(z!=null&&z.path))return;const Q={sessionId:ge.value,path:z.path,name:z.name||Me(z),type:z.type||"file",usedAt:Date.now()},ce=Ie(Co,[]),Se=[Q];Array.isArray(ce)&&ce.forEach(qe=>{!(qe!=null&&qe.path)||!(qe!=null&&qe.sessionId)||qe.sessionId===Q.sessionId&&qe.path===Q.path||Se.push(qe)}),Be(Co,Se.slice(0,40)),he()}function vt(z=""){const Q=String(z||"").trim();return!Q||!Q.includes("/")?"":Q.slice(0,Q.lastIndexOf("/"))}function Xe(){const z=te.value;if(!z.length)return-1;const Q=z.findIndex(ce=>ce.path===h.value);return Q>=0?Q:0}function St(){const z=te.value,Q=Xe();return Q<0||!z.length?null:z[Q]||null}function et(){const z=te.value;if(!z.length){h.value="";return}z.some(Q=>Q.path===h.value)||(h.value=z[0].path)}function mt(z,Q){if(Q){p.set(z,Q);return}p.delete(z)}function ze(){var Q;const z=p.get(h.value);(Q=z==null?void 0:z.scrollIntoView)==null||Q.call(z,{block:"nearest"})}function Ce(z=""){return String(z||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function lt(z="",Q=""){const ce=String(z||""),Se=String(Q||"").trim().toLowerCase();if(!ce||!Se)return null;const qe=ce.toLowerCase(),gt=qe.indexOf(Se);if(gt>=0)return{start:gt,end:gt+Se.length};const Rt=Se.split(/[\\/\s_.-]+/).filter(Boolean).sort((jt,Pt)=>Pt.length-jt.length);for(const jt of Rt){if(jt.length<2)continue;const Pt=qe.indexOf(jt);if(Pt>=0)return{start:Pt,end:Pt+jt.length}}return null}function dt(z="",Q=""){const ce=String(z||""),Se=lt(ce,Q);return Se?`${Ce(ce.slice(0,Se.start))}<mark class="theme-search-highlight">${Ce(ce.slice(Se.start,Se.end))}</mark>${Ce(ce.slice(Se.end))}`:Ce(ce)}function L(z){return dt(Me(z),K.value)}function U(z){return dt(je(z),K.value)}async function oe(z="",Q={}){if(!n.sessionId){s.value=[],l.value="",r.value=!1;return}const ce=!z,Se=ce?null:we(z);if(!(!ce&&!Se)&&!(!Q.force&&(ce&&s.value.length||!ce&&Se.loaded))){ce?(r.value=!0,l.value=""):(Se.loading=!0,l.value="",H());try{const qe=await Il(n.sessionId,{path:z,refreshToken:Q.refreshToken||""}),gt=Ye(qe.items||[]).map(Je);if(ce){s.value=gt;return}Se.children=gt,Se.loaded=!0}catch(qe){l.value=qe.message}finally{ce?r.value=!1:(Se.loading=!1,H())}}}async function Te(z=s.value,Q=new Set,ce={}){for(const Se of z)Se.type!=="directory"||!Q.has(Se.path)||(Se.expanded=!0,H(),await oe(Se.path,ce),Se.children.length&&await Te(Se.children,Q,ce))}async function Re(z={}){await oe("",z);const Q=new Set(T.value),ce=Le(s.value,Q),Se=Q.size>0&&!ce;ce&&(T.value=[],Be(ye.value,[]),Q.clear());for(const qe of s.value)qe.type!=="directory"||!qe.hasChildren||(qe.expanded=Se?Q.has(qe.path):!1);if(H(),Se){await Te(s.value,Q,z);return}}async function $e(z){if(I.value!=="tree")return;const Q=we(z);if(!(!Q||Q.type!=="directory")){if(!Q.loaded&&!Q.loading){Q.expanded=!0,H(),await oe(Q.path),_e();return}Q.expanded=!Q.expanded,H(),_e()}}function tt(z){return z!=null&&z.path?(De(z),o==null||o(z),!0):!1}async function Ve(z={}){const Q=K.value;ee+=1;const ce=ee,Se=z.refreshToken||"";if(Z(),!n.open||!n.sessionId||!Q||!N.value){m.value=!1,k.value="",u.value=[];return}B=new AbortController;try{const qe=await $l(n.sessionId,Q,{limit:80,refreshToken:Se,signal:B.signal});if(ce!==ee)return;u.value=qe.items||[]}catch(qe){if(Ro(qe)||ce!==ee)return;k.value=qe.message,u.value=[]}finally{ce===ee&&(B=null),ce===ee&&(m.value=!1)}}function _t(z={}){if(Z(),!n.open||!n.sessionId||!K.value||!N.value){m.value=!1,k.value="",u.value=[];return}m.value=!0,k.value="",$=window.setTimeout(()=>{$=null,Ve(z)},Cd)}function yt(){if(!n.sessionId){s.value=[],l.value="",r.value=!1,u.value=[],k.value="",m.value=!1;return}y=Date.now(),s.value=[],l.value="",u.value=[],k.value="",Re({force:!0,refreshToken:y}),_t({refreshToken:y})}function xt(){if(se.value)return!1;const z=K.value?"search":"tree";return v.value===z?!1:(v.value=z,!0)}function We(){he(),fe(),xt(),yt()}function Ht(){Z(),u.value=[],k.value="",m.value=!1}function Qt(z){const Q=te.value;if(!Q.length)return!1;const ce=Xe(),Se=ce<0?0:(ce+z+Q.length)%Q.length;return h.value=Q[Se].path,ct(ze),!0}async function Yt(){if(I.value!=="tree")return!1;const z=St();if(!z||z.type!=="directory")return!1;if(!z.expanded)return await $e(z.path),h.value=z.path,!0;const Q=te.value,ce=Xe(),Se=Q[ce+1];return Se&&vt(Se.path)===z.path?(h.value=Se.path,!0):!1}function re(){if(I.value!=="tree")return!1;const z=St();if(!z)return!1;if(z.type==="directory"&&z.expanded){const ce=we(z.path);return ce&&(ce.expanded=!1,H(),_e()),h.value=z.path,!0}const Q=vt(z.path);return Q?(h.value=Q,!0):!1}function Oe(){const z=te.value;return z.length?tt(z[Xe()]):!1}function rt(){s.value=[],l.value="",r.value=!1,u.value=[],k.value="",m.value=!1,he(),fe(),n.sessionId&&n.open&&(Re({force:!0}),_t())}function nt(){xt(),_t()}function Bt(){et(),ct(ze)}return Mt(()=>{Z()}),{activeKey:h,collapseActiveDirectory:re,confirmActive:Oe,currentError:C,currentLoading:ve,emitSelect:tt,expandActiveDirectory:Yt,getDisplayName:Me,getHighlightedName:L,getHighlightedPath:U,handleQueryChange:nt,handleSessionChange:rt,handleVisibleItemsChange:Bt,initializeData:We,moveActive:Qt,normalSearchItems:ne,normalizedQuery:K,recentSearchItems:D,resetData:Ht,setItemRef:mt,showSearchPromptState:P,showSearchEmptyState:W,showTreeEmptyState:Ee,toggleDirectory:$e,treeItems:X,visibleItems:te}}const $d={class:"min-w-0"},Pd={class:"theme-heading truncate text-sm font-medium"},Dd={class:"source-browser-layout grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[21rem_minmax(0,1fr)]"},Ld={class:"theme-divider border-b px-4 py-3"},Md={class:"block"},Bd={class:"sr-only"},Rd={class:"relative"},Nd=["placeholder","onKeydown"],Od=["title","aria-label"],Fd={class:"min-h-0 flex-1 overflow-y-auto p-2"},Ud={key:0,class:"theme-empty-state px-3 py-4 text-[12px]"},jd={key:1,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},Vd={key:2,class:"theme-status-danger rounded-sm border px-3 py-3 text-[12px]"},zd={key:3,class:"theme-empty-state px-3 py-4 text-[12px]"},Hd={key:4,class:"theme-empty-state px-3 py-4 text-[12px]"},qd={key:5,class:"theme-empty-state px-3 py-4 text-[12px]"},Kd={key:6,class:"theme-empty-state px-3 py-4 text-[12px]"},Wd={key:7,class:"theme-empty-state px-3 py-4 text-[12px]"},Gd={key:8,class:"theme-empty-state px-3 py-4 text-[12px]"},Xd={key:9,class:"theme-empty-state px-3 py-4 text-[12px]"},Yd={key:10,class:"theme-empty-state px-3 py-4 text-[12px]"},Jd={key:11,class:"space-y-1"},Qd={key:0,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},Zd=["onClick"],ef={class:"min-w-0 flex-1"},tf=["innerHTML"],nf=["innerHTML"],sf={key:1,class:"theme-muted-text px-1 py-0.5 text-[12px] tracking-[0.08em]"},of=["onClick"],rf={class:"min-w-0 flex-1"},af=["innerHTML"],lf=["innerHTML"],uf={key:12,class:"space-y-3"},cf={class:"theme-divider flex items-start gap-2.5 border-b px-3 py-2.5"},df={class:"min-w-0 flex-1"},ff={class:"theme-list-item-title theme-list-item-title--strong break-all"},pf={key:0,class:"theme-list-item-meta truncate"},mf={class:"theme-list-item-meta shrink-0 pt-0.5"},gf={class:"space-y-1 px-2 py-2"},hf=["onClick"],vf=["innerHTML"],yf={key:0,class:"theme-muted-text px-1 text-[12px]"},Sf={key:13,class:"space-y-1"},wf=["onClick"],xf={class:"flex items-start gap-1.5"},bf=["onClick"],kf={key:1,class:"block h-5 w-5 shrink-0"},Tf=["onClick"],_f={class:"flex min-h-0 flex-col overflow-hidden"},Cf={class:"theme-divider border-b px-4 py-2"},Ef={class:"flex items-center justify-between gap-3"},Af={class:"min-w-0"},If={key:0,class:"theme-muted-text truncate text-[12px]"},$f={key:1,class:"theme-muted-text mt-1 text-[11px]"},Pf={class:"min-h-0 flex-1 overflow-auto px-4 py-3"},Df={key:0,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},Lf={key:1,class:"theme-status-danger rounded-sm border px-4 py-3 text-[12px]"},Mf={key:2,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},Bf={key:3,class:"theme-empty-state flex h-full min-h-[12rem] items-center justify-center text-[12px]"},Rf={key:4,class:"source-browser-image-wrap flex h-full min-h-[12rem] items-center justify-center overflow-hidden rounded-sm border p-4"},Nf=["src","alt"],Of={key:5,class:"theme-empty-state flex h-full min-h-[12rem] flex-col items-center justify-center gap-3 text-[12px]"},Ff={class:"source-code-view"},Uf={class:"source-code-view__table"},jf=["innerHTML"],Vf={key:0,class:"inline-flex items-center gap-2"},zf={key:1,class:"min-w-0"},Hf={class:"flex min-w-0 items-center gap-2"},qf={class:"font-medium"},Kf={class:"theme-muted-text"},Wf={key:0,class:"theme-muted-text"},Gf={key:0,class:"mt-1 truncate"},Xf={key:1,class:"theme-muted-text mt-1"},Yf={key:2},vr=20,Jf={__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}=Et(),{isDark:l}=Gr(),u=Cs({open:!1,sessionId:"",query:""}),m=j(""),k=j(""),d=j(!1),T=j(""),v=j(null),h=j(""),p=j("path"),$=j([]),ee=j(!1),y=j(""),B=j(""),K=j(!1),V=j(""),N=new Map,se=j(null),I=j(null),X=j(0),ge=j([]),ye=j(""),D=j(!1),ne=j(""),le=j(null),te=j(0),ve=j(8);let C=0,W=0,P=0,Ee=null,Ie=null,Be=null;const Ye=Ed,Je=Ad;let Ke=null;const we=new Map,H=new Map,Z=q(()=>{var c;return String(((c=o.session)==null?void 0:c.id)||"").trim()}),me=q(()=>{var c;return String(((c=o.session)==null?void 0:c.cwd)||"").trim()}),_e=q(()=>p.value!=="content"),fe=q(()=>p.value==="content"),Le=q(()=>String(h.value||"").trim()),he=q(()=>Le.value.length>=js),Me=q(()=>{var c;return((c=v.value)==null?void 0:c.name)||m.value||""}),je=q(()=>{var c;return((c=v.value)==null?void 0:c.path)||m.value||""}),De=q(()=>{var c;return qt(((c=v.value)==null?void 0:c.size)||0)}),vt=q(()=>{var A,R;const c=[];return(je.value||Me.value)&&c.push(je.value||Me.value),(A=v.value)!=null&&A.size&&c.push(De.value),(R=v.value)!=null&&R.truncated&&c.push(r("sourceBrowser.truncated")),c.join(" ")}),Xe=q(()=>{var c;return!!((c=v.value)!=null&&c.previewUrl)}),St=q(()=>{var c,A;return!!((c=v.value)!=null&&c.binary&&!((A=v.value)!=null&&A.previewUrl))}),et=q(()=>!!(v.value&&!v.value.binary&&!v.value.previewUrl)),mt=j(""),ze=j(""),Ce=j(""),lt=j("2.6rem"),{selectedRows:dt,selectionAction:L,clearSelectionState:U,handleSelectionMouseUp:oe,updateSelectionActionFromDom:Te}=wa({getContainer:()=>I.value,isActive:()=>o.open&&et.value,rowSelector:".source-code-view__line",mapRowElement:c=>{var R;const A=Number(((R=c==null?void 0:c.getAttribute)==null?void 0:R.call(c,"data-line"))||0);return A>0?A:null},getCodeLeft:c=>{var pe,Ne,Fe;const A=(pe=c==null?void 0:c.querySelector)==null?void 0:pe.call(c,".source-code-view__code");if(!A)return 0;const R=(Ne=A.getBoundingClientRect)==null?void 0:Ne.call(A),J=(Fe=window.getComputedStyle)==null?void 0:Fe.call(window,A),G=Number.parseFloat((J==null?void 0:J.paddingLeft)||"0")||0;return((R==null?void 0:R.left)||0)+G},debounceMs:72}),Re=q(()=>[...new Set(dt.value)].map(c=>Number(c)||0).filter(c=>c>0).sort((c,A)=>c-A)),$e=q(()=>{var R;const c=String(((R=v.value)==null?void 0:R.content)||"").replace(/\r\n/g,`
16
+ `),A=c?c.split(`
17
+ `):[];return[...Re.value].sort((J,G)=>J-G).map(J=>({lineNumber:J,content:String(A[J-1]||"")})).filter(J=>J.lineNumber>0)}),tt=q(()=>$e.value.length>0),Ve=q(()=>{var A;const c=Math.max(0,Number(te.value)||0);return!c||!Array.isArray((A=le.value)==null?void 0:A.items)?null:le.value.items.find(R=>Number(R==null?void 0:R.line)===c)||null}),_t=q(()=>{var c;return!!(et.value&&te.value&&(D.value||ne.value||Ve.value||(c=le.value)!=null&&c.message))}),yt=q(()=>fe.value?r("sourceBrowser.contentSearchPlaceholder"):r("sourceBrowser.searchPlaceholder")),xt=q(()=>fe.value?r("sourceBrowser.searchModeContent"):r("sourceBrowser.searchModePath")),We=q(()=>!!Le.value),Ht=q(()=>We.value?"search":"tree"),Qt=q(()=>We.value&&fe.value?ee.value:Rt.value),Yt=q(()=>_e.value&&hn.value),re=q(()=>_e.value&&an.value),Oe=q(()=>We.value&&fe.value&&!he.value&&!ee.value&&!y.value),rt=q(()=>We.value&&fe.value&&he.value&&!!B.value&&!ee.value&&!y.value&&!$.value.length),nt=q(()=>We.value&&fe.value&&he.value&&!ee.value&&!y.value&&!B.value&&!$.value.length),Bt=q(()=>{const c=[],A=new Map;return $.value.forEach(R=>{const J=String((R==null?void 0:R.path)||"").trim();if(!J)return;let G=A.get(J);G||(G={path:J,name:String((R==null?void 0:R.name)||J.split("/").pop()||J),items:[]},A.set(J,G),c.push(G)),G.items.push(R)}),c}),z=q(()=>$.value.map(c=>F(c)).join("|")),Q=q(()=>_.value.map(c=>{const A=String((c==null?void 0:c.path)||"").trim(),R=c!=null&&c.expanded?1:0,J=c!=null&&c.loading?1:0;return`${A}:${R}:${J}`}).join("|")),{activeKey:ce,collapseActiveDirectory:Se,expandActiveDirectory:qe,currentError:gt,currentLoading:Rt,getDisplayName:jt,getHighlightedName:Pt,getHighlightedPath:Dt,handleQueryChange:mn,handleSessionChange:Ct,handleVisibleItemsChange:on,initializeData:In,moveActive:tn,normalSearchItems:Jt,recentSearchItems:rn,resetData:gn,setItemRef:nn,showSearchPromptState:an,showSearchEmptyState:hn,showTreeEmptyState:ln,toggleDirectory:vn,treeItems:yn,visibleItems:_}=xa({getMode:()=>Ht.value,props:u,onSelect:xe});function w(c=""){return String(c||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function F(c){return`${(c==null?void 0:c.path)||""}:${(c==null?void 0:c.line)||0}:${(c==null?void 0:c.column)||0}`}function ie(c,A){if(A){N.set(c,A);return}N.delete(c)}function f(){var A;const c=N.get(V.value);(A=c==null?void 0:c.scrollIntoView)==null||A.call(c,{block:"nearest"})}function E(c="",A=""){const R=String(c||""),J=String(A||"").trim();if(!R||!J)return w(R);const G=R.toLowerCase(),pe=J.toLowerCase(),Ne=G.indexOf(pe);if(Ne<0)return w(R);const Fe=Ne+pe.length;return`${w(R.slice(0,Ne))}<mark class="theme-search-highlight">${w(R.slice(Ne,Fe))}</mark>${w(R.slice(Fe))}`}function M(c="",A=""){const R=String(c||""),J=String(A||"").trim();if(!R||!J)return[];const G=R.toLowerCase(),pe=J.toLowerCase(),Ne=[];let Fe=0;for(;Fe<G.length;){const bt=G.indexOf(pe,Fe);if(bt<0)break;Ne.push({start:bt,end:bt+pe.length}),Fe=bt+pe.length}return Ne}function ae(c,A,R){if(!c)return null;if(c.nodeType===Node.TEXT_NODE){const G=c.textContent||"",pe=R.offset,Ne=pe+G.length;if(R.offset=Ne,!G)return document.createTextNode("");const Fe=A.filter(Wt=>Wt.start<Ne&&Wt.end>pe);if(!Fe.length)return document.createTextNode(G);const bt=document.createDocumentFragment();let Lt=0;return Fe.forEach(Wt=>{const Ds=Math.max(0,Wt.start-pe),vo=Math.min(G.length,Wt.end-pe);if(Ds>Lt&&bt.appendChild(document.createTextNode(G.slice(Lt,Ds))),vo>Ds){const yo=document.createElement("mark");yo.className="source-code-view__search-hit",yo.textContent=G.slice(Ds,vo),bt.appendChild(yo)}Lt=Math.max(Lt,vo)}),Lt<G.length&&bt.appendChild(document.createTextNode(G.slice(Lt))),bt}if(c.nodeType!==Node.ELEMENT_NODE)return c.cloneNode(!0);const J=c.cloneNode(!1);return Array.from(c.childNodes||[]).forEach(G=>{const pe=ae(G,A,R);pe&&J.appendChild(pe)}),J}function Ue(c=I.value){var A,R,J;c&&((J=(R=(A=c.querySelectorAll)==null?void 0:A.call(c,".source-code-view__line-inner[data-original-html]"))==null?void 0:R.forEach)==null||J.call(R,G=>{const pe=G.dataset.originalHtml;typeof pe=="string"&&(G.innerHTML=pe)}))}function At(){var R,J,G;const c=I.value,A=String(ye.value||"").trim();c&&(Ue(c),A&&((G=(J=(R=c.querySelectorAll)==null?void 0:R.call(c,".source-code-view__line.is-match .source-code-view__line-inner"))==null?void 0:J.forEach)==null||G.call(J,pe=>{pe.dataset.originalHtml||(pe.dataset.originalHtml=pe.innerHTML);const Ne=M(pe.textContent||"",A);if(!Ne.length)return;const Fe=document.createDocumentFragment(),bt={offset:0};Array.from(pe.childNodes||[]).forEach(Lt=>{const Wt=ae(Lt,Ne,bt);Wt&&Fe.appendChild(Wt)}),pe.replaceChildren(Fe)})))}function qt(c=0){const A=Math.max(0,Number(c)||0);return A<1024?`${A} B`:A<1024*1024?`${(A/1024).toFixed(A<10*1024?1:0)} KB`:`${(A/(1024*1024)).toFixed(1)} MB`}function Sn(c=""){const A=new Date(String(c||""));return Number.isNaN(A.getTime())?r("common.notAvailable"):new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(A)}function Nt(c=""){const R=new Date(String(c||"")).getTime();if(Number.isNaN(R))return"";const J=Date.now()-R,G=Math.abs(J),pe=[["year",365*24*60*60*1e3],["month",30*24*60*60*1e3],["day",24*60*60*1e3],["hour",60*60*1e3],["minute",60*1e3]],Ne=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"}),[Fe,bt]=pe.find(([,Wt])=>G>=Wt)||["minute",60*1e3],Lt=Math.round((R-Date.now())/bt);return Ne.format(Lt,Fe)}function Vt(){return{top:`${Math.max(8,Number(ve.value)||0)}px`,right:"12px"}}function It(c=""){const A=String(c||"").trim();return A&&H.get(A)||null}function jn(c="",A=null){const R=String(c||"").trim();if(!(!R||!A))for(H.set(R,A);H.size>vr;){const J=H.keys().next().value;if(!J)break;H.delete(J)}}function ss(c={}){W+=1,Be&&(Be.abort(),Be=null),D.value=!1,ne.value="",le.value=null,te.value=0,c.clearCache&&H.clear()}async function uo(){const c=je.value;if(!Z.value||!c||!et.value)return;const A=It(c);if(A){le.value=A,D.value=!1,ne.value="";return}W+=1;const R=W;Be&&Be.abort(),Be=new AbortController,D.value=!0,ne.value="";try{const J=await Dl(Z.value,{path:c,refreshToken:String(Date.now()),signal:Be.signal});if(R!==W)return;le.value=J,jn(c,J),ne.value=(J==null?void 0:J.supported)===!1?String(J.message||""):""}catch(J){if(Ro(J)||R!==W)return;le.value=null,ne.value=(J==null?void 0:J.message)||r("sourceBrowser.blameLoadFailed")}finally{R===W&&(D.value=!1,Be=null)}}function os(c){var pe,Ne,Fe;if(!et.value)return;const A=(Ne=(pe=c==null?void 0:c.target)==null?void 0:pe.closest)==null?void 0:Ne.call(pe,".source-code-view__line");if(!A||!((Fe=I.value)!=null&&Fe.contains(A))){te.value=0;return}const R=Number(A.getAttribute("data-line")||0)||0,J=I.value.getBoundingClientRect(),G=A.getBoundingClientRect();te.value=R,ve.value=G.bottom-J.top+I.value.scrollTop+4,!le.value&&!D.value&&uo()}function co(){te.value=0}function un(){var A,R,J;const c=I.value;c&&(Ue(c),(J=(R=(A=c.querySelectorAll)==null?void 0:A.call(c,".source-code-view__line.is-match, .source-code-view__line.is-focus-match"))==null?void 0:R.forEach)==null||J.call(R,G=>G.classList.remove("is-match","is-focus-match")))}function As(){var A,R,J;const c=I.value;c&&((J=(R=(A=c.querySelectorAll)==null?void 0:A.call(c,".source-code-view__line.is-selected"))==null?void 0:R.forEach)==null||J.call(R,G=>G.classList.remove("is-selected")))}function $n(){As();const c=I.value;!c||!Re.value.length||Re.value.forEach(A=>{var G,pe;const R=c.querySelector(`.source-code-view__gutter[data-line="${A}"]`),J=(G=R==null?void 0:R.closest)==null?void 0:G.call(R,"tr");(pe=J==null?void 0:J.classList)==null||pe.add("is-selected")})}function rs(){if(!Re.value.length)return"";const c=[...Re.value].sort((A,R)=>A-R);return c[0]===c[c.length-1]?`L${c[0]}`:`L${c[0]}-${c[c.length-1]}`}function fo(){var A,R,J,G;if(!v.value||!tt.value)return;const c=$e.value.map(pe=>pe.lineNumber);s("insert-code-context",{source:"source",filePath:je.value,language:String(((A=v.value)==null?void 0:A.language)||""),rangeLabel:rs(),lineStart:Math.min(...c),lineEnd:Math.max(...c),content:String(L.value.content||"").trim()||$e.value.map(pe=>pe.content).join(`
18
+ `)}),(G=(J=(R=window.getSelection)==null?void 0:R.call(window))==null?void 0:J.removeAllRanges)==null||G.call(J),U(),s("close")}function Is(c){var Ne,Fe,bt,Lt;const A=(Ne=window.getSelection)==null?void 0:Ne.call(window),R=I.value;if(!A||A.rangeCount<1||A.isCollapsed||!R)return;Te();const G=A.getRangeAt(0).commonAncestorContainer;if(!R.contains((G==null?void 0:G.nodeType)===1?G:G==null?void 0:G.parentNode))return;const pe=String(A.toString()||"").replace(/\u200b/g,"");pe&&((bt=(Fe=c==null?void 0:c.clipboardData)==null?void 0:Fe.setData)==null||bt.call(Fe,"text/plain",pe),(Lt=c==null?void 0:c.preventDefault)==null||Lt.call(c))}function wn(){Ke&&(window.clearTimeout(Ke),Ke=null)}function po(){we.clear(),H.clear()}function mo(c=""){const A=String(c||"").trim();if(!A||!we.has(A))return null;const R=we.get(A);return we.delete(A),we.set(A,R),R}function as(c="",A=null){const R=String(c||"").trim();if(!(!R||!A))for(we.delete(R),we.set(R,A);we.size>vr;){const J=we.keys().next().value;if(!J)break;we.delete(J)}}function is(c){wn(),Ke=window.setTimeout(()=>{Ke=null,c==null||c()},Je)}function xn(){ct(()=>{var c,A;(A=(c=se.value)==null?void 0:c.focus)==null||A.call(c)})}function ls(c=""){const A=String(c||"").trim();return A?(p.value="path",Kt(),h.value=A,u.query=A,xn(),!0):!1}function Vn(c){var A,R,J;if((A=c==null?void 0:c.preventDefault)==null||A.call(c),Le.value){(R=c==null?void 0:c.stopPropagation)==null||R.call(c),h.value="";return}(J=c==null?void 0:c.stopPropagation)==null||J.call(c),s("close")}function us(){wn(),C+=1,po(),m.value="",k.value="",d.value=!1,T.value="",v.value=null,mt.value="",ze.value="",Ce.value="",lt.value="2.6rem",X.value=0,ge.value=[],ye.value="",ss({clearCache:!0}),U(),un()}function Kt(){P+=1,Ee&&(window.clearTimeout(Ee),Ee=null),Ie&&(Ie.abort(),Ie=null),$.value=[],ee.value=!1,y.value="",B.value="",K.value=!1,V.value="",ge.value=[],ye.value="",un()}function go(){if(Ee&&(window.clearTimeout(Ee),Ee=null),!o.open||!Z.value||!fe.value)return;if(!Le.value||!he.value){Kt();return}ee.value=!0,y.value="",Ee=window.setTimeout(()=>{Ee=null,at()},Ye)}function cs(c=1){const A=$.value;if(!A.length)return!1;const R=A.findIndex(G=>F(G)===V.value),J=R<0?0:(R+c+A.length)%A.length;return V.value=F(A[J]),ct(f),!0}function zn(){return _.value.length&&(_.value.find(c=>c.path===ce.value)||_.value[0])||null}function bn(c,A={}){return c?(ce.value=(c==null?void 0:c.path)||"",V.value="",m.value=String((c==null?void 0:c.path)||"").trim(),k.value=String((c==null?void 0:c.type)||"").trim(),T.value="",X.value=0,ge.value=[],ye.value="",ss(),(c==null?void 0:c.type)==="directory"?(wn(),v.value=null,A.toggleDirectory&&!We.value&&vn(c.path),!0):A.previewMode==="debounced"?(is(()=>ke(c==null?void 0:c.path)),!0):(wn(),ke(c==null?void 0:c.path),!0)):!1}function $s(){const c=$.value;if(!c.length)return!1;const A=c.find(R=>F(R)===V.value)||c[0];return ft(A),!0}function Ps(c){const A=String((c==null?void 0:c.key)||"");if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter","Escape"].includes(A)&&!(We.value&&(A==="ArrowLeft"||A==="ArrowRight"))){if(fe.value&&We.value){if(A==="ArrowDown"){if(c.preventDefault(),cs(1)){const R=$.value,J=R.find(G=>F(G)===V.value)||R[0];ft(J,{previewMode:"debounced"})}return}if(A==="ArrowUp"){if(c.preventDefault(),cs(-1)){const R=$.value,J=R.find(G=>F(G)===V.value)||R[0];ft(J,{previewMode:"debounced"})}return}if(A==="Enter"){c.preventDefault(),$s();return}A==="Escape"&&Vn(c);return}if(A==="ArrowDown"){c.preventDefault(),tn(1)&&ct(()=>{bn(zn(),{previewMode:"debounced"})});return}if(A==="ArrowUp"){c.preventDefault(),tn(-1)&&ct(()=>{bn(zn(),{previewMode:"debounced"})});return}if(A==="ArrowRight"){c.preventDefault(),qe();return}if(A==="ArrowLeft"){c.preventDefault(),Se();return}if(A==="Enter"){c.preventDefault(),bn(zn(),{toggleDirectory:!0});return}A==="Escape"&&Vn(c)}}async function ds(){const c=fe.value?"path":"content";if(p.value=c,!Le.value){c==="content"?Kt():(Kt(),u.query="");return}if(c==="content"){u.query="",at();return}Kt(),u.query=h.value}function ho(c){var A;c.preventDefault(),(A=c.stopPropagation)==null||A.call(c),ds().finally(()=>{xn()})}async function S(){var pe;if(await ct(),un(),!I.value)return;const c=[...new Set(ge.value.map(Ne=>Math.max(0,Number(Ne)||0)).filter(Ne=>Ne>0))],A=Math.max(0,Number(X.value)||0);if(c.forEach(Ne=>{var Lt,Wt;const Fe=I.value.querySelector(`.source-code-view__gutter[data-line="${Ne}"]`),bt=(Lt=Fe==null?void 0:Fe.closest)==null?void 0:Lt.call(Fe,"tr");(Wt=bt==null?void 0:bt.classList)==null||Wt.add("is-match")}),At(),!A){$n();return}const R=A,J=I.value.querySelector(`.source-code-view__gutter[data-line="${R}"]`),G=(pe=J==null?void 0:J.closest)==null?void 0:pe.call(J,"tr");if(!G){$n();return}G.classList.add("is-match","is-focus-match"),At(),G.scrollIntoView({block:"center",inline:"nearest"}),$n()}async function Y(){var pe,Ne,Fe;if(!et.value){mt.value="",ze.value="",Ce.value="";return}const c=C,A=String(((pe=v.value)==null?void 0:pe.content)||"").replace(/\r\n/g,`
19
+ `),R=((Ne=v.value)==null?void 0:Ne.language)||"",J=Ec(A,To),G=await $c(((Fe=v.value)==null?void 0:Fe.content)||"",{isDark:l.value,language:R,maxHighlightLines:To.maxLines,maxHighlightChars:To.maxChars});c===C&&(mt.value=G.html,ze.value=J?"":G.bg||"",Ce.value=J?"":G.fg||"",lt.value=G.gutterWidth||"2.6rem",await ct(),$n())}async function ke(c="",A={}){var Ne;const R=String(c||"").trim();if(!Z.value||!R)return;X.value=Math.max(0,Number(A.focusLine)||0),U();const J=String(((Ne=v.value)==null?void 0:Ne.path)||"").trim();if(!A.forceReload&&J===R&&!d.value&&!T.value){await S();return}if(!A.forceReload&&d.value&&m.value===R)return;C+=1;const G=C;T.value="";const pe=A.forceReload?null:mo(R);if(pe){d.value=!1,v.value=pe,await Y(),G===C&&et.value&&await S();return}d.value=!0;try{const Fe=await Pl(Z.value,{path:R,limit:204800,refreshToken:String(Date.now())});if(G!==C)return;v.value=Fe,as(R,Fe),await Y()}catch(Fe){if(G!==C)return;v.value=null,T.value=(Fe==null?void 0:Fe.message)||r("sourceBrowser.previewFailed")}finally{G===C&&(d.value=!1,et.value&&await S())}}function xe(c){bn(c,{toggleDirectory:!0}),ct(xn)}function Qe(c,A){var R,J;(J=(R=c==null?void 0:c.currentTarget)==null?void 0:R.focus)==null||J.call(R),xe(A)}async function at(){const c=Le.value;if(!o.open||!Z.value)return;P+=1;const A=P;if(!c||!he.value){Kt();return}Ie&&(Ie.abort(),Ie=null),ee.value=!0,y.value="",$.value=[],K.value=!1,V.value="",Ie=new AbortController;try{const R=await Ll(Z.value,c,{limit:80,refreshToken:String(Date.now()),signal:Ie.signal});if(A!==P)return;B.value=c,$.value=Array.isArray(R.items)?R.items:[],K.value=!!R.truncated,V.value=$.value[0]?F($.value[0]):"",$.value[0]&&ft($.value[0],{previewMode:"debounced"})}catch(R){if(Ro(R)||A!==P)return;B.value=c,$.value=[],y.value=(R==null?void 0:R.message)||r("sourceBrowser.contentSearchFailed")}finally{A===P&&(Ie=null),A===P&&(ee.value=!1)}}function ft(c,A={}){V.value=F(c),ce.value=(c==null?void 0:c.path)||"",m.value=String((c==null?void 0:c.path)||"").trim(),k.value="file",T.value="",ss(),ye.value=B.value||Le.value,ge.value=$.value.filter(J=>(J==null?void 0:J.path)===(c==null?void 0:c.path)).map(J=>Number((J==null?void 0:J.line)||0)).filter(J=>J>0);const R=()=>ke(c==null?void 0:c.path,{focusLine:c==null?void 0:c.line});if(A.previewMode==="debounced"){is(R),ct(xn);return}wn(),R(),ct(xn)}function Ot(c){const A=String((c==null?void 0:c.path)||"").trim();if(!A)return"";const R=A.split("/");return R[R.length-1]||A}function Pn(c){const A=String((c==null?void 0:c.path)||"").trim();return!A||!A.includes("/")?"":A.slice(0,A.lastIndexOf("/"))}function Xa(c){return`${Array.isArray(c==null?void 0:c.items)?c.items.length:0} 处`}function Ya(c){const A=B.value||Le.value;return E((c==null?void 0:c.preview)||"",A)}return Pe(()=>o.open,c=>{var A,R,J,G,pe,Ne;if(u.open=c,c){(J=(R=(A=window.getSelection)==null?void 0:A.call(window))==null?void 0:R.removeAllRanges)==null||J.call(R),u.sessionId=Z.value,h.value="",p.value="path",u.query="",us(),Kt(),In(),ls(o.initialSearchQuery)||xn();return}(Ne=(pe=(G=window.getSelection)==null?void 0:G.call(window))==null?void 0:pe.removeAllRanges)==null||Ne.call(pe),h.value="",p.value="path",us(),Kt(),gn()},{immediate:!0}),Pe(Z,c=>{u.sessionId=c,o.open&&(us(),Kt(),Ct())}),Pe(()=>o.initialSearchQuery,c=>{o.open&&ls(c)}),Pe(h,c=>{if(_e.value){u.query=c;return}String(c||"").trim()!==String(B.value||"").trim()&&(ye.value="",At()),go()}),Pe(()=>u.query,()=>{_e.value&&mn()}),Pe(z,()=>{ct(f)}),Pe(Q,()=>{on(),!(!We.value||!_e.value)&&ct(()=>{const c=zn();c&&bn(c,{previewMode:"debounced"})})}),Pe(l,async()=>{!o.open||!et.value||(await Y(),await S())}),Pe(Re,()=>{$n()}),Mt(()=>{var c,A,R;(R=(A=(c=window.getSelection)==null?void 0:c.call(window))==null?void 0:A.removeAllRanges)==null||R.call(A),U({clearBrowserSelection:!0}),wn()}),t({applyPathSearch:ls}),(c,A)=>(g(),Ae(io,{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:A[2]||(A[2]=R=>s("close"))},{title:st(()=>[i("div",$d,[i("div",Pd,x(me.value||a(r)("sourceBrowser.title")),1)])]),default:st(()=>{var R,J;return[i("div",Dd,[i("aside",{class:"theme-divider flex min-h-0 flex-col border-b md:border-b-0 md:border-r",onKeydown:Ps},[i("div",Ld,[i("label",Md,[i("span",Bd,x(a(r)("sourceBrowser.searchLabel")),1),i("div",Rd,[ue(a(ri),{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:se,"onUpdate:modelValue":A[0]||(A[0]=G=>h.value=G),type:"text",class:"tool-input w-full pl-9 pr-18 text-[12px]",placeholder:yt.value,onKeydown:[en(Vn,["esc"]),en(ot(ho,["prevent"]),["tab"])]},null,40,Nd),[[ms,h.value]]),Qt.value?(g(),Ae(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"})):de("",!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:xt.value,"aria-label":xt.value,onClick:ot(ds,["stop","prevent"])},[ue(a(ai),{class:"h-3.5 w-3.5"})],8,Od)])])]),i("div",Fd,[Z.value?We.value&&fe.value&&y.value?(g(),b("div",jd,x(y.value),1)):a(gt)?(g(),b("div",Vd,x(a(gt)),1)):re.value?(g(),b("div",zd,x(a(r)("sourceBrowser.searchMinKeywordHint",{count:a(js)})),1)):Yt.value?(g(),b("div",Hd,x(a(r)("sourceBrowser.searchEmpty")),1)):Oe.value?(g(),b("div",qd,x(a(r)("sourceBrowser.searchMinKeywordHint",{count:a(js)})),1)):nt.value?(g(),b("div",Kd,x(a(r)("sourceBrowser.contentSearchPrompt")),1)):rt.value?(g(),b("div",Wd,x(a(r)("sourceBrowser.contentSearchEmpty")),1)):a(ln)?(g(),b("div",Gd,x(a(r)("sourceBrowser.treeEmpty")),1)):We.value&&fe.value&&ee.value&&!$.value.length?(g(),b("div",Xd,x(a(r)("sourceBrowser.contentSearching")),1)):a(Rt)&&!a(_).length?(g(),b("div",Yd,x(a(r)("sourceBrowser.loadingFiles")),1)):We.value&&_e.value?(g(),b("div",Jd,[a(rn).length?(g(),b("div",Qd,x(a(r)("sourceBrowser.recent")),1)):de("",!0),(g(!0),b(it,null,pt(a(rn),G=>(g(),b("button",{key:`recent-${G.path}`,ref_for:!0,ref:pe=>a(nn)(G.path,pe),type:"button",class:be(["theme-list-row focus:outline-none",a(ce)===G.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:pe=>xe(G)},[(g(),Ae(En(G.type==="directory"?a(Gn):a(Rn)),{class:"theme-list-item-icon"})),i("div",ef,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Pt)(G)},null,8,tf)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Dt)(G)},null,8,nf)])],10,Zd))),128)),u.query.trim()&&a(Jt).length?(g(),b("div",sf,x(a(r)("sourceBrowser.results")),1)):de("",!0),(g(!0),b(it,null,pt(a(Jt),G=>(g(),b("button",{key:`result-${G.path}`,ref_for:!0,ref:pe=>a(nn)(G.path,pe),type:"button",class:be(["theme-list-row focus:outline-none",a(ce)===G.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:pe=>xe(G)},[(g(),Ae(En(G.type==="directory"?a(Gn):a(Rn)),{class:"theme-list-item-icon"})),i("div",rf,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(Pt)(G)},null,8,af)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(Dt)(G)},null,8,lf)])],10,of))),128))])):We.value?(g(),b("div",uf,[(g(!0),b(it,null,pt(Bt.value,G=>(g(),b("div",{key:G.path,class:"rounded-sm border border-[var(--theme-borderDefault)] bg-[var(--theme-panel)]"},[i("div",cf,[ue(a(Rn),{class:"theme-list-item-icon"}),i("div",df,[i("div",ff,x(Ot(G)),1),Pn(G)?(g(),b("div",pf,x(Pn(G)),1)):de("",!0)]),i("div",mf,x(Xa(G)),1)]),i("div",gf,[(g(!0),b(it,null,pt(G.items,pe=>(g(),b("button",{key:F(pe),ref_for:!0,ref:Ne=>ie(F(pe),Ne),type:"button",class:be(["theme-list-row gap-0 focus:outline-none",V.value===F(pe)?"theme-list-item-active":"theme-list-item-hover"]),onClick:Ne=>ft(pe)},[i("div",{class:"theme-list-item-title min-w-0 flex-1 break-words leading-[1.45rem]",innerHTML:Ya(pe)},null,8,vf)],10,hf))),128))])]))),128)),K.value?(g(),b("div",yf,x(a(r)("sourceBrowser.contentSearchTruncated")),1)):de("",!0)])):(g(),b("div",Sf,[(g(!0),b(it,null,pt(a(yn),G=>(g(),b("div",{key:G.path,ref_for:!0,ref:pe=>a(nn)(G.path,pe),class:be(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(ce)===G.path?"theme-list-item-active":G.type==="directory"&&G.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:An({paddingLeft:`${G.depth*16+6}px`}),tabindex:"-1",onClick:pe=>Qe(pe,G)},[i("div",xf,[G.type==="directory"?(g(),b("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:ot(pe=>a(vn)(G.path),["stop"])},[G.loading?(g(),Ae(a(Xt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),Ae(a(Qr),{key:1,class:be(["h-3.5 w-3.5 transition",G.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,bf)):(g(),b("span",kf)),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:ot(pe=>xe(G),["stop"])},[(g(),Ae(En(G.type==="directory"?a(Gn):a(Rn)),{class:be(["h-4 w-4 shrink-0",G.type==="directory"&&G.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("span",{class:be(["theme-list-item-title min-w-0 flex-1 truncate",G.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},x(a(jt)(G)),3)],8,Tf)])],14,wf))),128))])):(g(),b("div",Ud,x(a(r)("sourceBrowser.noProject")),1))])],32),i("section",_f,[i("div",Cf,[i("div",Ef,[i("div",Af,[vt.value?(g(),b("p",If,x(vt.value),1)):de("",!0),et.value?(g(),b("p",$f,x(a(r)("sourceBrowser.selectCodeLineHint")),1)):de("",!0)])])]),i("div",Pf,[d.value?(g(),b("div",Df,[i("span",null,x(a(r)("sourceBrowser.previewLoading")),1)])):T.value?(g(),b("div",Lf,x(T.value),1)):k.value==="directory"?(g(),b("div",Mf,x(a(r)("sourceBrowser.selectFileHint")),1)):m.value?Xe.value?(g(),b("div",Rf,[i("img",{src:v.value.previewUrl,alt:Me.value,class:"source-browser-image object-contain"},null,8,Nf)])):St.value?(g(),b("div",Of,[ue(a(ii),{class:"h-8 w-8"}),i("span",null,x((R=v.value)!=null&&R.tooLarge?a(r)("sourceBrowser.binaryTooLarge"):a(r)("sourceBrowser.binaryUnsupported")),1)])):et.value?(g(),b("div",{key:6,ref_key:"previewContainerRef",ref:I,class:"source-browser-code relative rounded-sm border",style:An({"--source-code-bg":ze.value||"var(--theme-panel)","--source-code-fg":Ce.value||"var(--theme-textPrimary)","--source-code-gutter-width":lt.value}),onCopy:Is,onMouseup:A[1]||(A[1]=(...G)=>a(oe)&&a(oe)(...G)),onMousemove:os,onMouseleave:co},[i("div",Ff,[i("table",Uf,[i("tbody",{innerHTML:mt.value},null,8,jf)])]),_t.value?(g(),b("div",{key:0,class:"source-blame-popover pointer-events-none absolute z-20 w-[min(24rem,calc(100%-1.5rem))] rounded-sm border px-3 py-2 text-[11px] shadow-lg",style:An(Vt())},[D.value?(g(),b("div",Vf,[ue(a(Xt),{class:"h-3.5 w-3.5 animate-spin"}),i("span",null,x(a(r)("sourceBrowser.blameLoading")),1)])):Ve.value?(g(),b("div",zf,[i("div",Hf,[i("span",qf,x(Ve.value.author||a(r)("common.notAvailable")),1),i("span",Kf,x(Ve.value.shortCommit),1),Ve.value.authorTime?(g(),b("span",Wf,x(Nt(Ve.value.authorTime)),1)):de("",!0)]),Ve.value.summary?(g(),b("div",Gf,x(Ve.value.summary),1)):de("",!0),Ve.value.authorTime?(g(),b("div",Xf,x(Sn(Ve.value.authorTime)),1)):de("",!0)])):(g(),b("div",Yf,x(ne.value||((J=le.value)==null?void 0:J.message)||a(r)("sourceBrowser.blameUnavailable")),1))],4)):de("",!0),e.open&&a(L).visible?(g(),Ae(ya,{key:1,top:a(L).top,left:a(L).left,label:a(r)("sourceBrowser.insertSelection"),onClick:fo},null,8,["top","left","label"])):de("",!0)],36)):de("",!0):(g(),b("div",Bf,x(a(r)("sourceBrowser.selectFile")),1))])])])]}),_:1},8,["open"]))}},Qf=Wr(Jf,[["__scopeId","data-v-5ae1fae5"]]);function Zf(e={}){const{items:t,themeKey:n,getCacheKey:o=y=>String((y==null?void 0:y.id)||"").trim(),getSource:s=y=>String((y==null?void 0:y.content)||""),shouldRender:r=()=>!0,renderAsync:l=async y=>y,renderFallback:u=y=>y,onRendered:m=null}=e,k=new Map,d=new Map,T=j(0),v=q(()=>(Array.isArray(t==null?void 0:t.value)?t.value:[]).map(y=>{const B=!!r(y),K=String(o(y)||"").trim(),V=B?String(s(y)||""):"";return{item:y,active:B,cacheKey:K,source:V}}));function h(y){if(T.value,!r(y))return"";const B=String(s(y)||""),K=String(o(y)||"").trim(),V=String((n==null?void 0:n.value)||"");if(!K)return u(B,y);const N=k.get(K);return(N==null?void 0:N.source)===B&&(N==null?void 0:N.theme)===V?N.html:u(B,y)}async function p(y){if(!r(y))return;const B=String(s(y)||""),K=String(o(y)||"").trim();if(!K)return;const V=String((n==null?void 0:n.value)||""),N=k.get(K);if((N==null?void 0:N.source)===B&&(N==null?void 0:N.theme)===V)return;const se=Symbol(K);d.set(K,se);try{const I=await l(B,y,{themeKey:V});if(d.get(K)!==se)return;k.set(K,{source:B,theme:V,html:I}),T.value+=1,m==null||m(y,{cacheKey:K,source:B,themeKey:V})}catch{}finally{d.get(K)===se&&d.delete(K)}}function $(y=[]){y.forEach(B=>{B!=null&&B.item&&p(B.item)})}function ee(y=[]){const B=new Set((Array.isArray(y)?y:[]).filter(V=>V==null?void 0:V.active).map(V=>String((V==null?void 0:V.cacheKey)||"").trim()).filter(Boolean));let K=!1;for(const V of k.keys())B.has(V)||(k.delete(V),K=!0);for(const V of d.keys())B.has(V)||d.delete(V);K&&(T.value+=1)}return Pe(v,()=>{ee(v.value||[]),$(v.value||[])},{immediate:!0}),Pe(n,()=>{$(v.value||[])}),Mt(()=>{d.clear()}),{getRenderedHtml:h}}const ep=`${Zn()}/api/events/stream`,Yn=new Set;let Nn=null,Vs=null;function No(){Vs&&(window.clearTimeout(Vs),Vs=null)}function ba(){Nn&&(Nn.close(),Nn=null)}function tp(e){Yn.forEach(t=>{try{t(e)}catch{}})}function ka(){typeof window>"u"||typeof window.EventSource>"u"||Nn||!Yn.size||(No(),Nn=new window.EventSource(ep),Nn.onmessage=e=>{try{const t=JSON.parse(String(e.data||"{}"));if(!(t!=null&&t.type))return;tp(t)}catch{}},Nn.onerror=()=>{ba(),Yn.size&&(No(),Vs=window.setTimeout(()=>{ka()},1500))})}function np(e){return typeof e!="function"?()=>{}:(Yn.add(e),ka(),()=>{Yn.delete(e),!Yn.size&&(No(),ba())})}const Ta=j(0),Oo=j(0),zs=j(""),hs=j(""),Hs=j(0),_a=Cs({}),Fo=Cs({}),Uo=Cs({}),vs=new Map;let yr=!1;const sp=new Set(["created","updated","deleted","reordered","session-linked","session-cleared"]),op=new Set(["completed","error","stopped","interrupted","stop_timeout","failed","cancelled","timeout"]);function Eo(e,t=""){const n=String(t||"").trim();n&&(e[n]=Math.max(0,Number(e[n])||0)+1)}function rp(e={}){const t=String(e.type||"").trim(),n=String(e.reason||"").trim();return{updatesTaskList:t==="runs.changed"||t==="tasks.changed"&&sp.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 ap(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:op.has(r)}function ip(e="",t={}){const n=String(e||"").trim();if(!n)return;const o=vs.get(n);o!=null&&o.size&&o.forEach(s=>{try{s(t)}catch{}})}function lp(e={}){const t=String(e.type||"").trim(),n=String(e.taskSlug||"").trim(),o=rp(e);if(t){if(t==="ready"){Ta.value+=1,zs.value="",hs.value="",Hs.value+=1;return}if(t==="tasks.changed"){zs.value=n,hs.value=String(e.reason||"").trim(),o.updatesTaskList&&(Oo.value+=1),o.updatesTaskDiff&&Eo(Fo,n);return}if(t==="runs.changed"){zs.value=n,hs.value="";const s={runId:String(e.runId||"").trim(),status:String(e.status||"").trim(),sentAt:String(e.sentAt||"").trim()},r=n&&Uo[n]||null,l=ap(r,s);n&&(Uo[n]=s),o.updatesTaskList&&!l&&(Oo.value+=1),o.updatesSessions&&(Hs.value+=1),o.updatesTaskRuns&&Eo(_a,n),o.updatesTaskDiff&&!l&&Eo(Fo,n);return}if(t==="sessions.changed"){hs.value="",o.updatesSessions&&(Hs.value+=1);return}t==="run.event"&&ip(n,{taskSlug:n,runId:String(e.runId||"").trim(),event:e.event||null})}}function Ca(){yr||typeof window>"u"||(np(e=>{lp(e)}),yr=!0)}function up(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(_a[t])||0):0}function cp(e=""){const t=String(e||"").trim();return t?Math.max(0,Number(Fo[t])||0):0}function dp(e=""){const t=String(e||"").trim();return t&&Uo[t]||null}function fp(e="",t){const n=String(e||"").trim();if(!n||typeof t!="function")return()=>{};Ca();const o=vs.get(n)||new Set;return o.add(t),vs.set(n,o),()=>{const s=vs.get(n);s&&(s.delete(t),s.size||vs.delete(n))}}function Ea(){return Ca(),{readyVersion:Ta,listSyncVersion:Oo,listSyncTaskSlug:zs,listSyncReason:hs,sessionsSyncVersion:Hs,getTaskRunSyncVersion:up,getTaskRunChange:dp,getTaskDiffSyncVersion:cp}}const pp=/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)/g,mp=/\u001B\[[0-?]*[ -/]*[@-~]/g,gp=/\u001B[@-_]/g,hp=/[\u0000-\u0008\u000B-\u001A\u001C-\u001F\u007F]/g;function vp(e=""){let t="";for(const n of String(e||"")){if(n==="\b"||n===""){t=t.slice(0,-1);continue}t+=n}return t}function ts(e=""){return vp(String(e||"")).replace(pp,"").replace(mp,"").replace(gp,"").replace(/\r\n/g,`
20
+ `).replace(/\r/g,`
21
+ `).replace(hp,"")}function Es(e=""){return ts(e)}function Un(e=""){return String(e||"").replace(/^(?:[ \t]*\n)+/,"").replace(/(?:\n[ \t]*)+$/,"")}function tr(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 yp(e=""){const t=Un(Es(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=Un(n.slice(1).join(`
23
+ `));return{meta:{type:"meta",items:[{label:s[1].trim(),value:s[2].trim()}]},rest:u}}function Sp(e="",t={}){const n=Un(Es(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(k=>k.trim()).filter(Boolean).filter(k=>!/^\(\d+\s+entries?\)$/i.test(k)),{items:u,hiddenCount:m}=tr(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 wp(e="",t={}){const n=Un(Es(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}=tr(s,t.maxItems??12);return{type:"checklist",items:r,totalCount:s.length,hiddenCount:l}}function xp(e="",t={}){const n=Un(Es(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}=tr(s,t.maxItems??12);return{type:"bullet_list",items:r,totalCount:s.length,hiddenCount:l}}function bp(e="",t={}){return{type:t.preferMarkdown?"markdown":"text",text:e}}function kp(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 Tp(e="",t={}){const n=String(e||"").split(/\n{2,}/).map(l=>Un(l)).filter(l=>l.trim());if(n.length<2)return null;const o=kp(n.flatMap(l=>nr(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 nr(e="",t={}){const n=Un(Es(e));if(!n.trim())return[];const o=yp(n);if(o!=null&&o.rest){const u=nr(o.rest,t);return[o.meta,...u.length?u:[{type:"text",text:o.rest}]]}const s=Sp(n,t);if(s)return[s];const r=wp(n,t);if(r)return[r];const l=xp(n,t);if(l)return[l];if(!t._disableMixedSegmentation){const u=Tp(n,t);if(u!=null&&u.length)return u}return[bp(n,t)]}const _p=new Set(["queued","starting","running","stopping"]);function _n(){return ro()==="en-US"}function O(e,t){return _n()?t:e}function ys(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=Ge(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 wr(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),ro())})}function Aa(e="",t=24,n=2400){const o=ts(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 Bn(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 Ft(e=0){const t=Number(e||0);return Number.isFinite(t)?t.toLocaleString(ro()):"0"}function sr(e=""){return String(e||"").trim().toLowerCase()==="shell"}function Cp(e=""){return sr(e)?O("Shell","Shell"):ht(e)}function Ep(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 Ia(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 Ia(e).length}function $a(e={}){const t=Ia(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:Ep(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?Fn(r):[]}})}function Ap(e={},t=120){const n=$a(e).map(o=>o.message).filter(Boolean);return wt(n.join(_n()?" | ":"|"),t)}function Pa(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?_n()?`${n}h ${o}m ${s}s`:`${n}小时${o}分${s}秒`:_n()?`${o}m ${s}s`:`${o}分${s}秒`}function wt(e="",t=140){const n=String(e||"").replace(/\s+/g," ").trim();return n?n.length<=t?n:`${n.slice(0,t)}...`:""}function Da(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 xs(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 Ip(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 $p(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 qs(e=[]){return(Array.isArray(e)?e:[]).map(t=>{if(!t||typeof t!="object")return null;const n=Ip(t.status??(t.completed?"completed":"pending"));return{completed:n==="completed",status:n,text:$p(t)}}).filter(Boolean)}function xr(e){const t=String(e||"").trim();if(!t)return[];try{const n=JSON.parse(t);if(Array.isArray(n))return qs(n);if(n&&typeof n=="object"){if(Array.isArray(n.todos))return qs(n.todos);if(Array.isArray(n.items))return qs(n.items)}}catch{return[]}return[]}function La(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];return t.length?{type:"checklist",items:t,totalCount:t.length,hiddenCount:0}:null}function or(e=""){var k;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?((k=Object.entries({shell:["bash","shell","sh","terminal","cmd","powershell"],read:["read","open","view","cat"],grep:["grep","rg","search","find"],list:["glob","ls","dir","tree","list"],web:["websearch","web_search","webfetch","fetch","browse","open_page"],todo:["todowrite","todo","tasklist","tasks"],edit:["edit","multiedit","write","patch","apply_patch","replace","create"]}).find(([,d])=>d.includes(l)))==null?void 0:k[0])||"generic":"shell";return{raw:t,toolName:s,normalizedTool:l,subject:r,category:m}}function bs(e={},t=null){const n=t||or(e.command);if(n.category!=="todo")return[];const o=xr(e.aggregated_output);return o.length?o:xr(n.subject)}function Fn(e="",t={}){return nr(ts(e),t)}function br(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=xs([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 kr(e={}){const t=String(e.tool||"").trim(),n=Zs(e),o=String(e.prompt||"").trim(),s=$a(e),r=[],l=[t?{label:O("工具","Tool"),value:t}:null,n?{label:O("子代理","Sub-agent"),value:String(n)}:null],u=xs(l);return u&&r.push(u),s.length&&r.push({type:"sub_agent_list",items:s,totalCount:s.length,hiddenCount:0}),o&&r.push(...Fn(o,{preferMarkdown:!0})),r}function Tr(e={}){const t=Array.isArray(e.changes)?e.changes:[];return t.length?[{type:"file_changes",items:t.map(n=>({kind:String((n==null?void 0:n.kind)||"").trim(),path:String((n==null?void 0:n.path)||"").trim()})),totalCount:t.length,hiddenCount:0}]:[]}function Bs(e={},t=!1,n="codex"){const o=[],s=or(e.command),r=bs(e,s),l=La(r),u=typeof e.exit_code=="number",m=u?e.exit_code===0:e.status==="completed",k=xs([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:Cp(n)}:null,u&&!m?{label:O("退出码","Exit code"),value:String(e.exit_code)}:null]);if(k&&o.push(k),l&&o.push(l),t){if(l)return o;const d=Aa(e.aggregated_output);d&&o.push(...Fn(d,{preferMarkdown:s.category==="web"||s.category==="edit"}))}return o}function Kn(e={}){const t=or(e.command);return{groupType:["read","grep","list","web","todo"].includes(t.category)?t.category:"",groupTarget:t.subject||e.command||"",toolName:t.toolName||""}}function Ao(e={}){const t=Array.isArray(e.items)?qs(e.items):[];return t.length?[La(t)]:[]}function ns(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function jo(e=[],t=""){const n=String(t||"").trim();return n&&(Array.isArray(e)?e:[]).find(o=>(o==null?void 0:o.runId)===n)||null}function Pp(e,t,n,o,s){const r=jo(e,t);return r?(r.events=[],r.lastEventSeq=0,r.summary=ns(),((n==null?void 0:n.items)||[]).forEach(l=>{ar(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 Ma(e={}){const t=String((e==null?void 0:e.displayEngine)||"").trim();return t?Qs(t):sr(e==null?void 0:e.engine)?"codex":Qs(e==null?void 0:e.engine)}function Ut(e={}){return ht(Ma(e))}function Dp(e={}){return sr(e==null?void 0:e.engine)}function ks(e=""){return _p.has(String(e||"").trim())}function rr(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 _r(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:Da(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=wt(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 Er(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:Da("",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 Lp(e,t={}){var l,u,m,k,d,T,v,h;e!=null&&e.summary||(e.summary=ns());const n=e.summary,o=Ut(e),s=String(t.type||"").trim(),r=t.item||{};if(s===kt.TURN_STARTED){n.currentActivity=O("正在分析任务","Analyzing task"),n.latestActivity=O(`${o} 开始执行`,`${o} started`),n.latestDetail="";return}if(s===kt.TURN_COMPLETED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=O(`${o} 执行完成`,`${o} completed`),n.latestDetail="";return}if(s===kt.TURN_FAILED){n.currentActivity="",n.waitingAgentCount=0,n.latestActivity=O("本轮运行失败","This run failed"),n.latestDetail="";return}if(s===kt.ERROR){const p=rr(Ts(t));if(p){n.currentActivity=O(`网络异常,正在重试 (${p.attempt}/${p.total})`,`Network error, retrying (${p.attempt}/${p.total})`),n.latestActivity=n.currentActivity,n.latestDetail=wt(p.reason,120);return}n.currentActivity="",n.latestActivity=O(`${o} 返回错误`,`${o} returned an error`),n.latestDetail=wt(Ts(t),120);return}if(s===kt.ITEM_STARTED){if(r.type===ut.REASONING){n.currentActivity=O("正在思考","Thinking"),n.latestActivity=O("正在思考","Thinking"),n.latestDetail=wt(r.text,120);return}if(r.type===ut.COMMAND_EXECUTION){if(Kn(r).groupType==="todo"){const $=Bn(bs(r));n.currentActivity=O("正在更新待办列表","Updating todo list"),n.latestActivity=O("正在更新待办列表","Updating todo list"),n.latestDetail=wt($,120);return}n.currentActivity=O("正在执行命令","Running command"),n.latestActivity=O("开始执行命令","Command started"),n.latestDetail=wt(r.command,120);return}if(r.type===ut.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=wt(((u=r.action)==null?void 0:u.type)==="open_page"?((m=r.action)==null?void 0:m.url)||r.query:r.query||((k=r.action)==null?void 0:k.query),120);return}if(r.type===ut.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=wt(r.prompt,120);return}if(r.tool==="spawn_agent"){n.currentActivity=O("正在启动子代理","Starting sub-agent"),n.latestActivity=O("正在启动子代理","Starting sub-agent"),n.latestDetail=wt(r.prompt,120);return}}if(r.type===ut.FILE_CHANGE){n.currentActivity=O("正在整理文件变更","Collecting file changes"),n.latestActivity=O("正在整理文件变更","Collecting file changes"),n.latestDetail=wt((r.changes||[]).map(p=>p==null?void 0:p.path).filter(Boolean).join(_n()?", ":","),120);return}r.type===ut.TODO_LIST&&(n.currentActivity=O("正在规划执行步骤","Planning steps"),n.latestActivity=O("正在规划执行步骤","Planning steps"),n.latestDetail=wt((r.items||[]).map(p=>p==null?void 0:p.text).filter(Boolean).join(_n()?"; ":";"),120));return}if(s===kt.ITEM_COMPLETED){if(r.type===ut.COMMAND_EXECUTION){if(Kn(r).groupType==="todo"){n.currentActivity="",n.latestActivity=O("待办列表已更新","Todo list updated"),n.latestDetail=wt(Bn(bs(r)),120);return}n.commandCount+=1,n.currentActivity="",n.latestActivity=O("命令执行完成","Command completed"),n.latestDetail=wt(r.command,120);return}if(r.type===ut.WEB_SEARCH){n.webSearchCount+=1,n.currentActivity="",n.latestActivity=((d=r.action)==null?void 0:d.type)==="open_page"?O("已打开网页","Page opened"):O("已搜索网页","Web search completed"),n.latestDetail=wt(((T=r.action)==null?void 0:T.type)==="open_page"?((v=r.action)==null?void 0:v.url)||r.query:r.query||((h=r.action)==null?void 0:h.query),120);return}if(r.type===ut.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=wt(r.prompt,120);return}if(r.tool==="wait"){n.waitingAgentCount=0,n.currentActivity="",n.latestActivity=O("子代理结果已汇总","Sub-agent results aggregated"),n.latestDetail=Ap(r,120)||wt(r.prompt,120);return}n.currentActivity="",n.latestActivity=O(`协作工具完成:${r.tool||"未知工具"}`,`Collaboration tool completed: ${r.tool||"Unknown tool"}`),n.latestDetail=wt(r.prompt,120);return}if(r.type===ut.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=wt(p.map($=>$==null?void 0:$.path).filter(Boolean).join(_n()?", ":","),120);return}if(r.type===ut.TODO_LIST){n.currentActivity="",n.latestActivity=O("待办列表已更新","Todo list updated"),n.latestDetail=wt((r.items||[]).map(p=>p==null?void 0:p.text).filter(Boolean).join(_n()?"; ":";"),120);return}r.type===ut.AGENT_MESSAGE&&(n.currentActivity="",n.latestActivity=O(`${o} 已返回结果`,`${o} returned a result`),n.latestDetail=wt(r.text,120))}}function Mp(e={},t={}){const n=Date.parse(String(e.startedAt||""));if(!Number.isFinite(n))return 0;if(ks(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 Ba(e={},t={}){const n=e.summary||ns(),o=[],s=Mp(e,t);return s>0&&o.push({key:"elapsed",label:O("耗时","Elapsed"),value:Pa(s)}),n.webSearchCount&&o.push({key:"web",label:O("网页","Web"),value:Ft(n.webSearchCount)}),n.commandCount&&o.push({key:"command",label:O("命令","Command"),value:Ft(n.commandCount)}),n.fileChangeCount&&o.push({key:"file",label:O("改动","Changes"),value:Ft(n.fileChangeCount)}),n.subAgentCount&&o.push({key:"agent",label:O("子代理","Sub-agent"),value:Ft(n.subAgentCount)}),o}function Ra(e={}){const t=e.summary||ns();return t.waitingAgentCount>0?O(`当前:等待 ${Ft(t.waitingAgentCount)} 个子代理返回结果`,`Current: waiting for ${Ft(t.waitingAgentCount)} sub-agent result(s)`):t.currentActivity?O(`当前:${t.currentActivity}`,`Current: ${t.currentActivity}`):t.latestActivity?O(`最近:${t.latestActivity}`,`Latest: ${t.latestActivity}`):ks(e.status)?O(`当前:正在等待 ${Ut(e)} 返回更多事件`,`Current: waiting for more events from ${Ut(e)}`):""}function Na(e={}){const t=e.summary||ns();return String(t.latestDetail||"").trim()}function Bp(e={}){return!!(Ba(e).length||Ra(e)||Na(e))}const Rp=[{type:"startup_config",title:e=>O(`${ht(e)} 启动配置冲突`,`${ht(e)} startup config conflict`),summary:e=>O(`${ht(e)} 当前启动参数可能与本机包装脚本、别名或外部环境配置冲突,请检查 CLI 启动方式。`,`${ht(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(`${ht(e)} 可能因为额度不足、欠费或账单限制而无法继续执行。`,`${ht(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(`${ht(e)} 当前权限不够,无法访问所需文件、命令或资源。`,`${ht(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(`${ht(e)} 可能触发了限流,请稍后再试。`,`${ht(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(`${ht(e)} 背后的模型或服务当前不可用,请稍后重试。`,`The model or service behind ${ht(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(`${ht(e)} 在请求过程中遇到了网络问题或连接超时。`,`${ht(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(`${ht(e)} CLI 不可用`,`${ht(e)} CLI unavailable`),summary:e=>O(`当前环境没有正确安装或配置 ${ht(e)} CLI。`,`${ht(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 es(e="",t="codex"){const n=ts(e).trim();if(!n)return null;const o=Rp.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 fn(e="",t="codex"){const n=ts(e).trim();if(!n)return"";const o=es(n,t);return o?`${o.summary}
35
+
36
+ ${O("原始错误","Raw error")}: ${o.rawMessage}`:n}function Vo(e,t=0){if(!e||t>4)return"";if(typeof e=="string")return ts(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=Vo(e[o],t+1);if(s)return s}for(const o of Object.values(e)){const s=Vo(o,t+1);if(s)return s}return""}function Ts(e={}){return Vo(e)}function Np(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===kt.THREAD_STARTED){const k=e.thread_id?O(`线程 ID: ${e.thread_id}`,`Thread ID: ${e.thread_id}`):"";return{title:O(`${t} 会话已创建`,`${t} session created`),detail:k,detailBlocks:k?[xs([{label:"ID",value:e.thread_id}])]:[]}}if(o===kt.TURN_STARTED)return{title:O(`${t} 开始执行`,`${t} started`),detail:""};if(o===kt.TURN_COMPLETED){const k=e.usage?[O(`输入 ${Ft(e.usage.input_tokens)}`,`Input ${Ft(e.usage.input_tokens)}`),e.usage.cached_input_tokens?O(`缓存 ${Ft(e.usage.cached_input_tokens)}`,`Cached ${Ft(e.usage.cached_input_tokens)}`):"",O(`输出 ${Ft(e.usage.output_tokens)}`,`Output ${Ft(e.usage.output_tokens)}`)].filter(Boolean).join(" / "):"";return{title:O(`${t} 执行完成`,`${t} completed`),detail:k,detailBlocks:e.usage?[xs([{label:O("输入","Input"),value:Ft(e.usage.input_tokens)},e.usage.cached_input_tokens?{label:O("缓存","Cached"),value:Ft(e.usage.cached_input_tokens)}:null,{label:O("输出","Output"),value:Ft(e.usage.output_tokens)}])]:[]}}if(o==="claude.system"&&!String(e.detail||"").trim())return{title:"",detail:""};if(o===kt.ERROR||o===kt.TURN_FAILED){const k=Ts(e)||O(`${t} 执行失败`,`${t} failed`),d=o===kt.ERROR?rr(k):null;if(d)return{kind:"info",title:O(`网络异常,正在重试 (${d.attempt}/${d.total})`,`Network error, retrying (${d.attempt}/${d.total})`),detail:fn(d.reason||d.rawMessage,n),detailBlocks:Fn(fn(d.reason||d.rawMessage,n),{preferMarkdown:!0})};const T=es(k,n);return{kind:"error",title:(T==null?void 0:T.title)||(o===kt.TURN_FAILED?O("本轮运行失败","This run failed"):O(`${t} 返回错误`,`${t} returned an error`)),detail:fn(k,n),detailBlocks:Fn(fn(k,n),{preferMarkdown:!0})}}if(o===kt.ITEM_STARTED)return s.type===ut.REASONING?{kind:"reasoning",title:O("思考过程","Thinking"),detail:s.text||"",detailBlocks:Fn(s.text||"",{preferMarkdown:!0}),groupType:"reasoning",phase:"updated"}:s.type===ut.WEB_SEARCH?{..._r(s,"started"),detailBlocks:br(s),groupType:"web",groupTarget:String(s.query||((r=s.action)==null?void 0:r.query)||((l=s.action)==null?void 0:l.url)||"").trim(),phase:"started"}:s.type===ut.COLLAB_TOOL_CALL?{...Cr(s,"started"),detailBlocks:kr(s)}:s.type===ut.FILE_CHANGE?{...Er(s,"started"),detailBlocks:Tr(s)}:s.type===ut.COMMAND_EXECUTION?Kn(s).groupType==="todo"?{kind:"todo",title:O("更新待办列表","Update todo list"),detail:Bn(bs(s)),detailBlocks:Bs(s,!1,n),groupType:"todo",phase:"started"}:{kind:"command",title:O("开始执行命令","Command started"),detail:s.command||"",detailBlocks:Bs(s,!1,n),...Kn(s),phase:"started"}:s.type===ut.TODO_LIST?{kind:"todo",title:O("更新待办列表","Update todo list"),detail:Bn(s.items),detailBlocks:Ao(s),groupType:"todo",phase:"started"}:{title:O(`开始处理 ${s.type||"未知项目"}`,`Started handling ${s.type||"unknown item"}`),detail:""};if(o===kt.ITEM_UPDATED&&s.type===ut.TODO_LIST)return{kind:"todo",title:O("更新待办列表","Update todo list"),detail:Bn(s.items),detailBlocks:Ao(s),groupType:"todo",phase:"updated"};if(o===kt.ITEM_COMPLETED){if(s.type===ut.AGENT_MESSAGE&&s.text)return{kind:"result",title:O(`${t} 已返回结果`,`${t} returned a result`),detail:""};if(s.type===ut.WEB_SEARCH)return{..._r(s,"completed"),detailBlocks:br(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===ut.COLLAB_TOOL_CALL)return{...Cr(s,"completed"),detailBlocks:kr(s)};if(s.type===ut.FILE_CHANGE)return{...Er(s,"completed"),detailBlocks:Tr(s)};if(s.type===ut.COMMAND_EXECUTION){if(Kn(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:Bn(bs(s)),detailBlocks:Bs(s,!0,n),groupType:"todo",phase:"completed"}}const d=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:d?"command":"error",title:d?O("命令执行完成","Command completed"):O(`命令执行失败(exit ${s.exit_code??"?"})`,`Command failed (exit ${s.exit_code??"?"})`),detail:[s.command,Aa(s.aggregated_output)].filter(Boolean).join(`
37
+
38
+ `),detailBlocks:Bs(s,!0,n),...Kn(s),phase:"completed"}}return s.type===ut.TODO_LIST?{kind:"todo",title:O("更新待办列表","Update todo list"),detail:Bn(s.items),detailBlocks:Ao(s),groupType:"todo",phase:"completed"}:{title:O(`完成 ${s.type||"未知项目"}`,`Completed ${s.type||"unknown item"}`),detail:""}}return{title:O(`事件: ${o}`,`Event: ${o}`),detail:""}}function Op(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 Oa(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?Fn(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 Fp(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"?Us(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:ns()}}function Mn(e,t,n){const o=Oa(t,n);o&&(e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120))}function Up(e,t,n){var s;const o=Oa(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 jp(e,t={},n,o=()=>{}){var r,l,u,m,k,d,T,v,h;const s=sa(t.type);if(s===Gt.SESSION){o(t.session);return}if(s===Gt.SESSION_UPDATED){o(t.session);return}if(s===Gt.STATUS){if(t.stage==="starting"||t.stage==="resuming")return;Mn(e,{title:ys(t)||O("状态已更新","Status updated"),detail:""},n);return}if(s===Gt.STDERR){const p=es(t.text,e.engine);Mn(e,{kind:"error",title:(p==null?void 0:p.title)||"stderr",detail:fn(t.text,e.engine)},n);return}if(s===Gt.STDOUT){Mn(e,{kind:"command",title:"stdout",detail:t.text},n);return}if(s===Gt.AGENT_EVENT){if(Lp(e,t.event),((r=t.event)==null?void 0:r.type)===kt.THREAD_STARTED)return;const p=Np(t.event,Ut(e),e.engine);String(p.title||"").startsWith(O("网络异常,正在重试","Network error, retrying"))?Up(e,p,n):Mn(e,p,n),((l=t.event)==null?void 0:l.type)===kt.ITEM_COMPLETED&&((m=(u=t.event)==null?void 0:u.item)==null?void 0:m.type)===ut.AGENT_MESSAGE&&((d=(k=t.event)==null?void 0:k.item)!=null&&d.text)&&(e.responseMessage=t.event.item.text);const $=Ts(t.event)||O(`${Ut(e)} 执行失败`,`${Ut(e)} failed`);if(!(((T=t.event)==null?void 0:T.type)==="error"?rr($):null)&&(((v=t.event)==null?void 0:v.type)===kt.ERROR||((h=t.event)==null?void 0:h.type)===kt.TURN_FAILED)){const y=Ts(t.event)||O(`${Ut(e)} 执行失败`,`${Ut(e)} failed`);e.errorMessage=fn(y,e.engine),e.status="error"}return}if(s===Gt.COMPLETED){Mn(e,{kind:"result",title:O("本轮执行结束","Run finished"),detail:""},n);const p=ys(t);p&&(e.responseMessage=p);return}if(s===Gt.STOPPED){Mn(e,{title:ys(t)||O("执行已手动停止","Execution stopped manually"),detail:""},n);return}if(s===Gt.ERROR){const p=ys(t),$=es(p,e.engine);Mn(e,{kind:"error",title:($==null?void 0:$.title)||O("执行失败","Execution failed"),detail:fn(p||O(`${Ut(e)} 执行失败`,`${Ut(e)} failed`),e.engine)},n)}}function Vp(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=es(o,n),l=es(s,n);return!r&&!!l}function zp(e,t={}){e.status=t.status||"completed",e.responseMessage=String(t.responseMessage||e.responseMessage||""),e.finishedAt=String(t.finishedAt||e.finishedAt||"");const n=fn(String(t.errorMessage||""),e.engine),o=String(e.errorMessage||"");return e.errorMessage=Vp(t.errorMessage,o,e.engine)?o:n,e.status==="completed"&&!e.responseMessage&&(e.responseMessage=O(`本轮 ${Ut(e)} 执行已完成,没有返回额外文本。`,`${Ut(e)} completed in this run without returning additional text.`)),e}function ar(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)||{};jp(e,r,n,o);const l=sa(r.type);return l===Gt.COMPLETED?(e.status="completed",e.finishedAt=new Date().toISOString()):l===Gt.STOPPED?(e.status="stopped",e.errorMessage="",e.finishedAt=new Date().toISOString()):l===Gt.ERROR&&(e.status="error",e.errorMessage=fn(String(ys(r)||e.errorMessage||O(`${Ut(e)} 执行失败`,`${Ut(e)} failed`)),e.engine),e.finishedAt=new Date().toISOString()),s&&(e.lastEventSeq=s),e.eventCount=Math.max(Math.max(0,Number(e.eventCount)||0),s,Array.isArray(e.events)?e.events.length:0),(s||Array.isArray(e.events)&&e.events.length)&&(e.eventsLoaded=!0),!0}function Ar(e,t,n,o){const s=Fp(e,t);return(e.events||[]).forEach(r=>{ar(s,r,n,o)}),zp(s,e)}const Hp=1800,Ir=7200,qp=15e3,Io={clearTaskCodexRuns:Ol,listCodexRunEvents:Rl,listTaskCodexRuns:Bl};function Ss(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 Kp(e=[],t=!0){const n=Array.isArray(e)?e:[];return JSON.stringify(n.map(o=>Ss(o,t)))}function Wp(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function Gp(e={}){const{props:t,turns:n,sessions:o,sending:s,sendingStartedAt:r,currentRunningRunId:l,sessionError:u,supportsServerEvents:m,scheduleScrollToBottom:k,resetAutoStickToBottom:d,mergeSessionRecord:T,mergeSession:v,loadSessions:h,showProcessLogs:p}=e;let $=0,ee=0,y=null,B="",K=null,V=null,N="",se=!!(p!=null&&p.value),I=0;const X=new Map;function ge(){return $+=1,$}function ye(){return ee+=1,ee}function D(){K&&(window.clearInterval(K),K=null)}function ne(){V&&(window.clearInterval(V),V=null)}function le(){I=Date.now()}function te(){X.clear(),n.value=[],s.value=!1,r.value=0,l.value="",N="",B="",$=0,ee=0,d()}function ve(){const H=[...n.value].reverse().find(Z=>ks(Z.status))||null;if(l.value=(H==null?void 0:H.runId)||"",s.value=!!H,H!=null&&H.startedAt){const Z=Date.parse(String(H.startedAt||""));r.value=Number.isFinite(Z)?Z:Date.now();return}r.value=0}function C(H=null){return H?{...H}:Wp()}function W(H,Z=null){if(!(Z!=null&&Z.runId)||H.eventsLoaded||!Z.eventsLoaded)return X.has(H.runId)&&(H.eventsLoading=!0),H;const me=Math.max(Math.max(0,Number(Z.lastEventSeq)||0),Math.max(0,Number(Z.eventCount)||0),Array.isArray(Z.events)?Z.events.length:0),_e=Math.max(0,Number(H.eventCount)||0);return me<_e?(X.has(H.runId)&&(H.eventsLoading=!0),H):(H.events=Array.isArray(Z.events)?[...Z.events]:[],H.eventCount=Math.max(Math.max(0,Number(H.eventCount)||0),Math.max(0,Number(Z.eventCount)||0),H.events.length),H.eventsLoaded=!0,H.eventsLoading=X.has(H.runId),H.lastEventSeq=Math.max(0,Number(Z.lastEventSeq)||0),H.summary=C(Z.summary),H)}function P(H,Z){const me=jo(n.value,H);return me?(me.eventsLoading=!!Z,n.value=[...n.value],me):null}async function Ee(H,Z={}){const me=String((H==null?void 0:H.runId)||"").trim(),{force:_e=!1}=Z;if(!me)return[];const fe=jo(n.value,me)||H;if(fe!=null&&fe.eventsLoaded&&!_e)return fe.events;if(X.has(me))return X.get(me);P(me,!0);const Le=(async()=>{var he;try{const Me=Ss(fe,!!(p!=null&&p.value)),je=await Io.listCodexRunEvents(me,{limit:5e3}),De=Pp(n.value,me,je,ye,Xe=>{v(Xe,{preserveRunning:!0})});if(!De)return Array.isArray(fe==null?void 0:fe.events)?fe.events:[];const vt=JSON.stringify(Me)!==JSON.stringify(Ss(De,!!(p!=null&&p.value)));return n.value=[...n.value],vt&&t.active&&((he=n.value.at(-1))==null?void 0:he.runId)===me&&k(),De.events}catch(Me){throw u.value=Me.message,Me}finally{P(me,!1),X.delete(me)}})();return X.set(me,Le),Le}function Ie(H,Z){const me=String(H||"").trim();if(!me||!Z)return!1;const _e=n.value.findIndex(je=>je.runId===me);if(_e<0)return!1;const fe=n.value[_e],Le=Ss(fe,!!(p!=null&&p.value));if(!ar(fe,Z,ye,je=>{v(je,{preserveRunning:!0})}))return!0;const Me=JSON.stringify(Le)!==JSON.stringify(Ss(fe,!!(p!=null&&p.value)));return n.value=[...n.value],ve(),Me&&k(),!0}function Be(){if(D(),ne(),!(!t.active||!s.value||!t.taskSlug)){if(m){V=window.setInterval(()=>{Je({force:!0}).catch(()=>{});const H=Date.now();H-I<Ir||(I=H,h({force:!0}).catch(()=>{}))},qp);return}K=window.setInterval(()=>{Je({force:!0}).catch(()=>{});const H=Date.now();H-I<Ir||(I=H,h({force:!0}).catch(()=>{}))},Hp)}}function Ye(H=[]){const Z=[...o.value],me=new Map(n.value.filter(fe=>String((fe==null?void 0:fe.runId)||"").trim()).map(fe=>[String(fe.runId||"").trim(),fe])),_e=fe=>{if(!(fe!=null&&fe.id))return;const Le=Z.findIndex(he=>he.id===fe.id);Le>=0?Z[Le]=T(Z[Le],fe,{preserveRunning:!0}):Z.unshift(T(null,fe,{preserveRunning:!0}))};$=0,ee=0,n.value=[...H||[]].reverse().map(fe=>{const Le=Ar(fe,ge,ye,_e);return W(Le,me.get(String((fe==null?void 0:fe.id)||"").trim())||null)}),o.value=Z,ve()}async function Je(H={}){const{force:Z=!1,scrollToLatest:me=!1}=H,_e=String(t.taskSlug||"").trim();if(!(!_e||!t.active&&!Z))return y&&B===_e||y&&!Z||(B=_e,y=(async()=>{try{const Le=(await Io.listTaskCodexRuns(_e,{limit:30,events:"latest"})).items||[],he=!!(p!=null&&p.value),Me=Kp(Le,he),je=me||N&&se===he&&Me!==N;Ye(Le),N=Me,se=he,Be();const De=n.value.at(-1)||null;if(De!=null&&De.runId&&!De.eventsLoaded){const vt=De.runId;Ee(De).catch(()=>{}).finally(()=>{var Xe;me&&t.active&&((Xe=n.value.at(-1))==null?void 0:Xe.runId)===vt&&k({force:!0})})}je&&k({force:me})}catch(fe){u.value=fe.message}finally{y=null,B=""}})()),y}function Ke(H={}){const Z=(H==null?void 0:H.run)||null,me=(H==null?void 0:H.session)||null;if(me&&v(me,{preserveRunning:!0}),!(Z!=null&&Z.id)){ve(),k({force:!0});return}const fe=Ar(Z,ge,ye,he=>{v(he,{preserveRunning:!0})}),Le=n.value.findIndex(he=>he.runId===fe.runId);if(Le>=0){const he=[...n.value];he.splice(Le,1,fe),n.value=he}else n.value=[...n.value,fe];ve(),k({force:!0})}async function we(){if(!(!t.taskSlug||s.value))try{await Io.clearTaskCodexRuns(t.taskSlug),te(),k({force:!0})}catch(H){u.value=H.message}}return{applyCreatedRun:Ke,applyIncomingRunEvent:Ie,clearRealtimeReconcileTimer:ne,clearRunPollTimer:D,clearTurns:we,loadTurnEvents:Ee,markFallbackSessionPollNow:le,refreshRunHistory:Je,resetRunHistoryState:te,syncRunningStateFromTurns:ve,updatePollingState:Be}}const Xp=1500,Yp=3e4;function Jp(e={}){const{props:t,sessions:n,workspaces:o,loading:s,managerBusy:r,sending:l,stopping:u,sessionError:m,showManager:k,selectedSessionId:d,currentRunningRunId:T,supportsServerEvents:v,mergeSession:h,applyCreatedRun:p,refreshRunHistory:$,markFallbackSessionPollNow:ee,showToast:y,getActiveAgentBinding:B=null}=e;let K=null,V=null,N=0,se=0;const I=q(()=>typeof t.buildPrompt=="function"||!!String(t.prompt||"").trim()),X=q(()=>n.value.length>0),ge=q(()=>wr(n.value,d.value)),ye=q(()=>X.value?"":Ge("projectManager.noProjects"));async function D(we={}){const{force:H=!1}=we;if(K)return K;const Z=Date.now();return!H&&N&&Z-N<Xp?{items:n.value,workspaces:o.value}:(K=(async()=>{s.value=!0,m.value="";try{const _e=(await kl()).items||[];return n.value=_e,N=Date.now(),{items:_e,workspaces:o.value}}catch(me){throw m.value=me.message,me}finally{s.value=!1,K=null}})(),K)}async function ne(we={}){const{force:H=!1}=we;if(V)return V;const Z=Date.now();return!H&&se&&Z-se<Yp?{items:o.value}:(V=(async()=>{try{const me=await Tl();return o.value=me.items||[],se=Date.now(),{items:o.value}}finally{V=null}})(),V)}async function le(we={}){const{forceSessions:H=!1,forceWorkspaces:Z=!1}=we,[me,_e]=await Promise.all([D({force:H}),ne({force:Z})]);return{items:(me==null?void 0:me.items)||n.value,workspaces:(_e==null?void 0:_e.items)||o.value}}function te(we=""){const H=String(we||"").trim();!H||o.value.includes(H)||(o.value=[H,...o.value])}function ve(){k.value=!0,ne().catch(()=>{})}function C(){k.value=!1}function W(we){const H=String(we||"").trim();if(t.sessionSelectionLocked&&H&&H!==d.value){m.value=t.sessionSelectionLockReason||Ge("taskActions.sessionLocked");return}d.value=H}function P(){le({forceSessions:!0,forceWorkspaces:!0}).catch(()=>{})}async function Ee(we){r.value=!0,m.value="";try{const H=await _l(we);return h(H),te(H.cwd),d.value=H.id,H}catch(H){throw m.value=H.message,H}finally{r.value=!1}}async function Ie(we,H){r.value=!0,m.value="";try{const Z=await Cl(we,H);return h(Z),te(Z.cwd),Z}catch(Z){throw m.value=Z.message,Z}finally{r.value=!1}}async function Be(we){var Z;const H=String(we||"").trim();if(!H)return{deletedSessionId:"",selectedSessionId:d.value};r.value=!0,m.value="";try{await El(H);const me=n.value.filter(fe=>fe.id!==H);n.value=me;let _e=d.value;return d.value===H&&(_e=((Z=wr(me,"")[0])==null?void 0:Z.id)||"",d.value=_e),{deletedSessionId:H,selectedSessionId:_e}}catch(me){throw m.value=me.message,me}finally{r.value=!1}}async function Ye(we){const H=String(we||"").trim();if(!H)return null;r.value=!0,m.value="";try{const Z=await Al(H);return Z!=null&&Z.session&&h(Z.session),ee(),await Promise.all([$({force:!0}),D({force:!0})]),y==null||y({message:Ge("projectManager.sessionReset"),type:"success"}),Z}catch(Z){throw m.value=Z.message,Z}finally{r.value=!1}}async function Je(){if(!t.taskSlug||!I.value||l.value||u.value)return!1;if(!d.value){const we=Ge("projectManager.selectProject");return m.value=we,y==null||y({message:we,type:"warning"}),!1}m.value="";try{await le({forceSessions:!0});const we=n.value.find(De=>De.id===d.value)||null;if(!we)return m.value=Ge("projectManager.projectMissing"),!1;if(we.running)return m.value=Ge("sessionTurns.currentProjectRunning"),!1;const H=typeof t.buildPrompt=="function"?await t.buildPrompt():t.prompt,Z=typeof t.buildPromptBlocks=="function"?await t.buildPromptBlocks():[],me=Li({prompt:H,promptBlocks:Z});if(me.reason){const De=me.reason==="unsupported_blocks"?Ge("sessionPanel.shellUnsupportedBlocks"):Ge("sessionPanel.shellEmptyCommand");return m.value=De,y==null||y({message:De,type:"warning"}),!1}if(!String(H||"").trim())return m.value=Ge("sessionTurns.noPromptToSend"),!1;const _e=Qp(we),fe=typeof B=="function"?B(we):null,Le=String((fe==null?void 0:fe.engine)||"").trim();if(Le&&!_e.some(De=>De.engine===Le)){const De=Ge("sessionPanel.agentNotEnabled");return m.value=De,y==null||y({message:De,type:"warning"}),!1}const he=fe,Me=String(me.mode==="shell"?d.value:(he==null?void 0:he.sessionRecordId)||d.value).trim(),je=await Nl(t.taskSlug,{projectSessionId:d.value,sessionId:Me,displayEngine:Le,prompt:me.mode==="shell"?me.prompt:H,promptBlocks:Z,commandMode:me.mode,command:me.command});return p(je),typeof t.afterSend=="function"&&Promise.resolve(t.afterSend()).catch(De=>{console.error("[promptx] afterSend failed",De)}),v||(ee(),Promise.all([$({force:!0}),D({force:!0})]).catch(De=>{m.value=De.message})),!0}catch(we){return m.value=we.message,!1}}async function Ke(){if(!(!T.value||u.value))try{u.value=!0,await Fl(T.value),v||(ee(),await Promise.all([$({force:!0}),D({force:!0})]))}catch(we){u.value=!1,m.value=we.message}}return{closeManager:C,handleCreateSession:Ee,handleDeleteSession:Be,handleResetSession:Ye,handleSelectSession:W,handleSend:Je,handleUpdateSession:Ie,hasPrompt:I,helperText:ye,loadSessions:D,loadSessionResources:le,loadWorkspaces:ne,openManager:ve,refreshSessionsForSelection:P,sortedSessions:ge,stopSending:Ke}}function Qp(e={}){return Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length?e.agentBindings:e!=null&&e.id?[{engine:Zp(e.engine),sessionRecordId:e.id,sessionId:e.sessionId||"",isDefault:!0,running:!!e.running,started:!!e.started}]:[]}function Zp(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 em=1200,tm=[0,80,220,500,900];function nm(e={}){const{transcriptRef:t,hasNewerMessages:n,threshold:o=48}=e;let s=0,r=[],l=!1,u=!1,m=0,k=!0,d=0,T=[],v=0,h=null;function p(){const P=typeof window<"u"?window:globalThis;return typeof(P==null?void 0:P.setTimeout)!="function"||typeof(P==null?void 0:P.clearTimeout)!="function"?null:{setTimeout:P.setTimeout.bind(P),clearTimeout:P.clearTimeout.bind(P)}}function $(){if(typeof window>"u"||!r.length){r=[];return}r.forEach(P=>{window.cancelAnimationFrame(P)}),r=[]}function ee(){s+=1,$()}function y(){const P=p();if(!P){T=[],v=0;return}T.forEach(Ee=>{P.clearTimeout(Ee)}),T=[],v&&(P.clearTimeout(v),v=0)}function B(){var P;(P=h==null?void 0:h.disconnect)==null||P.call(h),h=null}function K(){return d>Date.now()}function V(P){u=!!P,(n==null?void 0:n.value)!==void 0&&(n.value=u)}function N(){l=!1,m+=1,k=!0,V(!1)}function se(P=t==null?void 0:t.value){return P?P.scrollHeight-P.scrollTop-P.clientHeight<=o:!0}function I(){return K()||k&&!l}function X(){k&&!l&&V(!1)}function ge(){if(k=se(),!k){ee();return}X()}function ye(){m+=1,l=!0,d=0,y(),B(),ee()}function D(){const P=m+1;m=P,ct(()=>{P===m&&requestAnimationFrame(()=>{P===m&&(l=!1,k=se(),X())})})}function ne(){l=!0,d=0,y(),B(),ee()}function le(){D()}function te(P={}){const{force:Ee=!1}=P;Ee&&N(),ee();const Ie=s;ct(()=>{if(!(t==null?void 0:t.value)||Ie!==s)return;if(!Ee&&!I()){V(!0);return}const Ye=()=>{const Ke=t==null?void 0:t.value;!Ke||Ie!==s||(Ke.scrollTop=Ke.scrollHeight,k=!0,V(!1))};Ye(),r=[requestAnimationFrame(()=>{Ye(),r=[requestAnimationFrame(Ye)]})]})}function ve(){te({force:!0})}function C(P={}){const Ee=Number(P.durationMs),Ie=Math.max(0,Number.isFinite(Ee)?Ee:em),Be=p();N(),d=Date.now()+Ie,y(),B(),Be&&(T=tm.map(Ye=>Be.setTimeout(()=>{K()&&te({force:!0})},Ye)),v=Be.setTimeout(()=>{d=0,v=0,y(),B()},Ie+40)),typeof window<"u"&&typeof window.ResizeObserver=="function"&&(h=new window.ResizeObserver(()=>{K()&&te({force:!0})}),t!=null&&t.value&&h.observe(t.value)),te({force:!0})}function W(){m+=1,d=0,y(),B(),ee()}return{cancelScheduledScrollToBottom:ee,destroy:W,handleTranscriptScroll:ge,handleTranscriptTouchEnd:le,handleTranscriptTouchMove:ne,handleTranscriptTouchStart:ye,beginForceFollowWindow:C,isTranscriptNearBottom:se,resetAutoStickToBottom:N,scheduleScrollToBottom:te,scrollToBottom:ve}}const sm=150,Fa="promptx:session-panel:show-process";function om(e){return!(e==="0"||e==="false")}function rm(){if(typeof window>"u")return!0;try{return om(window.localStorage.getItem(Fa))}catch{return!0}}function am(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 im(e,t){const n=Ea(),o=j([]),s=j([]),r=j(!1),l=j(!1),u=j(!1),m=j(!1),k=j(""),d=j([]),T=j(null),v=j(0),h=j(0),p=j(!1),$=j(""),ee=j(!1),y=j(rm()),B=typeof window<"u"&&typeof window.EventSource<"u";function K(re=""){const Oe=typeof re=="object"&&re!==null?String(re.message||"").trim():String(re||"").trim();Oe&&t("toast",typeof re=="object"&&re!==null?{...re,message:Oe}:Oe)}let V=null,N=null,se=null,I={sessions:!1,runs:!1};const X=q({get(){return String(e.selectedSessionId||"").trim()},set(re){t("selected-session-change",String(re||"").trim())}}),ge=q(()=>m.value?Ge("sessionPanel.stopping"):`${Ge("projectManager.running")} (${Pa(h.value)})`),ye=q(()=>o.value.find(re=>re.id===X.value)||null),D=q(()=>{var Oe;if(Array.isArray((Oe=ye.value)==null?void 0:Oe.agentBindings)&&ye.value.agentBindings.length)return ye.value.agentBindings;const re=ye.value;return re!=null&&re.id?[{engine:re.engine,sessionRecordId:re.id,sessionId:re.sessionId||"",started:!!re.started,running:!!re.running,isDefault:!0}]:[]}),ne=q({get(){var Oe,rt;const re=$o(e.selectedAgentEngine,D.value);return re||((Oe=D.value.find(nt=>nt.isDefault))==null?void 0:Oe.engine)||((rt=D.value[0])==null?void 0:rt.engine)||""},set(re){const Oe=$o(re,D.value);Oe&&t("update:selectedAgentEngine",Oe)}}),le=q(()=>D.value.find(re=>re.engine===ne.value)||D.value[0]||null),{beginForceFollowWindow:te,destroy:ve,handleTranscriptScroll:C,handleTranscriptTouchEnd:W,handleTranscriptTouchMove:P,handleTranscriptTouchStart:Ee,resetAutoStickToBottom:Ie,scheduleScrollToBottom:Be,scrollToBottom:Ye}=nm({transcriptRef:T,hasNewerMessages:ee});function Je(re,Oe,rt={}){return am(re,Oe,rt)}function Ke(re,Oe={}){if(!(re!=null&&re.id))return;const rt=[...o.value],nt=rt.findIndex(Bt=>Bt.id===re.id);nt>=0?rt[nt]=Je(rt[nt],re,Oe):rt.unshift(Je(null,re,Oe)),o.value=rt}const{applyCreatedRun:we,applyIncomingRunEvent:H,clearRealtimeReconcileTimer:Z,clearRunPollTimer:me,clearTurns:_e,loadTurnEvents:fe,markFallbackSessionPollNow:Le,refreshRunHistory:he,resetRunHistoryState:Me,updatePollingState:je}=Gp({props:e,turns:d,sessions:o,sending:u,sendingStartedAt:v,currentRunningRunId:$,sessionError:k,supportsServerEvents:B,scheduleScrollToBottom:Be,resetAutoStickToBottom:Ie,showProcessLogs:y,mergeSessionRecord:Je,mergeSession:Ke,loadSessions:(...re)=>lt(...re)}),{closeManager:De,handleCreateSession:vt,handleDeleteSession:Xe,handleResetSession:St,handleSelectSession:et,handleSend:mt,handleUpdateSession:ze,helperText:Ce,loadSessions:lt,loadSessionResources:dt,loadWorkspaces:L,openManager:U,refreshSessionsForSelection:oe,sortedSessions:Te,stopSending:Re}=Jp({props:e,sessions:o,workspaces:s,loading:r,managerBusy:l,sending:u,stopping:m,sessionError:k,showManager:p,selectedSessionId:X,currentRunningRunId:$,supportsServerEvents:B,mergeSession:Ke,applyCreatedRun:we,refreshRunHistory:he,markFallbackSessionPollNow:Le,showToast:K,getActiveAgentBinding:()=>le.value});function $e(){V&&(window.clearInterval(V),V=null)}function tt(){$e(),v.value||(v.value=Date.now()),h.value=Math.max(0,Math.floor((Date.now()-v.value)/1e3)),V=window.setInterval(()=>{h.value=Math.max(0,Math.floor((Date.now()-v.value)/1e3))},1e3)}function Ve(){se&&(window.clearTimeout(se),se=null)}function _t(){Ve();const re=I;I={sessions:!1,runs:!1},re.sessions&&lt({force:!0}).catch(()=>{}),re.runs&&he({force:!0}).catch(()=>{})}function yt(re={}){typeof window>"u"||(I={sessions:I.sessions||!!re.sessions,runs:I.runs||!!re.runs},!(se||!I.sessions&&!I.runs)&&(se=window.setTimeout(()=>{_t()},sm)))}function xt(re){return Ba(re,{currentRunningRunId:$.value,runningElapsedSeconds:h.value,nowMs:Date.now()})}function We(re=""){if(!re)return"";const Oe=new Date(re);return Number.isNaN(Oe.getTime())?"":Oe.toLocaleTimeString(ro(),{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Ht(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 Qt(){y.value=!y.value}function Yt(re){return!!(re.responseMessage||re.errorMessage||re.status==="completed")}return Pe(y,re=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Fa,re?"true":"false")}catch{}},{immediate:!0}),Pe(u,re=>{re?(v.value||(v.value=Date.now()),tt()):($e(),v.value=0,h.value=0,m.value=!1),je(),t("sending-change",re)},{immediate:!0}),Pe(h,(re,Oe)=>{e.active&&Oe===0&&re>0&&Be()}),Pe(()=>!!e.taskRunning,re=>{!e.active||re||!u.value||yt({sessions:!0,runs:!0})}),Pe(()=>e.active,re=>{if(re){dt({forceSessions:!0}).catch(()=>{});return}Ve(),Z(),me()},{immediate:!0}),Pe(()=>e.taskSlug,()=>{Me(),p.value=!1,k.value="",e.active&&(te(),he({force:!0,scrollToLatest:!0}).catch(()=>{}))},{immediate:!0}),Pe(()=>{var re;return[((re=ye.value)==null?void 0:re.id)||"",D.value.map(Oe=>Oe.engine).join(","),e.selectedAgentEngine||""].join(`
39
+ `)},()=>{var z,Q,ce;const re=String(((z=ye.value)==null?void 0:z.id)||"").trim(),Oe=D.value,rt=ne.value;if(t("agent-bindings-change",{sessionId:re,bindings:Oe,selectedEngine:rt}),!re||$o(e.selectedAgentEngine,Oe))return;const Bt=((Q=Oe.find(Se=>Se.isDefault))==null?void 0:Q.engine)||((ce=Oe[0])==null?void 0:ce.engine)||"";Bt&&t("update:selectedAgentEngine",Bt)},{immediate:!0}),Mt(()=>{$e(),Z(),me(),Ve(),ve(),N==null||N()}),Pe(()=>n.readyVersion.value,()=>{const re=String(e.taskSlug||"").trim();!e.active&&!p.value||(p.value&&L().catch(()=>{}),yt({sessions:!0,runs:!!re}))}),Pe(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!p.value||yt({sessions:!0})}),Pe(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||yt({sessions:!0,runs:!0})}),Pe(()=>String(e.taskSlug||"").trim(),re=>{N==null||N(),N=null,re&&(N=fp(re,({runId:Oe,event:rt})=>{if(!e.active)return;H(Oe,rt)||yt({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:le,activeAgentEngine:ne,clearTurns:_e,closeManager:De,formatTurnTime:We,getProcessCardClass:Ht,getProcessStatus:Op,getTurnAgentLabel:Ut,getTurnSummaryDetail:Na,getDisplayTurnSummaryItems:xt,getTurnSummaryStatus:Ra,handleCreateSession:vt,handleDeleteSession:Xe,handleResetSession:St,handleSelectSession:et,handleSend:mt,handleUpdateSession:ze,loadTurnEvents:fe,hasTurnSummary:Bp,helperText:Ce,loading:r,managerBusy:l,openManager:U,refreshSessionsForSelection:oe,selectedSessionId:X,sending:u,showProcessLogs:y,stopping:m,sessionError:k,shouldShowResponse:Yt,showManager:p,sortedSessions:Te,stopSending:Re,toggleProcessLogs:Qt,hasNewerMessages:ee,transcriptRef:T,turns:d,workspaces:s,workingLabel:ge,sessions:o,loadSessions:lt,currentProjectAgentBindings:D,handleTranscriptScroll:C,handleTranscriptTouchEnd:W,handleTranscriptTouchMove:P,handleTranscriptTouchStart:Ee,scheduleScrollToBottom:Be,scrollToBottom:Ye}}function $o(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const lm=8,um=320,cm=10,dm=400;function $r(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function fm(e={}){const{turns:t,loadTurnEvents:n}=e,o=j({}),s=j({}),r=j({});function l(I){return String((I==null?void 0:I.runId)||(I==null?void 0:I.id)||"").trim()}function u(I){const X=l(I);return!!X&&X===l(t.value.at(-1))}function m(I){return Math.max(0,Number(I==null?void 0:I.eventCount)||0,Array.isArray(I==null?void 0:I.events)?I.events.length:0)}function k(I){return!ks(I==null?void 0:I.status)&&!u(I)&&m(I)>3}function d(I){return $r(I==null?void 0:I.prompt,lm,um)}function T(I){return!ks(I==null?void 0:I.status)&&!u(I)&&d(I)}function v(I){return String((I==null?void 0:I.errorMessage)||(I==null?void 0:I.responseMessage)||"")}function h(I){return $r(v(I),cm,dm)}function p(I){return!(I!=null&&I.errorMessage)&&!u(I)&&h(I)}function $(I){return m(I)>0}function ee(I=[]){const X=new Set((I||[]).map(D=>l(D)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([D])=>X.has(D))),s.value=Object.fromEntries(Object.entries(s.value).filter(([D])=>X.has(D))),r.value=Object.fromEntries(Object.entries(r.value).filter(([D])=>X.has(D)));const ge=(I||[]).at(-1)||null,ye=l(ge);ye&&(Object.prototype.hasOwnProperty.call(o.value,ye)||(o.value={...o.value,[ye]:!1}),Object.prototype.hasOwnProperty.call(s.value,ye)||(s.value={...s.value,[ye]:!1}),Object.prototype.hasOwnProperty.call(r.value,ye)||(r.value={...r.value,[ye]:!1}))}function y(I){const X=l(I);return X?Object.prototype.hasOwnProperty.call(o.value,X)?!!o.value[X]:k(I):!1}async function B(I){const X=l(I);if(!X)return;const ge=!y(I);o.value={...o.value,[X]:ge},!ge&&$(I)&&!I.eventsLoaded&&!I.eventsLoading&&await n(I).catch(()=>{})}function K(I){const X=l(I);return X?Object.prototype.hasOwnProperty.call(s.value,X)?!!s.value[X]:T(I):!1}function V(I){const X=l(I);!X||!d(I)||(s.value={...s.value,[X]:!K(I)})}function N(I){const X=l(I);return X?Object.prototype.hasOwnProperty.call(r.value,X)?!!r.value[X]:p(I):!1}function se(I){const X=l(I);!X||!h(I)||(r.value={...r.value,[X]:!N(I)})}return Pe(t,I=>{ee(I)},{immediate:!0,deep:!0}),{canCollapsePrompt:d,canCollapseResponse:h,getTurnEventCollapseKey:l,getTurnEventCount:m,hasTurnEventHistory:$,isLatestTurn:u,isPromptCollapsed:K,isResponseCollapsed:N,isTurnEventsCollapsed:y,togglePrompt:V,toggleResponse:se,toggleTurnEvents:B}}function pm(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function mm(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 gm(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function Po(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 Do(e="",t=[],n=[]){var l;const o=pm(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=mm([{label:"类型",value:gm(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 Ua(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:Po(n,e.length),detail:"",detailBlocks:Do(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:Po(n,e.length),detail:"",detailBlocks:Do(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:Po(n,o.length),detail:"",detailBlocks:Do(n,o,o),isGrouped:!0,groupedCount:o.length}]}function hm(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]=Ua(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 vm(e=[]){var o;const t=hm(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(...Ua(u))}return n}const ym={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},Sm={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},wm={class:"flex flex-col gap-2"},xm={class:"flex items-center gap-2"},bm=["title"],km={class:"flex shrink-0 items-center gap-1.5"},Tm=["aria-pressed","aria-label","title"],_m=["disabled"],Cm={class:"hidden sm:inline"},Em=["disabled"],Am={class:"hidden sm:inline"},Im=["aria-label"],$m=["aria-pressed"],Pm=["aria-pressed","title","onClick"],Dm={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},Lm={class:"min-h-0 flex-1"},Mm={key:0,class:"theme-empty-state px-4 py-6 text-sm"},Bm={key:1,class:"theme-empty-state px-4 py-6 text-sm"},Rm=["data-turn-id","data-run-id"],Nm={class:"flex justify-end"},Om={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)]"},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={class:"relative mt-2"},Hm={key:0,class:"space-y-3"},qm={key:0,class:"whitespace-pre-wrap break-words leading-7"},Km=["onClick"],Wm=["src","alt"],Gm={key:1,class:"whitespace-pre-wrap break-words leading-7"},Xm={key:0,class:"flex min-w-0 justify-start"},Ym={class:"flex items-center justify-between gap-3 text-xs"},Jm={class:"font-semibold"},Qm={class:"flex items-center gap-2"},Zm=["disabled","onClick"],eg={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},tg={key:1,class:"mt-2 min-w-0 space-y-2"},ng={class:"text-sm font-medium leading-6"},sg={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},og={key:3,class:"mt-2 text-xs text-current"},rg={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},ag={key:0,class:"leading-5"},ig={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},lg={key:2,class:"mt-2 flex flex-wrap gap-2"},ug={class:"font-medium"},cg={key:1,class:"flex justify-start"},dg={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},fg={class:"font-semibold"},pg={class:"flex items-center gap-2"},mg=["onClick"],gg=["onClick"],hg={class:"relative mt-2"},vg={key:0,class:"whitespace-pre-wrap break-words"},yg=["innerHTML"],Sg={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"},wg=["disabled"],xg={key:2,class:"task-loading-dots","aria-hidden":"true"},Pr="promptx:selected-agent-filter-map",bg={__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=Bo(()=>He(()=>import("./CodexSessionManagerDialog-D_72LIMv.js"),__vite__mapDeps([34,35,2,3,36,37,38,39,40]))),s=n,r=e,{closeManager:l,formatTurnTime:u,getProcessCardClass:m,getProcessStatus:k,getTurnAgentLabel:d,getDisplayTurnSummaryItems:T,getTurnSummaryDetail:v,getTurnSummaryStatus:h,handleCreateSession:p,handleDeleteSession:$,handleResetSession:ee,handleSelectSession:y,handleSend:B,handleTranscriptScroll:K,handleTranscriptTouchEnd:V,handleTranscriptTouchMove:N,handleTranscriptTouchStart:se,handleUpdateSession:I,helperText:X,loadTurnEvents:ge,loading:ye,managerBusy:D,openManager:ne,refreshSessionsForSelection:le,selectedSessionId:te,sending:ve,showProcessLogs:C,stopping:W,hasTurnSummary:P,hasNewerMessages:Ee,sessionError:Ie,shouldShowResponse:Be,showManager:Ye,sortedSessions:Je,stopSending:Ke,toggleProcessLogs:we,transcriptRef:H,turns:Z,workspaces:me,sessions:_e,loadSessions:fe,currentProjectAgentBindings:Le,scheduleScrollToBottom:he,scrollToBottom:Me}=im(r,s),je=j(null),De=j(!1),vt=j(""),Xe=j(""),St=j("");function et(){try{const f=JSON.parse(window.localStorage.getItem(Pr)||"{}");if(f&&typeof f=="object"&&!Array.isArray(f))return f}catch{}return{}}function mt(f){window.localStorage.setItem(Pr,JSON.stringify(f))}const ze=j("all");Pe(ze,f=>{const E=String(r.taskSlug||"").trim();if(!E)return;const M=et();M[E]=f,mt(M)});const{t:Ce}=Et(),{isDark:lt}=Gr(),dt=q(()=>lt.value?"dark":"light"),L=q(()=>{const f=new Set;return(Array.isArray(Le.value)?Le.value:[]).filter(E=>{const M=String((E==null?void 0:E.engine)||"").trim();return!M||f.has(M)?!1:(f.add(M),!0)})}),U=q(()=>L.value.length>1),oe=q(()=>{const f=String(ze.value||"").trim();return!U.value||f==="all"?Z.value:Z.value.filter(E=>Ma(E)===f)}),{selectionAction:Te,clearSelectionState:Re,handleSelectionMouseUp:$e}=wa({getContainer:()=>H.value,isActive:()=>!!(r.active&&Z.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:f=>[...f.querySelectorAll("[data-response-selection-root]")],getCodeLeft:f=>{var E,M;return((M=(E=f==null?void 0:f.getBoundingClientRect)==null?void 0:E.call(f))==null?void 0:M.left)||0},debounceMs:72});Pe([ze,()=>L.value.map(f=>f.engine).join(`
40
+ `)],()=>{ze.value!=="all"&&L.value.length&&(L.value.some(f=>f.engine===ze.value)||(ze.value="all"))},{immediate:!0}),Pe(ze,()=>{Re({clearBrowserSelection:!0}),he({force:!0})}),Pe(()=>r.taskSlug,(f,E)=>{if(!String(f||"").trim()||f===E)return;const ae=et()[f];ze.value=ae||"all"},{immediate:!0});function tt(f={}){const E=String((f==null?void 0:f.title)||"").trim();return E?[/^已连接项目:/,/^工作目录:/,/^项目会话已更新$/,/ 会话已创建$/,/^事件: claude\.system$/,/^线程 ID:/,/^Thread ID:/,/^Connected project:/,/^Working directory:/,/^Project session updated$/,/ session created$/,/^Event: claude\.system$/,/ 已返回结果$/,/ returned a result$/,/^本轮执行结束$/,/^Run finished$/].some(M=>M.test(E)):!1}function Ve(f={}){return Ce("sessionPanel.promptTitleWithAgent",{agent:d(f)})}function _t(f={}){return f.errorMessage?Ce("sessionPanel.errorSuffix",{agent:d(f)}):Ce("sessionPanel.responseSuffix",{agent:d(f)})}const{getTurnEventCount:yt,hasTurnEventHistory:xt,isTurnEventsCollapsed:We,toggleTurnEvents:Ht}=fm({turns:Z,loadTurnEvents:ge});function Qt(f){return String((f==null?void 0:f.runId)||(f==null?void 0:f.id)||"").trim()}function Yt(f){f!=null&&f.runId&&s("open-diff",{scope:"run",runId:f.runId})}function re(){s("open-diff",{scope:"workspace",runId:""})}const{getRenderedHtml:Oe}=Zf({items:Z,themeKey:dt,getCacheKey:Qt,getSource:f=>String((f==null?void 0:f.responseMessage)||""),shouldRender:f=>!!(f!=null&&f.responseMessage)&&!(f!=null&&f.errorMessage),renderAsync:f=>Oc(f,{isDark:lt.value,copyLabel:Ce("sessionPanel.copyCode"),copyAriaLabel:Ce("sessionPanel.copyCodeAria")}),renderFallback:f=>va(f),onRendered:f=>{const E=Z.value.at(-1)||null;!r.active||!(E!=null&&E.runId)||E.runId!==(f==null?void 0:f.runId)||he()}});function rt(f){St.value=String(f||"").trim()}async function nt(f){var M;if((M=navigator.clipboard)!=null&&M.writeText&&window.isSecureContext){await navigator.clipboard.writeText(f);return}const E=document.createElement("textarea");E.value=f,E.setAttribute("readonly","true"),E.style.position="fixed",E.style.opacity="0",E.style.pointerEvents="none",document.body.appendChild(E),E.select(),document.execCommand("copy"),document.body.removeChild(E)}function Bt(f={}){const M=(Array.isArray(f==null?void 0:f.promptBlocks)?f.promptBlocks:[]).filter(Ue=>(Ue==null?void 0:Ue.type)===Tt.TEXT||(Ue==null?void 0:Ue.type)===Tt.IMPORTED_TEXT||(Ue==null?void 0:Ue.type)===Tt.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(M.length)return M;const ae=String((f==null?void 0:f.prompt)||"").replace(/\u200b/g,"").trim();return ae?[{type:Tt.TEXT,content:ae,meta:{}}]:[]}function z(f={}){return Bt(f).length>0}function Q(f={}){const E=Bt(f);E.length&&s("insert-code-context",{source:"response",blocks:E})}async function ce(f){var At,qt,Sn,Nt,Vt;const E=(qt=(At=f==null?void 0:f.target)==null?void 0:At.closest)==null?void 0:qt.call(At,'[data-copy-code="1"]');if(!E)return!1;const M=E.closest(".codex-code-block"),ae=(Sn=M==null?void 0:M.querySelector)==null?void 0:Sn.call(M,"pre code"),Ue=String((ae==null?void 0:ae.textContent)||"").replace(/\u200b/g,"");if(!Ue)return!1;(Nt=f.preventDefault)==null||Nt.call(f),(Vt=f.stopPropagation)==null||Vt.call(f);try{return await nt(Ue),s("toast",{message:Ce("sessionPanel.codeCopied"),type:"success"}),!0}catch{return s("toast",{message:Ce("errors.requestFailed"),type:"warning"}),!0}}function Se(f=""){return String(f||"").trim().split(/[?#]/)[0].replace(/:(\d+)(?::\d+)?$/,"")}function qe(f=""){const E=String(f||"").trim();try{return decodeURI(E)}catch{return E}}function gt(f=""){return qe(f).replace(/\\/g,"/").replace(/\/+/g,"/").trim()}function Rt(f=""){const E=gt(f).replace(/^\.\//,"").split("/").filter(Boolean);return!E.length||E.some(M=>M==="."||M==="..")?"":E.join("/")}function jt(f=""){const E=String(f||"").trim();if(!E||E.startsWith("#")||E.startsWith("//"))return"";if(/^(?:https?:|mailto:|tel:|data:|blob:|javascript:)/i.test(E))try{const M=new URL(E);return M.origin!==window.location.origin?"":Se(M.pathname)}catch{return""}return Se(E)}function Pt(f=""){const E=_(),M=gt((E==null?void 0:E.cwd)||"").replace(/\/$/,""),ae=gt(jt(f));return!M||!ae?"":ae.startsWith("/")?ae===M||!ae.startsWith(`${M}/`)?"":Rt(ae.slice(M.length+1)):Rt(ae)}function Dt(f){var ae,Ue,At,qt;const E=(Ue=(ae=f==null?void 0:f.target)==null?void 0:ae.closest)==null?void 0:Ue.call(ae,".codex-markdown a[href]");if(!E)return!1;const M=Pt(E.getAttribute("href")||"");return M?((At=f.preventDefault)==null||At.call(f),(qt=f.stopPropagation)==null||qt.call(f),w(null,{searchQuery:M})||s("toast",{message:Ce("sourceBrowser.noProject"),type:"warning"}),!0):!1}function mn(f){Dt(f)||ce(f)}function Ct(){if(!Te.value.visible)return;const f=String(Te.value.content||"").replace(/\u200b/g,"").trim();if(!f){Re({clearBrowserSelection:!0});return}s("insert-code-context",{source:"response",content:f}),Re({clearBrowserSelection:!0})}function on(f={}){if(f!=null&&f.errorMessage)return;const E=String((f==null?void 0:f.responseMessage)||"").replace(/\u200b/g,"").trim();E&&s("insert-code-context",{source:"response",content:E})}const In=q(()=>Z.value.flatMap(f=>(Array.isArray(f==null?void 0:f.promptBlocks)?f.promptBlocks:[]).filter(E=>(E==null?void 0:E.type)==="image").map(E=>E.content)));function tn(f){const M=(Array.isArray(f==null?void 0:f.events)?f.events:[]).filter(ae=>!tt(ae));return vm(M)}function Jt(f){return yt(f)}function rn(f){return f!=null&&f.eventsLoaded?Jt(f)>0:xt(f)}function gn(f){return!!(f!=null&&f.eventsLoading)}function nn(f){return!!(f!=null&&f.eventsLoaded)&&tn(f).length>0&&!We(f)}function an(f){return!!(f!=null&&f.eventsLoaded)&&Jt(f)>0&&We(f)}function hn(f){return xt(f)&&!(f!=null&&f.eventsLoaded)&&!(f!=null&&f.eventsLoading)}function ln(f={}){return ia(f,{defaultLabel:Ce("sessionPanel.defaultAgent")})}function vn(f={}){return!Dp(f)}function yn(f={}){return"bg-[var(--theme-appPanelStrong)]"}function _(f=null){const E=String((f==null?void 0:f.id)||"").trim();if(E)return _e.value.find(ae=>ae.id===E)||null;const M=String(te.value||"").trim();return M?_e.value.find(ae=>ae.id===M)||null:Je.value[0]||null}function w(f=null,E={}){const M=_(f);return M!=null&&M.cwd?(vt.value=M.id,Xe.value=String(E.searchQuery||"").trim(),De.value=!0,!0):!1}function F(){return D.value?!1:(ne(),!0)}function ie(){var f,E;return De.value?(De.value=!1,!0):(E=(f=je.value)==null?void 0:f.closeTopDialog)!=null&&E.call(f)?!0:Ye.value?(l(),!0):!1}return t({closeTopDialog:ie,openProjectManager:F,openSourceBrowser:w,send:B,scrollToBottom:Me,stop:Ke}),(f,E)=>(g(),b("section",ym,[ue(Qf,{open:De.value,session:a(_e).find(M=>M.id===vt.value)||null,"initial-search-query":Xe.value,onInsertCodeContext:E[0]||(E[0]=M=>s("insert-code-context",M)),onClose:E[1]||(E[1]=M=>De.value=!1)},null,8,["open","session","initial-search-query"]),ue(a(o),{ref_key:"managerDialogRef",ref:je,open:a(Ye),sessions:a(_e),workspaces:a(me),"selected-session-id":a(te),"selection-locked":e.sessionSelectionLocked,"selection-lock-reason":e.sessionSelectionLockReason,loading:a(ye),sending:a(ve),"on-refresh":a(fe),"on-create":a(p),"on-update":a(I),"on-delete":a($),"on-reset":a(ee),onClose:a(l),onOpenSourceBrowser:E[2]||(E[2]=M=>w(M)),onProjectCreated:E[3]||(E[3]=M=>s("project-created",M)),onSelectSession:a(y)},null,8,["open","sessions","workspaces","selected-session-id","selection-locked","selection-lock-reason","loading","sending","on-refresh","on-create","on-update","on-delete","on-reset","onClose","onSelectSession"]),i("div",Sm,[i("div",wm,[i("div",xm,[i("div",{class:"min-w-0 flex-1",title:a(X)||""},[ue(wc,{modelValue:a(te),"onUpdate:modelValue":E[4]||(E[4]=M=>ei(te)?te.value=M:null),sessions:a(Je),loading:a(ye),disabled:a(ve)||a(D)||e.sessionSelectionLocked,onRefreshIntent:a(le)},null,8,["modelValue","sessions","loading","disabled","onRefreshIntent"])],8,bm),i("div",km,[i("button",{type:"button",class:be(["tool-button inline-flex h-9 w-9 items-center justify-center whitespace-nowrap px-0 py-0 text-xs",a(C)?"tool-button-accent-subtle":""]),"aria-pressed":a(C)?"true":"false","aria-label":a(C)?a(Ce)("sessionPanel.hideProcessToggle"):a(Ce)("sessionPanel.showProcessToggle"),title:a(C)?a(Ce)("sessionPanel.hideProcessToggle"):a(Ce)("sessionPanel.showProcessToggle"),onClick:E[5]||(E[5]=(...M)=>a(we)&&a(we)(...M))},[a(C)?(g(),Ae(a(li),{key:0,class:"h-4 w-4"})):(g(),Ae(a(ui),{key:1,class:"h-4 w-4"}))],10,Tm),e.diffSupported?(g(),b("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-1.5 whitespace-nowrap px-2.5 py-2 text-xs sm:gap-2 sm:px-3",disabled:!e.taskSlug,onClick:re},[ue(a(ur),{class:"h-4 w-4"}),E[17]||(E[17]=i("span",{class:"sm:hidden"},"代码",-1)),i("span",Cm,x(a(Ce)("sessionPanel.diff")),1)],8,_m)):de("",!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(D),onClick:E[6]||(E[6]=(...M)=>a(ne)&&a(ne)(...M))},[ue(a(ws),{class:"h-4 w-4"}),E[18]||(E[18]=i("span",{class:"sm:hidden"},"项目",-1)),i("span",Am,x(a(Ce)("sessionPanel.manageProjects")),1)],8,Em)])]),U.value?(g(),b("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:be(["theme-agent-selector-button",ze.value==="all"?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":ze.value==="all"?"true":"false",onClick:E[7]||(E[7]=M=>ze.value="all")},x(a(Ce)("sessionPanel.allAgents")),11,$m),(g(!0),b(it,null,pt(L.value,M=>(g(),b("button",{key:M.engine,type:"button",class:be(["theme-agent-selector-button",ze.value===M.engine?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":ze.value===M.engine?"true":"false",title:ln(M),onClick:ae=>ze.value=M.engine},x(ln(M)),11,Pm))),128))],8,Im)):de("",!0),a(Ie)?(g(),b("p",Dm,[ue(a(Wo),{class:"h-4 w-4"}),i("span",null,x(a(Ie)),1)])):de("",!0)])]),i("div",Lm,[i("div",{ref_key:"transcriptRef",ref:H,"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:E[9]||(E[9]=(...M)=>a(K)&&a(K)(...M)),onTouchstartPassive:E[10]||(E[10]=(...M)=>a(se)&&a(se)(...M)),onTouchmovePassive:E[11]||(E[11]=(...M)=>a(N)&&a(N)(...M)),onTouchendPassive:E[12]||(E[12]=(...M)=>a(V)&&a(V)(...M)),onTouchcancelPassive:E[13]||(E[13]=(...M)=>a(V)&&a(V)(...M))},[a(Z).length?oe.value.length?de("",!0):(g(),b("div",Bm,x(a(Ce)("sessionPanel.emptyAgentFilter")),1)):(g(),b("div",Mm,x(a(Ce)("sessionPanel.empty")),1)),(g(!0),b(it,null,pt(oe.value,M=>(g(),b("div",{key:M.id,"data-promptx-turn":"1","data-turn-id":M.id,"data-run-id":M.runId||"",class:"flex min-w-0 flex-col gap-3"},[i("div",Nm,[i("div",Om,[i("div",Fm,[i("span",Um,x(Ve(M)),1),i("div",jm,[z(M)?(g(),b("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:ae=>Q(M)},[ue(a(Ys),{class:"h-3 w-3"}),i("span",null,x(a(Ce)("sessionPanel.insert")),1)],8,Vm)):de("",!0),i("span",null,x(a(u)(M.startedAt)),1)])]),i("div",zm,[Array.isArray(M.promptBlocks)&&M.promptBlocks.length?(g(),b("div",Hm,[(g(!0),b(it,null,pt(M.promptBlocks,(ae,Ue)=>(g(),b(it,{key:`${M.id}-prompt-${Ue}`},[ae.type==="text"||ae.type==="imported_text"?(g(),b("pre",qm,x(ae.content),1)):(g(),b("button",{key:1,type:"button",class:"inline-flex cursor-zoom-in justify-center rounded-sm",onClick:At=>rt(ae.content)},[i("img",{src:ae.content,alt:a(Ce)("sessionPanel.promptImageAlt"),class:"max-h-52 w-auto max-w-full rounded-sm object-contain shadow-sm"},null,8,Wm)],8,Km))],64))),128))])):(g(),b("pre",Gm,x(M.prompt),1))])])]),a(C)&&vn(M)?(g(),b("div",Xm,[i("div",{class:be(["transcript-card transcript-card--process min-w-0 w-full rounded-sm px-4 py-3",a(m)(M)])},[i("div",Ym,[i("span",Jm,x(a(Ce)("sessionPanel.processTitle")),1),i("div",Qm,[rn(M)?(g(),b("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",disabled:M.eventsLoading,onClick:ae=>a(Ht)(M)},[gn(M)?(g(),Ae(a(Xt),{key:0,class:"h-3 w-3 animate-spin"})):a(We)(M)?(g(),Ae(a(Ko),{key:1,class:"h-3 w-3"})):(g(),Ae(a(ci),{key:2,class:"h-3 w-3"})),i("span",null,x(M.eventsLoading?a(Ce)("sessionPanel.loading"):a(We)(M)?`${a(Ce)("sessionPanel.expand")} (${Jt(M)})`:a(Ce)("sessionPanel.collapse")),1)],8,Zm)):de("",!0),i("span",null,x(a(k)(M)),1)])]),gn(M)?(g(),b("div",eg,x(a(Ce)("sessionPanel.loadingEvents")),1)):nn(M)?(g(),b("div",tg,[(g(!0),b(it,null,pt(tn(M),ae=>(g(),b("div",{key:ae.id,class:be(["transcript-event-card min-w-0 rounded-sm px-3 py-2",yn(ae)])},[i("div",ng,x(ae.title),1),ae.detail||Array.isArray(ae.detailBlocks)&&ae.detailBlocks.length?(g(),Ae(xd,{key:0,detail:ae.detail,blocks:ae.detailBlocks,kind:ae.kind,class:"mt-2"},null,8,["detail","blocks","kind"])):de("",!0)],2))),128))])):an(M)||hn(M)?(g(),b("div",sg,x(M.eventsLoaded?a(Ce)("sessionPanel.hiddenEventsLoaded",{count:Jt(M)}):a(Ce)("sessionPanel.hiddenEventsLoadLater",{count:Jt(M)})),1)):(g(),b("p",og,x(["queued","starting","running","stopping"].includes(M.status)?a(Ce)("sessionPanel.waitingEvents",{agent:a(d)(M)}):a(Ce)("sessionPanel.noEvents")),1)),a(P)(M)?(g(),b("div",rg,[a(h)(M)?(g(),b("div",ag,x(a(h)(M)),1)):de("",!0),a(v)(M)?(g(),b("div",ig,x(a(v)(M)),1)):de("",!0),a(T)(M).length?(g(),b("div",lg,[(g(!0),b(it,null,pt(a(T)(M),ae=>(g(),b("span",{key:ae.key,class:"transcript-card__pill inline-flex items-center gap-1 rounded-sm border border-dashed border-[var(--theme-borderDefault)] px-2 py-1"},[i("span",null,x(ae.label),1),i("span",ug,x(ae.value),1)]))),128))])):de("",!0)])):de("",!0)],2)])):de("",!0),a(Be)(M)?(g(),b("div",cg,[i("div",{class:be(["transcript-card transcript-card--response min-w-0 w-full rounded-sm px-4 py-3 text-sm leading-7",M.errorMessage?"bg-[var(--theme-dangerSoft)] text-[var(--theme-dangerText)]":"bg-[var(--theme-responseBg)] text-[var(--theme-responseText)]"])},[i("div",dg,[i("span",fg,x(_t(M)),1),i("div",pg,[e.diffSupported&&M.runId?(g(),b("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:ae=>Yt(M)},[ue(a(ur),{class:"h-3 w-3"}),i("span",null,x(a(Ce)("sessionPanel.view")),1)],8,mg)):de("",!0),M.responseMessage&&!M.errorMessage?(g(),b("button",{key:1,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:ae=>on(M)},[ue(a(Ys),{class:"h-3 w-3"}),i("span",null,x(a(Ce)("sessionPanel.insert")),1)],8,gg)):de("",!0),i("span",null,x(a(u)(M.finishedAt||M.startedAt)),1)])]),i("div",hg,[M.errorMessage?(g(),b("div",vg,x(M.errorMessage),1)):(g(),b("div",{key:1,class:"prose-like codex-markdown","data-response-selection-root":"1",onMouseup:E[8]||(E[8]=(...ae)=>a($e)&&a($e)(...ae)),onClick:mn,innerHTML:a(Oe)(M)},null,40,yg))])],2)])):de("",!0)],8,Rm))),128)),a(Te).visible?(g(),Ae(ya,{key:2,top:a(Te).top,left:a(Te).left,label:a(Ce)("sourceBrowser.insertSelection"),onClick:Ct},null,8,["top","left","label"])):de("",!0)],544),i("div",Sg,[a(Ee)?(g(),b("button",{key:0,type:"button",class:be([a(ve)?"mb-10 sm:mb-8":"","tool-button pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur"]),onClick:E[14]||(E[14]=(...M)=>a(Me)&&a(Me)(...M))},[ue(a(di),{class:"h-3.5 w-3.5"}),i("span",null,x(a(Ce)("sessionPanel.jumpToLatest")),1)],2)):de("",!0),a(ve)?(g(),b("button",{key:1,type:"button",class:"tool-button tool-button-warning-subtle pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur",disabled:a(W),onClick:E[15]||(E[15]=(...M)=>a(Ke)&&a(Ke)(...M))},[a(W)?(g(),Ae(a(Xt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),Ae(a(fi),{key:1,class:"h-3.5 w-3.5"})),i("span",null,x(a(W)?a(Ce)("sessionPanel.stopping"):a(Ce)("sessionPanel.stop")),1),a(W)?de("",!0):(g(),b("span",xg,[...E[19]||(E[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,wg)):de("",!0)])]),ue(la,{modelValue:St.value,"onUpdate:modelValue":E[16]||(E[16]=M=>St.value=M),images:In.value},null,8,["modelValue","images"])]))}},kg={key:0,class:"h-full min-h-0"},Tg={key:1,class:"panel theme-muted-text flex h-full items-center px-5 py-4 text-sm"},Dr={__name:"WorkbenchActivityPanel",props:{taskSlug:{type:String,default:""},buildPrompt:{type:Function,default:null},buildPromptBlocks:{type:Function,default:null},selectedSessionId:{type:String,default:""},selectedAgentEngine:{type:String,default:""},sessionSelectionLocked:{type:Boolean,default:!1},sessionSelectionLockReason:{type:String,default:""},diffSupported:{type:Boolean,default:!1},taskRunning:{type:Boolean,default:!1},emptyMessage:{type:String,default:""}},emits:["agent-bindings-change","insert-code-context","sending-change","project-created","selected-session-change","open-diff","toast","update:selectedAgentEngine"],setup(e,{expose:t,emit:n}){const o=n,s=j(null);function r(){var 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 k(){var T,v;return((v=(T=s.value)==null?void 0:T.openSourceBrowser)==null?void 0:v.call(T))||!1}function d(){var T,v;return((v=(T=s.value)==null?void 0:T.closeTopDialog)==null?void 0:v.call(T))||!1}return t({closeTopDialog:d,openProjectManager:m,openSourceBrowser:k,send:r,stop:l,scrollToBottom:u}),(T,v)=>e.taskSlug?(g(),b("div",kg,[ue(bg,{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]=h=>o("agent-bindings-change",h)),onInsertCodeContext:v[1]||(v[1]=h=>o("insert-code-context",h)),onProjectCreated:v[2]||(v[2]=h=>o("project-created",h)),onSendingChange:v[3]||(v[3]=h=>o("sending-change",h)),onSelectedSessionChange:v[4]||(v[4]=h=>o("selected-session-change",h)),"onUpdate:selectedAgentEngine":v[5]||(v[5]=h=>o("update:selectedAgentEngine",h)),onOpenDiff:v[6]||(v[6]=h=>o("open-diff",h)),onToast:v[7]||(v[7]=h=>o("toast",h))},null,8,["active","task-slug","build-prompt","build-prompt-blocks","selected-session-id","selected-agent-engine","session-selection-locked","session-selection-lock-reason","diff-supported","task-running"])])):e.emptyMessage?(g(),b("section",Tg,x(e.emptyMessage),1)):de("",!0)}},_g=["title"],Cg={class:"flex min-w-0 items-center gap-1.5"},Eg=["aria-pressed","title","data-agent-engine","onClick"],Lr={__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}=Et(),r=q(()=>{const d=new Set;return(Array.isArray(n.agentBindings)?n.agentBindings:[]).filter(T=>{const v=String((T==null?void 0:T.engine)||"").trim();return!v||d.has(v)?!1:(d.add(v),!0)})}),l=q(()=>r.value.length>1),u=q(()=>{var T,v;const d=String(n.selectedAgentEngine||"").trim();return r.value.some(h=>h.engine===d)?d:((T=r.value.find(h=>h.isDefault))==null?void 0:T.engine)||((v=r.value[0])==null?void 0:v.engine)||""}),m=q(()=>n.align==="end"?"sm:justify-end":n.align==="center"?"sm:justify-center":"sm:justify-start");function k(d={}){return ia(d,{prefix:"→ ",defaultLabel:s("sessionPanel.defaultAgent")})}return(d,T)=>l.value?(g(),b("div",{key:0,class:be(["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]=ot(()=>{},["stop"]))},[i("div",Cg,[(g(!0),b(it,null,pt(r.value,v=>(g(),b("button",{key:v.engine,type:"button",class:be(["theme-agent-selector-button",v.engine===u.value?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":v.engine===u.value,title:k(v),"data-agent-engine":v.engine,onMousedown:T[0]||(T[0]=ot(()=>{},["prevent"])),onClick:h=>o("update:selectedAgentEngine",v.engine)},x(k(v)),43,Eg))),128))])],42,_g)):de("",!0)}},Ag={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":""},Ig={class:"grid w-full grid-cols-5 gap-2 sm:flex sm:w-full sm:flex-wrap sm:justify-end sm:gap-2"},$g=["disabled","title","aria-label"],Pg={class:"sr-only sm:not-sr-only sm:inline"},Dg=["title","aria-label"],Lg={class:"sr-only sm:not-sr-only sm:inline"},Mg=["disabled","title","aria-label"],Bg={class:"sr-only sm:not-sr-only sm:inline"},Rg=["title","aria-label"],Ng={class:"sr-only sm:not-sr-only sm:inline"},Og={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"},Fg=["disabled","title","aria-label"],Ug={class:"sr-only sm:not-sr-only sm:inline"},Mr={__name:"WorkbenchEditorActions",props:{canAddTodo:{type:Boolean,default:!1},uploading:{type:Boolean,default:!1},isCurrentTaskSending:{type:Boolean,default:!1},sendState:{type:String,default:"idle"},todoCount:{type:Number,default:0}},emits:["add-todo","open-file-picker","clear-request","copy-request","manage-todo","send-request"],setup(e,{emit:t}){const n=e,o=t,{t:s}=Et(),r=q(()=>n.sendState==="sending"||n.sendState==="running");function l(){return n.todoCount>0?s("editor.todoWithCount",{count:n.todoCount}):s("editor.todo")}return(u,m)=>(g(),b("div",Ag,[i("div",Ig,[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]=ot(()=>{},["prevent"])),onClick:m[1]||(m[1]=k=>o("open-file-picker"))},[e.uploading?(g(),Ae(a(Xt),{key:0,class:"h-4 w-4 animate-spin"})):(g(),Ae(a(pi),{key:1,class:"h-4 w-4"})),i("span",Pg,x(a(s)("editor.chooseFiles")),1)],40,$g),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]=ot(()=>{},["prevent"])),onClick:m[3]||(m[3]=k=>o("clear-request"))},[ue(a(mi),{class:"h-4 w-4"}),i("span",Lg,x(a(s)("editor.clear")),1)],40,Dg),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]=ot(()=>{},["prevent"])),onClick:m[5]||(m[5]=k=>o("add-todo"))},[ue(a(Ys),{class:"h-4 w-4"}),i("span",Bg,x(a(s)("editor.todo")),1)],40,Mg),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]=ot(()=>{},["prevent"])),onClick:m[7]||(m[7]=k=>o("manage-todo"))},[ue(a(Zr),{class:"h-4 w-4"}),i("span",Ng,x(l()),1),e.todoCount>0?(g(),b("span",Og,x(e.todoCount>9?"9+":e.todoCount),1)):de("",!0)],40,Rg),i("button",{type:"button",class:"tool-button tool-button-primary inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:e.isCurrentTaskSending,title:a(s)("editor.send"),"aria-label":a(s)("editor.send"),"data-promptx-editor-action":"send",onMousedown:m[8]||(m[8]=ot(()=>{},["prevent"])),onClick:m[9]||(m[9]=k=>o("send-request"))},[r.value?(g(),Ae(a(Xt),{key:0,class:"h-4 w-4 animate-spin"})):(g(),Ae(a(gi),{key:1,class:"h-4 w-4"})),i("span",Ug,x(a(s)("editor.send")),1)],40,Fg)])]))}};function jg(e){const{props:t,panelRef:n,onClose:o}=e,s=j({left:"12px",top:"12px",width:"560px",maxHeight:"420px"}),r=j(!1),l=j("bottom");function u(){o==null||o()}function m(h=!1){const p=window.innerWidth,$=window.innerHeight,ee=12,y=8,B=320,K=560,V=420,N=180,se=Math.min(K,Math.max(B,p-ee*2)),I=Math.min(se,p-ee*2),X=t.anchorRect||{left:(p-I)/2,top:$/2,bottom:$/2};let ge=X.left;ge+I>p-ee&&(ge=p-ee-I),ge<ee&&(ge=ee);const ye=Math.max(0,$-ee-(X.bottom+y)),D=Math.max(0,X.top-y-ee);h?l.value=ye>=D?"bottom":"top":l.value==="bottom"&&ye<N&&D>ye+24?l.value="top":l.value==="top"&&D<N&&ye>D+24&&(l.value="bottom");const ne=l.value,le=ne==="bottom"?ye:D,te=Math.max(140,$-ee*2),ve=Math.min(te,Math.max(Math.min(V,le||V),N)),C={left:`${Math.round(ge)}px`,width:`${Math.round(I)}px`,maxHeight:`${Math.round(ve)}px`,top:"auto",bottom:"auto"};return ne==="bottom"?C.top=`${Math.round(Math.max(ee,X.bottom+y))}px`:C.bottom=`${Math.round(Math.max(ee,$-X.top+y))}px`,C}function k(h=!1){const p=m(h);s.value={...s.value,left:p.left,top:p.top,bottom:p.bottom,width:p.width,maxHeight:p.maxHeight}}function d(){return!t.open||!t.anchorRect?!1:(l.value="bottom",k(!0),r.value=!0,!0)}function T(){r.value=!1}function v(h){!t.open||!n.value||n.value.contains(h.target)||u()}return pn(()=>{document.addEventListener("pointerdown",v)}),Mt(()=>{document.removeEventListener("pointerdown",v)}),{closePicker:u,initializePanel:d,panelReady:r,panelStyle:s,resetPanel:T,updatePanelPosition:k}}function Vg(e){const{props:t,panelRef:n,onClose:o,onSelect:s}=e,{closePicker:r,initializePanel:l,panelReady:u,panelStyle:m,resetPanel:k,updatePanelPosition:d}=jg({props:t,panelRef:n,onClose:o}),T=xa({getMode:()=>String(t.query||"").trim()?"search":"tree",props:t,onSelect:s});return Pe(()=>t.open,v=>{if(!v){T.resetData(),k();return}k(),t.anchorRect&&l()&&T.initializeData()},{flush:"sync"}),Pe(()=>t.anchorRect,v=>{if(!(!t.open||!v)){if(!u.value){l()&&T.initializeData();return}d(!1)}},{flush:"sync"}),Pe(()=>t.sessionId,()=>{T.handleSessionChange()},{flush:"sync",immediate:!0}),Pe(()=>t.query,()=>{T.handleQueryChange()},{immediate:!0}),Pe(T.visibleItems,()=>{T.handleVisibleItemsChange()},{immediate:!0}),{...T,closePicker:r,panelReady:u,panelStyle:m}}const zg={class:"theme-divider flex items-center justify-end gap-2 border-b border-dashed px-2.5 py-2"},Hg={class:"flex shrink-0 items-center gap-2"},qg={class:"min-h-0 flex-1 overflow-y-auto p-2"},Kg={key:0,class:"theme-empty-state px-3 py-4 text-xs"},Wg={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},Gg={key:2,class:"theme-empty-state px-3 py-4 text-xs"},Xg={key:3,class:"theme-empty-state px-3 py-4 text-xs"},Yg={key:4,class:"theme-empty-state px-3 py-4 text-xs"},Jg={key:5,class:"space-y-1"},Qg={key:0,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},Zg=["onClick"],eh={class:"min-w-0 flex-1"},th=["innerHTML"],nh=["innerHTML"],sh={key:1,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},oh=["onClick"],rh={class:"min-w-0 flex-1"},ah=["innerHTML"],ih=["innerHTML"],lh={key:6,class:"space-y-1"},uh={class:"flex items-start gap-1.5"},ch=["onClick"],dh={key:1,class:"block h-5 w-5 shrink-0"},fh=["onClick"],ph={class:"min-w-0 flex-1"},mh={class:"flex items-center gap-1.5"},gh={__name:"PathMentionPicker",props:{open:{type:Boolean,default:!1},sessionId:{type:String,default:""},query:{type:String,default:""},anchorRect:{type:Object,default:null}},emits:["close","select"],setup(e,{expose:t,emit:n}){const o=e,s=n,r=j(null),{t:l}=Et(),{activeKey:u,closePicker:m,collapseActiveDirectory:k,confirmActive:d,currentError:T,currentLoading:v,emitSelect:h,expandActiveDirectory:p,getDisplayName:$,getHighlightedName:ee,getHighlightedPath:y,moveActive:B,normalSearchItems:K,normalizedQuery:V,panelReady:N,panelStyle:se,recentSearchItems:I,setItemRef:X,showSearchEmptyState:ge,showTreeEmptyState:ye,toggleDirectory:D,treeItems:ne,visibleItems:le}=Vg({props:o,panelRef:r,onClose:()=>s("close"),onSelect:te=>s("select",te)});return t({collapseActiveDirectory:k,moveActive:B,confirmActive:d,expandActiveDirectory:p}),(te,ve)=>(g(),Ae(_s,{to:"body"},[e.open&&a(N)?(g(),b("div",{key:0,ref_key:"panelRef",ref:r,class:"theme-popover fixed z-40 flex flex-col overflow-hidden rounded-sm border shadow-lg",style:An(a(se))},[i("div",zg,[i("div",Hg,[i("div",{class:be(["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:ve[0]||(ve[0]=(...C)=>a(m)&&a(m)(...C))},[ue(a(Yr),{class:"h-4 w-4"})])])]),i("div",qg,[e.sessionId?a(T)?(g(),b("div",Wg,x(a(T)),1)):a(ge)?(g(),b("div",Gg,x(a(l)("pathPicker.noResults")),1)):a(ye)?(g(),b("div",Xg,x(a(l)("pathPicker.emptyDirectory")),1)):a(v)&&!a(le).length?(g(),b("div",Yg,x(a(l)("pathPicker.loading")),1)):a(V)?(g(),b("div",Jg,[a(I).length?(g(),b("div",Qg,x(a(l)("pathPicker.recent")),1)):de("",!0),(g(!0),b(it,null,pt(a(I),C=>(g(),b("button",{key:C.path,ref_for:!0,ref:W=>a(X)(C.path,W),type:"button",class:be(["theme-list-row focus:outline-none",a(u)===C.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:W=>a(h)(C)},[(g(),Ae(En(C.type==="directory"?a(Gn):a(Rn)),{class:"theme-list-item-icon"})),i("div",eh,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(ee)(C)},null,8,th)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(y)(C)},null,8,nh)])],10,Zg))),128)),a(V)&&a(K).length?(g(),b("div",sh,x(a(l)("pathPicker.results")),1)):de("",!0),(g(!0),b(it,null,pt(a(K),C=>(g(),b("button",{key:C.path,ref_for:!0,ref:W=>a(X)(C.path,W),type:"button",class:be(["theme-list-row focus:outline-none",a(u)===C.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:W=>a(h)(C)},[(g(),Ae(En(C.type==="directory"?a(Gn):a(Rn)),{class:"theme-list-item-icon"})),i("div",rh,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(ee)(C)},null,8,ah)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(y)(C)},null,8,ih)])],10,oh))),128))])):(g(),b("div",lh,[(g(!0),b(it,null,pt(a(ne),C=>(g(),b("div",{key:C.path,ref_for:!0,ref:W=>a(X)(C.path,W),class:be(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(u)===C.path?"theme-list-item-active":C.type==="directory"&&C.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:An({paddingLeft:`${C.depth*16+6}px`})},[i("div",uh,[C.type==="directory"?(g(),b("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:ot(W=>a(D)(C.path),["stop"])},[C.loading?(g(),Ae(a(Xt),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),Ae(a(Qr),{key:1,class:be(["h-3.5 w-3.5 transition",C.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,ch)):(g(),b("span",dh)),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:W=>a(h)(C)},[(g(),Ae(En(C.type==="directory"?a(Gn):a(Rn)),{class:be(["h-4 w-4 shrink-0",C.type==="directory"&&C.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("div",ph,[i("div",mh,[i("span",{class:be(["theme-list-item-title truncate",C.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},x(a($)(C)),3)])])],8,fh)])],6))),128))])):(g(),b("div",Kg,x(a(l)("pathPicker.selectProjectFirst")),1))])],4)):de("",!0)]))}},hh={__name:"TiptapTextBlockView",props:Go,setup(e){return(t,n)=>(g(),Ae(a(Xo),{"data-promptx-node":"text"},{default:st(()=>[ue(a(na),{"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}))}},ja={__name:"TiptapSpecialBlockFrame",props:{frameClass:{type:String,default:""},headerPaddingClass:{type:String,default:"px-4 py-3"},headerClass:{type:String,default:""},selected:{type:Boolean,default:!1}},setup(e){const t=e,n=q(()=>t.selected?"ring-1 ring-inset ring-[var(--theme-borderStrong)]":""),o=q(()=>t.selected?"opacity-100":"opacity-100 sm:opacity-45 sm:group-hover:opacity-100 sm:focus-within:opacity-100");return(s,r)=>(g(),b("div",{class:be(["overflow-hidden rounded-sm transition",[e.frameClass,n.value]])},[i("div",{class:be(["theme-divider border-b text-xs",[e.headerPaddingClass,e.headerClass]])},[sn(s.$slots,"header",{actionsStateClass:o.value})],2),sn(s.$slots,"default")],2))}},$t={DOC:"doc",TEXT_BLOCK:"paragraph",IMPORTED_TEXT_BLOCK:"promptxImportedTextBlock",IMAGE_BLOCK:"promptxImageBlock",TEXT:"text",HARD_BREAK:"hardBreak"};function vh(){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 Jn(e={}){return{...e,clientId:String((e==null?void 0:e.clientId)||(e==null?void 0:e.id)||vh()),meta:e!=null&&e.meta?{...e.meta}:{}}}function Wn(e=""){return Jn({type:Tt.TEXT,content:e,meta:{}})}function Rs(e){return e&&e.type!==Tt.TEXT}function On(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];if(!t.length)return[Wn("")];const n=[];return t.forEach((o,s)=>{const r=Jn(o),l=n[n.length-1];!l&&Rs(r)&&n.push(Wn("")),l&&Rs(l)&&Rs(r)&&n.push(Wn("")),n.push(r),s===t.length-1&&Rs(r)&&n.push(Wn(""))}),n}function zo(e=""){const t=String(e||"").split(`
41
+ `),n=[];return t.forEach((o,s)=>{o&&n.push({type:$t.TEXT,text:o}),s<t.length-1&&n.push({type:$t.HARD_BREAK})}),n}function yh(e=""){return zo(e)}function Sh(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 eo(e=[]){return Sh(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===$t.TEXT?String(t.text||""):n===$t.HARD_BREAK?`
42
+ `:eo((t==null?void 0:t.content)||[])}).join("")}function wh(e=[]){return eo(e)}function xh(e={}){var n,o;const t=Jn(e);return t.type===Tt.IMAGE?{type:$t.IMAGE_BLOCK,attrs:{clientId:t.clientId,src:String(t.content||"")}}:t.type===Tt.IMPORTED_TEXT?{type:$t.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:zo(t.content)}:{type:$t.TEXT_BLOCK,attrs:{clientId:t.clientId},content:zo(t.content)}}function Va(e=[]){return On(e).map(xh)}function Ns(e=[]){return{type:$t.DOC,content:Va(e)}}function bh(e={}){var t,n,o,s,r,l;return(e==null?void 0:e.type)===$t.IMAGE_BLOCK?Jn({type:Tt.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)===$t.IMPORTED_TEXT_BLOCK?Jn({type:Tt.IMPORTED_TEXT,content:eo(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)===$t.TEXT_BLOCK?Jn({type:Tt.TEXT,content:eo(e.content||[]),clientId:String(((l=e.attrs)==null?void 0:l.clientId)||""),meta:{}}):null}function kh(e=null){const n=(Array.isArray(e==null?void 0:e.content)?e.content:[]).map(bh).filter(Boolean);return On(n)}function ps(e=[]){return JSON.stringify(On(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 Th(e=""){const t=String(e);return{lines:t?t.split(`
43
+ `).length:0,chars:t.length}}function Ks(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 _h={class:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-x-3 gap-y-1.5","data-promptx-imported-meta":""},Ch=["aria-expanded"],Eh={class:"theme-heading inline-flex items-center gap-1.5 text-xs font-medium leading-5"},Ah=["aria-expanded"],Ih={class:"mt-0.5 break-all text-[12px] leading-4 text-[var(--theme-textSecondary)]"},$h=["aria-label"],Ph={class:"max-h-[8.5rem] overflow-hidden whitespace-pre-wrap break-words leading-6"},Dh={key:0,class:"pointer-events-none absolute inset-x-0 bottom-0 h-10 bg-gradient-to-t from-[var(--theme-appPanelMuted)] to-transparent"},Lh={key:1,class:"theme-muted-text absolute bottom-2 right-4 bg-[var(--theme-appPanelMuted)] pl-2 text-xs"},Lo="tool-button inline-flex min-w-0 items-center justify-center gap-1 whitespace-nowrap px-2 py-1 text-[12px]",Mh={__name:"TiptapImportedTextBlockView",props:Go,setup(e){const t=e,{t:n}=Et(),o=q(()=>{var h;return wh(((h=t.node)==null?void 0:h.content)||[])}),s=q(()=>{var h,p;return String(((p=(h=t.node)==null?void 0:h.attrs)==null?void 0:p.fileName)||n("blockEditor.unnamedFile"))}),r=q(()=>{const h=Th(o.value);return n("blockEditor.stats",h)}),l=q(()=>n("blockEditor.fileSummary",{name:s.value,stats:r.value})),u=q(()=>{const h=String(o.value||"").replace(/\r\n/g,`
44
+ `),p=h.split(`
45
+ `),$=[];let ee=0;for(const K of p){const V=K.trimEnd(),N=V.length?V:"";if(!(!N&&$[$.length-1]==="")&&($.push(N),ee+=N.length,$.length>=4||ee>=220))break}const y=$.join(`
46
+ `).trim(),B=h.trim();return{text:y,truncated:$.length<p.length||y.length<B.length}}),m=`${Lo} tool-button-danger-subtle`;function k(h){h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),d())}function d(){var h,p,$;($=t.updateAttributes)==null||$.call(t,{collapsed:!((p=(h=t.node)==null?void 0:h.attrs)!=null&&p.collapsed)}),Ks(t.editor)}function T(){var y;const{editor:h,getPos:p,node:$}=t;if(!h||typeof p!="function"||!$)return;const ee=p();h.chain().focus().insertContentAt({from:ee,to:ee+$.nodeSize},{type:$t.TEXT_BLOCK,attrs:{clientId:String(((y=$.attrs)==null?void 0:y.clientId)||"")},content:yh(o.value)}).run(),Ks(t.editor)}function v(){var h;(h=t.deleteNode)==null||h.call(t),Ks(t.editor)}return(h,p)=>(g(),Ae(a(Xo),{class:"group relative","data-promptx-node":"imported_text"},{default:st(()=>[ue(ja,{selected:h.selected,"frame-class":"dashed-panel","header-class":"theme-secondary-text border-dashed","header-padding-class":"px-3 py-2"},{header:st(({actionsStateClass:$})=>{var ee,y,B,K;return[i("div",_h,[i("div",{class:"min-w-0 cursor-pointer",role:"button",tabindex:"0","aria-expanded":String(!((ee=h.node.attrs)!=null&&ee.collapsed)),onClick:d,onKeydown:k},[i("p",Eh,[ue(a(Js),{class:"h-3.5 w-3.5 shrink-0"}),Tn(" "+x(a(n)("blockEditor.file")),1)])],40,Ch),i("div",{"data-promptx-imported-actions":"",class:be(["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:be(Lo),contenteditable:"false",onClick:d},[ue(a(Ko),{class:be(["h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5",(y=h.node.attrs)!=null&&y.collapsed?"rotate-180":""])},null,8,["class"]),i("span",null,x((B=h.node.attrs)!=null&&B.collapsed?a(n)("blockEditor.expand"):a(n)("blockEditor.collapse")),1)]),i("button",{type:"button",class:be(Lo),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,x(a(n)("blockEditor.convertToText")),1)]),i("button",{type:"button",class:be(m),contenteditable:"false",onClick:v},[ue(a(ao),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,x(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=h.node.attrs)!=null&&K.collapsed)),onClick:d,onKeydown:k},[i("p",Ih,x(l.value),1)],40,Ah)])]}),default:st(()=>{var $,ee;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:d,onKeydown:k},[i("div",Ph,x(u.value.text||a(n)("blockEditor.emptyContent")),1),u.value.truncated?(g(),b("div",Dh)):de("",!0),u.value.truncated?(g(),b("span",Lh,"...")):de("",!0)],40,$h),[[Gs,($=h.node.attrs)==null?void 0:$.collapsed]]),Zt(ue(a(na),{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),[[Gs,!((ee=h.node.attrs)!=null&&ee.collapsed)]])]}),_:1},8,["selected"])]),_:1}))}},Bh={class:"flex min-w-0 items-center justify-between gap-3"},Rh={class:"theme-heading min-w-0 inline-flex items-center gap-1.5 text-xs font-medium leading-5"},Nh={class:"mx-auto flex w-full max-w-[720px] justify-center px-4 py-4"},Oh=["src","alt"],Fh="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]",Uh={__name:"TiptapImageBlockView",props:Go,setup(e){const t=e,{t:n}=Et();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),Ks(t.editor)}return(r,l)=>(g(),Ae(a(Xo),{class:"group","data-promptx-node":"image"},{default:st(()=>[ue(ja,{selected:r.selected,"frame-class":"theme-inline-panel border","header-class":"theme-muted-text","header-padding-class":"px-3 py-2"},{header:st(({actionsStateClass:u})=>[i("div",Bh,[i("div",Rh,[ue(a(ea),{class:"h-3.5 w-3.5 shrink-0"}),Tn(" "+x(a(n)("blockEditor.image")),1)]),i("div",{class:be(["shrink-0 transition",u])},[i("button",{type:"button",class:be(Fh),contenteditable:"false",onClick:s},[ue(a(ao),{class:"h-3 w-3 shrink-0 sm:h-3.5 sm:w-3.5"}),i("span",null,x(a(n)("blockEditor.delete")),1)])],2)])]),default:st(()=>{var u;return[i("div",Nh,[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,Oh)])])]}),_:1},8,["selected"])]),_:1}))}},jh=["accept"],Br=10*1024*1024,Rr=2*1024*1024,Nr=8*1024*1024,Vh=1500,zh={__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}=Et(),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(","),k=j(null),d=j(null),T=j(""),v=j(je()),h=j(null),p=j(null),$=j(!1),ee=j(0),y=q(()=>On(o.modelValue)),B=q(()=>y.value.filter(L=>(L==null?void 0:L.type)===Tt.IMAGE&&String(L.content||"").trim()).map(L=>String(L.content||"").trim()));let K=ps(y.value);function V(L=X.value){if(!L)return!1;const U=kh(L.getJSON()),oe=ps(U);return oe===K?!1:(K=oe,s("update:modelValue",U),!0)}const N=_i.extend({name:$t.TEXT_BLOCK,group:"block",content:"inline*",addAttributes(){return{clientId:{default:""}}},addNodeView(){return So(hh)}}),se=cr.create({name:$t.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:L}){return["div",{...L,"data-type":"promptx-imported-text-block"}]},addNodeView(){return So(Mh)}}),I=cr.create({name:$t.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:L}){return["div",{...L,"data-type":"promptx-image-block"}]},addNodeView(){return So(Uh)}}),X=Ci({extensions:[Ei.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}),N,se,I],autofocus:!1,editorProps:{attributes:{class:"tiptap-editor min-h-full outline-none"},handleKeyDown(L,U){return Ja(U,{sendBehavior:o.sendBehavior,isEditing:!0,isComposing:fe()})?(U.preventDefault(),U.stopPropagation(),s("send-request"),!0):!U.shiftKey&&!U.altKey&&(U.metaKey||U.ctrlKey)&&String(U.key||"").toLowerCase()==="k"?Ce():dt(U)}},content:Ns(y.value),onCreate({editor:L}){ze(L)},onFocus({editor:L}){$.value=!0,ze(L)},onBlur(){$.value=!1},onSelectionUpdate({editor:L}){ze(L)},onUpdate({editor:L}){ee.value=Date.now(),V(L),ze(L)}});Pe(X,L=>{if(!L)return;const U=On(o.modelValue);K=ps(U),L.commands.setContent(Ns(U),!1)},{immediate:!0}),Pe(()=>o.modelValue,L=>{const U=X.value;if(!U){K=ps(On(L));return}const oe=On(L),Te=ps(oe);Te!==K&&(K=Te,U.commands.setContent(Ns(oe),!1))},{deep:!0});function ge(L){const U=String(L||"").trim();U&&s("file-feedback",U)}function ye(L){const U=String((L==null?void 0:L.name)||"").trim().toLowerCase();return U.includes(".")?`.${U.split(".").pop()}`:""}function D(L,U){return String((L==null?void 0:L.name)||"").trim()||r(U)}function ne(L){const U=Math.max(0,Number(L)||0);return U>=1024*1024?`${(U/(1024*1024)).toFixed(U>=10*1024*1024?0:1)} MB`:U>=1024?`${Math.round(U/1024)} KB`:`${U} B`}function le(L){if(!L)return!1;const U=String(L.type||"").toLowerCase(),oe=ye(L);return U.startsWith("text/")||l.has(oe)||u.has(U)}function te(L){if(!L)return!1;const U=String(L.name||"").toLowerCase(),oe=String(L.type||"").toLowerCase();return U.endsWith(".pdf")||oe==="application/pdf"}function ve(L){const U=Array.from(L||[]).filter(Boolean),oe={imageFiles:[],textFiles:[],pdfFiles:[]},Te=[],Re=[];return U.forEach($e=>{if($e.type.startsWith("image/")){if($e.size>Br){Re.push({name:D($e,"blockEditor.unnamedImage"),limit:ne(Br)});return}oe.imageFiles.push($e);return}if(te($e)){if($e.size>Nr){Re.push({name:D($e,"blockEditor.unnamedPdf"),limit:ne(Nr)});return}oe.pdfFiles.push($e);return}if(le($e)){if($e.size>Rr){Re.push({name:D($e,"blockEditor.unnamedFile"),limit:ne(Rr)});return}oe.textFiles.push($e);return}Te.push(D($e,"blockEditor.unnamedFile"))}),{...oe,unsupportedFiles:Te,oversizedFiles:Re}}function C({unsupportedFiles:L=[],oversizedFiles:U=[]}={}){var oe;L.length&&ge(r("blockEditor.unsupportedFiles",{names:L.slice(0,3).join("、"),extra:Math.max(0,L.length-3)})),U.length&&ge(r("blockEditor.oversizedFiles",{names:U.slice(0,2).map(Te=>Te.name).join("、"),extra:Math.max(0,U.length-2),limit:((oe=U[0])==null?void 0:oe.limit)||""}))}function W(L){const{imageFiles:U,textFiles:oe,pdfFiles:Te,unsupportedFiles:Re,oversizedFiles:$e}=ve(L);return C({unsupportedFiles:Re,oversizedFiles:$e}),oe.length&&s("import-text-files",oe),Te.length&&s("import-pdf-files",Te),U.length&&s("upload-files",U),U.length+oe.length+Te.length>0}function P(L){const U=[...L.clipboardData.items].filter(oe=>oe.kind==="file").map(oe=>oe.getAsFile()).filter(Boolean);U.length&&(L.preventDefault(),W(U))}function Ee(L){L.preventDefault(),W(L.dataTransfer.files)}function Ie(L){const U=X.value;if(!U)return;const oe=L.target instanceof Element?L.target:null,Te=L.currentTarget instanceof Element?L.currentTarget:null,Re=U.view.dom instanceof Element?U.view.dom:null;!oe||!Te||!Re||oe.closest('button, input, textarea, select, a, [contenteditable="false"]')||!Te.contains(oe)||oe.closest("[data-promptx-node]")||!(oe===Te||oe===Re||Te.contains(oe))||(L.preventDefault(),Je())}function Be(L){W(L.target.files),L.target.value=""}function Ye(){var L;(L=k.value)==null||L.click()}function Je(){const L=X.value;L&&L.chain().focus("end").run()}function Ke(){var oe,Te;const L=X.value;if(!L)return!1;(Te=(oe=L.view.domObserver)==null?void 0:oe.flush)==null||Te.call(oe);const U=V(L);return U&&(ee.value=Date.now()),ze(L),U}function we(L=[]){const U=X.value;!U||!L.length||U.chain().focus().insertContent(L).run()}function H(L=[]){we(Va(L))}function Z(L=[]){H(L)}function me(L=[]){H(L)}function _e(){const L=X.value;L&&L.commands.setContent(Ns([Wn("")]),!0)}function fe(){var L,U;return!!((U=(L=X.value)==null?void 0:L.view)!=null&&U.composing)}function Le(){var L;return fe()||$.value||(L=X.value)!=null&&L.isFocused?!0:Date.now()-ee.value<Vh}function he(){var Te;const L=X.value;if(!L)return!1;const U=L.state.selection,oe=U.$from.nodeAfter||U.$from.parent;return((Te=oe==null?void 0:oe.type)==null?void 0:Te.name)===$t.IMPORTED_TEXT_BLOCK}function Me(L){var oe;const U=String(((oe=L==null?void 0:L.detail)==null?void 0:oe.src)||"").trim();U&&(T.value=U)}function je(){return{open:!1,start:-1,end:-1,query:"",trigger:"mention",blockType:"",clientId:""}}function De(L=null,U=null){return!L||!U?!1:L.start===U.start&&L.end===U.end&&L.query===U.query&&L.clientId===U.clientId}function vt(){h.value=null}function Xe(L={}){const{suppressCurrent:U=!1}=L,oe=v.value;U&&oe.open&&(p.value={start:oe.start,end:oe.end,query:oe.query,clientId:oe.clientId}),v.value=je(),vt()}function St(){Xe({suppressCurrent:!0})}function et(L=X.value){var tt,Ve,_t;if(!L)return null;const U=L.state.selection;if(!U.empty)return null;const{$from:oe,from:Te}=U,Re=((Ve=(tt=oe.parent)==null?void 0:tt.type)==null?void 0:Ve.name)||"";if(![$t.TEXT_BLOCK,$t.IMPORTED_TEXT_BLOCK].includes(Re))return null;const $e=oe.parent.textBetween(0,oe.parentOffset,`
47
+ `,"\0");return{from:Te,node:oe.parent,nodeTypeName:Re,nodeStart:oe.start(),parentOffset:oe.parentOffset,clientId:String(((_t=oe.parent.attrs)==null?void 0:_t.clientId)||""),textBefore:$e}}function mt(L=v.value.end){const U=X.value;if(typeof L=="object"&&L!==null&&(L=v.value.end),!U||!v.value.open||L<0){vt();return}try{const oe=U.view.coordsAtPos(L);h.value={left:oe.left,right:oe.left,top:oe.bottom,bottom:oe.bottom,width:0,height:0}}catch{vt()}}function ze(L=X.value){const U=et(L),oe=v.value;if(oe.open&&oe.trigger==="shortcut"){if(!U||U.clientId!==oe.clientId||U.from<oe.start){Xe();return}const Ve=L.state.doc.textBetween(oe.start,U.from,`
48
+ `,"\0");if(/\s/.test(Ve)){Xe();return}p.value=null,v.value={...oe,end:U.from,query:Ve},mt(U.from);return}if(!U){Xe();return}const Te=U.textBefore.lastIndexOf("@");if(Te<0){Xe();return}const Re=U.textBefore.slice(Te+1);if(/\s/.test(Re)){Xe();return}const $e=U.nodeStart+Te,tt=U.from;De(p.value,{start:$e,end:tt,query:Re,clientId:U.clientId})||(p.value=null,v.value={open:!0,start:$e,end:tt,query:Re,trigger:"mention",blockType:U.nodeTypeName,clientId:U.clientId},mt(tt))}function Ce(){const L=X.value,U=et(L);return!L||!U?!1:(p.value=null,v.value={open:!0,start:U.from,end:U.from,query:"",trigger:"shortcut",blockType:U.nodeTypeName,clientId:U.clientId},mt(U.from),!0)}function lt(L){const U=X.value,oe=String((L==null?void 0:L.path)||"").trim(),Te=v.value;if(!U||!oe||Te.start<0||Te.end<Te.start)return Xe(),!1;const Re=Te.trigger==="shortcut"?`${oe} `:`@${oe} `,$e=Te.start+Re.length;return U.chain().focus().command(({tr:tt,dispatch:Ve})=>(tt.insertText(Re,Te.start,Te.end),tt.setSelection(ti.create(tt.doc,$e)),Ve==null||Ve(tt),!0)).run(),ee.value=Date.now(),p.value=null,Xe(),!0}function dt(L){var U,oe,Te,Re,$e,tt,Ve,_t,yt,xt;if(!v.value.open)return!1;if(L.key==="Escape")return St(),!0;if(L.key==="ArrowDown")return!!((oe=(U=d.value)==null?void 0:U.moveActive)!=null&&oe.call(U,1));if(L.key==="ArrowUp")return!!((Re=(Te=d.value)==null?void 0:Te.moveActive)!=null&&Re.call(Te,-1));if(v.value.query&&(L.key==="ArrowLeft"||L.key==="ArrowRight"))return!1;if(L.key==="ArrowRight"){const We=(tt=($e=d.value)==null?void 0:$e.expandActiveDirectory)==null?void 0:tt.call($e);return We&&typeof We.then=="function"?(We.catch(()=>{}),!0):!!We}return L.key==="ArrowLeft"?!!((_t=(Ve=d.value)==null?void 0:Ve.collapseActiveDirectory)!=null&&_t.call(Ve)):!L.shiftKey&&!L.altKey&&!L.metaKey&&!L.ctrlKey&&L.key==="Enter"?!!((xt=(yt=d.value)==null?void 0:yt.confirmActive)!=null&&xt.call(yt)):!1}return pn(()=>{window.addEventListener("promptx:tiptap-image-preview",Me),window.addEventListener("resize",mt),window.addEventListener("scroll",mt)}),Mt(()=>{window.removeEventListener("promptx:tiptap-image-preview",Me),window.removeEventListener("resize",mt),window.removeEventListener("scroll",mt)}),Pe(()=>o.codexSessionId,()=>{Xe()}),t({clearContent:_e,flushPendingInput:Ke,focusEditor:Je,insertBlocks:H,insertImportedBlocks:Z,insertUploadedBlocks:me,isComposing:fe,isEditing:Le,isImportedBlockActive:he,openFilePicker:Ye}),(L,U)=>(g(),b("section",{class:"workbench-input-editor relative flex h-full min-h-0 flex-col overflow-hidden","data-promptx-editor":"tiptap",onDrop:Ee,onDragover:U[1]||(U[1]=ot(()=>{},["prevent"])),onPaste:P},[i("input",{ref_key:"fileInputRef",ref:k,class:"hidden",type:"file",accept:a(m),multiple:"",onChange:Be},null,40,jh),i("div",{class:"flex-1 overflow-y-auto px-5 py-5","data-promptx-editor-scroll":"tiptap",onMousedown:Ie},[a(X)?(g(),Ae(a(Ai),{key:0,editor:a(X),class:"min-h-full","data-promptx-editor-content":"tiptap"},null,8,["editor"])):de("",!0)],32),ue(la,{modelValue:T.value,"onUpdate:modelValue":U[0]||(U[0]=oe=>T.value=oe),images:B.value},null,8,["modelValue","images"]),ue(gh,{ref_key:"mentionPickerRef",ref:d,open:v.value.open&&!!h.value,"session-id":e.codexSessionId,query:v.value.query,"anchor-rect":h.value,onClose:St,onSelect:lt},null,8,["open","session-id","query","anchor-rect"])],32))}},Hh={key:0,class:"theme-muted-text flex h-full items-center px-5 py-4 text-sm"},Or={__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=j(null),{t:l}=Et(),u=q({get:()=>o.modelValue,set:y=>s("update:modelValue",y)});function m(){var y,B;(B=(y=r.value)==null?void 0:y.openFilePicker)==null||B.call(y)}function k(){var y,B;(B=(y=r.value)==null?void 0:y.focusEditor)==null||B.call(y)}function d(){var y,B;return((B=(y=r.value)==null?void 0:y.flushPendingInput)==null?void 0:B.call(y))||!1}function T(y){var B,K;(K=(B=r.value)==null?void 0:B.insertBlocks)==null||K.call(B,y)}function v(y){var B,K;(K=(B=r.value)==null?void 0:B.insertImportedBlocks)==null||K.call(B,y)}function h(y){var B,K;(K=(B=r.value)==null?void 0:B.insertUploadedBlocks)==null||K.call(B,y)}function p(){var y,B;return((B=(y=r.value)==null?void 0:y.isImportedBlockActive)==null?void 0:B.call(y))||!1}function $(){var y,B;return((B=(y=r.value)==null?void 0:y.isComposing)==null?void 0:B.call(y))||!1}function ee(){var y,B;return((B=(y=r.value)==null?void 0:y.isEditing)==null?void 0:B.call(y))||!1}return t({focusEditor:k,flushPendingInput:d,insertBlocks:T,insertImportedBlocks:v,insertUploadedBlocks:h,isComposing:$,isEditing:ee,isImportedBlockActive:p,openFilePicker:m}),(y,B)=>e.loading&&!e.modelValue.length?(g(),b("section",Hh,x(a(l)("workbench.loadingTaskContent")),1)):(g(),Ae(zh,{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"]))}},qh={class:"panel workbench-mobile-header-panel shrink-0 overflow-hidden"},Kh={class:"workbench-panel-header workbench-mobile-header theme-divider border-b px-2.5 py-2"},Wh={class:"flex items-center gap-2"},Gh=["title","aria-label"],Xh={class:"min-w-0 flex-1"},Yh=["value","placeholder"],Jh=["disabled"],Qh={class:"truncate"},Zh={__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}=Et();return(s,r)=>(g(),b("section",qh,[i("div",Kh,[i("div",Wh,[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(hi),{class:"h-3.5 w-3.5"})],8,Gh),i("div",Xh,[e.currentTaskSlug&&e.editingTaskTitleSlug===e.currentTaskSlug?(g(),b("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(ot(l=>l.target.blur(),["prevent"]),["enter"])),r[3]||(r[3]=en(ot(l=>n("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:r[4]||(r[4]=l=>n("title-blur"))},null,40,Yh)):(g(),b("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",Qh,x(e.title||a(o)("workbench.untitledTask")),1),ue(a(ws),{class:"h-2.5 w-2.5 shrink-0 opacity-50"})],8,Jh))])])])]))}},ev={class:"workbench-sidebar-panel panel flex h-full min-h-0 flex-col overflow-hidden"},tv={class:"workbench-panel-header theme-divider border-b px-4 py-4"},nv={class:"flex items-center justify-between gap-3"},sv={class:"flex min-h-8 items-center"},ov={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},rv=["title"],av=["disabled","title"],iv={class:"whitespace-nowrap"},lv={class:"min-h-0 flex-1 overflow-y-auto px-3 py-3"},uv={key:0,class:"theme-empty-state px-3 py-4 text-sm"},cv=["onClick"],dv={key:0,class:"theme-selection-indicator absolute inset-y-2 left-0 w-1 rounded-full"},fv={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"},pv={class:"flex items-start justify-between gap-3"},mv={class:"flex min-w-0 flex-1 items-start gap-2 overflow-hidden"},gv=["title","aria-label"],hv={class:"flex h-5 min-w-0 flex-1 items-center"},vv=["value","placeholder"],yv=["title","onClick"],Sv={class:"min-w-0 truncate"},wv={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},xv={class:"workbench-task-card__preview mt-2 truncate text-xs opacity-80"},bv={class:"mt-2 flex items-center justify-between gap-3"},kv={class:"min-w-0 text-[11px] opacity-70"},Tv={class:"flex shrink-0 items-center gap-1.5 text-[10px] uppercase tracking-[0.18em] opacity-80"},_v={class:"theme-divider border-t px-3 py-3"},Cv={key:0,class:"theme-danger-text mb-3 inline-flex min-w-0 items-start gap-2 text-xs"},Ev={class:"min-w-0 break-words"},Av={class:"grid grid-cols-2 gap-2"},Iv=["disabled","title"],$v={class:"whitespace-nowrap"},Pv=["disabled","title"],Dv={class:"whitespace-nowrap"},Lv={__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}=Et(),r=j([]);Pe(()=>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 h=new Date(v.updatedAt);return Number.isNaN(h.getTime())?"":Kr(h.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function k(v){var h,p;return!!((h=v==null?void 0:v.workspaceDiffSummary)!=null&&h.supported&&((p=v==null?void 0:v.workspaceDiffSummary)!=null&&p.fileCount))}function d(v){return v.slug===n.currentTaskSlug?"theme-badge-strong":"theme-badge-muted"}function T(v){if(n.mobile)return;const h=Number(v==null?void 0:v.oldIndex),p=Number(v==null?void 0:v.newIndex);!Number.isInteger(h)||!Number.isInteger(p)||h===p||o("reorder-task",r.value.map($=>String(($==null?void 0:$.slug)||"").trim()).filter(Boolean))}return(v,h)=>(g(),b("aside",ev,[i("div",tv,[i("div",nv,[i("div",sv,[i("div",ov,[ue(a(vi),{class:"h-4 w-4"}),i("span",null,x(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:h[0]||(h[0]=p=>o("open-settings"))},[ue(a(yi),{class:"h-4 w-4"}),i("span",{class:be(e.mobile?"whitespace-nowrap":"hidden whitespace-nowrap sm:inline")},x(a(s)("workbench.settings")),3)],8,rv)]),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:h[1]||(h[1]=p=>o("create-task"))},[ue(a(Ys),{class:"h-4 w-4"}),i("span",iv,x(e.creatingTask?a(s)("workbench.creatingTask"):a(s)("workbench.createTask")),1)],8,av)]),i("div",lv,[e.loadingTasks&&!e.tasks.length?(g(),b("div",uv,x(a(s)("workbench.loadingTasks")),1)):(g(),Ae(a(Si),{key:1,modelValue:r.value,"onUpdate:modelValue":h[8]||(h[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:st(()=>[(g(!0),b(it,null,pt(r.value,p=>{var $,ee;return g(),b("article",{key:p.slug,class:be(["workbench-task-card group relative cursor-default rounded-sm border px-3 py-3 transition",l(p)]),onClick:y=>o("select-task",p.slug)},[p.slug===e.currentTaskSlug?(g(),b("span",dv)):de("",!0),p.hasUnreadUpdate?(g(),b("span",fv)):de("",!0),i("div",pv,[i("div",mv,[e.mobile?de("",!0):(g(),b("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:h[2]||(h[2]=ot(()=>{},["stop"]))},[ue(a(wi),{class:"h-3.5 w-3.5"})],8,gv)),i("div",hv,[p.slug===e.currentTaskSlug&&e.editingTaskTitleSlug===p.slug?(g(),b("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:h[3]||(h[3]=ot(()=>{},["stop"])),onInput:h[4]||(h[4]=y=>o("update:draftTitle",y.target.value)),onKeydown:[h[5]||(h[5]=en(ot(y=>y.target.blur(),["prevent"]),["enter"])),h[6]||(h[6]=en(ot(y=>o("cancel-title-edit"),["prevent"]),["esc"]))],onBlur:h[7]||(h[7]=y=>o("title-blur"))},null,40,vv)):(g(),b("button",{key:1,type:"button",class:be(["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:ot(y=>o("title-click",p.slug),["stop"])},[($=p.automation)!=null&&$.enabled?(g(),Ae(a(Xs),{key:0,class:"h-3.5 w-3.5 shrink-0 opacity-70"})):de("",!0),i("span",Sv,x(p.displayTitle),1)],10,yv))])]),i("div",wv,[p.sending?(g(),b("span",{key:0,class:be(["inline-flex items-center gap-1.5 rounded-sm border border-dashed px-1.5 py-0.5",u()])},[h[11]||(h[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,x(a(s)("workbench.running")),1)],2)):de("",!0)])]),i("div",xv,x(p.lastPromptPreview||a(s)("workbench.noMessagesYet")),1),i("div",bv,[i("div",kv,x(m(p)),1),i("div",Tv,[k(p)?(g(),b("span",{key:0,class:be(["inline-flex items-center gap-1 rounded-sm border border-dashed px-1.5 py-0.5",d(p)])},[i("span",null,x(a(s)("workbench.filesCount",{count:((ee=p.workspaceDiffSummary)==null?void 0:ee.fileCount)||0})),1)],2)):de("",!0)])])],10,cv)}),128))]),_:1},8,["modelValue","disabled"]))]),i("div",_v,[e.error?(g(),b("div",Cv,[ue(a(Wo),{class:"mt-0.5 h-4 w-4 shrink-0"}),i("span",Ev,x(e.error),1)])):de("",!0),i("div",Av,[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:h[9]||(h[9]=p=>o("edit-task"))},[ue(a(ws),{class:"h-4 w-4"}),i("span",$v,x(a(s)("workbench.editTask")),1)],8,Iv),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:h[10]||(h[10]=p=>o("delete-task"))},[ue(a(ao),{class:"h-4 w-4"}),i("span",Dv,x(e.removingTask?a(s)("workbench.deletingTask"):a(s)("workbench.deleteTask")),1)],8,Pv)])])]))}},Fr=Wr(Lv,[["__scopeId","data-v-200c2c76"]]),Mv={class:"min-w-0"},Bv={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},Rv={class:"theme-muted-text mt-1 text-xs leading-5"},Nv={class:"theme-divider flex items-center justify-between gap-3 border-b border-dashed px-5 py-3 text-xs"},Ov={class:"theme-muted-text"},Fv={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-2 py-1"},Uv={key:0,class:"min-h-0 flex-1 overflow-y-auto px-5 py-4"},jv={class:"space-y-3"},Vv={class:"flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between"},zv={class:"min-w-0 flex-1"},Hv={class:"theme-heading flex flex-wrap items-center gap-2 text-sm font-medium"},qv={class:"theme-status-neutral inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-0.5 text-[11px]"},Kv={class:"mt-2 whitespace-pre-wrap break-words text-sm leading-6"},Wv={class:"theme-muted-text mt-3 flex flex-wrap items-center gap-2 text-[11px]"},Gv={class:"rounded-sm border border-dashed px-2 py-1"},Xv={key:0,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},Yv={key:1,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},Jv={key:2,class:"inline-flex items-center gap-1 rounded-sm border border-dashed px-2 py-1"},Qv={class:"flex w-full items-center gap-2 sm:w-auto sm:shrink-0"},Zv=["onClick"],ey=["onClick"],ty={key:1,class:"theme-empty-state flex min-h-0 flex-1 items-center justify-center px-6 py-10 text-sm"},ny={__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}=Et(),r=q(()=>(n.items||[]).map(u=>{var p;const m=Array.isArray(u==null?void 0:u.blocks)?u.blocks:[],k=((p=m.find($=>["text","imported_text"].includes(String(($==null?void 0:$.type)||""))&&String(($==null?void 0:$.content)||"").trim()))==null?void 0:p.content)||"",d=String(k||"").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,h=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:d||(T?s("todoDialog.imagePreview",{count:T}):s("todoDialog.noPreview")),textCount:h,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)=>(g(),Ae(io,{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]=k=>o("close"))},{title:st(()=>[i("div",Mv,[i("div",Bv,[ue(a(Zr),{class:"h-4 w-4"}),i("span",null,x(a(s)("todoDialog.title")),1)]),i("p",Rv,x(a(s)("todoDialog.intro")),1)])]),default:st(()=>[i("div",Nv,[i("span",Ov,x(a(s)("todoDialog.summary",{count:r.value.length})),1),i("span",Fv,x(a(s)("todoDialog.summaryHint")),1)]),r.value.length?(g(),b("div",Uv,[i("div",jv,[(g(!0),b(it,null,pt(r.value,k=>(g(),b("article",{key:k.id,class:"theme-card-idle-muted rounded-sm border border-dashed p-4"},[i("div",Vv,[i("div",zv,[i("div",Hv,[i("span",null,x(a(s)("todoDialog.itemTitle")),1),i("span",qv,[ue(a(Xs),{class:"h-3.5 w-3.5"}),Tn(" "+x(k.timeLabel),1)])]),i("p",Kv,x(k.preview),1),i("div",Wv,[i("span",Gv,x(a(s)("todoDialog.blockCount",{count:k.blockCount})),1),k.textCount?(g(),b("span",Xv,[ue(a(Js),{class:"h-3.5 w-3.5"}),Tn(" "+x(a(s)("todoDialog.textCount",{count:k.textCount})),1)])):de("",!0),k.importedCount?(g(),b("span",Yv,[ue(a(Js),{class:"h-3.5 w-3.5"}),Tn(" "+x(a(s)("todoDialog.importedCount",{count:k.importedCount})),1)])):de("",!0),k.imageCount?(g(),b("span",Jv,[ue(a(ea),{class:"h-3.5 w-3.5"}),Tn(" "+x(a(s)("todoDialog.imageCount",{count:k.imageCount})),1)])):de("",!0)])]),i("div",Qv,[i("button",{type:"button",class:"tool-button inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:d=>o("use",k.id)},[ue(a(xi),{class:"h-4 w-4"}),i("span",null,x(a(s)("todoDialog.use")),1)],8,Zv),i("button",{type:"button",class:"tool-button tool-button-danger-subtle inline-flex flex-1 items-center justify-center gap-2 px-3 py-2 text-xs sm:flex-none",onClick:d=>o("delete",k.id)},[ue(a(ao),{class:"h-4 w-4"}),i("span",null,x(a(s)("todoDialog.delete")),1)],8,ey)])])]))),128))])])):(g(),b("div",ty,x(a(s)("todoDialog.empty")),1))]),_:1},8,["open"]))}},sy={class:"pointer-events-none fixed inset-x-0 top-4 z-40 flex justify-center px-4"},oy={__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"?Wo:s==="error"?bi:s==="info"?ki:Ti}return(s,r)=>(g(),Ae(_s,{to:"body"},[i("div",sy,[ue(Xr,{"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:st(()=>[e.message?(g(),b("div",{key:0,class:be(["app-top-toast flex max-w-md items-center gap-2 rounded-sm border px-4 py-2 text-sm shadow-[var(--theme-shadowPanel)] backdrop-blur",n(t.type)])},[(g(),Ae(En(o(t.type)),{class:"h-4 w-4 shrink-0"})),i("span",null,x(e.message),1)],2)):de("",!0)]),_:1})])]))}};function ry(e,t=!1){const n=j(!!t);let o=null,s=()=>{};function r(l){n.value=!!l}return pn(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;o=window.matchMedia(e),r(o.matches);const l=u=>{r(u.matches)};if(typeof o.addEventListener=="function"){o.addEventListener("change",l),s=()=>o==null?void 0:o.removeEventListener("change",l);return}typeof o.addListener=="function"&&(o.addListener(l),s=()=>o==null?void 0:o.removeListener(l))}),Mt(()=>{s()}),{matches:n}}const ay="(max-width: 1023px)",Ws="promptxWorkbenchMobileView";function Mo(e){return(e==null?void 0:e[Ws])==="detail"}function iy({currentTaskSlug:e}){const{matches:t}=ry(ay),n=j("tasks"),o=j("activity");function s(T="tasks"){if(typeof window>"u")return;const v={...window.history.state||{}};T==="detail"?v[Ws]="detail":delete v[Ws],window.history.replaceState(v,"")}function r(){if(typeof window>"u")return;const T={...window.history.state||{},[Ws]:"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=Mo(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 k(T={}){const{useHistory:v=!0}=T;if(!t.value){n.value="tasks";return}if(v&&typeof window<"u"&&Mo(window.history.state)){window.history.back();return}n.value="tasks",s("tasks")}function d(T){t.value&&(n.value=Mo(T.state)&&e.value?"detail":"tasks")}return pn(()=>{typeof window>"u"||window.addEventListener("popstate",d)}),Mt(()=>{typeof window<"u"&&window.removeEventListener("popstate",d)}),Pe(t,T=>{u(T)},{immediate:!0}),Pe(e,()=>{typeof window>"u"||l(window.history.state)},{flush:"post"}),{enterMobileDetail:m,isMobileLayout:t,leaveMobileDetail:k,mobileDetailTab:o,mobileView:n}}const to="PromptX";function ly(e=""){const t=String(a(e)||"").trim();return t?`${to} (${t})`:to}function uy(e="",t={}){ni(()=>{if(typeof document>"u")return;const o=String(a(e)||"").trim();document.title=a(t.raw)?o||to:ly(o)}),Mt(()=>{typeof document>"u"||(document.title=to)})}const Qn="success";function cy(e,t){return e&&typeof e=="object"&&!Array.isArray(e)?{message:String(e.message||"").trim(),type:String(e.type||Qn).trim()||Qn,duration:Number(e.duration)>0?Number(e.duration):t}:{message:String(e||"").trim(),type:Qn,duration:t}}function dy(e=2200){const t=j(""),n=j(Qn);let o=null;function s(){o&&(window.clearTimeout(o),o=null),t.value="",n.value=Qn}function r(l,u=e){const m=cy(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=Qn,o=null},m.duration)}return Mt(()=>{o&&window.clearTimeout(o)}),{toastMessage:t,toastType:n,flashToast:r,clearToast:s}}function fy(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 py(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 my(e,t){const n=[];for(const[o,s]of((e==null?void 0:e.blocks)||[]).entries()){if(s.type===Tt.TEXT||s.type===Tt.IMPORTED_TEXT){const r=py(s.content);r&&n.push(r,"");continue}if(s.type===Tt.IMAGE){const r=fy(s.content,t);r&&n.push(r,"")}}return n.join(`
52
+ `).trim()}function gy(e,t){return my(e,t)}const Ho="promptx:active-task-slug",hy=150,vy=1500,yy=800,no=500,Sy=new Set(["completed","error","stopped","interrupted","stop_timeout","failed","cancelled","timeout"]);function so(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 Cn(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:Cn((t==null?void 0:t.blocks)||[])}))}function Ur(e={}){return{title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),blocks:Cn(e.blocks||[]),todoItems:zt(e.todoItems||[])}}function za(e=[]){return Cn(e).filter(t=>(t==null?void 0:t.type)===Tt.IMAGE?!!String(t.content||"").trim():!!String((t==null?void 0:t.content)||"").trim())}function wy(e=[]){return za(e).length>0}function xy(){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 jr(){return Cn([{type:Tt.TEXT,content:"",meta:{}}])}function qo(e=[],t=16){return Hi(e,t)||""}function by(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 Vr(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=qo(t);if(s)return s;const r=String((e==null?void 0:e.preview)||"").trim();return r?r.slice(0,16):Ge("workbench.untitledTask")}function oo(e={}){return!!(e!=null&&e.running)}function ky(e={},t=!1){return t&&!oo(e)?"sending":oo(e)?"running":"idle"}function Ty(e=""){return["queued","starting","running","stopping"].includes(String(e||"").trim())}function Ha(e=""){return Sy.has(String(e||"").trim())}function _y(e={},t={}){return!!(String((e==null?void 0:e.codexSessionId)||"").trim()&&Ha(t==null?void 0:t.status))}function qa(e="",t="",n=!1){const o=String(e||"").trim();return!!(o&&o===String(t||"").trim()&&n)}function Cy(e={},t="",n={}){const o=String(t||"").trim();return!o||qa(o,n.currentTaskSlug,n.pageFocused)?{unreadMap:e,didMark:!1}:e!=null&&e[o]?{unreadMap:e,didMark:!1}:{unreadMap:{...e||{},[o]:!0},didMark:!0}}function Ka(e={},t=""){const n=String(t||"").trim();if(!n||!(e!=null&&e[n]))return e;const o={...e||{}};return delete o[n],o}function Ey(e={},t={}){return t.pageFocused?Ka(e,t.currentTaskSlug):e}function Ay(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 Wa(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 Ga(e={},t=no){const n=Math.max(1,Number(t)||no),o=Object.entries(e||{});return o.length<=n?e:Object.fromEntries(o.slice(-n))}function Iy(e={},t=[],n=no){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=Wa(l);u.taskSlug&&o.has(u.taskSlug)&&(s[r]=u)}),Ga(s,n)}function $y(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||!Ha(s))return{unreadMap:r,notifiedMap:l,didMark:!1,didDedupe:!1};if(Wa(l[o]).status===s)return{unreadMap:r,notifiedMap:l,didMark:!1,didDedupe:!0};const m=Ga({...l,[o]:{taskSlug:t,status:s}},e.maxNotifiedRuns),k=Cy(r,t,{currentTaskSlug:e.currentTaskSlug,pageFocused:e.pageFocused});return{unreadMap:k.unreadMap,notifiedMap:m,didMark:k.didMark,didDedupe:!1}}function zr(e="",t=72){return String(e||"").replace(/\s+/g," ").trim().slice(0,t)}function Py(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 Hr(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:so(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:so(u.workspaceDiffSummary)}:{...s,workspaceDiffSummary:null}})}function Dy(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(),k=String((u==null?void 0:u.codexSessionId)||"").trim();return!!(m!==k||!!(r!=null&&r.running)!=!!(u!=null&&u.running)||m&&!Object.prototype.hasOwnProperty.call(u||{},"workspaceDiffSummary")||m&&(u==null?void 0:u.workspaceDiffSummary)==null)})}function Os(e){if(typeof window>"u")return;const t=String(e||"").trim();if(t){window.localStorage.setItem(Ho,t);return}window.localStorage.removeItem(Ho)}function Ly(){return typeof window>"u"?"":String(window.localStorage.getItem(Ho)||"").trim()}function My(){if(typeof window>"u")return"";try{const e=new URL(window.location.href);return String(e.searchParams.get("task")||"").trim()}catch{return""}}function By(){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 qn(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=so(e.workspaceDiffSummary)),t}function Ry(e={}){const{clearToast:t=()=>{},flashToast:n=()=>{},scrollCurrentPanelToBottom:o=()=>{}}=e,s=Zn(),r=Ea(),l=j(null),u=j([]),m=j({}),k=j({}),d=j({}),T=j({}),v=j({}),h=j(""),p=j({title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]}),$=j(!0),ee=j(!1),y=j(!1),B=j(!1),K=j(!1),V=j(!1),N=j(""),se=j(!1),I=j("");let X=null,ge=null,ye=0,D=null,ne=0,le=null;const te=new Set;let ve=null,C=0,W={};const P=q(()=>qo(p.value.blocks)),Ee=q(()=>Vr({title:p.value.title,autoTitle:p.value.autoTitle,preview:by(p.value.blocks)},p.value.blocks));function Ie(_,w={}){const F=String(_||"").trim();if(!F)return"";const ie=w.summary||St(F),f=w.cachedDraft===void 0?et(F):w.cachedDraft,E=F===h.value;return Object.prototype.hasOwnProperty.call(k.value,F)?String(k.value[F]||"").trim():E?String(p.value.codexSessionId||(ie==null?void 0:ie.codexSessionId)||"").trim():String((f==null?void 0:f.codexSessionId)||(ie==null?void 0:ie.codexSessionId)||"").trim()}const Be=q(()=>Ie(h.value)),Ye=q(()=>ky(St(h.value),d.value[h.value])),Je=q(()=>Ye.value!=="idle"),Ke=q(()=>u.value.some(_=>oo(_))||Object.values(d.value).some(Boolean)),we=q(()=>Object.values(T.value).some(Boolean)),H=j(0),Z=q(()=>wy(p.value.blocks)),me=q(()=>zt(p.value.todoItems)),_e=q(()=>Ee.value||Ge("workbench.untitledTask")),fe=q(()=>u.value.map(_=>Ce(_)));function Le(_=""){const w=String(_||"").trim();if(!w||w.startsWith("/uploads/"))return w;const F=Zn();if(F&&w.startsWith(F))return w.slice(F.length);if(/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?\/uploads\//.test(w)){const ie=w.match(/^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?(\/uploads\/.*)$/);if(ie)return ie[3]}return w}function he(_=""){const w=String(_||"").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 Me(_=[]){return _.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):he(w.content),meta:w!=null&&w.meta?{...w.meta}:{}}))}function je(_=[]){return(_||[]).map(w=>({id:String((w==null?void 0:w.id)||"").trim(),createdAt:String((w==null?void 0:w.createdAt)||""),blocks:Me((w==null?void 0:w.blocks)||[])}))}function De(_=p.value.title,w=p.value.autoTitle,F=p.value.lastPromptPreview,ie=p.value.todoItems,f=p.value.codexSessionId,E=p.value.blocks){return JSON.stringify({title:String(_||""),autoTitle:String(w||""),lastPromptPreview:String(F||""),todoItems:je(ie),codexSessionId:String(f||""),blocks:Me(E)})}function vt(){return De()!==I.value}function Xe(){var _,w;return!!((w=(_=l.value)==null?void 0:_.isEditing)!=null&&w.call(_))}function St(_){return u.value.find(w=>w.slug===_)||null}function et(_){return _&&m.value[_]||null}function mt(_,w=""){const F=String(_||"").trim();F&&(W={...W,[F]:String(w||"").trim()})}function ze(_=""){var f;const w=String(_||"").trim();if(!w)return!1;const F=String(((f=St(w))==null?void 0:f.updatedAt)||"").trim(),ie=String(W[w]||"").trim();return!!(F&&ie&&F===ie)}function Ce(_){const w=et(_.slug),F=_.slug===h.value?p.value.blocks:(w==null?void 0:w.blocks)||[],ie=_.slug===h.value?p.value.title:(w==null?void 0:w.title)??_.title,f=_.slug===h.value?p.value.autoTitle:(w==null?void 0:w.autoTitle)??_.autoTitle,E=_.slug===h.value?zt(p.value.todoItems).length:zt((w==null?void 0:w.todoItems)||[]).length||Number(_.todoCount||0),M=_.slug===h.value?p.value.lastPromptPreview||_.lastPromptPreview||"":(w==null?void 0:w.lastPromptPreview)||_.lastPromptPreview||"",ae=Ie(_.slug,{summary:_,cachedDraft:w});return{..._,title:ie,autoTitle:f,todoCount:E,preview:M,codexSessionId:ae,sessionSelectionLocked:!!(ae&&Number(_.codexRunCount||0)>0),sessionSelectionLockReason:ae&&Number(_.codexRunCount||0)>0?Ge("taskActions.sessionLocked"):"",displayTitle:Vr({title:ie,autoTitle:f,preview:M},F),sending:oo(_),hasUnreadUpdate:!!T.value[_.slug]}}function lt(_,w={}){const{insertAtStart:F=!1}=w;if(!(_!=null&&_.slug))return;const ie=[...u.value],f=ie.findIndex(E=>E.slug===_.slug);if(f>=0){ie.splice(f,1,{...ie[f],..._}),u.value=ie;return}F?ie.unshift(_):ie.push(_),u.value=ie}function dt(_,w){_&&(m.value={...m.value,[_]:Ur(w)})}function L(_){return _?`${s}/api/tasks/${_}/raw`:`${s}/api/tasks/`}function U(_=""){const w=String(_||"").trim();if(!w)return;const F=St(w),ie=r.getTaskRunChange(w);if(!F||!(ie!=null&&ie.status))return;const f=Ty(ie.status);!!F.running!==f&&lt({...F,running:f})}function oe(){return typeof document>"u"?!0:document.visibilityState==="visible"&&document.hasFocus()}function Te(_=""){return qa(_,h.value,oe())}function Re(_=""){T.value=Ka(T.value,_)}function $e(){T.value=Ey(T.value,{currentTaskSlug:h.value,pageFocused:oe()})}function tt(_=[]){T.value=Ay(T.value,_),v.value=Iy(v.value,_)}function Ve(_=""){const w=String(_||"").trim();if(!w)return;const F=$y({unreadMap:T.value,notifiedMap:v.value,taskSlug:w,change:r.getTaskRunChange(w),currentTaskSlug:h.value,pageFocused:oe(),maxNotifiedRuns:no});T.value=F.unreadMap,v.value=F.notifiedMap,F.didMark&&(H.value+=1)}function _t(_,w){d.value={...d.value,[_]:!!w}}function yt(_=u.value){const w={};(_||[]).forEach(F=>{F!=null&&F.slug&&(w[F.slug]=!!F.running)}),d.value=w}function xt(_,w){_&&(k.value={...k.value,[_]:String(w||"").trim()})}async function We(_,w){const F=String(_||"").trim();if(!F)return;const ie=String(w||"").trim(),f=St(F),E=k.value[F]||(f==null?void 0:f.codexSessionId)||"";if(!!(E&&Number((f==null?void 0:f.codexRunCount)||0)>0)&&ie!==E){N.value=Ge("taskActions.sessionLocked");return}xt(F,ie);const ae=et(F);ae&&dt(F,{...ae,codexSessionId:ie}),f&&lt({...f,codexSessionId:ie,workspaceDiffSummary:ie&&ie===E?f.workspaceDiffSummary:null}),F===h.value&&(p.value={...p.value,codexSessionId:ie});try{await Ml(F,ie)}catch(Ue){xt(F,E),ae&&dt(F,{...ae,codexSessionId:E}),f&&lt({...f,codexSessionId:E}),F===h.value&&(p.value={...p.value,codexSessionId:E}),N.value=Ue.message}}function Ht(){X&&(window.clearTimeout(X),X=null)}function Qt(){D&&(window.clearTimeout(D),D=null)}function Yt(){Ht(),!(ee.value||!h.value)&&(X=window.setTimeout(()=>{Rt({auto:!0,silent:!0})},1500))}function re(){if(!h.value)return;const _=St(h.value)||{slug:h.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};lt({..._,title:String(p.value.title||""),autoTitle:String(p.value.autoTitle||""),lastPromptPreview:String(p.value.lastPromptPreview||""),todoCount:zt(p.value.todoItems).length,codexSessionId:Be.value,preview:String(p.value.lastPromptPreview||"")})}function Oe(_={}){const w=String((_==null?void 0:_.slug)||"").trim();if(!w)return;const F=qn(_);lt(F),mt(w,F.updatedAt||_.updatedAt||""),w===h.value&&(Object.prototype.hasOwnProperty.call(_,"title")&&(p.value.title=String(_.title||"")),Object.prototype.hasOwnProperty.call(_,"autoTitle")&&(p.value.autoTitle=String(_.autoTitle||"")),dt(w,{...p.value}))}function rt(_=[]){const w=new Map((_||[]).map(F=>{const ie=String((F==null?void 0:F.slug)||"").trim();return ie?[ie,so(F.workspaceDiffSummary)]:null}).filter(Boolean));w.size&&(u.value=u.value.map(F=>w.has(F.slug)?{...F,workspaceDiffSummary:w.get(F.slug)}:F))}async function nt(_=u.value){const w=Array.isArray(_)?_:[],F=w.filter(f=>String((f==null?void 0:f.codexSessionId)||"").trim()),ie=++ne;if(!F.length){u.value=w.map(f=>Object.prototype.hasOwnProperty.call(f,"workspaceDiffSummary")?f:{...f,workspaceDiffSummary:null});return}try{const f=await hl({limit:w.length||30,slugs:F.map(E=>E.slug)});if(ie!==ne)return;rt(f.items||[])}catch{}}function Bt(_=""){const w=String(_||"").trim();if(!w)return;const F=r.getTaskRunChange(w),f=u.value.find(E=>E.slug===w);_y(f,F)&&(te.add(w),le&&window.clearTimeout(le),le=window.setTimeout(()=>{le=null;const E=new Set(te);te.clear();const M=u.value.filter(ae=>E.has(ae.slug));nt(M)},yy))}async function z(_={}){const{silent:w=!1}=_;w||($.value=!0,N.value="");try{const F=u.value,ie=await gl(),f=Hr(F,(ie.items||[]).map(qn));u.value=f,tt(f),yt(f),Dy(F,f)&&nt(f)}catch(F){w||(N.value=F.message)}finally{w||($.value=!1)}}async function Q(_=[]){const w=Py(u.value,_),F=u.value.map(E=>String((E==null?void 0:E.slug)||"").trim()).filter(Boolean),ie=w.map(E=>String((E==null?void 0:E.slug)||"").trim()).filter(Boolean);if(!ie.length||ie.join(",")===F.join(","))return!1;const f=u.value;u.value=w;try{const E=await yl(ie);C=Date.now()+vy;const M=Hr(f,(E.items||[]).map(qn));return u.value=M,tt(M),yt(M),!0}catch(E){return u.value=f,N.value=E.message,!1}}async function ce(_=""){const w=String(h.value||"").trim(),F=String(_||"").trim();if(!w)return;if(!u.value.some(f=>f.slug===w)){if(u.value.length){await gt(u.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}h.value="",Os(""),p.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},I.value=De("","","",[],"",[]),se.value=!1;return}F&&F!==w||F&&(Xe()||vt()||se.value||K.value||V.value||ee.value||await gt(w,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function Se(_=""){const w=String(_||"").trim();ve===null?ve=w:ve!==w&&(ve=""),!D&&(D=window.setTimeout(async()=>{const F=ve;ve=null,D=null,await z({silent:!0}),await ce(F||"")},hy))}async function qe(_){const w=await ra(_),F=(w.blocks||[]).map(f=>({...f,content:f.type==="image"?Us(f.content):f.content}));return{state:{title:String(w.title||""),autoTitle:String(w.autoTitle||""),lastPromptPreview:String(w.lastPromptPreview||""),codexSessionId:String(w.codexSessionId||""),blocks:F,todoItems:zt(w.todoItems||[])},summary:qn({...w,blocks:F}),updatedAt:String(w.updatedAt||"")}}async function gt(_,w={}){const{focusEditor:F=!1,force:ie=!1,skipIfDirtyOnApply:f=!1,skipIfEditingOnApply:E=!1,scrollPanelToBottom:M=!1}=w,ae=String(_||"").trim();if(!ae)return!1;const Ue=++ye;ee.value=!0,N.value="",t();try{const At=String(h.value||"").trim(),qt=et(ae),Sn=ie&&qt&&ze(ae);let Nt=ie&&!Sn?null:qt,Vt=null;if(!Nt){const It=await qe(ae);Nt=(It==null?void 0:It.state)||null,Vt=(It==null?void 0:It.summary)||null,mt(ae,(It==null?void 0:It.updatedAt)||(Vt==null?void 0:Vt.updatedAt)||"")}return Ue!==ye||f&&ae===h.value&&(vt()||se.value)||E&&ae===h.value&&Xe()?!1:(h.value=ae,Os(ae),Te(ae)&&Re(ae),p.value=Ur(Nt),dt(ae,Nt),Vt&&lt(Vt),xt(ae,Nt.codexSessionId),I.value=De(p.value.title,p.value.autoTitle,p.value.lastPromptPreview,p.value.todoItems,p.value.codexSessionId,p.value.blocks),se.value=!1,F&&ct(()=>{var It,jn;return(jn=(It=l.value)==null?void 0:It.focusEditor)==null?void 0:jn.call(It)}),(M||ae!==At)&&o(),!0)}catch(At){return Ue===ye&&(N.value=At.message),!1}finally{Ue===ye&&(ee.value=!1)}}async function Rt(_={}){const{auto:w=!1,silent:F=!1}=_;return h.value?De()===I.value?!0:ge||(Ht(),K.value=!0,N.value="",ge=(async()=>{try{const f=await aa(h.value,{title:String(p.value.title||""),autoTitle:String(p.value.autoTitle||""),lastPromptPreview:String(p.value.lastPromptPreview||""),todoItems:zt(p.value.todoItems),codexSessionId:Be.value,expiry:"none",visibility:"private",blocks:Me(p.value.blocks)}),E={title:String(f.title||""),autoTitle:String(f.autoTitle||""),lastPromptPreview:String(f.lastPromptPreview||""),todoItems:zt(f.todoItems||p.value.todoItems||[]),codexSessionId:Be.value||String(f.codexSessionId||"").trim(),blocks:Cn(p.value.blocks)};return dt(h.value,E),I.value=De(E.title,E.autoTitle,E.lastPromptPreview,E.todoItems,E.codexSessionId,E.blocks),se.value=!1,lt(qn(f)),mt(h.value,f.updatedAt||""),!w&&!F&&n({message:Ge("taskActions.taskSaved"),type:"success"}),!0}catch(f){return N.value=f.message,!1}finally{K.value=!1,ge=null,De()!==I.value&&(se.value=!0,Yt())}})(),ge):!1}async function jt(){return V.value?(N.value=Ge("taskActions.fileProcessing"),!1):ge||(se.value?Rt({auto:!1,silent:!0}):!0)}async function Pt(){if(!await jt()&&h.value)return!1;y.value=!0,N.value="";try{const _=await vl({title:"",expiry:"none",visibility:"private"}),w={title:String(_.title||""),autoTitle:String(_.autoTitle||""),lastPromptPreview:String(_.lastPromptPreview||""),codexSessionId:String(_.codexSessionId||""),blocks:Cn(_.blocks||[]),todoItems:zt(_.todoItems||[])};return dt(_.slug,w),lt(qn(_),{insertAtStart:!0}),await gt(_.slug,{focusEditor:!0}),n({message:Ge("taskActions.taskCreated"),type:"success"}),!0}catch(_){return N.value=_.message,!1}finally{y.value=!1}}async function Dt(_){const w=String(_||"").trim();!w||w===h.value||!await jt()||await gt(w)}async function mn(){if(h.value){B.value=!0,N.value="";try{const _=h.value;await Sl(_),u.value=u.value.filter(f=>f.slug!==_);const w={...m.value};delete w[_],m.value=w;const F={...k.value};delete F[_],k.value=F;const ie={...d.value};delete ie[_],d.value=ie,Re(_),u.value.length?await gt(u.value[0].slug,{focusEditor:!0}):(h.value="",Os(""),p.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},I.value=De("","","",[],"",[]),se.value=!1,await Pt())}catch(_){N.value=_.message}finally{B.value=!1}}}function Ct(_={}){const{silent:w=!1}=_;h.value&&(p.value={...p.value,blocks:jr()},dt(h.value,p.value),re(),se.value=!0,ct(()=>{var F,ie;(ie=(F=l.value)==null?void 0:F.focusEditor)==null||ie.call(F)}),w||n({message:Ge("taskActions.taskCleared"),type:"info"}))}function on(){if(!h.value)return!1;const _=za(p.value.blocks);return _.length?(p.value={...p.value,blocks:jr(),todoItems:[{id:xy(),createdAt:new Date().toISOString(),blocks:_},...zt(p.value.todoItems)]},dt(h.value,p.value),re(),se.value=!0,ct(()=>{var w,F;(F=(w=l.value)==null?void 0:w.focusEditor)==null||F.call(w)}),n({message:Ge("taskActions.todoAdded"),type:"success"}),!0):!1}function In(_=""){const w=String(_||"").trim();if(!h.value||!w)return!1;const F=zt(p.value.todoItems).filter(ie=>ie.id!==w);return F.length===zt(p.value.todoItems).length?!1:(p.value={...p.value,todoItems:F},dt(h.value,p.value),re(),se.value=!0,!0)}function tn(_=""){const w=String(_||"").trim();if(!h.value||!w)return null;const F=zt(p.value.todoItems).find(ie=>ie.id===w);return F?(p.value={...p.value,blocks:Cn(F.blocks),todoItems:zt(p.value.todoItems).filter(ie=>ie.id!==w)},dt(h.value,p.value),re(),se.value=!0,ct(()=>{var ie,f;(f=(ie=l.value)==null?void 0:ie.focusEditor)==null||f.call(ie)}),F):null}async function Jt(){var f;if(await z(),!u.value.length){await Pt();return}const _=My();if(_){const E=await gt(_,{focusEditor:!0,force:!0});if(By(),E)return}const w=((f=u.value.find(E=>!!(E!=null&&E.running)))==null?void 0:f.slug)||"",F=Ly(),ie=w||(u.value.some(E=>E.slug===F)?F:u.value[0].slug);await gt(ie,{focusEditor:!0,force:!0})}async function rn(_){var w,F,ie;V.value=!0,N.value="";try{const f=((F=(w=l.value)==null?void 0:w.isImportedBlockActive)==null?void 0:F.call(w))||!1,E=[];for(const M of _){const ae=await wl(M);E.push({type:"image",content:Us(ae.url),meta:{}})}(ie=l.value)==null||ie.insertUploadedBlocks(E),n({message:Ge("taskActions.imageInserted",{count:E.length,appended:f}),type:"success"})}catch(f){N.value=f.message}finally{V.value=!1}}async function gn(_){var w,F,ie;N.value="";try{const f=((F=(w=l.value)==null?void 0:w.isImportedBlockActive)==null?void 0:F.call(w))||!1,E=[];for(const M of _){const ae=await M.text();ae.trim()&&E.push({type:"imported_text",content:ae,meta:{fileName:M.name||Ge("workbench.untitledTask"),collapsed:!0}})}if(!E.length){n({message:Ge("taskActions.noTextImported"),type:"warning"});return}(ie=l.value)==null||ie.insertImportedBlocks(E),n({message:Ge("taskActions.importedBlocksInserted",{count:E.length,appended:f}),type:"success"})}catch{N.value=Ge("taskActions.textImportFailed")}}async function nn(_){var w;V.value=!0,N.value="";try{let F=0,ie=0;for(const f of _){const E=await xl(f),M=(E.blocks||[]).map(ae=>({...ae,content:ae.type==="image"?Us(ae.content):ae.content}));M.length&&((w=l.value)==null||w.insertBlocks(M),F+=M.length,ie+=Number(E.pageCount||0))}if(!F){n({message:Ge("taskActions.noPdfContent"),type:"warning"});return}n({message:Ge("taskActions.pdfBlocksInserted",{blockCount:F,pageCount:ie}),type:"success"})}catch(F){N.value=F.message||Ge("taskActions.pdfImportFailed")}finally{V.value=!1}}function an(_){const w=_===h.value?p.value:et(_);return w?gy({title:String(w.title||""),blocks:Me(w.blocks||[])},L(_)):""}function hn(_){const w=_===h.value?p.value:et(_);return w?Cn(Me(w.blocks||[])):[]}async function ln(_){return V.value?(N.value=Ge("taskActions.fileProcessingBeforeSend"),!1):_!==h.value?!0:K.value&&ge?ge:se.value?Rt({auto:!1,silent:!0}):!0}async function vn(_){return await ln(_)?an(_):""}function yn(_,w){const F=zr(w);!F||_!==h.value||(p.value.lastPromptPreview=F,dt(h.value,p.value),re())}return Pe(p,()=>{if(ee.value||!h.value)return;const _=qo(p.value.blocks);!String(p.value.title||"").trim()&&_&&_!==p.value.autoTitle&&(p.value.autoTitle=_),dt(h.value,p.value),se.value=De()!==I.value,re(),se.value&&!K.value&&Yt()},{deep:!0}),Pe(h,_=>{_&&(Os(_),$e())}),pn(()=>{typeof window>"u"||(window.addEventListener("focus",$e),document.addEventListener("visibilitychange",$e))}),Mt(()=>{Ht(),Qt(),le&&(window.clearTimeout(le),le=null),te.clear(),typeof window<"u"&&(window.removeEventListener("focus",$e),document.removeEventListener("visibilitychange",$e))}),Pe(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<C||(Ve(r.listSyncTaskSlug.value),U(r.listSyncTaskSlug.value),Bt(r.listSyncTaskSlug.value),Se(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:on,applyTaskSettingsUpdate:Oe,buildPromptForTask:an,getPromptBlocksForTask:hn,buildPromptPreview:zr,clearCurrentTaskContent:Ct,createTaskAndSelect:Pt,currentProjectSessionId:Be,currentTaskSendState:Ye,currentTaskAutoTitle:P,currentTaskDisplayTitle:Ee,currentTaskSlug:h,draft:p,editorRef:l,error:N,handleImportPdfFiles:nn,handleImportTextFiles:gn,handleTaskSendingChange:_t,handleTaskSessionChange:We,handleUpload:rn,hasCurrentDraftContent:Z,hasAnyTaskSending:Ke,hasUnsavedChanges:se,hasUnreadTaskUpdates:we,initializeWorkbench:Jt,isCurrentTaskSending:Je,loadingTask:ee,loadingTasks:$,pageTitle:_e,prepareCodexPromptForTask:vn,currentTodoItems:me,removeTodoItem:In,removeCurrentTask:mn,reorderTaskList:Q,removingTask:B,renderedTasks:fe,refreshTaskList:z,saveTask:Rt,saving:K,selectTask:Dt,selectedSessionMap:k,sendingTaskMap:d,taskDraftMap:m,tasks:u,unreadNotificationVersion:H,useTodoItem:tn,updateLastPromptPreview:yn,uploading:V,creatingTask:y}}const Ny={class:"flex h-full min-h-0 flex-col overflow-hidden"},Oy={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"},Fy={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},Uy={class:"min-h-0 min-w-0 overflow-hidden"},jy={class:"min-h-0 min-w-0 overflow-hidden"},Vy={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},zy={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},Hy={class:"flex flex-col gap-2"},qy={class:"min-h-0 flex-1 overflow-hidden"},Ky={key:1,class:"min-h-0 flex-1 overflow-hidden"},Wy={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},Gy={class:"workbench-mobile-tabs-panel shrink-0"},Xy={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},Yy={class:"min-h-0 flex-1 overflow-hidden"},Jy={class:"h-full min-h-0"},Qy={class:"h-full min-h-0"},Zy={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},eS={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},tS={class:"flex flex-col gap-2"},nS={class:"min-h-0 flex-1 overflow-hidden"},sS="/sounds/notify-didi.wav?v=20260420-1",oS=3e3,qr="promptx:selected-agent-engine-map",rS={__name:"WorkbenchView",setup(e){const t=j(!1),n=j(!1),o=j(!1),s=j(!1),r=j(!1),l=j(!1),u=j(!1),m=j(!1),k=j(""),d=j(""),T=j(""),v=j(0),h=j("workspace"),p=j(""),{t:$}=Et(),{toastMessage:ee,toastType:y,flashToast:B,clearToast:K}=dy(),{notificationSoundEnabled:V,sendBehavior:N}=Qa(),se=Bo(()=>He(()=>import("./TaskDiffReviewDialog-CoQgN73y.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),I=Bo(()=>He(()=>import("./WorkbenchSettingsDialog-Bw-fcsXi.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),X=j(null),ge=j([]);function ye(){try{const S=JSON.parse(window.localStorage.getItem(qr)||"{}");if(S&&typeof S=="object"&&!Array.isArray(S))return S}catch{}return{}}function D(S){window.localStorage.setItem(qr,JSON.stringify(S))}const ne=j(ye());let le=null,te=!1,ve=0;function C(S="",Y=ge.value){const ke=String(S||"").trim();return ke&&Y.some(xe=>(xe==null?void 0:xe.engine)===ke)?ke:""}function W(S=ge.value){var Y,ke;return((Y=S.find(xe=>xe==null?void 0:xe.isDefault))==null?void 0:Y.engine)||((ke=S[0])==null?void 0:ke.engine)||""}const P=q({get(){const S=String(he.value||"").trim();if(!S)return"";const Y=String(ne.value[S]||"").trim();return Y||W()},set(S){const Y=String(he.value||"").trim(),ke=String(S||"").trim();!Y||!ke||(ne.value={...ne.value,[Y]:ke},D(ne.value))}});function Ee(S){return S?X.value:null}function Ie(){ct(()=>{var S,Y;(Y=(S=Ee(he.value))==null?void 0:S.scrollToBottom)==null||Y.call(S)})}const{addCurrentDraftToTodo:Be,applyTaskSettingsUpdate:Ye,buildPromptForTask:Je,getPromptBlocksForTask:Ke,clearCurrentTaskContent:we,createTaskAndSelect:H,creatingTask:Z,currentProjectSessionId:me,currentTaskSendState:_e,currentTaskAutoTitle:fe,currentTaskDisplayTitle:Le,currentTaskSlug:he,draft:Me,editorRef:je,error:De,handleImportPdfFiles:vt,handleImportTextFiles:Xe,handleTaskSendingChange:St,handleTaskSessionChange:et,handleUpload:mt,hasCurrentDraftContent:ze,hasUnsavedChanges:Ce,hasUnreadTaskUpdates:lt,initializeWorkbench:dt,isCurrentTaskSending:L,loadingTask:U,loadingTasks:oe,pageTitle:Te,prepareCodexPromptForTask:Re,currentTodoItems:$e,removeTodoItem:tt,removeCurrentTask:Ve,reorderTaskList:_t,removingTask:yt,renderedTasks:xt,saveTask:We,saving:Ht,selectTask:Qt,unreadNotificationVersion:Yt,updateLastPromptPreview:re,useTodoItem:Oe,uploading:rt}=Ry({clearToast:K,flashToast:B,scrollCurrentPanelToBottom:Ie}),nt=q(()=>xt.value.find(S=>S.slug===he.value)||null),Bt=q(()=>lt.value?$("workbench.newMessageTitle"):Te.value),z=q(()=>lt.value),Q=q(()=>{var S,Y;return!!((Y=(S=nt.value)==null?void 0:S.workspaceDiffSummary)!=null&&Y.supported)}),ce=q(()=>{const S=nt.value;return S?()=>Re(S.slug):null}),Se=q(()=>{const S=nt.value;return S?()=>Ke(S.slug):null}),qe=q(()=>({creatingTask:Z.value,currentTaskAutoTitle:Me.value.autoTitle||fe.value,currentTaskSlug:he.value,draftTitle:Me.value.title,editingTaskTitleSlug:T.value,error:De.value,isCurrentTaskSending:L.value,loadingTask:U.value,loadingTasks:oe.value,removingTask:yt.value,tasks:xt.value,uploading:rt.value})),gt=q(()=>{var S,Y,ke,xe;return{buildPromptBlocks:Se.value,buildPrompt:ce.value,diffSupported:Q.value,selectedAgentEngine:P.value,selectedSessionId:me.value,sessionSelectionLockReason:((S=nt.value)==null?void 0:S.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((Y=nt.value)!=null&&Y.sessionSelectionLocked),taskSlug:((ke=nt.value)==null?void 0:ke.slug)||"",taskRunning:!!((xe=nt.value)!=null&&xe.running)}}),Rt=q(()=>({codexSessionId:me.value,sendBehavior:N.value,loading:U.value})),jt=q(()=>({currentTaskAutoTitle:Me.value.autoTitle||fe.value,currentTaskSlug:he.value,editingTaskTitleSlug:T.value,title:Le.value,titleInputValue:Me.value.title})),{enterMobileDetail:Pt,isMobileLayout:Dt,leaveMobileDetail:mn,mobileDetailTab:Ct,mobileView:on}=iy({currentTaskSlug:he});function In(S){return S!=null&&S.sending||Number((S==null?void 0:S.codexRunCount)||0)>0?"activity":"input"}uy(Bt,{raw:z});function tn(){return typeof window>"u"?null:(le||(le=new Audio(sS),le.preload="auto",le.volume=.7),le)}function Jt(){if(!V.value)return;const S=tn();if(!(!S||te))try{S.muted=!0;const Y=S.play();if(Y&&typeof Y.then=="function"){Y.then(()=>{S.pause(),S.currentTime=0,S.muted=!1,te=!0}).catch(()=>{S.muted=!1});return}S.pause(),S.currentTime=0,S.muted=!1,te=!0}catch{S.muted=!1}}function rn(){Jt()}function gn(){const S=tn();if(!S||!V.value)return;const Y=Date.now();if(!(Y-ve<oS)){ve=Y;try{S.muted=!1,S.currentTime=0,S.play().catch(()=>{})}catch{}}}function nn(S="workspace",Y=""){h.value=S==="run"?"run":S==="task"?"task":"workspace",p.value=h.value==="run"?String(Y||""):"",o.value=!0,v.value+=1}function an(){o.value=!1}function hn(){s.value=!0}function ln(){s.value=!1}function vn(){he.value&&(r.value=!0)}function yn(){r.value=!1}function _(){l.value=!0}function w(){l.value=!1,F(),ie()}function F(){u.value=!1,k.value=""}function ie(){m.value=!1,d.value=""}function f(S){Ye(S)}function E(S){Me.value.title=S}async function M(){T.value="",Ce.value&&await We({auto:!1,silent:!0})}function ae(S){S===he.value&&(T.value=S,ct(()=>{var ke,xe;const Y=document.querySelector('[data-task-title-input="current"]');(ke=Y==null?void 0:Y.focus)==null||ke.call(Y),(xe=Y==null?void 0:Y.select)==null||xe.call(Y)}))}async function Ue(S){if(Dt.value){await rs(S);return}if(S!==he.value){await rs(S);return}ae(S)}function At(){n.value=!0}function qt(){yt.value||(n.value=!1)}async function Sn(){await Ve(),n.value=!1,Dt.value&&mn({useHistory:!1})}function Nt(){t.value=!0}function Vt(){t.value=!1}function It(){t.value=!1,we()}function jn(S){const Y=nt.value;Y&&St(Y.slug,S)}function ss(S){const Y=nt.value;Y&&et(Y.slug,S)}function uo(S={}){const Y=String((S==null?void 0:S.sessionId)||"").trim(),ke=me.value;if(Y&&Y!==ke)return;const xe=Array.isArray(S==null?void 0:S.bindings)?S.bindings:[];ge.value=xe;const Qe=String(he.value||"").trim();if(!Qe)return;const at=String(ne.value[Qe]||"").trim();if(at&&xe.some(Ot=>(Ot==null?void 0:Ot.engine)===at)){P.value!==at&&(P.value=at);return}const ft=C(S==null?void 0:S.selectedEngine,xe)||W(xe);ft&&P.value!==ft&&(P.value=ft)}Pe(me,(S,Y)=>{String(S||"").trim()!==String(Y||"").trim()&&(ge.value=[])});function os(S){P.value=S}function co(S){B(S),!(!Dt.value||!he.value)&&(Ct.value="activity")}async function un(){var S,Y,ke,xe,Qe,at,ft,Ot;typeof document<"u"&&((Y=(S=je.value)==null?void 0:S.isComposing)!=null&&Y.call(S))&&((xe=(ke=document.activeElement)==null?void 0:ke.blur)==null||xe.call(ke)),(at=(Qe=je.value)==null?void 0:Qe.flushPendingInput)==null||at.call(Qe),await ct(),(Ot=(ft=je.value)==null?void 0:ft.flushPendingInput)==null||Ot.call(ft),await ct()}async function As(){await un(),await navigator.clipboard.writeText(Je(he.value)),B({message:$("workbench.promptCopied"),type:"info"})}async function $n(){await H()&&Dt.value&&(Ct.value="input",Pt())}async function rs(S){const Y=String(S||"").trim();Y&&(Y!==he.value&&await Qt(Y),Dt.value&&he.value===Y&&(Ct.value=In(nt.value),Pt()))}async function fo(S=[]){await _t(S)}async function Is(){await un(),Be()}function wn(S={}){const Y=String((S==null?void 0:S.rangeLabel)||"").trim();if(Y)return Y;const ke=Math.max(0,Number(S==null?void 0:S.lineStart)||0),xe=Math.max(0,Number(S==null?void 0:S.lineEnd)||0);return ke&&xe&&ke!==xe?`L${ke}-L${xe}`:ke||xe?`L${ke||xe}`:""}function po(S=""){return`code-context-${String(S||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function mo(S={}){const Y=String((S==null?void 0:S.filePath)||"").trim(),ke=String((S==null?void 0:S.content)||"").replace(/\r\n/g,`
56
+ `).trimEnd();if(!Y||!ke.trim())return null;const xe=String((S==null?void 0:S.language)||"").trim(),Qe=wn(S),at=String((S==null?void 0:S.source)||"").trim()==="diff"?$("workbench.codeContextSourceDiff"):$("workbench.codeContextSourceFile"),ft=xe?`\`\`\`${xe}`:"```",Ot=[$("workbench.codeContextTitle"),$("workbench.codeContextFile",{path:Y}),Qe?$("workbench.codeContextRange",{range:Qe}):"",$("workbench.codeContextSource",{source:at}),"",ft,ke,"```"].filter(Pn=>Pn!=="");return{type:Tt.IMPORTED_TEXT,content:Ot.join(`
57
+ `),meta:{fileName:po(Y),collapsed:!1}}}async function as(S=[],Y="insertBlocks"){var xe,Qe,at,ft;const ke=Array.isArray(S)?S.filter(Boolean):[];return ke.length?(await un(),(Qe=(xe=je.value)==null?void 0:xe[Y])==null||Qe.call(xe,ke),await ct(),(ft=(at=je.value)==null?void 0:at.focusEditor)==null||ft.call(at),Dt.value&&he.value&&(Ct.value="input"),B({message:$("taskActions.insertedToEditor"),type:"success"}),!0):!1}async function is(S={}){const Y=String((S==null?void 0:S.source)||"").trim(),ke=Array.isArray(S==null?void 0:S.blocks)?S.blocks.filter(Boolean):[],xe=String((S==null?void 0:S.content)||"").replace(/\r\n/g,`
58
+ `).trim();if(Y==="response"){if(ke.length){await as(ke,"insertBlocks");return}if(!xe)return;await as([Wn(xe)],"insertBlocks");return}const Qe=mo(S);Qe&&await as([Qe],"insertImportedBlocks")}function xn(S){k.value=String(S||"").trim(),u.value=!!k.value}function ls(){k.value&&(tt(k.value),F())}async function Vn(S=d.value){const Y=String(S||"").trim();return!Y||!Oe(Y)?!1:(ie(),w(),!0)}async function us(S){await un();const Y=String(S||"").trim();if(Y){if(!ze.value){await Vn(Y);return}d.value=Y,m.value=!0}}async function Kt(){var xe,Qe,at,ft;const S=he.value;if(!S)return;const Y=!!((Qe=(xe=nt.value)==null?void 0:xe.automation)!=null&&Qe.enabled);await un(),re(S,Je(S)),!(!await((ft=(at=Ee(S))==null?void 0:at.send)==null?void 0:ft.call(at))||S!==he.value)&&(Dt.value&&(Ct.value="activity"),Y||we({silent:!0}),await We({auto:!1,silent:!0}))}function go(){!Dt.value||on.value!=="detail"||Ct.value!=="input"||!he.value||ct(()=>{var S,Y;(Y=(S=je.value)==null?void 0:S.focusEditor)==null||Y.call(S)})}function cs(S){!Ce.value&&!rt.value&&!Ht.value||(S.preventDefault(),S.returnValue="")}function zn(){var S,Y;return m.value?(ie(),!0):u.value?(F(),!0):t.value?(Vt(),!0):n.value?(qt(),!0):r.value?(yn(),!0):l.value?(w(),!0):o.value?(an(),!0):s.value?(ln(),!0):!!((Y=(S=Ee(he.value))==null?void 0:S.closeTopDialog)!=null&&Y.call(S))}function bn(S){var Qe,at,ft,Ot,Pn;const Y=String(S.key||""),ke=Y.toLowerCase(),xe=S.metaKey||S.ctrlKey;if(Y==="Escape"){zn()&&(S.preventDefault(),(Qe=S.stopImmediatePropagation)==null||Qe.call(S));return}if(xe){if(ke==="s"){S.preventDefault(),We({auto:!1});return}if(S.shiftKey&&Y==="Backspace"){S.preventDefault(),Nt();return}if(!S.isComposing){if(S.shiftKey&&S.code==="Comma"){S.preventDefault(),hn();return}if(S.shiftKey&&ke==="k"){S.preventDefault(),(ft=(at=Ee(he.value))==null?void 0:at.openProjectManager)==null||ft.call(at);return}if(S.shiftKey&&ke==="o"){S.preventDefault(),(Pn=(Ot=Ee(he.value))==null?void 0:Ot.openSourceBrowser)==null||Pn.call(Ot);return}S.shiftKey&&ke==="d"&&(S.preventDefault(),Q.value&&nn("workspace"))}}}pn(()=>{dt(),window.addEventListener("beforeunload",cs),window.addEventListener("keydown",bn),window.addEventListener("pointerdown",rn,{passive:!0})}),Mt(()=>{window.removeEventListener("beforeunload",cs),window.removeEventListener("keydown",bn),window.removeEventListener("pointerdown",rn)}),Pe([Dt,on,Ct,he],([S,Y,ke,xe])=>{!S||Y!=="detail"||ke!=="input"||!xe||go()}),Pe(Yt,(S,Y)=>{Number(S)<=Number(Y||0)||gn()});const $s={"update:draftTitle":E,"cancel-title-edit":()=>{T.value=""},"create-task":$n,"edit-task":vn,"delete-task":At,"open-settings":hn,"reorder-task":fo,"select-task":rs,"title-blur":M,"title-click":Ue},Ps={"agent-bindings-change":uo,"insert-code-context":is,"open-diff":({scope:S,runId:Y})=>nn(S,Y),"project-created":()=>B({message:$("workbench.projectCreated"),type:"success"}),"selected-session-change":ss,"update:selectedAgentEngine":os,"sending-change":jn,toast:co},ds={"clear-request":Nt,"file-feedback":S=>B({message:S,type:"warning"}),"import-pdf-files":vt,"import-text-files":Xe,"send-request":Kt,"upload-files":mt},ho={"begin-edit":()=>ae(he.value),back:mn,"cancel-title-edit":()=>{T.value=""},"title-blur":M,"update:titleInputValue":E};return(S,Y)=>(g(),b("div",Ny,[ue(oy,{message:a(ee),type:a(y)},null,8,["message","type"]),ue(Ls,{open:t.value,title:a($)("workbench.confirmClearTitle"),description:a($)("workbench.confirmClearDescription"),"confirm-text":a($)("workbench.confirmClearAction"),"cancel-text":a($)("workbench.continueEditing"),onCancel:Vt,onConfirm:It},null,8,["open","title","description","confirm-text","cancel-text"]),ue(Ls,{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(yt),danger:"",onCancel:qt,onConfirm:Sn},null,8,["open","title","description","confirm-text","cancel-text","loading"]),ue(Ls,{open:u.value,title:a($)("workbench.confirmDeleteTodoTitle"),description:a($)("workbench.confirmDeleteTodoDescription"),"confirm-text":a($)("workbench.confirmDeleteAction"),"cancel-text":a($)("workbench.keepForNow"),danger:"",onCancel:F,onConfirm:ls},null,8,["open","title","description","confirm-text","cancel-text"]),ue(Ls,{open:m.value,title:a($)("workbench.replaceEditorTitle"),description:a($)("workbench.replaceEditorDescription"),"confirm-text":a($)("workbench.confirmReplaceAction"),"cancel-text":a($)("workbench.dontReplaceYet"),onCancel:ie,onConfirm:Y[0]||(Y[0]=ke=>Vn())},null,8,["open","title","description","confirm-text","cancel-text"]),ue(ny,{open:l.value,items:a($e),onClose:w,onDelete:xn,onUse:us},null,8,["open","items"]),ue(a(se),{open:o.value,"task-slug":a(he),"task-title":a(Le),"preferred-scope":h.value,"preferred-run-id":p.value,"focus-token":v.value,onInsertCodeContext:is,onClose:an},null,8,["open","task-slug","task-title","preferred-scope","preferred-run-id","focus-token"]),ue(a(I),{open:s.value,onClose:ln},null,8,["open"]),ue(tc,{open:r.value,"task-slug":a(he),"task-title":a(Le),onClose:yn,onSaved:f},null,8,["open","task-slug","task-title"]),a(Dt)?(g(),b("div",Ky,[a(on)==="tasks"?(g(),Ae(Fr,Dn({key:0},qe.value,{mobile:""},Ln($s)),null,16)):(g(),b("div",Wy,[ue(Zh,Dn(jt.value,Ln(ho)),null,16),i("section",Gy,[i("div",Xy,[i("button",{type:"button",class:be(["tool-button px-3 py-1.5 text-sm",a(Ct)==="activity"?"tool-button-accent-subtle":""]),onClick:Y[3]||(Y[3]=ke=>Ct.value="activity")},x(a($)("workbench.activity")),3),i("button",{type:"button",class:be(["tool-button px-3 py-1.5 text-sm",a(Ct)==="input"?"tool-button-accent-subtle":""]),onClick:Y[4]||(Y[4]=ke=>Ct.value="input")},x(a($)("workbench.input")),3)])]),i("div",Yy,[Zt(i("div",Jy,[ue(Dr,Dn({ref_key:"codexPanelRef",ref:X},gt.value,{"empty-message":a($)("workbench.selectTask")},Ln(Ps)),null,16,["empty-message"])],512),[[Gs,a(Ct)==="activity"]]),Zt(i("div",Qy,[i("div",Zy,[i("div",eS,[i("div",tS,[ue(Mr,{"can-add-todo":a(ze),"is-current-task-sending":a(L),"send-state":a(_e),"todo-count":a($e).length,uploading:a(rt),onAddTodo:Is,onOpenFilePicker:Y[5]||(Y[5]=ke=>{var xe,Qe;return(Qe=(xe=a(je))==null?void 0:xe.openFilePicker)==null?void 0:Qe.call(xe)}),onClearRequest:Nt,onCopyRequest:As,onManageTodo:_,onSendRequest:Kt},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(Lr,{"agent-bindings":ge.value,"selected-agent-engine":P.value,"onUpdate:selectedAgentEngine":os},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",nS,[ue(Or,Dn({ref_key:"editorRef",ref:je,modelValue:a(Me).blocks,"onUpdate:modelValue":Y[6]||(Y[6]=ke=>a(Me).blocks=ke)},Rt.value,Ln(ds)),null,16,["modelValue"])])])],512),[[Gs,a(Ct)==="input"]])])]))])):(g(),b("div",Oy,[ue(Fr,Dn(qe.value,Ln($s)),null,16),i("div",Fy,[i("div",Uy,[nt.value?(g(),Ae(Dr,Dn({key:0,ref_key:"codexPanelRef",ref:X},gt.value,Ln(Ps)),null,16)):de("",!0)]),i("div",jy,[i("div",Vy,[i("div",zy,[i("div",Hy,[ue(Mr,{"can-add-todo":a(ze),"is-current-task-sending":a(L),"send-state":a(_e),"todo-count":a($e).length,uploading:a(rt),onAddTodo:Is,onOpenFilePicker:Y[1]||(Y[1]=ke=>{var xe,Qe;return(Qe=(xe=a(je))==null?void 0:xe.openFilePicker)==null?void 0:Qe.call(xe)}),onClearRequest:Nt,onCopyRequest:As,onManageTodo:_,onSendRequest:Kt},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(Lr,{"agent-bindings":ge.value,"selected-agent-engine":P.value,align:"end","onUpdate:selectedAgentEngine":os},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",qy,[ue(Or,Dn({ref_key:"editorRef",ref:je,modelValue:a(Me).blocks,"onUpdate:modelValue":Y[2]||(Y[2]=ke=>a(Me).blocks=ke)},Rt.value,Ln(ds)),null,16,["modelValue"])])])])])]))]))}},bS=Object.freeze(Object.defineProperty({__proto__:null,default:rS},Symbol.toStringTag,{value:"Module"}));export{dS as A,bS as B,SS as D,js as W,la as _,wa as a,vS as b,ya as c,Ic as d,Cc as e,ry as f,hS as g,dn as h,wS as i,io as j,Ze as k,Bl as l,al as m,fS as n,Cd as o,Ro as p,mS as q,xS as r,gS as s,ht as t,Ea as u,sc as v,Ls as w,yS as x,Qs as y,pS as z};