1import{$ as w,C as T}from"./BM8Wk4t6.js";import{d as S,l as k,m as $,n as L,ak as p,O as q,c as A,f as F,z as I,o as O,S as g,G as f}from"./C8OjvWdH.js";const z=S({__name:"SpectatorChessboard",props:{fen:{},moves:{},theme:{},compact:{type:Boolean}},setup(e){const a=e,r=k(null);let t=null,u=null,l=null,n=null;const h=[{light:"#f3eadc",dark:"#9f4152"},{light:"#dbeafe",dark:"#3b6f8f"},{light:"#e5ead7",dark:"#6b7f4e"},{light:"#eee7f5",dark:"#76558d"},{light:"#f3e5c8",dark:"#b07a45"},{light:"#d9e2e8",dark:"#526d78"}],v=$(()=>h[Math.abs(a.theme||0)%h.length]),E=()=>{var c;return((c=a.fen)==null?void 0:c.trim())||"start"},b=()=>{var c,m;const i=r.value;if(!i)return;i.querySelectorAll(".spectator-last-move").forEach(s=>s.classList.remove("spectator-last-move")),i.querySelectorAll(".black-3c85d, .b-square").forEach(s=>{s.style.setProperty("background-color",v.value.dark,"important")}),i.querySelectorAll(".white-1e1d7, .w-square").forEach(s=>{s.style.setProperty("background-color",v.value.light,"important")});const _=(m=(c=a.moves)==null?void 0:c.at(-1))==null?void 0:m.toLowerCase(),d=(_==null?void 0:_.match(/^([a-h][1-8])([a-h][1-8])/))||null;if(d)for(const s of[d[1],d[2]]){const N=i.querySelector(`.square-${s}`);N&&N.classList.add("spectator-last-move")}},o=()=>{l!=null&&cancelAnimationFrame(l),n&&clearTimeout(n),l=requestAnimationFrame(()=>{l=requestAnimationFrame(()=>{l=null,b()})}),n=setTimeout(()=>{n=null,b()},120)};return L(()=>{window.$=window.jQuery=w,t=T(r.value,{position:E(),draggable:!1,showNotation:!0,pieceTheme:"/img/chesspieces/{piece}.png",onMoveEnd:o,onSnapEnd:o}),o(),u=new ResizeObserver(()=>{t==null||t.resize(),o()}),r.value&&u.observe(r.value)}),p(()=>a.fen,()=>{t==null||t.position(E(),!1),g(o)}),p(()=>a.moves,()=>g(o),{deep:!0}),p(()=>a.theme,()=>g(o)),q(()=>{l!=null&&cancelAnimationFrame(l),n&&clearTimeout(n),u==null||u.disconnect(),t==null||t.destroy(),t=null}),(c,m)=>(O(),A("div",{class:I(["spectator-board aspect-square w-full overflow-hidden rounded-lg bg-gray-200 shadow-xl dark:bg-gray-800",a.compact?"spectator-board--compact":""])},[F("div",{ref_key:"boardElement",ref:r,class:"w-full","aria-label":"Read-only spectator chessboard"},null,512)],2))}}),M={ONE_MIN:"1 min",THREE_MIN:"3 min",FIVE_MIN:"5 min",TEN_MIN:"10 min",FIFTEEN_MIN:"15 min",ONE_PLUS_ONE:"1 + 1",TWO_PLUS_ONE:"2 + 1",THREE_PLUS_TWO:"3 + 2",FIVE_PLUS_FIVE:"5 + 5",TEN_PLUS_TEN:"10 + 10"},P=e=>e?M[e]||e.toLowerCase().replaceAll("_"," ").replace(/\b\w/g,a=>a.toUpperCase()):"",y=e=>String(e||"").normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/-+/g,"-").replace(/^[-_]+|[-_]+$/g,"")||"player",G=(e,a,r)=>`/watch/game/${y(e)}-${y(a)}-${r}`,U=e=>{const a=Array.isArray(e)?e[0]:e,r=String(a||"").match(/(?:^|-)(\d+)$/);return r?Number(r[1]):Number.NaN},C=()=>({getLiveGames:(e=0,a=6)=>f("GET",`/spectator/games/live?page=${e}&size=${a}`),getRecentGames:(e=0,a=6)=>f("GET",`/spectator/games/recent?page=${e}&size=${a}`),getGame:e=>f("GET",`/spectator/games/${e}`)});export{z as _,U as a,P as f,G as s,C as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.