Files
chess-3miz/client/assets/index-CHF7ocq9.js
T

210 lines
32 KiB
JavaScript
Raw Normal View History

2026-11-06 22:29:07 +03:30
(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))t(s);new MutationObserver(s=>{for(const e of s)if(e.type==="childList")for(const c of e.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&t(c)}).observe(document,{childList:!0,subtree:!0});function r(s){const e={};return s.integrity&&(e.integrity=s.integrity),s.referrerPolicy&&(e.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?e.credentials="include":s.crossOrigin==="anonymous"?e.credentials="omit":e.credentials="same-origin",e}function t(s){if(s.ep)return;s.ep=!0;const e=r(s);fetch(s.href,e)}})();function ct(o){const a=new URLSearchParams(location.search).get("host")??"*",r=s=>window.parent.postMessage({m3:1,...s},a);let t=0;return window.addEventListener("message",s=>{var c,i,y;if(s.source!==window.parent||a!=="*"&&s.origin!==a)return;const e=s.data;if(!(!e||e.m3!==1))switch(e.type){case"init":o.onInit(e),r({type:"ready"});break;case"state":o.onState(e.env);break;case"ack":(c=o.onAck)==null||c.call(o,e);break;case"view_changed":(i=o.onViewChanged)==null||i.call(o,e.view);break;case"cmd_failed":(y=o.onCmdFailed)==null||y.call(o,e.req_id,e.code);break}}),r({type:"loaded"}),{cmd(s,e={}){const c=++t;return r({type:"cmd",cmd_type:s,payload:e,req_id:c}),c},toast(s,e,c="info"){r({type:"toast",text_fa:s,text_en:e,kind:c})}}}const S=`
<defs>
<linearGradient id="cp-w-body" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#ffffff"/>
<stop offset="35%" stop-color="#f8fafc"/>
<stop offset="70%" stop-color="#e2e8f0"/>
<stop offset="100%" stop-color="#94a3b8"/>
</linearGradient>
<linearGradient id="cp-w-spec" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.95"/>
<stop offset="60%" stop-color="#ffffff" stop-opacity="0.3"/>
<stop offset="100%" stop-color="#ffffff" stop-opacity="0"/>
</linearGradient>
<linearGradient id="cp-w-gold" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#fef08a"/>
<stop offset="30%" stop-color="#f59e0b"/>
<stop offset="70%" stop-color="#d97706"/>
<stop offset="100%" stop-color="#78350f"/>
</linearGradient>
<radialGradient id="cp-ruby" cx="35%" cy="30%" r="70%">
<stop offset="0%" stop-color="#fda4af"/>
<stop offset="35%" stop-color="#f43f5e"/>
<stop offset="75%" stop-color="#be123c"/>
<stop offset="100%" stop-color="#4c0519"/>
</radialGradient>
<radialGradient id="cp-pearl" cx="30%" cy="30%" r="70%">
<stop offset="0%" stop-color="#ffffff"/>
<stop offset="45%" stop-color="#fef08a"/>
<stop offset="85%" stop-color="#f59e0b"/>
<stop offset="100%" stop-color="#b45309"/>
</radialGradient>
</defs>
`,G=`
<defs>
<linearGradient id="cp-b-body" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#334155"/>
<stop offset="25%" stop-color="#1e293b"/>
<stop offset="65%" stop-color="#0f172a"/>
<stop offset="100%" stop-color="#020617"/>
</linearGradient>
<linearGradient id="cp-b-spec" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="#94a3b8" stop-opacity="0.9"/>
<stop offset="45%" stop-color="#64748b" stop-opacity="0.35"/>
<stop offset="100%" stop-color="#0f172a" stop-opacity="0"/>
</linearGradient>
<linearGradient id="cp-b-gold" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#fde047"/>
<stop offset="30%" stop-color="#eab308"/>
<stop offset="70%" stop-color="#ca8a04"/>
<stop offset="100%" stop-color="#581c87"/>
</linearGradient>
<radialGradient id="cp-sapphire" cx="35%" cy="30%" r="70%">
<stop offset="0%" stop-color="#93c5fd"/>
<stop offset="35%" stop-color="#38bdf8"/>
<stop offset="75%" stop-color="#1d4ed8"/>
<stop offset="100%" stop-color="#091e60"/>
</radialGradient>
<radialGradient id="cp-amethyst" cx="30%" cy="30%" r="70%">
<stop offset="0%" stop-color="#e9d5ff"/>
<stop offset="45%" stop-color="#a855f7"/>
<stop offset="85%" stop-color="#6b21a8"/>
<stop offset="100%" stop-color="#2e1065"/>
</radialGradient>
</defs>
`;function nt(o){const a=o?S:G,r=o?"#0f172a":"#020617",t=o?"url(#cp-w-body)":"url(#cp-b-body)",s=o?"url(#cp-w-spec)":"url(#cp-b-spec)",e=o?"url(#cp-w-gold)":"url(#cp-b-gold)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${o?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
${a}
<g stroke="${r}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 18 90 C 20 84, 30 82, 50 82 C 70 82, 80 84, 82 90 L 82 93 C 82 95, 78 96, 50 96 C 22 96, 18 95, 18 93 Z" fill="${t}"/>
<ellipse cx="50" cy="83" rx="28" ry="3.5" fill="${e}"/>
<path d="M 27 82 C 29 74, 34 68, 38 52 C 40 44, 42 42, 42 42 L 58 42 C 58 42, 60 44, 62 52 C 66 68, 71 74, 73 82 Z" fill="${t}"/>
<path d="M 33 80 C 35 73, 40 60, 42 50 C 45 49, 48 50, 48 51 C 45 61, 41 72, 38 80 Z" fill="${s}" stroke="none"/>
<ellipse cx="50" cy="42" rx="14" ry="4" fill="${e}"/>
<ellipse cx="50" cy="39" rx="11" ry="3" fill="${t}"/>
<circle cx="50" cy="24" r="14" fill="${t}"/>
<ellipse cx="44" cy="18" rx="6" ry="3.5" transform="rotate(-30 44 18)" fill="#ffffff" opacity="${o?"0.85":"0.5"}" stroke="none"/>
<circle cx="50" cy="9.5" r="2.5" fill="${e}"/>
<path d="M 21 89 C 30 85, 70 85, 79 89" fill="none" stroke="${o?"#e2e8f0":"#64748b"}" stroke-width="1.2" opacity="0.6"/>
</g>
</svg>`}function lt(o){const a=o?S:G,r=o?"#0f172a":"#020617",t=o?"url(#cp-w-body)":"url(#cp-b-body)",s=o?"url(#cp-w-spec)":"url(#cp-b-spec)",e=o?"url(#cp-w-gold)":"url(#cp-b-gold)",c=o?"url(#cp-ruby)":"url(#cp-sapphire)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${o?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
${a}
<g stroke="${r}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 18 90 C 20 84, 30 82, 50 82 C 70 82, 80 84, 82 90 L 82 93 C 82 95, 78 96, 50 96 C 22 96, 18 95, 18 93 Z" fill="${t}"/>
<ellipse cx="50" cy="83" rx="29" ry="3.5" fill="${e}"/>
<path d="M 25 82 C 32 72, 38 60, 34 50 C 31 46, 24 47, 18 43 C 14 40, 15 35, 19 32 C 24 29, 32 30, 36 24 C 40 18, 44 14, 52 11 L 55 18 C 58 14, 62 12, 65 14 C 67 15, 66 18, 64 22 C 74 26, 78 40, 77 56 C 76 68, 73 76, 75 82 Z" fill="${t}"/>
<path d="M 64 22 C 70 24, 76 29, 78 36 C 73 34, 68 33, 65 34 C 72 38, 77 44, 78 52 C 73 50, 68 49, 65 51 C 72 55, 75 62, 76 70 C 72 68, 68 67, 66 69" fill="none" stroke="${e}" stroke-width="2.6"/>
<path d="M 36 24 C 44 32, 48 44, 45 52 C 40 56, 34 52, 34 50" fill="none" stroke="${r}" stroke-width="1.8"/>
<path d="M 52 24 C 58 34, 60 52, 58 72 C 54 74, 48 74, 46 72 C 50 56, 48 38, 44 26 Z" fill="${s}" stroke="none"/>
<ellipse cx="20" cy="38" rx="2.5" ry="1.5" transform="rotate(-20 20 38)" fill="${r}"/>
<path d="M 17 41 C 21 44, 25 43, 27 41" fill="none" stroke="${r}" stroke-width="1.5"/>
<ellipse cx="36" cy="27" rx="3.5" ry="2.2" transform="rotate(-15 36 27)" fill="${c}"/>
<circle cx="35" cy="26" r="1" fill="#ffffff" stroke="none"/>
<path d="M 33 66 C 42 70, 58 70, 67 66 L 68 71 C 58 75, 42 75, 32 71 Z" fill="${e}"/>
<circle cx="50" cy="71" r="4.5" fill="${e}"/>
<circle cx="50" cy="71" r="2.5" fill="${c}"/>
</g>
</svg>`}function it(o){const a=o?S:G,r=o?"#0f172a":"#020617",t=o?"url(#cp-w-body)":"url(#cp-b-body)",s=o?"url(#cp-w-spec)":"url(#cp-b-spec)",e=o?"url(#cp-w-gold)":"url(#cp-b-gold)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${o?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
${a}
<g stroke="${r}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 20 90 C 22 84, 30 82, 50 82 C 70 82, 78 84, 80 90 L 80 93 C 80 95, 76 96, 50 96 C 24 96, 20 95, 20 93 Z" fill="${t}"/>
<ellipse cx="50" cy="83" rx="27" ry="3.5" fill="${e}"/>
<path d="M 29 82 C 31 72, 38 64, 40 52 L 60 52 C 62 64, 69 72, 71 82 Z" fill="${t}"/>
<path d="M 35 80 C 37 72, 42 62, 44 54 C 47 54, 49 55, 49 56 C 45 66, 42 74, 39 80 Z" fill="${s}" stroke="none"/>
<path d="M 38 52 C 44 55, 56 55, 62 52 L 63 56 C 56 59, 44 59, 37 56 Z" fill="${e}"/>
<path d="M 36 50 C 33 42, 32 30, 42 19 C 46 15, 49 13, 50 13 C 51 13, 54 15, 58 19 C 68 30, 67 42, 64 50 Z" fill="${t}"/>
<path d="M 58 22 L 40 40 L 44 43 L 61 24 Z" fill="${e}"/>
<path d="M 50 28 L 50 42 M 45 33 L 55 33" stroke="${e}" stroke-width="2.6"/>
<circle cx="50" cy="11" r="3.5" fill="${e}"/>
<circle cx="50" cy="11" r="1.8" fill="${o?"url(#cp-ruby)":"url(#cp-sapphire)"}" stroke="none"/>
<path d="M 40 24 C 36 30, 36 40, 39 46 C 40 46, 42 45, 42 44 C 40 38, 41 30, 43 25 Z" fill="${s}" stroke="none"/>
</g>
</svg>`}function dt(o){const a=o?S:G,r=o?"#0f172a":"#020617",t=o?"url(#cp-w-body)":"url(#cp-b-body)",s=o?"url(#cp-w-spec)":"url(#cp-b-spec)",e=o?"url(#cp-w-gold)":"url(#cp-b-gold)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${o?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
${a}
<g stroke="${r}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 18 90 C 20 84, 30 82, 50 82 C 70 82, 80 84, 82 90 L 82 93 C 82 95, 78 96, 50 96 C 22 96, 18 95, 18 93 Z" fill="${t}"/>
<ellipse cx="50" cy="83" rx="29" ry="3.5" fill="${e}"/>
<path d="M 26 82 L 31 34 L 69 34 L 74 82 Z" fill="${t}"/>
<path d="M 31 80 L 35 36 L 43 36 L 39 80 Z" fill="${s}" stroke="none"/>
<path d="M 23 34 L 77 34 L 75 27 L 25 27 Z" fill="${e}"/>
<rect x="28" y="29" width="6" height="4" fill="${t}"/>
<rect x="40" y="29" width="6" height="4" fill="${t}"/>
<rect x="54" y="29" width="6" height="4" fill="${t}"/>
<rect x="66" y="29" width="6" height="4" fill="${t}"/>
<path d="M 24 27 L 24 14 L 33 14 L 33 20 L 44 20 L 44 14 L 56 14 L 56 20 L 67 20 L 67 14 L 76 14 L 76 27 Z" fill="${t}"/>
<path d="M 23 14 L 34 14 M 43 14 L 57 14 M 66 14 L 77 14" stroke="${e}" stroke-width="2"/>
<path d="M 48 46 C 48 43, 52 43, 52 46 L 52 64 L 48 64 Z" fill="${r}"/>
<circle cx="50" cy="46" r="1.5" fill="${e}"/>
<path d="M 33 55 L 67 55" stroke="${r}" stroke-width="1.2" opacity="0.4"/>
</g>
</svg>`}function ft(o){const a=o?S:G,r=o?"#0f172a":"#020617",t=o?"url(#cp-w-body)":"url(#cp-b-body)",s=o?"url(#cp-w-spec)":"url(#cp-b-spec)",e=o?"url(#cp-w-gold)":"url(#cp-b-gold)",c=o?"url(#cp-ruby)":"url(#cp-sapphire)",i=o?"url(#cp-pearl)":"url(#cp-amethyst)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${o?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
${a}
<g stroke="${r}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 18 90 C 20 84, 30 82, 50 82 C 70 82, 80 84, 82 90 L 82 93 C 82 95, 78 96, 50 96 C 22 96, 18 95, 18 93 Z" fill="${t}"/>
<ellipse cx="50" cy="83" rx="29" ry="3.5" fill="${e}"/>
<path d="M 27 82 C 29 68, 38 60, 41 48 L 59 48 C 62 60, 71 68, 73 82 Z" fill="${t}"/>
<path d="M 32 80 C 35 68, 41 58, 44 50 C 47 49, 49 50, 49 52 C 45 64, 40 74, 37 80 Z" fill="${s}" stroke="none"/>
<path d="M 38 48 C 44 51, 56 51, 62 48 L 63 53 C 56 56, 44 56, 37 53 Z" fill="${e}"/>
<path d="M 40 48 C 37 40, 31 34, 28 32 L 72 32 C 69 34, 63 40, 60 48 Z" fill="${t}"/>
<path d="M 28 32 L 20 18 L 34 26 L 50 12 L 66 26 L 80 18 L 72 32 Z" fill="${t}"/>
<path d="M 27 32 C 40 35, 60 35, 73 32 L 73 35 C 60 38, 40 38, 27 35 Z" fill="${e}"/>
<circle cx="20" cy="17" r="3.2" fill="${i}"/>
<circle cx="34" cy="25" r="3.2" fill="${i}"/>
<circle cx="50" cy="11" r="4.2" fill="${i}"/>
<circle cx="66" cy="25" r="3.2" fill="${i}"/>
<circle cx="80" cy="17" r="3.2" fill="${i}"/>
<ellipse cx="50" cy="40" rx="3.5" ry="4.5" fill="${c}"/>
<circle cx="49" cy="38" r="1.2" fill="#ffffff" stroke="none"/>
</g>
</svg>`}function pt(o){const a=o?S:G,r=o?"#0f172a":"#020617",t=o?"url(#cp-w-body)":"url(#cp-b-body)",s=o?"url(#cp-w-spec)":"url(#cp-b-spec)",e=o?"url(#cp-w-gold)":"url(#cp-b-gold)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${o?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
${a}
<g stroke="${r}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 16 90 C 18 84, 28 82, 50 82 C 72 82, 82 84, 84 90 L 84 94 C 84 96, 78 97, 50 97 C 22 97, 16 96, 16 94 Z" fill="${t}"/>
<ellipse cx="50" cy="83" rx="31" ry="3.8" fill="${e}"/>
<path d="M 25 82 C 27 68, 36 58, 38 46 L 62 46 C 64 58, 73 68, 75 82 Z" fill="${t}"/>
<path d="M 30 80 C 33 68, 40 56, 42 48 C 45 47, 48 48, 48 50 C 44 62, 38 74, 35 80 Z" fill="${s}" stroke="none"/>
<path d="M 34 46 C 42 49, 58 49, 66 46 L 67 51 C 58 54, 42 54, 33 51 Z" fill="${e}"/>
<path d="M 33 46 C 28 38, 28 28, 50 24 C 72 28, 72 38, 67 46 Z" fill="${t}"/>
<path d="M 50 24 L 50 46 M 34 36 C 42 34, 58 34, 66 36" stroke="${e}" stroke-width="2.6"/>
<ellipse cx="50" cy="46" rx="16" ry="3.5" fill="${e}"/>
<path d="M 46 24 L 54 24 L 52 19 L 48 19 Z" fill="${e}"/>
<path d="M 48 19 L 42 16 L 44 11 L 47 13 L 47 6 L 53 6 L 53 13 L 56 11 L 58 16 L 52 19 Z" fill="${e}"/>
<circle cx="50" cy="13" r="2.8" fill="${o?"url(#cp-ruby)":"url(#cp-sapphire)"}"/>
<circle cx="49" cy="12" r="0.9" fill="#ffffff" stroke="none"/>
</g>
</svg>`}const ut={p:nt,n:lt,b:it,r:dt,q:ft,k:pt},D={};function _(o,a){if(!o||!a)return"";const r=`${o}-${a}`;if(!D[r]){const t=ut[o];t&&(D[r]=t(a==="w"))}return D[r]??""}class ht{constructor(a){this.particles=[],this.shockwaves=[],this.animId=null,this.lastTime=0,this.canvas=a,this.ctx=a.getContext("2d"),this.resize(),window.addEventListener("resize",()=>this.resize()),this.startLoop()}resize(){var t,s,e;const a=(t=this.canvas.parentElement)==null?void 0:t.getBoundingClientRect();if(!a)return;const r=window.devicePixelRatio||1;this.canvas.width=Math.round(a.width*r),this.canvas.height=Math.round(a.height*r),this.canvas.style.width=`${a.width}px`,this.canvas.style.height=`${a.height}px`,(e=(s=this.ctx).resetTransform)==null||e.call(s),this.ctx.scale(r,r)}startLoop(){if(this.animId)return;const a=r=>{const t=this.lastTime?Math.min((r-this.lastTime)/1e3,.1):.016;this.lastTime=r,this.update(t),this.render(),this.animId=requestAnimationFrame(a)};this.animId=requestAnimationFrame(a)}update(a){for(let r=this.shockwaves.length-1;r>=0;r--){const t=this.shockwaves[r];t.radius+=(t.maxRadius-t.radius)*12*a,t.alpha-=t.decay*a,(t.alpha<=0||t.radius>=t.maxRadius*.98)&&this.shockwaves.splice(r,1)}for(let r=this.particles.length-1;r>=0;r--){const t=this.particles[r];t.x+=t.vx*a,t.y+=t.vy*a,t.vx*=Math.pow(t.drag,a*60),t.vy*=Math.pow(t.drag,a*60),t.vy+=t.gravity*a,t.vRot&&t.rotation!==void 0&&(t.rotation+=t.vRot*a),t.alpha-=t.decay*a,t.alpha<=0&&this.particles.splice(r,1)}}render(){const a=this.canvas.width/(window.devicePixelRatio||1),r=this.canvas.height/(window.devicePixelRatio||1);this.ctx.clearRect(0,0,a,r);for(const t of this.shockwaves)this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(t.x,t.y,Math.max(1,t.radius),0,Math.PI*2),this.ctx.strokeStyle=t.color,this.ctx.globalAlpha=Math.max(0,t.alpha),this.ctx.lineWidth=t.lineWidth,this.ctx.stroke(),this.ctx.restore();for(const t of this.particles){if(this.ctx.save(),this.ctx.globalAlpha=Math.max(0,t.alpha),this.ctx.fillStyle=t.color,t.shape==="rect"||t.shape==="spark"){this.ctx.translate(t.x,t.y),t.rotation!==void 0&&this.ctx.rotate(t.rotation);const s=t.size||t.radius*2;t.shape==="spark"?this.ctx.fillRect(-s,-s*.25,s*2,s*.5):this.ctx.fillRect(-s*.5,-s*.5,s,s)}else this.ctx.beginPath(),this.ctx.arc(t.x,t.y,Math.max(.5,t.radius),0,Math.PI*2),this.ctx.fill();this.ctx.restore()}}captureImpact(a,r,t="w"){this.shockwaves.push({x:a,y:r,radius:4,maxRadius:48,color:t==="w"?"rgba(255, 235, 180, 0.9)":"rgba(120, 140, 180, 0.9)",alpha:.9,decay:2.8,lineWidth:3});const s=t==="w"?["#ffffff","#fef08a","#f59e0b","#fbbf24"]:["#94a3b8","#cbd5e1","#64748b","#38bdf8"],e=18;for(let c=0;c<e;c++){const i=Math.PI*2*c/e+(Math.random()-.5)*.5,y=120+Math.random()*220;this.particles.push({x:a,y:r,vx:Math.cos(i)*y,vy:Math.sin(i)*y,radius:2+Math.random()*2.5,color:s[Math.floor(Math.random()*s.length)],alpha:1,decay:1.8+Math.random()*1.4,gravity:80,drag:.92,shape:"spark",size:3+Math.random()*3,rotation:i})}for(let c=0;c<6;c++){const i=Math.random()*Math.PI*2,y=25+Math.random()*45;this.particles.push({x:a+(Math.random()-.5)*12,y:r+(Math.random()-.5)*12,vx:Math.cos(i)*y,vy:Math.sin(i)*y,radius:4+Math.random()*6,color:"rgba(200, 200, 210, 0.4)",alpha:.6,decay:1.2,gravity:-10,drag:.88,shape:"circle"})}}landingPuff(a,r){for(let t=0;t<8;t++){const s=20+Math.random()*40;this.particles.push({x:a+(Math.random()-.5)*10,y:r+10,vx:(Math.random()-.5)*s,vy:-Math.random()*20,radius:2.5+Math.random()*3,color:"rgba(220, 220, 230, 0.35)",alpha:.5,decay:2,gravity:15,drag:.85,shape:"circle"})}}dissolvePuff(a,r,t="w"){const s=t==="w"?["#fef08a","#fbbf24","#ffffff","rgba(254, 240, 138, 0.7)"]:["#c084fc","#a855f7","#60a5fa","rgba(192, 132, 252, 0.7)"];for(let e=0;e<16;e++){const c=Math.random()*Math.PI*2,i=12+Math.random()*38;this.particles.push({x:a+(Math.random()-.5)*22,y:r+8+(Math.random()-.5)*12,vx:Math.cos(c)*i,vy:Math.sin(c)*i-22,radius:1.5+Math.random()*2.8,color:s[Math.floor(Math.random()*s.length)],alpha:.85,decay:1.5+Math.random()*.8,gravity:-18,drag:.91,shape:"circle"})}}promotionBurst(a,r){this.shockwaves.push({x:a,y:r,radius:
<div id="top-bar" class="player-bar"></div>
<div class="board-container">
<canvas id="vfx-canvas"></canvas>
<div id="board-grid" class="board-grid"></div>
<div id="ghost-layer" class="ghost-layer"></div>
</div>
<div id="bottom-bar" class="player-bar"></div>
<div id="modal-container"></div>
`;const a=document.getElementById("vfx-canvas");$=new ht(a);const r=document.getElementById("board-grid");r.addEventListener("click",t=>{const s=t.target.closest(".cell");s&&s.dataset.square&&!s.disabled&&Mt(s.dataset.square)});for(let t=0;t<64;t++){const s=document.createElement("button");s.className="cell",s.dataset.index=String(t),r.appendChild(s)}}function I(){var m;if(!n)return;const o=n.me,a=o!=null&&n.players[o]!==void 0;let r,t;a?(r=n.players[o],t=n.players.find(v=>v.seat!==o)||n.players[1-o]):(r=n.players.find(v=>v.color==="w")||n.players[0],t=n.players.find(v=>v.color==="b")||n.players[1]);const s=(r==null?void 0:r.color)||"w",e=s==="b",c=r?n.turn===r.seat&&n.phase==="play":!1,i=t?n.turn===t.seat&&n.phase==="play":!1;z("top-bar",t,i,!1),z("bottom-bar",r,c,a);const y=new Map;for(const v of n.board)y.set(v.square,v);const l=e?[7,6,5,4,3,2,1,0]:[0,1,2,3,4,5,6,7],g=e?[0,1,2,3,4,5,6,7]:[7,6,5,4,3,2,1,0],u=document.getElementById("board-grid");if(!u)return;const d=u.children;let f=0;const p=n.phase==="play"&&n.turn===o,h=n.check&&n.phase==="play"?(m=n.board.find(v=>{var M;return v.type==="k"&&v.color===((M=n.players[n.turn])==null?void 0:M.color)}))==null?void 0:m.square:null;for(const v of g)for(const M of l){const k=String.fromCharCode(97+M)+(v+1),q=y.get(k)||{type:null,color:null},P=d[f++];P.dataset.square=k,P.dataset.color=q.color||"";const Q=(M+v)%2===0?"dark":"light",N=C===k,J=R&&(R.from===k||R.to===k),X=h===k;P.className=`cell ${Q}`+(N?" selected":"")+(J?" last-move":"")+(X?" in-check":"");const W=x.some(B=>B.target===k),tt=x.some(B=>B.target===k&&B.isCapture);let E="";const et=e?M===7:M===0,ot=e?v===7:v===0;if(et&&(E+=`<span class="coord-rank">${v+1}</span>`),ot&&(E+=`<span class="coord-file">${String.fromCharCode(97+M)}</span>`),q.type&&q.color){const B=_(q.type,q.color),at=q.type==="n"&&N?" anim-knight":"";E+=`<div class="piece-wrapper${at}">${B}</div>`}tt?E+='<div class="capture-ring"></div>':W&&(E+='<div class="move-dot"></div>'),P.innerHTML=E;const rt=p&&!0&&q.color===s,st=C?p:rt;P.disabled=!st}wt()}function V(o){const a=Math.max(0,Math.floor(o/1e3)),r=Math.floor(a/60),t=a%60;return`${r}:${t<10?"0":""}${t}`}function Y(o){if(!n||!n.clocks)return 0;const a=n.clocks[o]??0;if(n.phase==="play"&&n.turn===o){const r=Date.now()-U;return Math.max(0,a-r)}return a}function yt(){if(!(!n||!n.clocks||n.phase!=="play"))for(const o of["top-bar","bottom-bar"]){const a=document.getElementById(o);if(!a)continue;const r=a.querySelector(".chess-clock");if(!r||!r.dataset.seat)continue;const t=Number(r.dataset.seat),s=Y(t);r.textContent=V(s),s<=3e4&&s>0?r.classList.add("low-time"):r.classList.remove("low-time")}}function z(o,a,r,t){const s=document.getElementById(o);if(!s||!a||!n)return;s.className="player-bar"+(r?" active":"");const e=vt(a.color),c=bt(a.color),i=c>0?`<span class="advantage-score">+${c}</span>`:"",y=a.bot?'<span class="bot-tag">BOT</span>':"",l=t?`<span class="bot-tag you-tag">${w("شما","YOU")}</span>`:"",g=n.phase==="over"?n.winner===a.seat?w("برنده 🏆","Winner 🏆"):n.winner===null?w("تساوی 🤝","Draw 🤝"):"":r?t?w("نوبت شماست","Your turn"):w("در حال تفکر…","Thinking…"):"",u=Y(a.seat),d=u<=3e4&&u>0&&n.phase==="play",f=n.clocks?`<div class="chess-clock ${r?"active":""} ${d?"low-time":""}" data-seat="${a.seat}">${V(u)}</div>`:"";s.innerHTML=`
<div class="player-profile">
<div class="player-badge ${a.color}">
${a.color==="w"?"♔":"♚"}
</div>
<div class="player-meta">
<div class="player-name">${a.name} ${y} ${l}</div>
<div class="player-status">${g}</div>
</div>
</div>
<div class="player-clock-section">
<div class="captured-tray">
${e.map(p=>`<div class="mini-piece">${_(p.type,p.color)}</div>`).join("")}
${i}
</div>
${f}
</div>
`}function vt(o){if(!n)return[];const a=o==="w"?"b":"w",r={p:8,n:2,b:2,r:2,q:1},t={p:0,n:0,b:0,r:0,q:0};for(const e of n.board)e.color===a&&e.type&&t[e.type]!==void 0&&t[e.type]++;const s=[];for(const e of["q","r","b","n","p"]){const c=r[e]-(t[e]||0);for(let i=0;i<c;i++)s.push({square:"",type:e,color:a})}return s}function bt(o){if(!n)return 0;const a={p:1,n:3,b:3,r:5,q:9};let r=0,t=0;for(const s of n.board){if(!s.type||!s.color)continue;const e=a[s.type]||0;s.color===o?r+=e:t+=e}return r-t}function wt(){var a,r,t;const o=document.getElementById("modal-container");if(!(!o||!n)){if(L){const s=n.me!==null&&n.me!==void 0?(a=n.players[n.me])==null?void 0:a.color:"w";o.innerHTML=`
<div class="modal-backdrop">
<div class="promo-card">
<div class="promo-title">${w("ارتقای پیاده به:","Promote pawn to:")}</div>
<div class="promo-options">
${["q","r","b","n"].map(e=>`
<button class="promo-piece-btn" data-promo="${e}" title="${e}">
${_(e,s)}
</button>
`).join("")}
</div>
<button class="promo-cancel-btn" data-cancel-promo="1">${w("لغو","Cancel")}</button>
</div>
</div>
`,o.querySelectorAll("[data-promo]").forEach(e=>{e.addEventListener("click",()=>{var i;const c=e.dataset.promo;if(L&&c){O.cmd("move",{from:L.from,to:L.to,promotion:c});const y=document.querySelector(`[data-square="${L.to}"]`);if(y){const l=y.getBoundingClientRect(),g=(i=document.getElementById("vfx-canvas"))==null?void 0:i.getBoundingClientRect();g&&($==null||$.promotionBurst(l.left-g.left+l.width/2,l.top-g.top+l.height/2))}L=null,C="",x=[],I()}})}),(r=o.querySelector("[data-cancel-promo]"))==null||r.addEventListener("click",()=>{L=null,I()});return}if(n.phase==="over"){n.winner!==null&&(n.winner,n.me);const s=n.winner===null;let e="",c="";s?n.result_reason==="stalemate"?(e=w("پات — مساوی!","Stalemate — Draw!"),c=w("شاه راه حرکتی ندارد","King has no legal moves")):n.result_reason==="insufficient_material"?(e=w("تساوی — عدم کفایت مهره‌ها","Draw — Insufficient Material"),c=w("مهره کافی برای مات کردن در صفحه وجود ندارد","Neither side has sufficient pieces to force checkmate")):n.result_reason==="timeout_draw"?(e=w("تساوی — پایان زمان و عدم کفایت مهره","Draw — Timeout vs Insufficient Material"),c=w("زمان حریف تمام شد اما مهره کافی برای مات کردن ندارید","Opponent flagged but you lack mating material")):(e=w("بازی مساوی شد","Draw!"),c=w("هیچ‌کدام از طرفین برنده نشد","No side achieved victory")):(e=`${(t=n.players[n.winner])==null?void 0:t.name} ${w("برنده شد! 🏆","Wins! 🏆")}`,n.result_reason==="checkmate"?c=w("با کیش و مات حریف","By checkmate"):n.result_reason==="timeout"?c=w("با اتمام زمان حریف","On time"):n.result_reason==="abandoned"?c=w("به دلیل ترک حریف","By abandonment"):c=""),o.innerHTML=`
<div class="game-over-banner">
<div class="game-over-title">${e}</div>
<div class="game-over-subtitle">${c}</div>
</div>
`;return}o.innerHTML=""}}function Mt(o){var s;if(!n||n.phase!=="play"||L)return;const a=n.me;if(a==null||n.turn!==a)return;const r=(s=n.players[a])==null?void 0:s.color;if(!r)return;const t=n.board.find(e=>e.square===o);if(C){if(C===o){C="",x=[],I();return}if(t!=null&&t.color&&t.color===r){C=o;try{x=A(o,n.board,r)}catch{x=[]}I();return}const e=n.board.find(i=>i.square===C),c=r==="b"?"1":"8";if((e==null?void 0:e.type)==="p"&&o[1]===c){L={from:C,to:o},C="",x=[],I();return}O.cmd("move",{from:C,to:o}),C="",x=[],I()}else if(t&&t.color===r){C=o;try{x=A(o,n.board,r)}catch{x=[]}I()}}