codex-mobile-re 0.1.101 → 0.1.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AutomationsPanel-BujKO0oC.js → AutomationsPanel-BZ73-GJE.js} +1 -1
- package/dist/assets/{DirectoryHub-C4D0oVqF.js → DirectoryHub-DWtUbt5I.js} +1 -1
- package/dist/assets/ReviewPane-B8ZRIB5L.css +1 -0
- package/dist/assets/ReviewPane-Cd7kjB6d.js +1 -0
- package/dist/assets/{ThreadConversation-CO1w6DqK.js → ThreadConversation-BFAPAWUd.js} +1 -1
- package/dist/assets/{ThreadTerminalPanel-BrRExfgh.js → ThreadTerminalPanel-C0cuIPzx.js} +1 -1
- package/dist/assets/{index-CA0M4Wjh.js → index-BALsV_-J.js} +5 -5
- package/dist/assets/{index-DpBCV6zI.css → index-bLpg1m_q.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-cli/index.js +97 -28
- package/dist-cli/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/assets/ReviewPane-C3Zdl2_i.css +0 -1
- package/dist/assets/ReviewPane-DJs-RkeF.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ThreadConversation-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ThreadConversation-BFAPAWUd.js","assets/sanitizeHtml-Bd3No2dT.js","assets/ThreadConversation-Db8A09JM.css","assets/ThreadTerminalPanel-C0cuIPzx.js","assets/ThreadTerminalPanel-O7IxAyfy.css","assets/ReviewPane-Cd7kjB6d.js","assets/ReviewPane-B8ZRIB5L.css","assets/DirectoryHub-DWtUbt5I.js","assets/DirectoryHub-BOBZNd77.css","assets/AutomationsPanel-BZ73-GJE.js","assets/AutomationsPanel-ulx5N8pM.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&o(a)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();/**
|
|
3
3
|
* @vue/shared v3.5.40
|
|
4
4
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
@@ -52,7 +52,7 @@ ${e}
|
|
|
52
52
|
...${e.length-lf} more item(s)`:"";return`${t}:
|
|
53
53
|
${n.join(`
|
|
54
54
|
`)||"empty"}${r}`}catch(n){return`${t}: unavailable (${Ry(lc(n))})`}}function y1(){return typeof window>"u"?"unknown":[`Path: ${window.location.pathname||"/"}`,`Hash: ${window.location.hash||"(none)"}`,`Search: ${window.location.search||"(none)"}`,`Online: ${typeof navigator>"u"?"unknown":String(navigator.onLine)}`,`Language: ${typeof navigator>"u"?"unknown":navigator.language}`,`Platform: ${typeof navigator>"u"?"unknown":navigator.platform}`,qm(window.localStorage,"localStorage"),qm(window.sessionStorage,"sessionStorage")].join(`
|
|
55
|
-
`)}function Mi(e){const t=e.message.trim();if(!t)return;const n=Tl.value[0];if(n&&n.kind===e.kind&&n.message===t&&n.url===e.url&&n.method===e.method&&n.status===e.status)return;const o={...e,message:t,atIso:e.atIso??new Date().toISOString()};Tl.value=[o,...Tl.value].slice(0,d1)}function My(e=Tl.value){var h;const t=typeof window>"u"?"unknown":`${window.innerWidth}x${window.innerHeight} @${window.devicePixelRatio||1}x`,n=typeof window>"u"?"unknown":window.location.href,o=typeof navigator>"u"?"unknown":navigator.userAgent,r="0.1.
|
|
55
|
+
`)}function Mi(e){const t=e.message.trim();if(!t)return;const n=Tl.value[0];if(n&&n.kind===e.kind&&n.message===t&&n.url===e.url&&n.method===e.method&&n.status===e.status)return;const o={...e,message:t,atIso:e.atIso??new Date().toISOString()};Tl.value=[o,...Tl.value].slice(0,d1)}function My(e=Tl.value){var h;const t=typeof window>"u"?"unknown":`${window.innerWidth}x${window.innerHeight} @${window.devicePixelRatio||1}x`,n=typeof window>"u"?"unknown":window.location.href,o=typeof navigator>"u"?"unknown":navigator.userAgent,r="0.1.102",s="codex-mobile",a=e.slice(0,12).map((v,y)=>[`${y+1}. [${v.atIso}] ${v.kind}`,v.method?`${v.method}`:"",v.url??"",typeof v.status=="number"?`${v.status} ${v.statusText??""}`.trim():"",v.message].filter(Boolean).join(" | ")).join(`
|
|
56
56
|
`),l=["What happened?","","","Context",`URL: ${n}`,`User agent: ${o}`,`Viewport: ${t}`,`App version: ${r}`,`Worktree: ${s}`,"","Browser/app state",y1(),"","Recent diagnostics",a||"No diagnostics captured.","","Visible page text",v1()].join(`
|
|
57
57
|
`).slice(0,f1),d=`Codex Web feedback: ${Ry((h=e[0])==null?void 0:h.message)}`;return`mailto:${Ey}?subject=${Bm(d)}&body=${Bm(l)}`}function w1(){typeof window>"u"||(window.location.href=My())}function b1(){if(!(typeof window>"u")&&(Um||(Um=!0,window.addEventListener("error",e=>{Mi({kind:"window-error",message:e.error?lc(e.error):e.message,url:e.filename||window.location.href})}),window.addEventListener("unhandledrejection",e=>{Mi({kind:"unhandled-rejection",message:lc(e.reason),url:window.location.href})})),!cf)){if(typeof window.fetch!="function"){Mi({kind:"fetch-error",message:"Feedback diagnostics could not monitor fetch: window.fetch is unavailable",url:window.location.href});return}try{uf=window.fetch.bind(window),window.fetch=async(e,t)=>{const n=p1(e),o=h1(e,t);try{const r=await uf(e,t);return r.ok||Mi({kind:n.includes("/codex-api/")?"api-response":"fetch-error",message:`Request failed with HTTP ${r.status}`,url:n,method:o,status:r.status,statusText:r.statusText}),r}catch(r){throw Mi({kind:"fetch-error",message:lc(r),url:n,method:o}),r}},cf=!0}catch(e){uf=null,cf=!1;try{Mi({kind:"fetch-error",message:`Feedback diagnostics could not monitor fetch: ${lc(e)}`,url:window.location.href})}catch{}}}}function xp(){const e=X(()=>Tl.value.length>0);function t(n,o){Mi({kind:"visible-error",message:n,url:o||(typeof window>"u"?void 0:window.location.href)})}return{diagnostics:Tl,hasFeedbackDiagnostics:e,recordVisibleFailure:t,openFeedbackMail:w1,buildFeedbackMailto:My,feedbackMailtoBase:m1}}const $y="codex-web-local.recycle-bin.v1";function jy(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem($y);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>!!n&&typeof n.id=="string"&&typeof n.title=="string"):[]}catch{return[]}}function zm(e){if(!(typeof window>"u"))try{window.localStorage.setItem($y,JSON.stringify(e))}catch{}}const is=A(jy());function k1(){function e(){is.value=jy()}function t(r){is.value=[{...r,archivedAtIso:new Date().toISOString()},...is.value.filter(s=>s.id!==r.id)],zm(is.value)}function n(r){is.value=is.value.filter(s=>s.id!==r),zm(is.value)}async function o(r){if(!is.value.some(s=>s.id===r))return{ok:!1,error:"Thread is not in the recycle bin"};try{return await j_(r),n(r),{ok:!0}}catch(s){return{ok:!1,error:s instanceof Error?s.message:"Failed to restore thread"}}}return{records:is,loadRecords:e,recordArchivedThread:t,removeArchivedRecord:n,restoreArchivedThread:o}}const C1=["title","aria-label","disabled"],T1={key:1,class:"composer-dropdown-value"},S1={key:0,class:"composer-dropdown-search-wrap"},_1=["placeholder","onKeydown"],x1={class:"composer-dropdown-options",role:"listbox"},A1=["onClick"],P1={key:0,class:"composer-dropdown-empty"},I1=tn({__name:"ComposerDropdown",props:{modelValue:{},options:{},placeholder:{},disabled:{type:Boolean},selectedPrefixIcon:{},iconOnly:{type:Boolean},openDirection:{},menuAlign:{},enableSearch:{type:Boolean},searchPlaceholder:{},emptyLabel:{},variant:{}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,o=t,r=A(null),s=A(null),a=A(null),l=A(null),d=A(!1),h=A(""),v=A({});let y=!1;const _=X(()=>{var Ae;const xe=n.options.find(Ue=>Ue.value===n.modelValue);return xe?xe.label:((Ae=n.placeholder)==null?void 0:Ae.trim())||""}),P=X(()=>n.openDirection??"down"),j=X(()=>n.menuAlign??"start"),B=X(()=>n.iconOnly===!0),J=X(()=>n.enableSearch===!0),ce=X(()=>n.variant==="pill"?"composer-dropdown-trigger--pill":""),U=X(()=>{var xe;return((xe=n.searchPlaceholder)==null?void 0:xe.trim())||"Quick search projects"}),V=X(()=>{var xe;return((xe=n.emptyLabel)==null?void 0:xe.trim())||"No results"}),K=X(()=>{var xe;return _.value||((xe=n.placeholder)==null?void 0:xe.trim())||"Select option"}),ye=X(()=>{const xe=h.value.trim().toLowerCase();return xe?n.options.filter(Ae=>Ae.label.toLowerCase().includes(xe)||Ae.value.toLowerCase().includes(xe)):n.options});function _e(){n.disabled||(d.value=!d.value)}function we(xe,Ae,Ue){return Math.min(Ue,Math.max(Ae,xe))}function $e(){var te,oe,z,Be;if(!d.value)return;const xe=r.value;if(!xe||typeof window>"u")return;const Ae=xe.getBoundingClientRect(),Ue=window.innerWidth,Ye=window.innerHeight,He=8,At=8,ct=Math.max(0,Ue-He*2),Qe=((te=a.value)==null?void 0:te.offsetWidth)??((oe=s.value)==null?void 0:oe.offsetWidth)??224,et=((z=a.value)==null?void 0:z.offsetHeight)??((Be=s.value)==null?void 0:Be.offsetHeight)??0,ft=Math.min(Qe,ct),mt=Math.max(He,Ue-ft-He),kt=j.value==="end"?Ae.right-ft:Ae.left,at=we(kt,He,mt);let ae=P.value==="up"?Ae.top-et-At:Ae.bottom+At;et>0&&ae+et>Ye-He&&(ae=Ye-et-He),ae=Math.max(He,ae),v.value={position:"fixed",left:`${at}px`,right:"auto",top:`${ae}px`,bottom:"auto",width:`${ft}px`}}function de(){y||typeof window>"u"||(window.addEventListener("resize",$e),window.addEventListener("scroll",$e,!0),y=!0)}function Le(){!y||typeof window>"u"||(window.removeEventListener("resize",$e),window.removeEventListener("scroll",$e,!0),y=!1)}function je(xe){o("update:modelValue",xe),d.value=!1,h.value=""}function fe(){if(h.value.length>0){h.value="";return}d.value=!1}function Te(xe){if(!d.value)return;const Ae=r.value;if(!Ae)return;const Ue=xe.target;Ue instanceof Node&&(Ae.contains(Ue)||(d.value=!1,h.value=""))}return nt(d,xe=>{if(!xe){Le(),v.value={};return}de(),Wt(()=>{var Ae;$e(),window.requestAnimationFrame($e),J.value&&((Ae=l.value)==null||Ae.focus())})}),ws(()=>{window.addEventListener("pointerdown",Te)}),qi(()=>{window.removeEventListener("pointerdown",Te),Le()}),(xe,Ae)=>(S(),I("div",{ref_key:"rootRef",ref:r,class:"composer-dropdown"},[p("button",{class:Ke(["composer-dropdown-trigger",ce.value]),type:"button",title:K.value,"aria-label":K.value,disabled:e.disabled,onClick:_e},[e.selectedPrefixIcon?(S(),tt(cp(e.selectedPrefixIcon),{key:0,class:"composer-dropdown-prefix-icon"})):ee("",!0),B.value?ee("",!0):(S(),I("span",T1,T(_.value),1)),Ie(Js,{class:"composer-dropdown-chevron"})],10,C1),d.value?(S(),I("div",{key:0,ref_key:"menuWrapRef",ref:s,class:Ke(["composer-dropdown-menu-wrap",{"composer-dropdown-menu-wrap-up":P.value==="up","composer-dropdown-menu-wrap-down":P.value==="down"}]),style:kr(v.value)},[p("div",{ref_key:"menuRef",ref:a,class:"composer-dropdown-menu"},[J.value?(S(),I("div",S1,[Lt(p("input",{ref_key:"searchInputRef",ref:l,"onUpdate:modelValue":Ae[0]||(Ae[0]=Ue=>h.value=Ue),class:"composer-dropdown-search-input",type:"text",placeholder:U.value,onKeydown:An(lt(fe,["prevent"]),["esc"])},null,40,_1),[[an,h.value]])])):ee("",!0),p("ul",x1,[(S(!0),I(ze,null,_t(ye.value,Ue=>(S(),I("li",{key:Ue.value},[p("button",{class:Ke(["composer-dropdown-option",{"is-selected":Ue.value===e.modelValue}]),type:"button",onClick:Ye=>je(Ue.value)},T(Ue.label),11,A1)]))),128)),ye.value.length===0?(S(),I("li",P1,T(V.value),1)):ee("",!0)])],512)],6)):ee("",!0)],512))}}),or=bt(I1,[["__scopeId","data-v-48e2516e"]]),E1={},R1={xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24","aria-hidden":"true"};function M1(e,t){return S(),I("svg",R1,[...t[0]||(t[0]=[p("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"},null,-1)])])}const Ru=bt(E1,[["render",M1]]),$1=["aria-label","onKeydown"],j1={class:"app-dialog-header"},L1={class:"app-dialog-title-wrap"},N1={class:"app-dialog-title"},O1={key:0,class:"app-dialog-subtitle"},D1=["aria-label","title"],F1={class:"app-dialog-body"},U1={key:0,class:"app-dialog-footer"},B1=tn({__name:"AppDialog",props:{open:{type:Boolean},title:{},subtitle:{default:""},ariaLabel:{default:""},size:{default:"sm"}},emits:["close"],setup(e,{emit:t}){const n=e,o=t,{t:r}=io();function s(){o("close")}function a(l){n.open&&l.key==="Escape"&&(l.preventDefault(),s())}return nt(()=>n.open,l=>{typeof window>"u"||(l?window.addEventListener("keydown",a):window.removeEventListener("keydown",a))},{immediate:!0}),qi(()=>{typeof window>"u"||window.removeEventListener("keydown",a)}),(l,d)=>(S(),tt(Xs,{to:"body"},[e.open?(S(),I("div",{key:0,class:"app-dialog-overlay",onClick:lt(s,["self"])},[p("div",{class:Ke(["app-dialog-panel",`app-dialog-panel--${e.size}`]),role:"dialog","aria-modal":"true","aria-label":e.ariaLabel||e.title,onKeydown:An(lt(s,["prevent"]),["esc"])},[p("div",j1,[p("div",L1,[p("h3",N1,T(e.title),1),e.subtitle?(S(),I("p",O1,T(e.subtitle),1)):ee("",!0)]),p("button",{class:"app-dialog-close",type:"button","aria-label":g(r)("Close"),title:g(r)("Close"),onClick:s},[Ie(Ru,{class:"app-dialog-close-icon"})],8,D1)]),p("div",F1,[rr(l.$slots,"default",{},void 0)]),l.$slots.footer?(S(),I("div",U1,[rr(l.$slots,"footer",{},void 0)])):ee("",!0)],42,$1)])):ee("",!0)]))}}),df=bt(B1,[["__scopeId","data-v-0c988f32"]]),q1={key:0,class:"sidebar-menu-row-left"},z1={class:"sidebar-menu-row-main"},H1={key:1,class:"sidebar-menu-row-right"},W1={key:0,class:"sidebar-menu-row-right-default"},V1={key:1,class:"sidebar-menu-row-right-hover"},G1=tn({inheritAttrs:!1,__name:"SidebarMenuRow",props:{as:{default:"div"},forceRightHover:{type:Boolean,default:!1}},setup(e){const t=e,n=kk(),o=X(()=>!!n.left),r=X(()=>!!n.right),s=X(()=>!!n["right-hover"]),a=X(()=>r.value||s.value);return(l,d)=>(S(),tt(cp(t.as),Ug({class:"sidebar-menu-row","data-has-left":o.value,"data-has-right":a.value,"data-has-right-hover":s.value,"data-force-right-hover":t.forceRightHover},l.$attrs),{default:yt(()=>[o.value?(S(),I("span",q1,[rr(l.$slots,"left",{},void 0,!0)])):ee("",!0),p("span",z1,[rr(l.$slots,"default",{},void 0,!0)]),a.value?(S(),I("span",H1,[r.value?(S(),I("span",W1,[rr(l.$slots,"right",{},void 0,!0)])):ee("",!0),s.value?(S(),I("span",V1,[rr(l.$slots,"right-hover",{},void 0,!0)])):ee("",!0)])):ee("",!0)]),_:3},16,["data-has-left","data-has-right","data-has-right-hover","data-force-right-hover"]))}}),Ws=bt(G1,[["__scopeId","data-v-5fc666fb"]]),K1={},Y1={xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24","aria-hidden":"true"};function J1(e,t){return S(),I("svg",Y1,[...t[0]||(t[0]=[p("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 18v-6m0 0a4 4 0 0 1 4-4h2m-6 4a4 4 0 0 0-4-4H6m0-4a2 2 0 1 0 0 4a2 2 0 0 0 0-4m12 0a2 2 0 1 0 0 4a2 2 0 0 0 0-4m-6 14a2 2 0 1 0 0 4a2 2 0 0 0 0-4"},null,-1)])])}const Gu=bt(K1,[["render",J1]]),Q1={},X1={xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24","aria-hidden":"true"};function Z1(e,t){return S(),I("svg",X1,[...t[0]||(t[0]=[p("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 7h16M10 11v6M14 11v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3"},null,-1)])])}const Ly=bt(Q1,[["render",Z1]]),eA=["data-menu-open"],tA={class:"thread-left-stack"},nA=["data-state"],oA=["data-confirming","title"],rA={key:0,class:"thread-delete-confirm-label"},aA={class:"thread-row-title-wrap"},sA={class:"thread-row-title-line"},iA={class:"thread-row-title"},lA=["title"],cA={key:0,class:"thread-row-automation-count"},uA=["data-state"],dA={class:"thread-row-time"},fA=tn({__name:"SidebarThreadRow",props:{thread:{},selected:{type:Boolean},pinned:{type:Boolean},menuOpen:{type:Boolean},showStatusIndicator:{type:Boolean},threadState:{},inlineDeleteConfirming:{type:Boolean},automationCount:{},automationTooltip:{},requestLabel:{},relativeTime:{},deleteLabel:{},confirmDeleteLabel:{},confirmLabel:{},worktreeLabel:{},setMenuWrapRef:{type:Function}},emits:["select","inline-delete","menu-toggle","row-leave","row-contextmenu"],setup(e,{emit:t}){const n=e,o=t;function r(s){n.setMenuWrapRef(s instanceof HTMLDivElement?s:null)}return(s,a)=>(S(),I("li",{class:"thread-row-item","data-menu-open":n.menuOpen?"true":"false"},[Ie(Ws,{class:"thread-row","data-active":n.selected,"data-pinned":n.pinned,"data-menu-open":n.menuOpen?"true":"false","force-right-hover":n.menuOpen,onClick:a[3]||(a[3]=l=>o("select")),onMouseleave:a[4]||(a[4]=l=>o("row-leave",l)),onContextmenu:a[5]||(a[5]=l=>o("row-contextmenu",l))},{left:yt(()=>[p("span",tA,[n.showStatusIndicator?(S(),I("span",{key:0,class:"thread-status-indicator","data-state":n.threadState},null,8,nA)):ee("",!0),p("button",{class:"thread-delete-button",type:"button","data-confirming":n.inlineDeleteConfirming,title:n.inlineDeleteConfirming?n.confirmDeleteLabel:n.deleteLabel,onClick:a[0]||(a[0]=lt(l=>o("inline-delete"),["stop"]))},[n.inlineDeleteConfirming?(S(),I("span",rA,T(n.confirmLabel),1)):(S(),tt(Ly,{key:1,class:"thread-icon"}))],8,oA)])]),right:yt(()=>[p("span",dA,T(n.relativeTime),1)]),"right-hover":yt(()=>[p("div",{ref:r,class:"thread-menu-wrap"},[p("button",{class:"thread-menu-trigger",type:"button",title:"thread_menu",onClick:a[2]||(a[2]=lt(l=>o("menu-toggle"),["stop"]))},[Ie(Bf,{class:"thread-icon"})])])]),default:yt(()=>[p("button",{class:"thread-main-button",type:"button",onClick:a[1]||(a[1]=lt(l=>o("select"),["stop"]))},[p("span",aA,[p("span",sA,[p("span",iA,T(n.thread.title),1),n.thread.hasWorktree?(S(),tt(Gu,{key:0,class:"thread-row-worktree-icon",title:n.worktreeLabel},null,8,["title"])):ee("",!0),n.automationCount>0?(S(),I("span",{key:1,class:"thread-row-automation-chip",title:n.automationTooltip},[Ie(Ys,{class:"thread-row-automation-icon"}),n.automationCount>1?(S(),I("span",cA,T(n.automationCount),1)):ee("",!0)],8,lA)):ee("",!0),n.thread.pendingRequestState?(S(),I("span",{key:2,class:"thread-row-request-chip","data-state":n.thread.pendingRequestState},T(n.requestLabel),9,uA)):ee("",!0)])])])]),_:1},8,["data-active","data-pinned","data-menu-open","force-right-hover"])],8,eA))}}),vu=bt(fA,[["__scopeId","data-v-f14bf478"]]);function pA(e,t,n){return n.canPruneMissing?e.filter(o=>t.has(o)):e}const hA={key:0,class:"pinned-section"},mA={class:"thread-tree-header"},vA={key:0,class:"thread-list"},gA={class:"projects-section"},yA={class:"thread-tree-header"},wA=["aria-expanded","aria-label","title"],bA={class:"organize-menu-title"},kA=["data-active"],CA={key:0},TA=["data-active"],SA={key:0},_A=["data-active"],xA={key:0},AA={class:"organize-menu-title"},PA=["data-active"],IA={key:0},EA=["data-active"],RA={key:0},MA={key:0,class:"thread-tree-action-error"},$A={key:1,class:"thread-tree-no-results"},jA={key:2,class:"thread-tree-loading"},LA={key:3,class:"thread-list thread-list-global"},NA=["data-project-name","data-expanded","data-dragging"],OA={class:"project-icon-stack"},DA={class:"project-icon-folder"},FA={class:"project-icon-chevron"},UA=["data-dragging-handle","onMousedown"],BA=["title"],qA=["title"],zA={key:0,class:"thread-row-automation-count"},HA={class:"project-hover-controls"},WA=["onClick"],VA=["data-open-direction"],GA=["onClick"],KA=["onClick"],YA=["onClick"],JA=["onClick"],QA=["onClick"],XA=["onClick"],ZA={class:"project-menu-label"},eP=["onInput"],tP=["aria-label","title","onClick"],nP={key:0,class:"thread-list"},oP={class:"project-empty"},rP=["onClick"],aP={class:"chats-section"},sP={class:"thread-tree-header"},iP={class:"chats-section-actions"},lP=["aria-label","title"],cP={key:0,class:"thread-tree-no-results"},uP={key:1,class:"thread-list thread-list-global"},dP=["data-open-direction"],fP=["disabled","title"],pP=["placeholder","onKeydown"],hP={key:0,class:"recycle-bin-empty"},mP={key:1,class:"recycle-bin-list"},vP={class:"recycle-bin-item-copy"},gP={class:"recycle-bin-item-title"},yP={key:0,class:"recycle-bin-item-meta"},wP={class:"recycle-bin-item-time"},bP={class:"recycle-bin-item-actions"},kP=["disabled","onClick"],CP=["onClick"],TP={key:2,class:"recycle-bin-error",role:"alert"},SP=["aria-label"],_P={class:"rename-thread-title"},xP={class:"rename-thread-subtitle"},AP={key:0,class:"automation-target-picker"},PP={class:"automation-target-mode-group",role:"radiogroup","aria-label":"Automation target type"},IP={class:"automation-target-dropdown"},EP=["aria-label"],RP=["onClick"],MP={class:"automation-thread-field"},$P={class:"automation-thread-label"},jP=["placeholder"],LP={class:"automation-thread-field"},NP={class:"automation-thread-label"},OP=["placeholder"],DP={class:"automation-thread-field"},FP={class:"automation-thread-label"},UP={class:"automation-schedule-mode-group",role:"radiogroup","aria-label":"Automation schedule type"},BP={key:0,class:"automation-schedule-row"},qP={class:"automation-schedule-copy"},zP={key:1,class:"automation-schedule-row"},HP={class:"automation-schedule-copy"},WP={class:"automation-schedule-preview"},VP={class:"automation-thread-field"},GP={class:"automation-thread-label"},KP={key:2,class:"rename-thread-subtitle automation-thread-error"},YP={key:3,class:"rename-thread-subtitle automation-thread-notice"},JP={class:"rename-thread-actions"},QP=["disabled"],XP=["disabled"],ZP=["disabled"],eI=["disabled"],tI=4,Hm=6,Wm="codex-web-local.sidebar-section-expansion.v1",Vm="codex-web-local.sidebar-chats-first.v1",Gm="codex-web-local.sidebar-chat-sort-mode.v1",Km="codex-web-local.thread-view-mode.v1",Ym="codex-web-local.collapsed-projects.v1",nI=tn({__name:"SidebarThreadTree",props:{groups:{},projectDisplayNameById:{},projectGitRepoByName:{},projectCwdByName:{},selectedThreadId:{},isLoading:{type:Boolean},isThreadListFullyLoaded:{type:Boolean},searchQuery:{},searchMatchedThreadIds:{}},emits:["select","archive","start-new-thread","browse-thread-files","save-thread-project","browse-project-files","save-project","request-project-git-status","create-project-worktree","rename-project","rename-thread","remove-project","reorder-project","copy-thread-chat","fork-thread","start-new-chat","automations-changed","restore-thread"],setup(e,{expose:t,emit:n}){const o=e,{t:r}=io(),{recordVisibleFailure:s}=xp(),a=n,{records:l,loadRecords:d,recordArchivedThread:h,removeArchivedRecord:v,restoreArchivedThread:y}=k1(),_=A(!1),P=A(""),j=A("");function B(){Qt.value=!1,P.value="",d(),_.value=!0}async function J(w){if(!j.value){j.value=w,P.value="";try{const k=await y(w);k.ok?a("restore-thread",w):P.value=k.error??"Failed to restore thread"}finally{j.value=""}}}const ce=A({}),U=A({}),V=A(!0),K=A(!0),ye=A(!0),_e=A(!1),we=A(ni(Vm,!1)),$e=A(Et());let de=!1;const Le=A([]),je=A({}),fe=A(""),Te=A([]),xe=A(""),Ae=A(""),Ue=A("hover"),Ye=A({}),He=A({}),At=A({}),ct=A("actions"),Qe=A(""),et=A(!1),ft=A(""),mt=A(""),kt=A(null),at=A(!1),ae=A(""),te=A(""),oe=A({}),z=A({}),Be=A(!1),$=A("thread"),O=A(""),G=A(""),ue=A(""),ie=A("create"),re=A(!1),Se=A("thread"),be=A(""),pe=A(""),se=A(""),Ee=A(""),ge=A(!1),Fe=A(!1),Me=A({name:"",prompt:"",rrule:"FREQ=DAILY;BYHOUR=9;BYMINUTE=0",status:"ACTIVE"}),Ve=A({mode:"daily",dailyTime:"09:00",interval:1,intervalUnit:"hours"}),rt=X(()=>{if($.value==="project"){const k=G.value;return k?z.value[k]??[]:[]}const w=O.value;return w?oe.value[w]??[]:[]}),gt=X(()=>fn(Me.value.rrule)),It=X(()=>re.value&&ie.value==="create"?Se.value==="thread"?r("This creates a heartbeat automation attached to the selected chat."):r("This creates a project automation attached to the selected project folder."):$.value==="project"?r("This creates project automations attached to the selected project folder."):r("This creates heartbeat automations attached to the selected thread.")),Tt=X(()=>{var k;const w=[];for(const C of o.groups)for(const D of C.threads){const Ce=((k=D.title)==null?void 0:k.trim())||D.id,st=no(C.projectName);w.push({value:D.id,label:`${Ce} · ${st}`,searchText:`${Ce} ${st} ${D.id}`.toLowerCase()})}return w}),Tn=X(()=>{const w=[];for(const k of o.groups){const C=Mo(k.projectName);if(!C)continue;const D=no(k.projectName);w.push({value:C,label:D,searchText:`${D} ${C}`.toLowerCase()})}return w}),H=X(()=>(Se.value==="project"?Tn.value:Tt.value).map(k=>({value:k.value,label:k.label}))),W=[{value:"minutes",label:r("minutes")},{value:"hours",label:r("hours")},{value:"days",label:r("days")}],Y=X(()=>[{value:"ACTIVE",label:r("Active")},{value:"PAUSED",label:r("Paused")}]);nt(H,w=>{var k;re.value&&(w.some(C=>C.value===be.value)||(be.value=((k=w[0])==null?void 0:k.value)??""))});const me=A(null),Oe=A(null),We=A(null);let Ze=null,Ft=null;const Nt=A(""),Kn=A({}),lo=new Map,co=new Map,uo=new Map,fo=new WeakMap,za=A(null),Cr=A(null),Qt=A(!1),ut=A(bs()),gn=typeof window<"u"?new ResizeObserver(w=>{for(const k of w){const C=k.target,D=fo.get(C);D&&wn(D,C)}}):null;function zo(){if(typeof window>"u")return{};try{const w=window.localStorage.getItem(Ym);if(!w)return{};const k=JSON.parse(w);return!k||typeof k!="object"||Array.isArray(k)?{}:k}catch{return{}}}function bs(){return typeof window>"u"?"project":window.localStorage.getItem(Km)==="chronological"?"chronological":"project"}function ni(w,k){if(typeof window>"u")return k;const C=window.localStorage.getItem(w);return C==="true"?!0:C==="false"?!1:k}function Et(){return typeof window>"u"?"updated":window.localStorage.getItem(Gm)==="created"?"created":"updated"}U.value=zo();function Ut(){if(!(typeof window>"u"))try{const w=JSON.parse(window.localStorage.getItem(Wm)||"{}");typeof w.pinned=="boolean"&&(V.value=w.pinned),typeof w.projects=="boolean"&&(K.value=w.projects),typeof w.chats=="boolean"&&(ye.value=w.chats)}catch{}}function ht(){typeof window>"u"||window.localStorage.setItem(Wm,JSON.stringify({pinned:V.value,projects:K.value,chats:ye.value}))}Ut(),nt(U,w=>{typeof window>"u"||window.localStorage.setItem(Ym,JSON.stringify(w))},{deep:!0}),nt(ut,w=>{typeof window>"u"||window.localStorage.setItem(Km,w)}),nt(we,w=>{typeof window>"u"||window.localStorage.setItem(Vm,String(w))}),nt($e,w=>{typeof window>"u"||window.localStorage.setItem(Gm,w)}),nt([V,K,ye],ht);const Ho=X(()=>o.searchQuery.trim().toLowerCase()),dn=X(()=>Ho.value.length>0),sr=X(()=>o.searchMatchedThreadIds?new Set(o.searchMatchedThreadIds):null),ir=X(()=>new Set(Le.value)),Yn=X(()=>new Set(Te.value));function lr(w){if(Yn.value.has(w.id))return!1;if(!dn.value)return!0;if(sr.value)return sr.value.has(w.id);const k=Ho.value;return w.title.toLowerCase().includes(k)||w.preview.toLowerCase().includes(k)}const ba=X(()=>o.groups.flatMap(w=>{const k=w.threads.filter(C=>!Wu(C.cwd)&&lr(C));return k.length>0?[{...w,threads:k}]:!dn.value&&w.threads.length===0?[{...w,threads:k}]:[]})),Ha=X(()=>ut.value==="chronological"),Dn=X(()=>{const w=[];for(const k of o.groups)for(const C of k.threads)ir.value.has(C.id)||lr(C)&&w.push(C);return w.sort((k,C)=>{const D=new Date(k.updatedAtIso||k.createdAtIso).getTime();return new Date(C.updatedAtIso||C.createdAtIso).getTime()-D})}),In=X(()=>{const w=Dn.value.filter(C=>Wu(C.cwd)),k=$e.value==="created"?"createdAtIso":"updatedAtIso";return w.sort((C,D)=>{const Ce=new Date(C[k]||C.updatedAtIso||C.createdAtIso).getTime();return new Date(D[k]||D.updatedAtIso||D.createdAtIso).getTime()-Ce})}),Gr=X(()=>dn.value||_e.value?In.value:In.value.slice(0,10)),Ao=X(()=>dn.value?!1:In.value.length>10),nn=X(()=>{const w=new Map;for(const k of o.groups)for(const C of k.threads)Yn.value.has(C.id)||w.set(C.id,C);return w});nt(Le,w=>{de&&Mx(w)}),nt([nn,()=>o.isThreadListFullyLoaded],([w])=>{const k=pA(Le.value,new Set(w.keys()),{canPruneMissing:o.isThreadListFullyLoaded});if(k.length===Le.value.length)return;const C=new Set(k),D=Object.fromEntries(Object.entries(je.value).filter(([Ce])=>C.has(Ce)));je.value=D,Le.value=k});let Kr=0;async function Yt(){if(o.isLoading)return;const w=Le.value.filter(Ce=>!nn.value.has(Ce)&&!je.value[Ce]);if(w.length===0)return;const k=Kr+=1,C=await Promise.all(w.map(async Ce=>{try{return await e_(Ce)}catch{return null}}));if(k!==Kr)return;const D={...je.value};for(const Ce of C)Ce&&(D[Ce.id]=Ce);je.value=D}nt([Le,nn,()=>o.isLoading],()=>{de&&Yt()}),ws(async()=>{const{threadIds:w}=await Rx(),k=Array.isArray(w)?w.filter(C=>typeof C=="string").map(C=>C.trim()).filter((C,D,Ce)=>C.length>0&&Ce.indexOf(C)===D):[];k.length>0&&(Le.value=k);try{oe.value=await g_()}catch{oe.value={}}try{await Gt()}catch{z.value={}}de=!0,Yt()});const Yr=X(()=>_r(ae.value)),ka=X(()=>{const w=te.value;return Yr.value?r('This will archive the thread "{title}" and remove the attached heartbeat automations.',{title:w}):r('This will archive the thread "{title}". You can find it later in archived threads.',{title:w})}),Jn=X(()=>{const w=new Map;for(const k of o.groups)for(const C of k.threads)w.set(C.id,k.projectName);return w}),Qn=X(()=>{const w=new Map;for(const k of o.groups){const C=k.threads.filter(D=>!ir.value.has(D.id)&&!Yn.value.has(D.id));w.set(k.projectName,C)}return w}),Po=X(()=>{const w=new Map;for(const k of o.groups)for(const C of k.threads){const D=new Date(C.updatedAtIso||C.createdAtIso).getTime();w.set(C.id,D)}return w}),Pt=X(()=>{const w=Ae.value;return w?nn.value.get(w)??null:null}),$t=X(()=>Le.value.map(w=>nn.value.get(w)??je.value[w]??null).filter(w=>w!==null).filter(lr));function zn(){V.value=!V.value}function po(){K.value=!K.value}function Hn(){ye.value=!ye.value}const Xn=X(()=>{const w=We.value;if(!w||w.dropTargetIndexFull===null||o.groups.length===0)return null;const k=Math.max(0,Math.min(w.dropTargetIndexFull,o.groups.length)),C=k>w.fromIndex?k-1:k,D=Math.max(0,Math.min(C,o.groups.length-1));return D===w.fromIndex?null:D}),Mn=X(()=>{const k=(dn.value?ba.value:o.groups).map(Rt=>Rt.projectName),C=We.value,D=Xn.value;if(!C||D===null)return k;const Ce=[...k],[st]=Ce.splice(C.fromIndex,1);return st?(Ce.splice(D,0,st),Ce):k}),Io=X(()=>{const w={};let k=0;for(const C of Mn.value)w[C]=k,k+=Un(C);return w}),ho=X(()=>{let w=0;for(const k of Mn.value)w+=Un(k);return{height:`${Math.max(0,w)}px`}});function Tr(w){if(Number.isNaN(w))return"n/a";const k=Math.abs(Date.now()-w);if(k<6e4)return r("now");const C=Math.floor(k/6e4);if(C<60)return`${C}m`;const D=Math.floor(C/60);return D<24?`${D}h`:`${Math.floor(D/24)}d`}function Sr(w){const k=Po.value.get(w.id);return Tr(typeof k=="number"?k:new Date(w.updatedAtIso||w.createdAtIso).getTime())}function oi(w){const k=new Date(w).getTime();return Number.isNaN(k)?"":new Date(k).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Wo(w){return ir.value.has(w)}function Wa(w){if(Wo(w)){Le.value=Le.value.filter(k=>k!==w);return}Le.value=[w,...Le.value]}function Ca(w){Wa(w),Ge()}function cr(w){fe.value="",a("select",w)}function _r(w){return ur(w)>0}function ur(w){var k;return((k=oe.value[w])==null?void 0:k.length)??0}function Ct(w){return Fn(w)>0}function Fn(w){var C;const k=Mo(w);return k?((C=z.value[k])==null?void 0:C.length)??0:0}function Sn(w){if(w.length===0)return"";if(w.length>1){const D=w.filter(Ce=>Ce.status==="ACTIVE").length;return`${w.length} ${r("automations")} • ${D} ${r("active")}`}const[k]=w,C=k.status==="PAUSED"?"-":k.nextRunAtMs?new Date(k.nextRunAtMs).toLocaleString():r("Not scheduled");return`${k.name} • ${r("Next run")}: ${C}`}function sn(w){return Sn(oe.value[w]??[])}function mo(w){const k=Mo(w);return Sn(k?z.value[k]??[]:[])}function Vo(w){return String(Math.max(0,w)).padStart(2,"0")}function En(w,k){const C=typeof w=="number"?w:Number(w);return Number.isFinite(C)?Math.max(1,Math.floor(C)):k}function Wn(w){const[k,C]=w.split(":"),D=Math.min(23,Math.max(0,Number(k)||0)),Ce=Math.min(59,Math.max(0,Number(C)||0));return`FREQ=DAILY;BYHOUR=${D};BYMINUTE=${Ce}`}function xt(w,k){const C=En(w,1);return k==="minutes"?`FREQ=MINUTELY;INTERVAL=${C}`:k==="hours"?`FREQ=HOURLY;INTERVAL=${C}`:`FREQ=DAILY;INTERVAL=${C}`}function yn(w){return Object.fromEntries(w.split(";").map(k=>k.trim()).filter(Boolean).map(k=>{const[C,...D]=k.split("=");return[C.toUpperCase(),D.join("=").trim()]}).filter(([k,C])=>k&&C))}function Bt(w){var Ce;const k=yn(w),C=(Ce=k.FREQ)==null?void 0:Ce.toUpperCase(),D=En(k.INTERVAL,1);if(C==="DAILY"&&k.BYHOUR!==void 0&&k.BYMINUTE!==void 0&&D===1){const st=Math.min(23,Math.max(0,Number(k.BYHOUR)||0)),Rt=Math.min(59,Math.max(0,Number(k.BYMINUTE)||0));return{mode:"daily",dailyTime:`${Vo(st)}:${Vo(Rt)}`,interval:1,intervalUnit:"hours"}}return C==="MINUTELY"||C==="HOURLY"||C==="DAILY"&&k.INTERVAL!==void 0?{mode:"interval",dailyTime:"09:00",interval:D,intervalUnit:C==="MINUTELY"?"minutes":C==="HOURLY"?"hours":"days"}:{mode:"advanced",dailyTime:"09:00",interval:1,intervalUnit:"hours"}}function fn(w){var Ce;const k=yn(w),C=(Ce=k.FREQ)==null?void 0:Ce.toUpperCase(),D=En(k.INTERVAL,1);if(C==="DAILY"&&k.BYHOUR!==void 0&&k.BYMINUTE!==void 0&&D===1){const st=Math.min(23,Math.max(0,Number(k.BYHOUR)||0)),Rt=Math.min(59,Math.max(0,Number(k.BYMINUTE)||0));return`${r("RRULE")}: ${w} · ${r("runs daily at")} ${Vo(st)}:${Vo(Rt)}`}return C==="MINUTELY"?`${r("RRULE")}: ${w} · ${r("runs every")} ${D} ${r("minute(s)")}`:C==="HOURLY"?`${r("RRULE")}: ${w} · ${r("runs every")} ${D} ${r("hour(s)")}`:C==="DAILY"&&k.INTERVAL!==void 0?`${r("RRULE")}: ${w} · ${r("runs every")} ${D} ${r("day(s)")}`:w?`${r("RRULE")}: ${w}`:r("RRULE is required.")}function Vn(){const w=Ve.value;w.mode==="daily"?Me.value.rrule=Wn(w.dailyTime):w.mode==="interval"&&(Me.value.rrule=xt(w.interval,w.intervalUnit))}function Zn(w){w!=="minutes"&&w!=="hours"&&w!=="days"||(Ve.value={...Ve.value,intervalUnit:w},Vn())}function vo(w){w!=="ACTIVE"&&w!=="PAUSED"||(Me.value={...Me.value,status:w})}function xr(){Ve.value=Bt(Me.value.rrule)}function Go(w){Ve.value={...Ve.value,mode:w},Vn()}function Jr(w){w===o.selectedThreadId&&(a("copy-thread-chat",w),Ge())}function Ko(w){a("fork-thread",w),Ge()}function Eo(w){return`${r("start new thread")} ${no(w)}`}function Ar(w){a("start-new-thread",w)}function go(w){a("browse-thread-files",w),Ge()}function M(w){a("save-thread-project",w),Ge()}async function F(w){var C,D;const k=((D=(C=nn.value.get(w))==null?void 0:C.cwd)==null?void 0:D.trim())??"";if(Ge(),!(!k||typeof navigator>"u"||!navigator.clipboard))try{await navigator.clipboard.writeText(k)}catch{}}function ne(w,k){if(Ae.value===w&&Ue.value==="hover"){if(k){const C=k.relatedTarget,D=Cr.value;if(C instanceof Node&&D&&D.contains(C))return}Ge()}}function Pe(w){return Ae.value===w}function Ge(){Ae.value="",Ue.value="hover",At.value={}}function qt(w){if(fe.value="",Ae.value===w){Ge();return}Ue.value="hover",$n(),Qt.value=!1,Ae.value=w,Wt(()=>{Jo(w)})}function pn(w,k){w.preventDefault(),fe.value="",Ue.value="contextmenu",Ae.value=k}function Xt(w,k){ft.value=w,mt.value=k,et.value=!0,Ge(),Wt(()=>{var C,D;(C=kt.value)==null||C.focus(),(D=kt.value)==null||D.select()})}function jt(){et.value=!1,ft.value="",mt.value=""}function Pr(){const w=ft.value,k=mt.value.trim();!w||!k||(a("rename-thread",{threadId:w,title:k}),jt())}function yo(w,k){fe.value="",ae.value=w,te.value=k,at.value=!0,Ge()}function Ta(){at.value=!1,ae.value="",te.value=""}async function Ml(){const w=ae.value;w&&(ks(w),Ta())}function Qr(w){return fe.value===w}function Gn(w){if(fe.value!==w){fe.value=w,Ge();return}ks(w),fe.value=""}function ks(w){var C,D;const k=nn.value.get(w)??null;Yn.value.has(w)||(Te.value=[w,...Te.value]),fe.value="",Ge(),h({id:w,title:((C=k==null?void 0:k.title)==null?void 0:C.trim())||"(untitled)",cwd:((D=k==null?void 0:k.cwd)==null?void 0:D.trim())??"",projectName:Jn.value.get(w)??""}),Le.value=Le.value.filter(Ce=>Ce!==w),a("archive",w),_r(w)&&(Cm(w).catch(()=>{}),oe.value=to(oe.value,w))}function _n(w){var C;$.value="thread",O.value=w,G.value="",re.value=!1,pe.value="",se.value="";const k=(C=oe.value[w])==null?void 0:C[0];k?Ro(k.id):hn(),Be.value=!0,Ge()}function ri(w){var D;const k=Mo(w);if(!k){$.value="project",O.value="",G.value="",re.value=!1,pe.value=r("Project automation requires a resolved absolute project path."),se.value="",Be.value=!0,$n();return}$.value="project",O.value="",G.value=k,re.value=!1,pe.value="",se.value="";const C=(D=z.value[k])==null?void 0:D[0];C?Ro(C.id):hn(),Be.value=!0,$n()}function Hi(w){$.value=w.scope,O.value=w.scope==="thread"?w.target:"",G.value=w.scope==="project"?w.target:"",re.value=!1,pe.value="",se.value="",w.scope==="project"?z.value=si(z.value,w.target,w.automation):oe.value=Yo(oe.value,w.target,w.automation),Ro(w.automation.id),Be.value=!0,$n(),Ge()}function ai(){var w;re.value=!0,Se.value="thread",be.value=((w=Tt.value[0])==null?void 0:w.value)??"",$.value="thread",O.value="",G.value="",pe.value="",se.value="",hn(),Be.value=!0,$n(),Ge()}function ln(w){var k;Se.value=w,be.value="",$.value=w==="project"?"project":"thread",be.value=((k=H.value[0])==null?void 0:k.value)??""}function hn(){ue.value="",ie.value="create",pe.value="",se.value="",Me.value={name:$.value==="project"?"Project automation":"Thread automation",prompt:"",rrule:"FREQ=DAILY;BYHOUR=9;BYMINUTE=0",status:"ACTIVE"},Ve.value=Bt(Me.value.rrule)}function Ro(w){const k=rt.value.find(C=>C.id===w);k&&(ue.value=k.id,ie.value="edit",pe.value="",se.value="",Me.value={name:k.name,prompt:k.prompt,rrule:k.rrule,status:k.status},Ve.value=Bt(k.rrule))}function eo(){Be.value=!1,$.value="thread",O.value="",G.value="",ue.value="",pe.value="",se.value="",ge.value=!1,Fe.value=!1}function to(w,k){return Object.fromEntries(Object.entries(w).filter(([C])=>C!==k))}function Yo(w,k,C){const D=w[k]??[],Ce=D.findIndex(Rt=>Rt.id===C.id),st=[...D];return Ce>=0?st.splice(Ce,1,C):st.push(C),{...w,[k]:st}}function Cs(w,k,C){const D=(w[k]??[]).filter(Ce=>Ce.id!==C);return D.length>0?{...w,[k]:D}:to(w,k)}function Sa(w,k){return Object.fromEntries(Object.entries(w).filter(([C])=>C!==k))}function si(w,k,C){const D=w[k]??[],Ce=D.findIndex(Rt=>Rt.id===C.id),st=[...D];return Ce>=0?st.splice(Ce,1,C):st.push(C),{...w,[k]:st}}async function Gt(){z.value=await y_()}async function Zt(){let w=O.value,k=G.value;ge.value=!0,pe.value="",se.value="";try{if(Vn(),re.value&&ie.value==="create"&&(Se.value==="thread"?(w=be.value,k="",$.value="thread",O.value=w,G.value=""):(k=be.value,w="",$.value="project",O.value="",G.value=k)),$.value==="thread"&&!w)throw new Error(r("Select a chat target for this automation"));if($.value==="project"&&!k)throw new Error(r("Select a project target for this automation"));const C={id:ue.value||void 0,name:Me.value.name,prompt:Me.value.prompt,rrule:Me.value.rrule,status:Me.value.status},D=$.value==="project"?await b_({...C,projectName:k}):await w_({...C,threadId:w});$.value==="project"?await Gt():oe.value=Yo(oe.value,w,D),a("automations-changed"),Ro(D.id),se.value=r("Automation saved."),ge.value=!1}catch(C){pe.value=C instanceof Error?C.message:r("Failed to save automation"),ge.value=!1}}async function ii(){const w=O.value,k=G.value,C=ue.value;if(C&&!($.value==="thread"&&!w)&&!($.value==="project"&&!k)){ge.value=!0,pe.value="",se.value="";try{$.value==="project"?(await Tm(k,C),await Gt()):(await Cm(w,C),oe.value=Cs(oe.value,w,C));const D=rt.value[0];D?Ro(D.id):hn(),a("automations-changed"),ge.value=!1}catch(D){pe.value=D instanceof Error?D.message:r("Failed to remove automation"),ge.value=!1}}}async function Ts(){const w=O.value,k=ue.value;if(!(!w||!k)){Fe.value=!0,pe.value="",se.value="";try{await k_(w,k),se.value=r("Automation run queued.")}catch(C){pe.value=C instanceof Error?C.message:r("Failed to run automation")}finally{Fe.value=!1}}}function no(w){return o.projectDisplayNameById[w]??w}t({openAutomationEditorFromPanel:Hi,openAutomationCreatorFromPanel:ai,openRenameThreadDialog:Xt,openRecycleBin:B});function dr(w){return w.includes("/")||w.includes("\\")}function Wi(w){return dr(w)?w:no(w)}function fr(w){const k=br(w);if(!k)return!1;let C=0;for(const D of o.groups)if(dr(D.projectName)&&br(D.projectName)===k&&(C+=1,C>1))return!0;return!1}function li(w){const k=o.projectDisplayNameById[w.projectName],C=no(w.projectName),D=w.projectName;if(k&&!dr(D)&&D!==C)return C.includes(D)||/^[0-9a-f]{8}-[0-9a-f-]{27,}$/iu.test(D)?C:`${C} ${D}`;if(k&&dr(D)){const Rt=br(D),$o=br(Cl(D)),Kt=fr(D)?$o:Rt;return Kt&&Kt!==C?`${C} ${Kt}`:C}if(!C.includes("/")&&!C.includes("\\"))return C;const Ce=br(C)||C,st=br(Cl(C));return st.startsWith(".")&&st!==Ce?`${Ce} ${st}`:w.threads.length>0||!fr(D)?Ce:st?`${Ce} ${st}`:Ce}function _a(w){return xe.value===w}function $n(){xe.value="",ct.value="actions",Qe.value=""}function Va(){const w=!Qt.value;w&&($n(),Ge()),Qt.value=w}function ci(w){ut.value=w,Qt.value=!1}function ui(){we.value=!we.value}function Vi(w){$e.value=w}function Ss(w){a("request-project-git-status",w),Wt(()=>{Ka(w)})}function $l(w){if(xe.value===w){$n();return}Ge(),Qt.value=!1,xe.value=w,ct.value="actions",Qe.value=no(w),Ss(w)}function di(w){Ge(),Qt.value=!1,xe.value=w,ct.value="actions",Qe.value=no(w),Ss(w)}function Ir(w){return o.projectDisplayNameById[w.projectName]??li(w)}function Xr(w){Ge();const k=w.projectName;xe.value=k,ct.value="rename",Qe.value=Ir(w),Wt(()=>{Ka(k)})}function pr(w){a("browse-project-files",w),$n()}function Zr(w){a("save-project",w),$n()}function xa(w){a("create-project-worktree",w),$n()}function hr(w){a("rename-project",{projectName:w,displayName:Qe.value})}function Aa(w){const k=Mo(w);if(a("remove-project",w),k&&Ct(w)){Ee.value="";const C=z.value;z.value=Sa(z.value,k),Tm(k).then(Gt).catch(async D=>{z.value=C;const Ce=D instanceof Error?D.message:r("Failed to delete project automation");Ee.value=Ce,s(Ce);try{await Gt()}catch{z.value=C}}).finally(()=>{a("automations-changed")})}$n()}function Mo(w){var C;const k=((C=o.projectCwdByName[w])==null?void 0:C.trim())??"";return fS(k)?k:""}function Ga(w,k){if(!w.altKey||w.key!=="ArrowUp"&&w.key!=="ArrowDown")return;const C=o.groups.findIndex(st=>st.projectName===k);if(C<0)return;const D=w.key==="ArrowUp"?-1:1,Ce=Math.max(0,Math.min(C+D,o.groups.length-1));Ce!==C&&(w.preventDefault(),a("reorder-project",{projectName:k,toIndex:Ce}))}function Er(w){return ce.value[w]===!0}function wo(w){return U.value[w]===!0}function Rr(w){ce.value={...ce.value,[w]:!Er(w)}}function qe(){_e.value=!_e.value}function ke(w){if(Nt.value===w){Nt.value="";return}U.value={...U.value,[w]:!wo(w)}}function Un(w){const k=Kn.value[w]??0,C=We.value,Ce=((C==null?void 0:C.projectName)===w?C.groupHeight:null)??k,st=wo(w)?0:Hm;return Math.max(0,Ce+st)}function Pa(w,k){const C=k instanceof HTMLElement?k:k&&"$el"in k&&k.$el instanceof HTMLElement?k.$el:null;if(C){co.set(w,C);return}co.delete(w)}function mr(w,k){const C=k instanceof HTMLElement?k:k&&"$el"in k&&k.$el instanceof HTMLElement?k.$el:null;if(C){uo.set(w,C);return}uo.delete(w)}function _s(w){let k=w.parentElement;for(;k;){const C=window.getComputedStyle(k),D=C.overflowY||C.overflow;if(D==="auto"||D==="scroll"||D==="hidden"||D==="clip")return k.getBoundingClientRect();k=k.parentElement}return new DOMRect(0,0,window.innerWidth,window.innerHeight)}function cn(w,k){const C=w.getBoundingClientRect(),D=_s(w),Ce=6,st=D.bottom-C.bottom,Rt=C.top-D.top;return st>=k+Ce?"down":Rt>st?"up":"down"}function ea(w,k){const C=uo.get(w);if(!C)return"down";const D=cn(C,k);return He.value={...He.value,[w]:D},D}function jl(w){return He.value[w]??"down"}function Ka(w){const k=co.get(w);if(!k)return;const C=k.querySelector(".project-menu-panel"),D=(C==null?void 0:C.getBoundingClientRect().height)??0;Ye.value={...Ye.value,[w]:cn(k,D)}}function jn(w,k,C){return Math.min(Math.max(w,k),C)}function Jo(w){const k=uo.get(w);if(!k)return;const C=Cr.value,D=C==null?void 0:C.getBoundingClientRect(),Ce=(D==null?void 0:D.height)||(C==null?void 0:C.offsetHeight)||112,st=(D==null?void 0:D.width)||(C==null?void 0:C.offsetWidth)||160,Rt=ea(w,Ce),$o=k.getBoundingClientRect(),Kt=8,Nn=4,bn=Math.max(Kt,window.innerWidth-st-Kt),tr=jn($o.right-st,Kt,bn),Nr=jn(Rt==="up"?$o.top-Ce-Nn:$o.bottom+Nn,Kt,Math.max(Kt,window.innerHeight-Ce-Kt));At.value={left:`${Math.round(tr)}px`,top:`${Math.round(Nr)}px`}}function bo(){const w=Ae.value;w&&Jo(w)}function Mr(){window.addEventListener("resize",bo),document.addEventListener("scroll",bo,!0)}function Ln(){window.removeEventListener("resize",bo),document.removeEventListener("scroll",bo,!0)}function Ya(w){const k=xe.value;if(!k)return!1;const C=co.get(k);if(!C)return!1;if((typeof w.composedPath=="function"?w.composedPath():[]).includes(C))return!0;const Ce=w.target;return Ce instanceof Node?C.contains(Ce):!1}function Ia(w){const k=Ae.value;if(!k)return!1;const C=uo.get(k);if(!C)return!1;const D=typeof w.composedPath=="function"?w.composedPath():[];if(D.includes(C))return!0;const Ce=Cr.value;if(Ce&&D.includes(Ce))return!0;const st=w.target;return st instanceof Node?!!(C.contains(st)||Ce&&Ce.contains(st)):!1}function $r(w){if(Qt.value){const k=za.value,C=typeof w.composedPath=="function"?w.composedPath():[];!!k&&(C.includes(k)||w.target instanceof Node&&k.contains(w.target))||(Qt.value=!1)}xe.value&&(Ya(w)||$n(),Ae.value&&(Ia(w)||Ge()))}function fi(w){xe.value&&!Ya(w)&&$n(),Ae.value&&!Ia(w)&&Ge()}function Qo(){Qt.value&&(Qt.value=!1),xe.value&&$n(),Ae.value&&Ge()}function Xo(){window.addEventListener("pointerdown",$r,{capture:!0}),window.addEventListener("focusin",fi,{capture:!0}),window.addEventListener("blur",Qo)}function vr(){window.removeEventListener("pointerdown",$r,{capture:!0}),window.removeEventListener("focusin",fi,{capture:!0}),window.removeEventListener("blur",Qo)}function wn(w,k){const C=k.getBoundingClientRect().height;if(!Number.isFinite(C)||C<=0)return;const D=Kn.value[w];D!==void 0&&Math.abs(D-C)<.5||(Kn.value={...Kn.value,[w]:C})}function ta(w,k){const C=lo.get(w);C&&C!==k&&gn&&gn.unobserve(C);const D=k instanceof HTMLElement?k:k&&"$el"in k&&k.$el instanceof HTMLElement?k.$el:null;if(D){lo.set(w,D),fo.set(D,w),wn(w,D),gn==null||gn.observe(D);return}C&&(gn==null||gn.unobserve(C)),lo.delete(w)}function Ea(w,k){if(w.button!==0||dn.value||Oe.value||We.value)return;const C=o.groups.findIndex(Rt=>Rt.projectName===k),D=lo.get(k);if(C<0||!D)return;const Ce=D.getBoundingClientRect(),st=wo(k)?0:Hm;Oe.value={projectName:k,fromIndex:C,startClientX:w.clientX,startClientY:w.clientY,pointerOffsetY:w.clientY-Ce.top,groupLeft:Ce.left,groupWidth:Ce.width,groupHeight:Ce.height,groupOuterHeight:Ce.height+st},w.preventDefault(),na()}function na(){window.addEventListener("mousemove",Zo),window.addEventListener("mouseup",oa),window.addEventListener("keydown",Ra)}function Ja(){window.removeEventListener("mousemove",Zo),window.removeEventListener("mouseup",oa),window.removeEventListener("keydown",Ra)}function Zo(w){Ze={clientX:w.clientX,clientY:w.clientY},Ll()}function oa(w){pi({clientX:w.clientX,clientY:w.clientY});const k=We.value;if(k&&Xn.value!==null){const C=o.groups.findIndex(D=>D.projectName===k.projectName);if(C>=0){const D=Xn.value;D!==C&&a("reorder-project",{projectName:k.projectName,toIndex:D})}}Qa({preserveToggleSuppression:!!k})}function Ra(w){w.key==="Escape"&&(!Oe.value&&!We.value||(w.preventDefault(),Qa()))}function Qa(w={}){Ft!==null&&(window.cancelAnimationFrame(Ft),Ft=null),Ze=null,Oe.value=null,We.value=null,w.preserveToggleSuppression||(Nt.value=""),Ja()}function Ll(){Ft===null&&(Ft=window.requestAnimationFrame(()=>{if(Ft=null,!Ze)return;const w=Ze;Ze=null,pi(w)}))}function pi(w){const k=Oe.value;if(!We.value&&k){const C=w.clientX-k.startClientX,D=w.clientY-k.startClientY;if(Math.hypot(C,D)<tI)return;$n(),Nt.value=k.projectName,We.value={projectName:k.projectName,fromIndex:k.fromIndex,pointerOffsetY:k.pointerOffsetY,groupLeft:k.groupLeft,groupWidth:k.groupWidth,groupHeight:k.groupHeight,groupOuterHeight:k.groupOuterHeight,ghostTop:w.clientY-k.pointerOffsetY,dropTargetIndexFull:null}}We.value&&xs(w)}function xs(w){const k=We.value;if(!k)return;if(k.ghostTop=w.clientY-k.pointerOffsetY,!jr(w)){k.dropTargetIndexFull=null;return}const C=w.clientY,D=me.value;if(!D){k.dropTargetIndexFull=null;return}const Ce=D.getBoundingClientRect(),st=new Map(o.groups.map((Nn,bn)=>[Nn.projectName,bn])),Rt=o.groups.map(Nn=>Nn.projectName).filter(Nn=>Nn!==k.projectName);let $o=0,Kt=o.groups.length;for(const Nn of Rt){const bn=st.get(Nn);if(bn===void 0)continue;const tr=Un(Nn),Nr=Ce.top+$o+tr/2;if(C<Nr){Kt=bn;break}$o+=tr}k.dropTargetIndexFull=Kt}function jr(w){const k=me.value;if(!k)return!1;const C=k.getBoundingClientRect(),D=w.clientX>=C.left&&w.clientX<=C.right,Ce=w.clientY>=C.top-32&&w.clientY<=C.bottom+32;return D&&Ce}function Lr(w){var k;return((k=We.value)==null?void 0:k.projectName)===w}function ra(w){const k=We.value,C=Io.value[w]??0,D=Ae.value?Jn.value.get(Ae.value)??"":"",Ce=xe.value===w||D===w;return!k||k.projectName!==w?{position:"absolute",top:"0",left:"0",right:"0",zIndex:Ce?"40":"1",transform:`translate3d(0, ${C}px, 0)`,willChange:"transform",transition:"transform 180ms ease"}:{position:"fixed",top:"0",left:`${k.groupLeft}px`,width:`${k.groupWidth}px`,height:`${k.groupHeight}px`,zIndex:"50",pointerEvents:"none",transform:`translate3d(0, ${k.ghostTop}px, 0)`,willChange:"transform",transition:"transform 0ms linear"}}function Xa(w){return Qn.value.get(w.projectName)??[]}function Gi(w){if(dn.value)return Xa(w);if(wo(w.projectName))return[];const k=Xa(w);return Er(w.projectName)?k:k.slice(0,10)}function Jt(w){return dn.value?!1:!wo(w.projectName)&&Xa(w).length>10}function oo(w){return Xa(w).length>0}function xn(w){var k;return!!w.pendingRequestState||w.inProgress||w.unread||((k=w.externalSession)==null?void 0:k.active)===!0}function As(w){return w.pendingRequestState==="approval"?r("Awaiting approval"):r("Awaiting response")}function er(w){var k;return((k=w.externalSession)==null?void 0:k.active)===!0?"external":w.pendingRequestState==="approval"?"awaiting-approval":w.pendingRequestState==="response"?"awaiting-response":w.inProgress?"working":w.unread?"unread":"idle"}nt(()=>o.groups.map(w=>w.projectName),w=>{var Ce,st;const k=((Ce=We.value)==null?void 0:Ce.projectName)??((st=Oe.value)==null?void 0:st.projectName)??"";k&&!o.groups.some(Rt=>Rt.projectName===k)&&Qa();const C=new Set(w),D=Object.fromEntries(Object.entries(Kn.value).filter(([Rt])=>C.has(Rt)));Object.keys(D).length!==Object.keys(Kn.value).length&&(Kn.value=D)}),nt(()=>{const w=xe.value;return w?o.projectGitRepoByName[w]:void 0},()=>{const w=xe.value;w&&Wt(()=>{xe.value===w&&Ka(w)})});const Za=X(()=>Qt.value||xe.value!==""||Ae.value!=="");return nt(Za,w=>{if(w){Xo();return}vr()}),nt(Ae,w=>{if(!w){Ln();return}Mr(),Wt(()=>{Jo(w)})}),qi(()=>{for(const w of lo.values())gn==null||gn.unobserve(w);lo.clear(),co.clear(),Ln(),vr(),Qa()}),(w,k)=>(S(),I("section",{class:Ke(["thread-tree-root",{"chats-first":we.value}])},[$t.value.length>0?(S(),I("section",hA,[Ie(Ws,{as:"button",class:"section-toggle-row",type:"button","aria-expanded":V.value,onClick:zn},{left:yt(()=>[V.value?(S(),tt(Js,{key:1,class:"thread-icon"})):(S(),tt(mu,{key:0,class:"thread-icon"}))]),default:yt(()=>[p("span",mA,T(g(r)("Pinned")),1)]),_:1},8,["aria-expanded"]),V.value?(S(),I("ul",vA,[(S(!0),I(ze,null,_t($t.value,C=>(S(),tt(vu,{key:C.id,thread:C,selected:C.id===e.selectedThreadId,pinned:Wo(C.id),"menu-open":Pe(C.id),"show-status-indicator":xn(C),"thread-state":er(C),"inline-delete-confirming":Qr(C.id),"automation-count":ur(C.id),"automation-tooltip":sn(C.id),"request-label":As(C),"relative-time":Sr(C),"delete-label":g(r)("Delete thread"),"confirm-delete-label":g(r)("Confirm delete"),"confirm-label":g(r)("Confirm"),"worktree-label":g(r)("Worktree thread"),"set-menu-wrap-ref":D=>mr(C.id,D),onSelect:D=>cr(C.id),onInlineDelete:D=>Gn(C.id),onMenuToggle:D=>qt(C.id),onRowLeave:D=>ne(C.id,D),onRowContextmenu:D=>pn(D,C.id)},null,8,["thread","selected","pinned","menu-open","show-status-indicator","thread-state","inline-delete-confirming","automation-count","automation-tooltip","request-label","relative-time","delete-label","confirm-delete-label","confirm-label","worktree-label","set-menu-wrap-ref","onSelect","onInlineDelete","onMenuToggle","onRowLeave","onRowContextmenu"]))),128))])):ee("",!0)])):ee("",!0),p("section",gA,[Ie(Ws,{as:"button",class:"thread-tree-header-row section-toggle-row",type:"button","aria-expanded":K.value,onClick:po},{left:yt(()=>[K.value?(S(),tt(Js,{key:1,class:"thread-icon"})):(S(),tt(mu,{key:0,class:"thread-icon"}))]),right:yt(()=>[p("div",{ref_key:"organizeMenuWrapRef",ref:za,class:"organize-menu-wrap"},[p("button",{class:"organize-menu-trigger",type:"button","aria-expanded":Qt.value,"aria-label":g(r)("Organize threads"),title:g(r)("Organize threads"),onClick:lt(Va,["stop"])},[Ie(Bf,{class:"thread-icon"})],8,wA),Qt.value?(S(),I("div",{key:0,class:"organize-menu-panel",onClick:k[4]||(k[4]=lt(()=>{},["stop"]))},[p("p",bA,T(g(r)("Organize")),1),p("button",{class:"organize-menu-item","data-active":ut.value==="project",type:"button",onClick:k[0]||(k[0]=C=>ci("project"))},[p("span",null,T(g(r)("By project")),1),ut.value==="project"?(S(),I("span",CA,"✓")):ee("",!0)],8,kA),p("button",{class:"organize-menu-item","data-active":ut.value==="chronological",type:"button",onClick:k[1]||(k[1]=C=>ci("chronological"))},[p("span",null,T(g(r)("Chronological list")),1),ut.value==="chronological"?(S(),I("span",SA,"✓")):ee("",!0)],8,TA),p("button",{class:"organize-menu-item","data-active":we.value,type:"button",onClick:ui},[p("span",null,T(g(r)("Chats first")),1),we.value?(S(),I("span",xA,"✓")):ee("",!0)],8,_A),k[31]||(k[31]=p("div",{class:"organize-menu-separator"},null,-1)),p("p",AA,T(g(r)("Sort by")),1),p("button",{class:"organize-menu-item","data-active":$e.value==="created",type:"button",onClick:k[2]||(k[2]=C=>Vi("created"))},[p("span",null,T(g(r)("Created")),1),$e.value==="created"?(S(),I("span",IA,"✓")):ee("",!0)],8,PA),p("button",{class:"organize-menu-item","data-active":$e.value==="updated",type:"button",onClick:k[3]||(k[3]=C=>Vi("updated"))},[p("span",null,T(g(r)("Updated")),1),$e.value==="updated"?(S(),I("span",RA,"✓")):ee("",!0)],8,EA),k[32]||(k[32]=p("div",{class:"organize-menu-separator"},null,-1)),p("button",{class:"organize-menu-item",type:"button",onClick:B},[p("span",null,T(g(r)("Recycle bin")),1)])])):ee("",!0)],512)]),default:yt(()=>[p("span",yA,T(g(r)("Projects")),1)]),_:1},8,["aria-expanded"]),K.value?(S(),I(ze,{key:0},[Ee.value?(S(),I("p",MA,T(Ee.value),1)):ee("",!0),dn.value&&ba.value.length===0?(S(),I("p",$A,T(g(r)("No matching threads")),1)):e.isLoading&&e.groups.length===0?(S(),I("p",jA,T(g(r)("Loading threads...")),1)):Ha.value?(S(),I("ul",LA,[(S(!0),I(ze,null,_t(Dn.value,C=>(S(),tt(vu,{key:C.id,thread:C,selected:C.id===e.selectedThreadId,pinned:Wo(C.id),"menu-open":Pe(C.id),"show-status-indicator":xn(C),"thread-state":er(C),"inline-delete-confirming":Qr(C.id),"automation-count":ur(C.id),"automation-tooltip":sn(C.id),"request-label":As(C),"relative-time":Sr(C),"delete-label":g(r)("Delete thread"),"confirm-delete-label":g(r)("Confirm delete"),"confirm-label":g(r)("Confirm"),"worktree-label":g(r)("Worktree thread"),"set-menu-wrap-ref":D=>mr(C.id,D),onSelect:D=>cr(C.id),onInlineDelete:D=>Gn(C.id),onMenuToggle:D=>qt(C.id),onRowLeave:D=>ne(C.id,D),onRowContextmenu:D=>pn(D,C.id)},null,8,["thread","selected","pinned","menu-open","show-status-indicator","thread-state","inline-delete-confirming","automation-count","automation-tooltip","request-label","relative-time","delete-label","confirm-delete-label","confirm-label","worktree-label","set-menu-wrap-ref","onSelect","onInlineDelete","onMenuToggle","onRowLeave","onRowContextmenu"]))),128))])):(S(),I("div",{key:4,ref_key:"groupsContainerRef",ref:me,class:"thread-tree-groups",style:kr(ho.value)},[(S(!0),I(ze,null,_t(ba.value,C=>(S(),I("article",{key:C.projectName,ref_for:!0,ref:D=>ta(C.projectName,D),class:"project-group","data-project-name":C.projectName,"data-expanded":!wo(C.projectName),"data-dragging":Lr(C.projectName),style:kr(ra(C.projectName))},[Ie(Ws,{as:"div",class:"project-header-row",role:"button",tabindex:"0",onClick:D=>ke(C.projectName),onContextmenu:lt(D=>di(C.projectName),["prevent"]),onKeydown:[D=>Ga(D,C.projectName),An(lt(D=>ke(C.projectName),["prevent"]),["enter"]),An(lt(D=>ke(C.projectName),["prevent"]),["space"])]},{left:yt(()=>[p("span",OA,[p("span",DA,[wo(C.projectName)?(S(),tt(_p,{key:0,class:"thread-icon"})):(S(),tt(o1,{key:1,class:"thread-icon"}))]),p("span",FA,[wo(C.projectName)?(S(),tt(mu,{key:0,class:"thread-icon"})):(S(),tt(Js,{key:1,class:"thread-icon"}))])])]),right:yt(()=>[p("div",HA,[p("div",{ref_for:!0,ref:D=>Pa(C.projectName,D),class:"project-menu-wrap"},[p("button",{class:"project-menu-trigger",type:"button",title:"project_menu",onClick:lt(D=>$l(C.projectName),["stop"])},[Ie(Bf,{class:"thread-icon"})],8,WA),_a(C.projectName)?(S(),I("div",{key:0,class:"project-menu-panel","data-open-direction":Ye.value[C.projectName]??"down",onClick:k[6]||(k[6]=lt(()=>{},["stop"]))},[ct.value==="actions"?(S(),I(ze,{key:0},[p("button",{class:"project-menu-item",type:"button",onClick:D=>pr(C.projectName)},T(g(r)("Browse files")),9,GA),p("button",{class:"project-menu-item",type:"button",onClick:D=>Zr(C.projectName)},T(g(r)("Export Project")),9,KA),p("button",{class:"project-menu-item",type:"button",onClick:D=>ri(C.projectName)},T(Ct(C.projectName)?g(r)("Manage automations…"):g(r)("Add automation…")),9,YA),e.projectGitRepoByName[C.projectName]?(S(),I("button",{key:0,class:"project-menu-item",type:"button",onClick:D=>xa(C.projectName)},T(g(r)("New worktree")),9,JA)):ee("",!0),p("button",{class:"project-menu-item",type:"button",onClick:D=>Xr(C)},T(g(r)("Rename project")),9,QA),p("button",{class:"project-menu-item project-menu-item-danger",type:"button",onClick:D=>Aa(C.projectName)},T(g(r)("Remove")),9,XA)],64)):(S(),I(ze,{key:1},[p("label",ZA,T(g(r)("Project name")),1),Lt(p("input",{"onUpdate:modelValue":k[5]||(k[5]=D=>Qe.value=D),class:"project-menu-input",type:"text",onInput:D=>hr(C.projectName)},null,40,eP),[[an,Qe.value]])],64))],8,VA)):ee("",!0)],512),p("button",{class:"thread-start-button",type:"button","aria-label":Eo(C.projectName),title:Eo(C.projectName),onClick:lt(D=>Ar(C.projectName),["stop"])},[Ie(Bi,{class:"thread-icon"})],8,tP)])]),default:yt(()=>[p("span",{class:"project-main-button","data-dragging-handle":Lr(C.projectName),onMousedown:lt(D=>Ea(D,C.projectName),["left"])},[p("span",{class:"project-title",title:Wi(C.projectName)},T(li(C)),9,BA),Ct(C.projectName)?(S(),I("span",{key:0,class:"thread-row-automation-chip",title:mo(C.projectName)},[Ie(Ys,{class:"thread-row-automation-icon"}),Fn(C.projectName)>1?(S(),I("span",zA,T(Fn(C.projectName)),1)):ee("",!0)],8,qA)):ee("",!0)],40,UA)]),_:2},1032,["onClick","onContextmenu","onKeydown"]),oo(C)?(S(),I("ul",nP,[(S(!0),I(ze,null,_t(Gi(C),D=>(S(),tt(vu,{key:D.id,thread:D,selected:D.id===e.selectedThreadId,pinned:Wo(D.id),"menu-open":Pe(D.id),"show-status-indicator":xn(D),"thread-state":er(D),"inline-delete-confirming":Qr(D.id),"automation-count":ur(D.id),"automation-tooltip":sn(D.id),"request-label":As(D),"relative-time":Sr(D),"delete-label":g(r)("Delete thread"),"confirm-delete-label":g(r)("Confirm delete"),"confirm-label":g(r)("Confirm"),"worktree-label":g(r)("Worktree thread"),"set-menu-wrap-ref":Ce=>mr(D.id,Ce),onSelect:Ce=>cr(D.id),onInlineDelete:Ce=>Gn(D.id),onMenuToggle:Ce=>qt(D.id),onRowLeave:Ce=>ne(D.id,Ce),onRowContextmenu:Ce=>pn(Ce,D.id)},null,8,["thread","selected","pinned","menu-open","show-status-indicator","thread-state","inline-delete-confirming","automation-count","automation-tooltip","request-label","relative-time","delete-label","confirm-delete-label","confirm-label","worktree-label","set-menu-wrap-ref","onSelect","onInlineDelete","onMenuToggle","onRowLeave","onRowContextmenu"]))),128))])):(S(),tt(Ws,{key:1,as:"p",class:"project-empty-row"},{left:yt(()=>[...k[33]||(k[33]=[p("span",{class:"project-empty-spacer"},null,-1)])]),default:yt(()=>[p("span",oP,T(g(r)("No threads")),1)]),_:1})),Jt(C)?(S(),tt(Ws,{key:2,class:"thread-show-more-row"},{left:yt(()=>[...k[34]||(k[34]=[p("span",{class:"thread-show-more-spacer"},null,-1)])]),default:yt(()=>[p("button",{class:"thread-show-more-button",type:"button",onClick:D=>Rr(C.projectName)},T(Er(C.projectName)?"Show less":"Show more"),9,rP)]),_:2},1024)):ee("",!0)],12,NA))),128))],4))],64)):ee("",!0)]),p("section",aP,[Ie(Ws,{as:"button",class:"section-toggle-row",type:"button","aria-expanded":ye.value,onClick:Hn},{left:yt(()=>[ye.value?(S(),tt(Js,{key:1,class:"thread-icon"})):(S(),tt(mu,{key:0,class:"thread-icon"}))]),right:yt(()=>[p("div",iP,[p("button",{class:"chats-section-action",type:"button","aria-label":g(r)("New chat"),title:g(r)("New chat"),onClick:k[7]||(k[7]=lt(C=>w.$emit("start-new-chat"),["stop"]))},[Ie(Bi,{class:"thread-icon"})],8,lP)])]),default:yt(()=>[p("span",sP,T(g(r)("Chats")),1)]),_:1},8,["aria-expanded"]),ye.value&&In.value.length===0?(S(),I("p",cP,T(g(r)("No chats")),1)):ye.value?(S(),I("ul",uP,[(S(!0),I(ze,null,_t(Gr.value,C=>(S(),tt(vu,{key:C.id,thread:C,selected:C.id===e.selectedThreadId,pinned:Wo(C.id),"menu-open":Pe(C.id),"show-status-indicator":xn(C),"thread-state":er(C),"inline-delete-confirming":Qr(C.id),"automation-count":ur(C.id),"automation-tooltip":sn(C.id),"request-label":As(C),"relative-time":Sr(C),"delete-label":g(r)("Delete thread"),"confirm-delete-label":g(r)("Confirm delete"),"confirm-label":g(r)("Confirm"),"worktree-label":g(r)("Worktree thread"),"set-menu-wrap-ref":D=>mr(C.id,D),onSelect:D=>cr(C.id),onInlineDelete:D=>Gn(C.id),onMenuToggle:D=>qt(C.id),onRowLeave:D=>ne(C.id,D),onRowContextmenu:D=>pn(D,C.id)},null,8,["thread","selected","pinned","menu-open","show-status-indicator","thread-state","inline-delete-confirming","automation-count","automation-tooltip","request-label","relative-time","delete-label","confirm-delete-label","confirm-label","worktree-label","set-menu-wrap-ref","onSelect","onInlineDelete","onMenuToggle","onRowLeave","onRowContextmenu"]))),128))])):ee("",!0),ye.value&&Ao.value?(S(),tt(Ws,{key:2,class:"thread-show-more-row"},{left:yt(()=>[...k[35]||(k[35]=[p("span",{class:"thread-show-more-spacer"},null,-1)])]),default:yt(()=>[p("button",{class:"thread-show-more-button",type:"button",onClick:qe},T(_e.value?"Show less":"Show more"),1)]),_:1})):ee("",!0)]),(S(),tt(Xs,{to:"body"},[Pt.value?(S(),I("div",{key:0,ref_key:"openThreadMenuPanelRef",ref:Cr,class:"thread-menu-panel thread-menu-panel-fixed",style:kr(At.value),"data-open-direction":jl(Pt.value.id),onClick:k[17]||(k[17]=lt(()=>{},["stop"]))},[p("button",{class:"thread-menu-item",type:"button",onClick:k[8]||(k[8]=C=>_n(Pt.value.id))},T(_r(Pt.value.id)?g(r)("Manage automations…"):g(r)("Add automation…")),1),p("button",{class:"thread-menu-item",type:"button",onClick:k[9]||(k[9]=C=>go(Pt.value.id))},T(g(r)("Browse files")),1),p("button",{class:"thread-menu-item",type:"button",onClick:k[10]||(k[10]=C=>M(Pt.value.id))},T(g(r)("Export Project")),1),p("button",{class:"thread-menu-item",type:"button",onClick:k[11]||(k[11]=C=>F(Pt.value.id))},T(g(r)("Copy path")),1),p("button",{class:"thread-menu-item",type:"button",disabled:Pt.value.id!==e.selectedThreadId,title:Pt.value.id===e.selectedThreadId?g(r)("Copy chat"):g(r)("Open this chat before copying"),onClick:k[12]||(k[12]=C=>Jr(Pt.value.id))},T(g(r)("Copy chat")),9,fP),p("button",{class:"thread-menu-item",type:"button",onClick:k[13]||(k[13]=C=>Ko(Pt.value.id))},T(g(r)("Create chat fork")),1),p("button",{class:"thread-menu-item",type:"button",onClick:k[14]||(k[14]=C=>Ca(Pt.value.id))},T(Wo(Pt.value.id)?g(r)("Unpin thread"):g(r)("Pin thread")),1),p("button",{class:"thread-menu-item",type:"button",onClick:k[15]||(k[15]=C=>Xt(Pt.value.id,Pt.value.title))},T(g(r)("Rename thread")),1),p("button",{class:"thread-menu-item thread-menu-item-danger",type:"button",onClick:k[16]||(k[16]=C=>yo(Pt.value.id,Pt.value.title))},T(g(r)("Delete thread")),1)],12,dP)):ee("",!0)])),Ie(df,{open:et.value,title:g(r)("Rename thread"),subtitle:g(r)("Make it short and recognizable."),onClose:jt},{footer:yt(()=>[p("button",{class:"rename-thread-button",type:"button",onClick:jt},T(g(r)("Cancel")),1),p("button",{class:"rename-thread-button rename-thread-button-primary",type:"button",onClick:Pr},T(g(r)("Save")),1)]),default:yt(()=>[Lt(p("input",{ref_key:"renameThreadInputRef",ref:kt,"onUpdate:modelValue":k[18]||(k[18]=C=>mt.value=C),class:"rename-thread-input",type:"text",placeholder:g(r)("Add title..."),onKeydown:An(lt(Pr,["prevent"]),["enter"])},null,40,pP),[[an,mt.value]])]),_:1},8,["open","title","subtitle"]),Ie(df,{open:at.value,title:Yr.value?g(r)("Archive chat and remove automations?"):g(r)("Delete thread?"),subtitle:ka.value,onClose:Ta},{footer:yt(()=>[p("button",{class:"rename-thread-button",type:"button",onClick:Ta},T(g(r)("Cancel")),1),p("button",{class:"rename-thread-button rename-thread-button-danger",type:"button",onClick:Ml},T(Yr.value?g(r)("Archive and remove"):g(r)("Delete")),1)]),_:1},8,["open","title","subtitle"]),Ie(df,{open:_.value,title:g(r)("Recycle bin"),subtitle:g(r)("Threads you removed are kept here so you can restore them."),size:"md",onClose:k[19]||(k[19]=C=>_.value=!1)},{default:yt(()=>[g(l).length===0?(S(),I("div",hP,T(g(r)("Recycle bin is empty.")),1)):(S(),I("ul",mP,[(S(!0),I(ze,null,_t(g(l),C=>(S(),I("li",{key:C.id,class:"recycle-bin-item"},[p("div",vP,[p("span",gP,T(C.title),1),C.projectName?(S(),I("span",yP,T(C.projectName),1)):ee("",!0),p("span",wP,T(oi(C.archivedAtIso)),1)]),p("div",bP,[p("button",{class:"recycle-bin-button recycle-bin-button-primary",type:"button",disabled:j.value===C.id,onClick:D=>J(C.id)},T(j.value===C.id?g(r)("Restoring…"):g(r)("Restore")),9,kP),p("button",{class:"recycle-bin-button recycle-bin-button-danger",type:"button",onClick:D=>g(v)(C.id)},T(g(r)("Delete permanently")),9,CP)])]))),128))])),P.value?(S(),I("p",TP,T(P.value),1)):ee("",!0)]),_:1},8,["open","title","subtitle"]),(S(),tt(Xs,{to:"body"},[Be.value?(S(),I("div",{key:0,class:"rename-thread-overlay",onClick:lt(eo,["self"])},[p("div",{class:"rename-thread-panel automation-thread-panel",role:"dialog","aria-modal":"true","aria-label":$.value==="project"?g(r)("Project automation"):g(r)("Thread automation")},[p("h3",_P,T(ie.value==="edit"?g(r)("Edit automation"):g(r)("Add automation")),1),p("p",xP,T(It.value),1),re.value&&ie.value==="create"?(S(),I("div",AP,[k[36]||(k[36]=p("span",{class:"automation-thread-label"},"Target",-1)),p("div",PP,[p("button",{class:Ke(["automation-target-mode",{"is-active":Se.value==="thread"}]),type:"button",onClick:k[20]||(k[20]=C=>ln("thread"))}," Existing chat ",2),p("button",{class:Ke(["automation-target-mode",{"is-active":Se.value==="project"}]),type:"button",onClick:k[21]||(k[21]=C=>ln("project"))}," Project ",2)]),p("div",IP,[Ie(or,{modelValue:be.value,"onUpdate:modelValue":k[22]||(k[22]=C=>be.value=C),class:"automation-thread-dropdown",options:H.value,placeholder:Se.value==="project"?"Select project":"Select chat","enable-search":"","search-placeholder":Se.value==="project"?"Search projects":"Search chats"},null,8,["modelValue","options","placeholder","search-placeholder"])])])):ee("",!0),rt.value.length>0?(S(),I("div",{key:1,class:"automation-thread-list","aria-label":$.value==="project"?"Project automations":"Thread automations"},[(S(!0),I(ze,null,_t(rt.value,C=>(S(),I("button",{key:C.id,class:Ke(["automation-thread-list-item",{"is-active":C.id===ue.value}]),type:"button",onClick:D=>Ro(C.id)},[p("span",null,T(C.name),1),p("small",null,T(C.status==="PAUSED"?"Paused":"Active"),1)],10,RP))),128)),p("button",{class:"automation-thread-list-item automation-thread-list-add",type:"button",onClick:hn},T(g(r)("Add another automation")),1)],8,EP)):ee("",!0),p("label",MP,[p("span",$P,T(g(r)("Name")),1),Lt(p("input",{"onUpdate:modelValue":k[23]||(k[23]=C=>Me.value.name=C),class:"rename-thread-input",type:"text",placeholder:g(r)("Automation name")},null,8,jP),[[an,Me.value.name]])]),p("label",LP,[p("span",NP,T(g(r)("Prompt")),1),Lt(p("textarea",{"onUpdate:modelValue":k[24]||(k[24]=C=>Me.value.prompt=C),class:"automation-thread-textarea",rows:"6",placeholder:g(r)("Describe what the automation should do")},null,8,OP),[[an,Me.value.prompt]])]),p("div",DP,[p("span",FP,T(g(r)("Schedule")),1),p("div",UP,[p("button",{class:Ke(["automation-schedule-mode",{"is-active":Ve.value.mode==="daily"}]),type:"button",onClick:k[25]||(k[25]=C=>Go("daily"))},T(g(r)("Daily")),3),p("button",{class:Ke(["automation-schedule-mode",{"is-active":Ve.value.mode==="interval"}]),type:"button",onClick:k[26]||(k[26]=C=>Go("interval"))},T(g(r)("Interval")),3),p("button",{class:Ke(["automation-schedule-mode",{"is-active":Ve.value.mode==="advanced"}]),type:"button",onClick:k[27]||(k[27]=C=>Go("advanced"))}," RRULE ",2)]),Ve.value.mode==="daily"?(S(),I("div",BP,[p("span",qP,T(g(r)("Run every day at")),1),Lt(p("input",{"onUpdate:modelValue":k[28]||(k[28]=C=>Ve.value.dailyTime=C),class:"automation-schedule-time",type:"time",onInput:Vn},null,544),[[an,Ve.value.dailyTime]])])):Ve.value.mode==="interval"?(S(),I("div",zP,[p("span",HP,T(g(r)("Run every")),1),Lt(p("input",{"onUpdate:modelValue":k[29]||(k[29]=C=>Ve.value.interval=C),class:"automation-schedule-number",type:"number",min:"1",step:"1",onInput:Vn},null,544),[[an,Ve.value.interval,void 0,{number:!0}]]),Ie(or,{class:"automation-schedule-unit-dropdown","model-value":Ve.value.intervalUnit,options:W,placeholder:g(r)("Unit"),"onUpdate:modelValue":Zn},null,8,["model-value","placeholder"])])):ee("",!0),Ve.value.mode==="advanced"?Lt((S(),I("input",{key:2,"onUpdate:modelValue":k[30]||(k[30]=C=>Me.value.rrule=C),class:"rename-thread-input",type:"text",placeholder:"FREQ=DAILY;BYHOUR=9;BYMINUTE=0",onInput:xr},null,544)),[[an,Me.value.rrule]]):ee("",!0),p("p",WP,T(gt.value),1)]),p("div",VP,[p("span",GP,T(g(r)("Status")),1),Ie(or,{class:"automation-thread-dropdown","model-value":Me.value.status,options:Y.value,placeholder:g(r)("Status"),"onUpdate:modelValue":vo},null,8,["model-value","options","placeholder"])]),pe.value?(S(),I("p",KP,T(pe.value),1)):se.value?(S(),I("p",YP,T(se.value),1)):ee("",!0),p("div",JP,[ie.value==="edit"&&$.value==="thread"?(S(),I("button",{key:0,class:"rename-thread-button",type:"button",disabled:ge.value||Fe.value,onClick:Ts},T(Fe.value?g(r)("Running…"):g(r)("Run now")),9,QP)):ee("",!0),ie.value==="edit"?(S(),I("button",{key:1,class:"rename-thread-button rename-thread-button-danger",type:"button",disabled:ge.value||Fe.value,onClick:ii},T(g(r)("Remove")),9,XP)):ee("",!0),p("button",{class:"rename-thread-button",type:"button",disabled:ge.value||Fe.value,onClick:eo},T(g(r)("Cancel")),9,ZP),p("button",{class:"rename-thread-button rename-thread-button-primary",type:"button",disabled:ge.value||Fe.value,onClick:Zt},T(ge.value?g(r)("Saving…"):g(r)("Save")),9,eI)])],8,SP)])):ee("",!0)]))],2))}}),oI=bt(nI,[["__scopeId","data-v-2f390881"]]),rI={class:"content-header"},aI=["title"],sI={class:"content-actions"},iI=tn({__name:"ContentHeader",props:{title:{},accent:{type:Boolean}},setup(e){return(t,n)=>(S(),I("header",rI,[p("div",{class:Ke(["content-leading",{"is-accent":e.accent}])},[rr(t.$slots,"leading",{},void 0)],2),p("h1",{class:Ke(["content-title",{"is-accent":e.accent}]),title:e.title},T(e.title),11,aI),p("div",sI,[rr(t.$slots,"actions",{},void 0)])]))}}),lI=bt(iI,[["__scopeId","data-v-61739409"]]),Jm=.0025,ff=3,Qm=2,cI=256;function uI(e){var je;const t=A("idle"),n=A(typeof navigator<"u"&&!!((je=navigator.mediaDevices)!=null&&je.getUserMedia)),o=A(0),r=A(null);let s=null,a=null,l=[],d=null,h=null,v=null,y=null,_=[],P=!1,j=!1,B=null;function J(){B&&(B.abort(),B=null),t.value==="transcribing"&&(t.value="idle")}function ce(){const fe=r.value;if(!fe||typeof window>"u")return;const Te=fe.getContext("2d");if(!Te)return;const xe=Math.max(1,Math.floor(fe.clientWidth)),Ae=Math.max(1,Math.floor(fe.clientHeight||36)),Ue=window.devicePixelRatio||1,Ye=Math.max(1,Math.floor(xe*Ue)),He=Math.max(1,Math.floor(Ae*Ue));(fe.width!==Ye||fe.height!==He)&&(fe.width=Ye,fe.height=He),Te.setTransform(Ue,0,0,Ue,0,0),Te.clearRect(0,0,xe,Ae);const At=Math.max(12,Math.floor(xe/(ff+Qm))),ct=_.slice(-At),Qe=Math.max(0,At-ct.length),et=Ae/2,ft=getComputedStyle(fe).color||"#000000";for(let mt=0;mt<At;mt+=1){const kt=ct[mt-Qe]??0,ae=Math.max(.08,Math.min(1,kt*18))*et,te=mt*(ff+Qm);Te.globalAlpha=kt<=Jm?.35:1,Te.fillStyle=ft,Te.fillRect(te,et-ae,ff,ae*2)}Te.globalAlpha=1}function U(){_=[],o.value=0,ce()}function V(){v&&(v.disconnect(),v.onaudioprocess=null,v=null),h&&(h.disconnect(),h=null),d&&(d.close(),d=null),y=null}function K(fe){if(typeof window>"u")return;const Te=window.webkitAudioContext,xe=window.AudioContext??Te;xe&&(V(),U(),d=new xe,h=d.createMediaStreamSource(fe),v=d.createScriptProcessor(2048,1,1),y=performance.now(),v.onaudioprocess=Ae=>{const Ue=Ae.inputBuffer.getChannelData(0);let Ye=0;for(let He=0;He<Ue.length;He+=1){const At=Math.abs(Ue[He]??0);Ye+=At<Jm?0:At}_.push(Ye/Ue.length),_.length>cI&&_.shift(),y!==null&&(o.value=Math.max(0,performance.now()-y)),ce()},h.connect(v),v.connect(d.destination),ce())}async function ye(){var fe;if(t.value==="transcribing"&&J(),!(t.value!=="idle"||!n.value||P)){P=!0,j=!1;try{a=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1}}),l=[],s=new MediaRecorder(a),s.ondataavailable=Te=>{Te.data.size>0&&l.push(Te.data)},s.onstop=()=>{var Ae;const Te=l,xe=(s==null?void 0:s.mimeType)||((Ae=Te[0])==null?void 0:Ae.type)||"audio/webm";de(),$e(Te,xe)},K(a),s.start(250),t.value="recording",j&&_e()}catch(Te){de(),t.value="idle",(fe=e.onError)==null||fe.call(e,Te)}finally{P=!1}}}function _e(){if(P&&t.value==="idle"){j=!0;return}if(!(t.value!=="recording"||!s)&&s.state!=="inactive"){t.value="transcribing";try{s.requestData()}catch{}s.stop()}}function we(){j=!1,J(),de(),t.value="idle"}async function $e(fe,Te){var Ue,Ye,He,At,ct;if(fe.length===0){(Ue=e.onEmpty)==null||Ue.call(e),t.value="idle";return}const xe=new Blob(fe,{type:Te});t.value="transcribing";let Ae=null;try{const Qe=Te.split(/[/;]/)[1]??"webm",et=new FormData;et.append("file",xe,`codex.${Qe}`);const ft=((Ye=e.getLanguage)==null?void 0:Ye.call(e).trim())??"";ft&&ft.toLowerCase()!=="auto"&&et.append("language",ft),Ae=new AbortController,B=Ae;const mt=await fetch("/codex-api/transcribe",{method:"POST",body:et,signal:Ae.signal}),kt=await mt.text();let at=null;try{at=kt.trim()?JSON.parse(kt):null}catch{at=null}if(!mt.ok){const te=(He=at==null?void 0:at.error)==null?void 0:He.trim(),oe=kt.trim();throw new Error(te||oe||`Transcription failed: ${mt.status}`)}const ae=((at==null?void 0:at.text)??"").trim();ae.length>0?e.onTranscript(ae):(At=e.onEmpty)==null||At.call(e)}catch(Qe){if(Qe instanceof DOMException&&Qe.name==="AbortError")return;(ct=e.onError)==null||ct.call(e,Qe)}finally{Ae&&B===Ae&&(B=null),t.value==="transcribing"&&(t.value="idle")}}function de(){V(),U(),s&&(s.ondataavailable=null,s.onstop=null,s=null),a&&(a.getTracks().forEach(fe=>fe.stop()),a=null),l=[]}qi(()=>{we()});function Le(){if(t.value==="recording"){_e();return}(t.value==="idle"||t.value==="transcribing")&&ye()}return{state:t,isSupported:n,recordingDurationMs:o,waveformCanvasRef:r,startRecording:ye,stopRecording:_e,toggleRecording:Le,cancel:we}}const dI={},fI={xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24","aria-hidden":"true"};function pI(e,t){return S(),I("svg",fI,[...t[0]||(t[0]=[p("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m12 5l0 14m-6-8l6-6l6 6"},null,-1)])])}const hI=bt(dI,[["render",pI]]),mI={},vI={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"};function gI(e,t){return S(),I("svg",vI,[...t[0]||(t[0]=[p("path",{d:"M4 8V4h4"},null,-1),p("path",{d:"M20 8V4h-4"},null,-1),p("path",{d:"M4 16v4h4"},null,-1),p("path",{d:"M20 16v4h-4"},null,-1)])])}const yI=bt(mI,[["render",gI]]),wI={},bI={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"};function kI(e,t){return S(),I("svg",bI,[...t[0]||(t[0]=[p("path",{d:"M8 4v4H4"},null,-1),p("path",{d:"M16 4v4h4"},null,-1),p("path",{d:"M8 20v-4H4"},null,-1),p("path",{d:"M16 20v-4h4"},null,-1)])])}const CI=bt(wI,[["render",kI]]),TI={},SI={xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24","aria-hidden":"true"};function _I(e,t){return S(),I("svg",SI,[...t[0]||(t[0]=[p("path",{stroke:"none",fill:"none",d:"M0 0h24v24H0z"},null,-1),p("path",{fill:"currentColor",d:"M8 5a3 3 0 0 0 -3 3v8a3 3 0 0 0 3 3h8a3 3 0 0 0 3 -3v-8a3 3 0 0 0 -3 -3h-8z"},null,-1)])])}const xI=bt(TI,[["render",_I]]),AI=["aria-label"],PI=tn({__name:"ComposerPopover",props:{open:{type:Boolean},align:{},width:{},panelClass:{},ariaLabel:{}},emits:["update:open"],setup(e,{expose:t,emit:n}){const o=e,r=n,s=A(null),a=A(null),l=X(()=>o.open),d=X(()=>o.width==="lg"?"composer-popover-panel--lg":"composer-popover-panel--md");nt(l,async y=>{var _;y&&(await Wt(),(_=a.value)==null||_.focus())});function h(){r("update:open",!o.open)}function v(y){var ce,U,V;if(y.key==="Escape"){r("update:open",!1);return}const _=a.value;if(!_)return;const P=Array.from(_.querySelectorAll("button")).filter(K=>!K.disabled&&K.offsetParent!==null);if(P.length===0)return;if(y.key==="Home"){y.preventDefault(),(ce=P[0])==null||ce.focus();return}if(y.key==="End"){y.preventDefault(),(U=P[P.length-1])==null||U.focus();return}if(y.key!=="ArrowDown"&&y.key!=="ArrowUp")return;y.preventDefault();let j=P.findIndex(K=>K===document.activeElement);j<0&&(j=y.key==="ArrowDown"?-1:0);const B=y.key==="ArrowDown"?1:-1,J=(j+B+P.length)%P.length;(V=P[J])==null||V.focus()}return t({root:s}),(y,_)=>(S(),I("div",{ref_key:"rootRef",ref:s,class:Ke(["composer-popover-anchor",{"is-align-end":e.align==="end","is-align-center":e.align==="center"}])},[rr(y.$slots,"trigger",{toggle:h,isOpen:l.value},void 0),Ie(Mc,{name:"composer-popover"},{default:yt(()=>[l.value?(S(),I("div",{key:0,ref_key:"panelRef",ref:a,class:Ke(["composer-popover-panel",[d.value,e.panelClass]]),role:"menu",tabindex:"-1","aria-label":e.ariaLabel,onKeydown:v},[rr(y.$slots,"default",{},void 0,!0)],42,AI)):ee("",!0)]),_:3})],2))}}),Ku=bt(PI,[["__scopeId","data-v-bdd45c16"]]),II=["aria-label"],EI={class:"composer-popover-group-label"},RI=["aria-selected","onMousedown"],MI={class:"thread-composer-slash-body"},$I={class:"thread-composer-slash-name"},jI={class:"thread-composer-slash-desc"},LI={class:"thread-composer-slash-kind"},NI={class:"composer-popover-group-label composer-popover-group-label--skills"},OI=["aria-selected","onMousedown"],DI=["aria-label","title"],FI={class:"thread-composer-slash-body thread-composer-slash-body--skill"},UI={class:"thread-composer-slash-skill-name"},BI={class:"thread-composer-slash-desc thread-composer-slash-desc--skill"},qI=tn({__name:"ComposerSlashMenu",props:{commands:{},highlightedIndex:{}},emits:["select"],setup(e,{emit:t}){const n=e,o=t,{t:r}=io(),s=A(null),a=X(()=>n.commands.filter(y=>y.group!=="skill")),l=X(()=>n.commands.filter(y=>y.group==="skill"));nt(()=>n.highlightedIndex,async()=>{var y,_;await Wt(),(_=(y=s.value)==null?void 0:y.querySelector(".is-active"))==null||_.scrollIntoView({block:"nearest"})});function d(y){return r(y==="rpc"?"Action":y==="text"?"Prompt":y==="skill"?"Skill":"Local")}function h(y){return y==="system"?"S":y==="repo"?"R":y==="plugin"?"P":"U"}function v(y){return r(y==="system"?"System":y==="repo"?"Repo":y==="plugin"?"Plugin":"User")}return(y,_)=>(S(),I("div",{ref_key:"rootRef",ref:s,class:"composer-popover",role:"listbox","aria-label":g(r)("Commands")},[a.value.length>0?(S(),I(ze,{key:0},[p("div",EI,T(g(r)("Commands")),1),(S(!0),I(ze,null,_t(a.value,(P,j)=>(S(),I("button",{key:P.id,class:Ke(["thread-composer-slash-row",{"is-active":j===e.highlightedIndex}]),type:"button",role:"option","aria-selected":j===e.highlightedIndex,onMousedown:lt(B=>o("select",P),["prevent"])},[_[0]||(_[0]=p("span",{class:"thread-composer-slash-prefix","aria-hidden":"true"},"/",-1)),p("span",MI,[p("span",$I,T(P.id),1),p("span",jI,T(g(r)(P.description)),1)]),p("span",LI,T(d(P.kind)),1)],42,RI))),128))],64)):ee("",!0),l.value.length>0?(S(),I(ze,{key:1},[p("div",NI,T(g(r)("Skills")),1),(S(!0),I(ze,null,_t(l.value,(P,j)=>(S(),I("button",{key:P.skillPath||P.id,class:Ke(["thread-composer-slash-row thread-composer-slash-row--skill",{"is-active":a.value.length+j===e.highlightedIndex}]),type:"button",role:"option","aria-selected":a.value.length+j===e.highlightedIndex,onMousedown:lt(B=>o("select",P),["prevent"])},[p("span",{class:Ke(["thread-composer-slash-skill-icon",`is-${P.scope||"user"}`]),"aria-label":v(P.scope),title:v(P.scope)},T(h(P.scope)),11,DI),p("span",FI,[p("span",UI,T(P.displayName||P.id),1),p("span",BI,T(P.description),1)])],42,OI))),128))],64)):ee("",!0)],8,II))}}),zI=bt(qI,[["__scopeId","data-v-ca16aa11"]]),HI=["data-streaming"],WI=["aria-expanded"],VI={class:"thread-composer-plan-panel-title"},GI={key:0,class:"thread-composer-plan-panel-badge"},KI={class:"thread-composer-plan-panel-progress"},YI=["title"],JI=["data-status"],QI={class:"thread-composer-plan-panel-latest-text"},XI={class:"thread-composer-plan-panel-popover-content"},ZI={class:"thread-composer-plan-panel-popover-scroll"},eE={class:"thread-composer-plan-panel-popover-head"},tE={class:"thread-composer-plan-panel-title"},nE={class:"thread-composer-plan-panel-progress"},oE={key:0,class:"thread-composer-plan-panel-popover-section"},rE={class:"thread-composer-plan-panel-section-label"},aE=["title"],sE={class:"thread-composer-plan-panel-popover-section"},iE={class:"thread-composer-plan-panel-section-label"},lE={class:"thread-composer-plan-panel-steps"},cE=["data-status"],uE=["data-status"],dE=["title"],fE={class:"thread-composer-plan-panel-popover-footer"},pE=["disabled","data-state"],hE=tn({__name:"ThreadComposerPlanPanel",props:{planPanel:{}},emits:["implement-plan"],setup(e,{emit:t}){const n=e,o=t,{t:r}=io(),s=A(!1),a=X(()=>{var _;return(((_=n.planPanel)==null?void 0:_.steps)??[]).filter(P=>P.status==="completed").length}),l=X(()=>{var _;const y=((_=n.planPanel)==null?void 0:_.steps)??[];if(y.length===0)return null;for(let P=y.length-1;P>=0;P-=1){const j=y[P];if(j.status==="inProgress")return j}return y[y.length-1]}),d=X(()=>{var j,B,J;const y=((B=(j=n.planPanel)==null?void 0:j.explanation)==null?void 0:B.trim())??"";if(!y)return"";const _=((J=y.split(/[。!?!?\n]/u)[0])==null?void 0:J.trim())??"";if(!_)return y;const P=80;return _.length>P?`${_.slice(0,P)}…`:_});function h(y){switch(y){case"completed":return"✓";case"inProgress":return"•";default:return"○"}}function v(){s.value=!1,o("implement-plan")}return(y,_)=>(S(),I("div",{class:"thread-composer-plan-panel","data-streaming":e.planPanel.streaming},[Ie(Ku,{open:s.value,align:"center",width:"lg","panel-class":"thread-composer-plan-panel-popover","aria-label":g(r)("Plan"),"onUpdate:open":_[1]||(_[1]=P=>s.value=P)},{trigger:yt(()=>{var P,j;return[p("button",{type:"button",class:"thread-composer-plan-panel-header","aria-expanded":s.value,onClick:_[0]||(_[0]=B=>s.value=!s.value)},[_[2]||(_[2]=p("span",{class:"thread-composer-plan-panel-icon","aria-hidden":"true"},"🗒",-1)),p("span",VI,T(g(r)("Plan")),1),e.planPanel.streaming?(S(),I("span",GI,T(g(r)("Updating")),1)):ee("",!0),p("span",KI,T(a.value)+"/"+T(e.planPanel.steps.length),1),p("span",{class:"thread-composer-plan-panel-latest",title:((P=l.value)==null?void 0:P.step)??""},[l.value?(S(),I("span",{key:0,class:"thread-composer-plan-panel-latest-status","data-status":l.value.status},T(h(l.value.status)),9,JI)):ee("",!0),p("span",QI,T(((j=l.value)==null?void 0:j.step)??""),1)],8,YI),Ie(Js,{class:"thread-composer-plan-panel-chevron"})],8,WI)]}),default:yt(()=>[p("div",XI,[p("div",ZI,[p("header",eE,[_[3]||(_[3]=p("span",{class:"thread-composer-plan-panel-icon","aria-hidden":"true"},"🗒",-1)),p("span",tE,T(g(r)("Plan")),1),p("span",nE,T(a.value)+"/"+T(e.planPanel.steps.length),1)]),e.planPanel.explanation?(S(),I("section",oE,[p("p",rE,T(g(r)("Summary")),1),p("p",{class:"thread-composer-plan-panel-explanation",title:e.planPanel.explanation},T(d.value),9,aE)])):ee("",!0),p("section",sE,[p("p",iE,T(g(r)("Steps"))+" ("+T(e.planPanel.steps.length)+")",1),p("ol",lE,[(S(!0),I(ze,null,_t(e.planPanel.steps,(P,j)=>(S(),I("li",{key:`composer-plan-${e.planPanel.id}-${j}`,class:"thread-composer-plan-panel-step","data-status":P.status},[p("span",{class:"thread-composer-plan-panel-step-status","data-status":P.status},T(h(P.status)),9,uE),p("span",{class:"thread-composer-plan-panel-step-text",title:P.step},T(P.step),9,dE)],8,cE))),128))])])]),p("footer",fE,[p("button",{type:"button",class:"thread-composer-plan-panel-implement",disabled:e.planPanel.streaming||e.planPanel.implemented,"data-state":e.planPanel.implemented?"done":e.planPanel.streaming?"running":"idle",onClick:v},T(e.planPanel.implemented?g(r)("Plan executed"):e.planPanel.streaming?g(r)("Implementing…"):g(r)("Implement plan")),9,pE)])])]),_:1},8,["open","aria-label"])],8,HI))}}),mE=bt(hE,[["__scopeId","data-v-b1cbf479"]]),vE={key:0,class:"thread-composer-attachments"},gE=["src"],yE=["src","alt"],wE=["aria-label","disabled","onClick"],bE={key:1,class:"thread-composer-folder-chips"},kE=["title"],CE={class:"thread-composer-folder-chip-meta"},TE=["aria-label","disabled","onClick"],SE={key:2,class:"thread-composer-file-chips"},_E=["title"],xE=["aria-label","disabled","onClick"],AE={key:3,class:"thread-composer-skill-chips"},PE=["title","aria-label","onClick"],IE=["aria-label","onClick"],EE=tn({__name:"ThreadComposerAttachments",props:{selectedImages:{},folderUploadGroups:{},standaloneFileAttachments:{},selectedSkills:{},isInteractionDisabled:{type:Boolean}},emits:["remove-image","remove-folder","remove-file","remove-skill"],setup(e,{emit:t}){const n=t,o=/\.(mp4|m4v|webm|mov|mkv|ogv|ogg|mpeg|avi)$/iu;function r(d){const h=d.trim();return h?!!(/^video\/|^data:video\//i.test(h)||o.test(h)):!1}function s(d){return d.total<=0?0:Math.round(d.processed/d.total*100)}function a(d){const h=d.trim();return h?h.endsWith("/SKILL.md")?h:`${h.replace(/\/+$/,"")}/SKILL.md`:""}function l(d){const h=a(d.path);!h||typeof window>"u"||window.open(`/codex-local-browse${encodeURI(h)}`,"_blank","noopener,noreferrer")}return(d,h)=>(S(),I(ze,null,[e.selectedImages.length>0?(S(),I("div",vE,[(S(!0),I(ze,null,_t(e.selectedImages,v=>(S(),I("div",{key:v.id,class:"thread-composer-attachment"},[r(v.url)?(S(),I("video",{key:0,class:"thread-composer-attachment-image",src:v.url,controls:"",preload:"metadata"},null,8,gE)):(S(),I("img",{key:1,class:"thread-composer-attachment-image",src:v.url,alt:v.name||"Selected image"},null,8,yE)),p("button",{class:"thread-composer-attachment-remove",type:"button","aria-label":`Remove ${v.name||"image"}`,disabled:e.isInteractionDisabled,onClick:y=>n("remove-image",v.id)}," x ",8,wE)]))),128))])):ee("",!0),e.folderUploadGroups.length>0?(S(),I("div",bE,[(S(!0),I(ze,null,_t(e.folderUploadGroups,v=>(S(),I("span",{key:v.id,class:"thread-composer-folder-chip"},[Ie(_p,{class:"thread-composer-folder-chip-icon"}),p("span",{class:"thread-composer-folder-chip-name",title:v.name},T(v.name),9,kE),p("span",CE,[v.isUploading?(S(),I(ze,{key:0},[ps(T(s(v))+"% uploading ("+T(v.processed)+"/"+T(v.total)+") ",1)],64)):(S(),I(ze,{key:1},[ps(T(v.filePaths.length)+" file"+T(v.filePaths.length===1?"":"s"),1)],64))]),p("button",{class:"thread-composer-folder-chip-remove",type:"button","aria-label":`Remove folder ${v.name}`,disabled:e.isInteractionDisabled,onClick:y=>n("remove-folder",v.id)},"×",8,TE)]))),128))])):ee("",!0),e.standaloneFileAttachments.length>0?(S(),I("div",SE,[(S(!0),I(ze,null,_t(e.standaloneFileAttachments,v=>(S(),I("span",{key:v.fsPath,class:"thread-composer-file-chip"},[Ie(Bi,{class:"thread-composer-file-chip-icon"}),p("span",{class:"thread-composer-file-chip-name",title:v.fsPath},T(v.label),9,_E),p("button",{class:"thread-composer-file-chip-remove",type:"button","aria-label":`Remove ${v.label}`,disabled:e.isInteractionDisabled,onClick:y=>n("remove-file",v.fsPath)},"×",8,xE)]))),128))])):ee("",!0),e.selectedSkills.length>0?(S(),I("div",AE,[(S(!0),I(ze,null,_t(e.selectedSkills,v=>(S(),I("span",{key:v.path,class:"thread-composer-skill-chip"},[p("button",{class:"thread-composer-skill-chip-name",type:"button",title:a(v.path),"aria-label":`Open ${v.displayName||v.name} SKILL.md`,onClick:y=>l(v)},T(v.displayName||v.name),9,PE),p("button",{class:"thread-composer-skill-chip-remove",type:"button","aria-label":`Remove skill ${v.displayName||v.name}`,onClick:y=>n("remove-skill",v.path)},"×",8,IE)]))),128))])):ee("",!0)],64))}}),RE=bt(EE,[["__scopeId","data-v-acea11fd"]]),ME=tn({__name:"ThreadComposerModelControls",props:{models:{},selectedModel:{},modelReasoningEfforts:{},selectedReasoningEffort:{},selectedSpeedMode:{},disabled:{type:Boolean},activeThreadId:{}},emits:["update:selected-model","update:selected-reasoning-effort"],setup(e,{emit:t}){const n=e,o=t,{t:r}=io(),s=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}],a=X(()=>{var J;const j=(J=n.modelReasoningEfforts)==null?void 0:J[n.selectedModel];if(j===void 0)return s;const B=new Set(j);return s.filter(ce=>B.has(ce.value))});function l(j){return j.trim().replace(/^gpt/i,"GPT")}const d=X(()=>n.models.map(j=>({value:j,label:l(j)}))),h=X(()=>n.disabled||!n.activeThreadId),v=X(()=>/^gpt-5\.(?:4|5)(?:$|-)/.test(n.selectedModel.trim())),y=X(()=>n.selectedSpeedMode==="fast"&&v.value);function _(j){o("update:selected-model",j)}function P(j){o("update:selected-reasoning-effort",j)}return(j,B)=>(S(),I(ze,null,[Ie(or,{class:"thread-composer-control thread-composer-model-control","model-value":e.selectedModel,options:d.value,"selected-prefix-icon":y.value?Ys:null,placeholder:g(r)("Model"),"open-direction":"up",variant:"pill",disabled:h.value||e.models.length===0,"enable-search":"","search-placeholder":g(r)("Search models..."),"onUpdate:modelValue":_},null,8,["model-value","options","selected-prefix-icon","placeholder","disabled","search-placeholder"]),Ie(or,{class:"thread-composer-control thread-composer-thinking-control","model-value":e.selectedReasoningEffort,options:a.value,placeholder:g(r)("Thinking"),"open-direction":"up",variant:"pill",disabled:h.value||a.value.length===0,"onUpdate:modelValue":P},null,8,["model-value","options","placeholder","disabled"])],64))}}),$E=bt(ME,[["__scopeId","data-v-05288bd3"]]),jE=["aria-label","disabled"],LE=["disabled"],NE=["disabled"],OE=["disabled"],DE={class:"thread-composer-attach-mode"},FE={class:"thread-composer-attach-mode-label"},UE={class:"thread-composer-attach-mode-buttons"},BE=["disabled"],qE=["disabled"],zE={class:"thread-composer-attach-mode"},HE={class:"thread-composer-attach-mode-label"},WE={class:"thread-composer-attach-mode-buttons"},VE=["disabled","onClick"],GE={class:"thread-composer-attach-mode"},KE={class:"thread-composer-attach-mode-label"},YE={class:"thread-composer-attach-mode-buttons"},JE=["disabled","onClick"],QE={key:0,class:"thread-composer-menu-error",role:"alert"},XE={key:0,class:"thread-composer-approval-tip",role:"status"},ZE=tn({__name:"ThreadComposerAttachMenu",props:{open:{type:Boolean},isMobile:{type:Boolean},isInteractionDisabled:{type:Boolean},isComposerConfigDisabled:{type:Boolean},isApprovalPolicySaving:{type:Boolean},approvalPolicy:{},approvalPolicyError:{},approvalPolicyNotice:{},selectedCollaborationMode:{},collaborationModeChoices:{},approvalPolicyChoices:{},activeInProgressMode:{}},emits:["update:open","toggle","set-active-mode","select-photo","select-folder","capture-camera","select-collaboration-mode","select-approval-policy"],setup(e,{emit:t}){const n=t,{t:o}=io();function r(){n("toggle")}function s(y){n("set-active-mode",y)}function a(){n("select-photo")}function l(){n("select-folder")}function d(){n("capture-camera")}function h(y){n("select-collaboration-mode",y)}function v(y){n("select-approval-policy",y)}return(y,_)=>(S(),tt(Ku,{open:e.open,align:"start",width:"lg","aria-label":g(o)("Add photos & files"),"onUpdate:open":_[2]||(_[2]=P=>n("update:open",P))},{trigger:yt(()=>[p("button",{class:"thread-composer-attach-trigger",type:"button","aria-label":g(o)("Add photos & files"),disabled:e.isInteractionDisabled,onClick:r}," + ",8,jE)]),default:yt(()=>[p("button",{class:"thread-composer-attach-item",type:"button",disabled:e.isInteractionDisabled,onClick:a},T(g(o)("Add photos & files")),9,LE),p("button",{class:"thread-composer-attach-item",type:"button",disabled:e.isInteractionDisabled,onClick:l},T(g(o)("Add folder")),9,NE),p("button",{class:"thread-composer-attach-item",type:"button",disabled:e.isInteractionDisabled,onClick:d},T(g(o)("Take photo")),9,OE),_[5]||(_[5]=p("div",{class:"thread-composer-attach-separator"},null,-1)),p("div",DE,[p("span",FE,T(g(o)("In-progress send")),1),p("div",UE,[p("button",{class:Ke(["thread-composer-attach-mode-button",{"is-active":e.activeInProgressMode==="steer"}]),type:"button",disabled:e.isInteractionDisabled,onClick:_[0]||(_[0]=P=>s("steer"))},T(g(o)("Steer")),11,BE),p("button",{class:Ke(["thread-composer-attach-mode-button",{"is-active":e.activeInProgressMode==="queue"}]),type:"button",disabled:e.isInteractionDisabled,onClick:_[1]||(_[1]=P=>s("queue"))},T(g(o)("Queue")),11,qE)])]),e.isMobile?(S(),I(ze,{key:0},[_[3]||(_[3]=p("div",{class:"thread-composer-attach-separator"},null,-1)),p("div",zE,[p("span",HE,T(g(o)("Plan mode")),1),p("div",WE,[(S(!0),I(ze,null,_t(e.collaborationModeChoices,P=>(S(),I("button",{key:`mobile-plan-${P.value}`,class:Ke(["thread-composer-attach-mode-button",{"is-active":e.selectedCollaborationMode===P.value}]),type:"button",disabled:P.disabled||e.isComposerConfigDisabled,onClick:j=>h(P.value)},T(g(o)(P.labelKey)),11,VE))),128))])]),_[4]||(_[4]=p("div",{class:"thread-composer-attach-separator"},null,-1)),p("div",GE,[p("span",KE,T(g(o)("Approval policy")),1),p("div",YE,[(S(!0),I(ze,null,_t(e.approvalPolicyChoices,P=>(S(),I("button",{key:`mobile-approval-${P.value}`,class:Ke(["thread-composer-attach-mode-button",{"is-active":e.approvalPolicy===P.value}]),type:"button",disabled:e.isApprovalPolicySaving,onClick:j=>v(P.value)},T(g(o)(P.label)),11,JE))),128))])]),e.approvalPolicyError?(S(),I("p",QE,T(e.approvalPolicyError),1)):ee("",!0),Ie(Mc,{name:"approval-tip"},{default:yt(()=>[e.approvalPolicyNotice?(S(),I("span",XE,T(e.approvalPolicyNotice),1)):ee("",!0)]),_:1})],64)):ee("",!0)]),_:1},8,["open","aria-label"]))}}),eR=bt(ZE,[["__scopeId","data-v-24be0643"]]),tR=/(^|\s)(\/[a-zA-Z]*)$/,Xm=[{id:"compact",description:"Compact the current thread context",kind:"rpc",group:"builtin"},{id:"review",description:"Open the code review pane",kind:"rpc",group:"builtin"},{id:"rename",description:"Rename the current thread",kind:"rpc",group:"builtin"},{id:"archive",description:"Archive the current thread",kind:"rpc",group:"builtin"},{id:"fork",description:"Fork the current thread",kind:"rpc",group:"builtin"},{id:"new",description:"Start a new thread",kind:"rpc",group:"builtin"},{id:"skills",description:"Open the skills page",kind:"rpc",group:"builtin"},{id:"init",description:"Generate or update AGENTS.md",kind:"text",group:"builtin",insertText:"Create or update the AGENTS.md file for this project: include an overview, architecture notes, development conventions, and a workflow guide based on the codebase."},{id:"help",description:"Show help about Codex",kind:"text",group:"builtin",insertText:"How do I use Codex? Point me to the official documentation and explain the available commands."},{id:"mention",description:"Mention files with @",kind:"text",group:"builtin",insertText:"Please review the files I mention with @, starting with: "},{id:"diff",description:"Show the current git diff",kind:"text",group:"builtin",insertText:"Show the current git diff of this project and summarize the changes."},{id:"clear",description:"Clear the input",kind:"local",group:"builtin"}];function nR(e){var o,r,s;const t=[],n=new Set;for(const a of e){const l=a.name.trim().replace(/^\//u,"").toLowerCase().replace(/\s+/gu,"-");if(!l)continue;const d=a.path.trim()||l;n.has(d)||(n.add(d),t.push({id:l,description:((o=a.description)==null?void 0:o.trim())||"Run this skill",kind:"skill",group:"skill",skillPath:a.path,displayName:((r=a.displayName)==null?void 0:r.trim())||a.name.trim(),scope:((s=a.scope)==null?void 0:s.trim())||"user"}))}return t.sort((a,l)=>a.id.localeCompare(l.id))}function oR(e){const t=e.match(tR);if(!t)return null;const n=t[2]??"";return{query:n.slice(1).toLowerCase(),token:n,startIndex:e.length-n.length}}function rR(e,t){const n=t.trim().toLowerCase();if(!n)return e;const o=e.filter(r=>r.id===n);return o.length>0?o:e.filter(r=>r.id.startsWith(n))}const aR={class:"thread-composer-main"},sR={class:"thread-composer-input-row"},iR={key:0,class:"thread-composer-drop-overlay","aria-hidden":"true"},lR={class:"thread-composer-drop-overlay-copy"},cR={key:1,class:"composer-popover"},uR=["onMousedown"],dR={key:1,class:"thread-composer-file-mention-icon-markdown"},fR={class:"thread-composer-file-mention-text"},pR={class:"thread-composer-file-mention-name"},hR={key:0,class:"thread-composer-file-mention-dir"},mR={key:1,class:"thread-composer-file-mention-empty"},vR={key:2,class:"thread-composer-file-mention-empty"},gR=["placeholder","disabled"],yR=["aria-label","title","disabled"],wR={class:"thread-composer-actions"},bR=["aria-label","title","disabled"],kR={key:0,class:"thread-composer-stop-spinner","aria-hidden":"true"},CR=["aria-label","title","disabled"],TR=["aria-label","disabled"],SR={class:"thread-composer-plan-trigger-label"},_R=["aria-checked","disabled","onClick"],xR={class:"thread-composer-menu-item-copy"},AR={class:"thread-composer-menu-item-title"},PR={key:0,class:"thread-composer-menu-item-sub"},IR={key:1,class:"thread-composer-menu-item-hint"},ER={key:0,class:"thread-composer-menu-item-check","aria-hidden":"true"},RR=["aria-label","disabled"],MR={class:"thread-composer-approval-trigger-label"},$R=["aria-checked","disabled","onClick"],jR={class:"thread-composer-menu-item-copy"},LR={class:"thread-composer-menu-item-title"},NR={key:0,class:"thread-composer-menu-item-check","aria-hidden":"true"},OR={key:0,class:"thread-composer-menu-error",role:"alert"},DR={key:0,class:"thread-composer-approval-tip",role:"status"},FR=["title","aria-label"],UR={class:"thread-composer-context-usage-value"},BR={key:0,class:"thread-composer-context-usage-compact"},qR=["disabled"],zR=["disabled"],HR=["disabled"],pf=12e3,WR=2e3,VR="codex-web-local.thread-draft.v1.",GR=tn({__name:"ThreadComposer",props:{activeThreadId:{},cwd:{},fuzzyFileSearchResults:{},collaborationModes:{},selectedCollaborationMode:{},models:{},modelReasoningEfforts:{},selectedModel:{},selectedReasoningEffort:{},selectedSpeedMode:{},skills:{},threadTokenUsage:{},codexQuota:{},isTurnInProgress:{type:Boolean},isStopPending:{type:Boolean},isInterruptingTurn:{type:Boolean},isCompacting:{type:Boolean},externalSessionActive:{type:Boolean},isUpdatingSpeedMode:{type:Boolean},disabled:{type:Boolean},hasQueueAbove:{type:Boolean},sendWithEnter:{type:Boolean},inProgressSubmitMode:{},dictationClickToToggle:{type:Boolean},dictationAutoSend:{type:Boolean},dictationLanguage:{},approvalPolicy:{},isApprovalPolicySaving:{type:Boolean},approvalPolicyError:{},approvalPolicyNotice:{},planPanel:{}},emits:["submit","interrupt","register-fuzzy-session","slash-command","update:selected-collaboration-mode","update:selected-model","update:selected-reasoning-effort","update:selected-speed-mode","update:approval-policy","save-approval-policy","implement-plan","compact-context"],setup(e,{expose:t,emit:n}){const o=e,r=n,{t:s}=io(),a=A(""),l=A([]),d=A([]),h=A([]),v=A([]),y=A(""),_=A(0),P=A(null),j=A(!1),{state:B,cancel:J}=uI({getLanguage:()=>o.dictationLanguage??"auto",onTranscript:M=>{if(a.value=a.value?`${a.value}
|
|
58
58
|
${M}`:M,y.value="",o.dictationAutoSend!==!1){const F=o.isTurnInProgress?ge.value:"steer";Ze(F);return}Wt(()=>{var F;return(F=K.value)==null?void 0:F.focus()})},onEmpty:()=>{y.value=o.dictationClickToToggle?"No speech detected. Click again after speaking.":"No speech detected. Hold the mic and speak."},onError:M=>{if(M instanceof DOMException&&M.name==="NotAllowedError"){y.value="Microphone access was denied.";return}y.value=M instanceof Error?M.message:"Dictation failed."}}),ce=A(null),U=A(null),V=A(null),K=A(null),{isMobile:ye}=yp(),_e=A(!1),we=A(!1),$e=A(!1),de=A(null),Le=A(""),je=A([]),fe=A(!1),Te=A(0),xe=A(!1),Ae=A(null),Ue=A(""),Ye=A(0),He=A(Xm),At=X(()=>[...Xm,...nR(o.skills??[])]),ct=A(!1),Qe=A(!1);let et=!1;const ft=A(0);let mt=0,kt=null,at="",ae=!1,te=0,oe=0;const z=typeof navigator<"u"&&/Android/i.test(navigator.userAgent);let Be="";const $=X(()=>{const M=new Set((o.collaborationModes??[]).map(F=>F.value));return[{value:"default",labelKey:"Default",subLabel:"",disabled:!1},{value:"plan",labelKey:"Plan mode",subLabel:s("Agent proposes a plan before acting"),disabled:!1},{value:"execplans",labelKey:"Execution plans",subLabel:"",disabled:!M.has("execplans")}]}),O=[{value:"on-request",label:"When Codex requests it"},{value:"untrusted",label:"Unless trusted"},{value:"never",label:"Never"}],G=X(()=>{const M=$.value.find(F=>F.value===o.selectedCollaborationMode);return s(M?M.labelKey:"Plan mode")}),ue=X(()=>{const M=O.find(F=>F.value===o.approvalPolicy);return s(M?M.label:"Approval policy")}),ie=X(()=>o.selectedCollaborationMode==="plan"&&o.selectedModel.trim().length===0),re=X(()=>o.disabled||o.isUpdatingSpeedMode||!o.activeThreadId||ie.value||_.value>0?!1:a.value.trim().length>0||l.value.length>0||h.value.length>0),Se=X(()=>a.value.trim().length>0||l.value.length>0||d.value.length>0||h.value.length>0||v.value.length>0),be=X(()=>{const M=new Set;for(const F of v.value)for(const ne of F.filePaths)M.add(ne);return h.value.filter(F=>!M.has(F.fsPath))}),pe=X(()=>o.disabled||!o.activeThreadId||o.externalSessionActive===!0),se=X(()=>o.disabled||!o.activeThreadId),Ee=X(()=>o.inProgressSubmitMode==="steer"?"steer":"queue"),ge=A(Ee.value),Fe=X(()=>B.value==="recording"),Me=X(()=>o.activeThreadId?ie.value?s("Loading models for plan mode..."):s("Ask Codex anything, @ to add files, / for commands"):s("Select a thread to send a message")),Ve=X(()=>a.value.trim().length>0||l.value.length>0||h.value.length>0),rt=X(()=>a.value.split(`
|
|
@@ -73,14 +73,14 @@ ${F}`:F,Wt(()=>{var ne;(ne=K.value)==null||ne.focus(),Qt()}))}function xr(M){con
|
|
|
73
73
|
`).trim()}function Gi(i){if(i.method!=="item/started"&&i.method!=="item/completed")return null;const u=qe(i.params),m=qe(u==null?void 0:u.item);if(!m||ke(m.type).toLowerCase()!=="reasoning")return null;const b=ke(m.id);return b?{itemId:b,text:Xa(m)}:null}function Jt(i,u,m){if(!i||!m)return;m.trim()&&y.set(u,m.trim());const b=h.value[i]??"",R=v.get(u)??"";if(b.endsWith(m)||R&&m===R){v.set(u,m);return}if(R&&m.startsWith(R)){const L=m.slice(R.length);L&&Ir(i,L),v.set(u,m);return}const E=b.length>0&&!b.endsWith(`
|
|
74
74
|
`)?`
|
|
75
75
|
|
|
76
|
-
`:"";Ir(i,`${E}${m}`),v.set(u,m)}function oo(i){const u=qe(i.params);if(!u)return;const m=i.method==="item/started"||i.method==="item/completed",b=i.method==="item/reasoning/textDelta"||i.method==="item/reasoning/summaryTextDelta";if(!m&&!b)return;const R=qe(u.item),E=ke(b?u.itemId:R==null?void 0:R.id);if(!E)return;const L=cn(i);if(!L)return;const q=b||ke(R==null?void 0:R.type).toLowerCase()==="reasoning"?"reasoning":"other",Z=_.get(L)??[];Z.some(he=>he.itemId===E)||_.set(L,[...Z,{itemId:E,kind:q}])}function xn(i){var R;const u=_.get(i)??[],m=[];let b="";for(const E of u)if(E.kind==="reasoning"){const L=((R=y.get(E.itemId))==null?void 0:R.trim())??"";L&&m.push({text:L,anchorMessageId:b,itemId:E.itemId})}else b=E.itemId;return m}function As(i){var Z;if(i.method!=="item/started"&&i.method!=="item/completed")return null;const u=qe(i.params),m=qe(u==null?void 0:u.item);if(!m||ke(m.type).toLowerCase()!=="plan")return null;const b=cn(i),R=ke(u==null?void 0:u.turnId)||ke(u==null?void 0:u.turn_id),E=ke(m.id),L=ke(m.text);if(!b||!E||!L)return null;const q=b&&R?(Z=re.value[b])==null?void 0:Z[R]:void 0;return{threadId:b,message:{id:E,role:"assistant",text:L,messageType:i.method==="item/completed"?"plan":"plan.live",plan:Dy(L)??void 0,turnId:R||void 0,turnIndex:typeof q=="number"?q:void 0}}}function er(i){const u=qe(i.params);if(!u)return"";if(i.method==="item/started"){const m=qe(u.item);return!m||m.type!=="agentMessage"?"":ke(m.id)}return""}function Za(i){const u=qe(i.params);if(!u)return null;if(i.method==="item/agentMessage/delta"){const m=ke(u.itemId),b=ke(u.delta);return!m||!b?null:{messageId:m,delta:b}}return null}function w(i){const u=qe(i.params);if(!u)return null;if(i.method==="item/completed"){const m=qe(u.item);if(!m||m.type!=="agentMessage")return null;const b=ke(m.id),R=ke(m.text);return!b||!R?null:{id:b,role:"assistant",text:R,messageType:"agentMessage.live"}}return null}function k(i){return`/codex-local-image?path=${encodeURIComponent(i)}`}function C(i){const u=i.trim();if(!u)return"";if(u.startsWith("data:")||u.startsWith("http://")||u.startsWith("https://")||u.startsWith("/codex-local-image?"))return u;const m=u.replace(/\s+/gu,"");return/^[A-Za-z0-9+/]+={0,2}$/u.test(m)?`data:image/png;base64,${m}`:""}function D(i){if(i.method!=="item/completed")return null;const u=qe(i.params),m=qe(u==null?void 0:u.item);if(!m)return null;const b=ke(m.id);if(!b)return null;if(m.type==="imageView"){const L=ke(m.path);return L?{id:b,role:"assistant",text:"",images:[k(L)],messageType:"imageView"}:null}if(m.type!=="imageGeneration"&&m.type!=="image_generation")return null;const R=ke(m.result),E=R?C(R):"";return E?{id:b,role:"assistant",text:"",images:[E],messageType:"imageView"}:null}function Ce(i){var he;if(i.method!=="item/started")return null;const u=qe(i.params),m=qe(u==null?void 0:u.item);if(!m||m.type!=="commandExecution")return null;const b=ke(m.id),R=ke(m.command);if(!b)return null;const E=typeof m.cwd=="string"?m.cwd:null,L=cn(i),q=ke(u==null?void 0:u.turnId)||ke(u==null?void 0:u.turn_id),Z=L&&q?(he=re.value[L])==null?void 0:he[q]:void 0;return{id:b,role:"system",text:R,messageType:"commandExecution",commandExecution:{command:R,cwd:E,status:"inProgress",aggregatedOutput:"",exitCode:null},turnId:q||void 0,turnIndex:typeof Z=="number"?Z:void 0}}function st(i){if(i.method!=="item/commandExecution/outputDelta")return null;const u=qe(i.params);if(!u)return null;const m=ke(u.itemId),b=ke(u.delta);return!m||!b?null:{itemId:m,delta:b}}function Rt(i){var it;if(i.method!=="item/completed")return null;const u=qe(i.params),m=qe(u==null?void 0:u.item);if(!m||m.type!=="commandExecution")return null;const b=ke(m.id),R=ke(m.command);if(!b)return null;const E=typeof m.cwd=="string"?m.cwd:null,L=ke(m.status),q=L==="failed"?"failed":L==="declined"?"declined":L==="interrupted"?"interrupted":"completed",Z=typeof m.aggregatedOutput=="string"?m.aggregatedOutput:"",he=typeof m.exitCode=="number"?m.exitCode:null,Ne=cn(i),Je=ke(u==null?void 0:u.turnId)||ke(u==null?void 0:u.turn_id),pt=Ne&&Je?(it=re.value[Ne])==null?void 0:it[Je]:void 0;return{id:b,role:"system",text:R,messageType:"commandExecution",commandExecution:{command:R,cwd:E,status:q,aggregatedOutput:Z,exitCode:he},turnId:Je||void 0,turnIndex:typeof pt=="number"?pt:void 0}}function $o(i){var he;if(i.method!=="item/completed")return null;const u=qe(i.params),m=qe(u==null?void 0:u.item);if(!m||m.type!=="fileChange")return null;const b=ke(m.id);if(!b)return null;const R=ke(u==null?void 0:u.threadId),E=ke(u==null?void 0:u.turnId),L=R&&E?(he=re.value[R])==null?void 0:he[E]:void 0,q=Nf(m.changes),Z=dy(m.status);return q.length===0||Z!=="completed"?null:{id:b,role:"system",text:"",messageType:"fileChange",fileChangeStatus:Z,fileChanges:q,turnId:E||void 0,turnIndex:typeof L=="number"?L:void 0}}function Kt(i,u){const m=j.value[i]??[],b=Su(m,u);b!==m&&(j.value={...j.value,[i]:b})}function Nn(i,u){const m=j.value[i];if(!m||m.length===0)return;const b=new Set(u.map(E=>E.id)),R=m.filter(E=>!b.has(E.id));R.length!==m.length&&(R.length===0?j.value=St(j.value,i):j.value={...j.value,[i]:R})}function bn(i,u){const m=B.value[i];if(!m||m.length===0)return;const b=new Set(u.map(q=>q.id)),R=new Set(u.filter(q=>q.messageType==="fileChange"&&typeof q.turnId=="string"&&q.turnId.length>0).map(q=>q.turnId)),E=new Set(u.filter(q=>q.messageType==="fileChange"&&typeof q.turnIndex=="number").map(q=>q.turnIndex)),L=m.filter(q=>!b.has(q.id)&&!(q.turnId&&R.has(q.turnId))&&!(typeof q.turnIndex=="number"&&E.has(q.turnIndex)));L.length!==m.length&&(L.length===0?B.value=St(B.value,i):B.value={...B.value,[i]:L})}function tr(i){if(i.method==="item/agentMessage/delta")return!0;const u=qe(i.params);if(!u)return!1;if(i.method==="item/completed"){const m=qe(u.item);return(m==null?void 0:m.type)==="agentMessage"}return!1}const Nr=new Set;function jo(i){for(const u of Nr)try{u(i)}catch{}}function Ps(i){return Nr.add(i),()=>{Nr.delete(i)}}function hi(i,u,m){if(!i||!u)return;const b=B.value[i];if(!b)return;const R=b.findIndex(L=>L.id===u||L.turnId===u);if(R<0)return;const E=[...b];E[R]={...E[R],fileChanges:m},Va(i,E)}function mi(i,u,m){if(!i||!u)return;const b=B.value[i];if(!b)return;const R=b.findIndex(q=>q.turnId===u);if(R<0)return;const E=[...b],L=E[R];E[R]={...L,fileChanges:(L.fileChanges??[]).map(q=>({...q,diff:m}))},Va(i,E)}function Is(i){var Wc,Vc,Gc,ol,Kc,Yc;if(wn(i))return;if(oo(i),i.method==="turn/started"){const Re=cn(i);Re&&_.delete(Re)}if(vN.has(i.method))return;if(i.method==="app/list/updated"||i.method==="mcpServer/startupStatus/updated"||i.method==="mcpServer/oauthLogin/completed"||i.method==="remoteControl/status/changed"){jo(i.method);return}if(i.method==="skills/changed"){Rs({force:!0});return}if(i.method==="hook/started"||i.method==="hook/completed"){Ki({force:!0});return}if(i.method==="thread/status/changed"){const Re=cn(i);Re&&Re===n.value&&Yt.add(Re);return}if(i.method==="thread/archived"||i.method==="thread/unarchived"||i.method==="thread/deleted"||i.method==="thread/closed")return;if(i.method==="item/fileChange/patchUpdated"||i.method==="turn/diff/updated"){const Re=qe(i.params),Ot=ke(Re==null?void 0:Re.threadId);Ot&&(i.method==="item/fileChange/patchUpdated"?hi(Ot,ke(Re==null?void 0:Re.itemId),Nf(Re==null?void 0:Re.changes)):mi(Ot,ke(Re==null?void 0:Re.turnId),ke(Re==null?void 0:Re.diff)??""),Ot===n.value&&Yt.add(Ot));return}if(i.method==="account/rateLimits/updated"&&Pr(),i.method==="thread/name/updated"){const Re=qe(i.params),Ot=ke(Re==null?void 0:Re.threadId),Ns=ke(Re==null?void 0:Re.threadName);if(Ot&&Ns){const Jc=zs(Ns);W.value={...W.value,[Ot]:Jc},_n(),pu(Ot,Jc)}}if(i.method==="thread/compacted"){const Re=qe(i.params),Ot=ke(Re==null?void 0:Re.threadId);Ot&&(Ms(Ot,!1),yr(Ot,"done"),Yt.add(Ot));return}if(i.method==="fuzzyFileSearch/sessionUpdated"){const Re=qe(i.params),Ot=ke(Re==null?void 0:Re.sessionId);Ot&&Ot===Qt&&(Cr.value=BS(Re));return}if(i.method==="fuzzyFileSearch/sessionCompleted"){const Re=qe(i.params),Ot=ke(Re==null?void 0:Re.sessionId);Ot&&Ot===Qt&&(Qt="");return}if(i.method==="account/rateLimits/updated"){Ar(gy(i.params));return}const u=_s(i);if(u){Jr(u.threadId,u.usage);return}const m=Ea(i);m&&Gt(m.threadId,m.activity);const b=cn(i),R=jl(i);!R&&b&&ii(b);const E=na(i);E&&(Xn.set(E.turnId,E),Ra(E.threadId,E.turnId,oa(E.threadId)),Ee.value={...Ee.value,[E.threadId]:E.turnId},Yo(E.threadId,E.turnId),hr(E.threadId),Aa(E.threadId),ln(E.threadId,null),Zt(E.threadId,null),hn(E.threadId,!0),Bl(E.threadId),Ae.value[E.threadId]&&(Ae.value=St(Ae.value,E.threadId)));const L=Ja(i),q=ea(i),Z=(L==null?void 0:L.threadId)??cn(i),he=Z?sn(Z):"",Ne=!!Z&&!!q&&he!==ca&&Tu(new Error(q));if(L){gt.value[L.threadId];const Re=Xn.get(L.turnId);Re&&Xn.delete(L.turnId);const Ot=Un((Wc=qe(i.params))==null?void 0:Wc.durationMs)??Un((Gc=qe((Vc=qe(i.params))==null?void 0:Vc.turn))==null?void 0:Gc.durationMs)??(typeof L.startedAtMs=="number"?L.completedAtMs-L.startedAtMs:null)??(Re?L.completedAtMs-Re.startedAtMs:null),Ns=typeof Ot=="number"?Math.max(0,Ot):0;ln(L.threadId,{turnId:L.turnId,durationMs:Ns}),Ee.value[L.threadId]&&(Ee.value=St(Ee.value,L.threadId)),hn(L.threadId,!1),Gt(L.threadId,null),si(L.threadId),Ne||(F(L.threadId),Bl(L.threadId))}if(q){const Re=(L==null?void 0:L.threadId)||cn(i);Re&&Zt(Re,q),ut.value=q,Re&&Ne&&ne(Re)}else L&&Zt(L.threadId,null);if(R){const Re=b,Ot=Re?sn(Re):ft.value.trim();Re&&Zt(Re,R.message,{transient:R.transient}),ut.value=R.message,Ot!==ca&&Tu(new Error(R.message))&&(Re?ne(Re):go())}const Je=wo(i);Je&&(ui(Je.threadId,Je.message),Gt(Je.threadId,{label:"Planning",details:((ol=Je.message.plan)==null?void 0:ol.steps.map(Re=>Re.step).slice(0,2))??[]}));const pt=Rr(i);pt&&(ui(pt.threadId,pt.message),Gt(pt.threadId,{label:"Planning",details:[]}));const it=As(i);if(it&&(ui(it.threadId,it.message),Gt(it.threadId,{label:"Planning",details:((Kc=it.message.plan)==null?void 0:Kc.steps.map(Re=>Re.step).slice(0,2))??[]})),!b||b!==n.value)return;er(i);const Mt=Za(i);if(Mt){const Re=(a.value[b]??[]).find(Ns=>Ns.id===Mt.messageId),Ot=`${(Re==null?void 0:Re.text)??""}${Mt.delta}`;Ss(b,{id:Mt.messageId,role:"assistant",text:Ot,messageType:"agentMessage.live"})}const Oa=w(i);Oa&&Ss(b,Oa);const $s=D(i);$s&&Ss(b,$s),xs(i)&&Xr(b);const wr=jr(i);if(wr&&(Ir(b,wr.delta),wr.itemId&&wr.delta)){const Re=y.get(wr.itemId)??"";Re.endsWith(wr.delta)||y.set(wr.itemId,`${Re}${wr.delta}`)}const js=Gi(i);if(js&&(Jt(b,js.itemId,js.text),Xr(b)),Lr(i)){const Re=h.value[b]??"";Re.trim().length>0&&!Re.endsWith(`
|
|
76
|
+
`:"";Ir(i,`${E}${m}`),v.set(u,m)}function oo(i){const u=qe(i.params);if(!u)return;const m=i.method==="item/started"||i.method==="item/completed",b=i.method==="item/reasoning/textDelta"||i.method==="item/reasoning/summaryTextDelta";if(!m&&!b)return;const R=qe(u.item),E=ke(b?u.itemId:R==null?void 0:R.id);if(!E)return;const L=cn(i);if(!L)return;const q=b||ke(R==null?void 0:R.type).toLowerCase()==="reasoning"?"reasoning":"other",Z=_.get(L)??[];Z.some(he=>he.itemId===E)||_.set(L,[...Z,{itemId:E,kind:q}])}function xn(i){var R;const u=_.get(i)??[],m=[];let b="";for(const E of u)if(E.kind==="reasoning"){const L=((R=y.get(E.itemId))==null?void 0:R.trim())??"";L&&m.push({text:L,anchorMessageId:b,itemId:E.itemId})}else b=E.itemId;return m}function As(i){var Z;if(i.method!=="item/started"&&i.method!=="item/completed")return null;const u=qe(i.params),m=qe(u==null?void 0:u.item);if(!m||ke(m.type).toLowerCase()!=="plan")return null;const b=cn(i),R=ke(u==null?void 0:u.turnId)||ke(u==null?void 0:u.turn_id),E=ke(m.id),L=ke(m.text);if(!b||!E||!L)return null;const q=b&&R?(Z=re.value[b])==null?void 0:Z[R]:void 0;return{threadId:b,message:{id:E,role:"assistant",text:L,messageType:i.method==="item/completed"?"plan":"plan.live",plan:Dy(L)??void 0,turnId:R||void 0,turnIndex:typeof q=="number"?q:void 0}}}function er(i){const u=qe(i.params);if(!u)return"";if(i.method==="item/started"){const m=qe(u.item);return!m||m.type!=="agentMessage"?"":ke(m.id)}return""}function Za(i){const u=qe(i.params);if(!u)return null;if(i.method==="item/agentMessage/delta"){const m=ke(u.itemId),b=ke(u.delta);return!m||!b?null:{messageId:m,delta:b}}return null}function w(i){const u=qe(i.params);if(!u)return null;if(i.method==="item/completed"){const m=qe(u.item);if(!m||m.type!=="agentMessage")return null;const b=ke(m.id),R=ke(m.text);return!b||!R?null:{id:b,role:"assistant",text:R,messageType:"agentMessage"}}return null}function k(i){return`/codex-local-image?path=${encodeURIComponent(i)}`}function C(i){const u=i.trim();if(!u)return"";if(u.startsWith("data:")||u.startsWith("http://")||u.startsWith("https://")||u.startsWith("/codex-local-image?"))return u;const m=u.replace(/\s+/gu,"");return/^[A-Za-z0-9+/]+={0,2}$/u.test(m)?`data:image/png;base64,${m}`:""}function D(i){if(i.method!=="item/completed")return null;const u=qe(i.params),m=qe(u==null?void 0:u.item);if(!m)return null;const b=ke(m.id);if(!b)return null;if(m.type==="imageView"){const L=ke(m.path);return L?{id:b,role:"assistant",text:"",images:[k(L)],messageType:"imageView"}:null}if(m.type!=="imageGeneration"&&m.type!=="image_generation")return null;const R=ke(m.result),E=R?C(R):"";return E?{id:b,role:"assistant",text:"",images:[E],messageType:"imageView"}:null}function Ce(i){var he;if(i.method!=="item/started")return null;const u=qe(i.params),m=qe(u==null?void 0:u.item);if(!m||m.type!=="commandExecution")return null;const b=ke(m.id),R=ke(m.command);if(!b)return null;const E=typeof m.cwd=="string"?m.cwd:null,L=cn(i),q=ke(u==null?void 0:u.turnId)||ke(u==null?void 0:u.turn_id),Z=L&&q?(he=re.value[L])==null?void 0:he[q]:void 0;return{id:b,role:"system",text:R,messageType:"commandExecution",commandExecution:{command:R,cwd:E,status:"inProgress",aggregatedOutput:"",exitCode:null},turnId:q||void 0,turnIndex:typeof Z=="number"?Z:void 0}}function st(i){if(i.method!=="item/commandExecution/outputDelta")return null;const u=qe(i.params);if(!u)return null;const m=ke(u.itemId),b=ke(u.delta);return!m||!b?null:{itemId:m,delta:b}}function Rt(i){var it;if(i.method!=="item/completed")return null;const u=qe(i.params),m=qe(u==null?void 0:u.item);if(!m||m.type!=="commandExecution")return null;const b=ke(m.id),R=ke(m.command);if(!b)return null;const E=typeof m.cwd=="string"?m.cwd:null,L=ke(m.status),q=L==="failed"?"failed":L==="declined"?"declined":L==="interrupted"?"interrupted":"completed",Z=typeof m.aggregatedOutput=="string"?m.aggregatedOutput:"",he=typeof m.exitCode=="number"?m.exitCode:null,Ne=cn(i),Je=ke(u==null?void 0:u.turnId)||ke(u==null?void 0:u.turn_id),pt=Ne&&Je?(it=re.value[Ne])==null?void 0:it[Je]:void 0;return{id:b,role:"system",text:R,messageType:"commandExecution",commandExecution:{command:R,cwd:E,status:q,aggregatedOutput:Z,exitCode:he},turnId:Je||void 0,turnIndex:typeof pt=="number"?pt:void 0}}function $o(i){var he;if(i.method!=="item/completed")return null;const u=qe(i.params),m=qe(u==null?void 0:u.item);if(!m||m.type!=="fileChange")return null;const b=ke(m.id);if(!b)return null;const R=ke(u==null?void 0:u.threadId),E=ke(u==null?void 0:u.turnId),L=R&&E?(he=re.value[R])==null?void 0:he[E]:void 0,q=Nf(m.changes),Z=dy(m.status);return q.length===0||Z!=="completed"?null:{id:b,role:"system",text:"",messageType:"fileChange",fileChangeStatus:Z,fileChanges:q,turnId:E||void 0,turnIndex:typeof L=="number"?L:void 0}}function Kt(i,u){const m=j.value[i]??[],b=Su(m,u);b!==m&&(j.value={...j.value,[i]:b})}function Nn(i,u){const m=j.value[i];if(!m||m.length===0)return;const b=new Set(u.map(E=>E.id)),R=m.filter(E=>!b.has(E.id));R.length!==m.length&&(R.length===0?j.value=St(j.value,i):j.value={...j.value,[i]:R})}function bn(i,u){const m=B.value[i];if(!m||m.length===0)return;const b=new Set(u.map(q=>q.id)),R=new Set(u.filter(q=>q.messageType==="fileChange"&&typeof q.turnId=="string"&&q.turnId.length>0).map(q=>q.turnId)),E=new Set(u.filter(q=>q.messageType==="fileChange"&&typeof q.turnIndex=="number").map(q=>q.turnIndex)),L=m.filter(q=>!b.has(q.id)&&!(q.turnId&&R.has(q.turnId))&&!(typeof q.turnIndex=="number"&&E.has(q.turnIndex)));L.length!==m.length&&(L.length===0?B.value=St(B.value,i):B.value={...B.value,[i]:L})}function tr(i){if(i.method==="item/agentMessage/delta")return!0;const u=qe(i.params);if(!u)return!1;if(i.method==="item/completed"){const m=qe(u.item);return(m==null?void 0:m.type)==="agentMessage"}return!1}const Nr=new Set;function jo(i){for(const u of Nr)try{u(i)}catch{}}function Ps(i){return Nr.add(i),()=>{Nr.delete(i)}}function hi(i,u,m){if(!i||!u)return;const b=B.value[i];if(!b)return;const R=b.findIndex(L=>L.id===u||L.turnId===u);if(R<0)return;const E=[...b];E[R]={...E[R],fileChanges:m},Va(i,E)}function mi(i,u,m){if(!i||!u)return;const b=B.value[i];if(!b)return;const R=b.findIndex(q=>q.turnId===u);if(R<0)return;const E=[...b],L=E[R];E[R]={...L,fileChanges:(L.fileChanges??[]).map(q=>({...q,diff:m}))},Va(i,E)}function Is(i){var Wc,Vc,Gc,ol,Kc,Yc;if(wn(i))return;if(oo(i),i.method==="turn/started"){const Re=cn(i);Re&&_.delete(Re)}if(vN.has(i.method))return;if(i.method==="app/list/updated"||i.method==="mcpServer/startupStatus/updated"||i.method==="mcpServer/oauthLogin/completed"||i.method==="remoteControl/status/changed"){jo(i.method);return}if(i.method==="skills/changed"){Rs({force:!0});return}if(i.method==="hook/started"||i.method==="hook/completed"){Ki({force:!0});return}if(i.method==="thread/status/changed"){const Re=cn(i);Re&&Re===n.value&&Yt.add(Re);return}if(i.method==="thread/archived"||i.method==="thread/unarchived"||i.method==="thread/deleted"||i.method==="thread/closed")return;if(i.method==="item/fileChange/patchUpdated"||i.method==="turn/diff/updated"){const Re=qe(i.params),Ot=ke(Re==null?void 0:Re.threadId);Ot&&(i.method==="item/fileChange/patchUpdated"?hi(Ot,ke(Re==null?void 0:Re.itemId),Nf(Re==null?void 0:Re.changes)):mi(Ot,ke(Re==null?void 0:Re.turnId),ke(Re==null?void 0:Re.diff)??""),Ot===n.value&&Yt.add(Ot));return}if(i.method==="account/rateLimits/updated"&&Pr(),i.method==="thread/name/updated"){const Re=qe(i.params),Ot=ke(Re==null?void 0:Re.threadId),Ns=ke(Re==null?void 0:Re.threadName);if(Ot&&Ns){const Jc=zs(Ns);W.value={...W.value,[Ot]:Jc},_n(),pu(Ot,Jc)}}if(i.method==="thread/compacted"){const Re=qe(i.params),Ot=ke(Re==null?void 0:Re.threadId);Ot&&(Ms(Ot,!1),yr(Ot,"done"),Yt.add(Ot));return}if(i.method==="fuzzyFileSearch/sessionUpdated"){const Re=qe(i.params),Ot=ke(Re==null?void 0:Re.sessionId);Ot&&Ot===Qt&&(Cr.value=BS(Re));return}if(i.method==="fuzzyFileSearch/sessionCompleted"){const Re=qe(i.params),Ot=ke(Re==null?void 0:Re.sessionId);Ot&&Ot===Qt&&(Qt="");return}if(i.method==="account/rateLimits/updated"){Ar(gy(i.params));return}const u=_s(i);if(u){Jr(u.threadId,u.usage);return}const m=Ea(i);m&&Gt(m.threadId,m.activity);const b=cn(i),R=jl(i);!R&&b&&ii(b);const E=na(i);E&&(Xn.set(E.turnId,E),Ra(E.threadId,E.turnId,oa(E.threadId)),Ee.value={...Ee.value,[E.threadId]:E.turnId},Yo(E.threadId,E.turnId),hr(E.threadId),Aa(E.threadId),ln(E.threadId,null),Zt(E.threadId,null),hn(E.threadId,!0),Bl(E.threadId),Ae.value[E.threadId]&&(Ae.value=St(Ae.value,E.threadId)));const L=Ja(i),q=ea(i),Z=(L==null?void 0:L.threadId)??cn(i),he=Z?sn(Z):"",Ne=!!Z&&!!q&&he!==ca&&Tu(new Error(q));if(L){gt.value[L.threadId];const Re=Xn.get(L.turnId);Re&&Xn.delete(L.turnId);const Ot=Un((Wc=qe(i.params))==null?void 0:Wc.durationMs)??Un((Gc=qe((Vc=qe(i.params))==null?void 0:Vc.turn))==null?void 0:Gc.durationMs)??(typeof L.startedAtMs=="number"?L.completedAtMs-L.startedAtMs:null)??(Re?L.completedAtMs-Re.startedAtMs:null),Ns=typeof Ot=="number"?Math.max(0,Ot):0;ln(L.threadId,{turnId:L.turnId,durationMs:Ns}),Ee.value[L.threadId]&&(Ee.value=St(Ee.value,L.threadId)),hn(L.threadId,!1),Gt(L.threadId,null),si(L.threadId),Ne||(F(L.threadId),Bl(L.threadId))}if(q){const Re=(L==null?void 0:L.threadId)||cn(i);Re&&Zt(Re,q),ut.value=q,Re&&Ne&&ne(Re)}else L&&Zt(L.threadId,null);if(R){const Re=b,Ot=Re?sn(Re):ft.value.trim();Re&&Zt(Re,R.message,{transient:R.transient}),ut.value=R.message,Ot!==ca&&Tu(new Error(R.message))&&(Re?ne(Re):go())}const Je=wo(i);Je&&(ui(Je.threadId,Je.message),Gt(Je.threadId,{label:"Planning",details:((ol=Je.message.plan)==null?void 0:ol.steps.map(Re=>Re.step).slice(0,2))??[]}));const pt=Rr(i);pt&&(ui(pt.threadId,pt.message),Gt(pt.threadId,{label:"Planning",details:[]}));const it=As(i);if(it&&(ui(it.threadId,it.message),Gt(it.threadId,{label:"Planning",details:((Kc=it.message.plan)==null?void 0:Kc.steps.map(Re=>Re.step).slice(0,2))??[]})),!b||b!==n.value)return;er(i);const Mt=Za(i);if(Mt){const Re=(a.value[b]??[]).find(Ns=>Ns.id===Mt.messageId),Ot=`${(Re==null?void 0:Re.text)??""}${Mt.delta}`;Ss(b,{id:Mt.messageId,role:"assistant",text:Ot,messageType:"agentMessage.live"})}const Oa=w(i);Oa&&Ss(b,Oa);const $s=D(i);$s&&Ss(b,$s),xs(i)&&Xr(b);const wr=jr(i);if(wr&&(Ir(b,wr.delta),wr.itemId&&wr.delta)){const Re=y.get(wr.itemId)??"";Re.endsWith(wr.delta)||y.set(wr.itemId,`${Re}${wr.delta}`)}const js=Gi(i);if(js&&(Jt(b,js.itemId,js.text),Xr(b)),Lr(i)){const Re=h.value[b]??"";Re.trim().length>0&&!Re.endsWith(`
|
|
77
77
|
|
|
78
78
|
`)&&di(b,`${Re}
|
|
79
79
|
|
|
80
|
-
`)}ra(i);const os=Ce(i);os&&(Kt(b,os),Gt(b,{label:"Running command",details:[((Yc=os.commandExecution)==null?void 0:Yc.command)??""]}));const Ls=st(i);if(Ls){const Re=(j.value[b]??[]).find(Ot=>Ot.id===Ls.itemId);Re!=null&&Re.commandExecution&&Kt(b,{...Re,commandExecution:{...Re.commandExecution,aggregatedOutput:`${Re.commandExecution.aggregatedOutput}${Ls.delta}`}})}const zc=Rt(i);zc&&Kt(b,zc);const Hc=$o(i);if(Hc&&$l(b,Hc),tr(i)&&pr(b,!0),i.method==="turn/completed"){Hn=!1,pr(b),y.clear(),j.value[b]&&(j.value=St(j.value,b));const Re=cn(i);Re&&(yo(Re),hn(Re,!1),Gt(Re,null),si(Re),Ne||(F(Re),Bl(Re)))}}function Ma(i){if(i.method==="thread/tokenUsage/updated"||i.method.startsWith("thread/realtime/"))return;const u=i.method,m=u==="turn/started"||u==="turn/completed"||u==="error",b=u.startsWith("thread/")||u==="turn/completed";if(!m&&!b)return;const R=cn(i);R&&m&&Yt.add(R),b&&(nn=!0,Kr=!0),!(ht!==null||typeof window>"u")&&(ht=window.setTimeout(()=>{ht=null,Ur()},yu))}async function Lo(i,u){if(!po){po=!0;try{if(!u)return;const m=[];for(const b of hd(u)){const R=Ui(b);m.includes(R)||m.push(R)}if(m.length>0){const b=u.projectOrder.length>0?ul(m,i):ul(z.value,i);us(z.value,b)||(z.value=b)}if(Object.keys(u.labels).length>0||(u.remoteProjects??[]).length>0){const b={...Be.value};let R=!1;for(const[E,L]of Object.entries(u.labels)){const q=ot(E).trim(),Z=[Ui(E)];q&&Z.push(q);for(const he of Z)b[he]!==L&&(b[he]=L,R=!0)}for(const E of u.order){const L=Ui(E),q=Hr(Cl(E));if(!q.startsWith(".")||q===L)continue;const Z=`${L} ${q}`;b[L]!==void 0||b[L]===Z||(b[L]=Z,R=!0)}for(const E of u.remoteProjects??[]){const L=nO(E);b[E.id]!==L&&(b[E.id]=L,R=!0)}R&&(Be.value=b)}}catch{}}}async function Nl(i={}){if(!(i.force!==!0&&Object.keys(W.value).length>0))try{const u=await Px();if(Object.keys(u.titles).length>0){const m={};for(const[b,R]of Object.entries(u.titles))m[b]=zs(R);W.value=m}}catch{}}async function jc(){try{return await pl()}catch{return null}}function $a(i,u,m){const b=i.trim();if(b)return zs(b);const R=m.map(E=>E.label.trim()).find(E=>E.length>0);return R?zs(R):u.length>0?zs("[Image]"):"Untitled thread"}async function Lc(i,u,m,b=[],R=[]){if(W.value[i])return;const E=u.trim();if(!E){const q=$a(u,b,R);W.value={...W.value,[i]:q},_n(),pu(i,q);return}const L=E.length>300?E.slice(0,300):E;try{const q=await Lx(L,m);if(!q||W.value[i])return;const Z=q.length>Kf?q.slice(0,Kf):q;W.value={...W.value,[i]:Z},_n(),pu(i,Z)}catch{}}function md(i,u){const m=Gf(i,u),b=sO(i,u),R=iO(b,u,m);if(!u||u.order.length===0&&(u.remoteProjects??[]).length===0)return R;const E=new Set;for(const q of Vf(u,m))E.add(q);const L=R.filter(q=>E.has(q.projectName)?!0:Yf(q));return aO(L,u,m)}function ja(i,u){const m=md(i,u),b=!!(u&&(u.order.length>0||u.projectOrder.length>0||(u.remoteProjects??[]).length>0)),R=u!=null&&u.projectOrder.length?ul(Vf(u,Gf(i,u)),m):ul(z.value,m);us(z.value,R)||(z.value=R,b||rc(z.value));const E=mf(m,z.value);Cs(new Set(To(E).map(Z=>Z.id)));const L=eO(t.value,E,J.value);t.value=_u(t.value,L),J.value=kn(J.value,new Set(To(t.value).map(Z=>Z.id))),new Set(To(t.value).map(Z=>Z.id));const q={};for(const Z of To(t.value))q[Z.id]=Z.externalSession??$e.value[Z.id]??null;$e.value=q,_n()}function Or(i){const u={};for(const[m,b]of Object.entries(i)){const R=m.trim();!R||b.length===0||(u[R]=b.map(E=>({id:E.id,text:E.text,imageUrls:[...E.imageUrls],skills:E.skills.map(L=>({name:L.name,path:L.path})),fileAttachments:E.fileAttachments.map(L=>({label:L.label,path:L.path,fsPath:L.fsPath})),collaborationMode:E.collaborationMode})))}return u}function aa(){nx(Or(de.value)).catch(()=>{})}async function Ol(){if(!xe){xe=!0;try{de.value=await $m()}catch{}}}function Bn(i){$t=bv($t,i),t.value=bv(t.value,i),J.value=St(J.value,i),_n()}function No(i,u){if(i.length===0)return u;if(u.length===0)return i;const m=new Map;for(const R of To(i))m.set(R.id,R);for(const R of To(u))m.set(R.id,R);const b=new Map;for(const R of m.values()){const E=b.get(R.projectName);E?E.push(R):b.set(R.projectName,[R])}return Array.from(b.entries()).map(([R,E])=>({projectName:R,threads:E.sort((L,q)=>new Date(q.updatedAtIso).getTime()-new Date(L.updatedAtIso).getTime())})).sort((R,E)=>{var Z,he;const L=new Date(((Z=R.threads[0])==null?void 0:Z.updatedAtIso)??0).getTime();return new Date(((he=E.threads[0])==null?void 0:he.updatedAtIso)??0).getTime()-L})}function ko(){return Object.values(J.value).some(i=>i===!0)}function vi(i=zn){if(!(!Jn||Po||ko())){if(zn=i,typeof window>"u"){Dr(i);return}Qn!==null&&window.clearTimeout(Qn),Qn=window.setTimeout(()=>{Qn=null,!(!Jn||ko())&&Dr(zn)},cN)}}async function Dr(i){if(!(Po||!Jn||ko())){Po=!0;try{const u=await km(Jn,ZS());Jn=u.nextCursor,Pt=u.nextCursor===null,Nt.value=Pt,$t=No($t,u.groups),ja($t,i)}catch{}finally{Po=!1,Jn&&!ko()&&vi(i)}}}async function Es(i={}){if(sr){await sr;return}i.force!==!0&&zo.value&&Date.now()-ba<fN||(sr=(async()=>{var u;zo.value||(Ze.value=!0);try{const[m,b]=await Promise.all([km(),jc(),Nl({force:i.force===!0})]);zn=b;const R=m.groups;$t=R,Jn=m.nextCursor,Pt=m.nextCursor===null,Nt.value=Pt,await Lo(R,b),ja($t,b),zo.value=!0,ba=Date.now(),Pt||vi(b);const E=To(e.value);Hi(E),!E.some(q=>q.id===n.value)&&!n.value&&fn(((u=E[0])==null?void 0:u.id)??"")}finally{Ze.value=!1}})().finally(()=>{sr=null}),await sr)}async function sa(i,u={}){var q;if(!i)return;const m=Date.now()-(ka.get(i)??0)<lv;if((q=se.value[i])!=null&&q.transient&&(u.silent===!0||m))return;const b=ir.get(i);if(b&&u.force!==!0){await b;return}const R=O.value[i]===!0,E=u.silent!==!0&&!R;E&&(Ft.value=!0);const L=(async()=>{try{const Z=no(i),he=$.value[i]??"",Ne=Date.now()-(Yr.get(i)??0)<lv;if(u.force===!0?!1:R&&(Ne||(Z.length===0||he===Z)&&J.value[i]!==!0)){ai(i);return}const it=ie.value[i]!==!0?await of(i):null,Mt=it??await nf(i);Mt.modelProvider&&xr(i,Mt.modelProvider),Mt.model&&vo(i,Go(i,Mt.model,Mt.modelProvider)),it&&(ie.value={...ie.value,[i]:!0});const{messages:Oa,inProgress:$s,activeTurnId:ia,turnIndexByTurnId:wr}=Mt;G.value={...G.value,[i]:Mt.hasMoreOlder===!0},Sa(i,Oa),Qa(i,wr),pi(i);const js=o.value[i]??[],qc=wv(js,Oa,{preserveMissing:u.silent===!0||BN(js)});fr(i,qc);const os=a.value[i]??[];if($s){const Ls=zN(os,Oa);_a(i,Ls)}else $n(i);Nn(i,Oa),bn(i,Oa),O.value={...O.value,[i]:!0},Yr.set(i,Date.now()),ka.delete(i),Z&&($.value={...$.value,[i]:Z}),hn(i,$s),Mt.externalSession&&($e.value={...$e.value,[i]:Mt.externalSession}),ii(i),ia?Ee.value={...Ee.value,[i]:ia}:Ee.value[i]&&(Ee.value=St(Ee.value,i)),$s||Mo(i),ai(i)}catch(Z){const he=Z instanceof Error?Z.message:"Unknown application error";throw n.value===i&&Zt(i,he,{transient:!0}),ka.set(i,Date.now()),Z}finally{E&&(Ft.value=!1)}})().finally(()=>{ir.delete(i)});ir.set(i,L),await L}async function Fr(i=n.value){if(!i||ue.value[i]===!0||G.value[i]!==!0)return;const u=Sn(i);if(!u){G.value={...G.value,[i]:!1};return}ue.value={...ue.value,[i]:!0};try{const m=await t_(i,u),b=o.value[i]??[],R=wv(m.messages,b,{preserveMissing:!0});fr(i,R),Qa(i,{...re.value[i]??{},...m.turnIndexByTurnId}),pi(i),G.value={...G.value,[i]:m.hasMoreOlder}}catch(m){throw ut.value=m instanceof Error?m.message:"Failed to load earlier messages",m}finally{ue.value={...ue.value,[i]:!1}}}async function gi(i,u={}){var m;i&&O.value[i]!==!0&&(u.silent===!0&&((m=se.value[i])!=null&&m.transient)||await sa(i,u))}async function Rs(i={}){var b,R;const u=((R=(b=ho.value)==null?void 0:b.cwd)==null?void 0:R.trim())??"",m=u||"__global__";if(Yn){await Yn;return}i.force!==!0&&Ha&&Gr===m&&Date.now()-In<pN||(Yn=(async()=>{try{Y.value=await Ox(u?[u]:void 0),Ha=!0,In=Date.now(),Gr=m}catch{}finally{Yn=null}})(),await Yn)}async function Ki(i={}){if(lr){await lr;return}i.force!==!0&&Dn||(We.value=!0,lr=(async()=>{try{Oe.value=await l_(),Dn=!0}catch{}finally{We.value=!1,lr=null}})(),await lr)}async function La(i={}){await Promise.allSettled([Xt({providerChanged:i.providerChanged,includeProviderModels:i.includeProviderModels}),jt(),qt(),Rs()])}function Dl(i={}){const u=()=>{La(i)};if(typeof window>"u"){u();return}window.setTimeout(u,0)}async function yi(i={}){ut.value="",ae.value="";const u=i.includeSelectedThreadMessages!==!1,m=i.awaitAncillaryRefreshes===!0;try{if(await Ol(),await Es({force:i.forceThreadRefresh===!0}),u)try{await sa(n.value)}catch(b){ut.value=b instanceof Error?b.message:"Unknown application error"}m?await La({providerChanged:i.providerChanged,includeProviderModels:i.providerChanged===!0||m}):Dl({providerChanged:i.providerChanged,includeProviderModels:!1})}catch(b){ut.value=b instanceof Error?b.message:"Unknown application error",uv(b)?ae.value=cv:ae.value=""}}async function Na(i){fn(i);try{return await sa(i),await Xt({includeProviderModels:!0}),Rs(),"ok"}catch(u){const m=u instanceof Error?u.message:"Unknown application error";ut.value=m;const b=gN(u)?"not-found":"error";return i.trim()&&Zt(i,m,{transient:!0}),b}}async function Fl(i){const u=n.value===i,m=u?aN(To(e.value),i):"";u&&(fn(m),m&&sa(m,{silent:!0}));try{await $_(i),Bn(i),await Es(),u&&m&&n.value===m&&await gi(m,{silent:!0})}catch(b){ut.value=b instanceof Error?b.message:"Unknown application error"}}async function Yi(i,u){const m=u.trim();if(!(!i||!m))try{await N_(i,m),W.value={...W.value,[i]:m},_n(),pu(i,m)}catch(b){ut.value=b instanceof Error?b.message:"Unknown application error"}}async function Ul(i){var L,q;const u=i.trim();if(!u)return"";const m=To(t.value).find(Z=>Z.id===u),b=((L=m==null?void 0:m.cwd)==null?void 0:L.trim())??"",R=((q=m==null?void 0:m.title)==null?void 0:q.trim())??"Forked chat",E=sn(u);ut.value="";try{const Z=await Am(u,b||void 0,E||void 0),he=Z.threadId.trim();return he?(ri(he,b,R),vo(he,Z.model),ie.value={...ie.value,[he]:!0},fn(he),await Es(),await sa(he),he):""}catch(Z){return ut.value=Z instanceof Error?Z.message:"Unknown application error",""}}async function wi(i,u){var L;const m=i.trim();if(!m||!Number.isInteger(u)||u<0)return"";if(J.value[m]===!0)return ut.value="Finish the current turn before forking from a response.","";if(O.value[m]!==!0)try{await sa(m)}catch(q){return ut.value=q instanceof Error?q.message:"Unknown application error",""}const b=o.value[m]??[];let R=-1;for(const q of b)typeof q.turnIndex=="number"&&Number.isFinite(q.turnIndex)&&(R=Math.max(R,q.turnIndex));if(R>=0&&u>R)return"";const E=To(t.value).find(q=>q.id===m)??null;try{ut.value="";const q=await Am(m),Z=q.threadId.trim();if(!Z)return"";const he=q.cwd.trim()||((L=E==null?void 0:E.cwd)==null?void 0:L.trim())||"",Ne=lO((E==null?void 0:E.title)||(E==null?void 0:E.preview)||"Untitled thread");ri(Z,he,Ne),vo(Z,q.model),fr(Z,q.messages),O.value={...O.value,[Z]:!0},ie.value={...ie.value,[Z]:!0},hr(Z),_a(Z,[]),pr(Z),j.value[Z]&&(j.value=St(j.value,Z)),ln(Z,null),Gt(Z,null),Zt(Z,null),hn(Z,!1);const Je=R-u;if(Je>0){const pt=await rf(Z,Je);fr(Z,pt)}return await Yi(Z,Ne),fn(Z),Es().catch(()=>{}),Z}catch(q){return ut.value=q instanceof Error?q.message:"Unknown application error",""}}async function es(i,u,m=[],b=[],R=[]){if(!i||!u.trim()||m.length>0||b.length>0||R.length>0)return!1;const L=(rt.value[i]??[]).filter(he=>he.method==="item/tool/requestUserInput");if(L.length!==1)return!1;const[q]=L,Z=$r(q);return Z.length!==1?!1:tl({id:q.id,result:{answers:{[Z[0]]:{answers:[u.trim()]}}}})}function Rn(){if(typeof window>"u")return{};try{const i=window.localStorage.getItem(sv);if(!i)return{};const u=JSON.parse(i);if(!u||typeof u!="object"||Array.isArray(u))return{};const m={};for(const[b,R]of Object.entries(u)){if(!b||!Array.isArray(R))continue;const E=R.filter(L=>!!L&&typeof L=="object"&&typeof L.id=="string"&&typeof L.text=="string");E.length>0&&(m[b]=E)}return m}catch{return{}}}function gr(){typeof window>"u"||window.localStorage.setItem(sv,JSON.stringify(je.value))}function ts(){if(typeof window>"u")return gu;try{const i=window.localStorage.getItem(iv);if(i===null)return gu;const u=Number(i);return Number.isFinite(u)&&u>=0?Math.round(u):gu}catch{return gu}}function Nc(i){const u=Number.isFinite(i)&&i>0?Math.round(i):0;u!==fe.value&&(fe.value=u,!(typeof window>"u")&&window.localStorage.setItem(iv,String(u)))}async function vd(i,u,m,b,R,E){if(Te||fe.value<=0||J.value[i]===!0)return!1;const L=Tt.value[i];if(!L||L.remainingContextPercent===null||L.remainingContextPercent>fe.value)return!1;const q=je.value[i]??[],Z=`stash-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,he=E==="plan"?"plan":E==="default"?"default":et.value;return je.value={...je.value,[i]:[...q,{id:Z,text:u,imageUrls:m,skills:b,fileAttachments:R,collaborationMode:he}]},gr(),fo.value.has(i)||zl(i),!0}async function bi(i){const u=je.value[i];if(!u||u.length===0||J.value[i]===!0)return;const m=[...u];je.value=St(je.value,i),gr(),Te=!0;try{for(const b of m)try{await Ji(b.text,b.imageUrls,b.skills,"steer",b.fileAttachments,void 0,b.collaborationMode)}catch{}}finally{Te=!1}}async function Ji(i,u=[],m=[],b="steer",R=[],E,L){if(co.value)return;const q=n.value,Z=i.trim();if(!q||!Z&&u.length===0&&R.length===0||await es(q,Z,u,m,R)||await vd(q,Z,u,m,R,L))return;const he=J.value[q]===!0;if(he&&b==="queue"){const Ne=de.value[q]??[],Je=`q-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,pt=[...Ne],it=typeof E=="number"?Math.max(0,Math.min(E,pt.length)):pt.length;pt.splice(it,0,{id:Je,text:Z,imageUrls:u,skills:m,fileAttachments:R,collaborationMode:L==="plan"?"plan":L==="default"?"default":et.value}),de.value={...de.value,[q]:pt},aa();return}if(he){Hn=!0,Qi(q,Z,u,m,R,L).catch(Ne=>{const Je=Ne instanceof Error?Ne.message:"Unknown application error";Zt(q,Je),ut.value=Je});return}ut.value="",Hn=!0,ln(q,null),Gt(q,{label:"Thinking",details:pn(sn(q),mt.value,L==="plan"?"plan":L==="default"?"default":et.value)}),Zt(q,null),hn(q,!0);try{await Qi(q,Z,u,m,R,L)}catch(Ne){Hn=!1,hn(q,!1),Gt(q,null);const Je=Ne instanceof Error?Ne.message:"Unknown application error";throw Zt(q,Je),ut.value=Je,Ne}}async function ki(i,u,m=[],b=[],R=[]){if(co.value)return"";const E=i.trim(),L=u.trim(),q=sn(Zs).trim(),Z=et.value;if(!E&&m.length===0&&R.length===0)return"";Kn.value=!0,ut.value="";let he="";try{try{const it=await xm(L||void 0,q||void 0);he=it.threadId,vo(he,it.model),xr(he,it.modelProvider||at.value),Eo(he,Z)}catch(it){if(q&&q!==ca&&Tu(it)){await go();const Mt=await xm(L||void 0,ca);he=Mt.threadId,vo(he,Mt.model),xr(he,Mt.modelProvider||at.value),Eo(he,Z)}else throw it}if(!he)return"";ri(he,L,E||"[Image]"),li(he,E,m,b,R),eo(he),ie.value={...ie.value,[he]:!0},fn(he),Hn=!0,ln(he,null),Gt(he,{label:"Thinking",details:pn(sn(he),mt.value,Z)}),Zt(he,null),hn(he,!0);const Ne=he,Je=L||null,pt=E;return Qi(he,E,m,b,R,Z).catch(it=>{Hn=!1,hn(he,!1),Gt(he,null);const Mt=it instanceof Error?it.message:"Unknown application error";Zt(he,Mt),ut.value=Mt}).finally(()=>{Kn.value=!1}),Lc(Ne,pt,Je,m,R),he}catch(Ne){Hn=!1,he&&(hn(he,!1),Gt(he,null));const Je=Ne instanceof Error?Ne.message:"Unknown application error";throw he&&Zt(he,Je),ut.value=Je,Kn.value=!1,Ne}}async function Qi(i,u,m=[],b=[],R=[],E){const L=mt.value,q=E==="plan"?"plan":E==="default"?"default":et.value,Z=u.trim(),he=[...m];if(he.length===0&&ni(Z)){const pt=Et(i);pt&&he.push(pt)}const Ne=b.map(pt=>({name:pt.name,path:pt.path})),Je=R.map(pt=>({...pt}));M(i,{text:Z,imageUrls:[...he],skills:Ne,fileAttachments:Je,effort:L,collaborationMode:q,fallbackRetried:!1});try{if(ie.value[i]!==!0){const Mt=await of(i);Mt.model&&vo(i,Go(i,Mt.model,Mt.modelProvider)),Mt.modelProvider&&xr(i,Mt.modelProvider),ie.value={...ie.value,[i]:!0}}const pt=sn(i);let it="";try{it=await af(i,u,he,pt||void 0,L||void 0,b.length>0?b:void 0,R,q)}catch(Mt){if(pt&&pt!==ca&&Tu(Mt))await go(i),M(i,{text:Z,imageUrls:[...he],skills:Ne,fileAttachments:Je,effort:L,collaborationMode:q,fallbackRetried:!0}),it=await af(i,u,he,ca,L||void 0,b.length>0?b:void 0,R,q);else throw Mt}it&&(Ee.value={...Ee.value,[i]:it},Yo(i,it)),Yt.add(i),await Ur(),Ta(i)}catch(pt){throw pt}}async function Xi(i){if(Le.value[i]!==!0){Le.value={...Le.value,[i]:!0};try{de.value=await $m()}catch{}finally{Le.value=St(Le.value,i)}}}function Bl(i){Xi(i),!(typeof window>"u")&&window.setTimeout(()=>{Xi(i)},650)}async function Oc(){const i=n.value;if(!i||J.value[i]!==!0||ge.value[i]===!0)return;let u=Ee.value[i];if(!u){const{activeTurnId:E}=await nf(i);u=E,u&&(Ee.value={...Ee.value,[i]:u})}if(!u)throw new Error("Could not determine active turn id for interrupt");const m=_r.value.filter(E=>E.turnId===u),b=m.find(E=>E.role==="user"),R=m.some(E=>{if(E.role==="assistant")return!0;const L=E.messageType??"";return L==="commandExecution"||L==="toolCall"||L==="worked"||L==="fileChange"||L==="plan"||L==="plan.live"||L==="compaction.done"||L==="turnError"});lo.value=!0,ut.value="";try{if(await z_(i,u),hn(i,!1),Gt(i,null),Zt(i,null),Ee.value[i]&&(Ee.value=St(Ee.value,i)),Yt.add(i),nn=!0,await Ur(),b&&!R){const E=(o.value[i]??[]).filter(q=>q.turnId!==u);fr(i,E);const L=d.value[i];if(L){const q=L.filter(Z=>Z.turnId!==u);q.length!==L.length&&(d.value={...d.value,[i]:q},wu(d.value))}Ve.value={...Ve.value,[i]:{text:b.text??"",imageUrls:b.images??[],fileAttachments:(b.fileAttachments??[]).map(q=>({label:q.label,path:q.path,fsPath:q.fsPath??q.path})),skills:b.skills??[]}}}}catch(E){const L=E instanceof Error?E.message:"Failed to interrupt active turn";Zt(i,L),ut.value=L}finally{lo.value=!1}}function ql(i){i&&Ve.value[i]&&(Ve.value=St(Ve.value,i))}async function gd(i){var m,b;const u=n.value;if(u&&!uo.value&&i.trim()){uo.value=!0,ut.value="";try{J.value[u]===!0&&await Oc();const R=o.value[u]??[],E=R.find(Je=>Je.turnId===i),L=typeof(E==null?void 0:E.turnIndex)=="number"?E.turnIndex:-1;if(L<0)return;const q=R.reduce((Je,pt)=>typeof pt.turnIndex=="number"&&pt.turnIndex>Je?pt.turnIndex:Je,-1);if(q<0||L>q)return;const Z=q-L+1;if(Z<1)return;const he=((b=(m=ho.value)==null?void 0:m.cwd)==null?void 0:b.trim())??"";he&&await D_(u,i,he);const Ne=await rf(u,Z);fr(u,Ne),_a(u,[]),pr(u),j.value[u]&&(j.value=St(j.value,u)),ln(u,null),Gt(u,null),Zt(u,null),nn=!0,await Ur()}catch(R){ut.value=R instanceof Error?R.message:"Failed to rollback thread"}finally{uo.value=!1}}}function yr(i,u){const b=(l.value[i]??[]).filter(R=>R.messageType!=="compaction.pending"&&R.messageType!=="compaction.done");b.push({id:`compaction:${u}:${i}:${Date.now()}`,role:"system",text:"",messageType:u==="pending"?"compaction.pending":"compaction.done"}),l.value={...l.value,[i]:b}}function Ms(i,u){const m=new Set(fo.value);u?m.add(i):m.delete(i),fo.value=m}function Zi(i){Qt=i.trim(),Cr.value=[]}async function zl(i){const u=i.trim();if(!(!u||fo.value.has(u))){Ms(u,!0),yr(u,"pending");try{await L_(u);const m=2e3,b=14,R=Date.now()+za;let E=0;for(;Date.now()<R&&E<b&&fo.value.has(u);){if((await nf(u)).messages.some(Z=>Z.messageType==="compaction.done")){Ms(u,!1),n.value===u&&await sa(u,{silent:!0,force:!0}),yr(u,"done"),bi(u);break}E+=1,await rN(m)}fo.value.has(u)&&(Ms(u,!1),yr(u,"done"),bi(u))}catch(m){ut.value=m instanceof Error?m.message:"Failed to compact thread",Ms(u,!1),yr(u,"done"),bi(u)}}}let mn=null;async function el(i,u){try{const m=await pl(),b={...m.labels};let R=!1;for(const E of m.order){if(!$u(E,i))continue;const L=u.trim();L.length===0?b[E]!==void 0&&(delete b[E],R=!0):b[E]!==L&&(b[E]=L,R=!0)}R&&await sf({order:m.order,labels:b,active:m.active,projectOrder:m.projectOrder})}catch{}}function yd(i,u){i.length===0||(Be.value[i]??"")===u||(Be.value={...Be.value,[i]:u},yv(Be.value),mn!==null&&clearTimeout(mn),mn=setTimeout(()=>{mn=null,el(i,u)},500))}async function Ci(i){var E;if(i.length===0)return;const u=z.value.filter(L=>L!==i);if(us(z.value,u)||(z.value=u,rc(z.value)),t.value=t.value.filter(L=>L.projectName!==i),Be.value[i]!==void 0){const L={...Be.value};delete L[i],Be.value=L,yv(L)}_n();const m=To(e.value);Hi(m),m.some(L=>L.id===n.value)||fn(((E=m[0])==null?void 0:E.id)??"");const R=new Set;try{const L=await pl();oO(L,i).forEach(q=>{R.add(q)})}catch{}if(R.size>0)try{const L=await pl(),q=L.order.filter(Ne=>!R.has(Ne)),Z=L.active.filter(Ne=>!R.has(Ne)),he=Z.length===0&&q.length>0?[q[0]]:Z;await sf({order:q,labels:JN(L.labels,R),active:he,projectOrder:L.projectOrder.filter(Ne=>Ne!==i&&!R.has(Ne))});return}catch{}await Ti()}function wd(i,u){if(i.length===0||t.value.length===0)return;const m=t.value.map(Z=>Z.projectName),b=m.indexOf(i);if(b===-1)return;const R=Math.max(0,Math.min(u,m.length-1)),E=NN(m,b,R);if(E===m)return;const L=ul(E,t.value);z.value=L,rc(z.value);const q=mf(t.value,z.value);t.value=_u(t.value,q),_n(),Ti()}function Dc(i){const u=i.trim();if(!u)return;const m=[u,...z.value.filter(R=>R!==u)];if(us(z.value,m))return;z.value=m,rc(z.value);const b=mf(t.value,z.value);t.value=_u(t.value,b),_n(),Ti()}async function Ti(){try{const i=await pl(),u=rO(i,z.value,t.value);await sf({order:u.order,labels:i.labels,active:u.active,projectOrder:u.projectOrder})}catch{}}async function Ur(){if(gn.value){typeof window<"u"&&ht===null&&(ht=window.setTimeout(()=>{ht=null,Ur()},yu));return}gn.value=!0;const i=nn,u=Kr,m=new Set(Yt);nn=!1,Kr=!1,Yt.clear();try{i&&await Es({force:u});const b=n.value;if(!b)return;const R=m.has(b),E=J.value[b]===!0,L=no(b),q=$.value[b]??"";(L.length>0&&L!==q||R||E&&O.value[b]!==!0||i&&O.value[b]!==!0)&&await sa(b,{silent:!0,force:R})}catch{}finally{gn.value=!1,(nn||Yt.size>0)&&typeof window<"u"&&ht===null&&(ht=window.setTimeout(()=>{ht=null,Ur()},yu))}}async function Fc(){await Bc(),nn=!zo.value,n.value&&O.value[n.value]!==!0&&Yt.add(n.value),await Ur()}function Hl(i){const u=qe(i.params),m=typeof(u==null?void 0:u.threadId)=="string"?u.threadId.trim():"";if(!m)return;const b=qe(u==null?void 0:u.externalSession),R=b&&typeof b.origin=="string"&&b.origin.trim().length>0?{origin:b.origin.trim(),active:b.active===!0,lastWriteAt:typeof b.lastWriteAt=="string"?b.lastWriteAt:null}:null;$e.value={...$e.value,[m]:R},hn(m,(R==null?void 0:R.active)===!0),_n(),nn=!0,n.value===m&&Yt.add(m),ht===null&&typeof window<"u"&&(ht=window.setTimeout(()=>{ht=null,Ur()},yu))}function Uc(){typeof window>"u"||Ut||(Bc(),bd(),Ut=C_(i=>{if(i.method==="ready"){Ts(),Fc();return}if(i.method==="externalSessionChanged"){Hl(i);return}Is(i),Ma(i)}))}async function Bc(){try{const u=(await Sm()).map(m=>Ka(m)).filter(m=>m!==null);vr(u)}catch{}}async function bd(){try{const i=await Ix(),u=Object.entries(i);if(u.length===0)return;const m={...d.value};let b=!1;for(const[R,E]of u){const L=E.filter(Ne=>!!Ne&&typeof Ne.id=="string");if(L.length===0)continue;const q=m[R]??[],Z=new Set(q.map(Ne=>Ne.text)),he=[...q];for(const Ne of L)Z.has(Ne.text)||(he.push(Ne),Z.add(Ne.text));m[R]=he.slice(-20),b=!0}b&&(d.value=m,wu(m))}catch{}}async function tl(i){try{return await __(i.id,{result:i.result,error:i.error}),Qo(i.id),pe.value=St(pe.value,String(i.id)),!0}catch(u){const m=u instanceof Error?u.message:"Failed to reply to server request";return await Wl(i.id)?(ut.value=m,pe.value={...pe.value,[String(i.id)]:m},!1):(Qo(i.id),pe.value=St(pe.value,String(i.id)),!0)}}async function Wl(i){try{const u=await Sm();for(const m of u){const b=qe(m);if((b==null?void 0:b.id)===i)return!0}return!1}catch{return!0}}function kd(){if(Ut&&(Ut(),Ut=null),nn=!1,Yt.clear(),Xn.clear(),ht!==null&&typeof window<"u"&&(window.clearTimeout(ht),ht=null),Ho!==null&&typeof window<"u"&&(window.clearTimeout(Ho),Ho=null),Qn!==null&&typeof window<"u"&&(window.clearTimeout(Qn),Qn=null),typeof window<"u")for(const i of dn.values())window.clearTimeout(i);dn.clear(),Hn=!1,o.value={},r.value={},a.value={},h.value={},d.value={},j.value={},B.value={},re.value={},be.value={},Se.value={},se.value={},Ee.value={},P.clear(),y.clear(),_.clear(),Qs.clear(),ju=0,ge.value={},Fe.value={},Me.value={},de.value={},Le.value={},je.value={},gr(),aa(),It.value=null,Tt.value={}}const Si=X(()=>{const i=n.value;if(!i)return[];const u=de.value[i]??[];return[...(je.value[i]??[]).map(R=>({...R,awaitingCompaction:!0})),...u]});function nl(i){const u=n.value;if(!u)return;const m=je.value[u];if(m!=null&&m.some(E=>E.id===i)){const E=m.filter(L=>L.id!==i);je.value=E.length>0?{...je.value,[u]:E}:St(je.value,u),gr();return}const b=de.value[u];if(!b)return;const R=b.filter(E=>E.id!==i);de.value=R.length>0?{...de.value,[u]:R}:St(de.value,u),aa()}function Vl(i,u){const m=n.value;if(!m)return;const b=de.value[m];if(!b)return;const R=je.value[m];if(R!=null&&R.some(he=>he.id===i||he.id===u))return;const E=b.findIndex(he=>he.id===i),L=b.findIndex(he=>he.id===u);if(E<0||L<0||E===L)return;const q=[...b],[Z]=q.splice(E,1);q.splice(L,0,Z),de.value={...de.value,[m]:q},aa()}function ns(i){const u=n.value;if(!u)return;const m=je.value[u],b=m==null?void 0:m.find(L=>L.id===i);if(b){nl(i),Ko(b.collaborationMode),Te=!0,Ji(b.text,b.imageUrls,b.skills,"steer",b.fileAttachments).finally(()=>{Te=!1});return}const R=de.value[u];if(!R)return;const E=R.find(L=>L.id===i);E&&(nl(i),Ko(E.collaborationMode),Ji(E.text,E.imageUrls,E.skills,"steer",E.fileAttachments))}function Cd(i,u={}){fn(i,u)}return{projectGroups:e,projectDisplayNameById:Be,selectedThread:ho,selectedThreadTokenUsage:cr,selectedThreadTerminalOpen:Tr,isSelectedThreadInterruptPending:Sr,selectedThreadServerRequests:oi,selectedLiveOverlay:Wa,selectedActiveTurnId:Wo,lastPlanByThreadId:s,resolveThreadTurnIndex:Ll,codexQuota:Ca,selectedThreadId:n,availableCollaborationModes:At,availableModelIds:Ue,availableModelReasoningEfforts:Ye,selectedCollaborationMode:et,selectedModelId:ft,selectedReasoningEffort:mt,selectedSpeedMode:kt,codexCliMissingError:ae,installedSkills:Y,accountRateLimitSnapshots:me,messages:_r,hasMoreOlderMessages:Ct,isLoadingThreads:Ze,isThreadListFullyLoaded:Nt,isLoadingMessages:Ft,isLoadingOlderMessages:Fn,isSendingMessage:Kn,isInterruptingTurn:lo,isUpdatingSpeedMode:co,isRollingBack:uo,compactingThreadIds:fo,fuzzyFileSearchResults:Cr,registerFuzzyFileSearchSession:Zi,error:ut,refreshAll:yi,refreshSkills:Rs,refreshHooks:Ki,hooksList:Oe,isHooksLoading:We,onRealtimeEvent:Ps,selectThread:Na,loadMessages:sa,loadOlderMessages:Fr,ensureThreadMessagesLoaded:gi,setThreadTerminalOpen:dr,toggleSelectedThreadTerminal:Wi,archiveThreadById:Fl,compactThreadById:zl,renameThreadById:Yi,forkThreadById:Ul,forkThreadFromTurn:wi,rollbackSelectedThread:gd,sendMessageToSelectedThread:Ji,sendMessageToNewThread:ki,interruptSelectedThreadTurn:Oc,interruptedUnsubmittedMessage:ur,clearInterruptedUnsubmittedMessage:ql,selectedThreadQueuedMessages:Si,removeQueuedMessage:nl,reorderQueuedMessage:Vl,steerQueuedMessage:ns,autoCompactThreshold:fe,setAutoCompactThreshold:Nc,setSelectedCollaborationMode:Ko,readModelIdForThread:sn,setSelectedModelIdForThread:Vn,setSelectedModelId:Zn,setSelectedReasoningEffort:Pe,updateSelectedSpeedMode:Ge,respondToPendingServerRequest:tl,pendingReplyErrorForRequest:Xo,renameProject:yd,removeProject:Ci,reorderProject:wd,pinProjectToTop:Dc,startPolling:Uc,stopPolling:kd,primeSelectedThread:Cd}}const hO={class:"sidebar-root"},mO=["aria-pressed","aria-label","title"],vO={key:1,class:"sidebar-search-bar"},gO=["placeholder"],yO=["aria-label"],wO={class:"sidebar-skills-link-icon","aria-hidden":"true"},bO={class:"sidebar-skills-link-copy"},kO={class:"sidebar-skills-link-title"},CO={class:"sidebar-skills-link-subtitle"},TO={class:"sidebar-skills-link-icon sidebar-automations-link-icon","aria-hidden":"true"},SO={class:"sidebar-skills-link-copy"},_O={class:"sidebar-skills-link-title"},xO={class:"sidebar-skills-link-subtitle"},AO=["aria-label"],PO={class:"settings-dialog-header"},IO={class:"settings-dialog-title"},EO=["aria-label","title"],RO={class:"settings-dialog-body"},MO=["aria-label"],$O=["aria-current","onClick"],jO={class:"settings-group-content"},LO=["title"],NO={class:"sidebar-settings-label"},OO=["title"],DO={class:"sidebar-settings-label"},FO={class:"sidebar-settings-value"},UO=["title"],BO={class:"sidebar-settings-label"},qO={class:"sidebar-settings-value"},zO=["title"],HO={class:"sidebar-settings-label"},WO=["title"],VO={class:"sidebar-settings-label"},GO={class:"sidebar-settings-value"},KO=["title"],YO={class:"sidebar-settings-label"},JO=["title"],QO={class:"sidebar-settings-label"},XO=["title"],ZO={class:"sidebar-settings-label"},e2=["title"],t2={class:"sidebar-settings-label"},n2=["href"],o2={class:"sidebar-settings-label"},r2={class:"sidebar-settings-value"},a2=["title"],s2={class:"sidebar-settings-label"},i2={key:0,class:"sidebar-settings-row sidebar-settings-error"},l2=["href"],c2={key:1,class:"sidebar-settings-row sidebar-settings-row--input"},u2={class:"sidebar-settings-provider-info"},d2={class:"sidebar-settings-label"},f2={class:"sidebar-settings-provider-link",href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer"},p2={class:"sidebar-settings-key-group"},h2={class:"sidebar-settings-key-masked"},m2=["disabled","title"],v2=["placeholder"],g2=["disabled"],y2={class:"sidebar-settings-row sidebar-settings-row--select",style:{"margin-top":"4px",padding:"0"}},w2={class:"sidebar-settings-label"},b2=["aria-label"],k2=["disabled"],C2=["disabled"],T2={key:2,class:"sidebar-settings-row sidebar-settings-row--input"},S2={class:"sidebar-settings-provider-info"},_2={class:"sidebar-settings-label"},x2={class:"sidebar-settings-provider-link",href:"https://opencode.ai/auth",target:"_blank",rel:"noopener noreferrer"},A2={class:"sidebar-settings-key-group"},P2=["placeholder"],I2=["disabled"],E2={key:3,class:"sidebar-settings-row sidebar-settings-row--input"},R2={class:"sidebar-settings-label"},M2={class:"sidebar-settings-key-group"},$2=["placeholder"],j2={class:"sidebar-settings-label",style:{"margin-top":"4px"}},L2={class:"sidebar-settings-key-group"},N2=["placeholder"],O2=["disabled"],D2={class:"sidebar-settings-row sidebar-settings-row--select",style:{"margin-top":"4px",padding:"0"}},F2={class:"sidebar-settings-label"},U2=["aria-label"],B2={class:"sidebar-settings-label"},q2={class:"sidebar-settings-value"},z2={key:0,class:"sidebar-settings-telegram-panel"},H2={class:"sidebar-settings-field"},W2={class:"sidebar-settings-field-label"},V2={class:"sidebar-settings-field"},G2={class:"sidebar-settings-field-label"},K2={class:"sidebar-settings-field-help"},Y2={key:0,class:"sidebar-settings-telegram-error"},J2=["href"],Q2={class:"sidebar-settings-telegram-actions"},X2=["disabled"],Z2={class:"sidebar-settings-hooks-section"},eD={class:"sidebar-settings-hooks-header"},tD={class:"sidebar-settings-hooks-title"},nD=["disabled","title"],oD={key:0,class:"sidebar-settings-hooks-empty"},rD={key:0,class:"sidebar-settings-hooks-empty"},aD={key:1,class:"sidebar-settings-hooks-empty"},sD={key:2,class:"sidebar-settings-hooks-list"},iD={class:"sidebar-settings-hooks-cwd"},lD={class:"sidebar-settings-hooks-event"},cD={class:"sidebar-settings-hooks-command"},uD={class:"sidebar-settings-remote-section"},dD={class:"sidebar-settings-remote-header"},fD={class:"sidebar-settings-remote-title"},pD=["disabled","title"],hD={class:"sidebar-settings-remote-toggle-label"},mD={key:0,class:"sidebar-settings-remote-empty"},vD={key:0,class:"sidebar-settings-remote-error"},gD={key:1,class:"sidebar-settings-remote-notice"},yD={key:2,class:"sidebar-settings-remote-empty"},wD=["disabled"],bD={class:"sidebar-settings-remote-label"},kD={class:"sidebar-settings-remote-value"},CD={class:"sidebar-settings-remote-clients"},TD={class:"sidebar-settings-remote-clients-header"},SD={class:"sidebar-settings-remote-label"},_D=["disabled"],xD={key:0,class:"sidebar-settings-remote-empty"},AD={class:"sidebar-settings-remote-client-name"},PD=["disabled","onClick"],ID={class:"sidebar-settings-rate-limits"},ED=["aria-label"],RD={class:"sidebar-settings-actions"},MD=["title","aria-label"],$D=["title","aria-label"],jD={class:"content-root-wrap"},LD={key:0,class:"content-keyboard-spacer","aria-hidden":"true"},ND={key:1,class:"skills-route-header-icon","aria-hidden":"true"},OD={key:2,class:"skills-route-header-icon automations-route-header-icon","aria-hidden":"true"},DD=["aria-label","title"],FD={class:"content-body"},UD={key:2,class:"content-grid content-grid-home"},BD={class:"new-thread-empty"},qD={class:"new-thread-hero"},zD=["title"],HD={class:"new-thread-folder-actions"},WD=["disabled"],VD={key:1,class:"new-thread-launch-card","aria-label":"Plugins and Apps announcement"},GD={class:"new-thread-launch-card-copy"},KD={class:"new-thread-launch-card-topline"},YD={class:"new-thread-launch-card-badge","aria-hidden":"true"},JD={class:"new-thread-launch-card-eyebrow"},QD={class:"new-thread-launch-card-title"},XD={class:"new-thread-launch-card-text"},ZD={class:"new-thread-launch-card-actions"},eF=["aria-label","onKeydown"],tF={class:"new-thread-open-folder-header"},nF={class:"new-thread-open-folder-title"},oF={class:"new-thread-open-folder-label"},rF={class:"new-thread-open-folder-current"},aF=["placeholder","title","disabled","onKeydown"],sF=["disabled"],iF={class:"new-thread-open-folder-actions"},lF={class:"new-thread-open-folder-toggle"},cF=["aria-pressed","disabled"],uF={key:0,class:"new-thread-open-folder-create"},dF={class:"new-thread-open-folder-create-composer"},fF=["placeholder","onKeydown"],pF=["disabled"],hF={key:0,class:"new-thread-open-folder-error visible-error-with-feedback"},mF=["href"],vF=["placeholder","onKeydown"],gF={key:1,class:"new-thread-open-folder-error-actions"},yF={class:"new-thread-open-folder-error visible-error-with-feedback"},wF=["href"],bF=["disabled"],kF={key:2,class:"new-thread-open-folder-status"},CF={key:3,class:"new-thread-open-folder-status"},TF={key:4,class:"new-thread-open-folder-list"},SF=["title","disabled","onClick"],_F={class:"new-thread-open-folder-item-name"},xF=["disabled","onClick"],AF=["aria-label","onKeydown"],PF={class:"new-thread-open-folder-header"},IF={class:"new-thread-open-folder-title"},EF=["disabled"],RF=["aria-label"],MF=["aria-selected","disabled"],$F=["aria-selected","disabled"],jF={class:"new-thread-project-field"},LF={class:"new-thread-open-folder-label"},NF=["disabled","placeholder"],OF={key:0,class:"new-thread-project-field"},DF={class:"new-thread-open-folder-label"},FF=["disabled","placeholder","onKeydown"],UF={key:1,class:"new-thread-project-field"},BF={class:"new-thread-open-folder-label"},qF=["disabled","onKeydown"],zF={key:2,class:"new-thread-open-folder-error visible-error-with-feedback"},HF=["href"],WF={class:"new-thread-project-modal-actions"},VF=["disabled"],GF=["disabled"],KF={key:3,class:"new-thread-branch-select"},YF={class:"new-thread-branch-select-label"},JF={class:"new-thread-branch-select-help"},QF={key:4,class:"new-thread-runtime-help"},XF={class:"worktree-init-status-title"},ZF={class:"worktree-init-status-message"},eU={class:"composer-with-queue"},tU={key:0,class:"composer-runtime-error",role:"alert"},nU=["href"],oU={key:3,class:"content-grid"},rU={class:"content-thread"},aU={key:0,class:"external-session-banner",role:"alert"},sU={key:1,class:"composer-runtime-error",role:"alert"},iU=["href"],lU={key:2,class:"interrupt-recovered-banner",role:"status"},cU=["aria-label"],uU={class:"content-right-panel-header"},dU={class:"content-right-panel-tabs",role:"tablist"},fU=["aria-selected"],pU=["aria-selected"],hU=["aria-selected","title","onClick"],mU={class:"content-right-panel-tab-label"},vU=["aria-label","title","onClick"],gU={class:"content-right-panel-actions"},yU={class:"content-right-panel-add-wrap"},wU=["aria-label","title"],bU={key:0,class:"content-right-panel-menu"},kU=["aria-label","title"],CU={class:"content-right-panel-body"},TU={key:0,class:"project-zip-modal-backdrop",role:"presentation"},SU=["aria-label"],_U={class:"project-zip-modal-header"},xU={class:"project-zip-modal-title"},AU=["aria-label","disabled"],PU={class:"project-zip-modal-copy"},IU={class:"project-zip-progress-label",role:"status","aria-live":"polite"},EU={class:"project-zip-progress-track"},RU={key:0,class:"project-zip-modal-error",role:"alert"},MU={class:"project-zip-modal-actions"},$U=["disabled"],jU=["disabled"],LU=["disabled"],NU=["aria-label"],OU={class:"codex-login-modal-header"},DU={class:"codex-login-modal-title"},FU=["aria-label","disabled"],UU={class:"codex-login-modal-copy"},BU=["href"],qU=["placeholder","disabled"],zU={key:1,class:"codex-login-modal-error visible-error-with-feedback"},HU=["href"],WU={class:"codex-login-modal-actions"},VU=["disabled"],GU=["disabled"],Cv="codex-web-local.sidebar-collapsed.v1",Tv="codex-web-local.accounts-section-collapsed.v1",Sv="codex-web-local.right-panel-width.v1",KU=260,YU=640,_v=320,JU=400,xv="codex-web-local.send-with-enter.v1",Av="codex-web-local.in-progress-send-mode.v1",Pv="codex-web-local.dark-mode.v1",Iv="codex-web-local.dictation-click-to-toggle.v1",Ev="codex-web-local.dictation-auto-send.v1",Rv="codex-web-local.dictation-language.v1",Mv="codex-web-local.chat-width.v1",QU=400,XU=tn({__name:"App",setup(e){var sh,ih;const t=Zl(()=>nc(()=>import("./ThreadConversation-CO1w6DqK.js"),__vite__mapDeps([0,1,2]))),n=Zl(()=>nc(()=>import("./ThreadTerminalPanel-BrRExfgh.js"),__vite__mapDeps([3,4]))),o=Zl(()=>nc(()=>import("./ReviewPane-DJs-RkeF.js"),__vite__mapDeps([5,6]))),r=Zl(()=>nc(()=>import("./DirectoryHub-C4D0oVqF.js"),__vite__mapDeps([7,1,8]))),s=Zl(()=>nc(()=>import("./AutomationsPanel-BujKO0oC.js"),__vite__mapDeps([9,10]))),{t:a,uiLanguage:l,uiLanguageOptions:d,setUiLanguage:h}=io(),v="codex-mobile",y="0.1.101",_={sendWithEnter:a("When enabled, press Enter to send. When disabled, use Command+Enter to send."),inProgressSendMode:a("If a turn is still running, choose whether a new prompt should steer the current turn or be queued."),appearance:a("Switch between system theme, light mode, and dark mode."),chatWidth:a("Choose how wide the conversation column and composer can grow on desktop screens."),dictationClickToToggle:a("Use click-to-start and click-to-stop dictation instead of hold-to-talk."),dictationAutoSend:a("Automatically send transcribed dictation when recording stops."),dictationLanguage:a("Choose transcription language or keep auto-detect.")},P={standard:{label:"Standard",columnMax:"45rem",cardMax:"76ch"},wide:{label:"Wide",columnMax:"72rem",cardMax:"88ch"},"extra-wide":{label:"Extra wide",columnMax:"96rem",cardMax:"96ch"}},j={en:"english",zh:"chinese",de:"german",es:"spanish",ru:"russian",ko:"korean",fr:"french",ja:"japanese",pt:"portuguese",tr:"turkish",pl:"polish",ca:"catalan",nl:"dutch",ar:"arabic",sv:"swedish",it:"italian",id:"indonesian",hi:"hindi",fi:"finnish",vi:"vietnamese",he:"hebrew",uk:"ukrainian",el:"greek",ms:"malay",cs:"czech",ro:"romanian",da:"danish",hu:"hungarian",ta:"tamil",no:"norwegian",th:"thai",ur:"urdu",hr:"croatian",bg:"bulgarian",lt:"lithuanian",la:"latin",mi:"maori",ml:"malayalam",cy:"welsh",sk:"slovak",te:"telugu",fa:"persian",lv:"latvian",bn:"bengali",sr:"serbian",az:"azerbaijani",sl:"slovenian",kn:"kannada",et:"estonian",mk:"macedonian",br:"breton",eu:"basque",is:"icelandic",hy:"armenian",ne:"nepali",mn:"mongolian",bs:"bosnian",kk:"kazakh",sq:"albanian",sw:"swahili",gl:"galician",mr:"marathi",pa:"punjabi",si:"sinhala",km:"khmer",sn:"shona",yo:"yoruba",so:"somali",af:"afrikaans",oc:"occitan",ka:"georgian",be:"belarusian",tg:"tajik",sd:"sindhi",gu:"gujarati",am:"amharic",yi:"yiddish",lo:"lao",uz:"uzbek",fo:"faroese",ht:"haitian creole",ps:"pashto",tk:"turkmen",nn:"nynorsk",mt:"maltese",sa:"sanskrit",lb:"luxembourgish",my:"myanmar",bo:"tibetan",tl:"tagalog",mg:"malagasy",as:"assamese",tt:"tatar",haw:"hawaiian",ln:"lingala",ha:"hausa",ba:"bashkir",jw:"javanese",su:"sundanese",yue:"cantonese"},{projectGroups:B,projectDisplayNameById:J,selectedThread:ce,selectedThreadTokenUsage:U,selectedThreadServerRequests:V,selectedLiveOverlay:K,lastPlanByThreadId:ye,resolveThreadTurnIndex:_e,selectedActiveTurnId:we,codexQuota:$e,selectedThreadId:de,availableCollaborationModes:Le,availableModelIds:je,availableModelReasoningEfforts:fe,selectedCollaborationMode:Te,selectedReasoningEffort:xe,selectedSpeedMode:Ae,codexCliMissingError:Ue,installedSkills:Ye,accountRateLimitSnapshots:He,messages:At,hasMoreOlderMessages:ct,isLoadingThreads:Qe,isThreadListFullyLoaded:et,isLoadingMessages:ft,isLoadingOlderMessages:mt,isSendingMessage:kt,isInterruptingTurn:at,isSelectedThreadInterruptPending:ae,isUpdatingSpeedMode:te,error:oe,refreshAll:z,refreshSkills:Be,refreshHooks:$,hooksList:O,isHooksLoading:G,onRealtimeEvent:ue,selectThread:ie,ensureThreadMessagesLoaded:re,loadMessages:Se,loadOlderMessages:be,archiveThreadById:pe,compactThreadById:se,compactingThreadIds:Ee,fuzzyFileSearchResults:ge,registerFuzzyFileSearchSession:Fe,forkThreadById:Me,renameThreadById:Ve,forkThreadFromTurn:rt,sendMessageToSelectedThread:gt,sendMessageToNewThread:It,interruptSelectedThreadTurn:Tt,interruptedUnsubmittedMessage:Tn,clearInterruptedUnsubmittedMessage:H,selectedThreadQueuedMessages:W,removeQueuedMessage:Y,reorderQueuedMessage:me,steerQueuedMessage:Oe,autoCompactThreshold:We,setAutoCompactThreshold:Ze,setSelectedCollaborationMode:Ft,readModelIdForThread:Nt,setSelectedModelIdForThread:Kn,setSelectedReasoningEffort:lo,updateSelectedSpeedMode:co,respondToPendingServerRequest:uo,pendingReplyErrorForRequest:fo,renameProject:za,removeProject:Cr,reorderProject:Qt,pinProjectToTop:ut,startPolling:gn,stopPolling:zo,primeSelectedThread:bs,rollbackSelectedThread:ni}=pO(),Et=XT(),Ut=QT(),{isMobile:ht}=yp();function Ho(){return typeof navigator<"u"&&/mac|iphone|ipad|ipod/i.test(navigator.platform)}const dn=A(null),sr=A(null),ir=A(null);let Yn=null;const{buildFeedbackMailto:lr,feedbackMailtoBase:ba,recordVisibleFailure:Ha}=xp(),Dn=ba();function In(c,f){f&&Ha(f);const x=c.currentTarget;x instanceof HTMLAnchorElement&&(x.href=lr())}const Gr=A(null),Ao=A(null),nn=A(null),Kr=A(0);let Yt=null;function Yr(){const c=nn.value;if(!c)return;const f=window.getComputedStyle(c),x=Number.parseFloat(f.paddingLeft)+Number.parseFloat(f.paddingRight),N=Math.max(0,c.clientWidth-(Number.isFinite(x)?x:0)),Q=window.getComputedStyle(c).getPropertyValue("--chat-column-max").trim(),ve=Number.parseFloat(Q)*(Q.endsWith("rem")?16:1),De=Number.isFinite(ve)&&ve>0?Math.min(N,ve):N;Kr.value=De}const ka=A(null),Jn=A(null),Qn=A(!1),Po=A(!1),Pt=A(!0),$t=A("git"),zn=A([]),po=A(""),Hn=X(()=>zn.value.find(c=>c.key===po.value)??null),Xn=A(!1),Mn=A(!1),Io=A(!1),ho=A(Sr());function Tr(c){return Math.min(YU,Math.max(KU,c))}function Sr(){if(typeof window>"u")return _v;const c=window.localStorage.getItem(Sv),f=Number(c);return Number.isFinite(f)?Tr(f):_v}function oi(c){typeof window>"u"||window.localStorage.setItem(Sv,String(c))}function Wo(c){c.preventDefault();const f=c.clientX,x=ho.value,N=ve=>{const De=f-ve.clientX;ho.value=Tr(x+De)},Q=()=>{oi(ho.value),window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",Q)};window.addEventListener("mousemove",N),window.addEventListener("mouseup",Q)}const Wa=A(null),Ca=A(!1),cr=A("");let _r=!1;const ur=A(!1),Ct=A(""),Fn=A("local"),Sn=A({}),sn=new Map,mo=A(""),Vo=A([]),En=A(!1),Wn=A({order:[],labels:{},projectOrder:[]}),xt=A({phase:"idle",loaded:0,total:null,blob:null,fileName:"",error:""}),yn=A({phase:"idle",title:"",message:""}),Bt=A(Zb()),fn=A(""),Vn=A(!1),Zn=A(null),vo=A(null),xr=A(null),Go=A(null),Jr=A(null),Ko=A(null);let Eo=null,Ar=null,go=0,M=0,F=!1,ne=0,Pe=0,Ge=0,qt=0;const pn=A("New Project (1)"),Xt=A(""),jt=A(!1),Pr=[{id:"general",label:"General settings"},{id:"models",label:"Models & providers"},{id:"integrations",label:"Integrations"},{id:"usage",label:"Usage & about"}],yo=A("general");let Ta=0;function Ml(){if(jt.value){Ta=Date.now(),jt.value=!1;return}Date.now()-Ta<JU||(jt.value=!0)}const Qr=A(t0()),Gn=A(!1),ks=A(!1),_n=A(new Set);async function ri(){try{_n.value=new Set(await s_())}catch{}finally{ks.value=!0}}const Hi=X(()=>!ks.value||_n.value.has("hooks/list")),ai=X(()=>!ks.value||["remoteControl/status/read","remoteControl/enable","remoteControl/pairing/start","remoteControl/client/list"].every(c=>_n.value.has(c)));nt(jt,c=>{c&&($(),li(),ai.value&&ci())});const ln=A({enabled:!1,clients:[]}),hn=A(null),Ro=A(!1),eo=A(!1),to=A(""),Yo=A(""),Cs=A("");let Sa=null,si=!1,Gt=null;const Zt=A("never"),ii=A(!1),Ts=A(!1),no=A(""),dr=A("");let Wi=!1;const fr=A(!1);async function li(c={}){if(!(c.force!==!0&&Wi)){ii.value=!0,no.value="";try{Zt.value=await d_(),Wi=!0}catch(f){no.value=f instanceof Error?f.message:"Failed to load approval policy"}finally{ii.value=!1}}}function _a(c){Zt.value=c}async function $n(){Ts.value=!0,no.value="",dr.value="";try{await f_(Zt.value),fr.value=!0,dr.value=a("Approval policy saved"),Va&&clearTimeout(Va),Va=setTimeout(()=>{dr.value=""},2200)}catch(c){no.value=c instanceof Error?c.message:"Failed to save approval policy"}finally{Ts.value=!1}}let Va=null;async function ci(c={}){if(!(c.force!==!0&&si)){Ro.value=!0,Yo.value="";try{const f=await u_();ln.value=f,si=!0}catch(f){Yo.value=f instanceof Error?f.message:"Failed to load remote control status"}finally{Ro.value=!1}}}async function ui(){const c=!ln.value.enabled;eo.value=!0,to.value=c?"enable":"disable";try{await p_(c),ln.value={...ln.value,enabled:c},di(c?"Remote control enabled":"Remote control disabled")}catch(f){Yo.value=f instanceof Error?f.message:"Failed to update remote control"}finally{eo.value=!1,to.value=""}}async function Vi(){eo.value=!0,to.value="pairing";try{hn.value=await h_()}catch(c){Yo.value=c instanceof Error?c.message:"Failed to start pairing"}finally{eo.value=!1,to.value=""}}async function Ss(){eo.value=!0,to.value="clients";try{ln.value={...ln.value,clients:await m_()}}catch(c){Yo.value=c instanceof Error?c.message:"Failed to load remote clients"}finally{eo.value=!1,to.value=""}}async function $l(c){eo.value=!0,to.value=`revoke:${c}`;try{await v_(c),ln.value={...ln.value,clients:ln.value.clients.filter(f=>f.clientId!==c)},di("Remote client removed")}catch(f){Yo.value=f instanceof Error?f.message:"Failed to remove remote client"}finally{eo.value=!1,to.value=""}}function di(c){Cs.value=c,Sa&&clearTimeout(Sa),Sa=setTimeout(()=>{Cs.value=""},3e3)}const Ir=A(""),Xr=A(""),pr=A([]),Zr=A(null),xa=A(null),hr=A(null),Aa=A(null),Mo=A(!1),Ga=A(!1),Er=A({addedLineCount:0,removedLineCount:0}),wo=A([]),Rr=A(""),qe=A({}),ke=A(""),Un=A(""),Pa=A({}),mr=A(""),_s=A(""),cn=A(!1),ea=A(!1);function jl(c,f){return`${c}\0${f?"with-reset-history":"without-reset-history"}`}const Ka=A(null),jn=A([]),Jo=A(!1),bo=A(!1),Mr=A(!1),Ln=A(!1),Ya=A(!1),Ia=A(""),$r=A(""),fi=A(null),Qo=A(""),Xo=A(""),vr=A(""),wn=A(""),ta=A($d(xv,!0)),Ea=A(Db()),na=A(Ob()),Ja=A(Fb()),Zo=A($d(Iv,!1)),oa=A($d(Ev,!0)),Ra=A(Qb()),Qa=X(()=>Xb()),Ll=X(()=>{const{loaded:c,total:f}=xt.value,x=Mp(c);return f&&f>0?`${x} / ${Mp(f)}`:c>0?x:a("Preparing...")}),pi=X(()=>{const{loaded:c,total:f,phase:x}=xt.value;return x==="ready"?"100%":!f||f<=0?c>0?"55%":"20%":`${Math.min(100,Math.max(5,Math.round(c/f*100)))}%`}),xs=A(!1),jr=A(!1),Lr=A(!1),ra=A(""),Xa=A(!1),Gi=A(null),Jt=A(!1),oo=A(""),xn=A("codex"),As=X(()=>[{value:"codex",label:a("Codex")},{value:"openrouter",label:a("OpenRouter")},{value:"opencode-zen",label:a("OpenCode Zen")},{value:"custom",label:a("Custom endpoint")}]),er=A(""),Za=A(""),w=A("responses"),k=A("responses"),C=A(""),D=A(!1),Ce=A(""),st=A(""),Rt=A(""),$o=A(!1),Kt=A(!1),Nn=A(""),bn=A(""),tr=A(!1),Nr=A(!1),jo=A("create"),Ps=A(""),hi=A(""),mi=A(""),Is=A(!1),Ma=A(""),Lo=A(!1),Nl=A(null),jc=A(null),$a=A(!1),Lc=A(null),md=A(null),ja=A(""),Or=A(""),aa=A(""),Ol=A([]),Bn=A(""),No=A(!1),ko=A(!1),vi=A(!1),Dr=A(""),Es=[oe,Ue,Rr,Un,wn,oo,Rt,bn,Ma,Bn],sa=X(()=>Es.some(c=>c.value.trim().length>0)),Fr=A({configured:!1,active:!1,mappedChats:0,mappedThreads:0,allowedUsers:0,allowAllUsers:!1,lastError:""}),gi=A(null),Rs=A(!1),Ki=A(!1),La=A(typeof window<"u"?((sh=window.visualViewport)==null?void 0:sh.height)??window.innerHeight:0),Dl=A(typeof window<"u"?((ih=window.visualViewport)==null?void 0:ih.offsetTop)??0:0),yi=A(typeof window<"u"?window.innerHeight:0);let Na=null,Fl=!1,Yi=!1,Ul=!1,wi=0;const es=X(()=>{const c=Et.params.threadId;return typeof c=="string"?c:""}),Rn=X(()=>Et.name==="home"),gr=X(()=>Et.name==="skills"),ts=X(()=>Et.name==="automations"),Nc=X(()=>{const c=Et.query.automationId;return typeof c=="string"?c:""}),vd=X(()=>{var c;return ts.value?a("Automations"):gr.value?a("Skills"):Rn.value?a("Start new thread"):((c=ce.value)==null?void 0:c.title)??a("Choose a thread")}),bi=typeof window<"u"&&(window.location.hostname||window.location.host)||"codexui",Ji=X(()=>{var f,x;return(((x=(f=ce.value)==null?void 0:f.title)==null?void 0:x.trim())??"")||bi}),ki=X(()=>At.value.filter(c=>{const f=o0(c.messageType,c.role);return f==="worked"?!0:!(f==="turnActivity.live"||f==="turnError.live"||f==="agentReasoning.live")})),Qi=new Set(["commandExecution","worked","toolCall","fileChange","agentMessage","agentMessage.live","plan"]),Xi=A(null);function Bl(c,f,x){const N=typeof f.turnIndex=="number"?f.turnIndex:-1;return N<0?!1:c.some((Q,ve)=>ve>x&&typeof Q.turnIndex=="number"&&Q.turnIndex>=N&&Qi.has(Q.messageType??""))}function Oc(c,f){return c.some(x=>typeof x.turnIndex=="number"&&x.turnIndex>=f&&Qi.has(x.messageType??""))}const ql=X(()=>{const c=ki.value,f=ft.value;for(let ve=c.length-1;ve>=0;ve-=1){const De=c[ve];if(De.messageType!=="plan"&&De.messageType!=="plan.live")continue;const on=ov(De);if(!on||Xi.value!==null&&De.id===Xi.value)return null;const c0=f?!0:Bl(c,De,ve);return{id:De.id,streaming:De.messageType==="plan.live",explanation:on.explanation,steps:on.steps,implemented:c0}}const x=de.value?ye.value[de.value]??null:null;if(!x)return null;const N=ov(x);if(!N)return null;const Q=typeof x.turnIndex=="number"?x.turnIndex:x.turnId?_e(de.value,x.turnId)??-1:-1;return{id:x.id,streaming:x.messageType==="plan.live",explanation:N.explanation,steps:N.steps,implemented:f?!0:Q>=0?Oc(c,Q):!1}}),gd=X(()=>K.value),yr=X(()=>Rn.value?"__new-thread__":de.value),Ms=X(()=>Nt(yr.value)),Zi=X(()=>{const c=V.value;return c.length>0?c[c.length-1]:null}),zl=X(()=>Zi.value?fo(Zi.value.id):""),mn=X(()=>{var c,f;return Rn.value?Ct.value.trim():((f=(c=ce.value)==null?void 0:c.cwd)==null?void 0:f.trim())??""}),el=X(()=>Pt.value&&(Rn.value&&mn.value.length>0||Et.name==="thread"&&de.value.length>0)),yd=X(()=>el.value&&$t.value==="terminal"),Ci=X(()=>!ht.value||La.value<=0||yi.value<=0?!1:yi.value-La.value>120),wd=X(()=>Ci.value||yd.value&&Po.value),Dc=X(()=>{var c,f;return((f=(c=ce.value)==null?void 0:c.cwd)==null?void 0:f.trim())??Ct.value.trim()}),Ti=X(()=>{var c;return!Rn.value&&((c=ce.value)==null?void 0:c.inProgress)===!0}),Ur=X(()=>{const c=de.value;return!!c&&Ee.value.has(c)}),Fc=X(()=>{var c,f;return!Rn.value&&((f=(c=ce.value)==null?void 0:c.externalSession)==null?void 0:f.active)===!0}),Hl=X(()=>kt.value||at.value||Ti.value||V.value.length>0);function Uc(){xs.value&&(xs.value=!1,jx(!0))}function Bc(){Uc(),Ut.push({name:"skills",query:{tab:"plugins"}})}function bd(){const c=de.value;c&&se(c)}function tl(c,f){const x=ot(c).trim(),N=br(x);return!x||!N?!1:f.some(Q=>{const ve=ot(Q).trim();return ve!==x&&br(ve)===N})}function Wl(c,f=""){const x=ot(c).trim(),N=f.trim();if(N)return N;const Q=br(x),ve=[...Wn.value.order,...B.value.map(De=>{var on,nr;return((nr=(on=De.threads[0])==null?void 0:on.cwd)==null?void 0:nr.trim())??""}).filter(Boolean)];return tl(x,ve)?x:Q}function kd(){const c=new Set(Wn.value.order),f=Wn.value.projectOrder.filter(x=>c.has(x));for(const x of Wn.value.order)f.includes(x)||f.push(x);return f}function Si(c){const f=ot(c).trim(),x=[...Wn.value.order,...B.value.map(N=>{var Q,ve;return((ve=(Q=N.threads[0])==null?void 0:Q.cwd)==null?void 0:ve.trim())??""}).filter(Boolean)];return tl(f,x)?f:br(f)}function nl(c){const f=ot(c).trim();if(!f)return"";const x=[...Wn.value.order,...B.value.map(N=>{var Q,ve;return((ve=(Q=N.threads[0])==null?void 0:Q.cwd)==null?void 0:ve.trim())??""}).filter(Boolean)];for(const N of Wn.value.order){const Q=ot(N).trim();if(!Q)continue;const ve=br(Q),De=tl(Q,x)?Q:ve;if(Q===f||De===f||ve===f)return Q}return""}const Vl=X(()=>{var N,Q;const c=[],f=new Set;for(const ve of kd()){const De=ve.trim();!De||f.has(De)||(f.add(De),c.push({value:De,label:Wl(De,Wn.value.labels[De])}))}for(const ve of B.value){const De=((Q=(N=ve.threads[0])==null?void 0:N.cwd)==null?void 0:Q.trim())??"";!De||f.has(De)||Wu(De)||(f.add(De),c.push({value:De,label:Wl(De,J.value[ve.projectName])}))}const x=Ct.value.trim();return x&&!f.has(x)&&c.unshift({value:x,label:Wl(x)}),c}),ns=X(()=>{const c=Ct.value.trim();return c?Sn.value[c]===!0:!1}),Cd=X(()=>{var f,x;const c={};for(const N of B.value){const Q=rl(N.projectName,((x=(f=N.threads[0])==null?void 0:f.cwd)==null?void 0:x.trim())??"");c[N.projectName]=Q?Sn.value[Q]===!0:!1}return c}),i=X(()=>{const c=mo.value.trim(),f=[...Vo.value];return c&&!f.some(x=>x.value===c)&&f.unshift({value:c,label:c}),f}),u=X(()=>{const c=mo.value.trim();if(!c)return"";const f=i.value.find(x=>x.value===c);return(f==null?void 0:f.label)??c}),m=X(()=>Or.value.trim()),b=X(()=>{const c=Nn.value.trim();return!c||c==="."||c===".."?!1:!/[\\/]/u.test(c)}),R=X(()=>b.value&&m.value.trim().length>0&&!Bn.value),E=X(()=>{const c=hi.value.trim();return!c||c==="."||c===".."?!1:!/[\\/]/u.test(c)}),L=X(()=>Ps.value.trim()?jo.value==="create"?E.value:mi.value.trim().length>0:!1),q=X(()=>{const c=ot(ja.value).trim();return c||Or.value.trim()}),Z=X(()=>tr.value?"Creating…":"Create"),he=X(()=>Lo.value?jo.value==="clone"?a("Cloning…"):a("Creating…"):jo.value==="clone"?a("Clone repository"):a("Create project")),Ne=X(()=>{const c=Or.value.trim(),f=aa.value.trim();return!!(c&&f&&c!==f)}),Je=X(()=>{const c=[];Ne.value&&c.push({key:`parent:${aa.value}`,name:"..",path:aa.value,kind:"parent"});for(const f of Ol.value)c.push({key:`directory:${f.path}`,name:f.name,path:f.path,kind:"directory"});return c}),pt=X(()=>{const c=Dr.value.trim().toLowerCase();return c?Je.value.filter(f=>f.kind==="parent"||f.name.toLowerCase().includes(c)):Je.value}),it=typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)"):null,Mt=X(()=>a(P[Ja.value].label)),Oa=X(()=>{const c=P[Ja.value],f=Math.max(0,yi.value-La.value-Dl.value);return{"--chat-column-max":c.columnMax,"--chat-card-max":c.cardMax,"--visual-viewport-height":La.value>0?`${La.value}px`:"100dvh","--visual-viewport-offset-top":`${Math.max(0,Dl.value)}px`,"--virtual-keyboard-inset":`${f}px`}}),$s=X(()=>{if(!Fr.value.configured)return a("Not configured");const c=Fr.value.active?a("Online"):a("Configured (offline)"),f=Fr.value.allowAllUsers?a("allow all users"):`${Fr.value.allowedUsers} ${a("allowed user(s)")}`,x=`${Fr.value.mappedChats} ${a("chat(s)")}, ${Fr.value.mappedThreads} ${a("thread(s)")}, ${f}`,N=Fr.value.lastError?`, ${a("error")}: ${Fr.value.lastError}`:"";return`${c}, ${x}${N}`});ws(()=>{var c,f;document.addEventListener("pointerdown",Fp),window.addEventListener("keydown",Np),document.addEventListener("visibilitychange",Up),window.addEventListener("pageshow",Bp),window.addEventListener("focus",qp),window.addEventListener("resize",ia),(c=window.visualViewport)==null||c.addEventListener("resize",ia),(f=window.visualViewport)==null||f.addEventListener("scroll",ia),ia(),ru(),it==null||it.addEventListener("change",ru),Yn=ue(x=>{ir.value&&ir.value.refreshFromNotification(x)}),Gt=ue(x=>{x==="remoteControl/status/changed"&&ci({force:!0})}),r0(),Ib(),ri(),zc(),Ds(),la(),Ls(),os(),Ld(),Jw(),li()}),nt(Es,(c,f)=>{c.forEach((x,N)=>{if(x===f[N])return;const Q=x.trim();Q&&Ha(Q)})}),nt(nn,c=>{Yt&&(Yt.disconnect(),Yt=null),typeof ResizeObserver<"u"&&(Yt=new ResizeObserver(Yr),c&&Yt.observe(c)),Yr()},{immediate:!0}),Ec(()=>{var c,f;document.removeEventListener("pointerdown",Fp),window.removeEventListener("keydown",Np),document.removeEventListener("visibilitychange",Up),window.removeEventListener("pageshow",Bp),window.removeEventListener("focus",qp),window.removeEventListener("resize",ia),(c=window.visualViewport)==null||c.removeEventListener("resize",ia),(f=window.visualViewport)==null||f.removeEventListener("scroll",ia),it==null||it.removeEventListener("change",ru),Yt&&(Yt.disconnect(),Yt=null),Na!==null&&(window.clearInterval(Na),Na=null),Eo&&(clearTimeout(Eo),Eo=null),eu(),zo(),Yn&&(Yn(),Yn=null),Gt&&(Gt(),Gt=null),Sa&&(clearTimeout(Sa),Sa=null)});function ia(){var c,f;typeof window>"u"||(yi.value=Math.max(yi.value,window.innerHeight),La.value=((c=window.visualViewport)==null?void 0:c.height)??window.innerHeight,Dl.value=((f=window.visualViewport)==null?void 0:f.offsetTop)??0)}nt(fn,c=>{const f=c.trim();if(Eo&&(clearTimeout(Eo),Eo=null),!f){Ko.value=null;return}Eo=setTimeout(()=>{Sx(f,1e3).then(x=>{fn.value.trim()===f&&(Ko.value=x.threadIds)}).catch(()=>{fn.value.trim()===f&&(Ko.value=null)})},220)}),nt(Ci,c=>{c||(Po.value=!1)}),nt(jn,()=>{if(typeof window>"u")return;if(!jn.value.some(f=>f.quotaStatus==="loading")){Na!==null&&(window.clearInterval(Na),Na=null);return}Na===null&&(Na=window.setInterval(()=>{Fl||(Fl=!0,Gl({silent:!0}).finally(()=>{Fl=!1}))},1500))},{deep:!0}),nt(He,()=>{wr().then(c=>{c&&z({includeSelectedThreadMessages:!1,providerChanged:!0,awaitAncillaryRefreshes:!0})})},{deep:!0});async function wr(){if(!Yi||Ul||xn.value!=="codex"||jn.value.length>0||He.value.length===0)return!1;Ul=!0;const c=JSON.stringify(jn.value.map(x=>x.accountId).sort());try{const x=await _m();jn.value=x.accounts}catch{await Gl({silent:!0})}const f=JSON.stringify(jn.value.map(x=>x.accountId).sort());return c!==f}function js(){Be({force:!0})}function qc(c){c&&Se(c,{silent:!0,force:!0})}async function os(){try{Fr.value=await Ax()}catch(c){const f=c instanceof Error?c.message:"Failed to load Telegram status";Fr.value={configured:!1,active:!1,mappedChats:0,mappedThreads:0,allowedUsers:0,allowAllUsers:!1,lastError:f}}}async function Ls(){try{const c=await xx();Ce.value=c.botToken,st.value=c.allowedUserIds.map(f=>String(f)).join(`
|
|
80
|
+
`)}ra(i);const os=Ce(i);os&&(Kt(b,os),Gt(b,{label:"Running command",details:[((Yc=os.commandExecution)==null?void 0:Yc.command)??""]}));const Ls=st(i);if(Ls){const Re=(j.value[b]??[]).find(Ot=>Ot.id===Ls.itemId);Re!=null&&Re.commandExecution&&Kt(b,{...Re,commandExecution:{...Re.commandExecution,aggregatedOutput:`${Re.commandExecution.aggregatedOutput}${Ls.delta}`}})}const zc=Rt(i);zc&&Kt(b,zc);const Hc=$o(i);if(Hc&&$l(b,Hc),tr(i)&&pr(b,!0),i.method==="turn/completed"){Hn=!1,pr(b),y.clear(),j.value[b]&&(j.value=St(j.value,b));const Re=cn(i);Re&&(yo(Re),hn(Re,!1),Gt(Re,null),si(Re),Ne||(F(Re),Bl(Re)))}}function Ma(i){if(i.method==="thread/tokenUsage/updated"||i.method.startsWith("thread/realtime/"))return;const u=i.method,m=u==="turn/started"||u==="turn/completed"||u==="error",b=u.startsWith("thread/")||u==="turn/completed";if(!m&&!b)return;const R=cn(i);R&&m&&Yt.add(R),b&&(nn=!0,Kr=!0),!(ht!==null||typeof window>"u")&&(ht=window.setTimeout(()=>{ht=null,Ur()},yu))}async function Lo(i,u){if(!po){po=!0;try{if(!u)return;const m=[];for(const b of hd(u)){const R=Ui(b);m.includes(R)||m.push(R)}if(m.length>0){const b=u.projectOrder.length>0?ul(m,i):ul(z.value,i);us(z.value,b)||(z.value=b)}if(Object.keys(u.labels).length>0||(u.remoteProjects??[]).length>0){const b={...Be.value};let R=!1;for(const[E,L]of Object.entries(u.labels)){const q=ot(E).trim(),Z=[Ui(E)];q&&Z.push(q);for(const he of Z)b[he]!==L&&(b[he]=L,R=!0)}for(const E of u.order){const L=Ui(E),q=Hr(Cl(E));if(!q.startsWith(".")||q===L)continue;const Z=`${L} ${q}`;b[L]!==void 0||b[L]===Z||(b[L]=Z,R=!0)}for(const E of u.remoteProjects??[]){const L=nO(E);b[E.id]!==L&&(b[E.id]=L,R=!0)}R&&(Be.value=b)}}catch{}}}async function Nl(i={}){if(!(i.force!==!0&&Object.keys(W.value).length>0))try{const u=await Px();if(Object.keys(u.titles).length>0){const m={};for(const[b,R]of Object.entries(u.titles))m[b]=zs(R);W.value=m}}catch{}}async function jc(){try{return await pl()}catch{return null}}function $a(i,u,m){const b=i.trim();if(b)return zs(b);const R=m.map(E=>E.label.trim()).find(E=>E.length>0);return R?zs(R):u.length>0?zs("[Image]"):"Untitled thread"}async function Lc(i,u,m,b=[],R=[]){if(W.value[i])return;const E=u.trim();if(!E){const q=$a(u,b,R);W.value={...W.value,[i]:q},_n(),pu(i,q);return}const L=E.length>300?E.slice(0,300):E;try{const q=await Lx(L,m);if(!q||W.value[i])return;const Z=q.length>Kf?q.slice(0,Kf):q;W.value={...W.value,[i]:Z},_n(),pu(i,Z)}catch{}}function md(i,u){const m=Gf(i,u),b=sO(i,u),R=iO(b,u,m);if(!u||u.order.length===0&&(u.remoteProjects??[]).length===0)return R;const E=new Set;for(const q of Vf(u,m))E.add(q);const L=R.filter(q=>E.has(q.projectName)?!0:Yf(q));return aO(L,u,m)}function ja(i,u){const m=md(i,u),b=!!(u&&(u.order.length>0||u.projectOrder.length>0||(u.remoteProjects??[]).length>0)),R=u!=null&&u.projectOrder.length?ul(Vf(u,Gf(i,u)),m):ul(z.value,m);us(z.value,R)||(z.value=R,b||rc(z.value));const E=mf(m,z.value);Cs(new Set(To(E).map(Z=>Z.id)));const L=eO(t.value,E,J.value);t.value=_u(t.value,L),J.value=kn(J.value,new Set(To(t.value).map(Z=>Z.id))),new Set(To(t.value).map(Z=>Z.id));const q={};for(const Z of To(t.value))q[Z.id]=Z.externalSession??$e.value[Z.id]??null;$e.value=q,_n()}function Or(i){const u={};for(const[m,b]of Object.entries(i)){const R=m.trim();!R||b.length===0||(u[R]=b.map(E=>({id:E.id,text:E.text,imageUrls:[...E.imageUrls],skills:E.skills.map(L=>({name:L.name,path:L.path})),fileAttachments:E.fileAttachments.map(L=>({label:L.label,path:L.path,fsPath:L.fsPath})),collaborationMode:E.collaborationMode})))}return u}function aa(){nx(Or(de.value)).catch(()=>{})}async function Ol(){if(!xe){xe=!0;try{de.value=await $m()}catch{}}}function Bn(i){$t=bv($t,i),t.value=bv(t.value,i),J.value=St(J.value,i),_n()}function No(i,u){if(i.length===0)return u;if(u.length===0)return i;const m=new Map;for(const R of To(i))m.set(R.id,R);for(const R of To(u))m.set(R.id,R);const b=new Map;for(const R of m.values()){const E=b.get(R.projectName);E?E.push(R):b.set(R.projectName,[R])}return Array.from(b.entries()).map(([R,E])=>({projectName:R,threads:E.sort((L,q)=>new Date(q.updatedAtIso).getTime()-new Date(L.updatedAtIso).getTime())})).sort((R,E)=>{var Z,he;const L=new Date(((Z=R.threads[0])==null?void 0:Z.updatedAtIso)??0).getTime();return new Date(((he=E.threads[0])==null?void 0:he.updatedAtIso)??0).getTime()-L})}function ko(){return Object.values(J.value).some(i=>i===!0)}function vi(i=zn){if(!(!Jn||Po||ko())){if(zn=i,typeof window>"u"){Dr(i);return}Qn!==null&&window.clearTimeout(Qn),Qn=window.setTimeout(()=>{Qn=null,!(!Jn||ko())&&Dr(zn)},cN)}}async function Dr(i){if(!(Po||!Jn||ko())){Po=!0;try{const u=await km(Jn,ZS());Jn=u.nextCursor,Pt=u.nextCursor===null,Nt.value=Pt,$t=No($t,u.groups),ja($t,i)}catch{}finally{Po=!1,Jn&&!ko()&&vi(i)}}}async function Es(i={}){if(sr){await sr;return}i.force!==!0&&zo.value&&Date.now()-ba<fN||(sr=(async()=>{var u;zo.value||(Ze.value=!0);try{const[m,b]=await Promise.all([km(),jc(),Nl({force:i.force===!0})]);zn=b;const R=m.groups;$t=R,Jn=m.nextCursor,Pt=m.nextCursor===null,Nt.value=Pt,await Lo(R,b),ja($t,b),zo.value=!0,ba=Date.now(),Pt||vi(b);const E=To(e.value);Hi(E),!E.some(q=>q.id===n.value)&&!n.value&&fn(((u=E[0])==null?void 0:u.id)??"")}finally{Ze.value=!1}})().finally(()=>{sr=null}),await sr)}async function sa(i,u={}){var q;if(!i)return;const m=Date.now()-(ka.get(i)??0)<lv;if((q=se.value[i])!=null&&q.transient&&(u.silent===!0||m))return;const b=ir.get(i);if(b&&u.force!==!0){await b;return}const R=O.value[i]===!0,E=u.silent!==!0&&!R;E&&(Ft.value=!0);const L=(async()=>{try{const Z=no(i),he=$.value[i]??"",Ne=Date.now()-(Yr.get(i)??0)<lv;if(u.force===!0?!1:R&&(Ne||(Z.length===0||he===Z)&&J.value[i]!==!0)){ai(i);return}const it=ie.value[i]!==!0?await of(i):null,Mt=it??await nf(i);Mt.modelProvider&&xr(i,Mt.modelProvider),Mt.model&&vo(i,Go(i,Mt.model,Mt.modelProvider)),it&&(ie.value={...ie.value,[i]:!0});const{messages:Oa,inProgress:$s,activeTurnId:ia,turnIndexByTurnId:wr}=Mt;G.value={...G.value,[i]:Mt.hasMoreOlder===!0},Sa(i,Oa),Qa(i,wr),pi(i);const js=o.value[i]??[],qc=wv(js,Oa,{preserveMissing:u.silent===!0||BN(js)});fr(i,qc);const os=a.value[i]??[];if($s){const Ls=zN(os,Oa);_a(i,Ls)}else $n(i);Nn(i,Oa),bn(i,Oa),O.value={...O.value,[i]:!0},Yr.set(i,Date.now()),ka.delete(i),Z&&($.value={...$.value,[i]:Z}),hn(i,$s),Mt.externalSession&&($e.value={...$e.value,[i]:Mt.externalSession}),ii(i),ia?Ee.value={...Ee.value,[i]:ia}:Ee.value[i]&&(Ee.value=St(Ee.value,i)),$s||Mo(i),ai(i)}catch(Z){const he=Z instanceof Error?Z.message:"Unknown application error";throw n.value===i&&Zt(i,he,{transient:!0}),ka.set(i,Date.now()),Z}finally{E&&(Ft.value=!1)}})().finally(()=>{ir.delete(i)});ir.set(i,L),await L}async function Fr(i=n.value){if(!i||ue.value[i]===!0||G.value[i]!==!0)return;const u=Sn(i);if(!u){G.value={...G.value,[i]:!1};return}ue.value={...ue.value,[i]:!0};try{const m=await t_(i,u),b=o.value[i]??[],R=wv(m.messages,b,{preserveMissing:!0});fr(i,R),Qa(i,{...re.value[i]??{},...m.turnIndexByTurnId}),pi(i),G.value={...G.value,[i]:m.hasMoreOlder}}catch(m){throw ut.value=m instanceof Error?m.message:"Failed to load earlier messages",m}finally{ue.value={...ue.value,[i]:!1}}}async function gi(i,u={}){var m;i&&O.value[i]!==!0&&(u.silent===!0&&((m=se.value[i])!=null&&m.transient)||await sa(i,u))}async function Rs(i={}){var b,R;const u=((R=(b=ho.value)==null?void 0:b.cwd)==null?void 0:R.trim())??"",m=u||"__global__";if(Yn){await Yn;return}i.force!==!0&&Ha&&Gr===m&&Date.now()-In<pN||(Yn=(async()=>{try{Y.value=await Ox(u?[u]:void 0),Ha=!0,In=Date.now(),Gr=m}catch{}finally{Yn=null}})(),await Yn)}async function Ki(i={}){if(lr){await lr;return}i.force!==!0&&Dn||(We.value=!0,lr=(async()=>{try{Oe.value=await l_(),Dn=!0}catch{}finally{We.value=!1,lr=null}})(),await lr)}async function La(i={}){await Promise.allSettled([Xt({providerChanged:i.providerChanged,includeProviderModels:i.includeProviderModels}),jt(),qt(),Rs()])}function Dl(i={}){const u=()=>{La(i)};if(typeof window>"u"){u();return}window.setTimeout(u,0)}async function yi(i={}){ut.value="",ae.value="";const u=i.includeSelectedThreadMessages!==!1,m=i.awaitAncillaryRefreshes===!0;try{if(await Ol(),await Es({force:i.forceThreadRefresh===!0}),u)try{await sa(n.value)}catch(b){ut.value=b instanceof Error?b.message:"Unknown application error"}m?await La({providerChanged:i.providerChanged,includeProviderModels:i.providerChanged===!0||m}):Dl({providerChanged:i.providerChanged,includeProviderModels:!1})}catch(b){ut.value=b instanceof Error?b.message:"Unknown application error",uv(b)?ae.value=cv:ae.value=""}}async function Na(i){fn(i);try{return await sa(i),await Xt({includeProviderModels:!0}),Rs(),"ok"}catch(u){const m=u instanceof Error?u.message:"Unknown application error";ut.value=m;const b=gN(u)?"not-found":"error";return i.trim()&&Zt(i,m,{transient:!0}),b}}async function Fl(i){const u=n.value===i,m=u?aN(To(e.value),i):"";u&&(fn(m),m&&sa(m,{silent:!0}));try{await $_(i),Bn(i),await Es(),u&&m&&n.value===m&&await gi(m,{silent:!0})}catch(b){ut.value=b instanceof Error?b.message:"Unknown application error"}}async function Yi(i,u){const m=u.trim();if(!(!i||!m))try{await N_(i,m),W.value={...W.value,[i]:m},_n(),pu(i,m)}catch(b){ut.value=b instanceof Error?b.message:"Unknown application error"}}async function Ul(i){var L,q;const u=i.trim();if(!u)return"";const m=To(t.value).find(Z=>Z.id===u),b=((L=m==null?void 0:m.cwd)==null?void 0:L.trim())??"",R=((q=m==null?void 0:m.title)==null?void 0:q.trim())??"Forked chat",E=sn(u);ut.value="";try{const Z=await Am(u,b||void 0,E||void 0),he=Z.threadId.trim();return he?(ri(he,b,R),vo(he,Z.model),ie.value={...ie.value,[he]:!0},fn(he),await Es(),await sa(he),he):""}catch(Z){return ut.value=Z instanceof Error?Z.message:"Unknown application error",""}}async function wi(i,u){var L;const m=i.trim();if(!m||!Number.isInteger(u)||u<0)return"";if(J.value[m]===!0)return ut.value="Finish the current turn before forking from a response.","";if(O.value[m]!==!0)try{await sa(m)}catch(q){return ut.value=q instanceof Error?q.message:"Unknown application error",""}const b=o.value[m]??[];let R=-1;for(const q of b)typeof q.turnIndex=="number"&&Number.isFinite(q.turnIndex)&&(R=Math.max(R,q.turnIndex));if(R>=0&&u>R)return"";const E=To(t.value).find(q=>q.id===m)??null;try{ut.value="";const q=await Am(m),Z=q.threadId.trim();if(!Z)return"";const he=q.cwd.trim()||((L=E==null?void 0:E.cwd)==null?void 0:L.trim())||"",Ne=lO((E==null?void 0:E.title)||(E==null?void 0:E.preview)||"Untitled thread");ri(Z,he,Ne),vo(Z,q.model),fr(Z,q.messages),O.value={...O.value,[Z]:!0},ie.value={...ie.value,[Z]:!0},hr(Z),_a(Z,[]),pr(Z),j.value[Z]&&(j.value=St(j.value,Z)),ln(Z,null),Gt(Z,null),Zt(Z,null),hn(Z,!1);const Je=R-u;if(Je>0){const pt=await rf(Z,Je);fr(Z,pt)}return await Yi(Z,Ne),fn(Z),Es().catch(()=>{}),Z}catch(q){return ut.value=q instanceof Error?q.message:"Unknown application error",""}}async function es(i,u,m=[],b=[],R=[]){if(!i||!u.trim()||m.length>0||b.length>0||R.length>0)return!1;const L=(rt.value[i]??[]).filter(he=>he.method==="item/tool/requestUserInput");if(L.length!==1)return!1;const[q]=L,Z=$r(q);return Z.length!==1?!1:tl({id:q.id,result:{answers:{[Z[0]]:{answers:[u.trim()]}}}})}function Rn(){if(typeof window>"u")return{};try{const i=window.localStorage.getItem(sv);if(!i)return{};const u=JSON.parse(i);if(!u||typeof u!="object"||Array.isArray(u))return{};const m={};for(const[b,R]of Object.entries(u)){if(!b||!Array.isArray(R))continue;const E=R.filter(L=>!!L&&typeof L=="object"&&typeof L.id=="string"&&typeof L.text=="string");E.length>0&&(m[b]=E)}return m}catch{return{}}}function gr(){typeof window>"u"||window.localStorage.setItem(sv,JSON.stringify(je.value))}function ts(){if(typeof window>"u")return gu;try{const i=window.localStorage.getItem(iv);if(i===null)return gu;const u=Number(i);return Number.isFinite(u)&&u>=0?Math.round(u):gu}catch{return gu}}function Nc(i){const u=Number.isFinite(i)&&i>0?Math.round(i):0;u!==fe.value&&(fe.value=u,!(typeof window>"u")&&window.localStorage.setItem(iv,String(u)))}async function vd(i,u,m,b,R,E){if(Te||fe.value<=0||J.value[i]===!0)return!1;const L=Tt.value[i];if(!L||L.remainingContextPercent===null||L.remainingContextPercent>fe.value)return!1;const q=je.value[i]??[],Z=`stash-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,he=E==="plan"?"plan":E==="default"?"default":et.value;return je.value={...je.value,[i]:[...q,{id:Z,text:u,imageUrls:m,skills:b,fileAttachments:R,collaborationMode:he}]},gr(),fo.value.has(i)||zl(i),!0}async function bi(i){const u=je.value[i];if(!u||u.length===0||J.value[i]===!0)return;const m=[...u];je.value=St(je.value,i),gr(),Te=!0;try{for(const b of m)try{await Ji(b.text,b.imageUrls,b.skills,"steer",b.fileAttachments,void 0,b.collaborationMode)}catch{}}finally{Te=!1}}async function Ji(i,u=[],m=[],b="steer",R=[],E,L){if(co.value)return;const q=n.value,Z=i.trim();if(!q||!Z&&u.length===0&&R.length===0||await es(q,Z,u,m,R)||await vd(q,Z,u,m,R,L))return;const he=J.value[q]===!0;if(he&&b==="queue"){const Ne=de.value[q]??[],Je=`q-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,pt=[...Ne],it=typeof E=="number"?Math.max(0,Math.min(E,pt.length)):pt.length;pt.splice(it,0,{id:Je,text:Z,imageUrls:u,skills:m,fileAttachments:R,collaborationMode:L==="plan"?"plan":L==="default"?"default":et.value}),de.value={...de.value,[q]:pt},aa();return}if(he){Hn=!0,Qi(q,Z,u,m,R,L).catch(Ne=>{const Je=Ne instanceof Error?Ne.message:"Unknown application error";Zt(q,Je),ut.value=Je});return}ut.value="",Hn=!0,ln(q,null),Gt(q,{label:"Thinking",details:pn(sn(q),mt.value,L==="plan"?"plan":L==="default"?"default":et.value)}),Zt(q,null),hn(q,!0);try{await Qi(q,Z,u,m,R,L)}catch(Ne){Hn=!1,hn(q,!1),Gt(q,null);const Je=Ne instanceof Error?Ne.message:"Unknown application error";throw Zt(q,Je),ut.value=Je,Ne}}async function ki(i,u,m=[],b=[],R=[]){if(co.value)return"";const E=i.trim(),L=u.trim(),q=sn(Zs).trim(),Z=et.value;if(!E&&m.length===0&&R.length===0)return"";Kn.value=!0,ut.value="";let he="";try{try{const it=await xm(L||void 0,q||void 0);he=it.threadId,vo(he,it.model),xr(he,it.modelProvider||at.value),Eo(he,Z)}catch(it){if(q&&q!==ca&&Tu(it)){await go();const Mt=await xm(L||void 0,ca);he=Mt.threadId,vo(he,Mt.model),xr(he,Mt.modelProvider||at.value),Eo(he,Z)}else throw it}if(!he)return"";ri(he,L,E||"[Image]"),li(he,E,m,b,R),eo(he),ie.value={...ie.value,[he]:!0},fn(he),Hn=!0,ln(he,null),Gt(he,{label:"Thinking",details:pn(sn(he),mt.value,Z)}),Zt(he,null),hn(he,!0);const Ne=he,Je=L||null,pt=E;return Qi(he,E,m,b,R,Z).catch(it=>{Hn=!1,hn(he,!1),Gt(he,null);const Mt=it instanceof Error?it.message:"Unknown application error";Zt(he,Mt),ut.value=Mt}).finally(()=>{Kn.value=!1}),Lc(Ne,pt,Je,m,R),he}catch(Ne){Hn=!1,he&&(hn(he,!1),Gt(he,null));const Je=Ne instanceof Error?Ne.message:"Unknown application error";throw he&&Zt(he,Je),ut.value=Je,Kn.value=!1,Ne}}async function Qi(i,u,m=[],b=[],R=[],E){const L=mt.value,q=E==="plan"?"plan":E==="default"?"default":et.value,Z=u.trim(),he=[...m];if(he.length===0&&ni(Z)){const pt=Et(i);pt&&he.push(pt)}const Ne=b.map(pt=>({name:pt.name,path:pt.path})),Je=R.map(pt=>({...pt}));M(i,{text:Z,imageUrls:[...he],skills:Ne,fileAttachments:Je,effort:L,collaborationMode:q,fallbackRetried:!1});try{if(ie.value[i]!==!0){const Mt=await of(i);Mt.model&&vo(i,Go(i,Mt.model,Mt.modelProvider)),Mt.modelProvider&&xr(i,Mt.modelProvider),ie.value={...ie.value,[i]:!0}}const pt=sn(i);let it="";try{it=await af(i,u,he,pt||void 0,L||void 0,b.length>0?b:void 0,R,q)}catch(Mt){if(pt&&pt!==ca&&Tu(Mt))await go(i),M(i,{text:Z,imageUrls:[...he],skills:Ne,fileAttachments:Je,effort:L,collaborationMode:q,fallbackRetried:!0}),it=await af(i,u,he,ca,L||void 0,b.length>0?b:void 0,R,q);else throw Mt}it&&(Ee.value={...Ee.value,[i]:it},Yo(i,it)),Yt.add(i),await Ur(),Ta(i)}catch(pt){throw pt}}async function Xi(i){if(Le.value[i]!==!0){Le.value={...Le.value,[i]:!0};try{de.value=await $m()}catch{}finally{Le.value=St(Le.value,i)}}}function Bl(i){Xi(i),!(typeof window>"u")&&window.setTimeout(()=>{Xi(i)},650)}async function Oc(){const i=n.value;if(!i||J.value[i]!==!0||ge.value[i]===!0)return;let u=Ee.value[i];if(!u){const{activeTurnId:E}=await nf(i);u=E,u&&(Ee.value={...Ee.value,[i]:u})}if(!u)throw new Error("Could not determine active turn id for interrupt");const m=_r.value.filter(E=>E.turnId===u),b=m.find(E=>E.role==="user"),R=m.some(E=>{if(E.role==="assistant")return!0;const L=E.messageType??"";return L==="commandExecution"||L==="toolCall"||L==="worked"||L==="fileChange"||L==="plan"||L==="plan.live"||L==="compaction.done"||L==="turnError"});lo.value=!0,ut.value="";try{if(await z_(i,u),hn(i,!1),Gt(i,null),Zt(i,null),Ee.value[i]&&(Ee.value=St(Ee.value,i)),Yt.add(i),nn=!0,await Ur(),b&&!R){const E=(o.value[i]??[]).filter(q=>q.turnId!==u);fr(i,E);const L=d.value[i];if(L){const q=L.filter(Z=>Z.turnId!==u);q.length!==L.length&&(d.value={...d.value,[i]:q},wu(d.value))}Ve.value={...Ve.value,[i]:{text:b.text??"",imageUrls:b.images??[],fileAttachments:(b.fileAttachments??[]).map(q=>({label:q.label,path:q.path,fsPath:q.fsPath??q.path})),skills:b.skills??[]}}}}catch(E){const L=E instanceof Error?E.message:"Failed to interrupt active turn";Zt(i,L),ut.value=L}finally{lo.value=!1}}function ql(i){i&&Ve.value[i]&&(Ve.value=St(Ve.value,i))}async function gd(i){var m,b;const u=n.value;if(u&&!uo.value&&i.trim()){uo.value=!0,ut.value="";try{J.value[u]===!0&&await Oc();const R=o.value[u]??[],E=R.find(Je=>Je.turnId===i),L=typeof(E==null?void 0:E.turnIndex)=="number"?E.turnIndex:-1;if(L<0)return;const q=R.reduce((Je,pt)=>typeof pt.turnIndex=="number"&&pt.turnIndex>Je?pt.turnIndex:Je,-1);if(q<0||L>q)return;const Z=q-L+1;if(Z<1)return;const he=((b=(m=ho.value)==null?void 0:m.cwd)==null?void 0:b.trim())??"";he&&await D_(u,i,he);const Ne=await rf(u,Z);fr(u,Ne),_a(u,[]),pr(u),j.value[u]&&(j.value=St(j.value,u)),ln(u,null),Gt(u,null),Zt(u,null),nn=!0,await Ur()}catch(R){ut.value=R instanceof Error?R.message:"Failed to rollback thread"}finally{uo.value=!1}}}function yr(i,u){const b=(l.value[i]??[]).filter(R=>R.messageType!=="compaction.pending"&&R.messageType!=="compaction.done");b.push({id:`compaction:${u}:${i}:${Date.now()}`,role:"system",text:"",messageType:u==="pending"?"compaction.pending":"compaction.done"}),l.value={...l.value,[i]:b}}function Ms(i,u){const m=new Set(fo.value);u?m.add(i):m.delete(i),fo.value=m}function Zi(i){Qt=i.trim(),Cr.value=[]}async function zl(i){const u=i.trim();if(!(!u||fo.value.has(u))){Ms(u,!0),yr(u,"pending");try{await L_(u);const m=2e3,b=14,R=Date.now()+za;let E=0;for(;Date.now()<R&&E<b&&fo.value.has(u);){if((await nf(u)).messages.some(Z=>Z.messageType==="compaction.done")){Ms(u,!1),n.value===u&&await sa(u,{silent:!0,force:!0}),yr(u,"done"),bi(u);break}E+=1,await rN(m)}fo.value.has(u)&&(Ms(u,!1),yr(u,"done"),bi(u))}catch(m){ut.value=m instanceof Error?m.message:"Failed to compact thread",Ms(u,!1),yr(u,"done"),bi(u)}}}let mn=null;async function el(i,u){try{const m=await pl(),b={...m.labels};let R=!1;for(const E of m.order){if(!$u(E,i))continue;const L=u.trim();L.length===0?b[E]!==void 0&&(delete b[E],R=!0):b[E]!==L&&(b[E]=L,R=!0)}R&&await sf({order:m.order,labels:b,active:m.active,projectOrder:m.projectOrder})}catch{}}function yd(i,u){i.length===0||(Be.value[i]??"")===u||(Be.value={...Be.value,[i]:u},yv(Be.value),mn!==null&&clearTimeout(mn),mn=setTimeout(()=>{mn=null,el(i,u)},500))}async function Ci(i){var E;if(i.length===0)return;const u=z.value.filter(L=>L!==i);if(us(z.value,u)||(z.value=u,rc(z.value)),t.value=t.value.filter(L=>L.projectName!==i),Be.value[i]!==void 0){const L={...Be.value};delete L[i],Be.value=L,yv(L)}_n();const m=To(e.value);Hi(m),m.some(L=>L.id===n.value)||fn(((E=m[0])==null?void 0:E.id)??"");const R=new Set;try{const L=await pl();oO(L,i).forEach(q=>{R.add(q)})}catch{}if(R.size>0)try{const L=await pl(),q=L.order.filter(Ne=>!R.has(Ne)),Z=L.active.filter(Ne=>!R.has(Ne)),he=Z.length===0&&q.length>0?[q[0]]:Z;await sf({order:q,labels:JN(L.labels,R),active:he,projectOrder:L.projectOrder.filter(Ne=>Ne!==i&&!R.has(Ne))});return}catch{}await Ti()}function wd(i,u){if(i.length===0||t.value.length===0)return;const m=t.value.map(Z=>Z.projectName),b=m.indexOf(i);if(b===-1)return;const R=Math.max(0,Math.min(u,m.length-1)),E=NN(m,b,R);if(E===m)return;const L=ul(E,t.value);z.value=L,rc(z.value);const q=mf(t.value,z.value);t.value=_u(t.value,q),_n(),Ti()}function Dc(i){const u=i.trim();if(!u)return;const m=[u,...z.value.filter(R=>R!==u)];if(us(z.value,m))return;z.value=m,rc(z.value);const b=mf(t.value,z.value);t.value=_u(t.value,b),_n(),Ti()}async function Ti(){try{const i=await pl(),u=rO(i,z.value,t.value);await sf({order:u.order,labels:i.labels,active:u.active,projectOrder:u.projectOrder})}catch{}}async function Ur(){if(gn.value){typeof window<"u"&&ht===null&&(ht=window.setTimeout(()=>{ht=null,Ur()},yu));return}gn.value=!0;const i=nn,u=Kr,m=new Set(Yt);nn=!1,Kr=!1,Yt.clear();try{i&&await Es({force:u});const b=n.value;if(!b)return;const R=m.has(b),E=J.value[b]===!0,L=no(b),q=$.value[b]??"";(L.length>0&&L!==q||R||E&&O.value[b]!==!0||i&&O.value[b]!==!0)&&await sa(b,{silent:!0,force:R})}catch{}finally{gn.value=!1,(nn||Yt.size>0)&&typeof window<"u"&&ht===null&&(ht=window.setTimeout(()=>{ht=null,Ur()},yu))}}async function Fc(){await Bc(),nn=!zo.value,n.value&&O.value[n.value]!==!0&&Yt.add(n.value),await Ur()}function Hl(i){const u=qe(i.params),m=typeof(u==null?void 0:u.threadId)=="string"?u.threadId.trim():"";if(!m)return;const b=qe(u==null?void 0:u.externalSession),R=b&&typeof b.origin=="string"&&b.origin.trim().length>0?{origin:b.origin.trim(),active:b.active===!0,lastWriteAt:typeof b.lastWriteAt=="string"?b.lastWriteAt:null}:null;$e.value={...$e.value,[m]:R},hn(m,(R==null?void 0:R.active)===!0),_n(),nn=!0,n.value===m&&Yt.add(m),ht===null&&typeof window<"u"&&(ht=window.setTimeout(()=>{ht=null,Ur()},yu))}function Uc(){typeof window>"u"||Ut||(Bc(),bd(),Ut=C_(i=>{if(i.method==="ready"){Ts(),Fc();return}if(i.method==="externalSessionChanged"){Hl(i);return}Is(i),Ma(i)}))}async function Bc(){try{const u=(await Sm()).map(m=>Ka(m)).filter(m=>m!==null);vr(u)}catch{}}async function bd(){try{const i=await Ix(),u=Object.entries(i);if(u.length===0)return;const m={...d.value};let b=!1;for(const[R,E]of u){const L=E.filter(Ne=>!!Ne&&typeof Ne.id=="string");if(L.length===0)continue;const q=m[R]??[],Z=new Set(q.map(Ne=>Ne.text)),he=[...q];for(const Ne of L)Z.has(Ne.text)||(he.push(Ne),Z.add(Ne.text));m[R]=he.slice(-20),b=!0}b&&(d.value=m,wu(m))}catch{}}async function tl(i){try{return await __(i.id,{result:i.result,error:i.error}),Qo(i.id),pe.value=St(pe.value,String(i.id)),!0}catch(u){const m=u instanceof Error?u.message:"Failed to reply to server request";return await Wl(i.id)?(ut.value=m,pe.value={...pe.value,[String(i.id)]:m},!1):(Qo(i.id),pe.value=St(pe.value,String(i.id)),!0)}}async function Wl(i){try{const u=await Sm();for(const m of u){const b=qe(m);if((b==null?void 0:b.id)===i)return!0}return!1}catch{return!0}}function kd(){if(Ut&&(Ut(),Ut=null),nn=!1,Yt.clear(),Xn.clear(),ht!==null&&typeof window<"u"&&(window.clearTimeout(ht),ht=null),Ho!==null&&typeof window<"u"&&(window.clearTimeout(Ho),Ho=null),Qn!==null&&typeof window<"u"&&(window.clearTimeout(Qn),Qn=null),typeof window<"u")for(const i of dn.values())window.clearTimeout(i);dn.clear(),Hn=!1,o.value={},r.value={},a.value={},h.value={},d.value={},j.value={},B.value={},re.value={},be.value={},Se.value={},se.value={},Ee.value={},P.clear(),y.clear(),_.clear(),Qs.clear(),ju=0,ge.value={},Fe.value={},Me.value={},de.value={},Le.value={},je.value={},gr(),aa(),It.value=null,Tt.value={}}const Si=X(()=>{const i=n.value;if(!i)return[];const u=de.value[i]??[];return[...(je.value[i]??[]).map(R=>({...R,awaitingCompaction:!0})),...u]});function nl(i){const u=n.value;if(!u)return;const m=je.value[u];if(m!=null&&m.some(E=>E.id===i)){const E=m.filter(L=>L.id!==i);je.value=E.length>0?{...je.value,[u]:E}:St(je.value,u),gr();return}const b=de.value[u];if(!b)return;const R=b.filter(E=>E.id!==i);de.value=R.length>0?{...de.value,[u]:R}:St(de.value,u),aa()}function Vl(i,u){const m=n.value;if(!m)return;const b=de.value[m];if(!b)return;const R=je.value[m];if(R!=null&&R.some(he=>he.id===i||he.id===u))return;const E=b.findIndex(he=>he.id===i),L=b.findIndex(he=>he.id===u);if(E<0||L<0||E===L)return;const q=[...b],[Z]=q.splice(E,1);q.splice(L,0,Z),de.value={...de.value,[m]:q},aa()}function ns(i){const u=n.value;if(!u)return;const m=je.value[u],b=m==null?void 0:m.find(L=>L.id===i);if(b){nl(i),Ko(b.collaborationMode),Te=!0,Ji(b.text,b.imageUrls,b.skills,"steer",b.fileAttachments).finally(()=>{Te=!1});return}const R=de.value[u];if(!R)return;const E=R.find(L=>L.id===i);E&&(nl(i),Ko(E.collaborationMode),Ji(E.text,E.imageUrls,E.skills,"steer",E.fileAttachments))}function Cd(i,u={}){fn(i,u)}return{projectGroups:e,projectDisplayNameById:Be,selectedThread:ho,selectedThreadTokenUsage:cr,selectedThreadTerminalOpen:Tr,isSelectedThreadInterruptPending:Sr,selectedThreadServerRequests:oi,selectedLiveOverlay:Wa,selectedActiveTurnId:Wo,lastPlanByThreadId:s,resolveThreadTurnIndex:Ll,codexQuota:Ca,selectedThreadId:n,availableCollaborationModes:At,availableModelIds:Ue,availableModelReasoningEfforts:Ye,selectedCollaborationMode:et,selectedModelId:ft,selectedReasoningEffort:mt,selectedSpeedMode:kt,codexCliMissingError:ae,installedSkills:Y,accountRateLimitSnapshots:me,messages:_r,hasMoreOlderMessages:Ct,isLoadingThreads:Ze,isThreadListFullyLoaded:Nt,isLoadingMessages:Ft,isLoadingOlderMessages:Fn,isSendingMessage:Kn,isInterruptingTurn:lo,isUpdatingSpeedMode:co,isRollingBack:uo,compactingThreadIds:fo,fuzzyFileSearchResults:Cr,registerFuzzyFileSearchSession:Zi,error:ut,refreshAll:yi,refreshSkills:Rs,refreshHooks:Ki,hooksList:Oe,isHooksLoading:We,onRealtimeEvent:Ps,selectThread:Na,loadMessages:sa,loadOlderMessages:Fr,ensureThreadMessagesLoaded:gi,setThreadTerminalOpen:dr,toggleSelectedThreadTerminal:Wi,archiveThreadById:Fl,compactThreadById:zl,renameThreadById:Yi,forkThreadById:Ul,forkThreadFromTurn:wi,rollbackSelectedThread:gd,sendMessageToSelectedThread:Ji,sendMessageToNewThread:ki,interruptSelectedThreadTurn:Oc,interruptedUnsubmittedMessage:ur,clearInterruptedUnsubmittedMessage:ql,selectedThreadQueuedMessages:Si,removeQueuedMessage:nl,reorderQueuedMessage:Vl,steerQueuedMessage:ns,autoCompactThreshold:fe,setAutoCompactThreshold:Nc,setSelectedCollaborationMode:Ko,readModelIdForThread:sn,setSelectedModelIdForThread:Vn,setSelectedModelId:Zn,setSelectedReasoningEffort:Pe,updateSelectedSpeedMode:Ge,respondToPendingServerRequest:tl,pendingReplyErrorForRequest:Xo,renameProject:yd,removeProject:Ci,reorderProject:wd,pinProjectToTop:Dc,startPolling:Uc,stopPolling:kd,primeSelectedThread:Cd}}const hO={class:"sidebar-root"},mO=["aria-pressed","aria-label","title"],vO={key:1,class:"sidebar-search-bar"},gO=["placeholder"],yO=["aria-label"],wO={class:"sidebar-skills-link-icon","aria-hidden":"true"},bO={class:"sidebar-skills-link-copy"},kO={class:"sidebar-skills-link-title"},CO={class:"sidebar-skills-link-subtitle"},TO={class:"sidebar-skills-link-icon sidebar-automations-link-icon","aria-hidden":"true"},SO={class:"sidebar-skills-link-copy"},_O={class:"sidebar-skills-link-title"},xO={class:"sidebar-skills-link-subtitle"},AO=["aria-label"],PO={class:"settings-dialog-header"},IO={class:"settings-dialog-title"},EO=["aria-label","title"],RO={class:"settings-dialog-body"},MO=["aria-label"],$O=["aria-current","onClick"],jO={class:"settings-group-content"},LO=["title"],NO={class:"sidebar-settings-label"},OO=["title"],DO={class:"sidebar-settings-label"},FO={class:"sidebar-settings-value"},UO=["title"],BO={class:"sidebar-settings-label"},qO={class:"sidebar-settings-value"},zO=["title"],HO={class:"sidebar-settings-label"},WO=["title"],VO={class:"sidebar-settings-label"},GO={class:"sidebar-settings-value"},KO=["title"],YO={class:"sidebar-settings-label"},JO=["title"],QO={class:"sidebar-settings-label"},XO=["title"],ZO={class:"sidebar-settings-label"},e2=["title"],t2={class:"sidebar-settings-label"},n2=["href"],o2={class:"sidebar-settings-label"},r2={class:"sidebar-settings-value"},a2=["title"],s2={class:"sidebar-settings-label"},i2={key:0,class:"sidebar-settings-row sidebar-settings-error"},l2=["href"],c2={key:1,class:"sidebar-settings-row sidebar-settings-row--input"},u2={class:"sidebar-settings-provider-info"},d2={class:"sidebar-settings-label"},f2={class:"sidebar-settings-provider-link",href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer"},p2={class:"sidebar-settings-key-group"},h2={class:"sidebar-settings-key-masked"},m2=["disabled","title"],v2=["placeholder"],g2=["disabled"],y2={class:"sidebar-settings-row sidebar-settings-row--select",style:{"margin-top":"4px",padding:"0"}},w2={class:"sidebar-settings-label"},b2=["aria-label"],k2=["disabled"],C2=["disabled"],T2={key:2,class:"sidebar-settings-row sidebar-settings-row--input"},S2={class:"sidebar-settings-provider-info"},_2={class:"sidebar-settings-label"},x2={class:"sidebar-settings-provider-link",href:"https://opencode.ai/auth",target:"_blank",rel:"noopener noreferrer"},A2={class:"sidebar-settings-key-group"},P2=["placeholder"],I2=["disabled"],E2={key:3,class:"sidebar-settings-row sidebar-settings-row--input"},R2={class:"sidebar-settings-label"},M2={class:"sidebar-settings-key-group"},$2=["placeholder"],j2={class:"sidebar-settings-label",style:{"margin-top":"4px"}},L2={class:"sidebar-settings-key-group"},N2=["placeholder"],O2=["disabled"],D2={class:"sidebar-settings-row sidebar-settings-row--select",style:{"margin-top":"4px",padding:"0"}},F2={class:"sidebar-settings-label"},U2=["aria-label"],B2={class:"sidebar-settings-label"},q2={class:"sidebar-settings-value"},z2={key:0,class:"sidebar-settings-telegram-panel"},H2={class:"sidebar-settings-field"},W2={class:"sidebar-settings-field-label"},V2={class:"sidebar-settings-field"},G2={class:"sidebar-settings-field-label"},K2={class:"sidebar-settings-field-help"},Y2={key:0,class:"sidebar-settings-telegram-error"},J2=["href"],Q2={class:"sidebar-settings-telegram-actions"},X2=["disabled"],Z2={class:"sidebar-settings-hooks-section"},eD={class:"sidebar-settings-hooks-header"},tD={class:"sidebar-settings-hooks-title"},nD=["disabled","title"],oD={key:0,class:"sidebar-settings-hooks-empty"},rD={key:0,class:"sidebar-settings-hooks-empty"},aD={key:1,class:"sidebar-settings-hooks-empty"},sD={key:2,class:"sidebar-settings-hooks-list"},iD={class:"sidebar-settings-hooks-cwd"},lD={class:"sidebar-settings-hooks-event"},cD={class:"sidebar-settings-hooks-command"},uD={class:"sidebar-settings-remote-section"},dD={class:"sidebar-settings-remote-header"},fD={class:"sidebar-settings-remote-title"},pD=["disabled","title"],hD={class:"sidebar-settings-remote-toggle-label"},mD={key:0,class:"sidebar-settings-remote-empty"},vD={key:0,class:"sidebar-settings-remote-error"},gD={key:1,class:"sidebar-settings-remote-notice"},yD={key:2,class:"sidebar-settings-remote-empty"},wD=["disabled"],bD={class:"sidebar-settings-remote-label"},kD={class:"sidebar-settings-remote-value"},CD={class:"sidebar-settings-remote-clients"},TD={class:"sidebar-settings-remote-clients-header"},SD={class:"sidebar-settings-remote-label"},_D=["disabled"],xD={key:0,class:"sidebar-settings-remote-empty"},AD={class:"sidebar-settings-remote-client-name"},PD=["disabled","onClick"],ID={class:"sidebar-settings-rate-limits"},ED=["aria-label"],RD={class:"sidebar-settings-actions"},MD=["title","aria-label"],$D=["title","aria-label"],jD={class:"content-root-wrap"},LD={key:0,class:"content-keyboard-spacer","aria-hidden":"true"},ND={key:1,class:"skills-route-header-icon","aria-hidden":"true"},OD={key:2,class:"skills-route-header-icon automations-route-header-icon","aria-hidden":"true"},DD=["aria-label","title"],FD={class:"content-body"},UD={key:2,class:"content-grid content-grid-home"},BD={class:"new-thread-empty"},qD={class:"new-thread-hero"},zD=["title"],HD={class:"new-thread-folder-actions"},WD=["disabled"],VD={key:1,class:"new-thread-launch-card","aria-label":"Plugins and Apps announcement"},GD={class:"new-thread-launch-card-copy"},KD={class:"new-thread-launch-card-topline"},YD={class:"new-thread-launch-card-badge","aria-hidden":"true"},JD={class:"new-thread-launch-card-eyebrow"},QD={class:"new-thread-launch-card-title"},XD={class:"new-thread-launch-card-text"},ZD={class:"new-thread-launch-card-actions"},eF=["aria-label","onKeydown"],tF={class:"new-thread-open-folder-header"},nF={class:"new-thread-open-folder-title"},oF={class:"new-thread-open-folder-label"},rF={class:"new-thread-open-folder-current"},aF=["placeholder","title","disabled","onKeydown"],sF=["disabled"],iF={class:"new-thread-open-folder-actions"},lF={class:"new-thread-open-folder-toggle"},cF=["aria-pressed","disabled"],uF={key:0,class:"new-thread-open-folder-create"},dF={class:"new-thread-open-folder-create-composer"},fF=["placeholder","onKeydown"],pF=["disabled"],hF={key:0,class:"new-thread-open-folder-error visible-error-with-feedback"},mF=["href"],vF=["placeholder","onKeydown"],gF={key:1,class:"new-thread-open-folder-error-actions"},yF={class:"new-thread-open-folder-error visible-error-with-feedback"},wF=["href"],bF=["disabled"],kF={key:2,class:"new-thread-open-folder-status"},CF={key:3,class:"new-thread-open-folder-status"},TF={key:4,class:"new-thread-open-folder-list"},SF=["title","disabled","onClick"],_F={class:"new-thread-open-folder-item-name"},xF=["disabled","onClick"],AF=["aria-label","onKeydown"],PF={class:"new-thread-open-folder-header"},IF={class:"new-thread-open-folder-title"},EF=["disabled"],RF=["aria-label"],MF=["aria-selected","disabled"],$F=["aria-selected","disabled"],jF={class:"new-thread-project-field"},LF={class:"new-thread-open-folder-label"},NF=["disabled","placeholder"],OF={key:0,class:"new-thread-project-field"},DF={class:"new-thread-open-folder-label"},FF=["disabled","placeholder","onKeydown"],UF={key:1,class:"new-thread-project-field"},BF={class:"new-thread-open-folder-label"},qF=["disabled","onKeydown"],zF={key:2,class:"new-thread-open-folder-error visible-error-with-feedback"},HF=["href"],WF={class:"new-thread-project-modal-actions"},VF=["disabled"],GF=["disabled"],KF={key:3,class:"new-thread-branch-select"},YF={class:"new-thread-branch-select-label"},JF={class:"new-thread-branch-select-help"},QF={key:4,class:"new-thread-runtime-help"},XF={class:"worktree-init-status-title"},ZF={class:"worktree-init-status-message"},eU={class:"composer-with-queue"},tU={key:0,class:"composer-runtime-error",role:"alert"},nU=["href"],oU={key:3,class:"content-grid"},rU={class:"content-thread"},aU={key:0,class:"external-session-banner",role:"alert"},sU={key:1,class:"composer-runtime-error",role:"alert"},iU=["href"],lU={key:2,class:"interrupt-recovered-banner",role:"status"},cU=["aria-label"],uU={class:"content-right-panel-header"},dU={class:"content-right-panel-tabs",role:"tablist"},fU=["aria-selected"],pU=["aria-selected"],hU=["aria-selected","title","onClick"],mU={class:"content-right-panel-tab-label"},vU=["aria-label","title","onClick"],gU={class:"content-right-panel-actions"},yU={class:"content-right-panel-add-wrap"},wU=["aria-label","title"],bU={key:0,class:"content-right-panel-menu"},kU=["aria-label","title"],CU={class:"content-right-panel-body"},TU={key:0,class:"project-zip-modal-backdrop",role:"presentation"},SU=["aria-label"],_U={class:"project-zip-modal-header"},xU={class:"project-zip-modal-title"},AU=["aria-label","disabled"],PU={class:"project-zip-modal-copy"},IU={class:"project-zip-progress-label",role:"status","aria-live":"polite"},EU={class:"project-zip-progress-track"},RU={key:0,class:"project-zip-modal-error",role:"alert"},MU={class:"project-zip-modal-actions"},$U=["disabled"],jU=["disabled"],LU=["disabled"],NU=["aria-label"],OU={class:"codex-login-modal-header"},DU={class:"codex-login-modal-title"},FU=["aria-label","disabled"],UU={class:"codex-login-modal-copy"},BU=["href"],qU=["placeholder","disabled"],zU={key:1,class:"codex-login-modal-error visible-error-with-feedback"},HU=["href"],WU={class:"codex-login-modal-actions"},VU=["disabled"],GU=["disabled"],Cv="codex-web-local.sidebar-collapsed.v1",Tv="codex-web-local.accounts-section-collapsed.v1",Sv="codex-web-local.right-panel-width.v1",KU=260,YU=640,_v=320,JU=400,xv="codex-web-local.send-with-enter.v1",Av="codex-web-local.in-progress-send-mode.v1",Pv="codex-web-local.dark-mode.v1",Iv="codex-web-local.dictation-click-to-toggle.v1",Ev="codex-web-local.dictation-auto-send.v1",Rv="codex-web-local.dictation-language.v1",Mv="codex-web-local.chat-width.v1",QU=400,XU=tn({__name:"App",setup(e){var sh,ih;const t=Zl(()=>nc(()=>import("./ThreadConversation-BFAPAWUd.js"),__vite__mapDeps([0,1,2]))),n=Zl(()=>nc(()=>import("./ThreadTerminalPanel-C0cuIPzx.js"),__vite__mapDeps([3,4]))),o=Zl(()=>nc(()=>import("./ReviewPane-Cd7kjB6d.js"),__vite__mapDeps([5,6]))),r=Zl(()=>nc(()=>import("./DirectoryHub-DWtUbt5I.js"),__vite__mapDeps([7,1,8]))),s=Zl(()=>nc(()=>import("./AutomationsPanel-BZ73-GJE.js"),__vite__mapDeps([9,10]))),{t:a,uiLanguage:l,uiLanguageOptions:d,setUiLanguage:h}=io(),v="codex-mobile",y="0.1.102",_={sendWithEnter:a("When enabled, press Enter to send. When disabled, use Command+Enter to send."),inProgressSendMode:a("If a turn is still running, choose whether a new prompt should steer the current turn or be queued."),appearance:a("Switch between system theme, light mode, and dark mode."),chatWidth:a("Choose how wide the conversation column and composer can grow on desktop screens."),dictationClickToToggle:a("Use click-to-start and click-to-stop dictation instead of hold-to-talk."),dictationAutoSend:a("Automatically send transcribed dictation when recording stops."),dictationLanguage:a("Choose transcription language or keep auto-detect.")},P={standard:{label:"Standard",columnMax:"45rem",cardMax:"76ch"},wide:{label:"Wide",columnMax:"72rem",cardMax:"88ch"},"extra-wide":{label:"Extra wide",columnMax:"96rem",cardMax:"96ch"}},j={en:"english",zh:"chinese",de:"german",es:"spanish",ru:"russian",ko:"korean",fr:"french",ja:"japanese",pt:"portuguese",tr:"turkish",pl:"polish",ca:"catalan",nl:"dutch",ar:"arabic",sv:"swedish",it:"italian",id:"indonesian",hi:"hindi",fi:"finnish",vi:"vietnamese",he:"hebrew",uk:"ukrainian",el:"greek",ms:"malay",cs:"czech",ro:"romanian",da:"danish",hu:"hungarian",ta:"tamil",no:"norwegian",th:"thai",ur:"urdu",hr:"croatian",bg:"bulgarian",lt:"lithuanian",la:"latin",mi:"maori",ml:"malayalam",cy:"welsh",sk:"slovak",te:"telugu",fa:"persian",lv:"latvian",bn:"bengali",sr:"serbian",az:"azerbaijani",sl:"slovenian",kn:"kannada",et:"estonian",mk:"macedonian",br:"breton",eu:"basque",is:"icelandic",hy:"armenian",ne:"nepali",mn:"mongolian",bs:"bosnian",kk:"kazakh",sq:"albanian",sw:"swahili",gl:"galician",mr:"marathi",pa:"punjabi",si:"sinhala",km:"khmer",sn:"shona",yo:"yoruba",so:"somali",af:"afrikaans",oc:"occitan",ka:"georgian",be:"belarusian",tg:"tajik",sd:"sindhi",gu:"gujarati",am:"amharic",yi:"yiddish",lo:"lao",uz:"uzbek",fo:"faroese",ht:"haitian creole",ps:"pashto",tk:"turkmen",nn:"nynorsk",mt:"maltese",sa:"sanskrit",lb:"luxembourgish",my:"myanmar",bo:"tibetan",tl:"tagalog",mg:"malagasy",as:"assamese",tt:"tatar",haw:"hawaiian",ln:"lingala",ha:"hausa",ba:"bashkir",jw:"javanese",su:"sundanese",yue:"cantonese"},{projectGroups:B,projectDisplayNameById:J,selectedThread:ce,selectedThreadTokenUsage:U,selectedThreadServerRequests:V,selectedLiveOverlay:K,lastPlanByThreadId:ye,resolveThreadTurnIndex:_e,selectedActiveTurnId:we,codexQuota:$e,selectedThreadId:de,availableCollaborationModes:Le,availableModelIds:je,availableModelReasoningEfforts:fe,selectedCollaborationMode:Te,selectedReasoningEffort:xe,selectedSpeedMode:Ae,codexCliMissingError:Ue,installedSkills:Ye,accountRateLimitSnapshots:He,messages:At,hasMoreOlderMessages:ct,isLoadingThreads:Qe,isThreadListFullyLoaded:et,isLoadingMessages:ft,isLoadingOlderMessages:mt,isSendingMessage:kt,isInterruptingTurn:at,isSelectedThreadInterruptPending:ae,isUpdatingSpeedMode:te,error:oe,refreshAll:z,refreshSkills:Be,refreshHooks:$,hooksList:O,isHooksLoading:G,onRealtimeEvent:ue,selectThread:ie,ensureThreadMessagesLoaded:re,loadMessages:Se,loadOlderMessages:be,archiveThreadById:pe,compactThreadById:se,compactingThreadIds:Ee,fuzzyFileSearchResults:ge,registerFuzzyFileSearchSession:Fe,forkThreadById:Me,renameThreadById:Ve,forkThreadFromTurn:rt,sendMessageToSelectedThread:gt,sendMessageToNewThread:It,interruptSelectedThreadTurn:Tt,interruptedUnsubmittedMessage:Tn,clearInterruptedUnsubmittedMessage:H,selectedThreadQueuedMessages:W,removeQueuedMessage:Y,reorderQueuedMessage:me,steerQueuedMessage:Oe,autoCompactThreshold:We,setAutoCompactThreshold:Ze,setSelectedCollaborationMode:Ft,readModelIdForThread:Nt,setSelectedModelIdForThread:Kn,setSelectedReasoningEffort:lo,updateSelectedSpeedMode:co,respondToPendingServerRequest:uo,pendingReplyErrorForRequest:fo,renameProject:za,removeProject:Cr,reorderProject:Qt,pinProjectToTop:ut,startPolling:gn,stopPolling:zo,primeSelectedThread:bs,rollbackSelectedThread:ni}=pO(),Et=XT(),Ut=QT(),{isMobile:ht}=yp();function Ho(){return typeof navigator<"u"&&/mac|iphone|ipad|ipod/i.test(navigator.platform)}const dn=A(null),sr=A(null),ir=A(null);let Yn=null;const{buildFeedbackMailto:lr,feedbackMailtoBase:ba,recordVisibleFailure:Ha}=xp(),Dn=ba();function In(c,f){f&&Ha(f);const x=c.currentTarget;x instanceof HTMLAnchorElement&&(x.href=lr())}const Gr=A(null),Ao=A(null),nn=A(null),Kr=A(0);let Yt=null;function Yr(){const c=nn.value;if(!c)return;const f=window.getComputedStyle(c),x=Number.parseFloat(f.paddingLeft)+Number.parseFloat(f.paddingRight),N=Math.max(0,c.clientWidth-(Number.isFinite(x)?x:0)),Q=window.getComputedStyle(c).getPropertyValue("--chat-column-max").trim(),ve=Number.parseFloat(Q)*(Q.endsWith("rem")?16:1),De=Number.isFinite(ve)&&ve>0?Math.min(N,ve):N;Kr.value=De}const ka=A(null),Jn=A(null),Qn=A(!1),Po=A(!1),Pt=A(!0),$t=A("git"),zn=A([]),po=A(""),Hn=X(()=>zn.value.find(c=>c.key===po.value)??null),Xn=A(!1),Mn=A(!1),Io=A(!1),ho=A(Sr());function Tr(c){return Math.min(YU,Math.max(KU,c))}function Sr(){if(typeof window>"u")return _v;const c=window.localStorage.getItem(Sv),f=Number(c);return Number.isFinite(f)?Tr(f):_v}function oi(c){typeof window>"u"||window.localStorage.setItem(Sv,String(c))}function Wo(c){c.preventDefault();const f=c.clientX,x=ho.value,N=ve=>{const De=f-ve.clientX;ho.value=Tr(x+De)},Q=()=>{oi(ho.value),window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",Q)};window.addEventListener("mousemove",N),window.addEventListener("mouseup",Q)}const Wa=A(null),Ca=A(!1),cr=A("");let _r=!1;const ur=A(!1),Ct=A(""),Fn=A("local"),Sn=A({}),sn=new Map,mo=A(""),Vo=A([]),En=A(!1),Wn=A({order:[],labels:{},projectOrder:[]}),xt=A({phase:"idle",loaded:0,total:null,blob:null,fileName:"",error:""}),yn=A({phase:"idle",title:"",message:""}),Bt=A(Zb()),fn=A(""),Vn=A(!1),Zn=A(null),vo=A(null),xr=A(null),Go=A(null),Jr=A(null),Ko=A(null);let Eo=null,Ar=null,go=0,M=0,F=!1,ne=0,Pe=0,Ge=0,qt=0;const pn=A("New Project (1)"),Xt=A(""),jt=A(!1),Pr=[{id:"general",label:"General settings"},{id:"models",label:"Models & providers"},{id:"integrations",label:"Integrations"},{id:"usage",label:"Usage & about"}],yo=A("general");let Ta=0;function Ml(){if(jt.value){Ta=Date.now(),jt.value=!1;return}Date.now()-Ta<JU||(jt.value=!0)}const Qr=A(t0()),Gn=A(!1),ks=A(!1),_n=A(new Set);async function ri(){try{_n.value=new Set(await s_())}catch{}finally{ks.value=!0}}const Hi=X(()=>!ks.value||_n.value.has("hooks/list")),ai=X(()=>!ks.value||["remoteControl/status/read","remoteControl/enable","remoteControl/pairing/start","remoteControl/client/list"].every(c=>_n.value.has(c)));nt(jt,c=>{c&&($(),li(),ai.value&&ci())});const ln=A({enabled:!1,clients:[]}),hn=A(null),Ro=A(!1),eo=A(!1),to=A(""),Yo=A(""),Cs=A("");let Sa=null,si=!1,Gt=null;const Zt=A("never"),ii=A(!1),Ts=A(!1),no=A(""),dr=A("");let Wi=!1;const fr=A(!1);async function li(c={}){if(!(c.force!==!0&&Wi)){ii.value=!0,no.value="";try{Zt.value=await d_(),Wi=!0}catch(f){no.value=f instanceof Error?f.message:"Failed to load approval policy"}finally{ii.value=!1}}}function _a(c){Zt.value=c}async function $n(){Ts.value=!0,no.value="",dr.value="";try{await f_(Zt.value),fr.value=!0,dr.value=a("Approval policy saved"),Va&&clearTimeout(Va),Va=setTimeout(()=>{dr.value=""},2200)}catch(c){no.value=c instanceof Error?c.message:"Failed to save approval policy"}finally{Ts.value=!1}}let Va=null;async function ci(c={}){if(!(c.force!==!0&&si)){Ro.value=!0,Yo.value="";try{const f=await u_();ln.value=f,si=!0}catch(f){Yo.value=f instanceof Error?f.message:"Failed to load remote control status"}finally{Ro.value=!1}}}async function ui(){const c=!ln.value.enabled;eo.value=!0,to.value=c?"enable":"disable";try{await p_(c),ln.value={...ln.value,enabled:c},di(c?"Remote control enabled":"Remote control disabled")}catch(f){Yo.value=f instanceof Error?f.message:"Failed to update remote control"}finally{eo.value=!1,to.value=""}}async function Vi(){eo.value=!0,to.value="pairing";try{hn.value=await h_()}catch(c){Yo.value=c instanceof Error?c.message:"Failed to start pairing"}finally{eo.value=!1,to.value=""}}async function Ss(){eo.value=!0,to.value="clients";try{ln.value={...ln.value,clients:await m_()}}catch(c){Yo.value=c instanceof Error?c.message:"Failed to load remote clients"}finally{eo.value=!1,to.value=""}}async function $l(c){eo.value=!0,to.value=`revoke:${c}`;try{await v_(c),ln.value={...ln.value,clients:ln.value.clients.filter(f=>f.clientId!==c)},di("Remote client removed")}catch(f){Yo.value=f instanceof Error?f.message:"Failed to remove remote client"}finally{eo.value=!1,to.value=""}}function di(c){Cs.value=c,Sa&&clearTimeout(Sa),Sa=setTimeout(()=>{Cs.value=""},3e3)}const Ir=A(""),Xr=A(""),pr=A([]),Zr=A(null),xa=A(null),hr=A(null),Aa=A(null),Mo=A(!1),Ga=A(!1),Er=A({addedLineCount:0,removedLineCount:0}),wo=A([]),Rr=A(""),qe=A({}),ke=A(""),Un=A(""),Pa=A({}),mr=A(""),_s=A(""),cn=A(!1),ea=A(!1);function jl(c,f){return`${c}\0${f?"with-reset-history":"without-reset-history"}`}const Ka=A(null),jn=A([]),Jo=A(!1),bo=A(!1),Mr=A(!1),Ln=A(!1),Ya=A(!1),Ia=A(""),$r=A(""),fi=A(null),Qo=A(""),Xo=A(""),vr=A(""),wn=A(""),ta=A($d(xv,!0)),Ea=A(Db()),na=A(Ob()),Ja=A(Fb()),Zo=A($d(Iv,!1)),oa=A($d(Ev,!0)),Ra=A(Qb()),Qa=X(()=>Xb()),Ll=X(()=>{const{loaded:c,total:f}=xt.value,x=Mp(c);return f&&f>0?`${x} / ${Mp(f)}`:c>0?x:a("Preparing...")}),pi=X(()=>{const{loaded:c,total:f,phase:x}=xt.value;return x==="ready"?"100%":!f||f<=0?c>0?"55%":"20%":`${Math.min(100,Math.max(5,Math.round(c/f*100)))}%`}),xs=A(!1),jr=A(!1),Lr=A(!1),ra=A(""),Xa=A(!1),Gi=A(null),Jt=A(!1),oo=A(""),xn=A("codex"),As=X(()=>[{value:"codex",label:a("Codex")},{value:"openrouter",label:a("OpenRouter")},{value:"opencode-zen",label:a("OpenCode Zen")},{value:"custom",label:a("Custom endpoint")}]),er=A(""),Za=A(""),w=A("responses"),k=A("responses"),C=A(""),D=A(!1),Ce=A(""),st=A(""),Rt=A(""),$o=A(!1),Kt=A(!1),Nn=A(""),bn=A(""),tr=A(!1),Nr=A(!1),jo=A("create"),Ps=A(""),hi=A(""),mi=A(""),Is=A(!1),Ma=A(""),Lo=A(!1),Nl=A(null),jc=A(null),$a=A(!1),Lc=A(null),md=A(null),ja=A(""),Or=A(""),aa=A(""),Ol=A([]),Bn=A(""),No=A(!1),ko=A(!1),vi=A(!1),Dr=A(""),Es=[oe,Ue,Rr,Un,wn,oo,Rt,bn,Ma,Bn],sa=X(()=>Es.some(c=>c.value.trim().length>0)),Fr=A({configured:!1,active:!1,mappedChats:0,mappedThreads:0,allowedUsers:0,allowAllUsers:!1,lastError:""}),gi=A(null),Rs=A(!1),Ki=A(!1),La=A(typeof window<"u"?((sh=window.visualViewport)==null?void 0:sh.height)??window.innerHeight:0),Dl=A(typeof window<"u"?((ih=window.visualViewport)==null?void 0:ih.offsetTop)??0:0),yi=A(typeof window<"u"?window.innerHeight:0);let Na=null,Fl=!1,Yi=!1,Ul=!1,wi=0;const es=X(()=>{const c=Et.params.threadId;return typeof c=="string"?c:""}),Rn=X(()=>Et.name==="home"),gr=X(()=>Et.name==="skills"),ts=X(()=>Et.name==="automations"),Nc=X(()=>{const c=Et.query.automationId;return typeof c=="string"?c:""}),vd=X(()=>{var c;return ts.value?a("Automations"):gr.value?a("Skills"):Rn.value?a("Start new thread"):((c=ce.value)==null?void 0:c.title)??a("Choose a thread")}),bi=typeof window<"u"&&(window.location.hostname||window.location.host)||"codexui",Ji=X(()=>{var f,x;return(((x=(f=ce.value)==null?void 0:f.title)==null?void 0:x.trim())??"")||bi}),ki=X(()=>At.value.filter(c=>{const f=o0(c.messageType,c.role);return f==="worked"?!0:!(f==="turnActivity.live"||f==="turnError.live"||f==="agentReasoning.live")})),Qi=new Set(["commandExecution","worked","toolCall","fileChange","agentMessage","agentMessage.live","plan"]),Xi=A(null);function Bl(c,f,x){const N=typeof f.turnIndex=="number"?f.turnIndex:-1;return N<0?!1:c.some((Q,ve)=>ve>x&&typeof Q.turnIndex=="number"&&Q.turnIndex>=N&&Qi.has(Q.messageType??""))}function Oc(c,f){return c.some(x=>typeof x.turnIndex=="number"&&x.turnIndex>=f&&Qi.has(x.messageType??""))}const ql=X(()=>{const c=ki.value,f=ft.value;for(let ve=c.length-1;ve>=0;ve-=1){const De=c[ve];if(De.messageType!=="plan"&&De.messageType!=="plan.live")continue;const on=ov(De);if(!on||Xi.value!==null&&De.id===Xi.value)return null;const c0=f?!0:Bl(c,De,ve);return{id:De.id,streaming:De.messageType==="plan.live",explanation:on.explanation,steps:on.steps,implemented:c0}}const x=de.value?ye.value[de.value]??null:null;if(!x)return null;const N=ov(x);if(!N)return null;const Q=typeof x.turnIndex=="number"?x.turnIndex:x.turnId?_e(de.value,x.turnId)??-1:-1;return{id:x.id,streaming:x.messageType==="plan.live",explanation:N.explanation,steps:N.steps,implemented:f?!0:Q>=0?Oc(c,Q):!1}}),gd=X(()=>K.value),yr=X(()=>Rn.value?"__new-thread__":de.value),Ms=X(()=>Nt(yr.value)),Zi=X(()=>{const c=V.value;return c.length>0?c[c.length-1]:null}),zl=X(()=>Zi.value?fo(Zi.value.id):""),mn=X(()=>{var c,f;return Rn.value?Ct.value.trim():((f=(c=ce.value)==null?void 0:c.cwd)==null?void 0:f.trim())??""}),el=X(()=>Pt.value&&(Rn.value&&mn.value.length>0||Et.name==="thread"&&de.value.length>0)),yd=X(()=>el.value&&$t.value==="terminal"),Ci=X(()=>!ht.value||La.value<=0||yi.value<=0?!1:yi.value-La.value>120),wd=X(()=>Ci.value||yd.value&&Po.value),Dc=X(()=>{var c,f;return((f=(c=ce.value)==null?void 0:c.cwd)==null?void 0:f.trim())??Ct.value.trim()}),Ti=X(()=>{var c;return!Rn.value&&((c=ce.value)==null?void 0:c.inProgress)===!0}),Ur=X(()=>{const c=de.value;return!!c&&Ee.value.has(c)}),Fc=X(()=>{var c,f;return!Rn.value&&((f=(c=ce.value)==null?void 0:c.externalSession)==null?void 0:f.active)===!0}),Hl=X(()=>kt.value||at.value||Ti.value||V.value.length>0);function Uc(){xs.value&&(xs.value=!1,jx(!0))}function Bc(){Uc(),Ut.push({name:"skills",query:{tab:"plugins"}})}function bd(){const c=de.value;c&&se(c)}function tl(c,f){const x=ot(c).trim(),N=br(x);return!x||!N?!1:f.some(Q=>{const ve=ot(Q).trim();return ve!==x&&br(ve)===N})}function Wl(c,f=""){const x=ot(c).trim(),N=f.trim();if(N)return N;const Q=br(x),ve=[...Wn.value.order,...B.value.map(De=>{var on,nr;return((nr=(on=De.threads[0])==null?void 0:on.cwd)==null?void 0:nr.trim())??""}).filter(Boolean)];return tl(x,ve)?x:Q}function kd(){const c=new Set(Wn.value.order),f=Wn.value.projectOrder.filter(x=>c.has(x));for(const x of Wn.value.order)f.includes(x)||f.push(x);return f}function Si(c){const f=ot(c).trim(),x=[...Wn.value.order,...B.value.map(N=>{var Q,ve;return((ve=(Q=N.threads[0])==null?void 0:Q.cwd)==null?void 0:ve.trim())??""}).filter(Boolean)];return tl(f,x)?f:br(f)}function nl(c){const f=ot(c).trim();if(!f)return"";const x=[...Wn.value.order,...B.value.map(N=>{var Q,ve;return((ve=(Q=N.threads[0])==null?void 0:Q.cwd)==null?void 0:ve.trim())??""}).filter(Boolean)];for(const N of Wn.value.order){const Q=ot(N).trim();if(!Q)continue;const ve=br(Q),De=tl(Q,x)?Q:ve;if(Q===f||De===f||ve===f)return Q}return""}const Vl=X(()=>{var N,Q;const c=[],f=new Set;for(const ve of kd()){const De=ve.trim();!De||f.has(De)||(f.add(De),c.push({value:De,label:Wl(De,Wn.value.labels[De])}))}for(const ve of B.value){const De=((Q=(N=ve.threads[0])==null?void 0:N.cwd)==null?void 0:Q.trim())??"";!De||f.has(De)||Wu(De)||(f.add(De),c.push({value:De,label:Wl(De,J.value[ve.projectName])}))}const x=Ct.value.trim();return x&&!f.has(x)&&c.unshift({value:x,label:Wl(x)}),c}),ns=X(()=>{const c=Ct.value.trim();return c?Sn.value[c]===!0:!1}),Cd=X(()=>{var f,x;const c={};for(const N of B.value){const Q=rl(N.projectName,((x=(f=N.threads[0])==null?void 0:f.cwd)==null?void 0:x.trim())??"");c[N.projectName]=Q?Sn.value[Q]===!0:!1}return c}),i=X(()=>{const c=mo.value.trim(),f=[...Vo.value];return c&&!f.some(x=>x.value===c)&&f.unshift({value:c,label:c}),f}),u=X(()=>{const c=mo.value.trim();if(!c)return"";const f=i.value.find(x=>x.value===c);return(f==null?void 0:f.label)??c}),m=X(()=>Or.value.trim()),b=X(()=>{const c=Nn.value.trim();return!c||c==="."||c===".."?!1:!/[\\/]/u.test(c)}),R=X(()=>b.value&&m.value.trim().length>0&&!Bn.value),E=X(()=>{const c=hi.value.trim();return!c||c==="."||c===".."?!1:!/[\\/]/u.test(c)}),L=X(()=>Ps.value.trim()?jo.value==="create"?E.value:mi.value.trim().length>0:!1),q=X(()=>{const c=ot(ja.value).trim();return c||Or.value.trim()}),Z=X(()=>tr.value?"Creating…":"Create"),he=X(()=>Lo.value?jo.value==="clone"?a("Cloning…"):a("Creating…"):jo.value==="clone"?a("Clone repository"):a("Create project")),Ne=X(()=>{const c=Or.value.trim(),f=aa.value.trim();return!!(c&&f&&c!==f)}),Je=X(()=>{const c=[];Ne.value&&c.push({key:`parent:${aa.value}`,name:"..",path:aa.value,kind:"parent"});for(const f of Ol.value)c.push({key:`directory:${f.path}`,name:f.name,path:f.path,kind:"directory"});return c}),pt=X(()=>{const c=Dr.value.trim().toLowerCase();return c?Je.value.filter(f=>f.kind==="parent"||f.name.toLowerCase().includes(c)):Je.value}),it=typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)"):null,Mt=X(()=>a(P[Ja.value].label)),Oa=X(()=>{const c=P[Ja.value],f=Math.max(0,yi.value-La.value-Dl.value);return{"--chat-column-max":c.columnMax,"--chat-card-max":c.cardMax,"--visual-viewport-height":La.value>0?`${La.value}px`:"100dvh","--visual-viewport-offset-top":`${Math.max(0,Dl.value)}px`,"--virtual-keyboard-inset":`${f}px`}}),$s=X(()=>{if(!Fr.value.configured)return a("Not configured");const c=Fr.value.active?a("Online"):a("Configured (offline)"),f=Fr.value.allowAllUsers?a("allow all users"):`${Fr.value.allowedUsers} ${a("allowed user(s)")}`,x=`${Fr.value.mappedChats} ${a("chat(s)")}, ${Fr.value.mappedThreads} ${a("thread(s)")}, ${f}`,N=Fr.value.lastError?`, ${a("error")}: ${Fr.value.lastError}`:"";return`${c}, ${x}${N}`});ws(()=>{var c,f;document.addEventListener("pointerdown",Fp),window.addEventListener("keydown",Np),document.addEventListener("visibilitychange",Up),window.addEventListener("pageshow",Bp),window.addEventListener("focus",qp),window.addEventListener("resize",ia),(c=window.visualViewport)==null||c.addEventListener("resize",ia),(f=window.visualViewport)==null||f.addEventListener("scroll",ia),ia(),ru(),it==null||it.addEventListener("change",ru),Yn=ue(x=>{ir.value&&ir.value.refreshFromNotification(x)}),Gt=ue(x=>{x==="remoteControl/status/changed"&&ci({force:!0})}),r0(),Ib(),ri(),zc(),Ds(),la(),Ls(),os(),Ld(),Jw(),li()}),nt(Es,(c,f)=>{c.forEach((x,N)=>{if(x===f[N])return;const Q=x.trim();Q&&Ha(Q)})}),nt(nn,c=>{Yt&&(Yt.disconnect(),Yt=null),typeof ResizeObserver<"u"&&(Yt=new ResizeObserver(Yr),c&&Yt.observe(c)),Yr()},{immediate:!0}),Ec(()=>{var c,f;document.removeEventListener("pointerdown",Fp),window.removeEventListener("keydown",Np),document.removeEventListener("visibilitychange",Up),window.removeEventListener("pageshow",Bp),window.removeEventListener("focus",qp),window.removeEventListener("resize",ia),(c=window.visualViewport)==null||c.removeEventListener("resize",ia),(f=window.visualViewport)==null||f.removeEventListener("scroll",ia),it==null||it.removeEventListener("change",ru),Yt&&(Yt.disconnect(),Yt=null),Na!==null&&(window.clearInterval(Na),Na=null),Eo&&(clearTimeout(Eo),Eo=null),eu(),zo(),Yn&&(Yn(),Yn=null),Gt&&(Gt(),Gt=null),Sa&&(clearTimeout(Sa),Sa=null)});function ia(){var c,f;typeof window>"u"||(yi.value=Math.max(yi.value,window.innerHeight),La.value=((c=window.visualViewport)==null?void 0:c.height)??window.innerHeight,Dl.value=((f=window.visualViewport)==null?void 0:f.offsetTop)??0)}nt(fn,c=>{const f=c.trim();if(Eo&&(clearTimeout(Eo),Eo=null),!f){Ko.value=null;return}Eo=setTimeout(()=>{Sx(f,1e3).then(x=>{fn.value.trim()===f&&(Ko.value=x.threadIds)}).catch(()=>{fn.value.trim()===f&&(Ko.value=null)})},220)}),nt(Ci,c=>{c||(Po.value=!1)}),nt(jn,()=>{if(typeof window>"u")return;if(!jn.value.some(f=>f.quotaStatus==="loading")){Na!==null&&(window.clearInterval(Na),Na=null);return}Na===null&&(Na=window.setInterval(()=>{Fl||(Fl=!0,Gl({silent:!0}).finally(()=>{Fl=!1}))},1500))},{deep:!0}),nt(He,()=>{wr().then(c=>{c&&z({includeSelectedThreadMessages:!1,providerChanged:!0,awaitAncillaryRefreshes:!0})})},{deep:!0});async function wr(){if(!Yi||Ul||xn.value!=="codex"||jn.value.length>0||He.value.length===0)return!1;Ul=!0;const c=JSON.stringify(jn.value.map(x=>x.accountId).sort());try{const x=await _m();jn.value=x.accounts}catch{await Gl({silent:!0})}const f=JSON.stringify(jn.value.map(x=>x.accountId).sort());return c!==f}function js(){Be({force:!0})}function qc(c){c&&Se(c,{silent:!0,force:!0})}async function os(){try{Fr.value=await Ax()}catch(c){const f=c instanceof Error?c.message:"Failed to load Telegram status";Fr.value={configured:!1,active:!1,mappedChats:0,mappedThreads:0,allowedUsers:0,allowAllUsers:!1,lastError:f}}}async function Ls(){try{const c=await xx();Ce.value=c.botToken,st.value=c.allowedUserIds.map(f=>String(f)).join(`
|
|
81
81
|
`),Rt.value=""}catch(c){Rt.value=c instanceof Error?c.message:"Failed to load Telegram configuration"}}async function zc(){const c=await $x();xs.value=c.dismissed!==!0}function Hc(c){const f=c.split(/[\n,]/).map(Q=>Q.trim().replace(/^(telegram|tg):/i,"").trim()).filter(Boolean),x=f.includes("*"),N=Array.from(new Set(f.filter(Q=>/^-?\d+$/.test(Q)).map(Q=>Number.parseInt(Q,10))));return x?["*",...N]:N}async function Wc(){const c=Ce.value.trim(),f=Hc(st.value);if(!c){Rt.value=a("Telegram bot token is required.");return}if(f.length===0){Rt.value=a("At least one allowed Telegram user ID or * is required.");return}$o.value=!0,Rt.value="";try{await _x(c,f),st.value=f.map(x=>String(x)).join(`
|
|
82
82
|
`),await Promise.all([Ls(),os()]),window.alert(a("Telegram bot configured. Only allowlisted Telegram users can use the bridge."))}catch(x){Rt.value=x instanceof Error?x.message:a("Failed to connect Telegram bot"),os()}finally{$o.value=!1}}function Vc(){Vn.value=!Vn.value,Vn.value?Wt(()=>{var c;return(c=vo.value)==null?void 0:c.focus()}):fn.value=""}function Gc(){var c;fn.value="",(c=vo.value)==null||c.focus()}function ol(){return Zn.value?Zn.value:typeof document>"u"?null:document.querySelector(".mobile-drawer .sidebar-scrollable, .sidebar-scrollable")}function Kc(c){if(Bt.value||F)return;const f=c==null?void 0:c.currentTarget,x=f instanceof HTMLElement?f:ol();go=(x==null?void 0:x.scrollTop)??go}function Yc(){const c=++M,f=go,x=90;F=!0;const N=()=>{c===M&&(go=f,F=!1)},Q=ve=>{if(c!==M)return;if(Bt.value){N();return}const De=ol();if(De&&(De.scrollTop=f,Math.abs(De.scrollTop-f)<=1||ve>=x)){N();return}if(ve>=x||typeof window>"u"){N();return}window.requestAnimationFrame(()=>Q(ve+1))};Wt(()=>Q(0))}function Re(c){c.key==="Escape"&&(Vn.value=!1,fn.value="")}function Ot(c){c&&(Et.name==="thread"&&es.value===c||(Ut.push({name:"thread",params:{threadId:c}}),ht.value&&Co(!0)))}function Ns(c){Et.name==="automations"&&Nc.value!==c&&Ut.replace({name:"automations",query:c?{automationId:c}:{}})}async function Jc(c){var f;Bt.value&&(Co(!1),await Wt()),(f=dn.value)==null||f.openAutomationEditorFromPanel(c)}async function Zy(){var c;Bt.value&&(Co(!1),await Wt()),(c=dn.value)==null||c.openAutomationCreatorFromPanel()}function ew(){var c;Et.name==="automations"&&((c=sr.value)==null||c.loadAutomations())}async function tw(c){c&&de.value===c&&await jb()}function nw(c){return c.length>8?c.slice(-8):c}function Pp(c){const f=[c.planType||a("unknown")];return c.authMode&&f.unshift(c.authMode),f.join(" · ")}function ow(c){if(!c)return!1;const f=c.toLowerCase();return f.includes("payment required")||/\b402\b/.test(f)}function Qc(c){return c.unavailableReason==="payment_required"||ow(c.quotaError)}function rw(c){return Jo.value||bo.value||Mr.value||Ln.value||Qo.value.length>0||c.isActive&&Qo.value!==c.storageId&&Hl.value}function Td(c){return Xo.value===c.storageId}function aw(c){return vr.value===c.storageId||Td(c)}function sw(c){return Qc(c)?a("Unavailable"):c.isActive?a("Active"):bo.value?a("Switching…"):a("Switch")}function iw(c){return Qo.value===c.storageId?a("Removing…"):Td(c)?a("Click again to remove"):a("Remove")}function lw(c){vr.value=c}function cw(c){vr.value===c&&(vr.value=""),Qo.value!==c&&Xo.value===c&&(Xo.value="")}function uw(c){const f=c.quotaSnapshot;if(!f)return null;const x=[f==null?void 0:f.primary,f==null?void 0:f.secondary].filter(ve=>ve!==null),N=x.find(ve=>ve.windowMinutes===7*24*60);if(N)return N;const Q=x.filter(ve=>typeof ve.windowMinutes=="number"&&ve.windowMinutes>=7*24*60).sort((ve,De)=>(ve.windowMinutes??0)-(De.windowMinutes??0))[0]??null;return Q||(f.secondary??null)}function dw(c){if(typeof c!="number"||!Number.isFinite(c))return"";const f=new Date(c*1e3);return`${f.getMonth()+1}月${f.getDate()}日`}function Ip(c){var ve,De;if(Qc(c))return c.quotaError||a("402 Payment Required");const f=c.quotaSnapshot,x=uw(c),N=(f==null?void 0:f.primary)??(f==null?void 0:f.secondary)??null,Q=x??N;if(Q){const on=Math.max(0,Math.min(100,100-Math.round(Q.usedPercent))),nr=dw(Q.resetsAt);return nr?`${on}% ${a("weekly remaining")} · ${nr}`:`${on}% ${a("weekly remaining")}`}return(ve=f==null?void 0:f.credits)!=null&&ve.unlimited?a("Unlimited credits"):(De=f==null?void 0:f.credits)!=null&&De.hasCredits&&f.credits.balance?`${f.credits.balance} ${a("credits")}`:c.quotaStatus==="loading"?a("Loading quota…"):c.quotaStatus==="error"?c.quotaError||a("Quota unavailable"):c.quotaStatus==="ready"||c.quotaStatus==="idle"?a("Quota unavailable"):a("Fetching account details…")}function fw(c){return[c.email||a("Account"),Pp(c),Qc(c)?a("Unavailable account"):null,Ip(c),`${a("Workspace")} ${c.accountId}`].filter(Boolean).join(`
|
|
83
83
|
`)}async function Gl(c={}){try{const f=await A_();jn.value=f.accounts,f.accounts.some(x=>x.storageId===vr.value)||(vr.value=""),f.accounts.some(x=>x.storageId===Xo.value)||(Xo.value="")}catch(f){if(c.silent===!0)return;wn.value=f instanceof Error?f.message:a("Failed to load accounts")}}async function pw(){if(!(Jo.value||bo.value||Mr.value||Ln.value)){wn.value="",vr.value="",Xo.value="",Jo.value=!0;try{const c=await _m();jn.value=c.accounts,zo(),gn(),z({includeSelectedThreadMessages:!0})}catch(c){wn.value=c instanceof Error?c.message:a("Failed to refresh accounts")}finally{Jo.value=!1}}}async function hw(c){if(!(bo.value||Jo.value||Mr.value||Ln.value)){if(Hl.value){wn.value=a("Finish the current turn and pending requests before switching accounts.");return}wn.value="",vr.value="",Xo.value="",bo.value=!0;try{const f=await E_(c);jn.value=jn.value.map(x=>x.storageId===c?f:{...x,isActive:!1}),zo(),gn(),z({includeSelectedThreadMessages:!0}),Gl({silent:!0})}catch(f){wn.value=f instanceof Error?f.message:a("Failed to switch account")}finally{bo.value=!1}}}async function mw(){var c;if(!(Jo.value||bo.value||Mr.value||Ln.value)){wn.value="",$r.value="",Mr.value=!0;try{const f=await P_();Ia.value=f,Ya.value=!0,window.open(f,"_blank","noopener,noreferrer"),await Wt(),(c=fi.value)==null||c.focus()}catch(f){wn.value=f instanceof Error?f.message:a("Failed to start Codex login")}finally{Mr.value=!1}}}function Sd(){Ln.value||(Ya.value=!1,$r.value="")}async function vw(){const c=$r.value.trim();c&&await gw(c)}async function gw(c){if(!(Ln.value||c.length===0)){wn.value="",Ln.value=!0;try{const f=await I_(c);jn.value=f.accounts,Ia.value="",$r.value="",Ya.value=!1,zo(),gn(),z({includeSelectedThreadMessages:!0})}catch(f){wn.value=f instanceof Error?f.message:a("Failed to complete Codex login")}finally{Ln.value=!1}}}async function yw(c){if(Jo.value||bo.value||Mr.value||Ln.value||Qo.value.length>0)return;const f=jn.value.find(N=>N.storageId===c)??null;if(!f)return;if(Xo.value!==c){Xo.value=c;return}if(f.isActive&&Hl.value){wn.value=a("Finish the current turn and pending requests before removing the active account.");return}const x=f.isActive;wn.value="",Xo.value="",Qo.value=c;try{const N=await R_(c);jn.value=N.accounts,zo(),gn(),x&&z({includeSelectedThreadMessages:!0}),Gl({silent:!0})}catch(N){wn.value=N instanceof Error?N.message:a("Failed to remove account")}finally{Qo.value=""}}function ww(c){pe(c)}function bw(c){z({includeSelectedThreadMessages:!1,forceThreadRefresh:!0})}async function kw(c){const f=await Me(c);f&&(Rn.value?await Ut.replace({name:"thread",params:{threadId:f}}):await Ut.push({name:"thread",params:{threadId:f}}),ht.value&&Co(!0))}function Ep(c){const f=c.trim().replace(/\\/gu,"/");return f?f.includes("/.codex/worktrees/")||f.includes("/.git/worktrees/"):!1}function rl(c,f=""){var ve,De,on;const x=B.value.find(nr=>nr.projectName===c);if(!x)return nl(c)||f.trim();const N=x.threads.find(nr=>!Ep(nr.cwd));return(((ve=N==null?void 0:N.cwd)==null?void 0:ve.trim())??((on=(De=x.threads[0])==null?void 0:De.cwd)==null?void 0:on.trim())??"")||nl(c)||f.trim()}function Cw(c){var N,Q;const f=B.value.find(ve=>ve.projectName===c),x=rl(c,((Q=(N=f==null?void 0:f.threads[0])==null?void 0:N.cwd)==null?void 0:Q.trim())??"");x&&(Ct.value=x),ht.value&&Co(!0),!Rn.value&&Ut.push({name:"home"})}function Tw(c){var x;let f="";for(const N of B.value){const Q=N.threads.find(ve=>ve.id===c);if((x=Q==null?void 0:Q.cwd)!=null&&x.trim()){f=Q.cwd.trim();break}}!f||typeof window>"u"||window.open(`/codex-local-browse${encodeURI(f)}`,"_blank","noopener,noreferrer")}function Xc(c){var x,N;const f=B.value.find(Q=>Q.projectName===c);return rl(c,((N=(x=f==null?void 0:f.threads[0])==null?void 0:x.cwd)==null?void 0:N.trim())??"")}const Rp=X(()=>Object.fromEntries(B.value.map(c=>[c.projectName,Xc(c.projectName).trim()]).filter(([,c])=>c.length>0)));function Sw(c){return(J.value[c]??c).trim()||c}function _w(c){return Sw(c).replace(/[\\/]+/gu,"-").replace(/[\u0000-\u001f]+/gu,"").trim()||"worktree"}function xw(c){const f=Xc(c);!f||typeof window>"u"||window.open(`/codex-local-browse${encodeURI(f)}`,"_blank","noopener,noreferrer")}async function Aw(c){const f=Xc(c);await jp(f)}async function Pw(c){const f=Iw(c);await jp(f)}function Iw(c){var f;for(const x of B.value){const N=x.threads.find(Q=>Q.id===c);if((f=N==null?void 0:N.cwd)!=null&&f.trim())return N.cwd.trim()}return""}function Mp(c){if(!Number.isFinite(c)||c<=0)return"0 B";const f=["B","KB","MB","GB"];let x=c,N=0;for(;x>=1024&&N<f.length-1;)x/=1024,N+=1;return`${x>=10||N===0?x.toFixed(0):x.toFixed(1)} ${f[N]}`}function Ew(c,f){const x=URL.createObjectURL(c),N=document.createElement("a");N.href=x,N.download=f,document.body.appendChild(N),N.click(),document.body.removeChild(N),window.setTimeout(()=>URL.revokeObjectURL(x),3e4)}async function Rw(c,f){const N={files:[new File([c],f,{type:c.type||"application/zip"})],title:f};if(!(typeof navigator<"u"&&typeof navigator.share=="function"&&(typeof navigator.canShare!="function"||navigator.canShare(N))))throw new Error("File sharing is not supported in this browser.");await navigator.share(N)}function $p(){xt.value.phase!=="exporting"&&(xt.value={phase:"idle",loaded:0,total:null,blob:null,fileName:"",error:""})}function Mw(){const{blob:c,fileName:f}=xt.value;!c||!f||(xt.value={...xt.value,error:""},Ew(c,f))}async function $w(){const{blob:c,fileName:f}=xt.value;if(!(!c||!f))try{xt.value={...xt.value,error:""},await Rw(c,f)}catch(x){if(x instanceof DOMException&&x.name==="AbortError")return;const N=x instanceof Error?x.message:"",Q=x instanceof DOMException&&x.name==="NotAllowedError"||/permission denied|notallowed|not allowed|gesture/iu.test(N);xt.value={...xt.value,error:Q?a("This browser blocked sharing the ZIP. Use Download instead."):N||a("Failed to share project. Use Download instead.")}}}async function jp(c){if(!(!c||typeof document>"u")){xt.value={phase:"exporting",loaded:0,total:null,blob:null,fileName:"",error:""};try{const{blob:f,fileName:x}=await yx(c,({loaded:N,total:Q})=>{xt.value={...xt.value,phase:"exporting",loaded:N,total:Q}});xt.value={phase:"ready",loaded:f.size,total:f.size,blob:f,fileName:x,error:""}}catch(f){if(xt.value={phase:"idle",loaded:0,total:null,blob:null,fileName:"",error:""},f instanceof DOMException&&f.name==="AbortError")return;const x=f instanceof Error?f.message:"Failed to export project.";window.alert(x)}}}async function jw(c){const f=Xc(c);if(!f||typeof window>"u"||(await Zc(f),Sn.value[f]!==!0))return;const x=`${_w(c)}-`,N=window.prompt("New worktree folder name",x);if(N===null)return;const Q=N.trim();if(Q){if(Q.includes("/")||Q.includes("\\")||Q==="."||Q===".."){window.alert("Worktree name must be a single folder name.");return}try{const ve=await rx(f,Q),De=await fu(ve.cwd,{createIfMissing:!1,label:""});if(!De)return;Ct.value=De,Fn.value="local",ut(Si(De)),await Ds(),await la(),ht.value&&Co(!0),Rn.value||await Ut.push({name:"home"})}catch(ve){const De=ve instanceof Error?ve.message:"Failed to create worktree.";window.alert(De)}}}function Lw(){var x,N,Q;const c=ce.value;if(!c)return"";const f=((x=c.projectName)==null?void 0:x.trim())??"";return f?rl(f,((Q=c.cwd)==null?void 0:Q.trim())??""):((N=c.cwd)==null?void 0:N.trim())??""}function _d(){const c=Lw();c&&(Ct.value=c),Fn.value="local",ht.value&&Co(!0),!Rn.value&&Ut.push({name:"home"})}function Nw(){Ct.value="",Fn.value="local",ht.value&&Co(!0),!Rn.value&&Ut.push({name:"home"})}async function Zc(c){const f=c.trim();if(!f||Object.prototype.hasOwnProperty.call(Sn.value,f))return;const x=sn.get(f);if(x){const ve=await x;Object.prototype.hasOwnProperty.call(Sn.value,f)||(Sn.value={...Sn.value,[f]:ve});return}const N=ix(f).then(ve=>ve.isGitRepo).catch(()=>!1).finally(()=>{sn.delete(f)});sn.set(f,N);const Q=await N;Object.prototype.hasOwnProperty.call(Sn.value,f)||(Sn.value={...Sn.value,[f]:Q})}function Ow(c){za(c.projectName,c.displayName)}function Dw(c){Ve(c.threadId,c.title)}async function Fw(c){await Cr(c),await Ds(),la()}function Uw(c){Qt(c.projectName,c.toIndex)}function Bw(c){var N,Q;const f=B.value.find(ve=>ve.projectName===c),x=rl(c,((Q=(N=f==null?void 0:f.threads[0])==null?void 0:N.cwd)==null?void 0:Q.trim())??"");Zc(x)}function Lp(c){qw(c)}async function qw(c){var N;const f=await uo(c),x=((N=c.followUpMessageText)==null?void 0:N.trim())??"";if(!(!f||!x||Rn.value))try{await gt(x,[],[],"steer",[])}catch{}}async function zw(c){const f=await rt(c.threadId,c.turnIndex);f&&(await Ut.push({name:"thread",params:{threadId:f}}),de.value!==f&&await ie(f),ht.value&&Co(!0))}function Co(c){var f;if(Bt.value!==c){if(c){const x=(f=ol())==null?void 0:f.scrollTop;typeof x=="number"&&(x>0||go===0)&&(go=x)}Bt.value=c,e0(c),c||Yc()}}function Np(c){if(c.defaultPrevented)return;if(c.key==="Escape"&&jt.value){jt.value=!1;return}if(!c.ctrlKey&&!c.metaKey||c.shiftKey||c.altKey)return;const f=c.key.toLowerCase();if(f==="b"){if(!(Ho()?c.metaKey&&!c.ctrlKey:c.ctrlKey&&!c.metaKey))return;c.preventDefault(),Co(!Bt.value);return}if(f==="j"&&Et.name==="thread"&&de.value){c.preventDefault(),Op();return}f==="j"&&Rn.value&&mn.value&&(c.preventDefault(),Op())}function Op(){el.value&&(ht.value&&!Mn.value&&(Mn.value=!0),ht.value||(Io.value=!1),$t.value=$t.value==="terminal"?"git":"terminal",$t.value!=="terminal"&&xi())}function _i(c){$t.value=c,Xn.value=!1,ht.value||(Io.value=!1),ht.value&&(Mn.value=!0),c!=="terminal"&&xi()}function Hw(c){const f=zn.value.find(x=>x.path===c.path);if(f)po.value=f.key;else{const x={key:`preview-${Date.now()}`,path:c.path,label:c.label};zn.value=[...zn.value,x],po.value=x.key}_i("preview")}function Ww(c){zn.value.some(f=>f.key===c)&&(po.value=c,_i("preview"))}function Vw(c){const f=zn.value.findIndex(Q=>Q.key===c);if(f<0)return;const x=zn.value.filter(Q=>Q.key!==c);if(zn.value=x,po.value!==c)return;if(x.length===0){po.value="",$t.value="files";return}const N=x[Math.min(f,x.length-1)];po.value=N.key}function Dp(){if(ht.value){Mn.value=!1;return}Io.value=!0,Xn.value=!1,xi()}function Gw(){if(ht.value){Mn.value=!Mn.value;return}Io.value=!Io.value,Io.value&&(Xn.value=!1,xi())}function Kw(){$t.value="git",ht.value&&(Mn.value=!1),xi()}function Yw(c){if(Qn.value=c,!c){Po.value=!1,eu();return}Po.value=!0,eu(),Ar=setTimeout(()=>{Ar=null,Ci.value||(Po.value=!1)},1500)}function xi(){Qn.value=!1,Po.value=!1,eu()}function eu(){Ar&&(clearTimeout(Ar),Ar=null)}async function Jw(){try{const c=await S_();Pt.value=c.available,!c.available&&$t.value==="terminal"&&($t.value="git",xi())}catch{Pt.value=!1,$t.value==="terminal"&&($t.value="git")}}function Fp(c){var x,N;const f=c.target;if(f instanceof Node){if(Qn.value){const Q=f instanceof Element?f:f.parentElement;Q!=null&&Q.closest(".thread-terminal-panel")||xi()}jt.value&&((x=Go.value)!=null&&x.contains(f)||(N=Jr.value)!=null&&N.contains(f)||(Ta=Date.now(),jt.value=!1))}}function Qw(c){var x,N;if(!jt.value)return;const f=c.target;f instanceof Node&&((x=Go.value)!=null&&x.contains(f)||(N=Jr.value)!=null&&N.contains(f)||(Ta=Date.now(),jt.value=!1))}function Xw(){var c;(c=dn.value)==null||c.openRecycleBin()}function Up(){if(!(typeof document>"u")&&ht.value){if(document.visibilityState==="hidden"){gi.value=Date.now(),Rs.value=!1;return}xd()}}function Bp(c){c.persisted&&xd()}function qp(){Et.name==="home"&&(Ds(),la()),xd()}function xd(){typeof window>"u"||typeof document>"u"||!ht.value||document.visibilityState!=="visible"||Rs.value||gi.value===null||Date.now()-gi.value<QU||(Rs.value=!0,gi.value=null,Zw())}async function Zw(){if(!Ki.value){Ki.value=!0;try{await z({includeSelectedThreadMessages:!0,awaitAncillaryRefreshes:!0}),await Od()}finally{Ki.value=!1}}}function zp(c){const f=c.text;tu();const x=Wa.value,N=c.mode==="queue"&&x&&x.threadId===de.value?x.queueIndex:void 0;if(Wa.value=null,Rn.value){a0(f,c.imageUrls,c.skills,c.fileAttachments);return}gt(f,c.imageUrls,c.skills,c.mode,c.fileAttachments,N)}function eb(c){const f=W.value.findIndex(ve=>ve.id===c),x=f>=0?W.value[f]:void 0,N=Ao.value;if(!x||!N||N.hasUnsavedDraft()&&!window.confirm("Replace the current draft with this queued message for editing?"))return;Wa.value=de.value?{threadId:de.value,queueIndex:f}:null;const Q={text:x.text,imageUrls:[...x.imageUrls],fileAttachments:x.fileAttachments.map(ve=>({...ve})),skills:x.skills.map(ve=>({...ve}))};N.hydrateDraft(Q),Y(c)}function tu(){if(!ht.value||Rn.value)return;const c=()=>{var f;(f=ka.value)==null||f.jumpToLatest()};c(),Wt(()=>{c(),!(typeof window>"u")&&window.requestAnimationFrame(()=>{c(),window.requestAnimationFrame(c)})})}function tb(c){Ct.value=c.trim(),bn.value=""}function nb(c){mo.value=c.trim()}function Os(c){const f=mn.value.trim();return!c||f!==c?!1:Et.name==="thread"||Et.name==="home"&&ns.value}function Hp(){ne+=1,Pe+=1,Ge+=1,qt+=1,pr.value=[],Zr.value=null,xa.value=null,hr.value=null,Aa.value=null,Mo.value=!1,Ga.value=!1,Er.value={addedLineCount:0,removedLineCount:0},wo.value=[],qe.value={},ke.value="",Un.value="",Pa.value={},mr.value="",_s.value="",Rr.value="",cn.value=!1}function Wp(c){const f=c.trim();if(!f){Er.value={addedLineCount:0,removedLineCount:0};return}const x=++qt;fx(f,"unstaged").then(N=>{x!==qt||!Os(f)||(Er.value={addedLineCount:N.addedLineCount,removedLineCount:N.removedLineCount})}).catch(()=>{x!==qt||!Os(f)||(Er.value={addedLineCount:0,removedLineCount:0})})}async function Kl(c){var N,Q,ve;const f=c.trim();if(!f){Hp();return}const x=++ne;cn.value=!0,Rr.value="";try{const De=await sx(f);if(x!==ne||!Os(f))return;pr.value=De.options,Zr.value=De.currentBranch,xa.value=De.headSha,hr.value=De.headSubject,Aa.value=De.headDate,Mo.value=De.detached,Ga.value=De.dirty,wo.value=De.changedFiles,Wp(f);const on=((N=De.currentBranch)==null?void 0:N.trim())||((ve=(Q=De.options[0])==null?void 0:Q.value)==null?void 0:ve.trim())||"";on&&Vp({branch:on,includeResetHistory:!0})}catch{if(x!==ne||!Os(f))return;pr.value=[],Zr.value=null,xa.value=null,hr.value=null,Aa.value=null,Mo.value=!1,Ga.value=!1,Er.value={addedLineCount:0,removedLineCount:0},wo.value=[]}finally{x===ne&&(cn.value=!1)}}function ob(c){Zr.value=c.currentBranch,xa.value=c.headSha,hr.value=c.headSubject,Aa.value=c.headDate,Mo.value=c.detached,Ga.value=c.dirty,wo.value=c.changedFiles,Wp(mn.value)}function rb(c){if(ea.value)return;const f=c.trim();if(!f||f===(Zr.value??""))return;const x=mn.value.trim();x&&(ea.value=!0,Rr.value="",lx(x,f).then(N=>(Zr.value=N||f,xa.value=null,hr.value=null,Aa.value=null,Mo.value=!1,Gn.value=!1,Kl(x))).catch(N=>{const Q=N instanceof Error?N.message:"Failed to switch branch";Kl(x).finally(()=>{Rr.value=Q})}).finally(()=>{ea.value=!1}))}function ab(c){if(ea.value)return;const f=c.branch.trim(),x=c.sha.trim(),N=mn.value.trim();!f||!x||!N||(ea.value=!0,Rr.value="",dx(N,f,x).then(Q=>(ob(Q),Gn.value=!1,Kl(N))).catch(Q=>{const ve=Q instanceof Error?Q.message:"Failed to reset branch to commit";Kl(N).finally(()=>{Rr.value=ve})}).finally(()=>{ea.value=!1}))}function Vp(c){const f=(typeof c=="string"?c:c.branch).trim(),x=typeof c=="string"?!0:c.includeResetHistory!==!1,N=mn.value.trim(),Q=jl(f,x);if(!f||!N||ke.value===Q||(Un.value="",qe.value[Q]))return;const ve=++Pe;ke.value=Q,cx(N,f,{includeResetHistory:x}).then(De=>{ve!==Pe||!Os(N)||(qe.value={...qe.value,[Q]:De})}).catch(De=>{ve!==Pe||!Os(N)||(Un.value=De instanceof Error?De.message:"Failed to load branch commits")}).finally(()=>{ve===Pe&&ke.value===Q&&(ke.value="")})}function sb(c){const f=c.trim(),x=mn.value.trim();if(!f||!x||mr.value===f||(_s.value="",Pa.value[f]))return;const N=++Ge;mr.value=f,ux(x,f).then(Q=>{N!==Ge||!Os(x)||(Pa.value={...Pa.value,[f]:Q})}).catch(Q=>{N!==Ge||!Os(x)||(_s.value=Q instanceof Error?Q.message:"Failed to load commit files")}).finally(()=>{N===Ge&&mr.value===f&&(mr.value="")})}function ib(c){const f=c.path.trim(),x=c.sha.trim();!f||!x||(Ir.value=f,Xr.value=x,Gn.value=!0)}function lb(){Ir.value="",Xr.value="",Gn.value=!Gn.value}function cb(){!Ir.value&&!Xr.value||(Ir.value="",Xr.value="",Gn.value=!1)}async function ub(){const c=await ou();c&&(await la(),Ps.value=c,hi.value=pn.value.trim()||"New Project (1)",mi.value="",Ma.value="",jo.value="create",Nr.value=!0,Wt(()=>{var f;return(f=Nl.value)==null?void 0:f.focus()}))}function nu(){Lo.value||(Nr.value=!1,Ma.value="")}let Ad=!1,Pd=!1;function db(){Ad=!0}function fb(){Ad&&(Ad=!1,al())}function pb(){Pd=!0}function hb(){Pd&&(Pd=!1,nu())}async function mb(){const c=Ps.value.trim(),f=hi.value.trim();if(!E.value)throw new Error("Enter a single project folder name.");const x=Jp(Yp(c,f));return x?fu(x,{createIfMissing:!0,label:""}):""}async function vb(){const c=Ps.value.trim(),f=mi.value.trim();return f?kx(f,c):""}async function Id(){if(!(!L.value||Lo.value)){Ma.value="",Lo.value=!0;try{const c=jo.value==="clone"?await vb():await mb();if(!c)return;Ct.value=c,ut(Si(c)),await Ds(),await la(),Nr.value=!1}catch(c){Ma.value=c instanceof Error?c.message:"Failed to create or clone project."}finally{Lo.value=!1}}}function gb(){yb(jc.value)}function yb(c){Is.value||!c||(c.value="",c.click())}async function wb(c,f,x){Is.value=!0;try{const N=await ou();if(!N)return;const Q=await f(N);if(!Q.path)return;Ct.value=Q.path,ut(Si(Q.path)),await Ds(),await z({includeSelectedThreadMessages:!1,forceThreadRefresh:!0}),await la()}catch(N){const Q=N instanceof Error?N.message:x;window.alert(Q)}finally{Is.value=!1,c&&(c.value="")}}async function bb(c){var N;const f=c.target instanceof HTMLInputElement?c.target:null,x=((N=f==null?void 0:f.files)==null?void 0:N[0])??null;!x||Is.value||await wb(f,Q=>wx(x,Q),"Failed to import project.")}async function kb(){const c=Ct.value.trim()||await ou();c&&(Kt.value=!1,$a.value=!0,Dr.value="",await Fs(c),Bn.value||Wt(()=>{var f;return(f=Lc.value)==null?void 0:f.focus()}))}function al(){wi+=1,$a.value=!1,No.value=!1,Bn.value="",Dr.value="",ja.value="",Yl()}async function Cb(c){!c||No.value||(Dr.value="",await Fs(c))}function Tb(){const c=Or.value.trim();!$a.value||!c||Fs(c)}function Sb(){const c=q.value;!$a.value||!c||No.value||Fs(c)}function _b(){if(!$a.value||No.value||ko.value)return;const c=q.value,f=Or.value.trim();!c||c===f||Fs(c)}function xb(){const c=q.value,f=Or.value.trim();if(c){if(c!==f){Fs(c);return}Ed(c)}}async function Ed(c=q.value){const f=ot(c).trim();if(f){Bn.value="",ko.value=!0;try{const x=await fu(f,{createIfMissing:!1,label:""});if(!x){Bn.value="Failed to open the selected folder.";return}Ct.value=x,ut(Si(x)),await Ds(),await z({includeSelectedThreadMessages:!1,forceThreadRefresh:!0}),await la(),al()}catch(x){Bn.value=x instanceof Error?x.message:"Failed to open the selected folder."}finally{ko.value=!1}}}async function Ab(){if(bn.value="",Kt.value){Yl();return}if(!$a.value){const c=Ct.value.trim()||await ou();if(!c||($a.value=!0,Dr.value="",await Fs(c),Bn.value))return}Bn.value||(Nn.value=pn.value,Kt.value=!0,Wt(()=>{var c;return(c=Ka.value)==null?void 0:c.focus()}))}function Yl(){bn.value="",Nn.value="",Kt.value=!1}async function Gp(){const c=Nn.value.trim();if(!c)return;if(bn.value="",Bn.value){bn.value="Reload the current folder before creating a new one.";return}tr.value=!0;const f=m.value.trim(),x=Jp(Yp(f,c));if(!x){bn.value="Unable to determine where the new folder should be created.",tr.value=!1;return}if(!b.value){bn.value="Enter a single folder name.",tr.value=!1;return}try{const N=await bx(x);if(!N){bn.value="Failed to create the folder.";return}bn.value="",Dr.value="",await Fs(N),Yl()}catch(N){bn.value=N instanceof Error?N.message:"Failed to create folder."}finally{tr.value=!1}}async function Pb(){var f;if(typeof window>"u")return!1;const c=((f=new URLSearchParams(window.location.search).get("openProjectPath"))==null?void 0:f.trim())??"";if(!c)return!1;try{const x=await fu(c,{createIfMissing:!1,label:""});if(!x)return!1;Ct.value=x,ut(Si(x)),await Ut.replace({name:"home"}),await Ds();const N=new URL(window.location.href);return N.searchParams.delete("openProjectPath"),window.history.replaceState({},"",N.toString()),!0}catch{return!1}}async function ou(){const c=Kp();if(c)return c;try{const f=await jm();if(f)return Xt.value=f,f}catch{}return""}async function la(){const c=Kp();if(!c){pn.value="New Project (1)";return}try{const f=await Tx(c);pn.value=f.name||"New Project (1)"}catch{pn.value="New Project (1)"}}function Kp(){var x,N;const c=Ct.value.trim();if(c)return Cl(c);const f=((N=(x=Vl.value[0])==null?void 0:x.value)==null?void 0:N.trim())??"";return f?Cl(f):Xt.value.trim()}async function Ib(){try{Xt.value=await jm()}catch{Xt.value=""}}async function Ds(){try{const c=await pl();Wn.value={order:[...c.order],labels:{...c.labels},projectOrder:[...c.projectOrder]}}catch{Wn.value={order:[],labels:{},projectOrder:[]}}}async function Fs(c){const f=++wi,x=ot(c).trim();ja.value=x,Or.value=x,Bn.value="",No.value=!0;try{const N=await px(c,{showHidden:vi.value});if(f!==wi)return;ja.value=N.path,Or.value=N.path,aa.value=N.parentPath,Ol.value=N.entries}catch(N){if(f!==wi)return;Bn.value=N instanceof Error?N.message:"Failed to load local folders.",aa.value=Cl(Or.value),Ol.value=[],Yl()}finally{f===wi&&(No.value=!1)}}function Yp(c,f){const x=ot(c).trim(),N=ot(f).trim().replace(/^[\\/]+/u,"");if(!x||!N)return"";const Q=x.includes("\\")&&!x.includes("/")?"\\":"/";if(/^[a-zA-Z]:[\\/]?$/u.test(x))return`${x.slice(0,2)}${Q}${N}`;if(/^\/+$/u.test(x))return`/${N}`;const ve=x.replace(/[\\/]+$/u,"");return ve?`${ve}${Q}${N}`:""}function Jp(c){const f=ot(c).trim();if(!f)return"";const x=f.match(/^\\\\([^\\/]+)[\\/]+([^\\/]+)([\\/].*)?$/u);if(x){const[,Q,ve,De=""]=x,on=Rd(De.split(/[\\/]+/u));return on.length>0?`\\\\${Q}\\${ve}\\${on.join("\\")}`:`\\\\${Q}\\${ve}`}const N=f.match(/^([a-zA-Z]:)([\\/].*)?$/u);if(N){const[,Q,ve=""]=N,De=f.includes("\\")&&!f.includes("/")?"\\":"/",on=Rd(ve.split(/[\\/]+/u));return on.length>0?`${Q}${De}${on.join(De)}`:`${Q}${De}`}if(f.startsWith("/")){const Q=Rd(f.split("/"));return Q.length>0?`/${Q.join("/")}`:"/"}return f}function Rd(c){const f=[];for(const x of c){const N=x.trim();if(!(!N||N===".")){if(N===".."){f.length>0&&f.pop();continue}f.push(N)}}return f}function Eb(c){me(c.draggedId,c.targetId)}function Qp(c){Kn(yr.value,c)}function Xp(c){lo(c)}function Zp(c){co(c)}function Rb(){Tt()}const Jl=A("");let Md=null;nt(Tn,c=>{var f;c&&(c.text&&((f=Ao.value)==null||f.hydrateDraft({text:c.text,imageUrls:c.imageUrls,fileAttachments:c.fileAttachments,skills:c.skills})),Jl.value=c.text?a("Stopped: message not submitted, restored to input."):a("Stopped: message not submitted."),Md&&clearTimeout(Md),Md=setTimeout(()=>{Jl.value=""},6e3),H(yr.value))});function eh(c){var x,N;const f=de.value.trim();switch(c){case"compact":f&&se(f);break;case"review":if(!f)return;Ir.value="",Xr.value="",Gn.value=!0;break;case"rename":f&&((N=dn.value)==null||N.openRenameThreadDialog(f,((x=ce.value)==null?void 0:x.title)??""));break;case"archive":f&&pe(f);break;case"fork":f&&Me(f);break;case"new":_d();break;case"skills":gr.value||Ut.push({name:"skills"});break}}function Mb(c){const f=c.turnId.trim();if(f.length>0){const x=[...ki.value].reverse().find(N=>{var Q;return N.role==="user"&&(((Q=N.turnId)==null?void 0:Q.trim())??"")===f&&N.text.trim().length>0});x!=null&&x.text&&Ao.value&&Ao.value.appendTextToDraft(x.text)}ni(c.turnId)}function $b(){Rn.value||!de.value||(ql.value&&(Xi.value=ql.value.id),Ft("default"),tu(),gt("Implement",[],[],"steer",[],void 0,"default"))}async function jb(){if(Rn.value||gr.value||ts.value||!ce.value||ki.value.length===0)return;const c=Lb();try{await Oy(c)}catch{}}function Lb(){var x,N,Q;const c=[],f=((N=(x=ce.value)==null?void 0:x.title)==null?void 0:N.trim())||"Untitled thread";c.push(`# ${Nb(f)}`),c.push(""),c.push(`- Exported: ${new Date().toISOString()}`),c.push(`- Thread ID: ${((Q=ce.value)==null?void 0:Q.id)??""}`),c.push(""),c.push("---"),c.push("");for(const ve of ki.value){const De=ve.role?ve.role.toUpperCase():"MESSAGE";c.push(`## ${De}`),c.push("");const on=ve.text.trim();if(on&&(c.push(on),c.push("")),ve.commandExecution&&(c.push("```text"),c.push(`command: ${ve.commandExecution.command}`),c.push(`status: ${ve.commandExecution.status}`),ve.commandExecution.cwd&&c.push(`cwd: ${ve.commandExecution.cwd}`),ve.commandExecution.exitCode!==null&&c.push(`exitCode: ${ve.commandExecution.exitCode}`),c.push(ve.commandExecution.aggregatedOutput||"(no output)"),c.push("```"),c.push("")),ve.fileAttachments&&ve.fileAttachments.length>0){c.push("Attachments:");for(const nr of ve.fileAttachments)c.push(`- ${nr.path}`);c.push("")}if(ve.images&&ve.images.length>0){c.push("Images:");for(const nr of ve.images)c.push(`- ${nr}`);c.push("")}}return`${c.join(`
|
|
84
84
|
`).trimEnd()}
|
|
85
85
|
`}function Nb(c){return c.replace(/([\\`*_{}\[\]()#+\-.!])/g,"\\$1")}function $d(c,f){if(typeof window>"u")return f;const x=window.localStorage.getItem(c);return x===null?f:x==="1"}function Ob(){if(typeof window>"u")return"system";const c=window.localStorage.getItem(Pv);return c==="light"||c==="dark"?c:"system"}function Db(){if(typeof window>"u")return"steer";const c=window.localStorage.getItem(Av);return c==="steer"||c==="queue"?c:"queue"}function Fb(){if(typeof window>"u")return"standard";const c=window.localStorage.getItem(Mv);return c==="standard"||c==="wide"||c==="extra-wide"?c:"standard"}function Ub(){ta.value=!ta.value,window.localStorage.setItem(xv,ta.value?"1":"0")}function Bb(){Ea.value=Ea.value==="steer"?"queue":"steer",window.localStorage.setItem(Av,Ea.value)}function qb(){const c=["system","light","dark"],f=c.indexOf(na.value);na.value=c[(f+1)%c.length],window.localStorage.setItem(Pv,na.value),ru()}function zb(){const c=["standard","wide","extra-wide"],f=c.indexOf(Ja.value);Ja.value=c[(f+1)%c.length],window.localStorage.setItem(Mv,Ja.value)}function Hb(){Zo.value=!Zo.value,window.localStorage.setItem(Iv,Zo.value?"1":"0")}function Wb(){oa.value=!oa.value,window.localStorage.setItem(Ev,oa.value?"1":"0")}async function Vb(c){if(!Lr.value){Lr.value=!0;try{if(c==="codex"){xn.value="codex";const f=await Em(!1);jr.value=f.enabled}else if(c==="openrouter"){xn.value="openrouter";const f=await Em(!0);jr.value=f.enabled,await ll("","",{wireApi:k.value,provider:"openrouter"})}else c==="opencode-zen"?(xn.value="opencode-zen",await ll("",C.value.trim(),{wireApi:"responses",provider:"opencode-zen"}),jr.value=!0):c==="custom"&&(xn.value="custom",er.value.trim()&&Za.value.trim()&&(await ll(er.value.trim(),Za.value.trim(),{wireApi:w.value}),jr.value=!0));oo.value="",await z({includeSelectedThreadMessages:!1,providerChanged:!0,awaitAncillaryRefreshes:!0})}catch(f){oo.value=f instanceof Error?f.message:"Failed to switch provider"}finally{Lr.value=!1}}}async function jd(){if(Jt.value)return;const c=er.value.trim();if(c){Jt.value=!0;try{oo.value="",await ll(c,Za.value.trim(),{wireApi:w.value}),jr.value=!0;const f=await Im();f.provider==="custom"&&!f.currentModel&&(oo.value=a("Failed to resolve model from custom endpoint; check the URL and try again")),await z({includeSelectedThreadMessages:!1,providerChanged:!0,awaitAncillaryRefreshes:!0})}catch(f){oo.value=f instanceof Error?f.message:"Failed to save custom endpoint"}finally{Jt.value=!1}}}async function th(c){if(Jt.value||Lr.value||k.value===c)return;const f=k.value;k.value=c,Jt.value=!0;try{oo.value="",await ll("","",{wireApi:c,provider:"openrouter"}),jr.value=!0,await z({includeSelectedThreadMessages:!1,providerChanged:!0,awaitAncillaryRefreshes:!0})}catch(x){k.value=f,oo.value=x instanceof Error?x.message:"Failed to save OpenRouter API format"}finally{Jt.value=!1}}async function nh(){if(Jt.value)return;const c=C.value.trim();if(c){Jt.value=!0;try{oo.value="",await ll("",c,{wireApi:"responses",provider:"opencode-zen"}),jr.value=!0,await z({includeSelectedThreadMessages:!1,providerChanged:!0,awaitAncillaryRefreshes:!0})}catch(f){oo.value=f instanceof Error?f.message:"Failed to save OpenCode Zen config"}finally{Jt.value=!1}}}async function oh(){if(!Jt.value){Jt.value=!0;try{const c=ra.value.trim();await Rm(c),ra.value="",await Ld(),await z({includeSelectedThreadMessages:!1})}catch{}finally{Jt.value=!1}}}async function Gb(){if(!Jt.value){Jt.value=!0;try{await Rm(""),ra.value="",await Ld(),await z({includeSelectedThreadMessages:!1})}catch{}finally{Jt.value=!1}}}async function Ld(){try{const c=xn.value,f=await Im();jr.value=f.enabled,Xa.value=f.customKey??!1,Gi.value=f.maskedKey??null,f.enabled?f.provider==="opencode-zen"?xn.value="opencode-zen":f.provider==="custom"?(xn.value="custom",er.value=f.customBaseUrl??"",w.value=f.wireApi==="chat"?"chat":"responses"):(xn.value="openrouter",k.value=f.wireApi==="chat"?"chat":"responses"):xn.value="codex",Yi=f.hasCodexAuth===!0,Yi||(Ul=!1);const x=xn.value!==c;x&&await z({includeSelectedThreadMessages:!1,providerChanged:!0,awaitAncillaryRefreshes:!0});const N=await wr();N&&await z({includeSelectedThreadMessages:!1,providerChanged:x||N,awaitAncillaryRefreshes:!0})}catch{}}function Kb(c){const x=Nd(c.trim())||"auto";Ra.value=x,window.localStorage.setItem(Rv,x)}function Yb(c){Ze(Number(c))}const Jb=[{value:"0",label:a("Off")},{value:"5",label:"5%"},{value:"10",label:"10%"},{value:"15",label:"15%"},{value:"20",label:"20%"},{value:"25",label:"25%"}];function Qb(){var x;if(typeof window>"u")return"auto";const c=((x=window.localStorage.getItem(Rv))==null?void 0:x.trim())||"auto";return Nd(c)||"auto"}function Xb(){const c=[{value:"auto",label:a("Auto-detect")}],f=new Set(["auto"]);function x(Q){const ve=j[Q]||Q;return`${ve.charAt(0).toUpperCase()+ve.slice(1)} (${Q})`}for(const Q of typeof navigator<"u"?navigator.languages??[]:[]){const ve=Nd(Q);!ve||f.has(ve)||(f.add(ve),c.push({value:ve,label:`${a("Preferred")}: ${x(ve)}`}))}for(const Q of Object.keys(j))f.has(Q)||(f.add(Q),c.push({value:Q,label:x(Q)}));const N=Ra.value.trim();return N&&!f.has(N)&&c.push({value:N,label:x(N)}),c}function Nd(c){const f=c.trim().toLowerCase();if(!f||f==="auto")return"";if(f in j)return f;const x=f.split("-")[0]??f;return x in j?x:""}function ru(){const c=document.documentElement;if(na.value==="dark")c.classList.add("dark");else if(na.value==="light")c.classList.remove("dark");else{const f=window.matchMedia("(prefers-color-scheme: dark)").matches;c.classList.toggle("dark",f)}}function Zb(){return typeof window>"u"?!1:window.localStorage.getItem(Cv)==="1"}function e0(c){typeof window>"u"||window.localStorage.setItem(Cv,c?"1":"0")}function t0(){if(typeof window>"u")return!0;const c=window.localStorage.getItem(Tv);return c===null?!0:c==="1"}function n0(){Qr.value=!Qr.value,!(typeof window>"u")&&window.localStorage.setItem(Tv,Qr.value?"1":"0")}function o0(c,f){const x=(c??"").trim();return x.length>0?x:f.trim()||"message"}function rh(c){Ft(c)}async function r0(){await Ut.isReady(),Et.name==="thread"&&es.value?bs(es.value):(Et.name==="home"||Et.name==="skills"||Et.name==="automations")&&bs("",{persist:!1}),await z({includeSelectedThreadMessages:Et.name==="thread"}),Gl({silent:!0}),await Pb(),ur.value=!0,await Od(),gn()}async function Od(){if(Ca.value){_r=!0;return}Ca.value=!0;try{do{if(_r=!1,Et.name==="home"||Et.name==="skills"||Et.name==="automations"){de.value!==""&&await ie("");continue}if(Et.name==="thread"){const c=es.value;if(!c)continue;if(de.value!==c){if(await ie(c)==="not-found")continue}else re(c,{silent:!0}).catch(()=>{})}}while(_r)}finally{Ca.value=!1}}nt(()=>[Et.name,es.value,Qe.value,de.value],async()=>{ur.value&&await Od()}),nt(()=>[de.value,mn.value],()=>{cb()}),nt(()=>[Et.name,mn.value],([c,f])=>{c==="thread"&&Zc(f)},{immediate:!0}),nt(()=>de.value,async c=>{if(ur.value&&!Ca.value&&!(Rn.value||gr.value||ts.value)){if(!c){Et.name!=="home"&&await Ut.replace({name:"home"});return}Et.name==="thread"&&es.value===c||await Ut.replace({name:"thread",params:{threadId:c}})}}),nt(()=>Vl.value,c=>{if(c.length===0){Ct.value="",la();return}const f=Ct.value.trim();f&&(c.some(N=>N.value===f)||(Ct.value="")),la()},{immediate:!0}),nt(()=>Ct.value,()=>{yn.value={phase:"idle",title:"",message:""},la()}),nt(()=>[Et.name,Ct.value],([c,f])=>{c==="home"&&Zc(f)},{immediate:!0}),nt(ns,c=>{!c&&Fn.value==="worktree"&&(Fn.value="local")},{immediate:!0}),nt(()=>[Fn.value,Ct.value],([c,f])=>{c!=="worktree"||!ns.value||ah(f)},{immediate:!0}),nt(()=>Fn.value,c=>{var f;if(c==="local"){yn.value={phase:"idle",title:"",message:""};const x=Ct.value.trim();if(x&&Ep(x)){const N=((f=ce.value)==null?void 0:f.projectName)??br(x),Q=rl(N,"");Q&&(Ct.value=Q)}return}ns.value&&ah(Ct.value)}),nt(()=>Et.name,c=>{c!=="home"&&(yn.value={phase:"idle",title:"",message:""}),c!=="thread"&&(Gn.value=!1)}),nt(()=>de.value,()=>{yn.value={phase:"idle",title:"",message:""}}),nt(()=>[Et.name,mn.value,ns.value],([c,f,x])=>{if(!(c==="thread"||c==="home"&&x)){Hp();return}Pe+=1,qe.value={},ke.value="",Un.value="",Kl(f)},{immediate:!0}),nt(Ji,c=>{typeof document>"u"||(document.title=c)},{immediate:!0}),nt(ht,c=>{c&&!Bt.value&&Co(!0)},{immediate:!0});async function a0(c,f=[],x=[],N=[]){try{yn.value={phase:"idle",title:"",message:""};let Q=Ct.value;if(Fn.value==="worktree"){yn.value={phase:"running",title:a("Creating worktree"),message:a("Creating a worktree and running setup.")};try{const De=await ox(Ct.value,mo.value);Q=De.cwd,Ct.value=De.cwd,yn.value={phase:"idle",title:"",message:""}}catch{yn.value={phase:"error",title:a("Worktree setup failed"),message:a("Unable to create worktree. Try again or switch to Local project.")};return}}else if(!Q.trim()){const De=await Cx(c);Q=De.cwd,Ct.value=De.cwd}const ve=await It(c,Q,f,x,N);if(!ve)return;await Ut.replace({name:"thread",params:{threadId:ve}}),tu()}catch{}}function s0(c){var N;if((N=c.prompt)!=null&&N.trim())return c.prompt.trim();const f=c.displayName.trim()||c.name.trim(),x=c.kind==="skill"?"skill":c.kind==="plugin"?"plugin":c.kind==="composio"?"Composio connector":"app";return`Test ${f} ${x}. Give me a list of what it can do and one useful example.`}function i0(c){return`${c.kind}:${c.name}:${c.skillPath??""}`}async function l0(c){var N;if(cr.value)return;cr.value=i0(c);const f=s0(c),x=(N=c.attachedSkills)!=null&&N.length?c.attachedSkills:c.kind==="skill"&&c.skillPath?[{name:c.name,path:c.skillPath}]:[];try{const Q=Dc.value.trim()||mn.value.trim(),ve=await It(f,Q,[],x,[]);if(!ve)return;await Ut.replace({name:"thread",params:{threadId:ve}}),tu()}catch{}finally{cr.value=""}}async function ah(c){var x;const f=c.trim();if(!f){Vo.value=[],mo.value="";return}En.value=!0;try{const N=await ax(f);Vo.value=N;const Q=mo.value.trim();if(!(Q.length>0&&N.some(De=>De.value===Q))){const De=N.find(on=>on.value.trim()==="main");mo.value=(De==null?void 0:De.value)??((x=N[0])==null?void 0:x.value)??""}}catch{Vo.value=[],mo.value=""}finally{En.value=!1}}return(c,f)=>(S(),I(ze,null,[Ie(rS,{"is-sidebar-collapsed":Bt.value,onCloseSidebar:f[47]||(f[47]=x=>Co(!0))},{sidebar:yt(()=>{var x;return[p("section",hO,[p("div",{ref_key:"sidebarScrollableRef",ref:Zn,class:"sidebar-scrollable",onScroll:Kc},[Bt.value?ee("",!0):(S(),tt(ev,{key:0,class:"sidebar-thread-controls-host","is-sidebar-collapsed":Bt.value,"show-new-thread-button":!0,onToggleSidebar:f[0]||(f[0]=N=>Co(!Bt.value)),onStartNewThread:_d},{default:yt(()=>[p("button",{class:"sidebar-search-toggle",type:"button","aria-pressed":Vn.value,"aria-label":g(a)("Search threads"),title:g(a)("Search threads"),onClick:Vc},[Ie(tv,{class:"sidebar-search-toggle-icon"})],8,mO)]),_:1},8,["is-sidebar-collapsed"])),!Bt.value&&Vn.value?(S(),I("div",vO,[Ie(tv,{class:"sidebar-search-bar-icon"}),Lt(p("input",{ref_key:"sidebarSearchInputRef",ref:vo,"onUpdate:modelValue":f[1]||(f[1]=N=>fn.value=N),class:"sidebar-search-input",type:"text",placeholder:g(a)("Filter threads..."),onKeydown:Re},null,40,gO),[[an,fn.value]]),fn.value.length>0?(S(),I("button",{key:0,class:"sidebar-search-clear",type:"button","aria-label":g(a)("Clear search"),onClick:Gc},[Ie(Ru,{class:"sidebar-search-clear-icon"})],8,yO)):ee("",!0)])):ee("",!0),Bt.value?ee("",!0):(S(),I("button",{key:2,class:Ke(["sidebar-skills-link",{"is-active":gr.value}]),type:"button",onClick:f[2]||(f[2]=N=>{g(Ut).push({name:"skills"}),g(ht)&&Co(!0)})},[p("span",wO,[Ie(Ys)]),p("span",bO,[p("span",kO,T(g(a)("Skills")),1),p("span",CO,T(g(a)("Plugins, apps, MCPs")),1)])],2)),Bt.value?ee("",!0):(S(),I("button",{key:3,class:Ke(["sidebar-skills-link",{"is-active":ts.value}]),type:"button",onClick:f[3]||(f[3]=N=>{g(Ut).push({name:"automations"}),g(ht)&&Co(!0)})},[p("span",TO,[Ie(Ys)]),p("span",SO,[p("span",_O,T(g(a)("Automations")),1),p("span",xO,T(g(a)("Scheduled work")),1)])],2)),Bt.value?ee("",!0):(S(),tt(oI,{key:4,ref_key:"sidebarThreadTreeRef",ref:dn,groups:g(B),"project-display-name-by-id":g(J),"project-git-repo-by-name":Cd.value,"project-cwd-by-name":Rp.value,"selected-thread-id":g(de),"is-loading":g(Qe),"is-thread-list-fully-loaded":g(et),"search-query":fn.value,"search-matched-thread-ids":Ko.value,onSelect:Ot,onArchive:ww,onStartNewThread:Cw,onRenameProject:Ow,onBrowseThreadFiles:Tw,onSaveThreadProject:Pw,onBrowseProjectFiles:xw,onSaveProject:Aw,onRequestProjectGitStatus:Bw,onCreateProjectWorktree:jw,onRenameThread:Dw,onForkThread:kw,onRemoveProject:Fw,onReorderProject:Uw,onCopyThreadChat:tw,onAutomationsChanged:ew,onRestoreThread:bw,onStartNewChat:Nw},null,8,["groups","project-display-name-by-id","project-git-repo-by-name","project-cwd-by-name","selected-thread-id","is-loading","is-thread-list-fully-loaded","search-query","search-matched-thread-ids"]))],544),Bt.value?ee("",!0):(S(),I("div",{key:0,ref_key:"settingsAreaRef",ref:xr,class:"sidebar-settings-area",onClick:Qw},[(S(),tt(Xs,{to:"body"},[jt.value?(S(),I("div",{key:0,class:"settings-dialog-backdrop",role:"presentation",onClick:f[21]||(f[21]=lt(N=>jt.value=!1,["self"]))},[p("div",{ref_key:"settingsPanelRef",ref:Go,class:"sidebar-settings-panel",role:"dialog","aria-modal":"true","aria-label":g(a)("Settings"),onClick:f[20]||(f[20]=lt(()=>{},["stop"]))},[p("div",PO,[p("h2",IO,T(g(a)("Settings")),1),p("button",{class:"settings-dialog-close",type:"button","aria-label":g(a)("Close"),title:g(a)("Close"),onClick:f[4]||(f[4]=N=>jt.value=!1)},[Ie(Ru,{class:"settings-dialog-close-icon"})],8,EO)]),p("div",RO,[p("nav",{class:"settings-group-nav","aria-label":g(a)("Settings groups")},[(S(),I(ze,null,_t(Pr,N=>p("button",{key:N.id,type:"button",class:Ke(["settings-group-nav-item",{"is-active":yo.value===N.id}]),"aria-current":yo.value===N.id?"true":void 0,onClick:Q=>yo.value=N.id},T(g(a)(N.label)),11,$O)),64))],8,MO),p("div",jO,[Lt(p("div",null,[Ie(Z$,{accounts:jn.value,"is-accounts-section-collapsed":Qr.value,"is-refreshing-accounts":Jo.value,"is-switching-accounts":bo.value,"is-starting-codex-login":Mr.value,"is-completing-codex-login":Ln.value,"account-action-error":wn.value,"codex-login-url":Ia.value,"feedback-mailto":g(Dn),"is-account-unavailable":Qc,"is-remove-confirmation-active":Td,"is-remove-visible":aw,"build-account-title":fw,"format-account-meta":Pp,"format-account-quota":Ip,"short-account-id":nw,"is-account-action-disabled":rw,"get-account-switch-label":sw,"get-account-remove-label":iw,"on-refresh-accounts":pw,"on-start-codex-login":mw,"on-switch-account":hw,"on-remove-account":yw,"on-account-card-pointer-enter":lw,"on-account-card-pointer-leave":cw,"toggle-accounts-section-collapsed":n0,"prepare-feedback-link":In},null,8,["accounts","is-accounts-section-collapsed","is-refreshing-accounts","is-switching-accounts","is-starting-codex-login","is-completing-codex-login","account-action-error","codex-login-url","feedback-mailto"]),p("button",{class:"sidebar-settings-row",type:"button",title:_.sendWithEnter,onClick:Ub},[p("span",NO,T(g(a)("Require ⌘ + enter to send")),1),p("span",{class:Ke(["sidebar-settings-toggle",{"is-on":!ta.value}])},null,2)],8,LO),p("button",{class:"sidebar-settings-row",type:"button",title:_.inProgressSendMode,onClick:Bb},[p("span",DO,T(g(a)("When busy, send as")),1),p("span",FO,T(Ea.value==="steer"?g(a)("Steer"):g(a)("Queue")),1)],8,OO),p("button",{class:"sidebar-settings-row",type:"button",title:_.appearance,onClick:qb},[p("span",BO,T(g(a)("Appearance")),1),p("span",qO,T(na.value==="system"?g(a)("System"):na.value==="dark"?g(a)("Dark"):g(a)("Light")),1)],8,UO),p("div",{class:"sidebar-settings-row sidebar-settings-row--select",title:g(a)("Choose the interface language for the app.")},[p("span",HO,T(g(a)("UI language")),1),Ie(or,{class:"sidebar-settings-provider-dropdown","model-value":g(l),options:g(d),placeholder:g(a)("UI language"),"menu-align":"end","onUpdate:modelValue":f[5]||(f[5]=N=>g(h)(N))},null,8,["model-value","options","placeholder"])],8,zO),p("button",{class:"sidebar-settings-row",type:"button",title:_.chatWidth,onClick:zb},[p("span",VO,T(g(a)("Chat width")),1),p("span",GO,T(Mt.value),1)],8,WO),p("button",{class:"sidebar-settings-row",type:"button",title:_.dictationClickToToggle,onClick:Hb},[p("span",YO,T(g(a)("Click to toggle dictation")),1),p("span",{class:Ke(["sidebar-settings-toggle",{"is-on":Zo.value}])},null,2)],8,KO),p("button",{class:"sidebar-settings-row",type:"button",title:_.dictationAutoSend,onClick:Wb},[p("span",QO,T(g(a)("Auto send dictation")),1),p("span",{class:Ke(["sidebar-settings-toggle",{"is-on":oa.value}])},null,2)],8,JO),p("div",{class:"sidebar-settings-row sidebar-settings-row--select",title:_.dictationLanguage},[p("span",ZO,T(g(a)("Dictation language")),1),Ie(or,{class:"sidebar-settings-language-dropdown","model-value":Ra.value,options:Qa.value,placeholder:g(a)("Auto-detect"),"open-direction":"up","enable-search":!0,"search-placeholder":g(a)("Search language..."),"onUpdate:modelValue":Kb},null,8,["model-value","options","placeholder","search-placeholder"])],8,XO),p("div",{class:"sidebar-settings-row sidebar-settings-row--select",title:g(a)("Auto-compact at or below remaining context percentage. 0 disables auto-compaction and falls back to server-side compaction.")},[p("span",t2,T(g(a)("Auto-compact before send")),1),Ie(or,{class:"sidebar-settings-auto-compact-dropdown","model-value":String(g(We)),options:Jb,placeholder:g(a)("Off"),"menu-align":"end","onUpdate:modelValue":Yb},null,8,["model-value","placeholder"])],8,e2),sa.value?(S(),I("a",{key:0,class:"sidebar-settings-row sidebar-settings-feedback-row",href:g(Dn),onClick:In},[p("span",o2,T(g(a)("Send feedback")),1),p("span",r2,T(g(a)("Issue detected")),1)],8,n2)):ee("",!0)],512),[[uu,yo.value==="general"]]),Lt(p("div",null,[p("div",{class:"sidebar-settings-row sidebar-settings-row--select",title:g(a)("Choose the API provider for the Codex backend")},[p("span",s2,T(g(a)("Provider")),1),Ie(or,{class:"sidebar-settings-provider-dropdown","model-value":xn.value,options:As.value,placeholder:g(a)("Provider"),disabled:Lr.value,"menu-align":"end","onUpdate:modelValue":Vb},null,8,["model-value","options","placeholder","disabled"])],8,a2),oo.value?(S(),I("div",i2,[p("span",null,T(oo.value),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[6]||(f[6]=N=>In(N,oo.value))},T(g(a)("Send feedback")),9,l2)])):ee("",!0),xn.value==="openrouter"?(S(),I("div",c2,[p("div",u2,[p("span",d2,T(g(a)("OpenRouter API key")),1),p("a",f2,T(g(a)("Get API key")),1)]),p("div",p2,[Xa.value&&!ra.value?(S(),I(ze,{key:0},[p("span",h2,T(Gi.value),1),p("button",{class:"sidebar-settings-key-clear",type:"button",disabled:Jt.value,title:g(a)("Remove custom key, use community keys"),onClick:Gb},"✕",8,m2)],64)):(S(),I(ze,{key:1},[Lt(p("input",{"onUpdate:modelValue":f[7]||(f[7]=N=>ra.value=N),class:"sidebar-settings-key-input",type:"password",placeholder:g(a)("sk-or-v1-... (optional, uses free keys if empty)"),onKeydown:An(oh,["enter"])},null,40,v2),[[an,ra.value]]),p("button",{class:"sidebar-settings-key-save",type:"button",disabled:Jt.value||!ra.value.trim(),onClick:oh},T(Jt.value?"...":g(a)("Set")),9,g2)],64))]),p("div",y2,[p("span",w2,T(g(a)("API format")),1),p("div",{class:"sidebar-settings-segmented",role:"group","aria-label":g(a)("OpenRouter API format")},[p("button",{type:"button",class:Ke(["sidebar-settings-segmented-option",{"is-active":k.value==="responses"}]),disabled:Jt.value||Lr.value,onClick:f[8]||(f[8]=N=>th("responses"))},T(g(a)("Responses")),11,k2),p("button",{type:"button",class:Ke(["sidebar-settings-segmented-option",{"is-active":k.value==="chat"}]),disabled:Jt.value||Lr.value,onClick:f[9]||(f[9]=N=>th("chat"))},T(g(a)("Completions")),11,C2)],8,b2)])])):ee("",!0),xn.value==="opencode-zen"?(S(),I("div",T2,[p("div",S2,[p("span",_2,T(g(a)("OpenCode Zen API key")),1),p("a",x2,T(g(a)("Get API key")),1)]),p("div",A2,[Lt(p("input",{"onUpdate:modelValue":f[10]||(f[10]=N=>C.value=N),class:"sidebar-settings-key-input",type:"password",placeholder:g(a)("sk-..."),onKeydown:An(nh,["enter"])},null,40,P2),[[an,C.value]]),p("button",{class:"sidebar-settings-key-save",type:"button",disabled:Jt.value||!C.value.trim(),onClick:nh},T(Jt.value?"...":g(a)("Save")),9,I2)])])):ee("",!0),xn.value==="custom"?(S(),I("div",E2,[p("span",R2,T(g(a)("Custom endpoint URL")),1),p("div",M2,[Lt(p("input",{"onUpdate:modelValue":f[11]||(f[11]=N=>er.value=N),class:"sidebar-settings-key-input",type:"url",placeholder:g(a)("https://api.example.com/v1"),onKeydown:An(jd,["enter"])},null,40,$2),[[an,er.value]])]),p("span",j2,T(g(a)("API key")),1),p("div",L2,[Lt(p("input",{"onUpdate:modelValue":f[12]||(f[12]=N=>Za.value=N),class:"sidebar-settings-key-input",type:"password",placeholder:g(a)("Bearer token (optional)"),onKeydown:An(jd,["enter"])},null,40,N2),[[an,Za.value]]),p("button",{class:"sidebar-settings-key-save",type:"button",disabled:Jt.value||!er.value.trim(),onClick:jd},T(Jt.value?"...":g(a)("Save")),9,O2)]),p("div",D2,[p("span",F2,T(g(a)("API format")),1),p("div",{class:"sidebar-settings-segmented",role:"group","aria-label":g(a)("Custom endpoint API format")},[p("button",{type:"button",class:Ke(["sidebar-settings-segmented-option",{"is-active":w.value==="responses"}]),onClick:f[13]||(f[13]=N=>w.value="responses")},T(g(a)("Responses")),3),p("button",{type:"button",class:Ke(["sidebar-settings-segmented-option",{"is-active":w.value==="chat"}]),onClick:f[14]||(f[14]=N=>w.value="chat")},T(g(a)("Completions")),3)],8,U2)])])):ee("",!0)],512),[[uu,yo.value==="models"]]),Lt(p("div",null,[p("button",{class:"sidebar-settings-row",type:"button","aria-live":"polite",onClick:f[15]||(f[15]=N=>D.value=!D.value)},[p("span",B2,T(g(a)("Telegram")),1),p("span",q2,T($s.value),1)]),D.value?(S(),I("div",z2,[p("label",H2,[p("span",W2,T(g(a)("Bot token")),1),Lt(p("input",{"onUpdate:modelValue":f[16]||(f[16]=N=>Ce.value=N),class:"sidebar-settings-input",type:"password",placeholder:"123456:ABCDEF",autocomplete:"off",spellcheck:"false"},null,512),[[an,Ce.value]])]),p("label",V2,[p("span",G2,T(g(a)("Allowed Telegram user IDs")),1),Lt(p("textarea",{"onUpdate:modelValue":f[17]||(f[17]=N=>st.value=N),class:"sidebar-settings-textarea",rows:"3",placeholder:`123456789
|
|
86
|
-
987654321`,spellcheck:"false"},null,512),[[an,st.value]])]),p("div",K2,T(g(a)("Put one Telegram user ID per line or separate them with commas. Use `*` to allow all Telegram users. Unauthorized users will see their own ID in the rejection message so they can copy it here.")),1),Rt.value?(S(),I("div",Y2,[p("span",null,T(Rt.value),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[18]||(f[18]=N=>In(N,Rt.value))},T(g(a)("Send feedback")),9,J2)])):ee("",!0),p("div",Q2,[p("button",{class:"sidebar-settings-telegram-save",type:"button",disabled:$o.value,onClick:Wc},T($o.value?g(a)("Saving…"):g(a)("Save Telegram config")),9,X2)])])):ee("",!0),p("div",Z2,[p("div",eD,[p("span",tD,T(g(a)("Hooks")),1),p("button",{class:"sidebar-settings-hooks-reload",type:"button",disabled:g(G),title:g(a)("Reload lifecycle hooks"),onClick:f[19]||(f[19]=N=>g($)({force:!0}))},T(g(G)?g(a)("Reloading…"):g(a)("Reload")),9,nD)]),Hi.value?(S(),I(ze,{key:1},[g(G)?(S(),I("p",rD,T(g(a)("Loading hooks…")),1)):g(O).length===0?(S(),I("p",aD,T(g(a)("No hooks registered.")),1)):(S(),I("div",sD,[(S(!0),I(ze,null,_t(g(O),N=>(S(),I("div",{key:N.cwd||"__global__",class:"sidebar-settings-hooks-entry"},[p("p",iD,T(N.cwd||g(a)("Global")),1),(S(!0),I(ze,null,_t(N.hooks,(Q,ve)=>(S(),I("div",{key:`${N.cwd}:${Q.event}:${ve}`,class:"sidebar-settings-hooks-item"},[p("span",{class:Ke(["sidebar-settings-hooks-state",{"is-on":Q.enabled!==!1}])},T(Q.enabled===!1?g(a)("Disabled"):g(a)("Enabled")),3),p("span",lD,T(Q.event),1),p("code",cD,T(Q.command),1)]))),128))]))),128))]))],64)):(S(),I("p",oD,T(g(a)("Hooks are not supported by this Codex version.")),1))]),p("div",uD,[p("div",dD,[p("span",fD,T(g(a)("Remote control")),1),p("button",{class:"sidebar-settings-remote-toggle",type:"button",disabled:eo.value||Ro.value,title:g(a)("Enable or disable remote control"),onClick:ui},[p("span",{class:Ke(["sidebar-settings-remote-toggle-track",{"is-on":ln.value.enabled}])},[...f[52]||(f[52]=[p("span",{class:"sidebar-settings-remote-toggle-thumb"},null,-1)])],2),p("span",hD,T(ln.value.enabled?g(a)("Enabled"):g(a)("Disabled")),1)],8,pD)]),ai.value?(S(),I(ze,{key:1},[Yo.value?(S(),I("p",vD,T(Yo.value),1)):ee("",!0),Cs.value?(S(),I("p",gD,T(Cs.value),1)):ee("",!0),Ro.value?(S(),I("p",yD,T(g(a)("Loading…")),1)):(S(),I(ze,{key:3},[p("button",{class:"sidebar-settings-remote-row",type:"button",disabled:!ln.value.enabled||eo.value,onClick:Vi},[p("span",bD,T(g(a)("Pair a new device")),1),p("span",kD,T(to.value==="pairing"?g(a)("Starting…"):(x=hn.value)!=null&&x.pairingCode?hn.value.pairingCode:g(a)("Generate code")),1)],8,wD),p("div",CD,[p("div",TD,[p("span",SD,T(g(a)("Paired devices")),1),p("button",{class:"sidebar-settings-remote-reload",type:"button",disabled:eo.value,onClick:Ss},T(to.value==="clients"?g(a)("Reloading…"):g(a)("Reload")),9,_D)]),ln.value.clients.length===0?(S(),I("p",xD,T(g(a)("No paired devices.")),1)):ee("",!0),(S(!0),I(ze,null,_t(ln.value.clients,N=>(S(),I("div",{key:N.clientId,class:"sidebar-settings-remote-client"},[p("span",AD,T(N.deviceName||N.clientId),1),p("button",{class:"sidebar-settings-remote-client-revoke",type:"button",disabled:eo.value,onClick:Q=>$l(N.clientId)},T(to.value===`revoke:${N.clientId}`?g(a)("Removing…"):g(a)("Revoke")),9,PD)]))),128))])],64))],64)):(S(),I("p",mD,T(g(a)("Remote control is not supported by this Codex version.")),1))])],512),[[uu,yo.value==="integrations"]]),Lt(p("div",null,[p("div",ID,[Ie(d$,{snapshots:g(He)},null,8,["snapshots"])]),p("div",{class:"sidebar-settings-build-label","aria-label":g(a)("Worktree name and version")}," WT "+T(g(v))+" · v"+T(g(y)),9,ED)],512),[[uu,yo.value==="usage"]])])])],8,AO)])):ee("",!0)])),p("div",RD,[p("button",{ref_key:"settingsButtonRef",ref:Jr,class:"sidebar-settings-icon-button",type:"button",title:g(a)("Settings"),"aria-label":g(a)("Settings"),onClick:lt(Ml,["stop"])},[Ie(KL,{class:"sidebar-settings-icon"})],8,MD),p("button",{ref:"recycleBinButtonRef",class:"sidebar-settings-icon-button",type:"button",title:g(a)("Recycle bin"),"aria-label":g(a)("Recycle bin"),onClick:lt(Xw,["stop"])},[Ie(Ly,{class:"sidebar-settings-icon"})],8,$D)])],512))])]}),content:yt(()=>[p("div",jD,[p("section",{class:Ke(["content-root",{"is-virtual-keyboard-open":wd.value}]),style:kr(Oa.value)},[Ci.value?(S(),I("span",LD)):ee("",!0),Ie(lI,{title:vd.value,accent:gr.value||ts.value},{leading:yt(()=>[Bt.value||g(ht)?(S(),tt(ev,{key:0,class:"sidebar-thread-controls-header-host","is-sidebar-collapsed":Bt.value,"show-new-thread-button":!0,onToggleSidebar:f[22]||(f[22]=x=>Co(!Bt.value)),onStartNewThread:_d},null,8,["is-sidebar-collapsed"])):ee("",!0),gr.value?(S(),I("span",ND,[Ie(Ys)])):ts.value?(S(),I("span",OD,[Ie(Ys)])):ee("",!0)]),actions:yt(()=>[el.value?(S(),I("button",{key:0,class:"content-header-right-panel-toggle",type:"button","aria-label":g(ht)?Mn.value?g(a)("Close side panel"):g(a)("Open side panel"):Io.value?g(a)("Open side panel"):g(a)("Close side panel"),title:g(ht)?Mn.value?g(a)("Close side panel"):g(a)("Open side panel"):Io.value?g(a)("Open side panel"):g(a)("Close side panel"),onClick:Gw},[Ie(Ny,{class:"content-header-right-panel-toggle-icon"})],8,DD)):ee("",!0)]),_:1},8,["title","accent"]),p("section",FD,[gr.value?(S(),tt(g(r),{key:0,ref_key:"directoryHubRef",ref:ir,cwd:Dc.value,"thread-id":es.value,"try-in-flight-key":cr.value,onSkillsChanged:js,onTryItem:l0},null,8,["cwd","thread-id","try-in-flight-key"])):ts.value?(S(),tt(g(s),{key:1,ref_key:"automationsPanelRef",ref:sr,groups:g(B),"project-cwd-by-name":Rp.value,"project-display-name-by-id":g(J),"selected-automation-id":Nc.value,onSelectAutomation:Ns,onEditAutomation:Jc,onCreateAutomation:Zy},null,8,["groups","project-cwd-by-name","project-display-name-by-id","selected-automation-id"])):Rn.value?(S(),I("div",UD,[p("div",BD,[p("p",qD,T(g(a)("Let's build")),1),Ie(or,{class:"new-thread-folder-dropdown","model-value":Ct.value,options:Vl.value,placeholder:g(a)("Choose folder"),"enable-search":!0,"search-placeholder":g(a)("Quick search project"),disabled:!1,"onUpdate:modelValue":tb},null,8,["model-value","options","placeholder","search-placeholder"]),Ct.value?(S(),I("p",{key:0,class:"new-thread-folder-selected",title:Ct.value},T(g(a)("Selected folder"))+": "+T(Ct.value),9,zD)):ee("",!0),p("div",HD,[p("button",{class:"new-thread-folder-action new-thread-folder-action-primary",type:"button",onClick:kb},T(g(a)("Select folder")),1),p("button",{class:"new-thread-folder-action",type:"button",onClick:ub},T(g(a)("Create Project")),1),p("button",{class:"new-thread-folder-action",type:"button",disabled:Is.value,onClick:gb},T(Is.value?g(a)("Importing…"):g(a)("Import Project")),9,WD),p("input",{ref_key:"projectImportInputRef",ref:jc,class:"new-thread-project-import-input",type:"file",accept:".zip,application/zip",tabindex:"-1","aria-hidden":"true",onChange:bb},null,544)]),xs.value?(S(),I("section",VD,[p("div",GD,[p("div",KD,[p("span",YD,[Ie(Ys)]),p("p",JD,T(g(a)("New in Codex")),1)]),p("h2",QD,T(g(a)("Plugins are here")),1),p("p",XD,T(g(a)("Hook Codex up to Gmail, Calendar, GitHub, Slack, Browser Use, and more so it can actually help with real work right away.")),1),f[53]||(f[53]=p("div",{class:"new-thread-launch-card-pills","aria-label":"Example integrations"},[p("span",{class:"new-thread-launch-card-pill"},"Gmail"),p("span",{class:"new-thread-launch-card-pill"},"Calendar"),p("span",{class:"new-thread-launch-card-pill"},"GitHub"),p("span",{class:"new-thread-launch-card-pill"},"Slack"),p("span",{class:"new-thread-launch-card-pill"},"Browser Use")],-1))]),p("div",ZD,[p("button",{class:"new-thread-launch-card-button new-thread-launch-card-button-primary",type:"button",onClick:Bc},T(g(a)("Explore Plugins & Apps")),1),p("button",{class:"new-thread-launch-card-button",type:"button",onClick:Uc},T(g(a)("Dismiss")),1)])])):ee("",!0),(S(),tt(Xs,{to:"body"},[$a.value?(S(),I("div",{key:0,class:"new-thread-open-folder-overlay",onMousedown:lt(db,["self"]),onMouseup:fb},[p("div",{class:"new-thread-open-folder",role:"dialog","aria-modal":"true","aria-label":g(a)("Select folder"),onKeydown:An(lt(al,["prevent"]),["esc"])},[p("div",tF,[p("p",nF,T(g(a)("Select folder")),1),p("button",{class:"new-thread-open-folder-close",type:"button",onClick:al},T(g(a)("Cancel")),1)]),p("p",oF,T(g(a)("Current folder")),1),p("div",rF,[Lt(p("input",{ref_key:"existingFolderPathInputRef",ref:Lc,"onUpdate:modelValue":f[23]||(f[23]=x=>ja.value=x),class:"new-thread-open-folder-path",type:"text",placeholder:g(a)("Current folder"),title:ja.value||g(a)("Unavailable"),disabled:No.value||ko.value,onBlur:_b,onKeydown:[An(lt(xb,["prevent"]),["enter"]),An(lt(al,["prevent"]),["esc"])]},null,40,aF),[[an,ja.value]]),p("button",{class:"new-thread-folder-action new-thread-folder-action-primary",type:"button",disabled:!q.value||No.value||ko.value,onClick:f[24]||(f[24]=x=>Ed())},T(ko.value?g(a)("Opening…"):g(a)("Open")),9,sF)]),p("div",iF,[p("label",lF,[Lt(p("input",{"onUpdate:modelValue":f[25]||(f[25]=x=>vi.value=x),class:"new-thread-open-folder-toggle-input",type:"checkbox",onChange:Tb},null,544),[[Gg,vi.value]]),p("span",null,T(g(a)("Show hidden folders")),1)]),p("button",{class:Ke(["new-thread-folder-action",{"new-thread-folder-action-primary":Kt.value}]),type:"button","aria-pressed":Kt.value,disabled:!Or.value||No.value||ko.value||tr.value||!!Bn.value&&!Kt.value,onClick:Ab},T(g(a)("New folder")),11,cF)]),Kt.value?(S(),I("div",uF,[p("div",dF,[Lt(p("input",{ref_key:"createFolderInputRef",ref:Ka,"onUpdate:modelValue":f[26]||(f[26]=x=>Nn.value=x),class:"new-thread-open-folder-create-input",type:"text",placeholder:g(a)("Folder name"),onKeydown:[An(lt(Gp,["prevent"]),["enter"]),An(lt(Yl,["prevent"]),["esc"])]},null,40,fF),[[an,Nn.value]]),p("button",{class:"new-thread-folder-action new-thread-folder-action-primary new-thread-open-folder-create-submit",type:"button",disabled:!R.value||tr.value,onClick:Gp},T(Z.value),9,pF)]),bn.value?(S(),I("div",hF,[p("span",null,T(bn.value),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[27]||(f[27]=x=>In(x,bn.value))},T(g(a)("Send feedback")),9,mF)])):ee("",!0)])):ee("",!0),Lt(p("input",{ref_key:"existingFolderFilterInputRef",ref:md,"onUpdate:modelValue":f[28]||(f[28]=x=>Dr.value=x),class:"new-thread-open-folder-filter",type:"text",placeholder:g(a)("Filter folders..."),onKeydown:An(lt(al,["prevent"]),["esc"])},null,40,vF),[[an,Dr.value]]),Bn.value?(S(),I("div",gF,[p("div",yF,[p("span",null,T(Bn.value),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[29]||(f[29]=x=>In(x,Bn.value))},T(g(a)("Send feedback")),9,wF)]),p("button",{class:"new-thread-folder-action",type:"button",disabled:No.value||ko.value,onClick:Sb},T(g(a)("Retry")),9,bF)])):ee("",!0),No.value?(S(),I("p",kF,T(g(a)("Loading folders…")),1)):!Bn.value&&pt.value.length===0?(S(),I("p",CF,T(Dr.value.trim()?g(a)("No folders match this filter."):g(a)("No subfolders found here.")),1)):pt.value.length>0?(S(),I("ul",TF,[(S(!0),I(ze,null,_t(pt.value,x=>(S(),I("li",{key:x.key,class:"new-thread-open-folder-item"},[p("button",{class:"new-thread-open-folder-item-main",type:"button",title:x.path,disabled:No.value||ko.value,onClick:N=>Cb(x.path)},[p("span",_F,T(x.name),1)],8,SF),x.kind==="directory"?(S(),I("button",{key:0,class:"new-thread-open-folder-item-open",type:"button",disabled:No.value||ko.value,onClick:N=>Ed(x.path)},T(g(a)("Open")),9,xF)):ee("",!0)]))),128))])):ee("",!0)],40,eF)],32)):ee("",!0)])),(S(),tt(Xs,{to:"body"},[Nr.value?(S(),I("div",{key:0,class:"new-thread-open-folder-overlay",onMousedown:lt(pb,["self"]),onMouseup:hb},[p("div",{class:"new-thread-project-modal",role:"dialog","aria-modal":"true","aria-label":g(a)("Create or clone project"),onKeydown:An(lt(nu,["prevent"]),["esc"])},[p("div",PF,[p("p",IF,T(g(a)("Create or clone project")),1),p("button",{class:"new-thread-open-folder-close",type:"button",disabled:Lo.value,onClick:nu},T(g(a)("Cancel")),9,EF)]),p("div",{class:"new-thread-project-mode-tabs",role:"tablist","aria-label":g(a)("Project source")},[p("button",{class:Ke(["new-thread-project-mode-tab",{"is-active":jo.value==="create"}]),type:"button",role:"tab","aria-selected":jo.value==="create",disabled:Lo.value,onClick:f[30]||(f[30]=x=>jo.value="create")},T(g(a)("New project")),11,MF),p("button",{class:Ke(["new-thread-project-mode-tab",{"is-active":jo.value==="clone"}]),type:"button",role:"tab","aria-selected":jo.value==="clone",disabled:Lo.value,onClick:f[31]||(f[31]=x=>jo.value="clone")},T(g(a)("Clone from GitHub")),11,$F)],8,RF),p("label",jF,[p("span",LF,T(g(a)("Destination folder")),1),Lt(p("input",{"onUpdate:modelValue":f[32]||(f[32]=x=>Ps.value=x),class:"new-thread-open-folder-path",type:"text",disabled:Lo.value,placeholder:g(a)("Destination folder")},null,8,NF),[[an,Ps.value]])]),jo.value==="create"?(S(),I("label",OF,[p("span",DF,T(g(a)("Project name")),1),Lt(p("input",{ref_key:"projectSetupPrimaryInputRef",ref:Nl,"onUpdate:modelValue":f[33]||(f[33]=x=>hi.value=x),class:"new-thread-open-folder-create-input",type:"text",disabled:Lo.value,placeholder:g(a)("Project name"),onKeydown:An(lt(Id,["prevent"]),["enter"])},null,40,FF),[[an,hi.value]])])):jo.value==="clone"?(S(),I("label",UF,[p("span",BF,T(g(a)("GitHub repository URL")),1),Lt(p("input",{ref_key:"projectSetupPrimaryInputRef",ref:Nl,"onUpdate:modelValue":f[34]||(f[34]=x=>mi.value=x),class:"new-thread-open-folder-create-input",type:"url",disabled:Lo.value,placeholder:"https://github.com/owner/repo",onKeydown:An(lt(Id,["prevent"]),["enter"])},null,40,qF),[[an,mi.value]])])):ee("",!0),Ma.value?(S(),I("div",zF,[p("span",null,T(Ma.value),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[35]||(f[35]=x=>In(x,Ma.value))},T(g(a)("Send feedback")),9,HF)])):ee("",!0),p("div",WF,[p("button",{class:"new-thread-folder-action",type:"button",disabled:Lo.value,onClick:nu},T(g(a)("Cancel")),9,VF),p("button",{class:"new-thread-folder-action new-thread-folder-action-primary",type:"button",disabled:!L.value||Lo.value,onClick:Id},T(he.value),9,GF)])],40,AF)],32)):ee("",!0)])),ns.value?(S(),tt(v$,{key:2,class:"new-thread-runtime-dropdown",modelValue:Fn.value,"onUpdate:modelValue":f[36]||(f[36]=x=>Fn.value=x)},null,8,["modelValue"])):ee("",!0),Fn.value==="worktree"?(S(),I("div",KF,[p("p",YF,T(g(a)("Base branch")),1),Ie(or,{class:"new-thread-branch-dropdown","model-value":mo.value,options:i.value,placeholder:g(a)("Select branch"),"enable-search":!0,"search-placeholder":g(a)("Search branches..."),disabled:En.value||i.value.length===0,"onUpdate:modelValue":nb},null,8,["model-value","options","placeholder","search-placeholder","disabled"]),p("p",JF,T(En.value?g(a)("Loading branches…"):u.value?g(a)("New worktree branch will start from {branch}.",{branch:u.value}):g(a)("No Git branches found for this folder.")),1)])):ee("",!0),ns.value?(S(),I("p",QF,T(g(a)("Local project uses the selected folder directly. New worktree creates an isolated Git worktree before the first prompt.")),1)):ee("",!0),yn.value.phase!=="idle"?(S(),I("div",{key:5,class:Ke(["worktree-init-status",{"is-running":yn.value.phase==="running","is-error":yn.value.phase==="error"}])},[p("strong",XF,T(yn.value.title),1),p("span",ZF,T(yn.value.message),1)],2)):ee("",!0)]),p("div",eU,[g(Ue)?(S(),I("div",tU,[p("span",null,T(g(a)(g(Ue))),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[37]||(f[37]=x=>In(x,g(Ue)))},T(g(a)("Send feedback")),9,nU)])):ee("",!0),Ie(Zm,{ref_key:"homeThreadComposerRef",ref:Gr,"active-thread-id":yr.value,cwd:mn.value,"fuzzy-file-search-results":g(ge),onRegisterFuzzySession:g(Fe),"collaboration-modes":g(Le),"selected-collaboration-mode":g(Te),models:g(je),"model-reasoning-efforts":g(fe),"selected-model":Ms.value,"selected-reasoning-effort":g(xe),"selected-speed-mode":g(Ae),"is-updating-speed-mode":g(te),skills:g(Ye),"thread-token-usage":g(U),"codex-quota":g($e),"is-turn-in-progress":!1,"is-stop-pending":!1,"is-interrupting-turn":!1,"send-with-enter":ta.value,"in-progress-submit-mode":Ea.value,"dictation-click-to-toggle":Zo.value,"dictation-auto-send":oa.value,"dictation-language":Ra.value,onSubmit:zp,"onUpdate:selectedCollaborationMode":rh,"onUpdate:selectedModel":Qp,"onUpdate:selectedReasoningEffort":Xp,"onUpdate:selectedSpeedMode":Zp,"approval-policy":Zt.value,"is-approval-policy-saving":Ts.value,"approval-policy-error":no.value,"approval-policy-notice":dr.value,"onUpdate:approvalPolicy":_a,onSaveApprovalPolicy:$n,onSlashCommand:eh},null,8,["active-thread-id","cwd","fuzzy-file-search-results","onRegisterFuzzySession","collaboration-modes","selected-collaboration-mode","models","model-reasoning-efforts","selected-model","selected-reasoning-effort","selected-speed-mode","is-updating-speed-mode","skills","thread-token-usage","codex-quota","send-with-enter","in-progress-submit-mode","dictation-click-to-toggle","dictation-auto-send","dictation-language","approval-policy","is-approval-policy-saving","approval-policy-error","approval-policy-notice"])])])):(S(),I("div",oU,[Gn.value&&g(de)&&mn.value?(S(),tt(g(o),{key:0,"thread-id":g(de),cwd:mn.value,"is-thread-in-progress":Ti.value,"initial-file-path":Ir.value,"commit-sha":Xr.value,onClose:f[38]||(f[38]=x=>Gn.value=!1)},null,8,["thread-id","cwd","is-thread-in-progress","initial-file-path","commit-sha"])):(S(),I(ze,{key:1},[p("div",rU,[Ie(g(t),{ref_key:"threadConversationRef",ref:ka,messages:ki.value,"is-loading":g(ft),"active-thread-id":yr.value,cwd:mn.value,"live-overlay":gd.value,"live-turn-id":g(we),"pending-requests":g(V),"has-more-persisted-above":g(ct),"is-loading-persisted-above":g(mt),"load-earlier-messages":g(be),onForkThread:zw,onRollback:Mb,onFileChangesChanged:qc,onRespondServerRequest:Lp},null,8,["messages","is-loading","active-thread-id","cwd","live-overlay","live-turn-id","pending-requests","has-more-persisted-above","is-loading-persisted-above","load-earlier-messages"])]),p("div",{class:"composer-with-queue",ref_key:"composerQueueRef",ref:nn},[Fc.value?(S(),I("div",aU,T(g(a)("This thread is running in the Codex TUI")),1)):ee("",!0),g(Ue)?(S(),I("div",sU,[p("span",null,T(g(a)(g(Ue))),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[39]||(f[39]=x=>In(x,g(Ue)))},T(g(a)("Send feedback")),9,iU)])):ee("",!0),Ie(n$,{messages:g(W),onEdit:eb,onSteer:g(Oe),onDelete:g(Y),onReorder:Eb},null,8,["messages","onSteer","onDelete"]),Jl.value?(S(),I("div",lU,[p("span",null,T(Jl.value),1),p("button",{type:"button",class:"interrupt-recovered-dismiss","aria-label":g(a)("Dismiss"),onClick:f[40]||(f[40]=x=>Jl.value="")}," × ",8,cU)])):ee("",!0),Zi.value?(S(),tt(HM,{key:3,request:Zi.value,"request-count":g(V).length,"has-queue-above":g(W).length>0,"panel-width":Kr.value,"visual-viewport-height":Ci.value?La.value:0,"panel-error":zl.value,onRespondServerRequest:Lp},null,8,["request","request-count","has-queue-above","panel-width","visual-viewport-height","panel-error"])):(S(),tt(Zm,{key:4,ref_key:"threadComposerRef",ref:Ao,"active-thread-id":yr.value,cwd:mn.value,"fuzzy-file-search-results":g(ge),onRegisterFuzzySession:g(Fe),"collaboration-modes":g(Le),"selected-collaboration-mode":g(Te),models:g(je),"model-reasoning-efforts":g(fe),"selected-model":Ms.value,"selected-reasoning-effort":g(xe),"selected-speed-mode":g(Ae),"is-updating-speed-mode":g(te),skills:g(Ye),"thread-token-usage":g(U),"codex-quota":g($e),"is-turn-in-progress":Ti.value,"is-stop-pending":g(ae),"is-interrupting-turn":g(at),"is-compacting":Ur.value,"external-session-active":Fc.value,"has-queue-above":g(W).length>0,"send-with-enter":ta.value,"in-progress-submit-mode":Ea.value,"dictation-click-to-toggle":Zo.value,"dictation-auto-send":oa.value,"dictation-language":Ra.value,"onUpdate:selectedCollaborationMode":rh,onSubmit:zp,"onUpdate:selectedModel":Qp,"onUpdate:selectedReasoningEffort":Xp,"onUpdate:selectedSpeedMode":Zp,"approval-policy":Zt.value,"is-approval-policy-saving":Ts.value,"approval-policy-error":no.value,"approval-policy-notice":dr.value,"onUpdate:approvalPolicy":_a,onSaveApprovalPolicy:$n,"plan-panel":ql.value,onInterrupt:Rb,onSlashCommand:eh,onImplementPlan:$b,onCompactContext:bd},null,8,["active-thread-id","cwd","fuzzy-file-search-results","onRegisterFuzzySession","collaboration-modes","selected-collaboration-mode","models","model-reasoning-efforts","selected-model","selected-reasoning-effort","selected-speed-mode","is-updating-speed-mode","skills","thread-token-usage","codex-quota","is-turn-in-progress","is-stop-pending","is-interrupting-turn","is-compacting","external-session-active","has-queue-above","send-with-enter","in-progress-submit-mode","dictation-click-to-toggle","dictation-auto-send","dictation-language","approval-policy","is-approval-policy-saving","approval-policy-error","approval-policy-notice","plan-panel"]))],512)],64))]))])],6),g(ht)&&Mn.value?(S(),I("div",{key:0,class:"content-right-panel-backdrop",role:"presentation",onClick:Dp})):ee("",!0),el.value&&(g(ht)||!Io.value)?(S(),I("aside",{key:1,class:Ke(["content-right-panel",{"is-mobile-open":Mn.value}]),style:kr({"--right-panel-width":`${ho.value}px`})},[g(ht)?ee("",!0):(S(),I("div",{key:0,class:"content-right-panel-resize-handle","aria-hidden":"true",onMousedown:Wo},null,32)),p("div",uU,[p("div",dU,[p("button",{class:Ke(["content-right-panel-tab",{"is-active":$t.value==="git"}]),type:"button",role:"tab","aria-selected":$t.value==="git",onClick:f[41]||(f[41]=x=>_i("git"))},[Ie(Gu,{class:"content-right-panel-tab-icon"}),ps(" "+T(g(a)("Git")),1)],10,fU),p("button",{class:Ke(["content-right-panel-tab",{"is-active":$t.value==="files"}]),type:"button",role:"tab","aria-selected":$t.value==="files",onClick:f[42]||(f[42]=x=>_i("files"))},[Ie(nv,{class:"content-right-panel-tab-icon"}),ps(" "+T(g(a)("Files")),1)],10,pU),(S(!0),I(ze,null,_t(zn.value,x=>(S(),I("button",{key:x.key,class:Ke(["content-right-panel-tab content-right-panel-tab--preview",{"is-active":$t.value==="preview"&&po.value===x.key}]),type:"button",role:"tab","aria-selected":$t.value==="preview"&&po.value===x.key,title:x.path,onClick:N=>Ww(x.key)},[Ie(Bi,{class:"content-right-panel-tab-icon"}),p("span",mU,T(x.label),1),p("span",{class:"content-right-panel-tab-close",role:"button","aria-label":g(a)("Close"),title:g(a)("Close"),onClick:lt(N=>Vw(x.key),["stop"])},"×",8,vU)],10,hU))),128))]),p("div",gU,[p("div",yU,[p("button",{ref:"rightPanelAddButtonRef",class:"content-right-panel-add",type:"button","aria-label":g(a)("Add panel"),title:g(a)("Add panel"),onClick:f[43]||(f[43]=lt(x=>Xn.value=!Xn.value,["stop"]))},"+",8,wU),Ie(Mc,{name:"right-panel-menu"},{default:yt(()=>[Xn.value?(S(),I("div",bU,[p("button",{type:"button",onClick:f[44]||(f[44]=x=>_i("terminal"))},[Ie(XL,{class:"content-right-panel-menu-icon"}),ps(" "+T(g(a)("Terminal panel")),1)]),p("button",{type:"button",onClick:f[45]||(f[45]=x=>_i("git"))},[Ie(Gu,{class:"content-right-panel-menu-icon"}),ps(" "+T(g(a)("Git panel")),1)]),p("button",{type:"button",onClick:f[46]||(f[46]=x=>_i("files"))},[Ie(nv,{class:"content-right-panel-menu-icon"}),ps(" "+T(g(a)("Files panel")),1)])])):ee("",!0)]),_:1})]),p("button",{class:"content-right-panel-close",type:"button","aria-label":g(a)("Close panel"),title:g(a)("Close panel"),onClick:Dp},[Ie(Ru,{class:"content-right-panel-close-icon"})],8,kU)])]),p("div",CU,[$t.value==="git"?(S(),tt(uL,{key:0,"current-branch":Zr.value,"head-sha":xa.value,"head-subject":hr.value,"head-date":Aa.value,detached:Mo.value,dirty:Ga.value,"worktree-change-summary":Er.value,"worktree-changes":wo.value,branches:pr.value,"commits-by-branch":qe.value,"commits-loading-for":ke.value,"commits-error":Un.value,"commit-files-by-sha":Pa.value,"commit-files-loading-for":mr.value,"commit-files-error":_s.value,loading:cn.value,busy:ea.value,error:Rr.value,"review-open":Gn.value,"show-review":g(Et).name==="thread"&&g(de).length>0,onToggleReview:lb,onCheckoutBranch:rb,onResetBranchToCommit:ab,onLoadCommits:Vp,onLoadCommitFiles:sb,onOpenCommitFile:ib},null,8,["current-branch","head-sha","head-subject","head-date","detached","dirty","worktree-change-summary","worktree-changes","branches","commits-by-branch","commits-loading-for","commits-error","commit-files-by-sha","commit-files-loading-for","commit-files-error","loading","busy","error","review-open","show-review"])):$t.value==="files"?(S(),tt(_L,{key:1,cwd:mn.value,onOpenPreview:Hw},null,8,["cwd"])):$t.value==="preview"&&Hn.value?(S(),tt(BL,{key:2,"file-path":Hn.value.path,name:Hn.value.label},null,8,["file-path","name"])):(S(),tt(g(n),{key:3,ref_key:"threadTerminalPanelRef",ref:Jn,"thread-id":yr.value,cwd:mn.value,onHide:Kw,onTerminalFocusChange:Yw},null,8,["thread-id","cwd"]))])],6)):ee("",!0)])]),_:1},8,["is-sidebar-collapsed"]),xt.value.phase!=="idle"?(S(),I("div",TU,[p("div",{class:"project-zip-modal",role:"dialog","aria-modal":"true","aria-label":g(a)("Export Project"),onClick:f[48]||(f[48]=lt(()=>{},["stop"]))},[p("div",_U,[p("h2",xU,T(g(a)("Export Project")),1),p("button",{class:"project-zip-modal-close",type:"button","aria-label":g(a)("Close"),disabled:xt.value.phase==="exporting",onClick:$p}," × ",8,AU)]),p("p",PU,T(xt.value.phase==="exporting"?g(a)("Preparing project ZIP..."):xt.value.fileName),1),p("div",IU,[p("span",null,T(xt.value.phase==="exporting"?g(a)("Exporting"):g(a)("Ready")),1),p("span",null,T(Ll.value),1)]),p("div",EU,[p("div",{class:"project-zip-progress-fill",style:kr({width:pi.value})},null,4)]),xt.value.error?(S(),I("p",RU,T(xt.value.error),1)):ee("",!0),p("div",MU,[p("button",{class:"project-zip-modal-cancel",type:"button",disabled:xt.value.phase==="exporting",onClick:$p},T(g(a)("Close")),9,$U),p("button",{class:"project-zip-modal-action",type:"button",disabled:!xt.value.blob,onClick:Mw},T(g(a)("Download")),9,jU),p("button",{class:"project-zip-modal-action project-zip-modal-action-primary",type:"button",disabled:!xt.value.blob,onClick:$w},T(g(a)("Share")),9,LU)])],8,SU)])):ee("",!0),Ya.value?(S(),I("div",{key:1,class:"codex-login-modal-backdrop",role:"presentation",onClick:Sd},[p("form",{class:"codex-login-modal",role:"dialog","aria-modal":"true","aria-label":g(a)("Complete Codex login"),onSubmit:lt(vw,["prevent"]),onClick:f[51]||(f[51]=lt(()=>{},["stop"]))},[p("div",OU,[p("h2",DU,T(g(a)("Complete Codex login")),1),p("button",{class:"codex-login-modal-close",type:"button","aria-label":g(a)("Close"),disabled:Ln.value,onClick:Sd}," × ",8,FU)]),p("p",UU,T(g(a)("Finish login in the browser, then paste the localhost callback URL here.")),1),Ia.value?(S(),I("a",{key:0,class:"codex-login-modal-link",href:Ia.value,target:"_blank",rel:"noreferrer"},T(g(a)("Open login URL")),9,BU)):ee("",!0),Lt(p("input",{ref_key:"codexLoginCallbackInputRef",ref:fi,"onUpdate:modelValue":f[49]||(f[49]=x=>$r.value=x),class:"codex-login-modal-input",type:"url",inputmode:"url",placeholder:g(a)("Paste localhost callback URL"),disabled:Ln.value},null,8,qU),[[an,$r.value]]),wn.value?(S(),I("div",zU,[p("span",null,T(wn.value),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[50]||(f[50]=x=>In(x,wn.value))},T(g(a)("Send feedback")),9,HU)])):ee("",!0),p("div",WU,[p("button",{class:"codex-login-modal-cancel",type:"button",disabled:Ln.value,onClick:Sd},T(g(a)("Cancel")),9,VU),p("button",{class:"codex-login-modal-submit",type:"submit",disabled:Ln.value||$r.value.trim().length===0},T(Ln.value?g(a)("Completing…"):g(a)("Complete")),9,GU)])],40,NU)])):ee("",!0)],64))}}),ZU=bt(XU,[["__scopeId","data-v-de87fe36"]]),xu={render:()=>null},eB=JT({history:PT(),routes:[{path:"/",name:"home",component:xu},{path:"/thread/:threadId",name:"thread",component:xu},{path:"/skills",name:"skills",component:xu},{path:"/automations",name:"automations",component:xu},{path:"/new-thread",redirect:{name:"home"}},{path:"/:pathMatch(.*)*",redirect:{name:"home"}}]});console.log("Welcome to codex-mobile-re. github: https://github.com/cattails-lgao/codex-mobile");b1();FC(ZU).use(eB).mount("#app");"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js").catch(e=>{console.error(Iy("Service worker registration failed."),e)})});export{An as $,mu as A,yp as B,Wt as C,ov as D,nB as E,ze as F,cp as G,hI as H,Ru as I,nc as J,ej as K,O_ as L,HN as M,ws as N,C_ as O,fB as P,uB as Q,pB as R,dB as S,Xs as T,hB as U,or as V,RB as W,$B as X,MB as Y,tB as Z,bt as _,I as a,_p as a0,Lt as a1,an as a2,XT as a3,QT as a4,s_ as a5,mB as a6,oB as a7,rB as a8,aB as a9,bB as aa,_B as ab,xB as ac,vB as ad,SB as ae,iB as af,sB as ag,lB as ah,cB as ai,AB as aj,IB as ak,EB as al,gB as am,yB as an,wB as ao,kB as ap,TB as aq,CB as ar,PB as as,g_ as at,y_ as au,Ys as av,xI as aw,p as b,tt as c,tn as d,ee as e,ps as f,Ie as g,Mc as h,yt as i,io as j,X as k,nt as l,qi as m,Ke as n,S as o,kr as p,A as q,_t as r,Oy as s,T as t,g as u,xp as v,lt as w,Gu as x,rr as y,Js as z};
|
|
86
|
+
987654321`,spellcheck:"false"},null,512),[[an,st.value]])]),p("div",K2,T(g(a)("Put one Telegram user ID per line or separate them with commas. Use `*` to allow all Telegram users. Unauthorized users will see their own ID in the rejection message so they can copy it here.")),1),Rt.value?(S(),I("div",Y2,[p("span",null,T(Rt.value),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[18]||(f[18]=N=>In(N,Rt.value))},T(g(a)("Send feedback")),9,J2)])):ee("",!0),p("div",Q2,[p("button",{class:"sidebar-settings-telegram-save",type:"button",disabled:$o.value,onClick:Wc},T($o.value?g(a)("Saving…"):g(a)("Save Telegram config")),9,X2)])])):ee("",!0),p("div",Z2,[p("div",eD,[p("span",tD,T(g(a)("Hooks")),1),p("button",{class:"sidebar-settings-hooks-reload",type:"button",disabled:g(G),title:g(a)("Reload lifecycle hooks"),onClick:f[19]||(f[19]=N=>g($)({force:!0}))},T(g(G)?g(a)("Reloading…"):g(a)("Reload")),9,nD)]),Hi.value?(S(),I(ze,{key:1},[g(G)?(S(),I("p",rD,T(g(a)("Loading hooks…")),1)):g(O).length===0?(S(),I("p",aD,T(g(a)("No hooks registered.")),1)):(S(),I("div",sD,[(S(!0),I(ze,null,_t(g(O),N=>(S(),I("div",{key:N.cwd||"__global__",class:"sidebar-settings-hooks-entry"},[p("p",iD,T(N.cwd||g(a)("Global")),1),(S(!0),I(ze,null,_t(N.hooks,(Q,ve)=>(S(),I("div",{key:`${N.cwd}:${Q.event}:${ve}`,class:"sidebar-settings-hooks-item"},[p("span",{class:Ke(["sidebar-settings-hooks-state",{"is-on":Q.enabled!==!1}])},T(Q.enabled===!1?g(a)("Disabled"):g(a)("Enabled")),3),p("span",lD,T(Q.event),1),p("code",cD,T(Q.command),1)]))),128))]))),128))]))],64)):(S(),I("p",oD,T(g(a)("Hooks are not supported by this Codex version.")),1))]),p("div",uD,[p("div",dD,[p("span",fD,T(g(a)("Remote control")),1),p("button",{class:"sidebar-settings-remote-toggle",type:"button",disabled:eo.value||Ro.value,title:g(a)("Enable or disable remote control"),onClick:ui},[p("span",{class:Ke(["sidebar-settings-remote-toggle-track",{"is-on":ln.value.enabled}])},[...f[52]||(f[52]=[p("span",{class:"sidebar-settings-remote-toggle-thumb"},null,-1)])],2),p("span",hD,T(ln.value.enabled?g(a)("Enabled"):g(a)("Disabled")),1)],8,pD)]),ai.value?(S(),I(ze,{key:1},[Yo.value?(S(),I("p",vD,T(Yo.value),1)):ee("",!0),Cs.value?(S(),I("p",gD,T(Cs.value),1)):ee("",!0),Ro.value?(S(),I("p",yD,T(g(a)("Loading…")),1)):(S(),I(ze,{key:3},[p("button",{class:"sidebar-settings-remote-row",type:"button",disabled:!ln.value.enabled||eo.value,onClick:Vi},[p("span",bD,T(g(a)("Pair a new device")),1),p("span",kD,T(to.value==="pairing"?g(a)("Starting…"):(x=hn.value)!=null&&x.pairingCode?hn.value.pairingCode:g(a)("Generate code")),1)],8,wD),p("div",CD,[p("div",TD,[p("span",SD,T(g(a)("Paired devices")),1),p("button",{class:"sidebar-settings-remote-reload",type:"button",disabled:eo.value,onClick:Ss},T(to.value==="clients"?g(a)("Reloading…"):g(a)("Reload")),9,_D)]),ln.value.clients.length===0?(S(),I("p",xD,T(g(a)("No paired devices.")),1)):ee("",!0),(S(!0),I(ze,null,_t(ln.value.clients,N=>(S(),I("div",{key:N.clientId,class:"sidebar-settings-remote-client"},[p("span",AD,T(N.deviceName||N.clientId),1),p("button",{class:"sidebar-settings-remote-client-revoke",type:"button",disabled:eo.value,onClick:Q=>$l(N.clientId)},T(to.value===`revoke:${N.clientId}`?g(a)("Removing…"):g(a)("Revoke")),9,PD)]))),128))])],64))],64)):(S(),I("p",mD,T(g(a)("Remote control is not supported by this Codex version.")),1))])],512),[[uu,yo.value==="integrations"]]),Lt(p("div",null,[p("div",ID,[Ie(d$,{snapshots:g(He)},null,8,["snapshots"])]),p("div",{class:"sidebar-settings-build-label","aria-label":g(a)("Worktree name and version")}," WT "+T(g(v))+" · v"+T(g(y)),9,ED)],512),[[uu,yo.value==="usage"]])])])],8,AO)])):ee("",!0)])),p("div",RD,[p("button",{ref_key:"settingsButtonRef",ref:Jr,class:"sidebar-settings-icon-button",type:"button",title:g(a)("Settings"),"aria-label":g(a)("Settings"),onClick:lt(Ml,["stop"])},[Ie(KL,{class:"sidebar-settings-icon"})],8,MD),p("button",{ref:"recycleBinButtonRef",class:"sidebar-settings-icon-button",type:"button",title:g(a)("Recycle bin"),"aria-label":g(a)("Recycle bin"),onClick:lt(Xw,["stop"])},[Ie(Ly,{class:"sidebar-settings-icon"})],8,$D)])],512))])]}),content:yt(()=>[p("div",jD,[p("section",{class:Ke(["content-root",{"is-virtual-keyboard-open":wd.value}]),style:kr(Oa.value)},[Ci.value?(S(),I("span",LD)):ee("",!0),Ie(lI,{title:vd.value,accent:gr.value||ts.value},{leading:yt(()=>[Bt.value||g(ht)?(S(),tt(ev,{key:0,class:"sidebar-thread-controls-header-host","is-sidebar-collapsed":Bt.value,"show-new-thread-button":!0,onToggleSidebar:f[22]||(f[22]=x=>Co(!Bt.value)),onStartNewThread:_d},null,8,["is-sidebar-collapsed"])):ee("",!0),gr.value?(S(),I("span",ND,[Ie(Ys)])):ts.value?(S(),I("span",OD,[Ie(Ys)])):ee("",!0)]),actions:yt(()=>[el.value?(S(),I("button",{key:0,class:"content-header-right-panel-toggle",type:"button","aria-label":g(ht)?Mn.value?g(a)("Close side panel"):g(a)("Open side panel"):Io.value?g(a)("Open side panel"):g(a)("Close side panel"),title:g(ht)?Mn.value?g(a)("Close side panel"):g(a)("Open side panel"):Io.value?g(a)("Open side panel"):g(a)("Close side panel"),onClick:Gw},[Ie(Ny,{class:"content-header-right-panel-toggle-icon"})],8,DD)):ee("",!0)]),_:1},8,["title","accent"]),p("section",FD,[gr.value?(S(),tt(g(r),{key:0,ref_key:"directoryHubRef",ref:ir,cwd:Dc.value,"thread-id":es.value,"try-in-flight-key":cr.value,onSkillsChanged:js,onTryItem:l0},null,8,["cwd","thread-id","try-in-flight-key"])):ts.value?(S(),tt(g(s),{key:1,ref_key:"automationsPanelRef",ref:sr,groups:g(B),"project-cwd-by-name":Rp.value,"project-display-name-by-id":g(J),"selected-automation-id":Nc.value,onSelectAutomation:Ns,onEditAutomation:Jc,onCreateAutomation:Zy},null,8,["groups","project-cwd-by-name","project-display-name-by-id","selected-automation-id"])):Rn.value?(S(),I("div",UD,[p("div",BD,[p("p",qD,T(g(a)("Let's build")),1),Ie(or,{class:"new-thread-folder-dropdown","model-value":Ct.value,options:Vl.value,placeholder:g(a)("Choose folder"),"enable-search":!0,"search-placeholder":g(a)("Quick search project"),disabled:!1,"onUpdate:modelValue":tb},null,8,["model-value","options","placeholder","search-placeholder"]),Ct.value?(S(),I("p",{key:0,class:"new-thread-folder-selected",title:Ct.value},T(g(a)("Selected folder"))+": "+T(Ct.value),9,zD)):ee("",!0),p("div",HD,[p("button",{class:"new-thread-folder-action new-thread-folder-action-primary",type:"button",onClick:kb},T(g(a)("Select folder")),1),p("button",{class:"new-thread-folder-action",type:"button",onClick:ub},T(g(a)("Create Project")),1),p("button",{class:"new-thread-folder-action",type:"button",disabled:Is.value,onClick:gb},T(Is.value?g(a)("Importing…"):g(a)("Import Project")),9,WD),p("input",{ref_key:"projectImportInputRef",ref:jc,class:"new-thread-project-import-input",type:"file",accept:".zip,application/zip",tabindex:"-1","aria-hidden":"true",onChange:bb},null,544)]),xs.value?(S(),I("section",VD,[p("div",GD,[p("div",KD,[p("span",YD,[Ie(Ys)]),p("p",JD,T(g(a)("New in Codex")),1)]),p("h2",QD,T(g(a)("Plugins are here")),1),p("p",XD,T(g(a)("Hook Codex up to Gmail, Calendar, GitHub, Slack, Browser Use, and more so it can actually help with real work right away.")),1),f[53]||(f[53]=p("div",{class:"new-thread-launch-card-pills","aria-label":"Example integrations"},[p("span",{class:"new-thread-launch-card-pill"},"Gmail"),p("span",{class:"new-thread-launch-card-pill"},"Calendar"),p("span",{class:"new-thread-launch-card-pill"},"GitHub"),p("span",{class:"new-thread-launch-card-pill"},"Slack"),p("span",{class:"new-thread-launch-card-pill"},"Browser Use")],-1))]),p("div",ZD,[p("button",{class:"new-thread-launch-card-button new-thread-launch-card-button-primary",type:"button",onClick:Bc},T(g(a)("Explore Plugins & Apps")),1),p("button",{class:"new-thread-launch-card-button",type:"button",onClick:Uc},T(g(a)("Dismiss")),1)])])):ee("",!0),(S(),tt(Xs,{to:"body"},[$a.value?(S(),I("div",{key:0,class:"new-thread-open-folder-overlay",onMousedown:lt(db,["self"]),onMouseup:fb},[p("div",{class:"new-thread-open-folder",role:"dialog","aria-modal":"true","aria-label":g(a)("Select folder"),onKeydown:An(lt(al,["prevent"]),["esc"])},[p("div",tF,[p("p",nF,T(g(a)("Select folder")),1),p("button",{class:"new-thread-open-folder-close",type:"button",onClick:al},T(g(a)("Cancel")),1)]),p("p",oF,T(g(a)("Current folder")),1),p("div",rF,[Lt(p("input",{ref_key:"existingFolderPathInputRef",ref:Lc,"onUpdate:modelValue":f[23]||(f[23]=x=>ja.value=x),class:"new-thread-open-folder-path",type:"text",placeholder:g(a)("Current folder"),title:ja.value||g(a)("Unavailable"),disabled:No.value||ko.value,onBlur:_b,onKeydown:[An(lt(xb,["prevent"]),["enter"]),An(lt(al,["prevent"]),["esc"])]},null,40,aF),[[an,ja.value]]),p("button",{class:"new-thread-folder-action new-thread-folder-action-primary",type:"button",disabled:!q.value||No.value||ko.value,onClick:f[24]||(f[24]=x=>Ed())},T(ko.value?g(a)("Opening…"):g(a)("Open")),9,sF)]),p("div",iF,[p("label",lF,[Lt(p("input",{"onUpdate:modelValue":f[25]||(f[25]=x=>vi.value=x),class:"new-thread-open-folder-toggle-input",type:"checkbox",onChange:Tb},null,544),[[Gg,vi.value]]),p("span",null,T(g(a)("Show hidden folders")),1)]),p("button",{class:Ke(["new-thread-folder-action",{"new-thread-folder-action-primary":Kt.value}]),type:"button","aria-pressed":Kt.value,disabled:!Or.value||No.value||ko.value||tr.value||!!Bn.value&&!Kt.value,onClick:Ab},T(g(a)("New folder")),11,cF)]),Kt.value?(S(),I("div",uF,[p("div",dF,[Lt(p("input",{ref_key:"createFolderInputRef",ref:Ka,"onUpdate:modelValue":f[26]||(f[26]=x=>Nn.value=x),class:"new-thread-open-folder-create-input",type:"text",placeholder:g(a)("Folder name"),onKeydown:[An(lt(Gp,["prevent"]),["enter"]),An(lt(Yl,["prevent"]),["esc"])]},null,40,fF),[[an,Nn.value]]),p("button",{class:"new-thread-folder-action new-thread-folder-action-primary new-thread-open-folder-create-submit",type:"button",disabled:!R.value||tr.value,onClick:Gp},T(Z.value),9,pF)]),bn.value?(S(),I("div",hF,[p("span",null,T(bn.value),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[27]||(f[27]=x=>In(x,bn.value))},T(g(a)("Send feedback")),9,mF)])):ee("",!0)])):ee("",!0),Lt(p("input",{ref_key:"existingFolderFilterInputRef",ref:md,"onUpdate:modelValue":f[28]||(f[28]=x=>Dr.value=x),class:"new-thread-open-folder-filter",type:"text",placeholder:g(a)("Filter folders..."),onKeydown:An(lt(al,["prevent"]),["esc"])},null,40,vF),[[an,Dr.value]]),Bn.value?(S(),I("div",gF,[p("div",yF,[p("span",null,T(Bn.value),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[29]||(f[29]=x=>In(x,Bn.value))},T(g(a)("Send feedback")),9,wF)]),p("button",{class:"new-thread-folder-action",type:"button",disabled:No.value||ko.value,onClick:Sb},T(g(a)("Retry")),9,bF)])):ee("",!0),No.value?(S(),I("p",kF,T(g(a)("Loading folders…")),1)):!Bn.value&&pt.value.length===0?(S(),I("p",CF,T(Dr.value.trim()?g(a)("No folders match this filter."):g(a)("No subfolders found here.")),1)):pt.value.length>0?(S(),I("ul",TF,[(S(!0),I(ze,null,_t(pt.value,x=>(S(),I("li",{key:x.key,class:"new-thread-open-folder-item"},[p("button",{class:"new-thread-open-folder-item-main",type:"button",title:x.path,disabled:No.value||ko.value,onClick:N=>Cb(x.path)},[p("span",_F,T(x.name),1)],8,SF),x.kind==="directory"?(S(),I("button",{key:0,class:"new-thread-open-folder-item-open",type:"button",disabled:No.value||ko.value,onClick:N=>Ed(x.path)},T(g(a)("Open")),9,xF)):ee("",!0)]))),128))])):ee("",!0)],40,eF)],32)):ee("",!0)])),(S(),tt(Xs,{to:"body"},[Nr.value?(S(),I("div",{key:0,class:"new-thread-open-folder-overlay",onMousedown:lt(pb,["self"]),onMouseup:hb},[p("div",{class:"new-thread-project-modal",role:"dialog","aria-modal":"true","aria-label":g(a)("Create or clone project"),onKeydown:An(lt(nu,["prevent"]),["esc"])},[p("div",PF,[p("p",IF,T(g(a)("Create or clone project")),1),p("button",{class:"new-thread-open-folder-close",type:"button",disabled:Lo.value,onClick:nu},T(g(a)("Cancel")),9,EF)]),p("div",{class:"new-thread-project-mode-tabs",role:"tablist","aria-label":g(a)("Project source")},[p("button",{class:Ke(["new-thread-project-mode-tab",{"is-active":jo.value==="create"}]),type:"button",role:"tab","aria-selected":jo.value==="create",disabled:Lo.value,onClick:f[30]||(f[30]=x=>jo.value="create")},T(g(a)("New project")),11,MF),p("button",{class:Ke(["new-thread-project-mode-tab",{"is-active":jo.value==="clone"}]),type:"button",role:"tab","aria-selected":jo.value==="clone",disabled:Lo.value,onClick:f[31]||(f[31]=x=>jo.value="clone")},T(g(a)("Clone from GitHub")),11,$F)],8,RF),p("label",jF,[p("span",LF,T(g(a)("Destination folder")),1),Lt(p("input",{"onUpdate:modelValue":f[32]||(f[32]=x=>Ps.value=x),class:"new-thread-open-folder-path",type:"text",disabled:Lo.value,placeholder:g(a)("Destination folder")},null,8,NF),[[an,Ps.value]])]),jo.value==="create"?(S(),I("label",OF,[p("span",DF,T(g(a)("Project name")),1),Lt(p("input",{ref_key:"projectSetupPrimaryInputRef",ref:Nl,"onUpdate:modelValue":f[33]||(f[33]=x=>hi.value=x),class:"new-thread-open-folder-create-input",type:"text",disabled:Lo.value,placeholder:g(a)("Project name"),onKeydown:An(lt(Id,["prevent"]),["enter"])},null,40,FF),[[an,hi.value]])])):jo.value==="clone"?(S(),I("label",UF,[p("span",BF,T(g(a)("GitHub repository URL")),1),Lt(p("input",{ref_key:"projectSetupPrimaryInputRef",ref:Nl,"onUpdate:modelValue":f[34]||(f[34]=x=>mi.value=x),class:"new-thread-open-folder-create-input",type:"url",disabled:Lo.value,placeholder:"https://github.com/owner/repo",onKeydown:An(lt(Id,["prevent"]),["enter"])},null,40,qF),[[an,mi.value]])])):ee("",!0),Ma.value?(S(),I("div",zF,[p("span",null,T(Ma.value),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[35]||(f[35]=x=>In(x,Ma.value))},T(g(a)("Send feedback")),9,HF)])):ee("",!0),p("div",WF,[p("button",{class:"new-thread-folder-action",type:"button",disabled:Lo.value,onClick:nu},T(g(a)("Cancel")),9,VF),p("button",{class:"new-thread-folder-action new-thread-folder-action-primary",type:"button",disabled:!L.value||Lo.value,onClick:Id},T(he.value),9,GF)])],40,AF)],32)):ee("",!0)])),ns.value?(S(),tt(v$,{key:2,class:"new-thread-runtime-dropdown",modelValue:Fn.value,"onUpdate:modelValue":f[36]||(f[36]=x=>Fn.value=x)},null,8,["modelValue"])):ee("",!0),Fn.value==="worktree"?(S(),I("div",KF,[p("p",YF,T(g(a)("Base branch")),1),Ie(or,{class:"new-thread-branch-dropdown","model-value":mo.value,options:i.value,placeholder:g(a)("Select branch"),"enable-search":!0,"search-placeholder":g(a)("Search branches..."),disabled:En.value||i.value.length===0,"onUpdate:modelValue":nb},null,8,["model-value","options","placeholder","search-placeholder","disabled"]),p("p",JF,T(En.value?g(a)("Loading branches…"):u.value?g(a)("New worktree branch will start from {branch}.",{branch:u.value}):g(a)("No Git branches found for this folder.")),1)])):ee("",!0),ns.value?(S(),I("p",QF,T(g(a)("Local project uses the selected folder directly. New worktree creates an isolated Git worktree before the first prompt.")),1)):ee("",!0),yn.value.phase!=="idle"?(S(),I("div",{key:5,class:Ke(["worktree-init-status",{"is-running":yn.value.phase==="running","is-error":yn.value.phase==="error"}])},[p("strong",XF,T(yn.value.title),1),p("span",ZF,T(yn.value.message),1)],2)):ee("",!0)]),p("div",eU,[g(Ue)?(S(),I("div",tU,[p("span",null,T(g(a)(g(Ue))),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[37]||(f[37]=x=>In(x,g(Ue)))},T(g(a)("Send feedback")),9,nU)])):ee("",!0),Ie(Zm,{ref_key:"homeThreadComposerRef",ref:Gr,"active-thread-id":yr.value,cwd:mn.value,"fuzzy-file-search-results":g(ge),onRegisterFuzzySession:g(Fe),"collaboration-modes":g(Le),"selected-collaboration-mode":g(Te),models:g(je),"model-reasoning-efforts":g(fe),"selected-model":Ms.value,"selected-reasoning-effort":g(xe),"selected-speed-mode":g(Ae),"is-updating-speed-mode":g(te),skills:g(Ye),"thread-token-usage":g(U),"codex-quota":g($e),"is-turn-in-progress":!1,"is-stop-pending":!1,"is-interrupting-turn":!1,"send-with-enter":ta.value,"in-progress-submit-mode":Ea.value,"dictation-click-to-toggle":Zo.value,"dictation-auto-send":oa.value,"dictation-language":Ra.value,onSubmit:zp,"onUpdate:selectedCollaborationMode":rh,"onUpdate:selectedModel":Qp,"onUpdate:selectedReasoningEffort":Xp,"onUpdate:selectedSpeedMode":Zp,"approval-policy":Zt.value,"is-approval-policy-saving":Ts.value,"approval-policy-error":no.value,"approval-policy-notice":dr.value,"onUpdate:approvalPolicy":_a,onSaveApprovalPolicy:$n,onSlashCommand:eh},null,8,["active-thread-id","cwd","fuzzy-file-search-results","onRegisterFuzzySession","collaboration-modes","selected-collaboration-mode","models","model-reasoning-efforts","selected-model","selected-reasoning-effort","selected-speed-mode","is-updating-speed-mode","skills","thread-token-usage","codex-quota","send-with-enter","in-progress-submit-mode","dictation-click-to-toggle","dictation-auto-send","dictation-language","approval-policy","is-approval-policy-saving","approval-policy-error","approval-policy-notice"])])])):(S(),I("div",oU,[Gn.value&&g(de)&&mn.value?(S(),tt(g(o),{key:0,"thread-id":g(de),cwd:mn.value,"is-thread-in-progress":Ti.value,"initial-file-path":Ir.value,"commit-sha":Xr.value,onClose:f[38]||(f[38]=x=>Gn.value=!1)},null,8,["thread-id","cwd","is-thread-in-progress","initial-file-path","commit-sha"])):(S(),I(ze,{key:1},[p("div",rU,[Ie(g(t),{ref_key:"threadConversationRef",ref:ka,messages:ki.value,"is-loading":g(ft),"active-thread-id":yr.value,cwd:mn.value,"live-overlay":gd.value,"live-turn-id":g(we),"pending-requests":g(V),"has-more-persisted-above":g(ct),"is-loading-persisted-above":g(mt),"load-earlier-messages":g(be),onForkThread:zw,onRollback:Mb,onFileChangesChanged:qc,onRespondServerRequest:Lp},null,8,["messages","is-loading","active-thread-id","cwd","live-overlay","live-turn-id","pending-requests","has-more-persisted-above","is-loading-persisted-above","load-earlier-messages"])]),p("div",{class:"composer-with-queue",ref_key:"composerQueueRef",ref:nn},[Fc.value?(S(),I("div",aU,T(g(a)("This thread is running in the Codex TUI")),1)):ee("",!0),g(Ue)?(S(),I("div",sU,[p("span",null,T(g(a)(g(Ue))),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[39]||(f[39]=x=>In(x,g(Ue)))},T(g(a)("Send feedback")),9,iU)])):ee("",!0),Ie(n$,{messages:g(W),onEdit:eb,onSteer:g(Oe),onDelete:g(Y),onReorder:Eb},null,8,["messages","onSteer","onDelete"]),Jl.value?(S(),I("div",lU,[p("span",null,T(Jl.value),1),p("button",{type:"button",class:"interrupt-recovered-dismiss","aria-label":g(a)("Dismiss"),onClick:f[40]||(f[40]=x=>Jl.value="")}," × ",8,cU)])):ee("",!0),Zi.value?(S(),tt(HM,{key:3,request:Zi.value,"request-count":g(V).length,"has-queue-above":g(W).length>0,"panel-width":Kr.value,"visual-viewport-height":Ci.value?La.value:0,"panel-error":zl.value,onRespondServerRequest:Lp},null,8,["request","request-count","has-queue-above","panel-width","visual-viewport-height","panel-error"])):(S(),tt(Zm,{key:4,ref_key:"threadComposerRef",ref:Ao,"active-thread-id":yr.value,cwd:mn.value,"fuzzy-file-search-results":g(ge),onRegisterFuzzySession:g(Fe),"collaboration-modes":g(Le),"selected-collaboration-mode":g(Te),models:g(je),"model-reasoning-efforts":g(fe),"selected-model":Ms.value,"selected-reasoning-effort":g(xe),"selected-speed-mode":g(Ae),"is-updating-speed-mode":g(te),skills:g(Ye),"thread-token-usage":g(U),"codex-quota":g($e),"is-turn-in-progress":Ti.value,"is-stop-pending":g(ae),"is-interrupting-turn":g(at),"is-compacting":Ur.value,"external-session-active":Fc.value,"has-queue-above":g(W).length>0,"send-with-enter":ta.value,"in-progress-submit-mode":Ea.value,"dictation-click-to-toggle":Zo.value,"dictation-auto-send":oa.value,"dictation-language":Ra.value,"onUpdate:selectedCollaborationMode":rh,onSubmit:zp,"onUpdate:selectedModel":Qp,"onUpdate:selectedReasoningEffort":Xp,"onUpdate:selectedSpeedMode":Zp,"approval-policy":Zt.value,"is-approval-policy-saving":Ts.value,"approval-policy-error":no.value,"approval-policy-notice":dr.value,"onUpdate:approvalPolicy":_a,onSaveApprovalPolicy:$n,"plan-panel":ql.value,onInterrupt:Rb,onSlashCommand:eh,onImplementPlan:$b,onCompactContext:bd},null,8,["active-thread-id","cwd","fuzzy-file-search-results","onRegisterFuzzySession","collaboration-modes","selected-collaboration-mode","models","model-reasoning-efforts","selected-model","selected-reasoning-effort","selected-speed-mode","is-updating-speed-mode","skills","thread-token-usage","codex-quota","is-turn-in-progress","is-stop-pending","is-interrupting-turn","is-compacting","external-session-active","has-queue-above","send-with-enter","in-progress-submit-mode","dictation-click-to-toggle","dictation-auto-send","dictation-language","approval-policy","is-approval-policy-saving","approval-policy-error","approval-policy-notice","plan-panel"]))],512)],64))]))])],6),g(ht)&&Mn.value?(S(),I("div",{key:0,class:"content-right-panel-backdrop",role:"presentation",onClick:Dp})):ee("",!0),el.value&&(g(ht)||!Io.value)?(S(),I("aside",{key:1,class:Ke(["content-right-panel",{"is-mobile-open":Mn.value}]),style:kr({"--right-panel-width":`${ho.value}px`})},[g(ht)?ee("",!0):(S(),I("div",{key:0,class:"content-right-panel-resize-handle","aria-hidden":"true",onMousedown:Wo},null,32)),p("div",uU,[p("div",dU,[p("button",{class:Ke(["content-right-panel-tab",{"is-active":$t.value==="git"}]),type:"button",role:"tab","aria-selected":$t.value==="git",onClick:f[41]||(f[41]=x=>_i("git"))},[Ie(Gu,{class:"content-right-panel-tab-icon"}),ps(" "+T(g(a)("Git")),1)],10,fU),p("button",{class:Ke(["content-right-panel-tab",{"is-active":$t.value==="files"}]),type:"button",role:"tab","aria-selected":$t.value==="files",onClick:f[42]||(f[42]=x=>_i("files"))},[Ie(nv,{class:"content-right-panel-tab-icon"}),ps(" "+T(g(a)("Files")),1)],10,pU),(S(!0),I(ze,null,_t(zn.value,x=>(S(),I("button",{key:x.key,class:Ke(["content-right-panel-tab content-right-panel-tab--preview",{"is-active":$t.value==="preview"&&po.value===x.key}]),type:"button",role:"tab","aria-selected":$t.value==="preview"&&po.value===x.key,title:x.path,onClick:N=>Ww(x.key)},[Ie(Bi,{class:"content-right-panel-tab-icon"}),p("span",mU,T(x.label),1),p("span",{class:"content-right-panel-tab-close",role:"button","aria-label":g(a)("Close"),title:g(a)("Close"),onClick:lt(N=>Vw(x.key),["stop"])},"×",8,vU)],10,hU))),128))]),p("div",gU,[p("div",yU,[p("button",{ref:"rightPanelAddButtonRef",class:"content-right-panel-add",type:"button","aria-label":g(a)("Add panel"),title:g(a)("Add panel"),onClick:f[43]||(f[43]=lt(x=>Xn.value=!Xn.value,["stop"]))},"+",8,wU),Ie(Mc,{name:"right-panel-menu"},{default:yt(()=>[Xn.value?(S(),I("div",bU,[p("button",{type:"button",onClick:f[44]||(f[44]=x=>_i("terminal"))},[Ie(XL,{class:"content-right-panel-menu-icon"}),ps(" "+T(g(a)("Terminal panel")),1)]),p("button",{type:"button",onClick:f[45]||(f[45]=x=>_i("git"))},[Ie(Gu,{class:"content-right-panel-menu-icon"}),ps(" "+T(g(a)("Git panel")),1)]),p("button",{type:"button",onClick:f[46]||(f[46]=x=>_i("files"))},[Ie(nv,{class:"content-right-panel-menu-icon"}),ps(" "+T(g(a)("Files panel")),1)])])):ee("",!0)]),_:1})]),p("button",{class:"content-right-panel-close",type:"button","aria-label":g(a)("Close panel"),title:g(a)("Close panel"),onClick:Dp},[Ie(Ru,{class:"content-right-panel-close-icon"})],8,kU)])]),p("div",CU,[$t.value==="git"?(S(),tt(uL,{key:0,"current-branch":Zr.value,"head-sha":xa.value,"head-subject":hr.value,"head-date":Aa.value,detached:Mo.value,dirty:Ga.value,"worktree-change-summary":Er.value,"worktree-changes":wo.value,branches:pr.value,"commits-by-branch":qe.value,"commits-loading-for":ke.value,"commits-error":Un.value,"commit-files-by-sha":Pa.value,"commit-files-loading-for":mr.value,"commit-files-error":_s.value,loading:cn.value,busy:ea.value,error:Rr.value,"review-open":Gn.value,"show-review":g(Et).name==="thread"&&g(de).length>0,onToggleReview:lb,onCheckoutBranch:rb,onResetBranchToCommit:ab,onLoadCommits:Vp,onLoadCommitFiles:sb,onOpenCommitFile:ib},null,8,["current-branch","head-sha","head-subject","head-date","detached","dirty","worktree-change-summary","worktree-changes","branches","commits-by-branch","commits-loading-for","commits-error","commit-files-by-sha","commit-files-loading-for","commit-files-error","loading","busy","error","review-open","show-review"])):$t.value==="files"?(S(),tt(_L,{key:1,cwd:mn.value,onOpenPreview:Hw},null,8,["cwd"])):$t.value==="preview"&&Hn.value?(S(),tt(BL,{key:2,"file-path":Hn.value.path,name:Hn.value.label},null,8,["file-path","name"])):(S(),tt(g(n),{key:3,ref_key:"threadTerminalPanelRef",ref:Jn,"thread-id":yr.value,cwd:mn.value,onHide:Kw,onTerminalFocusChange:Yw},null,8,["thread-id","cwd"]))])],6)):ee("",!0)])]),_:1},8,["is-sidebar-collapsed"]),xt.value.phase!=="idle"?(S(),I("div",TU,[p("div",{class:"project-zip-modal",role:"dialog","aria-modal":"true","aria-label":g(a)("Export Project"),onClick:f[48]||(f[48]=lt(()=>{},["stop"]))},[p("div",_U,[p("h2",xU,T(g(a)("Export Project")),1),p("button",{class:"project-zip-modal-close",type:"button","aria-label":g(a)("Close"),disabled:xt.value.phase==="exporting",onClick:$p}," × ",8,AU)]),p("p",PU,T(xt.value.phase==="exporting"?g(a)("Preparing project ZIP..."):xt.value.fileName),1),p("div",IU,[p("span",null,T(xt.value.phase==="exporting"?g(a)("Exporting"):g(a)("Ready")),1),p("span",null,T(Ll.value),1)]),p("div",EU,[p("div",{class:"project-zip-progress-fill",style:kr({width:pi.value})},null,4)]),xt.value.error?(S(),I("p",RU,T(xt.value.error),1)):ee("",!0),p("div",MU,[p("button",{class:"project-zip-modal-cancel",type:"button",disabled:xt.value.phase==="exporting",onClick:$p},T(g(a)("Close")),9,$U),p("button",{class:"project-zip-modal-action",type:"button",disabled:!xt.value.blob,onClick:Mw},T(g(a)("Download")),9,jU),p("button",{class:"project-zip-modal-action project-zip-modal-action-primary",type:"button",disabled:!xt.value.blob,onClick:$w},T(g(a)("Share")),9,LU)])],8,SU)])):ee("",!0),Ya.value?(S(),I("div",{key:1,class:"codex-login-modal-backdrop",role:"presentation",onClick:Sd},[p("form",{class:"codex-login-modal",role:"dialog","aria-modal":"true","aria-label":g(a)("Complete Codex login"),onSubmit:lt(vw,["prevent"]),onClick:f[51]||(f[51]=lt(()=>{},["stop"]))},[p("div",OU,[p("h2",DU,T(g(a)("Complete Codex login")),1),p("button",{class:"codex-login-modal-close",type:"button","aria-label":g(a)("Close"),disabled:Ln.value,onClick:Sd}," × ",8,FU)]),p("p",UU,T(g(a)("Finish login in the browser, then paste the localhost callback URL here.")),1),Ia.value?(S(),I("a",{key:0,class:"codex-login-modal-link",href:Ia.value,target:"_blank",rel:"noreferrer"},T(g(a)("Open login URL")),9,BU)):ee("",!0),Lt(p("input",{ref_key:"codexLoginCallbackInputRef",ref:fi,"onUpdate:modelValue":f[49]||(f[49]=x=>$r.value=x),class:"codex-login-modal-input",type:"url",inputmode:"url",placeholder:g(a)("Paste localhost callback URL"),disabled:Ln.value},null,8,qU),[[an,$r.value]]),wn.value?(S(),I("div",zU,[p("span",null,T(wn.value),1),p("a",{class:"visible-error-feedback",href:g(Dn),onClick:f[50]||(f[50]=x=>In(x,wn.value))},T(g(a)("Send feedback")),9,HU)])):ee("",!0),p("div",WU,[p("button",{class:"codex-login-modal-cancel",type:"button",disabled:Ln.value,onClick:Sd},T(g(a)("Cancel")),9,VU),p("button",{class:"codex-login-modal-submit",type:"submit",disabled:Ln.value||$r.value.trim().length===0},T(Ln.value?g(a)("Completing…"):g(a)("Complete")),9,GU)])],40,NU)])):ee("",!0)],64))}}),ZU=bt(XU,[["__scopeId","data-v-7c7078e5"]]),xu={render:()=>null},eB=JT({history:PT(),routes:[{path:"/",name:"home",component:xu},{path:"/thread/:threadId",name:"thread",component:xu},{path:"/skills",name:"skills",component:xu},{path:"/automations",name:"automations",component:xu},{path:"/new-thread",redirect:{name:"home"}},{path:"/:pathMatch(.*)*",redirect:{name:"home"}}]});console.log("Welcome to codex-mobile-re. github: https://github.com/cattails-lgao/codex-mobile");b1();FC(ZU).use(eB).mount("#app");"serviceWorker"in navigator&&window.addEventListener("load",()=>{navigator.serviceWorker.register("/sw.js").catch(e=>{console.error(Iy("Service worker registration failed."),e)})});export{An as $,mu as A,yp as B,Wt as C,ov as D,nB as E,ze as F,cp as G,hI as H,Ru as I,nc as J,ej as K,O_ as L,HN as M,ws as N,C_ as O,fB as P,uB as Q,pB as R,dB as S,Xs as T,hB as U,or as V,RB as W,$B as X,MB as Y,tB as Z,bt as _,I as a,_p as a0,Lt as a1,an as a2,XT as a3,QT as a4,s_ as a5,mB as a6,oB as a7,rB as a8,aB as a9,bB as aa,_B as ab,xB as ac,vB as ad,SB as ae,iB as af,sB as ag,lB as ah,cB as ai,AB as aj,IB as ak,EB as al,gB as am,yB as an,wB as ao,kB as ap,TB as aq,CB as ar,PB as as,g_ as at,y_ as au,Ys as av,xI as aw,p as b,tt as c,tn as d,ee as e,ps as f,Ie as g,Mc as h,yt as i,io as j,X as k,nt as l,qi as m,Ke as n,S as o,kr as p,A as q,_t as r,Oy as s,T as t,g as u,xp as v,lt as w,Gu as x,rr as y,Js as z};
|