import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./parse-date-BdYTmLpo.mjs";import{load as n}from"cheerio";const r={path:`/central/:group/:artifact`,name:`Maven Central Feed`,maintainers:[`chrisis58`],description:`Get the latest versions of a Maven artifact from Maven Central Repository.`,url:`central.sonatype.com/`,categories:[`programming`],parameters:{group:{description:`The group ID of the Maven artifact (e.g., org.springframework)`},artifact:{description:`The artifact ID of the Maven artifact (e.g., spring-core)`}},example:`/maven/central/org.springframework/spring-core`,radar:[{source:[`central.sonatype.com/artifact/:group/:artifact/:suffix`,`central.sonatype.com/artifact/:group/:artifact`],target:`/maven/central/:group/:artifact`}],features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportRadar:!0,supportBT:!1,supportPodcast:!1,supportScihub:!1,nsfw:!1},handler:o},i=/[-_.]?(rc|m|snapshot|alpha|beta|preview|canary)[.\d]*$/i,a=/(\d{4}-\d{2}-\d{2} \d{2}:\d{2})/;async function o(r){let o=r.req.param(`group`),s=r.req.param(`artifact`),c=r.req.query(`limit`)?Number.parseInt(r.req.query(`limit`),10):15,l=`${o.replaceAll(`.`,`/`)}/${s}`;try{if(!n(await e(`https://repo1.maven.org/maven2/${l}/maven-metadata.xml`),{xmlMode:!0})(`metadata > versioning > latest`).text())throw Error(`Not a valid component for ${o}:${s}: versions not found`)}catch(e){throw e?.response?.status===404?Error(`Could not find component for ${o}:${s}: metadata not found`,{cause:e}):e}let u=n(await e(`https://repo1.maven.org/maven2/${l}/`)),d=u(`pre#contents a`).toArray().filter(e=>{let t=u(e).attr(`href`)??``;return t.endsWith(`/`)&&t!==`../`}).map(e=>{let n=(u(e).attr(`href`)??``).replace(`/`,``),r=`https://central.sonatype.com/artifact/${o}/${s}/${n}`,c=(e.nextSibling?e.nextSibling.nodeValue:``).match(a),l;c&&(l=t(c[1],`YYYY-MM-DD HH:mm`));let d=i.test(n)?`Unstable`:`Stable`;return{title:`Version ${n} of ${o}:${s}`,link:r,pubDate:l,description:`Released version ${n} of ${o}:${s}.`,category:[d]}}).filter(e=>!!e&&e.pubDate!==void 0).toSorted((e,t)=>(t.pubDate?.getTime()??0)-(e.pubDate?.getTime()??0)).slice(0,c);return{title:`Maven Central - ${o}:${s}`,link:`https://central.sonatype.com/artifact/${o}/${s}`,description:`Versions of ${o}:${s} available on Maven Central.`,item:d}}export{r as route};