1import{u as U,b as V,r as c,j as e,H as G,p as W,L as B,A as w,M as X,X as F,B as K,y as Q,D as Y,s as D,c as I,G as Z}from"./index-Cfs4EKUJ.js";import{b as q,d as ee,c as E,m as te}from"./artistConnections-BzA7mNrv.js";import{N as se,B as M}from"./Navbar-KvWRdtdR.js";import{C as re}from"./CollectorConnectionSummaryCard-BavFkDrh.js";import{B as ne}from"./bookmark-CrwQY6zt.js";import{M as oe}from"./map-pin-C2H4O5b8.js";import"./sparkles-BJnDhz2W.js";import"./log-out-CiJyIRs_.js";import"./heart-Cvni-yVs.js";function pe(){}function ae(s){if(Array.isArray(s))return s.filter(r=>typeof r=="string");if(typeof s=="string")try{const r=JSON.parse(s);if(Array.isArray(r))return r.filter(m=>typeof m=="string")}catch{return s?[s]:[]}return[]}function z(s){return new Date(s.responded_at||s.created_at).getTime()}function N(s){return s!=null&&s.responded_at?s.collector_seen_at?new Date(s.collector_seen_at).getTime()<new Date(s.responded_at).getTime():!0:!1}function be(){const s=U(),{user:r,loading:m,trialExpiresAt:_,subscriptionStatus:P}=V(),T=!!r&&P!=="active"&&!!_&&new Date(_).getTime()>Date.now()&&sessionStorage.getItem("wb_trial_banner_dismissed")!=="1",[g,u]=c.useState([]),[C,S]=c.useState(!0),[f,h]=c.useState(null),[x,k]=c.useState(!1),[p,v]=c.useState(null);c.useEffect(()=>{m||r||s("/collectors",{replace:!0})},[m,r,s]),c.useEffect(()=>{if(m||!r)return;let t=!0;const o=r.id;async function a(){S(!0);try{const l=K();(l==null?void 0:l.action)==="bookmark"&&l.artistSlug&&(await Q(o,l.artistSlug),Y());const[d,b]=await Promise.all([D.from("collector_saved_artists").select("artist_user_id, created_at").eq("collector_user_id",o).order("created_at",{ascending:!0}),ee("collector",o)]);if(d.error)throw d.error;const j=Array.from(new Set((d.data??[]).map(n=>n.artist_user_id).filter(Boolean)));if(j.length===0){t&&u([]);return}const{data:O,error:R}=await D.from("artist_profiles").select("user_id, slug, name, city, country, disciplines, positioning_text, thumbnail_url").in("user_id",j).eq("is_public",!0);if(R)throw R;const y=new Map;b.forEach(n=>{const i=y.get(n.artist_user_id);(!i||z(n)>z(i))&&y.set(n.artist_user_id,n)});const H=new Map((O??[]).map(n=>[n.user_id,n])),J=j.flatMap(n=>{const i=H.get(n);return i!=null&&i.slug?[{...i,disciplines:ae(i.disciplines),connection:y.get(n)??null}]:[]});t&&u(J)}catch(l){t&&I.error(E(l))}finally{t&&S(!1)}}return a(),()=>{t=!1}},[m,r]);const $=async()=>{if(!(!r||!f||x)){k(!0);try{const t=await Z(r.id,f.slug,"remove");if(!t)throw new Error("Could not remove this artist from Saved.");u(o=>o.filter(a=>a.user_id!==f.user_id)),localStorage.setItem("wb_collector_bookmarks",JSON.stringify(t)),h(null)}catch(t){I.error(E(t))}finally{k(!1)}}},L=async t=>{const o=new Date().toISOString(),a=N(t)?{...t,collector_seen_at:o}:t;if(v(a),!!N(t)){u(l=>l.map(d=>{var b;return((b=d.connection)==null?void 0:b.id)===t.id?{...d,connection:a}:d}));try{await te(t.id)}catch{}}},A=c.useMemo(()=>p?q(p):null,[p]);return e.jsxs("div",{className:"min-h-screen",children:[e.jsxs(G,{children:[e.jsx("title",{children:"Saved Artists â Washboat"}),e.jsx("meta",{name:"robots",content:"noindex"})]}),e.jsx("div",{className:"fixed inset-0 z-0 pointer-events-none",style:{backgroundImage:`url(${W})`,backgroundSize:"cover",backgroundPosition:"center"}}),e.jsx("div",{className:"fixed inset-0 z-0 pointer-events-none",style:{background:"rgba(250,248,245,0.75)"}}),e.jsx(se,{}),e.jsxs("div",{className:`relative z-10 pb-24 max-w-5xl mx-auto px-5 sm:px-6 ${T?"pt-[108px]":"pt-20"}`,children:[e.jsxs("div",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(M,{className:"w-5 h-5 text-[#c9a84c]"}),e.jsx("h1",{className:"font-serif text-3xl font-semibold text-[#1a1916]",children:"Saved Artists"})]}),e.jsx("p",{className:"text-stone-500 text-sm",children:"Artists you want to follow, with your introduction updates in one place."})]}),C?e.jsx("div",{className:"flex items-center justify-center py-24",children:e.jsx(B,{className:"w-6 h-6 text-stone-300 animate-spin"})}):g.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-stone-100 border border-stone-200 flex items-center justify-center mb-5",children:e.jsx(ne,{className:"w-6 h-6 text-stone-300"})}),e.jsx("h2",{className:"font-serif text-2xl font-semibold text-[#1a1916] mb-2",children:"No saved artists yet"}),e.jsx("p",{className:"text-stone-500 text-sm max-w-xs leading-relaxed mb-6",children:"Save artists from Discover to build your collection here."}),e.jsxs("button",{type:"button",onClick:()=>s("/collectors/discover"),className:"inline-flex items-center gap-2 px-6 py-3 border border-[#c9a84c] bg-[#f7efd9] text-charcoal text-sm font-semibold rounded-xl hover:bg-[#f2e6c4] transition-colors",children:["Discover artists ",e.jsx(w,{className:"w-4 h-4"})]})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5",children:g.map(t=>{const o=t.city&&t.country?`${t.city}, ${t.country}`:t.country||t.city||null;return e.jsxs("article",{className:"group bg-white/90 border border-stone-100 rounded-2xl overflow-hidden hover:shadow-md transition-all duration-200 flex flex-col",children:[e.jsx("button",{type:"button",className:"relative aspect-[4/3] bg-stone-50 overflow-hidden text-left",onClick:()=>{sessionStorage.setItem("wb_collector_back","/collectors/saved"),s(`/artist/${t.slug}`)},children:t.thumbnail_url?e.jsx("img",{src:t.thumbnail_url,alt:t.name,className:"w-full h-full object-cover group-hover:scale-[1.02] transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("span",{className:"font-serif text-5xl text-stone-200 select-none",children:(t.name||"?").charAt(0).toUpperCase()})})}),e.jsxs("div",{className:"p-4 flex flex-col flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-serif text-base font-semibold text-[#1a1916] leading-snug mb-1",children:t.name}),o&&e.jsxs("div",{className:"flex items-center gap-1 text-stone-400 text-xs mb-2",children:[e.jsx(oe,{className:"w-3 h-3 flex-shrink-0"}),e.jsx("span",{children:o})]})]}),e.jsx("button",{type:"button",onClick:()=>h(t),"aria-label":`Remove ${t.name} from Saved`,className:"text-[#c9a84c] hover:text-red-400 transition-colors p-1",children:e.jsx(M,{className:"w-4 h-4"})})]}),t.disciplines.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mb-3",children:t.disciplines.slice(0,3).map(a=>e.jsx("span",{className:"px-2 py-0.5 bg-stone-50 border border-stone-100 rounded-full text-[11px] text-stone-500 font-medium",children:a},a))}),t.connection&&e.jsxs("button",{type:"button",onClick:()=>L(t.connection),className:"mt-2 mb-3 flex items-center gap-2 rounded-xl border border-stone-100 bg-stone-50 px-3 py-2.5 text-left hover:border-[#c9a84c]/50 transition-colors",children:[e.jsx(X,{className:"w-3.5 h-3.5 text-[#c9a84c] flex-shrink-0"}),e.jsx("span",{className:"text-xs text-stone-600 flex-1",children:t.connection.status==="pending"?"Request delivered":"Connection update"}),N(t.connection)&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#c9a84c]"})]}),e.jsxs("button",{type:"button",onClick:()=>{sessionStorage.setItem("wb_collector_back","/collectors/saved"),s(`/artist/${t.slug}`)},className:"mt-auto pt-3 border-t border-stone-100 flex items-center justify-between text-xs font-medium text-stone-500 hover:text-charcoal",children:["View profile ",e.jsx(w,{className:"w-3.5 h-3.5"})]})]})]},t.user_id)})}),!C&&g.length>0&&e.jsx("div",{className:"mt-12 text-center",children:e.jsxs("button",{type:"button",onClick:()=>s("/collectors/discover"),className:"inline-flex items-center gap-2 text-sm text-stone-500 hover:text-[#1a1916] transition-colors border border-stone-200 rounded-xl px-5 py-2.5 hover:border-stone-300",children:["Discover more artists ",e.jsx(w,{className:"w-4 h-4"})]})})]}),f&&e.jsx("div",{className:"fixed inset-0 z-[100] bg-charcoal/35 flex items-center justify-center p-5",onClick:()=>!x&&h(null),children:e.jsxs("div",{role:"alertdialog","aria-modal":"true",className:"w-full max-w-md bg-white rounded-2xl p-6 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsx("h2",{className:"font-serif text-2xl font-semibold text-charcoal",children:"Remove this artist from Saved?"}),e.jsx("p",{className:"mt-3 text-sm leading-relaxed text-stone-600",children:"They will be removed from your Saved Artists. Any requests you already sent and the artistâs responses will remain."}),e.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>h(null),disabled:x,className:"px-4 py-2 text-sm text-stone-500 hover:text-charcoal",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:$,disabled:x,className:"rounded-xl border border-red-200 bg-red-50 px-4 py-2 text-sm font-medium text-red-700 hover:bg-red-100 disabled:opacity-50 flex items-center gap-2",children:[x&&e.jsx(B,{className:"w-4 h-4 animate-spin"})," Remove"]})]})]})}),p&&A&&e.jsx("div",{className:"fixed inset-0 z-[100] bg-charcoal/35 flex items-center justify-center p-5",onClick:()=>v(null),children:e.jsxs("div",{role:"dialog","aria-modal":"true",className:"relative w-full max-w-lg bg-white rounded-2xl p-7 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsx("button",{type:"button",onClick:()=>v(null),"aria-label":"Close",className:"absolute z-10 top-4 right-4 w-8 h-8 rounded-full bg-white/80 hover:bg-stone-100 flex items-center justify-center text-stone-500",children:e.jsx(F,{className:"w-4 h-4"})}),e.jsx("div",{className:"-m-7",children:e.jsx(re,{summary:A})})]})})]})}
1export{be as default,pe as invalidateSavedCache};
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.