import{n as u}from"./chunk-2HZMOK4U.js";import{b as g}from"./chunk-Q6LCSRIW.js";import{b as y}from"./chunk-IDKUJQIG.js";import{d as r}from"./chunk-ELIH6GCC.js";import{Lb as v,Mb as w,ua as l,wa as m}from"./chunk-EYDNSYYE.js";import{f as p,i as h}from"./chunk-773TIA5M.js";import{r as R}from"./chunk-T6CC5WUU.js";import{e as A,g as s}from"./chunk-VKWPEFWQ.js";s();s();var U="text/markdown",L="X-Shopify-Surface",E="cli",F=["shopify.dev"];async function S(t,e){let c;try{c=new URL(t)}catch{throw new r(`Invalid URL: ${t}`)}let{hostname:d}=c;if(!F.some(o=>d===o||d.endsWith(`.${o}`)))throw new r(`Only documents from the following hosts can be fetched: ${F.join(", ")}.`);let i=await u(t,{headers:{Accept:U,[L]:E}});if(!i.ok)throw new r(`Failed to fetch ${t}: ${i.status} ${i.statusText}`);let f=await i.text();if(e){let o=p(e);await m(h(o)),await l(o,f),w(`Saved ${t} to ${o}`);return}v(f)}var n=A(R(),1),a=class t extends y{static{this.description="Download a complete document from shopify.dev. Every page on shopify.dev has a Markdown version, and that is what this tool returns. Use this to pull an entire document verbatim \u2014 for example, a set of instructions an agent follows like a centrally-served skill. For finding the relevant pieces of content across shopify.dev instead, use `doc search`."}static{this.examples=[`# fetch the Markdown version of a Shopify.dev page
shopify doc fetch --url https://shopify.dev/docs/api/shopify-cli`,`# save the document to a file instead of printing it
shopify doc fetch --url https://shopify.dev/docs/api/shopify-cli --output docs/shopify-cli.md`]}static{this.flags={...g,url:n.Flags.string({description:"The shopify.dev URL to fetch.",env:"SHOPIFY_FLAG_URL",required:!0}),output:n.Flags.string({description:"Write the document to this file path instead of printing it to stdout.",env:"SHOPIFY_FLAG_OUTPUT"})}}async run(){let{flags:e}=await this.parse(t);await S(e.url,e.output)}};export{a};
