PageSourceSearch

https://radreport.com.br/assets/EducacaoRanking-ki-aoRLB.js

js radreport.com.br collected 2026-09-24 14:35:41 UTC 88,121 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-JdOupi9i.js","assets/vendor-query-skQMsM6X.js","assets/vendor-react-DyYvSSk1.js","assets/vendor-supabase-BfoV2C50.js","assets/extends-CF3RwP-h.js","assets/index-BGwtrXIa.js","assets/vendor-ui-CCmu0bzQ.js","assets/index-DRKIJnYW.css","assets/useWeeklyLeague-CdgpvQBy.js","assets/leagueConfig-CXK-5Xsj.js","assets/SocialShareMenu-C_v-z9-f.js","assets/LeagueIcon-CFDY3G8r.js","assets/useUserSessionData-DFvafMsG.js","assets/useResidencyRankingLaunch-DmpSDkJL.js","assets/ResidencyProgramPicker-Bs3nkvDd.js","assets/useResidencyAmbassador-CThSSPqC.js","assets/useMyResidentVerification-CXgnMx-J.js","assets/useUserProfile-DVWdtdi_.js","assets/ResidencyStatusBadge-DMS5OgHK.js","assets/useMyResidencyState-Ckxt9Il1.js","assets/EducationPageHeader-DaegdZX0.js","assets/index-CyzpCJhv.js","assets/pt-BR-0bEujIJO.js"])))=>i.map(i=>d[i]);
2import{d as te,T as p,m as C,B as A,u as K,aU as F,bL as X,aV as B,b as M,C as Z,aA as De,c7 as Oe,U as Ve,aQ as ds,aj as ms,c as re,at as xs,ab as us,aq as ps,r as hs,v as fs,x as gs,y as js,z as Me,p as Ie,ak as ke,am as vs,an as Ns,ao as bs,ap as ys,bH as ws,bI as _s,k}from"./index-BGwtrXIa.js";import{j as e,a as Re,u as U,b as oe}from"./vendor-query-skQMsM6X.js";import{r as v,u as Ke,a as ks}from"./vendor-react-DyYvSSk1.js";import{u as Ue,a as Rs,b as Ss}from"./useWeeklyLeague-CdgpvQBy.js";import{a as Ps,g as Cs,b as W,d as _e,e as Ts,M as Es,L as Q}from"./leagueConfig-CXK-5Xsj.js";import{S as We}from"./SocialShareMenu-C_v-z9-f.js";import{L}from"./LeagueIcon-CFDY3G8r.js";import{o as le,aA as P,bg as J,dr as D,ds as ee,k as Y,ab as se,Z as $,bz as xe,aE as ze,dt as Ls,dh as As,a0 as Ms,du as Is,au as Ws,dv as $s,am as Fs,S as O,aB as Xs,aC as ue,aa as He,bc as Ge,V as Bs,cr as qs,bY as Ds,bW as Os,C as Vs,a5 as Ks,ad as V,co as Us,U as zs,b5 as Hs,b$ as Gs,br as Qs}from"./vendor-ui-CCmu0bzQ.js";import{U as Ys}from"./useUserSessionData-DFvafMsG.js";import{u as Zs}from"./useResidencyRankingLaunch-DmpSDkJL.js";import{R as Js}from"./ResidencyProgramPicker-Bs3nkvDd.js";import{u as ea}from"./useUserProfile-DVWdtdi_.js";import{R as sa}from"./ResidencyStatusBadge-DMS5OgHK.js";import{E as aa}from"./EducationPageHeader-DaegdZX0.js";const ta=(s,t)=>t>0?s.toFixed(t).replace(".",","):Math.round(s).toLocaleString("pt-BR");function S({value:s,duration:t=1200,decimals:o=0,prefix:i,suffix:a,className:n,resetKey:c,format:l}){const r=te(),[h,f]=v.useState(r?s:0),x=v.useRef(null),u=v.useRef(!1),j=v.useRef(null);v.useEffect(()=>{if(r){f(s);return}u.current=!1,f(0);const g=x.current;if(!g)return;const _=g.getBoundingClientRect();_.top<window.innerHeight&&_.bottom>0&&m()},[c,s,r]);const m=()=>{if(u.current)return;u.current=!0;const g=performance.now(),_=0,N=s,b=y=>{const R=y-g,T=Math.min(1,R/t),z=1-Math.pow(1-T,3);f(_+(N-_)*z),T<1&&(j.current=requestAnimationFrame(b))};j.current=requestAnimationFrame(b)};v.useEffect(()=>{if(r)return;const g=x.current;if(!g||typeof IntersectionObserver>"u"){m();return}const _=new IntersectionObserver(([N])=>{N.isIntersecting&&(m(),_.disconnect())},{threshold:.25});return _.observe(g),()=>{_.disconnect(),j.current&&cancelAnimationFrame(j.current)}},[r,s]);const d=l?l(h):ta(h,o);return e.jsxs("span",{ref:x,className:p("tabular-nums",n),children:[i,d,a]})}function na({compact:s=!1,banner:t=!1,flat:o=!1,onViewRanking:i,className:a}){const{currentLeague:n,tier:c,weeklyXP:l,position:r,timeRemaining:h,isPromoted:f,isDemoted:x,isLoading:u,promotionBlockedReason:j,minXPForPromotion:m,ladderEnabled:d,activeParticipants:g,singlePoolThreshold:_,monthlyActiveStudents:N}=Ue();if(u)return e.jsx("div",{className:p("mono-card-surface border hairline p-4 animate-pulse",a),children:e.jsx("div",{className:"h-16 bg-[color:var(--mono-elevated)]"})});if(!n)return null;const b=Ps(c),y=b?b.minXP-l:0,R=b?Math.min(100,l/b.minXP*100):100;if(t){const T=d?f?{Icon:D,label:"Você está na zona de promoção",accent:!0}:x?{Icon:ee,label:"Você está na zona de rebaixamento",accent:!0}:{Icon:Y,label:"Você mantém a liga",accent:!1}:{Icon:Y,label:"Todos competem juntos por enquanto — sem rebaixamento",accent:!1};return e.jsx("div",{className:p("mono-card-surface border hairline",a),children:e.jsxs("div",{className:"p-5 md:p-6 space-y-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"h-12 w-12 border hairline rounded-sm flex items-center justify-center shrink-0",children:e.jsx(L,{name:n.icon,className:"text-mono",size:24})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-display text-lg md:text-xl text-mono leading-snug",children:r?e.jsxs(e.Fragment,{children:["Você está em ",e.jsxs("strong",{className:"font-semibold tabular-nums",children:[r,"º"]})," na Liga ",e.jsx("strong",{className:"font-semibold",children:n.name})]}):e.jsxs(e.Fragment,{children:["Você ainda não pontuou na Liga ",e.jsx("strong",{className:"font-semibold",children:n.name})]})}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-mono-muted mt-1",children:[e.jsx(le,{className:"h-3 w-3",strokeWidth:1.6,"aria-hidden":!0}),e.jsxs("span",{children:["A semana termina em ",h]}
2),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsxs("span",{className:"tabular-nums",children:[l.toLocaleString("pt-BR")," XP estudados nesta semana"]}),g>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsxs("span",{className:"tabular-nums",children:[g.toLocaleString("pt-BR")," estudando nesta liga esta semana"]})]})]})]})]}),e.jsx(We,{title:`Ranking: Estou em ${r?`${r}º lugar`:"destaque"} na liga ${n.name} do RadReport Learning Hub!`,url:"https://radreport.com.br/educacao",hashtags:["RadReport","Radiologia","Aprendizado"],variant:"icon"})]}),e.jsx(G,{icon:T.Icon,label:T.label,accent:T.accent}),!d&&e.jsxs("p",{className:"text-[11px] text-mono-muted",children:[N!=null?`A plataforma tem ${N.toLocaleString("pt-BR")} estudantes ativos no último mês; a escada de ligas abre a partir de ${_.toLocaleString("pt-BR")}.`:`A escada de ligas abre a partir de ${_.toLocaleString("pt-BR")} estudantes ativos no último mês.`," ","Até lá, o ranking é único e ninguém é rebaixado."]}),d&&j==="insufficient_xp"&&!f&&e.jsxs("p",{className:"text-[11px] text-mono-muted",children:["Faltam ",Math.max(0,m-l).toLocaleString("pt-BR")," XP para entrar na zona de promoção."]}),b&&e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted font-display",children:"Próxima liga"}),e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx(L,{name:b.icon,size:14,className:"text-mono"}),e.jsx("span",{className:"font-display text-sm text-mono",children:b.name})]})]}),e.jsx("div",{className:"h-1 w-full bg-[color:var(--mono-hairline)] overflow-hidden rounded-full",role:"progressbar","aria-valuenow":Math.round(R),"aria-valuemin":0,"aria-valuemax":100,children:e.jsx(C.div,{className:"h-full bg-[color:var(--mono-text)] origin-left",initial:{scaleX:0},whileInView:{scaleX:R/100},viewport:{once:!0},transition:{duration:.9,ease:[.16,1,.3,1],delay:.15},style:{width:"100%"}})}),e.jsxs("p",{className:"text-[11px] text-mono-muted text-right tabular-nums",children:["Faltam ",Math.max(0,y).toLocaleString("pt-BR")," XP"]})]}),i&&e.jsxs(A,{variant:"outline",onClick:i,className:"w-full inline-flex items-center gap-2 justify-center",children:[e.jsx(P,{className:"h-4 w-4",strokeWidth:1.7}),"Ver ranking completo",e.jsx(J,{className:"h-4 w-4 ml-auto",strokeWidth:1.7})]})]})})}return s?e.jsxs("button",{type:"button",onClick:i,className:p("w-full flex items-center gap-3 mono-card-surface border hairline px-4 py-2.5 text-left","transition-colors duration-200 hover:bg-[color:var(--mono-elevated)]",a),children:[e.jsx(L,{name:n.icon,className:"text-mono",size:22}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-display text-sm text-mono",children:n.name}),r&&e.jsxs("span",{className:"text-xs text-mono-muted tabular-nums",children:["#",r]})]}),e.jsxs("span",{className:"text-xs text-mono-muted tabular-nums",children:[l.toLocaleString("pt-BR")," XP"]})]}),h&&e.jsx("span",{className:"text-xs text-mono-muted tabular-nums",children:h})]}):e.jsxs("div",{className:p(o?"":"mono-card-surface border hairline overflow-hidden",a),children:[e.jsxs("div",{className:"px-5 py-4 border-b hairline flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"h-11 w-11 border hairline rounded-sm flex items-center justify-center shrink-0",children:e.jsx(L,{name:n.icon,className:"text-mono",size:22})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"font-display text-lg text-mono leading-tight truncate",children:["Liga ",n.name]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-mono-muted mt-0.5",children:[e.jsx(le,{className:"h-3 w-3",strokeWidth:1.6,"aria-hidden":!0}),e.jsxs("span",{children:["Termina em ",h]})]})]})]}),r&&e.jsxs("div",{className:"text-right shrink-0",children:[e.jsxs("div",{className:"font-display text-2xl md:text-3xl text-mono tabular-nums leading-none",children:["#",e.jsx(S,{value:r,duration:900,resetKey:`wpos-${r}`})]}),e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted mt-1",children:"Sua posição"})]})]}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted font-display",children:"XP esta semana"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-display text-2xl text-mono tabular-nums",children:e.jsx(S,{value:l,duration:1200,resetKey:`wxp-${l}`})}),e.jsx(We,{title:`Ranking: Estou em ${r?`${r}º lugar`:"destaque"} na liga ${n.name} do RadReport Learning Hub!`,url:"https://radreport.com.br/educacao",hashtags:["RadReport","Radiologia","Aprendizado"],variant:"icon"})]})]}),f&&e.jsx(G,{icon:D,label:"Você será promovido!",accent:!0}),!f&&x&&e.jsx(G,{icon:ee,label:"Zona de rebaixamento",accent:!0}),!f&&!x&&j==="insufficient_xp"&&e.jsx(G,{icon:D,label:`Faltam ${Math.max(0,m-l).toLocaleStr
2ing("pt-BR")} XP para a zona de promoção`,accent:!0}),!f&&!x&&j==="tier_too_small"&&e.jsx(G,{icon:Y,label:"Aguardando mais participantes neste tier"}),b&&e.jsxs("div",{className:"space-y-2 pt-2 hairline-t",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted font-display",children:"Próxima liga"}),e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx(L,{name:b.icon,size:14,className:"text-mono"}),e.jsx("span",{className:"font-display text-sm text-mono",children:b.name})]})]}),e.jsx("div",{className:"h-1 w-full bg-[color:var(--mono-hairline)] overflow-hidden rounded-full",role:"progressbar","aria-valuenow":Math.round(R),"aria-valuemin":0,"aria-valuemax":100,children:e.jsx(C.div,{className:"h-full bg-[color:var(--mono-text)] origin-left",initial:{scaleX:0},whileInView:{scaleX:R/100},viewport:{once:!0},transition:{duration:.9,ease:[.16,1,.3,1],delay:.15},style:{width:"100%"}})}),e.jsxs("p",{className:"text-[11px] text-mono-muted text-right tabular-nums",children:["Faltam ",e.jsx(S,{value:Math.max(0,y),duration:1e3,resetKey:`xptonext-${y}`})," XP"]})]}),i&&e.jsxs(A,{variant:"outline",onClick:i,className:"w-full inline-flex items-center gap-2 justify-center mt-2",children:[e.jsx(P,{className:"h-4 w-4",strokeWidth:1.7}),"Ver ranking completo",e.jsx(J,{className:"h-4 w-4 ml-auto",strokeWidth:1.7})]})]})]})}function G({icon:s,label:t,accent:o}){return e.jsxs("div",{className:p("flex items-center gap-2 px-3 py-2 border hairline",o?"border-mono-strong text-mono-emph":"text-mono-muted"),children:[e.jsx(s,{className:"h-4 w-4 shrink-0",strokeWidth:1.7,"aria-hidden":!0}),e.jsx("span",{className:"text-sm font-display",children:t})]})}function ia(s,t){return t==="%"?s.toLocaleString("pt-BR",{maximumFractionDigits:1})+"%":s.toLocaleString("pt-BR")}function ra({rankings:s,currentUserId:t,promotionThreshold:o=10,demotionStart:i=26,className:a,metricLabel:n="XP",showPromotionStatus:c=!0}){const{user:l}=K(),r=t||(l==null?void 0:l.id),h=te();if(s.length===0)return e.jsxs("div",{className:p("text-center py-10 text-mono-muted",a),children:[e.jsx("div",{className:"mx-auto h-12 w-12 border hairline rounded-sm flex items-center justify-center mb-3",children:e.jsx(P,{className:"h-5 w-5",strokeWidth:1.6})}),e.jsx("p",{className:"text-sm text-mono",children:"Nenhum participante ainda"}),e.jsx("p",{className:"text-xs mt-1",children:"Seja o primeiro a estudar esta semana"})]});const f=s.map(d=>d.position),x=Math.min(...f),u=Math.max(...f),j=c&&o>0&&o>=x&&o<u,m=c&&i>0&&i>x&&i<=u;return e.jsxs("div",{className:p("border hairline mono-card-surface divide-y divide-[color:var(--mono-hairline)]",a),children:[c&&o>0&&x===1&&e.jsx(be,{variant:"promotion",label:`Zona de promoção · Top ${o}`}),s.map((d,g)=>{const _=d.user_id===r,N=c&&d.position<=o,b=c&&d.position>=i,y=j&&d.position===o,R=m&&d.position===i;return e.jsxs(v.Fragment,{children:[R&&e.jsx(be,{variant:"risk",label:"Risco de queda"}),e.jsxs(C.div,{initial:h?void 0:{opacity:0,y:8},whileInView:h?void 0:{opacity:1,y:0},viewport:{once:!0,margin:"-40px"},transition:{duration:.35,delay:Math.min(g,14)*.025,ease:[.16,1,.3,1]},className:p("flex items-center gap-3 px-4 py-3 transition-colors duration-200","hover:bg-[color:var(--mono-elevated)]",_&&"bg-[color:var(--mono-elevated)] ring-1 ring-inset ring-[color:var(--mono-text)]/40"),children:[e.jsx("div",{className:"w-10 shrink-0 flex items-center justify-center",children:d.position<=3?e.jsx("span",{className:"font-display text-xl md:text-2xl text-mono-emph tabular-nums leading-none",children:d.position}):e.jsx("span",{className:"font-display text-sm text-mono-muted tabular-nums",children:d.position})}),e.jsxs(F,{className:"h-9 w-9 border hairline rounded-sm",children:[e.jsx(X,{src:d.avatar_url,alt:d.display_name,className:"rounded-sm"}),e.jsx(B,{className:"bg-transparent rounded-sm",children:e.jsx(se,{className:"h-4 w-4 text-mono-muted",strokeWidth:1.6})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:p("font-display text-sm truncate",_&&"text-mono"),children:d.display_name}),_&&e.jsx("span",{className:"chip-mono !text-[11px] !py-0 !px-1.5 border-mono-strong text-mono-emph",children:"Você"})]}),d.specialty&&e.jsx("p",{className:"text-[11px] text-mono-muted truncate hidden sm:block mt-0.5",children:d.specialty})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("div",{className:"font-display text-base sm:text-lg text-mono tabular-nums leading-none",children:g<5&&n!=="%"?e.jsx(S,{value:d.xp_earned,duration:1100,resetKey:`lb-${d.user_id}-${d.xp_earned}`}):ia(d.xp_earned,n)}
2),n!=="%"&&e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted mt-1 hidden sm:block",children:n})]}),N&&!_&&e.jsx("span",{className:"ml-1 h-7 w-7 border hairline border-mono-strong rounded-sm flex items-center justify-center text-mono-emph",children:e.jsx(D,{className:"h-3.5 w-3.5",strokeWidth:1.8})}),b&&!_&&e.jsx("span",{className:"ml-1 h-7 w-7 border hairline border-mono-strong rounded-sm flex items-center justify-center text-mono-emph",children:e.jsx(ee,{className:"h-3.5 w-3.5",strokeWidth:1.8})})]}),y&&e.jsx(be,{variant:"safe",label:"Mantém a liga"})]},d.user_id)})]})}const oa={promotion:D,safe:Y,risk:ee};function be({variant:s,label:t}){const o=oa[s],i=s!=="safe";return e.jsxs("div",{role:"separator","aria-label":t,className:p("flex items-center gap-2 px-4 py-2 bg-[color:var(--mono-elevated)]","border-t border-b hairline",i&&"border-mono-strong/60"),children:[e.jsx(o,{className:p("h-3.5 w-3.5 shrink-0",i?"text-mono-emph":"text-mono-muted"),strokeWidth:1.7,"aria-hidden":!0}),e.jsx("span",{className:p("text-[11px] font-display uppercase tracking-[0.14em]",i?"text-mono-emph":"text-mono-muted"),children:t})]})}function Qe(){const{user:s}=K(),t=Re(),{data:o,isLoading:i,refetch:a}=U({queryKey:["special-events",s==null?void 0:s.id],queryFn:async()=>{if(!(s!=null&&s.id))return{events:[]};const{data:x,error:u}=await M.rpc("get_active_special_events",{p_user_id:s.id});if(u)throw u;return x},enabled:!!(s!=null&&s.id),staleTime:6e4}),n=oe({mutationFn:async x=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const{data:u,error:j}=await M.rpc("join_special_event",{p_user_id:s.id,p_event_id:x});if(j)throw j;return u},onSuccess:()=>{t.invalidateQueries({queryKey:["special-events",s==null?void 0:s.id]})}}),c=oe({mutationFn:async({eventId:x,progressAdd:u})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const{data:j,error:m}=await M.rpc("update_event_progress",{p_user_id:s.id,p_event_id:x,p_progress_add:u});if(m)throw m;return j},onSuccess:()=>{t.invalidateQueries({queryKey:["special-events",s==null?void 0:s.id]})}}),l=(o==null?void 0:o.events)??[],r=l.filter(x=>x.is_participating),h=l.filter(x=>!x.is_participating),f=x=>{const u=new Date(x),j=new Date,m=u.getTime()-j.getTime();if(m<=0)return"Encerrado";const d=Math.floor(m/(1e3*60*60)),g=Math.floor(m%(1e3*60*60)/(1e3*60));return d>=24?`${Math.floor(d/24)}d ${d%24}h`:`${d}h ${g}m`};return{activeEvents:l,participatingEvents:r,availableEvents:h,joinEvent:n.mutateAsync,updateProgress:c.mutateAsync,getTimeRemaining:f,isLoading:i,isJoining:n.isPending,isUpdating:c.isPending,refetch:a}}function la({event:s,compact:t=!1,onJoin:o,className:i}){const{activeEvents:a,joinEvent:n,getTimeRemaining:c,isJoining:l}=Qe(),r=s||a[0];if(!r)return null;const h=r.is_participating?Math.min(100,r.user_progress/r.target_cards*100):0,f=c(r.end_at),x=async()=>{o?o(r.id):await n(r.id)};return t?e.jsxs("div",{className:p("flex items-center gap-3 mono-card-surface border hairline px-4 py-2.5",i),children:[e.jsx($,{className:"h-4 w-4 text-mono-emph",strokeWidth:1.7,"aria-hidden":!0}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-display text-sm text-mono truncate",children:r.name}),r.xp_multiplier>1&&e.jsxs(Z,{className:"ml-2 !text-[11px] !py-0 !px-1.5 border-mono-strong text-mono-emph",children:[r.xp_multiplier,"x XP"]})]}),e.jsx("span",{className:"text-xs text-mono-muted tabular-nums",children:f})]}):e.jsx("div",{className:p("py-5 first:pt-0 last:pb-0",i),children:e.jsxs("div",{children:[e.jsx("div",{className:"flex items-start justify-between mb-4 gap-3",children:e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"h-11 w-11 border hairline rounded-sm flex items-center justify-center shrink-0 text-mono-emph border-mono-strong",children:e.jsx($,{className:"h-5 w-5",strokeWidth:1.7,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-display text-lg text-mono truncate",children:r.name}),r.xp_multiplier>1&&e.jsxs(Z,{className:"!text-[11px] border-mono-strong text-mono-emph",children:[r.xp_multiplier,"x XP"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-mono-muted mt-1",children:[e.jsx(le,{className:"h-3 w-3",strokeWidth:1.6,"aria-hidden":!0}),e.jsxs("span",{children:["Termina em ",f]})]})]})]})}),r.description&&e.jsx("p",{className:"text-sm text-mono-muted mb-4 leading-relaxed",children:r.description}),r.is_participating&&!r.is_completed&&e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[e.jsx("span",{className:"uppercase tracking-[0.14em] text-mono-muted font-display",children:"Seu progresso"}),e.jsxs("span",{className:"font-display text-mono tabular-nums",children:[r.user_progress," / ",r.target_cards]})]}
2),e.jsx("div",{className:"h-1 w-full bg-[color:var(--mono-hairline)] overflow-hidden rounded-full",role:"progressbar","aria-valuenow":Math.round(h),"aria-valuemin":0,"aria-valuemax":100,children:e.jsx(C.div,{className:"h-full bg-[color:var(--mono-text)] origin-left",initial:{scaleX:0},whileInView:{scaleX:h/100},viewport:{once:!0},transition:{duration:.9,ease:[.16,1,.3,1],delay:.15},style:{width:"100%"}})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-4 text-mono",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx(xe,{className:"h-4 w-4",strokeWidth:1.6,"aria-hidden":!0}),e.jsxs("span",{className:"text-sm font-display tabular-nums",children:["+",r.reward_xp," XP"]})]}),r.reward_badge&&e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx(ze,{className:"h-4 w-4",strokeWidth:1.6,"aria-hidden":!0}),e.jsx("span",{className:"text-sm font-display",children:r.reward_badge})]})]}),!r.is_participating&&e.jsxs(A,{onClick:x,disabled:l,className:"inline-flex items-center gap-2",children:["Participar",e.jsx(J,{className:"h-4 w-4",strokeWidth:1.7})]}),r.is_completed&&e.jsx("span",{className:"chip-mono border-mono-strong text-mono-emph",children:"Concluído"})]})]})})}function ca({className:s}){const{activeEvents:t,isLoading:o}=Qe();return o||t.length===0?null:e.jsx("div",{className:p("divide-y divide-[color:var(--mono-hairline)] border-t border-b hairline",s),children:t.map(i=>e.jsx(la,{event:i},i.id))})}function da(s,t){const o=s??0;return t==="%"?`${o.toLocaleString("pt-BR",{maximumFractionDigits:1})}%`:t==="questões"?`${o.toLocaleString("pt-BR")} questões`:`${o.toLocaleString("pt-BR")} XP`}const ma=[{id:"weekly",label:"Semanal",sub:"Liga ativa",icon:$},{id:"global",label:"Global",sub:"Hall da Fama",icon:Ls},{id:"monthly",label:"Mensal",sub:"Últimos 28 dias",icon:As},{id:"accuracy",label:"Precisão",sub:"Sniper · ≥3 sessões",icon:Ms},{id:"cases",label:"Casos",sub:"Maratonista",icon:Is}];function xa({activeFilter:s,onFilterChange:t}){return e.jsx("div",{className:"flex gap-1 sm:gap-2 flex-wrap justify-center py-3",role:"tablist","aria-label":"Modo de ranking",children:ma.map(o=>{const i=o.icon,a=s===o.id;return e.jsxs("button",{type:"button",role:"tab","aria-selected":a,title:`${o.label} — ${o.sub}`,onClick:()=>t(o.id),className:p("group relative inline-flex items-center gap-1.5 px-3 py-1.5 text-xs sm:text-[13px]","font-display tracking-wide transition-colors duration-200","focus:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mono-hairline-strong)]",a?"text-mono":"text-mono-muted hover:text-mono"),children:[e.jsx(i,{className:"h-3.5 w-3.5",strokeWidth:1.7,"aria-hidden":!0}),e.jsx("span",{children:o.label}),e.jsx("span",{"aria-hidden":!0,className:p("absolute left-3 right-3 -bottom-px h-px bg-[color:var(--mono-text)] transition-all duration-300",a?"opacity-100 scale-x-100":"opacity-0 scale-x-0 group-hover:opacity-40 group-hover:scale-x-100","origin-left")})]},o.id)})})}function ua({top3:s,metricLabel:t="XP"}){const[o,i,a]=s,n=te(),c=r=>da(r??0,t),l=({user:r,rank:h,baseH:f,delay:x,accent:u=!1})=>e.jsxs(C.div,{initial:n?void 0:{opacity:0,y:24},animate:n?void 0:{opacity:1,y:0},transition:{duration:.55,delay:x,ease:[.16,1,.3,1]},className:"flex flex-col items-center min-w-0",children:[e.jsxs(F,{className:p("border hairline rounded-sm mb-2",h===1?"h-16 w-16 sm:h-20 sm:w-20":"h-12 w-12 sm:h-14 sm:w-14",u&&"border-mono-strong"),children:[e.jsx(X,{src:(r==null?void 0:r.avatar_url)??void 0,alt:(r==null?void 0:r.display_name)??"",className:"rounded-sm"}),e.jsx(B,{className:"bg-transparent rounded-sm",children:e.jsx(se,{className:"h-4 w-4 text-mono-muted",strokeWidth:1.6})})]}),e.jsx("div",{className:p("surface-mono border hairline flex items-center justify-center","w-16 sm:w-20",f),children:h===1?e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx(P,{className:"h-4 w-4 text-mono-emph",strokeWidth:1.7,"aria-hidden":!0}),e.jsx("span",{className:"font-display text-2xl sm:text-3xl text-mono-emph tabular-nums leading-none",children:"1"})]}):e.jsx("span",{className:"font-display text-xl sm:text-2xl text-mono tabular-nums leading-none",children:h})}),e.jsx("p",{className:p("text-[12px] sm:text-sm font-display mt-2 text-center truncate max-w-[92px] sm:max-w-[110px]","text-mono"),children:(r==null?void 0:r.display_name)||"Vazio"}),e.jsx("p",{className:p("text-[11px] sm:text-[11px] tabular-nums",u?"text-mono-emph":"text-mono-muted"),children:c(r==null?void 0:r.xp_earned)})]});return e.jsxs("div",{className:"w-full py-6 flex items-end justify-center gap-3 sm:gap-6",children:[e.jsx(l,{user:i,rank:2,baseH:"h-16 sm:h-20",delay:.1}),e.jsx(l,{user:o,rank:1,baseH:"h-24 sm:h-28",delay:0,accent:!0}),e.jsx(l,{user:a,rank:3,baseH:"h-12 sm:h-16",delay:.2})]})}const pa=v.lazy(()=>De(()=>import("./index-JdOupi9i.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])).then(s=>({default:s.HolographicPodiumCanvas})));function ha({rankings:s,isLoading:t,onFilterChange:o,activeFilter:i,metricLabel:a="XP"}){const[n,c]=v.useState(i||"weekly"),l=i??n,r=v.useMemo(()=>{const u=[...s].sort((j,m)=>(j.position??999)-(m.position??999));return[u[0]||null,u[1]||null,u[2]||null]},[s]),h=u=>{c(u),o==null||o(u)},f={global:"Ranking global de todos os tempos",monthly:"Os melhores do mês",weekly:"Os melhores da semana",accuracy:"Maior precisão (≥10 questões respondidas)",cases:"Mais casos resolvidos"},x=!t&&r.every(u=>u==null);return e.jsxs("section",{className:"mono-card-surface border hairline relative overflow-hidden",children:[e.jsx("div",{className:"text-center pt-5 pb-3 px-4 border-b hairline",children:e.jsx("div",{className:"min-h-[16px]",children:e.jsx(Oe,{mode:"wait",children:e.jsx(C.p,{initial:{opacity:0,y:4}
2,animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.18,ease:[.16,1,.3,1]},className:"text-[11px] text-mono-muted uppercase tracking-[0.14em]",children:f[l]},l)})})}),e.jsx("div",{className:"border-b hairline",children:e.jsx(xa,{activeFilter:l,onFilterChange:h})}),e.jsx("div",{className:"px-4 pb-6 pt-4",children:x?e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 px-4 text-center gap-3",children:[e.jsx("div",{className:"h-14 w-14 border hairline rounded-sm flex items-center justify-center",children:e.jsx(P,{className:"h-6 w-6 text-mono-muted",strokeWidth:1.5})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-display text-base text-mono",children:"Seja o primeiro a aparecer aqui"}),e.jsx("p",{className:"text-xs text-mono-muted mt-1 max-w-xs",children:l==="accuracy"?"Responda ao menos 10 questões para entrar no ranking de precisão.":l==="cases"?"Resolva casos para escalar o pódio.":"Treine para começar a pontuar nesta liga."})]})]}):e.jsx(v.Suspense,{fallback:e.jsx(ua,{top3:r,metricLabel:a}),children:e.jsx(pa,{top3:r,isLoading:t,metricLabel:a})})})]})}function fa({userId:s,avatarUrl:t,displayName:o,position:i,total:a,xpEarned:n=0,promotionCutoff:c,demotionCutoff:l,weekEnd:r,activeFilter:h,filterLabel:f}){if(!s)return null;const x=h==="weekly",[u,j]=v.useState(()=>Date.now());v.useEffect(()=>{if(!x||!r)return;const N=setInterval(()=>j(Date.now()),6e4);return()=>clearInterval(N)},[x,r]);const m=v.useMemo(()=>{if(!x||!r)return null;const N=r.getTime()-u;if(N<=0)return{label:"Encerrada",urgent:!1,ended:!0};const b=Math.floor(N/864e5),y=Math.floor(N%864e5/36e5),R=Math.floor(N%36e5/6e4),T=N<24*36e5;return{label:b>0?`${b}d ${y}h`:y>0?`${y}h ${R}m`:`${R}m`,urgent:T,ended:!1}},[x,r,u]),d=i&&a>0?Math.max(1,Math.ceil(i/a*100)):null,g=v.useMemo(()=>{if(!x||!i||a<=0)return null;const N=c??0,b=l??0,y=a-b+1;return N>0&&i<=N?{key:"promotion",label:"Zona de promoção",Icon:D,accent:!0}:b>0&&i>=y?{key:"risk",label:"Risco de queda",Icon:ee,accent:!0}:{key:"safe",label:"Mantém a liga",Icon:Y,accent:!1}},[x,i,a,c,l]),_=v.useMemo(()=>{if(!x||!i||a<=0||!g)return null;const N=c??0,b=l??0,y=a-b+1;if(g.key==="promotion")return{pct:100,hint:`Em #${i}, dentro do top ${N}`};if(g.key==="risk"){const R=i-(y-1);return{pct:Math.max(5,Math.min(35,100-R/Math.max(1,b)*100)),hint:`Suba ${R} posiç${R===1?"ão":"ões"} para sair da zona de queda`}}if(N>0){const R=i-N,T=Math.max(1,y-1-N);return{pct:Math.max(5,Math.min(95,100-R/T*100)),hint:`Suba ${R} posiç${R===1?"ão":"ões"} para a zona de promoção`}}return{pct:50,hint:"Continue pontuando para manter a liga"}},[x,i,a,c,l,g]);return i?e.jsxs(C.div,{role:"status","aria-live":"polite",initial:{opacity:0,y:8},whileInView:{opacity:1,y:0},viewport:{once:!0,margin:"-40px"},transition:{duration:.55,ease:[.16,1,.3,1]},className:"mono-card-surface border hairline px-4 py-3.5 sm:px-5 sm:py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(F,{className:"h-11 w-11 border hairline rounded-sm shrink-0",children:[e.jsx(X,{src:t,alt:o??"Você",className:"rounded-sm"}),e.jsx(B,{className:"bg-transparent rounded-sm",children:e.jsx(se,{className:"h-4 w-4 text-mono-muted",strokeWidth:1.6})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted",children:"Você está em"}),e.jsxs("span",{className:"font-display text-lg text-mono tabular-nums leading-none",children:["#",e.jsx(S,{value:i,duration:900,resetKey:`pos-${i}`})]}),a>0&&e.jsxs("span",{className:"text-[11px] text-mono-muted tabular-nums",children:["de ",e.jsx(S,{value:a,duration:900,resetKey:`total-${a}`})]}),d&&d<=25&&e.jsxs(Z,{icon:e.jsx(Ws,{}),className:"!text-[11px] border-mono-strong text-mono-emph",children:["Top ",d,"%"]}),d&&d>25&&e.jsxs("span",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted",children:["Top ",d,"%"]})]}),e.jsxs("p",{className:"text-[11px] text-mono-muted truncate mt-1",children:[f,n>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx(S,{value:n,duration:1100,resetKey:`xp-${n}`})," XP"]})]})]}),m&&e.jsxs("div",{className:p("flex items-center gap-1.5 px-2.5 py-1.5 border hairline shrink-0",m.urgent?"border-mono-strong text-mono-emph animate-pulse":"text-mono-muted"),"aria-label":`Semana termina em ${m.label}
2`,children:[m.urgent?e.jsx($s,{className:"h-3.5 w-3.5",strokeWidth:1.7,"aria-hidden":!0}):e.jsx(Fs,{className:"h-3.5 w-3.5",strokeWidth:1.6,"aria-hidden":!0}),e.jsx("span",{className:"text-xs font-display tabular-nums",children:m.label})]})]}),x&&g&&_&&e.jsxs("div",{className:"mt-4 pt-3 hairline-t space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:p("inline-flex items-center gap-1.5 text-[11px] font-display uppercase tracking-[0.16em]",g.accent?"text-mono-emph":"text-mono-muted"),children:[e.jsx(g.Icon,{className:"h-3.5 w-3.5",strokeWidth:1.7,"aria-hidden":!0}),g.label]}),e.jsx("span",{className:"text-[11px] text-mono-muted truncate",children:_.hint})]}),e.jsx("div",{className:"h-1 w-full bg-[color:var(--mono-hairline)] overflow-hidden rounded-full",role:"progressbar","aria-valuenow":Math.round(_.pct),"aria-valuemin":0,"aria-valuemax":100,children:e.jsx(C.div,{className:"h-full bg-[color:var(--mono-text)] origin-left",initial:{scaleX:0},whileInView:{scaleX:_.pct/100},viewport:{once:!0},transition:{duration:.9,ease:[.16,1,.3,1],delay:.15},style:{width:"100%"}})})]})]}):e.jsxs("div",{role:"status","aria-live":"polite",className:"mono-card-surface border hairline px-4 py-3.5 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(F,{className:"h-10 w-10 border hairline rounded-sm",children:[e.jsx(X,{src:t,alt:o??"Você",className:"rounded-sm"}),e.jsx(B,{className:"bg-transparent rounded-sm",children:e.jsx(se,{className:"h-4 w-4 text-mono-muted",strokeWidth:1.6})})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-display text-sm text-mono",children:"Você ainda não pontuou"}),e.jsx("p",{className:"text-[11px] text-mono-muted truncate",children:f})]})]}),e.jsx(A,{variant:"outline",size:"default",asChild:!0,className:"shrink-0",children:e.jsxs("a",{href:"/educacao/jornada",className:"inline-flex items-center gap-1.5",children:[e.jsx($,{className:"h-3.5 w-3.5",strokeWidth:1.7,"aria-hidden":!0}),e.jsx("span",{className:"hidden sm:inline",children:"Treinar agora"}),e.jsx("span",{className:"sm:hidden",children:"Treinar"})]})})]})}function $e({userTier:s,position:t,onSeeMore:o}){const i=Cs(s);let a=W.weekly.safe,n="Mantém a liga";t===1?(a=W.weekly.first,n="1º lugar"):t===2?(a=W.weekly.second,n="2º lugar"):t===3?(a=W.weekly.third,n="3º lugar"):t==null&&(a=W.weekly.safe,n="Comece a pontuar");const c=a.aiCredits,l=a.xpBonus;return e.jsx(C.button,{type:"button",onClick:o,whileHover:{y:-2},transition:{type:"spring",stiffness:320,damping:22},className:"w-full text-left group surface-mono border hairline px-4 py-3 transition-colors duration-200 hover:bg-[color:var(--mono-elevated)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mono-hairline-strong)]","aria-label":"Ver detalhes de recompensas e temporada",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 border hairline rounded-sm flex items-center justify-center shrink-0 text-mono-emph border-mono-strong",children:e.jsx(xe,{className:"h-4 w-4",strokeWidth:1.7,"aria-hidden":!0})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-mono-muted font-display",children:"Recompensa projetada"}),e.jsx("span",{className:"chip-mono !text-[11px] !py-0 !px-1.5",children:n})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm font-display flex-wrap",children:[c>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-mono",children:[e.jsx(O,{className:"h-3.5 w-3.5 text-mono-emph",strokeWidth:1.7,"aria-hidden":!0}),"+",c," crédito",c!==1?"s":""," IA"]}),c>0&&l>0&&e.jsx("span",{className:"text-mono-muted",children:"·"}),l>0&&e.jsxs("span",{className:"text-mono tabular-nums",children:["+",l.toLocaleString("pt-BR")," XP"]}),e.jsx("span",{className:"text-mono-muted",children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-mono-muted",children:[e.jsx(L,{name:i.icon,size:14,className:"text-mono"}),i.name]})]})]}),e.jsx(J,{className:"h-4 w-4 text-mono-muted group-hover:translate-x-1 transition-transform shrink-0",strokeWidth:1.6,"aria-hidden":!0})]})})}function ae(s){const t=(s??"").trim();if(!t)return"Anônimo";
2const o=t.split(/\s+/).filter(Boolean);return o.length===1?o[0]:`${o[0]} ${o[o.length-1]}`}function ga({rankings:s,currentUserId:t,metricLabel:o="XP",attached:i}){return!s||s.length===0?null:e.jsx("div",{className:p("overflow-x-auto scrollbar-hide snap-x snap-mandatory",!i&&"-mx-4 px-4"),"aria-label":"Ranks 4 a 10",children:e.jsx("ul",{className:p("flex gap-px pb-1 min-w-min mono-card-surface bg-[color:var(--mono-hairline)]",i?"border-t hairline":"border hairline"),children:s.map((a,n)=>{const c=a.position??n+4,l=a.user_id===t,r=o==="%"?"%":"";return e.jsxs("li",{className:p("snap-start shrink-0 w-[112px] sm:w-[124px] p-3 text-center mono-card-surface","transition-colors duration-200 hover:bg-[color:var(--mono-elevated)]",l&&"ring-1 ring-inset ring-[color:var(--mono-text)]/40 bg-[color:var(--mono-elevated)]"),children:[e.jsxs("div",{className:p("mx-auto mb-2 inline-flex items-center justify-center h-6 min-w-[28px] px-1.5 border hairline","font-display text-[11px] tabular-nums",l?"border-mono-strong text-mono-emph":"text-mono"),children:["#",c]}),e.jsxs(F,{className:"h-10 w-10 mx-auto border hairline rounded-sm",children:[e.jsx(X,{src:a.avatar_url??void 0,alt:a.display_name,className:"rounded-sm"}),e.jsx(B,{className:"bg-transparent rounded-sm",children:e.jsx(se,{className:"h-3.5 w-3.5 text-mono-muted",strokeWidth:1.6,"aria-hidden":!0})})]}),e.jsx("p",{className:p("mt-2 text-[11px] font-display truncate",l&&"text-mono-emph"),children:ae(a.display_name)}),l&&e.jsx("span",{className:"block text-[11px] uppercase tracking-[0.16em] text-mono-emph",children:"Você"}),e.jsxs("p",{className:"mt-1 text-[12px] font-display tabular-nums text-mono leading-tight",children:[e.jsx(S,{value:a.xp_earned??0,duration:1e3,resetKey:`np-${a.user_id}-${a.xp_earned??0}`}),r]}),o!=="%"&&e.jsx("p",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted",children:o})]},a.user_id)})})})}function ja(s,t){return`T${s}-${t}`}function Ye(s){const t=new Date,o=s.getTime()-t.getTime();return o<=0?0:Math.ceil(o/(7*24*60*60*1e3))}function va(s){return Ye(s)<=1}function Na(s,t){const o=new Date,i=t.getTime()-s.getTime(),a=o.getTime()-s.getTime();return a<=0?0:a>=i?100:Math.round(a/i*100)}function ce(s){return{1:"Raio-X",2:"Contraste",3:"Ultrassom",4:"Tomografia",5:"Ressonância",6:"Angiotomografia",7:"PET-CT",8:"Neuro Elite",9:"Intervencionista",10:"Catedrático"}[s]||"Desconhecido"}function de(s){return{1:"Atom",2:"Droplets",3:"Activity",4:"Scan",5:"Magnet",6:"Orbit",7:"Zap",8:"Brain",9:"Target",10:"Crown"}[s]||"HelpCircle"}function ba(s,t){const o=t.getTime()-s.getTime();return o<=0?ya.WEEKS_PER_SEASON:Math.max(1,Math.round(o/(7*24*60*60*1e3)))}const ya={WEEKS_PER_SEASON:12,SEASONS_PER_YEAR:4,CATCH_UP_XP_MULTIPLIER:2},wa={rewards_by_tier:Object.fromEntries(Object.entries(W.seasonal).map(([s,t])=>[s,{credits:t.aiCredits,title:t.title}]))};function Ze(){const{user:s}=K(),t=Re(),{config:o}=Ve("seasonal_league",wa),{data:i,isLoading:a,refetch:n}=U({queryKey:["league-rewards",s==null?void 0:s.id],queryFn:async()=>{if(!(s!=null&&s.id))return null;const{data:m,error:d}=await M.rpc("get_user_season_rewards",{p_user_id:s.id});if(d)throw d;return m},enabled:!!(s!=null&&s.id),staleTime:6e4}),c=oe({mutationFn:async m=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const{data:d,error:g}=await M.rpc("set_displayed_title",{p_user_id:s.id,p_title_id:m});if(g)throw g;return d},onSuccess:()=>{t.invalidateQueries({queryKey:["league-rewards",s==null?void 0:s.id]})}}),l=i==null?void 0:i.season,r=l?{seasonId:l.id??null,maxTierReached:l.max_tier_reached??1,weeksParticipated:l.weeks_participated??0,totalFirstPlaces:l.total_first_places??0,totalPodiums:l.total_podiums??0,aiCreditsEarned:l.ai_credits_earned??0,xpBonusEarned:l.xp_bonus_earned??0,titleEarned:l.title_earned??null,claimedAt:l.claimed_at??null}:{seasonId:null,maxTierReached:1,weeksParticipated:0,totalFirstPlaces:0,totalPodiums:0,aiCreditsEarned:0,xpBonusEarned:0,titleEarned:null,claimedAt:null},h=((i==null?void 0:i.titles)??[]).map(m=>({id:m.id,titleType:m.title_type,titleName:m.title_name,titleIcon:m.title_icon,earnedAt:m.earned_at,isDisplayed:m.is_displayed})),f=((i==null?void 0:i.weekly_history)??[]).map(m=>({weekStart:m.week_start,position:m.position,tier:m.tier,aiCreditsEarned:m.ai_credits_earned??0,xpBonusEarned:m.xp_bonus_earned??0,badgeEarned:m.badge_earned??null,wasPromoted:m.was_promoted??!1,wasDemoted:m.was_demoted??!1})),x=h.find(m=>m.isDisplayed)??null,u=_e(r.maxTierReached,o),j={maxTierName:ce(r.maxTierReached),maxTierIcon:de(r.maxTierReached),totalCreditsEarned:r.aiCreditsEarned,totalXPBonusEarned:r.xpBonusEarned,weeksParticipated:r.weeksParticipated,firstPlaces:r.totalFirstPlaces,podiums:r.totalPodiums,pendingSeasonalCredits:u.aiCredits,pendingSeasonalTitle:u.title};return{seasonProgress:r,titles:h,weeklyHistory:f,displayedTitle:x,stats:j,currentSeasonalReward:u,setDisplayedTitle:c.mutateAsync,refetch:n,isLoading:a,isSettingTitle:c.isPending}}function _a(){const{weeklyHistory:s,isLoading:t}=Ze(),o=s.map(a=>({...a,tierName:ce(a.tier),tierIcon:de(a.tier),badgeLabel:Ts(a.badgeEarned),weekLabel:new Date(a.weekStart).toLocaleDateString("pt-BR",{day:"2-digit",month:"short"})})),i={totalCredits:s.reduce((a,n)=>a+n.aiCreditsEarned,0),totalXP:s.reduce((a,n)=>a+n.xpBonusEarned,0),promotions:s.filter(a=>a.wasPromoted).length,demotions:s.filter(a=>a.wasDemoted).length,podiums:s.filter(a=>a.position<=3).length,firstPlaces:s.filter(a=>a.position===1).length};return{history:o,totals:i,isLoading:t}}function ka({flat:s=!1,className:t}={}){const{stats:o,isLoading:i}=Ze(),{history:a,totals:n}=_a();return i?e.jsxs("div",{className:p(s?"":"mono-card-surface border hairline","p-4 animate-pulse space-y-3",t),children:[e.jsx("div",{className:"h-5 w-40 bg-[color:var(--mono-elevated)]"}),e.jsx("div",{className:"h-20 w-full bg-[color:var(--mono-elevated)]"}),e.jsx("div",{className:"h-32 w-full bg-[color:var(--mono-elevated)]"})]}):e.jsxs("div",{className:p(s?"":"mono-card-surface border hairline overflow-hidden",t),children:[!s&&e.jsxs("div",{className:"px-5 py-4 border-b hairline inline-flex items-center gap-2 w-full",children:[e.jsx(xe,{className:"h-4 w-4 text-mono",strokeWidth:1.6,"aria-hidden":!0}),e.jsx("h3",{className:"font-display text-lg text-mono",children:"Recompensas"})]}),e.jsxs("div",{className:p(s?"space-y-5":"p-5 space-y-5"),children:[e.jsxs("div",{className:"grid grid-cols-1 xs:grid-cols-2 sm:grid-cols-2 gap-px bg-[
2color:var(--mono-hairline)] border hairline",children:[e.jsx(Fe,{icon:$,eyebrow:"Créditos IA",value:o.totalCreditsEarned,hint:"ganhos esta temporada"}),e.jsx(Fe,{icon:ze,eyebrow:"XP Bônus",value:o.totalXPBonusEarned,prefix:"+",hint:"de recompensas"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm border-t hairline pt-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx(ye,{icon:P,value:n.firstPlaces,label:"1º lugar"}),e.jsx(ye,{icon:Xs,value:n.podiums,label:"pódios"})]}),e.jsx(ye,{icon:ue,value:n.promotions,label:"promoções"})]}),a.length>0&&e.jsxs("div",{className:"border-t hairline pt-4",children:[e.jsxs("h4",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted font-display mb-3 inline-flex items-center gap-2",children:[e.jsx(P,{className:"h-3.5 w-3.5",strokeWidth:1.6,"aria-hidden":!0}),"Histórico recente"]}),e.jsx(ds,{className:"h-[140px]",children:e.jsx("div",{className:"border hairline divide-y divide-[color:var(--mono-hairline)]",children:a.slice(0,5).map((c,l)=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 text-sm hover:bg-[color:var(--mono-elevated)] transition-colors duration-200",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"h-8 w-8 border hairline rounded-sm flex items-center justify-center shrink-0",children:e.jsx(L,{name:c.tierIcon,size:16,className:"text-mono"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-display text-sm text-mono truncate",children:[c.position,"º · ",c.tierName]}),e.jsx("p",{className:"text-[11px] text-mono-muted truncate",children:c.weekLabel})]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[c.aiCreditsEarned>0&&e.jsxs("span",{className:"chip-mono !text-[11px] !py-0 !px-1.5 border-mono-strong text-mono-emph",children:["+",c.aiCreditsEarned," créditos"]}),c.badgeLabel&&e.jsx("p",{className:"text-[11px] text-mono-muted mt-1",children:c.badgeLabel})]})]},l))})})]})]})]})}function Fe({icon:s,eyebrow:t,value:o,hint:i,prefix:a}){return e.jsxs("div",{className:"mono-card-surface p-4",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 text-mono",children:[e.jsx(s,{className:"h-4 w-4",strokeWidth:1.6,"aria-hidden":!0}),e.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] font-display text-mono-muted",children:t})]}),e.jsxs("p",{className:"font-display text-2xl text-mono mt-2 tabular-nums leading-none",children:[a,e.jsx(S,{value:o,duration:1100,resetKey:`sum-${t}-${o}`})]}),e.jsx("p",{className:"text-[11px] text-mono-muted mt-1.5",children:i})]})}function ye({icon:s,value:t,label:o}){return e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx(s,{className:"h-4 w-4 text-mono",strokeWidth:1.6,"aria-hidden":!0}),e.jsx("span",{className:"font-display text-sm text-mono tabular-nums",children:e.jsx(S,{value:t,duration:900,resetKey:`stat-${o}-${t}`})}),e.jsx("span",{className:"text-[11px] text-mono-muted",children:o})]})}const Ra={rewards_by_tier:Object.fromEntries(Object.entries(W.seasonal).map(([s,t])=>[s,{credits:t.aiCredits,title:t.title}]))};function Sa(){const{user:s}=K(),{config:t}=Ve("seasonal_league",Ra),{payload:o,isLoading:i}=ms(),a=o.active_season??null,{data:n,isLoading:c}=U({queryKey:["season-progress",s==null?void 0:s.id,a==null?void 0:a.id],queryFn:async()=>{if(!(s!=null&&s.id)||!(a!=null&&a.id))return null;const{data:x,error:u}=await M.from("league_season_rewards").select("*").eq("user_id",s.id).eq("season_id",a.id).maybeSingle();if(u)throw u;return x},enabled:!!(s!=null&&s.id)&&!!(a!=null&&a.id),staleTime:6e4}),l=v.useMemo(()=>a?{id:a.id,seasonNumber:a.season_number,year:a.year,startDate:new Date(a.start_date),endDate:new Date(a.end_date),isActive:a.is_active,name:ja(a.season_number,a.year)}:null,[a]),r=v.useMemo(()=>l?{weeksRemaining:Ye(l.endDate),isCatchUpWeek:va(l.endDate),progressPercent:Na(l.startDate,l.endDate),totalWeeks:ba(l.startDate,l.endDate)}:null,[l]),h=v.useMemo(()=>{const x=(n==null?void 0:n.max_tier_reached)??1,u=_e(x,t);return{maxTierReached:x,weeksParticipated:(n==null?void 0:n.weeks_participated)??0,totalFirstPlaces:(n==null?void 0:n.total_first_places)??0,totalPodiums:(n==null?void 0:n.total_podiums)??0,aiCreditsEarned:(n==null?void 0:n.ai_credits_earned)??0,xpBonusEarned:(n==null?void 0:n.xp_bonus_earned)??0,titleEarned:(n==null?void 0:n.title_earned)??null,hasClaimed:!!(n!=null&&n.claimed_at),pendingReward:u}},[n,t]),f=v.useMemo(()=>{const x=h.maxTierReached;if(x>=10)return null;const u=x+1,j=_e(u,t);return{tier:u,reward:j,creditsGain:j.aiCredits-h.pendingReward.aiCredits}},[h,t]);return{season:l,timeMetrics:r,progress:h,nextTierReward:f,isLoading:i||c}}function Pa({flat:s=!1,className:t}={}){const{season:o,timeMetrics:i,progress:a,nextTierReward:n,isLoading:c}=Sa();if(c)return e.jsxs("div",{className:p(s?"":"mono-card-surface border hairline","p-4 animate-pulse space-y-3",t),children:[e.jsx("div",{className:"h-5 w-40 bg-[color:var(--mono-elevated)]"}),e.jsx("div",{className:"h-4 w-full bg-[color:var(--mono-elevated)]"}),e.jsx("div",{className:"h-20 w-full bg-[color:var(--mono-elevated)]"})]});if(!o)return null;const l=(i==null?void 0:i.progressPercent)??0;return e.jsxs("div",{className:p(s?"":"mono-card-surface border hairline overflow-hidden",t),children:[e.jsxs("div",{className:"px-5 py-4 border-b hairline flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"inline-flex items-center gap-2",children:[e.jsx(He,{className:"h-4 w-4 text-mono",strokeWidth:1.6,"aria-hidden":!0}),e.jsxs("h3",{className:"font-display text-lg text-mono",children:["Temporada ",e.jsx("strong",{className:"font-semibold",children:o.name})]})]}
2),(i==null?void 0:i.isCatchUpWeek)&&e.jsx(Z,{icon:e.jsx(O,{}),className:"border-mono-strong text-mono-emph",children:"XP 2x"})]}),e.jsxs("div",{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted font-display",children:"Progresso da temporada"}),e.jsxs("span",{className:"font-display text-mono tabular-nums",children:[e.jsx(S,{value:l,duration:1e3,resetKey:`pct-${l}`}),"%"]})]}),e.jsx("div",{className:"h-1 w-full bg-[color:var(--mono-hairline)] overflow-hidden rounded-full",role:"progressbar","aria-valuenow":Math.round(l),"aria-valuemin":0,"aria-valuemax":100,children:e.jsx(C.div,{className:"h-full bg-[color:var(--mono-text)] origin-left",initial:{scaleX:0},whileInView:{scaleX:l/100},viewport:{once:!0},transition:{duration:.9,ease:[.16,1,.3,1],delay:.15},style:{width:"100%"}})}),e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-mono-muted tabular-nums",children:[e.jsxs("span",{children:[a.weeksParticipated,"/",i==null?void 0:i.totalWeeks," semanas"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(le,{className:"h-3 w-3",strokeWidth:1.6,"aria-hidden":!0}),i==null?void 0:i.weeksRemaining," restantes"]})]})]}),e.jsxs("div",{className:"border hairline p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted font-display mb-1.5",children:"Liga mais alta alcançada"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-9 w-9 border hairline rounded-sm flex items-center justify-center shrink-0",children:e.jsx(L,{name:de(a.maxTierReached),size:20,className:"text-mono"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-display text-lg text-mono truncate",children:ce(a.maxTierReached)}),e.jsxs("p",{className:"text-[11px] text-mono-muted tabular-nums",children:["Nível ",a.maxTierReached," de ",Es]})]})]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted font-display mb-1",children:"Se terminasse hoje"}),e.jsxs("p",{className:"font-display text-2xl text-mono-emph tabular-nums leading-none",children:["+",e.jsx(S,{value:a.pendingReward.aiCredits,duration:1100,resetKey:`cred-${a.pendingReward.aiCredits}`})]}),e.jsx("p",{className:"text-[11px] uppercase tracking-[0.12em] text-mono-muted mt-1",children:"créditos IA"}),e.jsx("p",{className:"text-[11px] text-mono-muted mt-1 max-w-[9rem] ml-auto leading-snug",children:"+ bônus por constância (semanas e pódios)"})]})]}),a.pendingReward.title&&e.jsxs("div",{className:"mt-3 pt-3 hairline-t inline-flex items-center gap-2",children:[e.jsx(Ge,{className:"h-4 w-4 text-mono",strokeWidth:1.6,"aria-hidden":!0}),e.jsxs("span",{className:"text-sm text-mono",children:["Título: ",e.jsxs("span",{className:"font-display",children:[a.pendingReward.title," ",o.name]})]})]})]}),n&&e.jsxs("div",{className:"flex items-center gap-3 p-3 border border-dashed border-[color:var(--mono-hairline)]",children:[e.jsx(ue,{className:"h-4 w-4 text-mono-muted shrink-0",strokeWidth:1.6,"aria-hidden":!0}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm text-mono",children:["Suba para ",e.jsx("span",{className:"font-display",children:ce(n.tier)})," e ganhe"]}),e.jsxs("p",{className:"text-[11px] text-mono-muted",children:["+",n.creditsGain," créditos adicionais",n.reward.title&&` + título "${n.reward.title}"`]})]}),e.jsx(L,{name:de(n.tier),size:22,className:"text-mono"})]})]})]})}function Ca({selectedTier:s,userTier:t,onSelect:o,className:i}){const a=[...Q].sort((n,c)=>c.tier-n.tier);return e.jsx("div",{className:p("border hairline divide-y divide-[color:var(--mono-hairline)]",i),children:a.map(n=>{const c=n.tier===s,l=n.tier===t,r=W.seasonal[n.tier];return e.jsxs("button",{type:"button",onClick:()=>o(n.tier),"aria-pressed":c,className:p("w-full text-left flex items-center gap-3 px-4 py-3","transition-colors duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mono-h
2airline-strong)]",c?"bg-[color:var(--mono-elevated)]":"hover:bg-[color:var(--mono-elevated)]/60"),children:[e.jsx("div",{className:"h-9 w-9 border hairline rounded-sm flex items-center justify-center shrink-0",children:e.jsx(L,{name:n.icon,size:18,className:c||l?"text-mono":"text-mono-muted"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:p("font-display text-sm",c||l?"text-mono":"text-mono-muted"),children:n.name}),l&&e.jsx("span",{className:"chip-mono !text-[11px] !py-0 !px-1.5 border-mono-strong text-mono-emph",children:"você está aqui"})]}),e.jsxs("p",{className:"text-[11px] text-mono-muted tabular-nums mt-0.5",children:["A partir de ",n.minXP.toLocaleString("pt-BR")," XP na semana"]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("p",{className:"text-[11px] text-mono tabular-nums",children:r!=null&&r.aiCredits?`+${r.aiCredits} créditos`:"sem prêmio"}),e.jsx("p",{className:"text-[11px] text-mono-muted",children:r!=null&&r.title?`título "${r.title}"`:"no fim da temporada"})]}),c&&e.jsx(Bs,{className:"h-4 w-4 text-mono shrink-0",strokeWidth:1.8,"aria-hidden":!0})]},n.tier)})})}function Ta(s,t,o=!0){return U({queryKey:["residency-program-ranking",s,t],enabled:o,staleTime:5*60*1e3,queryFn:async()=>{const{data:i,error:a}=await M.rpc("get_residency_program_ranking",{p_period:s,p_metric:t,p_limit:100,p_offset:0});if(a)throw a;return i}})}function Ea(s,t=null,o=!0){return U({queryKey:["residency-residents-ranking",s,t],enabled:o,staleTime:5*60*1e3,queryFn:async()=>{const{data:i,error:a}=await M.rpc("get_residents_ranking",{p_period:s,p_program_id:t,p_limit:50,p_offset:0});if(a)throw a;return i}})}function La(){const s=Re(),{user:t}=K();return oe({mutationFn:async o=>{const{data:i,error:a}=await M.rpc("set_my_residency",{p_program_id:o.programId,p_year:o.year??null});if(a)throw a;const n=i;if(n!=null&&n.error)throw new Error(n.error);return n},onSuccess:()=>{s.invalidateQueries({queryKey:[Ys,t==null?void 0:t.id]}),s.invalidateQueries({queryKey:["residency-program-ranking"]}),s.invalidateQueries({queryKey:["residency-residents-ranking"]}),s.invalidateQueries({queryKey:["my-resident-verification",t==null?void 0:t.id]}),s.invalidateQueries({queryKey:["residency-program-row"]}),re.success("Programa de residência atualizado")},onError:o=>{const i={PROGRAM_NOT_FOUND:"Programa não encontrado",INVALID_YEAR:"Ano/etapa inválido (use R1–R6 ou A1/A2/AF)",NOT_AUTHENTICATED:"Você precisa estar logado"};re.error(i[o.message]??"Erro ao atualizar residência")}})}function Aa(s){const t=s.thresholds,o=s.counts,i=[t.min_programs>0?o.active_programs/t.min_programs:1,t.min_verified_residents>0?o.verified_residents/t.min_verified_residents:1,t.min_active_programs>0?o.active_programs_with_xp/t.min_active_programs:1,t.min_active_residents>0?o.active_verified_residents_with_xp/t.min_active_residents:1].map(l=>Math.min(1,Math.max(0,l))),a=i.reduce((l,r)=>l+r,0)/i.length,n=Math.round(a*100);let c="Fase inicial";return n>=80?c="Quase lá":n>=40&&(c="Ganhando tração"),{pct:n,label:c}}function Ma(){const s=document.getElementById("my-residency-editor");s&&(s.scrollIntoView({behavior:"smooth",block:"center"}),s.classList.add("ring-1","ring-[color:var(--mono-text)]/40"),setTimeout(()=>s.classList.remove("ring-1","ring-[color:var(--mono-text)]/40"),1800))}async function Ia(){const s=typeof window<"u"?window.location.href:"",t="O RadReport vai abrir o Ranking Nacional de Programas de Residência em Radiologia. Cadastre seu programa e entre na disputa.";try{if(navigator.share){await navigator.share({title:"Ranking de Residências — RadReport",text:t,url:s});return}await navigator.clipboard.writeText(`${t} ${s}`),re.success("Link copiado para compartilhar com seus colegas")}catch{}}function Wa({status:s}){const{pct:t,label:o}=Aa(s),i=te();return e.jsx("div",{className:"mono-card-surface border hairline relative overflow-hidden",children:e.jsxs("div",{className:"grid gap-6 p-5 sm:p-6 md:grid-cols-[1.15fr_1fr] md:p-8",children:[e.jsxs("div",{className:"flex flex-col justify-center space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Z,{icon:e.jsx(O,{}
2),dot:!0,className:"border-mono-strong text-mono-emph",children:"Em breve"}),e.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted",children:"Lançamento nacional"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h2",{className:"font-display text-xl sm:text-2xl md:text-3xl leading-tight text-mono",children:["O ",e.jsx("strong",{className:"font-semibold",children:"ranking nacional"})," entre programas",e.jsx("br",{className:"hidden sm:block"})," de residência em radiologia está chegando."]}),e.jsx("p",{className:"text-sm text-mono-muted max-w-prose",children:"Hospital vs hospital. Residente vs residente. Pódio mensal, prêmios em créditos e visibilidade para o seu programa em todo o Brasil. Vincule sua residência agora — seu XP já está sendo contabilizado e entrará no ranking automaticamente na abertura."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[e.jsx("span",{className:"uppercase tracking-[0.16em] font-display text-mono-muted",children:o}),e.jsx(S,{value:t,suffix:"%",className:"text-mono font-display",resetKey:t})]}),e.jsx("div",{className:"h-1 w-full bg-[color:var(--mono-hairline)] overflow-hidden rounded-full",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx(C.div,{className:"h-full bg-[color:var(--mono-text)] origin-left",initial:{scaleX:0},whileInView:{scaleX:Math.max(.04,t/100)},viewport:{once:!0},transition:{duration:.9,ease:[.16,1,.3,1],delay:.15},style:{width:"100%"}})}),e.jsx("p",{className:"text-[11px] text-mono-muted",children:"Abertura automática assim que atingirmos a massa crítica de programas e residentes verificados."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-1",children:[e.jsxs(A,{onClick:Ma,className:"inline-flex items-center gap-1.5",children:[e.jsx(qs,{className:"h-3.5 w-3.5",strokeWidth:1.7})," Vincular minha residência"]}),e.jsxs(A,{variant:"outline",onClick:Ia,className:"inline-flex items-center gap-1.5",children:[e.jsx(Ds,{className:"h-3.5 w-3.5",strokeWidth:1.7})," Convidar colegas"]})]})]}),e.jsxs("div",{className:"relative hidden md:block min-h-[260px]",children:[e.jsx(we,{className:"absolute top-0 right-8 w-[80%] rotate-[-4deg]",icon:Os,title:"Pódio de Programas",subtitle:"HCFMUSP · INCOR · HUPE",metric:"XP médio",delay:0,reduced:i??!1}),e.jsx(we,{className:"absolute top-14 right-0 w-[80%] rotate-[3deg]",icon:ue,title:"Top Residentes",subtitle:"Ranking nacional verificado",metric:"XP do mês",delay:.1,reduced:i??!1}),e.jsx(we,{className:"absolute top-32 right-12 w-[80%] rotate-[-2deg]",icon:Ge,title:"Prêmio Mensal",subtitle:"Créditos + badge exclusivo",metric:"3 pódios",delay:.2,accent:!0,reduced:i??!1})]})]})})}function we({className:s,icon:t,title:o,subtitle:i,metric:a,delay:n,accent:c,reduced:l}){return e.jsxs(C.div,{initial:l?void 0:{opacity:0,y:14},whileInView:l?void 0:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.55,delay:n,ease:[.16,1,.3,1]},className:p("mono-card-surface border hairline p-3 flex items-center gap-3",c&&"border-mono-strong",s),children:[e.jsx("div",{className:p("h-9 w-9 border hairline rounded-sm flex items-center justify-center shrink-0",c&&"border-mono-strong"),children:e.jsx(t,{className:p("h-4 w-4",c?"text-mono-emph":"text-mono"),strokeWidth:1.7})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-display text-mono truncate",children:o}),e.jsx("div",{className:"text-[11px] text-mono-muted truncate",children:i})]}),e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted whitespace-nowrap",children:a})]})}const $a=["R1","R2","R3","R4","R5","R6"],Fa=[{value:"A1",label:"A1 — 1º ano"},{value:"A2",label:"A2 — 2º ano"},{value:"AF",label:"AF — Concluído"}],Xa=["cbr_aperfeicoamento_rdi","cbr_aperfeicoamento_us"];function Ba({onSaved:s}){const{profile:t}=ea(),o=(t==null?void 0:t.residency_program_id)??null,i=(t==null?void 0:t.residency_year)??"",[a,n]=v.useState(null),[c,l]=v.useState(i),r=La(),{data:h}
2=U({queryKey:["residency-program-row",o],enabled:!!o&&!a,staleTime:10*60*1e3,queryFn:async()=>{const{data:d,error:g}=await M.from("residency_programs").select("id, hospital_name, city, uf, vagas_autorizadas, slug, program_type, cbr_classification, cbr_recognized").eq("id",o).maybeSingle();if(g)throw g;return d}});v.useEffect(()=>{h&&!a&&n(h)},[h,a]),v.useEffect(()=>{i&&!c&&l(i)},[i,c]);const f=r.data??null,x=((a==null?void 0:a.id)??null)!==o||(c||null)!==(i||null),u=!!(a!=null&&a.id)&&!a._manual&&!!c&&x&&!r.isPending,j=async()=>{a!=null&&a.id&&(await r.mutateAsync({programId:a.id,year:c}),s==null||s())},m=async()=>{await r.mutateAsync({programId:null,year:null}),n(null),l(""),s==null||s()};return e.jsxs(xs,{id:"my-residency-editor",className:"p-4 sm:p-5 space-y-4 border-primary/30 bg-primary/5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/15 text-primary flex items-center justify-center flex-shrink-0",children:e.jsx(P,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-foreground text-sm sm:text-base",children:o?"Sua residência / aperfeiçoamento":"Vincule sua residência (MEC) ou aperfeiçoamento (CBR RDI/US) para entrar no ranking"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Sua pontuação conta para o ranking do seu programa e disputa prêmios mensais. Para o XP contar, você precisa estar verificado (desconto de residente ou embaixador)."})]})]}),e.jsx(sa,{className:"text-xs"}),f&&f.verified&&f.counts_for_ranking&&e.jsx("div",{className:"text-xs",children:e.jsxs(us,{className:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300 border-emerald-500/30 gap-1",children:[e.jsx(Vs,{className:"h-3 w-3"})," Programa salvo — XP conta no ranking",f.verified_via&&e.jsxs("span",{className:"opacity-70",children:["· via ",f.verified_via]})]})}),e.jsx(Js,{value:a,onChange:d=>{n(d);const g=d==null?void 0:d.program_type,_=a==null?void 0:a.program_type;g!==_&&l("")},allowedTypes:["mec_residencia","cbr_aperfeicoamento_rdi","cbr_aperfeicoamento_us"]}),(()=>{const d=!!(a!=null&&a.program_type)&&Xa.includes(a.program_type);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ps,{className:"text-xs",children:d?"Etapa do aperfeiçoamento":"Ano de residência"}),e.jsxs(hs,{value:c,onValueChange:l,children:[e.jsx(fs,{children:e.jsx(gs,{placeholder:"Selecione"})}),e.jsx(js,{children:d?Fa.map(g=>e.jsx(Me,{value:g.value,children:g.label},g.value)):$a.map(g=>e.jsx(Me,{value:g,children:g},g))})]})]})})(),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ie,{onClick:j,disabled:!u,className:"flex-1",children:r.isPending?"Salvando…":"Salvar residência"}),o&&e.jsxs(Ie,{variant:"outline",onClick:m,disabled:r.isPending,className:"sm:w-auto",children:[e.jsx(Ks,{className:"h-3.5 w-3.5 mr-1"})," Remover"]})]})]})}const qa=[{value:"week",label:"Semana"},{value:"month",label:"Mês"},{value:"alltime",label:"Geral"}];function me({pos:s}){const t=s<=3;return e.jsx("span",{className:p("inline-flex items-center justify-center h-8 w-8 border hairline font-display tabular-nums shrink-0",t?"text-mono-emph border-mono-strong text-sm":"text-mono-muted text-xs"),children:s})}function Xe({active:s,onClick:t,icon:o,children:i}){return e.jsxs("button",{type:"button",role:"tab","aria-selected":s,onClick:t,className:p("relative inline-flex items-center gap-2 px-4 py-2.5 text-sm font-display","transition-colors duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mono-hairline-strong)]",s?"text-mono":"text-mono-muted hover:text-mono"),children:[e.jsx(o,{className:"h-3.5 w-3.5",strokeWidth:1.7,"aria-hidden":!0}),i,e.jsx("span",{"aria-hidden":!0,className:p("absolute left-0 right-0 -bottom-px h-px bg-[color:var(--mono-text)] transition-all duration-300 origin-left",s?"opacity-100 scale-x-100":"opacity-0 scale-x-0")})]})}function Da({period:s,onOpenProgram:t}){const[o,i]=v.useState("avg"),{data:a,isLoading:n}=Ta(s,o),c=(a==null?void 0:a.rows)??[],l=(a==null?void 0:a.my_program)??null;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"text-[11px] text-mono-muted",children:["Métrica principal:"," ",e.jsx("strong",{className:"text-mono font-display",children:o==="avg"?"XP médio por residente ativo":"XP total"})," · ","min. 3 ativos no pódio."]}),e.jsxs("div",{className:"inline-flex border hairline",children:[e.jsx("button",{type:"button",onClick:()=>i("avg"),className:p("px-3 py-1 text-xs font-display transition-colors duration-200",o==="avg"?"bg-[color:var(--mono-elevated)] text-mono":"text-mono-muted hover:text-mono"),children:"Média"}),e.jsx("button",{type:"button",onClick:()=>i("total"),className:p("px-3 py-1 text-xs font-display transition-colors duration-200 border-l hairline",o==="total"?"bg-[color:var(--mono-elevated)] text-mono":"text-mono-muted hover:text-mono"),children:"Total"})]})]}),l&&e.jsxs("div",{className:"surface-mono border hairline border-mono-strong px-3 py-3 flex items-center gap-3",children:[e.jsx(me,{pos:l.position}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted font-display",children:"Seu programa"}),e.jsx("div",{className:"font-display text-sm text-mono truncate",children:l.hospital_name})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsxs("div",{className:"font-display text-sm text-mono tabular-nums",children:[e.jsx(S,{value:o==="avg"?l.avg_xp:l.total_xp,duration:1e3,resetKey:`myp-${o}-${l.program_id}`})," XP"]}),e.jsxs("div",{className:"text-[11px] text-mono-muted",children:[l.active_residents," ativo(s)"]})]})]}),n?e.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((r,h)=>e.jsx(ke,{className:"h-14 w-full"},h))}):c.length===0?e.jsx("div",{className:"surface-mono border hairline p-6 text-center text-sm text-mono-muted",children:"Nenhum programa pontuou neste período ainda. Seja o primeiro a colocar seu hospital no mapa."}
2):e.jsx("div",{className:"border hairline surface-mono divide-y divide-[color:var(--mono-hairline)]",children:c.map(r=>e.jsxs("button",{onClick:()=>t(r),className:p("w-full text-left flex items-center gap-3 p-3 transition-colors duration-200 hover:bg-[color:var(--mono-elevated)]",(l==null?void 0:l.program_id)===r.program_id&&"bg-[color:var(--mono-elevated)] ring-1 ring-inset ring-[color:var(--mono-text)]/30"),children:[e.jsx(me,{pos:r.position}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-display text-sm text-mono truncate flex items-center gap-2",children:[e.jsx(V,{className:"h-3.5 w-3.5 text-mono-muted flex-shrink-0",strokeWidth:1.6}),e.jsx("span",{className:"truncate",children:r.hospital_name})]}),e.jsxs("div",{className:"text-[11px] text-mono-muted flex items-center gap-1.5 mt-0.5 flex-wrap",children:[r.city&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Us,{className:"h-3 w-3",strokeWidth:1.6}),r.city,r.uf?`/${r.uf}`:""]}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(zs,{className:"h-3 w-3",strokeWidth:1.6}),r.active_residents," ativo(s)"]})]})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsx("div",{className:"font-display text-sm text-mono tabular-nums",children:e.jsx(S,{value:o==="avg"?r.avg_xp:r.total_xp,duration:1e3,resetKey:`p-${r.program_id}-${o}`})}),e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted",children:o==="avg"?"XP médio":"XP total"})]})]},r.program_id))})]})}function Be({period:s,programId:t,currentUserId:o}){const{data:i,isLoading:a}=Ea(s,t??null),n=(i==null?void 0:i.rows)??[],c=(i==null?void 0:i.me)??null;return e.jsxs("div",{className:"space-y-3",children:[c&&e.jsxs("div",{className:"surface-mono border hairline border-mono-strong p-3 flex items-center gap-3",children:[e.jsx(me,{pos:c.position}),e.jsxs(F,{className:"h-9 w-9 border hairline rounded-sm",children:[e.jsx(X,{src:c.avatar_url??void 0,className:"rounded-sm"}),e.jsx(B,{className:"bg-transparent rounded-sm text-xs font-display",children:(c.full_name??"?").slice(0,1)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted font-display",children:"Sua posição"}),e.jsx("div",{className:"font-display text-sm text-mono truncate",children:ae(c.full_name??"Você")})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsxs("div",{className:"font-display text-sm text-mono tabular-nums",children:[e.jsx(S,{value:c.xp,duration:1100,resetKey:`me-${c.user_id}-${c.xp}`})," XP"]}),c.residency_year&&e.jsx("span",{className:"chip-mono !text-[11px] !py-0 !px-1.5 mt-1 inline-flex",children:c.residency_year})]})]}),a?e.jsx("div",{className:"space-y-2",children:Array.from({length:8}).map((l,r)=>e.jsx(ke,{className:"h-12 w-full"},r))}):n.length===0?e.jsx("div",{className:"surface-mono border hairline p-6 text-center text-sm text-mono-muted",children:"Nenhum residente/aperfeiçoando verificado pontuou neste período ainda."}):e.jsx("div",{className:"border hairline surface-mono divide-y divide-[color:var(--mono-hairline)]",children:n.map(l=>e.jsxs("div",{className:p("flex items-center gap-3 p-2.5 transition-colors duration-200 hover:bg-[color:var(--mono-elevated)]",l.user_id===o&&"bg-[color:var(--mono-elevated)] ring-1 ring-inset ring-[color:var(--mono-text)]/30"),children:[e.jsx(me,{pos:l.position}),e.jsxs(F,{className:"h-9 w-9 border hairline rounded-sm",children:[e.jsx(X,{src:l.avatar_url??void 0,className:"rounded-sm"}),e.jsx(B,{className:"bg-transparent rounded-sm text-xs font-display",children:(l.full_name??"?").slice(0,1)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-display text-sm text-mono truncate flex items-center gap-1.5",children:[ae(l.full_name??"—"),l.residency_year&&e.jsx("span",{className:"chip-mono !text-[11px] !py-0 !px-1 h-4",children:l.residency_year})]}),l.hospital_name&&e.jsxs("div",{className:"text-[11px] text-mono-muted truncate flex items-center gap-1",children:[e.jsx(V,{className:"h-3 w-3",strokeWidth:1.6}),l.hospital_name,l.uf?` · ${l.uf}`:""]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("div",{className:"font-display text-sm text-mono tabular-nums",children:e.jsx(S,{value:l.xp,duration:1e3,resetKey:`r-${l.user_id}-${l.xp}`})}),e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted",children:"XP"})]})]},l.user_id))})]})}function Oa({currentUserId:s}
2){const[t,o]=v.useState("week"),[i,a]=v.useState("programs"),[n,c]=v.useState(null),{data:l,isLoading:r}=Zs(),h=(l==null?void 0:l.enabled)===!0;return e.jsxs("div",{className:"space-y-4",children:[r?e.jsx(ke,{className:"h-48 w-full"}):!h&&l?e.jsx(Wa,{status:l}):null,e.jsx(Ba,{}),h&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap pb-4 border-b hairline",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted font-display",children:"Período"}),e.jsx("div",{className:"inline-flex border hairline",children:qa.map((f,x)=>e.jsx("button",{type:"button",onClick:()=>o(f.value),className:p("px-3 py-1 text-xs font-display transition-colors duration-200",x>0&&"border-l hairline",t===f.value?"bg-[color:var(--mono-elevated)] text-mono":"text-mono-muted hover:text-mono"),children:f.label},f.value))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex border-b hairline",role:"tablist",children:[e.jsx(Xe,{active:i==="programs",onClick:()=>a("programs"),icon:V,children:"Programas"}),e.jsx(Xe,{active:i==="residents",onClick:()=>a("residents"),icon:ue,children:"Residentes"})]}),e.jsx("div",{className:"mt-4",children:i==="programs"?e.jsx(Da,{period:t,onOpenProgram:c}):e.jsx(Be,{period:t,currentUserId:s})})]}),e.jsx(vs,{open:!!n,onOpenChange:f=>!f&&c(null),children:e.jsxs(Ns,{className:"landing-mono edu-scope w-[95vw] max-w-lg sm:max-w-lg max-h-[85svh] overflow-y-auto",children:[e.jsxs(bs,{children:[e.jsxs(ys,{className:"flex items-center gap-2 font-display",children:[e.jsx(V,{className:"h-4 w-4",strokeWidth:1.6}),n==null?void 0:n.hospital_name]}),e.jsxs("div",{className:"text-xs text-mono-muted",children:[n==null?void 0:n.city,n!=null&&n.uf?`/${n==null?void 0:n.uf}`:""," · #",n==null?void 0:n.position," no ranking nacional"]})]}),n&&e.jsx(Be,{period:t,programId:n.program_id,currentUserId:s})]})})]})]})}const Va=v.lazy(()=>De(()=>import("./index-CyzpCJhv.js"),__vite__mapDeps([21,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22])).then(s=>({default:s.RecentChampions}))),q=30,Ka=["ranking","residencias","temporada","historico"],Ua={ranking:"Ranking",residencias:"Residências",temporada:"Ligas e temporada",historico:"Histórico"},za={global:"Pontuação acumulada de todos os tempos",monthly:"Os melhores dos últimos 28 dias",weekly:"Competição da semana corrente",accuracy:"Maior precisão média (≥ 3 sessões)",cases:"Mais questões resolvidas"},Ha=[{key:"ranking",label:"Ranking",icon:P},{key:"residencias",label:"Residências",icon:V},{key:"temporada",label:"Ligas e temporada",icon:$},{key:"historico",label:"Histórico",icon:O}];function E({eyebrow:s,icon:t,title:o,description:i,action:a}){return e.jsxs("div",{className:"flex items-end justify-between gap-4 flex-wrap pb-4 border-b hairline",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 text-[11px] uppercase tracking-[0.16em] text-mono-muted font-display mb-2",children:[e.jsx(t,{className:"h-3 w-3",strokeWidth:1.7,"aria-hidden":!0}),s]}),e.jsx("h2",{className:"font-display text-xl md:text-2xl text-mono leading-tight",children:o}),i&&e.jsx("p",{className:"mt-1.5 text-sm text-mono-muted max-w-xl",children:i})]}),a&&e.jsx("div",{className:"shrink-0",children:a})]})}function Ga(){var Le,Ae;Ke();const{user:s}=K(),[t,o]=ks(),i=t.get("tab"),a=i&&Ka.includes(i)?i:"ranking",[n,c]=v.useState(a),l=te();ws();const{tier:r,weekEnd:h,promotionCutoff:f,demotionCutoff:x,weeklyXP:u,isPromoted:j}=Ue(),[m,d]=v.useState(r||1),[g,_]=v.useState("weekly"),[N,b]=v.useState(0),y=g==="weekly",R=n==="temporada"?m:r||1,T=n==="ranking"&&y||n==="temporada",z=n==="ranking"&&!y,{rankings:Se,userPosition:ne,totalCount:pe,isLoading:Pe}=Rs(R,N*q,T),{rankings:Je,metricLabel:es,userPosition:ss,totalCount:as,isLoading:ts}=Ss(g,N*q,q,z),ns=v.useCallback(w=>{_(w),b(0)},[]),is=v.useCallback(w=>{d(w),b(0)},[]),he=v.useCallback(w=>{c(w),b(0),o(I=>{const H=new URLSearchParams(I);return w==="ranking"?H.delete("tab"):H.set("tab",w),H},{replace:!0})},[o]);v.useEffect(()=>{r&&r>0&&d(r)},[r]),v.useEffect(()=>{if(!j||!(s!=null&&s.id)||!h)return;const I=`promo_seen_${h.toISOString().slice(0,10)}_${s.id}`;typeof window>"u"||window.localStorage.getItem(I)||(window.localStorage.setItem(I,"1"),re.success("Promoção garantida nesta semana!",{description:"Você está dentro da zona de promoção. Mantenha o ritmo até o fim da semana.",icon:e.jsx(Hs,{className:"h-4 w-4"}),duration:6e3}))},[j,s==null?void 0:s.id,h]);const Ce=h?new Date(h.getTime()-6*24*60*60*1e3):null,ie=Ce?Ce.toLocaleDateString("pt-BR",{day:"2-digit",month:"short"}):null,fe=y?Se:Je.map(w=>({user_id:w.user_id,display_name:w.display_name,avatar_url:w.avatar_url??"",specialty:w.specialty,xp_earned:Number(w.metric??0),position:w.position,is_promoted:!1,is_demoted:!1})),ge=y?pe:as,je=y?Pe:ts,ve=y?"XP":es,Te=y?ne:ss,rs=Math.ceil(ge/q),os=fe.slice(0,3).map((w,I)=>({user_id:w.user_id,display_name:ae(w.display_name),avatar_url:w.avatar_url,xp_earned:w.xp_earned,position:w.position??I+1}
2)),Ee=N===0?fe.slice(3,10):[],ls=(Le=s==null?void 0:s.user_metadata)==null?void 0:Le.avatar_url,cs=((Ae=s==null?void 0:s.user_metadata)==null?void 0:Ae.full_name)??(s==null?void 0:s.email)??"Você";return e.jsxs("div",{className:"landing-mono edu-page-min bg-[color:var(--mono-bg)] text-mono relative overflow-hidden",children:[e.jsx(_s,{}),e.jsxs("main",{className:"relative z-10 container mx-auto px-4 md:px-6 py-10 md:py-14 edu-shell",children:[e.jsx(aa,{className:"mb-8",backTo:"/educacao",kicker:"vol. 12 · ranking",title:Ua[n]}),e.jsx("div",{className:"mb-6 border-b hairline overflow-x-auto scrollbar-hide",role:"tablist","aria-label":"Seções do ranking",children:e.jsx("div",{className:"flex min-w-min",children:Ha.map(({key:w,label:I,icon:H})=>{const Ne=n===w;return e.jsxs("button",{type:"button",role:"tab","aria-selected":Ne,onClick:()=>he(w),className:p("relative inline-flex items-center gap-2 px-4 py-3 text-sm font-display whitespace-nowrap","transition-colors duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--mono-hairline-strong)]",Ne?"text-mono":"text-mono-muted hover:text-mono"),children:[e.jsx(H,{className:"h-4 w-4",strokeWidth:1.7,"aria-hidden":!0}),I,e.jsx("span",{"aria-hidden":!0,className:p("absolute left-0 right-0 -bottom-px h-[2px] bg-[color:var(--mono-text)] transition-all duration-300 origin-left",Ne?"opacity-100 scale-x-100":"opacity-0 scale-x-0")})]},w)})})}),e.jsx(Oe,{mode:"wait",initial:!1,children:e.jsxs(C.div,{initial:l?void 0:{opacity:0,y:8},animate:l?void 0:{opacity:1,y:0},exit:l?void 0:{opacity:0,y:-6},transition:{duration:.22,ease:[.16,1,.3,1]},children:[n==="ranking"&&e.jsxs("div",{className:"space-y-8",children:[e.jsx(k,{direction:"up",distance:24,duration:700,children:e.jsx(E,{eyebrow:"Seu status",icon:P,title:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold",children:"Onde você está"})," agora"]}),description:"Acompanhe sua posição, XP da semana e distância até a promoção."})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(k,{direction:"up",distance:24,duration:700,delay:60,children:e.jsx(fa,{userId:s==null?void 0:s.id,avatarUrl:ls,displayName:cs,position:Te,total:ge,xpEarned:u,promotionCutoff:f,demotionCutoff:x,weekEnd:h,activeFilter:g,filterLabel:za[g]})}),y&&e.jsx(k,{direction:"up",distance:24,duration:700,delay:100,children:e.jsx($e,{userTier:r||1,position:Te,onSeeMore:()=>he("temporada")})})]}),e.jsx(k,{direction:"up",distance:24,duration:700,children:e.jsx(E,{eyebrow:"Destaque",icon:O,title:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold",children:"Top"})," radiologistas"]}),description:"Filtre por semana, mês, precisão ou casos resolvidos."})}),e.jsx(k,{direction:"up",distance:24,duration:700,delay:80,children:e.jsxs("div",{children:[e.jsx(ha,{rankings:os,isLoading:je,onFilterChange:ns,activeFilter:g,metricLabel:ve}),!je&&Ee.length>0&&e.jsx(ga,{rankings:Ee,currentUserId:s==null?void 0:s.id,metricLabel:ve,attached:!0})]})}),e.jsx(k,{direction:"up",distance:24,duration:700,children:e.jsx(E,{eyebrow:"Ranking completo",icon:P,title:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold",children:"Todos"})," os participantes"]})})}),e.jsx(k,{direction:"up",distance:24,duration:700,delay:80,children:e.jsx(qe,{league:Q.find(w=>w.tier===R)??Q[0],rankings:fe,userPosition:y?ne:null,totalCount:ge,isLoading:je,page:N,totalPages:rs,onPageChange:b,metricLabel:ve,promotionCutoff:y?f:void 0,demotionCutoff:y?x:void 0,hidePromotionStatus:!y,emptyMessage:y&&ie?`Ninguém pontuou nesta semana ainda — a semana começou em ${ie}. Seja o primeiro!`:void 0})})]}),n==="residencias"&&e.jsxs("div",{className:"space-y-8",children:[e.jsx(k,{direction:"up",distance:24,duration:700,children:e.jsx(E,{eyebrow:"Residências",icon:V,title:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold",children:"Ranking"})," nacional"]}),description:"Competição entre programas de residência verificados e residentes ativos."})}),e.jsx(k,{direction:"up",distance:24,duration:700,delay:80,children:e.jsx(Oa,{currentUserId:s==null?void 0:s.id})})]}),n==="temporada"&&e.jsxs("div",{className:"space-y-12",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx(k,{direction:"up",distance:24,duration:700,children:e.jsx(E,{eyebrow:"Esta semana",icon:$,title:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold",children:"Sua liga"})," agora"]})})}),e.jsx(k,{direction:"up",distance:24,duration:700,delay:60,children:e.jsx(na,{banner:!0})}),e.jsx(k,{direction:"up",distance:24,duration:700,delay:100,children:e.jsx($e,{userTier:r||1,position:ne,onSeeMore:()=>he("ranking")})}),e.jsx(k,{direction:"up",distance:24,duration:700,delay:140,children:e.jsxs("div",{className:"border hairline p-4 space-y-1.5",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-[0.16em] text-mono-muted font-display",children:"Como funciona"}),e.jsxs("p",{className:"text-sm text-mono-muted",children:[e.jsx("span",{className:"text-mono",children:"Semana:"}
2)," sua posição é calculada entre quem estudou na liga nesta semana. O pódio ganha créditos IA e XP — desde que você tenha estudado e haja concorrência."]}),e.jsxs("p",{className:"text-sm text-mono-muted",children:[e.jsx("span",{className:"text-mono",children:"Ligas:"})," a escada de ligas só abre quando a plataforma tiver estudantes ativos suficientes no último mês. Até lá, todos disputam o mesmo ranking e ninguém é rebaixado."]}),e.jsxs("p",{className:"text-sm text-mono-muted",children:[e.jsx("span",{className:"text-mono",children:"Temporada:"})," ao fim do ciclo, a liga mais alta que você alcançou define seus créditos IA e seu título."]})]})})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx(k,{direction:"up",distance:24,duration:700,children:e.jsx(E,{eyebrow:"Temporada",icon:He,title:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold",children:"Ciclo"})," atual"]}),description:"A liga mais alta que você alcançar até o fim do ciclo define o prêmio."})}),e.jsx(k,{direction:"up",distance:24,duration:700,delay:80,children:e.jsx(Pa,{})})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx(k,{direction:"up",distance:24,duration:700,children:e.jsx(E,{eyebrow:"Suas conquistas",icon:xe,title:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold",children:"Tudo"})," que você já ganhou"]}),description:"Créditos IA, XP bônus, pódios e o histórico das últimas semanas."})}),e.jsx(k,{direction:"up",distance:24,duration:700,delay:80,children:e.jsx(ka,{flat:!0})})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx(k,{direction:"up",distance:24,duration:700,children:e.jsx(E,{eyebrow:"Escada de ligas",icon:P,title:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold",children:"Todas"})," as ligas"]}),description:"Toque numa liga para ver quem está competindo nela nesta semana."})}),e.jsx(k,{direction:"up",distance:24,duration:700,delay:80,children:e.jsx(Ca,{selectedTier:m,userTier:r,onSelect:is})}),e.jsx(k,{direction:"up",distance:24,duration:700,delay:140,children:e.jsx(qe,{league:Q.find(w=>w.tier===m)??Q[0],rankings:Se,userPosition:ne,totalCount:pe,isLoading:Pe,page:N,totalPages:Math.ceil(pe/q),onPageChange:b,metricLabel:"XP",promotionCutoff:m===r?f:void 0,demotionCutoff:m===r?x:void 0,emptyMessage:ie?`Ninguém pontuou nesta semana ainda — a semana começou em ${ie}. Seja o primeiro!`:void 0})})]})]}),n==="historico"&&e.jsxs("div",{className:"space-y-12",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx(k,{direction:"up",distance:24,duration:700,children:e.jsx(E,{eyebrow:"Campeões recentes",icon:P,title:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold",children:"Vencedores"})," das últimas semanas"]}),description:"Os três primeiros de cada semana da sua liga."})}),e.jsx(k,{direction:"up",distance:24,duration:700,delay:80,children:e.jsx(v.Suspense,{fallback:e.jsx("div",{className:"h-24 border-t border-b hairline animate-pulse"}),children:e.jsx(Va,{})})})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx(k,{direction:"up",distance:24,duration:700,children:e.jsx(E,{eyebrow:"Eventos especiais",icon:O,title:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold",children:"Missões"})," e desafios"]}),description:"Objetivos com multiplicador de XP e recompensas exclusivas."})}),e.jsx(k,{direction:"up",distance:24,duration:700,delay:80,children:e.jsx(ca,{})})]})]})]},n)})]})]})}function qe({rankings:s,totalCount:t,isLoading:o,page:i,totalPages:a,onPageChange:n,metricLabel:c="XP",emptyMessage:l,hidePromotionStatus:r,promotionCutoff:h,demotionCutoff:f}){const x=Ke();if(o)return e.jsx("div",{className:"mono-card-surface border hairline p-4 space-y-2",children:[...Array(10)].map((j,m)=>e.jsx("div",{className:"h-12 bg-[color:var(--mono-elevated)] animate-pulse"},m))});if(s.length===0)return e.jsxs("div",{className:"border-t border-b hairline text-center py-12 px-4",children:[e.jsx("div",{className:"mx-auto h-14 w-14 border hairline rounded-sm flex items-center justify-center mb-4",children:e.jsx(P,{className:"h-6 w-6 text-mono",strokeWidth:1.5})}),e.jsx("h3",{className:"font-display text-lg text-mono mb-2",children:l?"Sem dados ainda":"Seja o primeiro"}),e.jsx("p",{className:"text-sm text-mono-muted mb-6 max-w-md mx-auto",children:l??"Ninguém entrou nesta liga ainda. Complete sessões de estudo para ganhar XP e aparecer no ranking."}),e.jsxs("div",{className:"flex gap-3 justify-center flex-wrap",children:[e.jsxs(A,{onClick:()=>x("/educacao/jornada"),className:"inline-flex items-center gap-2",children:[e.jsx($,{className:"h-4 w-4",strokeWidth:1.7}),"Treino rápido"]}),e.jsxs(A,{variant:"outline",onClick:()=>x("/educacao/trilhas"),className:"inline-flex items-center gap-2",children:[e.jsx(Gs,{className:"h-4 w-4",strokeWidth:1.7}),"Ver trilhas"]})]})]});const u=s.map((j,m)=>({user_id:j.user_id,display_name:ae(j.display_name),avatar_url:j.avatar_url||"",specialty:j.specialty,xp_earned:j.xp_earned??0,position:j.position??i*q+m+1,is_promoted:j.is_promoted??!1,is_demoted:j.is_demoted??!1}));return e.jsxs("div",{className:"space-y-4",children:[t>0&&e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsxs("p",{className:"text-[11px] uppercase tracking-[0.14em] text-mono-muted font-display",children:[e.jsx("span",{className:"text-mono tabular-nums",children:t})," ","participante",t!==1?"s":""]}),a>1&&e.jsxs("p",{className:"text-[11px] text-mono-muted tabular-nums",children:["Página ",i+1," de ",a]})]}),e.jsx(ra,{rankings:u,promotionThreshold:r?0:h??Math.max(1,Math.ceil(t*.2)),demotionStart:r?t+1:Math.max(1,t-(f??Math.floor(t*.1))+1),metricLabel:c,showPromotionStatus:!r}),a>1&&e.jsxs("div",{className:"flex items-center justify-center gap-2 pt-2 flex-wrap",children:[e.jsxs(A,{variant:"outline",disabled:i===0,onClick:()=>n(i-1),className:"inline-flex items-center gap-1",children:[e.jsx(Qs,{className:"h-4 w-4",strokeWidth:1.7}),e.jsx("span",{className:"hidden sm:inline",children:"Anterior"})]}),e.jsx("div",{className:"hidden sm:inline-flex border hairline",children:Array.from({length:Math.min(a,5)},(j,m)=>{let d;a<=5||i<3?d=m:i>
2a-4?d=a-5+m:d=i-2+m;const g=d===i;return e.jsx("button",{type:"button",onClick:()=>n(d),className:p("h-9 w-9 inline-flex items-center justify-center text-xs font-display tabular-nums","transition-colors duration-200",m>0&&"border-l hairline",g?"bg-[color:var(--mono-elevated)] text-mono":"text-mono-muted hover:text-mono hover:bg-[color:var(--mono-elevated)]/60"),children:d+1},d)})}),e.jsxs("span",{className:"sm:hidden inline-flex items-center px-3 h-9 border hairline text-xs font-display tabular-nums text-mono",children:[i+1," ",e.jsx("span",{className:"text-mono-muted mx-1",children:"/"})," ",a]}),e.jsxs(A,{variant:"outline",disabled:i>=a-1,onClick:()=>n(i+1),className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"hidden sm:inline",children:"Próximo"}),e.jsx(J,{className:"h-4 w-4",strokeWidth:1.7})]})]})]})}const dt=Object.freeze(Object.defineProperty({__proto__:null,default:Ga},Symbol.toStringTag,{value:"Module"}));export{dt as E,ra as L,fa as M,ga as N,ha as P,$e as R,la as S,na as W,ca as a,xa as b,ka as c,Pa as d,Ca as e,ua as f,da as g,ae as s,Ze as u};

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.