// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later
// @source: https://gitlab.com/soapbox-pub/ditto/-/tree/f0a3877c
import{t as e}from"./dist-DQ82bf9M.js";import{h as t,t as n}from"./useQuery-rCAlChE8.js";import{t as r}from"./useCurrentUser-C6OJJlWo.js";import{t as i}from"./useNostrPublish-CrMjnYm4.js";import{d as a,f as o,l as s,p as c,u as l}from"./index-CYEZWNq6.js";function u(t){let{nostr:r}=e();return n({queryKey:[`profile-tabs`,t??``],queryFn:async({signal:e})=>{if(!t)return null;let n=await r.query([{kinds:[s],authors:[t],limit:1}],{signal:AbortSignal.any([e,AbortSignal.timeout(5e3)])});return n.length===0?null:a(o(n[0]),t)},enabled:!!t,staleTime:300*1e3,gcTime:600*1e3})}function d(){let{user:e}=r(),{mutateAsync:n,isPending:a}=i(),o=t();return{publishProfileTabs:async t=>{if(!e)throw Error(`Must be logged in to publish profile tabs`);await n({kind:s,content:``,tags:l(c(t,e.pubkey))}),o.setQueryData([`profile-tabs`,e.pubkey],t),await o.invalidateQueries({queryKey:[`profile-supplementary`,e.pubkey]})},isPending:a}}export{u as n,d as t};
// @license-end
