1import{cl as Js,bV as Zs,dJ as Xs,u as $e,j as e,J as k,b as $,h as z,i as Ys,bw as Rt,aD as ns,an as Ut,bx as er,W as A,V as G,U as we,dK as tr,dL as sr,H as rr,am as D,a3 as as,aO as is,s as nr,v as ar,dM as ir,dN as or,dO as lr,dP as cr,dQ as dr,dR as mr,X as os,dj as ur,b7 as xr,O as oe,dS as pr,dT as fr}from"./index-CSBsxxXo.js";import{s as S,t as _e,o as $t,aD as hr,al as gr,ak as br,bm as yr}from"./home-startup-core-Dtjb9Klo.js";import{a as _r,e as nt,p as he,r as jr,d as ls,f as wr}from"./profileUrl-4RoTWi9j.js";import ge from"./NotFound-D-zQOZJR.js";import{D as at}from"./DashboardLayout-2h0_q0u8.js";import{N as vr}from"./NotificationsDropdown-Ces9INvJ.js";import{TopBarUserMenu as Nr}from"./TopBarUserMenu-C8O9q7_v.js";import{a as kr,b as Pr,c as Lr,d as Cr,e as Sr}from"./useFollows-DJ4Mwo9T.js";import{L as it,r as h,X as cs,l as qe,a as Mr,D as Ar,M as Tr,T as Er}from"./ui-icons-CK9lrQxE.js";import{a as ct,aT as Fr,ar as Bt,l as Ot,n as ot,t as Dr,ae as Ir,bn as qr,F as Rr,aq as Ur,L as $r,c8 as Br,c9 as Or,H as et}from"./ui-icons-deferred-Bu5t7E0l.js";import{N as re}from"./NavLink-DCYCzEyJ.js";import{D as ds,a as ms,b as us,c as xs}from"./dialog-DZ3-wTfB.js";import{T as zr}from"./textarea-BO06FP54.js";import{L as Te}from"./label-BWC9f_J5.js";import{P as Kr,u as zt}from"./profileStorageUpload-53UvQtmR.js";import{a as Kt,m as Ht,g as Re,A as Hr,b as Gr}from"./gradients-DRbhr8Gn.js";import{u as Vr,i as Wr}from"./useReservedProfileSlugs-CyOAC8hv.js";import{P as Qr}from"./ProfileLinksEditor-C27Er5Jp.js";import{g as Jr}from"./supabaseErrorMessage-zkGRmjiv.js";import{c as Zr,f as Xr}from"./useCoinGecko-Ct8AqhTc.js";import{S as fe}from"./skeleton-DOOgpjse.js";import{g as Yr}from"./badgeEmoji-zayMcpcv.js";import{m as I}from"./proxy-vhuDVgGb.js";import{A as ps}from"./index-qQOzC0xd.js";import{P as fs}from"./ProfileLinksInline-D3ArjVrT.js";import{S as en}from"./StaffBadge-VjoXk-Ao.js";import{V as dt,a as Ie}from"./VerifiedProBadge-B2ipU2Bj.js";import{B as tn}from"./mentions-D2QESrOR.js";import{a as hs,P as sn}from"./profilePublishedArticles-CBfur521.js";import{g as rn}from"./useGamification-BdEghg6l.js";import{g as gs}from"./researchUtils-BjUy8_Ed.js";import{g as bs,f as ys}from"./memberPublicIdentity-b3vgEacW.js";import{d as nn}from"./differenceInDays-z65GEZJR.js";import{d as an}from"./differenceInMonths-PRexzmO1.js";import{b as Gt}from"./communityChannels-C0htHZvh.js";import{P as on}from"./PublishedContentTime-BkN1WCR3.js";import{p as ln}from"./seoMetadata-D_VytN9h.js";import{c as _s,a as je}from"./timeFormatPreference-8MgSxt-E.js";import{s as mt}from"./marketingFeatures-8z32r410.js";import"./urlEncoding-2r3P1_Nw.js";import"./use-mobile-DuPkq2mB.js";import"./separator-DQFmeamO.js";import"./sheet-BtECJAPx.js";import"./index-DJuFbNyI.js";import"./index-Bg46vq2q.js";import"./useChatChannels-lppMsB3V.js";import"./popover-Z5_HoWIH.js";import"./avatar-B6zxV-eR.js";import"./communityMentionCountEvents-DB9-hjem.js";import"./notificationReadState-XxkD7v0M.js";import"./useContentTranslations-BUpEa8H5.js";import"./useQueries-CqkcyplF.js";import"./UpgradeCtaButton-zHbuV9eW.js";import"./upgradeCtaButtonClassName-DGC2ISc7.js";import"./select-ByUdccAe.js";import"./index-BZuCPabT.js";import"./index-BbLuf0Sh.js";import"./index-CtKn_Q1M.js";import"./BadgeLabel-rJC1glJQ.js";import"./AnimatedLikeIcon-Bj679LhS.js";import"./use-reduced-motion-CNKE-Uz4.js";import"./feedArticleTagLabel-CulriIT4.js";import"./format-C_-eNGcO.js";import"./en-US-BgVfQvvk.js";import"./differenceInCalendarMonths-DO38EnIO.js";import"./endOfDay-Bk_ufaoe.js";import"./endOfMonth-DaNV2sMa.js";import"./publicRoutes-D8hG6k1p.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new t.Error().stack;r&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[r]="fa803ee6-f27c-4f93-8212-c08ae55738df",t._sentryDebugIdIdentifier="sentry-dbid-fa803ee6-f27c-4f93-8212-c08ae55738df")}catch{}})();function cn(t,r){return Js({...t,enabled:!0,suspense:!0,throwOnError:Xs,placeholderData:void 0},Zs)}const dn=/^[a-z0-9]+(?:-[a-z0-9]+)+$/i;function js(t){return dn.test((t??"").trim())}function mn(t){return`/post/${t.trim().toLowerCase()}`}async function un(t){const r=t.trim().toLowerCase();if(!js(r))return null;const{data:n,error:i}=await S.from("research_articles").select("seo_slug").eq("seo_slug",r).eq("content_type","news").eq("status","published").maybeSingle();return i||!(n!=null&&n.seo_slug)?null:mn(n.seo_slug)}function xn({userId:t,size:r="default",variant:n="primary",className:i}){const{user:l}=$e(),{data:p,isLoading:c}=kr(t),m=Pr(),d=Lr();if(!l||l.id===t)return null;const u=m.isPending||d.isPending,b=c||u,y=g=>{g.preventDefault(),g.stopPropagation(),!u&&(p?d.mutate(t,{onError:s=>{$.error($t(s))}}):m.mutate(t,{onError:s=>{$.error($t(s))}}))},x=r==="sm";return p?e.jsxs("button",{onClick:y,disabled:b,className:k("group inline-flex items-center gap-1.5 rounded-full border border-border/60 font-medium transition-all","text-foreground bg-muted/40 hover:border-destructive/50 hover:bg-destructive/10 hover:text-destructive",x?"px-3 py-1 text-xs":"px-4 py-1.5 text-sm",b&&"opacity-60 cursor-not-allowed",i),"aria-label":_e("Unfollow"),children:[b?e.jsx(it,{className:k("animate-spin",x?"h-3 w-3":"h-3.5 w-3.5")}):e.jsx(ct,{className:k("group-hover:hidden",x?"h-3 w-3":"h-3.5 w-3.5")}),e.jsx("span",{className:"group-hover:hidden",children:_e("Following")}),e.jsx("span",{className:"hidden group-hover:inline",children:_e("Unfollow")})]}):e.jsxs("button",{onClick:y,disabled:b,className:k("inline-flex items-center gap-1.5 rounded-full font-medium transition-all",n==="inverse"?"border border-zinc-950 bg-zinc-950 text-white shadow-none hover:bg-zinc-800 dark:border-white/20 dark:bg-white dark:text-zinc-950 dark:hover:bg-white/90":"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm",x?"px-3 py-1 text-xs":"px-4 py-1.5 text-sm",b&&"opacity-60 cursor-not-allowed",i),"aria-label":_e("Follow"),children:[b?e.jsx(it,{className:k("animate-spin",x?"h-3 w-3":"h-3.5 w-3.5")}):e.jsx(Fr,{className:k(x?"h-3 w-3":"h-3.5 w-3.5")}),_e("Follow")]})}function pn(t){if(!t||typeof t!="object")return!1;const r=t;return r.code==="23505"||r.code===23505?!0:/duplicate key|unique constraint/i.test(String(r.message??""))}
1const Ee="text-[12px] font-medium text-muted-foreground/90",tt="min-h-11 rounded-[3px] border-border/60 bg-muted/30 focus-visible:border-foreground/40 focus-visible:bg-card focus-visible:ring-0 focus-visible:ring-offset-0 sm:min-h-10",Vt="inline-flex min-h-11 flex-1 items-center justify-center rounded-[3px] border px-4 py-2.5 text-[13px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50";function fn({open:t,onOpenChange:r,profile:n}){const{t:i}=z(),{user:l}=$e(),p=Ys(),{data:c}=Vr(),[m,d]=h.useState(n.display_name||""),[u,b]=h.useState(n.username||""),[y,x]=h.useState(n.bio||""),[g,s]=h.useState(Rt(n.social_links)),[_,j]=h.useState(n.avatar_url),[F,T]=h.useState(n.banner_url),[q,V]=h.useState(null),[X,Y]=h.useState(null),[W,Q]=h.useState(!1),[K,J]=h.useState(Kt(n.avatar_url)),ne=JSON.stringify(ns(n.social_links));h.useEffect(()=>{t&&(d(n.display_name||""),b(n.username||""),x(n.bio||""),s(Rt(n.social_links)),j(n.avatar_url),T(n.banner_url),V(null),Y(null),J(Kt(n.avatar_url)))},[t,n.user_id,n.display_name,n.username,n.bio,ne,n.avatar_url,n.banner_url]);const ae=(L,R,O)=>{var U;const E=(U=L.target.files)==null?void 0:U[0];if(L.target.value="",!!E){if(!E.type.startsWith("image/")){$.error(i("settings.profile.errors.chooseImage"));return}if(E.size>Kr){$.error(i("settings.profile.errors.imageSize"));return}R(E),O(URL.createObjectURL(E))}};h.useEffect(()=>{K!=null&&j(Ht(K,m||n.display_name||"?"))},[m,n.display_name,K]);const Z={background:Re(n.user_id)},P=(m||n.display_name||"?").charAt(0).toUpperCase(),H=async()=>{if(!l)return;if(l.id!==n.user_id){$.error(i("settings.profile.errors.editOwnProfile"));return}const L=u.trim().toLowerCase(),R=(n.username||"").toLowerCase();if(L&&!/^[a-z0-9_]{4,20}$/.test(L)){$.error(i("settings.profile.errors.usernameFormat",{max:20}));return}if(L!==R&&L&&Wr(L,c??void 0)){$.error(i("settings.profile.errors.usernameReserved"));return}const O=er(g);if(O.error){$.error(i(O.error,{index:O.errorIndex??1}));return}Q(!0);try{const E={};if(m!==(n.display_name||"")&&(E.display_name=m||null),L!==R&&(E.username=L||null),y!==(n.bio||"")&&(E.bio=y.slice(0,160)||null),JSON.stringify(O.links)!==ne&&(E.social_links=O.links),q?E.avatar_url=await zt(l.id,q,"avatars"):_!==n.avatar_url&&(E.avatar_url=_),X&&(E.banner_url=await zt(l.id,X,"banners")),Object.keys(E).length===0){$.message(i("settings.profile.feedback.noChanges"));return}const{error:U}=await S.from("profiles").update(E).eq("user_id",l.id);if(U){if(pn(U)&&E.username!=null){$.error(i("settings.profile.errors.usernameTaken"));return}throw U}p.invalidateQueries({queryKey:["profile"]}),p.invalidateQueries({queryKey:["profile-by-uid"]}),p.invalidateQueries({queryKey:["my-profile"]}),$.success(i("settings.profile.feedback.profileUpdated")),r(!1)}catch(E){console.error("profile edit",E),$.error(i("settings.profile.errors.update"))}finally{Q(!1)}};return e.jsx(ds,{open:t,onOpenChange:r,children:e.jsxs(ms,{showCloseButton:!1,className:"flex max-h-[min(90dvh,46rem)] w-[calc(100vw-2rem)] flex-col gap-0 overflow-hidden rounded-[6px] border-border bg-card p-0 sm:max-h-[calc(100dvh-2rem)] sm:w-full sm:max-w-lg",children:[e.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between gap-3 border-b border-border/60 bg-card px-4 sm:h-12 sm:px-6",children:[e.jsx(us,{className:"flex-1 min-w-0 text-start space-y-0",children:e.jsx(xs,{className:"text-[15px] font-semibold tracking-[-0.01em]",children:i("common.profile.actions.edit")})}),e.jsx("button",{type:"button",className:"-me-2 inline-flex h-11 w-11 items-center justify-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 sm:-me-1.5 sm:h-8 sm:w-8","aria-label":i("common.actions.close"),onClick:()=>r(!1),children:e.jsx(cs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"relative h-20 shrink-0 overflow-hidden sm:h-32",style:F?void 0:Z,children:[F?e.jsx("img",{src:F,alt:"",className:"h-full w-full object-cover"}):null,e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-t from-background/30 to-transparent"}),e.jsx("input",{id:"profile-edit-banner-file",type:"file",accept:"image/jpeg,image/png,image/webp,image/gif,image/*",className:"peer sr-only",onChange:L=>ae(L,Y,T)}),e.jsxs("label",{htmlFor:"profile-edit-banner-file",className:"absolute bottom-1.5 end-2 z-20 flex min-h-9 cursor-pointer items-center gap-1.5 rounded-[3px] bg-card/90 px-2.5 py-1 text-[11.5px] font-medium text-foreground
1/90 backdrop-blur-sm transition-colors hover:bg-card peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring/60 sm:bottom-2 sm:end-3 sm:min-h-0 sm:px-2",children:[e.jsx(Bt,{className:"h-3.5 w-3.5"}),i("settings.profile.media.changeBanner")]})]}),e.jsx("div",{className:"relative z-10 -mt-7 shrink-0 px-4 sm:-mt-10 sm:px-6",children:e.jsxs("div",{className:"relative inline-block",children:[e.jsx("div",{className:"flex h-14 w-14 items-center justify-center overflow-hidden rounded-[10px] bg-muted text-xl font-semibold text-white shadow-md ring-[3px] ring-background sm:h-20 sm:w-20 sm:rounded-[12px] sm:text-2xl sm:ring-[3.5px]",children:_?e.jsx("img",{src:_,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"h-full w-full flex items-center justify-center",style:{background:Re(n.user_id)},children:P})}),e.jsx("input",{id:"profile-edit-avatar-file",type:"file",accept:"image/jpeg,image/png,image/webp,image/gif,image/*",className:"peer sr-only",onChange:L=>{J(null),ae(L,V,j)}}),e.jsxs("label",{htmlFor:"profile-edit-avatar-file",className:"absolute -bottom-2.5 -end-2.5 flex h-10 w-10 cursor-pointer items-center justify-center rounded-full peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring/60 sm:-bottom-1.5 sm:-end-1.5 sm:h-8 sm:w-8",children:[e.jsx("span",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-foreground text-background shadow-md transition-opacity hover:opacity-90",children:e.jsx(Bt,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"sr-only",children:i("settings.profile.media.changeAvatar")})]})]})}),e.jsx("div",{className:"min-h-0 flex-1 touch-pan-y scroll-pb-24 overflow-y-auto overscroll-contain bg-card",children:e.jsxs("div",{className:"space-y-3 px-4 pb-4 pt-2.5 sm:space-y-3.5 sm:px-6 sm:pb-6 sm:pt-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Te,{className:Ee,children:i("settings.profile.media.defaultStyles")}),e.jsx("div",{className:"-ms-1 flex flex-wrap items-center gap-0.5 sm:ms-0 sm:gap-2",children:Hr.map((L,R)=>{const O=K===R;return e.jsx("button",{type:"button",onClick:()=>{V(null),J(R),j(Ht(R,m||n.display_name||"?"))},className:"inline-flex h-10 w-10 items-center justify-center rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50","aria-label":i("settings.profile.media.defaultStyle",{index:R+1}),"aria-pressed":O,children:e.jsx("span",{className:k("h-7 w-7 rounded-full transition-shadow ring-offset-2 ring-offset-background",O?"ring-2 ring-foreground":"ring-1 ring-border/70 hover:ring-foreground/50"),style:{background:Gr(R)},"aria-hidden":!0})},R)})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Te,{htmlFor:"edit-display-name",className:Ee,children:i("settings.profile.identity.displayName")}),e.jsx(Ut,{id:"edit-display-name",value:m,onChange:L=>d(L.target.value),placeholder:i("settings.profile.preview.nameFallback"),maxLength:50,className:tt})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Te,{htmlFor:"edit-username",className:Ee,children:i("settings.profile.identity.username")}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"pointer-events-none absolute start-3 top-1/2 -translate-y-1/2 text-base text-muted-foreground sm:text-sm",children:"@"}),e.jsx(Ut,{id:"edit-username",value:u,onChange:L=>b(L.target.value.replace(/[^a-zA-Z0-9_]/g,"").slice(0,20)),placeholder:"handle",className:k(tt,"ps-[26px]"),autoComplete:"username"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Te,{htmlFor:"edit-bio",className:Ee,children:i("settings.profile.identity.bio")}),e.jsxs("span",{className:"text-[11px] tabular-nums text-muted-foreground/70",children:[y.length,"/160"]})]}),e.jsx(zr,{id:"edit-bio",value:y,onChange:L=>x(L.target.value.slice(0,160)),placeholder:i("settings.profile.identity.bioPlaceholder"),rows:2,className:k(tt,"min-h-[72px] resize-none text-base sm:min-h-[84px] sm:text-sm"),maxLength:160})]}),e.jsx("div",{className:"border-t border-border/50 pt-3.5 sm:pt-4",children:e.jsx(Qr,{idPrefix:"profile-edit",links:g,onChange:s,compact:!0})})]})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t border-border/60 bg-card px-4 pb-[max(0.75rem,env(safe-area-inset-bottom,0px))] pt-3 sm:px-6 sm:py-4",children:[e.jsx("button",{type:"button",onClick:()=>r(!1),disabled:W,className:k(Vt,"border-border bg-card text-foreground hover:bg-muted/50"),children:i("common.actions.cancel")}),e.jsx("button",{type:"button",onClick:()=>void H(),disabled:W,className:k(Vt,"border-foreground bg-foreground text-background hover:bg-foreground
1/90"),children:W?e.jsx(it,{className:"h-4 w-4 animate-spin"}):i("settings.profile.actions.saveChanges")})]})]})})}function Wt(t){if(!Array.isArray(t))return[];const r=[];for(const n of t){if(!n||typeof n!="object")continue;const i=n,l=typeof i.coin_id=="string"?i.coin_id:null;l&&r.push({coin_id:l,coin_symbol:typeof i.coin_symbol=="string"?i.coin_symbol:"",coin_name:typeof i.coin_name=="string"?i.coin_name:"Coin",coin_image:typeof i.coin_image=="string"?i.coin_image:"",sort_order:typeof i.sort_order=="number"?i.sort_order:0})}return r}function hn(t){if(t==null)return[];let r=t;if(typeof r=="string")try{r=JSON.parse(r)}catch{return[]}return Array.isArray(r)?r.filter(n=>n!=null&&typeof n=="object"&&typeof n.name=="string"&&typeof n.share_slug=="string"):[]}function gn(t){return A({queryKey:["profile-public-watchlists",t],queryFn:async()=>{if(!t)return[];const{data:r,error:n}=await S.rpc("get_profile_public_watchlists",{p_user_id:t});if(n)throw new Error(Jr(n));return hn(r)},enabled:!!t,staleTime:3e4})}const Fe=5;function ws({profileUserId:t}){const{t:r}=z(),{data:n,isLoading:i,isError:l}=gn(t),p=h.useMemo(()=>{if(!(n!=null&&n.length))return[];const u=new Set;for(const b of n){const y=Wt(b.coins).sort((x,g)=>x.sort_order-g.sort_order||x.coin_id.localeCompare(g.coin_id));for(const x of y.slice(0,Fe))u.add(x.coin_id)}return Array.from(u)},[n]),{data:c,isLoading:m}=Zr(p),d=h.useMemo(()=>{const u=new Map;return((c==null?void 0:c.coins)??[]).forEach(b=>u.set(b.id,b)),u},[c]);return i?e.jsxs("div",{className:"rounded-[3px] bg-muted/25 p-3 shadow-sm",children:[e.jsx(fe,{className:"h-4 w-40 mb-3"}),e.jsx(fe,{className:"h-10 w-full mb-2"}),e.jsx(fe,{className:"h-10 w-full mb-2"}),e.jsx(fe,{className:"h-10 w-full"})]}):l||!(n!=null&&n.length)?null:e.jsxs("div",{className:"group overflow-hidden rounded-[3px] bg-muted/25 shadow-sm transition-colors hover:bg-muted/35",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/25 bg-muted/15 px-3 py-2.5 sm:px-4",children:[e.jsx(Ot,{className:"h-4 w-4 text-warning shrink-0 fill-warning/25","aria-hidden":!0}),e.jsx("h2",{className:"text-sm font-semibold text-foreground flex-1",children:r("common.profile.watchlist.title",{count:n.length})}),e.jsx(qe,{className:"h-4 w-4 text-muted-foreground/35 opacity-0 group-hover:opacity-100 transition-opacity hidden sm:block","aria-hidden":!0})]}),n.map(u=>{const b=Wt(u.coins).sort((s,_)=>s.sort_order-_.sort_order||s.coin_id.localeCompare(_.coin_id)),y=b.slice(0,Fe),x=`/watchlist?shared=${encodeURIComponent(u.share_slug)}`,g=b.length;return e.jsxs("section",{className:"border-b border-border/40 last:border-b-0 transition-colors hover:bg-muted/15","aria-labelledby":`watchlist-preview-${u.id}`,children:[e.jsxs(G,{to:x,className:"flex flex-wrap items-start justify-between gap-2 px-3 py-2.5 group/row rounded-[3px] outline-none focus-visible:ring-2 focus-visible:ring-ring sm:px-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{id:`watchlist-preview-${u.id}`,className:"text-[13px] font-medium text-foreground flex items-center gap-2",children:[e.jsx(Ot,{className:"h-4 w-4 text-warning shrink-0 fill-warning/30","aria-hidden":!0}),u.name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:g===0?r("common.profile.watchlist.noCoins"):r("common.profile.watchlist.showing",{visible:Math.min(Fe,g),total:g})})]}),e.jsx("span",{className:"inline-flex shrink-0 items-center text-muted-foreground/40 group-hover/row:text-muted-foreground/70 transition-colors",children:e.jsx(qe,{className:"h-4 w-4","aria-hidden":!0})})]}),y.length===0?e.jsx("p",{className:"px-4 pb-4 text-xs text-muted-foreground",children:r("common.profile.watchlist.emptyDescription")}):e.jsx("ul",{className:"space-y-0.5 px-2 pb-2",children:y.map(s=>{const _=d.get(s.coin_id),j=(_==null?void 0:_.change_24h)??0,F=j>=0;return e.jsx("li",{children:e.jsxs(G,{to:`/markets/${s.coin_id}`,className:k("flex w-full items-center gap-3 rounded-[3px] px-2 py-2 text-start text-sm","transition-colors hover:bg-muted/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),children:[_!=null&&_.image||s.coin_image?e.jsx("img",{src:(_==null?void 0:_.image)||s.coin_image,alt:"",className:"h-9 w-9 shrink-0 rounded-full bg-muted object-cover"}):e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-bold uppercase text-muted-foreground",children:((_==null?void 0:_.symbol)??s.coin_symbol).slice(0,2)||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate font-medium text-foreground",children:(_==null?void 0:_.name)??s.coin_name}),e.jsx("p",{className:"text-xs text-muted-foreground tabular-nums uppercase",children:(_==null?void 0:_.symbol)??s.coin_symbol})]}),e.jsx("div",{className:"shrink-0 text-end",children:m&&!_?e.jsx(fe,{className:"ms-auto h-4 w-14"}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium tabular-nums text-foreground",children:_?Xr(_.price):"-"}),_&&e.jsxs("p",{className:k("text-[11px] tabular-nums",F?"text-success":"text-destructive"),children:[F?"+":"",j.toFixed(2),"%"]})]})})]})},s.coin_id)})}),g>Fe&&e.jsx("div",{className:"border-t border-border/30 px-4 py-2.5",children:e.jsxs(G,{to:x,className:"text-xs font-medium text-primary hover:underline inline-flex items-center gap-1",children:[r("common.profile.watchlist.viewAll",{count:g}),e.jsx(Mr,{className:"h-3.5 w-3.5","aria-hidden":!0})]})})]},u.id)})]})}function bn({open:t,onOpenChange:r,earnedBadgeIds:n}){const{t:i}=z(),{data:l=[],isLoading:p}=A({queryKey:["badge-definitions-all"],enabled:t,queryFn:async()=>{const{data:m,error:d}=await S.from("badge_definitions").select("*").order("criteria_value",{ascending:!0});if(d)throw d;return m??[]}}),c=l.filter(m=>n.has(m.id)).length;return e.jsx(ps,{children:t?e.jsx(I.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-background/80 backdrop-blur-sm",onClick:()=>r(!1),onPointerDown:m=>{m.target===m.currentTarget&&m.preventDefault()},onPointerUp:m=>{m.target===m.currentTarget&&(m.preventDefault(),window.setTimeout(()=>r(!1),0))},children:e.jsxs(I.div,{initial:{scale:.95,opacity:0,y:10},animate:{scale:1,opacity:1,y:0},exit:{scale:.95,opacity:0,y:10},transition:{type:"spring",stiffness:320,damping:26},className:"bg-background border border-border/50 rounded-2xl w-full max-w-md max-h-[80vh] overflow-hidden shadow-xl flex flex-col",onClick:m=>m.stopPropagation(),children:[e.jsx("div",{className:"sticky top-0 bg-background/95 backdrop-blur-sm px-5 pt-5 pb-3 border-b border-border/20 z-10 shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-[17px] font-semibold text-foreground tracking-tight",children:i("common.profile.badges.all")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:i("common.profile.badges.earned",{earned:c,total:l.length})})]}),e.jsx("button",{type:"button",className:"p-2 rounded-lg hover:bg-muted transition-colors -me-1","aria-label":i("common.actions.close"),onClick:()=>r(!1),children:e.jsx(cs,{className:"w-4 h-4"})})]})}),e.jsx("div",{className:"overflow-y-auto p-4 space-y-1.5",children:p?e.jsx("p",{className:"text-sm text-muted-foreground py-8 text-center",children:i("common.loading")}):l.map(m=>{const d=n.has(m.id);return e.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-xl border transition-colors ${d?"border-border/25":"border-border/10 opacity-[0.35]"}`,children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 bg-muted/30 text-[10px] font-semibold uppercase tracking-normal text-muted-foreground","aria-hidden":!0,children:Yr(m.icon)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-foreground",children:m.name}),m.description?e.jsx("p",{className:"text-[11px] text-muted-foreground leading-snug mt-0.5",children:m.description}):null]}),d?e.jsx(ct,{className:"w-4 h-4 text-success shrink-0","aria-hidden":!0}):null]},m.id)})})]})},"badges-modal"):null})}function yn(t){return{followers:t("community.followList.followers"),following:t("community.followList.following"),noMembers:t("community.followList.noMembers"),member:t("community.followList.member")}}function _n(t){var n;const r=typeof t=="string"?t.trim():"";if(!r)return!1;try{const i=new URL(r),l=i.hostname.toLowerCase(),p=i.pathname.toLowerCase();if((l==="cdn.discordapp.com"||l==="media.discordapp.net")&&p.startsWith("/embed/avatars/"))return!0;if(l==="ui-avatars.com"||l.endsWith(".ui-avatars.com")){const c=(n=i.searchParams.get("rounded"))==null?void 0:n.toLowerCase();return c==="true"||c==="1"}}catch{return!1}return!1}function jn({avatarUrl:t,label:r}){const n=r.slice(0,1).toUpperCase();return t?e.jsx("div",{className:"h-9 w-9 shrink-0 overflow-hidden rounded-[8px] bg-muted",children:e.jsx("img",{src:t,alt:"",className:k("block h-full w-full origin-center object-cover",_n(t)&&"scale-150")})}):e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-[8px] bg-muted text-xs font-semibold text-muted-foreground",children:n})}function wn({open:t,onOpenChange:r,userId:n,mode:i}){const{t:l}=z(),p=yn(l),{data:c,isLoading:m}=A({queryKey:["profile-follow-list",n,i,t],enabled:t&&!!n,queryFn:async()=>{if(i==="followers"){const{data:g,error:s}=await S.from("user_follows").select("follower_id").eq("following_id",n);if(s)throw s;return[...new Set((g??[]).map(_=>_.follower_id))]}const{data:y,error:x}=await S.from("user_follows").select("following_id").eq("follower_id",n);if(x)throw x;return[...new Set((y??[]).map(g=>g.following_id))]}}),{data:d,isLoading:u}=A({queryKey:["profile-follow-list-profiles",(c==null?void 0:c.join(","))??""],enabled:!!c&&c.length>0,queryFn:async()=>{const{data:y,error:x}=await S.from("profiles").select("user_id, username, display_name, avatar_url").in("user_id",c);if(x)throw x;return y??[]}}),b=i==="followers"?p.followers:p.following;return e.jsx(ds,{open:t,onOpenChange:r,children:e.jsxs(ms,{className:"sm:max-w-md max-h-[min(70vh,520px)] flex flex-col gap-0 p-0 overflow-hidden",children:[e.jsx(us,{className:"px-5 pt-5 pb-3 border-b border-border/40 shrink-0",children:e.jsx(xs,{children:b})}),e.jsx("div",{className:"overflow-y-auto px-3 py-2 pb-4",children:m||c&&c.length>0&&u?e.jsx("div",{className:"space-y-2 p-2",children:[1,2,3,4].map(y=>e.jsx(fe,{className:"h-12 w-full rounded-lg"},y))}):c!=null&&c.length?e.jsx("ul",{className:"space-y-0.5",children:(d??[]).map(y=>{const x=y.display_name||y.username||p.member,g=_r({username:y.username,userId:y.user_id});return e.jsx("li",{children:e.jsxs(re,{to:g,className:"flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm hover:bg-muted/60 transition-colors",onClick:()=>r(!1),children:[e.jsx(jn,{avatarUrl:y.avatar_url,label:x}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-foreground truncate",children:x}),y.username?e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["@",y.username]}):null]})]})}
1,y.user_id)})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-10 px-4",children:p.noMembers})})]})})}function Qt({name:t,isStaff:r,isOwn:n,isVerifiedPro:i,badgeStatus:l}){return e.jsxs("span",{className:"profile-activity-author inline-flex min-w-0 items-center gap-1 text-[13px] font-medium",children:[e.jsx("span",{className:r?"truncate text-[var(--chat-name-team)]":"truncate text-[var(--chat-name-member)]",style:!r&&n?{color:"var(--chat-name-own)"}:void 0,children:t}),e.jsx(dt,{show:i,status:l,size:"chat"}),r?e.jsx(en,{size:"chat"}):null]})}function Ue(t){const r=String(t??"").trim().replace(/^#+\s*/,"");return r?r.replace(/^(?:(?:<a?:[A-Za-z0-9_]+:\d+>)|[^\p{Letter}\p{Number}_-])+/gu,"").trim()||r:"unknown"}const vn=/\.(png|jpe?g|gif|webp|svg|bmp|ico)(\?.*)?$/i,Nn=/(https?:\/\/[^\s]+|<#[0-9]+>|<@!?[^>]+>|<a?:[A-Za-z0-9_]+:[0-9]+>)/g,kn=/^https?:\/\/(?:cdn\.discordapp\.com|media\.discordapp\.net)\/attachments\/[^\s<]+$/i,pe="bidi-token mention-pill chat-mention";function Pn(t){try{const r=new URL(t),n=r.hostname.replace(/^www\./,""),i=r.pathname.replace(/\/$/,""),l=i&&i!=="/"?i.split("/").filter(Boolean).slice(0,2).join("/"):"",p=l?`${n}/${l}`:n;return p.length>34?`${p.slice(0,31)}...`:p}catch{return t.length>34?`${t.slice(0,31)}...`:t}}function Jt({content:t,lookups:r,className:n}){const{t:i}=z(),l=t.split(Nn);return e.jsx("div",{className:k("bidi-prose text-[14px] text-foreground/90 leading-[1.45]",n),children:l.map((p,c)=>{if(!p)return null;const m=p.match(/^https?:\/\/[^\s]+$/);if(!m){const u=p.match(/^<#(\d+)>$/);if(u){const x=r.resolveChannel(u[1]);return x?x.chatChannelId?e.jsxs(re,{dir:"ltr",to:`/community?channel=${x.chatChannelId}`,className:pe,children:[e.jsx(ot,{className:"chat-mention__icon","aria-hidden":!0}),Ue(x.name)]},c):e.jsxs("span",{dir:"ltr",className:k(pe,"opacity-85"),children:[e.jsx(ot,{className:"chat-mention__icon","aria-hidden":!0}),Ue(x.name)]},c):e.jsx("span",{className:"whitespace-pre-wrap",children:p},c)}const b=p.match(/^<@([^>]+)>$/);if(b){let x=b[1];if(x.startsWith("!")&&(x=x.slice(1)),tn.some(s=>s===x))return e.jsxs("span",{dir:"ltr",className:pe,children:[e.jsx(Dr,{className:"chat-mention__icon","aria-hidden":!0}),"@",x]},c);const g=k(pe,"chat-mention--unknown");if(/^\d{15,}$/.test(x)){const s=r.resolveDiscordUser(x);return s?e.jsxs(re,{dir:"ltr",to:nt(s.userId),className:pe,children:["@",s.displayName]},c):e.jsx("span",{dir:"ltr",className:g,children:i("common.profile.memberFallback")},c)}if(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(x)){const s=r.resolveAppUser(x);return s?e.jsxs(re,{dir:"ltr",to:nt(s.userId),className:pe,children:["@",s.displayName]},c):e.jsx("span",{dir:"ltr",className:g,children:i("common.profile.memberFallback")},c)}return e.jsx("span",{className:"whitespace-pre-wrap",children:p},c)}const y=p.match(/^<a?:([A-Za-z0-9_]+):(\d+)>$/);if(y){const[,x,g]=y,s=p.startsWith("<a:");return e.jsx("img",{src:`https://cdn.discordapp.com/emojis/${g}.${s?"gif":"webp"}`,alt:`:${x}:`,className:"mx-1 inline-block h-5 w-5 align-[-0.25em]",loading:"lazy"},c)}return p?e.jsx("span",{className:"whitespace-pre-wrap",children:p},c):null}const d=m[0];return vn.test(d)||kn.test(d)?e.jsx("img",{src:d,alt:i("common.profile.sharedImage"),className:"max-w-full max-h-64 rounded-lg mt-1.5 mb-1",onError:u=>{var x;const b=u.currentTarget;b.style.display="none";const y=document.createElement("span");y.className="text-xs text-muted-foreground italic",y.textContent=i("common.profile.imageUnavailable"),(x=b.parentNode)==null||x.insertBefore(y,b.nextSibling)}},c):e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"mx-1 inline-flex max-w-full items-center gap-1 rounded-[5px] border border-border/50 bg-muted/35 px-1.5 py-0.5 align-baseline text-[12.5px] font-medium text-foreground/80 transition-colors hover:bg-muted/55 dark:border-border/35 dark:bg-muted/20 dark:text-foreground/85",title:d,children:[e.jsx(Ir,{className:"h-3 w-3 shrink-0 text-muted-foreground","aria-hidden":!0}),e.jsx("span",{className:"truncate",children:Pn(d)})]},c)})})}function Ln(t,r=0,n=new Date){const i=t?new Date(t):null,l=i==null?void 0:i.getTime();if(i&&l!=null&&Number.isFinite(l)){if(n.getTime()-l<1440*60*1e3)return"Joined today";const m=Math.max(nn(n,i),1);if(m<30)return`Member for ${m} ${m===1?"day":"days"}`;const d=Math.max(an(n,i),r,1);return d>=12?`Member for ${Math.floor(d/12)}y ${d%12}m`:`Member for ${d}m`}const p=Math.max(r,0);return p<=0?"Joined today":p>=12?`Member for ${Math.floor(p/12)}y ${p%12}m`:`Member for ${p}m`}const Cn=new Set(["superadmin","admin","manager","editor","finance","marketing","support","moderator","accountant"]),Sn=new Set(["@everyone","everyone"]);function vs(t){const r=new Set,n=[];for(const i of t){const l=String(i??"").trim(),p=l.toLowerCase();if(!p||Sn.has(p))continue;const c=Cn.has(p)?"Team":l,m=c.toLowerCase();r.has(m)||(r.add(m),n.push(c))}return n}function Ns(t,r=!0){const n=(t??"").trim()||void 0;return A({queryKey:["profile-activity-stats",n],enabled:!!n&&r,staleTime:6e4,queryFn:async()=>{const{data:i,error:l}=await S.rpc("get_profile_activity_stats",{_user_id:n});if(l)throw l;const p=i??[];return p.length>0?p[0]:null}})}const Mn=["building","active","frozen","completed"];function st(t){const r=Number(t??0);return Number.isFinite(r)?r:0}function An(t,r,n=!0){return A({queryKey:["profile-trading-league-summary",t,r??null],enabled:n&&!!t,staleTime:3e4,queryFn:async()=>{const i=S,{data:l,error:p}=await i.from("trading_leagues").select("id, name, season_label").eq("status","active").order("starts_at",{ascending:!1}).limit(1).maybeSingle();if(p)throw p;if(!l)return null;const{data:c,error:m}
1=await i.from("trading_league_entries").select("id, public_name, public_username, status, created_at").eq("league_id",l.id).eq("user_id",t).in("status",Mn).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(m)throw m;if(!c)return null;const{data:d,error:u}=await i.rpc("trading_league_entry_metrics",{p_entry_id:c.id});if(u)throw u;const b=d&&typeof d=="object"?d:{};return{entryId:c.id,portfolioName:String(c.public_name||"Trading League Portfolio"),leagueName:String(l.name||"Trading League"),seasonLabel:String(l.season_label||"Current season"),status:c.status,portfolioValue:st(b.portfolio_value),returnPct:st(b.return_pct),assetCount:Math.max(0,Math.round(st(b.asset_count))),href:hr({id:c.id,public_username:r||c.public_username})}}})}const Tn=(t,r)=>S.rpc(t,r);async function En(t,r,n=Tn){if(!t||!r||t===r)return!1;const{data:i,error:l}=await n("record_member_profile_view",{p_profile_user_id:r});if(l)throw l;return i===!0}const Fn=40;function Dn(t){return!(t!=null&&t.is_public)||!t.show_bio||!t.username||!/^[A-Za-z0-9_]{1,32}$/.test(t.username)||/^deleted_user_/i.test(t.username)?!1:[...(t.bio??"").replace(/[\u0009-\u000d\u0020\u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g,"")].length>=Fn}function In(t){return Dn(t)?"index,follow,max-image-preview:large,max-snippet:-1":"noindex,follow"}function qn(t){const r=In(t);h.useEffect(()=>{let n=document.head.querySelector('meta[name="robots"]');const i=!n,l=(n==null?void 0:n.getAttribute("content"))??null;return n||(n=document.createElement("meta"),n.name="robots",document.head.appendChild(n)),n.content=r,()=>{i?n.remove():l===null?n.removeAttribute("content"):n.content=l}},[r])}const Zt=["bg-blue-500","bg-violet-500","bg-emerald-500","bg-amber-500","bg-rose-500"];function Rn(){const{t}=z();return e.jsx("header",{className:"sticky top-0 z-40 border-b border-border/60 bg-background/85 backdrop-blur-md",children:e.jsxs("div",{className:"mx-auto flex max-w-[1100px] items-center justify-between gap-3 px-4 py-3 sm:px-6",children:[e.jsx(G,{to:"/",className:"flex min-w-0 items-center","aria-label":t("common.profile.public.homeLabel"),children:e.jsx(rr,{variant:"marketing",className:"!h-7 max-w-[9.5rem] sm:!h-8 sm:max-w-[11rem]"})}),e.jsxs("div",{className:"flex min-w-0 flex-shrink-0 items-center gap-1.5 sm:gap-2",children:[e.jsx(G,{to:"/auth",className:"hidden rounded-[3px] px-2.5 py-1.5 text-[12.5px] text-muted-foreground transition-colors hover:bg-muted/30 hover:text-foreground sm:inline-flex sm:px-3 sm:text-[13px]",children:t("common.profile.public.logIn")}),e.jsx(G,{to:mt,className:"inline-flex min-h-[36px] min-w-0 max-w-[min(100%,11rem)] items-center justify-center whitespace-nowrap rounded-[3px] bg-foreground px-2.5 py-1.5 text-[12px] font-medium text-background transition-colors hover:bg-foreground
1/90 sm:max-w-none sm:px-3.5 sm:py-2 sm:text-[13px]",children:t("common.profile.public.createAccount")})]})]})})}function Un(t){h.useEffect(()=>{if(!t||!t.is_public)return;const r=ln({displayName:t.display_name,username:t.username}),n=r.title,i=r.description,l=typeof window<"u"?`${window.location.origin}${t.username?he(t.username):window.location.pathname}`:"",p=t.avatar_url??"",c=document.title;document.title=n;const m=[],d=(g,s,_)=>{if(!_)return null;let j=document.head.querySelector(`meta[${g}="${s}"]`);const F=!j;j||(j=document.createElement("meta"),j.setAttribute(g,s),document.head.appendChild(j));const T=j.getAttribute("content");return j.setAttribute("content",_),j.dataset.cproProfileMeta="1",m.push(()=>{F?j==null||j.remove():T==null?j==null||j.removeAttribute("content"):j==null||j.setAttribute("content",T)}),j};d("name","description",i),d("property","og:title",n),d("property","og:description",i),d("property","og:type","profile"),d("property","og:url",l),d("property","og:image",p),d("property","profile:username",t.username??""),d("name","twitter:card",p?"summary_large_image":"summary"),d("name","twitter:title",n),d("name","twitter:description",i),d("name","twitter:image",p);let u=document.head.querySelector('link[rel="canonical"]');const b=!u;u||(u=document.createElement("link"),u.rel="canonical",document.head.appendChild(u));const y=u.getAttribute("href");u.href=l,m.push(()=>{b?u==null||u.remove():y==null?u==null||u.removeAttribute("href"):u==null||u.setAttribute("href",y)});let x=null;if(t.username){x=document.createElement("script"),x.type="application/ld+json",x.dataset.cproProfileMeta="1";const g=[...new Set(ns(t.social_links).map(s=>s.url))];x.text=JSON.stringify({"@context":"https://schema.org","@type":"ProfilePage",mainEntity:{"@type":"Person","@id":`${l}#profile`,name:r.name,alternateName:`@${r.handle}`,url:l,image:t.avatar_url??void 0,...g.length>0?{sameAs:g}:{}}}),document.head.appendChild(x)}return()=>{document.title=c,m.reverse().forEach(g=>g()),x==null||x.remove()}},[t])}function $n(t,r){return A({queryKey:["public-profile-articles",t,"preview"],enabled:!!t&&r,queryFn:()=>hs(t,{limit:2,offset:0})})}function Bn(t,r){return A({queryKey:["public-profile-recent-activity",t],enabled:!!t&&r,staleTime:15e3,refetchInterval:3e4,queryFn:async()=>{const{data:n,error:i}=await S.rpc("get_public_profile_recent_activity",{_user_id:t});if(i)throw i;return(n==null?void 0:n[0])??null}})}function On(t){return t.trim().replace(/^#+\s*/,"").replace(/^(?:(?:<a?:[A-Za-z0-9_]+:\d+>)|[^\p{Letter}\p{Number}_-])+/gu,"").trim()||"community"}function zn({username:t}){const{t:r}=z(),n=t?`@${t}`:r("common.profile.public.profileFallback");return e.jsxs("main",{className:"mx-auto w-full max-w-[640px] px-5 py-16 text-center sm:py-24",children:[e.jsx("div",{className:"mx-auto mb-5 flex h-12 w-12 items-center justify-center rounded-full border border-border/40 bg-muted/15",children:e.jsx(Ur,{className:"h-5 w-5 text-muted-foreground","aria-hidden":!0})}),e.jsx("h1",{className:"text-[22px] font-semibold tracking-[-0.02em] text-foreground",children:r("common.profile.public.privateTitle",{member:n})}),e.jsx("p",{className:"mx-auto mt-3 max-w-[420px] text-[14px] leading-relaxed text-muted-foreground",children:r("common.profile.public.privateDescription")}),e.jsxs("div",{className:"mt-7 flex flex-col items-center justify-center gap-2 sm:flex-row sm:gap-3",children:[e.jsx(G,{to:mt,className:"inline-flex items-center justify-center rounded-[3px] bg-foreground px-4 py-2.5 text-[13.5px] font-medium text-background transition-colors hover:bg-foreground
1/90",children:r("common.profile.public.createAccount")}),e.jsx(G,{to:"/auth",className:"inline-flex items-center justify-center rounded-[3px] border border-border/60 px-4 py-2.5 text-[13.5px] font-medium text-foreground transition-colors hover:bg-muted/40",children:r("common.profile.public.logIn")})]})]})}function Kn(){const{t}=z();return e.jsxs("main",{className:"mx-auto w-full max-w-[640px] px-5 py-16 text-center sm:py-24",children:[e.jsx("h1",{className:"text-[22px] font-semibold tracking-[-0.02em] text-foreground",children:t("common.profile.public.notFoundTitle")}),e.jsx("p",{className:"mx-auto mt-3 max-w-[420px] text-[14px] leading-relaxed text-muted-foreground",children:t("common.profile.public.notFoundDescription")}),e.jsx(as,{to:"/",className:"mt-6 inline-flex items-center justify-center px-2 py-1.5 text-[13.5px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:t("common.profile.public.backHome")})]})}function Hn(){const{t}=z();return e.jsx("main",{className:"min-w-0 pb-16 sm:pb-20",role:"status","aria-label":t("common.profile.public.loading"),"aria-busy":"true",children:e.jsxs("div",{className:"mx-auto max-w-[900px] animate-pulse","aria-hidden":!0,children:[e.jsx("div",{className:"h-24 w-full bg-muted/35 sm:h-[120px]"}),e.jsx("div",{className:"relative z-10 -mt-12 px-5 pt-3 sm:-mt-14 sm:pt-3.5 lg:px-8",children:e.jsx("div",{className:"h-24 w-24 rounded-[12px] bg-muted ring-[3.5px] ring-background sm:h-[104px] sm:w-[104px]"})}),e.jsxs("div",{className:"px-5 pb-5 pt-3 lg:px-8",children:[e.jsx("div",{className:"h-7 w-48 rounded-sm bg-muted/70"}),e.jsx("div",{className:"mt-2 h-3.5 w-28 rounded-sm bg-muted/45"}),e.jsx("div",{className:"mt-4 h-3.5 w-full max-w-lg rounded-sm bg-muted/35"}),e.jsx("div",{className:"mt-2 h-3.5 w-3/4 max-w-md rounded-sm bg-muted/30"})]}),e.jsx("section",{className:"mx-5 mt-1 grid grid-cols-3 gap-2 lg:mx-8",children:Array.from({length:3}).map((r,n)=>e.jsx("div",{className:"h-[72px] rounded-[3px] bg-muted/25"},n))}),e.jsx("div",{className:"mx-5 mt-4 h-32 rounded-[3px] bg-muted/20 lg:mx-8"})]})})}function De({label:t,value:r,sub:n}){return e.jsxs("div",{className:"min-w-0 rounded-[3px] bg-muted/25 p-2.5 shadow-sm sm:p-3",children:[e.jsx("p",{className:"text-[9.5px] font-medium uppercase tracking-[0.13em] text-muted-foreground/70",children:t}),e.jsx("p",{className:"mt-0.5 text-[17px] font-medium leading-tight tabular-nums tracking-[-0.025em] text-foreground sm:text-[20px]",children:r}),n?e.jsx("p",{className:"mt-1 text-[10.5px] leading-snug text-muted-foreground",children:n}):null]})}function Gn({displayName:t}){const{t:r}=z(),n=t!=null&&t.trim()?t.trim():r("common.profile.public.membersFallback");return e.jsxs("section",{className:"relative z-10 mx-5 min-h-[214px] overflow-hidden border-y border-border/35 sm:-mt-8 lg:mx-8",children:[e.jsxs("div",{className:"absolute inset-0 px-1 py-4 opacity-55","aria-hidden":"true",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.13em] text-muted-foreground",children:r("common.profile.public.inside")}),e.jsx($r,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),e.jsx("div",{className:"mt-4 grid grid-cols-3 divide-x divide-border/40",children:Vn.map(i=>e.jsxs("div",{className:"px-3 first:pl-0 last:pr-0",children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground/75",children:r(`common.profile.public.previewColumns.${i}`)}),e.jsxs("div",{className:"mt-3 space-y-2 blur-[1.5px]",children:[e.jsx("span",{className:"block h-1.5 w-full rounded-[2px] bg-muted-foreground/25"}),e.jsx("span",{className:"block h-1.5 w-4/5 rounded-[2px] bg-muted-foreground/20"}),e.jsx("span",{className:"block h-1.5 w-2/3 rounded-[2px] bg-muted-foreground/15"})]})]},i))})]}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-background/10 via-background/55 to-background","aria-hidden":"true"}),e.jsx("div",{className:"relative z-10 flex min-h-[214px] items-start justify-center px-3 pb-5 pt-7 sm:px-5 sm:pt-8",children:e.jsxs("div",{className:"w-full max-w-[590px] rounded-[3px] border border-border/45 bg-background/82 px-4 py-4 text-center shadow-[0_16px_45px_-28px_rgba(0,0,0,0.6)] backdrop-blur-md sm:px-6 sm:py-5",children:[e.jsx("h2",{className:"text-[20px] font-semibold tracking-[-0.02em] text-foreground sm:text-[23px]",children:r("common.profile.public.seeNext",{member:n})}),e.jsx("p",{className:"mx-auto mt-1.5 max-w-[440px] text-[13px] leading-relaxed text-muted-foreground sm:text-[13.5px]",children:r("common.profile.public.joinDiscussion")}),e.jsxs("div",{className:"mt-4 flex flex-col items-stretch justify-center gap-2 sm:mx-auto sm:max-w-md
1sm:flex-row sm:items-center sm:gap-3",children:[e.jsx(G,{to:mt,className:"inline-flex items-center justify-center rounded-[3px] bg-foreground px-4 py-2.5 text-[13.5px] font-medium text-background transition-colors hover:bg-foreground/90",children:r("common.profile.public.createAccount")}),e.jsx(G,{to:"/auth",className:"inline-flex items-center justify-center rounded-[3px] border border-border/60 bg-background/70 px-4 py-2.5 text-[13.5px] font-medium text-foreground transition-colors hover:bg-muted/30",children:r("common.profile.public.logIn")})]})]})})]})}const Vn=["community","research","marketPulse"];function Wn({profile:t,isLoading:r}){var ae,Z;const{locale:n,t:i}=z();Un(t??null),qn(r?null:t);const l=!!t&&t.is_public&&t.show_discord_info,{data:p=[]}=A({queryKey:["public-profile-roles",t==null?void 0:t.user_id],enabled:!!(t!=null&&t.user_id)&&t.is_public&&t.show_discord_info,queryFn:async()=>{const{data:P,error:H}=await S.rpc("get_member_public_roles",{_user_id:t.user_id});if(H)throw H;return vs(P??[])}}),{data:c}=$n(t==null?void 0:t.user_id,!!(t!=null&&t.user_id)&&!!(t!=null&&t.is_public)),{data:m}=Bn(t==null?void 0:t.user_id,!!(t!=null&&t.user_id)&&!!(t!=null&&t.is_public)&&!!(t!=null&&t.show_posts)),{data:d}=Ns(t==null?void 0:t.user_id,!!(t!=null&&t.user_id)&&!!(t!=null&&t.is_public)&&!!(t!=null&&t.show_activity_stats)),u=h.useMemo(()=>t?bs(t.username,t.display_name,t.user_id,{}):null,[t]),b=((c==null?void 0:c.totalCount)??0)>0,y=(c==null?void 0:c.articles)??[];if(r)return e.jsx(Hn,{});if(!t)return e.jsx(Kn,{});if(!t.is_public)return e.jsx(zn,{username:t.username});const x=ys(t.username),g=((ae=t.display_name)==null?void 0:ae.trim())||(u==null?void 0:u.primary)||i("common.profile.memberFallback"),s=Re(t.user_id),_=t.show_join_date&&!!t.created_at,j=t.show_bio&&!!((Z=t.bio)!=null&&Z.trim()),F=t.is_verified_pro?p.filter(P=>P.trim().toLowerCase()!=="pro"):p,T=t.show_activity_stats?(d==null?void 0:d.message_count)??null:null,q=(c==null?void 0:c.totalCount)??0,V=_&&!!t.created_at,X=T!=null&&T>0,Y=t.show_activity_stats?(d==null?void 0:d.current_streak)??0:0,W=V?_s(new Date(t.created_at),n,{year:"numeric"}):"",Q=X&&V?i("common.profile.public.summaryMessagesAndMember",{member:g,count:D(T),year:W}):X?i("common.profile.public.summaryMessages",{member:g,count:D(T)}):V?i("common.profile.public.summaryMember",{member:g,year:W}):null,K=m?On(m.channel_name):null,J=t.show_activity_stats&&!!d,ne=J?b?4:3:0;return e.jsx("main",{className:"min-w-0 pb-16 sm:pb-20",children:e.jsxs("div",{className:"mx-auto max-w-[900px]",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"relative h-24 w-full overflow-hidden bg-muted sm:h-[120px]",children:t.banner_url?e.jsx("img",{src:t.banner_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("div",{className:"h-full w-full",style:{background:s}})}),e.jsx("div",{className:"relative z-10 -mt-12 px-5 pt-3 lg:px-8 sm:-mt-14 sm:pt-3.5",children:e.jsx("div",{className:"flex items-end gap-4 sm:gap-5",children:e.jsxs(I.div,{initial:{scale:.92,opacity:0},animate:{scale:1,opacity:1},transition:{type:"spring",stiffness:220,damping:22},className:"relative shrink-0",children:[e.jsx("div",{className:k("flex h-24 w-24 items-center justify-center overflow-hidden rounded-[12px] text-3xl font-semibold text-white shadow-lg ring-[3.5px] ring-background sm:h-[104px] sm:w-[104px] sm:text-[34px]"),style:t.avatar_url?void 0:{background:s},children:t.avatar_url?e.jsx("img",{src:t.avatar_url,alt:"",className:"h-full w-full object-cover"}):(u==null?void 0:u.initial)??"?"}),e.jsx(Ie,{show:t.is_verified_pro,size:"lg"})]})})}),e.jsxs("div",{className:"px-5 pb-5 pt-3 lg:px-8",children:[e.jsxs(I.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:.06},children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("h1",{className:"min-w-0 text-[22px] font-semibold tracking-[-0.025em] text-foreground sm:text-[26px]",children:g}),e.jsx(dt,{show:t.is_verified_pro,status:t.member_badge_status,size:"lg"}),l&&F.length>0?F.map((P,H)=>e.jsxs("span",{className:"inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md border border-border/30 bg-muted/10 px-2 text-[11px] text-foreground
1/80",children:[e.jsx("span",{className:k("h-1.5 w-1.5 shrink-0 rounded-full",Zt[H%Zt.length])}),P]},`${P}-${H}`)):null]}),x?e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:x}):null]}),j?e.jsx("p",{className:"mt-3 max-w-lg text-[13.5px] leading-relaxed text-foreground/75",children:t.bio}):null,t.show_bio?e.jsx(fs,{links:t.social_links,className:"mt-2.5"}):null]})]}),J?e.jsxs("section",{className:k("mx-5 mt-1 grid gap-2 lg:mx-8",ne===4?"grid-cols-2 sm:grid-cols-4":"grid-cols-3"),"aria-label":i("common.profile.public.activitySummary"),children:[e.jsx(De,{label:i("common.profile.stats.messages"),value:D((d==null?void 0:d.message_count)??0),sub:i("common.profile.stats.allTime")}),e.jsx(De,{label:i("common.profile.stats.xp"),value:D((d==null?void 0:d.total_xp)??0),sub:i("common.profile.stats.level",{level:(d==null?void 0:d.level)??1})}),e.jsx(De,{label:i("common.profile.stats.streak"),value:i("common.profile.stats.days",{count:D(Y)}),sub:i("common.profile.stats.currentStreak")}),b?e.jsx(De,{label:i("common.profile.stats.articles"),value:D(q),sub:i("common.profile.stats.published")}):null]}):null,e.jsx("div",{className:"mx-5 mt-2 lg:mx-8",children:e.jsx(ws,{profileUserId:t.user_id})}),Q||m||b?e.jsxs("section",{className:"mx-5 mt-2 rounded-[3px] bg-muted/25 px-3.5 py-3.5 shadow-sm lg:mx-8 lg:px-4",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.13em] text-muted-foreground/75",children:i("common.profile.public.latestFrom",{member:g})}),Q?e.jsxs("p",{className:"mt-2 max-w-[690px] text-[15px] font-medium leading-relaxed text-foreground sm:text-[16px]",children:[Q,Y>0?` ${i("common.profile.public.currentStreak",{count:D(Y)})}`:""]}):null,m||b?e.jsxs("div",{className:k("mt-3 grid border-t border-border/25 pt-3",m&&b?"gap-3 md:grid-cols-2 md:divide-x md:divide-border/30":"grid-cols-1"),children:[m?e.jsxs("div",{className:"min-w-0 md:pr-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10.5px] font-medium text-muted-foreground",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success","aria-hidden":"true"}),e.jsx(qr,{className:"h-3.5 w-3.5","aria-hidden":"true"}),i("common.profile.public.recentlyIn",{channel:K??""})]}),e.jsx("p",{className:"mt-1.5 line-clamp-2 text-[13px] leading-relaxed text-foreground/80 sm:text-[13.5px]",children:m.content_preview}),e.jsx("p",{className:"mt-1 text-[10.5px] text-muted-foreground",children:je(new Date(m.created_at),n)})]}):null,b?e.jsxs("div",{className:"min-w-0 md:pl-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[10.5px] text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(Rr,{className:"h-3.5 w-3.5","aria-hidden":"true"}),i("common.profile.public.publishedArticles",{count:q})]}),e.jsx("span",{className:"text-[10.5px] tabular-nums text-muted-foreground",children:i("common.profile.public.total",{count:D(q)})})]}),e.jsx("div",{className:"mt-1.5",children:y.slice(0,1).map(P=>e.jsxs(as,{to:gs(P.content_type,P.seo_slug,P.id),className:"group flex items-start gap-3",children:[P.cover_image_url?e.jsx("img",{src:P.cover_image_url,alt:"",loading:"eager",decoding:"async",sizes:"56px",className:"h-10 w-12 shrink-0 rounded-[3px] object-cover"}):null,e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"line-clamp-2 text-[13px] font-semibold leading-snug text-foreground",children:P.title}),P.published_at||P.created_at?e.jsx("span",{className:"mt-1 block text-[10.5px] text-muted-foreground",children:e.jsx(on,{value:P.published_at||P.created_at,variant:"card"})}):null]})]},P.id))})]}):null]}):null]}):null,e.jsx(Gn,{displayName:g})]})})}function Qn(){const t=we(),r=t.handle??t.username,n=t.userId,i=tr(r),l=sr(r?void 0:n),p=r?i.isLoading:l.isLoading,c=r?i.data:l.data;return e.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[e.jsx(Rn,{}),e.jsx(Wn,{profile:c,isLoading:p})]})}const rt="cpro-profile-canonical",Jn=30,Zn=48,Xn=/<@!?([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})>
1/gi,Xt=["bg-blue-500","bg-violet-500","bg-emerald-500","bg-amber-500","bg-rose-500"],Yt="text-foreground dark:text-[#d7ff55]",es="bg-muted/45 dark:bg-[#d7ff55]/14",Yn="border-border/50 dark:border-[#d7ff55]/25",ea="border border-border/35 bg-muted/15 text-muted-foreground dark:border-border/30 dark:bg-muted/10 dark:text-muted-foreground/85";function ta(t,r){return r(`common.profile.tradingLeague.status.${t}`)}function sa(t,r,n,i,l){return A({queryKey:["profile-published-articles",t,n,i,l],enabled:!!t&&r,placeholderData:os,queryFn:()=>hs(t,{limit:n*Zn,offset:0,filter:i,sort:l})})}function ts({label:t,value:r,sub:n}){return e.jsxs("div",{className:"min-w-[118px] shrink-0 rounded-[3px] bg-muted/25 p-2.5 shadow-sm sm:min-w-0 sm:p-3",children:[e.jsx("p",{className:"text-[9.5px] font-medium uppercase tracking-[0.13em] text-muted-foreground/70",children:t}),e.jsx("p",{className:"mt-0.5 text-[17px] font-medium leading-tight tabular-nums tracking-[-0.025em] text-foreground sm:text-[20px] lg:text-[21px]",children:r}),n?e.jsx("p",{className:"mt-1 text-[10.5px] leading-snug text-muted-foreground",children:n}):null]})}function lt(){return e.jsx("header",{className:"sticky top-0 z-40 hidden min-w-0 border-b border-border/50 bg-background/95 px-6 py-3 backdrop-blur-xl sm:px-8 sm:py-4 lg:block",children:e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[e.jsx(vr,{}),e.jsx(Nr,{})]})})})}function ra(){return e.jsx(at,{children:e.jsxs("div",{className:"min-h-screen",children:[e.jsx(lt,{}),e.jsxs("main",{className:"mx-auto w-full max-w-6xl px-3 py-6 sm:px-8",children:[e.jsxs("div",{className:"overflow-hidden border-b border-border/40 pb-7",children:[e.jsx("div",{className:"h-28 w-full animate-pulse rounded-lg bg-muted/35 sm:h-36"}),e.jsxs("div",{className:"-mt-10 flex flex-col gap-4 sm:-mt-12 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"flex items-end gap-4",children:[e.jsx("div",{className:"h-24 w-24 animate-pulse rounded-[12px] border-4 border-background bg-muted sm:h-28 sm:w-28"}),e.jsxs("div",{className:"space-y-2 pb-2",children:[e.jsx("div",{className:"h-6 w-44 animate-pulse rounded bg-muted/70"}),e.jsx("div",{className:"h-4 w-28 animate-pulse rounded bg-muted/45"})]})]}),e.jsx("div",{className:"h-9 w-28 animate-pulse rounded-md bg-muted/45"})]})]}),e.jsxs("div",{className:"mt-6 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-16 animate-pulse rounded-lg bg-muted/35"}),e.jsx("div",{className:"h-16 animate-pulse rounded-lg bg-muted/25"})]}),e.jsx("div",{className:"h-36 animate-pulse rounded-lg bg-muted/30"})]})]})]})})}function ss(t){return t instanceof Element&&!!t.closest("a,button,input,textarea,select")}function rs(t){return`/home?post=${encodeURIComponent(t)}`}const na=()=>{var Dt,It;const{locale:t,t:r}=z(),n=nr(),[i,l]=ar(),{username:p,userId:c,handle:m}=we(),d=((Dt=m??p)==null?void 0:Dt.replace(/^@+/,"").trim())||void 0,{user:u}=$e(),{data:b,isLoading:y}=ir(d),{data:x,isLoading:g}=or(d?void 0:c),s=b||x,_=d?y:g,j=(s==null?void 0:s.user_id)===(u==null?void 0:u.id);h.useEffect(()=>{En(u==null?void 0:u.id,s==null?void 0:s.user_id).catch(()=>{})},[s==null?void 0:s.user_id,u==null?void 0:u.id]),h.useEffect(()=>{var N;if(!s)return;const a=window.location.origin,o=(N=s.username)!=null&&N.trim()?he(s.username):nt(s.user_id),f=`${a}${o}`;let v=document.getElementById(rt);return v||(v=document.createElement("link"),v.id=rt,v.rel="canonical",document.head.appendChild(v)),v.setAttribute("href",f),()=>{var se;(se=document.getElementById(rt))==null||se.remove()}},[s]);const F=i.get("tab"),[T,q]=h.useState(()=>F==="trading-league"?"trading-league":F==="articles"?"articles":F==="likes"?"likes":"posts"),[V,X]=h.useState(!1),[Y,W]=h.useState(!1),[Q,K]=h.useState(null),[J,ne]=h.useState(1),[ae,Z]=h.useState(1),[P,H]=h.useState("all"),[L,R]=h.useState("newest"),[O,E]=h.useState(!1),{data:U}=lr(s!=null&&s.settings.show_posts?s==null?void 0:s.user_id:void 0),Ps=h.useMemo(()=>(U??[]).map(a=>a.id),[U]),{data:ve}=cr(Ps),{data:ut}=dr(s!=null&&s.settings.show_likes?s==null?void 0:s.user_id:void 0),{data:xt}=mr(s!=null&&s.settings.show_likes?s==null?void 0:s.user_id:void 0),{data:C,isFetching:Ls}
1=sa(s==null?void 0:s.user_id,!!(s!=null&&s.user_id),ae,P,L),{data:B,isLoading:pt}=An(s==null?void 0:s.user_id,s==null?void 0:s.username,!!(s!=null&&s.user_id)),Cs=(s==null?void 0:s.activity_stats)??null,{data:Ss}=Ns(s==null?void 0:s.user_id,!!(s!=null&&s.user_id)&&!!(s!=null&&s.settings.show_activity_stats)),ee=Ss??Cs??null,le=ee?{total_xp:ee.total_xp,level:ee.level}:null,{data:Be}=A({queryKey:["profile-badges",s==null?void 0:s.user_id],enabled:!!(s!=null&&s.user_id),queryFn:async()=>{const{data:a}=await S.from("user_badges").select("id, user_id, badge_id, earned_at, badge_definitions(*)").eq("user_id",s.user_id);return a||[]}}),Ms=h.useMemo(()=>{const a=new Set;for(const o of Be??[])a.add(o.badge_id);return a},[Be]),{data:M}=A({queryKey:["profile-discord",s==null?void 0:s.user_id],enabled:!!(s!=null&&s.user_id),queryFn:async()=>{const{data:a}=await S.from("discord_user_map").select("discord_user_id, discord_username, discord_nickname, discord_roles, joined_at, premium_since").eq("cryptonary_user_id",s.user_id).maybeSingle();return a}}),{data:te}=A({queryKey:["profile-public-roles",s==null?void 0:s.user_id],enabled:!!(s!=null&&s.user_id),queryFn:async()=>{const{data:a,error:o}=await S.rpc("get_member_public_roles",{_user_id:s.user_id});return o?[]:a??[]}}),{data:ce}=A({queryKey:["profile-discord-user-fallback",s==null?void 0:s.discord_id],enabled:!!(s!=null&&s.discord_id),queryFn:async()=>{const{data:a}=await S.from("discord_users").select("username, global_name").eq("id",s.discord_id).maybeSingle();return a??null}}),{data:Oe}=A({queryKey:["profile-discord-import-fallback",s==null?void 0:s.discord_id],enabled:!!(s!=null&&s.discord_id),queryFn:async()=>{const{data:a}=await S.from("discord_user_import_data").select("discord_username").eq("discord_id",s.discord_id).maybeSingle();return a??null}}),ft=!!(s!=null&&s.settings.show_join_date),{data:ht}=A({queryKey:["profile-membership-anchor",s==null?void 0:s.user_id],enabled:!!(s!=null&&s.user_id)&&ft,queryFn:async()=>{const{data:a,error:o}=await S.rpc("public_profile_membership_anchor",{p_user_id:s.user_id});if(o)throw o;return a}}),Ne=h.useMemo(()=>{const a=new Set(["admin","superadmin","editor","editorial","moderator","finance","marketing","support","customer support","customer_support","customersupport"]);return[...Array.isArray(te)?te:[],...(M==null?void 0:M.discord_roles)??[]].some(f=>a.has(String(f??"").trim().toLowerCase()))},[te,M==null?void 0:M.discord_roles]),ze=ee?{current_streak:ee.current_streak}:null,ke=ee==null?void 0:ee.message_count,{data:As=0}=Cr(s==null?void 0:s.user_id),{data:Ts=0}=Sr(s==null?void 0:s.user_id),{data:Es=0}=A({queryKey:["profile-member-months",s==null?void 0:s.user_id],enabled:!!(s!=null&&s.user_id),queryFn:async()=>{const{data:a,error:o}=await S.rpc("public_profile_member_months_total",{p_user_id:s.user_id});if(o)throw o;return Math.max(0,Number(a??0))}});h.useEffect(()=>{ne(1),Z(1),H("all"),R("newest")},[s==null?void 0:s.user_id,s==null?void 0:s.discord_id]),h.useEffect(()=>{q(F==="trading-league"?"trading-league":F==="articles"?"articles":F==="likes"?"likes":"posts")},[F,s==null?void 0:s.user_id]),h.useEffect(()=>{T==="articles"&&(C==null?void 0:C.hasAuthorProfile)===!1&&q("posts")},[T,C==null?void 0:C.hasAuthorProfile]),h.useEffect(()=>{T==="trading-league"&&!pt&&!B&&q("posts")},[T,B,pt]);const{data:de,isLoading:Fs,isFetching:gt}=A({queryKey:["profile-messages",s==null?void 0:s.user_id,s==null?void 0:s.discord_id,J],enabled:!!(s!=null&&s.user_id)&&!!(s!=null&&s.settings.show_posts),placeholderData:os,queryFn:async()=>{const a=J*Jn,o=a+1,f=String((s==null?void 0:s.discord_id)??"").trim(),v=[];for(let w=0;w<o;w+=50){const{data:Ae,error:qt}=await S.rpc("localized_global_search_chat_messages_v4",{p_from_user_id:s.user_id,p_from_discord_author_id:f||null,p_limit:Math.min(50,o-w),p_offset:w});if(qt)throw qt;if(v.push(...Ae??[]),((Ae==null?void 0:Ae.length)??0)<Math.min(50,o-w))break}const N=v.length>a,se=v.slice(0,a);return se.length===0?{messages:[],hasMore:!1}:{messages:se.map(w=>({...w,channel_name:w.channel_name||"unknown"})),hasMore:N}}}),me=(de==null?void 0:de.messages)??[],Ds=(de==null?void 0:de.hasMore)??!1,Is=Fs&&me.length===0,ue=h.useMemo(()=>{const a=[];for(const o of U??[])o!=null&&o.content&&a.push(o.content);for(const o of me)o!=null&&o.content&&a.push(o.content);return a},[U,me]),Pe=h.useMemo(()=>{const a=new Set;for(const o of ue){const f=o.match(/<#(\d+)>/g)??[];for(const v of f){const N=v.slice(2,-1);N&&a.add(N)}}return[...a]},[ue]),{data:bt={}}=A({queryKey:["profile-discord-channel-mentions",Pe],enabled:Pe.length>0,queryFn:async()=>{const a=S,[o,f]=await Promise.all([a.from("discord_channels").select("id, guild_id, name").in("id",Pe),a.from("discord_channels").select("id, guild_id, name").in("guild_id",Pe)]);if(o.error)throw o.error;if(f.error)throw f.error;const v=(o.data??[]).map(w=>w.id),N=v.length?await a.from("discord_chat_channel_map").select("discord_channel_id, chat_channel_id").in("discord_channel_id",v):{data:[],error:null};if(N.error)throw N.error;const se=new Map((N.data??[]).map(w=>[w.discord_channel_id,w.chat_channel_id])),xe={};for(const w of o.data??[])!(w!=null&&w.id)||!(w!=null&&w.name)||xe[w.id]||(xe[w.id]={name:w.name,chatChannelId:se.get(w.id)??null});for(const w of f.data??[])!(w!=null&&w.guild_id)||!(w!=null&&w.name)||xe[w.guild_id]||(xe[w.guild_id]={name:w.name,chatChannelId:se.get(w.id)??null});return xe},staleTime:5*6e4}),Ke=h.useMemo(()=>{const a=new Set;for(const o of ue){const f=o.match(/<@!?(\d+)>/g)??[];for(const v of f){const N=v.replace(/[<@!>]/g,"");N&&a.add(N)}}return[...a]},[ue]),He=h.useMemo(()=>{const a=new Set;for(const o of ue)for(const f of o.matchAll(Xn))f[1]&&a.add(f[1]);return[...a]},[ue]),{data:yt={}}=A({queryKey:["profile-discord-user-mentions",Ke],enabled:Ke.length>0,queryFn:async()=>{const a=S,{data:o,error:f}=await a.from("profiles").select("discord_id, user_id, display_name").in("discord_id",Ke);if(f)throw f;const v={};for(const N of o??[])!(N!=null&&N.discord_id)||!(N!=null&&N.user_id
1)||(v[N.discord_id]={userId:N.user_id,displayName:N.display_name||"member"});return v},staleTime:5*6e4}),{data:_t={}}=A({queryKey:["profile-app-user-mentions",He],enabled:He.length>0,queryFn:async()=>{const a=S,{data:o,error:f}=await a.from("profiles").select("user_id, display_name").in("user_id",He);if(f)throw f;const v={};for(const N of o??[])N!=null&&N.user_id&&(v[N.user_id]={userId:N.user_id,displayName:N.display_name||"User"});return v},staleTime:5*6e4}),jt=h.useMemo(()=>a=>bt[a]??null,[bt]),wt=h.useMemo(()=>a=>yt[a]??null,[yt]),vt=h.useMemo(()=>a=>_t[a]??null,[_t]),Nt=h.useMemo(()=>{if(!s)return null;const o=(v=>{if(!v)return null;const N=new Date(v).getTime();return Number.isNaN(N)?null:N})(ht);if(o!==null&&!Ne)return new Date(o);const f=[];if(o!==null&&f.push(o),M!=null&&M.joined_at){const v=new Date(M.joined_at).getTime();Number.isNaN(v)||f.push(v)}if(s.created_at){const v=new Date(s.created_at).getTime();Number.isNaN(v)||f.push(v)}return f.length===0?null:new Date(Math.min(...f))},[ht,M==null?void 0:M.joined_at,s,Ne]),kt=Ln(Nt,Es),Ge=h.useMemo(()=>{const a=[];if(U&&ve&&(s!=null&&s.settings.show_posts))for(const o of U)a.push({kind:"post",id:o.id,created_at:o.created_at,content:o.content,likes:ve.likes.get(o.id)??0,comments:ve.comments.get(o.id)??0});if(me.length&&(s!=null&&s.settings.show_posts))for(const o of me)a.push({kind:"message",id:o.id,created_at:o.created_at,content:o.content,channel_id:o.channel_id,channel_name:o.channel_name});return a.sort((o,f)=>f.created_at.localeCompare(o.created_at))},[U,ve,me,s==null?void 0:s.settings.show_posts]),Ve=h.useMemo(()=>{const a=[];for(const o of xt??[])a.push({kind:"article",id:o.id,at:o.liked_at,title:o.title,subtitle:r("common.profile.content.research"),href:gs(o.content_type,o.seo_slug,o.id)});for(const o of ut??[]){const f=o;a.push({kind:"post",id:o.id,at:f.liked_at||o.created_at,content:o.content,author:o.author_name??r("common.profile.memberFallback"),authorHandle:o.author_username??null})}return a.sort((o,f)=>f.at.localeCompare(o.at))},[xt,ut,r]),qs=h.useMemo(()=>{const a=Array.isArray(te)?te:[],o=(M==null?void 0:M.discord_roles)??[];return vs([...a,...o])},[te,M==null?void 0:M.discord_roles]),Pt=(ze==null?void 0:ze.current_streak)??0,Rs=Math.min(7,Pt),Lt=le?rn(le.total_xp):null,Us=Lt?Math.round(Lt.progress*100):0;if(_)return e.jsx(ra,{});if(!s)return e.jsx(at,{children:e.jsxs("div",{className:"min-h-screen",children:[e.jsx(lt,{}),e.jsxs("div",{className:"flex flex-col items-center justify-center px-3 py-24 text-center text-muted-foreground sm:px-8",children:[e.jsx(Br,{className:"mx-auto mb-4 h-12 w-12 opacity-50"}),e.jsx("p",{className:"text-lg font-medium text-foreground",children:r("common.profile.notFound.title")}),e.jsx("p",{className:"text-sm",children:r("common.profile.notFound.description")}),e.jsx(re,{to:"/home",className:"mt-6 text-sm font-medium text-primary underline-offset-4 hover:underline",children:r("common.profile.notFound.backToFeed")})]})]})});const We=s.settings.show_bio,Le=s.settings.show_posts,Ct=s.settings.show_likes,St=s.settings.show_discord_info,ie=s.settings.show_activity_stats,Ce=bs(s.username,s.display_name,s.user_id,{discordUsername:(ce==null?void 0:ce.username)??(Oe==null?void 0:Oe.discord_username)??null,discordGlobalName:(ce==null?void 0:ce.global_name)??null}),$s=Ce.primary,Qe=((It=s.display_name)==null?void 0:It.trim())||$s,be=ys(s.username),Bs=qs,Os=(Array.isArray(te)?te:[]).map(a=>String(a??"").trim().toLowerCase()),Se=(()=>{const a=[["superadmin","Team"],["admin","Team"],["manager","Team"],["editor","Team"],["moderator","Team"],["finance","Team"],["marketing","Team"],["support","Team"],["accountant","Team"]],o=new Set([...Os,...((M==null?void 0:M.discord_roles)??[]).map(f=>String(f??"").trim().toLowerCase())]);for(const[f,v]of a)if(o.has(f))return v;return null})(),Je=new Set;Se&&Je.add(Se.toLowerCase()),s.is_verified_pro&&Je.add("pro");const Mt=Bs.filter(a=>!Je.has(a.trim().toLowerCase())),At=Se?Se.toUpperCase():null,Me=Re(s.user_id),zs=Le?ke??Ge.length:0,Ks=Ct?Ve.length:0,Ze=((C==null?void 0:C.articles)??[]).filter(a=>P==="all"||a.profile_type===P),Tt=(C==null?void 0:C.hasAuthorProfile)===!0,Et=(C==null?void 0:C.totalCount)??Ze.length,Hs=(C==null?void 0:C.filterCounts)??{all:Et,article:0,livestream:0,market_pulse:0,premium:0},Gs=(C==null?void 0:C.filteredCount)??Ze.length,Vs=(C==null?void 0:C.hasMore)===!0,Ws=["posts",...B?["trading-league"]:[],...Tt?["articles"]:[],"likes"],Qs=a=>{q(a),l(o=>{const f=new URLSearchParams(o);return a==="posts"?f.delete("tab"):f.set("tab",a),f},{replace:!0})},ye=Be??[],Xe=St&&ye.length>0,Ft=typeof ke=="number"&&ke>
1=1,Ye=[ie&&Ft,ie&&!!le,ie,Xe].filter(Boolean).length;return e.jsx(at,{children:e.jsxs("div",{className:"relative min-h-screen",children:[e.jsx(lt,{}),e.jsx("div",{className:"min-w-0 pb-16 sm:pb-20",children:e.jsxs("div",{className:"mx-auto w-full",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"relative h-[100px] w-full overflow-hidden bg-muted sm:h-[128px] lg:h-[168px]",children:[s.banner_url?e.jsx("img",{src:s.banner_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("div",{className:"h-full w-full",style:{background:Me}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/35 via-black/10 to-black/20","aria-hidden":!0})]}),e.jsx("div",{className:"relative z-10 mx-auto -mt-12 max-w-[900px] px-3 pt-3 sm:-mt-14 sm:px-5 sm:pt-3.5 lg:px-8",children:e.jsxs("div",{className:"flex items-end gap-4 sm:gap-5",children:[e.jsxs(I.div,{initial:{scale:.92,opacity:0},animate:{scale:1,opacity:1},transition:{type:"spring",stiffness:220,damping:22},className:"relative shrink-0",children:[e.jsx("div",{className:k("w-24 h-24 sm:w-[104px] sm:h-[104px] rounded-[12px] flex items-center justify-center text-white text-3xl sm:text-[34px] font-semibold shadow-lg ring-[3.5px] ring-background overflow-hidden"),style:s.avatar_url?void 0:{background:Me},children:s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:"",className:"h-full w-full object-cover"}):Ce.initial}),s.settings.show_online_status&&ur(s.last_seen_at)?e.jsx("span",{className:"absolute -bottom-1 -end-1 z-10 h-5 w-5 rounded-full border-[3px] border-background bg-emerald-500 shadow-sm sm:h-6 sm:w-6","aria-label":r("common.profile.presence.online")}):null,e.jsx(Ie,{show:s.is_verified_pro,size:"lg"})]}),e.jsx(I.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{delay:.12},className:"ms-auto flex pb-1",children:j?e.jsxs("button",{type:"button",onClick:()=>X(!0),className:"flex items-center gap-1.5 px-3.5 sm:px-4 py-2 rounded-[2px] border border-border/60 bg-background text-foreground shadow-sm hover:bg-muted/40 transition-colors text-[13px] font-medium",children:[e.jsx(Or,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:r("common.profile.actions.editProfile")}),e.jsx("span",{className:"sm:hidden",children:r("common.profile.actions.edit")})]}):e.jsx(xn,{userId:s.user_id,className:"!rounded-[2px] !shadow-md ring-2 ring-background text-[13px] px-4 py-2 !bg-foreground !text-background hover:!bg-foreground
1/90"})})]})}),e.jsxs("div",{className:"mx-auto max-w-[900px] px-3 pb-4 pt-2 sm:px-5 lg:px-8",children:[e.jsxs(I.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:.06},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("h2",{className:"text-[21px] sm:text-[24px] font-semibold tracking-[-0.025em] text-foreground",children:Qe}),e.jsx(dt,{show:s.is_verified_pro,status:s.member_badge_status,size:"lg"}),At?e.jsx("span",{className:"inline-flex h-4 items-center bg-muted/25 px-1 text-[9px] font-semibold leading-none tracking-[0.08em] text-muted-foreground",children:At}):null]}),be?e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[13px] text-muted-foreground",children:be}),e.jsx("button",{type:"button",className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":r("common.profile.actions.copyHandle"),onClick:async()=>{try{await xr(be),E(!0),$.success(r("common.profile.feedback.copied")),window.setTimeout(()=>E(!1),2e3)}catch{$.error(r("common.profile.feedback.copyFailed"))}},children:O?e.jsx(ct,{className:"w-3.5 h-3.5 text-success"}):e.jsx(Ar,{className:"w-3.5 h-3.5 text-muted-foreground/50"})})]}):null,St&&Mt.length>0?e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:Mt.map((a,o)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md border border-border/30 bg-muted/10 text-[11px] text-foreground/80",children:[e.jsx("span",{className:k("w-1.5 h-1.5 rounded-full shrink-0",Xt[o%Xt.length])}),a]},`${a}-${o}`))}):null]}),We&&s.bio?e.jsx("p",{className:"mt-2 max-w-lg text-[13px] leading-relaxed text-foreground/75",children:s.bio}):null,We?e.jsx(fs,{links:s.social_links}):null,!We&&s.bio?e.jsx("p",{className:"text-[11px] text-muted-foreground/60 mt-2 italic",children:r(j?"common.profile.bio.hiddenFromOthers":"common.profile.bio.hiddenByMember")}):null,ft?e.jsxs("p",{className:"mt-1.5 text-[12px] leading-relaxed text-muted-foreground",children:[r("common.profile.joined",{date:_s(Nt??new Date(s.created_at),t,{month:"short",year:"numeric"})}),kt?` · ${kt}`:""]}):null,e.jsxs(I.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{delay:.1},className:"mt-2 flex items-center gap-4 text-[12.5px]",children:[e.jsxs("button",{type:"button",className:"text-start hover:opacity-90 transition-opacity",onClick:()=>K("following"),children:[e.jsx("span",{className:"font-semibold tabular-nums text-foreground",children:D(As)})," ",e.jsx("span",{className:"text-muted-foreground",children:r("common.profile.following")})]}),e.jsxs("button",{type:"button",className:"text-start hover:opacity-90 transition-opacity",onClick:()=>K("followers"),children:[e.jsx("span",{className:"font-semibold tabular-nums text-foreground",children:D(Ts)})," ",e.jsx("span",{className:"text-muted-foreground",children:r("common.profile.followers")})]})]})]})]}),e.jsxs("div",{className:"mx-auto max-w-[900px] space-y-2 px-3 sm:px-5 lg:px-8",children:[(ie||Xe)&&e.jsxs(I.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.14},className:k("-mx-3 flex snap-x gap-2 overflow-x-auto px-3 py-1.5 scrollbar-none [scrollbar-width:none] sm:-mx-5 sm:gap-2 sm:px-5 lg:mx-0 lg:grid lg:gap-2 lg:overflow-visible lg:px-0 lg:py-0 [&::-webkit-scrollbar]:hidden",Ye===4?"lg:grid-cols-4":Ye===3?"lg:grid-cols-3":Ye===2?"lg:grid-cols-2":"lg:grid-cols-1"),children:[ie&&Ft?e.jsx(ts,{label:r("common.profile.stats.messages"),value:D(ke),sub:r("common.profile.stats.allTime")}):null,ie&&le?e.jsx(ts,{label:r("common.profile.stats.xp"),value:D(le.total_xp||0),sub:r("common.profile.stats.toNextLevel",{percent:Us,level:le.level+1})}):null,ie?e.jsxs("div",{className:"min-w-[118px] shrink-0 rounded-[3px] bg-muted/25 p-2.5 shadow-sm sm:min-w-0 sm:p-3",children:[e.jsx("p",{className:"text-[9.5px] font-medium uppercase tracking-[0.13em] text-muted-foreground/70",children:r("common.profile.stats.streak")}),e.jsx("p",{className:"mt-0.5 text-[17px] font-medium leading-tight tabular-nums tracking-[-0.025em] text-foreground sm:text-[20px] lg:text-[21px]",children:r("common.profile.stats.days",{count:Pt})}),e.jsx("div",{className:"mt-1.5 flex max-w-[96px] gap-[2.5px]",children:Array.from({length:7}).map((a,o)=>e.jsx("div",{className:k("h-[3px] flex-1 rounded-sm",o<Rs?"bg-rose-500/75 dark:bg-rose-300/75":"bg-muted-foreground
1/20")},o))})]}):null,Xe?e.jsxs("button",{type:"button",onClick:()=>W(!0),"aria-label":r("common.profile.badges.viewAllLabel",{count:ye.length}),className:"group min-w-[118px] shrink-0 rounded-[3px] bg-muted/25 p-2.5 text-start shadow-sm transition-colors hover:bg-muted/35 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 sm:min-w-0 sm:p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[e.jsx("p",{className:"text-[9.5px] font-medium uppercase tracking-[0.13em] text-muted-foreground/70",children:r("common.profile.badges.title")}),e.jsx(qe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/50 transition-colors group-hover:text-muted-foreground"})]}),e.jsx("p",{className:"mt-0.5 text-[17px] font-medium leading-tight tabular-nums tracking-[-0.025em] text-foreground sm:text-[20px] lg:text-[21px]",children:ye.length>0?D(ye.length):r("common.profile.badges.viewAll")}),e.jsx("p",{className:"mt-1 text-[10.5px] leading-snug text-muted-foreground",children:ye.length>0?r("common.profile.badges.viewAll"):r("common.profile.badges.seeAvailable")})]}):null]}),e.jsx(ws,{profileUserId:s.user_id}),e.jsx("div",{className:"-mx-3 border-b border-border/30 px-3 sm:-mx-5 sm:px-5 lg:-mx-8 lg:px-8",children:e.jsx("div",{className:"flex gap-0 overflow-x-auto max-w-full scrollbar-none [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:Ws.map((a,o)=>e.jsxs("button",{type:"button",onClick:()=>Qs(a),className:k("relative flex shrink-0 items-center gap-2 py-2 text-[13px] whitespace-nowrap transition-colors capitalize",o===0?"pl-0 pr-6":"px-3",T===a?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx("span",{children:r(`common.profile.tabs.${a.replace("-","_")}`)}),e.jsx("span",{className:k("rounded-[5px] px-1.5 py-0.5 text-[10px] font-medium tabular-nums",T===a?k(es,Yt):"bg-muted/30 text-muted-foreground"),children:a==="posts"?D(zs):a==="trading-league"?D(1):a==="articles"?D(Et):D(Ks)}),T===a?e.jsx(I.div,{layoutId:"profileTabUnderline",className:k("absolute bottom-0 h-0.5 rounded-full bg-foreground dark:bg-[#d7ff55]",o===0?"left-0 right-6":"left-2 right-2"),transition:{type:"spring",stiffness:380,damping:32}}):null]},a))})}),e.jsx("div",{className:"pt-4 pb-12",children:e.jsx(ps,{mode:"wait",children:T==="posts"?e.jsxs(I.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.2},className:"space-y-0",children:[Is&&Le?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:[e.jsx(is,{className:"me-2"}),r("common.states.loading")]}):Le?Ge.length===0?e.jsx("div",{className:"text-center py-16 text-muted-foreground text-sm",children:r("common.profile.content.noPosts")}):Ge.map((a,o)=>a.kind==="post"?e.jsx(I.div,{role:"button",tabIndex:0,"aria-label":r("common.profile.content.openOriginalPost"),onClick:f=>{ss(f.target)||n(rs(a.id))},onKeyDown:f=>{f.target===f.currentTarget&&(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),n(rs(a.id)))},initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:Math.min(o*.03,.25)},className:"group cursor-pointer border-b border-border/30 px-0 py-5 transition-colors hover:bg-muted/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"relative h-9 w-9 shrink-0",children:[e.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden rounded-[8px] text-[11px] font-semibold text-white",style:s.avatar_url?void 0:{background:Me},children:s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:"",className:"h-full w-full object-cover"}):Ce.initial}),e.jsx(Ie,{show:s.is_verified_pro,size:"xs"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5",children:[e.jsx(Qt,{name:Qe,isStaff:Ne,isOwn:j,isVerifiedPro:s.is_verified_pro,badgeStatus:s.member_badge_status}),be?e.jsx("span",{className:"text-[11px] text-muted-foreground",children:be}):null,e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["· ",je(new Date(a.created_at),t)]})]}
1),e.jsx(Jt,{content:a.content,lookups:{resolveChannel:jt,resolveDiscordUser:wt,resolveAppUser:vt},className:"text-[15px] tracking-[-0.01em]"}),e.jsxs("div",{className:"flex items-center gap-4 mt-2.5 text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1 text-[12px]",children:[e.jsx(et,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"tabular-nums",children:a.likes})]}),e.jsxs("span",{className:"flex items-center gap-1 text-[12px]",children:[e.jsx(Tr,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"tabular-nums",children:a.comments})]})]})]})]})},`p-${a.id}`):e.jsx(I.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:Math.min(o*.03,.25)},className:"group border-b border-border/30",children:e.jsxs("div",{role:"button",tabIndex:0,onClick:f=>{ss(f.target)||n(Gt(a.channel_name,a.id,a.channel_id))},onKeyDown:f=>{f.target===f.currentTarget&&(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),n(Gt(a.channel_name,a.id,a.channel_id)))},className:"flex w-full items-start gap-3 px-0 py-5 text-start transition-colors hover:bg-muted/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60","aria-label":r("common.profile.content.openMessage",{channel:Ue(a.channel_name)}),children:[e.jsxs("div",{className:"relative h-9 w-9 shrink-0",children:[e.jsx("div",{className:"flex h-full w-full items-center justify-center overflow-hidden rounded-[8px] text-[11px] font-semibold text-white",style:s.avatar_url?void 0:{background:Me},children:s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:"",className:"h-full w-full object-cover"}):Ce.initial}),e.jsx(Ie,{show:s.is_verified_pro,size:"xs"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5",children:[e.jsx(Qt,{name:Qe,isStaff:Ne,isOwn:j,isVerifiedPro:s.is_verified_pro,badgeStatus:s.member_badge_status}),e.jsxs("span",{className:k("inline-flex items-center gap-0 rounded-[4px] px-1 py-px text-[10px] font-medium",ea),children:[e.jsx(ot,{className:"w-2.5 h-2.5"}),Ue(a.channel_name)]}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:je(new Date(a.created_at),t)})]}),e.jsx(Jt,{content:a.content,lookups:{resolveChannel:jt,resolveDiscordUser:wt,resolveAppUser:vt},className:"mt-0.5 text-[15px] tracking-[-0.01em]"})]})]})},`m-${a.id}`)):e.jsx("div",{className:"text-center py-16 text-muted-foreground text-sm",children:r(j?"common.profile.content.ownPostsHidden":"common.profile.content.postsHidden")}),Ds&&Le?e.jsx("div",{className:"pt-5",children:e.jsx("button",{type:"button",onClick:()=>ne(a=>a+1),disabled:gt,className:k("inline-flex items-center rounded-[6px] border px-3.5 py-2 text-[12px] font-medium transition-colors disabled:opacity-60",Yn,es,Yt,"hover:bg-muted/65 dark:hover:bg-[#d7ff55]/18"),children:r(gt?"common.actions.loadingMore":"common.actions.loadMore")})}):null]},"posts"):T==="trading-league"?e.jsx(I.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.2},children:B?e.jsxs(re,{to:B.href,"aria-label":r("common.profile.tradingLeague.viewOverview",{portfolio:B.portfolioName}),className:"group flex items-center gap-3 rounded-[3px] bg-muted/25 p-3 shadow-sm transition-colors hover:bg-muted/35 sm:gap-4 sm:p-3.5",children:[e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-[3px] bg-muted/35 text-foreground dark:bg-[#d7ff55]/12 dark:text-[#d7ff55]",children:e.jsx(Er,{className:"h-4 w-4","aria-hidden":!0})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-[14px] font-semibold text-foreground sm:text-[15px]",children:B.portfolioName}),e.jsxs("span",{className:"mt-1 block truncate text-[11px] text-muted-foreground sm:text-[12px]",children:[B.seasonLabel," · ",ta(B.status,r)]})]}),e.jsxs("span",{className:"hidden shrink-0 text-end sm:block",children:[e.jsx("span",{className:"block text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:r("common.profile.tradingLeague.value")}),e.jsx("span",{className:"mt-1 block text-[13px] font-semibold tabular-nums text-foreground",children:gr(B.portfolioValue)})]}),e.jsxs("span",{className:"shrink-0 text-end",children:[e.jsx("span",{className:"block text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:r("common.profile.tradingLeague.return")}
1),e.jsx("span",{className:k("mt-1 block text-[13px] font-semibold tabular-nums",B.returnPct>=0?"text-success":"text-destructive"),children:br(B.returnPct)})]}),e.jsxs("span",{className:"hidden min-w-[48px] shrink-0 text-end md:block",children:[e.jsx("span",{className:"block text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:r("common.profile.tradingLeague.assets")}),e.jsx("span",{className:"mt-1 block text-[13px] font-semibold tabular-nums text-foreground",children:D(B.assetCount)})]}),e.jsx(qe,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5","aria-hidden":!0})]}):null},"trading-league"):T==="articles"?e.jsx(I.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.2},className:"space-y-0",children:Tt?e.jsx(sn,{articles:Ze,counts:Hs,filter:P,sort:L,filteredCount:Gs,hasMore:Vs,isFetching:Ls,onFilterChange:a=>{H(a),Z(1)},onSortChange:a=>{R(a),Z(1)},onLoadMore:()=>Z(a=>a+1)}):e.jsx("div",{className:"text-center py-16 text-muted-foreground text-sm",children:r("common.profile.content.noArticles")})},"articles"):e.jsx(I.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.2},className:"space-y-0",children:Ct?Ve.length===0?e.jsx("div",{className:"text-center py-16 text-muted-foreground text-sm",children:r("common.profile.content.noLikes")}):Ve.map((a,o)=>e.jsx(I.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:Math.min(o*.04,.3)},className:"group",children:a.kind==="article"?e.jsx(re,{to:a.href,className:"block border-b border-border/30 py-4 transition-colors hover:bg-muted/20 sm:py-5",children:e.jsxs("div",{className:"flex items-start gap-3.5",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-red-500/10",children:e.jsx(et,{className:"h-4 w-4 fill-red-500 text-red-500","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"mb-1.5 text-[11px] leading-4 text-muted-foreground",children:je(new Date(a.at),t)}),e.jsx("p",{className:"text-[15px] font-medium leading-[1.4] tracking-[-0.01em] text-foreground",children:a.title})]})]})}):e.jsx("div",{className:"border-b border-border/30 py-4 transition-colors hover:bg-muted/20 sm:py-5",children:e.jsxs("div",{className:"flex items-start gap-3.5",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-red-500/10",children:e.jsx(et,{className:"h-4 w-4 fill-red-500 text-red-500","aria-hidden":!0})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[11px] text-muted-foreground mb-1",children:[r("common.profile.content.likedPost")," · ",je(new Date(a.at),t)]}),e.jsx("p",{className:"text-[14px] leading-relaxed text-foreground/90 whitespace-pre-wrap",children:a.content}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r("common.profile.content.by")," ",a.authorHandle?e.jsx(re,{to:he(a.authorHandle),className:"text-primary hover:underline",children:a.author}):a.author]})]})]})})},`${a.kind}-${a.id}`)):e.jsx("div",{className:"text-center py-16 text-muted-foreground text-sm",children:r(j?"common.profile.content.ownLikesHidden":"common.profile.content.likesHidden")})},"likes")})})]})]})}),e.jsx(bn,{open:Y,onOpenChange:W,earnedBadgeIds:Ms}),s?e.jsx(wn,{open:Q!==null,onOpenChange:a=>{a||K(null)},userId:s.user_id,mode:Q??"followers"}):null,j&&s?e.jsx(fn,{open:V,onOpenChange:X,profile:s}):null]})})},ks=()=>{const{user:t,loading:r}=$e();return r?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(is,{className:"!h-8 !w-8"})}):t?e.jsx(na,{}):e.jsx(Qn,{})};function _i(){const{handle:t}=we();if(!t)return e.jsx(ge,{});const r=wr(t);return r?e.jsx(oe,{to:r,replace:!0}):ls(t)?e.jsx(ge,{}):js(t)?e.jsx(aa,{slug:t}):e.jsx(ks,{})}function aa({slug:t}){const{t:r}=yr(),{data:n,isPending:i}=A({queryKey:["legacy-news-root-redirect",t],queryFn:()=>un(t),staleTime:6e4});return i?e.jsx("div",{className:"min-h-svh bg-background",role:"status","aria-label":r("common.loading"),"aria-busy":"true"}):n?e.jsx(oe,{to:n,replace:!0}):e.jsx(ge,{})}function ji(){const{username:t}=we();if(!t)return e.jsx(oe,{to:"/",replace:!0});const r=t.trim();if(!r)return e.jsx(oe,{to:"/",replace:!0});const n=jr(r);return n?e.jsx(oe,{to:he(n),replace:!0}):ls(r)?e.jsx(ge,{}):e.jsx(oe,{to:he(r),replace:!0})}function wi(){const{userId:t}=we(),{data:r}=cn({queryKey:fr(t),queryFn:()=>
1(t?pr(t):Promise.resolve(null)).catch(()=>null)});return t?r?r.username?e.jsx(oe,{to:he(r.username),replace:!0}):e.jsx(ks,{}):e.jsx(ge,{}):e.jsx(ge,{})}export{wi as LegacyProfileIdEntry,ji as LegacyProfilePathRedirect,_i as ProfileHandleEntry};
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.