PageSourceSearch

https://www.kingchess.io/assets/report-NTHvG1u1.js

js kingchess.io collected 2026-10-08 11:32:49 UTC 72,161 bytes, 1 lines download raw bytes

1import{j as e,B as i,F as f,T as a,L as k,g as _,V as W,r as $,c0 as R,h as B,aR as se,a3 as ve,U as Se,aM as Le,i as Fe,S as Ee,k as De,H as Ie,c1 as He,c2 as Ne,c3 as Y}from"./index-B5_v9qME.js";import{e as F,J as Pe,S as Ue,U as Ge,i as Ye}from"./index-BYNKCrL8.js";import{u as Ke,r as ge}from"./reports-C94gGlWl.js";import{L as Ve}from"./LoggedOutLanding-DYqslwaw.js";import{R as w}from"./Reveal-zXuPyitN.js";import{B as E}from"./BjornAvatar-BPImgMLz.js";import{C as U,L as v,a as K,T as V,S as q,b as qe,P as j,c as y,d as Xe}from"./ui-CdbZh8ZN.js";import{P as Qe}from"./PremiumUpgradeModal-DWUAzIRi.js";import{d as ue,c as Je,h as Ze,m as L,s as he,a as _e,q as le,P as et,p as tt,b as nt,l as xe,u as rt,T as ot,e as st,f as lt}from"./Trajectory-B4IXJQJ3.js";import{L as at}from"./link-sfU_niYv.js";import{S as z}from"./simple-grid-CqcVP1SC.js";import{a as it}from"./packs-CedROZ0j.js";import{b as ct}from"./billing-api-oCwfIcGA.js";import{C as dt}from"./container-B8o_vqjm.js";import{I as ke}from"./image-ByjVXa23.js";import"./dialog-9E3HaqSl.js";import"./render-strategy-DKlMToVI.js";import"./create-split-props-u5h9OPvL.js";import"./pricing-DzBFbOCI.js";import"./grid-CrLLMc3V.js";function ut(){return e.jsx(i,{...U,p:{base:4,md:5},children:e.jsxs(f,{align:"center",gap:3,wrap:{base:"wrap",md:"nowrap"},children:[e.jsx(E,{size:"36px",flexShrink:0}),e.jsxs(i,{minW:0,flex:"1",children:[e.jsx(a,{fontWeight:"bold",color:"report.fg",children:"Bjorn's read of all your games"}),e.jsx(a,{fontSize:"sm",color:"report.fg.muted",mt:.5,children:"Your clock against your opponents, your endgames by type, and a drill for each finding."})]}),e.jsx(k,{to:"/insights",children:e.jsx(_,{size:"sm",variant:"outline",borderColor:"report.border",color:"report.fg",_hover:{borderColor:"report.accent",color:"report.accent"},children:"Open Insights"})})]})})}const ae=t=>`${Math.round(t*100)}%`,ze=6,D=.05;function fe({label:t,hit:r,total:o,peer:n,unit:s}){if(o===0)return e.jsxs(a,{fontSize:"sm",color:"report.fg.muted",children:[t,": none reached yet."]});const u=r/o,c=o>=ze,l=n!=null&&n>0&&u/n>1.15,d=n!=null&&n>0&&u/n<.85,m=l?"good":d&&c?"bad":"neutral";return e.jsx(K,{label:t,value:e.jsxs(e.Fragment,{children:[r," of ",o," ",e.jsxs(V,{children:[s,n!=null?` (typical ${ae(n)})`:""]})]}),share:u,typicalShare:n,tone:m,verdict:n==null?"No peer figure yet":l?"More than typical ✓":d?c?"Fewer than typical":`Too few to judge · ${o} seen so far`:"About typical"})}function ht({outcomes:t,assumedRating:r=null}){const o=t.endgames,n=o>=ze,s=t.gap,u=!n||s==null?`Too few endgames to judge · ${o} seen so far`:s>=D?"Your endgame play adds to what you bring in.":s<=-D?"Your endgame play gives back what you bring in.":"Your endgames land about where the position says.",c=!n||s==null?"report.fg.muted":s>=D?"report.good":s<=-D?"report.bad":"report.fg.muted",l=t.peer;return e.jsxs(i,{mt:2,pt:4,borderTop:"1px solid",borderColor:"report.border",children:[e.jsx(v,{mb:2,children:"Once you are in one"}),e.jsx(a,{fontSize:"sm",fontWeight:"bold",color:c,children:u}),t.entry_es!=null&&t.score!=null&&e.jsxs(a,{fontSize:"sm",color:"report.fg.muted",mt:1,children:["You arrive at ",ae(t.entry_es)," winning chances and score"," ",ae(t.score)," across ",o," endgames."]}),e.jsxs(W,{align:"stretch",gap:0,mt:2,children:[e.jsx(fe,{label:"Winning endgames converted",hit:t.conversion.won,total:t.conversion.total,peer:l.conversion,unit:"won"}),e.jsx(fe,{label:"Lost endgames held",hit:t.holds.saved,total:t.holds.total,peer:l.holds,unit:"not lost"})]}),e.jsxs(a,{fontSize:"xs",color:"report.fg.muted",mt:1,children:["Endgame here means the queens are off with six or fewer pieces besides kings and pawns, or a queen ending with two pieces or fewer in all. Winning means 60% chances or better on arrival, lost means 40% or worse."," ",r!=null?`Chances are measured for players at an assumed ${r} level, not for an engine, until we see a rating.`:"Chances are measured for players at your level, not for an engine."]})]})}const $e=t=>`${Math.round(t*100)}%`;function pt({games:t}){const[r,o]=$.useState(8),n=t.map(h=>h.accuracy).filter(h=>h!=null);if(n.length<4)return e.jsx(a,{fontSize:"sm",color:"report.fg.muted",children:"Not enough scored games to draw yet."});const s=Math.max(0,Math.floor(Math.min(...n)/5)*5),c=Ze(n,s,100,r),l=L(n),d=he(n),m=Math.max(...c.map(h=>
1h.count),1);return e.jsxs(i,{children:[e.jsxs(f,{justify:"flex-end",align:"center",gap:2,mb:2,children:[e.jsxs(a,{fontSize:"xs",color:"report.fg.muted",children:[r," bins"]}),e.jsx("input",{type:"range",min:4,max:16,value:r,onChange:h=>o(Number(h.target.value)),style:{accentColor:R("accent"),width:120},"aria-label":"Number of bins"})]}),e.jsx(f,{align:"flex-end",gap:"3px",h:"160px",children:c.map((h,p)=>{const x=h.to>l-d&&h.from<l+d;return e.jsx(i,{flex:"1",minW:0,h:"100%",display:"flex",alignItems:"flex-end",children:e.jsx(i,{w:"100%",h:`${h.count/m*100}%`,minH:h.count?"3px":0,bg:x?"report.accent":"report.chart5",borderTopRadius:"4px",transition:"height 500ms ease",title:`${h.from.toFixed(0)}–${h.to.toFixed(0)}%: ${h.count} ${h.count===1?"game":"games"}`,"data-index":p})},h.from)})}),e.jsx(f,{gap:"3px",mt:1,children:c.map((h,p)=>e.jsx(a,{flex:"1",minW:0,fontSize:"10px",color:"report.fg.muted",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",children:r>10&&p%2===1?"":`${h.from.toFixed(0)}`},h.from))}),e.jsxs(a,{mt:2,fontSize:"xs",color:"report.fg.muted",children:["Highlighted bars sit inside one standard deviation (±",d.toFixed(1),") of your mean, ",l.toFixed(1),"%. Bins start at the labelled accuracy."]})]})}function mt({games:t}){return e.jsx(i,{display:"flex",flexDirection:"column",gap:4,children:["white","black"].map(r=>{const o=t.filter(d=>d.user_color===r),n=o.filter(d=>d.result==="win").length,s=o.filter(d=>d.result==="draw").length,u=o.filter(d=>d.result==="loss").length,c=n+s+u,l=n+s*.5;return e.jsxs(i,{children:[e.jsxs(f,{align:"baseline",justify:"space-between",fontSize:"sm",children:[e.jsx(a,{fontWeight:"medium",color:"report.fg",textTransform:"capitalize",children:r}),e.jsxs(a,{color:"report.fg.muted",children:[c?$e(l/c):"—"," score · ",c," ",c===1?"game":"games"]})]}),e.jsx(i,{mt:2,children:e.jsx(q,{segments:[{label:"W",value:n,color:"report.good"},{label:"D",value:s,color:"report.neutral"},{label:"L",value:u,color:"report.bad"}]})})]},r)})})}const X=640,Q=240,C={top:12,right:16,bottom:28,left:40};function be(t,r,o){const s=(r-t||1)/o,u=10**Math.floor(Math.log10(s)),c=[1,2,5,10].map(d=>d*u).find(d=>d>=s)??u,l=[];for(let d=Math.ceil(t/c)*c;d<=r;d+=c)l.push(d);return l}function gt({games:t}){const r=t.filter(g=>g.opponent_rating!=null&&g.accuracy!=null);if(r.length<4)return e.jsx(a,{fontSize:"sm",color:"report.fg.muted",children:"Not enough rated, scored games to draw yet."});const o=r.map(g=>g.opponent_rating),n=r.map(g=>g.accuracy),s=Math.min(...o)-20,u=Math.max(...o)+20,c=Math.max(0,Math.floor(Math.min(...n)/5)*5-5),l=100,d=X-C.left-C.right,m=Q-C.top-C.bottom,h=g=>C.left+(g-s)/(u-s)*d,p=g=>C.top+m-(g-c)/(l-c)*m,x=Je(o,n),b=R("border"),S=R("fg.muted"),M=[...new Set(r.map(g=>g.platform))];return e.jsxs(i,{children:[e.jsxs("svg",{viewBox:`0 0 ${X} ${Q}`,width:"100%",role:"img","aria-label":"Opponent rating against accuracy",children:[be(c,l,4).map(g=>e.jsxs("g",{children:[e.jsx("line",{x1:C.left,x2:X-C.right,y1:p(g),y2:p(g),stroke:b}),e.jsx("text",{x:C.left-8,y:p(g)+4,fontSize:11,textAnchor:"end",fill:S,children:g})]},`y${g}`)),be(s,u,6).map(g=>e.jsxs("g",{children:[e.jsx("line",{x1:h(g),x2:h(g),y1:C.top,y2:C.top+m,stroke:b}),e.jsx("text",{x:h(g),y:Q-8,fontSize:11,textAnchor:"middle",fill:S,children:g})]},`x${g}`)),r.map(g=>e.jsx("circle",{cx:h(g.opponent_rating),cy:p(g.accuracy),r:4+Math.min(6,g.blunders)*1.6,fill:R(g.result==="win"?"good":g.result==="draw"?"neutral":"bad"),fillOpacity:.75,children:e.jsx("title",{children:`${g.opponent??"Unknown"} (${g.opponent_rating}): ${g.accuracy.toFixed(1)}%, ${g.blunders} ${g.blunders===1?"blunder":"blunders"}, ${g.result}`})},`${g.platform}-${g.game_id}`))]}),e.jsxs(a,{mt:1,fontSize:"xs",color:"report.fg.muted",children:["Bubble size is blunders in that game · green win, grey draw, coral loss · r = ",x.toFixed(2),M.length>1?` · ratings are each platform's own (${M.join(", ")})`:""]})]})}function xt({games:t}){const r=[{name:"Accuracy (%)",data:t.map(n=>n.accuracy).filter(n=>n!=null),digits:1},{name:"Blunders per game",data:t.map(n=>n.blunders),digits:1},{name:"Game length (moves)",data:t.map(n=>n.move_count).filter(n=>n!=null&&n>0),digits:0},{name:"Opponent rating",data:t.map(n=>n.opponent_rating).filter(n=>n!=null),digits:0}],o=["n","Mean","Median","σ","Min","Q1","Q3","Max"];return e.jsx(i,{overflowX:"auto",children:e.jsxs(i,{as:"table",w:"100%",minW:"560px",fontSize:"sm",borderCollapse:"collapse",children:[e.jsx(i,{as:"thead",children:e.jsxs(i,{as:"tr",fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.14em",color:"report.fg.muted",children:[e.jsx(i,{as:"th",textAlign:"left",fontWeight:"normal",pb:2,children:"Measure"}),o.map(n=>e.jsx(i,{as:"th",textAlign:"right",fontWeight:"normal",pb:2,pl:3,textTransform:n==="σ"?"none":void 0,children:n},n))]})}),e.jsx(i,{as:"tbody",children:r.map(n=>{const s=n.data,u=s.length?[s.length,L(s),_e(s),he(s),Math.min(...s),le(s,.25),le(s,.75),Math.max(...s)]:null;return e.jsxs(i,{as:"tr",borderTopWidth:"1px",borderColor:"report.border",_hover:{bg:"report.secondary/60"},children:[e.jsx(i,{as:"td",py:2.5,fontWeight:"medium",color:"report.fg",whiteSpace:"nowrap",children:n.name}),u?u.map((c,l)=>e.jsx(i,{as:"td",py:2.5,pl:3,textAlign:"right",color:"report.fg",children:l===0?c:c.toFixed(n.digits)},o[l])):o.map(c=>e.jsx(i,{as:"td",py:2.5,pl:3,textAlign:"right",color:"report.fg.muted",children:"—"},c))]},n.name)})})]})})}const ft=[{label:"00–04",from:0},{label:"04–08",from:4},{label:"08–12",from:8},{label:"12–16",from:12},{label:"16–20",from:16},{label:"20–24",from:20}];function bt({games:t,metric:r}){const o=$.useMemo(()=>ft.map(l=>{const d=t.filter(x=>{if(!x.game_date)return!1;
1const b=new Date(ue(x)).getHours();return b>=l.from&&b<l.from+4}),m=d.length,h=d.reduce((x,b)=>x+(b.result==="win"?1:b.result==="draw"?.5:0),0),p=d.reduce((x,b)=>x+b.blunders,0);return{...l,n:m,score:m?h/m:null,blundersPerGame:m?p/m:null}}),[t]),n=l=>r==="games"?l.n:r==="score"?l.score:l.blundersPerGame,s=l=>r!=="games"&&l.n<5,u=Math.max(...o.map(l=>s(l)?0:n(l)??0),1e-4),c=l=>r==="games"?`${l}`:r==="score"?$e(l):l.toFixed(1);return e.jsxs(i,{children:[e.jsx(f,{align:"flex-end",gap:3,h:"160px",children:o.map(l=>{const d=s(l)?null:n(l);return e.jsxs(i,{flex:"1",minW:0,h:"100%",display:"flex",flexDirection:"column",justifyContent:"flex-end",alignItems:"center",children:[e.jsx(a,{fontSize:"11px",color:"report.fg.muted",mb:1,children:d==null?l.n?`${l.n} g.`:"":c(d)}),e.jsx(i,{w:"100%",h:d==null?"3px":`${Math.max(2,d/u*100)}%`,bg:d==null?"report.track":"report.accent",borderTopRadius:"6px",transition:"height 500ms ease",title:`${l.label}: ${l.n} ${l.n===1?"game":"games"}`})]},l.label)})}),e.jsx(f,{gap:3,mt:1,children:o.map(l=>e.jsx(a,{flex:"1",minW:0,fontSize:"11px",color:"report.fg.muted",textAlign:"center",children:l.label},l.label))}),e.jsx(a,{mt:2,fontSize:"xs",color:"report.fg.muted",children:"By the hour the game ended, in your time zone. Buckets with fewer than five games show the count instead of a rate."})]})}function jt(t="blunders"){const[r,o]=$.useState(t);return{metric:r,setMetric:o}}function yt({controls:t}){return e.jsx(qe,{options:["games","score","blunders"],value:t.metric,onChange:t.setMetric})}function wt({games:t}){const r=[{label:"Good",count:t.reduce((n,s)=>n+s.good_moves,0),color:"report.good"},{label:"Inaccuracies",count:t.reduce((n,s)=>n+s.inaccuracies,0),color:"report.neutral"},{label:"Mistakes",count:t.reduce((n,s)=>n+s.mistakes,0),color:"report.warn"},{label:"Blunders",count:t.reduce((n,s)=>n+s.blunders,0),color:"report.bad"}],o=r.reduce((n,s)=>n+s.count,0);return o?e.jsxs(i,{children:[e.jsx(i,{display:"flex",flexDirection:"column",gap:2.5,children:r.map(n=>e.jsxs(f,{align:"center",gap:3,children:[e.jsx(a,{w:"96px",flexShrink:0,fontSize:"sm",color:"report.fg.muted",children:n.label}),e.jsx(i,{flex:"1",h:"10px",overflow:"hidden",borderRadius:"full",bg:"report.track",children:e.jsx(i,{h:"100%",borderRadius:"full",bg:n.color,w:`${n.count/o*100}%`,transition:"width 500ms ease"})}),e.jsxs(a,{w:"112px",flexShrink:0,textAlign:"right",fontSize:"sm",color:"report.fg",children:[n.count.toLocaleString()," ",e.jsxs(a,{as:"span",color:"report.fg.muted",children:[(n.count/o*100).toFixed(1),"%"]})]})]},n.label))}),e.jsx(i,{mt:3,children:e.jsxs(v,{children:[o.toLocaleString()," of your moves scored"]})})]}):e.jsx(a,{fontSize:"sm",color:"report.fg.muted",children:"No scored moves yet."})}const vt={win:"report.good",draw:"report.neutral",loss:"report.bad"},St={win:"W",draw:"D",loss:"L"};function je(t,r){switch(r){case"date":return ue(t);case"opponent_rating":return t.opponent_rating??-1;case"accuracy":return t.accuracy??-1;case"blunders":return t.blunders;case"move_count":return t.move_count??-1}}const _t=t=>t.game_date?new Date(ue(t)).toLocaleDateString(void 0,{month:"short",day:"numeric"}):"—";function kt({games:t,classColor:r,classLabel:o}){const[n,s]=$.useState("date"),[u,c]=$.useState(!0),l=$.useMemo(()=>{const p=[...t];return p.sort((x,b)=>{const S=je(x,n)-je(b,n);return u?-S:S}),p},[t,n,u]),d=p=>{p===n?c(x=>!x):(s(p),c(!0))},m=({children:p,sort:x,align:b="left",w:S})=>e.jsxs(i,{as:"th",textAlign:b,fontWeight:"normal",pb:2,pr:3,w:S,whiteSpace:"nowrap",cursor:x?"pointer":"default",color:x===n?"report.fg":"report.fg.muted",_hover:x?{color:"report.fg"}:void 0,onClick:x?()=>d(x):void 0,"aria-sort":x===n?u?"descending":"ascending":void 0,children:[p,x===n?u?" ↓":" ↑":""]}),h=({children:p,align:x="left",muted:b=!1,truncate:S=!1})=>e.jsx(i,{as:"td",py:2.5,pr:3,textAlign:x,color:b?"report.fg.muted":"report.fg",fontSize:b?"xs":"sm",whiteSpace:"nowrap",maxW:S?"220px":void 0,overflow:S?"hidden":void 0,textOverflow:S?"ellipsis":void 0,children:p});return e.jsx(i,{overflowX:"auto",mt:4,children:e.jsxs(i,{as:"table",w:"100%",minW:"760px",fontSize:"sm",borderCollapse:"collapse",children:[e.jsx(i,{as:"thead",children:e.jsxs(i,{as:"tr",fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.14em",color:"report.fg.muted",children:[e.jsx(m,{children:"Opponent"}),e.jsx(m,{w:"56px",children:"Side"}),e.jsx(m,{w:"56px",children:"Result"}),e.jsx(m,{sort:"opponent_rating",align:"right",children:"Opp. rating"}),e.jsx(m,{sort:"accuracy",align:"right",children:"Accuracy"}),e.jsx(m,{sort:"blunders",align:"right",children:"Blunders"}),e.jsx(m,{sort:"move_count",align:"right",children:"Moves"}),e.jsx(m,{children:"Opening"}),e.jsx(m,{sort:"date",align:"right",children:"Date"}),e.jsx(m,{w:"64px",children:""})]})}),e.jsx(i,{as:"tbody",children:l.map(p=>e.jsxs(i,{as:"tr",borderTopWidth:"1px",borderColor:"report.border",transition:"background 0.12s",_hover:{bg:"report.secondary/60"},children:[e.jsx(h,{children:e.jsxs(f,{align:"center",gap:2,minW:0,children:[e.jsx(i,{boxSize:"8px",borderRadius:"sm",bg:r[p.class],flexShrink:0,title:o[p.class]}),p.url?e.jsx(at,{href:p.url,target:"_blank",rel:"noopener noreferrer",fontWeight:"medium",color:"report.fg",_hover:{textDecoration:"underline"},truncate:!0,children:p.opponent??"Unknown"}):e.jsx(a,{fontWeight:"medium",truncate:!0,children:p.opponent??"Unknown"})]})}),e.jsx(h,{muted:!0,children:e.jsxs(f,{align:"center",gap:1.5,children:[e.jsx(i,{boxSize:"10px",borderRadius:"2px",bg:p.user_color==="white"?"#F0F2F4":"#0B0D11",border:"1px solid",borderColor:"report.border"}),p.user_color==="white"?"White":"Black"]})}),e.jsx(h,{children:e.jsx(a,{as:"span",fontWeight:"semibold",color:vt[p.result]??"report.fg",children:St[p.result]??p.result})}),e.jsx(h,{align:"right",muted:p.opponent_rating==null,children:p.opponent_rating??"—"}),e.jsx(h,{align:"right",muted:p.accuracy==null,children:p.accuracy!=null?`${p.accuracy.toFixed(1)}%`:"—"}),e.jsx(h,{align:"right",children:e.jsx(a,{as:"span",color:p.blunders>0?"report.fg":"report.fg.muted",children:p.blunders})}),e.jsx(h,{align:"right",muted:p.move_count==null,children:p.move_count??"—"}),e.jsx(h,{muted:!0,truncate:!0,children:p.opening_name??"—"}),e.jsx(h,{align:"right",muted:!0,children:_t(p)}),e.jsx(h,{children:e.jsx(k,{to:"/game-review/$platform/$gameId",params:{platform:p.platform,gameId:p.game_id},children:e.jsx(a,{as:"span",fontSize:"xs",fontWeight:"semibold",color:"report.accent",_hover:{textDecoration:"underline"},children:"Review →"})})})]},`${p.platform}-${p.game_id}`))})]})})}const zt={blunders:{title:"Every blunder, with the game and the drill",line:"What went wrong, how it happens, which piece, what time of day, and the replay or review for each one."},games:{title:"Every game, inspected",line:"Accuracy, opponents, colours, streaks, how you compare on five skills, and the full table with a review link per game."},skills:{title:"Your five skills against your level",line:"Missed threats, discipline, endgames and openings against players at your rating, with what to drill for each."}};function O({rows:t}){return e.jsx(i,{children:t.map(([r,o])=>e.jsxs(f,{align:"center",gap:4,py:2,children:[e.jsx(a,{fontSize:"sm",color:"report.fg",w:"40%",children:r}),e.jsx(i,{flex:"1",h:"8px",bg:"report.track",borderRadius:"full",children:e.jsx(i,{h:"100%",w:`${Math.round(o*100)}%`,bg:"report.primary",borderRadius:"full"})}),e.jsx(a,{fontSize:"sm",color:"report.fg",w:"24px",textAlign:"right",children:Math.round(o*20)})]},r))})}function $t(){return e.jsxs(e.Fragment,{children:[e.jsxs(z,{columns:{base:2,lg:4},gap:4,children:[e.jsx(y,{label:"Total blunders",value:"41",sub:"across 50 analyzed games"}),e.jsx(y,{label:"Blunders per game",value:"2.4",sub:"typical 2.6 for 1400-1600",tone:"good"}),e.jsx(y,{label:"Rating points sacrificed",value:"312",sub:"typical 512 over these games",tone:"good"}),e.jsx(y,{label:"Winning positions thrown",value:"3",sub:"of 22 losses",tone:"warn"})]}),e.jsxs(j,{title:"Where the blunders come from",children:[e.jsx(v,{mb:2,children:"When they happen"}),e.jsx(q,{segments:[{label:"Opening",value:14,color:"#5B6CFF"},{label:"Middlegame",value:19,color:"#8B7CFF"},{label:"Endgame",value:8,color:"#FF7A93"}]}),e.jsxs(i,{mt:5,children:[e.jsx(v,{mb:2,children:"What went wrong"}),e.jsx(O,{rows:[["Hung a piece",.6],["Walked into a fork",.35],["Losing trade",.3],["Gave back a winning position",.25],["Collapsed from equality",.5]]})]})]}),e.jsxs(z,{columns:{base:1,md:2},gap:4,children:[e.jsx(j,{title:"Pieces by blunder rate",children:e.jsx(O,{rows:[["Queen",.7],["Knight",.55],["Bishop",.5],["Rook",.4],["King",.3],["Pawn",.2]]})}),e.jsx(j,{title:"Move quality",children:e.jsx(O,{rows:[["Good",.9],["Inaccuracies",.3],["Mistakes",.2],["Blunders",.1]]})})]})]})}function Ct(){return e.jsxs(e.Fragment,{children:[e.jsxs(z,{columns:{base:2,lg:4},gap:4,children:[e.jsx(y,{label:"Games analyzed",value:"50",sub:"your last 50 at most"}),e.jsx(y,{label:"Average accuracy",value:"79.2%",sub:"over 50 scored games"}),e.jsx(y,{label:"Blunders per game",value:"2.4",sub:"typical 2.6 for 1400-1600",tone:"good"}),e.jsx(y,{label:"Score",value:"47%",sub:"21W · 5D · 24L · draws count half"})]}),e.jsx(j,{title:"How you compare to 1400-1600",children:e.jsx(O,{rows:[["Blunders",.45],["Missed threats",.7],["Endgames",.35],["Discipline",.5],["Openings",.6]]})}),e.jsx(j,{title:"Every game, inspected",children:[["Opponent one","W","1512","84.1%","1"],["Opponent two","L","1588","71.4%","3"],["Opponent three","D","1490","88.0%","0"],["Opponent four","L","1603","76.2%","2"],["Opponent five","W","1477","90.3%","0"],["Opponent six","L","1621","69.8%","4"]].map(t=>e.jsxs(f,{gap:6,py:2,borderBottom:"1px solid",borderColor:"report.border",fontSize:"sm",color:"report.fg",children:[e.jsx(a,{flex:"2",children:t[0]}),e.jsx(a,{flex:"1",children:t[1]}),e.jsx(a,{flex:"1",children:t[2]}),e.jsx(a,{flex:"1",children:t[3]}),e.jsx(a,{flex:"1",children:t[4]})]},t[0]))})]})}function Tt(){const t=(r,o,n,s)=>e.jsx(K,{label:r,value:e.jsxs(e.Fragment,{children:[o," ",e.jsx(V,{children:"(typical 1 in 3)"})]}),share:n,typicalShare:.45,tone:n>.5?"bad":"good",verdict:s});return e.jsxs(z,{columns:{base:1,md:2},gap:4,alignItems:"stretch",children:[e.jsx(j,{title:"Missed threats",children:t("Blunders that walk into tactics","1 in 2 games",.7,"More often than typical")}),e.jsx(j,{title:"Discipline",children:t("Blunders played rushed or in time trouble","24% of your blunders",.3,"A smaller share than typical")}),e.jsxs(j,{title:"Endgames",children:[t("Blunders in the endgame","1 in 6 games",.35,"Less often than typical"),e.jsxs(i,{mt:5,children:[e.jsx(v,{mb:2,children:"Once you are in one"}),e.jsx(O,{rows:[["Winning endgames converted",.8],["Lost endgames held",.2]]})]})]}),e.jsxs(j,{title:"Openings",children:[t("Blunders in the opening","1 in 3 games",.55,"About typical"),e.jsx(i,{mt:5,children:e.jsx(O,{rows:[["Italian Game",.7],["Sicilian Defense",.5],["Queen's Gambit Declined",.3]]})})]})]})}const Wt={blunders:$t,games:Ct,skills:Tt};function J({tab:t,onUnlock:r}){const o=Wt[t],n=zt[t];return e.jsxs(i,{position:"relative","data-testid":`locked-${t}`,children:[e.jsx(f,{direction:"column",gap:4,"aria-hidden":!0,pointerEvents:"none",userSelect:"none",filter:"blur(7px)",opacity:.85,minH:"640px",children:e.jsx(o,{})}),e.jsxs(f,{position:"absolute",top:{base:8,md:16}
1,left:"50%",transform:"translateX(-50%)",w:{base:"calc(100% - 16px)",md:"560px"},direction:"column",align:"center",textAlign:"center",gap:3,p:{base:5,md:7},borderWidth:"1px",borderColor:"report.border",borderRadius:"xl",bg:"report.card",boxShadow:"0 18px 48px rgba(0,0,0,0.35)",children:[e.jsx(E,{size:"52px"}),e.jsxs(B,{gap:2,color:"report.fg.muted",children:[e.jsx(F,{size:14}),e.jsx(v,{children:"Premium"})]}),e.jsx(a,{fontSize:"xl",fontWeight:"bold",color:"report.fg",lineHeight:"short",children:n.title}),e.jsx(a,{fontSize:"sm",color:"report.fg.muted",lineHeight:"tall",children:n.line}),e.jsx(et,{onClick:r,size:"md",mt:1,px:6,children:"Unlock Premium"}),e.jsx(a,{fontSize:"xs",color:"report.fg.muted",children:"The Overview stays free."})]})]})}const Ce=404,Rt=292,ie=Ce/2,ce=148,Bt=100,At=[25,50,75,100];function P(t,r,o){const n=-Math.PI/2+t/r*Math.PI*2,s=Math.max(0,Math.min(100,o))/100*Bt;return[ie+s*Math.cos(n),ce+s*Math.sin(n)]}const Z=t=>t.map((r,o)=>P(o,t.length,r).join(",")).join(" ");function Mt({axes:t,peerScore:r}){const o=t.length;if(o<3)return null;const n=t.map(m=>m.score??r),s=t.map(()=>r),u=R("fg"),c=R("fg.muted"),l=R("border"),d=R("accent");return e.jsxs(i,{maxW:"360px",mx:"auto",children:[e.jsxs("svg",{viewBox:`0 0 ${Ce} ${Rt}`,width:"100%",role:"img","aria-label":t.map(m=>`${m.label}: ${m.score??"no data"}`).join(", "),children:[At.map(m=>e.jsx("polygon",{points:Z(t.map(()=>m)),fill:"none",stroke:l,strokeWidth:1},m)),t.map((m,h)=>{const[p,x]=P(h,o,100);return e.jsx("line",{x1:ie,y1:ce,x2:p,y2:x,stroke:l,strokeWidth:1},m.key)}),e.jsx("polygon",{points:Z(s),fill:c,fillOpacity:.12,stroke:c,strokeWidth:1.5,strokeDasharray:"4 3"}),e.jsx("polygon",{points:Z(n),fill:d,fillOpacity:.35,stroke:d,strokeWidth:2,strokeLinejoin:"round"}),t.map((m,h)=>{const[p,x]=P(h,o,n[h]);return e.jsx("circle",{cx:p,cy:x,r:3.5,fill:m.score===null?c:d,stroke:R("card"),strokeWidth:1.5,children:e.jsxs("title",{children:[m.label,": ",m.score??"no data"," (typical ",r,")"]})},m.key)}),t.map((m,h)=>{const[p,x]=P(h,o,100),b=p-ie,S=x-ce,M=p+Math.sign(Math.round(b))*10,g=x+(S<-1?-10:S>1?16:4),Oe=Math.abs(b)<1?"middle":b>0?"start":"end";return e.jsxs("text",{x:M,y:g,fontSize:12,textAnchor:Oe,fill:m.score===null?c:u,children:[m.label,m.score===null?" · no data":""]},m.key)})]}),e.jsx(a,{fontSize:"xs",color:"report.fg.muted",textAlign:"center",mt:1,children:"Higher is better. The dashed ring is typical for your band."})]})}const Te=Se,We=ve,Ot={win:"won",loss:"lost",draw:"drew"},Lt={hangingPiece:"hanging pieces",fork:"forks",pin:"pins",skewer:"skewers",discoveredAttack:"discovered attacks",deflection:"deflections",trappedPiece:"trapped pieces",mateIn1:"mates"},Re="/report?tab=blunders";function Ft({start:t,themes:r,onOpen:o}){var c;const n=t.kind==="theme"?r.themes.find(l=>
1l.id===t.id)??null:t.kind==="cause"?((c=r.causes)==null?void 0:c.rows.find(l=>l.id===t.id))??null:null,s=`${Math.round(t.share*100)}%`,u=t.kind==="slips"?`${s} of the winning chances you gave away`:`${t.count??0} blunders · ${s} of what your mistakes cost`;return e.jsx(i,{borderWidth:"1px",borderColor:"report.border",borderRadius:"xl",bg:"report.card",p:{base:4,md:5},children:e.jsxs(f,{align:"flex-start",gap:3,children:[e.jsx(E,{size:"36px",flexShrink:0}),e.jsxs(i,{minW:0,flex:"1",children:[e.jsx(v,{mb:1,children:t.dominant?"Start here":"Start here · no single pattern dominates"}),e.jsxs(a,{fontSize:"lg",fontWeight:"bold",color:"report.fg",lineHeight:"short",children:[t.label,e.jsxs(a,{as:"span",fontWeight:"normal",color:"report.fg.muted",fontSize:"md",children:[" ",u]})]}),e.jsx(a,{fontSize:"sm",color:"report.fg",mt:2,lineHeight:"tall",children:t.advice}),n?e.jsx(Be,{row:n}):e.jsx(Et,{kind:t.kind,id:t.id}),o&&e.jsx(_,{size:"xs",variant:"ghost",mt:2,px:0,color:"report.fg.muted",_hover:{color:"report.accent",bg:"transparent"},onClick:o,children:"Every habit, with the games →"})]})]})})}function Et({kind:t,id:r}){const o=(s,u,c)=>e.jsx(k,{to:u,search:c,children:e.jsx(_,{size:"xs",bg:Te,color:"white",_hover:{bg:We},children:s})}),n=(s,u,c)=>e.jsx(k,{to:u,search:c,children:e.jsx(_,{size:"xs",variant:"outline",borderColor:"report.border",color:"report.fg",_hover:{borderColor:"report.accent",color:"report.accent"},children:s})});return e.jsxs(B,{gap:2,mt:2,flexWrap:"wrap",children:[t==="slips"&&o("Open Trade School","/trade-school"),t==="slips"&&n("Find the games","/report",{tab:"games"}),t==="phase"&&r==="endgame"&&o("Drill endgame defense","/endgame-defense"),t==="phase"&&r==="opening"&&o("See your openings","/report",{tab:"skills"}),t==="phase"&&r==="middlegame"&&o("Build a Woodpecker set","/woodpecker",{source:"my_games"}),t==="phase"&&n("Every blunder, with the games","/report",{tab:"blunders"}),t==="rushed"&&o("See your discipline numbers","/report",{tab:"skills"}),t==="rushed"&&n("Build a Woodpecker set","/woodpecker",{source:"my_games"})]})}function Dt({themes:t}){const[r,o]=$.useState(null),n=t.other?[...t.themes,t.other]:t.themes,s=t.unnamed?[...t.situations,t.unnamed]:t.situations,u=[...n,...s].reduce((l,d)=>Math.max(l,d.count),0),c=l=>o(d=>d===l?null:l);return e.jsxs(i,{mt:5,children:[e.jsx(i,{mb:5,children:e.jsx(k,{to:"/report",search:{tab:"overview"},children:e.jsx(a,{fontSize:"sm",fontWeight:"semibold",color:"report.accent",children:"Where to start is on the Overview →"})})}),t.causes&&t.causes.rows.length>0&&e.jsx(It,{causes:t.causes,open:r,onToggle:c}),e.jsx(v,{mb:2,children:"What went wrong"}),n.length>0?e.jsx(W,{gap:2,align:"stretch",children:n.map(l=>e.jsx(de,{row:l,max:u,open:r===l.id,onToggle:()=>c(l.id),muted:l.id==="other_tactic"},l.id))}):e.jsxs(a,{fontSize:"sm",color:"report.fg.muted",children:["No single tactic shows up ",t.min_count," times yet. That takes a few more games."]}),t.untagged>0&&e.jsxs(i,{mt:4,children:[e.jsxs(a,{fontSize:"sm",color:"report.fg.muted",lineHeight:"tall",children:[e.jsxs(a,{as:"span",color:"report.fg",fontWeight:"semibold",children:[t.untagged," of ",t.total]})," ","blunders weren't a named tactic. The eval dropped with no fork, pin or hanging piece to point at."]}),s.length>0&&e.jsx(W,{gap:2,align:"stretch",mt:2,children:s.map(l=>e.jsx(de,{row:l,max:u,open:r===l.id,onToggle:()=>c(l.id),muted:!0},l.id))})]})]})}function It({causes:t,open:r,onToggle:o}){const n=t.rows.reduce((s,u)=>Math.max(s,u.count),0);return e.jsxs(i,{mb:5,children:[e.jsx(v,{mb:2,children:"How they happen"}),t.verdict&&e.jsxs(f,{align:"flex-start",gap:2,mb:2,children:[e.jsx(E,{size:"22px",flexShrink:0,mt:"2px"}),e.jsx(a,{fontSize:"sm",color:"report.fg",lineHeight:"tall",children:t.verdict})]}),e.jsx(W,{gap:2,align:"stretch",children:t.rows.map(s=>e.jsx(de,{row:s,max:n,open:r===s.id,onToggle:()=>o(s.id)},s.id))}),t.unknown>0&&e.jsxs(a,{fontSize:"xs",color:"report.fg.muted",mt:2,lineHeight:"tall",children:[t.unknown," couldn't be told apart: no stored reply, or one that proves nothing in a single move."]})]})}function de({row:t,max:r,open:o,onToggle:n,muted:s}){const u=t.examples.length>0||t.advice.length>0;return e.jsxs(i,{children:[e.jsxs(f,{align:"center",gap:3,children:[e.jsx(i,{as:"button",onClick:u?n:void 0,"aria-expanded":o,fontSize:"sm",color:s?"report.fg.muted":"report.fg",w:{base:"45%",md:"30%"},flexShrink:0,textAlign:"left",cursor:u?"pointer":"default",_hover:u?{color:"report.accent"}:void 0,children:t.label}),e.jsx(i,{flex:"1",bg:"report.track",borderRadius:"full",h:"8px",overflow:"hidden",children:e.jsx(i,{w:`${r?t.count/r*100:0}%`,h:"100%",bg:s?"report.fg.muted":"report.accent",opacity:s?.6:1,borderRadius:"full",transition:"width 500ms ease"})}),e.jsx(a,{fontSize:"sm",fontWeight:"semibold",color:"report.fg",w:"28px",textAlign:"right",children:t.count})]}),o&&e.jsxs(i,{mt:2,ml:{base:0,md:"30%"}
1,pl:3,borderLeft:"2px solid",borderColor:"report.border",children:[t.advice&&e.jsxs(f,{align:"flex-start",gap:2,mb:2,children:[e.jsx(E,{size:"22px",flexShrink:0,mt:"2px"}),e.jsx(a,{fontSize:"sm",color:"report.fg",lineHeight:"tall",children:t.advice})]}),t.examples.map((c,l)=>e.jsx(Ht,{ex:c},c.puzzle_id??l)),e.jsx(Be,{row:t})]})]})}function Be({row:t}){const r=t.puzzle_ids.length,o=it({onSuccess:s=>{se.create(s.added===0?{title:"Already in your drills",description:`You already have all available ${s.theme} puzzles.`,type:"info"}:{title:`${s.added} puzzles added`,description:"Open Training to start drilling them.",type:"success"})},onError:s=>{se.create({title:"Couldn't add the pack",description:s.message,type:"error"})}}),n=t.pack?Lt[t.pack]:null;return e.jsxs(B,{gap:2,mt:2,flexWrap:"wrap",children:[r>0&&e.jsx(k,{to:"/puzzle/$id",params:{id:String(t.puzzle_ids[0])},search:{sequence:t.puzzle_ids.join(","),index:0,returnTo:Re,weakness:t.label},children:e.jsx(_,{size:"xs",bg:Te,color:"white",_hover:{bg:We},children:r<t.count?`Review the latest ${r}`:`Review all ${r}`})}),t.count>0&&e.jsx(k,{to:"/woodpecker",search:{source:"my_games",habit:t.id},children:e.jsx(_,{size:"xs",variant:"outline",borderColor:"report.border",color:"report.fg",_hover:{borderColor:"report.accent",color:"report.accent"},children:"Build a Woodpecker set"})}),t.pack&&n&&e.jsxs(_,{size:"xs",variant:"outline",borderColor:"report.border",color:"report.fg",_hover:{borderColor:"report.accent",color:"report.accent"},onClick:()=>o.mutate({theme:t.pack,count:30}),disabled:o.isPending,children:["Practice spotting ",n]})]})}function Ht({ex:t}){const r=t.game_date?new Date(t.game_date).toLocaleDateString(void 0,{month:"short",day:"numeric"}):null,o=t.move_number!=null?Math.ceil(t.move_number/2):null,n=[t.opponent?`vs ${t.opponent}`:"vs opponent",r,t.result?Ot[t.result]??t.result:null,o!=null?`move ${o}`:null].filter(Boolean);return e.jsxs(f,{py:1.5,align:"center",justify:"space-between",gap:3,borderBottom:"1px solid",borderColor:"report.border",children:[e.jsx(a,{fontSize:"sm",color:"report.fg.muted",minW:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:n.join(", ")}),e.jsxs(B,{gap:3,flexShrink:0,children:[t.puzzle_id!=null&&e.jsx(k,{to:"/puzzle/$id",params:{id:String(t.puzzle_id)},search:{sequence:String(t.puzzle_id),index:0,returnTo:Re},children:e.jsx(a,{as:"span",fontSize:"xs",fontWeight:"semibold",color:"report.accent",children:"Replay"})}),t.puzzle_id==null&&t.platform&&t.game_id&&t.ply!=null&&e.jsx(k,{to:"/game-review/$platform/$gameId",params:{platform:t.platform,gameId:t.game_id},search:{ply:t.ply+1},children:e.jsx(a,{as:"span",fontSize:"xs",fontWeight:"semibold",color:"report.accent",children:"Review"})}),t.game_url&&e.jsx("a",{href:t.game_url,target:"_blank",rel:"noreferrer",children:e.jsx(a,{as:"span",fontSize:"xs",color:"report.fg.muted",children:"View game"})})]})]})}const Nt=De,A=Se,pe=ve,ee={spotless:"report.good",clean:"report.good/55",flawed:"report.warn",thrown:"report.bad",unscored:"report.neutral"},te={spotless:"Spotless",clean:"Clean",flawed:"Flawed",thrown:"Thrown",unscored:"Not analyzed"},Pt={spotless:"not a single slip",clean:"minor slips, no blunders",flawed:"at least one blunder",thrown:"threw away a winning position",unscored:"analyzed before full move scoring"},Ut={opening:"#60A5FA",middlegame:"#A78BFA",endgame:"#FB7185"},ye={opening:"Opening",middlegame:"Middlegame",endgame:"Endgame"},T=t=>`${Math.round(t*100)}%`;function Hn(){return Le("benchmark-report"),Fe()?e.jsx(Gt,{}):e.jsx(Ve,{title:"How you compare to your rating band",subtitle:"Your blunder rate, what it costs you in rating, and your habits, each measured against what's typical for your level.",pitchTitle:"Get your benchmark report.",pitchBody:"Create a free account, link your games, and see exactly where you're behind, and where you're ahead of, players at your rating."})}function Gt(){const{data:t,isLoading:r,isError:o}=Ke();return r?e.jsx(I,{children:e.jsx(i,{py:16,textAlign:"center",children:e.jsx(Ee,{size:"lg",color:Nt})})}):o||!t?e.jsx(I,{children:e.jsx(a,{py:16,textAlign:"center",color:"report.fg.muted",children:"Could not load your report. Refresh to try again."})}):t.games.analyzed===0?e.jsx(I,{children:e.jsx(Yt,{})}):e.jsx(I,{children:e.jsx(Vt,{report:t})})}function I({children:t}){return e.jsx(i,{m:-4,p:4,minH:"calc(100% + 2rem)",flexShrink:0,bg:"report.bg",color:"report.fg",css:{fontVariantNumeric:"tabular-nums"},children:e.jsx(dt,{maxW:"6xl",px:{base:0,md:4},py:{base:2,md:6},children:t})})}function Yt(){return e.jsxs(W,{gap:4,...U,p:{base:6,md:8},textAlign:"center",maxW:"640px",mx:"auto",children:[e.jsx(ke,{src:"/assets/images/kc_mascot.webp",alt:"Coach Bjorn, the KingChess mascot",boxSize:"72px",objectFit:"contain"}
1),e.jsx(Ie,{size:"lg",color:"report.fg",children:"No analyzed games yet"}),e.jsx(a,{color:"report.fg.muted",maxW:"440px",children:"Coach Bjorn reads your recent games and shows how you compare to players at your rating. One analysis is all it takes."}),e.jsx(k,{to:"/puzzle-generation",children:e.jsx(_,{bg:A,color:"white",_hover:{bg:pe},children:"Analyze my games"})}),e.jsxs(i,{w:"full",mt:2,"aria-hidden":!0,children:[e.jsx(v,{mb:2,textAlign:"left",children:"This is what Bjorn builds for you"}),e.jsx(W,{gap:3,align:"stretch",pointerEvents:"none",userSelect:"none",children:[{title:"Endgames",sub:"Blunders in the endgame",fill:55,marker:30,color:"report.bad",verdict:"More often than typical",verdictColor:"report.bad",good:!1},{title:"Openings",sub:"Blunders in the opening",fill:28,marker:42,color:"report.good",verdict:"Less often than typical",verdictColor:"report.good",good:!0}].map(t=>e.jsxs(i,{...U,bg:"report.secondary",px:4,py:3,textAlign:"left",children:[e.jsx(a,{fontWeight:"semibold",color:"report.fg",fontSize:"sm",children:t.title}),e.jsxs(f,{justify:"space-between",align:"center",mt:.5,gap:3,children:[e.jsx(a,{color:"report.fg.muted",fontSize:"xs",children:t.sub}),e.jsx(a,{color:"report.fg.muted",fontSize:"xs",fontWeight:"bold",filter:"blur(3.5px)",opacity:.8,whiteSpace:"nowrap",children:"1 in 4 games (typical 1 in 8)"})]}),e.jsxs(i,{position:"relative",h:"8px",bg:"report.track",borderRadius:"full",mt:2,children:[e.jsx(i,{position:"absolute",left:0,top:0,bottom:0,w:`${t.fill}%`,bg:t.color,borderRadius:"full"}),e.jsx(i,{position:"absolute",left:`${t.marker}%`,top:"-3px",bottom:"-3px",w:"2px",bg:"report.fg/70"})]}),e.jsxs(a,{mt:1.5,fontSize:"xs",fontWeight:"semibold",color:t.verdictColor,children:[t.verdict,t.good?" ✓":""]})]},t.title))})]})]})}const Kt=[{key:"overview",label:"Overview",icon:Pe},{key:"blunders",label:"Blunders",icon:Ue},{key:"games",label:"Games",icon:Ge},{key:"skills",label:"Skills",icon:Ye}];function Vt({report:t}){var m;const[r,o]=$.useState(!1),{tab:n}=He.useSearch(),[s,u]=$.useState(n??"overview"),c=async h=>{try{await ct.upgradeToPremium(h)}catch{se.create({title:"Upgrade failed",description:"Could not start the upgrade flow. Please try again.",type:"error"})}},l=()=>o(!0),d=h=>h!=="overview"&&t.locked_tabs.includes(h);return e.jsxs(W,{gap:5,align:"stretch",children:[e.jsx(B,{gap:1,p:1,bg:"report.card",border:"1px solid",borderColor:"report.border",borderRadius:Ne,w:"fit-content",flexWrap:"wrap",children:Kt.map(h=>{const p=s===h.key;return e.jsxs(_,{size:"sm",variant:"ghost",fontWeight:"medium",px:3,h:"36px",borderRadius:Y,bg:p?"report.primary":"transparent",color:p?"white":"report.fg.muted",transition:"color 0.12s ease, background 0.12s ease",_hover:{color:p?"white":"report.fg",bg:p?"report.primary":"transparent"},_active:{transform:"translateY(1px)"},onClick:()=>u(h.key),children:[e.jsx(h.icon,{size:16}),h.label,d(h.key)&&e.jsx(F,{size:12})]},h.key)})}),s==="overview"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{children:e.jsx(qt,{report:t})}),t.start_here&&t.dimensions.blunders.themes&&e.jsx(w,{children:e.jsx(Ft,{start:t.start_here,themes:t.dimensions.blunders.themes,onOpen:()=>u("blunders")})}),e.jsx(w,{children:e.jsx(Xt,{report:t})}),e.jsx(w,{children:e.jsxs(z,{columns:{base:1,lg:3},gap:4,alignItems:"stretch",children:[e.jsx(i,{gridColumn:{lg:"span 2"},children:e.jsx(Jt,{games:t.ledger})}),e.jsx(rn,{report:t})]})}),e.jsx(w,{children:e.jsxs(z,{columns:{base:1,md:2},gap:4,alignItems:"stretch",children:[e.jsx(en,{report:t}),e.jsx(yn,{report:t})]})}),e.jsx(w,{children:e.jsx(ut,{})})]}),s==="blunders"&&d("blunders")&&e.jsx(w,{children:e.jsx(J,{tab:"blunders",onUnlock:l})}),s==="blunders"&&!d("blunders")&&e.jsxs(e.Fragment,{children:[e.jsx(w,{children:e.jsx(pn,{report:t})}),e.jsx(w,{children:e.jsx(mn,{report:t})}),e.jsx(w,{children:e.jsx(bn,{report:t})}),e.jsx(w,{children:e.jsxs(z,{columns:{base:1,md:2},gap:4,alignItems:"stretch",children:[e.jsx(Qt,{games:t.ledger}),e.jsx(j,{title:"Move quality",children:e.jsx(wt,{games:t.ledger})})]})}),e.jsx(w,{children:e.jsx(jn,{report:t})})]}),s==="games"&&d("games")&&e.jsx(w,{children:e.jsx(J,{tab:"games",onUnlock:l})}),s==="games"&&!d("games")&&e.jsxs(e.Fragment,{children:[e.jsx(w,{children:e.jsx(dn,{report:t})}),e.jsx(w,{children:e.jsxs(z,{columns:{base:1,lg:3},gap:4,alignItems:"stretch",children:[e.jsx(j,{title:"Skill radar",children:e.jsx(Mt,{axes:t.axes,peerScore:((m=t.axes[0])==null?void 0:m.peer_score)??75})}),e.jsx(i,{gridColumn:{lg:"span 2"},children:e.jsx(cn,{report:t,onUnlock:l})})]})}),e.jsx(w,{children:e.jsxs(z,{columns:{base:1,lg:3},gap:4,alignItems:"stretch",children:[e.jsx(j,{title:"By colour",children:e.jsx(mt,{games:t.ledger})}),e.jsx(i,{gridColumn:{lg:"span 2"},children:e.jsx(un,{games:t.ledger})})]})}),e.jsx(w,{children:e.jsx(hn,{report:t})})]}),s==="skills"&&d("skills")&&e.jsx(w,{children:e.jsx(J,{tab:"skills",onUnlock:l})}),s==="skills"&&!d("skills")&&e.jsx(w,{children:e.jsx(xn,{report:t,onUnlock:l})}),e.jsx(Qe,{open:r,onClose:()=>o(!1),onUpgrade:c,headerSubtitle:"Unlock the full report",bodyHeadline:"Every blunder, every game, every skill",bodyDescription:e.jsx(a,{children:"Free shows the Overview: the verdict, where to start, and your headline numbers. Premium opens the Blunders, Games and Skills tabs: every blunder tagged and linked to its game and drill, every game inspected, and 
1your five skills against players at your level, plus the rest of Premium."})})]})}const Ae={endgames:{to:"/endgame-defense",label:"Train endgames →"},blunders:{to:"/weaknesses",label:"See the drills →"},tactics:{to:"/weaknesses",label:"See the drills →"},openings:{to:"/weaknesses",label:"See the drills →"},discipline:{to:"/weaknesses",label:"See the drills →"}};function qt({report:t}){const r=t.verdict.axis?Ae[t.verdict.axis]:null;return e.jsxs(f,{align:"center",gap:4,children:[e.jsxs(W,{gap:.5,flexShrink:0,children:[e.jsx(ke,{src:"/assets/images/kc_mascot.webp",alt:"Coach Bjorn, the KingChess mascot",boxSize:{base:"84px",md:"116px"},objectFit:"contain"}),e.jsx(a,{fontSize:"xs",fontWeight:"bold",color:"report.fg.muted",children:"Coach Bjorn"})]}),e.jsxs(i,{position:"relative",...U,px:{base:4,md:6},py:{base:3,md:4},boxShadow:{base:"0 4px 14px rgba(0, 0, 0, 0.05)",_dark:"none"},_dark:{borderTopWidth:"3px",borderTopColor:"report.primary"},children:[e.jsx(i,{position:"absolute",left:"-7px",top:"50%",transform:"translateY(-50%) rotate(45deg)",boxSize:"14px",bg:"report.card",borderLeft:"1px solid",borderBottom:"1px solid",borderColor:"report.border"}),e.jsx(a,{fontWeight:"bold",color:"report.fg",fontSize:{base:"md",md:"lg"},children:t.verdict.text}),e.jsxs(a,{fontSize:"sm",color:"report.fg.muted",mt:1,children:[t.band.reference==="band"?e.jsxs(e.Fragment,{children:["Benchmarked against typical KingChess players rated"," ",t.band.label]}):e.jsx(e.Fragment,{children:"Benchmarked against typical KingChess players"}),t.band.source==="assumed"&&" (rating unknown so far)",", over your last ",t.games.analyzed," analyzed games."]}),r&&e.jsx(k,{to:r.to,children:e.jsx(_,{mt:3,size:"sm",bg:A,color:"white",_hover:{bg:pe},fontWeight:"bold",css:{animation:"analyzeGlow 2.4s ease-in-out infinite","@media (prefers-reduced-motion: reduce)":{animation:"none",boxShadow:"0 6px 20px rgba(84, 87, 224, 0.45)"}},children:r.label})})]})]})}function me(t,r){if(!(r===null||r<=0)){if(t/r>=1.15)return"bad";if(t/r<=.95)return"good"}}function Xt({report:t}){const r=t.games,o=t.rating_leak,n=t.axes.find(g=>g.key==="blunders"),s=r.win+r.draw+r.loss,u=s>0?(r.win+.5*r.draw)/s:null,c=r.analyzed-(t.ledger_summary.unscored??0),l=(t.ledger_summary.spotless??0)+(t.ledger_summary.clean??0),d=r.with_eval_curve>0,m=t.band.reference==="band"?t.band.label:"KingChess players",h=Zt(t.ledger),p=tt(t.ledger),x=t.ledger.map(g=>g.accuracy).filter(g=>g!=null),b=t.ledger.map(g=>g.move_count).filter(g=>g!=null&&g>0),S=nt(t.ledger),M={wins:xe(S,g=>g.result==="win"),losses:xe(S,g=>g.result==="loss")};return e.jsxs(z,{columns:{base:2,lg:4},gap:4,children:[e.jsx(y,{label:"Blunder cost",value:d?o.total:"Not yet",sub:d?o.peer_total!==null&&o.peer_total>0?`rating points · typical ${o.peer_total}`:"rating points sacrificed to blunders":"needs games analyzed with full eval data",tone:d?me(o.total,o.peer_total):void 0}),e.jsx(y,{label:"Blunders per game",value:(n==null?void 0:n.user_value)!=null?n.user_value.toFixed(1):"—",sub:(n==null?void 0:n.baseline)!=null?`typical ${n.baseline.toFixed(1)} for ${m}`:"two pawns' worth or more, per game",tone:(n==null?void 0:n.user_value)!=null&&n.baseline!=null?n.user_value>n.baseline*1.15?"bad":n.user_value<n.baseline*.85?"good":void 0:void 0}),e.jsx(y,{label:"Score",value:u!==null?T(u):"—",sub:h!==null?`${r.win}W · ${r.draw}D · ${r.loss}L · expected ${T(h)} from the ratings`:`${r.win}W · ${r.draw}D · ${r.loss}L in ${s} games`,tone:u!==null&&h!==null?u>=h+.05?"good":u<=h-.05?"bad":void 0:void 0}),e.jsx(y,{label:"Blunder-free games",value:c>0?T(l/c):"—",sub:`${l} of ${c} games without a blunder`}),e.jsx(y,{label:p.timeClass?`Performance rating (${p.timeClass})`:"Performance rating",value:p.value??"—",sub:p.value!==null?`avg opponent ${p.avgOpponent} over ${p.games} ${p.timeClass} games`:"needs a few rated games in one time class"}),e.jsx(y,{label:"Mean accuracy",value:x.length?`${L(x).toFixed(1)}%`:"—",sub:x.length?`σ ${he(x).toFixed(1)} · median ${_e(x).toFixed(1)}%`:"no scored games yet"}),e.jsx(y,{label:"Average game length",value:b.length?L(b).toFixed(0):"—",sub:b.length?`moves · ${le(b,.9).toFixed(0)} at the 90th percentile`:"no move counts yet"}),e.jsx(y,{label:"Longest streaks",value:`${M.wins}W / ${M.losses}L`,sub:`in a row, across these ${r.analyzed} games`})]})}function Qt({games:t}){const r=jt("blunders"),o=r.metric==="blunders"?"Blunders by time of day":r.metric==="score"?"Score by time of day":"Games by time of day";return e.jsx(j,{h:"100%",title:o,action:e.jsx(yt,{controls:r}),children:e.jsx(bt,{games:t,metric:r.metric})})}function Jt({games:t}){const r=rt(t);return e.jsx(j,{h:"100%",title:r.metric==="rating"?"Rating trajectory":"Accuracy trajectory",action:e.jsx(st,{controls:r}),children:e.jsx(ot,{games:t,controls:r})})}function Zt(t){const r=t.filter(o=>o.user_rating!=null&&o.opponent_rating!=null);return r.length<5||r.length<t.length/2?null:L(r.map(o=>lt(o.user_rating,o.opponent_rating)))}function en({report:t}){const[r,o]=$.useState(!1),n=t.rating_leak;if(t.games.with_eval_curve===0)return e.jsxs(j,{h:"100%",title:"What your blunders cost",children:[e.jsx(a,{color:"report.fg.muted",fontWeight:"medium",children:"Not measurable yet"}),e.jsx(a,{mt:1,fontSize:"sm",color:"report.fg.muted",lineHeight:"tall",children:"Your games were analyzed before we stored full eval data, so we can't price your blunders in rating points yet. Analyze fresh games and this number appears automatically."}),e.jsx(k,{to:"/puzzle-generation",children:e.jsx(_,{mt:3,size:"sm",bg:A,color:"white",_hover:{bg:pe},fontWeight:"bold",children:"Analyze recent games"})})]});const s=me(n.total,n.peer_total);return e.jsxs(j,{h:"100%",title:"What your blunders cost",children:[n.peer_total!==null&&n.peer_total>0?e.jsxs(a,{color:"report.fg.muted",fontSize:"sm",children:["Typical for a KingChess"," ",t.band.reference==="band"?`${t.band.label} `:"","player over"," ",t.games.with_eval_curve===1?"this 1 game":`these ${t.games.with_eval_curve} games`," ","is about"," ",e.jsxs(a,{as:"span",fontWeight:"bold",color:"report.fg",children:[n.peer_total," points"]}),"."," ",s==="bad"?e.jsxs(e.Fragment,{children:["Your blunders cost"," ",e.jsxs(a,{as:"span",fontWeight:"bold",color:"report.bad",children:[(n.total/n.peer_total).toFixed(1),"x"]})," ","that."]}):s==="good"?e.jsx(a,{as:"span",color:"report.good",fontWeight:"semibold",children:"Yours cost less than that. Nice."}):"Yours cost about the same."]}):e.jsxs(a,{color:"report.fg.muted",fontSize:"sm",children:[n.total," rating points sacrificed to blunders across"," ",t.games.with_eval_curve," games."]}),e.jsx(a,{fontSize:"xs",color:"report.fg.muted",mt:1,children:"An estimate of what your blunders cost, not your actual rating change."}),e.jsx(_,{variant:"plain",size:"xs",color:"report.fg.muted",mt:2,px:0,textDecoration:"underline",onClick:()=>o(u=>
1!u),children:r?"Hide the math":"How is this computed?"}),r&&e.jsx(i,{mt:2,bg:"report.secondary",borderRadius:Y,p:3,children:e.jsxs(a,{fontSize:"xs",color:"report.fg.muted",lineHeight:"tall",children:["Each of your ",n.blunders," blunders dropped your winning chances, measured by engine eval on a curve fitted to how KingChess games"," ",t.band.source==="assumed"?`at an assumed ${t.band.assumed_rating} level (until we see a rating)`:"at your level"," ","actually end. The curve most sites use gives everyone the same chances for the same eval. Measured, a lower-rated player converts an advantage less often than a stronger one. So the same blunder costs each of them something different. Those drops sum to"," ",n.es_lost," expected points, multiplied by ",n.k_factor,`, the K-factor FIDE uses for most rated players. The "typical" line multiplies your band's measured blunder frequency by its measured cost per blunder, both calibrated from real KingChess games.`,t.games.analyzed>t.games.with_eval_curve&&e.jsxs(e.Fragment,{children:[" ","Games without full eval data (",t.games.analyzed-t.games.with_eval_curve," of"," ",t.games.analyzed,") aren't counted."]})]})})]})}function tn(t){return t.source!=="measured"||t.rating===null?"Band: unknown (no rated games yet)":t.platform==="lichess"&&t.platform_rating!==null?`Band: ${t.label} on the Chess.com scale. Your Lichess rating in these games is about ${t.platform_rating}. Lichess runs about ${t.lichess_offset} higher, so that counts as ${t.rating}.`:t.platform==="chess_com"?`Band: ${t.label} (Chess.com rating about ${t.rating}).`:`Band: ${t.label} on the Chess.com scale (rating about ${t.rating}, Lichess games counted ${t.lichess_offset} lower).`}function nn({losses:t}){const{count:r,losses_measured:o,ever_winning:n,avg_blunders_per_loss:s}=t,u=Math.max(0,n-r),c=Math.max(0,o-n),l=o>=8&&r>=o/2;let d,m;r>0?(d=`${r} of your ${o} losses`,m=`${r===1?" was a winning position":" were winning positions"} you threw in one move.${l?" That's the pattern to fix.":""}`):n>0?(d=`None of your ${o} losses`,m=" were thrown in one move."):(d=`No thrown wins among your ${o} losses.`,m=s!==null&&s>=2?` They averaged ${s} blunders each, spread through the game rather than one decisive moment.`:" You were never clearly ahead in any of them. They drained slowly, move by move.");const h=u>0?` ${u===1?"One was":`${u} were`} winning at some point and slipped away over several moves.`:"",p=n>0&&c>0?` The other ${c} you were never clearly ahead in.`:"";return e.jsxs(a,{mt:3,fontSize:"sm",color:"report.fg.muted",lineHeight:"tall",children:[e.jsx(a,{as:"span",fontWeight:"bold",color:"report.fg",children:d}),m,h,p]})}function rn({report:t}){const r=t.games,o=t.thrown_losses;return e.jsxs(j,{h:"100%",title:"The sample",children:[e.jsxs(a,{color:"report.fg",fontWeight:"medium",children:[r.analyzed," analyzed games"]}),r.win+r.draw+r.loss>0&&e.jsx(i,{mt:2,children:e.jsx(q,{segments:[{label:"wins",value:r.win,color:"report.good"},{label:"draws",value:r.draw,color:"report.neutral"},{label:"losses",value:r.loss,color:"report.bad"}]})}),e.jsx(a,{mt:2,fontSize:"sm",color:"report.fg.muted",lineHeight:"tall",children:tn(t.band)}),o.losses_measured>=3&&e.jsx(nn,{losses:o})]})}const on={blunders:"all 2-pawn mistakes, per game",tactics:"blunders that hang material",endgames:"late-game blunders",discipline:"rushed or low on clock",openings:"blunders in the opening"},sn={discipline:{short:"No clock data yet",hint:"Analyze fresh games to unlock this."}},ln={short:"Not enough data yet",hint:"Analyze more games to measure this."},Me=3,we={blunders:"blunder",tactics:"hang material",endgames:"blunder in the endgame",openings:"blunder in the opening"};function an({axis:t,isWorst:r}){const o=t.user_value!=null&&t.baseline?t.user_value/t.baseline:t.score!==null?75/t.score:null;let n;if(t.locked)n=e.jsxs(B,{gap:1,color:"report.fg.muted",justify:"flex-end",children:[e.jsx(F,{size:12}),e.jsx(a,{fontSize:"sm",children:"Premium"})]});else if(o===null){const d=sn[t.key]??ln;n=e.jsxs(i,{textAlign:"right",children:[e.jsx(a,{fontSize:"sm",color:"report.fg.muted",children:d.short}),e.jsx(a,{fontSize:"xs",color:"report.fg.muted",children:d.hint})]})}else o>1.15&&(t.count??0)<6?n=e.jsxs(i,{textAlign:"right",children:[e.jsx(a,{fontSize:"sm",color:"report.fg.muted",children:"Too few to judge"}),e.jsxs(a,{fontSize:"xs",color:"report.fg.muted",children:[t.count??0," seen so far"]})]}):o>1.15?n=e.jsx(a,{fontSize:"sm",fontWeight:"semibold",color:"report.bad",textAlign:"right",children:r?"Your biggest gap":"Worse than typical"}):o<.85?n=e.jsx(a,{fontSize:"sm",fontWeight:"semibold",color:"report.good",textAlign:"right",children:"A strength"}):n=e.jsx(a,{fontSize:"sm",fontWeight:"medium",color:"report.fg.muted",textAlign:"right",children:"About typical"});const s=o!==null&&o>1,u=o===null?0:s?Math.min(1,(o-1)/(Me-1)):1-o,c=Math.max(u*50,o===null?0:2),l=o!==null&&o>1.15?"report.bad":o!==null&&o<.85?"report.good":"report.neutral";return e.jsxs(f,{align:"center",gap:{base:2,md:4},py:3,children:[e.jsxs(i,{w:{base:"110px",md:"176px"},flexShrink:0,children:[e.jsx(a,{fontSize:"sm",fontWeight:"medium",color:t.locked?"report.fg.muted":"report.fg",children:t.label}),e.jsx(a,{fontSize:"xs",color:"report.fg.muted",display:{base:"none",md:"block"},children:on[t.key]})]}),o===null?e.jsx(i,{flex:"1",h:"10px",borderRadius:"full",border:"1px dashed",borderColor:"report.border"}):e.jsxs(i,{position:"relative",flex:"1",bg:"report.track",borderRadius:"full",h:"10px",children:[e.jsx(i,{position:"absolute",left:s?"50%":`${50-c}%`,w:`${c}%`,h:"100%",bg:l,borderRadius:"full",transition:"width 500ms ease, left 500ms ease",filter:t.locked?"blur(4px)":void 0,opacity:t.locked?.6:1}),e.jsx(i,{position:"absolute",left:"50%",top:"-4px",h:"18px",w:"1px",bg:"report.fg/60"})]}),e.jsx(i,{w:{base:"40%",md:"128px"},flexShrink:0,children:n})]})}function cn({report:t,onUnlock:r}){const o=t.axes.some(l=>l.locked),n=t.verdict.axis?t.axes.find(l=>l.key===t.verdict.axis):null,s=t.verdict.axis?Ae[t.verdict.axis]:null,u=t.band.reference==="band"?`${t.band.label} player`:"KingChess player";let c=null;return n&&(n.key==="discipline"&&n.user_value!=null&&n.baseline!=null?c=`You rush ${T(n.user_value)} of your blunders. Typical for a ${u} is ${T(n.baseline)}.`:n.user_value!=null&&n.baseline!=null&&we[n.key]?c=`You ${we[n.key]} ${ge(n.user_value)}. A typical ${u} does it ${ge(n.baseline)}.`:c=`Your biggest gap: ${n.label}.`),e.jsxs(j,{h:"100%",title:t.band.reference==="band"?`How you compare to ${t.band.label}`:"How you compare to KingChess players",children:[n&&s&&e.jsxs(a,{fontSize:"sm",color:"report.fg",mt:-2,children:[c," ",e.jsx(k,{to:s.to,children:e.jsx(a,{as:"span",color:A,_dark:{color:"report.accent"},fontWeight:"semibold",textDecoration:"underline",children:s.label})})]}),e.jsxs(f,{align:"center",gap:{base:2,md:4},mt:3,display:{base:"none",md:"flex"},children:[e.jsx(i,{w:{base:"110px",md:"176px"},flexShrink:0}),e.jsxs(f,{flex:"1",justify:"space-between",fontSize:"xs",color:"report.fg.muted",children:[e.jsx(a,{color:"report.good",children:"← better than typical"}),e.jsxs(a,{color:"report.bad",children:["worse than typical →"," ",e.jsxs(a,{as:"span",color:"report.fg.muted",children:["(bar caps at ",Me,"x)"]})]})]}),e.jsx(i,{w:{base:"40%",md:"128px"},flexShrink:0})]}),e.jsx(i,{children:t.axes.map((l,d)=>e.jsx(i,{borderTopWidth:d===0?0:"1px",borderColor:"report.border",children:e.jsx(an,{axis:l,isWorst:l.key===t.verdict.axis})},l.key))}),e.jsx(a,{fontSize:"xs",color:"report.fg.muted",mt:2,lineHeight:"tall",children:"A blunder here means one move that throws away two pawns' worth of advantage or more; smaller mistakes aren't counted. We count blunders even in lost positions, so numbers run higher than the labels on chess sites. The cause and phase rows overlap, so they don't add up to the first row."}),o&&e.jsxs(f,{mt:3,bg:"report.secondary",borderRadius:Y,p:3,align:"center",justify:"space-between",gap:3,wrap:"wrap",children:[e.jsxs(B,{gap:2,color:"report.fg.muted",children:[e.jsx(F,{}),e.jsx(a,{fontSize:"sm",children:"Four rows are locked. The bars are yours; the numbers behind them are Premium."})]}),e.jsx(_,{size:"sm",bg:"yellow.500",color:"black",_hover:{bg:"yellow.400"},fontWeight:"bold",onClick:r,children:"Unlock the full report"})]})]})}function dn({report:t}){const r=t.games,o=t.axes.find(c=>c.key==="blunders"),n=r.win+r.draw+r.loss,s=t.band.reference==="band"?t.band.label:"KingChess players",u=t.ledger.map(c=>c.accuracy).filter(c=>c!=null);return e.jsxs(z,{columns:{base:2,lg:4},gap:4,children:[e.jsx(y,{label:"Games analyzed",value:r.analyzed,sub:r.with_eval_curve<r.analyzed?`${r.with_eval_curve} with full eval data`:`your last ${r.window}
1 at most`}),e.jsx(y,{label:"Average accuracy",value:u.length?`${L(u).toFixed(1)}%`:"—",sub:u.length?`over ${u.length} scored games`:"no scored games yet"}),e.jsx(y,{label:"Blunders per game",value:(o==null?void 0:o.user_value)!=null?o.user_value.toFixed(1):"—",sub:(o==null?void 0:o.baseline)!=null?`typical ${o.baseline.toFixed(1)} for ${s}`:"two pawns' worth or more, per game",tone:(o==null?void 0:o.user_value)!=null&&o.baseline!=null?o.user_value>o.baseline*1.15?"bad":o.user_value<o.baseline*.85?"good":void 0:void 0}),e.jsx(y,{label:"Score",value:n>0?T((r.win+.5*r.draw)/n):"—",sub:`${r.win}W · ${r.draw}D · ${r.loss}L · draws count half`})]})}function un({games:t}){const[r,o]=$.useState(!1);return e.jsxs(j,{h:"100%",title:"Advanced stats",children:[e.jsx(a,{fontSize:"sm",color:"report.fg.muted",children:"Opponent rating against your accuracy, the accuracy distribution, and the full descriptive table."}),e.jsx(_,{variant:"plain",size:"xs",color:"report.fg.muted",mt:2,px:0,textDecoration:"underline",onClick:()=>o(n=>!n),children:r?"Hide advanced stats":"Show advanced stats"}),r&&e.jsxs(W,{align:"stretch",gap:6,mt:4,children:[e.jsxs(i,{children:[e.jsx(v,{mb:2,children:"Opponent rating vs your accuracy"}),e.jsx(gt,{games:t})]}),e.jsxs(i,{children:[e.jsx(v,{mb:2,children:"Accuracy distribution"}),e.jsx(pt,{games:t})]}),e.jsxs(i,{children:[e.jsx(v,{mb:2,children:"Descriptive statistics"}),e.jsx(xt,{games:t})]})]})]})}function hn({report:t}){const r=t.ledger_summary,o=["spotless","clean","flawed","thrown","unscored"].filter(n=>n!=="unscored"||(r.unscored??0)>0);return e.jsxs(j,{title:"Every game, inspected",children:[e.jsx(W,{gap:1.5,align:"stretch",children:o.map(n=>e.jsxs(B,{gap:2.5,children:[e.jsx(i,{boxSize:"10px",borderRadius:"sm",bg:ee[n],flexShrink:0}),e.jsx(a,{fontSize:"sm",color:"report.fg",fontWeight:"medium",w:{base:"88px",md:"104px"},flexShrink:0,children:te[n]}),e.jsx(a,{fontSize:"sm",fontWeight:"semibold",color:"report.fg",w:"24px",textAlign:"right",flexShrink:0,children:r[n]}),e.jsx(a,{fontSize:"sm",color:"report.fg.muted",children:Pt[n]})]},n))}),e.jsx(f,{mt:4,gap:1.5,wrap:"wrap",children:t.ledger.map(n=>{const s=e.jsx(i,{boxSize:"18px",borderRadius:"sm",bg:ee[n.class],opacity:n.result==="win"?1:.85,title:`${te[n.class]}: ${n.result}${n.opponent?` vs ${n.opponent}`:""}`,cursor:n.url?"pointer":"default",_hover:{transform:"scale(1.2)"},transition:"transform 0.1s"},`${n.platform}-${n.game_id}`);return n.url?e.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",children:s},`${n.platform}-${n.game_id}`):s})}),e.jsx(kt,{games:t.ledger,classColor:ee,classLabel:te})]})}function pn({report:t}){const r=t.games,o=t.rating_leak,n=t.axes.find(l=>l.key==="blunders"),s=r.with_eval_curve>0,u=t.ledger.filter(l=>l.result==="loss"&&l.class==="thrown").length,c=t.band.reference==="band"?t.band.label:"KingChess players";return e.jsxs(z,{columns:{base:2,lg:4},gap:4,children:[e.jsx(y,{label:"Total blunders",value:(n==null?void 0:n.count)??"—",sub:`across ${r.analyzed} analyzed games`}),e.jsx(y,{label:"Blunders per game",value:(n==null?void 0:n.user_value)!=null?n.user_value.toFixed(1):"—",sub:(n==null?void 0:n.baseline)!=null?`typical ${n.baseline.toFixed(1)} for ${c}`:"two pawns' worth or more, per game",tone:(n==null?void 0:n.user_value)!=null&&n.baseline!=null?n.user_value>n.baseline*1.15?"bad":n.user_value<n.baseline*.85?"good":void 0:void 0}),e.jsx(y,{label:"Rating points sacrificed",value:s?o.total:"Not yet",sub:s?o.peer_total!==null&&o.peer_total>0?`typical ${o.peer_total} over these games`:`across ${o.blunders} priced blunders`:"needs games analyzed with full eval data",tone:s?me(o.total,o.peer_total):void 0}),e.jsx(y,{label:"Winning positions thrown",value:u,sub:`of ${r.loss} ${r.loss===1?"loss":"losses"}`,tone:u>0?"warn":void 0})]})}function mn({report:t}){const r=t.dimensions.blunders,o=t.axes.find(c=>c.key==="blunders"),n=r.phase_totals??{},s=Object.values(n).reduce((c,l)=>c+(l??0),0),u=r.themes??null;return e.jsxs(j,{title:"Where the blunders come from",children:[(o==null?void 0:o.user_value)!=null&&o.baseline!=null&&e.jsxs(a,{color:"report.fg.muted",fontSize:"sm",children:["You average"," ",e.jsxs(a,{as:"span",fontWeight:"bold",color:o.user_value>o.baseline*1.15?"report.bad":o.user_value<o.baseline*.85?"report.good":"report.fg",children:[o.user_value.toFixed(1)," blunders per game"]}),". Typical for ",t.band.reference==="band"?t.band.label:"KingChess players"," ","is about ",o.baseline.toFixed(1),"."]}),e.jsx(a,{mt:1,fontSize:"xs",color:"report.fg.muted",children:"A blunder here means one move that throws away two pawns' worth of advantage or more. Smaller mistakes aren't counted."}),s>0&&e.jsxs(i,{mt:5,children:[e.jsx(v,{mb:2,children:"When they happen"}),e.jsx(q,{segments:["opening","middlegame","endgame"].filter(c=>n[c]).map(c=>({label:ye[c],value:n[c]??0,color:Ut[c],legend:`${ye[c]} ${T((n[c]??0)/s)}`}))})]}),u&&e.jsx(Dt,{themes:u})]})}function gn({label:t,userShare:r,peerShare:o}){if(r==null||o==null)return e.jsxs(a,{fontSize:"sm",color:"report.fg.muted",children:[t,": not enough data yet."]});const n=o>0&&r/o>1.15?"bad":o>0&&r/o<.85?"good":"neutral",s=Math.min(1,Math.max(r,o)*1.6)||1;return e.jsx(K,{label:t,value:e.jsxs(e.Fragment,{children:[T(r)," of your blunders"," ",e.jsxs(V,{children:["(typical ",T(o),")"]})]}),share:r/s,typicalShare:o/s,tone:n,verdict:n==="bad"?"A bigger share than typical":n==="good"?"A smaller share than typical ✓":"About typical"})}function ne(t,r){return t.axes.find(o=>o.key===r)}function G(t,r=!1){if(t<=0)return"none";if(t>=1.5)return`${Math.round(t)} a game`;if(t>=.75)return"once a game";const o=Math.max(2,Math.round(1/t));return r?`1 in ${o}`:`1 in ${o} games`}function re({label:t,axis:r}){if(!r||r.user_value==null||r.baseline==null)return e.jsxs(a,{fontSize:"sm",color:"report.fg.muted",children:[t,": not enough data yet."]});const o=r.baseline>0?r.user_value/r.baseline:null,n=o!==null&&o>1.15&&(r.count??0)<6,s=o===null||n?"neutral":o>1.15?"bad":o<.85?"good":"neutral",u=Math.max(r.user_value,r.baseline)*1.6||1;return e.jsx(K,{label:t,value:e.jsxs(e.Fragment,{children:[G(r.user_value)," ",e.jsxs(V,{children:["(typical ",G(r.baseline,!0),")"]})]}),share:r.user_value/u,typicalShare:r.baseline/u,tone:s,verdict:n?`Too few to judge, ${r.count??0} seen so far`:s==="bad"?"More often than typical":s==="good"?"Less often than typical ✓":"About typical"})}function H({title:t,pitch:r,onUnlock:o}){return e.jsxs(j,{h:"100%",title:e.jsxs(B,{gap:2,color:"report.fg.muted",children:[e.jsx(F,{size:14}),e.jsx(a,{as:"span",children:t})]}),children:[e.jsx(a,{fontSize:"sm",color:"report.fg.muted",children:r}
1),e.jsx(_,{mt:3,size:"xs",bg:"yellow.500",color:"black",_hover:{bg:"yellow.400"},fontWeight:"bold",onClick:o,children:"Unlock"})]})}function xn({report:t,onUnlock:r}){const o=t.dimensions,n=s=>s.locked===!0;return e.jsxs(z,{columns:{base:1,md:2},gap:4,alignItems:"stretch",children:[e.jsx(i,{children:n(o.tactics)?e.jsx(H,{title:"Missed threats",pitch:"How often a blunder was a named tactic (a hung piece, a fork, a pin, a trapped piece), against what's typical for your band.",onUnlock:r}):e.jsx(N,{title:"Missed threats",children:e.jsx(re,{label:"Blunders that walk into tactics",axis:ne(t,"tactics")})})}),e.jsx(i,{children:n(o.discipline)?e.jsx(H,{title:"Discipline",pitch:"How many of your blunders were rushed, played in seconds with time on the clock.",onUnlock:r}):e.jsxs(N,{title:"Discipline",children:[e.jsx(gn,{label:"Blunders played rushed or in time trouble",userShare:o.discipline.rushed_share,peerShare:o.discipline.peer_share}),o.discipline.tempo&&o.discipline.tempo.unmeasured>0&&e.jsxs(a,{fontSize:"xs",color:"report.fg.muted",mt:2,children:[o.discipline.tempo.unmeasured," blunders predate clock tracking and aren't counted. New analyses collect clock data automatically."]})]})}),e.jsx(i,{children:n(o.endgames)?e.jsx(H,{title:"Endgames",pitch:"How much of your damage happens after move 30, and whether that's normal at your level.",onUnlock:r}):e.jsxs(N,{title:"Endgames",children:[e.jsx(re,{label:"Blunders in the endgame",axis:ne(t,"endgames")}),o.endgames.outcomes&&e.jsx(ht,{outcomes:o.endgames.outcomes,assumedRating:t.band.source==="assumed"?t.band.assumed_rating??null:null})]})}),e.jsx(i,{children:n(o.openings)?e.jsx(H,{title:"Openings",pitch:"Whether you're already worse out of the opening more often than players at your level.",onUnlock:r}):e.jsxs(N,{title:"Openings",children:[e.jsx(re,{label:"Blunders in the opening",axis:ne(t,"openings")}),e.jsx(fn,{table:o.openings.table})]})})]})}function fn({table:t}){if(!t)return null;const{rows:r,min_games:o}=t;if(r.length===0)return e.jsxs(a,{fontSize:"xs",color:"report.fg.muted",mt:3,children:["Not enough games per opening yet (",o," needed in one opening). This fills in on its own as you sync more games."]});const n=r.slice(0,3),s=r.length>=5?r.slice(3).slice(-2).reverse():[],u=Math.max(...r.map(l=>l.per_game),0),c=({r:l,tone:d})=>e.jsxs(i,{py:2.5,borderTopWidth:"1px",borderColor:"report.border",children:[e.jsxs(f,{align:"baseline",justify:"space-between",gap:3,children:[e.jsx(a,{fontSize:"sm",fontWeight:"medium",color:"report.fg",truncate:!0,children:l.name}),e.jsxs(a,{fontSize:"xs",color:"report.fg.muted",flexShrink:0,children:[l.per_game," mistakes/game · ",l.games," ",l.games===1?"game":"games"]})]}),e.jsx(i,{mt:1.5,h:"6px",w:"100%",overflow:"hidden",borderRadius:"full",bg:"report.track",children:e.jsx(i,{h:"100%",borderRadius:"full",bg:Xe[d],w:`${u?Math.min(100,l.per_game/u*100):0}%`,transition:"width 500ms ease"})})]});return e.jsxs(i,{mt:4,children:[e.jsxs(a,{fontSize:"sm",fontWeight:"semibold",color:"report.fg",mb:2,children:["Your riskiest opening is the ",n[0].name,"."]}),e.jsx(i,{children:n.map(l=>e.jsx(c,{r:l,tone:"warn"},l.name))}),s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(v,{mt:3,mb:1,children:"Steadiest"}),s.map(l=>e.jsx(c,{r:l,tone:"good"},l.name))]})]})}function N({title:t,children:r}){return e.jsx(j,{title:t,h:"100%",children:r})}const oe={Queen:"♕",Rook:"♖",Bishop:"♗",Knight:"♘",King:"♔",Pawn:"♙"};function bn({report:t}){const[r,o]=$.useState(null),n=t.piece_rates;if(!n||n.rows.length<2)return null;const s=n.rows[0],u=n.rows[n.rows.length-1],c=Math.max(...n.rows.map(l=>l.rate),0);return e.jsxs(z,{columns:{base:1,md:2},gap:4,alignItems:"stretch",children:[e.jsxs(j,{children:[e.jsx(v,{children:"Weakest piece"}),e.jsxs(a,{mt:1,fontSize:"2xl",fontWeight:"semibold",lineHeight:"1.1",color:"report.fg",children:[oe[s.piece]," ",s.piece]}),e.jsxs(a,{fontSize:"sm",color:"report.fg.muted",mt:1,children:["You blunder on ",s.rate,"% of your ",s.piece.toLowerCase()," ","moves."]}),e.jsx(i,{borderTopWidth:"1px",borderColor:"report.border",my:4}),e.jsx(v,{children:"Safest piece"}),e.jsxs(a,{mt:1,fontSize:"2xl",fontWeight:"semibold",lineHeight:"1.1",color:"report.fg",children:[oe[u.piece]," ",u.piece]}),e.jsxs(a,{fontSize:"sm",color:"report.fg.muted",mt:1,children:["Only ",u.rate,"% of your ",u.piece.toLowerCase()," moves go wrong."]})]}),e.jsxs(j,{title:"Pieces by blunder rate",children:[e.jsx(a,{fontSize:"xs",color:"report.fg.muted",mt:-2,mb:2,children:"Click a piece to see the moves behind the number."}),e.jsxs(f,{fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.14em",color:"report.fg.muted",pb:2,gap:3,children:[e.jsx(a,{flex:"1",children:"Piece"}),e.jsx(a,{w:"48px",textAlign:"right",children:"Rate"}),e.jsx(a,{w:"72px",textAlign:"right",children:"Moves"}),e.jsx(i,{w:{base:"56px",md:"96px"}})]}),n.rows.map(l=>{var m;const d=(((m=l.examples)==null?void 0:m.length)??0)>0;return e.jsxs(i,{borderTopWidth:"1px",borderColor:"report.border",children:[e.jsxs(f,{as:"button",w:"full",align:"center",gap:3,py:2.5,
1cursor:d?"pointer":"default",transition:"background 0.12s",_hover:d?{bg:"report.secondary/60"}:void 0,onClick:()=>d&&o(r===l.piece?null:l.piece),"aria-expanded":r===l.piece,children:[e.jsxs(a,{flex:"1",textAlign:"left",fontSize:"sm",fontWeight:"medium",color:"report.fg",children:[oe[l.piece]," ",l.piece]}),e.jsxs(a,{w:"48px",textAlign:"right",fontSize:"sm",fontWeight:"semibold",color:"report.fg",children:[l.rate,"%"]}),e.jsxs(a,{w:"72px",textAlign:"right",fontSize:"xs",color:"report.fg.muted",children:[l.moves," moves"]}),e.jsx(i,{w:{base:"56px",md:"96px"},h:"8px",bg:"report.track",borderRadius:"full",overflow:"hidden",children:e.jsx(i,{h:"100%",w:`${c?l.rate/c*100:0}%`,bg:l.piece===s.piece?"report.bad":"report.accent",borderRadius:"full",transition:"width 500ms ease"})})]}),r===l.piece&&e.jsx(i,{pl:5,pb:2,children:(l.examples??[]).map((h,p)=>e.jsxs(f,{align:"baseline",gap:2,py:.5,wrap:"wrap",children:[e.jsxs(a,{fontSize:"xs",color:"report.fg.muted",children:[h.san," on move ",h.move,h.opponent?` vs ${h.opponent}`:"",", lost"," ",h.loss_pawns.toFixed(1)," pawns."]}),h.puzzle_id!=null&&e.jsx(k,{to:"/puzzle/$id",params:{id:String(h.puzzle_id)},children:e.jsx(a,{as:"span",fontSize:"xs",fontWeight:"semibold",color:A,_dark:{color:"report.accent"},textDecoration:"underline",children:"View puzzle →"})})]},p))})]},l.piece)})]})]})}function jn({report:t}){const r=t.pivotal_moments;if(!r||!r.collapse&&!r.comeback)return null;const o=({label:n,labelColor:s,headline:u,moment:c})=>e.jsxs(i,{flex:"1",bg:"report.secondary",borderRadius:Y,p:3,children:[e.jsx(v,{color:s,children:n}),e.jsx(a,{mt:1,fontSize:"sm",fontWeight:"semibold",color:"report.fg",children:u}),e.jsxs(f,{align:"baseline",gap:2,mt:.5,wrap:"wrap",children:[e.jsxs(a,{fontSize:"xs",color:"report.fg.muted",children:["Move ",c.move,c.opponent?` vs ${c.opponent}`:""]}),c.puzzle_id!=null?e.jsx(k,{to:"/puzzle/$id",params:{id:String(c.puzzle_id)},children:e.jsx(a,{as:"span",fontSize:"xs",fontWeight:"semibold",color:A,_dark:{color:"report.accent"},textDecoration:"underline",children:"View puzzle →"})}):e.jsx(k,{to:"/game-review/$platform/$gameId",params:{platform:String(c.platform),gameId:String(c.game_id)},children:e.jsx(a,{as:"span",fontSize:"xs",fontWeight:"semibold",color:A,_dark:{color:"report.accent"},textDecoration:"underline",children:"View game →"})})]})]});return e.jsx(j,{title:"Pivotal moments",children:e.jsxs(f,{gap:3,direction:{base:"column",md:"row"},align:"stretch",children:[r.collapse&&e.jsx(o,{label:"Biggest collapse",labelColor:"report.bad",headline:(r.collapse.es_drop??0)>=.5&&(r.collapse.es_before??0)>=.6?"A winning position, lost in one move":r.collapse.pawns>=10?"A mate-scale swing, in one move":`−${r.collapse.pawns.toFixed(1)} pawns in one move`,moment:r.collapse}),r.comeback&&e.jsx(o,{label:"Biggest comeback",labelColor:"report.good",headline:(r.comeback.es_drop??0)>=.5?"A lost game, handed back to you":r.comeback.pawns>=10?"A mate-scale swing, handed to you":`+${r.comeback.pawns.toFixed(1)} pawns handed to you`,moment:r.comeback})]})})}function yn({report:t}){const r=t.personality;if(!(r!=null&&r.archetype))return null;const o=t.band.reference==="band"?`a typical ${t.band.label} player`:"typical KingChess players",n=r.axis&&r.user_value!=null&&r.baseline!=null?r.axis==="discipline"?`${T(r.user_value)} of your blunders rushed, against ${T(r.baseline)} for ${o}`:`${G(r.user_value)}, against ${G(r.baseline,!0)} for ${o}`:null,s=n?`${r.axis_label}: ${n}. That is your biggest gap against your band. Bjorn says drill it first.`:`Nothing stands out against ${o}. Start Here above points at the biggest cost instead.`,u=n?`${r.axis_label} · ${n}`:"No single weakness stands out",c=async()=>{const l=document.createElement("canvas");l.width=1200,l.height=630;const d=l.getContext("2d");if(!d)return;d.fillStyle="#FFF6EF",d.fillRect(0,0,1200,630),d.fillStyle="#FF5A36",d.fillRect(0,0,1200,10);const m=(h,p)=>`${h} ${p}px -apple-system, 'Segoe UI', Roboto, sans-serif`;d.fillStyle="#D64426",d.font=m("bold",28),d.fillText("MY BLUNDER PERSONALITY",80,120),d.fillStyle="#111827",d.font=m("800",84),d.fillText(`“${r.archetype??""}”`,76,240),d.fillStyle="#4B5563",d.font=m("500",40),d.fillText(r.tagline??"",80,320),d.font=m("500",32),d.fillStyle="#6B7280",d.fillText(u,80,400),d.fillStyle="#D64426",d.font=m("bold",34),d.fillText("What's yours? kingchess.io",80,540),l.toBlob(async h=>{var b;if(!h)return;const p=new File([h],"blunder-personality.png",{type:"image/png"});if((b=navigator.canShare)!=null&&b.call(navigator,{files:[p]}))try{await navigator.share({files:[p]});return}catch{}const x=document.createElement("a");x.href=URL.createObjectURL(h),x.download="blunder-personality.png",x.click(),URL.revokeObjectURL(x.href)},"image/png")};return e.jsx(j,{children:e.jsxs(f,{justify:"space-between",align:"flex-start",ga
1p:4,wrap:"wrap",children:[e.jsxs(i,{minW:0,children:[e.jsx(v,{children:"Your blunder personality"}),e.jsxs(a,{mt:1,fontSize:"lg",fontWeight:"semibold",lineHeight:"1.2",color:A,_dark:{color:"report.accent"},children:["“",r.archetype,"”"]}),e.jsxs(a,{fontSize:"sm",color:"report.fg.muted",mt:1,children:[r.tagline,r.phase_note?` ${r.phase_note}`:""]}),e.jsx(a,{fontSize:"sm",color:"report.fg",mt:2,children:s})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:c,flexShrink:0,borderColor:"report.border",color:"report.fg.muted",_hover:{color:"report.fg",bg:"report.secondary"},children:"Share"})]})})}export{Hn as component};

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.