var u=(n,r,t)=>new Promise((s,i)=>{var o=e=>{try{a(t.next(e))}catch(m){i(m)}},c=e=>{try{a(t.throw(e))}catch(m){i(m)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(o,c);a((t=t.apply(n,r)).next())});function g(n){return u(this,null,function*(){let{stdout:r}=yield n({command:"zsh",args:["-c","cat ${${ZSHZ_DATA:-${_Z_DATA:-${HOME}/.z}}:A}"]});return r.split(`
`).map(t=>{let[s,i,o]=t.split("|"),c=s.split("/");return{name:c[c.length-1],path:s,weight:75+Number(i)*25/9e3,time:Number(o)}})})}function p(n,r){return u(this,null,function*(){let{stdout:t}=yield r({command:"bash",args:["-c","ls -d */"]});return t.split(`
`).map(s=>{let i=s.replace("/","");return{name:i,path:`${n}/${i}`}})})}function l(n,r){let t=new Set(n);return r.filter(({name:s,path:i})=>!t.has(s)&&n.every(o=>i.includes(o)))}var h={name:"z",description:"CLI tool to jump around directories",args:{name:"directory",isVariadic:!0,isOptional:!0,generators:{custom:(n,r,t)=>u(void 0,null,function*(){let{currentWorkingDirectory:s}=t,[i,o]=yield Promise.all([g(r),p(s,r)]),c=[...i,...o].reduce((e,m)=>(e.some(({path:d})=>d===m.path)||e.push(m),e),[]);return l(n.filter(e=>e&&e!=="z"&&!e.startsWith("-")),c).map(e=>({name:e.name,icon:"\u{1F4C1}",description:e.path,priority:e.weight,insertValue:e.name,displayName:e.name}))})}},options:[{name:"-c",description:"Restrict matches to subdirectories of the current directory"},{name:"-e",description:"Echo the best match, don't cd"},{name:"-h",description:"Show a brief help message"},{name:"-l",description:"List only"},{name:"-r",description:"Match by rank only"},{name:"-t",description:"Match by recent access only"},{name:"-x",description:"Remove the current directory from the datafile"}]},y={name:"z",description:"Smarter cd command, inspired by z and autojump",args:{name:"directory",filterStrategy:"fuzzy",suggestCurrentToken:!0,isVariadic:!0,generators:{custom:(n,r)=>u(void 0,null,function*(){let t;n.length<2||n[1]===""?t=["query","--list","--score"]:t=["query","--list","--score","--",n.slice(1).join(" ")];let{stdout:s}=yield r({command:"zoxide",args:t});return s.split(`
`).map(i=>{let o=i.trim(),c=o.indexOf(" "),a=Number(o.slice(0,c));return{name:o.slice(c+1),description:`Score: ${a}`}})}),trigger:{on:"change"}}}},S={name:"z",generateSpec:(n,r)=>u(void 0,null,function*(){try{let{status:t}=yield r({command:"bash",args:["-c","command -v zoxide"]});if(t===0)return y}catch(t){}return h})},z=S;export{z as default};
