import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{Fragment as t,jsx as n,jsxs as r}from"hono/jsx/jsx-runtime";import*as i from"cheerio";import{renderToString as a}from"hono/jsx/dom/server";const o=({primaryImage:e,originalTitleText:i,certificate:o,ratingsSummary:s,plot:c})=>a(r(t,{children:[e?.url?r(t,{children:[r(`figure`,{children:[n(`img`,{src:e.url,alt:e.caption?.plainText}),n(`figcaption`,{children:e.caption?.plainText})]}),n(`br`,{})]}):null,`Original title: ${i.text}`,n(`br`,{}),o?`${o.rating} `:null,s?.aggregateRating?`IMDb RATING: ${s.aggregateRating}/10 (${s.voteCount})`:null,n(`br`,{}),n(`br`,{}),c?.plotText?.plainText]})),s={path:`/chart/:chart?`,categories:[`multimedia`],view:5,parameters:{chart:{description:"The chart to display, `top` by default",options:[{value:`top`,label:`Top 250 Movies`},{value:`moviemeter`,label:`Most Popular Movies`},{value:`toptv`,label:`Top 250 TV Shows`},{value:`tvmeter`,label:`Most Popular TV Shows`}],default:`top`}},example:`/imdb/chart`,radar:[{source:[`www.imdb.com/chart/:chart/`]}],name:`Charts`,maintainers:[`TonyRL`],handler:c,url:`www.imdb.com/chart/top/`,description:`| Top 250 Movies | Most Popular Movies | Top 250 TV Shows | Most Popular TV Shows |
| -------------- | ------------------- | ---------------- | --------------------- |
| top            | moviemeter          | toptv            | tvmeter               |`};async function c(t){let{chart:n=`top`}=t.req.param(),r=`https://www.imdb.com`,a=`${r}/chart/${n}/`,s=await e(a),c=i.load(s),l=JSON.parse(c(`script#__NEXT_DATA__`).text()).props.pageProps.pageData.chartTitles,u=l.edges.map(({currentRank:e,node:t})=>({title:`${e}. ${t.titleText.text} (${t.releaseYear.year}${t.releaseYear.endYear?`-${t.releaseYear.endYear}`:``})`,description:o({primaryImage:t.primaryImage,originalTitleText:t.originalTitleText,certificate:t.certificate,ratingsSummary:t.ratingsSummary,plot:t.plot}),link:`${r}/title/${t.id}`,category:t.titleGenres.genres.map(e=>l.genres.find(t=>t.filterId===e.genre.text)?.text)}));return{title:c(`head title`).text(),description:c(`head meta[name="description"]`).attr(`content`),link:a,item:u}}export{s as route};