import{t as e}from"./cache-DUthuMSu.mjs";import{t}from"./parse-date-BdYTmLpo.mjs";import{t as n}from"./got-BBDj7u1e.mjs";import{t as r}from"./timezone-keeL11Io.mjs";import{t as i}from"./invalid-parameter-DLv2wPKB.mjs";import{Fragment as a,jsxs as o}from"hono/jsx/jsx-runtime";import{load as s}from"cheerio";import{renderToString as c}from"hono/jsx/dom/server";import{raw as l}from"hono/html";const u=(e,t)=>e.startsWith(`http`)?e:`${t}${e}`,d={path:`/:language?/:keyword?`,categories:[`traditional-media`],example:`/kyodonews`,parameters:{language:"语言: `china` = 简体中文 (默认), `tchina` = 繁體中文",keyword:`关键词`},features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`china.kyodonews.net/news/:keyword`,`china.kyodonews.net/`],target:`/china/:keyword?`},{source:[`tchina.kyodonews.net/news/:keyword`,`tchina.kyodonews.net/`],target:`/tchina/:keyword?`}],name:`最新报道`,maintainers:[`Rongronggg9`],handler:f,description:"`keyword` 为关键词，由于共同网有许多关键词并不在主页列出，此处不一一列举，可从关键词页的 URL 的最后一级路径中提取。如 `日中关系` 的关键词页 URL 为 `https://china.kyodonews.net/news/japan-china_relationship`, 则将 `japan-china_relationship` 填入 `keyword`。特别地，当填入 `rss` 时，将从共同网官方 RSS 中抓取文章；略去时，将从首页抓取最新报道 (注意：首页更新可能比官方 RSS 稍慢)。"};async function f(d){let f=d.req.param(`language`)??`china`,p=d.req.param(`keyword`)===`RSS`?`rss`:d.req.param(`keyword`)??``;if(![`china`,`tchina`].includes(f))throw new i(`Invalid language`);let m=`https://${f}.kyodonews.net`,h=`${m}/${p?p===`rss`?`list/feed/rss4news`:`news/${p}`:``}`,g;try{g=await n(h)}catch(e){throw e.response&&e.response.statusCode===404?new i(`Invalid keyword`):e}let _=s(g.data,{xmlMode:p===`rss`}),v,y,b,x;return b=`https://${f}-kyodo.ismcdn.jp/common/images/apple-touch-icon-180x180.png`,p===`rss`?(v=_(`channel > title`).text(),y=_(`channel > description`).text(),x=_(`item`).toArray().map(e=>({link:_(e).find(`link`).text()}))):(v=_(`head > title`).text(),y=_(`meta[name="description"]`).attr(`content`),b=u(_(`head > link[rel="apple-touch-icon"]`).attr(`href`),m)||b,x=_(`.m-article-wrap:first-of-type .m-article-item__link`).toArray().map(e=>(e=_(e),{link:u(e.attr(`href`),m)}))),x=await Promise.all(x.map(i=>e.tryGet(i.link,async()=>{let e=s((await n(i.link)).data);i.title=e(`head > title`).text(),i.author=e(`meta[name="author"]`).attr(`content`);let u=e(`.article-header-img`).html();u=u?u.trim():``;let d=e(`div.article-body`).html();d=d?d.trim().replace(/（完）(?=<\/p>\s*$)/m,``):``,i.description=c(o(a,{children:[u?l(u):null,d?l(d):null]}));let f=JSON.parse(e(`script[type="application/ld+json"]`).text()||`[]`).find(e=>e[`@type`]===`NewsArticle`),p=f&&f.datePublished,m=f&&f.dateModified;return p&&(i.pubDate=r(t(p),9)),m&&(i.updated=r(t(m),9)),i.category=e(`.article-header-cate__link`).toArray().map(t=>e(t).text()),i}))),{title:v,description:y,link:h,item:x,image:b}}export{d as route};