PageSourceSearch

https://pblfg.com/assets/AccountSettings-DGqIXomn.js

js pblfg.com collected 2026-09-24 14:50:21 UTC 33,883 bytes, 25 lines download raw bytes

1import{r,j as e,m as ze,k as nt,L as V}from"./react-vendor-Q2BSRknM.js";import{u as L,a as lt}from"./query-BLOP9k_M.js";import{q as de,s as x,ab as ot,h as oe,B as E,C as q,b as M,d as R,a9 as Ke,e as U,ak as ct,a8 as De,R as ce,c as $,ad as P,al as dt,am as Ae,an as mt,ao as ut,ap as pt,aq as xt,ar as ft,as as ht,at as Ie,au as gt,$ as vt,u as jt,a1 as bt,a as yt,a2 as wt,av as kt,aw as Nt,a3 as _t,a4 as St,ax as Ee,ay as Le,az as qe,aA as Ct,aB as Tt,aC as Pt,aD as Me,aE as Dt,aF as At,aG as It,r as re,v as ie,w as ne,aH as Et,aI as Lt,Q as f,aJ as Ue,aK as qt}from"./index-CuraQpvj.js";import{H as Mt}from"./HandOfCardsIcon-V--rezwD.js";import{C as Ut}from"./CardVault-CG7bgH27.js";import{I as Ft}from"./ImageCropper-DRRbELg7.js";import{u as Rt}from"./usePickemPrizes-B6qBA3iz.js";import{aR as Ot,b as Bt,c as zt,y as He,w as Kt,J as Ht,ag as Ve,X as Vt,aj as $t,d as Fe,aS as Qt,aD as Yt,L as Jt,aT as Wt,aU as Re,I as Gt,aC as Xt,e as le,aV as Oe,aW as Zt,ak as es}from"./lucide-DhlFjs1-.js";import{A as ts}from"./AlertPreferencesSection-B0n7MxoW.js";import{M as ss}from"./MyAccountSection-DE__B_yj.js";import{D as as}from"./DisplaySection-CXWoekLP.js";import{F as rs}from"./FollowListDrawer-JKZSWr5X.js";import{V as is}from"./VerifiedBadge-k8370q7H.js";import"./capacitor-DSpR9wll.js";import"./ui-radix-DzQ_orwq.js";import"./supabase-DoZmW4Yf.js";import"./date-utils-DaNoSKVa.js";import"./PackTiles-CvAgfuqb.js";import"./cardRarity-BngzBEGy.js";import"./useCardBoost-CjNMtGQN.js";import"./useCardVault-BgcA0iAP.js";import"./useCardsEnabled-0wAqPl2y.js";import"./slider-DKSeILo7.js";import"./LazyNotificationSettings-ByWfdphH.js";import"./TeamAvatar--uUa1PRy.js";import"./useTeamAvatarCache-DnynuOLF.js";import"./usePersistedCollapse-DS6DEHRL.js";import"./useUserFollows-DQ7w9k1i.js";function ns(){const{user:i}=de(),{data:n,isLoading:s}=L({queryKey:["pickem-history",i==null?void 0:i.id],queryFn:async()=>{if(!(i!=null&&i.id))return[];const{data:m,error:d}=await x.from("pickem_leaderboard").select(`
2          event_id,
3          rank,
4          total_points,
5          correct_picks,
6          total_picks,
7          tiebreaker_diff,
8          pickem_events!inner(
9            name,
10            status,
11            image_url,
12            predictions_lock_at,
13            updated_at,
14            tournaments(name, image_url)
15          )
16        `).eq("user_id",i.id).order("created_at",{ascending:!1});return d?(console.error("[usePickemHistory] Failed to load history:",d),[]):m.map(a=>{var c,k;return{event_id:a.event_id,event_name:a.pickem_events.name,tournament_name:((c=a.pickem_events.tournaments)==null?void 0:c.name)||"Unknown",status:a.pickem_events.status,rank:a.rank,total_points:a.total_points||0,correct_picks:a.correct_picks||0,total_picks:a.total_picks||0,tiebreaker_diff:a.tiebreaker_diff,predictions_lock_at:a.pickem_events.predictions_lock_at,completed_at:a.pickem_events.status==="completed"?a.pickem_events.updated_at:null,image_url:a.pickem_events.image_url||((k=a.pickem_events.tournaments)==null?void 0:k.image_url)||null}})},enabled:!!(i!=null&&i.id),staleTime:3e4,retry:1}),{data:g,isLoading:h}=L({queryKey:["pickem-badges",i==null?void 0:i.id],queryFn:async()=>{if(!(i!=null&&i.id))return[];const{data:m,error:d}=await x.from("pickem_badges").select(`
17          id,
18          badge_type,
19          event_id,
20          metadata,
21          earned_at,
22          pickem_events(name)
23        `).eq("user_id",i.id).order("earned_at",{ascending:!1});return d?(console.error("[usePickemHistory] Failed to load badges:",d),[]):m.map(a=>{var c;return{id:a.id,badge_type:a.badge_type,event_id:a.event_id,event_name:(c=a.pickem_events)==null?void 0:c.name,metadata:a.metadata||{},earned_at:a.earned_at}})},enabled:!!(i!=null&&i.id),staleTime:3e4,retry:1}),w=m=>({champion:{label:"Champion",emoji:"🏆",color:"text-yellow-500"},podium_finish:{label:"Podium Finish",emoji:"🥈",color:"text-gray-400"},top_10:{label:"Top 10 Finisher",emoji:"🎯",color:"text-blue-500"},perfect_bracket:{label:"Perfect Bracket",emoji:"✨",color:"text-purple-500"},upset_prophet:{label:"Upset Prophet",emoji:"🔮",color:"text-green-500"},first_blood:{label:"First to Submit",emoji:"⚡",color:"text-amber-500"}})[m]||{label:m,emoji:"🏅",color:"text-muted-foreground"},v=(n==null?void 0:n.filter(m=>m.status==="completed"))||[],j=(n==null?void 0:n.filter(m=>m.status!=="completed"))||[];return{history:n,historyLoading:s,badges:g,badgesLoading:h,completedEvents:v,activeEvents:j,getBadgeInfo:w,isLoading:s||h}}function ls({variant:i="card"}={}){const{userPrizes:n,userPrizesLoading:s,claimPrize:g}
23=Rt(),{toast:h}=ot(),[w,v]=r.useState(null),j=async(a,c)=>{await navigator.clipboard.writeText(a),v(c),h({title:"Copied!",description:"Redemption code copied to clipboard"}),setTimeout(()=>v(null),2e3)},m=async a=>{await g.mutateAsync(a),h({title:"Prize Claimed!",description:"Your prize has been marked as claimed"})};if(s||!(n!=null&&n.length))return null;const d=e.jsx(e.Fragment,{children:n.map(a=>{var c;return e.jsxs("div",{className:"p-4 rounded-lg bg-background/50 border border-amber-500/20",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ot,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"font-semibold",children:((c=a.event)==null?void 0:c.name)||"Pick 'Em Event"})]}),e.jsx("p",{className:"text-scalable-sm text-muted-foreground mt-1",children:a.prize_description})]}),a.claimed_at?e.jsx(oe,{className:"bg-green-500/20 text-green-500",children:"Claimed"}):e.jsx(oe,{className:"bg-amber-500/20 text-amber-500 animate-pulse",children:"New!"})]}),a.redemption_code&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx("p",{className:"text-scalable-xs text-muted-foreground uppercase tracking-wide",children:"Redemption Code"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 p-2 bg-muted rounded font-mono text-scalable-sm tracking-wider",children:a.redemption_code}),e.jsx(E,{size:"icon",variant:"outline",onClick:()=>j(a.redemption_code,a.id),children:w===a.id?e.jsx(Bt,{className:"h-4 w-4 text-green-500"}):e.jsx(zt,{className:"h-4 w-4"})})]})]}),!a.claimed_at&&e.jsx(E,{className:"w-full mt-3 bg-amber-500 hover:bg-amber-600 text-black font-semibold",onClick:()=>m(a.id),disabled:g.isPending,children:"Mark as Claimed"}),e.jsxs("p",{className:"text-scalable-xs text-muted-foreground mt-3",children:["Awarded ",new Date(a.assigned_at).toLocaleDateString()," · Find this code anytime in My Profile → Pick 'Em Results → My Prizes."]})]},a.id)})});return i==="inline"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h4",{className:"text-scalable-xs font-player text-muted-foreground uppercase tracking-wide",children:"My Prizes"}),e.jsx("div",{className:"space-y-3",children:d})]}):e.jsxs(q,{className:"mb-6 bg-gradient-to-br from-amber-500/10 via-yellow-500/5 to-orange-500/10 border-amber-500/30",children:[e.jsx(M,{className:"pb-4",children:e.jsxs(R,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ke,{size:20,className:"text-amber-500"}),"My Pick 'Em Prizes"]})}),e.jsx(U,{className:"space-y-4",children:d})]})}function os(){const i=ze(),{userId:n}=de(),{history:s,completedEvents:g,activeEvents:h,isLoading:w}=ns(),{isVisible:v,isLoading:j}=ct(),{data:m}=L({queryKey:["pickem-alltime-stats",n],queryFn:async()=>{if(!n)return null;const{data:p,error:y}=await x.from("pickem_alltime_stats").select("rank, total_correct_picks, total_picks, events_participated").eq("user_id",n).maybeSingle();return y?null:p},enabled:!!n,staleTime:3e4}),{data:d}=L({queryKey:["user-fan-pick-accuracy",n],queryFn:async()=>{if(!n)return null;const{data:p,error:y}=await x.rpc("get_user_fan_pick_accuracy",{_user_id:n});return y?null:Array.isArray(p)?p[0]:p},enabled:!!n,staleTime:6e4}),{data:a}=L({queryKey:["user-fan-pick-counts-by-event",n],queryFn:async()=>{if(!n)return{};const{data:p,error:y}=await x.rpc("get_user_fan_pick_counts_by_event",{_user_id:n});if(y)return{};const C={};for(const N of p||[])C[N.event_id]=N.total_picks||0;return C},enabled:!!n,staleTime:6e4}),{data:c}=L({queryKey:["pickem-alltime-live-rank",n],queryFn:async()=>{if(!n)return null;const{data:p,error:y}=await x.functions.invoke("pickem-leaderboard",{body:{mode:"alltime",series:"all"}});if(y)return null;const N=((p==null?void 0:p.data)??[]).find(u=>u.user_id===n);return(N==null?void 0:N.rank)??null},enabled:!!n,staleTime:6e4}),k=s&&s.length>0;return!n||!j&&!v&&!k?null:w?!j&&!v?null:e.jsxs(q,{className:"mb-3",style:{background:"var(--gradient-match-card)"},children:[e.jsx(M,{className:"px-5 pt-3 pb-2",children:e.jsx(De,{className:"h-6 w-32"})}),e.jsx(U,{className:"px-5 pb-5",children:e.jsx(De,{className:"h-20 w-full"})})]}):k?e.jsxs(q,{className:"mb-3",style:{background:"var(--gradient-match-card)"},children:[e.jsx(M,{className:"px-5 pt-3 pb-2",children:e.jsxs(R,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ke,{size:20,className:"text-primary"}),"Pick 'Em Results",e.jsx(oe,{variant:"outline",className:"ml-auto text-[10px] font-player tracking-wide uppercase text-primary border-primary/40 px-1.5 h-5 leading-none",children:"All-Time"})]})}),e.jsxs(U,{className:"space-y-4 px-5 pb-5",children:[m&&(()=>{const p=m.total_correct_picks||0,y=m.total_picks||0,C=(d==null?void 0:d.correct_picks)||0,N=(d==null?void 0:d.total_picks)||0,u=p+C,D=y+N,_=c??m.rank;return e.jsxs("div",{className:"grid grid-cols-4 gap-2 mt-1",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-xl font-score tracking-wide",children:_?`#${_}`:"—"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Rank"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-xl font-score tracking-wide",children:D>
230?`${Math.round(u/D*100)}%`:"—"}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Accuracy"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-xl font-score tracking-wide",children:[u,"/",D]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Correct"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-xl font-score tracking-wide",children:m.events_participated||0}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Events"})]})]})})(),h.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h4",{className:"text-scalable-xs font-player text-muted-foreground uppercase tracking-wide",children:"Active"}),h.map(p=>e.jsx("button",{onClick:()=>i(`/pickem?event=${p.event_id}&view=results`),className:"w-full px-3 py-2 rounded-lg bg-primary/10 border border-border/30 text-left hover:bg-primary/15 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[p.image_url&&e.jsx("img",{src:p.image_url,alt:"",className:"h-7 w-7 rounded object-contain shrink-0",loading:"lazy"}),e.jsx("p",{className:"font-medium text-sm truncate",children:p.event_name.replace(/ Pick 'Em$/i,"")})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-score tracking-wide text-primary",children:p.total_picks+((a==null?void 0:a[p.event_id])||0)}),e.jsx("p",{className:"text-[10px] font-player text-muted-foreground uppercase tracking-wide -mt-1",children:"PICKS"})]}),e.jsx(He,{className:"h-4 w-4 text-muted-foreground shrink-0"})]})]})},p.event_id))]}),g.length>0&&e.jsx(cs,{completedEvents:g,navigate:i}),e.jsx(ls,{variant:"inline"})]})]}):null}function cs({completedEvents:i,navigate:n}){const[s,g]=r.useState(""),[h,w]=r.useState(!1),v=i.length>5,j=r.useMemo(()=>{if(!s.trim())return i;const c=s.toLowerCase();return i.filter(k=>k.event_name.toLowerCase().includes(c))},[i,s]),m=h?10:2,d=j.slice(0,m),a=j.length>m;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-scalable-xs font-player text-muted-foreground uppercase tracking-wide",children:"Past Events"}),v&&e.jsxs("div",{className:"ml-auto relative",children:[e.jsx(Kt,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground"}),e.jsx(ce,{value:s,onChange:c=>g(c.target.value),placeholder:"Search...",className:"h-6 w-28 pl-6 text-[11px] bg-muted/30 border-border/30"})]})]}),d.map(c=>e.jsx("button",{onClick:()=>n(`/pickem?event=${c.event_id}&view=results`),className:"w-full px-3 py-2 rounded-lg bg-muted/30 border border-border/30 text-left hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.image_url&&e.jsx("img",{src:c.image_url,alt:"",className:"h-7 w-7 rounded object-contain shrink-0",loading:"lazy"}),e.jsx("p",{className:"font-medium text-sm truncate",children:c.event_name.replace(/ Pick 'Em$/i,"")})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[c.rank&&c.rank<=3&&e.jsx(Ht,{className:$("h-4 w-4",c.rank===1&&"text-yellow-500",c.rank===2&&"text-gray-400",c.rank===3&&"text-amber-600")}),e.jsxs("span",{className:"font-score tracking-wide text-lg",children:["#",c.rank||"-"]})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide -mt-1",children:[c.total_points," PTS"]})]}),e.jsx(He,{className:"h-4 w-4 text-muted-foreground shrink-0"})]})]})},c.event_id)),a&&e.jsx("button",{onClick:()=>w(!0),className:"w-full text-center text-scalable-xs text-primary hover:text-primary/80 transition-colors py-1",children:"View more"}),j.length===0&&s&&e.jsx("p",{className:"text-scalable-xs text-center text-muted-foreground py-2",children:"No events found"})]})}function ds({trigger:i,open:n,onOpenChange:s}){const[g,h]=r.useState(!1),[w,v]=r.useState("midnight-blue"),[j,m]=r.useState(!1),[d,a]=r.useState("pearl-mist"),[c,k]=r.useState("midnight-blue"),p=n??g,y=s??h;r.useEffect(()=>{(async()=>{try{const[u,D,_,me]=await Promise.all([P.getItem("theme"),P.getItem("useDeviceSettings"),P.getItem("lightTheme"),P.getItem("darkTheme")]);m(D==="true"),a(_||"pearl-mist"),k(me||"midnight-blue"),u&&(dt.some(ue=>ue.id===u)||Ae(u))&&v(u)}catch{}})()},[]);const C=u=>{v(u),document.documentElement.setAttribute("data-theme",u),Ie(u),j?gt.some(_=>_.id===u)||Ae(u)?(k(u),P.setItem("darkTheme",u)):(a(u),P.setItem("lightTheme",u)):P.setItem("theme",u)},N=u=>{if(m(u),P.setItem("useDeviceSettings",String(u)),u){const _=window.matchMedia("(prefers-color-scheme: dark)").matches?c:d;v(_),document.documentElement.setAttribute("data-theme",_),Ie(_)}else P.setItem("theme",w)};return e.jsxs(e.Fragment,{children:[i(()=>y(!0)),e.jsx(mt,{open:p,onOpenChange:y,children:e.jsxs(ut,{className:"max-h-[92dvh] overflow-y-auto overscroll-contain pb-safe !px-4",style:{background:"var(--gradient-header)"},children:[e.jsx(pt,{className:"!space-y-0 !p-0 !pt-2",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs(xt,{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"h-5 w-5"}),"Choose Your Style"]}),e.jsx(ft,{className:"rounded-full p-1.5 bg-muted hover:bg-accent transition-colors flex-shrink-0",children:e.jsx(Vt,{className:"h-4 w-4"})})]})}),e.jsx(ht,{selectedTheme:w,useDeviceSettings:j,darkThemePreference:c,lightThemePreference:d,onThemeChange:C,onDeviceSettingsToggle:N})]})})]})}function Be(i){if(i<1e3)return String(i);if(i<1e6){const s=i/1e3;return(s>=100?Math.floor(s):Math.round(s*10)/10)+"k"}const n=i/1e6;return(n>=100?Math.floor(n):Math.round(n*10)/10)+"m"}const sa=()=>{const i=ze(),n=nt(),{user:s}=de(),g=lt(),{isAdmin:h}=vt(),[w,v]=r.useState(!1),[j,m]=r.useState(!1),d=jt();bt();const{isNativeIOS:a}=yt(),{isNativeAndroid:c}=wt(),[k,p]=r.useState(""),[y,C]=r.useState(""),[N,u]=r.useState(!1),[D,_]=r.useState(!1),[me,ue]=r.useState(!1),[ms,us]=r.useState(""),[ps,xs]=r.useState(!1),pe
23="pbpulse:account-profile-cache:v1",b=(()=>{try{const t=typeof window<"u"?window.localStorage.getItem(pe):null;return t?JSON.parse(t):null}catch{return null}})(),[fs,$e]=r.useState((b==null?void 0:b.timezone)||"America/Los_Angeles"),[hs,gs]=r.useState(!1),[A,Q]=r.useState((b==null?void 0:b.avatar_url)??null),[xe,O]=r.useState(!1),[Qe,Y]=r.useState(null),[Ye,J]=r.useState(!1),B=r.useRef(null),[W,Je]=r.useState(null),[We,Ge]=r.useState(null),G=!!W,fe=(G?We||(W?kt(W):null):null)||A,[X,Z]=r.useState((b==null?void 0:b.display_name)||""),{isVerified:Xe,getVerifiedBadgeVariant:Ze}=Nt(),[js,he]=r.useState(!1),[ge,ee]=r.useState(!1),ve=r.useRef(null),[F,je]=r.useState((b==null?void 0:b.bio)||""),[et,te]=r.useState(!1),[be,ye]=r.useState(!1),we=r.useRef(null),[z,K]=r.useState((b==null?void 0:b.link)||""),[tt,se]=r.useState(!1),[ke,Ne]=r.useState(!1),_e=r.useRef(null),[ae,H]=r.useState(null),{data:T}=L({queryKey:["follow-counts",s==null?void 0:s.id],queryFn:async()=>{if(!(s!=null&&s.id))return{followers:0,following:0};const[{data:t},{data:o}]=await Promise.all([x.rpc("get_user_followers_count",{_target_user_id:s.id}),x.rpc("get_user_following_count",{_source_user_id:s.id})]);return{followers:t??0,following:o??0}},enabled:!!(s!=null&&s.id),staleTime:3e4}),[bs,ys]=r.useState(!1),[ws,ks]=r.useState(!1),[Ns,_s]=r.useState(""),[Ss,Cs]=r.useState(!1);r.useEffect(()=>{const t=n.state;t!=null&&t.openThemePicker&&(m(!0),t.expandMlpTeamPicker&&setTimeout(()=>window.dispatchEvent(new Event("open-mlp-team-picker")),220),i(n.pathname,{replace:!0,state:null}))},[n.pathname,n.state,i]),r.useEffect(()=>{const t=async()=>{if(!s)return;const{data:l,error:S}=await x.from("profiles").select("timezone, avatar_url, display_name, bio, link").eq("id",s.id).maybeSingle();if(!S&&l){l.timezone&&$e(l.timezone),Q(l.avatar_url??null),Z(l.display_name||""),je(l.bio||""),K(l.link||"");try{window.localStorage.setItem(pe,JSON.stringify({userId:s.id,timezone:l.timezone,avatar_url:l.avatar_url??null,display_name:l.display_name||"",bio:l.bio||"",link:l.link||""}))}catch{}}},o=async()=>{if(!s)return;const{data:l}=await x.from("player_user_links").select("player_name, admin_override_avatar_url").eq("user_id",s.id).is("external_source",null).not("player_name","like","pbtv:%").maybeSingle();Je((l==null?void 0:l.player_name)??null),Ge((l==null?void 0:l.admin_override_avatar_url)??null)};t(),o()},[s]),r.useEffect(()=>{if(!s){v(!1);return}(async()=>{var t;try{const{data:o}=await x.from("admin_permissions").select("allowed_tabs").eq("user_id",s.id).maybeSingle();v(h||((t=o==null?void 0:o.allowed_tabs)==null?void 0:t.includes("eventboard"))||!1)}catch{v(h)}})()},[s,h]);const Se=async()=>{if(!s)return;const t=X.trim();if(t.length<3||t.length>20){f({title:"Name must be 3-20 characters",variant:"destructive"});return}const o=Ue(t,"Display name");if(o){f({title:o,variant:"destructive"});return}he(!0);try{const{data:l,error:S}=await x.from("profiles").update({display_name:t,updated_at:new Date().toISOString()}).eq("id",s.id).select("id, display_name").maybeSingle();if(S)throw S;if(!l){f({title:"Couldn't save name",description:"Your account session may be out of sync. Try signing out and back in.",variant:"destructive"});return}const{data:I}=await x.from("profiles").select("display_name").eq("id",s.id).maybeSingle();I!=null&&I.display_name&&Z(I.display_name),g.invalidateQueries({queryKey:["user-profile-extra",s.id]}),g.invalidateQueries({queryKey:["user-profile-pickem",s.id]}),g.invalidateQueries({queryKey:["public-profile",s.id]}),g.invalidateQueries({queryKey:["profile-display",s.id]}),g.invalidateQueries({queryKey:["pickem-leaderboard"]}),f({title:"Display name updated!"})}catch(l){const S=(l==null?void 0:l.message)||(l==null?void 0:l.error_description)||"
23Unknown error";f({title:"Failed to save",description:S,variant:"destructive"})}finally{he(!1)}},Ce=async()=>{if(!s)return;const t=F.trim();if(t.length>150){f({title:"Bio must be 150 characters or less",variant:"destructive"});return}if(t){const o=Ue(t,"Bio");if(o){f({title:o,variant:"destructive"});return}}ye(!0);try{const{error:o}=await x.from("profiles").update({bio:t||null,updated_at:new Date().toISOString()}).eq("id",s.id);if(o)throw o;f({title:"Bio updated!"})}catch{f({title:"Failed to save",variant:"destructive"})}finally{ye(!1),te(!1)}},Te=async()=>{if(!s)return;let t=z.trim();if(t&&!t.match(/^https?:\/\//)&&(t="https://"+t,K(t)),t&&t.length>200){f({title:"Link is too long",variant:"destructive"});return}const o=qt(t);if(o){f({title:o,variant:"destructive"}),K("");return}Ne(!0);try{const{error:l}=await x.from("profiles").update({link:t||null,updated_at:new Date().toISOString()}).eq("id",s.id);if(l)throw l;t&&f({title:"Link updated!"})}catch{f({title:"Failed to save",variant:"destructive"})}finally{Ne(!1),se(!1)}},st=t=>{var S;const o=(S=t.target.files)==null?void 0:S[0];if(!o||!s)return;if(!o.type.startsWith("image/")){f.error("Please select an image file");return}if(o.size>3*1024*1024){f.error("Image must be less than 3MB");return}const l=URL.createObjectURL(o);Y(l),J(!0),B.current&&(B.current.value="")},at=async t=>{if(s){J(!1),Y(null),O(!0);try{if(A){const it=A.split("/").slice(-2).join("/").split("?")[0];await x.storage.from("user-avatars").remove([it])}const o=`${s.id}/avatar.jpg`,{error:l}=await x.storage.from("user-avatars").upload(o,t,{upsert:!0,contentType:"image/jpeg"});if(l)throw l;const{data:{publicUrl:S}}=x.storage.from("user-avatars").getPublicUrl(o),I=`${S}?t=${Date.now()}`,{error:Pe}=await x.from("profiles").update({avatar_url:I}).eq("id",s.id);if(Pe)throw Pe;Q(I),f.success("Profile picture updated!")}catch(o){f.error(o.message||"Failed to upload avatar")}finally{O(!1)}}},rt=async()=>{if(!(!s||!A)){O(!0);try{const t=A.split("/").slice(-2).join("/").split("?")[0];await x.storage.from("user-avatars").remove([t]);const{error:o}=await x.from("profiles").update({avatar_url:null}).eq("id",s.id);if(o)throw o;Q(null),f.success("Profile picture removed")}catch(t){f.error(t.message||"Failed to remove avatar")}finally{O(!1)}}};return s?e.jsxs("div",{className:"min-h-screen pb-safe bg-background",children:[d?e.jsx(_t,{onAuthClick:()=>{}
23,forceOpaqueBackground:!0}):e.jsx(St,{onRefresh:()=>{},lastRefreshTime:null,onAuthClick:()=>{}}),e.jsxs("div",{className:`container mx-auto px-4 pb-8 max-w-lg relative ${d?"pt-20":"pt-24"}`,children:[e.jsx(ds,{open:j,onOpenChange:m,trigger:t=>e.jsx(E,{variant:"ghost",size:"icon",onClick:t,"aria-label":"Choose theme",className:$("absolute left-[18px] h-9 w-9 p-0 [&_svg]:!size-5 text-muted-foreground hover:text-primary hover:bg-primary/15 active:scale-95 transition-all z-10","top-20"),children:e.jsx(Ve,{})})}),h&&e.jsx(E,{variant:"ghost",size:"icon",onClick:()=>i("/admin"),"aria-label":"Open admin console",className:$("absolute right-[18px] h-9 w-9 p-0 [&_svg]:!size-5 text-muted-foreground hover:text-primary hover:bg-primary/15 active:scale-95 transition-all z-10","top-20"),children:e.jsx($t,{})}),e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"pt-1 pb-4 px-5",children:[e.jsx("div",{className:"flex justify-center",children:e.jsxs("div",{className:"relative shrink-0",children:[G?e.jsxs(Ee,{className:"h-24 w-24 ring-2 ring-[hsl(var(--pickem-accent)/0.5)]",children:[e.jsx(Le,{src:fe||void 0,alt:"Profile"}),e.jsx(qe,{className:"bg-muted",children:e.jsx(Fe,{className:"h-10 w-10 text-muted-foreground"})})]}):e.jsxs(Ct,{children:[e.jsx(Tt,{asChild:!0,children:e.jsx("button",{className:"rounded-full focus:outline-none",disabled:xe,children:e.jsxs(Ee,{className:"h-24 w-24 ring-2 ring-border/30 cursor-pointer hover:opacity-90 transition-opacity",children:[e.jsx(Le,{src:fe||void 0,alt:"Profile"}),e.jsx(qe,{className:"bg-muted",children:e.jsx(Fe,{className:"h-10 w-10 text-muted-foreground"})})]})})}),e.jsxs(Pt,{align:"center",side:"bottom",children:[e.jsxs(Me,{onClick:()=>{var t;return(t=B.current)==null?void 0:t.click()},children:[e.jsx(Qt,{className:"h-4 w-4 mr-2"}),A?"Change Photo":"Upload Photo"]}),A&&e.jsxs(Me,{onClick:rt,className:"text-destructive focus:text-destructive",children:[e.jsx(Yt,{className:"h-4 w-4 mr-2"}),"Remove Photo"]})]})]}),xe&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 rounded-full",children:e.jsx(Jt,{className:"h-6 w-6 animate-spin text-white"})}),e.jsx("input",{ref:B,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:st,className:"hidden"})]})}),e.jsxs("div",{className:"mt-3 flex flex-col items-center",children:[e.jsxs("div",{className:"relative flex items-center justify-center gap-1 min-w-0 max-w-full",children:[e.jsx("span",{className:"text-muted-foreground text-lg",children:"@"}),ge?e.jsx(ce,{ref:ve,value:X,onChange:t=>Z(t.target.value),onBlur:()=>{Se(),ee(!1)},onKeyDown:t=>{t.key==="Enter"&&(Se(),ee(!1))},placeholder:"username",maxLength:15,autoFocus:!0,className:"border-0 bg-transparent p-0 h-auto text-lg font-bold text-center focus-visible:ring-0 focus-visible:ring-offset-0 w-auto min-w-[8rem]"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-lg font-bold truncate",children:X||"username"}),Xe(s==null?void 0:s.id)&&e.jsx(is,{size:"md",variant:Ze(s==null?void 0:s.id)})]}),!ge&&!G&&e.jsx("button",{onClick:()=>{ee(!0),setTimeout(()=>{var t;return(t=ve.current)==null?void 0:t.focus()},50)},className:"absolute left-full ml-1 top-1/2 -translate-y-1/2 shrink-0 p-1 hover:bg-muted/50 rounded transition-colors","aria-label":"Edit username",children:e.jsx(Wt,{className:"h-3 w-3 text-muted-foreground/40"})})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-1.5",children:[e.jsxs("button",{className:"text-sm hover:opacity-80 transition-opacity",onClick:()=>H("followers"),children:[e.jsx("span",{className:"font-bold",children:Be((T==null?void 0:T.followers)??0)})," ",e.jsx("span",{className:"text-muted-foreground text-xs",children:((T==null?void 0:T.followers)??0)===1?"follower":"followers"})]}),e.jsxs("button",{className:"text-sm hover:opacity-80 transition-opacity",onClick:()=>H("following"),children:[e.jsx("span",{className:"font-bold",children:Be((T==null?void 0:T.following)??0)})," ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"following"})]})]})]}),e.jsx("div",{className:"mt-1.5 text-center",children:et?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("textarea",{ref:we,value:F,onChange:t=>{let o=t.target.value.slice(0,150);const l=o.split(`
24`);l.length>3&&(o=l.slice(0,3).join(`
25`).slice(0,150)),je(o)},onKeyDown:t=>{t.key==="Enter"&&(F.match(/\n/g)||[]).length>=2&&(t.preventDefault(),Ce())},placeholder:"Write a short bio...",maxLength:150,autoFocus:!0,rows:3,className:"w-full resize-none rounded-md border border-input bg-background/50 px-3 py-2 text-sm text-center focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring placeholder:text-muted-foreground
25/50 placeholder:italic"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[F.length,"/150"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{te(!1)},className:"text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-0.5",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>Ce(),disabled:be,className:"text-xs font-medium text-primary hover:text-primary/80 transition-colors px-2 py-0.5 rounded-md bg-primary/10",children:be?"Saving...":"Save"})]})]})]}):e.jsx("button",{onClick:()=>{te(!0),setTimeout(()=>{var t;return(t=we.current)==null?void 0:t.focus()},50)},className:"w-full",children:F?e.jsx("p",{className:"text-sm text-foreground/70 leading-snug whitespace-pre-line",children:F}):e.jsx("p",{className:"text-sm text-muted-foreground/50 italic",children:"Add description..."})})}),e.jsx("div",{className:"mt-2 flex justify-center",children:tt?e.jsxs("div",{className:"w-full space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx(ce,{ref:_e,value:z,onChange:t=>K(t.target.value.slice(0,200)),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),Te())},placeholder:"yourwebsite.com",maxLength:200,autoFocus:!0,className:"h-8 text-sm text-primary"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{se(!1)},className:"text-xs text-muted-foreground hover:text-foreground transition-colors px-2 py-0.5",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>Te(),disabled:ke,className:"text-xs font-medium text-primary hover:text-primary/80 transition-colors px-2 py-0.5 rounded-md bg-primary/10",children:ke?"Saving...":"Save"})]})]}):e.jsxs("button",{onClick:()=>{se(!0),setTimeout(()=>{var t;return(t=_e.current)==null?void 0:t.focus()},50)},className:"flex items-center gap-1.5 hover:opacity-80 transition-opacity",children:[e.jsx(Re,{className:"h-3 w-3 text-muted-foreground/50 shrink-0"}),z?e.jsx("span",{className:"text-sm text-primary truncate",children:z.replace(/^https?:\/\//,"")}):e.jsx("span",{className:"text-sm text-muted-foreground/50 italic",children:"Add link..."})]})})]})}),e.jsx(Ft,{open:Ye,onClose:()=>{J(!1),Y(null)},imageSrc:Qe||"",onCropComplete:at}),s&&ae&&e.jsx(rs,{open:!!ae,onOpenChange:t=>{t||H(null)},userId:s.id,mode:ae,onUserClick:t=>{H(null),i("/pickem",{state:{openProfileUserId:t.id}})}}),e.jsxs(q,{id:"card-vault",className:"mb-3 scroll-mt-24",style:{background:"var(--gradient-match-card)"},children:[e.jsx(M,{className:"px-5 pt-3 pb-2",children:e.jsxs(R,{className:"text-lg flex items-center justify-between gap-2",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Mt,{className:"h-5 w-6 text-primary"}),"Card Binder"]}),e.jsxs(Dt,{children:[e.jsx(At,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"How cards work",className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",children:e.jsx(Gt,{className:"h-4 w-4"})})}),e.jsxs(It,{align:"end",className:"w-64 text-xs leading-relaxed",children:[e.jsx("p",{className:"text-muted-foreground",children:"You collect cards per event — pull packs after each tournament and keep them here. Equip a card while making your Pick'em picks to earn bonus points for that event."}),e.jsx(V,{to:"/points-explainer",className:"mt-2 inline-block font-semibold text-primary underline-offset-2 hover:underline",children:"Learn more"})]})]})]})}),e.jsx(U,{className:"px-5 pb-5",children:e.jsx(Ut,{})})]}),e.jsx(os,{}),e.jsx(re,{defaultOpen:!1,children:e.jsxs(q,{id:"settings-section",className:"mb-3 scroll-mt-24 transition-shadow",style:{background:"var(--gradient-match-card)"},children:[e.jsx(ie,{className:"w-full group",children:e.jsx(M,{className:"px-5 pt-3 pb-2",children:e.jsxs(R,{className:"text-lg flex items-center gap-2",children:[e.jsx(Xt,{className:"h-5 w-5 text-primary"}),"Account Settings",e.jsx(le,{className:"h-4 w-4 text-muted-foreground ml-auto transition-transform group-data-[state=open]:rotate-180"})]})})}),e.jsx(ne,{children:e.jsxs(U,{className:"px-3 pb-3 space-y-0",children:[e.jsx(ts,{}),e.jsx(re,{defaultOpen:!1,children:e.jsxs(q,{className:"mb-3 transition-shadow",style:{background:"var(--gradient-match-card)"},children:[e.jsx(ie,{className:"w-full group",children:e.jsx(M,{className:"px-5 pt-3 pb-2",children:e.jsxs(R,{className:"text-lg flex items-center gap-2",children:[e.jsx(Oe,{className:"h-5 w-5 text-primary"}),"My Account",e.jsx(le,{className:"h-4 w-4 text-muted-foreground ml-auto transition-transform group-data-[state=open]:rotate-180"})]})})}),e.jsx(ne,{children:e.jsx(U,{className:"px-5 pb-5",children:e.jsx(ss,{})})})]})}),e.jsx(re,{defaultOpen:!1,children:e.jsxs(q,{id:"display-section",className:"mb-3 scroll-mt-24 transition-shadow",style:{background:"var(--gradient-match-card)"},children:[e.jsx(ie,{className:"w-full group",children:e.jsx(M,{className:"px-5 pt-3 pb-2",children:e.jsxs(R,{className:"text-lg flex items-center gap-2",children:[e.jsx(Zt,{className:"h-5 w-5 text-primary"}),"Display",e.jsx(le,{className:"h-4 w-4 text-muted-foreground ml-auto transition-transform group-data-[state=open]:rotate-180"})]})})}),e.jsx(ne,{children:e.jsx(U,{className:"px-5 pb-5",children:e.jsx(as,{})})})]})}),e.jsxs("div",{className:"px-2 pt-1 pb-2 space-y-2",children:[w&&e.jsxs(E,{variant:"outline",className:"w-full justify-center gap-2",onClick:()=>i("/eventboard"),children:[e.jsx(Et,{className:"h-4 w-4"}),"Event Board"]}),h&&e.jsxs(E,{variant:"outline",className:"w-full justify-center gap-2",onClick:()=>i("/admin"),children:[e.jsx(Oe,{className:"h-4 w-4"}),"Admin Console"]}),e.jsxs(E,{variant:"outline",className:"w-full justify-center gap-2",onClick:async()=>{try{await Lt()}catch(t){console.error("Sign out failed:",t)}finally{f({title:"Signed out"}),i("/")}},children:[e.jsx(es,{className:"h-4 w-4"}),"Sign Out"]})]})]})})]})}),e.jsx("footer",{className:$("text-center pt-4",d&&a&&"pb-[calc(4rem+env(safe-area-inset-bottom))]",d&&c&&"pb-24",d&&!a&&!c&&"pb-20",!d&&"pb-4"),children:e.jsxs("p",{className:"text-[9px] text-muted-foreground
25/60",children:[e.jsx(V,{to:"/support",className:"hover:text-muted-foreground underline-offset-2 hover:underline",children:"Contact Us"})," · ",e.jsx(V,{to:"/privacy-policy",className:"hover:text-muted-foreground underline-offset-2 hover:underline",children:"Privacy Policy"})," · ",e.jsx(V,{to:"/terms-of-service",className:"hover:text-muted-foreground underline-offset-2 hover:underline",children:"Terms of Use"})]})})]})]}):(i("/auth"),null)};export{sa as default};

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.