1import{F as e,H as t,O as n,T as r,W as i,ct as a,it as o,k as s,n as c,st as l,ut as u}from"./vendor-vue-Bu-KQjoC.js";import{a as d,c as f,o as p,s as m}from"./apiResponse-C8fEm_-L.js";import{st as h}from"./index-BE2-dWra.js";var g={key:0,type:`button`,class:`invisible h-7 w-14`,"aria-hidden":`true`},_={key:2,type:`button`,class:`invisible h-8 w-16`,"aria-hidden":`true`},v=[`disabled`],y=e({__name:`ProfileFollowButton`,props:{profileUid:{},overlay:{type:Boolean,default:!1}},setup(e){let y=e,{t:b}=c(),x=h(),S=o(null),C=o(!1);function w(e){switch(e){case 1:return b(`blog.follow`);case 2:return b(`blog.unfollow`);case 3:return b(`blog.followBack`);case 4:return b(`blog.unfollowMutual`);default:return``}}async function T(){let e=x.activeAccount?.token;if(!(!x.isAuthenticated||!e))try{let t=`${f}/api/following/status/${encodeURIComponent(y.profileUid)}?token=${encodeURIComponent(e)}`,n=await fetch(t,{cache:`no-store`}),r=await p(n);if(m(n,r))return;let i=d(r),a=Number(i?.follow_status);a>=0&&a<=4&&(S.value=a)}catch{}}async function E(){let e=x.activeAccount?.token;if(!(!e||C.value)){C.value=!0;try{let t=await fetch(`${f}/api/following/follow/${encodeURIComponent(y.profileUid)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e}),cache:`no-store`}),n=await p(t);if(m(t,n))return;let r=d(n),i=Number(r?.follow_status);i>=0&&i<=4&&(S.value=i)}finally{C.value=!1}}}t(()=>{T()});let D=r(()=>S.value===1||S.value===3);return(t,r)=>l(x).isReady?l(x).isAuthenticated?S.value===null?(i(),s(`button`,_)):S.value===0?n(``,!0):(i(),s(`button`,{key:3,type:`button`,class:a([`nico-btn nico-btn-sm inline-flex h-8 !min-h-8 items-center px-3 text-[12px] disabled:opacity-60`,D.value?e.overlay?`nico-btn-primary shadow-md`:`nico-btn-primary`:e.overlay?`border border-white/30 bg-black/40 text-white backdrop-blur-sm`:`border border-border bg-base text-primary`]),disabled:C.value,onClick:E},u(w(S.value)),11,v)):(i(),s(`button`,{key:1,type:`button`,class:a([`nico-btn nico-btn-sm inline-flex h-8 !min-h-8 items-center px-3 text-[12px]`,e.overlay?`border border-white/30 bg-black/40 text-white backdrop-blur-sm`:`nico-btn-primary`]),onClick:r[0]||(r[0]=e=>l(x).openAuth(`login`))},u(l(b)(`blog.follow`)),3)):(i(),s(`button`,g))}});export{y as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.