PageSourceSearch

https://www.itembo.com/assets/ProfileEmbed-BiE6Mv_8.js

js itembo.com collected 2026-09-25 10:25:22 UTC 8,620 bytes, 8 lines download raw bytes

1import{j as e}from"./vendor-ui-core-DWyIHxpY.js";import{k as P,h as T}from"./vendor-react-DzMUrXFC.js";import{a as E}from"./vendor-query-9q-iqsHw.js";import{s as m,k as q,bA as D,r as n,M as j,ae as v,E as C}from"./main-Z1rTqt3M.js";import{B as N}from"./badge-check-BKisayHa.js";import"./vendor-supabase-B3U3ReBo.js";import"./vendor-charts-CBBN6_gB.js";import"./vendor-ui-extra-C3HD5Ard.js";import"./vendor-motion-YGI21uN_.js";import"./vendor-forms-BIjZt7Hz.js";function I(u){const{data:a,isLoading:i,error:x}=E({queryKey:["optimizedPublicProfile",u],queryFn:async()=>{if(!u)return null;try{const{data:f,error:b}=await m.rpc("get_public_profile_by_username",{p_username:u}),s=(f==null?void 0:f[0])||null;if(b)throw b;if(!s)throw new Error("Profile not found");try{const o=[];s.role==="artist"?o.push(m.rpc("get_artist_profiles_public",{artist_ids:[s.id]}).then(r=>{var p;return{data:(p=r.data)!=null&&p[0]?{track_count:r.data[0].track_count,stream_count:r.data[0].stream_count,genres:r.data[0].genres,kyc_status:r.data[0].kyc_status,kyc_expiry_date:r.data[0].kyc_expiry_date,kyc_verified_at:r.data[0].kyc_verified_at}:null,error:r.error}})):s.role==="sponsor"?o.push(m.from("sponsor_profiles").select("sponsored_artists_count, sponsored_tracks_count, company_name").eq("id",s.id).maybeSingle()):o.push(Promise.resolve({data:null,error:null})),o.push(m.from("verification_requests").select("*").eq("user_id",s.id).eq("status","verified").order("verified_at",{ascending:!1}).limit(1).maybeSingle()),s.role==="artist"?o.push(m.from("tracks").select("*, sponsor_id").eq("artist_id",s.id).order("created_at",{ascending:!1}).limit(5).then(async r=>{if(r.data&&r.data.length>0){const p=r.data.map(t=>t.id),{data:l}=await m.from("album_tracks").select("track_id, albums(is_pre_release, scheduled_release_at, artist_id, title)").in("track_id",p);if(l){const t=new Map;l.forEach(d=>{var w;(w=d.albums)!=null&&w.is_pre_release&&t.set(d.track_id,{is_pre_release:d.albums.is_pre_release,scheduled_release_at:d.albums.scheduled_release_at,artist_id:d.albums.artist_id,title:d.albums.title})}),r.data=r.data.map(d=>({...d,albumPreRelease:t.get(d.id)||!1}))}}return r})):o.push(Promise.resolve({data:[],error:null})),s.role==="sponsor"?o.push(m.from("tracks").select(`
2                *,
3                artist_profiles!tracks_artist_id_fkey (
4                  name,
5                  avatar_url
6                )
7              `).eq("sponsor_id",s.id).eq("is_sponsored",!0).order("created_at",{ascending:!1})):o.push(Promise.resolve({data:[],error:null}));const[h,y,_,k]=await Promise.all(o);let g=[];if(s.role==="artist"&&_.data){const r=_.data.filter(l=>l.is_sponsored&&l.sponsor_id),p=[...new Set(r.map(l=>l.sponsor_id).filter(Boolean))];if(p.length>0){const{data:l}=await m.from("public_profiles").select("id, display_name, avatar_url, username").in("id",p);g=(l==null?void 0:l.map(t=>({id:`temp_${t.id}`,sponsor_id:t.id,sponsor:t})))||[]}}let c=_.data||[];if(s.role==="artist"){const{data:r}=await m.from("track_featured_artists").select("track_id").eq("artist_id",s.id),p=new Set(c.map(t=>t.id)),l=(r||[]).map(t=>t.track_id).filter(t=>!p.has(t));if(c=c.map(t=>({...t,is_featured:!1})),l.length>0){const{data:t}=await m.from("tracks").select("*, sponsor_id").in("id",l).order("created_at",{ascending:!1});c=[...c,...(t||[]).map(d=>({...d,is_featured:!0}))]}}return{profile:s,profileDetails:h.data,latestVerification:y.data,tracks:c,sponsorships:g,sponsoredTracks:k.data||[]}}catch(o){return console.error("Error fetching secondary profile data:",o),{profile:s,profileDetails:null,latestVerification:null,tracks:[],sponsorships:[],sponsoredTracks:[]}}}catch(f){throw console.error("Error fetching optimized public profile:",f),f}},enabled:!!u,...q.DYNAMIC,...D.STANDARD,retry:1});return{profile:(a==null?void 0:a.profile)||null,profileDetails:(a==null?void 0:a.profileDetails)||null,latestVerification:(a==null?void 0:a.latestVerification)||null,tracks:(a==null?void 0:a.tracks)||[],sponsorships:(a==null?void 0:a.sponsorships)||[],sponsoredTracks:(a==null?void 0:a.sponsoredTracks)||[],isLoading:i,error:(x==null?void 0:x.message)||null}}function H(){const{username:u}=P(),[a]=T(),i=a.get("theme")||"light",x=a.get("layout")||"card",f=a.get("showTracks")!=="false",b=parseInt(a.get("maxTracks")||"3"),{profile:s,profileDetails:o,tracks:h,isLoading:y,error:_}=I(u||""),k=()=>{window.open(`${window.location.origin}/profiles/${u}`,"_blank")};if(y)return e.jsx("div",{className:n("w-full h-full flex items-center justify-center",i==="dark"?"bg-gray-900 text-white":"bg-white text-gray-900"),children:e.jsx("div",{className:"animate-pulse",children:"Loading..."})});if(_||!s)return e.jsx("div",{className:n("w-full h-full flex items-center justify-center",i==="dark"?"bg-gray-900 text-white":"bg-white text-gray-900"),children:e.jsx("div",{children:"Profile not found"})});const g=f?(h||[]).slice(0,b):[];return x==="banner"?e.jsx("div",{className:n("w-full h-full overflow-hidden font-sans",i==="dark"?" text-white":" text-gray-900"),children:e.jsxs("div",{className:"p-4 h-full flex items-center gap-4",children:[e.jsx("img",{src:s.avatar_url||"/default-avatar.png",alt:s.display_name||s.username,className:"w-16 h-16 rounded-full object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-lg truncate",children:s.display_name||s.username}),s.is_verified&&e.jsx(N,{className:"w-4 h-4 text-blue-500 flex-shrink-0"})]}),s.bio&&e.jsx("p",{className:n("text-sm line-clamp-2",i==="dark"?"text-gray-300":"text-gray-600"),children:s.bio}),e.jsxs("div",{className:n("flex items-center gap-4 mt-2 text-xs",i==="dark"?"text-gray-400":"text-gray-500"),children:[s.role==="artist"&&h&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(j,{className:"w-3 h-3"}),h.length," tracks"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(v,{className:"w-3 h-3"}),s.role]}
7)]})]}),e.jsx("button",{onClick:k,className:n("flex-shrink-0 px-4 py-2 rounded-lg font-medium text-sm transition-colors",i==="dark"?"bg-white text-black hover:bg-gray-200":"bg-black text-white hover:bg-gray-800"),children:"View Profile"})]})}):e.jsx("div",{className:n("w-full h-full overflow-hidden font-sans",i==="dark"?" text-white":" text-gray-900"),children:e.jsxs("div",{className:"p-4 h-full flex flex-col",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("img",{src:s.avatar_url||"/default-avatar.png",alt:s.display_name||s.username,className:"w-20 h-20 rounded-full object-cover mx-auto mb-3"}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-semibold text-lg truncate",children:s.display_name||s.username}),s.is_verified&&e.jsx(N,{className:"w-4 h-4 text-blue-500 flex-shrink-0"})]}),s.bio&&e.jsx("p",{className:n("text-sm line-clamp-3 mb-3",i==="dark"?"text-gray-300":"text-gray-600"),children:s.bio}),e.jsxs("div",{className:n("flex items-center justify-center gap-4 text-xs mb-4",i==="dark"?"text-gray-400":"text-gray-500"),children:[s.role==="artist"&&h&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(j,{className:"w-3 h-3"}),h.length," tracks"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(v,{className:"w-3 h-3"}),s.role]})]})]}),f&&g.length>0&&e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:n("text-sm font-medium mb-3",i==="dark"?"text-gray-300":"text-gray-600"),children:"Recent Tracks"}),e.jsx("div",{className:"space-y-2 overflow-y-auto",children:g.map(c=>e.jsxs("div",{className:n("flex items-center gap-3 p-2 rounded-lg transition-colors",i==="dark"?"hover:bg-white/5":"hover:bg-gray-100"),children:[e.jsx("img",{src:c.cover_url||"/placeholder-track.png",alt:c.title,className:"w-10 h-10 rounded object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:c.title}),e.jsxs("p",{className:n("text-xs truncate",i==="dark"?"text-gray-400":"text-gray-500"),children:[c.streams||0," streams"]})]})]},c.id))})]}),e.jsx("div",{className:"mt-4 pt-4 border-t border-current/10",children:e.jsxs("button",{onClick:k,className:n("w-full py-2 px-4 rounded-lg font-medium text-sm transition-colors flex items-center justify-center gap-2",i==="dark"?"bg-white text-black hover:bg-gray-200":"bg-black text-white hover:bg-gray-800"),children:[e.jsx(C,{className:"w-4 h-4"}),"View Full Profile"]})})]})})}export{H as default};
8//# sourceMappingURL=ProfileEmbed-BiE6Mv_8.js.map

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.