@lichess-org/chessground 9.7.2 → 9.8.0
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/board.js +8 -8
- package/dist/board.js.map +1 -1
- package/dist/chessground.min.js +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.js.map +1 -1
- package/dist/drag.js +8 -2
- package/dist/drag.js.map +1 -1
- package/dist/draw.d.ts +1 -1
- package/dist/fen.js +2 -1
- package/dist/fen.js.map +1 -1
- package/dist/premove.js +61 -45
- package/dist/premove.js.map +1 -1
- package/dist/state.d.ts +2 -0
- package/dist/state.js +2 -1
- package/dist/state.js.map +1 -1
- package/dist/types.d.ts +18 -0
- package/dist/types.js.map +1 -1
- package/dist/util.d.ts +4 -2
- package/dist/util.js +5 -3
- package/dist/util.js.map +1 -1
- package/package.json +1 -1
- package/src/board.ts +10 -7
- package/src/config.ts +4 -3
- package/src/drag.ts +10 -2
- package/src/draw.ts +1 -1
- package/src/fen.ts +2 -1
- package/src/premove.ts +74 -75
- package/src/state.ts +4 -1
- package/src/types.ts +20 -0
- package/src/util.ts +9 -4
package/dist/board.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pos2key, key2pos, opposite, distanceSq, allPos, computeSquareCenter, queenDir, knightDir, samePos, } from './util.js';
|
|
1
|
+
import { pos2key, key2pos, opposite, distanceSq, allPos, computeSquareCenter, queenDir, knightDir, samePos, pos2keyUnsafe, } from './util.js';
|
|
2
2
|
import { premove } from './premove.js';
|
|
3
3
|
export function callUserFunction(f, ...args) {
|
|
4
4
|
if (f)
|
|
@@ -68,9 +68,9 @@ function tryAutoCastle(state, orig, dest) {
|
|
|
68
68
|
return false;
|
|
69
69
|
if (origPos[0] === 4 && !state.pieces.has(dest)) {
|
|
70
70
|
if (destPos[0] === 6)
|
|
71
|
-
dest =
|
|
71
|
+
dest = pos2keyUnsafe([7, destPos[1]]);
|
|
72
72
|
else if (destPos[0] === 2)
|
|
73
|
-
dest =
|
|
73
|
+
dest = pos2keyUnsafe([0, destPos[1]]);
|
|
74
74
|
}
|
|
75
75
|
const rook = state.pieces.get(dest);
|
|
76
76
|
if (!rook || rook.color !== king.color || rook.role !== 'rook')
|
|
@@ -78,12 +78,12 @@ function tryAutoCastle(state, orig, dest) {
|
|
|
78
78
|
state.pieces.delete(orig);
|
|
79
79
|
state.pieces.delete(dest);
|
|
80
80
|
if (origPos[0] < destPos[0]) {
|
|
81
|
-
state.pieces.set(
|
|
82
|
-
state.pieces.set(
|
|
81
|
+
state.pieces.set(pos2keyUnsafe([6, destPos[1]]), king);
|
|
82
|
+
state.pieces.set(pos2keyUnsafe([5, destPos[1]]), rook);
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
state.pieces.set(
|
|
86
|
-
state.pieces.set(
|
|
85
|
+
state.pieces.set(pos2keyUnsafe([2, destPos[1]]), king);
|
|
86
|
+
state.pieces.set(pos2keyUnsafe([3, destPos[1]]), rook);
|
|
87
87
|
}
|
|
88
88
|
return true;
|
|
89
89
|
}
|
|
@@ -316,7 +316,7 @@ export function getSnappedKeyAtDomPos(orig, pos, asWhite, bounds) {
|
|
|
316
316
|
const validSnapPos = allPos.filter(pos2 => samePos(origPos, pos2) ||
|
|
317
317
|
queenDir(origPos[0], origPos[1], pos2[0], pos2[1]) ||
|
|
318
318
|
knightDir(origPos[0], origPos[1], pos2[0], pos2[1]));
|
|
319
|
-
const validSnapCenters = validSnapPos.map(pos2 => computeSquareCenter(
|
|
319
|
+
const validSnapCenters = validSnapPos.map(pos2 => computeSquareCenter(pos2keyUnsafe(pos2), asWhite, bounds));
|
|
320
320
|
const validSnapDistances = validSnapCenters.map(pos2 => distanceSq(pos, pos2));
|
|
321
321
|
const [, closestSnapIndex] = validSnapDistances.reduce((a, b, index) => (a[0] < b ? a : [b, index]), [validSnapDistances[0], 0]);
|
|
322
322
|
return pos2key(validSnapPos[closestSnapIndex]);
|
package/dist/board.js.map
CHANGED
|
@@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AO,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAgB,EAAW,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,OAAO,CAAC"}
|
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 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};
|
|
1
|
+
var Ye=["white","black"];var W=["a","b","c","d","e","f","g","h"],j=["1","2","3","4","5","6","7","8"];var eo=[...j].reverse(),Q=W.flatMap(e=>j.map(o=>e+o)),M=e=>e.every(o=>o>=0&&o<=7)?Q[8*e[0]+e[1]]:void 0,L=e=>M(e),f=e=>[e.charCodeAt(0)-97,e.charCodeAt(1)-49];var De=Q.map(f),oo=Q.map((e,o)=>({key:e,pos:De[o]}));function ro(e){let o,r=()=>(o===void 0&&(o=e()),o);return r.clear=()=>{o=void 0},r}var no=()=>{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}}},U=e=>e==="white"?"black":"white",F=(e,o)=>(e[0]-o[0])**2+(e[1]-o[1])**2,z=(e,o)=>e.role===o.role&&e.color===o.color,le=(e,o)=>e[0]===o[0]&&e[1]===o[1],G=e=>(o,r)=>[(r?o[0]:7-o[0])*e.width/8,(r?7-o[1]:o[1])*e.height/8],C=(e,o)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px)`},Ke=(e,o,r=1)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px) scale(${r})`},Y=(e,o)=>{e.style.visibility=o?"visible":"hidden"},x=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]},de=e=>e.button===2,k=(e,o)=>{let r=document.createElement(e);return o&&(r.className=o),r};function ue(e,o,r){let n=f(e);return o||(n[0]=7-n[0],n[1]=7-n[1]),[r.left+r.width*n[0]/8+r.width/16,r.top+r.height*(7-n[1])/8+r.height/16]}var K=(e,o)=>Math.abs(e-o),J=(e,o,r,n)=>K(e,r)*K(o,n)===2,pe=(e,o,r,n)=>e===r!=(o===n),fe=(e,o,r,n)=>K(e,r)===K(o,n)&&e!==r,ge=(e,o,r,n)=>pe(e,o,r,n)||fe(e,o,r,n),xe=(e,o,r,n)=>Math.max(K(e,r),K(o,n))===1,Ee=(e,o,r,n,t)=>K(e,r)===1&&n===o+(t?1:-1),Ae=(e,o,r,n,t)=>{let i=t?1:-1;return e===r&&(n===o+i||n===o+2*i&&(t?o<=1:o>=6))},ee=(e,o,r,n)=>{let t=r-e,i=n-o;if(t&&i&&Math.abs(t)!==Math.abs(i))return[];let a=Math.sign(t),l=Math.sign(i),d=[],s=e+a,c=o+l;for(;s!==r||c!==n;)d.push([s,c]),s+=a,c+=l;return d.map(M).filter(u=>u!==void 0)},to=e=>{let o=f(e),r=[];return o[0]>0&&r.push([o[0]-1,o[1]]),o[0]<7&&r.push([o[0]+1,o[1]]),r.map(M).filter(n=>n!==void 0)},oe=(e,o)=>{let r=f(e);return r[1]+=o,M(r)};var Z=e=>e.friendlies.has(e.dest.key),ar=e=>e.enemies.has(e.dest.key),io=(e,o,r)=>ee(...e,...o).some(n=>r.has(n)),ao=(e,o,r)=>{let n=r.enemies.get(e);if(n?.role!=="pawn")return!1;let t=n.color==="white"?1:-1,i=f(e),a=f(o);return Ae(...i,...a,n.color==="white")&&!io(i,[a[0],a[1]+t],r.allPieces)},sr=(e,o,r)=>{let n=r.enemies.get(e);return n?.role==="pawn"&&Ee(...f(e),...f(o),n.color==="white")&&(r.friendlies.has(o)||be(oe(o,n.color==="white"?-1:1),r.friendlies,r.enemies,r.lastMove))},cr=e=>[...e.enemies.keys()].some(o=>ao(o,e.dest.key,e)),Ne=(e,o)=>{let r=e.dest.pos;return[...e.enemies].some(([n,t])=>{let i=f(n);return!o?.includes(t.role)&&(t.role==="pawn"&&Ee(...i,...r,t.color==="white")||t.role==="knight"&&J(...i,...r)||t.role==="bishop"&&fe(...i,...r)||t.role==="rook"&&pe(...i,...r)||t.role==="queen"&&ge(...i,...r)||t.role==="king"&&xe(...i,...r))&&(!["bishop","rook","queen"].includes(t.role)||!io(i,r,e.allPieces))})},me=e=>Z(e)&&(be(e.dest.key,e.friendlies,e.enemies,e.lastMove)||Ne(e)),be=(e,o,r,n)=>{if(!e||n&&e!==n[1])return!1;let t=f(e),i=o.get(e);return i?.role==="pawn"&&t[1]===(i.color==="white"?3:4)&&(!n||K(f(n[0])[1],t[1])===2)&&[1,-1].some(a=>{let l=M([t[0]+a,t[1]]);return!!l&&r.get(l)?.role==="pawn"})},lr=(e,o)=>{if(e.unrestrictedPremoves)return!0;let r=ee(...e.orig.pos,...e.dest.pos);o&&r.push(e.dest.key);let n=r.filter(a=>e.friendlies.has(a));if(!n.length)return!0;let t=n[0],i=oe(t,e.color==="white"?-1:1);return n.length===1&&be(t,e.friendlies,e.enemies,e.lastMove)&&!!i&&!r.includes(i)},dr=(e,o)=>{if(e.unrestrictedPremoves)return!0;let r=ee(...e.orig.pos,...e.dest.pos);o&&r.push(e.dest.key);let n=r.filter(c=>e.enemies.has(c));if(n.length>1)return!1;if(!n.length)return!0;let t=n[0],i=e.enemies.get(t);if(!i||i.role!=="pawn")return!0;let a=i.color==="white"?1:-1,l=oe(t,a),d=l?[...to(l).filter(c=>sr(t,c,e)),...[l,oe(l,a)].filter(c=>!!c).filter(c=>ao(t,c,e))]:[],s=[...r,e.orig.key];return d.some(c=>!s.includes(c))},He=(e,o)=>lr(e,o)&&dr(e,o),ur=e=>{let o=e.color==="white"?1:-1;return K(e.orig.pos[0],e.dest.pos[0])>1?!1:K(e.orig.pos[0],e.dest.pos[0])?e.dest.pos[1]!==e.orig.pos[1]+o?!1:e.unrestrictedPremoves||ar(e)?!0:Z(e)?Ne(e):cr(e)||be(M([e.dest.pos[0],e.dest.pos[1]+o]),e.friendlies,e.enemies,e.lastMove)||Ne(e,["pawn"]):Ae(...e.orig.pos,...e.dest.pos,e.color==="white")&&He(e,!0)},pr=e=>J(...e.orig.pos,...e.dest.pos)&&(e.unrestrictedPremoves||!Z(e)||me(e)),so=e=>fe(...e.orig.pos,...e.dest.pos)&&He(e,!1)&&(e.unrestrictedPremoves||!Z(e)||me(e)),co=e=>pe(...e.orig.pos,...e.dest.pos)&&He(e,!1)&&(e.unrestrictedPremoves||!Z(e)||me(e)),fr=e=>so(e)||co(e),gr=e=>xe(...e.orig.pos,...e.dest.pos)&&(e.unrestrictedPremoves||!Z(e)||me(e))||e.canCastle&&e.orig.pos[1]===e.dest.pos[1]&&e.orig.pos[1]===(e.color==="white"?0:7)&&(e.orig.pos[0]===4&&(e.dest.pos[0]===2&&e.rookFilesFriendlies.includes(0)||e.dest.pos[0]===6&&e.rookFilesFriendlies.includes(7))||e.rookFilesFriendlies.includes(e.dest.pos[0]))&&(e.unrestrictedPremoves||ee(...e.orig.pos,e.dest.pos[0]>e.orig.pos[0]?7:1,e.dest.pos[1]).map(o=>e.allPieces.get(o)).every(o=>!o||z(o,{role:"rook",color:e.color}))),mr={pawn:ur,knight:pr,bishop:so,rook:co,queen:fr,king:gr};function qe(e,o){let r=e.pieces,n=e.premovable.castle,t=!!e.premovable.unrestrictedPremoves,i=r.get(o);if(!i||i.color===e.turnColor)return[];let a=i.color,l=new Map([...r].filter(([p,m])=>m.color===a)),d=new Map([...r].filter(([p,m])=>m.color===U(a))),s={key:o,pos:f(o)},c=p=>mr[i.role](p)&&e.premovable.additionalPremoveRequirements(p),u={orig:s,role:i.role,allPieces:r,friendlies:l,enemies:d,unrestrictedPremoves:t,color:a,canCastle:n,rookFilesFriendlies:Array.from(r).filter(([p,m])=>p[1]===(a==="white"?"1":"8")&&m.color===a&&m.role==="rook").map(([p])=>f(p)[0]),lastMove:e.lastMove};return oo.filter(p=>c({...u,dest:p})).map(p=>p.key)}function S(e,...o){e&&setTimeout(()=>e(...o),1)}function lo(e){e.orientation=U(e.orientation),e.animation.current=e.draggable.current=e.selected=void 0}function uo(e,o){for(let[r,n]of o)n?e.pieces.set(r,n):e.pieces.delete(r)}function po(e,o){if(e.check=void 0,o===!0&&(o=e.turnColor),o)for(let[r,n]of e.pieces)n.role==="king"&&n.color===o&&(e.check=r)}function br(e,o,r,n){A(e),e.premovable.current=[o,r],S(e.premovable.events.set,o,r,n)}function E(e){e.premovable.current&&(e.premovable.current=void 0,S(e.premovable.events.unset))}function hr(e,o,r){E(e),e.predroppable.current={role:o,key:r},S(e.predroppable.events.set,o,r)}function A(e){let o=e.predroppable;o.current&&(o.current=void 0,S(o.events.unset))}function yr(e,o,r){if(!e.autoCastle)return!1;let n=e.pieces.get(o);if(!n||n.role!=="king")return!1;let t=f(o),i=f(r);if(t[1]!==0&&t[1]!==7||t[1]!==i[1])return!1;t[0]===4&&!e.pieces.has(r)&&(i[0]===6?r=L([7,i[1]]):i[0]===2&&(r=L([0,i[1]])));let a=e.pieces.get(r);return!a||a.color!==n.color||a.role!=="rook"?!1:(e.pieces.delete(o),e.pieces.delete(r),t[0]<i[0]?(e.pieces.set(L([6,i[1]]),n),e.pieces.set(L([5,i[1]]),a)):(e.pieces.set(L([2,i[1]]),n),e.pieces.set(L([3,i[1]]),a)),!0)}function Te(e,o,r){let n=e.pieces.get(o),t=e.pieces.get(r);if(o===r||!n)return!1;let i=t&&t.color!==n.color?t:void 0;return r===e.selected&&P(e),S(e.events.move,o,r,i),yr(e,o,r)||(e.pieces.set(r,n),e.pieces.delete(o)),e.lastMove=[o,r],e.check=void 0,S(e.events.change),i||!0}function he(e,o,r,n){if(e.pieces.has(r))if(n)e.pieces.delete(r);else return!1;return S(e.events.dropNewPiece,o,r),e.pieces.set(r,o),e.lastMove=[r],e.check=void 0,S(e.events.change),e.movable.dests=void 0,e.turnColor=U(e.turnColor),!0}function fo(e,o,r){let n=Te(e,o,r);return n&&(e.movable.dests=void 0,e.turnColor=U(e.turnColor),e.animation.current=void 0),n}function Be(e,o,r){if(ve(e,o,r)){let n=fo(e,o,r);if(n){let t=e.hold.stop();P(e);let i={premove:!1,ctrlKey:e.stats.ctrlKey,holdTime:t};return n!==!0&&(i.captured=n),S(e.movable.events.after,o,r,i),!0}}else if(wr(e,o,r))return br(e,o,r,{ctrlKey:e.stats.ctrlKey}),P(e),!0;return P(e),!1}function ye(e,o,r,n){let t=e.pieces.get(o);t&&(vr(e,o,r)||n)?(e.pieces.delete(o),he(e,t,r,n),S(e.movable.events.afterNewPiece,t.role,r,{premove:!1,predrop:!1})):t&&Pr(e,o,r)?hr(e,t.role,r):(E(e),A(e)),e.pieces.delete(o),P(e)}function ne(e,o,r){if(S(e.events.select,o),e.selected){if(e.selected===o&&!e.draggable.enabled){P(e),e.hold.cancel();return}else if((e.selectable.enabled||r)&&e.selected!==o&&Be(e,e.selected,o)){e.stats.dragged=!1;return}}(e.selectable.enabled||e.draggable.enabled)&&(go(e,o)||Oe(e,o))&&(Re(e,o),e.hold.start())}function Re(e,o){e.selected=o,Oe(e,o)?e.premovable.customDests||(e.premovable.dests=qe(e,o)):e.premovable.dests=void 0}function P(e){e.selected=void 0,e.premovable.dests=void 0,e.hold.cancel()}function go(e,o){let r=e.pieces.get(o);return!!r&&(e.movable.color==="both"||e.movable.color===r.color&&e.turnColor===r.color)}var ve=(e,o,r)=>o!==r&&go(e,o)&&(e.movable.free||!!e.movable.dests?.get(o)?.includes(r));function vr(e,o,r){let n=e.pieces.get(o);return!!n&&(o===r||!e.pieces.has(r))&&(e.movable.color==="both"||e.movable.color===n.color&&e.turnColor===n.color)}function Oe(e,o){let r=e.pieces.get(o);return!!r&&e.premovable.enabled&&e.movable.color===r.color&&e.turnColor!==r.color}var wr=(e,o,r)=>o!==r&&Oe(e,o)&&(e.premovable.customDests?.get(o)??qe(e,o)).includes(r);function Pr(e,o,r){let n=e.pieces.get(o),t=e.pieces.get(r);return!!n&&(!t||t.color!==e.movable.color)&&e.predroppable.enabled&&(n.role!=="pawn"||r[1]!=="1"&&r[1]!=="8")&&e.movable.color===n.color&&e.turnColor!==n.color}function mo(e,o){let r=e.pieces.get(o);return!!r&&e.draggable.enabled&&(e.movable.color==="both"||e.movable.color===r.color&&(e.turnColor===r.color||e.premovable.enabled))}function bo(e){let o=e.premovable.current;if(!o)return!1;let r=o[0],n=o[1],t=!1;if(ve(e,r,n)){let i=fo(e,r,n);if(i){let a={premove:!0};i!==!0&&(a.captured=i),S(e.movable.events.after,r,n,a),t=!0}}return E(e),t}function ho(e,o){let r=e.predroppable.current,n=!1;if(!r)return!1;if(o(r)){let t={role:r.role,color:e.movable.color};he(e,t,r.key)&&(S(e.movable.events.afterNewPiece,r.role,r.key,{premove:!1,predrop:!0}),n=!0)}return A(e),n}function te(e){E(e),A(e),P(e)}function Ve(e){e.movable.color=e.movable.dests=e.animation.current=void 0,te(e)}function N(e,o,r){let n=Math.floor(8*(e[0]-r.left)/r.width);o||(n=7-n);let t=7-Math.floor(8*(e[1]-r.top)/r.height);return o||(t=7-t),n>=0&&n<8&&t>=0&&t<8?M([n,t]):void 0}function yo(e,o,r,n){let t=f(e),i=De.filter(s=>le(t,s)||ge(t[0],t[1],s[0],s[1])||J(t[0],t[1],s[0],s[1])),l=i.map(s=>ue(L(s),r,n)).map(s=>F(o,s)),[,d]=l.reduce((s,c,u)=>s[0]<c?s:[c,u],[l[0],0]);return M(i[d])}var h=e=>e.orientation==="white";var Fe="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR",Sr={p:"pawn",r:"rook",n:"knight",b:"bishop",q:"queen",k:"king"},Mr={pawn:"p",rook:"r",knight:"n",bishop:"b",queen:"q",king:"k"};function we(e){e==="start"&&(e=Fe);let o=new Map,r=7,n=0;for(let t of e)switch(t){case" ":case"[":return o;case"/":if(--r,r<0)return o;n=0;break;case"~":{let i=M([n-1,r]),a=i&&o.get(i);a&&(a.promoted=!0);break}default:{let i=t.charCodeAt(0);if(i<57)n+=i-48;else{let a=t.toLowerCase(),l=M([n,r]);l&&o.set(l,{role:Sr[a],color:t===a?"black":"white"}),++n}}}return o}function vo(e){return eo.map(o=>W.map(r=>{let n=e.get(r+o);if(n){let t=Mr[n.role];return n.color==="white"&&(t=t.toUpperCase()),n.promoted&&(t+="~"),t}else return"1"}).join("")).join("/").replace(/1{2,}/g,o=>o.length.toString())}function Ge(e,o){o.animation&&(We(e.animation,o.animation),(e.animation.duration||0)<70&&(e.animation.enabled=!1))}function Pe(e,o){if(o.movable?.dests&&(e.movable.dests=void 0),o.drawable?.autoShapes&&(e.drawable.autoShapes=[]),We(e,o),o.fen&&(e.pieces=we(o.fen),e.drawable.shapes=o.drawable?.shapes||[]),"check"in o&&po(e,o.check||!1),"lastMove"in o&&!o.lastMove?e.lastMove=void 0:o.lastMove&&(e.lastMove=o.lastMove),e.selected&&Re(e,e.selected),Ge(e,o),!e.movable.rookCastle&&e.movable.dests){let r=e.movable.color==="white"?"1":"8",n="e"+r,t=e.movable.dests.get(n),i=e.pieces.get(n);if(!t||!i||i.role!=="king")return;e.movable.dests.set(n,t.filter(a=>!(a==="a"+r&&t.includes("c"+r))&&!(a==="h"+r&&t.includes("g"+r))))}}function We(e,o){for(let r in o)r==="__proto__"||r==="constructor"||!Object.prototype.hasOwnProperty.call(o,r)||(Object.prototype.hasOwnProperty.call(e,r)&&wo(e[r])&&wo(o[r])?We(e[r],o[r]):e[r]=o[r])}function wo(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?Kr(e,o):O(e,o);function O(e,o){let r=e(o);return o.dom.redraw(),r}var ze=(e,o)=>({key:e,pos:f(e),piece:o}),kr=(e,o)=>o.sort((r,n)=>F(e.pos,r.pos)-F(e.pos,n.pos))[0];function Dr(e,o){let r=new Map,n=[],t=new Map,i=[],a=[],l=new Map,d,s,c;for(let[u,p]of e)l.set(u,ze(u,p));for(let u of Q)d=o.pieces.get(u),s=l.get(u),d?s?z(d,s.piece)||(i.push(s),a.push(ze(u,d))):a.push(ze(u,d)):s&&i.push(s);for(let u of a)s=kr(u,i.filter(p=>z(u.piece,p.piece))),s&&(c=[s.pos[0]-u.pos[0],s.pos[1]-u.pos[1]],r.set(u.key,c.concat(c)),n.push(s.key));for(let u of i)n.includes(u.key)||t.set(u.key,u.piece);return{anims:r,fadings:t}}function Po(e,o){let r=e.animation.current;if(r===void 0){e.dom.destroyed||e.dom.redrawNow();return}let n=1-(o-r.start)*r.frequency;if(n<=0)e.animation.current=void 0,e.dom.redrawNow();else{let t=xr(n);for(let i of r.plan.anims.values())i[2]=i[0]*t,i[3]=i[1]*t;e.dom.redrawNow(!0),requestAnimationFrame((i=performance.now())=>Po(e,i))}}function Kr(e,o){let r=new Map(o.pieces),n=e(o),t=Dr(r,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||Po(o,performance.now())}else o.dom.redraw();return n}var xr=e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1;var Er=["green","red","blue","yellow"];function So(e,o){if(o.touches&&o.touches.length>1)return;o.stopPropagation(),o.preventDefault(),o.ctrlKey?P(e):te(e);let r=x(o),n=N(r,h(e),e.dom.bounds());n&&(e.drawable.current={orig:n,pos:r,brush:Ar(o),snapToValidMove:e.drawable.defaultSnapToValidMove},Mo(e))}function Mo(e){requestAnimationFrame(()=>{let o=e.drawable.current;if(o){let r=N(o.pos,h(e),e.dom.bounds());r||(o.snapToValidMove=!1);let n=o.snapToValidMove?yo(o.orig,o.pos,h(e),e.dom.bounds()):r;n!==o.mouseSq&&(o.mouseSq=n,o.dest=n!==o.orig?n:void 0,e.dom.redrawNow()),Mo(e)}})}function Co(e,o){e.drawable.current&&(e.drawable.current.pos=x(o))}function ko(e){let o=e.drawable.current;o&&(o.mouseSq&&Nr(e.drawable,o),$e(e))}function $e(e){e.drawable.current&&(e.drawable.current=void 0,e.dom.redraw())}function Do(e){e.drawable.shapes.length&&(e.drawable.shapes=[],e.dom.redraw(),Ko(e.drawable))}function Ar(e){let o=(e.shiftKey||e.ctrlKey)&&de(e),r=e.altKey||e.metaKey||e.getModifierState?.("AltGraph");return Er[(o?1:0)+(r?2:0)]}function Nr(e,o){let r=t=>t.orig===o.orig&&t.dest===o.dest,n=e.shapes.find(r);n&&(e.shapes=e.shapes.filter(t=>!r(t))),(!n||n.brush!==o.brush)&&e.shapes.push({orig:o.orig,dest:o.dest,brush:o.brush}),Ko(e)}function Ko(e){e.onChange&&e.onChange(e.shapes)}function xo(e,o){if(!(e.trustAllEvents||o.isTrusted)||o.buttons!==void 0&&o.buttons>1||o.touches&&o.touches.length>1)return;let r=e.dom.bounds(),n=x(o),t=N(n,h(e),r);if(!t)return;let i=e.pieces.get(t),a=e.selected;if(!a&&e.drawable.enabled&&(e.drawable.eraseOnMovablePieceClick||!i||i.color!==e.turnColor)&&(e.pixelCoordsOfMouchDownToMaybeClearShapes=n),o.cancelable!==!1&&(!o.touches||e.blockTouchScroll||i||a||qr(e,n)))o.preventDefault();else if(o.touches)return;let l=!!e.premovable.current,d=!!e.predroppable.current;e.stats.ctrlKey=o.ctrlKey,e.selected&&ve(e,e.selected,t)?R(u=>ne(u,t),e):ne(e,t);let s=e.selected===t,c=qo(e,t);if(i&&c&&s&&mo(e,t)){e.draggable.current={orig:t,piece:i,origPos:n,pos:n,started:e.draggable.autoDistance&&e.stats.dragged,element:c,previouslySelected:a,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}`,C(u,G(r)(f(t),h(e))),Y(u,!0)),Ie(e)}else l&&E(e),d&&A(e);e.dom.redraw()}function qr(e,o){let r=h(e),n=e.dom.bounds(),t=Math.pow(e.touchIgnoreRadius*n.width/16,2)*2;for(let i of e.pieces.keys()){let a=ue(i,r,n);if(F(a,o)<=t)return!0}return!1}function Eo(e,o,r,n){let t="a0";e.pieces.set(t,o),e.dom.redraw();let i=x(r);e.draggable.current={orig:t,piece:o,origPos:i,pos:i,started:!0,element:()=>qo(e,t),originTarget:r.target,newPiece:!0,force:!!n,keyHasChanged:!1},Ie(e)}function Ie(e){requestAnimationFrame(()=>{let o=e.draggable.current;if(!o)return;e.animation.current?.plan.anims.has(o.orig)&&(e.animation.current=void 0);let r=e.pieces.get(o.orig);if(!r||!z(r,o.piece))$(e);else if(!o.started&&F(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 n=e.dom.bounds();C(o.element,[o.pos[0]-n.left-n.width/16,o.pos[1]-n.top-n.height/16]),o.keyHasChanged||=o.orig!==N(o.pos,h(e),n)}Ie(e)})}function Ao(e,o){e.draggable.current&&(!o.touches||o.touches.length<2)&&(e.draggable.current.pos=x(o))}function No(e,o){let r=x(o);r&&e.pixelCoordsOfMouchDownToMaybeClearShapes&&le(r,e.pixelCoordsOfMouchDownToMaybeClearShapes)&&Do(e),e.pixelCoordsOfMouchDownToMaybeClearShapes=void 0;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),A(e);let t=x(o)||n.pos,i=N(t,h(e),e.dom.bounds());i&&n.started&&n.orig!==i?n.newPiece?ye(e,n.orig,i,n.force):(e.stats.ctrlKey=o.ctrlKey,Be(e,n.orig,i)&&(e.stats.dragged=!0)):n.newPiece?e.pieces.delete(n.orig):e.draggable.deleteOnDropOff&&!i&&(e.pieces.delete(n.orig),S(e.events.change)),(n.orig===n.previouslySelected||n.keyHasChanged)&&(n.orig===i||!i)?P(e):e.selectable.enabled||P(e),Ho(e),e.draggable.current=void 0,e.dom.redraw()}function $(e){let o=e.draggable.current;o&&(o.newPiece&&e.pieces.delete(o.orig),e.draggable.current=void 0,P(e),Ho(e),e.dom.redraw())}function Ho(e){let o=e.dom.elements;o.ghost&&Y(o.ghost,!1)}function qo(e,o){let r=e.dom.elements.board.firstChild;for(;r;){if(r.cgKey===o&&r.tagName==="PIECE")return r;r=r.nextSibling}}function Bo(e,o){e.exploding={stage:1,keys:o},e.dom.redraw(),setTimeout(()=>{To(e,2),setTimeout(()=>To(e,void 0),120)},120)}function To(e,o){e.exploding&&(o?e.exploding.stage=o:e.exploding=void 0,e.dom.redraw())}function Ro(e,o){function r(){lo(e),o()}return{set(n){n.orientation&&n.orientation!==e.orientation&&r(),Ge(e,n),(n.fen?R:O)(t=>Pe(t,n),e)},state:e,getFen:()=>vo(e.pieces),toggleOrientation:r,setPieces(n){R(t=>uo(t,n),e)},selectSquare(n,t){n?R(i=>ne(i,n,t),e):e.selected&&(P(e),e.dom.redraw())},move(n,t){R(i=>Te(i,n,t),e)},newPiece(n,t){R(i=>he(i,n,t),e)},playPremove(){if(e.premovable.current){if(R(bo,e))return!0;e.dom.redraw()}return!1},playPredrop(n){if(e.predroppable.current){let t=ho(e,n);return e.dom.redraw(),t}return!1},cancelPremove(){O(E,e)},cancelPredrop(){O(A,e)},cancelMove(){O(n=>{te(n),$(n)},e)},stop(){O(n=>{Ve(n),$(n)},e)},explode(n){Bo(e,n)},setAutoShapes(n){O(t=>t.drawable.autoShapes=n,e)},setShapes(n){O(t=>t.drawable.shapes=n.slice(),e)},getKeyAtDomPos(n){return N(n,h(e),e.dom.bounds())},redrawAll:o,dragNewPiece(n,t,i){Eo(e,n,t,i)},destroy(){Ve(e),e.dom.unbind&&e.dom.unbind(),e.dom.destroyed=!0}}}function Oo(){return{pieces:we(Fe),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,additionalPremoveRequirements:e=>!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,eraseOnMovablePieceClick:!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:no()}}function Fo(){let e=v("defs"),o=w(v("filter"),{id:"cg-filter-blur"});return o.appendChild(w(v("feGaussianBlur"),{stdDeviation:"0.013"})),e.appendChild(o),e}function Go(e,o){let r=e.drawable,n=r.current,t=n&&n.mouseSq?n:void 0,i=new Map,a=e.dom.bounds(),l=r.autoShapes.filter(c=>!c.piece);for(let c of r.shapes.concat(l).concat(t?[t]:[])){if(!c.dest)continue;let u=i.get(c.dest)??new Set,p=Me(Se(f(c.orig),e.orientation),a),m=Me(Se(f(c.dest),e.orientation),a);u.add(Ue(p,m)),i.set(c.dest,u)}let d=[];for(let c of r.shapes.concat(l))d.push({shape:c,current:!1,hash:Vo(c,je(c.dest,i),!1,a)});t&&d.push({shape:t,current:!0,hash:Vo(t,je(t.dest,i),!0,a)});let s=d.map(c=>c.hash).join(";");s!==e.drawable.prevSvgHash&&(e.drawable.prevSvgHash=s,Br(r,d,o),Rr(d,o,c=>Lr(e,c,r.brushes,i,a)))}function Br(e,o,r){for(let n of[r.shapes,r.shapesBelow]){let t=n.querySelector("defs"),i=o.filter(s=>n===r.shapesBelow==!!s.shape.below),a=new Map;for(let s of i.filter(c=>c.shape.dest&&c.shape.brush)){let c=Wo(e.brushes[s.shape.brush],s.shape.modifiers),{key:u,color:p}=zo(s.shape);u&&p&&a.set(u,{key:u,color:p,opacity:1,lineWidth:1}),a.set(c.key,c)}let l=new Set,d=t.firstElementChild;for(;d;)l.add(d.getAttribute("cgKey")),d=d.nextElementSibling;for(let[s,c]of a.entries())l.has(s)||t.appendChild(Wr(c))}}function Rr(e,o,r){for(let[n,t]of[[o.shapes,o.custom],[o.shapesBelow,o.customBelow]]){let[i,a]=[n,t].map(s=>s.querySelector("g")),l=e.filter(s=>n===o.shapesBelow==!!s.shape.below),d=new Map;for(let s of l)d.set(s.hash,!1);for(let s of[i,a]){let c=[],u=s.firstElementChild,p;for(;u;)p=u.getAttribute("cgHash"),d.has(p)?d.set(p,!0):c.push(u),u=u.nextElementSibling;for(let m of c)s.removeChild(m)}for(let s of l.filter(c=>!d.get(c.hash)))for(let c of r(s))c.isCustom?a.appendChild(c.el):i.appendChild(c.el)}}function Vo({orig:e,dest:o,brush:r,piece:n,modifiers:t,customSvg:i,label:a,below:l},d,s,c){return[c.width,c.height,s,e,o,r,d&&"-",n&&Or(n),t&&Vr(t),i&&`custom-${Lo(i.html)},${i.center?.[0]??"o"}`,a&&`label-${Lo(a.text)}`,l&&"below"].filter(u=>u).join(",")}function Or(e){return[e.color,e.role,e.scale].filter(o=>o).join(",")}function Vr(e){return[e.lineWidth,e.hilite].filter(o=>o).join(",")}function Lo(e){let o=0;for(let r=0;r<e.length;r++)o=(o<<5)-o+e.charCodeAt(r)>>>0;return o.toString()}function Lr(e,{shape:o,current:r,hash:n},t,i,a){let l=Me(Se(f(o.orig),e.orientation),a),d=o.dest?Me(Se(f(o.dest),e.orientation),a):l,s=o.brush&&Wo(t[o.brush],o.modifiers),c=i.get(o.dest),u=[];if(s){let p=w(v("g"),{cgHash:n});u.push({el:p}),l[0]!==d[0]||l[1]!==d[1]?p.appendChild(Gr(o,s,l,d,r,je(o.dest,i))):p.appendChild(Fr(t[o.brush],l,r,a))}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:zr(p,n,l,d,c,m),isCustom:!0})}if(o.customSvg){let p=o.customSvg.center??"orig",[m,y]=p==="label"?Io(l,d,c).map(B=>B-.5):p==="dest"?d:l,g=w(v("g"),{transform:`translate(${m},${y})`,cgHash:n});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 Fr(e,o,r,n){let t=$r(),i=(n.width+n.height)/(4*Math.max(n.width,n.height));return w(v("circle"),{stroke:e.color,"stroke-width":t[r?0:1],fill:"none",opacity:$o(e,r),cx:o[0],cy:o[1],r:i-t[1]/2})}function Gr(e,o,r,n,t,i){function a(s){let c=jr(i&&!t),u=n[0]-r[0],p=n[1]-r[1],m=Math.atan2(p,u),y=Math.cos(m)*c,g=Math.sin(m)*c,B=zo(e);return w(v("line"),{stroke:s?B.color:o.color,"stroke-width":Ir(o,t)*(s?1.14:1),"stroke-linecap":"round","marker-end":`url(#arrowhead-${s?B.key:o.key})`,opacity:e.modifiers?.hilite?1:$o(o,t),x1:r[0],y1:r[1],x2:n[0]-y,y2:n[1]-g})}if(!e.modifiers?.hilite)return a(!1);let l=w(v("g"),{opacity:o.opacity}),d=w(v("g"),{filter:"url(#cg-filter-blur)"});return d.appendChild(Ur(r,n)),d.appendChild(a(!0)),l.appendChild(d),l.appendChild(a(!1)),l}function Wr(e){let o=w(v("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(w(v("path"),{d:"M0,0 V4 L3,2 Z",fill:e.color})),o.setAttribute("cgKey",e.key),o}function zr(e,o,r,n,t,i){let l=.4*.75**e.text.length,d=Io(r,n,t),s=i==="tr"?.4:0,c=w(v("g"),{transform:`translate(${d[0]+s},${d[1]-s})`,cgHash:o});c.appendChild(w(v("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=w(v("text"),{"font-size":l,"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 je(e,o){return(e&&o.has(e)&&o.get(e).size>1)===!0}function v(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function w(e,o){for(let r in o)Object.prototype.hasOwnProperty.call(o,r)&&e.setAttribute(r,o[r]);return e}function Wo(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(r=>r).join("")}:e}function $r(){return[3/64,4/64]}function Ir(e,o){return(e.lineWidth||10)*(o?.85:1)/64}function zo(e){let o=e.modifiers?.hilite;return{key:o&&`hilite-${o.replace("#","")}`,color:o}}function $o(e,o){return(e.opacity||1)*(o?.9:1)}function jr(e){return(e?20:10)/64}function Me(e,o){let r=Math.min(1,o.width/o.height),n=Math.min(1,o.height/o.width);return[(e[0]-3.5)*r,(3.5-e[1])*n]}function Ur(e,o){let r={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 w(v("rect"),{x:r.from[0],y:r.from[1],width:r.to[0]-r.from[0],height:r.to[1]-r.from[1],fill:"none",stroke:"none"})}function Ue(e,o,r=!0){let n=Math.atan2(o[1]-e[1],o[0]-e[0])+Math.PI;return r?(Math.round(n*8/Math.PI)+16)%16:n}function Zr(e,o){return Math.sqrt([e[0]-o[0],e[1]-o[1]].reduce((r,n)=>r+n*n,0))}function Io(e,o,r){let n=Zr(e,o),t=Ue(e,o,!1);if(r&&(n-=33/64,r.size>1)){n-=10/64;let i=Ue(e,o);(r.has((i+1)%16)||r.has((i+15)%16))&&i&1&&(n-=.4)}return[e[0]-Math.cos(t)*n,e[1]-Math.sin(t)*n].map(i=>i+.5)}function Uo(e,o){e.innerHTML="",e.classList.add("cg-wrap");for(let c of Ye)e.classList.toggle("orientation-"+c,o.orientation===c);e.classList.toggle("manipulable",!o.viewOnly);let r=k("cg-container");e.appendChild(r);let n=k("cg-board");r.appendChild(n);let t,i,a,l,d;if(o.drawable.visible&&([t,i]=["cg-shapes-below","cg-shapes"].map(c=>jo(c,!0)),[a,l]=["cg-custom-below","cg-custom-svgs"].map(c=>jo(c,!1)),d=k("cg-auto-pieces"),r.appendChild(t),r.appendChild(a),r.appendChild(i),r.appendChild(l),r.appendChild(d)),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;W.forEach((m,y)=>r.appendChild(Ze(j.map(g=>m+g),"squares rank"+p(y)+c+u)))}else r.appendChild(Ze(j,"ranks"+c+u)),r.appendChild(Ze(W,"files"+c))}let s;return o.draggable.enabled&&o.draggable.showGhost&&(s=k("piece","ghost"),Y(s,!1),r.appendChild(s)),{board:n,container:r,wrap:e,ghost:s,shapes:i,shapesBelow:t,custom:l,customBelow:a,autoPieces:d}}function jo(e,o){let r=w(v("svg"),{class:e,viewBox:o?"-4 -4 8 8":"-3.5 -3.5 8 8",preserveAspectRatio:"xMidYMid slice"});return o&&r.appendChild(Fo()),r.appendChild(v("g")),r}function Ze(e,o){let r=k("coords",o),n;for(let t of e)n=k("coord"),n.textContent=t,r.appendChild(n);return r}function Zo(e,o){if(!e.dropmode.active)return;E(e),A(e);let r=e.dropmode.piece;if(r){e.pieces.set("a0",r);let n=x(o),t=n&&N(n,h(e),e.dom.bounds());t&&ye(e,"a0",t)}e.dom.redraw()}function Xo(e,o){let r=e.dom.elements.board;if("ResizeObserver"in window&&new ResizeObserver(o).observe(e.dom.elements.wrap),(e.disableContextMenu||e.drawable.enabled)&&r.addEventListener("contextmenu",t=>t.preventDefault()),e.viewOnly)return;let n=Xr(e);r.addEventListener("touchstart",n,{passive:!1}),r.addEventListener("mousedown",n,{passive:!1})}function Qo(e,o){let r=[];if("ResizeObserver"in window||r.push(ie(document.body,"chessground.resize",o)),!e.viewOnly){let n=_o(e,Ao,Co),t=_o(e,No,ko);for(let a of["touchmove","mousemove"])r.push(ie(document,a,n));for(let a of["touchend","mouseup"])r.push(ie(document,a,t));let i=()=>e.dom.bounds.clear();r.push(ie(document,"scroll",i,{capture:!0,passive:!0})),r.push(ie(window,"resize",i,{passive:!0}))}return()=>r.forEach(n=>n())}function ie(e,o,r,n){return e.addEventListener(o,r,n),()=>e.removeEventListener(o,r,n)}var Xr=e=>o=>{e.draggable.current?$(e):e.drawable.current?$e(e):o.shiftKey||de(o)?e.drawable.enabled&&So(e,o):e.viewOnly||(e.dropmode.active?Zo(e,o):xo(e,o))},_o=(e,o,r)=>n=>{e.drawable.current?e.drawable.enabled&&r(e,n):e.viewOnly||o(e,n)};function Jo(e){let o=h(e),r=G(e.dom.bounds()),n=e.dom.elements.board,t=e.pieces,i=e.animation.current,a=i?i.plan.anims:new Map,l=i?i.plan.fadings:new Map,d=e.draggable.current,s=Yr(e),c=new Set,u=new Set,p=new Map,m=new Map,y,g,B,I,D,_,Ce,H,ke,se;for(g=n.firstChild;g;){if(y=g.cgKey,or(g))if(B=t.get(y),D=a.get(y),_=l.get(y),I=g.cgPiece,g.cgDragging&&(!d||d.orig!==y)&&(g.classList.remove("dragging"),C(g,r(f(y),o)),g.cgDragging=!1),!_&&g.cgFading&&(g.cgFading=!1,g.classList.remove("fading")),B){if(D&&g.cgAnimating&&I===ae(B)){let b=f(y);b[0]+=D[2],b[1]+=D[3],g.classList.add("anim"),C(g,r(b,o))}else g.cgAnimating&&(g.cgAnimating=!1,g.classList.remove("anim"),C(g,r(f(y),o)),e.addPieceZIndex&&(g.style.zIndex=_e(f(y),o)));I===ae(B)&&(!_||!g.cgFading)?c.add(y):_&&I===ae(_)?(g.classList.add("fading"),g.cgFading=!0):Xe(p,I,g)}else Xe(p,I,g);else if(rr(g)){let b=g.className;s.get(y)===b?u.add(y):Xe(m,b,g)}g=g.nextSibling}for(let[b,X]of s)if(!u.has(b)){ke=m.get(X),se=ke&&ke.pop();let q=r(f(b),o);if(se)se.cgKey=b,C(se,q);else{let T=k("square",X);T.cgKey=b,C(T,q),n.insertBefore(T,n.firstChild)}}for(let[b,X]of t)if(D=a.get(b),!c.has(b))if(Ce=p.get(ae(X)),H=Ce&&Ce.pop(),H){H.cgKey=b,H.cgFading&&(H.classList.remove("fading"),H.cgFading=!1);let q=f(b);e.addPieceZIndex&&(H.style.zIndex=_e(q,o)),D&&(H.cgAnimating=!0,H.classList.add("anim"),q[0]+=D[2],q[1]+=D[3]),C(H,r(q,o))}else{let q=ae(X),T=k("piece",q),ce=f(b);T.cgPiece=q,T.cgKey=b,D&&(T.cgAnimating=!0,ce[0]+=D[2],ce[1]+=D[3]),C(T,r(ce,o)),e.addPieceZIndex&&(T.style.zIndex=_e(ce,o)),n.appendChild(T)}for(let b of p.values())Yo(e,b);for(let b of m.values())Yo(e,b)}function er(e){let o=h(e),r=G(e.dom.bounds()),n=e.dom.elements.board.firstChild;for(;n;)(or(n)&&!n.cgAnimating||rr(n))&&C(n,r(f(n.cgKey),o)),n=n.nextSibling}function Qe(e){let o=e.dom.elements.wrap.getBoundingClientRect(),r=e.dom.elements.container,n=o.height/o.width,t=Math.floor(o.width*window.devicePixelRatio/8)*8/window.devicePixelRatio,i=t*n;r.style.width=t+"px",r.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 or=e=>e.tagName==="PIECE",rr=e=>e.tagName==="SQUARE";function Yo(e,o){for(let r of o)e.dom.elements.board.removeChild(r)}function _e(e,o){let n=e[1];return`${o?10-n:3+n}`}var ae=e=>`${e.color} ${e.role}`;function Yr(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 a of t)V(o,a,"move-dest"+(e.pieces.has(a)?" oc":""));let i=e.premovable.customDests?.get(e.selected)??e.premovable.dests;if(i)for(let a of i)V(o,a,"premove-dest"+(e.pieces.has(a)?" oc":""))}let r=e.premovable.current;if(r)for(let t of r)V(o,t,"current-premove");else e.predroppable.current&&V(o,e.predroppable.current.key,"current-premove");let n=e.exploding;if(n)for(let t of n.keys)V(o,t,"exploding"+n.stage);return e.highlight.custom&&e.highlight.custom.forEach((t,i)=>{V(o,i,t)}),o}function V(e,o,r){let n=e.get(o);n?e.set(o,`${n} ${r}`):e.set(o,r)}function Xe(e,o,r){let n=e.get(o);n?n.push(r):e.set(o,[r])}function nr(e,o,r){let n=new Map,t=[];for(let l of e)n.set(l.hash,!1);let i=o.firstElementChild,a;for(;i;)a=i.getAttribute("cgHash"),n.has(a)?n.set(a,!0):t.push(i),i=i.nextElementSibling;for(let l of t)o.removeChild(l);for(let l of e)n.get(l.hash)||o.appendChild(r(l))}function tr(e,o){let n=e.drawable.autoShapes.filter(t=>t.piece).map(t=>({shape:t,hash:en(t),current:!1}));nr(n,o,t=>Jr(e,t,e.dom.bounds()))}function ir(e){let o=h(e),r=G(e.dom.bounds()),n=e.dom.elements.autoPieces?.firstChild;for(;n;)Ke(n,r(f(n.cgKey),o),n.cgScale),n=n.nextSibling}function Jr(e,{shape:o,hash:r},n){let t=o.orig,i=o.piece?.role,a=o.piece?.color,l=o.piece?.scale,d=k("piece",`${i} ${a}`);return d.setAttribute("cgHash",r),d.cgKey=t,d.cgScale=l,Ke(d,G(n)(f(t),h(e)),l),d}var en=e=>[e.orig,e.piece?.role,e.piece?.color,e.piece?.scale].join(",");function ot({el:e,config:o}){return rn(e,o)}function rn(e,o){let r=Oo();Pe(r,o||{});function n(){let t="dom"in r?r.dom.unbind:void 0,i=Uo(e,r),a=ro(()=>i.board.getBoundingClientRect()),l=c=>{Jo(s),i.autoPieces&&tr(s,i.autoPieces),!c&&i.shapes&&Go(s,i)},d=()=>{Qe(s),er(s),i.autoPieces&&ir(s)},s=r;return s.dom={elements:i,bounds:a,redraw:nn(l),redrawNow:l,unbind:t},s.drawable.prevSvgHash="",Qe(s),l(!1),Xo(s,d),t||(s.dom.unbind=Qo(s,d)),s.events.insert&&s.events.insert(i),s}return Ro(n(),n)}function nn(e){let o=!1;return()=>{o||(o=!0,requestAnimationFrame(()=>{e(),o=!1}))}}export{rn as Chessground,ot as initModule};
|
package/dist/config.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export interface Config {
|
|
|
45
45
|
dests?: cg.Key[];
|
|
46
46
|
customDests?: cg.Dests;
|
|
47
47
|
unrestrictedPremoves?: boolean;
|
|
48
|
+
additionalPremoveRequirements?: Partial<Record<cg.Role, cg.Mobility>>;
|
|
48
49
|
events?: {
|
|
49
50
|
set?: (orig: cg.Key, dest: cg.Key, metadata?: cg.SetPremoveMetadata) => void;
|
|
50
51
|
unset?: () => void;
|
|
@@ -78,7 +79,7 @@ export interface Config {
|
|
|
78
79
|
enabled?: boolean;
|
|
79
80
|
visible?: boolean;
|
|
80
81
|
defaultSnapToValidMove?: boolean;
|
|
81
|
-
|
|
82
|
+
eraseOnMovablePieceClick?: boolean;
|
|
82
83
|
shapes?: DrawShape[];
|
|
83
84
|
autoShapes?: DrawShape[];
|
|
84
85
|
brushes?: DrawBrushes;
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,IAAI,IAAI,OAAO,E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CAChE,CACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,IAAS,EAAE,MAAW;IACvC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,aAAa,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC;YACpG,SAAS;QACX,IACE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC;YAC/C,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACxB,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAE1B,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;;YAC/B,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,CAAU;IAC/B,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IACvC,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC"}
|
package/dist/drag.js
CHANGED
|
@@ -16,8 +16,8 @@ export function start(s, e) {
|
|
|
16
16
|
const previouslySelected = s.selected;
|
|
17
17
|
if (!previouslySelected &&
|
|
18
18
|
s.drawable.enabled &&
|
|
19
|
-
(s.drawable.
|
|
20
|
-
|
|
19
|
+
(s.drawable.eraseOnMovablePieceClick || !piece || piece.color !== s.turnColor))
|
|
20
|
+
s.pixelCoordsOfMouchDownToMaybeClearShapes = position;
|
|
21
21
|
// Prevent touch scroll and create no corresponding mouse event, if there
|
|
22
22
|
// is an intent to interact with the board.
|
|
23
23
|
if (e.cancelable !== false &&
|
|
@@ -138,6 +138,12 @@ export function move(s, e) {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
export function end(s, e) {
|
|
141
|
+
const position = util.eventPosition(e);
|
|
142
|
+
if (position &&
|
|
143
|
+
s.pixelCoordsOfMouchDownToMaybeClearShapes &&
|
|
144
|
+
util.samePos(position, s.pixelCoordsOfMouchDownToMaybeClearShapes))
|
|
145
|
+
drawClear(s);
|
|
146
|
+
s.pixelCoordsOfMouchDownToMaybeClearShapes = undefined;
|
|
141
147
|
const cur = s.draggable.current;
|
|
142
148
|
if (!cur)
|
|
143
149
|
return;
|
package/dist/drag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drag.js","sourceRoot":"","sources":["../src/drag.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAgBjC,MAAM,UAAU,KAAK,CAAC,CAAQ,EAAE,CAAgB;IAC9C,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,IAAI,CAAC,CAAC,SAAS,CAAC;QAAE,OAAO,CAAC,4CAA4C;IAC5F,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC,OAAO,GAAG,CAAC;QAAE,OAAO,CAAC,2BAA2B;IACjF,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,gCAAgC;IAC/E,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,EAC3B,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAE,EACjC,IAAI,GA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AAI,GAAG,EAAE,CAAC;QACR,IAAI,GAAG,CAAC,QAAQ;YAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC,CAAC,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC;QAChC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAClB,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IACjB,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,CAAQ;IAClC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC;IACzB,IAAI,CAAC,CAAC,KAAK;QAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED,SAAS,iBAAiB,CAAC,CAAQ,EAAE,GAAW;IAC9C,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;IACzC,OAAO,EAAE,EAAE,CAAC;QACV,IAAK,EAAmB,CAAC,KAAK,KAAK,GAAG,IAAK,EAAmB,CAAC,OAAO,KAAK,OAAO;YAChF,OAAO,EAAkB,CAAC;QAC5B,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC;IACtB,CAAC;IACD,OAAO;AACT,CAAC"}
|
package/dist/draw.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export interface Drawable {
|
|
|
42
42
|
enabled: boolean;
|
|
43
43
|
visible: boolean;
|
|
44
44
|
defaultSnapToValidMove: boolean;
|
|
45
|
-
|
|
45
|
+
eraseOnMovablePieceClick: boolean;
|
|
46
46
|
onChange?: (shapes: DrawShape[]) => void;
|
|
47
47
|
shapes: DrawShape[];
|
|
48
48
|
autoShapes: DrawShape[];
|
package/dist/fen.js
CHANGED
package/dist/fen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fen.js","sourceRoot":"","sources":["../src/fen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,MAAM,CAAC,MAAM,OAAO,GAAW,6CAA6C,CAAC;AAE7E,MAAM,KAAK,GAAkC;IAC3C,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,MAAM;CACV,CAAC;AAEF,MAAM,OAAO,GAAG;IACd,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,GAAG;CACV,CAAC;AAEF,MAAM,UAAU,IAAI,CAAC,GAAW;IAC9B,IAAI,GAAG,KAAK,OAAO;QAAE,GAAG,GAAG,OAAO,CAAC;IACnC,MAAM,MAAM,GAAc,IAAI,GAAG,EAAE,CAAC;IACpC,IAAI,GAAG,GAAG,CAAC,EACT,GAAG,GAAG,CAAC,CAAC;IACV,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;QACpB,QAAQ,CAAC,EAAE,CAAC;YACV,KAAK,GAAG,CAAC;YACT,KAAK,GAAG;gBACN,OAAO,MAAM,CAAC;YAChB,KAAK,GAAG;gBACN,EAAE,GAAG,CAAC;gBACN,IAAI,GAAG,GAAG,CAAC;oBAAE,OAAO,MAAM,CAAC;gBAC3B,GAAG,GAAG,CAAC,CAAC;gBACR,MAAM;YACR,KAAK,GAAG,CAAC,CAAC,CAAC;gBACT,MAAM,
|
|
1
|
+
{"version":3,"file":"fen.js","sourceRoot":"","sources":["../src/fen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,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