import{A as y,g as C,t as b,u as w,y as j}from"./chunk-HLTU4WIU.mjs";import{f as h,k as p,l as e}from"./chunk-C74EET73.mjs";e();var S=h(j());e();var r=h(b());import{join as N}from"path";var s,f=N(p,"_storage.json");async function R(i){return!s&&(0,r.existsSync)(f)&&(s=await(0,r.readJsonSync)(f).catch(()=>({}))||{}),i&&await i(s)&&await d(),s}var d=async()=>s&&await(0,r.writeJson)(f,s);y(async(i,o,a)=>{let n=await R();if(o[0]==="-"&&(n.lastRunCommand||(console.error("No last command found"),process.exit(1)),o[0]=n.lastRunCommand),o.length===0){let l=w(a==null?void 0:a.cwd),u=l.scripts||{},P=l["scripts-info"]||{},g=Object.entries(u);if(!g.length)return;let m=g.filter(t=>!t[0].startsWith("?")).map(([t,c])=>({title:t,value:t,description:P[t]||u[`?${t}`]||c}));if(n.lastRunCommand){let t=m.find(c=>c.value===n.lastRunCommand);t&&m.unshift(t)}try{let{fn:t}=await(0,S.default)({name:"fn",message:"script to run",type:"autocomplete",choices:m});if(!t)return;o.push(t)}catch{process.exit(1)}}return n.lastRunCommand!==o[0]&&(n.lastRunCommand=o[0],d()),C(i,o)});
//# sourceMappingURL=nr.mjs.map