import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./cache-DUthuMSu.mjs";import{t as n}from"./parse-date-BdYTmLpo.mjs";import{t as r}from"./timezone-keeL11Io.mjs";import{load as i}from"cheerio";const a={path:`/topic/:topic?`,categories:[`new-media`],example:`/ctinews/topic/KDdek5vgXx`,parameters:{topic:"話題 ID，可在 URL 中獲取，留空為 `KDdek5vgXx`"},features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`ctinews.com/news/topics/:topic`,`ctinews.com`]}],name:`話題`,maintainers:[`TonyRL`],handler:o,url:`ctinews.com`};async function o(a){let{topic:o=`KDdek5vgXx`}=a.req.param(),s=`https://www.ctinews.com`,c=`${s}/news/topics/${o}`,l=i(await e(c)),u=[...l(`.hero-news__layer .news-link`).toArray().map(e=>{let t=l(e);return{title:t.attr(`title`),link:t.attr(`href`)?.startsWith(`http`)?t.attr(`href`):s+t.attr(`href`)}}),...l(`.second-section .news-link`).toArray().map(e=>{let t=l(e);return{title:t.attr(`title`),link:t.attr(`href`)?.startsWith(`http`)?t.attr(`href`):s+t.attr(`href`)}}),...l(`.news-section .news-link.absolute`).toArray().map(e=>{let t=l(e);return{title:t.attr(`title`)?.replace(`點擊觀看`,``),link:t.attr(`href`)?.startsWith(`http`)?t.attr(`href`):s+t.attr(`href`)}})],d=new Set,f=[];for(let e of u){let t=e.link||``;d.has(t)||(d.add(t),f.push(e))}let p=await Promise.all(f.map(a=>t.tryGet(a.link,async()=>{let t=i(await e(a.link));if(a.link?.includes(`/videos/`)){let e=JSON.parse(t(`script[type="application/ld+json"]:contains("VideoObject")`).text());return a.description=`<iframe id="ytplayer" type="text/html" width="640" height="360" src="https://www.youtube-nocookie.com/embed/${e.embedUrl.match(/embed\/([a-zA-Z0-9_-]+)/)?.[1]}" frameborder="0" allowfullscreen referrerpolicy="strict-origin-when-cross-origin"></iframe><br>`+e.description.replaceAll(`
`,`<br>`),a.pubDate=r(n(e.uploadDate),8),a.image=e.thumbnailUrl[0],a}let o=JSON.parse(t(`script[type="application/ld+json"]:contains("NewsArticle")`).text()),s=t(`.rendered-content`);return s.find(`.show-in-md, .article-promote-items, [data-ad-part]`).remove(),a.description=s.html(),a.pubDate=n(o.datePublished),a.category=[...new Set([o.articleSection,...o.keywords])],a.author=o.author?.name??o.publisher?.name,a})));return{title:l(`title`).text(),description:l(`meta[name="description"]`).attr(`content`),link:c,image:`${s}/favicon.ico`,language:`zh-TW`,item:p}}export{a as route};