1import{n as O,a as x,aJ as A,af as _,b as e,T,h as q,fB as G}from"./index-COxKkHg0.js";import{l as H,R as Y,A as I,X,Y as J,m as Q,n as U}from"./profile-history-utils-Ro9DRjlB.js";import{f as V,b as Z,c as $,C as ee}from"./CoachAdjustmentSheet-C1-ODTbC.js";import"./use-czpadel-history-BvAUcyOu.js";import"./use-czpadel-ranking-DzBNUrCg.js";import"./gift-DTZVQ6gI.js";import"./flame-Bf-qwqkQ.js";import"./badge-check-DRjE4Nct.js";import"./peer-rating-utils-BQpqhs0G.js";import"./revolut-utils-Ba2OUagZ.js";import"./bank-country-DjpCe7Em.js";import"./QRCodeModal-DOsDY059.js";import"./landmark-LiUiEpb3.js";const te=[{value:"5",labelKey:"level.filter5"},{value:"10",labelKey:"level.filter10"},{value:"all",labelKey:"level.filterAll"}],se={level:{label:"Level",color:"hsl(var(--chart-1))"}};function ve({playerId:u,sport:f,currentLevel:v}){const{t:l}=O("profile"),[g,S]=x.useState("5"),[F,p]=x.useState(null),{data:o=[],isLoading:w}=A({queryKey:["public-rating-history",u,f],queryFn:async()=>{const{data:s,error:t}=await _.rpc("get_public_rating_history",{p_player_id:u,p_sport:f});if(t)throw t;return(s??[]).slice().reverse()},enabled:!!u,staleTime:60*1e3}),B=V(o,g),c=x.useMemo(()=>{const s=o.filter(t=>t.change_reason==="coach_adjustment"&&t.coach_id).map(t=>t.coach_id);return[...new Set(s)]},[o]),{data:j=[]}=A({queryKey:["coach-profiles",c],queryFn:async()=>{if(c.length===0)return[];const{data:s}=await _.from("certified_coaches").select("id, name").in("id",c);return s||[]},enabled:c.length>0,staleTime:30*60*1e3}),n=Z(B,v),W=x.useMemo(()=>{const s=new Map(j.map(t=>[t.id,t.name]));return n.map(t=>({...t,coachName:t.coachId&&s.get(t.coachId)||null}))},[n,j]),E=n.map(s=>s.level),[L,z]=$(E),K=n.length>0?n[n.length-1].level:v??3.5,R=n.length,b=o.some(s=>s.change_reason==="coach_adjustment"),y=o.some(s=>s.change_reason==="manual_adjustment"),D=s=>{const{cx:t,cy:r,payload:a,index:k}=s,d=k===R-1,M=k===0&&a.entryId==="start",h=a.changeReason==="manual_adjustment",i=a.changeReason==="coach_adjustment",m=a.changeReason==="peer_consensus",C=()=>{p({date:a.date,levelBefore:Number(a.level)-Number(a.change??0),levelAfter:Number(a.level),coachName:a.coachName??null})};if(M)return e.jsx("circle",{cx:t,cy:r,r:3,fill:"hsl(var(--muted-foreground))",stroke:"hsl(var(--background))",strokeWidth:1.5});if(i&&!d)return e.jsxs("g",{onClick:C,style:{cursor:"pointer"},children:[e.jsx("circle",{cx:t,cy:r,r:16,fill:"transparent"}),e.jsx("circle",{cx:t,cy:r,r:6,fill:"hsl(var(--brand-500, 142 71% 45%))",stroke:"hsl(var(--background))",strokeWidth:2}),e.jsx("text",{x:t,y:r-14,textAnchor:"middle",fill:"hsl(var(--brand-500, 142 71% 45%))",fontSize:9,fontWeight:600,children:l("level.evaluatedByCoach")})]});if(h&&!d)return e.jsxs("g",{children:[e.jsx("circle",{cx:t,cy:r,r:6,fill:"#F59E0B",stroke:"hsl(var(--background))",strokeWidth:2}),e.jsx("text",{x:t,y:r-14,textAnchor:"middle",fill:"#F59E0B",fontSize:9,fontWeight:600,children:l("level.adjusted")})]});if(m&&!d)return e.jsxs("g",{children:[e.jsx("circle",{cx:t,cy:r,r:5,fill:"#8B5CF6",stroke:"hsl(var(--background))",strokeWidth:2}),e.jsx("text",{x:t,y:r-12,textAnchor:"middle",fill:"#8B5CF6",fontSize:9,fontWeight:600,children:l("level.peerNudged")})]});if(d){const N=i?"hsl(var(--brand-500, 142 71% 45%))":h?"#F59E0B":m?"#8B5CF6":"#B3F90E",P=i||h||m?"#ffffff":"#1a1a1a";return e.jsxs("g",{onClick:i?C:void 0,style:i?{cursor:"pointer"}:void 0,children:[e.jsx("circle",{cx:t,cy:r,r:22,fill:N,opacity:.15}),e.jsx("circle",{cx:t,cy:r,r:18,fill:"none",stroke:"hsl(var(--muted))",strokeWidth:3,opacity:.5}),e.jsx("circle",{cx:t,cy:r,r:16,fill:N,stroke:"hsl(var(--background))",strokeWidth:2}),e.jsx("text",{x:t,y:r+1,textAnchor:"middle",dominantBaseline:"middle",fill:P,fontSize:11,fontWeight:700,children:a.level.toFixed(2)}),i&&e.jsx("text",{x:t,y:r-24,textAnchor:"middle",fill:"hsl(var(--brand-500, 142 71% 45%))",fontSize:9,fontWeight:600,children:l("level.evaluatedByCoach")}),h&&!i&&e.jsx("text",{x:t,y:r-24,textAnchor:"middle",fill:"#F59E0B",fontSize:9,fontWeight:600,children:l("level.adjusted")}),m&&e.jsx("text",{x:t,y:r-24,textAnchor:"middle",fill:"#8B5CF6",fontSize:9,fontWeight:600,children:l("level.peerNudged")})]})}return e.jsx("circle",{cx:t,cy:r,r:4,fill:"hsl(var(--chart-1))",stroke:"hsl(var(--background))",strokeWidth:2})};return w?e.jsxs("div",{className:"rounded-2xl bg-card border border-border p-4",children:[e.jsx("h3",{className:"font-semibold mb-3",children:l("level.levelProgression")}),e.jsx("div",{className:"h-48 flex items-center justify-center",children:e.jsx("div",{className:"animate-pulse text-sm text-muted-foreground",children:l("common:state.loading")})})]}):n.length===0?e.jsxs("div",{className:"rounded-2xl bg-card border border-border p-4 space-y-3",children:[e.jsx("h3",{className:"font-semibold",children:l("level.levelProgression")}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mb-3",children:e.jsx(T,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("p",{className:"text-sm text-muted-foreground px-4",children:l("level.noHistoryOther")})]})]}):e.jsxs("div",{className:"rounded-2xl bg-card border border-border p-4 space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:l("level.levelProgression")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:te.map(s=>e.jsx("button",{onClick:()=>
1S(s.value),className:q("px-3 py-1.5 rounded-full text-xs sm:text-sm font-medium transition-colors",g===s.value?"bg-foreground text-background":"bg-muted text-muted-foreground hover:bg-muted/80"),children:l(s.labelKey)},s.value))}),(b||y)&&e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[b&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-[hsl(var(--brand-500,142_71%_45%))]"}),e.jsx("span",{children:l("level.evaluatedByCoach")})]}),y&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-[#F59E0B]"}),e.jsx("span",{children:l("level.adjusted")})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-[hsl(var(--chart-1))]"}),e.jsx("span",{children:l("level.match")})]})]}),e.jsx(H,{config:se,className:"h-48 w-full",children:e.jsx(Y,{width:"100%",height:"100%",children:e.jsxs(I,{data:W,margin:{top:30,right:16,left:10,bottom:4},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"publicLevelGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--chart-1))",stopOpacity:.3}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-1))",stopOpacity:.02})]})}),e.jsx(X,{dataKey:"date",axisLine:!1,tickLine:!1,tickFormatter:s=>G(new Date(s),"d/M"),tick:{fontSize:9,fill:"hsl(var(--muted-foreground))",opacity:.5},interval:"preserveStartEnd",minTickGap:50,height:18}),e.jsx(J,{domain:[L,z],orientation:"right",axisLine:!1,tickLine:!1,width:32,tickFormatter:s=>s.toFixed(2),tick:{fontSize:11,fill:"hsl(var(--muted-foreground))"},tickCount:3}),e.jsx(Q,{y:K,stroke:"hsl(var(--border))",strokeDasharray:"3 3",strokeOpacity:.5}),e.jsx(U,{type:"monotone",dataKey:"level",stroke:"hsl(var(--chart-1))",strokeWidth:2,fill:"url(#publicLevelGradient)",dot:e.jsx(D,{}),isAnimationActive:!1})]})})}),e.jsx(ee,{entry:F,onOpenChange:s=>!s&&p(null)})]})}export{ve 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.