import{t as e}from"./cache-DUthuMSu.mjs";import{t}from"./got-BBDj7u1e.mjs";import{Fragment as n,jsx as r,jsxs as i}from"hono/jsx/jsx-runtime";import{load as a}from"cheerio";import{renderToString as o}from"hono/jsx/dom/server";import{raw as s}from"hono/html";const c=(e,t)=>{switch(e){case`Image`:switch(t){case`sq`:return`Fotografi`;case`am`:return`ምስል`;case`ar`:return`صورة من`;case`bn`:return`ছবি`;case`bs`:return`Foto`;case`bg`:return`Снимка`;case`zh`:return`图像来源`;case`zh-hant`:return`圖片來源`;case`hr`:return`Foto`;case`fa-af`:return`عکس`;case`en`:return`Image`;case`fr`:return`Image`;case`de`:return`Bild`;case`el`:return`Εικόνα`;case`ha`:return`Hoto`;case`hi`:return`तस्वीर`;case`id`:return`Foto`;case`sw`:return`Picha`;case`mk`:return`Фотографија`;case`ps`:return`انځور`;case`fa-ir`:return`عکس`;case`pl`:return`Zdjęcie`;case`pt-002`:return`Foto`;case`pt-br`:return`Foto`;case`ro`:return`Imagine`;case`ru`:return`Фото`;case`sr`:return`Foto`;case`es`:return`Imagen`;case`tr`:return`Fotoğraf`;case`uk`:return`Фото`;case`ur`:return`تصویر`;default:return`Image`}default:return e}},l=e=>e.replace(`https://hlsvod.dw.com/i/`,`https://tvdownloaddw-a.akamaihd.net/`).replace(`,AVC_480x270,AVC_512x288,AVC_640x360,AVC_960x540,AVC_1280x720,AVC_1920x1080,.mp4.csmil/master.m3u8`,`AVC_1920x1080.mp4`),u=e=>o(r(n,{children:e?.map(e=>i(n,{children:[r(`hr`,{}),e.localizedContentDate?r(`p`,{children:r(`i`,{children:e.localizedContentDate})}):null,e.title?r(`h2`,{children:e.title}):null,e.persons?e.persons.map(e=>r(`p`,{children:r(`i`,{children:e.fullName})})):null,e.text?r(n,{children:s(e.text)}):null]}))})),d=({hlsVideoSrc:e,mp4VideoSrc:t,posterImageUrl:n})=>o(i(`video`,{controls:!0,preload:`metadata`,poster:n??void 0,children:[r(`source`,{src:e,type:`application/x-mpegURL`}),r(`source`,{src:t,type:`video/mp4`})]})),f=({teaser:e,video:t,mainImage:a,text:c,liveblog:l,imageI18n:u})=>o(i(n,{children:[e?r(`blockquote`,{children:r(`p`,{children:r(`em`,{children:e})})}):null,t?r(n,{children:s(t)}):a?i(`figure`,{children:[r(`img`,{src:`https://static.dw.com/image/${a.targetId}_605.jpg`,alt:a.additionalInformation}),i(`figcaption`,{children:[a.description,i(`small`,{children:[u,`: `,a.target.licenserSupplement]})]})]}):null,c?r(n,{children:s(c)}):null,l?r(n,{children:s(l)}):null]})),p=(e,t)=>{e(`img`).each((n,r)=>{try{let n=e(r).attr(`data-id`),i=t.find(e=>String(e.targetId)===n);e(r).attr({title:i?.name,alt:i?.description,src:`https://static.dw.com/image/${n}_605.jpg`}),e(r).removeAttr(`style`)}catch{}}),e(`video`).each((t,n)=>{try{e(n).attr(`poster`,e(n).attr(`data-posterurl`))}catch{}}),e(`iframe`).each((t,n)=>{try{e(n).attr(`src`,e(n).attr(`data-src`))}catch{}}),e(`svg`).remove()},m=(e,t)=>{let n=a(t.text);p(n,t.contentLinks);let r=e.type===`liveblog`&&t.posts?u(t.posts.map(e=>{let n=a(e.text);return p(n,t.contentLinks),e.text=n.html(),e})):void 0,i=e.type===`video`&&t.hlsVideoSrc?d({hlsVideoSrc:t.hlsVideoSrc,mp4VideoSrc:l(t.hlsVideoSrc),posterImageUrl:t.posterImageUrl}):void 0;return e.description=f({teaser:t.teaser,video:i,mainImage:n(`[data-id="${t.mainContentImageLink?.targetId}"]`).length===0?t.mainContentImageLink:void 0,text:n.html(),liveblog:r,imageI18n:c(`Image`,e.language)}),t.trackingCategories&&(e.category=t.trackingCategories),t.firstPersonArray&&(e.author=t.firstPersonArray.map(e=>e.fullName).join(`, `)),e},h=async n=>(n=await Promise.all(n.map(n=>e.tryGet(n.link,async()=>{let e=(await t(`https://www.dw.com/graph-api/${n.language}/content/${n.type}/${n.id}`)).data.data.content;return m(n,e)}))),n);export{h as t};