import{n as e}from"./chunk-DR8-3Aex.js";import{Rn as t,b as n,t as r,x as i}from"./src-Di342QoJ.js";import{t as a}from"./jsx-runtime-D-D469L8.js";import{cn as o,rn as s}from"./state-sIHsFpDu.js";import{Ax as c,FD as l,_y as u,by as d,gy as f,j as p,jD as m,w as h,zx as g}from"./loadAgentsDir-C_wFhytF.js";import{a as _,i as v,r as y,t as b}from"./promptEditor-Dz41P-3I.js";import{r as x,t as S}from"./staticRender-C5v46np_.js";function C({planContent:e,planPath:t,editorName:r}){return(0,T.jsxs)(i,{flexDirection:`column`,children:[(0,T.jsx)(n,{bold:!0,children:`Current Plan`}),(0,T.jsx)(n,{dimColor:!0,children:t}),(0,T.jsx)(i,{marginTop:1,children:(0,T.jsx)(n,{children:e})}),r&&(0,T.jsxs)(i,{marginTop:1,children:[(0,T.jsx)(n,{dimColor:!0,children:`"/plan open"`}),(0,T.jsx)(n,{dimColor:!0,children:` to edit this plan in `}),(0,T.jsx)(n,{bold:!0,dimColor:!0,children:r})]})]})}async function w(e,t,n){let{getAppState:r,setAppState:i}=t,a=r().toolPermissionContext.mode;if(a!==`plan`){s(a,`plan`),i(e=>({...e,toolPermissionContext:m(p(e.toolPermissionContext),{type:`setMode`,mode:`plan`,destination:`session`})}));let t=n.trim();return t&&t!==`open`?e(`Enabled plan mode`,{shouldQuery:!0}):e(`Enabled plan mode`),null}let o=f(),c=u();if(!o)return e(`Already in plan mode. No plan written yet.`),null;if(n.trim().split(/\s+/)[0]===`open`){let t=await b(c);return t.error?e(`Failed to open plan in editor: ${t.error}`):e(`Opened plan in editor: ${c}`),null}let l=v();return e(await x((0,T.jsx)(C,{planContent:o,planPath:c,editorName:l?g(l):void 0}))),null}var T;e((()=>{t(),o(),r(),_(),c(),l(),h(),d(),y(),S(),T=a()}))();export{w as call};