1import{i as e}from"./jsx-runtime-DUAcabCT.js";import{t}from"./react-DEX2qfRi.js";import{n}from"./client-Bul7L89V.js";import{t as r}from"./useQuery-BjetB2kp.js";var i=e(t(),1);function a(){let[e,t]=(0,i.useState)({checked:!1,userId:null});(0,i.useEffect)(()=>{let e=!0,r=!1,{data:i}=n.auth.onAuthStateChange((n,i)=>{r=!0,e&&t({checked:!0,userId:i?.user.id??null})});return n.auth.getSession().then(({data:n})=>{e&&!r&&t({checked:!0,userId:n.session?.user.id??null})}).catch(()=>{e&&!r&&t({checked:!0,userId:null})}),()=>{e=!1,i.subscription.unsubscribe()}},[]);let a=r({queryKey:[`site-account`,e.userId],enabled:!!e.userId,staleTime:6e4,retry:1,queryFn:async()=>{let{data:t,error:r}=await n.from(`artist_profiles`).select(`artist_name, photo_url, genres, location, target_cities, target_markets, hidden_collection_ids`).eq(`user_id`,e.userId).maybeSingle();if(r)throw r;return t}}),o=r({queryKey:[`site-account`,`collection-pins`,e.userId],enabled:!!e.userId,staleTime:6e4,retry:1,queryFn:async()=>{let{data:t,error:r}=await n.from(`artist_collection_pins`).select(`collection_id`).eq(`user_id`,e.userId).order(`pinned_at`,{ascending:!1});return r?[]:(t??[]).map(e=>e.collection_id)}}),s=(0,i.useMemo)(()=>{let t=e.userId?a.data:null,n=t?.target_cities?.filter(e=>e.trim())??[];return{artistName:t?.artist_name?.trim()||null,genres:t?.genres??[],markets:t?.target_markets??[],hiddenCollectionIds:t?.hidden_collection_ids??[],pinnedCollectionIds:e.userId?o.data??[]:[],cities:n.length?n:t?.location?.trim()?[t.location.trim()]:[]}},[e.userId,a.data,o.data]);return{checked:e.checked,signedIn:!!e.userId,userId:e.userId,profileReady:!e.userId||a.isSuccess||a.isError,...s,name:e.userId?s.artistName||`My account`:``,photoUrl:e.userId?a.data?.photo_url:null}}export{a 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.