import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./cache-DUthuMSu.mjs";import{t as n}from"./parse-date-BdYTmLpo.mjs";const r={path:`/user/:username/articles`,categories:[`program-update`],example:`/civitai/user/Chenkin/articles`,parameters:{username:`Username`},radar:[{source:[`civitai.com/user/:username`,`civitai.com/user/:username/articles`]}],name:`User Article`,maintainers:[`TonyRL`],handler:i,features:{nsfw:!0}};async function i(r){let{username:i}=r.req.param(),a=await t.tryGet(`civitai:userProfile:${i}`,async()=>(await e(`https://civitai.com/api/trpc/userProfile.get`,{query:{input:JSON.stringify({json:{username:i}})}})).result.data.json),o=await e(`https://civitai.com/api/trpc/article.getInfinite`,{query:{input:JSON.stringify({json:{period:`AllTime`,periodMode:`published`,sort:`Newest`,username:i,includeDrafts:!1,pending:!0,browsingLevel:1,excludedTagIds:[415792,426772,5188,5249,130818,130820,133182],cursor:null},meta:{values:{cursor:[`undefined`]}}})}});if(!o.result.data.json.items.length)throw Error(`This user has no articles.`);let s=o.result.data.json.items.map(e=>({title:e.title,link:`https://civitai.com/articles/${e.id}`,id:e.id,pubDate:n(e.publishedAt),updated:n(e.publishedAt),author:e.user?.username,category:e.tags.map(e=>e.name),image:`https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/${e.coverImage.url}/${e.coverImage.name}`})),c=await Promise.all(s.map(n=>t.tryGet(n.link,async()=>(n.description=(await e(`https://civitai.com/api/trpc/article.getById`,{query:{input:JSON.stringify({json:{id:n.id}})}})).result.data.json.content,n))));return{title:`${i} Creator Profile | Civitai`,description:a.profile.message.replaceAll(`
`,` `)||a.profile.bio,link:`https://civitai.com/user/${i}/articles`,image:a.image,item:c}}export{r as route};