import{d as v,aD as p,aL as y,Y as w,ah as l,f as _,l as t,o as r,g as k,w as C,k as B,c,F as b,h as m,bQ as S,i as d,ar as x,N,j as T}from"./Co0rzPff.js";import{u as D}from"./CdDJKVfF.js";const g=v({__name:"NewsletterButton",async setup(A){let s,n;const i=([s,n]=p(()=>y()),s=await s,n(),s),o=w(!1),a=D(async()=>{var u;if((u=i.value)!=null&&u.user)try{const{subscribed:e}=await l("auth/email/subscribe",{method:"GET"});return!e}catch{return!0}else return!1},{watch:[i],server:!1},"$veCcGm5ljT");async function f(){try{await l("auth/email/subscribe",{method:"POST"}),o.value=!0}catch{}finally{setTimeout(()=>{o.value=!1,a.status.value="success",a.data.value=!1},2500)}}return(u,e)=>{const h=_("tooltip");return t(a).status.value==="success"&&t(a).data.value?(r(),k(t(N),{key:0,color:"brand",type:"outlined"},{default:C(()=>[B((r(),c("button",{onClick:f},[o.value?(r(),c(b,{key:1},[m(t(x)),e[1]||(e[1]=d(" Subscribed! "))],64)):(r(),c(b,{key:0},[m(t(S)),e[0]||(e[0]=d(" Subscribe "))],64))])),[[h,"Subscribe to the Modrinth newsletter"]])]),_:1})):T("",!0)}}});export{g as _};