@lichess-org/chessground 9.7.1 → 9.7.4
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.
- package/dist/chessground.min.js +1 -1
- package/dist/premove.js +2 -2
- package/dist/premove.js.map +1 -1
- package/dist/wrap.js +1 -1
- package/dist/wrap.js.map +1 -1
- package/package.json +1 -1
- package/src/premove.ts +4 -3
- package/src/wrap.ts +1 -1
package/dist/chessground.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var _e=["white","black"];var G=["a","b","c","d","e","f","g","h"],I=["1","2","3","4","5","6","7","8"];var Ye=[...I].reverse(),se=G.flatMap(e=>I.map(o=>e+o)),h=e=>se[8*e[0]+e[1]],f=e=>[e.charCodeAt(0)-97,e.charCodeAt(1)-49];var ce=se.map(f);function Je(e){let o,n=()=>(o===void 0&&(o=e()),o);return n.clear=()=>{o=void 0},n}var eo=()=>{let e;return{start(){e=performance.now()},cancel(){e=void 0},stop(){if(!e)return 0;let o=performance.now()-e;return e=void 0,o}}},j=e=>e==="white"?"black":"white",L=(e,o)=>(e[0]-o[0])**2+(e[1]-o[1])**2,W=(e,o)=>e.role===o.role&&e.color===o.color,oo=(e,o)=>e[0]===o[0]&&e[1]===o[1],F=e=>(o,n)=>[(n?o[0]:7-o[0])*e.width/8,(n?7-o[1]:o[1])*e.height/8],k=(e,o)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px)`},Ce=(e,o,n=1)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px) scale(${n})`},_=(e,o)=>{e.style.visibility=o?"visible":"hidden"},T=e=>{if(e.clientX||e.clientX===0)return[e.clientX,e.clientY];if(e.targetTouches?.[0])return[e.targetTouches[0].clientX,e.targetTouches[0].clientY]},le=e=>e.button===2,C=(e,o)=>{let n=document.createElement(e);return o&&(n.className=o),n};function de(e,o,n){let r=f(e);return o||(r[0]=7-r[0],r[1]=7-r[1]),[n.left+n.width*r[0]/8+n.width/16,n.top+n.height*(7-r[1])/8+n.height/16]}var K=(e,o)=>Math.abs(e-o),Q=(e,o,n,r)=>K(e,n)*K(o,r)===2,ue=(e,o,n,r)=>e===n!=(o===r),pe=(e,o,n,r)=>K(e,n)===K(o,r)&&e!==n,fe=(e,o,n,r)=>ue(e,o,n,r)||pe(e,o,n,r),De=(e,o,n,r)=>Math.max(K(e,n),K(o,r))===1,Ke=(e,o,n,r,t)=>K(e,n)===1&&r===o+(t?1:-1),Ee=(e,o,n,r,t)=>{let i=t?1:-1;return e===n&&(r===o+i||r===o+2*i&&(t?o<=1:o>=6))},Y=(e,o,n,r)=>{let t=n-e,i=r-o;if(t&&i&&Math.abs(t)!==Math.abs(i))return[];let s=Math.sign(t),d=Math.sign(i),l=[],a=e+s,c=o+d;for(;a!==n||c!==r;)l.push([a,c]),a+=s,c+=d;return l.map(u=>h(u))},no=e=>{let o=f(e),n=[];return o[0]>0&&n.push([o[0]-1,o[1]]),o[0]<7&&n.push([o[0]+1,o[1]]),n.map(h)},J=(e,o)=>{let n=f(e);return n[1]+=o,h(n)};var U=e=>e.friendlies.has(h(e.pos2)),tn=e=>e.enemies.has(h(e.pos2)),ro=(e,o,n)=>Y(...e,...o).some(r=>n.has(r)),to=(e,o,n)=>{let r=n.enemies.get(e);if(r?.role!=="pawn")return!1;let t=r.color==="white"?1:-1,i=f(e),s=f(o);return Ee(...i,...s,r.color==="white")&&!ro(i,[s[0],s[1]+t],n.allPieces)},an=(e,o,n)=>{let r=n.enemies.get(e);return r?.role==="pawn"&&Ke(...f(e),...f(o),r.color==="white")&&(n.friendlies.has(o)||me(J(o,r.color==="white"?-1:1),n.friendlies,n.enemies,n.lastMove))},sn=e=>[...e.enemies.keys()].some(o=>to(o,h(e.pos2),e)),xe=(e,o)=>{let n=e.pos2;return[...e.enemies].some(([r,t])=>{let i=f(r);return!o?.includes(t.role)&&(t.role==="pawn"&&Ke(...i,...n,t.color==="white")||t.role==="knight"&&Q(...i,...n)||t.role==="bishop"&&pe(...i,...n)||t.role==="rook"&&ue(...i,...n)||t.role==="queen"&&fe(...i,...n)||t.role==="king"&&De(...i,...n))&&(!["bishop","rook","queen"].includes(t.role)||!ro(i,n,e.allPieces))})},ge=e=>U(e)&&(me(h(e.pos2),e.friendlies,e.enemies,e.lastMove)||xe(e)),me=(e,o,n,r)=>{if(r&&e!==r[1])return!1;let t=f(e),i=o.get(e);return i?.role==="pawn"&&t[1]===(i.color==="white"?3:4)&&(!r||K(f(r[0])[1],t[1])===2)&&[1,-1].some(s=>n.get(h([t[0]+s,t[1]]))?.role==="pawn")},cn=e=>{if(e.unrestrictedPremoves)return!0;let o=Y(...e.pos1,...e.pos2),n=o.filter(r=>e.friendlies.has(r));return!n.length||n.length===1&&me(n[0],e.friendlies,e.enemies,e.lastMove)&&!o.includes(J(n[0],e.color==="white"?-1:1))},ln=e=>{if(e.unrestrictedPremoves)return!0;let o=Y(...e.pos1,...e.pos2),n=o.filter(a=>e.enemies.has(a));if(n.length>1)return!1;if(!n.length)return!0;let r=n[0],t=e.enemies.get(r);if(!t||t.role!=="pawn")return!0;let i=t.color==="white"?1:-1,s=J(r,i),d=[...no(s).filter(a=>an(r,a,e)),...[s,J(s,i)].filter(a=>a&&to(r,a,e))],l=[...o,h(e.pos1)];return d.some(a=>!l.includes(a))},Ae=e=>cn(e)&&ln(e),dn=e=>{let o=e.color==="white"?1:-1;return K(e.pos1[0],e.pos2[0])>1?!1:K(e.pos1[0],e.pos2[0])?e.pos2[1]!==e.pos1[1]+o?!1:e.unrestrictedPremoves||tn(e)?!0:U(e)?xe(e):sn(e)||me(h([e.pos2[0],e.pos2[1]+o]),e.friendlies,e.enemies,e.lastMove)||xe(e,["pawn"]):Ee(...e.pos1,...e.pos2,e.color==="white")&&Ae({...e,pos2:[e.pos2[0],e.pos2[1]+o]})},un=e=>Q(...e.pos1,...e.pos2)&&(e.unrestrictedPremoves||!U(e)||ge(e)),io=e=>pe(...e.pos1,...e.pos2)&&Ae(e)&&(e.unrestrictedPremoves||!U(e)||ge(e)),ao=e=>ue(...e.pos1,...e.pos2)&&Ae(e)&&(e.unrestrictedPremoves||!U(e)||ge(e)),pn=e=>io(e)||ao(e),fn=e=>De(...e.pos1,...e.pos2)&&(e.unrestrictedPremoves||!U(e)||ge(e))||e.canCastle&&e.pos1[1]===e.pos2[1]&&e.pos1[1]===(e.color==="white"?0:7)&&(e.pos1[0]===4&&(e.pos2[0]===2&&e.rookFilesFriendlies.includes(0)||e.pos2[0]===6&&e.rookFilesFriendlies.includes(7))||e.rookFilesFriendlies.includes(e.pos2[0]))&&(e.unrestrictedPremoves||Y(...e.pos1,e.pos2[0]>e.pos1[0]?7:1,e.pos2[1]).map(o=>e.allPieces.get(o)).every(o=>!o||W(o,{role:"rook",color:e.color}))),gn={pawn:dn,knight:un,bishop:io,rook:ao,queen:pn,king:fn};function Ne(e,o){let n=e.pieces,r=e.premovable.castle,t=!!e.premovable.unrestrictedPremoves,i=n.get(o);if(!i||i.color===e.turnColor)return[];let s=i.color,d=new Map([...n].filter(([p,m])=>m.color===s)),l=new Map([...n].filter(([p,m])=>m.color===j(s))),a=f(o),c=gn[i.role],u={pos1:a,allPieces:n,friendlies:d,enemies:l,unrestrictedPremoves:t,color:s,canCastle:r,rookFilesFriendlies:Array.from(n).filter(([p,m])=>p[1]===(s==="white"?"1":"8")&&m.color===s&&m.role==="rook").map(([p])=>f(p)[0]),lastMove:e.lastMove};return ce.filter(p=>c({...u,pos2:p})).map(h)}function M(e,...o){e&&setTimeout(()=>e(...o),1)}function so(e){e.orientation=j(e.orientation),e.animation.current=e.draggable.current=e.selected=void 0}function co(e,o){for(let[n,r]of o)r?e.pieces.set(n,r):e.pieces.delete(n)}function lo(e,o){if(e.check=void 0,o===!0&&(o=e.turnColor),o)for(let[n,r]of e.pieces)r.role==="king"&&r.color===o&&(e.check=n)}function mn(e,o,n,r){x(e),e.premovable.current=[o,n],M(e.premovable.events.set,o,n,r)}function E(e){e.premovable.current&&(e.premovable.current=void 0,M(e.premovable.events.unset))}function hn(e,o,n){E(e),e.predroppable.current={role:o,key:n},M(e.predroppable.events.set,o,n)}function x(e){let o=e.predroppable;o.current&&(o.current=void 0,M(o.events.unset))}function bn(e,o,n){if(!e.autoCastle)return!1;let r=e.pieces.get(o);if(!r||r.role!=="king")return!1;let t=f(o),i=f(n);if(t[1]!==0&&t[1]!==7||t[1]!==i[1])return!1;t[0]===4&&!e.pieces.has(n)&&(i[0]===6?n=h([7,i[1]]):i[0]===2&&(n=h([0,i[1]])));let s=e.pieces.get(n);return!s||s.color!==r.color||s.role!=="rook"?!1:(e.pieces.delete(o),e.pieces.delete(n),t[0]<i[0]?(e.pieces.set(h([6,i[1]]),r),e.pieces.set(h([5,i[1]]),s)):(e.pieces.set(h([2,i[1]]),r),e.pieces.set(h([3,i[1]]),s)),!0)}function He(e,o,n){let r=e.pieces.get(o),t=e.pieces.get(n);if(o===n||!r)return!1;let i=t&&t.color!==r.color?t:void 0;return n===e.selected&&P(e),M(e.events.move,o,n,i),bn(e,o,n)||(e.pieces.set(n,r),e.pieces.delete(o)),e.lastMove=[o,n],e.check=void 0,M(e.events.change),i||!0}function he(e,o,n,r){if(e.pieces.has(n))if(r)e.pieces.delete(n);else return!1;return M(e.events.dropNewPiece,o,n),e.pieces.set(n,o),e.lastMove=[n],e.check=void 0,M(e.events.change),e.movable.dests=void 0,e.turnColor=j(e.turnColor),!0}function uo(e,o,n){let r=He(e,o,n);return r&&(e.movable.dests=void 0,e.turnColor=j(e.turnColor),e.animation.current=void 0),r}function qe(e,o,n){if(ve(e,o,n)){let r=uo(e,o,n);if(r){let t=e.hold.stop();P(e);let i={premove:!1,ctrlKey:e.stats.ctrlKey,holdTime:t};return r!==!0&&(i.captured=r),M(e.movable.events.after,o,n,i),!0}}else if(yn(e,o,n))return mn(e,o,n,{ctrlKey:e.stats.ctrlKey}),P(e),!0;return P(e),!1}function be(e,o,n,r){let t=e.pieces.get(o);t&&(vn(e,o,n)||r)?(e.pieces.delete(o),he(e,t,n,r),M(e.movable.events.afterNewPiece,t.role,n,{premove:!1,predrop:!1})):t&&wn(e,o,n)?hn(e,t.role,n):(E(e),x(e)),e.pieces.delete(o),P(e)}function oe(e,o,n){if(M(e.events.select,o),e.selected){if(e.selected===o&&!e.draggable.enabled){P(e),e.hold.cancel();return}else if((e.selectable.enabled||n)&&e.selected!==o&&qe(e,e.selected,o)){e.stats.dragged=!1;return}}(e.selectable.enabled||e.draggable.enabled)&&(po(e,o)||Be(e,o))&&(Te(e,o),e.hold.start())}function Te(e,o){e.selected=o,Be(e,o)?e.premovable.customDests||(e.premovable.dests=Ne(e,o)):e.premovable.dests=void 0}function P(e){e.selected=void 0,e.premovable.dests=void 0,e.hold.cancel()}function po(e,o){let n=e.pieces.get(o);return!!n&&(e.movable.color==="both"||e.movable.color===n.color&&e.turnColor===n.color)}var ve=(e,o,n)=>o!==n&&po(e,o)&&(e.movable.free||!!e.movable.dests?.get(o)?.includes(n));function vn(e,o,n){let r=e.pieces.get(o);return!!r&&(o===n||!e.pieces.has(n))&&(e.movable.color==="both"||e.movable.color===r.color&&e.turnColor===r.color)}function Be(e,o){let n=e.pieces.get(o);return!!n&&e.premovable.enabled&&e.movable.color===n.color&&e.turnColor!==n.color}var yn=(e,o,n)=>o!==n&&Be(e,o)&&(e.premovable.customDests?.get(o)??Ne(e,o)).includes(n);function wn(e,o,n){let r=e.pieces.get(o),t=e.pieces.get(n);return!!r&&(!t||t.color!==e.movable.color)&&e.predroppable.enabled&&(r.role!=="pawn"||n[1]!=="1"&&n[1]!=="8")&&e.movable.color===r.color&&e.turnColor!==r.color}function fo(e,o){let n=e.pieces.get(o);return!!n&&e.draggable.enabled&&(e.movable.color==="both"||e.movable.color===n.color&&(e.turnColor===n.color||e.premovable.enabled))}function go(e){let o=e.premovable.current;if(!o)return!1;let n=o[0],r=o[1],t=!1;if(ve(e,n,r)){let i=uo(e,n,r);if(i){let s={premove:!0};i!==!0&&(s.captured=i),M(e.movable.events.after,n,r,s),t=!0}}return E(e),t}function mo(e,o){let n=e.predroppable.current,r=!1;if(!n)return!1;if(o(n)){let t={role:n.role,color:e.movable.color};he(e,t,n.key)&&(M(e.movable.events.afterNewPiece,n.role,n.key,{premove:!1,predrop:!0}),r=!0)}return x(e),r}function ne(e){E(e),x(e),P(e)}function Oe(e){e.movable.color=e.movable.dests=e.animation.current=void 0,ne(e)}function A(e,o,n){let r=Math.floor(8*(e[0]-n.left)/n.width);o||(r=7-r);let t=7-Math.floor(8*(e[1]-n.top)/n.height);return o||(t=7-t),r>=0&&r<8&&t>=0&&t<8?h([r,t]):void 0}function ho(e,o,n,r){let t=f(e),i=ce.filter(a=>oo(t,a)||fe(t[0],t[1],a[0],a[1])||Q(t[0],t[1],a[0],a[1])),d=i.map(a=>de(h(a),n,r)).map(a=>L(o,a)),[,l]=d.reduce((a,c,u)=>a[0]<c?a:[c,u],[d[0],0]);return h(i[l])}var v=e=>e.orientation==="white";var Ve="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR",Sn={p:"pawn",r:"rook",n:"knight",b:"bishop",q:"queen",k:"king"},Pn={pawn:"p",rook:"r",knight:"n",bishop:"b",queen:"q",king:"k"};function ye(e){e==="start"&&(e=Ve);let o=new Map,n=7,r=0;for(let t of e)switch(t){case" ":case"[":return o;case"/":if(--n,n<0)return o;r=0;break;case"~":{let i=o.get(h([r-1,n]));i&&(i.promoted=!0);break}default:{let i=t.charCodeAt(0);if(i<57)r+=i-48;else{let s=t.toLowerCase(),d=h([r,n]);d&&o.set(d,{role:Sn[s],color:t===s?"black":"white"}),++r}}}return o}function bo(e){return Ye.map(o=>G.map(n=>{let r=e.get(n+o);if(r){let t=Pn[r.role];return r.color==="white"&&(t=t.toUpperCase()),r.promoted&&(t+="~"),t}else return"1"}).join("")).join("/").replace(/1{2,}/g,o=>o.length.toString())}function Le(e,o){o.animation&&(Fe(e.animation,o.animation),(e.animation.duration||0)<70&&(e.animation.enabled=!1))}function we(e,o){if(o.movable?.dests&&(e.movable.dests=void 0),o.drawable?.autoShapes&&(e.drawable.autoShapes=[]),Fe(e,o),o.fen&&(e.pieces=ye(o.fen),e.drawable.shapes=o.drawable?.shapes||[]),"check"in o&&lo(e,o.check||!1),"lastMove"in o&&!o.lastMove?e.lastMove=void 0:o.lastMove&&(e.lastMove=o.lastMove),e.selected&&Te(e,e.selected),Le(e,o),!e.movable.rookCastle&&e.movable.dests){let n=e.movable.color==="white"?"1":"8",r="e"+n,t=e.movable.dests.get(r),i=e.pieces.get(r);if(!t||!i||i.role!=="king")return;e.movable.dests.set(r,t.filter(s=>!(s==="a"+n&&t.includes("c"+n))&&!(s==="h"+n&&t.includes("g"+n))))}}function Fe(e,o){for(let n in o)n==="__proto__"||n==="constructor"||!Object.prototype.hasOwnProperty.call(o,n)||(Object.prototype.hasOwnProperty.call(e,n)&&vo(e[n])&&vo(o[n])?Fe(e[n],o[n]):e[n]=o[n])}function vo(e){if(typeof e!="object"||e===null)return!1;let o=Object.getPrototypeOf(e);return o===Object.prototype||o===null}var O=(e,o)=>o.animation.enabled?Dn(e,o):R(e,o);function R(e,o){let n=e(o);return o.dom.redraw(),n}var Ge=(e,o)=>({key:e,pos:f(e),piece:o}),kn=(e,o)=>o.sort((n,r)=>L(e.pos,n.pos)-L(e.pos,r.pos))[0];function Cn(e,o){let n=new Map,r=[],t=new Map,i=[],s=[],d=new Map,l,a,c;for(let[u,p]of e)d.set(u,Ge(u,p));for(let u of se)l=o.pieces.get(u),a=d.get(u),l?a?W(l,a.piece)||(i.push(a),s.push(Ge(u,l))):s.push(Ge(u,l)):a&&i.push(a);for(let u of s)a=kn(u,i.filter(p=>W(u.piece,p.piece))),a&&(c=[a.pos[0]-u.pos[0],a.pos[1]-u.pos[1]],n.set(u.key,c.concat(c)),r.push(a.key));for(let u of i)r.includes(u.key)||t.set(u.key,u.piece);return{anims:n,fadings:t}}function yo(e,o){let n=e.animation.current;if(n===void 0){e.dom.destroyed||e.dom.redrawNow();return}let r=1-(o-n.start)*n.frequency;if(r<=0)e.animation.current=void 0,e.dom.redrawNow();else{let t=Kn(r);for(let i of n.plan.anims.values())i[2]=i[0]*t,i[3]=i[1]*t;e.dom.redrawNow(!0),requestAnimationFrame((i=performance.now())=>yo(e,i))}}function Dn(e,o){let n=new Map(o.pieces),r=e(o),t=Cn(n,o);if(t.anims.size||t.fadings.size){let i=o.animation.current&&o.animation.current.start;o.animation.current={start:performance.now(),frequency:1/o.animation.duration,plan:t},i||yo(o,performance.now())}else o.dom.redraw();return r}var Kn=e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1;var En=["green","red","blue","yellow"];function wo(e,o){if(o.touches&&o.touches.length>1)return;o.stopPropagation(),o.preventDefault(),o.ctrlKey?P(e):ne(e);let n=T(o),r=A(n,v(e),e.dom.bounds());r&&(e.drawable.current={orig:r,pos:n,brush:xn(o),snapToValidMove:e.drawable.defaultSnapToValidMove},So(e))}function So(e){requestAnimationFrame(()=>{let o=e.drawable.current;if(o){let n=A(o.pos,v(e),e.dom.bounds());n||(o.snapToValidMove=!1);let r=o.snapToValidMove?ho(o.orig,o.pos,v(e),e.dom.bounds()):n;r!==o.mouseSq&&(o.mouseSq=r,o.dest=r!==o.orig?r:void 0,e.dom.redrawNow()),So(e)}})}function Po(e,o){e.drawable.current&&(e.drawable.current.pos=T(o))}function Mo(e){let o=e.drawable.current;o&&(o.mouseSq&&An(e.drawable,o),We(e))}function We(e){e.drawable.current&&(e.drawable.current=void 0,e.dom.redraw())}function ko(e){e.drawable.shapes.length&&(e.drawable.shapes=[],e.dom.redraw(),Co(e.drawable))}function xn(e){let o=(e.shiftKey||e.ctrlKey)&&le(e),n=e.altKey||e.metaKey||e.getModifierState?.("AltGraph");return En[(o?1:0)+(n?2:0)]}function An(e,o){let n=t=>t.orig===o.orig&&t.dest===o.dest,r=e.shapes.find(n);r&&(e.shapes=e.shapes.filter(t=>!n(t))),(!r||r.brush!==o.brush)&&e.shapes.push({orig:o.orig,dest:o.dest,brush:o.brush}),Co(e)}function Co(e){e.onChange&&e.onChange(e.shapes)}function Do(e,o){if(!(e.trustAllEvents||o.isTrusted)||o.buttons!==void 0&&o.buttons>1||o.touches&&o.touches.length>1)return;let n=e.dom.bounds(),r=T(o),t=A(r,v(e),n);if(!t)return;let i=e.pieces.get(t),s=e.selected;if(!s&&e.drawable.enabled&&(e.drawable.eraseOnClick||!i||i.color!==e.turnColor)&&ko(e),o.cancelable!==!1&&(!o.touches||e.blockTouchScroll||i||s||Hn(e,r)))o.preventDefault();else if(o.touches)return;let d=!!e.premovable.current,l=!!e.predroppable.current;e.stats.ctrlKey=o.ctrlKey,e.selected&&ve(e,e.selected,t)?O(u=>oe(u,t),e):oe(e,t);let a=e.selected===t,c=No(e,t);if(i&&c&&a&&fo(e,t)){e.draggable.current={orig:t,piece:i,origPos:r,pos:r,started:e.draggable.autoDistance&&e.stats.dragged,element:c,previouslySelected:s,originTarget:o.target,keyHasChanged:!1},c.cgDragging=!0,c.classList.add("dragging");let u=e.dom.elements.ghost;u&&(u.className=`ghost ${i.color} ${i.role}`,k(u,F(n)(f(t),v(e))),_(u,!0)),ze(e)}else d&&E(e),l&&x(e);e.dom.redraw()}function Hn(e,o){let n=v(e),r=e.dom.bounds(),t=Math.pow(e.touchIgnoreRadius*r.width/16,2)*2;for(let i of e.pieces.keys()){let s=de(i,n,r);if(L(s,o)<=t)return!0}return!1}function Ko(e,o,n,r){let t="a0";e.pieces.set(t,o),e.dom.redraw();let i=T(n);e.draggable.current={orig:t,piece:o,origPos:i,pos:i,started:!0,element:()=>No(e,t),originTarget:n.target,newPiece:!0,force:!!r,keyHasChanged:!1},ze(e)}function ze(e){requestAnimationFrame(()=>{let o=e.draggable.current;if(!o)return;e.animation.current?.plan.anims.has(o.orig)&&(e.animation.current=void 0);let n=e.pieces.get(o.orig);if(!n||!W(n,o.piece))z(e);else if(!o.started&&L(o.pos,o.origPos)>=Math.pow(e.draggable.distance,2)&&(o.started=!0),o.started){if(typeof o.element=="function"){let t=o.element();if(!t)return;t.cgDragging=!0,t.classList.add("dragging"),o.element=t}let r=e.dom.bounds();k(o.element,[o.pos[0]-r.left-r.width/16,o.pos[1]-r.top-r.height/16]),o.keyHasChanged||=o.orig!==A(o.pos,v(e),r)}ze(e)})}function Eo(e,o){e.draggable.current&&(!o.touches||o.touches.length<2)&&(e.draggable.current.pos=T(o))}function xo(e,o){let n=e.draggable.current;if(!n)return;if(o.type==="touchend"&&o.cancelable!==!1&&o.preventDefault(),o.type==="touchend"&&n.originTarget!==o.target&&!n.newPiece){e.draggable.current=void 0;return}E(e),x(e);let r=T(o)||n.pos,t=A(r,v(e),e.dom.bounds());t&&n.started&&n.orig!==t?n.newPiece?be(e,n.orig,t,n.force):(e.stats.ctrlKey=o.ctrlKey,qe(e,n.orig,t)&&(e.stats.dragged=!0)):n.newPiece?e.pieces.delete(n.orig):e.draggable.deleteOnDropOff&&!t&&(e.pieces.delete(n.orig),M(e.events.change)),(n.orig===n.previouslySelected||n.keyHasChanged)&&(n.orig===t||!t)?P(e):e.selectable.enabled||P(e),Ao(e),e.draggable.current=void 0,e.dom.redraw()}function z(e){let o=e.draggable.current;o&&(o.newPiece&&e.pieces.delete(o.orig),e.draggable.current=void 0,P(e),Ao(e),e.dom.redraw())}function Ao(e){let o=e.dom.elements;o.ghost&&_(o.ghost,!1)}function No(e,o){let n=e.dom.elements.board.firstChild;for(;n;){if(n.cgKey===o&&n.tagName==="PIECE")return n;n=n.nextSibling}}function qo(e,o){e.exploding={stage:1,keys:o},e.dom.redraw(),setTimeout(()=>{Ho(e,2),setTimeout(()=>Ho(e,void 0),120)},120)}function Ho(e,o){e.exploding&&(o?e.exploding.stage=o:e.exploding=void 0,e.dom.redraw())}function To(e,o){function n(){so(e),o()}return{set(r){r.orientation&&r.orientation!==e.orientation&&n(),Le(e,r),(r.fen?O:R)(t=>we(t,r),e)},state:e,getFen:()=>bo(e.pieces),toggleOrientation:n,setPieces(r){O(t=>co(t,r),e)},selectSquare(r,t){r?O(i=>oe(i,r,t),e):e.selected&&(P(e),e.dom.redraw())},move(r,t){O(i=>He(i,r,t),e)},newPiece(r,t){O(i=>he(i,r,t),e)},playPremove(){if(e.premovable.current){if(O(go,e))return!0;e.dom.redraw()}return!1},playPredrop(r){if(e.predroppable.current){let t=mo(e,r);return e.dom.redraw(),t}return!1},cancelPremove(){R(E,e)},cancelPredrop(){R(x,e)},cancelMove(){R(r=>{ne(r),z(r)},e)},stop(){R(r=>{Oe(r),z(r)},e)},explode(r){qo(e,r)},setAutoShapes(r){R(t=>t.drawable.autoShapes=r,e)},setShapes(r){R(t=>t.drawable.shapes=r.slice(),e)},getKeyAtDomPos(r){return A(r,v(e),e.dom.bounds())},redrawAll:o,dragNewPiece(r,t,i){Ko(e,r,t,i)},destroy(){Oe(e),e.dom.unbind&&e.dom.unbind(),e.dom.destroyed=!0}}}function Bo(){return{pieces:ye(Ve),orientation:"white",turnColor:"white",coordinates:!0,coordinatesOnSquares:!1,ranksPosition:"right",autoCastle:!0,viewOnly:!1,disableContextMenu:!1,addPieceZIndex:!1,blockTouchScroll:!1,touchIgnoreRadius:1,pieceKey:!1,trustAllEvents:!1,highlight:{lastMove:!0,check:!0},animation:{enabled:!0,duration:200},movable:{free:!0,color:"both",showDests:!0,events:{},rookCastle:!0},premovable:{enabled:!0,showDests:!0,castle:!0,events:{}},predroppable:{enabled:!1,events:{}},draggable:{enabled:!0,distance:3,autoDistance:!0,showGhost:!0,deleteOnDropOff:!1},dropmode:{active:!1},selectable:{enabled:!0},stats:{dragged:!("ontouchstart"in window)},events:{},drawable:{enabled:!0,visible:!0,defaultSnapToValidMove:!0,eraseOnClick:!0,shapes:[],autoShapes:[],brushes:{green:{key:"g",color:"#15781B",opacity:1,lineWidth:10},red:{key:"r",color:"#882020",opacity:1,lineWidth:10},blue:{key:"b",color:"#003088",opacity:1,lineWidth:10},yellow:{key:"y",color:"#e68f00",opacity:1,lineWidth:10},paleBlue:{key:"pb",color:"#003088",opacity:.4,lineWidth:15},paleGreen:{key:"pg",color:"#15781B",opacity:.4,lineWidth:15},paleRed:{key:"pr",color:"#882020",opacity:.4,lineWidth:15},paleGrey:{key:"pgr",color:"#4a4a4a",opacity:.35,lineWidth:15},purple:{key:"purple",color:"#68217a",opacity:.65,lineWidth:10},pink:{key:"pink",color:"#ee2080",opacity:.5,lineWidth:10},white:{key:"white",color:"white",opacity:1,lineWidth:10},paleWhite:{key:"pwhite",color:"white",opacity:.6,lineWidth:10}},prevSvgHash:""},hold:eo()}}function Vo(){let e=w("defs"),o=S(w("filter"),{id:"cg-filter-blur"});return o.appendChild(S(w("feGaussianBlur"),{stdDeviation:"0.013"})),e.appendChild(o),e}function Lo(e,o){let n=e.drawable,r=n.current,t=r&&r.mouseSq?r:void 0,i=new Map,s=e.dom.bounds(),d=n.autoShapes.filter(c=>!c.piece);for(let c of n.shapes.concat(d).concat(t?[t]:[])){if(!c.dest)continue;let u=i.get(c.dest)??new Set,p=Pe(Se(f(c.orig),e.orientation),s),m=Pe(Se(f(c.dest),e.orientation),s);u.add(Ie(p,m)),i.set(c.dest,u)}let l=[];for(let c of n.shapes.concat(d))l.push({shape:c,current:!1,hash:Oo(c,$e(c.dest,i),!1,s)});t&&l.push({shape:t,current:!0,hash:Oo(t,$e(t.dest,i),!0,s)});let a=l.map(c=>c.hash).join(";");a!==e.drawable.prevSvgHash&&(e.drawable.prevSvgHash=a,Tn(n,l,o),Bn(l,o,c=>Vn(e,c,n.brushes,i,s)))}function Tn(e,o,n){for(let r of[n.shapes,n.shapesBelow]){let t=r.querySelector("defs"),i=o.filter(a=>r===n.shapesBelow==!!a.shape.below),s=new Map;for(let a of i.filter(c=>c.shape.dest&&c.shape.brush)){let c=Fo(e.brushes[a.shape.brush],a.shape.modifiers),{key:u,color:p}=Go(a.shape);u&&p&&s.set(u,{key:u,color:p,opacity:1,lineWidth:1}),s.set(c.key,c)}let d=new Set,l=t.firstElementChild;for(;l;)d.add(l.getAttribute("cgKey")),l=l.nextElementSibling;for(let[a,c]of s.entries())d.has(a)||t.appendChild(Gn(c))}}function Bn(e,o,n){for(let[r,t]of[[o.shapes,o.custom],[o.shapesBelow,o.customBelow]]){let[i,s]=[r,t].map(a=>a.querySelector("g")),d=e.filter(a=>r===o.shapesBelow==!!a.shape.below),l=new Map;for(let a of d)l.set(a.hash,!1);for(let a of[i,s]){let c=[],u=a.firstElementChild,p;for(;u;)p=u.getAttribute("cgHash"),l.has(p)?l.set(p,!0):c.push(u),u=u.nextElementSibling;for(let m of c)a.removeChild(m)}for(let a of d.filter(c=>!l.get(c.hash)))for(let c of n(a))c.isCustom?s.appendChild(c.el):i.appendChild(c.el)}}function Oo({orig:e,dest:o,brush:n,piece:r,modifiers:t,customSvg:i,label:s,below:d},l,a,c){return[c.width,c.height,a,e,o,n,l&&"-",r&&On(r),t&&Rn(t),i&&`custom-${Ro(i.html)},${i.center?.[0]??"o"}`,s&&`label-${Ro(s.text)}`,d&&"below"].filter(u=>u).join(",")}function On(e){return[e.color,e.role,e.scale].filter(o=>o).join(",")}function Rn(e){return[e.lineWidth,e.hilite].filter(o=>o).join(",")}function Ro(e){let o=0;for(let n=0;n<e.length;n++)o=(o<<5)-o+e.charCodeAt(n)>>>0;return o.toString()}function Vn(e,{shape:o,current:n,hash:r},t,i,s){let d=Pe(Se(f(o.orig),e.orientation),s),l=o.dest?Pe(Se(f(o.dest),e.orientation),s):d,a=o.brush&&Fo(t[o.brush],o.modifiers),c=i.get(o.dest),u=[];if(a){let p=S(w("g"),{cgHash:r});u.push({el:p}),d[0]!==l[0]||d[1]!==l[1]?p.appendChild(Fn(o,a,d,l,n,$e(o.dest,i))):p.appendChild(Ln(t[o.brush],d,n,s))}if(o.label){let p=o.label;p.fill??=o.brush&&t[o.brush].color;let m=o.brush?void 0:"tr";u.push({el:Wn(p,r,d,l,c,m),isCustom:!0})}if(o.customSvg){let p=o.customSvg.center??"orig",[m,y]=p==="label"?zo(d,l,c).map(B=>B-.5):p==="dest"?l:d,g=S(w("g"),{transform:`translate(${m},${y})`,cgHash:r});g.innerHTML=`<svg width="1" height="1" viewBox="0 0 100 100">${o.customSvg.html}</svg>`,u.push({el:g,isCustom:!0})}return u}function Ln(e,o,n,r){let t=zn(),i=(r.width+r.height)/(4*Math.max(r.width,r.height));return S(w("circle"),{stroke:e.color,"stroke-width":t[n?0:1],fill:"none",opacity:Wo(e,n),cx:o[0],cy:o[1],r:i-t[1]/2})}function Fn(e,o,n,r,t,i){function s(a){let c=In(i&&!t),u=r[0]-n[0],p=r[1]-n[1],m=Math.atan2(p,u),y=Math.cos(m)*c,g=Math.sin(m)*c,B=Go(e);return S(w("line"),{stroke:a?B.color:o.color,"stroke-width":$n(o,t)*(a?1.14:1),"stroke-linecap":"round","marker-end":`url(#arrowhead-${a?B.key:o.key})`,opacity:e.modifiers?.hilite?1:Wo(o,t),x1:n[0],y1:n[1],x2:r[0]-y,y2:r[1]-g})}if(!e.modifiers?.hilite)return s(!1);let d=S(w("g"),{opacity:o.opacity}),l=S(w("g"),{filter:"url(#cg-filter-blur)"});return l.appendChild(jn(n,r)),l.appendChild(s(!0)),d.appendChild(l),d.appendChild(s(!1)),d}function Gn(e){let o=S(w("marker"),{id:"arrowhead-"+e.key,orient:"auto",overflow:"visible",markerWidth:4,markerHeight:4,refX:e.key.startsWith("hilite")?1.86:2.05,refY:2});return o.appendChild(S(w("path"),{d:"M0,0 V4 L3,2 Z",fill:e.color})),o.setAttribute("cgKey",e.key),o}function Wn(e,o,n,r,t,i){let d=.4*.75**e.text.length,l=zo(n,r,t),a=i==="tr"?.4:0,c=S(w("g"),{transform:`translate(${l[0]+a},${l[1]-a})`,cgHash:o});c.appendChild(S(w("circle"),{r:.4/2,"fill-opacity":i?1:.8,"stroke-opacity":i?1:.7,"stroke-width":.03,fill:e.fill??"#666",stroke:"white"}));let u=S(w("text"),{"font-size":d,"font-family":"Noto Sans","text-anchor":"middle",fill:"white",y:.13*.75**e.text.length});return u.innerHTML=e.text,c.appendChild(u),c}function Se(e,o){return o==="white"?e:[7-e[0],7-e[1]]}function $e(e,o){return(e&&o.has(e)&&o.get(e).size>1)===!0}function w(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function S(e,o){for(let n in o)Object.prototype.hasOwnProperty.call(o,n)&&e.setAttribute(n,o[n]);return e}function Fo(e,o){return o?{color:e.color,opacity:Math.round(e.opacity*10)/10,lineWidth:Math.round(o.lineWidth||e.lineWidth),key:[e.key,o.lineWidth].filter(n=>n).join("")}:e}function zn(){return[3/64,4/64]}function $n(e,o){return(e.lineWidth||10)*(o?.85:1)/64}function Go(e){let o=e.modifiers?.hilite;return{key:o&&`hilite-${o.replace("#","")}`,color:o}}function Wo(e,o){return(e.opacity||1)*(o?.9:1)}function In(e){return(e?20:10)/64}function Pe(e,o){let n=Math.min(1,o.width/o.height),r=Math.min(1,o.height/o.width);return[(e[0]-3.5)*n,(3.5-e[1])*r]}function jn(e,o){let n={from:[Math.floor(Math.min(e[0],o[0])),Math.floor(Math.min(e[1],o[1]))],to:[Math.ceil(Math.max(e[0],o[0])),Math.ceil(Math.max(e[1],o[1]))]};return S(w("rect"),{x:n.from[0],y:n.from[1],width:n.to[0]-n.from[0],height:n.to[1]-n.from[1],fill:"none",stroke:"none"})}function Ie(e,o,n=!0){let r=Math.atan2(o[1]-e[1],o[0]-e[0])+Math.PI;return n?(Math.round(r*8/Math.PI)+16)%16:r}function Un(e,o){return Math.sqrt([e[0]-o[0],e[1]-o[1]].reduce((n,r)=>n+r*r,0))}function zo(e,o,n){let r=Un(e,o),t=Ie(e,o,!1);if(n&&(r-=33/64,n.size>1)){r-=10/64;let i=Ie(e,o);(n.has((i+1)%16)||n.has((i+15)%16))&&i&1&&(r-=.4)}return[e[0]-Math.cos(t)*r,e[1]-Math.sin(t)*r].map(i=>i+.5)}function Io(e,o){e.innerHTML="",e.classList.add("cg-wrap");for(let c of _e)e.classList.toggle("orientation-"+c,o.orientation===c);e.classList.toggle("manipulable",!o.viewOnly);let n=C("cg-container");e.appendChild(n);let r=C("cg-board");n.appendChild(r);let t,i,s,d,l;if(o.drawable.visible&&([t,i]=["cg-shapes-below","cg-shapes"].map(c=>$o(c,!0)),[s,d]=["cg-custom-below","cg-custom-svgs"].map(c=>$o(c,!1)),l=C("cg-auto-pieces"),n.appendChild(t),n.appendChild(s),n.appendChild(i),n.appendChild(d),n.appendChild(l)),o.coordinates){let c=o.orientation==="black"?" black":"",u=o.ranksPosition==="left"?" left":"";if(o.coordinatesOnSquares){let p=o.orientation==="white"?m=>m+1:m=>8-m;G.forEach((m,y)=>n.appendChild(je(I.map(g=>m+g),"squares rank"+p(y)+c+u)))}else n.appendChild(je(I,"ranks"+c+u)),n.appendChild(je(G,"files"+c))}let a;return o.draggable.enabled&&o.draggable.showGhost&&(a=C("piece","ghost"),_(a,!1),n.appendChild(a)),{board:r,container:n,wrap:e,ghost:a,shapes:i,shapesBelow:t,custom:d,customBelow:s,autoPieces:l}}function $o(e,o){let n=S(w("svg"),{class:e,viewBox:o?"-4 -4 8 8":"-3.5 -3.5 8 8",preserveAspectRatio:"xMidYMid slice"});return n.appendChild(w("g")),o&&n.appendChild(Vo()),n}function je(e,o){let n=C("coords",o),r;for(let t of e)r=C("coord"),r.textContent=t,n.appendChild(r);return n}function jo(e,o){if(!e.dropmode.active)return;E(e),x(e);let n=e.dropmode.piece;if(n){e.pieces.set("a0",n);let r=T(o),t=r&&A(r,v(e),e.dom.bounds());t&&be(e,"a0",t)}e.dom.redraw()}function Zo(e,o){let n=e.dom.elements.board;if("ResizeObserver"in window&&new ResizeObserver(o).observe(e.dom.elements.wrap),(e.disableContextMenu||e.drawable.enabled)&&n.addEventListener("contextmenu",t=>t.preventDefault()),e.viewOnly)return;let r=Xn(e);n.addEventListener("touchstart",r,{passive:!1}),n.addEventListener("mousedown",r,{passive:!1})}function Xo(e,o){let n=[];if("ResizeObserver"in window||n.push(re(document.body,"chessground.resize",o)),!e.viewOnly){let r=Uo(e,Eo,Po),t=Uo(e,xo,Mo);for(let s of["touchmove","mousemove"])n.push(re(document,s,r));for(let s of["touchend","mouseup"])n.push(re(document,s,t));let i=()=>e.dom.bounds.clear();n.push(re(document,"scroll",i,{capture:!0,passive:!0})),n.push(re(window,"resize",i,{passive:!0}))}return()=>n.forEach(r=>r())}function re(e,o,n,r){return e.addEventListener(o,n,r),()=>e.removeEventListener(o,n,r)}var Xn=e=>o=>{e.draggable.current?z(e):e.drawable.current?We(e):o.shiftKey||le(o)?e.drawable.enabled&&wo(e,o):e.viewOnly||(e.dropmode.active?jo(e,o):Do(e,o))},Uo=(e,o,n)=>r=>{e.drawable.current?e.drawable.enabled&&n(e,r):e.viewOnly||o(e,r)};function Qo(e){let o=v(e),n=F(e.dom.bounds()),r=e.dom.elements.board,t=e.pieces,i=e.animation.current,s=i?i.plan.anims:new Map,d=i?i.plan.fadings:new Map,l=e.draggable.current,a=Qn(e),c=new Set,u=new Set,p=new Map,m=new Map,y,g,B,$,D,Z,Me,N,ke,ie;for(g=r.firstChild;g;){if(y=g.cgKey,Jo(g))if(B=t.get(y),D=s.get(y),Z=d.get(y),$=g.cgPiece,g.cgDragging&&(!l||l.orig!==y)&&(g.classList.remove("dragging"),k(g,n(f(y),o)),g.cgDragging=!1),!Z&&g.cgFading&&(g.cgFading=!1,g.classList.remove("fading")),B){if(D&&g.cgAnimating&&$===te(B)){let b=f(y);b[0]+=D[2],b[1]+=D[3],g.classList.add("anim"),k(g,n(b,o))}else g.cgAnimating&&(g.cgAnimating=!1,g.classList.remove("anim"),k(g,n(f(y),o)),e.addPieceZIndex&&(g.style.zIndex=Ue(f(y),o)));$===te(B)&&(!Z||!g.cgFading)?c.add(y):Z&&$===te(Z)?(g.classList.add("fading"),g.cgFading=!0):Ze(p,$,g)}else Ze(p,$,g);else if(en(g)){let b=g.className;a.get(y)===b?u.add(y):Ze(m,b,g)}g=g.nextSibling}for(let[b,X]of a)if(!u.has(b)){ke=m.get(X),ie=ke&&ke.pop();let H=n(f(b),o);if(ie)ie.cgKey=b,k(ie,H);else{let q=C("square",X);q.cgKey=b,k(q,H),r.insertBefore(q,r.firstChild)}}for(let[b,X]of t)if(D=s.get(b),!c.has(b))if(Me=p.get(te(X)),N=Me&&Me.pop(),N){N.cgKey=b,N.cgFading&&(N.classList.remove("fading"),N.cgFading=!1);let H=f(b);e.addPieceZIndex&&(N.style.zIndex=Ue(H,o)),D&&(N.cgAnimating=!0,N.classList.add("anim"),H[0]+=D[2],H[1]+=D[3]),k(N,n(H,o))}else{let H=te(X),q=C("piece",H),ae=f(b);q.cgPiece=H,q.cgKey=b,D&&(q.cgAnimating=!0,ae[0]+=D[2],ae[1]+=D[3]),k(q,n(ae,o)),e.addPieceZIndex&&(q.style.zIndex=Ue(ae,o)),r.appendChild(q)}for(let b of p.values())_o(e,b);for(let b of m.values())_o(e,b)}function Yo(e){let o=v(e),n=F(e.dom.bounds()),r=e.dom.elements.board.firstChild;for(;r;)(Jo(r)&&!r.cgAnimating||en(r))&&k(r,n(f(r.cgKey),o)),r=r.nextSibling}function Xe(e){let o=e.dom.elements.wrap.getBoundingClientRect(),n=e.dom.elements.container,r=o.height/o.width,t=Math.floor(o.width*window.devicePixelRatio/8)*8/window.devicePixelRatio,i=t*r;n.style.width=t+"px",n.style.height=i+"px",e.dom.bounds.clear(),e.addDimensionsCssVarsTo?.style.setProperty("---cg-width",t+"px"),e.addDimensionsCssVarsTo?.style.setProperty("---cg-height",i+"px")}var Jo=e=>e.tagName==="PIECE",en=e=>e.tagName==="SQUARE";function _o(e,o){for(let n of o)e.dom.elements.board.removeChild(n)}function Ue(e,o){let r=e[1];return`${o?10-r:3+r}`}var te=e=>`${e.color} ${e.role}`;function Qn(e){let o=new Map;if(e.lastMove&&e.highlight.lastMove)for(let t of e.lastMove)V(o,t,"last-move");if(e.check&&e.highlight.check&&V(o,e.check,"check"),e.selected&&(V(o,e.selected,"selected"),e.movable.showDests)){let t=e.movable.dests?.get(e.selected);if(t)for(let s of t)V(o,s,"move-dest"+(e.pieces.has(s)?" oc":""));let i=e.premovable.customDests?.get(e.selected)??e.premovable.dests;if(i)for(let s of i)V(o,s,"premove-dest"+(e.pieces.has(s)?" oc":""))}let n=e.premovable.current;if(n)for(let t of n)V(o,t,"current-premove");else e.predroppable.current&&V(o,e.predroppable.current.key,"current-premove");let r=e.exploding;if(r)for(let t of r.keys)V(o,t,"exploding"+r.stage);return e.highlight.custom&&e.highlight.custom.forEach((t,i)=>{V(o,i,t)}),o}function V(e,o,n){let r=e.get(o);r?e.set(o,`${r} ${n}`):e.set(o,n)}function Ze(e,o,n){let r=e.get(o);r?r.push(n):e.set(o,[n])}function on(e,o,n){let r=new Map,t=[];for(let d of e)r.set(d.hash,!1);let i=o.firstElementChild,s;for(;i;)s=i.getAttribute("cgHash"),r.has(s)?r.set(s,!0):t.push(i),i=i.nextElementSibling;for(let d of t)o.removeChild(d);for(let d of e)r.get(d.hash)||o.appendChild(n(d))}function nn(e,o){let r=e.drawable.autoShapes.filter(t=>t.piece).map(t=>({shape:t,hash:Jn(t),current:!1}));on(r,o,t=>Yn(e,t,e.dom.bounds()))}function rn(e){let o=v(e),n=F(e.dom.bounds()),r=e.dom.elements.autoPieces?.firstChild;for(;r;)Ce(r,n(f(r.cgKey),o),r.cgScale),r=r.nextSibling}function Yn(e,{shape:o,hash:n},r){let t=o.orig,i=o.piece?.role,s=o.piece?.color,d=o.piece?.scale,l=C("piece",`${i} ${s}`);return l.setAttribute("cgHash",n),l.cgKey=t,l.cgScale=d,Ce(l,F(r)(f(t),v(e)),d),l}var Jn=e=>[e.orig,e.piece?.role,e.piece?.color,e.piece?.scale].join(",");function Jr({el:e,config:o}){return or(e,o)}function or(e,o){let n=Bo();we(n,o||{});function r(){let t="dom"in n?n.dom.unbind:void 0,i=Io(e,n),s=Je(()=>i.board.getBoundingClientRect()),d=c=>{Qo(a),i.autoPieces&&nn(a,i.autoPieces),!c&&i.shapes&&Lo(a,i)},l=()=>{Xe(a),Yo(a),i.autoPieces&&rn(a)},a=n;return a.dom={elements:i,bounds:s,redraw:nr(d),redrawNow:d,unbind:t},a.drawable.prevSvgHash="",Xe(a),d(!1),Zo(a,l),t||(a.dom.unbind=Xo(a,l)),a.events.insert&&a.events.insert(i),a}return To(r(),r)}function nr(e){let o=!1;return()=>{o||(o=!0,requestAnimationFrame(()=>{e(),o=!1}))}}export{or as Chessground,Jr as initModule};
|
|
1
|
+
var _e=["white","black"];var G=["a","b","c","d","e","f","g","h"],I=["1","2","3","4","5","6","7","8"];var Ye=[...I].reverse(),se=G.flatMap(e=>I.map(o=>e+o)),h=e=>se[8*e[0]+e[1]],f=e=>[e.charCodeAt(0)-97,e.charCodeAt(1)-49];var ce=se.map(f);function Je(e){let o,n=()=>(o===void 0&&(o=e()),o);return n.clear=()=>{o=void 0},n}var eo=()=>{let e;return{start(){e=performance.now()},cancel(){e=void 0},stop(){if(!e)return 0;let o=performance.now()-e;return e=void 0,o}}},j=e=>e==="white"?"black":"white",L=(e,o)=>(e[0]-o[0])**2+(e[1]-o[1])**2,W=(e,o)=>e.role===o.role&&e.color===o.color,oo=(e,o)=>e[0]===o[0]&&e[1]===o[1],F=e=>(o,n)=>[(n?o[0]:7-o[0])*e.width/8,(n?7-o[1]:o[1])*e.height/8],k=(e,o)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px)`},Ce=(e,o,n=1)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px) scale(${n})`},_=(e,o)=>{e.style.visibility=o?"visible":"hidden"},T=e=>{if(e.clientX||e.clientX===0)return[e.clientX,e.clientY];if(e.targetTouches?.[0])return[e.targetTouches[0].clientX,e.targetTouches[0].clientY]},le=e=>e.button===2,C=(e,o)=>{let n=document.createElement(e);return o&&(n.className=o),n};function de(e,o,n){let r=f(e);return o||(r[0]=7-r[0],r[1]=7-r[1]),[n.left+n.width*r[0]/8+n.width/16,n.top+n.height*(7-r[1])/8+n.height/16]}var K=(e,o)=>Math.abs(e-o),Q=(e,o,n,r)=>K(e,n)*K(o,r)===2,ue=(e,o,n,r)=>e===n!=(o===r),pe=(e,o,n,r)=>K(e,n)===K(o,r)&&e!==n,fe=(e,o,n,r)=>ue(e,o,n,r)||pe(e,o,n,r),De=(e,o,n,r)=>Math.max(K(e,n),K(o,r))===1,Ke=(e,o,n,r,t)=>K(e,n)===1&&r===o+(t?1:-1),Ee=(e,o,n,r,t)=>{let i=t?1:-1;return e===n&&(r===o+i||r===o+2*i&&(t?o<=1:o>=6))},Y=(e,o,n,r)=>{let t=n-e,i=r-o;if(t&&i&&Math.abs(t)!==Math.abs(i))return[];let s=Math.sign(t),d=Math.sign(i),l=[],a=e+s,c=o+d;for(;a!==n||c!==r;)l.push([a,c]),a+=s,c+=d;return l.map(u=>h(u))},no=e=>{let o=f(e),n=[];return o[0]>0&&n.push([o[0]-1,o[1]]),o[0]<7&&n.push([o[0]+1,o[1]]),n.map(h)},J=(e,o)=>{let n=f(e);return n[1]+=o,h(n)};var U=e=>e.friendlies.has(h(e.pos2)),tn=e=>e.enemies.has(h(e.pos2)),ro=(e,o,n)=>Y(...e,...o).some(r=>n.has(r)),to=(e,o,n)=>{let r=n.enemies.get(e);if(r?.role!=="pawn")return!1;let t=r.color==="white"?1:-1,i=f(e),s=f(o);return Ee(...i,...s,r.color==="white")&&!ro(i,[s[0],s[1]+t],n.allPieces)},an=(e,o,n)=>{let r=n.enemies.get(e);return r?.role==="pawn"&&Ke(...f(e),...f(o),r.color==="white")&&(n.friendlies.has(o)||me(J(o,r.color==="white"?-1:1),n.friendlies,n.enemies,n.lastMove))},sn=e=>[...e.enemies.keys()].some(o=>to(o,h(e.pos2),e)),xe=(e,o)=>{let n=e.pos2;return[...e.enemies].some(([r,t])=>{let i=f(r);return!o?.includes(t.role)&&(t.role==="pawn"&&Ke(...i,...n,t.color==="white")||t.role==="knight"&&Q(...i,...n)||t.role==="bishop"&&pe(...i,...n)||t.role==="rook"&&ue(...i,...n)||t.role==="queen"&&fe(...i,...n)||t.role==="king"&&De(...i,...n))&&(!["bishop","rook","queen"].includes(t.role)||!ro(i,n,e.allPieces))})},ge=e=>U(e)&&(me(h(e.pos2),e.friendlies,e.enemies,e.lastMove)||xe(e)),me=(e,o,n,r)=>{if(!e||r&&e!==r[1])return!1;let t=f(e),i=o.get(e);return i?.role==="pawn"&&t[1]===(i.color==="white"?3:4)&&(!r||K(f(r[0])[1],t[1])===2)&&[1,-1].some(s=>n.get(h([t[0]+s,t[1]]))?.role==="pawn")},cn=e=>{if(e.unrestrictedPremoves)return!0;let o=Y(...e.pos1,...e.pos2),n=o.filter(r=>e.friendlies.has(r));return!n.length||n.length===1&&me(n[0],e.friendlies,e.enemies,e.lastMove)&&!o.includes(J(n[0],e.color==="white"?-1:1))},ln=e=>{if(e.unrestrictedPremoves)return!0;let o=Y(...e.pos1,...e.pos2),n=o.filter(a=>e.enemies.has(a));if(n.length>1)return!1;if(!n.length)return!0;let r=n[0],t=e.enemies.get(r);if(!t||t.role!=="pawn")return!0;let i=t.color==="white"?1:-1,s=J(r,i),d=[...no(s).filter(a=>an(r,a,e)),...[s,J(s,i)].filter(a=>a&&to(r,a,e))],l=[...o,h(e.pos1)];return d.some(a=>!l.includes(a))},Ae=e=>cn(e)&&ln(e),dn=e=>{let o=e.color==="white"?1:-1;return K(e.pos1[0],e.pos2[0])>1?!1:K(e.pos1[0],e.pos2[0])?e.pos2[1]!==e.pos1[1]+o?!1:e.unrestrictedPremoves||tn(e)?!0:U(e)?xe(e):sn(e)||me(h([e.pos2[0],e.pos2[1]+o]),e.friendlies,e.enemies,e.lastMove)||xe(e,["pawn"]):Ee(...e.pos1,...e.pos2,e.color==="white")&&Ae({...e,pos2:[e.pos2[0],e.pos2[1]+o]})},un=e=>Q(...e.pos1,...e.pos2)&&(e.unrestrictedPremoves||!U(e)||ge(e)),io=e=>pe(...e.pos1,...e.pos2)&&Ae(e)&&(e.unrestrictedPremoves||!U(e)||ge(e)),ao=e=>ue(...e.pos1,...e.pos2)&&Ae(e)&&(e.unrestrictedPremoves||!U(e)||ge(e)),pn=e=>io(e)||ao(e),fn=e=>De(...e.pos1,...e.pos2)&&(e.unrestrictedPremoves||!U(e)||ge(e))||e.canCastle&&e.pos1[1]===e.pos2[1]&&e.pos1[1]===(e.color==="white"?0:7)&&(e.pos1[0]===4&&(e.pos2[0]===2&&e.rookFilesFriendlies.includes(0)||e.pos2[0]===6&&e.rookFilesFriendlies.includes(7))||e.rookFilesFriendlies.includes(e.pos2[0]))&&(e.unrestrictedPremoves||Y(...e.pos1,e.pos2[0]>e.pos1[0]?7:1,e.pos2[1]).map(o=>e.allPieces.get(o)).every(o=>!o||W(o,{role:"rook",color:e.color}))),gn={pawn:dn,knight:un,bishop:io,rook:ao,queen:pn,king:fn};function Ne(e,o){let n=e.pieces,r=e.premovable.castle,t=!!e.premovable.unrestrictedPremoves,i=n.get(o);if(!i||i.color===e.turnColor)return[];let s=i.color,d=new Map([...n].filter(([p,m])=>m.color===s)),l=new Map([...n].filter(([p,m])=>m.color===j(s))),a=f(o),c=gn[i.role],u={pos1:a,allPieces:n,friendlies:d,enemies:l,unrestrictedPremoves:t,color:s,canCastle:r,rookFilesFriendlies:Array.from(n).filter(([p,m])=>p[1]===(s==="white"?"1":"8")&&m.color===s&&m.role==="rook").map(([p])=>f(p)[0]),lastMove:e.lastMove};return ce.filter(p=>c({...u,pos2:p})).map(h)}function M(e,...o){e&&setTimeout(()=>e(...o),1)}function so(e){e.orientation=j(e.orientation),e.animation.current=e.draggable.current=e.selected=void 0}function co(e,o){for(let[n,r]of o)r?e.pieces.set(n,r):e.pieces.delete(n)}function lo(e,o){if(e.check=void 0,o===!0&&(o=e.turnColor),o)for(let[n,r]of e.pieces)r.role==="king"&&r.color===o&&(e.check=n)}function mn(e,o,n,r){x(e),e.premovable.current=[o,n],M(e.premovable.events.set,o,n,r)}function E(e){e.premovable.current&&(e.premovable.current=void 0,M(e.premovable.events.unset))}function hn(e,o,n){E(e),e.predroppable.current={role:o,key:n},M(e.predroppable.events.set,o,n)}function x(e){let o=e.predroppable;o.current&&(o.current=void 0,M(o.events.unset))}function bn(e,o,n){if(!e.autoCastle)return!1;let r=e.pieces.get(o);if(!r||r.role!=="king")return!1;let t=f(o),i=f(n);if(t[1]!==0&&t[1]!==7||t[1]!==i[1])return!1;t[0]===4&&!e.pieces.has(n)&&(i[0]===6?n=h([7,i[1]]):i[0]===2&&(n=h([0,i[1]])));let s=e.pieces.get(n);return!s||s.color!==r.color||s.role!=="rook"?!1:(e.pieces.delete(o),e.pieces.delete(n),t[0]<i[0]?(e.pieces.set(h([6,i[1]]),r),e.pieces.set(h([5,i[1]]),s)):(e.pieces.set(h([2,i[1]]),r),e.pieces.set(h([3,i[1]]),s)),!0)}function He(e,o,n){let r=e.pieces.get(o),t=e.pieces.get(n);if(o===n||!r)return!1;let i=t&&t.color!==r.color?t:void 0;return n===e.selected&&P(e),M(e.events.move,o,n,i),bn(e,o,n)||(e.pieces.set(n,r),e.pieces.delete(o)),e.lastMove=[o,n],e.check=void 0,M(e.events.change),i||!0}function he(e,o,n,r){if(e.pieces.has(n))if(r)e.pieces.delete(n);else return!1;return M(e.events.dropNewPiece,o,n),e.pieces.set(n,o),e.lastMove=[n],e.check=void 0,M(e.events.change),e.movable.dests=void 0,e.turnColor=j(e.turnColor),!0}function uo(e,o,n){let r=He(e,o,n);return r&&(e.movable.dests=void 0,e.turnColor=j(e.turnColor),e.animation.current=void 0),r}function qe(e,o,n){if(ve(e,o,n)){let r=uo(e,o,n);if(r){let t=e.hold.stop();P(e);let i={premove:!1,ctrlKey:e.stats.ctrlKey,holdTime:t};return r!==!0&&(i.captured=r),M(e.movable.events.after,o,n,i),!0}}else if(yn(e,o,n))return mn(e,o,n,{ctrlKey:e.stats.ctrlKey}),P(e),!0;return P(e),!1}function be(e,o,n,r){let t=e.pieces.get(o);t&&(vn(e,o,n)||r)?(e.pieces.delete(o),he(e,t,n,r),M(e.movable.events.afterNewPiece,t.role,n,{premove:!1,predrop:!1})):t&&wn(e,o,n)?hn(e,t.role,n):(E(e),x(e)),e.pieces.delete(o),P(e)}function oe(e,o,n){if(M(e.events.select,o),e.selected){if(e.selected===o&&!e.draggable.enabled){P(e),e.hold.cancel();return}else if((e.selectable.enabled||n)&&e.selected!==o&&qe(e,e.selected,o)){e.stats.dragged=!1;return}}(e.selectable.enabled||e.draggable.enabled)&&(po(e,o)||Be(e,o))&&(Te(e,o),e.hold.start())}function Te(e,o){e.selected=o,Be(e,o)?e.premovable.customDests||(e.premovable.dests=Ne(e,o)):e.premovable.dests=void 0}function P(e){e.selected=void 0,e.premovable.dests=void 0,e.hold.cancel()}function po(e,o){let n=e.pieces.get(o);return!!n&&(e.movable.color==="both"||e.movable.color===n.color&&e.turnColor===n.color)}var ve=(e,o,n)=>o!==n&&po(e,o)&&(e.movable.free||!!e.movable.dests?.get(o)?.includes(n));function vn(e,o,n){let r=e.pieces.get(o);return!!r&&(o===n||!e.pieces.has(n))&&(e.movable.color==="both"||e.movable.color===r.color&&e.turnColor===r.color)}function Be(e,o){let n=e.pieces.get(o);return!!n&&e.premovable.enabled&&e.movable.color===n.color&&e.turnColor!==n.color}var yn=(e,o,n)=>o!==n&&Be(e,o)&&(e.premovable.customDests?.get(o)??Ne(e,o)).includes(n);function wn(e,o,n){let r=e.pieces.get(o),t=e.pieces.get(n);return!!r&&(!t||t.color!==e.movable.color)&&e.predroppable.enabled&&(r.role!=="pawn"||n[1]!=="1"&&n[1]!=="8")&&e.movable.color===r.color&&e.turnColor!==r.color}function fo(e,o){let n=e.pieces.get(o);return!!n&&e.draggable.enabled&&(e.movable.color==="both"||e.movable.color===n.color&&(e.turnColor===n.color||e.premovable.enabled))}function go(e){let o=e.premovable.current;if(!o)return!1;let n=o[0],r=o[1],t=!1;if(ve(e,n,r)){let i=uo(e,n,r);if(i){let s={premove:!0};i!==!0&&(s.captured=i),M(e.movable.events.after,n,r,s),t=!0}}return E(e),t}function mo(e,o){let n=e.predroppable.current,r=!1;if(!n)return!1;if(o(n)){let t={role:n.role,color:e.movable.color};he(e,t,n.key)&&(M(e.movable.events.afterNewPiece,n.role,n.key,{premove:!1,predrop:!0}),r=!0)}return x(e),r}function ne(e){E(e),x(e),P(e)}function Re(e){e.movable.color=e.movable.dests=e.animation.current=void 0,ne(e)}function A(e,o,n){let r=Math.floor(8*(e[0]-n.left)/n.width);o||(r=7-r);let t=7-Math.floor(8*(e[1]-n.top)/n.height);return o||(t=7-t),r>=0&&r<8&&t>=0&&t<8?h([r,t]):void 0}function ho(e,o,n,r){let t=f(e),i=ce.filter(a=>oo(t,a)||fe(t[0],t[1],a[0],a[1])||Q(t[0],t[1],a[0],a[1])),d=i.map(a=>de(h(a),n,r)).map(a=>L(o,a)),[,l]=d.reduce((a,c,u)=>a[0]<c?a:[c,u],[d[0],0]);return h(i[l])}var v=e=>e.orientation==="white";var Ve="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR",Sn={p:"pawn",r:"rook",n:"knight",b:"bishop",q:"queen",k:"king"},Pn={pawn:"p",rook:"r",knight:"n",bishop:"b",queen:"q",king:"k"};function ye(e){e==="start"&&(e=Ve);let o=new Map,n=7,r=0;for(let t of e)switch(t){case" ":case"[":return o;case"/":if(--n,n<0)return o;r=0;break;case"~":{let i=o.get(h([r-1,n]));i&&(i.promoted=!0);break}default:{let i=t.charCodeAt(0);if(i<57)r+=i-48;else{let s=t.toLowerCase(),d=h([r,n]);d&&o.set(d,{role:Sn[s],color:t===s?"black":"white"}),++r}}}return o}function bo(e){return Ye.map(o=>G.map(n=>{let r=e.get(n+o);if(r){let t=Pn[r.role];return r.color==="white"&&(t=t.toUpperCase()),r.promoted&&(t+="~"),t}else return"1"}).join("")).join("/").replace(/1{2,}/g,o=>o.length.toString())}function Le(e,o){o.animation&&(Fe(e.animation,o.animation),(e.animation.duration||0)<70&&(e.animation.enabled=!1))}function we(e,o){if(o.movable?.dests&&(e.movable.dests=void 0),o.drawable?.autoShapes&&(e.drawable.autoShapes=[]),Fe(e,o),o.fen&&(e.pieces=ye(o.fen),e.drawable.shapes=o.drawable?.shapes||[]),"check"in o&&lo(e,o.check||!1),"lastMove"in o&&!o.lastMove?e.lastMove=void 0:o.lastMove&&(e.lastMove=o.lastMove),e.selected&&Te(e,e.selected),Le(e,o),!e.movable.rookCastle&&e.movable.dests){let n=e.movable.color==="white"?"1":"8",r="e"+n,t=e.movable.dests.get(r),i=e.pieces.get(r);if(!t||!i||i.role!=="king")return;e.movable.dests.set(r,t.filter(s=>!(s==="a"+n&&t.includes("c"+n))&&!(s==="h"+n&&t.includes("g"+n))))}}function Fe(e,o){for(let n in o)n==="__proto__"||n==="constructor"||!Object.prototype.hasOwnProperty.call(o,n)||(Object.prototype.hasOwnProperty.call(e,n)&&vo(e[n])&&vo(o[n])?Fe(e[n],o[n]):e[n]=o[n])}function vo(e){if(typeof e!="object"||e===null)return!1;let o=Object.getPrototypeOf(e);return o===Object.prototype||o===null}var R=(e,o)=>o.animation.enabled?Dn(e,o):O(e,o);function O(e,o){let n=e(o);return o.dom.redraw(),n}var Ge=(e,o)=>({key:e,pos:f(e),piece:o}),kn=(e,o)=>o.sort((n,r)=>L(e.pos,n.pos)-L(e.pos,r.pos))[0];function Cn(e,o){let n=new Map,r=[],t=new Map,i=[],s=[],d=new Map,l,a,c;for(let[u,p]of e)d.set(u,Ge(u,p));for(let u of se)l=o.pieces.get(u),a=d.get(u),l?a?W(l,a.piece)||(i.push(a),s.push(Ge(u,l))):s.push(Ge(u,l)):a&&i.push(a);for(let u of s)a=kn(u,i.filter(p=>W(u.piece,p.piece))),a&&(c=[a.pos[0]-u.pos[0],a.pos[1]-u.pos[1]],n.set(u.key,c.concat(c)),r.push(a.key));for(let u of i)r.includes(u.key)||t.set(u.key,u.piece);return{anims:n,fadings:t}}function yo(e,o){let n=e.animation.current;if(n===void 0){e.dom.destroyed||e.dom.redrawNow();return}let r=1-(o-n.start)*n.frequency;if(r<=0)e.animation.current=void 0,e.dom.redrawNow();else{let t=Kn(r);for(let i of n.plan.anims.values())i[2]=i[0]*t,i[3]=i[1]*t;e.dom.redrawNow(!0),requestAnimationFrame((i=performance.now())=>yo(e,i))}}function Dn(e,o){let n=new Map(o.pieces),r=e(o),t=Cn(n,o);if(t.anims.size||t.fadings.size){let i=o.animation.current&&o.animation.current.start;o.animation.current={start:performance.now(),frequency:1/o.animation.duration,plan:t},i||yo(o,performance.now())}else o.dom.redraw();return r}var Kn=e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1;var En=["green","red","blue","yellow"];function wo(e,o){if(o.touches&&o.touches.length>1)return;o.stopPropagation(),o.preventDefault(),o.ctrlKey?P(e):ne(e);let n=T(o),r=A(n,v(e),e.dom.bounds());r&&(e.drawable.current={orig:r,pos:n,brush:xn(o),snapToValidMove:e.drawable.defaultSnapToValidMove},So(e))}function So(e){requestAnimationFrame(()=>{let o=e.drawable.current;if(o){let n=A(o.pos,v(e),e.dom.bounds());n||(o.snapToValidMove=!1);let r=o.snapToValidMove?ho(o.orig,o.pos,v(e),e.dom.bounds()):n;r!==o.mouseSq&&(o.mouseSq=r,o.dest=r!==o.orig?r:void 0,e.dom.redrawNow()),So(e)}})}function Po(e,o){e.drawable.current&&(e.drawable.current.pos=T(o))}function Mo(e){let o=e.drawable.current;o&&(o.mouseSq&&An(e.drawable,o),We(e))}function We(e){e.drawable.current&&(e.drawable.current=void 0,e.dom.redraw())}function ko(e){e.drawable.shapes.length&&(e.drawable.shapes=[],e.dom.redraw(),Co(e.drawable))}function xn(e){let o=(e.shiftKey||e.ctrlKey)&&le(e),n=e.altKey||e.metaKey||e.getModifierState?.("AltGraph");return En[(o?1:0)+(n?2:0)]}function An(e,o){let n=t=>t.orig===o.orig&&t.dest===o.dest,r=e.shapes.find(n);r&&(e.shapes=e.shapes.filter(t=>!n(t))),(!r||r.brush!==o.brush)&&e.shapes.push({orig:o.orig,dest:o.dest,brush:o.brush}),Co(e)}function Co(e){e.onChange&&e.onChange(e.shapes)}function Do(e,o){if(!(e.trustAllEvents||o.isTrusted)||o.buttons!==void 0&&o.buttons>1||o.touches&&o.touches.length>1)return;let n=e.dom.bounds(),r=T(o),t=A(r,v(e),n);if(!t)return;let i=e.pieces.get(t),s=e.selected;if(!s&&e.drawable.enabled&&(e.drawable.eraseOnClick||!i||i.color!==e.turnColor)&&ko(e),o.cancelable!==!1&&(!o.touches||e.blockTouchScroll||i||s||Hn(e,r)))o.preventDefault();else if(o.touches)return;let d=!!e.premovable.current,l=!!e.predroppable.current;e.stats.ctrlKey=o.ctrlKey,e.selected&&ve(e,e.selected,t)?R(u=>oe(u,t),e):oe(e,t);let a=e.selected===t,c=No(e,t);if(i&&c&&a&&fo(e,t)){e.draggable.current={orig:t,piece:i,origPos:r,pos:r,started:e.draggable.autoDistance&&e.stats.dragged,element:c,previouslySelected:s,originTarget:o.target,keyHasChanged:!1},c.cgDragging=!0,c.classList.add("dragging");let u=e.dom.elements.ghost;u&&(u.className=`ghost ${i.color} ${i.role}`,k(u,F(n)(f(t),v(e))),_(u,!0)),ze(e)}else d&&E(e),l&&x(e);e.dom.redraw()}function Hn(e,o){let n=v(e),r=e.dom.bounds(),t=Math.pow(e.touchIgnoreRadius*r.width/16,2)*2;for(let i of e.pieces.keys()){let s=de(i,n,r);if(L(s,o)<=t)return!0}return!1}function Ko(e,o,n,r){let t="a0";e.pieces.set(t,o),e.dom.redraw();let i=T(n);e.draggable.current={orig:t,piece:o,origPos:i,pos:i,started:!0,element:()=>No(e,t),originTarget:n.target,newPiece:!0,force:!!r,keyHasChanged:!1},ze(e)}function ze(e){requestAnimationFrame(()=>{let o=e.draggable.current;if(!o)return;e.animation.current?.plan.anims.has(o.orig)&&(e.animation.current=void 0);let n=e.pieces.get(o.orig);if(!n||!W(n,o.piece))z(e);else if(!o.started&&L(o.pos,o.origPos)>=Math.pow(e.draggable.distance,2)&&(o.started=!0),o.started){if(typeof o.element=="function"){let t=o.element();if(!t)return;t.cgDragging=!0,t.classList.add("dragging"),o.element=t}let r=e.dom.bounds();k(o.element,[o.pos[0]-r.left-r.width/16,o.pos[1]-r.top-r.height/16]),o.keyHasChanged||=o.orig!==A(o.pos,v(e),r)}ze(e)})}function Eo(e,o){e.draggable.current&&(!o.touches||o.touches.length<2)&&(e.draggable.current.pos=T(o))}function xo(e,o){let n=e.draggable.current;if(!n)return;if(o.type==="touchend"&&o.cancelable!==!1&&o.preventDefault(),o.type==="touchend"&&n.originTarget!==o.target&&!n.newPiece){e.draggable.current=void 0;return}E(e),x(e);let r=T(o)||n.pos,t=A(r,v(e),e.dom.bounds());t&&n.started&&n.orig!==t?n.newPiece?be(e,n.orig,t,n.force):(e.stats.ctrlKey=o.ctrlKey,qe(e,n.orig,t)&&(e.stats.dragged=!0)):n.newPiece?e.pieces.delete(n.orig):e.draggable.deleteOnDropOff&&!t&&(e.pieces.delete(n.orig),M(e.events.change)),(n.orig===n.previouslySelected||n.keyHasChanged)&&(n.orig===t||!t)?P(e):e.selectable.enabled||P(e),Ao(e),e.draggable.current=void 0,e.dom.redraw()}function z(e){let o=e.draggable.current;o&&(o.newPiece&&e.pieces.delete(o.orig),e.draggable.current=void 0,P(e),Ao(e),e.dom.redraw())}function Ao(e){let o=e.dom.elements;o.ghost&&_(o.ghost,!1)}function No(e,o){let n=e.dom.elements.board.firstChild;for(;n;){if(n.cgKey===o&&n.tagName==="PIECE")return n;n=n.nextSibling}}function qo(e,o){e.exploding={stage:1,keys:o},e.dom.redraw(),setTimeout(()=>{Ho(e,2),setTimeout(()=>Ho(e,void 0),120)},120)}function Ho(e,o){e.exploding&&(o?e.exploding.stage=o:e.exploding=void 0,e.dom.redraw())}function To(e,o){function n(){so(e),o()}return{set(r){r.orientation&&r.orientation!==e.orientation&&n(),Le(e,r),(r.fen?R:O)(t=>we(t,r),e)},state:e,getFen:()=>bo(e.pieces),toggleOrientation:n,setPieces(r){R(t=>co(t,r),e)},selectSquare(r,t){r?R(i=>oe(i,r,t),e):e.selected&&(P(e),e.dom.redraw())},move(r,t){R(i=>He(i,r,t),e)},newPiece(r,t){R(i=>he(i,r,t),e)},playPremove(){if(e.premovable.current){if(R(go,e))return!0;e.dom.redraw()}return!1},playPredrop(r){if(e.predroppable.current){let t=mo(e,r);return e.dom.redraw(),t}return!1},cancelPremove(){O(E,e)},cancelPredrop(){O(x,e)},cancelMove(){O(r=>{ne(r),z(r)},e)},stop(){O(r=>{Re(r),z(r)},e)},explode(r){qo(e,r)},setAutoShapes(r){O(t=>t.drawable.autoShapes=r,e)},setShapes(r){O(t=>t.drawable.shapes=r.slice(),e)},getKeyAtDomPos(r){return A(r,v(e),e.dom.bounds())},redrawAll:o,dragNewPiece(r,t,i){Ko(e,r,t,i)},destroy(){Re(e),e.dom.unbind&&e.dom.unbind(),e.dom.destroyed=!0}}}function Bo(){return{pieces:ye(Ve),orientation:"white",turnColor:"white",coordinates:!0,coordinatesOnSquares:!1,ranksPosition:"right",autoCastle:!0,viewOnly:!1,disableContextMenu:!1,addPieceZIndex:!1,blockTouchScroll:!1,touchIgnoreRadius:1,pieceKey:!1,trustAllEvents:!1,highlight:{lastMove:!0,check:!0},animation:{enabled:!0,duration:200},movable:{free:!0,color:"both",showDests:!0,events:{},rookCastle:!0},premovable:{enabled:!0,showDests:!0,castle:!0,events:{}},predroppable:{enabled:!1,events:{}},draggable:{enabled:!0,distance:3,autoDistance:!0,showGhost:!0,deleteOnDropOff:!1},dropmode:{active:!1},selectable:{enabled:!0},stats:{dragged:!("ontouchstart"in window)},events:{},drawable:{enabled:!0,visible:!0,defaultSnapToValidMove:!0,eraseOnClick:!0,shapes:[],autoShapes:[],brushes:{green:{key:"g",color:"#15781B",opacity:1,lineWidth:10},red:{key:"r",color:"#882020",opacity:1,lineWidth:10},blue:{key:"b",color:"#003088",opacity:1,lineWidth:10},yellow:{key:"y",color:"#e68f00",opacity:1,lineWidth:10},paleBlue:{key:"pb",color:"#003088",opacity:.4,lineWidth:15},paleGreen:{key:"pg",color:"#15781B",opacity:.4,lineWidth:15},paleRed:{key:"pr",color:"#882020",opacity:.4,lineWidth:15},paleGrey:{key:"pgr",color:"#4a4a4a",opacity:.35,lineWidth:15},purple:{key:"purple",color:"#68217a",opacity:.65,lineWidth:10},pink:{key:"pink",color:"#ee2080",opacity:.5,lineWidth:10},white:{key:"white",color:"white",opacity:1,lineWidth:10},paleWhite:{key:"pwhite",color:"white",opacity:.6,lineWidth:10}},prevSvgHash:""},hold:eo()}}function Vo(){let e=w("defs"),o=S(w("filter"),{id:"cg-filter-blur"});return o.appendChild(S(w("feGaussianBlur"),{stdDeviation:"0.013"})),e.appendChild(o),e}function Lo(e,o){let n=e.drawable,r=n.current,t=r&&r.mouseSq?r:void 0,i=new Map,s=e.dom.bounds(),d=n.autoShapes.filter(c=>!c.piece);for(let c of n.shapes.concat(d).concat(t?[t]:[])){if(!c.dest)continue;let u=i.get(c.dest)??new Set,p=Pe(Se(f(c.orig),e.orientation),s),m=Pe(Se(f(c.dest),e.orientation),s);u.add(Ie(p,m)),i.set(c.dest,u)}let l=[];for(let c of n.shapes.concat(d))l.push({shape:c,current:!1,hash:Ro(c,$e(c.dest,i),!1,s)});t&&l.push({shape:t,current:!0,hash:Ro(t,$e(t.dest,i),!0,s)});let a=l.map(c=>c.hash).join(";");a!==e.drawable.prevSvgHash&&(e.drawable.prevSvgHash=a,Tn(n,l,o),Bn(l,o,c=>Vn(e,c,n.brushes,i,s)))}function Tn(e,o,n){for(let r of[n.shapes,n.shapesBelow]){let t=r.querySelector("defs"),i=o.filter(a=>r===n.shapesBelow==!!a.shape.below),s=new Map;for(let a of i.filter(c=>c.shape.dest&&c.shape.brush)){let c=Fo(e.brushes[a.shape.brush],a.shape.modifiers),{key:u,color:p}=Go(a.shape);u&&p&&s.set(u,{key:u,color:p,opacity:1,lineWidth:1}),s.set(c.key,c)}let d=new Set,l=t.firstElementChild;for(;l;)d.add(l.getAttribute("cgKey")),l=l.nextElementSibling;for(let[a,c]of s.entries())d.has(a)||t.appendChild(Gn(c))}}function Bn(e,o,n){for(let[r,t]of[[o.shapes,o.custom],[o.shapesBelow,o.customBelow]]){let[i,s]=[r,t].map(a=>a.querySelector("g")),d=e.filter(a=>r===o.shapesBelow==!!a.shape.below),l=new Map;for(let a of d)l.set(a.hash,!1);for(let a of[i,s]){let c=[],u=a.firstElementChild,p;for(;u;)p=u.getAttribute("cgHash"),l.has(p)?l.set(p,!0):c.push(u),u=u.nextElementSibling;for(let m of c)a.removeChild(m)}for(let a of d.filter(c=>!l.get(c.hash)))for(let c of n(a))c.isCustom?s.appendChild(c.el):i.appendChild(c.el)}}function Ro({orig:e,dest:o,brush:n,piece:r,modifiers:t,customSvg:i,label:s,below:d},l,a,c){return[c.width,c.height,a,e,o,n,l&&"-",r&&Rn(r),t&&On(t),i&&`custom-${Oo(i.html)},${i.center?.[0]??"o"}`,s&&`label-${Oo(s.text)}`,d&&"below"].filter(u=>u).join(",")}function Rn(e){return[e.color,e.role,e.scale].filter(o=>o).join(",")}function On(e){return[e.lineWidth,e.hilite].filter(o=>o).join(",")}function Oo(e){let o=0;for(let n=0;n<e.length;n++)o=(o<<5)-o+e.charCodeAt(n)>>>0;return o.toString()}function Vn(e,{shape:o,current:n,hash:r},t,i,s){let d=Pe(Se(f(o.orig),e.orientation),s),l=o.dest?Pe(Se(f(o.dest),e.orientation),s):d,a=o.brush&&Fo(t[o.brush],o.modifiers),c=i.get(o.dest),u=[];if(a){let p=S(w("g"),{cgHash:r});u.push({el:p}),d[0]!==l[0]||d[1]!==l[1]?p.appendChild(Fn(o,a,d,l,n,$e(o.dest,i))):p.appendChild(Ln(t[o.brush],d,n,s))}if(o.label){let p=o.label;p.fill??=o.brush&&t[o.brush].color;let m=o.brush?void 0:"tr";u.push({el:Wn(p,r,d,l,c,m),isCustom:!0})}if(o.customSvg){let p=o.customSvg.center??"orig",[m,y]=p==="label"?zo(d,l,c).map(B=>B-.5):p==="dest"?l:d,g=S(w("g"),{transform:`translate(${m},${y})`,cgHash:r});g.innerHTML=`<svg width="1" height="1" viewBox="0 0 100 100">${o.customSvg.html}</svg>`,u.push({el:g,isCustom:!0})}return u}function Ln(e,o,n,r){let t=zn(),i=(r.width+r.height)/(4*Math.max(r.width,r.height));return S(w("circle"),{stroke:e.color,"stroke-width":t[n?0:1],fill:"none",opacity:Wo(e,n),cx:o[0],cy:o[1],r:i-t[1]/2})}function Fn(e,o,n,r,t,i){function s(a){let c=In(i&&!t),u=r[0]-n[0],p=r[1]-n[1],m=Math.atan2(p,u),y=Math.cos(m)*c,g=Math.sin(m)*c,B=Go(e);return S(w("line"),{stroke:a?B.color:o.color,"stroke-width":$n(o,t)*(a?1.14:1),"stroke-linecap":"round","marker-end":`url(#arrowhead-${a?B.key:o.key})`,opacity:e.modifiers?.hilite?1:Wo(o,t),x1:n[0],y1:n[1],x2:r[0]-y,y2:r[1]-g})}if(!e.modifiers?.hilite)return s(!1);let d=S(w("g"),{opacity:o.opacity}),l=S(w("g"),{filter:"url(#cg-filter-blur)"});return l.appendChild(jn(n,r)),l.appendChild(s(!0)),d.appendChild(l),d.appendChild(s(!1)),d}function Gn(e){let o=S(w("marker"),{id:"arrowhead-"+e.key,orient:"auto",overflow:"visible",markerWidth:4,markerHeight:4,refX:e.key.startsWith("hilite")?1.86:2.05,refY:2});return o.appendChild(S(w("path"),{d:"M0,0 V4 L3,2 Z",fill:e.color})),o.setAttribute("cgKey",e.key),o}function Wn(e,o,n,r,t,i){let d=.4*.75**e.text.length,l=zo(n,r,t),a=i==="tr"?.4:0,c=S(w("g"),{transform:`translate(${l[0]+a},${l[1]-a})`,cgHash:o});c.appendChild(S(w("circle"),{r:.4/2,"fill-opacity":i?1:.8,"stroke-opacity":i?1:.7,"stroke-width":.03,fill:e.fill??"#666",stroke:"white"}));let u=S(w("text"),{"font-size":d,"font-family":"Noto Sans","text-anchor":"middle",fill:"white",y:.13*.75**e.text.length});return u.innerHTML=e.text,c.appendChild(u),c}function Se(e,o){return o==="white"?e:[7-e[0],7-e[1]]}function $e(e,o){return(e&&o.has(e)&&o.get(e).size>1)===!0}function w(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function S(e,o){for(let n in o)Object.prototype.hasOwnProperty.call(o,n)&&e.setAttribute(n,o[n]);return e}function Fo(e,o){return o?{color:e.color,opacity:Math.round(e.opacity*10)/10,lineWidth:Math.round(o.lineWidth||e.lineWidth),key:[e.key,o.lineWidth].filter(n=>n).join("")}:e}function zn(){return[3/64,4/64]}function $n(e,o){return(e.lineWidth||10)*(o?.85:1)/64}function Go(e){let o=e.modifiers?.hilite;return{key:o&&`hilite-${o.replace("#","")}`,color:o}}function Wo(e,o){return(e.opacity||1)*(o?.9:1)}function In(e){return(e?20:10)/64}function Pe(e,o){let n=Math.min(1,o.width/o.height),r=Math.min(1,o.height/o.width);return[(e[0]-3.5)*n,(3.5-e[1])*r]}function jn(e,o){let n={from:[Math.floor(Math.min(e[0],o[0])),Math.floor(Math.min(e[1],o[1]))],to:[Math.ceil(Math.max(e[0],o[0])),Math.ceil(Math.max(e[1],o[1]))]};return S(w("rect"),{x:n.from[0],y:n.from[1],width:n.to[0]-n.from[0],height:n.to[1]-n.from[1],fill:"none",stroke:"none"})}function Ie(e,o,n=!0){let r=Math.atan2(o[1]-e[1],o[0]-e[0])+Math.PI;return n?(Math.round(r*8/Math.PI)+16)%16:r}function Un(e,o){return Math.sqrt([e[0]-o[0],e[1]-o[1]].reduce((n,r)=>n+r*r,0))}function zo(e,o,n){let r=Un(e,o),t=Ie(e,o,!1);if(n&&(r-=33/64,n.size>1)){r-=10/64;let i=Ie(e,o);(n.has((i+1)%16)||n.has((i+15)%16))&&i&1&&(r-=.4)}return[e[0]-Math.cos(t)*r,e[1]-Math.sin(t)*r].map(i=>i+.5)}function Io(e,o){e.innerHTML="",e.classList.add("cg-wrap");for(let c of _e)e.classList.toggle("orientation-"+c,o.orientation===c);e.classList.toggle("manipulable",!o.viewOnly);let n=C("cg-container");e.appendChild(n);let r=C("cg-board");n.appendChild(r);let t,i,s,d,l;if(o.drawable.visible&&([t,i]=["cg-shapes-below","cg-shapes"].map(c=>$o(c,!0)),[s,d]=["cg-custom-below","cg-custom-svgs"].map(c=>$o(c,!1)),l=C("cg-auto-pieces"),n.appendChild(t),n.appendChild(s),n.appendChild(i),n.appendChild(d),n.appendChild(l)),o.coordinates){let c=o.orientation==="black"?" black":"",u=o.ranksPosition==="left"?" left":"";if(o.coordinatesOnSquares){let p=o.orientation==="white"?m=>m+1:m=>8-m;G.forEach((m,y)=>n.appendChild(je(I.map(g=>m+g),"squares rank"+p(y)+c+u)))}else n.appendChild(je(I,"ranks"+c+u)),n.appendChild(je(G,"files"+c))}let a;return o.draggable.enabled&&o.draggable.showGhost&&(a=C("piece","ghost"),_(a,!1),n.appendChild(a)),{board:r,container:n,wrap:e,ghost:a,shapes:i,shapesBelow:t,custom:d,customBelow:s,autoPieces:l}}function $o(e,o){let n=S(w("svg"),{class:e,viewBox:o?"-4 -4 8 8":"-3.5 -3.5 8 8",preserveAspectRatio:"xMidYMid slice"});return o&&n.appendChild(Vo()),n.appendChild(w("g")),n}function je(e,o){let n=C("coords",o),r;for(let t of e)r=C("coord"),r.textContent=t,n.appendChild(r);return n}function jo(e,o){if(!e.dropmode.active)return;E(e),x(e);let n=e.dropmode.piece;if(n){e.pieces.set("a0",n);let r=T(o),t=r&&A(r,v(e),e.dom.bounds());t&&be(e,"a0",t)}e.dom.redraw()}function Zo(e,o){let n=e.dom.elements.board;if("ResizeObserver"in window&&new ResizeObserver(o).observe(e.dom.elements.wrap),(e.disableContextMenu||e.drawable.enabled)&&n.addEventListener("contextmenu",t=>t.preventDefault()),e.viewOnly)return;let r=Xn(e);n.addEventListener("touchstart",r,{passive:!1}),n.addEventListener("mousedown",r,{passive:!1})}function Xo(e,o){let n=[];if("ResizeObserver"in window||n.push(re(document.body,"chessground.resize",o)),!e.viewOnly){let r=Uo(e,Eo,Po),t=Uo(e,xo,Mo);for(let s of["touchmove","mousemove"])n.push(re(document,s,r));for(let s of["touchend","mouseup"])n.push(re(document,s,t));let i=()=>e.dom.bounds.clear();n.push(re(document,"scroll",i,{capture:!0,passive:!0})),n.push(re(window,"resize",i,{passive:!0}))}return()=>n.forEach(r=>r())}function re(e,o,n,r){return e.addEventListener(o,n,r),()=>e.removeEventListener(o,n,r)}var Xn=e=>o=>{e.draggable.current?z(e):e.drawable.current?We(e):o.shiftKey||le(o)?e.drawable.enabled&&wo(e,o):e.viewOnly||(e.dropmode.active?jo(e,o):Do(e,o))},Uo=(e,o,n)=>r=>{e.drawable.current?e.drawable.enabled&&n(e,r):e.viewOnly||o(e,r)};function Qo(e){let o=v(e),n=F(e.dom.bounds()),r=e.dom.elements.board,t=e.pieces,i=e.animation.current,s=i?i.plan.anims:new Map,d=i?i.plan.fadings:new Map,l=e.draggable.current,a=Qn(e),c=new Set,u=new Set,p=new Map,m=new Map,y,g,B,$,D,Z,Me,N,ke,ie;for(g=r.firstChild;g;){if(y=g.cgKey,Jo(g))if(B=t.get(y),D=s.get(y),Z=d.get(y),$=g.cgPiece,g.cgDragging&&(!l||l.orig!==y)&&(g.classList.remove("dragging"),k(g,n(f(y),o)),g.cgDragging=!1),!Z&&g.cgFading&&(g.cgFading=!1,g.classList.remove("fading")),B){if(D&&g.cgAnimating&&$===te(B)){let b=f(y);b[0]+=D[2],b[1]+=D[3],g.classList.add("anim"),k(g,n(b,o))}else g.cgAnimating&&(g.cgAnimating=!1,g.classList.remove("anim"),k(g,n(f(y),o)),e.addPieceZIndex&&(g.style.zIndex=Ue(f(y),o)));$===te(B)&&(!Z||!g.cgFading)?c.add(y):Z&&$===te(Z)?(g.classList.add("fading"),g.cgFading=!0):Ze(p,$,g)}else Ze(p,$,g);else if(en(g)){let b=g.className;a.get(y)===b?u.add(y):Ze(m,b,g)}g=g.nextSibling}for(let[b,X]of a)if(!u.has(b)){ke=m.get(X),ie=ke&&ke.pop();let H=n(f(b),o);if(ie)ie.cgKey=b,k(ie,H);else{let q=C("square",X);q.cgKey=b,k(q,H),r.insertBefore(q,r.firstChild)}}for(let[b,X]of t)if(D=s.get(b),!c.has(b))if(Me=p.get(te(X)),N=Me&&Me.pop(),N){N.cgKey=b,N.cgFading&&(N.classList.remove("fading"),N.cgFading=!1);let H=f(b);e.addPieceZIndex&&(N.style.zIndex=Ue(H,o)),D&&(N.cgAnimating=!0,N.classList.add("anim"),H[0]+=D[2],H[1]+=D[3]),k(N,n(H,o))}else{let H=te(X),q=C("piece",H),ae=f(b);q.cgPiece=H,q.cgKey=b,D&&(q.cgAnimating=!0,ae[0]+=D[2],ae[1]+=D[3]),k(q,n(ae,o)),e.addPieceZIndex&&(q.style.zIndex=Ue(ae,o)),r.appendChild(q)}for(let b of p.values())_o(e,b);for(let b of m.values())_o(e,b)}function Yo(e){let o=v(e),n=F(e.dom.bounds()),r=e.dom.elements.board.firstChild;for(;r;)(Jo(r)&&!r.cgAnimating||en(r))&&k(r,n(f(r.cgKey),o)),r=r.nextSibling}function Xe(e){let o=e.dom.elements.wrap.getBoundingClientRect(),n=e.dom.elements.container,r=o.height/o.width,t=Math.floor(o.width*window.devicePixelRatio/8)*8/window.devicePixelRatio,i=t*r;n.style.width=t+"px",n.style.height=i+"px",e.dom.bounds.clear(),e.addDimensionsCssVarsTo?.style.setProperty("---cg-width",t+"px"),e.addDimensionsCssVarsTo?.style.setProperty("---cg-height",i+"px")}var Jo=e=>e.tagName==="PIECE",en=e=>e.tagName==="SQUARE";function _o(e,o){for(let n of o)e.dom.elements.board.removeChild(n)}function Ue(e,o){let r=e[1];return`${o?10-r:3+r}`}var te=e=>`${e.color} ${e.role}`;function Qn(e){let o=new Map;if(e.lastMove&&e.highlight.lastMove)for(let t of e.lastMove)V(o,t,"last-move");if(e.check&&e.highlight.check&&V(o,e.check,"check"),e.selected&&(V(o,e.selected,"selected"),e.movable.showDests)){let t=e.movable.dests?.get(e.selected);if(t)for(let s of t)V(o,s,"move-dest"+(e.pieces.has(s)?" oc":""));let i=e.premovable.customDests?.get(e.selected)??e.premovable.dests;if(i)for(let s of i)V(o,s,"premove-dest"+(e.pieces.has(s)?" oc":""))}let n=e.premovable.current;if(n)for(let t of n)V(o,t,"current-premove");else e.predroppable.current&&V(o,e.predroppable.current.key,"current-premove");let r=e.exploding;if(r)for(let t of r.keys)V(o,t,"exploding"+r.stage);return e.highlight.custom&&e.highlight.custom.forEach((t,i)=>{V(o,i,t)}),o}function V(e,o,n){let r=e.get(o);r?e.set(o,`${r} ${n}`):e.set(o,n)}function Ze(e,o,n){let r=e.get(o);r?r.push(n):e.set(o,[n])}function on(e,o,n){let r=new Map,t=[];for(let d of e)r.set(d.hash,!1);let i=o.firstElementChild,s;for(;i;)s=i.getAttribute("cgHash"),r.has(s)?r.set(s,!0):t.push(i),i=i.nextElementSibling;for(let d of t)o.removeChild(d);for(let d of e)r.get(d.hash)||o.appendChild(n(d))}function nn(e,o){let r=e.drawable.autoShapes.filter(t=>t.piece).map(t=>({shape:t,hash:Jn(t),current:!1}));on(r,o,t=>Yn(e,t,e.dom.bounds()))}function rn(e){let o=v(e),n=F(e.dom.bounds()),r=e.dom.elements.autoPieces?.firstChild;for(;r;)Ce(r,n(f(r.cgKey),o),r.cgScale),r=r.nextSibling}function Yn(e,{shape:o,hash:n},r){let t=o.orig,i=o.piece?.role,s=o.piece?.color,d=o.piece?.scale,l=C("piece",`${i} ${s}`);return l.setAttribute("cgHash",n),l.cgKey=t,l.cgScale=d,Ce(l,F(r)(f(t),v(e)),d),l}var Jn=e=>[e.orig,e.piece?.role,e.piece?.color,e.piece?.scale].join(",");function Jr({el:e,config:o}){return or(e,o)}function or(e,o){let n=Bo();we(n,o||{});function r(){let t="dom"in n?n.dom.unbind:void 0,i=Io(e,n),s=Je(()=>i.board.getBoundingClientRect()),d=c=>{Qo(a),i.autoPieces&&nn(a,i.autoPieces),!c&&i.shapes&&Lo(a,i)},l=()=>{Xe(a),Yo(a),i.autoPieces&&rn(a)},a=n;return a.dom={elements:i,bounds:s,redraw:nr(d),redrawNow:d,unbind:t},a.drawable.prevSvgHash="",Xe(a),d(!1),Zo(a,l),t||(a.dom.unbind=Xo(a,l)),a.events.insert&&a.events.insert(i),a}return To(r(),r)}function nr(e){let o=!1;return()=>{o||(o=!0,requestAnimationFrame(()=>{e(),o=!1}))}}export{or as Chessground,Jr as initModule};
|
package/dist/premove.js
CHANGED
|
@@ -38,7 +38,7 @@ const isFriendlyOnDestAndAttacked = (ctx) => isDestOccupiedByFriendly(ctx) &&
|
|
|
38
38
|
(canBeCapturedBySomeEnemyEnPassant(util.pos2key(ctx.pos2), ctx.friendlies, ctx.enemies, ctx.lastMove) ||
|
|
39
39
|
isDestControlledByEnemy(ctx));
|
|
40
40
|
const canBeCapturedBySomeEnemyEnPassant = (potentialSquareOfFriendlyPawn, friendlies, enemies, lastMove) => {
|
|
41
|
-
if (lastMove && potentialSquareOfFriendlyPawn !== lastMove[1])
|
|
41
|
+
if (!potentialSquareOfFriendlyPawn || (lastMove && potentialSquareOfFriendlyPawn !== lastMove[1]))
|
|
42
42
|
return false;
|
|
43
43
|
const pos = util.key2pos(potentialSquareOfFriendlyPawn);
|
|
44
44
|
const friendly = friendlies.get(potentialSquareOfFriendlyPawn);
|
|
@@ -74,7 +74,7 @@ const isPathClearEnoughOfEnemiesForPremove = (ctx) => {
|
|
|
74
74
|
const squareAbove = util.squareShiftedVertically(enemySquare, enemyStep);
|
|
75
75
|
const enemyPawnDests = [
|
|
76
76
|
...util.adjacentSquares(squareAbove).filter(s => canEnemyPawnCaptureOnSquare(enemySquare, s, ctx)),
|
|
77
|
-
...[squareAbove, util.squareShiftedVertically(squareAbove, enemyStep)].filter(s => s && canEnemyPawnAdvanceToSquare(enemySquare, s, ctx)),
|
|
77
|
+
...[squareAbove, util.squareShiftedVertically(squareAbove, enemyStep)].filter((s) => s && canEnemyPawnAdvanceToSquare(enemySquare, s, ctx)),
|
|
78
78
|
];
|
|
79
79
|
const badSquares = [...squaresBetween, util.pos2key(ctx.pos1)];
|
|
80
80
|
return enemyPawnDests.some(square => !badSquares.includes(square));
|
package/dist/premove.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"premove.js","sourceRoot":"","sources":["../src/premove.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI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AC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,CAC/F;aACA,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC;IACJ,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAClF,CAAC"}
|
package/dist/wrap.js
CHANGED
|
@@ -68,9 +68,9 @@ function svgContainer(cls, isShapes) {
|
|
|
68
68
|
viewBox: isShapes ? '-4 -4 8 8' : '-3.5 -3.5 8 8',
|
|
69
69
|
preserveAspectRatio: 'xMidYMid slice',
|
|
70
70
|
});
|
|
71
|
-
svg.appendChild(createSVG('g'));
|
|
72
71
|
if (isShapes)
|
|
73
72
|
svg.appendChild(createDefs());
|
|
73
|
+
svg.appendChild(createSVG('g'));
|
|
74
74
|
return svg;
|
|
75
75
|
}
|
|
76
76
|
function renderCoords(elems, className) {
|
package/dist/wrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap.js","sourceRoot":"","sources":["../src/wrap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAY,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,aAAa,IAAI,SAAS,EAAE,a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K,EAAE,CAAC;QACzB,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QACtB,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC;QACrB,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/package.json
CHANGED
package/src/premove.ts
CHANGED
|
@@ -78,12 +78,13 @@ const isFriendlyOnDestAndAttacked = (ctx: MobilityContext): boolean =>
|
|
|
78
78
|
isDestControlledByEnemy(ctx));
|
|
79
79
|
|
|
80
80
|
const canBeCapturedBySomeEnemyEnPassant = (
|
|
81
|
-
potentialSquareOfFriendlyPawn: cg.Key,
|
|
81
|
+
potentialSquareOfFriendlyPawn: cg.Key | undefined,
|
|
82
82
|
friendlies: cg.Pieces,
|
|
83
83
|
enemies: cg.Pieces,
|
|
84
84
|
lastMove?: cg.Key[],
|
|
85
85
|
): boolean => {
|
|
86
|
-
if (lastMove && potentialSquareOfFriendlyPawn !== lastMove[1])
|
|
86
|
+
if (!potentialSquareOfFriendlyPawn || (lastMove && potentialSquareOfFriendlyPawn !== lastMove[1]))
|
|
87
|
+
return false;
|
|
87
88
|
const pos = util.key2pos(potentialSquareOfFriendlyPawn);
|
|
88
89
|
const friendly = friendlies.get(potentialSquareOfFriendlyPawn);
|
|
89
90
|
return (
|
|
@@ -128,7 +129,7 @@ const isPathClearEnoughOfEnemiesForPremove = (ctx: MobilityContext): boolean =>
|
|
|
128
129
|
const enemyPawnDests: cg.Key[] = [
|
|
129
130
|
...util.adjacentSquares(squareAbove).filter(s => canEnemyPawnCaptureOnSquare(enemySquare, s, ctx)),
|
|
130
131
|
...[squareAbove, util.squareShiftedVertically(squareAbove, enemyStep)].filter(
|
|
131
|
-
s => s && canEnemyPawnAdvanceToSquare(enemySquare, s, ctx),
|
|
132
|
+
(s: cg.Key | undefined) => s && canEnemyPawnAdvanceToSquare(enemySquare, s, ctx),
|
|
132
133
|
),
|
|
133
134
|
];
|
|
134
135
|
const badSquares = [...squaresBetween, util.pos2key(ctx.pos1)];
|
package/src/wrap.ts
CHANGED
|
@@ -89,8 +89,8 @@ function svgContainer(cls: string, isShapes: boolean) {
|
|
|
89
89
|
viewBox: isShapes ? '-4 -4 8 8' : '-3.5 -3.5 8 8',
|
|
90
90
|
preserveAspectRatio: 'xMidYMid slice',
|
|
91
91
|
});
|
|
92
|
-
svg.appendChild(createSVG('g'));
|
|
93
92
|
if (isShapes) svg.appendChild(createDefs());
|
|
93
|
+
svg.appendChild(createSVG('g'));
|
|
94
94
|
return svg;
|
|
95
95
|
}
|
|
96
96
|
|