import{t as e}from"./config-BYRrjYC5.mjs";import{t}from"./logger-B0fjfmRH.mjs";import{t as n}from"./cache-DUthuMSu.mjs";import{t as r}from"./parse-date-BdYTmLpo.mjs";import{n as i}from"./playwright-1-2p8zlN.mjs";import a from"sanitize-html";const o={path:`/user/:id`,categories:[`social-media`],example:`/sotwe/user/_RSSHub`,parameters:{id:`Twitter username`},features:{requireConfig:!1,requirePuppeteer:!0,antiCrawler:!0,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`www.sotwe.com/:id`],target:`/user/:id`}],name:`User timeline - Sotwe`,maintainers:[`TonyRL`],handler:l,view:2},s=e=>e.map(e=>{switch(e.type){case`photo`:return`<img src="${e.mediaURL}">`;case`video`:{let t=e.videoInfo.variants.filter(e=>e.type===`video/mp4`).toSorted((e,t)=>t.bitrate-e.bitrate)[0];return`<video controls preload="metadata" poster="${e.mediaURL}"><source src="${t.url}" type="video/mp4"></video>`}default:return``}}).join(`<br>`),c=e=>`${s(e.mediaEntities)}<br>${e.text.replaceAll(`
`,`<br>`)}${e.quotedStatus?`<br>${c(e.quotedStatus)}`:``}${e.retweetedStatus?`<br>${c(e.retweetedStatus)}`:``}`;async function l(o){let s=`https://www.sotwe.com`,{id:l}=o.req.param(),u=await n.tryGet(`sotwe:user:${l}`,async()=>{let e=await i(),n=await e.newPage();await n.setRequestInterception(!0),n.on(`request`,e=>{[`document`,`script`,`xhr`,`fetch`].includes(e.resourceType())?e.continue():e.abort()});let r=`${s}/api/v3/user/${l}/`;t.http(`Requesting ${r}`),await n.goto(r,{waitUntil:`domcontentloaded`});let a=await n.evaluate(()=>document.documentElement.textContent);return await n.close(),await e.close(),JSON.parse(a||`{}`)},e.cache.routeExpire,!1),d=u.data.map(e=>({title:a(e.text.split(`
`)[0],{allowedTags:[],allowedAttributes:{}}),description:c(e),link:`https://x.com/${l}/status/${e.id}`,pubDate:r(e.createdAt,`x`)}));return{title:`${u.info.name} @${u.info.screenName} - Twitter Profile | Sotwe`,description:u.info.description,link:`${s}/${l}`,image:u.info.profileImageThumbnail,item:d}}export{o as route};