import{t as e}from"./logger-B0fjfmRH.mjs";import{t}from"./cache-DUthuMSu.mjs";import{n}from"./parse-date-BdYTmLpo.mjs";import{load as r}from"cheerio";const i=`https://www.dailypush.dev`,a=new Set([`document`]);async function o(e){await e.setRequestInterception(!0),e.on(`request`,e=>{if(a.has(e.resourceType())){e.continue();return}e.abort()})}async function s(t,n,r){let i=await t.newPage();await o(i);try{return e.http(`Requesting ${n}`),await i.goto(n,{waitUntil:`domcontentloaded`}),r&&await i.waitForSelector(r),await i.content()}finally{await i.close()}}function c(e){try{let t=n(e);return Number.isNaN(t.getTime())?void 0:t}catch{return}}function l(e){let t=e.find(`.flex.items-center.gap-3`).first();if(t.length===0)return;let n=t.find(`span`),r=[];for(let e=0;e<n.length;e++){let t=n.eq(e),i=t.text().trim();i!==`•`&&!t.hasClass(`text-slate-300`)&&!t.hasClass(`dark:text-slate-600`)&&r.push(i)}switch(r.length){case 3:return r[0].includes(`,`)?r[0].split(`,`).map(e=>({name:e.trim()})):r[0];case 2:{let e=r[0];if(c(e))break;return e}case 1:{let e=r[0];return c(e)?void 0:e}default:break}let i=e.find(`span.text-xs.font-medium.uppercase`).first();if(i.length>0)return i.text().trim()}function u(e,t){return e.find(`a[href^="/"]`).toArray().map(e=>{let n=t(e),r=n.attr(`href`),i=n.text().trim();return r&&i&&!r.includes(`article/`)&&!r.includes(`Summary`)&&i.length<50&&!/^(Summary|stats|About|Tags|Toggle|Trending|Latest|Previous|Next)$/i.test(i)?i:null}).filter(e=>e!==null)}function d(e){let t=e.find(`.flex.items-center.gap-3`).first();if(t.length===0)return;let n=t.find(`span`),r=[];for(let e=0;e<n.length;e++){let t=n.eq(e),i=t.text().trim();i!==`•`&&!t.hasClass(`text-slate-300`)&&!t.hasClass(`dark:text-slate-600`)&&r.push(i)}let i;switch(r.length){case 3:i=r[1];break;case 2:{let e=r[0];i=c(e)?e:r[1];break}case 1:{let e=r[0];c(e)&&(i=e);break}default:break}return i?c(i):void 0}function f(e,t,n){let r=e.find(`h2 a[href^="http"]`);if(r.length===0)return null;let i=r.text().trim(),a=r.attr(`href`);if(!i||!a||a.includes(`dailypush.dev`))return null;let o=l(e),s=e.find(`p.text-sm.text-muted-foreground`).text().trim(),c=u(e,t),f=e.find(`.flex.items-center.justify-between.gap-4.flex-wrap`).find(`a[href*="/article/"]`).attr(`href`),p=f?`${n}${f}`:void 0;return{title:i,link:a,author:o,pubDate:d(e),category:c.length>0?c:void 0,description:s,articleUrl:a,dailyPushUrl:p,language:`en`}}function p(e,t){return e(`article`).toArray().map(n=>f(e(n),e,t)).filter(e=>e!==null)}async function m(e,n){let i=n.filter(e=>e.dailyPushUrl!==void 0),a=n.filter(e=>e.dailyPushUrl===void 0);return[...await Promise.all(i.map(n=>t.tryGet(n.dailyPushUrl,async()=>{try{let t=r(await s(e,n.dailyPushUrl,`p.font-ibm-plex-sans.leading-relaxed`))(`p.font-ibm-plex-sans.leading-relaxed`);t.length>0&&t.text().trim()&&(n.description=t.text().trim())}catch{}return n}))),...a]}export{p as i,m as n,s as r,i as t};