import{t as e}from"./config-BYRrjYC5.mjs";import{t}from"./cache-DUthuMSu.mjs";import{t as n}from"./got-BBDj7u1e.mjs";import{t as r}from"./utils-h84f_tmt.mjs";const i={path:`/news/:lang?/:id?`,categories:[`traditional-media`],example:`/dw/news`,parameters:{lang:`Language, see below, default to en`,id:`Category ID, see below, default to the id of the Top Stories Page of the language chosen`},features:{requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1,requireConfig:!1},name:`News`,maintainers:[`quiniapiezoelectricity`],handler:o,description:`
::: tip
Parameters can be obtained from the official website, for instance:
For the site https://www.dw.com/de/deutschland/s-12321 the language code would be \`de\` and the category ID would be \`s-1432\`.
:::
`,radar:[{source:[`www.dw.com/:lang/:name/:id`],target:`/news/:lang/:id`}]},a=new Set([`Article`,`Liveblog`,`Video`]);async function o(i){let o=i.req.param(`lang`)??`en`,s=i.req.param(`id`);/^s-\d+$/.test(s)?s=s.match(/^s-(\d+)$/i)[1]:s===void 0&&(s=(await t.tryGet(`dw:navigation`,async()=>(await n(`https://www.dw.com/graph-api/en/content/navigation/9097`)).data.data.content.topStoriesNavigations,e.cache.routeExpire,!1)).map(e=>e.namedUrl.split(`/`)).find(e=>e[1]===o)[3].match(/^s-(\d+)$/i)[1]);let c=(await n(`https://www.dw.com/graph-api/${o}/content/navigation/${s}`)).data.data.content;t.set(`dw:navigation`,c.topStoriesNavigations,e.cache.routeExpire);let l=await r(c.contentComposition.informationSpaces.flatMap(e=>Object.values(e).flatMap(e=>e[0]?.contents||[])).filter(e=>a.has(e.__typename)&&e.id).map(e=>(e.link=new URL(e.namedUrl,`https://www.dw.com`).href,e.pubDate=e.contentDate,e.description=e.teaser,e.language=o,e.type=e.__typename.toLowerCase(),e)));return{title:`DW | ${c.title}`,link:c.canonicalUrl,description:c.metaDescription,language:c.topStoriesNavigations.find(e=>e.namedUrl.startsWith(`/${o}/`))?.localeLang??o,item:l}}export{i as route};