torre 0.3.2.dev2__py3-none-any.whl → 0.3.3.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- torre/__init__.py +1 -1
- torre/server/studio.py +34 -3
- torre/ui/assets/{AiSetup-D0ojvOo6.js → AiSetup-BwHmjMLW.js} +1 -1
- torre/ui/assets/{AnalysisBanner-CgzZjuOs.js → AnalysisBanner-BL9q5ifl.js} +1 -1
- torre/ui/assets/{ArenaPage-DhhtFsO6.js → ArenaPage-Dwb97gYq.js} +1 -1
- torre/ui/assets/{AwardsPage-DIBR--pI.js → AwardsPage-BJQE0Xg3.js} +1 -1
- torre/ui/assets/BoardWorkspace-Dwl4rkFt.js +1 -0
- torre/ui/assets/BotCollectionPage-bhOqBdmS.js +1 -0
- torre/ui/assets/{BotReport-CegOQG0r.js → BotReport-ZRLG8BaH.js} +1 -1
- torre/ui/assets/BotsHomePage-6y1bUgcR.js +1 -0
- torre/ui/assets/{CoachExplain-CfTPObIL.js → CoachExplain-yo1VnMw4.js} +1 -1
- torre/ui/assets/{CoachPage-D01hygof.js → CoachPage-DFdwujZw.js} +1 -1
- torre/ui/assets/{EndgamesPage-DJGzTpkE.js → EndgamesPage-DltYRusp.js} +1 -1
- torre/ui/assets/{ExplorePage-iB6Kc6kX.js → ExplorePage-NfO4-4GB.js} +1 -1
- torre/ui/assets/GamesPage-DpvdcCTu.js +1 -0
- torre/ui/assets/HomePage-B0MjrRea.js +1 -0
- torre/ui/assets/{ImportPage-Bn5g3rvQ.js → ImportPage-CZcx0sHQ.js} +2 -2
- torre/ui/assets/InsightsPage-D0qeKM7h.js +1 -0
- torre/ui/assets/{LessonsPage-DeE2ulM2.js → LessonsPage-fprxNY-z.js} +1 -1
- torre/ui/assets/MiniBoard-hInvnSKf.js +1 -0
- torre/ui/assets/{MoveList-DytFbAp6.js → MoveList-DmeC8rTb.js} +1 -1
- torre/ui/assets/{OpeningStory-CnmDg1zw.js → OpeningStory-DLTeyFyB.js} +1 -1
- torre/ui/assets/{OpeningsPage-DydTgh8d.js → OpeningsPage-C4wjixAn.js} +1 -1
- torre/ui/assets/PhoneParts-BMOk4VLC.js +1 -0
- torre/ui/assets/PlayPage-BN6fEfQe.js +3 -0
- torre/ui/assets/{ProfilePage-DOSgcVMv.js → ProfilePage-DNc_nUTH.js} +1 -1
- torre/ui/assets/{PuzzlesPage-ofZhK6FU.js → PuzzlesPage-DNe3b4sI.js} +1 -1
- torre/ui/assets/{RookSpeaker-B_HLzkJm.js → RookSpeaker-Bsvcd1Z1.js} +1 -1
- torre/ui/assets/SettingsPage-Cx0H2b3p.js +1 -0
- torre/ui/assets/{Sidebar-Cio69IXU.js → Sidebar-ww3s_cI7.js} +1 -1
- torre/ui/assets/{StagePage-CMmIR1l-.js → StagePage-CNoKRUOX.js} +1 -1
- torre/ui/assets/{StoryPage-DplmoBTf.js → StoryPage-BAQVSCd0.js} +1 -1
- torre/ui/assets/{TodayPlan-D_0arCyI.js → TodayPlan-BTko_tLv.js} +1 -1
- torre/ui/assets/{TrainPage-D5NthACf.js → TrainPage-BqwwmtYz.js} +1 -1
- torre/ui/assets/{TrainerPages-BHIhhs8R.js → TrainerPages-DBt5UJCr.js} +1 -1
- torre/ui/assets/{awards-B1W0K4TV.js → awards-CdOsL55a.js} +1 -1
- torre/ui/assets/{bots-CqReul03.js → bots-CmOYIVmQ.js} +1 -1
- torre/ui/assets/{collections-2qe_ozuB.js → collections-BRU1tQk9.js} +1 -1
- torre/ui/assets/{content-D7CTF3q9.js → content-DWLaOO2z.js} +1 -1
- torre/ui/assets/{format-BR0clSXu.js → format-CyB705xj.js} +1 -1
- torre/ui/assets/{grades-CM1ebojp.js → grades-D6OvtJ99.js} +1 -1
- torre/ui/assets/{i18n-C6NUi9Vs.js → i18n-Cg-9EHIv.js} +2 -2
- torre/ui/assets/i18n-en-D2e5RdZ6.js +1 -0
- torre/ui/assets/i18n-es-Bnk2yvL_.js +1 -0
- torre/ui/assets/index-Ba3yxWjC.js +2 -0
- torre/ui/assets/{index-Zp2E1Y4q.css → index-Dz_TR6NX.css} +1 -1
- torre/ui/assets/{routes-C8cKcny6.js → routes-SOm45MWj.js} +1 -1
- torre/ui/assets/{storage-CWyoBvAQ.js → storage-CuQ-NiCI.js} +1 -1
- torre/ui/assets/{useChess-DdakFbd7.js → useChess-sMdAC0kt.js} +1 -1
- torre/ui/assets/useMasters-DtS0PB6J.js +1 -0
- torre/ui/assets/{useNarration-IQPX4VHr.js → useNarration-OmDn79jq.js} +1 -1
- torre/ui/assets/{usePlanning-BfNQrrQD.js → usePlanning-M5mnt77_.js} +1 -1
- torre/ui/assets/{useProfile-COaif7mf.js → useProfile-BN14mByx.js} +1 -1
- torre/ui/assets/{useSounds-DtGm8WF1.js → useSounds-Dr7vf2mM.js} +1 -1
- torre/ui/index.html +3 -3
- torre/ui/locales/en/board.json +4 -0
- torre/ui/locales/en/home.json +45 -0
- torre/ui/locales/en/play.json +32 -1
- torre/ui/locales/es/board.json +4 -0
- torre/ui/locales/es/home.json +45 -0
- torre/ui/locales/es/play.json +32 -1
- {torre-0.3.2.dev2.dist-info → torre-0.3.3.dev2.dist-info}/METADATA +1 -1
- {torre-0.3.2.dev2.dist-info → torre-0.3.3.dev2.dist-info}/RECORD +67 -65
- torre/ui/assets/BoardWorkspace-Cxrtuejv.js +0 -1
- torre/ui/assets/BotCollectionPage-DMIe2Mqp.js +0 -1
- torre/ui/assets/BotsHomePage-D73LJY3O.js +0 -1
- torre/ui/assets/GamesPage-BeCyNtCU.js +0 -1
- torre/ui/assets/HomePage-jcAUG1nj.js +0 -1
- torre/ui/assets/InsightsPage-CHoneM_p.js +0 -1
- torre/ui/assets/PlayPage-DK9-UawI.js +0 -3
- torre/ui/assets/SettingsPage-C4mt0o7O.js +0 -1
- torre/ui/assets/i18n-en-BnZCUyK7.js +0 -1
- torre/ui/assets/i18n-es-SAH-03ta.js +0 -1
- torre/ui/assets/index-Cl_QBZkR.js +0 -2
- torre/ui/assets/useMasters-CW1vT-o3.js +0 -1
- {torre-0.3.2.dev2.dist-info → torre-0.3.3.dev2.dist-info}/WHEEL +0 -0
- {torre-0.3.2.dev2.dist-info → torre-0.3.3.dev2.dist-info}/entry_points.txt +0 -0
- {torre-0.3.2.dev2.dist-info → torre-0.3.3.dev2.dist-info}/licenses/LICENSE +0 -0
- {torre-0.3.2.dev2.dist-info → torre-0.3.3.dev2.dist-info}/top_level.txt +0 -0
torre/__init__.py
CHANGED
torre/server/studio.py
CHANGED
|
@@ -43,6 +43,8 @@ PROXIED = False
|
|
|
43
43
|
ALLOWED_HOSTS = []
|
|
44
44
|
UI_DIR = paths.UI # built by `npm run build` in web/
|
|
45
45
|
STATIC_TYPES = MEDIA_TYPES
|
|
46
|
+
# Images, fonts and sounds of the built interface: kept a day by the browser (Handler.send_static).
|
|
47
|
+
CACHED_MEDIA = {'.png', '.webp', '.svg', '.ico', '.woff2', '.mp3', '.ogg', '.wav', '.m4a'}
|
|
46
48
|
# Uploaded PGN collections can be large; everything else is small.
|
|
47
49
|
BODY_LIMITS = {'/api/import/files': 30_000_000}
|
|
48
50
|
BODY_LIMIT = 1_000_000
|
|
@@ -116,6 +118,37 @@ class Handler(BaseHTTPRequestHandler):
|
|
|
116
118
|
self.end_headers()
|
|
117
119
|
self.wfile.write(data)
|
|
118
120
|
|
|
121
|
+
def send_static(self, path, target):
|
|
122
|
+
"""A file of the built interface, cached by what it is. Vite puts a content hash in every
|
|
123
|
+
/assets/ name, so those never change. The art, fonts and sounds keep their names across
|
|
124
|
+
releases: they are kept a day, then shown while the browser checks for a newer copy. The
|
|
125
|
+
rest is checked every time. The checks are cheap: an unchanged file answers 304."""
|
|
126
|
+
stat = target.stat()
|
|
127
|
+
etag = f'"{stat.st_size:x}-{stat.st_mtime_ns:x}"'
|
|
128
|
+
if path.startswith('/assets/'):
|
|
129
|
+
cache = 'public, max-age=31536000, immutable'
|
|
130
|
+
elif target.suffix in CACHED_MEDIA:
|
|
131
|
+
cache = 'public, max-age=86400, stale-while-revalidate=604800'
|
|
132
|
+
else:
|
|
133
|
+
cache = 'no-cache'
|
|
134
|
+
if etag in (tag.strip() for tag in self.headers.get('If-None-Match', '').split(',')):
|
|
135
|
+
self.responded = True
|
|
136
|
+
self.send_response(304)
|
|
137
|
+
self.send_header('ETag', etag)
|
|
138
|
+
self.send_header('Cache-Control', cache)
|
|
139
|
+
self.end_headers()
|
|
140
|
+
return None
|
|
141
|
+
data = target.read_bytes()
|
|
142
|
+
self.responded = True
|
|
143
|
+
self.send_response(200)
|
|
144
|
+
self.send_header('Content-Type', STATIC_TYPES[target.suffix])
|
|
145
|
+
self.send_header('Content-Length', str(len(data)))
|
|
146
|
+
self.send_header('Cache-Control', cache)
|
|
147
|
+
self.send_header('ETag', etag)
|
|
148
|
+
self.end_headers()
|
|
149
|
+
self.wfile.write(data)
|
|
150
|
+
return None
|
|
151
|
+
|
|
119
152
|
def reply(self, result):
|
|
120
153
|
"""Send what a route handler returned: a Response, a (body, status) pair, or a body."""
|
|
121
154
|
if isinstance(result, Response):
|
|
@@ -189,9 +222,7 @@ class Handler(BaseHTTPRequestHandler):
|
|
|
189
222
|
return self.reply(result)
|
|
190
223
|
target = static_file(path)
|
|
191
224
|
if target is not None:
|
|
192
|
-
|
|
193
|
-
cache = 'public, max-age=31536000, immutable' if path.startswith('/assets/') else 'no-store'
|
|
194
|
-
return self.send(target.read_bytes(), content_type=STATIC_TYPES[target.suffix], cache=cache)
|
|
225
|
+
return self.send_static(path, target)
|
|
195
226
|
if path.startswith(('/api/', '/assets/')) or Path(path).suffix:
|
|
196
227
|
return self.send({'error': 'Not found'}, 404)
|
|
197
228
|
# Every other path is a page of the app (/games/123/11, /train, ...).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,t as r}from"./vendor-DVQGMHsh.js";import{J as i}from"./i18n-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,t as r}from"./vendor-DVQGMHsh.js";import{J as i}from"./i18n-Cg-9EHIv.js";import{At as a,jt as o}from"./index-Ba3yxWjC.js";import{t as s}from"./Segments-B8XJlwPB.js";var c=e(t(),1),l=r(),u=e=>`setting-${e.replace(/\./g,`-`)}`;function d({label:e,note:t,show:r,htmlFor:a}){let{t:o}=n(`settings`),s=i.use(),c=a?(0,l.jsx)(`label`,{htmlFor:a,children:(0,l.jsx)(`strong`,{children:e})}):(0,l.jsx)(`strong`,{children:e});return s||r?(0,l.jsxs)(`span`,{className:`settings-row-text`,children:[c,(0,l.jsx)(`small`,{children:t})]}):(0,l.jsx)(`span`,{className:`settings-row-text`,children:(0,l.jsxs)(`span`,{className:`settings-row-name`,children:[c,(0,l.jsx)(`button`,{type:`button`,className:`settings-info`,"aria-label":o(`info`,{setting:e}),"data-tip":t,children:(0,l.jsxs)(`svg`,{"aria-hidden":`true`,width:`14`,height:`14`,viewBox:`0 0 16 16`,children:[(0,l.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`}),(0,l.jsx)(`path`,{d:`M8 7v4.5M8 4.6v.1`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`})]})})]})})}function f({id:e,label:t,note:n,disabled:r,keepNote:i,children:a}){return(0,l.jsxs)(`div`,{id:e,className:`settings-row${r?` disabled`:``}`,children:[(0,l.jsx)(d,{label:t,note:n,show:i||r}),a]})}function p({id:e,label:t,note:n,checked:r,disabled:i,onChange:a}){let o=(0,c.useId)();return(0,l.jsxs)(`div`,{id:e,className:`settings-row settings-switch${i?` disabled`:``}`,children:[(0,l.jsx)(d,{label:t,note:n,show:i,htmlFor:o}),(0,l.jsx)(`input`,{id:o,type:`checkbox`,role:`switch`,checked:r,disabled:i,onChange:e=>a(e.target.checked)})]})}function m({setting:e,text:t,disabled:r}){let{t:i}=n(`settings`);return(0,l.jsx)(p,{id:u(t),label:i(t),note:i(`${t}Note`),checked:e.use(),disabled:r,onChange:e.set})}function h({label:e,options:t,value:n,disabled:r,onChange:i}){return(0,l.jsx)(s,{className:`bots-segments settings-segments`,role:`group`,"aria-label":e,children:t.map(([e,t])=>(0,l.jsx)(`button`,{type:`button`,"aria-pressed":e===n,className:e===n?`selected`:``,disabled:r,onClick:()=>i(e),children:t},e))})}function g({setting:e,values:t,text:r,group:i,disabled:a}){let{t:o}=n(`settings`);return(0,l.jsx)(f,{id:u(r),label:o(r),note:o(`${r}Note`),disabled:a,children:(0,l.jsx)(h,{label:o(r),options:t.map(e=>[e,o(`${i}.${e}`)]),value:e.use(),disabled:a,onChange:e.set})})}function _({setting:e,text:t,disabled:r,children:i}){let{t:a}=n(`settings`),o=e.use();return(0,l.jsx)(f,{id:u(t),label:a(t),note:a(`${t}Note`),disabled:r,children:(0,l.jsxs)(`span`,{className:`settings-level`,children:[(0,l.jsx)(`input`,{type:`range`,min:0,max:100,step:5,value:o,"aria-label":a(t),disabled:r,"aria-valuetext":`${o}%`,onChange:t=>e.set(Number(t.target.value)),style:{"--level":`${o}%`}}),(0,l.jsxs)(`output`,{children:[o,`%`]}),i]})})}var v=({id:e,children:t})=>(0,l.jsx)(`h3`,{id:e,className:`settings-subheading`,children:t}),y=e=>e?e.split(`/`)[0]:null;function b({onSaved:e}){let{t}=n(`settings`),[r,i]=(0,c.useState)(null),[o,s]=(0,c.useState)(null),[d,f]=(0,c.useState)([]),[p,m]=(0,c.useState)(``),[h,g]=(0,c.useState)(``),[_,v]=(0,c.useState)(!1),[b,x]=(0,c.useState)(null),[S,C]=(0,c.useState)(null);(0,c.useEffect)(()=>{a(`api/coach/ai`).then(e=>{i(e);let t=y(e.model);s(e.providers.some(e=>e.id===t)?t:e.providers[0]?.id??null)}).catch(e=>x(e.message))},[]);let w=r?.providers.find(e=>e.id===o)??null;(0,c.useEffect)(()=>{if(!w)return;if(x(null),w.local){f(w.models??[]);return}if(!w.has_key){f([]);return}let e=!0;return a(`api/coach/ai/models`,{provider:w.id}).then(n=>{e&&(f(n.models),n.error&&x(t(`ai.keyStale`,{name:w.name})))}).catch(t=>e&&x(t.message)),()=>{e=!1}},[w,t]),(0,c.useEffect)(()=>{let e=r?.model&&y(r.model)===o?r.model.slice(o.length+1):null;m(e&&d.includes(e)?e:d[0]??``)},[d,r,o]);let T=(0,c.useCallback)(async e=>{if(e.preventDefault(),w&&h.trim()){v(!0),x(null);try{i(await a(`api/coach/ai/key`,{provider:w.id,key:h.trim()})),g(``)}catch(e){x(e.message)}v(!1)}},[w,h]);return r?(0,l.jsxs)(`div`,{className:`ai-setup`,children:[(0,l.jsxs)(`div`,{id:u(`ai.provider`),className:`ai-setup-step`,children:[(0,l.jsx)(`h3`,{children:t(`ai.provider`)}),(0,l.jsx)(`p`,{className:`ai-setup-note`,children:t(r.hosted?`ai.providerNoteHosted`:`ai.providerNote`)}),(0,l.jsx)(`div`,{className:`ai-providers`,role:`radiogroup`,"aria-label":t(`ai.provider`),children:r.providers.map(e=>(0,l.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e.id===o,className:`ai-provider${e.id===o?` is-chosen`:``}`,onClick:()=>s(e.id),children:[(0,l.jsx)(`span`,{className:`ai-provider-name`,children:e.name}),(0,l.jsx)(`span`,{className:`ai-provider-state`,children:e.local?t(`ai.onThisComputer`):e.has_key?t(`ai.keySavedShort`):t(`ai.needsKey`)})]},e.id))})]}),w&&!w.local&&(0,l.jsxs)(`div`,{id:u(`ai.key`),className:`ai-setup-step`,children:[(0,l.jsx)(`h3`,{children:t(`ai.key`)}),w.has_key?(0,l.jsxs)(`p`,{className:`ai-setup-note`,children:[t(`ai.keySaved`,{name:w.name,hint:w.key_hint}),` `,(0,l.jsx)(`button`,{type:`button`,className:`text-button`,disabled:_,onClick:async()=>{if(w){v(!0),x(null);try{i(await a(`api/coach/ai/key`,{provider:w.id,key:``}))}catch(e){x(e.message)}v(!1)}},children:t(`ai.removeKey`)})]}):(0,l.jsxs)(`form`,{className:`ai-key`,onSubmit:T,children:[(0,l.jsx)(`input`,{type:`password`,value:h,onChange:e=>g(e.target.value),autoComplete:`off`,spellCheck:!1,"aria-label":t(`ai.keyFor`,{name:w.name}),placeholder:t(`ai.keyPlaceholder`)}),(0,l.jsx)(`button`,{type:`submit`,className:`button`,disabled:_||!h.trim(),children:t(_?`ai.checking`:`ai.saveKey`)})]}),(0,l.jsxs)(`p`,{className:`ai-setup-note`,children:[t(`ai.keyNote`),` `,(0,l.jsx)(`a`,{href:w.key_url,target:`_blank`,rel:`noreferrer`,children:t(`ai.getKey`,{name:w.name})})]})]}),w&&(0,l.jsxs)(`div`,{id:u(`ai.model`),className:`ai-setup-step`,children:[(0,l.jsx)(`h3`,{children:t(`ai.model`)}),d.length?(0,l.jsxs)(`div`,{className:`ai-model`,children:[(0,l.jsx)(`select`,{value:p,onChange:e=>m(e.target.value),"aria-label":t(`ai.model`),children:d.map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))}),(0,l.jsx)(`button`,{type:`button`,className:`button primary`,disabled:_||!p,onClick:async()=>{if(!w||!p)return;let t=`${w.id}/${p}`;v(!0),x(null);try{await a(`api/coach/model`,{model:t}),i(e=>e&&{...e,model:t,auto:!1}),C(t),e?.(t)}catch(e){x(e.message)}v(!1)},children:t(`ai.use`)})]}):(0,l.jsx)(`p`,{className:`ai-setup-note`,children:w.local?t(`ai.ollamaMissing`):t(`ai.modelsAfterKey`)})]}),(S??r.model)&&(0,l.jsx)(`p`,{className:`ai-setup-current`,role:`status`,children:S?t(`ai.saved`,{model:S}):r.auto?t(`ai.currentAuto`,{model:r.model}):t(`ai.current`,{model:r.model})}),b&&(0,l.jsx)(`p`,{className:`ai-setup-error`,role:`alert`,children:b})]}):(0,l.jsx)(`p`,{className:`ai-setup-note`,role:b?`alert`:`status`,children:b??t(`ai.loading`)})}function x({open:e,onClose:t}){let{t:r}=n(`settings`),[i,a]=(0,c.useState)(!1);return(0,l.jsx)(o,{id:`ai-setup`,open:e,onClose:()=>t(i),children:(0,l.jsxs)(`div`,{className:`ai-setup-dialog`,children:[(0,l.jsx)(`h2`,{children:r(`ai.dialogTitle`)}),(0,l.jsx)(`p`,{className:`ai-setup-note`,children:r(`ai.dialogText`)}),(0,l.jsx)(b,{onSaved:()=>a(!0)}),(0,l.jsx)(`div`,{className:`ai-setup-actions`,children:(0,l.jsx)(`button`,{type:`button`,className:i?`button primary`:`text-button`,onClick:()=>t(i),children:r(i?`ai.done`:`ai.later`)})})]})})}export{m as a,v as c,h as i,p as l,x as n,_ as o,g as r,f as s,b as t,u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,t as r}from"./vendor-DVQGMHsh.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,t as r}from"./vendor-DVQGMHsh.js";import{Ct as i,Dt as a,ot as o}from"./index-Ba3yxWjC.js";var s=e(t(),1),c=r(),l=2;function u(){let{analysis:e,startAnalysis:t,stopAnalysis:r}=i(),u=a(),{t:d}=n(`board`),[f,p]=(0,s.useState)(!1);if(!e)return null;let m=e=>async()=>{p(!0);try{await e()}catch(e){u(e.message)}finally{p(!1)}};if(e.running)return(0,c.jsxs)(`div`,{className:`analysis-runner`,role:`status`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`strong`,{children:e.current?.mining?d(`analysis.mining`):d(`analysis.running`)}),(0,c.jsxs)(`span`,{children:[d(`analysis.progress`,{done:e.done,total:e.total}),e.current&&!e.current.mining?` · ${d(`analysis.versus`,{opponent:e.current.opponent||d(`analysis.unknown`)})}`:``,e.my_puzzles?` · ${d(`analysis.mined`,{count:e.my_puzzles})}`:``]})]}),(0,c.jsx)(`progress`,{max:e.total,value:e.done,"aria-label":d(`analysis.progressLabel`)}),(0,c.jsx)(`button`,{type:`button`,className:`analysis-runner-button`,disabled:f,onClick:m(r),children:d(`analysis.stop`)})]});if(e.error)return(0,c.jsxs)(`div`,{className:`analysis-runner`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`strong`,{children:d(`analysis.stopped`)}),(0,c.jsx)(`span`,{children:e.error})]}),(0,c.jsx)(`button`,{type:`button`,className:`analysis-runner-button`,disabled:f,onClick:m(t),children:d(`analysis.retry`)})]});if(!e.remaining)return null;if(!e.engine)return(0,c.jsx)(`div`,{className:`analysis-runner`,children:(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`strong`,{children:d(`analysis.notAnalyzed`,{count:e.remaining})}),(0,c.jsx)(`span`,{children:d(`analysis.install`)})]})});let h=Math.max(1,Math.round(e.remaining*l/60)),g=e.outdated?d(`analysis.toAnalyze`,{count:e.remaining,outdated:e.outdated}):d(`analysis.notAnalyzedYet`,{count:e.remaining});return(0,c.jsxs)(`div`,{className:`analysis-runner`,children:[(0,c.jsx)(`img`,{className:`runner-art`,src:o,alt:``,width:`44`,height:`44`}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`strong`,{children:g}),(0,c.jsx)(`span`,{children:d(`analysis.estimate`,{minutes:h})})]}),(0,c.jsx)(`button`,{type:`button`,className:`analysis-runner-button primary`,disabled:f,onClick:m(t),children:d(`analysis.all`)})]})}export{u as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,s as r,t as i}from"./vendor-DVQGMHsh.js";import{Dt as a,Ot as o,St as s}from"./index-Cl_QBZkR.js";import{a as c,i as l,l as u,s as d,t as f}from"./grades-CM1ebojp.js";import{n as p,t as m}from"./usePlanning-BfNQrrQD.js";import{t as h}from"./format-BR0clSXu.js";import{r as g,t as _}from"./MoveList-DytFbAp6.js";import{_ as v,b as y,h as b,l as x,m as S,v as C,y as w}from"./bots-CqReul03.js";import{t as T}from"./useMasters-CW1vT-o3.js";import{s as E}from"./routes-C8cKcny6.js";import{t as D}from"./Segments-B8XJlwPB.js";var O=e(t(),1),k=i();function ee({refresh:e}){let{t}=n(`arena`),[r,i]=(0,O.useState)(null);if((0,O.useEffect)(()=>{let e=new AbortController;return o(`api/arena/ladder`,void 0,e.signal).then(i).catch(()=>{}),()=>e.abort()},[e]),!r?.players.length)return null;let a=Math.min(...r.players.map(e=>e.ci_low))-50,s=Math.max(...r.players.map(e=>e.ci_high))+50,c=e=>`${(e-a)/(s-a)*100}%`;return(0,k.jsxs)(`section`,{className:`arena-recent arena-ladder`,"aria-labelledby":`arena-ladder-title`,children:[(0,k.jsx)(`h2`,{id:`arena-ladder-title`,children:t(`ladder.title`)}),(0,k.jsx)(`ol`,{className:`arena-list`,children:r.players.map((e,n)=>{let r=e.placed_by===`anchor`||e.placed_by===`nominal`;return(0,k.jsxs)(`li`,{className:`arena-rung`,children:[(0,k.jsx)(`span`,{className:`arena-rank${n<3?` medal-${n+1}`:``}`,"aria-label":t(`ladder.rankLabel`,{rank:n+1}),children:n+1}),(0,k.jsxs)(`div`,{className:`arena-rung-main`,children:[(0,k.jsxs)(`div`,{className:`arena-rung-name`,children:[(0,k.jsx)(`strong`,{children:e.name}),(0,k.jsxs)(`span`,{title:t(`ladder.games`),children:[e.wins,` · `,e.draws,` · `,e.losses]})]}),e.ci_low!==e.ci_high&&(0,k.jsxs)(`i`,{className:`arena-range`,"aria-hidden":`true`,children:[(0,k.jsx)(`b`,{style:{left:c(e.ci_low),width:`calc(${c(e.ci_high)} - ${c(e.ci_low)})`}}),(0,k.jsx)(`em`,{style:{left:c(e.rating)}})]}),(0,k.jsxs)(`small`,{children:[e.ci_low===e.ci_high?``:t(`ladder.rangeText`,{low:e.ci_low,high:e.ci_high}),r?`${e.ci_low===e.ci_high?``:` · `}${t(`ladder.nominal`,{elo:e.nominal??e.rating})}`:``]})]}),(0,k.jsxs)(`span`,{className:`arena-rung-rating`,children:[(0,k.jsx)(`strong`,{children:e.rating}),(0,k.jsx)(`small`,{children:t(`ladder.scoreText`,{score:e.score})})]})]},e.id)})}),(0,k.jsxs)(`p`,{className:`arena-hint`,children:[t(`ladder.hint`,{count:r.games}),r.groups>1?` ${t(`ladder.groups`,{count:r.groups})}`:``]})]})}var A=u.nodeElo.map(([e,t])=>[e,t]),j=[50,200,800,1600,3200,12800,51200,204800];function M(e){let t=A[0],n=A[A.length-1];if(e<=t[0])return t[1];for(let t=1;t<A.length;t++){let[n,r]=A[t-1],[i,a]=A[t];if(e<=i)return Math.round(r+(a-r)*Math.log(e/n)/Math.log(i/n))}return n[1]}var N=500,P=400,te=[2,4,10,20,100],ne=[.1,.3,1,3],F=[0,800,1200,1500,1800,2e3,2200,2500,2800];function I(e,t){return e.openingName?e.eco?`${e.openingName} (${e.eco})`:e.openingName:e.opening?t(`openings.${e.opening}`):``}function re(e){let[t,n,r]=e.key.split(`:`);return t===`master`?{masterId:n}:t===`model`?{engineId:n,modelId:r}:{engineId:n,...e.elo?{elo:e.elo}:{},...e.nodes?{nodes:e.nodes}:{}}}var L=e=>!!e&&(e.id===`stockfish`||e.capabilities.limit_strength||e.capabilities.skill_level);function R(e,t){if(e.result===`1/2-1/2`)return`½`;let n=e.result===`1-0`;return e.white===t===n?`1`:`0`}var z=e=>Number.isInteger(e)?String(e):`${Math.floor(e)||``}½`;function B(e){return e?{cp:e.cp??0,mate:e.mate,moves:[],uci:[]}:null}function V(e,t){return e.result?e.result===`1-0`?100:e.result===`0-1`?0:50:t?t.mate===null?Math.round(100/(1+10**(-t.cp/400))):t.mate>0?100:0:null}function H(e){return e?e.mate!==null&&e.mate!==void 0?`#${e.mate}`:e.cp===null||e.cp===void 0?null:`${e.cp>0?`+`:``}${(e.cp/100).toFixed(1)}`:null}function U(){let{t:e}=n(`arena`),{engines:t,loaded:i}=s(),{masters:c,missing:l,loaded:u,replace:d}=T(),[f,p]=(0,O.useState)(null),[m,h]=(0,O.useState)(null),[g,_]=(0,O.useState)([{key:``,elo:0},{key:``,elo:0}]),[v,y]=(0,O.useState)({games:2,movetime:.3,openings:`start`,pace:`watch`}),[b,x]=(0,O.useState)(!1),[S,C]=(0,O.useState)(null),[w,E]=(0,O.useState)(!1),{schedule:D,cancel:A,signal:j}=a(),M=(0,O.useMemo)(()=>t.filter(e=>e.installed),[t]),F={engines:M,models:(0,O.useMemo)(()=>M.flatMap(e=>(e.models??[]).filter(e=>e.installed).map(t=>({engine:e,model:t}))),[M]),masters:c};(0,O.useEffect)(()=>{if(!i||!u||g[0].key)return;let e=c.find(e=>e.id===`Carlsen`)??c[0];_([e?{key:`master:${e.id}`,elo:0}:{key:`engine:stockfish`,elo:1500},{key:`engine:stockfish`,elo:e?2500:2e3}])},[i,u,c,g]);let I=(0,O.useCallback)(async()=>{A();let e=j();try{let t=await o(`api/arena`,void 0,e);if(e.aborted)return;p(t),t.running&&D(I,N)}catch(t){e.aborted||h(t.message)}},[A,D,j]);(0,O.useEffect)(()=>{I()},[I]);async function L(){x(!0),h(null),C(null),E(!1);try{p(await o(`api/arena/start`,{players:g.map(re),...v})),D(I,P)}catch(e){h(e.message)}finally{x(!1)}}async function R(){try{p(await o(`api/arena/stop`,{}))}catch(e){h(e.message)}}async function B(e){E(!1);try{C(await o(`api/arena/matches/${e.id}`))}catch(e){h(e.message)}}let V=!!f?.running,H=S??f?.match??null,U=g.every(e=>e.key),G=V&&!S?`live`:!H||w?`setup`:H.current?`live`:`result`,q=[K(g[0],F,e),K(g[1],F,e)],Y=t=>(0,k.jsx)(ie,{label:e(`setup.player${t+1}`),seat:g[t],view:q[t],disabled:V,roster:F,onChange:e=>_(t?[g[0],e]:[e,g[1]])},t);return(0,k.jsxs)(`section`,{id:`arena`,"aria-label":e(`label`),"data-stage":G,children:[(0,k.jsxs)(`header`,{className:`arena-header`,children:[(0,k.jsx)(`h1`,{children:e(`title`)}),(0,k.jsx)(r,{className:`button`,to:`/settings/engines`,children:e(`enginesLink`)})]}),m&&(0,k.jsx)(`p`,{className:`arena-error`,role:`alert`,children:m}),G===`setup`&&(0,k.jsxs)(`section`,{className:`arena-setup`,"aria-label":e(`setup.label`),children:[(0,k.jsxs)(`div`,{className:`arena-faceoff`,children:[Y(0),(0,k.jsx)(ae,{a:q[0],b:q[1],games:v.games}),Y(1)]}),(0,k.jsxs)(`div`,{className:`arena-options`,children:[(0,k.jsxs)(`div`,{className:`arena-settings`,children:[(0,k.jsx)(W,{label:e(`setup.games`),options:te.map(e=>[e,String(e)]),value:v.games,disabled:V,onChange:e=>y({...v,games:e})}),(0,k.jsx)(W,{label:e(`setup.movetime`),options:ne.map(t=>[t,e(`setup.seconds`,{seconds:t})]),value:v.movetime,disabled:V,onChange:e=>y({...v,movetime:e})}),(0,k.jsx)(W,{label:e(`setup.openings`),options:[[`start`,e(`setup.openingsStart`)],[`varied`,e(`setup.openingsVaried`)],[`book`,e(`setup.openingsBook`)]],value:v.openings,disabled:V,onChange:e=>y({...v,openings:e})}),(0,k.jsx)(W,{label:e(`setup.pace`),options:[[`watch`,e(`setup.paceWatch`)],[`fast`,e(`setup.paceFast`)]],value:v.pace,disabled:V,onChange:e=>y({...v,pace:e})}),(0,k.jsx)(W,{label:e(`setup.sprt`),options:[[`off`,e(`setup.sprtOff`)],[`on`,e(`setup.sprtOn`)]],value:v.sprt?`on`:`off`,disabled:V,onChange:e=>y({...v,sprt:e===`on`})})]}),(0,k.jsxs)(`div`,{className:`arena-go`,children:[(0,k.jsxs)(`p`,{className:`arena-hint`,children:[e({start:`setup.startHint`,varied:`setup.variedHint`,book:`setup.bookHint`}[v.openings]),v.sprt?` ${e(`setup.sprtHint`)}`:``]}),H&&(0,k.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>E(!1),children:e(`result.back`)}),(0,k.jsx)(`button`,{type:`button`,className:`button primary arena-start`,disabled:!U||b,onClick:()=>void L(),children:e(b?`starting`:`start`)})]})]}),(0,k.jsx)(oe,{missing:l,onAdded:d})]}),G===`live`&&H&&(0,k.jsx)(le,{match:H,running:V&&!S,onStop:()=>void R(),onClose:S?()=>C(null):void 0}),G===`result`&&H&&(0,k.jsx)(ue,{match:H,canRematch:U&&!b,onRematch:()=>void L(),onNew:()=>{C(null),E(!0)}}),G!==`live`&&(0,k.jsxs)(`div`,{className:`arena-columns`,children:[!!f?.recent.length&&(0,k.jsxs)(`section`,{className:`arena-recent`,"aria-labelledby":`arena-recent-title`,children:[(0,k.jsx)(`h2`,{id:`arena-recent-title`,children:e(`recent.title`)}),(0,k.jsx)(`ul`,{className:`arena-list`,children:f.recent.map(t=>{let[n,r]=t.players;return(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,onClick:()=>void B(t),"aria-pressed":S?.id===t.id,children:[(0,k.jsx)(`img`,{className:`arena-tile`,src:J(n),alt:``}),(0,k.jsxs)(`span`,{className:`arena-recent-main`,children:[(0,k.jsxs)(`span`,{className:`arena-recent-names`,children:[(0,k.jsx)(`span`,{className:t.score[0]>t.score[1]?`won`:void 0,children:n.name}),(0,k.jsxs)(`b`,{children:[z(t.score[0]),`–`,z(t.score[1])]}),(0,k.jsx)(`span`,{className:t.score[1]>t.score[0]?`won`:void 0,children:r.name})]}),(0,k.jsxs)(`small`,{children:[t.date,` · `,e(`recent.games`,{count:t.games_played}),t.elo_diff===null?``:` · ${e(`eloGap`,{name:t.players[t.elo_diff>=0?0:1].name,elo:Math.abs(t.elo_diff)})}`,t.stopped?` · ${e(`recent.stopped`)}`:``,t.early&&t.sprt?.verdict?` · ${e(`recent.sprt`)}`:``]})]}),(0,k.jsx)(`img`,{className:`arena-tile`,src:J(r),alt:``})]})},t.id)})})]}),(0,k.jsx)(ee,{refresh:f?.recent[0]?.id})]})]})}function W({label:e,options:t,value:n,disabled:r,onChange:i}){return(0,k.jsxs)(`div`,{className:`arena-choice`,role:`group`,"aria-label":e,children:[(0,k.jsx)(`span`,{children:e}),(0,k.jsx)(D,{children:t.map(([e,t])=>(0,k.jsx)(`button`,{type:`button`,"aria-pressed":e===n,className:e===n?`selected`:``,disabled:r,onClick:()=>i(e),children:t},String(e)))})]})}var G=e=>e.split(/\s+/).filter(Boolean).map(e=>e[0]).slice(0,2).join(``).toUpperCase();function K(e,t,n){let[r,i,a]=e.key.split(`:`);if(r===`master`){let e=t.masters.find(e=>e.id===i);if(e)return{name:e.name,kind:`legend`,figure:w(e.id),initials:G(e.name),rating:e.elo,ratingText:String(e.elo),blurb:n(e.rated?`setup.legendNote`:`setup.legendNoteUnrated`,{count:e.games,games:e.games.toLocaleString(),elo:e.elo})}}if(r===`model`){let e=t.models.find(({engine:e,model:t})=>e.id===i&&t.id===a);if(e){let t=e.model.rating_target??null;return{name:e.model.name,kind:`model`,figure:x(i,a),initials:G(e.model.name),rating:t,ratingText:t?`~${t}`:``,blurb:t?n(`setup.modelNote`,{elo:t}):e.engine.description}}}if(r===`engine`){let r=t.engines.find(e=>e.id===i);if(r){let t=e.nodes&&r.type!==`neural`?M(e.nodes):null,i=e.nodes?t:e.elo||r.strength_ccrl,a=e.nodes?t?`~${t}`:n(`setup.nodes`,{nodes:e.nodes.toLocaleString()}):e.elo?n(`setup.rating`,{elo:e.elo}):r.strength_ccrl?n(`setup.ccrl`,{elo:r.strength_ccrl}):``;return{name:r.name,kind:`engine`,figure:x(r.id),initials:G(r.name),rating:i,ratingText:a,blurb:r.description}}}return{name:n(`setup.choose`),kind:null,initials:``,rating:null,ratingText:``,blurb:``}}function ie({label:e,seat:t,view:r,disabled:i,roster:a,onChange:o}){let{t:s}=n(`arena`),[c,l]=(0,O.useState)(!1),u=t.key.startsWith(`engine:`)?a.engines.find(e=>e.id===t.key.split(`:`)[1]):void 0;return(0,k.jsxs)(`section`,{className:`arena-seat`,"aria-label":e,children:[(0,k.jsx)(`span`,{className:`arena-seat-slot`,children:e}),(0,k.jsx)(`div`,{className:`arena-seat-figure`,children:r.figure?(0,k.jsx)(`img`,{src:r.figure,alt:``},r.figure):r.initials?(0,k.jsx)(`span`,{className:`arena-initials`,children:r.initials}):null}),(0,k.jsxs)(`div`,{className:`arena-seat-who`,children:[(0,k.jsx)(`strong`,{children:r.name}),r.kind&&(0,k.jsxs)(`span`,{className:`arena-seat-tags`,children:[(0,k.jsx)(`span`,{className:`arena-kind ${r.kind}`,children:s(`kinds.${r.kind}`)}),r.ratingText&&(0,k.jsx)(`span`,{className:`arena-seat-rating`,children:r.ratingText})]}),r.blurb&&(0,k.jsx)(`p`,{className:`arena-seat-note`,children:r.blurb})]}),u&&(0,k.jsxs)(`label`,{className:`arena-strength`,children:[s(`setup.strength`),(0,k.jsxs)(`select`,{value:t.nodes?`n${t.nodes}`:t.elo,disabled:i,onChange:e=>{let n=e.target.value;o(n.startsWith(`n`)?{...t,elo:0,nodes:Number(n.slice(1))}:{...t,elo:Number(n),nodes:void 0})},children:[L(u)?(0,k.jsx)(`optgroup`,{label:s(`setup.ratings`),children:F.map(e=>(0,k.jsx)(`option`,{value:e,children:e?s(`setup.rating`,{elo:e}):s(`setup.fullStrength`)},e))}):(0,k.jsx)(`option`,{value:0,children:s(`setup.fullStrength`)}),(0,k.jsx)(`optgroup`,{label:s(`setup.nodeLimit`),children:j.map(e=>(0,k.jsx)(`option`,{value:`n${e}`,children:u.type===`neural`?s(`setup.nodes`,{nodes:e.toLocaleString()}):s(`setup.nodesRated`,{nodes:e.toLocaleString(),elo:M(e)})},e))})]})]}),(0,k.jsx)(`button`,{type:`button`,className:`button arena-change`,disabled:i,"aria-expanded":c,onClick:()=>l(!c),children:s(`setup.change`)}),c&&!i&&(0,k.jsx)(q,{label:e,current:t.key,roster:a,onClose:()=>l(!1),onPick:e=>{let n=a.engines.find(t=>`engine:${t.id}`===e);o({key:e,elo:L(n)?t.elo:0,nodes:n?t.nodes:void 0}),l(!1)}})]})}function q({label:e,current:t,roster:r,onPick:i,onClose:a}){let{t:o}=n(`arena`);(0,O.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]);let s=S.map(e=>[e,r.masters.filter(t=>C(t.id)===e).sort((e,t)=>b(e.id,t.id))]).filter(([,e])=>e.length),c=(e,n,r,a)=>(0,k.jsxs)(`button`,{type:`button`,className:`arena-pick`,"aria-pressed":t===e,onClick:()=>i(e),children:[r?(0,k.jsx)(`img`,{className:`arena-tile`,src:r,alt:``,loading:`lazy`}):(0,k.jsx)(`span`,{className:`arena-tile arena-initials`,children:G(n)}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`strong`,{children:n}),a&&(0,k.jsx)(`small`,{children:a})]})]},e);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`arena-picker-scrim`,onClick:a}),(0,k.jsxs)(`div`,{className:`arena-picker`,role:`group`,"aria-label":o(`setup.pickerLabel`,{seat:e}),children:[s.map(([e,t])=>(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h3`,{children:o(`setup.legendEra`,{era:o(`setup.eras.${e}`)})}),(0,k.jsx)(`div`,{children:t.map(e=>c(`master:${e.id}`,e.name,w(e.id),e.peak?String(e.peak):``))})]},e)),r.engines.length>0&&(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h3`,{children:o(`setup.engines`)}),(0,k.jsx)(`div`,{children:r.engines.map(e=>c(`engine:${e.id}`,e.name,x(e.id),L(e)?o(`setup.anyStrength`):e.strength_ccrl?String(e.strength_ccrl):``))})]}),r.models.length>0&&(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h3`,{children:o(`setup.humanLike`)}),(0,k.jsx)(`div`,{children:r.models.map(({engine:e,model:t})=>c(`model:${e.id}:${t.id}`,t.name,x(e.id,t.id),t.rating_target?`~${t.rating_target}`:``))})]})]})]})}function ae({a:e,b:t,games:r}){let{t:i}=n(`arena`),a=e.rating!==null&&t.rating!==null,o=a?1/(1+10**((t.rating-e.rating)/400)):.5,s=a?Math.abs(e.rating-t.rating):0;return(0,k.jsxs)(`div`,{className:`arena-vs`,children:[(0,k.jsx)(`span`,{className:`arena-vs-badge`,"aria-hidden":`true`,children:i(`vs`)}),a?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`arena-vs-label`,children:i(`predict.title`)}),(0,k.jsxs)(`span`,{className:`arena-vs-score`,"aria-label":i(`predict.label`,{first:e.name,second:t.name,a:(o*r).toFixed(1),b:((1-o)*r).toFixed(1)}),children:[(o*r).toFixed(1),` – `,((1-o)*r).toFixed(1)]}),(0,k.jsx)(`i`,{className:`arena-vs-bar`,"aria-hidden":`true`,children:(0,k.jsx)(`b`,{style:{width:`${Math.round(o*100)}%`}})}),(0,k.jsx)(`span`,{className:`arena-vs-gap`,children:s<20?i(`predict.even`):i(`predict.gap`,{name:o>=.5?e.name:t.name,points:s})})]}):(0,k.jsx)(`span`,{className:`arena-vs-gap`,children:i(`predict.unknown`)})]})}function oe({missing:e,onAdded:t}){let{t:r}=n(`arena`),[i,a]=(0,O.useState)(null),[s,c]=(0,O.useState)(null);if(!e.length)return null;async function l(e){a(e),c(null);try{t(await o(`api/masters/download`,{id:e}))}catch(e){c(e.message)}finally{a(null)}}return(0,k.jsxs)(`details`,{className:`arena-more-legends`,children:[(0,k.jsx)(`summary`,{children:r(`legends.more`,{count:e.length})}),(0,k.jsx)(`p`,{children:r(`legends.source`)}),(0,k.jsx)(`div`,{className:`arena-legend-chips`,children:e.map(e=>(0,k.jsx)(`button`,{type:`button`,className:`button`,disabled:!!i,onClick:()=>void l(e.id),children:i===e.id?r(`legends.downloading`):e.name},e.id))}),s&&(0,k.jsx)(`p`,{className:`arena-error`,role:`alert`,children:s})]})}function J(e){return e.masterId&&w(e.masterId)||x(e.engineId,e.modelId)}function Y(e,t){return(e.masterId&&t!==null?y(e.masterId,t?`won`:`lost`):void 0)??J(e)}function X(e,t,n){let r=e.current,i=e.games.length,[a]=e.players,o=e.phase===`preparing`?n(`score.preparing`):t&&r?n(`score.game`,{number:r.number,total:e.settings.games})+(r.opening?` · ${I(r,n)}`:``):e.error?n(`score.failed`,{error:e.error}):n(e.stopped?`score.stopped`:`score.finished`,{count:i}),s=i>0&&e.elo_diff!==void 0&&e.elo_diff!==null&&!t?` · ${n(`eloGap`,{name:e.players[e.elo_diff>=0?0:1].name,elo:Math.abs(e.elo_diff)})}`:``,c=e.sprt?` · ${n(e.sprt.verdict?`sprt.${e.sprt.verdict}`:`sprt.open`,{name:a.name,llr:e.sprt.llr.toFixed(2),lower:e.sprt.lower.toFixed(2),upper:e.sprt.upper.toFixed(2),elo1:e.sprt.elo1})}`:``;return o+s+c}function Z({match:e}){let{t}=n(`arena`),[r,i]=e.players;return(0,k.jsxs)(`div`,{className:`arena-score`,"aria-label":t(`score.label`),children:[(0,k.jsx)(`span`,{className:`arena-score-name`,children:r.name}),(0,k.jsx)(`b`,{children:z(e.score[0])}),(0,k.jsx)(`span`,{className:`arena-score-dash`,children:`–`}),(0,k.jsx)(`b`,{children:z(e.score[1])}),(0,k.jsx)(`span`,{className:`arena-score-name right`,children:i.name})]})}var se=f;function Q({match:e,extra:t,rows:r}){let{t:i}=n(`arena`),a=e.grades??t;if(!a&&!r)return null;let o=(n,r)=>e.grades&&e.grades[n][r]==null||!e.grades&&e.games.length?null:(e.grades?.[n][r]??0)+(t?.[n][r]??0);return(0,k.jsxs)(`table`,{className:`arena-tally`,"aria-label":i(`tally.label`),children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{}),(0,k.jsx)(`th`,{children:e.players[0].name}),(0,k.jsx)(`th`,{children:e.players[1].name})]})}),(0,k.jsxs)(`tbody`,{children:[r,a&&se.map(e=>(0,k.jsxs)(`tr`,{className:`move-${e}`,children:[(0,k.jsxs)(`th`,{title:i(`board:grades.${e}.message`),children:[(0,k.jsx)(`img`,{src:c(e),alt:``,width:`18`,height:`18`}),i(`tally.${e}`)]}),[0,1].map(t=>(0,k.jsx)(`td`,{className:o(t,e)===0?`zero`:void 0,children:o(t,e)??`–`},t))]},e))]})]})}function ce(e){let t=[l(),l()];return e.notes.forEach((n,r)=>{let i=n.grade;if(!i)return;let a=d({...i,accuracy:i.accuracy??0,ply:r,san:``}),o=r%2==0?e.white:1-e.white;a&&t[o][a]++}),[t[0],t[1]]}function $({match:e}){let{t}=n(`arena`);return e.games.length?(0,k.jsxs)(`table`,{className:`arena-games`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{children:`#`}),(0,k.jsx)(`th`,{children:t(`games.white`)}),(0,k.jsx)(`th`,{children:t(`games.black`)}),(0,k.jsx)(`th`,{children:t(`games.result`)}),(0,k.jsx)(`th`,{children:t(`games.moves`)}),(0,k.jsx)(`th`,{children:t(`games.ending`)}),(0,k.jsx)(`th`,{})]})}),(0,k.jsx)(`tbody`,{children:e.games.map(n=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{children:n.number}),(0,k.jsxs)(`td`,{children:[e.players[n.white].name,n.book[n.white]?(0,k.jsxs)(`small`,{children:[` · `,t(`games.book`,{count:n.book[n.white]})]}):null]}),(0,k.jsxs)(`td`,{children:[e.players[1-n.white].name,n.book[1-n.white]?(0,k.jsxs)(`small`,{children:[` · `,t(`games.book`,{count:n.book[1-n.white]})]}):null]}),(0,k.jsxs)(`td`,{children:[(0,k.jsx)(`b`,{children:n.result.replace(`1/2`,`½`).replace(`1/2`,`½`)}),` `,(0,k.jsxs)(`small`,{children:[`(`,R(n,0),`–`,R(n,1),`)`]})]}),(0,k.jsx)(`td`,{children:Math.ceil(n.plies/2)}),(0,k.jsxs)(`td`,{children:[t(`endings.${n.termination.replace(/ /g,`_`)}`,{defaultValue:n.termination}),n.opening?(0,k.jsxs)(`small`,{children:[` · `,I(n,t)]}):null]}),(0,k.jsx)(`td`,{children:n.moves?.length?(0,k.jsx)(r,{to:E({fen:h,moves:n.moves,base:0,from:`/arena`}),children:t(`games.replay`)}):null})]},n.number))})]}):null}function le({match:e,running:t,onStop:r,onClose:i}){let{t:a}=n(`arena`),o=e.current,s=m(o?.board??null),[c,l]=e.players,u=o?.notes.at(-1),d=u?.book?u:null,f=o?o.moves.length%2==1?o.white:1-o.white:null,h=(0,O.useMemo)(()=>new Map((o?.notes??[]).flatMap((e,t)=>e.grade?[[t+1,{...e.grade,ply:t+1,san:o.moves[t].san,accuracy:e.grade.accuracy??0}]]:[])),[o]),v=n=>{let r=e.players[n],i=o?o.white===n?`white`:`black`:null,s=H(o?.evals[n]);return(0,k.jsxs)(`div`,{className:`arena-player${o&&o.board.turn===i&&t?` to-move`:``}`,children:[(0,k.jsx)(`img`,{className:`arena-player-figure`,src:J(r),alt:``}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`strong`,{children:r.name}),(0,k.jsx)(`small`,{children:r.masterId?a(`player.legend`,{engine:r.engine,elo:r.elo}):r.rating?`${r.engine} · ${r.rating}`:r.engine})]}),s&&(0,k.jsx)(`span`,{className:`arena-eval`,title:a(`player.evalTitle`),children:s}),i&&(0,k.jsx)(`span`,{className:`arena-color ${i}`,children:a(`games.${i}`)})]})},y=o?1-o.white:1,b=o?B(o.judge):null,x=o?V(o.board,b):null,S=x===null||!o?null:o.white===0?x:100-x;return(0,k.jsxs)(`div`,{className:`arena-live`,children:[(0,k.jsxs)(`div`,{className:`arena-board-column`,children:[v(y),o&&(0,k.jsx)(`div`,{className:`arena-board`,children:(0,k.jsx)(p,{board:o.board,flipped:!1,planning:s,lastMove:o.lastMove,movable:!1,evalBar:(0,k.jsx)(g,{board:o.board,line:b,flipped:!1})})}),v(1-y)]}),(0,k.jsxs)(`aside`,{className:`arena-panel`,children:[(0,k.jsx)(Z,{match:e}),(0,k.jsx)(`p`,{className:`arena-progress`,role:`status`,children:X(e,t,a)}),o&&(0,k.jsxs)(`div`,{className:`arena-chance`,role:`img`,"aria-label":S===null?a(`chance.pending`):a(`chance.label`,{first:c.name,firstChance:S,second:l.name,secondChance:100-S}),children:[(0,k.jsx)(`span`,{children:S===null?``:`${S}%`}),(0,k.jsx)(`i`,{className:S===null?`pending`:``,children:(0,k.jsx)(`b`,{style:{width:`${S??50}%`}})}),(0,k.jsx)(`span`,{children:S===null?``:`${100-S}%`})]}),o&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`arena-book-line`,"aria-live":`polite`,children:d?.book&&f!==null?a(`book.line`,{name:e.players[f].name,count:d.book.count,total:d.book.total,opponent:d.book.game.opponent,year:d.book.game.year??`?`}):u?.opening?a(`book.opening`):` `}),(0,k.jsx)(`div`,{className:`moves-heading`,children:(0,k.jsx)(`span`,{children:a(`moves`)})}),(0,k.jsx)(_,{initialFen:`rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1`,moves:o.moves,cursor:o.moves.length,onSelect:()=>{},judgments:h}),(0,k.jsx)(Q,{match:e,extra:ce(o)})]}),(0,k.jsx)($,{match:e}),(0,k.jsxs)(`div`,{className:`arena-panel-actions`,children:[i&&(0,k.jsx)(`button`,{type:`button`,className:`button`,onClick:i,children:a(`close`)}),t&&(0,k.jsx)(`button`,{type:`button`,className:`button danger`,onClick:r,children:a(`stop`)})]})]})]})}function ue({match:e,canRematch:t,onRematch:r,onNew:i}){let{t:a}=n(`arena`),o=e.score[0]===e.score[1]?null:e.score[0]>e.score[1]?0:1,s=(t,n)=>e.games.filter(e=>R(e,t)===n).length;return(0,k.jsxs)(`div`,{className:`arena-result`,children:[(0,k.jsxs)(`div`,{className:`arena-result-stage`,children:[[0,1].map(t=>(0,k.jsxs)(`figure`,{className:`arena-result-player${o===t?` winner`:o===null?``:` loser`}`,children:[o===t&&(0,k.jsx)(`img`,{className:`arena-result-wreath`,src:v(`wreath`),alt:``}),(0,k.jsx)(`img`,{className:`arena-result-figure`,src:Y(e.players[t],o===null?null:o===t),alt:``})]},t)),(0,k.jsxs)(`div`,{className:`arena-result-headline`,children:[(0,k.jsx)(`h2`,{children:o===null?a(`result.draw`):a(`result.wins`,{name:e.players[o].name})}),(0,k.jsx)(Z,{match:e}),(0,k.jsx)(`p`,{className:`arena-progress`,role:`status`,children:X(e,!1,a)})]})]}),(0,k.jsxs)(`div`,{className:`arena-result-body`,children:[(0,k.jsx)(Q,{match:e,rows:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{children:a(`tally.wins`)}),(0,k.jsx)(`td`,{children:s(0,`1`)}),(0,k.jsx)(`td`,{children:s(1,`1`)})]}),(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{children:a(`tally.draws`)}),(0,k.jsx)(`td`,{children:s(0,`½`)}),(0,k.jsx)(`td`,{children:s(1,`½`)})]})]})}),(0,k.jsx)($,{match:e}),(0,k.jsxs)(`div`,{className:`arena-panel-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`button`,onClick:i,children:a(`result.newMatch`)}),(0,k.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!t,onClick:r,children:a(`result.rematch`)})]})]})]})}export{U as ArenaPage};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,s as r,t as i}from"./vendor-DVQGMHsh.js";import{At as a,kt as o,wt as s}from"./index-Ba3yxWjC.js";import{a as c,i as l,l as u,s as d,t as f}from"./grades-D6OvtJ99.js";import{n as p,t as m}from"./usePlanning-M5mnt77_.js";import{t as h}from"./format-CyB705xj.js";import{r as g,t as _}from"./MoveList-DmeC8rTb.js";import{_ as v,b as y,h as b,l as x,m as S,v as C,y as w}from"./bots-CmOYIVmQ.js";import{t as T}from"./useMasters-DtS0PB6J.js";import{s as E}from"./routes-SOm45MWj.js";import{t as D}from"./Segments-B8XJlwPB.js";var O=e(t(),1),k=i();function ee({refresh:e}){let{t}=n(`arena`),[r,i]=(0,O.useState)(null);if((0,O.useEffect)(()=>{let e=new AbortController;return a(`api/arena/ladder`,void 0,e.signal).then(i).catch(()=>{}),()=>e.abort()},[e]),!r?.players.length)return null;let o=Math.min(...r.players.map(e=>e.ci_low))-50,s=Math.max(...r.players.map(e=>e.ci_high))+50,c=e=>`${(e-o)/(s-o)*100}%`;return(0,k.jsxs)(`section`,{className:`arena-recent arena-ladder`,"aria-labelledby":`arena-ladder-title`,children:[(0,k.jsx)(`h2`,{id:`arena-ladder-title`,children:t(`ladder.title`)}),(0,k.jsx)(`ol`,{className:`arena-list`,children:r.players.map((e,n)=>{let r=e.placed_by===`anchor`||e.placed_by===`nominal`;return(0,k.jsxs)(`li`,{className:`arena-rung`,children:[(0,k.jsx)(`span`,{className:`arena-rank${n<3?` medal-${n+1}`:``}`,"aria-label":t(`ladder.rankLabel`,{rank:n+1}),children:n+1}),(0,k.jsxs)(`div`,{className:`arena-rung-main`,children:[(0,k.jsxs)(`div`,{className:`arena-rung-name`,children:[(0,k.jsx)(`strong`,{children:e.name}),(0,k.jsxs)(`span`,{title:t(`ladder.games`),children:[e.wins,` · `,e.draws,` · `,e.losses]})]}),e.ci_low!==e.ci_high&&(0,k.jsxs)(`i`,{className:`arena-range`,"aria-hidden":`true`,children:[(0,k.jsx)(`b`,{style:{left:c(e.ci_low),width:`calc(${c(e.ci_high)} - ${c(e.ci_low)})`}}),(0,k.jsx)(`em`,{style:{left:c(e.rating)}})]}),(0,k.jsxs)(`small`,{children:[e.ci_low===e.ci_high?``:t(`ladder.rangeText`,{low:e.ci_low,high:e.ci_high}),r?`${e.ci_low===e.ci_high?``:` · `}${t(`ladder.nominal`,{elo:e.nominal??e.rating})}`:``]})]}),(0,k.jsxs)(`span`,{className:`arena-rung-rating`,children:[(0,k.jsx)(`strong`,{children:e.rating}),(0,k.jsx)(`small`,{children:t(`ladder.scoreText`,{score:e.score})})]})]},e.id)})}),(0,k.jsxs)(`p`,{className:`arena-hint`,children:[t(`ladder.hint`,{count:r.games}),r.groups>1?` ${t(`ladder.groups`,{count:r.groups})}`:``]})]})}var A=u.nodeElo.map(([e,t])=>[e,t]),j=[50,200,800,1600,3200,12800,51200,204800];function M(e){let t=A[0],n=A[A.length-1];if(e<=t[0])return t[1];for(let t=1;t<A.length;t++){let[n,r]=A[t-1],[i,a]=A[t];if(e<=i)return Math.round(r+(a-r)*Math.log(e/n)/Math.log(i/n))}return n[1]}var N=500,P=400,te=[2,4,10,20,100],ne=[.1,.3,1,3],F=[0,800,1200,1500,1800,2e3,2200,2500,2800];function I(e,t){return e.openingName?e.eco?`${e.openingName} (${e.eco})`:e.openingName:e.opening?t(`openings.${e.opening}`):``}function re(e){let[t,n,r]=e.key.split(`:`);return t===`master`?{masterId:n}:t===`model`?{engineId:n,modelId:r}:{engineId:n,...e.elo?{elo:e.elo}:{},...e.nodes?{nodes:e.nodes}:{}}}var L=e=>!!e&&(e.id===`stockfish`||e.capabilities.limit_strength||e.capabilities.skill_level);function R(e,t){if(e.result===`1/2-1/2`)return`½`;let n=e.result===`1-0`;return e.white===t===n?`1`:`0`}var z=e=>Number.isInteger(e)?String(e):`${Math.floor(e)||``}½`;function B(e){return e?{cp:e.cp??0,mate:e.mate,moves:[],uci:[]}:null}function V(e,t){return e.result?e.result===`1-0`?100:e.result===`0-1`?0:50:t?t.mate===null?Math.round(100/(1+10**(-t.cp/400))):t.mate>0?100:0:null}function H(e){return e?e.mate!==null&&e.mate!==void 0?`#${e.mate}`:e.cp===null||e.cp===void 0?null:`${e.cp>0?`+`:``}${(e.cp/100).toFixed(1)}`:null}function U(){let{t:e}=n(`arena`),{engines:t,loaded:i}=s(),{masters:c,missing:l,loaded:u,replace:d}=T(),[f,p]=(0,O.useState)(null),[m,h]=(0,O.useState)(null),[g,_]=(0,O.useState)([{key:``,elo:0},{key:``,elo:0}]),[v,y]=(0,O.useState)({games:2,movetime:.3,openings:`start`,pace:`watch`}),[b,x]=(0,O.useState)(!1),[S,C]=(0,O.useState)(null),[w,E]=(0,O.useState)(!1),{schedule:D,cancel:A,signal:j}=o(),M=(0,O.useMemo)(()=>t.filter(e=>e.installed),[t]),F={engines:M,models:(0,O.useMemo)(()=>M.flatMap(e=>(e.models??[]).filter(e=>e.installed).map(t=>({engine:e,model:t}))),[M]),masters:c};(0,O.useEffect)(()=>{if(!i||!u||g[0].key)return;let e=c.find(e=>e.id===`Carlsen`)??c[0];_([e?{key:`master:${e.id}`,elo:0}:{key:`engine:stockfish`,elo:1500},{key:`engine:stockfish`,elo:e?2500:2e3}])},[i,u,c,g]);let I=(0,O.useCallback)(async()=>{A();let e=j();try{let t=await a(`api/arena`,void 0,e);if(e.aborted)return;p(t),t.running&&D(I,N)}catch(t){e.aborted||h(t.message)}},[A,D,j]);(0,O.useEffect)(()=>{I()},[I]);async function L(){x(!0),h(null),C(null),E(!1);try{p(await a(`api/arena/start`,{players:g.map(re),...v})),D(I,P)}catch(e){h(e.message)}finally{x(!1)}}async function R(){try{p(await a(`api/arena/stop`,{}))}catch(e){h(e.message)}}async function B(e){E(!1);try{C(await a(`api/arena/matches/${e.id}`))}catch(e){h(e.message)}}let V=!!f?.running,H=S??f?.match??null,U=g.every(e=>e.key),G=V&&!S?`live`:!H||w?`setup`:H.current?`live`:`result`,q=[K(g[0],F,e),K(g[1],F,e)],Y=t=>(0,k.jsx)(ie,{label:e(`setup.player${t+1}`),seat:g[t],view:q[t],disabled:V,roster:F,onChange:e=>_(t?[g[0],e]:[e,g[1]])},t);return(0,k.jsxs)(`section`,{id:`arena`,"aria-label":e(`label`),"data-stage":G,children:[(0,k.jsxs)(`header`,{className:`arena-header`,children:[(0,k.jsx)(`h1`,{children:e(`title`)}),(0,k.jsx)(r,{className:`button`,to:`/settings/engines`,children:e(`enginesLink`)})]}),m&&(0,k.jsx)(`p`,{className:`arena-error`,role:`alert`,children:m}),G===`setup`&&(0,k.jsxs)(`section`,{className:`arena-setup`,"aria-label":e(`setup.label`),children:[(0,k.jsxs)(`div`,{className:`arena-faceoff`,children:[Y(0),(0,k.jsx)(ae,{a:q[0],b:q[1],games:v.games}),Y(1)]}),(0,k.jsxs)(`div`,{className:`arena-options`,children:[(0,k.jsxs)(`div`,{className:`arena-settings`,children:[(0,k.jsx)(W,{label:e(`setup.games`),options:te.map(e=>[e,String(e)]),value:v.games,disabled:V,onChange:e=>y({...v,games:e})}),(0,k.jsx)(W,{label:e(`setup.movetime`),options:ne.map(t=>[t,e(`setup.seconds`,{seconds:t})]),value:v.movetime,disabled:V,onChange:e=>y({...v,movetime:e})}),(0,k.jsx)(W,{label:e(`setup.openings`),options:[[`start`,e(`setup.openingsStart`)],[`varied`,e(`setup.openingsVaried`)],[`book`,e(`setup.openingsBook`)]],value:v.openings,disabled:V,onChange:e=>y({...v,openings:e})}),(0,k.jsx)(W,{label:e(`setup.pace`),options:[[`watch`,e(`setup.paceWatch`)],[`fast`,e(`setup.paceFast`)]],value:v.pace,disabled:V,onChange:e=>y({...v,pace:e})}),(0,k.jsx)(W,{label:e(`setup.sprt`),options:[[`off`,e(`setup.sprtOff`)],[`on`,e(`setup.sprtOn`)]],value:v.sprt?`on`:`off`,disabled:V,onChange:e=>y({...v,sprt:e===`on`})})]}),(0,k.jsxs)(`div`,{className:`arena-go`,children:[(0,k.jsxs)(`p`,{className:`arena-hint`,children:[e({start:`setup.startHint`,varied:`setup.variedHint`,book:`setup.bookHint`}[v.openings]),v.sprt?` ${e(`setup.sprtHint`)}`:``]}),H&&(0,k.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>E(!1),children:e(`result.back`)}),(0,k.jsx)(`button`,{type:`button`,className:`button primary arena-start`,disabled:!U||b,onClick:()=>void L(),children:e(b?`starting`:`start`)})]})]}),(0,k.jsx)(oe,{missing:l,onAdded:d})]}),G===`live`&&H&&(0,k.jsx)(le,{match:H,running:V&&!S,onStop:()=>void R(),onClose:S?()=>C(null):void 0}),G===`result`&&H&&(0,k.jsx)(ue,{match:H,canRematch:U&&!b,onRematch:()=>void L(),onNew:()=>{C(null),E(!0)}}),G!==`live`&&(0,k.jsxs)(`div`,{className:`arena-columns`,children:[!!f?.recent.length&&(0,k.jsxs)(`section`,{className:`arena-recent`,"aria-labelledby":`arena-recent-title`,children:[(0,k.jsx)(`h2`,{id:`arena-recent-title`,children:e(`recent.title`)}),(0,k.jsx)(`ul`,{className:`arena-list`,children:f.recent.map(t=>{let[n,r]=t.players;return(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,onClick:()=>void B(t),"aria-pressed":S?.id===t.id,children:[(0,k.jsx)(`img`,{className:`arena-tile`,src:J(n),alt:``}),(0,k.jsxs)(`span`,{className:`arena-recent-main`,children:[(0,k.jsxs)(`span`,{className:`arena-recent-names`,children:[(0,k.jsx)(`span`,{className:t.score[0]>t.score[1]?`won`:void 0,children:n.name}),(0,k.jsxs)(`b`,{children:[z(t.score[0]),`–`,z(t.score[1])]}),(0,k.jsx)(`span`,{className:t.score[1]>t.score[0]?`won`:void 0,children:r.name})]}),(0,k.jsxs)(`small`,{children:[t.date,` · `,e(`recent.games`,{count:t.games_played}),t.elo_diff===null?``:` · ${e(`eloGap`,{name:t.players[t.elo_diff>=0?0:1].name,elo:Math.abs(t.elo_diff)})}`,t.stopped?` · ${e(`recent.stopped`)}`:``,t.early&&t.sprt?.verdict?` · ${e(`recent.sprt`)}`:``]})]}),(0,k.jsx)(`img`,{className:`arena-tile`,src:J(r),alt:``})]})},t.id)})})]}),(0,k.jsx)(ee,{refresh:f?.recent[0]?.id})]})]})}function W({label:e,options:t,value:n,disabled:r,onChange:i}){return(0,k.jsxs)(`div`,{className:`arena-choice`,role:`group`,"aria-label":e,children:[(0,k.jsx)(`span`,{children:e}),(0,k.jsx)(D,{children:t.map(([e,t])=>(0,k.jsx)(`button`,{type:`button`,"aria-pressed":e===n,className:e===n?`selected`:``,disabled:r,onClick:()=>i(e),children:t},String(e)))})]})}var G=e=>e.split(/\s+/).filter(Boolean).map(e=>e[0]).slice(0,2).join(``).toUpperCase();function K(e,t,n){let[r,i,a]=e.key.split(`:`);if(r===`master`){let e=t.masters.find(e=>e.id===i);if(e)return{name:e.name,kind:`legend`,figure:w(e.id),initials:G(e.name),rating:e.elo,ratingText:String(e.elo),blurb:n(e.rated?`setup.legendNote`:`setup.legendNoteUnrated`,{count:e.games,games:e.games.toLocaleString(),elo:e.elo})}}if(r===`model`){let e=t.models.find(({engine:e,model:t})=>e.id===i&&t.id===a);if(e){let t=e.model.rating_target??null;return{name:e.model.name,kind:`model`,figure:x(i,a),initials:G(e.model.name),rating:t,ratingText:t?`~${t}`:``,blurb:t?n(`setup.modelNote`,{elo:t}):e.engine.description}}}if(r===`engine`){let r=t.engines.find(e=>e.id===i);if(r){let t=e.nodes&&r.type!==`neural`?M(e.nodes):null,i=e.nodes?t:e.elo||r.strength_ccrl,a=e.nodes?t?`~${t}`:n(`setup.nodes`,{nodes:e.nodes.toLocaleString()}):e.elo?n(`setup.rating`,{elo:e.elo}):r.strength_ccrl?n(`setup.ccrl`,{elo:r.strength_ccrl}):``;return{name:r.name,kind:`engine`,figure:x(r.id),initials:G(r.name),rating:i,ratingText:a,blurb:r.description}}}return{name:n(`setup.choose`),kind:null,initials:``,rating:null,ratingText:``,blurb:``}}function ie({label:e,seat:t,view:r,disabled:i,roster:a,onChange:o}){let{t:s}=n(`arena`),[c,l]=(0,O.useState)(!1),u=t.key.startsWith(`engine:`)?a.engines.find(e=>e.id===t.key.split(`:`)[1]):void 0;return(0,k.jsxs)(`section`,{className:`arena-seat`,"aria-label":e,children:[(0,k.jsx)(`span`,{className:`arena-seat-slot`,children:e}),(0,k.jsx)(`div`,{className:`arena-seat-figure`,children:r.figure?(0,k.jsx)(`img`,{src:r.figure,alt:``},r.figure):r.initials?(0,k.jsx)(`span`,{className:`arena-initials`,children:r.initials}):null}),(0,k.jsxs)(`div`,{className:`arena-seat-who`,children:[(0,k.jsx)(`strong`,{children:r.name}),r.kind&&(0,k.jsxs)(`span`,{className:`arena-seat-tags`,children:[(0,k.jsx)(`span`,{className:`arena-kind ${r.kind}`,children:s(`kinds.${r.kind}`)}),r.ratingText&&(0,k.jsx)(`span`,{className:`arena-seat-rating`,children:r.ratingText})]}),r.blurb&&(0,k.jsx)(`p`,{className:`arena-seat-note`,children:r.blurb})]}),u&&(0,k.jsxs)(`label`,{className:`arena-strength`,children:[s(`setup.strength`),(0,k.jsxs)(`select`,{value:t.nodes?`n${t.nodes}`:t.elo,disabled:i,onChange:e=>{let n=e.target.value;o(n.startsWith(`n`)?{...t,elo:0,nodes:Number(n.slice(1))}:{...t,elo:Number(n),nodes:void 0})},children:[L(u)?(0,k.jsx)(`optgroup`,{label:s(`setup.ratings`),children:F.map(e=>(0,k.jsx)(`option`,{value:e,children:e?s(`setup.rating`,{elo:e}):s(`setup.fullStrength`)},e))}):(0,k.jsx)(`option`,{value:0,children:s(`setup.fullStrength`)}),(0,k.jsx)(`optgroup`,{label:s(`setup.nodeLimit`),children:j.map(e=>(0,k.jsx)(`option`,{value:`n${e}`,children:u.type===`neural`?s(`setup.nodes`,{nodes:e.toLocaleString()}):s(`setup.nodesRated`,{nodes:e.toLocaleString(),elo:M(e)})},e))})]})]}),(0,k.jsx)(`button`,{type:`button`,className:`button arena-change`,disabled:i,"aria-expanded":c,onClick:()=>l(!c),children:s(`setup.change`)}),c&&!i&&(0,k.jsx)(q,{label:e,current:t.key,roster:a,onClose:()=>l(!1),onPick:e=>{let n=a.engines.find(t=>`engine:${t.id}`===e);o({key:e,elo:L(n)?t.elo:0,nodes:n?t.nodes:void 0}),l(!1)}})]})}function q({label:e,current:t,roster:r,onPick:i,onClose:a}){let{t:o}=n(`arena`);(0,O.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]);let s=S.map(e=>[e,r.masters.filter(t=>C(t.id)===e).sort((e,t)=>b(e.id,t.id))]).filter(([,e])=>e.length),c=(e,n,r,a)=>(0,k.jsxs)(`button`,{type:`button`,className:`arena-pick`,"aria-pressed":t===e,onClick:()=>i(e),children:[r?(0,k.jsx)(`img`,{className:`arena-tile`,src:r,alt:``,loading:`lazy`}):(0,k.jsx)(`span`,{className:`arena-tile arena-initials`,children:G(n)}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`strong`,{children:n}),a&&(0,k.jsx)(`small`,{children:a})]})]},e);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`arena-picker-scrim`,onClick:a}),(0,k.jsxs)(`div`,{className:`arena-picker`,role:`group`,"aria-label":o(`setup.pickerLabel`,{seat:e}),children:[s.map(([e,t])=>(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h3`,{children:o(`setup.legendEra`,{era:o(`setup.eras.${e}`)})}),(0,k.jsx)(`div`,{children:t.map(e=>c(`master:${e.id}`,e.name,w(e.id),e.peak?String(e.peak):``))})]},e)),r.engines.length>0&&(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h3`,{children:o(`setup.engines`)}),(0,k.jsx)(`div`,{children:r.engines.map(e=>c(`engine:${e.id}`,e.name,x(e.id),L(e)?o(`setup.anyStrength`):e.strength_ccrl?String(e.strength_ccrl):``))})]}),r.models.length>0&&(0,k.jsxs)(`section`,{children:[(0,k.jsx)(`h3`,{children:o(`setup.humanLike`)}),(0,k.jsx)(`div`,{children:r.models.map(({engine:e,model:t})=>c(`model:${e.id}:${t.id}`,t.name,x(e.id,t.id),t.rating_target?`~${t.rating_target}`:``))})]})]})]})}function ae({a:e,b:t,games:r}){let{t:i}=n(`arena`),a=e.rating!==null&&t.rating!==null,o=a?1/(1+10**((t.rating-e.rating)/400)):.5,s=a?Math.abs(e.rating-t.rating):0;return(0,k.jsxs)(`div`,{className:`arena-vs`,children:[(0,k.jsx)(`span`,{className:`arena-vs-badge`,"aria-hidden":`true`,children:i(`vs`)}),a?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`arena-vs-label`,children:i(`predict.title`)}),(0,k.jsxs)(`span`,{className:`arena-vs-score`,"aria-label":i(`predict.label`,{first:e.name,second:t.name,a:(o*r).toFixed(1),b:((1-o)*r).toFixed(1)}),children:[(o*r).toFixed(1),` – `,((1-o)*r).toFixed(1)]}),(0,k.jsx)(`i`,{className:`arena-vs-bar`,"aria-hidden":`true`,children:(0,k.jsx)(`b`,{style:{width:`${Math.round(o*100)}%`}})}),(0,k.jsx)(`span`,{className:`arena-vs-gap`,children:s<20?i(`predict.even`):i(`predict.gap`,{name:o>=.5?e.name:t.name,points:s})})]}):(0,k.jsx)(`span`,{className:`arena-vs-gap`,children:i(`predict.unknown`)})]})}function oe({missing:e,onAdded:t}){let{t:r}=n(`arena`),[i,o]=(0,O.useState)(null),[s,c]=(0,O.useState)(null);if(!e.length)return null;async function l(e){o(e),c(null);try{t(await a(`api/masters/download`,{id:e}))}catch(e){c(e.message)}finally{o(null)}}return(0,k.jsxs)(`details`,{className:`arena-more-legends`,children:[(0,k.jsx)(`summary`,{children:r(`legends.more`,{count:e.length})}),(0,k.jsx)(`p`,{children:r(`legends.source`)}),(0,k.jsx)(`div`,{className:`arena-legend-chips`,children:e.map(e=>(0,k.jsx)(`button`,{type:`button`,className:`button`,disabled:!!i,onClick:()=>void l(e.id),children:i===e.id?r(`legends.downloading`):e.name},e.id))}),s&&(0,k.jsx)(`p`,{className:`arena-error`,role:`alert`,children:s})]})}function J(e){return e.masterId&&w(e.masterId)||x(e.engineId,e.modelId)}function Y(e,t){return(e.masterId&&t!==null?y(e.masterId,t?`won`:`lost`):void 0)??J(e)}function X(e,t,n){let r=e.current,i=e.games.length,[a]=e.players,o=e.phase===`preparing`?n(`score.preparing`):t&&r?n(`score.game`,{number:r.number,total:e.settings.games})+(r.opening?` · ${I(r,n)}`:``):e.error?n(`score.failed`,{error:e.error}):n(e.stopped?`score.stopped`:`score.finished`,{count:i}),s=i>0&&e.elo_diff!==void 0&&e.elo_diff!==null&&!t?` · ${n(`eloGap`,{name:e.players[e.elo_diff>=0?0:1].name,elo:Math.abs(e.elo_diff)})}`:``,c=e.sprt?` · ${n(e.sprt.verdict?`sprt.${e.sprt.verdict}`:`sprt.open`,{name:a.name,llr:e.sprt.llr.toFixed(2),lower:e.sprt.lower.toFixed(2),upper:e.sprt.upper.toFixed(2),elo1:e.sprt.elo1})}`:``;return o+s+c}function Z({match:e}){let{t}=n(`arena`),[r,i]=e.players;return(0,k.jsxs)(`div`,{className:`arena-score`,"aria-label":t(`score.label`),children:[(0,k.jsx)(`span`,{className:`arena-score-name`,children:r.name}),(0,k.jsx)(`b`,{children:z(e.score[0])}),(0,k.jsx)(`span`,{className:`arena-score-dash`,children:`–`}),(0,k.jsx)(`b`,{children:z(e.score[1])}),(0,k.jsx)(`span`,{className:`arena-score-name right`,children:i.name})]})}var se=f;function Q({match:e,extra:t,rows:r}){let{t:i}=n(`arena`),a=e.grades??t;if(!a&&!r)return null;let o=(n,r)=>e.grades&&e.grades[n][r]==null||!e.grades&&e.games.length?null:(e.grades?.[n][r]??0)+(t?.[n][r]??0);return(0,k.jsxs)(`table`,{className:`arena-tally`,"aria-label":i(`tally.label`),children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{}),(0,k.jsx)(`th`,{children:e.players[0].name}),(0,k.jsx)(`th`,{children:e.players[1].name})]})}),(0,k.jsxs)(`tbody`,{children:[r,a&&se.map(e=>(0,k.jsxs)(`tr`,{className:`move-${e}`,children:[(0,k.jsxs)(`th`,{title:i(`board:grades.${e}.message`),children:[(0,k.jsx)(`img`,{src:c(e),alt:``,width:`18`,height:`18`}),i(`tally.${e}`)]}),[0,1].map(t=>(0,k.jsx)(`td`,{className:o(t,e)===0?`zero`:void 0,children:o(t,e)??`–`},t))]},e))]})]})}function ce(e){let t=[l(),l()];return e.notes.forEach((n,r)=>{let i=n.grade;if(!i)return;let a=d({...i,accuracy:i.accuracy??0,ply:r,san:``}),o=r%2==0?e.white:1-e.white;a&&t[o][a]++}),[t[0],t[1]]}function $({match:e}){let{t}=n(`arena`);return e.games.length?(0,k.jsxs)(`table`,{className:`arena-games`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{children:`#`}),(0,k.jsx)(`th`,{children:t(`games.white`)}),(0,k.jsx)(`th`,{children:t(`games.black`)}),(0,k.jsx)(`th`,{children:t(`games.result`)}),(0,k.jsx)(`th`,{children:t(`games.moves`)}),(0,k.jsx)(`th`,{children:t(`games.ending`)}),(0,k.jsx)(`th`,{})]})}),(0,k.jsx)(`tbody`,{children:e.games.map(n=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{children:n.number}),(0,k.jsxs)(`td`,{children:[e.players[n.white].name,n.book[n.white]?(0,k.jsxs)(`small`,{children:[` · `,t(`games.book`,{count:n.book[n.white]})]}):null]}),(0,k.jsxs)(`td`,{children:[e.players[1-n.white].name,n.book[1-n.white]?(0,k.jsxs)(`small`,{children:[` · `,t(`games.book`,{count:n.book[1-n.white]})]}):null]}),(0,k.jsxs)(`td`,{children:[(0,k.jsx)(`b`,{children:n.result.replace(`1/2`,`½`).replace(`1/2`,`½`)}),` `,(0,k.jsxs)(`small`,{children:[`(`,R(n,0),`–`,R(n,1),`)`]})]}),(0,k.jsx)(`td`,{children:Math.ceil(n.plies/2)}),(0,k.jsxs)(`td`,{children:[t(`endings.${n.termination.replace(/ /g,`_`)}`,{defaultValue:n.termination}),n.opening?(0,k.jsxs)(`small`,{children:[` · `,I(n,t)]}):null]}),(0,k.jsx)(`td`,{children:n.moves?.length?(0,k.jsx)(r,{to:E({fen:h,moves:n.moves,base:0,from:`/arena`}),children:t(`games.replay`)}):null})]},n.number))})]}):null}function le({match:e,running:t,onStop:r,onClose:i}){let{t:a}=n(`arena`),o=e.current,s=m(o?.board??null),[c,l]=e.players,u=o?.notes.at(-1),d=u?.book?u:null,f=o?o.moves.length%2==1?o.white:1-o.white:null,h=(0,O.useMemo)(()=>new Map((o?.notes??[]).flatMap((e,t)=>e.grade?[[t+1,{...e.grade,ply:t+1,san:o.moves[t].san,accuracy:e.grade.accuracy??0}]]:[])),[o]),v=n=>{let r=e.players[n],i=o?o.white===n?`white`:`black`:null,s=H(o?.evals[n]);return(0,k.jsxs)(`div`,{className:`arena-player${o&&o.board.turn===i&&t?` to-move`:``}`,children:[(0,k.jsx)(`img`,{className:`arena-player-figure`,src:J(r),alt:``}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`strong`,{children:r.name}),(0,k.jsx)(`small`,{children:r.masterId?a(`player.legend`,{engine:r.engine,elo:r.elo}):r.rating?`${r.engine} · ${r.rating}`:r.engine})]}),s&&(0,k.jsx)(`span`,{className:`arena-eval`,title:a(`player.evalTitle`),children:s}),i&&(0,k.jsx)(`span`,{className:`arena-color ${i}`,children:a(`games.${i}`)})]})},y=o?1-o.white:1,b=o?B(o.judge):null,x=o?V(o.board,b):null,S=x===null||!o?null:o.white===0?x:100-x;return(0,k.jsxs)(`div`,{className:`arena-live`,children:[(0,k.jsxs)(`div`,{className:`arena-board-column`,children:[v(y),o&&(0,k.jsx)(`div`,{className:`arena-board`,children:(0,k.jsx)(p,{board:o.board,flipped:!1,planning:s,lastMove:o.lastMove,movable:!1,evalBar:(0,k.jsx)(g,{board:o.board,line:b,flipped:!1})})}),v(1-y)]}),(0,k.jsxs)(`aside`,{className:`arena-panel`,children:[(0,k.jsx)(Z,{match:e}),(0,k.jsx)(`p`,{className:`arena-progress`,role:`status`,children:X(e,t,a)}),o&&(0,k.jsxs)(`div`,{className:`arena-chance`,role:`img`,"aria-label":S===null?a(`chance.pending`):a(`chance.label`,{first:c.name,firstChance:S,second:l.name,secondChance:100-S}),children:[(0,k.jsx)(`span`,{children:S===null?``:`${S}%`}),(0,k.jsx)(`i`,{className:S===null?`pending`:``,children:(0,k.jsx)(`b`,{style:{width:`${S??50}%`}})}),(0,k.jsx)(`span`,{children:S===null?``:`${100-S}%`})]}),o&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`arena-book-line`,"aria-live":`polite`,children:d?.book&&f!==null?a(`book.line`,{name:e.players[f].name,count:d.book.count,total:d.book.total,opponent:d.book.game.opponent,year:d.book.game.year??`?`}):u?.opening?a(`book.opening`):` `}),(0,k.jsx)(`div`,{className:`moves-heading`,children:(0,k.jsx)(`span`,{children:a(`moves`)})}),(0,k.jsx)(_,{initialFen:`rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1`,moves:o.moves,cursor:o.moves.length,onSelect:()=>{},judgments:h}),(0,k.jsx)(Q,{match:e,extra:ce(o)})]}),(0,k.jsx)($,{match:e}),(0,k.jsxs)(`div`,{className:`arena-panel-actions`,children:[i&&(0,k.jsx)(`button`,{type:`button`,className:`button`,onClick:i,children:a(`close`)}),t&&(0,k.jsx)(`button`,{type:`button`,className:`button danger`,onClick:r,children:a(`stop`)})]})]})]})}function ue({match:e,canRematch:t,onRematch:r,onNew:i}){let{t:a}=n(`arena`),o=e.score[0]===e.score[1]?null:e.score[0]>e.score[1]?0:1,s=(t,n)=>e.games.filter(e=>R(e,t)===n).length;return(0,k.jsxs)(`div`,{className:`arena-result`,children:[(0,k.jsxs)(`div`,{className:`arena-result-stage`,children:[[0,1].map(t=>(0,k.jsxs)(`figure`,{className:`arena-result-player${o===t?` winner`:o===null?``:` loser`}`,children:[o===t&&(0,k.jsx)(`img`,{className:`arena-result-wreath`,src:v(`wreath`),alt:``}),(0,k.jsx)(`img`,{className:`arena-result-figure`,src:Y(e.players[t],o===null?null:o===t),alt:``})]},t)),(0,k.jsxs)(`div`,{className:`arena-result-headline`,children:[(0,k.jsx)(`h2`,{children:o===null?a(`result.draw`):a(`result.wins`,{name:e.players[o].name})}),(0,k.jsx)(Z,{match:e}),(0,k.jsx)(`p`,{className:`arena-progress`,role:`status`,children:X(e,!1,a)})]})]}),(0,k.jsxs)(`div`,{className:`arena-result-body`,children:[(0,k.jsx)(Q,{match:e,rows:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{children:a(`tally.wins`)}),(0,k.jsx)(`td`,{children:s(0,`1`)}),(0,k.jsx)(`td`,{children:s(1,`1`)})]}),(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{children:a(`tally.draws`)}),(0,k.jsx)(`td`,{children:s(0,`½`)}),(0,k.jsx)(`td`,{children:s(1,`½`)})]})]})}),(0,k.jsx)($,{match:e}),(0,k.jsxs)(`div`,{className:`arena-panel-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`button`,onClick:i,children:a(`result.newMatch`)}),(0,k.jsx)(`button`,{type:`button`,className:`button primary`,disabled:!t,onClick:r,children:a(`result.rematch`)})]})]})]})}export{U as ArenaPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,t as r}from"./vendor-DVQGMHsh.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,t as r}from"./vendor-DVQGMHsh.js";import{At as i,O as a}from"./index-Ba3yxWjC.js";import{a as o}from"./format-CyB705xj.js";import{i as s,n as c,r as l,t as u}from"./awards-CdOsL55a.js";var d=e(t(),1),f=r();function p(){let{t:e}=n(`awards`),[t,r]=(0,d.useState)(null),[p,h]=(0,d.useState)(``),[g,_]=(0,d.useState)(null);if((0,d.useEffect)(()=>(document.body.dataset.page=`awards`,i(`api/achievements`).then(e=>r(e.awards),e=>h(e.message)),()=>{document.body.dataset.page=`board`}),[]),p)return(0,f.jsx)(`p`,{className:`page-status`,role:`alert`,children:p});if(!t)return(0,f.jsx)(`p`,{className:`page-status`,children:e(`loading`)});let v=t.filter(e=>e.level>0).length,y=e=>t.filter(t=>t.level===e).length,b=t.find(e=>e.id===g)??null;return(0,f.jsxs)(`section`,{id:`awards`,className:`awards`,"aria-label":e(`label`),children:[(0,f.jsxs)(`header`,{className:`awards-hero`,children:[(0,f.jsx)(a,{pose:y(4)?`trophy`:v?`confetti`:`determined`,size:120}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h2`,{children:e(`earned`,{count:v,total:t.length})}),(0,f.jsx)(`p`,{children:e(`intro`)}),(0,f.jsx)(`div`,{className:`awards-tally`,children:[4,3,2].map(e=>(0,f.jsxs)(`span`,{className:`tally-${[``,``,`bronze`,`silver`,`gold`][e]}`,children:[(0,f.jsx)(`b`,{children:y(e)}),` `,c[[``,``,`bronze`,`silver`,`gold`][e]]]},e))})]})]}),Object.keys(u).map(n=>(0,f.jsxs)(`section`,{className:`awards-group`,"aria-label":u[n],children:[(0,f.jsx)(`h3`,{children:u[n]}),(0,f.jsx)(`div`,{className:`awards-grid`,children:t.filter(e=>e.family===n).map(t=>(0,f.jsxs)(`button`,{type:`button`,className:`award-card tier-${t.tier}`,"aria-pressed":g===t.id,onClick:()=>_(g===t.id?null:t.id),children:[(0,f.jsx)(`span`,{className:`award-art`,children:(0,f.jsx)(`img`,{src:l(t.id,t.tier),alt:``,loading:`lazy`})}),t.level===0&&(0,f.jsx)(`img`,{className:`award-lock`,src:`art/ui3d/locked.webp`,alt:``,width:`26`,height:`26`}),(0,f.jsx)(`strong`,{children:t.title}),(0,f.jsx)(`span`,{className:`award-tier`,children:c[t.tier]}),(0,f.jsx)(`span`,{className:`award-progress`,"aria-hidden":`true`,children:(0,f.jsx)(`i`,{style:{width:`${s(t)*100}%`}})}),(0,f.jsx)(`small`,{children:t.next===null?e(`maxed`,{value:o(t.count),unit:t.unit}):e(`toNext`,{value:o(t.count),next:o(t.next),unit:t.unit})})]},t.id))}),b?.family===n&&(0,f.jsx)(m,{award:b})]},n))]})}function m({award:e}){return(0,f.jsxs)(`div`,{className:`award-detail`,"aria-live":`polite`,children:[e.level===4&&(0,f.jsx)(a,{pose:`clap`,size:64}),(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`h4`,{children:e.title}),(0,f.jsxs)(`p`,{children:[e.description,`.`]})]}),(0,f.jsx)(`ol`,{className:`award-steps`,children:[`unlocked`,`bronze`,`silver`,`gold`].map((t,n)=>(0,f.jsxs)(`li`,{className:e.level>n?`done`:``,children:[(0,f.jsx)(`img`,{src:l(e.id,t),alt:``}),(0,f.jsx)(`span`,{children:c[t]}),(0,f.jsxs)(`small`,{children:[o(e.thresholds[n]),` `,e.unit]})]},t))})]})}export{p as AwardsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,r,t as i}from"./vendor-DVQGMHsh.js";import{A as a,C as o,R as s,X as c,_ as l,a as u,j as d,q as f,v as p,x as m}from"./i18n-Cg-9EHIv.js";import{At as h,Dt as g,G as _,H as v,I as y,O as b,P as x,Tt as S,Y as C}from"./index-Ba3yxWjC.js";import{C as w}from"./i18n-en-D2e5RdZ6.js";import{a as ee,n as te,r as T,s as ne}from"./grades-D6OvtJ99.js";import{n as E,t as re}from"./usePlanning-M5mnt77_.js";import{l as ie,s as ae}from"./format-CyB705xj.js";import{n as oe,r as se,t as ce}from"./MoveList-DmeC8rTb.js";import{t as le}from"./CursorRook-B7eCvqMP.js";import{t as ue}from"./Segments-B8XJlwPB.js";import{i as de,n as fe}from"./PhoneParts-BMOk4VLC.js";import{a as pe}from"./useNarration-OmDn79jq.js";import{d as me,f as he,n as ge,u as D}from"./useChess-sMdAC0kt.js";import{t as _e}from"./NavIcon-Cdek5ONP.js";import{r as ve}from"./useSounds-Dr7vf2mM.js";var O=e(t(),1),k=i();function ye({status:e,result:t,auto:r,onToggleAuto:i,onTryBest:o,tryLabel:s,available:c,finished:l,engines:u,engineId:d,onEngineChange:f}){let{t:p}=n(`board`),m=u.find(e=>e.id===d),h=Number(a.use()),g=(e,t)=>(0,k.jsxs)(`div`,{className:`engine-empty`,children:[(0,k.jsx)(b,{pose:e,size:88}),(0,k.jsx)(`p`,{className:`engine-placeholder`,children:t})]}),_;return _=c?l?g(`content`,p(`engine.gameOver`)):r?e===`error`?g(`confused`,p(`engine.unavailable`)):t?(0,k.jsx)(k.Fragment,{children:t.lines.slice(0,h).map((e,t)=>(0,k.jsxs)(`div`,{className:`engine-line`,children:[(0,k.jsx)(`b`,{children:ae(e)}),(0,k.jsx)(`span`,{children:e.moves.join(` `)})]},t))}):(0,k.jsx)(`p`,{className:`engine-placeholder`,children:p(`engine.finding`)}):g(`sleepy`,p(`engine.paused`)):g(`shrug`,p(`engine.notInstalled`)),(0,k.jsxs)(`div`,{className:`engine-section`,children:[(0,k.jsxs)(`div`,{className:`engine-heading`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`i`,{}),u.length>1?(0,k.jsx)(`select`,{id:`engine-picker`,"aria-label":p(`engine.choose`),value:d,onChange:e=>f(e.target.value),children:u.map(e=>(0,k.jsx)(`option`,{value:e.id,children:e.name},e.id))}):(0,k.jsx)(`strong`,{children:m?.name??`Stockfish 18`})]}),(0,k.jsxs)(`div`,{className:`engine-heading-actions`,children:[(0,k.jsx)(`button`,{className:`text-button`,id:`try-line`,type:`button`,disabled:!t?.best||l,onClick:o,children:s}),(0,k.jsx)(`button`,{id:`analyze`,type:`button`,className:`engine-toggle`,"aria-pressed":r,onClick:i,disabled:!c,children:p(r?e===`pending`?`engine.thinking`:`engine.on`:`engine.off`)})]})]}),(0,k.jsx)(`div`,{id:`engine-lines`,children:_})]})}var be=4,xe=e=>Array.from({length:Math.max(0,e)},(e,t)=>(0,k.jsx)(`li`,{"aria-hidden":`true`,children:(0,k.jsxs)(`button`,{type:`button`,className:`blank`,tabIndex:-1,disabled:!0,children:[(0,k.jsx)(`span`,{children:`\xA0`}),(0,k.jsx)(`b`,{children:`\xA0`}),(0,k.jsx)(`em`,{})]})},`blank-${t}`));function Se({title:e,hint:t,pose:n}){return(0,k.jsxs)(`div`,{className:`move-verdict verdict-idle`,role:`status`,children:[(0,k.jsx)(`div`,{className:`verdict-head`,children:(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`strong`,{children:e}),(0,k.jsx)(`p`,{children:t})]})}),(0,k.jsxs)(`div`,{className:`verdict-idle-stage`,children:[(0,k.jsx)(`ol`,{className:`verdict-picks`,children:xe(be)}),n?(0,k.jsx)(b,{pose:n,size:140}):(0,k.jsx)(le,{size:150})]})]})}var Ce=(e,t)=>(e.mate==null?e.cp:Math.sign(e.mate)*(1e5-Math.abs(e.mate)))*(t?1:-1),we=(e,t)=>ae(t?e:{...e,cp:-e.cp,mate:e.mate==null?null:-e.mate});function Te({initialFen:e,moves:t,cursor:i,judged:a,bestUci:o,engineId:s,onGo:c,onPreview:l,voice:u,you:d}){let{t:f}=n(`board`),p=ne(a),m=te[p],g=p===`inaccuracy`||p===`mistake`||p===`blunder`,[_,v]=(0,O.useState)(null),y=ie(e)+i-1,b=`${Math.floor(y/2)+1}${y%2?`…`:`.`}`,x=y%2==0,S=f(!d||d===`white`===x?`verdict.you`:`verdict.played`),C=t[i-1],w=D(e,t,i-1,s)?.lines.slice(0,3)??[],T=D(e,t,i,s)?.lines[0],E=w.findIndex(e=>e.uci[0]===C?.uci),re=E>=0?E:T?w.filter(e=>Ce(e,x)>Ce(T,x)).length:w.length;return(0,O.useEffect)(()=>{if(v(null),!g||!o||w.length)return;let n=new AbortController,r=[...t.slice(0,i-1).map(e=>e.uci),o];return h(`api/line`,{initialFen:e,moves:r},n.signal).then(e=>{e.moves.length===r.length&&v(e.moves.at(-1).san)},()=>{}),()=>n.abort()},[e,t,i,o,g,w.length]),(0,k.jsxs)(`div`,{className:`move-verdict grade-${p}`,role:`status`,"aria-live":`polite`,children:[(0,k.jsxs)(`div`,{className:`verdict-head`,children:[(0,k.jsx)(`img`,{src:ee(p),alt:``,width:`36`,height:`36`},`${p}-${i}`),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`strong`,{children:f(`verdict.is`,{number:b,san:a.san,grade:m.label})}),(0,k.jsx)(`p`,{children:m.message}),(w.length>0||g)&&(0,k.jsxs)(`p`,{className:`verdict-better`,children:[w.length>0?(0,k.jsxs)(k.Fragment,{children:[E>=0?f(`verdict.pick`,{rank:E+1}):f(`verdict.better`,{count:re}),` `]}):_?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(r,{t:f,i18nKey:`verdict.preferred`,values:{san:_},components:{b:(0,k.jsx)(`b`,{})}}),` `]}):null,g&&(0,k.jsx)(`button`,{type:`button`,className:`text-button`,"aria-label":f(`verdict.showBefore`),title:f(`verdict.showBefore`),onClick:()=>c(i-1),children:f(`verdict.seeBefore`)})]})]}),u&&(0,k.jsx)(`button`,{type:`button`,className:`icon-button verdict-voice`,"aria-pressed":u.on,onClick:u.onToggle,title:f(u.on?`verdict.voiceOff`:`verdict.voiceOn`),"aria-label":f(u.on?`verdict.voiceOff`:`verdict.voiceOn`),children:u.on?`🔊`:`🔇`})]}),(0,k.jsxs)(`ol`,{className:`verdict-picks`,onMouseLeave:()=>l?.(null),children:[w.map((e,t)=>(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,className:t===E?`played`:void 0,title:f(`verdict.previewTitle`),onMouseEnter:()=>l?.(e.uci[0]),onFocus:()=>l?.(e.uci[0]),onBlur:()=>l?.(null),children:[(0,k.jsx)(`span`,{children:t===E?S:t+1}),(0,k.jsx)(`b`,{children:e.moves[0]}),(0,k.jsx)(`em`,{children:we(e,x)})]})},e.uci[0])),E<0&&C&&(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,className:`played${T&&re?` worse`:``}`,title:f(`verdict.previewTitle`),onMouseEnter:()=>l?.(C.uci),onFocus:()=>l?.(C.uci),onBlur:()=>l?.(null),children:[(0,k.jsx)(`span`,{children:S}),(0,k.jsx)(`b`,{children:C.san}),(0,k.jsx)(`em`,{children:T?we(T,x):``})]})}),xe(be-w.length-(E<0&&C?1:0))]})]})}function Ee({position:e,color:t,info:r,lead:i}){let{t:a}=n(`board`),o=y();return(0,k.jsxs)(`div`,{className:`player ${e}-player`,children:[r.avatar?(0,k.jsx)(`span`,{className:`player-avatar portrait`,children:(0,k.jsx)(`img`,{src:r.avatar,alt:``})}):(0,k.jsx)(`span`,{className:`player-avatar ${t===`white`?`light`:`dark`}-piece`,children:(0,k.jsx)(`img`,{src:x(t===`white`?`N`:`n`,o),alt:``})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`strong`,{id:`${e}-name`,children:r.name}),(0,k.jsx)(`small`,{id:`${e}-detail`,children:r.detail})]}),i===void 0?(0,k.jsx)(`span`,{className:`player-tag`,id:`${e}-tag`,children:a(`players.${t}`)}):(0,k.jsx)(`span`,{className:`player-lead`,id:`${e}-lead`,title:i?a(`players.ahead`,{count:Number(i.slice(1))}):void 0,children:i})]})}function De({progress:e,cursor:t,total:r,onGo:i,autoplay:a,onAutoplay:o,fen:s,onCopy:c,disabled:l=!1}){let{t:u}=n(`board`);return(0,k.jsxs)(`div`,{className:`playback`,children:[(0,k.jsx)(`span`,{id:`move-progress`,children:e}),(0,k.jsxs)(`div`,{className:`playback-buttons`,children:[(0,k.jsx)(`button`,{id:`first`,type:`button`,"aria-label":u(`playback.first`),title:u(`playback.first`),disabled:l||t===0,onClick:()=>i(0),children:(0,k.jsx)(_e,{to:`first`})}),(0,k.jsx)(`button`,{id:`previous`,type:`button`,"aria-label":u(`playback.previous`),title:u(`playback.previousTitle`),disabled:l||t===0,onClick:()=>i(t-1),children:(0,k.jsx)(_e,{to:`previous`})}),o&&(0,k.jsx)(`button`,{id:`autoplay`,type:`button`,className:`autoplay`,"aria-label":u(a?`playback.pause`:`playback.autoplay`),title:u(`playback.autoplay`),disabled:!r,onClick:o,children:(0,k.jsx)(`img`,{src:`art/ui3d/${a?`pause`:`play`}.webp`,alt:``,width:`20`,height:`20`})}),(0,k.jsx)(`button`,{id:`next`,type:`button`,"aria-label":u(`playback.next`),title:u(`playback.nextTitle`),disabled:l||t===r,onClick:()=>i(t+1),children:(0,k.jsx)(_e,{to:`next`})}),(0,k.jsx)(`button`,{id:`last`,type:`button`,"aria-label":u(`playback.last`),title:u(`playback.last`),disabled:l||t===r,onClick:()=>i(r),children:(0,k.jsx)(_e,{to:`last`})})]}),s!==void 0&&(0,k.jsxs)(`button`,{id:`copy-fen`,type:`button`,title:u(`playback.copyFen`),onClick:c,children:[`FEN `,(0,k.jsx)(`span`,{children:`⧉`})]})]})}function Oe({planning:e}){let{t}=n(`board`),r=e.marks.length;return(0,k.jsxs)(`div`,{className:`planning-toolbar`,children:[(0,k.jsx)(`button`,{id:`draw-mode`,type:`button`,"aria-pressed":e.drawMode,title:t(`planning.drawTitle`),onClick:e.toggleDrawMode,children:t(`planning.draw`)}),(0,k.jsxs)(`select`,{id:`arrow-mode`,"aria-label":t(`planning.mode`),value:e.freeform?`freeform`:`legal`,onChange:t=>e.setFreeform(t.target.value===`freeform`),children:[(0,k.jsx)(`option`,{value:`legal`,children:t(`planning.legal`)}),(0,k.jsx)(`option`,{value:`freeform`,children:t(`planning.freeform`)})]}),(0,k.jsx)(`span`,{id:`planning-help`,children:e.drawMode?t(`planning.chooseStart`):t(`planning.rightDrag`)}),(0,k.jsx)(`button`,{id:`clear-marks`,type:`button`,title:t(`planning.clearTitle`),disabled:!r,onClick:e.clear,children:t(`planning.clear`)})]})}function ke({info:e}){let{t}=n(`board`);return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{id:`heat-legend`,children:[(0,k.jsx)(`span`,{className:`heat-white-key`,children:t(`heat.legend.white`)}),(0,k.jsx)(`span`,{className:`heat-black-key`,children:t(`heat.legend.black`)}),(0,k.jsx)(`span`,{className:`heat-contested-key`,children:t(`heat.legend.both`)}),(0,k.jsx)(`span`,{className:`heat-neutral-key`,children:t(`heat.legend.neutral`)})]}),(0,k.jsx)(`p`,{id:`square-info`,children:e})]})}var A={p:`pawn`,n:`knight`,b:`bishop`,r:`rook`,q:`queen`,k:`king`},Ae=w._domains,j=(e,t)=>u.t(`commentary:${e}`,t??{}),je=(e,t)=>Number.isInteger(t)&&t>=Ae[e][0]&&t<=Ae[e][1],Me=new Map,M=new Map,Ne=Math.random;function N(e,t){let n=u.t(`commentary:${e}`,{returnObjects:!0,...t});if(typeof n==`string`)return n;if(!Array.isArray(n)||!n.length)return``;let r=`${u.language}:${e}`,i=Me.get(r);i?.length||(i=n.map((e,t)=>t).filter(e=>n.length<2||e!==M.get(r)));let a=i.splice(Math.floor(Ne()*i.length),1)[0];return Me.set(r,i),M.set(r,a),String(n[a]??n[0])}function P(e,t,n){return n===1?j(`${e}.1`):je(t,n)?j(`${e}.other`,{[t]:n}):null}function Pe(e){let t=e.replace(/[!?]+$/,``),n=[];if(t.startsWith(`O-O-O`))n.push(j(`move.castleLong`));else if(t.startsWith(`O-O`))n.push(j(`move.castleShort`));else{let e=t.match(/([a-h][1-8])(?:=[NBRQ])?[+#]?$/)?.[1];if(!e)return[];let r=/^[NBRQK]/.test(t)?A[t[0].toLowerCase()]:`pawn`;n.push(j(`move.${t.includes(`x`)?`takes`:`to`}.${r}`,{square:e}));let i=t.match(/=([NBRQ])/)?.[1];i&&n.push(j(`move.promote.${A[i.toLowerCase()]}`))}return t.endsWith(`#`)?n.push(j(`move.mate`)):t.endsWith(`+`)&&n.push(j(`move.check`)),n}function Fe(e){let t=Math.round(e);return t<60?P(`clock.seconds`,`seconds`,Math.max(1,t)):P(`clock.minutes`,`minutes`,Math.round(t/60))}function F(e,t,n){let r=n.slice(0,2),i=n.slice(2,4),a=e.pieces[r];if(!a)return null;let o=e.pieces[i];!o&&a.toLowerCase()===`p`&&r[0]!==i[0]&&(o=e.pieces[`${i[0]}${r[1]}`]);let s=o?A[o.toLowerCase()]:void 0;if(!s||s===`king`)return null;let c=a===a.toUpperCase()?`white`:`black`,l=t.control?.[i];if(!l)return{piece:s,mover:c,free:!1};let u=l[c].length>0;return{piece:s,mover:c,free:l[c===`white`?`black`:`white`].filter(e=>t.pieces[e]?.toLowerCase()!==`k`||!u).length===0}}var Ie={N:[`b1`,`g1`],B:[`c1`,`f1`],n:[`b8`,`g8`],b:[`c8`,`f8`]},I=`abcdefgh`,L={pawn:1,knight:3,bishop:3,rook:5,queen:9,king:100},R=e=>e===e.toUpperCase()?`white`:`black`,Le=16,Re=12;function ze(e,t){let n=e.pieces[t];if(!n)return[];let r=R(n),i=r===`white`?`black`:`white`,a=L[A[n.toLowerCase()]];return Object.entries(e.pieces).filter(([n,a])=>R(a)===i&&e.control?.[n]?.[r].includes(t)).map(([t,n])=>({piece:A[n.toLowerCase()],defended:(e.control?.[t]?.[i].length??0)>0})).filter(({piece:e,defended:t})=>e===`king`||e!==`pawn`&&(!t||L[e]>a)).map(({piece:e})=>e).sort((e,t)=>L[t]-L[e])}var z=[[1,1],[1,-1],[-1,1],[-1,-1]],Be=[[1,0],[-1,0],[0,1],[0,-1]],Ve={b:z,r:Be,q:[...z,...Be]};function He(e,t){let n=e.pieces[t],r=n?Ve[n.toLowerCase()]:void 0;if(!n||!r)return null;let i=R(n);for(let[n,a]of r){let r=[],o=I.indexOf(t[0])+n,s=Number(t[1])+a;for(;o>=0&&o<8&&s>=1&&s<=8&&r.length<2;){let t=e.pieces[`${I[o]}${s}`];if(t){if(R(t)===i)break;r.push(t)}o+=n,s+=a}if(r.length<2)continue;let[c,l]=r.map(e=>A[e.toLowerCase()]);if(c!==`pawn`&&c!==`king`){if(l===`king`)return{kind:`pinKing`,piece:c};if(L[l]>L[c])return{kind:`pin`,piece:c}}}return null}function Ue(e,t,n){let r=n.slice(0,2),i=n.slice(2,4),a=e.pieces[r],o=t.pieces[i];if(!a||!o)return null;let s=R(a),c=A[o.toLowerCase()];if(c===`king`)return null;let l=e.pieces[i]?L[A[e.pieces[i].toLowerCase()]]:0,u=t.control?.[i],d=(u?.[s===`white`?`black`:`white`]??[]).map(e=>L[A[t.pieces[e]?.toLowerCase()??`k`]]);if(!d.length||L[c]-l<1)return null;let f=(u?.[s].length??0)>0,p=Math.min(...d);return f&&(p>=L[c]||p===L.king)?null:c}var We=(e,t,n)=>{let r=e.control?.[t];return!!r&&r[n===`white`?`black`:`white`].length>0&&r[n].length===0};function B(e,t,n){let r=n.slice(0,2),i=n.slice(2,4),a=e.pieces[r];if(!a)return null;let o=R(a),s=null;for(let[n,a]of Object.entries(t.pieces)){let c=A[a.toLowerCase()];R(a)===o&&c!==`pawn`&&c!==`king`&&We(t,n,o)&&(We(e,n===i?r:n,o)&&e.pieces[n===i?r:n]===a||(!s||L[c]>L[s])&&(s=c))}return s}function Ge(e,t,n){let r=I.indexOf(t[0]),i=Number(t[1]),a=n?`p`:`P`;return!Object.entries(e.pieces).some(([e,t])=>t===a&&Math.abs(I.indexOf(e[0])-r)<=1&&(n?Number(e[1])>i:Number(e[1])<i))}function V(e,t,n,r,i,a,o){let s=e.replace(/[!?]+$/,``),c=t.slice(0,2),l=t.slice(2,4),u=n.pieces[c];if(!u)return null;let d=u===u.toUpperCase(),f=u.toLowerCase(),p=s.match(/=([NBRQ])/)?.[1];if(p)return{kind:`promote`,piece:A[p.toLowerCase()]};if(s.endsWith(`#`))return{kind:`mate`};if(s.startsWith(`O-O-O`))return{kind:`castleLong`};if(s.startsWith(`O-O`))return{kind:`castleShort`};if(s.includes(`x`)){if(i?.san.includes(`x`)&&i.uci.slice(2,4)===l)return{kind:`recapture`};let e=F(n,r,t);if(e)return{kind:e.piece===A[f]?`trade`:`takes`,piece:e.piece}}let m=ze(r,l);if(m.length>=2){let e=m.find(e=>e!==`king`);return m[0]===`king`&&e?{kind:`forkKing`,piece:e}:{kind:`fork`}}if(s.endsWith(`+`))return o?.san.replace(/[!?]+$/,``).endsWith(`+`)?{kind:`checkAgain`}:{kind:`check`,piece:A[f]};let h=He(r,l);if(h)return h;if(Ie[u]?.includes(c))return{kind:m.length?`tempo`:`develop`,piece:A[f]};if(m.length&&m[0]!==`king`)return{kind:`attacks`,piece:m[0]};if(f===`q`&&a!=null&&a<=Le)return{kind:`earlyQueen`};if(f===`k`&&Object.values(r.pieces).includes(`Q`)&&Object.values(r.pieces).includes(`q`))return{kind:`kingWalk`};if(f===`r`&&c[0]!==l[0]&&!Object.entries(r.pieces).some(([e,t])=>e[0]===l[0]&&t.toLowerCase()===`p`))return{kind:`openFile`};if(f===`p`){let e=Number(l[1]);if((d?e>=5:e<=4)&&Ge(r,l,d))return{kind:`passedPawn`};if([`d4`,`e4`,`d5`,`e5`].includes(l)&&Number(c[1])===(d?2:7))return{kind:`center`}}return a!=null&&Math.ceil(a/2)===Re&&r.pieces[d?`e1`:`e8`]===(d?`K`:`k`)?{kind:`kingCenter`}:null}var Ke=e=>N(`piece`in e?`describe.${e.kind}.${e.piece}`:`describe.${e.kind}`),qe=[`inaccuracy`,`mistake`,`blunder`],H=[`mistake`,`blunder`],U=[`brilliant`,`great`,`inaccuracy`,`mistake`,`blunder`],W=30,G=3,Je=5,Ye=[`winning`,`flipped`,`slipAway`,`mate`];function Xe(e,t=!1){let n=[],r=qe.includes(e.grade),i=H.includes(e.grade),a=t?U.filter(e=>e!==`inaccuracy`):U,o=!t;e.opening&&n.push(N(`opening`,{opening:e.opening})),o&&e.outOfBook&&n.push(N(`outOfBook`)),a.includes(e.grade)&&n.push(N(`grade.${e.grade}`)),i&&e.answersSlip&&n.push(N(`momentum.blunderBack`)),o&&e.firstCapture&&n.push(N(`momentum.firstCapture`));let s=!r&&!e.capture?.free?e.sacrifice:null;if(e.capture?.free)n.push(N(`${i?`poisoned`:`free`}.${e.capture.piece}`));else if(s){let t=s===`rook`&&(e.capture?.piece===`knight`||e.capture?.piece===`bishop`);n.push(N(t?`describe.exchangeSac`:`describe.sacrifice.${s}`))}else!U.includes(e.grade)&&e.theme&&(o||e.theme.kind===`mate`||e.theme.kind===`promote`)&&n.push(Ke(e.theme));o&&r&&e.hangs&&n.push(N(`reason.hangs.${e.hangs}`));let c=e.evalEvent,l=c&&!(r&&c.kind===`better`)&&(o||Ye.includes(c.kind));c&&l&&n.push(N(`side`in c?`eval.${c.kind}.${c.side}`:`eval.${c.kind}`));let u=e.missedMate&&e.missedMate<=Je?e.missedMate:null;if(u){let e=P(`missedMate`,`mate`,u);e&&n.push(e)}if(((o?r:i)||u)&&e.bestSan&&e.bestSan!==e.san){let t=Pe(e.bestSan);t.length&&n.push(N(`better`),...t)}if(o){let t=e.thinkSeconds,a=!!c&&(c.kind===`slipAway`||`side`in c&&c.kind!==`better`&&c.side===`white`!==e.moverWhite);if(t!=null){let o=Fe(t);t>=(e.longThink??W)&&o&&(i||!r&&!a)?n.push(N(`clock.tookYou`),o,N(i?`clock.stillWrong`:`clock.worthIt`)):t<=G&&i&&n.push(N(`clock.fastWrong`))}e.clockEvent&&n.push(N(`clock.${e.clockEvent}`))}e.repetition&&(o||e.repetition>=2)&&n.push(N(e.repetition>=2?`momentum.threefold`:`momentum.repeat`));let d=e.result===`1-0`?`white`:e.result===`0-1`?`black`:e.result===`1/2-1/2`?`draw`:null;return d&&n.push(N(`end.${d}`)),n.filter(Boolean)}var Ze=e=>e.split(/[:,]/)[0].trim();function Qe(e,t){let[n,r]=(t??``).split(`+`).map(Number);return e.map((t,i)=>{let a=t.clock,o=i>=2?e[i-2].clock:Number.isFinite(n)&&n>0?n:void 0;if(a==null||o==null)return null;let s=o-a+(Number.isFinite(r)?r:0);return s>=0?s:null})}function $e(e){let t=Number((e??``).split(`+`)[0]);return Number.isFinite(t)&&t>0?Math.min(120,Math.max(15,Math.round(t*.04))):W}var K=T;function et(e,t){if(!e)return null;let[n,r]=Array.isArray(e)?e:[e.cp,e.mate],i=r==null?n==null?null:Math.max(-K,Math.min(K,n)):r>0?K:-K;return i==null?null:t?i:-i}var q=300,J=100,tt=50,nt=150,rt=e=>e?Array.isArray(e)?e[1]:e.mate:null;function it(e,t,n,r){let i=et(e,!0),a=et(t,!0);if(i==null||a==null)return null;let o=e=>e>0?`white`:`black`,s=rt(t),c=[rt(e),rt(r??null)];if(s!=null&&s!==0&&!c.some(e=>e!=null&&Math.sign(e)===Math.sign(s)))return{kind:`mate`,side:s>0?`white`:`black`};if(s!=null)return null;if(Math.abs(i)>=nt&&Math.abs(a)>=nt&&Math.sign(a)!==Math.sign(i))return{kind:`flipped`,side:o(a)};let l=n?1:-1;return i*l>=q&&a*l<=J?{kind:`slipAway`}:Math.abs(a)>=q&&Math.abs(i)<q?{kind:`winning`,side:o(a)}:Math.abs(a)<tt&&Math.abs(i)>=nt?{kind:`equal`}:Math.abs(a)>=J&&Math.abs(i)<J?{kind:`better`,side:o(a)}:null}function Y(e,t){return e==null||t==null?null:e<10&&t>=10?`lowSeconds`:e<60&&t>=60?`lowMinute`:null}var at=300,ot=-100;function X(e,t,n,r){let i=e.map(e=>et(e,t===`white`)),a=-1,o=-1;if(i.slice(0,-1).forEach((e,t)=>{e!=null&&t!==0&&((a<0||e<i[a])&&(a=t),(o<0||e>i[o])&&(o=t))}),a<0)return null;let s=e=>Math.floor((ie(r)+e-1)/2)+1,c=i[a],l=i[o];return n===`won`?c<=-300?{kind:`comeback`,move:s(a)}:c>ot?{kind:`control`}:null:n===`lost`?l>=at?{kind:`collapse`,move:s(o)}:null:l>=at?{kind:`slippedToDraw`,move:s(o)}:c<=-300?{kind:`saved`,move:s(a)}:null}function st(e){let t=[];e.outcome&&t.push(j(`recap.${e.outcome}`));let n=e.swing;n&&(n.kind===`control`?t.push(j(`recap.control`)):je(`move`,n.move)&&t.push(j(`recap.${n.kind}`,{move:n.move}))),e.accuracy!=null&&je(`percent`,Math.round(e.accuracy))&&t.push(j(`recap.accuracy`,{percent:Math.round(e.accuracy)}));let r=e.counts;if(r){for(let e of[`brilliant`,`mistake`]){let n=r[e]?P(`recap.${e}`,`count`,r[e]):null;n&&t.push(n)}let e=r.blunder??0,n=e?P(`recap.blunder`,`count`,e):j(`recap.noBlunders`);n&&t.push(n)}let i=e.longestThink,a=i&&i.seconds>=(e.longThink??W)?Fe(i.seconds):null;return i&&a&&je(`move`,i.move)&&t.push(j(`recap.longestThink`),a,j(`recap.onMove`,{move:i.move}),j(i.good?`recap.paidOff`:`recap.didNotPayOff`)),t.filter(Boolean)}function ct(e,t){return N(`live.${e.mover===t?e.free?`free`:`took`:e.free?`hung`:`lost`}.${e.piece}`)}var lt=[`mistake`,`blunder`],ut=16,dt=1.25;function ft(e,t,n,r){let i=e=>e.split(` `).slice(0,4).join(` `),a=0;for(let o=n-2;o>=0;o-=2){let n=o===0?{fen:e}:ge(e,t,o);n&&i(n.fen)===i(r.fen)&&a++}return a}function pt({enabled:e,initialFen:t,moves:n,cursor:r,judgments:i,before:a,after:o,engineId:s,opening:c,thinkTimes:l,longThink:u,startClock:d,result:p,brief:m=!1}){let h=pe(),g=f.use(),_=(0,O.useMemo)(()=>{let e=!1;for(let t of[...i?.keys()??[]].sort((e,t)=>e-t)){let n=ne(i.get(t))===`book`;if(e&&!n)return t;e||=n}return null},[i]),v=r>0?i?.get(r):void 0,y=n[r-1],b=r>1?i?.get(r-1):void 0,x=!!(v&&y&&a&&o),S=(0,O.useMemo)(()=>{if(!x)return null;let e=(ie(t)+r-1)%2==0?1:-1,i=D(t,n,r-1,s)?.lines[0],f=D(t,n,r,s)?.lines[0],m=i?.mate!=null&&i.mate*e>0?i.mate*e:null,h=y.san.includes(`#`)||i?.uci[0]===y.uci||f?.mate!=null&&f.mate*e>0;return{san:y.san,grade:ne(v),capture:F(a,o,y.uci),theme:V(y.san,y.uci,a,o,n[r-2],ie(t)+r,n[r-3]),sacrifice:Ue(a,o,y.uci),repetition:ft(t,n,r,o),hangs:B(a,o,y.uci),evalEvent:i&&f?it(i,f,e>0,D(t,n,r-2,s)?.lines[0]):null,moverWhite:e>0,answersSlip:!!b&<.includes(ne(b)),firstCapture:y.san.includes(`x`)&&r>ut&&!n.slice(0,r-1).some(e=>e.san.includes(`x`)),result:r===n.length?p:null,clockEvent:Y(y.clock,r>=3?n[r-3].clock:d),bestSan:i&&i.uci[0]!==y.uci?i.moves[0]:null,missedMate:m&&!h?m:null,opening:c&&c.ply===r?Ze(c.name):null,outOfBook:r===_,thinkSeconds:l?.[r-1]??null,longThink:u}},[x,t,n,r,s,v,y,a,o,c,_,l,u,d,p,b]),C=(0,O.useRef)(null),w=(0,O.useRef)(r),{speak:ee,stop:te}=h,T=(0,O.useEffectEvent)(()=>{te(),C.current=e?r:null});return(0,O.useEffect)(()=>{w.current!==r&&(w.current=r,T())},[r]),(0,O.useEffect)(()=>{if(C.current!==r||!S)return;C.current=null;let e=g?Xe(S,m):[];e.length&&ee({parts:e,rate:dt})},[r,S,g,m,ee]),{on:g,speaking:h.speaking,toggle:()=>{g&&h.stop(),f.set(!g)}}}function mt(e,t){return(e?.lines.find(e=>e.uci[0]===t))?.moves[0]??null}var Z={p:1,n:3,b:3,r:5,q:9};function ht(e){let t=0;for(let n of e.split(` `)[0]){let e=Z[n.toLowerCase()];e&&(t+=n===n.toLowerCase()?-e:e)}return t}function Q(e){let{mode:t,initialFen:r,moves:i,cursor:a,onGo:u,flipped:f,onFlip:h,players:y,movable:b,onMove:x,busy:w=!1,busyText:ee,headerActions:te,heading:T=!0,context:ie,panelTop:pe,panelBottom:ge,summary:D,showSummary:be,startTab:xe,movesTop:Ce,boardFooter:we,judgments:A,bestMoves:Ae,resultText:j,onTryBest:je,tryLabel:Me,autoplay:M=!1,onBoard:Ne,opening:N,thinkTimes:P,longThink:Pe,startClock:Fe,loading:F,you:Ie,coachMarks:I,hidePieces:L,phoneHead:R,phoneSay:Le,phoneActions:Re}=e,ze=C()&&!!R,{t:z}=n(`board`),Be=Me??z(`engine.tryMove`),{engineAvailable:Ve,engines:He}=S(),Ue=g(),We=i.slice(0,a),{board:B,current:Ge}=he(r,We),[V,Ke]=(0,O.useState)(null);(0,O.useEffect)(()=>Ke(null),[a]);let qe=he(r,i.slice(0,Math.max(0,a-1)),t===`replay`&&a>0),H=V&&qe.current?qe.board:null,U=re(B),W=t!==`play`,G=m.use(),Je=o.use(),Ye=c.use(),Xe=s.use(),Ze=d.use(),Qe=l.use(),$e=!!B?.result,K=He.filter(e=>e.installed),et=p.use(),q=He.length&&!K.some(e=>e.id===et)?`stockfish`:et,J=me(r,We,W&&G&&Ve&&!!B&&!$e,250,q,Qe),tt=J.result?.lines[0]??null,[nt,rt]=(0,O.useState)(null),[it,Y]=(0,O.useState)(xe??`moves`),at=t===`replay`?[...D?[`summary`]:[],`moves`,`engine`]:[],ot=at.length>1,X=at.includes(it)?it:`moves`,st=e=>!ot||X===e;(0,O.useEffect)(()=>{be&&Y(`summary`)},[be]);let ct=(0,O.useRef)(a);(0,O.useEffect)(()=>{ct.current!==a&&(ct.current=a,Y(e=>e===`summary`?`moves`:e))},[a]);let lt=t===`explore`&&Ye;(0,O.useEffect)(()=>{B&&Ge&&Ne?.(B)},[B,Ge,Ne]),(0,O.useEffect)(()=>{document.body.dataset.mode=t,document.body.dataset.page=`board`},[t]);let ut=ve(),dt=(0,O.useRef)(a),ft=(0,O.useEffectEvent)(()=>{i[a-1]&&ut.move(i[a-1].san)});(0,O.useEffect)(()=>{let e=dt.current;dt.current=a,a===e+1&&ft()},[a]);let[Z,Q]=(0,O.useState)(!1),gt=pt({brief:Z,enabled:t===`replay`&&!w&&!F,initialFen:r,moves:i,cursor:a,judgments:A,engineId:q,opening:N,thinkTimes:P,longThink:Pe,startClock:Fe,result:B?.result||j,before:a>0&&qe.current?qe.board:null,after:Ge?B:null});(0,O.useEffect)(()=>{a>=i.length&&Q(!1)},[a,i.length]),(0,O.useEffect)(()=>{if(!Z||gt.speaking)return;let e=setTimeout(()=>u(a+1),900);return()=>clearTimeout(e)},[Z,a,u,gt.speaking]);let[_t,vt]=(0,O.useState)(null);(0,O.useEffect)(()=>{if(!_t)return;let e=setTimeout(()=>vt(null),280);return()=>clearTimeout(e)},[_t]);let yt=e=>{if(e<0||e>i.length){vt(e<0?`back`:`forward`);return}u(e)},bt=(0,O.useEffectEvent)(e=>{let t=e.target;t instanceof Element&&t.closest(`input,textarea,select,dialog`)||e.ctrlKey||e.metaKey||e.altKey||(e.key===`Escape`?(U.clear(),U.drawMode&&U.toggleDrawMode()):e.key===`ArrowLeft`?(e.preventDefault(),Q(!1),yt(a-1)):e.key===`ArrowRight`?(e.preventDefault(),Q(!1),yt(a+1)):e.key.toLowerCase()===`f`&&h())});(0,O.useEffect)(()=>{let e=e=>bt(e);return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);function xt(e){if(!lt||!B)return;let t=B.control?.[e],n=v(t),r=e=>(t?.[e]??[]).map(e=>`${_[B.pieces[e]?.toLowerCase()]??z(`heat.piece`)} ${e}`).join(`, `)||z(`heat.none`);rt(z(`heat.square`,{square:e,kind:z(`heat.kind.${n.kind}`),white:r(`white`),black:r(`black`)}))}async function St(){if(B)try{await navigator.clipboard.writeText(B.fen),Ue(z(`copy.copied`))}catch{Ue(z(`copy.blocked`))}}let Ct=f?`black`:`white`,wt=f?`white`:`black`,Tt=(t===`replay`||ze)&&B?ht(B.fen):null,Et=e=>Tt==null?void 0:(e===`white`?Tt:-Tt)>0?`+${Math.abs(Tt)}`:null,Dt=t===`replay`&&a>0?A?.get(a):void 0,Ot=Dt&&i[a-1]?{square:i[a-1].uci.slice(2,4),grade:ne(Dt)}:null,kt=w?ee??z(`status.thinking`):B?.result?`${B.termination} · ${B.result}`:B?`${z(`status.${B.turn}ToMove`)}${B.check?` · ${z(`status.check`)}`:``}${t===`explore`?` · ${z(`status.exploration`)}`:``}`:z(`status.loading`),$=J.result?.best??null,At=W&&G&&Je&&!$e?$:null,jt=W&&a<i.length?i[a]:null,Mt=Xe?jt?.uci??null:null,Nt=z(t===`replay`?`arrows.playedInGame`:`arrows.nextInLine`),Pt=(0,k.jsx)(De,{progress:oe(r,a,i.length),cursor:a,total:i.length,disabled:w,onGo:e=>{Q(!1),yt(e)},fen:B?.fen,onCopy:St,autoplay:Z,onAutoplay:M?()=>{!Z&&a>=i.length&&u(0),Q(!Z)}:void 0}),Ft=(0,k.jsx)(E,{board:H??B,flipped:f,planning:U,lastMove:H?i[a-2]?.uci:We.at(-1)?.uci,movable:!H&&b,onMove:x,busy:w,showHeat:lt,onHoverSquare:xt,gradeMark:H?null:Ot,bestMove:H?V===i[a-1]?.uci?null:V:I?.arrow??At,highlight:H?[]:I?.highlight,annotations:H?[]:I?.annotations,hidePieces:L,nextMove:H?V===i[a-1]?.uci?V:null:Mt,evalBar:W&&Ze?(0,k.jsx)(se,{board:B,line:G?tt:null,flipped:f}):void 0}),It=Dt&&!w?(0,k.jsx)(Te,{initialFen:r,moves:i,cursor:a,judged:Dt,bestUci:Ae?.[a-1],engineId:q,onPreview:Ke,onGo:e=>{Q(!1),u(e)},voice:{on:gt.on,onToggle:gt.toggle},you:Ie}):t===`replay`&&!!A?.size&&(a===0?(0,k.jsx)(Se,{title:z(`verdict.startTitle`),hint:z(`verdict.startHint`)}):(0,k.jsx)(Se,{title:z(`verdict.pendingTitle`),hint:z(`verdict.pendingHint`),pose:`magnify`}));if(ze){let e=D&&X===`summary`?`summary`:`moves`,n=(e,t,n)=>(0,k.jsx)(`button`,{type:`button`,id:e,"aria-label":z(`playback.${e}`),disabled:w||n,onClick:()=>{Q(!1),yt(t)},children:(0,k.jsx)(_e,{to:e})});return(0,k.jsxs)(`section`,{className:`workspace phone-workspace`,"data-mode":t,"aria-label":z(`workspace.label`),children:[(0,k.jsx)(de,{...R,onFlip:h}),ie,F??(0,k.jsxs)(k.Fragment,{children:[D&&(0,k.jsx)(ue,{className:`bots-segments phone-tabs`,role:`group`,"aria-label":z(`panel.label`),children:[`summary`,`moves`].map(t=>(0,k.jsx)(`button`,{type:`button`,id:`tab-${t}`,"aria-pressed":e===t,className:e===t?`selected`:void 0,onClick:()=>Y(t),children:z(`panel.${t}`)},t))}),e===`summary`?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`phone-summary`,id:`panel-summary`,children:D}),M&&i.length>0&&(0,k.jsx)(`div`,{className:`phone-dock`,children:(0,k.jsx)(`button`,{type:`button`,className:`button primary`,id:`step-through`,onClick:()=>{Y(`moves`),u(0),Q(!0)},children:z(`panel.stepThrough`)})})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(Ee,{position:`top`,color:wt,info:y[wt],lead:Et(wt)}),(0,k.jsx)(`div`,{className:`board-column phone-board`,"data-bump":_t??void 0,children:Ft}),(0,k.jsx)(Ee,{position:`bottom`,color:Ct,info:y[Ct],lead:Et(Ct)}),t===`replay`&&(0,k.jsx)(`div`,{className:`phone-verdict`,children:It}),Le,t===`replay`&&Ce,we,(0,k.jsxs)(`div`,{className:`phone-moves`,children:[t===`play`&&n(`previous`,a-1,a===0),(0,k.jsx)(fe,{initialFen:r,moves:i,cursor:a,onSelect:e=>{Q(!1),u(e)},judgments:A}),t===`play`&&n(`next`,a+1,a===i.length)]}),(0,k.jsx)(`span`,{className:`sr-only`,id:`board-status`,role:`status`,children:kt}),t===`replay`?(0,k.jsxs)(`div`,{className:`phone-dock phone-playback`,children:[n(`first`,0,a===0),n(`previous`,a-1,a===0),M&&(0,k.jsxs)(`button`,{type:`button`,id:`autoplay`,className:`phone-play`,"aria-label":z(Z?`playback.pause`:`playback.autoplay`),disabled:!i.length,onClick:()=>{!Z&&a>=i.length&&u(0),Q(!Z)},children:[(0,k.jsx)(`img`,{src:`art/ui3d/${Z?`pause`:`play`}.webp`,alt:``,width:`20`,height:`20`}),(0,k.jsx)(`span`,{children:oe(r,a,i.length)})]}),n(`next`,a+1,a===i.length),n(`last`,i.length,a===i.length)]}):Re&&(0,k.jsx)(`div`,{className:`phone-dock phone-actions`,children:Re})]})]})]})}return(0,k.jsxs)(`section`,{className:`workspace`,"aria-label":z(`workspace.label`),children:[(0,k.jsxs)(`div`,{className:`board-column`,"data-bump":_t??void 0,children:[T&&(0,k.jsx)(`div`,{className:`board-heading`,children:(0,k.jsxs)(`div`,{className:`board-heading-actions`,children:[te,t===`explore`&&(0,k.jsx)(`div`,{id:`explore-visuals`,children:(0,k.jsxs)(`button`,{id:`heat-toggle`,type:`button`,"aria-pressed":Ye,onClick:()=>c.set(!Ye),children:[`◉ `,z(`heat.toggle`)]})}),(0,k.jsx)(`button`,{className:`icon-button`,id:`flip`,type:`button`,title:z(`workspace.flipTitle`),"aria-label":z(`workspace.flip`),onClick:h,children:`⇅`})]})}),ie,(0,k.jsx)(Ee,{position:`top`,color:wt,info:y[wt],lead:Et(wt)}),Ft,(0,k.jsx)(Ee,{position:`bottom`,color:Ct,info:y[Ct],lead:Et(Ct)}),W&&(0,k.jsxs)(`div`,{className:`arrow-legend`,"aria-label":z(`arrows.label`),children:[(0,k.jsxs)(`button`,{type:`button`,className:`arrow-key best`,"aria-pressed":Je,disabled:!G||!Ve,onClick:()=>o.set(!Je),title:z(`arrows.bestTitle`),children:[(0,k.jsx)(`i`,{"aria-hidden":`true`}),z(`arrows.best`),$&&At?(0,k.jsx)(`b`,{children:mt(J.result,$)}):null]}),(0,k.jsxs)(`button`,{type:`button`,className:`arrow-key next`,"aria-pressed":Xe,disabled:!jt,onClick:()=>s.set(!Xe),title:z(t===`replay`?`arrows.playedTitle`:`arrows.nextTitle`),children:[(0,k.jsx)(`i`,{"aria-hidden":`true`}),Nt,jt?(0,k.jsx)(`b`,{children:jt.san}):null]}),jt&&$&&jt.uci===$&&At&&(0,k.jsxs)(`span`,{className:`arrow-match`,children:[`✓ `,z(`arrows.sameMove`)]})]}),!W&&(0,k.jsxs)(k.Fragment,{children:[Pt,(0,k.jsx)(`div`,{className:`board-footnote`,children:(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`i`,{className:`online-dot`}),` `,(0,k.jsx)(`span`,{id:`board-status`,role:`status`,children:kt})]})}),(0,k.jsx)(Oe,{planning:U})]}),lt&&(0,k.jsx)(ke,{info:nt??z(`heat.hint`)}),we]}),(0,k.jsxs)(`aside`,{className:`analysis-panel`,"data-tab":ot?X:void 0,children:[pe,F??(0,k.jsxs)(k.Fragment,{children:[ot&&(0,k.jsx)(ue,{className:`bots-segments panel-tabs`,role:`group`,"aria-label":z(`panel.label`),children:at.map(e=>(0,k.jsxs)(`button`,{type:`button`,id:`tab-${e}`,"aria-pressed":X===e,"aria-controls":`panel-${e}`,className:X===e?`selected`:void 0,onClick:()=>Y(e),children:[z(`panel.${e}`),e===`engine`&&G&&tt&&!$e&&(0,k.jsx)(`b`,{className:`panel-tab-score`,children:ae(tt)})]},e))}),(0,k.jsxs)(`div`,{className:`panel-page panel-moves`,id:`panel-moves`,hidden:!st(`moves`),children:[It,Ce,t!==`replay`&&(0,k.jsxs)(`div`,{className:`moves-heading`,children:[(0,k.jsx)(`span`,{children:z(`moves.heading`)}),(0,k.jsx)(`span`,{id:`game-result`,children:B?.result||j||z(`moves.inProgress`)})]}),(0,k.jsx)(ce,{initialFen:r,moves:i,cursor:a,onSelect:e=>{Q(!1),u(e)},judgments:A})]}),W&&(0,k.jsxs)(`div`,{className:`panel-page panel-engine`,id:`panel-engine`,hidden:!st(`engine`),children:[(0,k.jsx)(ye,{status:J.status,result:J.result,auto:G,onToggleAuto:()=>m.set(!G),onTryBest:()=>$&&je?.($),tryLabel:Be,available:Ve,finished:$e,engines:K,engineId:q,onEngineChange:p.set}),ot&&J.result&&(0,k.jsx)(`div`,{className:`panel-mascot`,children:(0,k.jsx)(le,{size:150})})]}),D&&(0,k.jsxs)(`div`,{className:`panel-page panel-summary`,id:`panel-summary`,hidden:!st(`summary`),children:[(0,k.jsx)(`div`,{className:`panel-summary-body`,children:D}),M&&i.length>0&&(0,k.jsx)(`div`,{className:`summary-actions`,children:(0,k.jsx)(`button`,{type:`button`,className:`button primary`,id:`step-through`,onClick:()=>{Y(`moves`),u(0),Q(!0)},children:z(`panel.stepThrough`)})})]}),ge,W&&Pt]})]})]})}export{$e as a,Qe as c,F as i,dt as n,st as o,ct as r,X as s,Q as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,g as n,h as r,l as i,m as a,n as o,s,t as c}from"./vendor-DVQGMHsh.js";import{At as l}from"./index-Ba3yxWjC.js";import{c as u,g as d,h as f,m as p,o as m,v as h,y as g}from"./bots-CmOYIVmQ.js";import{t as _}from"./Segments-B8XJlwPB.js";import{i as v,n as ee}from"./events-ClR1xEWT.js";import{c as y,i as b,o as te,s as x}from"./collections-BRU1tQk9.js";import{n as ne}from"./stars-De-qIuRF.js";import{a as S,c as re,collectionPath as C,i as ie,n as ae,o as w,r as T,s as E,t as oe}from"./BotsHomePage-6y1bUgcR.js";var D=e(t(),1),O=c();function se({legends:e,missing:t,fill:n,card:r,onAdded:i}){let{t:a}=o(`play`),[s,c]=(0,D.useState)(null),[u,m]=(0,D.useState)(null);async function _(e){c(e),m(null);try{i(await l(`api/masters/download`,{id:e}))}catch(e){m(e.message)}finally{c(null)}}let v=p.map(n=>({era:n,bots:e.filter(e=>h(e.masterId??``)===n),waiting:t.filter(e=>h(e.id)===n&&g(e.id)).sort((e,t)=>f(e.id,t.id))})).filter(e=>e.bots.length||e.waiting.length);return(0,O.jsxs)(`div`,{className:`bot-week legend-hall`,children:[n?.running&&(0,O.jsx)(`p`,{className:`hall-fill`,role:`status`,children:a(`hall.fetching`,{done:n.done,total:n.total})}),v.map(({era:e,bots:t,waiting:i})=>(0,O.jsxs)(`section`,{className:`hall-era era-${e}`,"aria-label":a(`hall.eras.${e}.name`),children:[(0,O.jsxs)(`div`,{className:`hall-era-heading`,children:[(0,O.jsx)(`img`,{src:d(e),alt:``,loading:`lazy`}),(0,O.jsx)(`h3`,{children:a(`hall.eras.${e}.name`)})]}),(0,O.jsxs)(`div`,{className:`bot-grid`,children:[t.map(r),i.map(e=>(0,O.jsxs)(`div`,{className:`bot-card waiting`,children:[(0,O.jsx)(`span`,{className:`bot-picture`,children:(0,O.jsx)(`img`,{src:g(e.id),alt:``,loading:`lazy`})}),(0,O.jsx)(`span`,{className:`bot-card-name`,children:(0,O.jsx)(`strong`,{children:e.name})}),n?.running&&n.current!==e.id&&!n.failed.includes(e.id)?(0,O.jsx)(`small`,{children:a(`hall.queued`)}):(0,O.jsx)(`button`,{type:`button`,disabled:!!s||n?.current===e.id,onClick:()=>void _(e.id),children:s===e.id||n?.current===e.id?a(`hall.downloading`):a(`hall.getGames`)})]},e.id))]})]},e)),u&&(0,O.jsx)(`p`,{className:`hall-problem`,role:`alert`,children:u})]})}var ce=[`season`,`country`,`theme`,`core`];function k(){let{t:e,i18n:t}=o(`play`),{id:c=``}=r(),l=a(),[d,f]=n(),{collections:p,rating:h,masters:g}=oe(),[E,k]=(0,D.useState)(`easy`),[A,j]=(0,D.useState)(!1),[M,N]=(0,D.useState)(4),[P,F]=(0,D.useState)(!1),[I,ue]=(0,D.useState)(``),L=ne(),R=v();(0,D.useEffect)(()=>(document.body.dataset.page=`bots`,()=>{document.body.dataset.page=`board`}),[]),(0,D.useEffect)(()=>{F(!1),j(!1)},[c]);let z=p.find(e=>e.id===c),B=h??1180,V=e=>e.coach?u(h):e.elo,H=e=>z?te(z,e,R):null,U=e=>z?.kind===`season`?ee(z.id,e.id,R):(L[w(e,M,z)]??0)>=3,W=(0,D.useMemo)(()=>{let e=(z?.bots??[]).slice(),t=e=>Math.abs(V(e)-B);return e.sort((e,n)=>E===`hard`?n.elo-e.elo:E===`near`?t(e)-t(n):e.elo-n.elo),e},[z,E,B]);if(!z)return(0,O.jsx)(i,{to:`/play/bots`,replace:!0});let G=A?W.filter(e=>!U(e)):W,K=d.get(`train`)===`1`,de=d.get(`bot`),q=W.find(e=>e.id===de)??W.filter(e=>!H(e)&&!e.coach).sort((e,t)=>Math.abs(V(e)-B)-Math.abs(V(t)-B))[0]??W[0],fe=e=>f({bot:e.id},{replace:!0}),J=p.filter(e=>e.kind===z.kind),pe=J.indexOf(z),Y=e=>J[(pe+e+J.length)%J.length],me=z.kind===`season`?b(z,R):z.bots.filter(U).length,X=e=>new Date(e).toLocaleDateString(t.language,{month:`long`,year:`numeric`}),Z=new Set(z.abroad??[]);function he(t){let n=x(t);if(z.movedHere?.includes(t.id))return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(T,{code:`VE`}),n?e(`bots.collection.from`,{from:n.from}):e(`bots.collection.venezuelan`)]});if(Z.has(t.id)){let e=y(p,t.id);return(0,O.jsxs)(O.Fragment,{children:[e?.flag&&(0,O.jsx)(T,{code:e.flag}),n?.to??e?.title]})}}let ge=t=>{let n=(z.movedHere?.includes(t.id)||Z.has(t.id))&&x(t),r=y(p,t.id),i=(e,n)=>e&&e!==z.id?(0,O.jsx)(s,{to:C(e,t.id),children:n}):(0,O.jsx)(`span`,{children:n});return n?(0,O.jsxs)(O.Fragment,{children:[i(`venezuela`,(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(T,{code:`VE`}),e(`bots.collection.movedFrom`,{from:n.from})]})),i(r?.id,(0,O.jsxs)(O.Fragment,{children:[r?.flag&&(0,O.jsx)(T,{code:r.flag}),e(`bots.collection.movedTo`,{to:n.to})]}))]}):void 0};function Q(t){let n=H(t);return(0,O.jsx)(ae,{bot:t,rating:t.id===`sf18`?`L${M}`:V(t),selected:t.id===q?.id&&!K,stars:!t.coach&&t.elo>0?L[w(t,M,z)]??0:void 0,starsLabel:e(`lobby.bestStars`,{count:L[w(t,M,z)]??0}),beaten:U(t),locked:!!n,title:t.kind,badge:he(t),onClick:()=>fe(t)},t.id)}let $=I.trim().toLowerCase();return(0,O.jsxs)(`section`,{id:`bot-lobby`,className:`bots-collection`,"aria-label":e(`lobby.label`),children:[(0,O.jsxs)(`nav`,{className:`collection-nav`,"aria-label":e(`bots.collection.navLabel`),children:[(0,O.jsxs)(s,{className:`bots-button back`,to:`/play/bots`,children:[`‹ `,e(`bots.collection.allBots`)]}),(0,O.jsx)(`span`,{className:`collection-group`,children:e(`bots.groups.${z.kind}`)}),(0,O.jsx)(`span`,{className:`collection-slash`,"aria-hidden":!0,children:`/`}),(0,O.jsxs)(`button`,{type:`button`,className:`bots-button picker${P?` open`:``}`,"aria-expanded":P,onClick:()=>F(!P),children:[z.title,` `,(0,O.jsx)(`span`,{"aria-hidden":!0,children:`▾`})]}),J.length>1&&(0,O.jsxs)(`span`,{className:`collection-siblings`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`bots-button`,onClick:()=>l(C(Y(-1).id)),children:[`‹ `,Y(-1).title]}),(0,O.jsxs)(`button`,{type:`button`,className:`bots-button`,onClick:()=>l(C(Y(1).id)),children:[Y(1).title,` ›`]})]}),P&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`div`,{className:`picker-scrim`,onClick:()=>F(!1)}),(0,O.jsxs)(`div`,{className:`collection-picker`,role:`dialog`,"aria-label":e(`bots.collection.pickerLabel`),children:[(0,O.jsx)(`input`,{type:`search`,autoFocus:!0,placeholder:e(`bots.collection.pickerSearch`),value:I,onChange:e=>ue(e.target.value)}),ce.map(t=>{let n=p.filter(e=>e.kind===t&&(!$||e.title.toLowerCase().includes($)));return n.length?(0,O.jsxs)(`div`,{className:`picker-group`,children:[(0,O.jsxs)(`span`,{className:`picker-group-label`,children:[e(`bots.groups.${t}`),` · `,n.length]}),(0,O.jsx)(`div`,{className:`picker-items`,children:n.map(e=>(0,O.jsxs)(s,{to:C(e.id),className:`picker-item${e.id===z.id?` current`:``}`,onClick:()=>F(!1),children:[(0,O.jsxs)(`span`,{className:`picker-face`,children:[e.bots[0]&&(0,O.jsx)(`img`,{src:m(e.bots.find(e=>e.avatar)??e.bots[0]),alt:``}),e.flag&&(0,O.jsx)(T,{code:e.flag,className:`flag picker-flag`})]}),(0,O.jsxs)(`span`,{className:`picker-text`,children:[(0,O.jsx)(`strong`,{children:e.title}),(0,O.jsx)(`small`,{className:e.status===`live`?`live`:``,children:_e(e)})]})]},e.id))})]},t):null})]})]})]}),(0,O.jsx)(le,{collection:z,won:me,month:X}),(0,O.jsxs)(`div`,{className:`collection-body`,children:[(0,O.jsxs)(`div`,{className:`collection-main`,children:[z.id!==`legends`&&(0,O.jsxs)(`div`,{className:`collection-tools`,children:[(0,O.jsx)(_,{"aria-label":e(`bots.collection.sortLabel`),children:[`easy`,`near`,`hard`].map(t=>(0,O.jsx)(`button`,{type:`button`,"aria-pressed":E===t,className:E===t?`selected`:``,onClick:()=>k(t),children:e(`bots.collection.sort.${t}`)},t))}),(0,O.jsxs)(`button`,{type:`button`,className:`hide-beaten`,role:`switch`,"aria-checked":A,onClick:()=>j(!A),children:[(0,O.jsx)(`span`,{className:`switch`,"aria-hidden":!0,children:(0,O.jsx)(`i`,{})}),e(`bots.collection.hideBeaten`)]}),(0,O.jsx)(`span`,{className:`collection-count`,children:e(`bots.collection.count`,{shown:G.length,total:W.length})})]}),z.id===`legends`?(0,O.jsx)(se,{legends:W,missing:g.missing,fill:g.fill,card:Q,onAdded:g.replace}):(0,O.jsxs)(`div`,{className:`bots-grid`,children:[z.id===`yours`&&(0,O.jsxs)(`button`,{type:`button`,className:`bot-card bot-train-tile`,onClick:()=>f({train:`1`},{replace:!0}),children:[(0,O.jsx)(`span`,{className:`bot-picture`,children:(0,O.jsx)(`img`,{src:`art/yours/train.webp`,alt:``,loading:`lazy`})}),(0,O.jsx)(`strong`,{children:e(`lobby.trainNewBot`)}),(0,O.jsx)(`small`,{children:e(`lobby.trainNewBotDetail`)})]}),G.map(Q)]}),A&&!G.length&&(0,O.jsx)(`p`,{className:`bots-empty`,children:e(`bots.collection.allBeaten`)})]}),K?(0,O.jsx)(S,{onClose:()=>f({},{replace:!0})}):q&&(0,O.jsx)(ie,{bot:q,collection:z,lock:H(q),level:M,onLevel:N,move:ge(q)},`${z.id}-${q.id}`)]})]});function _e(t){if(t.kind===`season`){let n=b(t,R);return t.status===`live`?e(`bots.events.liveMeta`,{count:n,total:t.bots.length}):t.status===`soon`?e(`bots.events.inDays`,{count:re(t.start)}):t.status===`later`?e(`bots.events.arrivesMonth`,{when:X(t.start)}):e(`bots.events.endedMeta`,{count:n})}return e(`bots.collection.beatenMeta`,{count:t.bots.filter(e=>(L[e.id]??0)>=3).length,total:t.bots.length})}}function le({collection:e,won:t,month:n}){let{t:r,i18n:i}=o(`play`),a=e.bots.length;if(e.kind===`season`){let o=e.status===`later`?`soon`:e.status,s=e=>new Date(e).toLocaleDateString(i.language,{month:`long`,day:`numeric`});return(0,O.jsxs)(`section`,{className:`collection-hero event-hero`,"data-theme":e.theme,"aria-labelledby":`collection-title`,children:[(0,O.jsxs)(`div`,{className:`event-hero-text`,children:[(0,O.jsxs)(`span`,{className:`event-kicker`,children:[o===`live`&&(0,O.jsx)(`i`,{className:`live-dot`}),r(`bots.events.${o}Kicker`)]}),(0,O.jsx)(`h2`,{id:`collection-title`,children:e.title}),(0,O.jsx)(`p`,{children:o===`live`?r(`bots.events.blurbLive`,{count:a,date:s(e.end-1),need:e.need}):o===`soon`?r(`bots.events.blurbSoon`,{count:a,date:s(e.start)}):r(`bots.events.blurbEnded`,{count:a})}),(0,O.jsxs)(`div`,{className:`event-progress`,children:[(0,O.jsx)(`span`,{className:`meter`,children:(0,O.jsx)(`i`,{style:{width:`${Math.min(100,Math.round(t/(o===`live`?e.need:a)*100))}%`}})}),(0,O.jsx)(`small`,{children:o===`live`?r(`bots.events.progress`,{count:t,need:e.need,total:a}):o===`soon`?r(`bots.events.lockedUntil`,{count:a}):r(`bots.events.youKept`,{count:t,total:a})})]})]}),o===`ended`?(0,O.jsx)(`p`,{className:`event-note`,children:r(`bots.events.returnsNote`,{when:n(e.start),count:t})}):(0,O.jsx)(E,{until:o===`live`?e.end:e.start,label:r(o===`live`?`bots.events.leavesIn`:`bots.events.arrivesIn`)})]})}return(0,O.jsxs)(`section`,{className:`collection-hero event-hero plain`,"aria-labelledby":`collection-title`,children:[(0,O.jsxs)(`div`,{className:`event-hero-text`,children:[(0,O.jsx)(`span`,{className:`event-kicker`,children:r(`bots.collection.kicker.${e.kind}`)}),(0,O.jsxs)(`h2`,{id:`collection-title`,children:[e.flag&&(0,O.jsx)(T,{code:e.flag,className:`flag hero-flag`}),e.title]}),(0,O.jsx)(`p`,{children:e.abroad?r(`bots.collection.blurb.venezuela`,{home:a-e.abroad.length,abroad:e.abroad.length}):r(`bots.collection.blurb.${e.kind===`core`?e.id:e.kind}`,{count:a,title:e.title})}),a>0&&(0,O.jsxs)(`div`,{className:`event-progress`,children:[(0,O.jsx)(`span`,{className:`meter`,children:(0,O.jsx)(`i`,{style:{width:`${Math.round(t/a*100)}%`}})}),(0,O.jsx)(`small`,{children:r(`bots.collection.beatenOf`,{count:t,total:a})})]})]}),e.neighbour&&(0,O.jsx)(`p`,{className:`event-note`,children:(()=>{let t=x(e.neighbour);return t?r(`bots.collection.neighbourMoved`,{name:e.neighbour.name,from:t.from,to:t.to}):r(`bots.collection.neighbourNote`,{name:e.neighbour.name,title:e.title})})()}),e.abroad&&(0,O.jsx)(`p`,{className:`event-note`,children:r(`bots.collection.venezuelaNote`,{count:e.abroad.length})})]})}export{k as BotCollectionPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,s as r,t as i}from"./vendor-DVQGMHsh.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,s as r,t as i}from"./vendor-DVQGMHsh.js";import{At as a}from"./index-Ba3yxWjC.js";import{d as o}from"./routes-SOm45MWj.js";import{n as s}from"./storage-CuQ-NiCI.js";var c=e(t(),1),l=i();function u({game:e,botName:t,onRetry:r}){let{t:i}=n(`play`),[o,u]=(0,c.useState)(null),[f,p]=(0,c.useState)(!1),m=`${e.initialFen} ${e.moves.map(e=>e.uci).join(` `)}`;if((0,c.useEffect)(()=>{let t=!0;return u(null),p(!1),a(`api/played/report`,{initialFen:e.initialFen,moves:e.moves.map(e=>e.uci),playerColor:e.playerColor,notes:e.botNotes??[]}).then(e=>{t&&u(e)},()=>{t&&p(!0)}),()=>{t=!1}},[m]),f||e.moves.length<2)return null;if(!o)return(0,l.jsx)(`p`,{className:`bot-report-loading`,role:`status`,children:i(`report.loading`,{name:t})});let h=s.map(e=>o.ratings[e]?.join(` / `)??null),g=h.filter(Boolean),_=new Set(g).size<=1;return(0,l.jsxs)(`section`,{className:`bot-report`,"aria-label":i(`report.title`,{name:t}),children:[(0,l.jsx)(`h3`,{children:i(`report.title`,{name:t})}),(0,l.jsx)(d,{phases:o.phases,other:t,ratings:g.length?h:void 0}),g.length>0&&(0,l.jsx)(`p`,{children:_?i(`report.steady`,{name:t,elo:g[0]}):i(`report.byPhase`,{name:t})}),o.slips.length>0&&(0,l.jsxs)(`p`,{children:[i(`report.slips`,{name:t,count:o.slips.length}),` `,o.luckySlips>0?i(`report.lucky`,{count:o.luckySlips}):i(`report.unlucky`)]}),o.retry&&r&&(0,l.jsx)(`button`,{type:`button`,className:`button`,onClick:()=>r(o.retry.fen),children:i(`report.retry`,{san:o.retry.san,move:`${o.retry.fen.split(` `)[5]}${o.retry.fen.split(` `)[1]===`b`?`...`:`.`}`})})]})}function d({phases:e,other:t,ratings:r}){let{t:i}=n(`play`),a=e=>e?`${Math.round(e.accuracy)}%`:`–`,o=s.filter(t=>e[t].you||e[t].bot);return(0,l.jsxs)(`table`,{className:`phase-table`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{children:i(`report.phase`)}),(0,l.jsx)(`th`,{children:i(`report.you`)}),(0,l.jsx)(`th`,{children:t}),r&&(0,l.jsx)(`th`,{children:i(`report.setTo`)})]})}),(0,l.jsx)(`tbody`,{children:o.map(t=>(0,l.jsxs)(`tr`,{children:[(0,l.jsx)(`th`,{scope:`row`,children:i(`report.phases.${t}`)}),(0,l.jsx)(`td`,{children:a(e[t].you)}),(0,l.jsx)(`td`,{children:a(e[t].bot)}),r&&(0,l.jsx)(`td`,{children:r[s.indexOf(t)]??`–`})]},t))})]})}function f({termination:e,onNavigate:t}){let{t:i}=n(`play`),a=e.replace(/ (\w)/g,(e,t)=>t.toUpperCase());return[`stalemate`,`insufficientMaterial`,`threefoldRepetition`,`fivefoldRepetition`,`fiftyMoves`,`seventyfiveMoves`].includes(a)?(0,l.jsxs)(`p`,{className:`result-rule`,children:[i(`drawRule.${a}`),` `,(0,l.jsx)(r,{className:`text-button`,to:o(a===`stalemate`?`stalemate`:`draws`),onClick:t,children:i(`drawRule.lesson`)})]}):null}export{f as n,d as r,u as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,f as n,m as r,n as i,r as a,s as o,t as s}from"./vendor-DVQGMHsh.js";import{At as c,O as l,Tt as u,Y as d,k as f,wt as p}from"./index-Ba3yxWjC.js";import{t as m}from"./format-CyB705xj.js";import{c as h,d as g,f as _,o as v,p as y,x as b}from"./bots-CmOYIVmQ.js";import{t as x}from"./useMasters-DtS0PB6J.js";import{t as S}from"./Segments-B8XJlwPB.js";import{i as ee,n as C}from"./events-ClR1xEWT.js";import{i as w,n as T,o as E,t as D}from"./collections-BRU1tQk9.js";import{n as O}from"./stars-De-qIuRF.js";import{a as k,n as A,r as j,s as M,t as N}from"./storage-CuQ-NiCI.js";import{t as P}from"./PhoneParts-BMOk4VLC.js";var F=e(t(),1),I=s(),L=1e3,R=60*L,z=60*R,B=24*z;function V(e=L){let[t,n]=(0,F.useState)(Date.now);return(0,F.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var te=(e,t=Date.now())=>Math.max(1,Math.floor((e-t)/B));function H({until:e,label:t}){let{t:n}=i(`play`),r=V(),a=Math.max(0,e-r),o=[[String(Math.floor(a/B)),`d`],[String(Math.floor(a%B/z)).padStart(2,`0`),`h`],[String(Math.floor(a%z/R)).padStart(2,`0`),`m`],[String(Math.floor(a%R/L)).padStart(2,`0`),`s`]];return(0,I.jsxs)(`div`,{className:`event-clock${a<B?` urgent`:``}`,role:`timer`,"aria-label":`${t} ${n(`bots.clock.spoken`,{d:o[0][0],h:Number(o[1][0]),m:Number(o[2][0])})}`,children:[(0,I.jsx)(`span`,{className:`event-clock-label`,"aria-hidden":!0,children:t}),(0,I.jsx)(`span`,{className:`event-clock-parts`,"aria-hidden":!0,children:o.map(([e,t])=>(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`b`,{children:e}),(0,I.jsx)(`small`,{children:n(`bots.clock.${t}`)})]},t))})]})}var ne=[`none`,`repertoire`,`drill`],re=[`aggression`,`accuracy`,`endgame`];function U({active:e,onClick:t,children:n,disabled:r,title:i}){return(0,I.jsx)(`button`,{type:`button`,"aria-pressed":e,className:e?`selected`:``,onClick:t,disabled:r,title:i,children:n})}var W=(e,t,n)=>e.id===`sf18`?`sf18-l${t}`:n?.kind===`season`?`${n.id}:${e.id}`:e.id;function G({bot:e,collection:t,lock:n,level:a,onLevel:o,move:s}){let{t:c,i18n:l}=i(`play`),d=r(),{games:_,engineAvailable:y}=u(),{loaded:x,installed:ee}=p(),C=x?ee:void 0,w=Number(_.find(e=>e.user_rating)?.user_rating)||null,[T,E]=(0,F.useState)(`White`),[D,k]=(0,F.useState)(!1),[P,L]=(0,F.useState)(null);(0,F.useEffect)(()=>L(null),[e.id]);let R=g(e,C),z=!n&&R&&(e.engineId&&e.engineId!==`stockfish`?!0:y),B=e.coach?h(w):e.elo,V=O()[W(e,a,t)]??0,H=e.id!==`sf18`&&!e.modelId&&e.elo>0&&R,G=P??{opening:B,middlegame:B,endgame:B},K=e.id===`sf18`?c(`lobby.engineLevel`,{level:a}):e.avatar||R?e.kind:c(`lobby.kindDesignPreview`,{kind:e.kind.split(` · `)[0]}),q=w&&e.elo>0&&e.id!==`sf18`?B-w:null,J=t?.kind===`season`?t:void 0,ae=e=>new Date(e).toLocaleDateString(l.language,{month:`long`,year:`numeric`});function oe(){if(!z)return;let t=T===`Random`?Math.random()<.5?`White`:`Black`:T,n=e.engineId&&e.engineId!==`stockfish`?e.engineId:void 0;M({initialFen:m,moves:[],playerColor:t===`White`?`white`:`black`,level:a,result:null,...e.avatar||n||e.masterId?{botId:e.id}:{},...e.masterId?{masterId:e.masterId,elo:e.elo,botName:e.name}:{},...e.avatar?{elo:B,botName:e.name}:{},...n?{engineId:n,botName:e.name}:{},...e.modelId?{modelId:e.modelId}:{},...e.nodes?{nodes:e.nodes}:{},...H&&D?{phaseElo:G}:{},...e.coach?{coached:!0}:{},...e.outfit&&e.avatar?{outfit:e.avatar}:{},...J?.status===`live`?{event:J.id}:{},...e.regular?{costume:e.name}:{},...J?{starsKey:W(e,a,J)}:{}}),d(`/play`,{state:{started:Date.now()}})}let Y=e.masterId?b(e.masterId):void 0;return(0,I.jsxs)(`aside`,{id:`bot-setup`,className:`bot-panel`,"aria-label":c(`lobby.setupLabel`),"aria-live":`polite`,children:[(0,I.jsxs)(`span`,{className:`bot-stage${Y?` has-venue`:``}${n?` locked`:``}`,children:[Y&&(0,I.jsx)(`img`,{className:`bot-stage-venue`,src:Y,alt:``}),(0,I.jsx)(`img`,{src:v(e),alt:e.name})]}),(0,I.jsxs)(`div`,{className:`bot-panel-title`,children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`span`,{className:`bot-detail-rating`,children:e.id===`sf18`?`L${a}`:B})]}),e.outfit&&J&&(0,I.jsx)(`span`,{className:`bot-outfit`,children:e.regular?c(`bots.panel.playedBy`,{name:e.regular}):c(`bots.panel.wearing`,{title:J.title})}),s&&(0,I.jsx)(`p`,{className:`bot-move`,children:s}),e.hello&&(0,I.jsxs)(`p`,{className:`bot-hello`,children:[`“`,e.hello,`”`]}),(0,I.jsxs)(`div`,{className:`bot-panel-row`,children:[(0,I.jsx)(`span`,{children:c(`bots.panel.plays`)}),(0,I.jsx)(`b`,{children:s?K.replace(/\s*·[^·]*→[^·]*$/,``):K})]}),R&&!e.coach&&(0,I.jsxs)(`div`,{className:`bot-panel-row bot-best`,children:[(0,I.jsx)(`span`,{children:c(`lobby.yourBest`)}),(0,I.jsx)(f,{count:V,size:18,label:c(`lobby.bestStars`,{count:V})}),q!==null&&(0,I.jsx)(`b`,{className:q>150?`above`:q<-150?`below`:``,children:q===0?c(`bots.panel.yourLevel`):c(`bots.panel.vsYou`,{diff:`${q>0?`+`:`−`}${Math.abs(q)}`})})]}),n?(0,I.jsxs)(`div`,{className:`bot-locked`,children:[(0,I.jsx)(`strong`,{children:n===`soon`?t.status===`later`?c(`bots.events.arrivesMonth`,{when:ae(t.start)}):c(`bots.locked.soon`,{count:te(t.start)}):c(`bots.locked.returns`,{when:ae(t.start)})}),(0,I.jsx)(`span`,{children:c(n===`soon`?`bots.locked.soonNote`:`bots.locked.endedNote`)})]}):(0,I.jsxs)(`div`,{className:`bot-game-options`,children:[e.id===`sf18`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`label`,{className:`bot-field-label`,children:c(`lobby.engineStrength`)}),(0,I.jsx)(S,{className:`bots-segments bot-levels`,children:N.map(e=>(0,I.jsx)(U,{active:a===e,onClick:()=>o(e),children:e},e))})]}),(0,I.jsx)(`label`,{className:`bot-field-label`,children:c(`lobby.timeControl`)}),(0,I.jsx)(S,{children:[`10+0`,`5+0`,`25+10`,`∞`].map(e=>(0,I.jsx)(U,{active:e===`∞`,disabled:e!==`∞`,title:e===`∞`?void 0:c(`lobby.timedNotConnected`),children:e},e))}),(0,I.jsx)(`label`,{className:`bot-field-label`,children:c(`lobby.playAs`)}),(0,I.jsx)(S,{children:[`White`,`Black`,`Random`].map(e=>(0,I.jsx)(U,{active:T===e,onClick:()=>E(e),children:c(`lobby.sides.${e}`)},e))}),e.coach&&(0,I.jsx)(`p`,{className:`bot-option-note`,children:c(`lobby.coachOnNote`)}),!z&&(0,I.jsx)(`p`,{className:`bot-preview-note`,children:c(R?`lobby.installStockfish`:`lobby.designPreview`)}),(0,I.jsx)(`button`,{type:`button`,className:`bots-button solid bot-start`,disabled:!z,onClick:oe,children:c(z?`lobby.start`:`lobby.previewOnly`)}),!R&&(0,I.jsx)(`button`,{type:`button`,className:`bot-stockfish-link`,onClick:()=>d(`/play/bots/engines?bot=sf18`),children:c(`lobby.chooseStockfish`)}),(0,I.jsxs)(`details`,{className:`bot-more`,children:[(0,I.jsx)(`summary`,{children:c(`bots.panel.more`)}),(0,I.jsx)(`p`,{className:`bot-desc`,children:e.desc}),e.id===`sf18`?(0,I.jsxs)(`div`,{className:`bot-engine-available`,children:[(0,I.jsx)(`i`,{}),c(y?`lobby.stockfishInstalled`:`lobby.stockfishUnavailable`)]}):e.master?(0,I.jsx)(ie,{master:e.master}):e.style.map((e,t)=>(0,I.jsxs)(`div`,{className:`bot-style`,children:[(0,I.jsx)(`span`,{children:c(`lobby.styles.${re[t]}`)}),(0,I.jsx)(`i`,{children:(0,I.jsx)(`b`,{className:`style-${t}`,style:{width:`${e}%`}})}),(0,I.jsxs)(`small`,{children:[e,`%`]})]},t)),(0,I.jsx)(`p`,{className:`bot-data-note`,children:e.id===`sf18`?c(`lobby.notes.engine`):e.master?c(`legend.note`,{name:e.name,elo:e.elo}):e.avatar?c(B<1150?`lobby.notes.characterSlips`:`lobby.notes.character`,{elo:B}):c(R?`lobby.notes.engine`:`lobby.notes.preview`)}),(0,I.jsx)(`label`,{className:`bot-field-label`,children:c(`lobby.opening`)}),(0,I.jsx)(S,{children:ne.map((e,t)=>(0,I.jsx)(U,{active:t===0,disabled:t>0,title:t?c(`lobby.openingNotConnected`):void 0,children:c(`lobby.openings.${e}`)},e))}),H&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`label`,{className:`bot-field-label`,children:c(`lobby.strengthByPhase`)}),(0,I.jsxs)(S,{children:[(0,I.jsx)(U,{active:!D,onClick:()=>k(!1),children:c(`lobby.sameStrength`,{elo:B})}),(0,I.jsx)(U,{active:D,onClick:()=>k(!0),children:c(`lobby.perPhase`)})]}),D&&(0,I.jsxs)(`div`,{className:`bot-phase-sliders`,children:[A.map(e=>(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:c(`lobby.phases.${e}`)}),(0,I.jsx)(`input`,{type:`range`,min:j[0],max:Math.min(j[1],2800),step:50,value:G[e],onChange:t=>L({...G,[e]:Number(t.target.value)})}),(0,I.jsx)(`b`,{children:G[e]})]},e)),(0,I.jsx)(`p`,{className:`bot-option-note`,children:c(`lobby.perPhaseNote`)})]})]}),(0,I.jsxs)(`div`,{className:`bot-option-unavailable`,children:[(0,I.jsx)(`span`,{children:c(`lobby.ladder`)}),(0,I.jsx)(`span`,{children:c(`lobby.unrated`)})]})]})]})]})}function K({onClose:e}){let{t}=i(`play`),n=r(),{games:o}=u();return(0,I.jsxs)(`aside`,{id:`bot-setup`,className:`bot-panel bot-training`,"aria-label":t(`lobby.trainBot`),children:[(0,I.jsxs)(`div`,{className:`bot-panel-title`,children:[(0,I.jsx)(`strong`,{children:t(`lobby.trainBot`)}),(0,I.jsx)(`button`,{type:`button`,className:`bots-button`,onClick:e,children:t(`lobby.close`)})]}),(0,I.jsx)(`p`,{children:t(`lobby.trainingIntro`)}),(0,I.jsx)(`div`,{className:`bot-training-source`,children:(0,I.jsx)(a,{t,i18nKey:`lobby.trainingSource`,count:o.length,components:{strong:(0,I.jsx)(`strong`,{})}})}),(0,I.jsx)(`p`,{children:t(`lobby.trainingNote`)}),(0,I.jsx)(`button`,{type:`button`,className:`bots-button solid`,disabled:!0,children:t(`lobby.trainingNotConnected`)}),(0,I.jsx)(`button`,{type:`button`,className:`bots-button`,onClick:()=>n(`/play/bots/engines?bot=sf18`),children:t(`lobby.playStockfishInstead`)})]})}function ie({master:e}){let{t}=i(`play`),[n,r]=(0,F.useState)(null),[a,o]=(0,F.useState)(!1);(0,F.useEffect)(()=>{let t=!0;return r(null),o(!1),c(`api/masters/prepare`,{id:e.id}).then(e=>{t&&r(e.master)},()=>{t&&o(!0)}),()=>{t=!1}},[e.id]);let s=e.wins+e.draws+e.losses||1,l=[[t(`legend.wins`),e.wins,`wins`],[t(`legend.draws`),e.draws,`draws`],[t(`legend.losses`),e.losses,`losses`]];return(0,I.jsxs)(`div`,{className:`legend-record`,children:[l.map(([e,t,n])=>(0,I.jsxs)(`div`,{className:`bot-style`,children:[(0,I.jsx)(`span`,{children:e}),(0,I.jsx)(`i`,{children:(0,I.jsx)(`b`,{className:`record-${n}`,style:{width:`${Math.round(t/s*100)}%`}})}),(0,I.jsxs)(`small`,{children:[Math.round(t/s*100),`%`]})]},e)),(0,I.jsx)(`p`,{className:`legend-openings`,children:n?(0,I.jsxs)(I.Fragment,{children:[t(`legend.favourite`),` `,(0,I.jsx)(`b`,{children:n.openings?.white.map(([e,t])=>`1.${e} ${t}%`).join(` · `)})]}):a?t(`legend.unreadable`):t(`legend.reading`,{count:e.games,games:e.games.toLocaleString()})})]})}var q=[`title`],J=[`title`],ae=[`title`],oe=[`title`],Y=[`title`],se=[`title`],ce=[`title`],le=[`title`],ue=[`title`],de=[`title`],fe=[`title`],pe=[`title`],me=[`title`],he=[`title`],ge=[`title`],_e=[`title`],ve=[`title`],ye=[`title`],be=[`title`],xe=[`title`],Se=[`title`],Ce=[`title`],we=[`title`],Te=[`title`],Ee=[`title`],De=[`title`],Oe=[`title`],ke=[`title`],Ae=[`title`],je=[`title`],Me=[`title`],Ne=[`title`];function X(){return X=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(this,arguments)}function Z(e,t){if(e==null)return{};var n=Pe(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Pe(e,t){if(e==null)return{};for(var n={},r=Object.keys(e),i,a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var Fe={AE:function(e){var t=e.title,n=Z(e,q);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 0h513v342H0z`}),F.createElement(`path`,{fill:`#009e49`,d:`M0 0h513v114H0z`}),F.createElement(`path`,{d:`M0 228h513v114H0z`}),F.createElement(`path`,{fill:`#ce1126`,d:`M0 0h171v342H0z`}))},AL:function(e){var t=e.title,n=Z(e,J);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 90 60`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#ED2024`,d:`M0 0h90v60H0z`}),F.createElement(`path`,{fill:`#212121`,d:`M32.5 12.2v16l7.1 2.5-5 4.9 2.4 3 5.3-5.5 1.2 2.3-3 4.9 3.6 5.6-1.8 2.6 2.8 3.6 2.7-3.7-1.5-2.6 3-5.8-2.7-4.6 1.2-2.3 5.2 5.5 2.5-2.9-5.2-5.1 7.2-2.6V12.2l-5.2 1.9-.1 3.8-3.3.3v-2.6l1.7-2.3 5.6-2.2-2.3-.4 1.4-1.2.9.4-.8-1.4L54 9l-1-1.1L47.5 9l1.4 1.1-3.8 4.9-3.8-4.8 1.3-1.1-5-1.2L36.2 9l-1.5-.4-.8 1.4.9-.6 1.6 1.1-2.3.5 5.5 2 1.6 2.3v2.9l-3.3-.3v-3.6z`}),F.createElement(`path`,{d:`M26.2 25h6.4v2.5h-6.4zm0-4.1h6.4v2.7h-6.4zm0-4.2h6.4v2.6h-6.4zm0-4h6.4v2.5h-6.4zM57.4 25h6.4v2.5h-6.4zm0-4.1h6.4v2.7h-6.4zm0-4.2h6.4v2.6h-6.4zm0-4h6.4v2.5h-6.4zM53.4 36.1h6.4V38h-6.4zm-23.2 0h6.4V38h-6.4z`,fill:`#212121`}))},AM:function(e){var t=e.title,n=Z(e,ae);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#0052B4`,d:`M0 0h513v342H0z`}),F.createElement(`path`,{fill:`#D80027`,d:`M0 0h513v114H0z`}),F.createElement(`path`,{fill:`#FF9811`,d:`M0 228h513v114H0z`}))},AR:function(e){var t=e.title,n=Z(e,oe);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 0h512v342H0z`}),F.createElement(`path`,{fill:`#338AF3`,d:`M0 0h512v114H0zm0 228h512v114H0z`}),F.createElement(`circle`,{fill:`#FFDA44`,stroke:`#d6ab00`,strokeWidth:5,cx:256.5,cy:171,r:40}))},BR:function(e){var t=e.title,n=Z(e,Y);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#009b3a`,d:`M0 0h513v342H0z`}),F.createElement(`path`,{fill:`#fedf00`,d:`m256.5 19.3 204.9 151.4L256.5 322 50.6 170.7z`}),F.createElement(`circle`,{fill:`#FFF`,cx:256.5,cy:171,r:80.4}),F.createElement(`path`,{fill:`#002776`,d:`M215.9 165.7c-13.9 0-27.4 2.1-40.1 6 .6 43.9 36.3 79.3 80.3 79.3 27.2 0 51.3-13.6 65.8-34.3-24.9-31-63.2-51-106-51zm119 20.3c.9-5 1.5-10.1 1.5-15.4 0-44.4-36-80.4-80.4-80.4-33.1 0-61.5 20.1-73.9 48.6 10.9-2.2 22.1-3.4 33.6-3.4 46.8.1 89 19.5 119.2 50.6z`}))},CA:function(e){var t=e.title,n=Z(e,se);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 0h513v342H0z`}),F.createElement(`path`,{d:`M0 0h142v342H0zm371 0h142v342H371zm-64.5 206 50.4-25.2-25.2-12.6V143l-50.4 25.2 25.2-50.4h-25.2L256.1 80l-25.2 37.8h-25.2l25.2 50.4-50.4-25.2v25.2l-25.2 12.6 50.4 25.2-12.6 25.2h50.4V269h25.2v-37.8h50.4z`,fill:`red`}))},CL:function(e){var t=e.title,n=Z(e,ce);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#D80027`,d:`M0 0h513v342H0z`}),F.createElement(`path`,{fill:`#FFF`,d:`M196 0h317v171H196z`}),F.createElement(`path`,{fill:`#0037A1`,d:`M0 0h196v171H0z`}),F.createElement(`path`,{fill:`#FFF`,d:`M98 24.5 113.1 71H162l-39.6 28.7 15.2 46.5L98 117.5l-39.6 28.7 15.2-46.5L34 71h48.9z`}))},CN:function(e){var t=e.title,n=Z(e,le);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#D80027`,d:`M0 0h513v342H0z`}),F.createElement(`path`,{d:`m226.8 239.2-9.7-15.6-17.9 4.4 11.9-14.1-9.7-15.6 17.1 6.9 11.8-14.1-1.3 18.4 17.1 6.9-17.9 4.4zM290.6 82l-10.1 15.4 11.6 14.3-17.7-4.8-10.1 15.5-1-18.4-17.7-4.8 17.2-6.6-1-18.4 11.6 14.3zm-54.4-56.6-2 18.3 16.8 7.6-18 3.8-2 18.3-9.2-16-17.9 3.8 12.3-13.7-9.2-15.9 16.8 7.5zm56.6 136.4-14.9 10.9 5.8 17.5-14.9-10.8-14.9 11 5.6-17.6-14.9-10.7 18.4-.1 5.6-17.6 5.8 17.5zM115 46.3l17.3 53.5h56.2l-45.4 32.9 17.3 53.5-45.4-33-45.5 33 17.4-53.5-45.5-32.9h56.3z`,fill:`#FFDA44`}))},CO:function(e){var t=e.title,n=Z(e,ue);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFDA44`,d:`M0 0h513v342H0z`}),F.createElement(`path`,{fill:`#D80027`,d:`M0 256.5h513V342H0z`}),F.createElement(`path`,{fill:`#0052B4`,d:`M0 171h513v85.5H0z`}))},DE:function(e){var t=e.title,n=Z(e,de);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#D80027`,d:`M0 0h513v342H0z`}),F.createElement(`path`,{d:`M0 0h513v114H0z`}),F.createElement(`path`,{fill:`#FFDA44`,d:`M0 228h513v114H0z`}))},ES:function(e){var t=e.title,n=Z(e,fe);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 22.5 15`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 0h22.5v15H0V0z`}),F.createElement(`path`,{fill:`#D03433`,d:`M0 0h22.5v4H0V0zm0 11h22.5v4H0v-4z`}),F.createElement(`path`,{fill:`#FBCA46`,d:`M0 4h22.5v7H0V4z`}),F.createElement(`path`,{fill:`#FFF`,d:`M7.8 7h1v.5h-1V7z`}),F.createElement(`path`,{fill:`#A41517`,d:`M7.2 8.5c0 .3.3.5.6.5s.6-.2.6-.5L8.5 7H7.1l.1 1.5zM6.6 7c0-.3.2-.5.4-.5h1.5c.3 0 .5.2.5.4V7l-.1 1.5c-.1.6-.5 1-1.1 1-.6 0-1-.4-1.1-1L6.6 7z`}),F.createElement(`path`,{fill:`#A41517`,d:`M6.8 7.5h2V8h-.5l-.5 1-.5-1h-.5v-.5zM5.3 6h1v3.5h-1V6zm4 0h1v3.5h-1V6zm-2.5-.5c0-.3.2-.5.5-.5h1c.3 0 .5.2.5.5v.2c0 .2-.1.3-.3.3H7c-.1 0-.2-.1-.2-.2v-.3z`}))},FR:function(e){var t=e.title,n=Z(e,pe);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 0h513v342H0z`}),F.createElement(`path`,{fill:`#0052B4`,d:`M0 0h171v342H0z`}),F.createElement(`path`,{fill:`#D80027`,d:`M342 0h171v342H342z`}))},HU:function(e){var t=e.title,n=Z(e,me);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 0h513v342H0z`}),F.createElement(`path`,{fill:`#D80027`,d:`M0 0h513v114H0z`}),F.createElement(`path`,{fill:`#6DA544`,d:`M0 228h513v114H0z`}))},IN:function(e){var t=e.title,n=Z(e,he);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#181A93`,d:`M17.3 0h478.4v342H17.3V0z`}),F.createElement(`path`,{fill:`#FFA44A`,d:`M0 0h513v114H0V0z`}),F.createElement(`path`,{fill:`#1A9F0B`,d:`M0 228h513v114H0V228z`}),F.createElement(`path`,{fill:`#FFF`,d:`M0 114h513v114H0V114z`}),F.createElement(`circle`,{fill:`#FFF`,cx:256.5,cy:171,r:34.2}),F.createElement(`path`,{fill:`#181A93`,d:`M256.5 216.6c-25.1 0-45.6-20.5-45.6-45.6s20.5-45.6 45.6-45.6 45.6 20.5 45.6 45.6-20.5 45.6-45.6 45.6zm0-11.4c18.2 0 34.2-16 34.2-34.2s-15.9-34.2-34.2-34.2-34.2 16-34.2 34.2 16 34.2 34.2 34.2z`}),F.createElement(`circle`,{fill:`#181A93`,cx:256.5,cy:171,r:22.8}))},IT:function(e){var t=e.title,n=Z(e,ge);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M342 0H0v341.3h512V0z`}),F.createElement(`path`,{fill:`#6DA544`,d:`M0 0h171v342H0z`}),F.createElement(`path`,{fill:`#D80027`,d:`M342 0h171v342H342z`}))},JP:function(e){var t=e.title,n=Z(e,_e);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 0h512v342H0z`}),F.createElement(`circle`,{fill:`#D80027`,cx:256.5,cy:171,r:96}))},KR:function(e){var t=e.title,n=Z(e,ve);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 900 600`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 0h900v600H0z`}),F.createElement(`g`,{transform:`rotate(-56.31)`},F.createElement(`path`,{d:`M-75 228.3H75m-150 37.5H75m-150 37.5H75m-150 475H75m-150 37.5H75m-150 37.5H75`,stroke:`#000`,strokeWidth:25}),F.createElement(`path`,{stroke:`#FFF`,strokeWidth:12.5,d:`M0 753.3v125`}),F.createElement(`circle`,{fill:`#ca163a`,cy:540.8,r:150}),F.createElement(`path`,{fill:`#0e4896`,d:`M0 390.8c-41.4 0-75 33.6-75 75s33.6 75 75 75 75 33.6 75 75-33.6 75-75 75c-82.8 0-150-67.2-150-150s67.2-150 150-150z`})),F.createElement(`path`,{d:`m231.56 535.73-83.205-124.808M262.76 514.928l-83.205-124.807m114.407 104.006-83.205-124.808m478.43-138.675-83.205-124.807M720.39 209.843 637.184 85.036m114.407 104.006L668.386 64.234`,stroke:`#000`,strokeWidth:25}),F.createElement(`path`,{stroke:`#FFF`,strokeWidth:12.5,d:`m205.6 462.897 31.202-20.8m389.981-259.989 36.444-24.296m31.202-20.801 31.202-20.801`}))},MX:function(e){var t=e.title,n=Z(e,ye);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#dc2339`,d:`M342 0H0v341.3h513V0z`}),F.createElement(`path`,{fill:`#11865d`,d:`M0 0h171v342H0z`}),F.createElement(`path`,{fill:`#FFF`,d:`M171 0h171v342H171z`}),F.createElement(`path`,{fill:`#8C9157`,d:`M195.8 171.2c0 21.6 11.5 41.7 30.3 52.5 5.8 3.4 13.2 1.4 16.6-4.4 3.4-5.8 1.4-13.2-4.4-16.6-11.3-6.5-18.2-18.5-18.2-31.5 0-6.7-5.4-12.1-12.1-12.1-6.7 0-12.2 5.4-12.2 12.1zm93.4 51.1c17.5-11.1 28-30.4 28-51.1 0-6.7-5.4-12.1-12.1-12.1s-12.1 5.4-12.1 12.1c0 12.4-6.3 24-16.8 30.7-5.7 3.5-7.5 10.9-4.1 16.7s10.9 7.5 16.7 4.1c0-.2.2-.3.4-.4z`}),F.createElement(`ellipse`,{fill:`#C59262`,cx:256.5,cy:159.1,rx:24.3,ry:36.4}))},NL:function(e){var t=e.title,n=Z(e,be);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 114h513v114H0z`}),F.createElement(`path`,{fill:`#cd1f2a`,d:`M0 0h513v114H0z`}),F.createElement(`path`,{fill:`#1d4185`,d:`M0 228h513v114H0z`}))},NO:function(e){var t=e.title,n=Z(e,xe);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 85.333 512 341.333`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#D80027`,d:`M0 85.334h512v341.337H0z`}),F.createElement(`path`,{fill:`#FFF`,d:`M512 295.883H202.195v130.783h-79.76V295.883H0v-79.772h122.435V85.329h79.76v130.782H512v61.218z`}),F.createElement(`path`,{fill:`#2E52B2`,d:`M512 234.666v42.663H183.652v149.337h-42.674V277.329H0v-42.663h140.978V85.329h42.674v149.337z`}))},PA:function(e){var t=e.title,n=Z(e,Se);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 85.333 512 341.333`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 85.337h512v341.326H0z`}),F.createElement(`path`,{fill:`#0052B4`,d:`M256 256v170.663H0V256h256z`}),F.createElement(`path`,{fill:`#D80027`,d:`M512 85.337V256H256V85.337h256z`}),F.createElement(`path`,{fill:`#0052B4`,d:`m128 123.034 11.824 36.389h38.263l-30.955 22.491 11.823 36.389L128 195.813l-30.955 22.49 11.823-36.389-30.955-22.491h38.263z`}),F.createElement(`path`,{fill:`#D80027`,d:`m384 293.697 11.824 36.389h38.263l-30.955 22.491 11.823 36.389L384 366.476l-30.955 22.49 11.823-36.389-30.955-22.491h38.263z`}))},PE:function(e){var t=e.title,n=Z(e,Ce);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 85.333 512 341.333`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 85.331h512v341.326H0z`}),F.createElement(`path`,{d:`M0 85.331h170.663v341.337H0zm341.337 0H512v341.337H341.337z`,fill:`#D80027`}))},PH:function(e){var t=e.title,n=Z(e,we);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 85.333 512 341.333`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 85.337h512v341.326H0z`}),F.createElement(`path`,{fill:`#0052B4`,d:`M512 85.337V256H256L0 85.337z`}),F.createElement(`path`,{fill:`#D80027`,d:`M512 256v170.663H0L256 256z`}),F.createElement(`path`,{d:`m161.908 256-27.288-12.835 14.532-26.428-29.632 5.668-3.755-29.933-20.64 22.015-20.639-22.015-3.755 29.933-29.631-5.669 14.531 26.428L28.343 256l27.288 12.835L41.1 295.263l29.633-5.668 3.753 29.933 20.639-22.015 20.64 22.015 3.755-29.933 29.631 5.669-14.532-26.427zM21.789 117.607l9.081 12.696 14.879-4.714-9.268 12.56 9.081 12.694-14.809-4.932-9.268 12.559.117-15.608-14.809-4.934 14.88-4.712zm0 235.923 9.081 12.696 14.879-4.714-9.268 12.56 9.081 12.695-14.809-4.933-9.268 12.558.117-15.607-14.809-4.934 14.88-4.712zm188.606-117.961-9.081 12.695-14.879-4.713 9.268 12.559-9.081 12.696 14.809-4.933 9.268 12.558-.117-15.607 14.809-4.934-14.88-4.713z`,fill:`#FFDA44`}))},PT:function(e){var t=e.title,n=Z(e,Te);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 85.333 512 341.333`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#D80027`,d:`M0 85.337h512v341.326H0z`}),F.createElement(`path`,{fill:`#6DA544`,d:`M196.641 85.337v341.326H0V85.337z`}),F.createElement(`circle`,{fill:`#FFDA44`,cx:196.641,cy:256,r:64}),F.createElement(`path`,{fill:`#D80027`,d:`M160.638 224v40.001c0 19.882 16.118 36 36 36s36-16.118 36-36V224h-72z`}),F.createElement(`path`,{fill:`#FFF`,d:`M196.638 276c-6.617 0-12-5.383-12-12v-16h24.001v16c-.001 6.616-5.385 12-12.001 12z`}))},RS:function(e){var t=e.title,n=Z(e,Ee);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 85.333 512 341.333`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#0052B4`,d:`M0 85.331h512v341.337H0z`}),F.createElement(`path`,{fill:`#D80027`,d:`M0 85.331h512v113.775H0z`}),F.createElement(`path`,{fill:`#FFF`,d:`M0 312.882h512v113.775H0z`}),F.createElement(`path`,{fill:`#D80027`,d:`M129.468 181.793v85.136c0 48.429 63.267 63.267 63.267 63.267S256 315.356 256 266.929v-85.136H129.468z`}),F.createElement(`path`,{d:`M155.634 196.634h74.201v-29.681l-14.841 7.42-22.261-22.26-22.259 22.26-14.84-7.42zm85.526 82.148-48.231-48.231-48.231 48.231 15.741 15.74 32.49-32.49 32.49 32.49z`,fill:`#FFDA44`}),F.createElement(`path`,{fill:`#FFF`,d:`M241.16 233.734h-22.504a14.74 14.74 0 0 0 2.001-7.418c0-8.196-6.645-14.84-14.84-14.84-5.663 0-10.581 3.172-13.083 7.836-2.502-4.663-7.421-7.836-13.083-7.836-8.195 0-14.84 6.644-14.84 14.84 0 2.706.736 5.235 2.001 7.418h-22.114c0 8.196 7.139 14.84 15.334 14.84h-.494c0 8.196 6.644 14.84 14.84 14.84 0 7.257 5.211 13.286 12.094 14.576l-11.694 26.401a48.075 48.075 0 0 0 18.149 3.544 48.079 48.079 0 0 0 18.149-3.544l-11.694-26.401c6.883-1.29 12.094-7.319 12.094-14.576 8.196 0 14.84-6.644 14.84-14.84h-.494c8.199 0 15.338-6.644 15.338-14.84z`}))},RU:function(e){var t=e.title,n=Z(e,De);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 85.333 512 341.333`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 85.33v341.332h512V85.33z`}),F.createElement(`path`,{fill:`#0052B4`,d:`M0 85.333h512V426.67H0z`}),F.createElement(`path`,{fill:`#FFF`,d:`M0 85.333h512v113.775H0z`}),F.createElement(`path`,{fill:`#D80027`,d:`M0 312.884h512v113.775H0z`}))},SE:function(e){var t=e.title,n=Z(e,Oe);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 85.333 512 341.333`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#0052B4`,d:`M0 85.333h512V426.67H0z`}),F.createElement(`path`,{fill:`#FFDA44`,d:`M192 85.33h-64v138.666H0v64h128v138.666h64V287.996h320v-64H192z`}))},SV:function(e){var t=e.title,n=Z(e,ke);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 85.333 512 341.333`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 85.337h512v341.326H0z`}),F.createElement(`path`,{d:`M0 85.337h512v113.775H0zm0 227.551h512v113.775H0z`,fill:`#0052B4`}),F.createElement(`path`,{fill:`#FFDA44`,d:`M228.582 261.936 256 214.447l27.418 47.489z`}),F.createElement(`path`,{fill:`#6DA544`,d:`M291.616 277.616 256 295.425l-35.616-17.809v-23.744h71.232z`}),F.createElement(`path`,{fill:`#FFDA44`,d:`m289.579 216.485-12.592 12.592c5.37 5.372 8.693 12.791 8.693 20.988 0 16.392-13.289 29.68-29.68 29.68-16.392 0-29.68-13.289-29.68-29.68 0-8.195 3.322-15.616 8.693-20.988l-12.592-12.592c-8.594 8.594-13.91 20.466-13.91 33.579 0 26.228 21.261 47.489 47.489 47.489s47.489-21.261 47.489-47.489c0-13.114-5.316-24.987-13.91-33.579z`}))},TR:function(e){var t=e.title,n=Z(e,Ae);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#E30A17`,d:`M0 0h513v342H0z`}),F.createElement(`path`,{fill:`#FFF`,d:`M259.7 118.6c-13.1-9.5-29-14.6-45.3-14.5-40.8 0-73.8 30.8-73.8 68.9s33.1 68.9 73.8 68.9c17.1 0 32.9-5.4 45.3-14.5-30 38.6-85.7 45.6-124.3 15.5s-45.6-85.7-15.5-124.3 85.7-45.6 124.3-15.5c5.8 4.5 11 9.8 15.5 15.5zm39.9 65.8-18.1 21.9 1.2-28.4-26.4-10.4 27.3-7.6 1.8-28.3 15.6 23.7 27.5-7.1-17.5 22 15.3 23.9-26.7-9.7z`}))},UA:function(e){var t=e.title,n=Z(e,je);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 85.333 512 341.333`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFDA44`,d:`M0 85.337h512v341.326H0z`}),F.createElement(`path`,{fill:`#338AF3`,d:`M0 85.337h512V256H0z`}))},US:function(e){var t=e.title,n=Z(e,Me);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 513 342`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFF`,d:`M0 0h513v342H0z`}),F.createElement(`path`,{d:`M0 0h513v26.3H0zm0 52.6h513v26.3H0zm0 52.6h513v26.3H0zm0 52.6h513v26.3H0zm0 52.7h513v26.3H0zm0 52.6h513v26.3H0zm0 52.6h513V342H0z`,fill:`#D80027`}),F.createElement(`path`,{fill:`#2E52B2`,d:`M0 0h256.5v184.1H0z`}),F.createElement(`path`,{d:`m47.8 138.9-4-12.8-4.4 12.8H26.2l10.7 7.7-4 12.8 10.9-7.9 10.6 7.9-4.1-12.8 10.9-7.7zm56.3 0-4.1-12.8-4.2 12.8H82.6l10.7 7.7-4 12.8 10.7-7.9 10.8 7.9-4-12.8 10.7-7.7zm56.5 0-4.3-12.8-4 12.8h-13.5l11 7.7-4.2 12.8 10.7-7.9 11 7.9-4.2-12.8 10.7-7.7zm56.2 0-4-12.8-4.2 12.8h-13.3l10.8 7.7-4 12.8 10.7-7.9 10.8 7.9-4.3-12.8 11-7.7zM100 75.3l-4.2 12.8H82.6L93.3 96l-4 12.6 10.7-7.8 10.8 7.8-4-12.6 10.7-7.9h-13.4zm-56.2 0-4.4 12.8H26.2L36.9 96l-4 12.6 10.9-7.8 10.6 7.8L50.3 96l10.9-7.9H47.8zm112.5 0-4 12.8h-13.5l11 7.9-4.2 12.6 10.7-7.8 11 7.8-4.2-12.6 10.7-7.9h-13.2zm56.5 0-4.2 12.8h-13.3l10.8 7.9-4 12.6 10.7-7.8 10.8 7.8-4.3-12.6 11-7.9h-13.5zm-169-50.6-4.4 12.6H26.2l10.7 7.9-4 12.7L43.8 50l10.6 7.9-4.1-12.7 10.9-7.9H47.8zm56.2 0-4.2 12.6H82.6l10.7 7.9-4 12.7L100 50l10.8 7.9-4-12.7 10.7-7.9h-13.4zm56.3 0-4 12.6h-13.5l11 7.9-4.2 12.7 10.7-7.9 11 7.9-4.2-12.7 10.7-7.9h-13.2zm56.5 0-4.2 12.6h-13.3l10.8 7.9-4 12.7 10.7-7.9 10.8 7.9-4.3-12.7 11-7.9h-13.5z`,fill:`#FFF`}))},VE:function(e){var t=e.title,n=Z(e,Ne);return F.createElement(`svg`,X({xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 22.5 15`},n),t&&F.createElement(`title`,null,t),F.createElement(`path`,{fill:`#FFCE00`,d:`M0 0h22.5v5H0z`}),F.createElement(`path`,{fill:`#203899`,d:`M0 5h22.5v5H0z`}),F.createElement(`path`,{fill:`#D82B2B`,d:`M0 10h22.5v5H0z`}),F.createElement(`path`,{fill:`#FFF`,d:`m12.13 5.38.14.46.45.14-.39.27.01.48-.38-.29-.45.15.15-.44-.28-.38h.47zm-1.77 0 .27.39h.47l-.28.38.15.45-.45-.16-.38.28.01-.47-.39-.28.45-.13zm3.44.56-.01.48.39.27-.46.14-.14.45-.27-.38h-.48l.29-.38-.15-.45.45.16zm-5.11.02.4.27.44-.18-.13.46.3.36-.47.02-.26.4-.16-.44-.46-.12.37-.3zm6.55 1.17-.2.44.25.4-.47-.05-.31.36-.1-.46-.43-.18.41-.24.03-.47.35.31zm.19 1.12.21.43.47.07-.34.33.08.46-.42-.22-.42.22.08-.46-.34-.33.47-.07zM7 8.2l.21.43.47.06-.34.33.08.47L7 9.27l-.42.22.08-.47-.34-.33.47-.06zm.31-1.15.45.14.38-.29v.48l.39.26-.45.15-.13.46-.28-.38-.47.01.27-.38z`}))}};function Ie({code:e,className:t=`flag`}){let n=Fe[e];return n?(0,I.jsx)(n,{className:t,"aria-hidden":!0}):null}function Le({bot:e,rating:t,stars:n,starsLabel:r,selected:i,beaten:a,locked:o,badge:s,note:c,title:l,onClick:u}){return(0,I.jsxs)(`button`,{type:`button`,className:`bot-card${i?` selected`:``}${o?` locked`:``}`,"aria-pressed":!!i,title:l,onClick:u,children:[(0,I.jsx)(`span`,{className:`bot-picture`,children:(0,I.jsx)(`img`,{src:v(e),alt:``,loading:`lazy`})}),s&&(0,I.jsx)(`span`,{className:`bot-card-badge`,children:s}),o?(0,I.jsx)(`span`,{className:`bot-card-mark lock`,"aria-hidden":!0,children:`🔒︎`}):a&&(0,I.jsx)(`span`,{className:`bot-card-mark beaten`,"aria-hidden":!0,children:`✓`}),(0,I.jsxs)(`span`,{className:`bot-card-name`,children:[(0,I.jsx)(`strong`,{children:e.name}),(0,I.jsx)(`span`,{className:`bot-rating`,children:t})]}),n!==void 0&&(0,I.jsx)(f,{count:n,size:13,label:r}),c&&(0,I.jsx)(`small`,{className:`bot-card-note`,children:c})]})}function Re(){let{t:e}=i(`play`),{engines:t}=p(),{games:n}=u(),r=x(),a=(0,F.useMemo)(()=>y(t),[t]),o=(0,F.useMemo)(()=>_(r.masters,e),[r.masters,e]),s=Number(n.find(e=>e.user_rating)?.user_rating)||null;return{collections:(0,F.useMemo)(()=>D({legends:o,engines:a,rating:s}),[o,a,s]),rating:s,masters:r}}function ze(e,t){if(!t||e<=0)return null;let n=e-t;return n<-250?`easy`:n<100?`fair`:n<400?`hard`:`boss`}var Be={season:0,core:1,theme:2,country:3};function Ve({collections:e,rating:t,hasSaved:n}){let{t:a}=i(`play`),s=r(),[c,u]=(0,F.useState)(`all`),[d,f]=(0,F.useState)(``),[p,m]=(0,F.useState)(`near`),[g,_]=(0,F.useState)(null),[y,b]=(0,F.useState)(4),x=O(),T=ee(),D=t??1180,k=e=>e.coach?h(t):e.elo,A=(0,F.useMemo)(()=>e.filter(e=>e.bots.length&&(e.kind!==`season`||e.status===`live`||e.status===`soon`)).sort((e,t)=>Be[e.kind]-Be[t.kind]),[e]),j=e.filter(e=>e.kind===`season`&&e.status===`live`).sort((e,t)=>e.end-t.end)[0],M=A.find(e=>e.id===c),N=(0,F.useMemo)(()=>M?M.bots.map(e=>({bot:e,collection:M})):e.filter(e=>e.kind===`country`||e.kind===`theme`||e.kind===`core`).flatMap(e=>e.bots.filter(t=>!e.abroad?.includes(t.id)).map(t=>({bot:t,collection:e}))).filter((e,t,n)=>n.findIndex(t=>t.bot.id===e.bot.id)===t),[M,e]),L=d.trim().toLowerCase(),R=N.filter(({bot:e})=>!L||`${e.name} ${e.kind} ${e.tags.join(` `)}`.toLowerCase().includes(L)).sort((e,t)=>p===`near`?Math.abs(k(e.bot)-D)-Math.abs(k(t.bot)-D):k(e.bot)-k(t.bot)),z=({bot:e,collection:t})=>t.kind===`season`?C(t.id,e.id,T):(x[W(e,y,t)]??0)>=3;(0,F.useEffect)(()=>{if(!g)return;let e=e=>{e.key===`Escape`&&_(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[g]);let B=j?.end?Math.max(0,j.end-Date.now()):0,V=j?w(j,T):0;return(0,I.jsxs)(`section`,{id:`bot-lobby`,className:`phone-lobby`,"aria-label":a(`lobby.label`),children:[(0,I.jsxs)(`header`,{className:`phone-lobby-head`,children:[(0,I.jsx)(o,{className:`phone-icon-button`,to:`/`,"aria-label":a(`phone.home`),children:P}),(0,I.jsx)(`h1`,{children:a(`phone.pickBot`)}),t&&(0,I.jsx)(`span`,{className:`phone-pill`,children:a(`phone.you`,{rating:t})})]}),n&&(0,I.jsxs)(`button`,{type:`button`,id:`resume-game`,className:`phone-resume-bar`,onClick:()=>s(`/play`),children:[a(`lobby.backToGame`),(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`›`})]}),(0,I.jsxs)(`label`,{className:`phone-search`,children:[(0,I.jsxs)(`svg`,{"aria-hidden":`true`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,I.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,I.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,I.jsx)(`input`,{id:`bot-search`,type:`search`,placeholder:a(`phone.search`),"aria-label":a(`phone.search`),value:d,onChange:e=>f(e.target.value)})]}),(0,I.jsx)(`div`,{className:`phone-chips`,role:`group`,"aria-label":a(`phone.collections`),children:[{id:`all`,title:a(`phone.all`)},...A].map(e=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":c===e.id,onClick:()=>u(e.id),children:[e.kind===`season`&&e.status===`live`&&(0,I.jsx)(`i`,{className:`live-dot`}),e.flag&&(0,I.jsx)(Ie,{code:e.flag}),e.title]},e.id))}),j&&!L&&(c===`all`||c===j.id)&&(0,I.jsxs)(`button`,{type:`button`,className:`phone-event`,"data-theme":j.theme,onClick:()=>u(j.id),children:[(0,I.jsxs)(`span`,{className:`phone-event-top`,children:[(0,I.jsx)(`span`,{className:`phone-event-tag`,children:a(`phone.event`)}),(0,I.jsx)(`span`,{className:`phone-event-left`,children:a(`phone.left`,{days:Math.floor(B/864e5),hours:Math.floor(B/36e5)%24})})]}),(0,I.jsx)(`strong`,{children:j.title}),(0,I.jsx)(`small`,{children:a(`phone.eventGoal`,{count:j.need})}),(0,I.jsxs)(`span`,{className:`phone-event-progress`,children:[(0,I.jsx)(`span`,{className:`meter`,children:(0,I.jsx)(`i`,{style:{width:`${Math.min(100,Math.round(V/(j.need||1)*100))}%`}})}),(0,I.jsxs)(`b`,{children:[V,`/`,j.need]})]})]}),(0,I.jsxs)(`div`,{className:`phone-lobby-bar`,children:[(0,I.jsx)(`span`,{children:a(`phone.count`,{count:R.length})}),(0,I.jsx)(S,{className:`bots-segments phone-sort`,children:[`near`,`easy`].map(e=>(0,I.jsx)(`button`,{type:`button`,"aria-pressed":p===e,className:p===e?`selected`:void 0,onClick:()=>m(e),children:a(`phone.sort.${e}`)},e))})]}),R.length?(0,I.jsx)(`div`,{className:`phone-bot-grid`,children:R.map(e=>{let{bot:n}=e,r=ze(k(n),t),i=z(e),o=!!E(e.collection,n,T);return(0,I.jsxs)(`button`,{type:`button`,className:`phone-bot${o?` locked`:``}`,onClick:()=>_(e),children:[(0,I.jsxs)(`span`,{className:`phone-bot-picture`,children:[(0,I.jsx)(`img`,{src:v(n),alt:``,loading:`lazy`}),(0,I.jsx)(`span`,{className:`phone-bot-rating`,children:n.id===`sf18`?`L${y}`:k(n)}),i&&(0,I.jsx)(`span`,{className:`phone-bot-won`,"aria-label":a(`phone.beaten`),children:`★`})]}),(0,I.jsxs)(`span`,{className:`phone-bot-text`,children:[(0,I.jsx)(`strong`,{children:n.name}),(0,I.jsx)(`small`,{children:n.kind.split(` · `)[0]}),r&&(0,I.jsx)(`span`,{className:`phone-diff ${r}`,children:a(`phone.diff.${r}`)})]})]},`${e.collection.id}-${n.id}`)})}):(0,I.jsxs)(`p`,{className:`bots-empty`,children:[(0,I.jsx)(l,{pose:`shrug`,size:72}),a(`bots.home.noResults`)]}),g&&(0,I.jsxs)(`div`,{className:`phone-sheet`,role:`dialog`,"aria-modal":`true`,"aria-label":g.bot.name,children:[(0,I.jsx)(`button`,{type:`button`,className:`phone-sheet-backdrop`,"aria-label":a(`lobby.close`),onClick:()=>_(null)}),(0,I.jsxs)(`div`,{className:`phone-sheet-body`,children:[(0,I.jsx)(`span`,{className:`phone-sheet-grip`,"aria-hidden":`true`}),(0,I.jsx)(G,{bot:g.bot,collection:g.collection,lock:E(g.collection,g.bot,T),level:y,onLevel:b})]})]})]})}var Q=(e,t)=>`/play/bots/${e}${t?`?bot=${encodeURIComponent(t)}`:``}`,$=(e,t)=>(e[t.id]??0)>=3,He=10,Ue=9,We=(e,t)=>e.bots.filter(e=>e.avatar||e.portrait).slice(0,t);function Ge(){let{t:e,i18n:t}=i(`play`),a=r(),s=n(),{collections:c,rating:u}=Re(),[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(He),[g,_]=(0,F.useState)(Ue),y=O(),b=ee(),x=!!k(),S=d();(0,F.useEffect)(()=>(document.body.dataset.page=`bots`,()=>{document.body.dataset.page=`board`}),[]);let C=s.state?.bot;(0,F.useEffect)(()=>{let e=C?T(c,C):void 0;e&&a(Q(e.id,C),{replace:!0})},[C,c,a]);let E=c.filter(e=>e.kind===`season`),D=E.filter(e=>e.status===`live`).sort((e,t)=>e.end-t.end),A=E.filter(e=>e.status===`soon`),j=D[0]??A[0],M=[...D.slice(1),...A.filter(e=>e!==j).slice(0,2),...E.filter(e=>e.status===`ended`&&w(e,b)>0)].slice(0,3),N=c.filter(e=>e.kind===`country`),P=c.filter(e=>e.kind===`theme`),L=c.filter(e=>e.kind===`core`),R=(0,F.useMemo)(()=>c.filter(e=>e.kind===`country`||e.kind===`theme`||e.id===`always`).flatMap(e=>e.bots.filter(t=>!t.coach&&!e.abroad?.includes(t.id)).map(t=>({bot:t,collection:e}))),[c]),z=u??1180,B=R.filter(e=>!$(y,e.bot)).sort((e,t)=>Math.abs(e.bot.elo-z)-Math.abs(t.bot.elo-z)).slice(0,6),V=f.trim().toLowerCase(),H=V?c.flatMap(e=>e.kind===`season`?[]:e.bots.filter(t=>!e.abroad?.includes(t.id)).map(t=>({bot:t,collection:e}))).filter(({bot:e})=>`${e.name} ${e.kind} ${e.tags.join(` `)}`.toLowerCase().includes(V)).slice(0,36):[],ne=e=>new Date(e-1).toLocaleDateString(t.language,{month:`long`,day:`numeric`});if(S)return(0,I.jsx)(Ve,{collections:c,rating:u,hasSaved:x});function re(){let e=R.filter(e=>Math.abs(e.bot.elo-z)<=200),t=e[Math.floor(Math.random()*e.length)]??R[0];t&&a(Q(t.collection.id,t.bot.id))}return(0,I.jsxs)(`section`,{id:`bot-lobby`,className:`bots-home`,"aria-label":e(`lobby.label`),children:[(0,I.jsxs)(`header`,{className:`bots-header`,children:[(0,I.jsx)(`h1`,{children:e(`lobby.title`)}),(0,I.jsxs)(`div`,{className:`bots-header-actions`,children:[(0,I.jsx)(`input`,{id:`bot-search`,type:`search`,placeholder:e(`bots.home.search`),"aria-label":e(`bots.home.search`),value:f,onChange:e=>p(e.target.value)}),x&&(0,I.jsx)(`button`,{id:`resume-game`,type:`button`,className:`bots-button`,onClick:()=>a(`/play`),children:e(`lobby.backToGame`)}),(0,I.jsx)(`button`,{id:`surprise-bot`,type:`button`,className:`bots-button`,onClick:re,children:e(`lobby.surprise`)}),(0,I.jsx)(`button`,{id:`train-bot`,type:`button`,className:`bots-button solid`,onClick:()=>a(`/play/bots/yours?train=1`),children:e(`lobby.trainBot`)})]})]}),V?(0,I.jsxs)(`section`,{className:`bots-section`,"aria-label":e(`bots.home.results`,{count:H.length,query:f.trim()}),children:[(0,I.jsxs)(`div`,{className:`bots-section-head`,children:[(0,I.jsx)(`h2`,{children:e(`bots.home.results`,{count:H.length,query:f.trim()})}),(0,I.jsx)(`button`,{type:`button`,className:`text-button`,onClick:()=>p(``),children:e(`bots.home.clear`)})]}),H.length?(0,I.jsx)(`div`,{className:`bots-grid`,children:H.map(({bot:e,collection:t})=>(0,I.jsx)(Le,{bot:e,rating:e.id===`sf18`?`L4`:e.elo,note:t.title,onClick:()=>a(Q(t.id,e.id))},`${t.id}-${e.id}`))}):(0,I.jsxs)(`p`,{className:`bots-empty`,children:[(0,I.jsx)(l,{pose:`shrug`,size:72}),e(`bots.home.noResults`)]})]}):(0,I.jsxs)(I.Fragment,{children:[j&&(0,I.jsx)(Ke,{event:j,kept:w(j,b),date:ne,onOpen:e=>a(Q(j.id,e))}),M.length>0&&(0,I.jsx)(`div`,{className:`event-strip`,children:M.map(t=>{let n=w(t,b);return(0,I.jsxs)(o,{className:`event-chip`,"data-theme":t.theme,to:Q(t.id),children:[(0,I.jsx)(`span`,{className:`face-stack`,children:We(t,3).map(e=>(0,I.jsx)(`img`,{src:v(e),alt:``,className:t.status===`soon`?`waiting`:``},e.id))}),(0,I.jsxs)(`span`,{className:`event-chip-text`,children:[(0,I.jsx)(`strong`,{children:t.title}),(0,I.jsx)(`small`,{children:t.status===`ended`?e(`bots.events.keptOf`,{count:n,total:t.bots.length}):e(`bots.events.characters`,{count:t.bots.length})})]}),(0,I.jsx)(`span`,{className:`event-pill ${t.status}`,children:t.status===`live`?e(`bots.events.live`):t.status===`soon`?e(`bots.events.inDays`,{count:te(t.start)}):e(`bots.events.ended`)})]},t.id)})}),(0,I.jsxs)(`section`,{className:`bots-section`,"aria-labelledby":`matches-title`,children:[(0,I.jsx)(`div`,{className:`bots-section-head`,children:(0,I.jsx)(`h2`,{id:`matches-title`,children:e(`bots.home.matches`)})}),(0,I.jsx)(`div`,{className:`bots-grid`,children:B.map(({bot:t,collection:n})=>{let r=t.elo-z;return(0,I.jsx)(Le,{bot:t,rating:t.elo,badge:n.title,note:r===0?e(`bots.home.exact`):e(r>0?`bots.home.above`:`bots.home.below`,{count:Math.abs(r)}),onClick:()=>a(Q(n.id,t.id))},t.id)})})]}),(0,I.jsxs)(`section`,{className:`bots-section`,"aria-labelledby":`world-title`,children:[(0,I.jsx)(`div`,{className:`bots-section-head`,children:(0,I.jsx)(`h2`,{id:`world-title`,children:e(`bots.home.world`)})}),(0,I.jsx)(`div`,{className:`country-grid`,children:N.slice(0,m).map(t=>{let n=t.bots.filter(e=>$(y,e)).length;return(0,I.jsxs)(o,{className:`country-card`,to:Q(t.id),children:[(0,I.jsx)(`span`,{className:`country-faces`,children:We(t,4).map(e=>(0,I.jsx)(`img`,{src:v(e),alt:``},e.id))}),(0,I.jsxs)(`span`,{className:`country-body`,children:[(0,I.jsxs)(`span`,{className:`country-title`,children:[t.flag&&(0,I.jsx)(Ie,{code:t.flag,className:`flag country-flag`}),(0,I.jsx)(`strong`,{children:t.title}),(0,I.jsxs)(`small`,{children:[n,` / `,t.bots.length]})]}),(0,I.jsx)(`span`,{className:`meter`,children:(0,I.jsx)(`i`,{style:{width:`${Math.round(n/(t.bots.length||1)*100)}%`}})}),(0,I.jsx)(`small`,{className:`country-note`,children:t.neighbour?e(`bots.home.neighbour`,{name:t.neighbour.name}):t.abroad?e(`bots.home.abroad`,{count:t.abroad.length}):e(`bots.events.characters`,{count:t.bots.length})})]})]},t.id)})}),(0,I.jsx)(qe,{shown:m,total:N.length,onMore:()=>h(m+He)})]}),(0,I.jsxs)(`section`,{className:`bots-section`,"aria-labelledby":`themes-title`,children:[(0,I.jsx)(`div`,{className:`bots-section-head`,children:(0,I.jsx)(`h2`,{id:`themes-title`,children:e(`bots.home.themes`)})}),(0,I.jsx)(`div`,{className:`collection-tiles`,children:P.slice(0,g).map(e=>(0,I.jsx)(Je,{collection:e,stars:y},e.id))}),(0,I.jsx)(qe,{shown:g,total:P.length,onMore:()=>_(g+Ue)})]}),(0,I.jsxs)(`section`,{className:`bots-section`,"aria-labelledby":`core-title`,children:[(0,I.jsx)(`div`,{className:`bots-section-head`,children:(0,I.jsx)(`h2`,{id:`core-title`,children:e(`bots.home.core`)})}),(0,I.jsx)(`div`,{className:`collection-tiles`,children:L.map(e=>(0,I.jsx)(Je,{collection:e,stars:y},e.id))})]})]})]})}function Ke({event:e,kept:t,date:n,onOpen:r}){let{t:a}=i(`play`),o=e.status===`live`,s=Math.max(1,Math.floor(e.bots.length/5)),c=e.bots.filter((e,t)=>t%s===0).slice(0,5);return(0,I.jsxs)(`section`,{className:`event-hero`,"data-theme":e.theme,"aria-labelledby":`event-title`,children:[(0,I.jsxs)(`div`,{className:`event-hero-text`,children:[(0,I.jsxs)(`span`,{className:`event-kicker`,children:[o&&(0,I.jsx)(`i`,{className:`live-dot`}),a(o?`bots.events.liveKicker`:`bots.events.soonKicker`)]}),(0,I.jsx)(`h2`,{id:`event-title`,children:e.title}),(0,I.jsx)(`p`,{children:o?a(`bots.events.blurbLive`,{count:e.bots.length,date:n(e.end),need:e.need}):a(`bots.events.blurbSoon`,{count:e.bots.length,date:n(e.start+1)})}),(0,I.jsx)(H,{until:o?e.end:e.start,label:a(o?`bots.events.leavesIn`:`bots.events.arrivesIn`)}),o&&(0,I.jsxs)(`div`,{className:`event-progress`,children:[(0,I.jsx)(`span`,{className:`meter`,children:(0,I.jsx)(`i`,{style:{width:`${Math.min(100,Math.round(t/e.need*100))}%`}})}),(0,I.jsx)(`small`,{children:a(`bots.events.progress`,{count:t,need:e.need,total:e.bots.length})})]}),(0,I.jsxs)(`div`,{className:`event-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`event-play`,onClick:()=>r(),children:a(o?`bots.events.play`:`bots.events.preview`)}),(0,I.jsx)(`button`,{type:`button`,className:`event-all`,onClick:()=>r(),children:a(`bots.events.seeAll`,{count:e.bots.length})})]})]}),(0,I.jsx)(`div`,{className:`event-fan`,children:c.map((e,t)=>(0,I.jsx)(`button`,{type:`button`,className:`fan-card fan-${t}`,"aria-label":e.name,onClick:()=>r(e.id),children:(0,I.jsx)(`img`,{src:v(e),alt:``,className:o?``:`waiting`})},e.id))})]})}function qe({shown:e,total:t,onMore:n}){let{t:r}=i(`play`);return e>=t?null:(0,I.jsx)(`button`,{type:`button`,className:`bots-button show-more`,onClick:n,children:r(`bots.home.more`,{count:t-e})})}function Je({collection:e,stars:t}){let{t:n}=i(`play`),r=e.bots.filter(e=>$(t,e)).length;return(0,I.jsxs)(o,{className:`collection-tile`,to:Q(e.id),children:[(0,I.jsx)(`span`,{className:`tile-faces`,children:We(e,3).map(e=>(0,I.jsx)(`img`,{src:v(e),alt:``},e.id))}),(0,I.jsxs)(`span`,{className:`tile-text`,children:[(0,I.jsx)(`strong`,{children:e.title}),(0,I.jsx)(`small`,{children:e.bots.length?n(`bots.home.tileCount`,{count:e.bots.length,won:r}):n(`bots.home.tileEmpty.${e.id}`,{defaultValue:``})})]}),(0,I.jsx)(`span`,{className:`tile-arrow`,"aria-hidden":!0,children:`›`})]})}export{Ge as BotsHomePage,K as a,$ as beaten,te as c,Q as collectionPath,G as i,Le as n,W as o,Ie as r,H as s,Re as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,t as r}from"./vendor-DVQGMHsh.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,n,t as r}from"./vendor-DVQGMHsh.js";import{At as i}from"./index-Ba3yxWjC.js";var a=e(t(),1),o=r(),s=null;function c(){let[e,t]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=!0;return s??=i(`api/coach/status`).then(e=>e.available,()=>!1),s.then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}function l(e,t,n){let[r,o]=(0,a.useState)(null),[s,c]=(0,a.useState)(!1),[l,u]=(0,a.useState)(null),d=JSON.stringify(t);return(0,a.useEffect)(()=>{if(o(null),u(null),!n)return;let t=!0;return i(e,{...JSON.parse(d),cachedOnly:!0}).then(e=>{t&&e.answer&&o(e.answer)},()=>{}),()=>{t=!1}},[e,d,n]),{answer:r,busy:s,error:l,ask:()=>{c(!0),u(null),i(e,t).then(e=>o(e.answer),e=>u(e.message)).finally(()=>c(!1))}}}function u({fen:e,move:t}){let{t:r}=n(`coach`),i=c(),{answer:a,busy:s,error:u,ask:d}=l(`api/explain`,{fen:e,move:t},i);return i?(0,o.jsxs)(`div`,{className:`coach-explain`,"aria-live":`polite`,children:[a?(0,o.jsxs)(`p`,{children:[(0,o.jsx)(`strong`,{children:r(`explain.title`)}),` `,a.text]}):s?(0,o.jsx)(`p`,{role:`status`,children:r(`explain.thinking`)}):(0,o.jsx)(`button`,{type:`button`,className:`text-button`,onClick:d,children:r(`explain.ask`,{move:t})}),u&&(0,o.jsx)(`p`,{role:`alert`,children:r(`error`,{error:u})})]}):null}function d({id:e}){let{t}=n(`coach`),r=c(),{answer:i,busy:a,error:s,ask:u}=l(`api/coach/game`,{id:e},r);return r?(0,o.jsxs)(`div`,{className:`coach-explain coach-game-review`,"aria-live":`polite`,children:[i?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:(0,o.jsx)(`strong`,{children:i.headline})}),(0,o.jsx)(`p`,{children:i.summary}),i.lesson&&(0,o.jsxs)(`p`,{children:[(0,o.jsx)(`strong`,{children:t(`review.lesson`)}),` `,i.lesson]})]}):a?(0,o.jsx)(`p`,{role:`status`,children:t(`review.thinking`)}):(0,o.jsx)(`button`,{type:`button`,className:`text-button`,onClick:u,children:t(`review.ask`)}),s&&(0,o.jsx)(`p`,{role:`alert`,children:t(`error`,{error:s})})]}):null}export{d as n,u as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,m as n,n as r,s as i,t as a}from"./vendor-DVQGMHsh.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,m as n,n as r,s as i,t as a}from"./vendor-DVQGMHsh.js";import{Et as o,dt as s,ft as c}from"./index-Ba3yxWjC.js";import{t as l}from"./grades-D6OvtJ99.js";import{t as u}from"./Segments-B8XJlwPB.js";import{n as d}from"./useProfile-BN14mByx.js";import{InsightsPage as f,n as p,r as m,t as h}from"./InsightsPage-D0qeKM7h.js";var g=e(t(),1),_=a(),v=[{mode:`plan`,to:`/coach`},{mode:`progress`,to:`/coach/progress`},{mode:`learn`,to:`/coach/learn`}],y=[{key:`lessons`,to:`/lessons`,art:c.study},{key:`puzzles`,to:`/puzzles`,art:c.target},{key:`train`,to:`/train`,art:c.calendar},{key:`openings`,to:`/openings`,art:`art/topics/opening.webp`},{key:`endgames`,to:`/endgames`,art:c.victory},{key:`story`,to:`/story`,art:s.Story}];function b({mode:e=`plan`}){let{t}=r(`coach`);return(0,g.useEffect)(()=>{document.body.dataset.page=`coach`},[]),(0,_.jsx)(`section`,{className:`coach-hub`,"aria-label":t(`hub.label`),children:e===`plan`?(0,_.jsx)(C,{}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(x,{mode:e}),e===`progress`?(0,_.jsx)(f,{basePath:`/coach/progress`}):(0,_.jsx)(`div`,{className:`coach-centers`,children:y.map(e=>(0,_.jsxs)(i,{className:`coach-center`,to:e.to,children:[(0,_.jsx)(`img`,{src:e.art,alt:``,width:`76`,height:`76`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{children:t(`centers.${e.key}.title`)}),(0,_.jsx)(`p`,{children:t(`centers.${e.key}.body`)}),(0,_.jsxs)(`span`,{children:[t(`hub.open`),` →`]})]})]},e.key))})]})})}function x({mode:e,children:t}){let{t:i}=r(`coach`),a=n();return(0,_.jsxs)(`header`,{className:`coach-head`,children:[(0,_.jsxs)(`div`,{className:`coach-head-main`,children:[(0,_.jsx)(u,{className:`bots-segments coach-tabs`,role:`group`,"aria-label":i(`hub.navigation`),children:v.map(t=>(0,_.jsx)(`button`,{type:`button`,"aria-pressed":t.mode===e,className:t.mode===e?`selected`:``,onClick:()=>a(t.to),children:i(`hub.${t.mode}`)},t.mode))}),(0,_.jsx)(`h1`,{children:i(`hub.label`)}),e===`progress`?(0,_.jsx)(S,{}):(0,_.jsx)(`p`,{children:i(`hub.${e}Intro`)})]}),t&&(0,_.jsx)(`div`,{className:`coach-head-side`,children:t})]})}function S(){let{t:e}=r(`coach`),{insights:t}=o();if(!t)return(0,_.jsx)(`p`,{children:e(`hub.progressIntro`)});let{analyzed:n,total:i}=t.coverage,a=l.reduce((e,n)=>e+(t.grades?.[n]??0),0);return(0,_.jsx)(`p`,{children:a?e(`hub.coverageMoves`,{analyzed:n,total:i,moves:a.toLocaleString()}):e(`hub.coverage`,{analyzed:n,total:i})})}function C(){let e=m();return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(x,{mode:`plan`,children:[(0,_.jsx)(w,{}),(0,_.jsx)(p,{state:e})]}),(0,_.jsx)(h,{coach:e})]})}function w(){let{t:e}=r(`coach`),t=d();if(!t)return null;let n=t.xpForLevel?Math.min(100,Math.round(t.xpIntoLevel/t.xpForLevel*100)):0;return(0,_.jsxs)(i,{className:`coach-level`,to:`/profile`,"aria-label":e(`hub.levelLabel`,{level:t.level,xp:t.xpIntoLevel,goal:t.xpForLevel}),children:[(0,_.jsx)(`span`,{className:`coach-level-badge`,"aria-hidden":`true`,children:t.level}),(0,_.jsxs)(`span`,{className:`coach-level-text`,children:[(0,_.jsx)(`strong`,{children:e(`hub.level`,{level:t.level})}),(0,_.jsxs)(`span`,{children:[(0,_.jsx)(`span`,{className:`coach-level-bar`,children:(0,_.jsx)(`span`,{style:{width:`${n}%`}})}),(0,_.jsx)(`small`,{children:e(`hub.xpLevel`,{xp:t.xpIntoLevel,goal:t.xpForLevel})})]})]})]})}export{b as CoachPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,h as n,n as r,s as i,t as a}from"./vendor-DVQGMHsh.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,h as n,n as r,s as i,t as a}from"./vendor-DVQGMHsh.js";import{At as o,Dt as s,Tt as c}from"./index-Ba3yxWjC.js";import{n as l,t as u}from"./usePlanning-M5mnt77_.js";import{o as d}from"./routes-SOm45MWj.js";import{f}from"./useChess-sMdAC0kt.js";var p=e(t(),1),m=a(),h=[`mates`,`pawns`,`pieces`,`rooks`];function g(){let{t:e}=r(`endgames`),{id:t}=n(),[a,s]=(0,p.useState)(null),[c,l]=(0,p.useState)(null);(0,p.useEffect)(()=>{document.body.dataset.page=`train`},[]);let u=(0,p.useCallback)(async()=>{l(null);try{s(await o(`api/endgames`))}catch(e){l(e.message)}},[]);(0,p.useEffect)(()=>{u()},[u]);let f;if(c)f=(0,m.jsxs)(`p`,{className:`train-empty`,role:`alert`,children:[c,` `,(0,m.jsx)(`button`,{type:`button`,className:`text-button`,onClick:u,children:e(`tryAgain`)})]});else if(!a)f=(0,m.jsx)(`p`,{className:`train-empty`,role:`status`,children:e(`loading`)});else if(t){let n=a.positions.findIndex(e=>e.id===t);f=n<0?(0,m.jsxs)(`p`,{className:`train-empty`,role:`alert`,children:[e(`notFound`),` `,(0,m.jsx)(i,{className:`text-button`,to:d(),children:e(`actions.all`)})]}):(0,m.jsx)(_,{position:a.positions[n],next:a.positions[n+1],onRecorded:u},t)}else f=(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`p`,{className:`train-detail`,children:e(`intro`,{completed:a.completed,total:a.total})}),h.map(t=>{let n=a.positions.filter(e=>e.group===t);return n.length>0&&(0,m.jsxs)(`section`,{className:`lesson-group`,"aria-labelledby":`endgames-${t}`,children:[(0,m.jsx)(`h2`,{id:`endgames-${t}`,children:e(`groups.${t}`)}),(0,m.jsx)(`div`,{className:`lesson-cards`,children:n.map(t=>(0,m.jsxs)(i,{className:`lesson-card${t.completed?` completed`:``}`,to:d(t.id),children:[(0,m.jsx)(`h3`,{children:t.title}),(0,m.jsxs)(`span`,{className:`lesson-meta`,children:[e(`goal.${t.goal}.${t.color}`),` · `,e(t.goal===`win`?`meta.win`:`meta.draw`,{count:t.moves})]}),(0,m.jsx)(`span`,{className:`lesson-status`,children:t.completed?e(`status.done`,{count:t.best??t.moves}):t.attempts?e(`status.tried`,{count:t.attempts}):e(`status.new`)})]},t.id))})]},t)})]});return(0,m.jsxs)(`section`,{id:`endgames`,className:`train`,"aria-label":e(`page.label`),children:[(0,m.jsxs)(`nav`,{className:`train-actions`,"aria-label":e(`page.modes`),children:[(0,m.jsx)(i,{className:`text-button`,to:`/train`,children:e(`page.drills`)}),(0,m.jsx)(i,{className:`text-button`,to:`/openings`,children:e(`page.openings`)}),t&&(0,m.jsx)(i,{className:`text-button`,to:d(),children:e(`actions.all`)})]}),f]})}function _({position:e,next:t,onRecorded:n}){let{t:a}=r(`endgames`),h=s(),{engineAvailable:g}=c(),[_,v]=(0,p.useState)([]),[y,b]=(0,p.useState)(null),[x,S]=(0,p.useState)(!1),{board:C}=f(e.fen,_),w=u(C),T=!!y&&y.status!==`playing`;async function E(t){if(x||T)return;let r=_,i=[...r,{uci:t,san:``}];v(i),S(!0);try{let t=await o(`api/endgames/move`,{id:e.id,moves:i.map(e=>e.uci)});b(t),t.reply&&v([...i,{uci:t.reply,san:t.reply_san??``}]),(t.status===`success`||r.length===0)&&n()}catch(e){v(r),h(e.message)}finally{S(!1)}}let D=()=>{v([]),b(null)},O=y?.used??0,k=_.at(-1)?.uci??null;return(0,m.jsxs)(`div`,{className:`train-layout`,children:[(0,m.jsx)(`div`,{className:`train-board-column`,children:(0,m.jsx)(l,{board:C,flipped:e.color===`black`,planning:w,lastMove:k,movable:T||x||!g?!1:e.color,onMove:E,busy:x})}),(0,m.jsxs)(`aside`,{className:`train-panel`,"aria-live":`polite`,children:[(0,m.jsxs)(`p`,{className:`train-source`,children:[a(`groups.${e.group}`),e.completed?` · ${a(`status.done`,{count:e.best??e.moves})}`:``]}),(0,m.jsx)(`h2`,{children:e.title}),(0,m.jsxs)(`p`,{className:`train-prompt`,children:[(0,m.jsxs)(`strong`,{children:[a(`goal.${e.goal}.${e.color}`),`.`]}),` `,e.explain]}),!g&&(0,m.jsx)(`p`,{className:`train-detail`,children:a(`noEngine`)}),T&&y?(0,m.jsx)(`p`,{className:`train-verdict ${y.status===`success`?`correct`:`missed`}`,children:a(`result.${y.status}.${y.reason}`,{count:O})}):(0,m.jsx)(`p`,{className:`train-detail`,children:a(e.goal===`win`?`left.win`:`left.draw`,{count:e.moves-O})}),(0,m.jsxs)(`div`,{className:`train-actions`,children:[(T||_.length>0)&&(0,m.jsx)(`button`,{className:`button${T?` primary`:``}`,type:`button`,onClick:D,children:a(`actions.retry`)}),T&&t&&(0,m.jsx)(i,{className:`text-button`,to:d(t.id),children:a(`actions.next`)}),(0,m.jsx)(i,{className:`text-button`,to:d(),children:a(`actions.all`)})]})]})]})}export{g as EndgamesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,f as n,g as r,m as i,n as a,s as o,t as s}from"./vendor-DVQGMHsh.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{b as t,f as n,g as r,m as i,n as a,s as o,t as s}from"./vendor-DVQGMHsh.js";import{At as c,Dt as l}from"./index-Ba3yxWjC.js";import{p as u,s as d}from"./routes-SOm45MWj.js";import{s as f}from"./useChess-sMdAC0kt.js";import{t as p}from"./BoardWorkspace-Dwl4rkFt.js";import{t as m}from"./lastVisited-ChiJXsfH.js";var h=e(t(),1),g=s(),_=new Map;function v(e,t){let n=t.join(`,`),r=`${e}|${n}`,[i,a]=(0,h.useState)(()=>({key:r,moves:_.get(r)??null,error:null}));return(0,h.useEffect)(()=>{let t=_.get(r);if(t){a({key:r,moves:t,error:null});return}let i=new AbortController;return c(`api/line`,{initialFen:e,moves:n?n.split(`,`):[]},i.signal).then(e=>{e.error||_.set(r,e.moves),a({key:r,moves:e.moves,error:e.error??null})}).catch(e=>{i.signal.aborted||a({key:r,moves:[],error:e.message})}),()=>i.abort()},[r,e,n]),i.key===r?i:{key:r,moves:null,error:null}}function y(e,t){return t?t.startsWith(`/play`)?e(`explore.back.play`):t.startsWith(`/games`)?e(`explore.back.games`):t.startsWith(`/train`)?e(`explore.back.train`):t.startsWith(`/insights`)?e(`explore.back.insights`):e(`explore.back.home`):``}function b(){let{t:e}=a(`play`),[t]=r(),s=u(t),c=i(),b=n(),x=l(),{moves:S,error:C}=v(s.fen,s.moves),[w,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(s.flipped);(0,h.useEffect)(()=>{m.explore=b.pathname+b.search},[b]),(0,h.useEffect)(()=>{C&&x(C)},[C,x]);let[O,k]=(0,h.useState)(null),A=s.moves.join(`,`);(0,h.useEffect)(()=>k(null),[A]);let j=S?.length??0,M=O===null?j:Math.min(O,j),N=(0,h.useCallback)((e,t=!0)=>c(d({...s,moves:e,base:Math.min(s.base,e.length),flipped:E}),{replace:t}),[c,s,E]),P=async e=>{if(S){T(!0);try{let t=S.slice(0,M),n=await f(s.fen,t,e),r=[...t,{uci:e,san:n.san}];_.set(`${s.fen}|${r.map(e=>e.uci).join(`,`)}`,r),N(r.map(e=>e.uci))}catch(e){x(e.message)}finally{T(!1)}}},F=y(e,s.from),I=s.moves.length!==s.base||M!==j,L=(0,h.useMemo)(()=>S??[],[S]);return S?(0,g.jsx)(p,{mode:`explore`,initialFen:s.fen,moves:L,cursor:M,onGo:e=>k(Math.max(0,Math.min(j,e))),flipped:E,onFlip:()=>D(!E),players:{white:{name:e(`explore.white`),detail:e(`explore.whitePieces`)},black:{name:e(`explore.black`),detail:e(`explore.blackPieces`)}},movable:`turn`,onMove:P,busy:w,busyText:e(`explore.checking`),onTryBest:P,context:s.from?(0,g.jsxs)(`div`,{id:`explore-context`,children:[(0,g.jsx)(`strong`,{id:`explore-context-title`,children:s.from.startsWith(`/play`)?e(`explore.gamePaused`):e(`explore.exploringCopy`)}),(0,g.jsx)(o,{id:`exit-explore`,className:`button`,to:s.from,children:F})]}):void 0,panelBottom:I||s.base?(0,g.jsx)(`div`,{id:`branch-banner`,children:(0,g.jsx)(`button`,{id:`return-game`,type:`button`,disabled:!I,onClick:()=>N(s.moves.slice(0,s.base)),children:e(`explore.resetLine`)})}):void 0}):(0,g.jsx)(`p`,{className:`page-status`,role:`status`,children:e(`explore.loading`)})}export{b as ExplorePage};
|