@lichess-org/chessground 9.4.1 → 9.5.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.
@@ -21,8 +21,8 @@ export function Chessground(element, config) {
21
21
  render(state);
22
22
  if (elements.autoPieces)
23
23
  autoPieces.render(state, elements.autoPieces);
24
- if (!skipSvg && elements.svg)
25
- svg.renderSvg(state, elements.svg, elements.customSvg);
24
+ if (!skipSvg && elements.shapes)
25
+ svg.renderSvg(state, elements);
26
26
  }, onResize = () => {
27
27
  updateBounds(state);
28
28
  renderResized(state);
@@ -1 +1 @@
1
- {"version":3,"file":"chessground.js","sourceRoot":"","sources":["../src/chessground.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAU,SAAS,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAwB,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,UAAU,UAAU,CAAC,EAAE,EAAE,EAAE,MAAM,EAAwC;IAC7E,OAAO,WAAW,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAoB,EAAE,MAAe;IAC/D,MAAM,UAAU,GAA0B,QAAQ,EAAE,CAAC;IAErD,SAAS,CAAC,UAAU,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC;IAEpC,SAAS,SAAS;QAChB,MAAM,UAAU,GAAG,KAAK,IAAI,UAAU,C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KAAK,CAAC,CAAC;QACpB,SAAS,CAAC,KAAK,CAAC,CAAC;QACjB,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAClC,IAAI,CAAC,UAAU;YAAE,KAAK,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACzE,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACrD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,cAAc,CAAC,SAAsC;IAC5D,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,OAAO,GAAG,EAAE;QACV,IAAI,SAAS;YAAE,OAAO;QACtB,SAAS,GAAG,IAAI,CAAC;QACjB,qBAAqB,CAAC,GAAG,EAAE;YACzB,SAAS,EAAE,CAAC;YACZ,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- var _e=["white","black"];var F=["a","b","c","d","e","f","g","h"],I=["1","2","3","4","5","6","7","8"];var Je=[...I].reverse(),se=F.flatMap(e=>I.map(o=>e+o)),m=e=>se[8*e[0]+e[1]],f=e=>[e.charCodeAt(0)-97,e.charCodeAt(1)-49];var ce=se.map(f);function eo(e){let o,r=()=>(o===void 0&&(o=e()),o);return r.clear=()=>{o=void 0},r}var oo=()=>{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",V=(e,o)=>(e[0]-o[0])**2+(e[1]-o[1])**2,G=(e,o)=>e.role===o.role&&e.color===o.color,ro=(e,o)=>e[0]===o[0]&&e[1]===o[1],L=e=>(o,r)=>[(r?o[0]:7-o[0])*e.width/8,(r?7-o[1]:o[1])*e.height/8],k=(e,o)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px)`},De=(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"},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 r=document.createElement(e);return o&&(r.className=o),r};function de(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),_=(e,o,r,n)=>K(e,r)*K(o,n)===2,ue=(e,o,r,n)=>e===r!=(o===n),pe=(e,o,r,n)=>K(e,r)===K(o,n)&&e!==r,fe=(e,o,r,n)=>ue(e,o,r,n)||pe(e,o,r,n),Ke=(e,o,r,n)=>Math.max(K(e,r),K(o,n))===1,xe=(e,o,r,n,t)=>K(e,r)===1&&n===o+(t?1:-1),Ee=(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))},Q=(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),c=Math.sign(i),l=[],s=e+a,p=o+c;for(;s!==r||p!==n;)l.push([s,p]),s+=a,p+=c;return l.map(d=>m(d))},no=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)},J=(e,o)=>{let r=f(e);return r[1]+=o,m(r)};var U=e=>e.friendlies.has(m(e.pos2)),tr=e=>e.enemies.has(m(e.pos2)),to=(e,o,r)=>Q(...e,...o).some(n=>r.has(n)),io=(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 Ee(...i,...a,n.color==="white")&&!to(i,[a[0],a[1]+t],r.allPieces)},ir=(e,o,r)=>{let n=r.enemies.get(e);return n?.role==="pawn"&&xe(...f(e),...f(o),n.color==="white")&&(r.friendlies.has(o)||me(J(o,n.color==="white"?-1:1),r.friendlies,r.enemies,r.lastMove))},ar=e=>[...e.enemies.keys()].some(o=>io(o,m(e.pos2),e)),Ae=(e,o)=>{let r=e.pos2;return[...e.enemies].some(([n,t])=>{let i=f(n);return!o?.includes(t.role)&&(t.role==="pawn"&&xe(...i,...r,t.color==="white")||t.role==="knight"&&_(...i,...r)||t.role==="bishop"&&pe(...i,...r)||t.role==="rook"&&ue(...i,...r)||t.role==="queen"&&fe(...i,...r)||t.role==="king"&&Ke(...i,...r))&&(!["bishop","rook","queen"].includes(t.role)||!to(i,r,e.allPieces))})},ge=e=>U(e)&&(me(m(e.pos2),e.friendlies,e.enemies,e.lastMove)||Ae(e)),me=(e,o,r,n)=>{if(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=>r.get(m([t[0]+a,t[1]]))?.role==="pawn")},sr=e=>{if(e.unrestrictedPremoves)return!0;let o=Q(...e.pos1,...e.pos2),r=o.filter(n=>e.friendlies.has(n));return!r.length||r.length===1&&me(r[0],e.friendlies,e.enemies,e.lastMove)&&!o.includes(J(r[0],e.color==="white"?-1:1))},cr=e=>{if(e.unrestrictedPremoves)return!0;let o=Q(...e.pos1,...e.pos2),r=o.filter(s=>e.enemies.has(s));if(r.length>1)return!1;if(!r.length)return!0;let n=r[0],t=e.enemies.get(n);if(!t||t.role!=="pawn")return!0;let i=t.color==="white"?1:-1,a=J(n,i),c=[...no(a).filter(s=>ir(n,s,e)),...[a,J(a,i)].filter(s=>io(n,s,e))],l=[...o,m(e.pos1)];return c.some(s=>!l.includes(s))},Ne=e=>sr(e)&&cr(e),lr=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||tr(e)?!0:U(e)?Ae(e):ar(e)||me(m([e.pos2[0],e.pos2[1]+o]),e.friendlies,e.enemies,e.lastMove)||Ae(e,["pawn"]):Ee(...e.pos1,...e.pos2,e.color==="white")&&Ne({...e,pos2:[e.pos2[0],e.pos2[1]+o]})},dr=e=>_(...e.pos1,...e.pos2)&&(e.unrestrictedPremoves||!U(e)||ge(e)),ao=e=>pe(...e.pos1,...e.pos2)&&Ne(e)&&(e.unrestrictedPremoves||!U(e)||ge(e)),so=e=>ue(...e.pos1,...e.pos2)&&Ne(e)&&(e.unrestrictedPremoves||!U(e)||ge(e)),ur=e=>ao(e)||so(e),pr=e=>Ke(...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||Q(...e.pos1,e.pos2[0]>e.pos1[0]?7:1,e.pos2[1]).map(o=>e.allPieces.get(o)).every(o=>!o||G(o,{role:"rook",color:e.color}))),fr={pawn:lr,knight:dr,bishop:ao,rook:so,queen:ur,king:pr};function He(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,c=new Map([...r].filter(([u,b])=>b.color===a)),l=new Map([...r].filter(([u,b])=>b.color===j(a))),s=f(o),p=fr[i.role],d={pos1:s,allPieces:r,friendlies:c,enemies:l,unrestrictedPremoves:t,color:a,canCastle:n,rookFilesFriendlies:Array.from(r).filter(([u,b])=>u[1]===(a==="white"?"1":"8")&&b.color===a&&b.role==="rook").map(([u])=>f(u)[0]),lastMove:e.lastMove};return ce.filter(u=>p({...d,pos2:u})).map(m)}function M(e,...o){e&&setTimeout(()=>e(...o),1)}function co(e){e.orientation=j(e.orientation),e.animation.current=e.draggable.current=e.selected=void 0}function lo(e,o){for(let[r,n]of o)n?e.pieces.set(r,n):e.pieces.delete(r)}function uo(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 gr(e,o,r,n){E(e),e.premovable.current=[o,r],M(e.premovable.events.set,o,r,n)}function x(e){e.premovable.current&&(e.premovable.current=void 0,M(e.premovable.events.unset))}function mr(e,o,r){x(e),e.predroppable.current={role:o,key:r},M(e.predroppable.events.set,o,r)}function E(e){let o=e.predroppable;o.current&&(o.current=void 0,M(o.events.unset))}function br(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=m([7,i[1]]):i[0]===2&&(r=m([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(m([6,i[1]]),n),e.pieces.set(m([5,i[1]]),a)):(e.pieces.set(m([2,i[1]]),n),e.pieces.set(m([3,i[1]]),a)),!0)}function qe(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),M(e.events.move,o,r,i),br(e,o,r)||(e.pieces.set(r,n),e.pieces.delete(o)),e.lastMove=[o,r],e.check=void 0,M(e.events.change),i||!0}function be(e,o,r,n){if(e.pieces.has(r))if(n)e.pieces.delete(r);else return!1;return M(e.events.dropNewPiece,o,r),e.pieces.set(r,o),e.lastMove=[r],e.check=void 0,M(e.events.change),e.movable.dests=void 0,e.turnColor=j(e.turnColor),!0}function po(e,o,r){let n=qe(e,o,r);return n&&(e.movable.dests=void 0,e.turnColor=j(e.turnColor),e.animation.current=void 0),n}function Te(e,o,r){if(ve(e,o,r)){let n=po(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),M(e.movable.events.after,o,r,i),!0}}else if(vr(e,o,r))return gr(e,o,r,{ctrlKey:e.stats.ctrlKey}),P(e),!0;return P(e),!1}function he(e,o,r,n){let t=e.pieces.get(o);t&&(hr(e,o,r)||n)?(e.pieces.delete(o),be(e,t,r,n),M(e.movable.events.afterNewPiece,t.role,r,{premove:!1,predrop:!1})):t&&yr(e,o,r)?mr(e,t.role,r):(x(e),E(e)),e.pieces.delete(o),P(e)}function oe(e,o,r){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||r)&&e.selected!==o&&Te(e,e.selected,o)){e.stats.dragged=!1;return}}(e.selectable.enabled||e.draggable.enabled)&&(fo(e,o)||Oe(e,o))&&(Be(e,o),e.hold.start())}function Be(e,o){e.selected=o,Oe(e,o)?e.premovable.customDests||(e.premovable.dests=He(e,o)):e.premovable.dests=void 0}function P(e){e.selected=void 0,e.premovable.dests=void 0,e.hold.cancel()}function fo(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&&fo(e,o)&&(e.movable.free||!!e.movable.dests?.get(o)?.includes(r));function hr(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 vr=(e,o,r)=>o!==r&&Oe(e,o)&&(e.premovable.customDests?.get(o)??He(e,o)).includes(r);function yr(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 go(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 mo(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=po(e,r,n);if(i){let a={premove:!0};i!==!0&&(a.captured=i),M(e.movable.events.after,r,n,a),t=!0}}return x(e),t}function bo(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};be(e,t,r.key)&&(M(e.movable.events.afterNewPiece,r.role,r.key,{premove:!1,predrop:!0}),n=!0)}return E(e),n}function re(e){x(e),E(e),P(e)}function Re(e){e.movable.color=e.movable.dests=e.animation.current=void 0,re(e)}function A(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 ho(e,o,r,n){let t=f(e),i=ce.filter(s=>ro(t,s)||fe(t[0],t[1],s[0],s[1])||_(t[0],t[1],s[0],s[1])),c=i.map(s=>de(m(s),r,n)).map(s=>V(o,s)),[,l]=c.reduce((s,p,d)=>s[0]<p?s:[p,d],[c[0],0]);return m(i[l])}var v=e=>e.orientation==="white";var Le="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR",wr={p:"pawn",r:"rook",n:"knight",b:"bishop",q:"queen",k:"king"},Sr={pawn:"p",rook:"r",knight:"n",bishop:"b",queen:"q",king:"k"};function ye(e){e==="start"&&(e=Le);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=o.get(m([n-1,r]));i&&(i.promoted=!0);break}default:{let i=t.charCodeAt(0);if(i<57)n+=i-48;else{let a=t.toLowerCase();o.set(m([n,r]),{role:wr[a],color:t===a?"black":"white"}),++n}}}return o}function vo(e){return Je.map(o=>F.map(r=>{let n=e.get(r+o);if(n){let t=Sr[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 Fe(e,o){o.animation&&(Ge(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=[]),Ge(e,o),o.fen&&(e.pieces=ye(o.fen),e.drawable.shapes=o.drawable?.shapes||[]),"check"in o&&uo(e,o.check||!1),"lastMove"in o&&!o.lastMove?e.lastMove=void 0:o.lastMove&&(e.lastMove=o.lastMove),e.selected&&Be(e,e.selected),Fe(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 Ge(e,o){for(let r in o)r==="__proto__"||r==="constructor"||!Object.prototype.hasOwnProperty.call(o,r)||(Object.prototype.hasOwnProperty.call(e,r)&&yo(e[r])&&yo(o[r])?Ge(e[r],o[r]):e[r]=o[r])}function yo(e){if(typeof e!="object"||e===null)return!1;let o=Object.getPrototypeOf(e);return o===Object.prototype||o===null}var B=(e,o)=>o.animation.enabled?Cr(e,o):O(e,o);function O(e,o){let r=e(o);return o.dom.redraw(),r}var We=(e,o)=>({key:e,pos:f(e),piece:o}),Mr=(e,o)=>o.sort((r,n)=>V(e.pos,r.pos)-V(e.pos,n.pos))[0];function kr(e,o){let r=new Map,n=[],t=new Map,i=[],a=[],c=new Map,l,s,p;for(let[d,u]of e)c.set(d,We(d,u));for(let d of se)l=o.pieces.get(d),s=c.get(d),l?s?G(l,s.piece)||(i.push(s),a.push(We(d,l))):a.push(We(d,l)):s&&i.push(s);for(let d of a)s=Mr(d,i.filter(u=>G(d.piece,u.piece))),s&&(p=[s.pos[0]-d.pos[0],s.pos[1]-d.pos[1]],r.set(d.key,p.concat(p)),n.push(s.key));for(let d of i)n.includes(d.key)||t.set(d.key,d.piece);return{anims:r,fadings:t}}function wo(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=Dr(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())=>wo(e,i))}}function Cr(e,o){let r=new Map(o.pieces),n=e(o),t=kr(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||wo(o,performance.now())}else o.dom.redraw();return n}var Dr=e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1;var Kr=["green","red","blue","yellow"];function So(e,o){if(o.touches&&o.touches.length>1)return;o.stopPropagation(),o.preventDefault(),o.ctrlKey?P(e):re(e);let r=T(o),n=A(r,v(e),e.dom.bounds());n&&(e.drawable.current={orig:n,pos:r,brush:xr(o),snapToValidMove:e.drawable.defaultSnapToValidMove},Po(e))}function Po(e){requestAnimationFrame(()=>{let o=e.drawable.current;if(o){let r=A(o.pos,v(e),e.dom.bounds());r||(o.snapToValidMove=!1);let n=o.snapToValidMove?ho(o.orig,o.pos,v(e),e.dom.bounds()):r;n!==o.mouseSq&&(o.mouseSq=n,o.dest=n!==o.orig?n:void 0,e.dom.redrawNow()),Po(e)}})}function Mo(e,o){e.drawable.current&&(e.drawable.current.pos=T(o))}function ko(e){let o=e.drawable.current;o&&(o.mouseSq&&Er(e.drawable,o),ze(e))}function ze(e){e.drawable.current&&(e.drawable.current=void 0,e.dom.redraw())}function Co(e){e.drawable.shapes.length&&(e.drawable.shapes=[],e.dom.redraw(),Do(e.drawable))}function xr(e){let o=(e.shiftKey||e.ctrlKey)&&le(e),r=e.altKey||e.metaKey||e.getModifierState?.("AltGraph");return Kr[(o?1:0)+(r?2:0)]}function Er(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}),Do(e)}function Do(e){e.onChange&&e.onChange(e.shapes)}function Ko(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=T(o),t=A(n,v(e),r);if(!t)return;let i=e.pieces.get(t),a=e.selected;if(!a&&e.drawable.enabled&&(e.drawable.eraseOnClick||!i||i.color!==e.turnColor)&&Co(e),o.cancelable!==!1&&(!o.touches||e.blockTouchScroll||i||a||Nr(e,n)))o.preventDefault();else if(o.touches)return;let c=!!e.premovable.current,l=!!e.predroppable.current;e.stats.ctrlKey=o.ctrlKey,e.selected&&ve(e,e.selected,t)?B(d=>oe(d,t),e):oe(e,t);let s=e.selected===t,p=Ho(e,t);if(i&&p&&s&&go(e,t)){e.draggable.current={orig:t,piece:i,origPos:n,pos:n,started:e.draggable.autoDistance&&e.stats.dragged,element:p,previouslySelected:a,originTarget:o.target,keyHasChanged:!1},p.cgDragging=!0,p.classList.add("dragging");let d=e.dom.elements.ghost;d&&(d.className=`ghost ${i.color} ${i.role}`,k(d,L(r)(f(t),v(e))),Y(d,!0)),$e(e)}else c&&x(e),l&&E(e);e.dom.redraw()}function Nr(e,o){let r=v(e),n=e.dom.bounds(),t=Math.pow(n.width/8,2);for(let i of e.pieces.keys()){let a=de(i,r,n);if(V(a,o)<=t)return!0}return!1}function xo(e,o,r,n){let t="a0";e.pieces.set(t,o),e.dom.redraw();let i=T(r);e.draggable.current={orig:t,piece:o,origPos:i,pos:i,started:!0,element:()=>Ho(e,t),originTarget:r.target,newPiece:!0,force:!!n,keyHasChanged:!1},$e(e)}function $e(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||!G(r,o.piece))W(e);else if(!o.started&&V(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();k(o.element,[o.pos[0]-n.left-n.width/16,o.pos[1]-n.top-n.height/16]),o.keyHasChanged||=o.orig!==A(o.pos,v(e),n)}$e(e)})}function Eo(e,o){e.draggable.current&&(!o.touches||o.touches.length<2)&&(e.draggable.current.pos=T(o))}function Ao(e,o){let r=e.draggable.current;if(!r)return;if(o.type==="touchend"&&o.cancelable!==!1&&o.preventDefault(),o.type==="touchend"&&r.originTarget!==o.target&&!r.newPiece){e.draggable.current=void 0;return}x(e),E(e);let n=T(o)||r.pos,t=A(n,v(e),e.dom.bounds());t&&r.started&&r.orig!==t?r.newPiece?he(e,r.orig,t,r.force):(e.stats.ctrlKey=o.ctrlKey,Te(e,r.orig,t)&&(e.stats.dragged=!0)):r.newPiece?e.pieces.delete(r.orig):e.draggable.deleteOnDropOff&&!t&&(e.pieces.delete(r.orig),M(e.events.change)),(r.orig===r.previouslySelected||r.keyHasChanged)&&(r.orig===t||!t)?P(e):e.selectable.enabled||P(e),No(e),e.draggable.current=void 0,e.dom.redraw()}function W(e){let o=e.draggable.current;o&&(o.newPiece&&e.pieces.delete(o.orig),e.draggable.current=void 0,P(e),No(e),e.dom.redraw())}function No(e){let o=e.dom.elements;o.ghost&&Y(o.ghost,!1)}function Ho(e,o){let r=e.dom.elements.board.firstChild;for(;r;){if(r.cgKey===o&&r.tagName==="PIECE")return r;r=r.nextSibling}}function To(e,o){e.exploding={stage:1,keys:o},e.dom.redraw(),setTimeout(()=>{qo(e,2),setTimeout(()=>qo(e,void 0),120)},120)}function qo(e,o){e.exploding&&(o?e.exploding.stage=o:e.exploding=void 0,e.dom.redraw())}function Bo(e,o){function r(){co(e),o()}return{set(n){n.orientation&&n.orientation!==e.orientation&&r(),Fe(e,n),(n.fen?B:O)(t=>we(t,n),e)},state:e,getFen:()=>vo(e.pieces),toggleOrientation:r,setPieces(n){B(t=>lo(t,n),e)},selectSquare(n,t){n?B(i=>oe(i,n,t),e):e.selected&&(P(e),e.dom.redraw())},move(n,t){B(i=>qe(i,n,t),e)},newPiece(n,t){B(i=>be(i,n,t),e)},playPremove(){if(e.premovable.current){if(B(mo,e))return!0;e.dom.redraw()}return!1},playPredrop(n){if(e.predroppable.current){let t=bo(e,n);return e.dom.redraw(),t}return!1},cancelPremove(){O(x,e)},cancelPredrop(){O(E,e)},cancelMove(){O(n=>{re(n),W(n)},e)},stop(){O(n=>{Re(n),W(n)},e)},explode(n){To(e,n)},setAutoShapes(n){O(t=>t.drawable.autoShapes=n,e)},setShapes(n){O(t=>t.drawable.shapes=n.slice(),e)},getKeyAtDomPos(n){return A(n,v(e),e.dom.bounds())},redrawAll:o,dragNewPiece(n,t,i){xo(e,n,t,i)},destroy(){Re(e),e.dom.unbind&&e.dom.unbind(),e.dom.destroyed=!0}}}function Oo(){return{pieces:ye(Le),orientation:"white",turnColor:"white",coordinates:!0,coordinatesOnSquares:!1,ranksPosition:"right",autoCastle:!0,viewOnly:!1,disableContextMenu:!1,addPieceZIndex:!1,blockTouchScroll:!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}},prevSvgHash:""},hold:oo()}}var Ro={hilitePrimary:{key:"hilitePrimary",color:"#3291ff",opacity:1,lineWidth:1},hiliteWhite:{key:"hiliteWhite",color:"#ffffff",opacity:1,lineWidth:1}};function Fo(){let e=y("defs"),o=S(y("filter"),{id:"cg-filter-blur"});return o.appendChild(S(y("feGaussianBlur"),{stdDeviation:"0.019"})),e.appendChild(o),e}function Go(e,o,r){let n=e.drawable,t=n.current,i=t&&t.mouseSq?t:void 0,a=new Map,c=e.dom.bounds(),l=n.autoShapes.filter(u=>!u.piece);for(let u of n.shapes.concat(l).concat(i?[i]:[])){if(!u.dest)continue;let b=a.get(u.dest)??new Set,w=Me(Pe(f(u.orig),e.orientation),c),g=Me(Pe(f(u.dest),e.orientation),c);b.add(je(w,g)),a.set(u.dest,b)}let s=n.shapes.concat(l).map(u=>({shape:u,current:!1,hash:Vo(u,Ie(u.dest,a),!1,c)}));i&&s.push({shape:i,current:!0,hash:Vo(i,Ie(i.dest,a),!0,c)});let p=s.map(u=>u.hash).join(";");if(p===e.drawable.prevSvgHash)return;e.drawable.prevSvgHash=p;let d=o.querySelector("defs");qr(n,s,d),Tr(s,o.querySelector("g"),r.querySelector("g"),u=>Rr(e,u,n.brushes,a,c))}function qr(e,o,r){let n=new Map,t;for(let c of o.filter(l=>l.shape.dest&&l.shape.brush))t=Wo(e.brushes[c.shape.brush],c.shape.modifiers),c.shape.modifiers?.hilite&&n.set(Se(t).key,Se(t)),n.set(t.key,t);let i=new Set,a=r.firstElementChild;for(;a;)i.add(a.getAttribute("cgKey")),a=a.nextElementSibling;for(let[c,l]of n.entries())i.has(c)||r.appendChild(Fr(l))}function Tr(e,o,r,n){let t=new Map;for(let i of e)t.set(i.hash,!1);for(let i of[o,r]){let a=[],c=i.firstElementChild,l;for(;c;)l=c.getAttribute("cgHash"),t.has(l)?t.set(l,!0):a.push(c),c=c.nextElementSibling;for(let s of a)i.removeChild(s)}for(let i of e.filter(a=>!t.get(a.hash)))for(let a of n(i))a.isCustom?r.appendChild(a.el):o.appendChild(a.el)}function Vo({orig:e,dest:o,brush:r,piece:n,modifiers:t,customSvg:i,label:a},c,l,s){return[s.width,s.height,l,e,o,r,c&&"-",n&&Br(n),t&&Or(t),i&&`custom-${Lo(i.html)},${i.center?.[0]??"o"}`,a&&`label-${Lo(a.text)}`].filter(p=>p).join(",")}function Br(e){return[e.color,e.role,e.scale].filter(o=>o).join(",")}function Or(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 Rr(e,{shape:o,current:r,hash:n},t,i,a){let c=Me(Pe(f(o.orig),e.orientation),a),l=o.dest?Me(Pe(f(o.dest),e.orientation),a):c,s=o.brush&&Wo(t[o.brush],o.modifiers),p=i.get(o.dest),d=[];if(s){let u=S(y("g"),{cgHash:n});d.push({el:u}),c[0]!==l[0]||c[1]!==l[1]?u.appendChild(Lr(o,s,c,l,r,Ie(o.dest,i))):u.appendChild(Vr(t[o.brush],c,r,a))}if(o.label){let u=o.label;u.fill??=o.brush&&t[o.brush].color;let b=o.brush?void 0:"tr";d.push({el:Gr(u,n,c,l,p,b),isCustom:!0})}if(o.customSvg){let u=o.customSvg.center??"orig",[b,w]=u==="label"?$o(c,l,p).map(z=>z-.5):u==="dest"?l:c,g=S(y("g"),{transform:`translate(${b},${w})`,cgHash:n});g.innerHTML=`<svg width="1" height="1" viewBox="0 0 100 100">${o.customSvg.html}</svg>`,d.push({el:g,isCustom:!0})}return d}function Vr(e,o,r,n){let t=Wr(),i=(n.width+n.height)/(4*Math.max(n.width,n.height));return S(y("circle"),{stroke:e.color,"stroke-width":t[r?0:1],fill:"none",opacity:zo(e,r),cx:o[0],cy:o[1],r:i-t[1]/2})}function Se(e){return["#ffffff","#fff","white"].includes(e.color)?Ro.hilitePrimary:Ro.hiliteWhite}function Lr(e,o,r,n,t,i){function a(s){let p=$r(i&&!t),d=n[0]-r[0],u=n[1]-r[1],b=Math.atan2(u,d),w=Math.cos(b)*p,g=Math.sin(b)*p;return S(y("line"),{stroke:s?Se(o).color:o.color,"stroke-width":zr(o,t)+(s?.04:0),"stroke-linecap":"round","marker-end":`url(#arrowhead-${s?Se(o).key:o.key})`,opacity:e.modifiers?.hilite?1:zo(o,t),x1:r[0],y1:r[1],x2:n[0]-w,y2:n[1]-g})}if(!e.modifiers?.hilite)return a(!1);let c=y("g"),l=S(y("g"),{filter:"url(#cg-filter-blur)"});return l.appendChild(Ir(r,n)),l.appendChild(a(!0)),c.appendChild(l),c.appendChild(a(!1)),c}function Fr(e){let o=S(y("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(y("path"),{d:"M0,0 V4 L3,2 Z",fill:e.color})),o.setAttribute("cgKey",e.key),o}function Gr(e,o,r,n,t,i){let c=.4*.75**e.text.length,l=$o(r,n,t),s=i==="tr"?.4:0,p=S(y("g"),{transform:`translate(${l[0]+s},${l[1]-s})`,cgHash:o});p.appendChild(S(y("circle"),{r:.4/2,"fill-opacity":i?1:.8,"stroke-opacity":i?1:.7,"stroke-width":.03,fill:e.fill??"#666",stroke:"white"}));let d=S(y("text"),{"font-size":c,"font-family":"Noto Sans","text-anchor":"middle",fill:"white",y:.13*.75**e.text.length});return d.innerHTML=e.text,p.appendChild(d),p}function Pe(e,o){return o==="white"?e:[7-e[0],7-e[1]]}function Ie(e,o){return(e&&o.has(e)&&o.get(e).size>1)===!0}function y(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function S(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 Wr(){return[3/64,4/64]}function zr(e,o){return(e.lineWidth||10)*(o?.85:1)/64}function zo(e,o){return(e.opacity||1)*(o?.9:1)}function $r(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 Ir(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 S(y("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 je(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 jr(e,o){return Math.sqrt([e[0]-o[0],e[1]-o[1]].reduce((r,n)=>r+n*n,0))}function $o(e,o,r){let n=jr(e,o),t=je(e,o,!1);if(r&&(n-=33/64,r.size>1)){n-=10/64;let i=je(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 Io(e,o){e.innerHTML="",e.classList.add("cg-wrap");for(let l of _e)e.classList.toggle("orientation-"+l,o.orientation===l);e.classList.toggle("manipulable",!o.viewOnly);let r=C("cg-container");e.appendChild(r);let n=C("cg-board");r.appendChild(n);let t,i,a;if(o.drawable.visible&&(t=S(y("svg"),{class:"cg-shapes",viewBox:"-4 -4 8 8",preserveAspectRatio:"xMidYMid slice"}),t.appendChild(Fo()),t.appendChild(y("g")),i=S(y("svg"),{class:"cg-custom-svgs",viewBox:"-3.5 -3.5 8 8",preserveAspectRatio:"xMidYMid slice"}),i.appendChild(y("g")),a=C("cg-auto-pieces"),r.appendChild(t),r.appendChild(i),r.appendChild(a)),o.coordinates){let l=o.orientation==="black"?" black":"",s=o.ranksPosition==="left"?" left":"";if(o.coordinatesOnSquares){let p=o.orientation==="white"?d=>d+1:d=>8-d;F.forEach((d,u)=>r.appendChild(Ue(I.map(b=>d+b),"squares rank"+p(u)+l+s)))}else r.appendChild(Ue(I,"ranks"+l+s)),r.appendChild(Ue(F,"files"+l))}let c;return o.draggable.enabled&&o.draggable.showGhost&&(c=C("piece","ghost"),Y(c,!1),r.appendChild(c)),{board:n,container:r,wrap:e,ghost:c,svg:t,customSvg:i,autoPieces:a}}function Ue(e,o){let r=C("coords",o),n;for(let t of e)n=C("coord"),n.textContent=t,r.appendChild(n);return r}function jo(e,o){if(!e.dropmode.active)return;x(e),E(e);let r=e.dropmode.piece;if(r){e.pieces.set("a0",r);let n=T(o),t=n&&A(n,v(e),e.dom.bounds());t&&he(e,"a0",t)}e.dom.redraw()}function Zo(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=Zr(e);r.addEventListener("touchstart",n,{passive:!1}),r.addEventListener("mousedown",n,{passive:!1})}function Xo(e,o){let r=[];if("ResizeObserver"in window||r.push(ne(document.body,"chessground.resize",o)),!e.viewOnly){let n=Uo(e,Eo,Mo),t=Uo(e,Ao,ko);for(let a of["touchmove","mousemove"])r.push(ne(document,a,n));for(let a of["touchend","mouseup"])r.push(ne(document,a,t));let i=()=>e.dom.bounds.clear();r.push(ne(document,"scroll",i,{capture:!0,passive:!0})),r.push(ne(window,"resize",i,{passive:!0}))}return()=>r.forEach(n=>n())}function ne(e,o,r,n){return e.addEventListener(o,r,n),()=>e.removeEventListener(o,r,n)}var Zr=e=>o=>{e.draggable.current?W(e):e.drawable.current?ze(e):o.shiftKey||le(o)?e.drawable.enabled&&So(e,o):e.viewOnly||(e.dropmode.active?jo(e,o):Ko(e,o))},Uo=(e,o,r)=>n=>{e.drawable.current?e.drawable.enabled&&r(e,n):e.viewOnly||o(e,n)};function _o(e){let o=v(e),r=L(e.dom.bounds()),n=e.dom.elements.board,t=e.pieces,i=e.animation.current,a=i?i.plan.anims:new Map,c=i?i.plan.fadings:new Map,l=e.draggable.current,s=Yr(e),p=new Set,d=new Set,u=new Map,b=new Map,w,g,z,$,D,Z,ke,N,Ce,ie;for(g=n.firstChild;g;){if(w=g.cgKey,Jo(g))if(z=t.get(w),D=a.get(w),Z=c.get(w),$=g.cgPiece,g.cgDragging&&(!l||l.orig!==w)&&(g.classList.remove("dragging"),k(g,r(f(w),o)),g.cgDragging=!1),!Z&&g.cgFading&&(g.cgFading=!1,g.classList.remove("fading")),z){if(D&&g.cgAnimating&&$===te(z)){let h=f(w);h[0]+=D[2],h[1]+=D[3],g.classList.add("anim"),k(g,r(h,o))}else g.cgAnimating&&(g.cgAnimating=!1,g.classList.remove("anim"),k(g,r(f(w),o)),e.addPieceZIndex&&(g.style.zIndex=Ze(f(w),o)));$===te(z)&&(!Z||!g.cgFading)?p.add(w):Z&&$===te(Z)?(g.classList.add("fading"),g.cgFading=!0):Xe(u,$,g)}else Xe(u,$,g);else if(er(g)){let h=g.className;s.get(w)===h?d.add(w):Xe(b,h,g)}g=g.nextSibling}for(let[h,X]of s)if(!d.has(h)){Ce=b.get(X),ie=Ce&&Ce.pop();let H=r(f(h),o);if(ie)ie.cgKey=h,k(ie,H);else{let q=C("square",X);q.cgKey=h,k(q,H),n.insertBefore(q,n.firstChild)}}for(let[h,X]of t)if(D=a.get(h),!p.has(h))if(ke=u.get(te(X)),N=ke&&ke.pop(),N){N.cgKey=h,N.cgFading&&(N.classList.remove("fading"),N.cgFading=!1);let H=f(h);e.addPieceZIndex&&(N.style.zIndex=Ze(H,o)),D&&(N.cgAnimating=!0,N.classList.add("anim"),H[0]+=D[2],H[1]+=D[3]),k(N,r(H,o))}else{let H=te(X),q=C("piece",H),ae=f(h);q.cgPiece=H,q.cgKey=h,D&&(q.cgAnimating=!0,ae[0]+=D[2],ae[1]+=D[3]),k(q,r(ae,o)),e.addPieceZIndex&&(q.style.zIndex=Ze(ae,o)),n.appendChild(q)}for(let h of u.values())Yo(e,h);for(let h of b.values())Yo(e,h)}function Qo(e){let o=v(e),r=L(e.dom.bounds()),n=e.dom.elements.board.firstChild;for(;n;)(Jo(n)&&!n.cgAnimating||er(n))&&k(n,r(f(n.cgKey),o)),n=n.nextSibling}function Ye(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 Jo=e=>e.tagName==="PIECE",er=e=>e.tagName==="SQUARE";function Yo(e,o){for(let r of o)e.dom.elements.board.removeChild(r)}function Ze(e,o){let n=e[1];return`${o?10-n:3+n}`}var te=e=>`${e.color} ${e.role}`;function Yr(e){let o=new Map;if(e.lastMove&&e.highlight.lastMove)for(let t of e.lastMove)R(o,t,"last-move");if(e.check&&e.highlight.check&&R(o,e.check,"check"),e.selected&&(R(o,e.selected,"selected"),e.movable.showDests)){let t=e.movable.dests?.get(e.selected);if(t)for(let a of t)R(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)R(o,a,"premove-dest"+(e.pieces.has(a)?" oc":""))}let r=e.premovable.current;if(r)for(let t of r)R(o,t,"current-premove");else e.predroppable.current&&R(o,e.predroppable.current.key,"current-premove");let n=e.exploding;if(n)for(let t of n.keys)R(o,t,"exploding"+n.stage);return e.highlight.custom&&e.highlight.custom.forEach((t,i)=>{R(o,i,t)}),o}function R(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 or(e,o,r){let n=new Map,t=[];for(let c of e)n.set(c.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 c of t)o.removeChild(c);for(let c of e)n.get(c.hash)||o.appendChild(r(c))}function rr(e,o){let n=e.drawable.autoShapes.filter(t=>t.piece).map(t=>({shape:t,hash:Qr(t),current:!1}));or(n,o,t=>_r(e,t,e.dom.bounds()))}function nr(e){let o=v(e),r=L(e.dom.bounds()),n=e.dom.elements.autoPieces?.firstChild;for(;n;)De(n,r(f(n.cgKey),o),n.cgScale),n=n.nextSibling}function _r(e,{shape:o,hash:r},n){let t=o.orig,i=o.piece?.role,a=o.piece?.color,c=o.piece?.scale,l=C("piece",`${i} ${a}`);return l.setAttribute("cgHash",r),l.cgKey=t,l.cgScale=c,De(l,L(n)(f(t),v(e)),c),l}var Qr=e=>[e.orig,e.piece?.role,e.piece?.color,e.piece?.scale].join(",");function Jn({el:e,config:o}){return en(e,o)}function en(e,o){let r=Oo();we(r,o||{});function n(){let t="dom"in r?r.dom.unbind:void 0,i=Io(e,r),a=eo(()=>i.board.getBoundingClientRect()),c=p=>{_o(s),i.autoPieces&&rr(s,i.autoPieces),!p&&i.svg&&Go(s,i.svg,i.customSvg)},l=()=>{Ye(s),Qo(s),i.autoPieces&&nr(s)},s=r;return s.dom={elements:i,bounds:a,redraw:on(c),redrawNow:c,unbind:t},s.drawable.prevSvgHash="",Ye(s),c(!1),Zo(s,l),t||(s.dom.unbind=Xo(s,l)),s.events.insert&&s.events.insert(i),s}return Bo(n(),n)}function on(e){let o=!1;return()=>{o||(o=!0,requestAnimationFrame(()=>{e(),o=!1}))}}export{en as Chessground,Jn 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],C=(e,o)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px)`},ke=(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,k=(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),u=Math.sign(i),l=[],a=e+s,c=o+u;for(;a!==n||c!==r;)l.push([a,c]),a+=s,c+=u;return l.map(d=>h(d))},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),u=[...no(s).filter(a=>an(r,a,e)),...[s,J(s,i)].filter(a=>to(r,a,e))],l=[...o,h(e.pos1)];return u.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,u=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],d={pos1:a,allPieces:n,friendlies:u,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({...d,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])),u=i.map(a=>de(h(a),n,r)).map(a=>L(o,a)),[,l]=u.reduce((a,c,d)=>a[0]<c?a:[c,d],[u[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();o.set(h([r,n]),{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}),Cn=(e,o)=>o.sort((n,r)=>L(e.pos,n.pos)-L(e.pos,r.pos))[0];function kn(e,o){let n=new Map,r=[],t=new Map,i=[],s=[],u=new Map,l,a,c;for(let[d,p]of e)u.set(d,Ge(d,p));for(let d of se)l=o.pieces.get(d),a=u.get(d),l?a?W(l,a.piece)||(i.push(a),s.push(Ge(d,l))):s.push(Ge(d,l)):a&&i.push(a);for(let d of s)a=Cn(d,i.filter(p=>W(d.piece,p.piece))),a&&(c=[a.pos[0]-d.pos[0],a.pos[1]-d.pos[1]],n.set(d.key,c.concat(c)),r.push(a.key));for(let d of i)r.includes(d.key)||t.set(d.key,d.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=kn(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 Co(e){e.drawable.shapes.length&&(e.drawable.shapes=[],e.dom.redraw(),ko(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}),ko(e)}function ko(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)&&Co(e),o.cancelable!==!1&&(!o.touches||e.blockTouchScroll||i||s||Hn(e,r)))o.preventDefault();else if(o.touches)return;let u=!!e.premovable.current,l=!!e.predroppable.current;e.stats.ctrlKey=o.ctrlKey,e.selected&&ve(e,e.selected,t)?O(d=>oe(d,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 d=e.dom.elements.ghost;d&&(d.className=`ghost ${i.color} ${i.role}`,C(d,F(n)(f(t),v(e))),_(d,!0)),ze(e)}else u&&E(e),l&&x(e);e.dom.redraw()}function Hn(e,o){let n=v(e),r=e.dom.bounds(),t=Math.pow(r.width/8,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();C(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,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(),u=n.autoShapes.filter(c=>!c.piece);for(let c of n.shapes.concat(u).concat(t?[t]:[])){if(!c.dest)continue;let d=i.get(c.dest)??new Set,p=Pe(Se(f(c.orig),e.orientation),s),m=Pe(Se(f(c.dest),e.orientation),s);d.add(Ie(p,m)),i.set(c.dest,d)}let l=[];for(let c of n.shapes.concat(u))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:d,color:p}=Go(a.shape);d&&p&&s.set(d,{key:d,color:p,opacity:1,lineWidth:1}),s.set(c.key,c)}let u=new Set,l=t.firstElementChild;for(;l;)u.add(l.getAttribute("cgKey")),l=l.nextElementSibling;for(let[a,c]of s.entries())u.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")),u=e.filter(a=>r===o.shapesBelow==!!a.shape.below),l=new Map;for(let a of u)l.set(a.hash,!1);for(let a of[i,s]){let c=[],d=a.firstElementChild,p;for(;d;)p=d.getAttribute("cgHash"),l.has(p)?l.set(p,!0):c.push(d),d=d.nextElementSibling;for(let m of c)a.removeChild(m)}for(let a of u.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:u},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)}`,u&&"below"].filter(d=>d).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 u=Pe(Se(f(o.orig),e.orientation),s),l=o.dest?Pe(Se(f(o.dest),e.orientation),s):u,a=o.brush&&Fo(t[o.brush],o.modifiers),c=i.get(o.dest),d=[];if(a){let p=S(w("g"),{cgHash:r});d.push({el:p}),u[0]!==l[0]||u[1]!==l[1]?p.appendChild(Fn(o,a,u,l,n,$e(o.dest,i))):p.appendChild(Ln(t[o.brush],u,n,s))}if(o.label){let p=o.label;p.fill??=o.brush&&t[o.brush].color;let m=o.brush?void 0:"tr";d.push({el:Wn(p,r,u,l,c,m),isCustom:!0})}if(o.customSvg){let p=o.customSvg.center??"orig",[m,y]=p==="label"?zo(u,l,c).map(B=>B-.5):p==="dest"?l:u,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>`,d.push({el:g,isCustom:!0})}return d}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),d=r[0]-n[0],p=r[1]-n[1],m=Math.atan2(p,d),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 u=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)),u.appendChild(l),u.appendChild(s(!1)),u}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 u=.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 d=S(w("text"),{"font-size":u,"font-family":"Noto Sans","text-anchor":"middle",fill:"white",y:.13*.75**e.text.length});return d.innerHTML=e.text,c.appendChild(d),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=k("cg-container");e.appendChild(n);let r=k("cg-board");n.appendChild(r);let t,i,s,u,l;if(o.drawable.visible&&([t,i]=["cg-shapes-below","cg-shapes"].map(c=>$o(c,!0)),[s,u]=["cg-custom-below","cg-custom-svgs"].map(c=>$o(c,!1)),l=k("cg-auto-pieces"),n.appendChild(t),n.appendChild(s),n.appendChild(i),n.appendChild(u),n.appendChild(l)),o.coordinates){let c=o.orientation==="black"?" black":"",d=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+d)))}else n.appendChild(je(I,"ranks"+c+d)),n.appendChild(je(G,"files"+c))}let a;return o.draggable.enabled&&o.draggable.showGhost&&(a=k("piece","ghost"),_(a,!1),n.appendChild(a)),{board:r,container:n,wrap:e,ghost:a,shapes:i,shapesBelow:t,custom:u,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=k("coords",o),r;for(let t of e)r=k("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,u=i?i.plan.fadings:new Map,l=e.draggable.current,a=Qn(e),c=new Set,d=new Set,p=new Map,m=new Map,y,g,B,$,D,Z,Me,N,Ce,ie;for(g=r.firstChild;g;){if(y=g.cgKey,Jo(g))if(B=t.get(y),D=s.get(y),Z=u.get(y),$=g.cgPiece,g.cgDragging&&(!l||l.orig!==y)&&(g.classList.remove("dragging"),C(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"),C(g,n(b,o))}else g.cgAnimating&&(g.cgAnimating=!1,g.classList.remove("anim"),C(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?d.add(y):Ze(m,b,g)}g=g.nextSibling}for(let[b,X]of a)if(!d.has(b)){Ce=m.get(X),ie=Ce&&Ce.pop();let H=n(f(b),o);if(ie)ie.cgKey=b,C(ie,H);else{let q=k("square",X);q.cgKey=b,C(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]),C(N,n(H,o))}else{let H=te(X),q=k("piece",H),ae=f(b);q.cgPiece=H,q.cgKey=b,D&&(q.cgAnimating=!0,ae[0]+=D[2],ae[1]+=D[3]),C(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))&&C(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 u of e)r.set(u.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 u of t)o.removeChild(u);for(let u of e)r.get(u.hash)||o.appendChild(n(u))}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;)ke(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,u=o.piece?.scale,l=k("piece",`${i} ${s}`);return l.setAttribute("cgHash",n),l.cgKey=t,l.cgScale=u,ke(l,F(r)(f(t),v(e)),u),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()),u=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(u),redrawNow:u,unbind:t},a.drawable.prevSvgHash="",Xe(a),u(!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/draw.d.ts CHANGED
@@ -14,10 +14,11 @@ export interface DrawShape {
14
14
  text: string;
15
15
  fill?: string;
16
16
  };
17
+ below?: boolean;
17
18
  }
18
19
  export interface DrawModifiers {
19
20
  lineWidth?: number;
20
- hilite?: boolean;
21
+ hilite?: string;
21
22
  }
22
23
  export interface DrawShapePiece {
23
24
  role: cg.Role;
package/dist/draw.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"draw.js","sourceRoot":"","sources":["../src/draw.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnG,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AA6DzD,MAAM,OAAO,GAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEpE,MAAM,UAAU,KAAK,CAAC,KAAY,EAAE,CAAgB;IAClD,gCAAgC;IAChC,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO;IAC9C,CAAC,CAAC,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC,cAAc,EAAE,CAAC;IACnB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,aAAa,CAAC,CAAC,CAAE,EAC3B,IAAI,GAAG,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,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CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK,KAAK,GAAG,CAAC,KAAK;QACzC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;YACnB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,KAAK,EAAE,GAAG,CAAC,KAAK;SACjB,CAAC,CAAC;IACL,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,QAAQ,CAAC,QAAkB;IAClC,IAAI,QAAQ,CAAC,QAAQ;QAAE,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC"}
package/dist/state.js CHANGED
@@ -83,6 +83,7 @@ export function defaults() {
83
83
  purple: { key: 'purple', color: '#68217a', opacity: 0.65, lineWidth: 10 },
84
84
  pink: { key: 'pink', color: '#ee2080', opacity: 0.5, lineWidth: 10 },
85
85
  white: { key: 'white', color: 'white', opacity: 1, lineWidth: 10 },
86
+ paleWhite: { key: 'pwhite', color: 'white', opacity: 0.6, lineWidth: 10 },
86
87
  },
87
88
  prevSvgHash: '',
88
89
  },
package/dist/state.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAIhC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AA2GlC,MAAM,UAAU,QAAQ;IACtB,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;QAC7B,WAAW,EAAE,OAAO;QACpB,SAAS,EAAE,OAAO;QAClB,WAAW,EAAE,IAAI;QACjB,oBAAoB,EAAE,KAAK;QAC3B,aAAa,EAAE,OAAO;QACtB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,KAAK;QAC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AAI,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE;gBACrE,QAAQ,EAAE;oBACR,GAAG,EAAE,KAAK;oBACV,KAAK,EAAE,SAAS;oBAChB,OAAO,EAAE,IAAI;oBACb,SAAS,EAAE,EAAE;iBACd;gBACD,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE;gBACzE,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE;gBACpE,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;gBAClE,SAAS,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE;aAC1E;YACD,WAAW,EAAE,EAAE;SAChB;QACD,IAAI,EAAE,KAAK,EAAE;KACd,CAAC;AACJ,CAAC"}
package/dist/svg.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { State } from './state.js';
2
+ import * as cg from './types.js';
2
3
  export { createElement, setAttributes };
3
4
  export declare function createDefs(): Element;
4
- export declare function renderSvg(state: State, shapesEl: SVGElement, customsEl: SVGElement): void;
5
+ export declare function renderSvg(state: State, els: cg.Elements): void;
5
6
  declare function createElement(tagName: string): SVGElement;
6
7
  declare function setAttributes(el: SVGElement, attrs: {
7
8
  [key: string]: any;
package/dist/svg.js CHANGED
@@ -1,17 +1,13 @@
1
1
  import { key2pos } from './util.js';
2
- const hilites = {
3
- hilitePrimary: { key: 'hilitePrimary', color: '#3291ff', opacity: 1, lineWidth: 1 },
4
- hiliteWhite: { key: 'hiliteWhite', color: '#ffffff', opacity: 1, lineWidth: 1 },
5
- };
6
2
  export { createElement, setAttributes };
7
3
  export function createDefs() {
8
4
  const defs = createElement('defs');
9
5
  const filter = setAttributes(createElement('filter'), { id: 'cg-filter-blur' });
10
- filter.appendChild(setAttributes(createElement('feGaussianBlur'), { stdDeviation: '0.019' }));
6
+ filter.appendChild(setAttributes(createElement('feGaussianBlur'), { stdDeviation: '0.013' }));
11
7
  defs.appendChild(filter);
12
8
  return defs;
13
9
  }
14
- export function renderSvg(state, shapesEl, customsEl) {
10
+ export function renderSvg(state, els) {
15
11
  const d = state.drawable, curD = d.current, cur = curD && curD.mouseSq ? curD : undefined, dests = new Map(), bounds = state.dom.bounds(), nonPieceAutoShapes = d.autoShapes.filter(autoShape => !autoShape.piece);
16
12
  for (const s of d.shapes.concat(nonPieceAutoShapes).concat(cur ? [cur] : [])) {
17
13
  if (!s.dest)
@@ -20,13 +16,14 @@ export function renderSvg(state, shapesEl, customsEl) {
20
16
  sources.add(moveAngle(from, to));
21
17
  dests.set(s.dest, sources);
22
18
  }
23
- const shapes = d.shapes.concat(nonPieceAutoShapes).map((s) => {
24
- return {
19
+ const shapes = [];
20
+ for (const s of d.shapes.concat(nonPieceAutoShapes)) {
21
+ shapes.push({
25
22
  shape: s,
26
23
  current: false,
27
24
  hash: shapeHash(s, isShort(s.dest, dests), false, bounds),
28
- };
29
- });
25
+ });
26
+ }
30
27
  if (cur)
31
28
  shapes.push({
32
29
  shape: cur,
@@ -37,76 +34,70 @@ export function renderSvg(state, shapesEl, customsEl) {
37
34
  if (fullHash === state.drawable.prevSvgHash)
38
35
  return;
39
36
  state.drawable.prevSvgHash = fullHash;
40
- /*
41
- -- DOM hierarchy --
42
- <svg class="cg-shapes"> (<= svg)
43
- <defs>
44
- ...(for brushes)...
45
- </defs>
46
- <g>
47
- ...(for arrows and circles)...
48
- </g>
49
- </svg>
50
- <svg class="cg-custom-svgs"> (<= customSvg)
51
- <g>
52
- ...(for custom svgs)...
53
- </g>
54
- </svg>
55
- */
56
- const defsEl = shapesEl.querySelector('defs');
57
- syncDefs(d, shapes, defsEl);
58
- syncShapes(shapes, shapesEl.querySelector('g'), customsEl.querySelector('g'), s => renderShape(state, s, d.brushes, dests, bounds));
37
+ syncDefs(d, shapes, els);
38
+ syncShapes(shapes, els, s => renderShape(state, s, d.brushes, dests, bounds));
59
39
  }
60
40
  // append only. Don't try to update/remove.
61
- function syncDefs(d, shapes, defsEl) {
62
- const brushes = new Map();
63
- let brush;
64
- for (const s of shapes.filter(s => s.shape.dest && s.shape.brush)) {
65
- brush = makeCustomBrush(d.brushes[s.shape.brush], s.shape.modifiers);
66
- if (s.shape.modifiers?.hilite)
67
- brushes.set(hilite(brush).key, hilite(brush));
68
- brushes.set(brush.key, brush);
69
- }
70
- const keysInDom = new Set();
71
- let el = defsEl.firstElementChild;
72
- while (el) {
73
- keysInDom.add(el.getAttribute('cgKey'));
74
- el = el.nextElementSibling;
75
- }
76
- for (const [key, brush] of brushes.entries()) {
77
- if (!keysInDom.has(key))
78
- defsEl.appendChild(renderMarker(brush));
79
- }
80
- }
81
- function syncShapes(syncables, shapes, customs, renderShape) {
82
- const hashesInDom = new Map();
83
- for (const sc of syncables)
84
- hashesInDom.set(sc.hash, false);
85
- for (const root of [shapes, customs]) {
86
- const toRemove = [];
87
- let el = root.firstElementChild, elHash;
41
+ function syncDefs(d, shapes, els) {
42
+ for (const shapesEl of [els.shapes, els.shapesBelow]) {
43
+ const defsEl = shapesEl.querySelector('defs');
44
+ const thisPlane = shapes.filter(s => (shapesEl === els.shapesBelow) === !!s.shape.below);
45
+ const brushes = new Map();
46
+ for (const s of thisPlane.filter(s => s.shape.dest && s.shape.brush)) {
47
+ const brush = makeCustomBrush(d.brushes[s.shape.brush], s.shape.modifiers);
48
+ const { key, color } = hiliteOf(s.shape);
49
+ if (key && color)
50
+ brushes.set(key, { key, color, opacity: 1, lineWidth: 1 });
51
+ brushes.set(brush.key, brush);
52
+ }
53
+ const keysInDom = new Set();
54
+ let el = defsEl.firstElementChild;
88
55
  while (el) {
89
- elHash = el.getAttribute('cgHash');
90
- if (hashesInDom.has(elHash))
91
- hashesInDom.set(elHash, true);
92
- else
93
- toRemove.push(el);
56
+ keysInDom.add(el.getAttribute('cgKey'));
94
57
  el = el.nextElementSibling;
95
58
  }
96
- for (const el of toRemove)
97
- root.removeChild(el);
59
+ for (const [key, brush] of brushes.entries()) {
60
+ if (!keysInDom.has(key))
61
+ defsEl.appendChild(renderMarker(brush));
62
+ }
98
63
  }
99
- // insert shapes that are not yet in dom
100
- for (const sc of syncables.filter(s => !hashesInDom.get(s.hash))) {
101
- for (const svg of renderShape(sc)) {
102
- if (svg.isCustom)
103
- customs.appendChild(svg.el);
104
- else
105
- shapes.appendChild(svg.el);
64
+ }
65
+ function syncShapes(shapes, els, renderShape) {
66
+ for (const [shapesEl, customEl] of [
67
+ [els.shapes, els.custom],
68
+ [els.shapesBelow, els.customBelow],
69
+ ]) {
70
+ const [shapesG, customG] = [shapesEl, customEl].map(el => el.querySelector('g'));
71
+ const thisPlane = shapes.filter(s => (shapesEl === els.shapesBelow) === !!s.shape.below);
72
+ const hashesInDom = new Map();
73
+ for (const sc of thisPlane)
74
+ hashesInDom.set(sc.hash, false);
75
+ for (const root of [shapesG, customG]) {
76
+ const toRemove = [];
77
+ let el = root.firstElementChild, elHash;
78
+ while (el) {
79
+ elHash = el.getAttribute('cgHash');
80
+ if (hashesInDom.has(elHash))
81
+ hashesInDom.set(elHash, true);
82
+ else
83
+ toRemove.push(el);
84
+ el = el.nextElementSibling;
85
+ }
86
+ for (const el of toRemove)
87
+ root.removeChild(el);
88
+ }
89
+ // insert shapes that are not yet in dom
90
+ for (const sc of thisPlane.filter(s => !hashesInDom.get(s.hash))) {
91
+ for (const svg of renderShape(sc)) {
92
+ if (svg.isCustom)
93
+ customG.appendChild(svg.el);
94
+ else
95
+ shapesG.appendChild(svg.el);
96
+ }
106
97
  }
107
98
  }
108
99
  }
109
- function shapeHash({ orig, dest, brush, piece, modifiers, customSvg, label }, shorten, current, bounds) {
100
+ function shapeHash({ orig, dest, brush, piece, modifiers, customSvg, label, below }, shorten, current, bounds) {
110
101
  // a shape and an overlay svg share a lifetime and have the same cgHash attribute
111
102
  return [
112
103
  bounds.width,
@@ -120,6 +111,7 @@ function shapeHash({ orig, dest, brush, piece, modifiers, customSvg, label }, sh
120
111
  modifiers && modifiersHash(modifiers),
121
112
  customSvg && `custom-${textHash(customSvg.html)},${customSvg.center?.[0] ?? 'o'}`,
122
113
  label && `label-${textHash(label.text)}`,
114
+ below && 'below',
123
115
  ]
124
116
  .filter(x => x)
125
117
  .join(',');
@@ -128,7 +120,7 @@ function pieceHash(piece) {
128
120
  return [piece.color, piece.role, piece.scale].filter(x => x).join(',');
129
121
  }
130
122
  function modifiersHash(m) {
131
- return [m.lineWidth, m.hilite && '*'].filter(x => x).join(',');
123
+ return [m.lineWidth, m.hilite].filter(x => x).join(',');
132
124
  }
133
125
  function textHash(s) {
134
126
  // Rolling hash with base 31 (cf. https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript)
@@ -175,19 +167,15 @@ function renderCircle(brush, at, current, bounds) {
175
167
  r: radius - widths[1] / 2,
176
168
  });
177
169
  }
178
- function hilite(brush) {
179
- return ['#ffffff', '#fff', 'white'].includes(brush.color)
180
- ? hilites['hilitePrimary']
181
- : hilites['hiliteWhite'];
182
- }
183
170
  function renderArrow(s, brush, from, to, current, shorten) {
184
171
  function renderLine(isHilite) {
185
172
  const m = arrowMargin(shorten && !current), dx = to[0] - from[0], dy = to[1] - from[1], angle = Math.atan2(dy, dx), xo = Math.cos(angle) * m, yo = Math.sin(angle) * m;
173
+ const hilite = hiliteOf(s);
186
174
  return setAttributes(createElement('line'), {
187
- stroke: isHilite ? hilite(brush).color : brush.color,
188
- 'stroke-width': lineWidth(brush, current) + (isHilite ? 0.04 : 0),
175
+ stroke: isHilite ? hilite.color : brush.color,
176
+ 'stroke-width': lineWidth(brush, current) * (isHilite ? 1.14 : 1),
189
177
  'stroke-linecap': 'round',
190
- 'marker-end': `url(#arrowhead-${isHilite ? hilite(brush).key : brush.key})`,
178
+ 'marker-end': `url(#arrowhead-${isHilite ? hilite.key : brush.key})`,
191
179
  opacity: s.modifiers?.hilite ? 1 : opacity(brush, current),
192
180
  x1: from[0],
193
181
  y1: from[1],
@@ -197,7 +185,7 @@ function renderArrow(s, brush, from, to, current, shorten) {
197
185
  }
198
186
  if (!s.modifiers?.hilite)
199
187
  return renderLine(false);
200
- const g = createElement('g');
188
+ const g = setAttributes(createElement('g'), { opacity: brush.opacity });
201
189
  const blurred = setAttributes(createElement('g'), { filter: 'url(#cg-filter-blur)' });
202
190
  blurred.appendChild(filterBox(from, to));
203
191
  blurred.appendChild(renderLine(true));
@@ -278,6 +266,10 @@ function circleWidth() {
278
266
  function lineWidth(brush, current) {
279
267
  return ((brush.lineWidth || 10) * (current ? 0.85 : 1)) / 64;
280
268
  }
269
+ function hiliteOf(shape) {
270
+ const hilite = shape.modifiers?.hilite;
271
+ return { key: hilite && `hilite-${hilite.replace('#', '')}`, color: hilite };
272
+ }
281
273
  function opacity(brush, current) {
282
274
  return (brush.opacity || 1) * (current ? 0.9 : 1);
283
275
  }
package/dist/svg.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"svg.js","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,MAAM,OAAO,GAAkC;IAC7C,aAAa,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;IACnF,WAAW,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;CAChF,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AA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,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACnB,GAAG,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,8BAA8B;YAC9C,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACjC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;gBAC9D,IAAI,IAAI,GAAG,CAAC;oBAAE,GAAG,IAAI,GAAG,CAAC;gBACzB,sEAAsE;YACxE,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAC3E,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CACI,CAAC;AACrB,CAAC"}
package/dist/types.d.ts CHANGED
@@ -31,8 +31,10 @@ export interface Elements {
31
31
  wrap: HTMLElement;
32
32
  container: HTMLElement;
33
33
  ghost?: HTMLElement;
34
- svg?: SVGElement;
35
- customSvg?: SVGElement;
34
+ shapes?: SVGElement;
35
+ custom?: SVGElement;
36
+ shapesBelow?: SVGElement;
37
+ customBelow?: SVGElement;
36
38
  autoPieces?: HTMLElement;
37
39
  }
38
40
  export interface Dom {
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAoGA,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,CAAU,CAAC;AAClD,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AACpF,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AACvE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAsGA,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,CAAU,CAAC;AAClD,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AACpF,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AACvE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC"}
package/dist/wrap.js CHANGED
@@ -27,26 +27,19 @@ export function renderWrap(element, s) {
27
27
  element.appendChild(container);
28
28
  const board = createEl('cg-board');
29
29
  container.appendChild(board);
30
- let svg;
31
- let customSvg;
30
+ let shapesBelow;
31
+ let shapes;
32
+ let customBelow;
33
+ let custom;
32
34
  let autoPieces;
33
35
  if (s.drawable.visible) {
34
- svg = setAttributes(createSVG('svg'), {
35
- class: 'cg-shapes',
36
- viewBox: '-4 -4 8 8',
37
- preserveAspectRatio: 'xMidYMid slice',
38
- });
39
- svg.appendChild(createDefs());
40
- svg.appendChild(createSVG('g'));
41
- customSvg = setAttributes(createSVG('svg'), {
42
- class: 'cg-custom-svgs',
43
- viewBox: '-3.5 -3.5 8 8',
44
- preserveAspectRatio: 'xMidYMid slice',
45
- });
46
- customSvg.appendChild(createSVG('g'));
36
+ [shapesBelow, shapes] = ['cg-shapes-below', 'cg-shapes'].map(cls => svgContainer(cls, true));
37
+ [customBelow, custom] = ['cg-custom-below', 'cg-custom-svgs'].map(cls => svgContainer(cls, false));
47
38
  autoPieces = createEl('cg-auto-pieces');
48
- container.appendChild(svg);
49
- container.appendChild(customSvg);
39
+ container.appendChild(shapesBelow);
40
+ container.appendChild(customBelow);
41
+ container.appendChild(shapes);
42
+ container.appendChild(custom);
50
43
  container.appendChild(autoPieces);
51
44
  }
52
45
  if (s.coordinates) {
@@ -67,15 +60,18 @@ export function renderWrap(element, s) {
67
60
  setVisible(ghost, false);
68
61
  container.appendChild(ghost);
69
62
  }
70
- return {
71
- board,
72
- container,
73
- wrap: element,
74
- ghost,
75
- svg,
76
- customSvg,
77
- autoPieces,
78
- };
63
+ return { board, container, wrap: element, ghost, shapes, shapesBelow, custom, customBelow, autoPieces };
64
+ }
65
+ function svgContainer(cls, isShapes) {
66
+ const svg = setAttributes(createSVG('svg'), {
67
+ class: cls,
68
+ viewBox: isShapes ? '-4 -4 8 8' : '-3.5 -3.5 8 8',
69
+ preserveAspectRatio: 'xMidYMid slice',
70
+ });
71
+ svg.appendChild(createSVG('g'));
72
+ if (isShapes)
73
+ svg.appendChild(createDefs());
74
+ return svg;
79
75
  }
80
76
  function renderCoords(elems, className) {
81
77
  const el = createEl('coords', 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,EAA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AwB,EAAE,SAAiB;IAC/D,MAAM,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACzC,IAAI,CAAc,CAAC;IACnB,KAAK,MAAM,IAAI,IAAI,KAAK,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lichess-org/chessground",
3
- "version": "9.4.1",
3
+ "version": "9.5.0",
4
4
  "//": "version is managed by the build system",
5
5
  "description": "lichess.org chess ui",
6
6
  "type": "module",
@@ -28,17 +28,6 @@
28
28
  "typescript": "^5.6.3",
29
29
  "vitest": "^3.2.4"
30
30
  },
31
- "scripts": {
32
- "prepare": "$npm_execpath run compile",
33
- "compile": "tsc --sourceMap --declaration",
34
- "lint": "eslint src/*.ts",
35
- "format": "prettier --write .",
36
- "check-format": "prettier --check .",
37
- "bundle": "esbuild src/chessground.ts --bundle --format=esm --outfile=dist/chessground.min.js --minify",
38
- "dist": "$npm_execpath run compile && $npm_execpath run bundle",
39
- "test": "vitest run",
40
- "test:watch": "vitest"
41
- },
42
31
  "files": [
43
32
  "/dist/*.js",
44
33
  "/dist/*.d.ts",
@@ -61,5 +50,14 @@
61
50
  "url": "https://github.com/lichess-org/chessground/issues"
62
51
  },
63
52
  "funding": "https://lichess.org/patron",
64
- "packageManager": "pnpm@9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
65
- }
53
+ "scripts": {
54
+ "compile": "tsc --sourceMap --declaration",
55
+ "lint": "eslint src/*.ts",
56
+ "format": "prettier --write .",
57
+ "check-format": "prettier --check .",
58
+ "bundle": "esbuild src/chessground.ts --bundle --format=esm --outfile=dist/chessground.min.js --minify",
59
+ "dist": "$npm_execpath run compile && $npm_execpath run bundle",
60
+ "test": "vitest run",
61
+ "test:watch": "vitest"
62
+ }
63
+ }
@@ -27,7 +27,7 @@ export function Chessground(element: HTMLElement, config?: Config): Api {
27
27
  redrawNow = (skipSvg?: boolean): void => {
28
28
  render(state);
29
29
  if (elements.autoPieces) autoPieces.render(state, elements.autoPieces);
30
- if (!skipSvg && elements.svg) svg.renderSvg(state, elements.svg, elements.customSvg!);
30
+ if (!skipSvg && elements.shapes) svg.renderSvg(state, elements);
31
31
  },
32
32
  onResize = (): void => {
33
33
  updateBounds(state);
package/src/draw.ts CHANGED
@@ -9,13 +9,14 @@ export interface DrawShape {
9
9
  brush?: string; // if no brush, no shape. label moved to top right of square
10
10
  modifiers?: DrawModifiers;
11
11
  piece?: DrawShapePiece;
12
- customSvg?: { html: string; center?: 'orig' | 'dest' | 'label' }; // 100 x 100 viewbox cenetered at [50,50]
13
- label?: { text: string; fill?: string }; // fill is in '#rrggbb' format
12
+ customSvg?: { html: string; center?: 'orig' | 'dest' | 'label' }; // midpoint location of 100 x 100 viewbox
13
+ label?: { text: string; fill?: string }; // '#rrggbb' or '#rgb'
14
+ below?: boolean; // render to board plane, default is false (above pieces)
14
15
  }
15
16
 
16
17
  export interface DrawModifiers {
17
18
  lineWidth?: number;
18
- hilite?: boolean;
19
+ hilite?: string; // '#rrggbb'/'#rgb' - only implemented for arrows
19
20
  }
20
21
 
21
22
  export interface DrawShapePiece {
package/src/state.ts CHANGED
@@ -192,6 +192,7 @@ export function defaults(): HeadlessState {
192
192
  purple: { key: 'purple', color: '#68217a', opacity: 0.65, lineWidth: 10 },
193
193
  pink: { key: 'pink', color: '#ee2080', opacity: 0.5, lineWidth: 10 },
194
194
  white: { key: 'white', color: 'white', opacity: 1, lineWidth: 10 },
195
+ paleWhite: { key: 'pwhite', color: 'white', opacity: 0.6, lineWidth: 10 },
195
196
  },
196
197
  prevSvgHash: '',
197
198
  },
package/src/svg.ts CHANGED
@@ -4,27 +4,39 @@ import { Drawable, DrawShape, DrawShapePiece, DrawBrush, DrawBrushes, DrawModifi
4
4
  import { SyncableShape, Hash } from './sync.js';
5
5
  import * as cg from './types.js';
6
6
 
7
+ /*
8
+ -- DOM hierarchy --
9
+ <svg class="cg-shapes"> (<= svg)
10
+ <defs>
11
+ ...(for brushes)...
12
+ </defs>
13
+ <g>
14
+ ...(for arrows and circles)...
15
+ </g>
16
+ </svg>
17
+ <svg class="cg-custom-svgs"> (<= customSvg)
18
+ <g>
19
+ ...(for custom svgs)...
20
+ </g>
21
+ </svg>
22
+ */
23
+
7
24
  type CustomBrushes = Map<string, DrawBrush>; // by hash
8
25
  type Svg = { el: SVGElement; isCustom?: boolean };
9
26
  type AngleSlots = Set<number>; // arrow angle slots for label positioning
10
27
  type ArrowDests = Map<cg.Key | undefined, AngleSlots>; // angle slots per dest
11
28
 
12
- const hilites: { [name: string]: DrawBrush } = {
13
- hilitePrimary: { key: 'hilitePrimary', color: '#3291ff', opacity: 1, lineWidth: 1 },
14
- hiliteWhite: { key: 'hiliteWhite', color: '#ffffff', opacity: 1, lineWidth: 1 },
15
- };
16
-
17
29
  export { createElement, setAttributes };
18
30
 
19
31
  export function createDefs(): Element {
20
32
  const defs = createElement('defs');
21
33
  const filter = setAttributes(createElement('filter'), { id: 'cg-filter-blur' });
22
- filter.appendChild(setAttributes(createElement('feGaussianBlur'), { stdDeviation: '0.019' }));
34
+ filter.appendChild(setAttributes(createElement('feGaussianBlur'), { stdDeviation: '0.013' }));
23
35
  defs.appendChild(filter);
24
36
  return defs;
25
37
  }
26
38
 
27
- export function renderSvg(state: State, shapesEl: SVGElement, customsEl: SVGElement): void {
39
+ export function renderSvg(state: State, els: cg.Elements): void {
28
40
  const d = state.drawable,
29
41
  curD = d.current,
30
42
  cur = curD && curD.mouseSq ? (curD as DrawShape) : undefined,
@@ -40,13 +52,15 @@ export function renderSvg(state: State, shapesEl: SVGElement, customsEl: SVGElem
40
52
  sources.add(moveAngle(from, to));
41
53
  dests.set(s.dest, sources);
42
54
  }
43
- const shapes: SyncableShape[] = d.shapes.concat(nonPieceAutoShapes).map((s: DrawShape) => {
44
- return {
55
+ const shapes: SyncableShape[] = [];
56
+
57
+ for (const s of d.shapes.concat(nonPieceAutoShapes)) {
58
+ shapes.push({
45
59
  shape: s,
46
60
  current: false,
47
61
  hash: shapeHash(s, isShort(s.dest, dests), false, bounds),
48
- };
49
- });
62
+ });
63
+ }
50
64
  if (cur)
51
65
  shapes.push({
52
66
  shape: cur,
@@ -56,85 +70,74 @@ export function renderSvg(state: State, shapesEl: SVGElement, customsEl: SVGElem
56
70
 
57
71
  const fullHash = shapes.map(sc => sc.hash).join(';');
58
72
  if (fullHash === state.drawable.prevSvgHash) return;
59
- state.drawable.prevSvgHash = fullHash;
60
-
61
- /*
62
- -- DOM hierarchy --
63
- <svg class="cg-shapes"> (<= svg)
64
- <defs>
65
- ...(for brushes)...
66
- </defs>
67
- <g>
68
- ...(for arrows and circles)...
69
- </g>
70
- </svg>
71
- <svg class="cg-custom-svgs"> (<= customSvg)
72
- <g>
73
- ...(for custom svgs)...
74
- </g>
75
- </svg>
76
- */
77
73
 
78
- const defsEl = shapesEl.querySelector('defs') as SVGElement;
79
-
80
- syncDefs(d, shapes, defsEl);
81
- syncShapes(shapes, shapesEl.querySelector('g')!, customsEl.querySelector('g')!, s =>
82
- renderShape(state, s, d.brushes, dests, bounds),
83
- );
74
+ state.drawable.prevSvgHash = fullHash;
75
+ syncDefs(d, shapes, els);
76
+ syncShapes(shapes, els, s => renderShape(state, s, d.brushes, dests, bounds));
84
77
  }
85
78
 
86
79
  // append only. Don't try to update/remove.
87
- function syncDefs(d: Drawable, shapes: SyncableShape[], defsEl: SVGElement) {
88
- const brushes: CustomBrushes = new Map();
89
- let brush: DrawBrush;
90
- for (const s of shapes.filter(s => s.shape.dest && s.shape.brush)) {
91
- brush = makeCustomBrush(d.brushes[s.shape.brush!], s.shape.modifiers);
92
- if (s.shape.modifiers?.hilite) brushes.set(hilite(brush).key, hilite(brush));
93
- brushes.set(brush.key, brush);
94
- }
95
- const keysInDom = new Set();
96
- let el: SVGElement | undefined = defsEl.firstElementChild as SVGElement;
97
- while (el) {
98
- keysInDom.add(el.getAttribute('cgKey'));
99
- el = el.nextElementSibling as SVGElement | undefined;
100
- }
101
- for (const [key, brush] of brushes.entries()) {
102
- if (!keysInDom.has(key)) defsEl.appendChild(renderMarker(brush));
80
+ function syncDefs(d: Drawable, shapes: SyncableShape[], els: cg.Elements) {
81
+ for (const shapesEl of [els.shapes, els.shapesBelow]) {
82
+ const defsEl = shapesEl!.querySelector('defs') as SVGElement;
83
+ const thisPlane = shapes.filter(s => (shapesEl === els.shapesBelow) === !!s.shape.below);
84
+ const brushes: CustomBrushes = new Map();
85
+ for (const s of thisPlane.filter(s => s.shape.dest && s.shape.brush)) {
86
+ const brush = makeCustomBrush(d.brushes[s.shape.brush!], s.shape.modifiers);
87
+ const { key, color } = hiliteOf(s.shape);
88
+ if (key && color) brushes.set(key, { key, color, opacity: 1, lineWidth: 1 });
89
+ brushes.set(brush.key, brush);
90
+ }
91
+ const keysInDom = new Set();
92
+ let el: SVGElement | undefined = defsEl.firstElementChild as SVGElement;
93
+ while (el) {
94
+ keysInDom.add(el.getAttribute('cgKey'));
95
+ el = el.nextElementSibling as SVGElement | undefined;
96
+ }
97
+ for (const [key, brush] of brushes.entries()) {
98
+ if (!keysInDom.has(key)) defsEl.appendChild(renderMarker(brush));
99
+ }
103
100
  }
104
101
  }
105
102
 
106
103
  function syncShapes(
107
- syncables: SyncableShape[],
108
- shapes: Element,
109
- customs: Element,
104
+ shapes: SyncableShape[],
105
+ els: cg.Elements,
110
106
  renderShape: (shape: SyncableShape) => Svg[],
111
107
  ): void {
112
- const hashesInDom = new Map();
113
-
114
- for (const sc of syncables) hashesInDom.set(sc.hash, false);
115
- for (const root of [shapes, customs]) {
116
- const toRemove: SVGElement[] = [];
117
- let el: SVGElement | undefined = root.firstElementChild as SVGElement,
118
- elHash: Hash | null;
119
- while (el) {
120
- elHash = el.getAttribute('cgHash') as Hash;
121
- if (hashesInDom.has(elHash)) hashesInDom.set(elHash, true);
122
- else toRemove.push(el);
123
- el = el.nextElementSibling as SVGElement | undefined;
108
+ for (const [shapesEl, customEl] of [
109
+ [els.shapes, els.custom],
110
+ [els.shapesBelow, els.customBelow],
111
+ ]) {
112
+ const [shapesG, customG] = [shapesEl, customEl].map(el => el!.querySelector('g') as SVGElement);
113
+ const thisPlane = shapes.filter(s => (shapesEl === els.shapesBelow) === !!s.shape.below);
114
+ const hashesInDom = new Map();
115
+
116
+ for (const sc of thisPlane) hashesInDom.set(sc.hash, false);
117
+ for (const root of [shapesG, customG]) {
118
+ const toRemove: SVGElement[] = [];
119
+ let el: SVGElement | undefined = root.firstElementChild as SVGElement,
120
+ elHash: Hash | null;
121
+ while (el) {
122
+ elHash = el.getAttribute('cgHash') as Hash;
123
+ if (hashesInDom.has(elHash)) hashesInDom.set(elHash, true);
124
+ else toRemove.push(el);
125
+ el = el.nextElementSibling as SVGElement | undefined;
126
+ }
127
+ for (const el of toRemove) root.removeChild(el);
124
128
  }
125
- for (const el of toRemove) root.removeChild(el);
126
- }
127
- // insert shapes that are not yet in dom
128
- for (const sc of syncables.filter(s => !hashesInDom.get(s.hash))) {
129
- for (const svg of renderShape(sc)) {
130
- if (svg.isCustom) customs.appendChild(svg.el);
131
- else shapes.appendChild(svg.el);
129
+ // insert shapes that are not yet in dom
130
+ for (const sc of thisPlane.filter(s => !hashesInDom.get(s.hash))) {
131
+ for (const svg of renderShape(sc)) {
132
+ if (svg.isCustom) customG.appendChild(svg.el);
133
+ else shapesG.appendChild(svg.el);
134
+ }
132
135
  }
133
136
  }
134
137
  }
135
138
 
136
139
  function shapeHash(
137
- { orig, dest, brush, piece, modifiers, customSvg, label }: DrawShape,
140
+ { orig, dest, brush, piece, modifiers, customSvg, label, below }: DrawShape,
138
141
  shorten: boolean,
139
142
  current: boolean,
140
143
  bounds: DOMRectReadOnly,
@@ -152,6 +155,7 @@ function shapeHash(
152
155
  modifiers && modifiersHash(modifiers),
153
156
  customSvg && `custom-${textHash(customSvg.html)},${customSvg.center?.[0] ?? 'o'}`,
154
157
  label && `label-${textHash(label.text)}`,
158
+ below && 'below',
155
159
  ]
156
160
  .filter(x => x)
157
161
  .join(',');
@@ -162,7 +166,7 @@ function pieceHash(piece: DrawShapePiece): Hash {
162
166
  }
163
167
 
164
168
  function modifiersHash(m: DrawModifiers): Hash {
165
- return [m.lineWidth, m.hilite && '*'].filter(x => x).join(',');
169
+ return [m.lineWidth, m.hilite].filter(x => x).join(',');
166
170
  }
167
171
 
168
172
  function textHash(s: string): Hash {
@@ -231,12 +235,6 @@ function renderCircle(
231
235
  });
232
236
  }
233
237
 
234
- function hilite(brush: DrawBrush): DrawBrush {
235
- return ['#ffffff', '#fff', 'white'].includes(brush.color)
236
- ? hilites['hilitePrimary']
237
- : hilites['hiliteWhite'];
238
- }
239
-
240
238
  function renderArrow(
241
239
  s: DrawShape,
242
240
  brush: DrawBrush,
@@ -252,11 +250,12 @@ function renderArrow(
252
250
  angle = Math.atan2(dy, dx),
253
251
  xo = Math.cos(angle) * m,
254
252
  yo = Math.sin(angle) * m;
253
+ const hilite = hiliteOf(s);
255
254
  return setAttributes(createElement('line'), {
256
- stroke: isHilite ? hilite(brush).color : brush.color,
257
- 'stroke-width': lineWidth(brush, current) + (isHilite ? 0.04 : 0),
255
+ stroke: isHilite ? hilite.color : brush.color,
256
+ 'stroke-width': lineWidth(brush, current) * (isHilite ? 1.14 : 1),
258
257
  'stroke-linecap': 'round',
259
- 'marker-end': `url(#arrowhead-${isHilite ? hilite(brush).key : brush.key})`,
258
+ 'marker-end': `url(#arrowhead-${isHilite ? hilite.key : brush.key})`,
260
259
  opacity: s.modifiers?.hilite ? 1 : opacity(brush, current),
261
260
  x1: from[0],
262
261
  y1: from[1],
@@ -266,7 +265,7 @@ function renderArrow(
266
265
  }
267
266
  if (!s.modifiers?.hilite) return renderLine(false);
268
267
 
269
- const g = createElement('g');
268
+ const g = setAttributes(createElement('g'), { opacity: brush.opacity });
270
269
  const blurred = setAttributes(createElement('g'), { filter: 'url(#cg-filter-blur)' });
271
270
  blurred.appendChild(filterBox(from, to));
272
271
  blurred.appendChild(renderLine(true));
@@ -371,6 +370,11 @@ function lineWidth(brush: DrawBrush, current: boolean): number {
371
370
  return ((brush.lineWidth || 10) * (current ? 0.85 : 1)) / 64;
372
371
  }
373
372
 
373
+ function hiliteOf(shape: DrawShape): { key?: string; color?: string } {
374
+ const hilite = shape.modifiers?.hilite;
375
+ return { key: hilite && `hilite-${hilite.replace('#', '')}`, color: hilite };
376
+ }
377
+
374
378
  function opacity(brush: DrawBrush, current: boolean): number {
375
379
  return (brush.opacity || 1) * (current ? 0.9 : 1);
376
380
  }
package/src/types.ts CHANGED
@@ -37,8 +37,10 @@ export interface Elements {
37
37
  wrap: HTMLElement;
38
38
  container: HTMLElement;
39
39
  ghost?: HTMLElement;
40
- svg?: SVGElement;
41
- customSvg?: SVGElement;
40
+ shapes?: SVGElement;
41
+ custom?: SVGElement;
42
+ shapesBelow?: SVGElement;
43
+ customBelow?: SVGElement;
42
44
  autoPieces?: HTMLElement;
43
45
  }
44
46
  export interface Dom {
package/src/wrap.ts CHANGED
@@ -34,30 +34,22 @@ export function renderWrap(element: HTMLElement, s: HeadlessState): Elements {
34
34
  const board = createEl('cg-board');
35
35
  container.appendChild(board);
36
36
 
37
- let svg: SVGElement | undefined;
38
- let customSvg: SVGElement | undefined;
37
+ let shapesBelow: SVGElement | undefined;
38
+ let shapes: SVGElement | undefined;
39
+ let customBelow: SVGElement | undefined;
40
+ let custom: SVGElement | undefined;
39
41
  let autoPieces: HTMLElement | undefined;
40
42
 
41
43
  if (s.drawable.visible) {
42
- svg = setAttributes(createSVG('svg'), {
43
- class: 'cg-shapes',
44
- viewBox: '-4 -4 8 8',
45
- preserveAspectRatio: 'xMidYMid slice',
46
- });
47
- svg.appendChild(createDefs());
48
- svg.appendChild(createSVG('g'));
49
-
50
- customSvg = setAttributes(createSVG('svg'), {
51
- class: 'cg-custom-svgs',
52
- viewBox: '-3.5 -3.5 8 8',
53
- preserveAspectRatio: 'xMidYMid slice',
54
- });
55
- customSvg.appendChild(createSVG('g'));
44
+ [shapesBelow, shapes] = ['cg-shapes-below', 'cg-shapes'].map(cls => svgContainer(cls, true));
45
+ [customBelow, custom] = ['cg-custom-below', 'cg-custom-svgs'].map(cls => svgContainer(cls, false));
56
46
 
57
47
  autoPieces = createEl('cg-auto-pieces');
58
48
 
59
- container.appendChild(svg);
60
- container.appendChild(customSvg);
49
+ container.appendChild(shapesBelow);
50
+ container.appendChild(customBelow);
51
+ container.appendChild(shapes);
52
+ container.appendChild(custom);
61
53
  container.appendChild(autoPieces);
62
54
  }
63
55
 
@@ -88,15 +80,18 @@ export function renderWrap(element: HTMLElement, s: HeadlessState): Elements {
88
80
  container.appendChild(ghost);
89
81
  }
90
82
 
91
- return {
92
- board,
93
- container,
94
- wrap: element,
95
- ghost,
96
- svg,
97
- customSvg,
98
- autoPieces,
99
- };
83
+ return { board, container, wrap: element, ghost, shapes, shapesBelow, custom, customBelow, autoPieces };
84
+ }
85
+
86
+ function svgContainer(cls: string, isShapes: boolean) {
87
+ const svg = setAttributes(createSVG('svg'), {
88
+ class: cls,
89
+ viewBox: isShapes ? '-4 -4 8 8' : '-3.5 -3.5 8 8',
90
+ preserveAspectRatio: 'xMidYMid slice',
91
+ });
92
+ svg.appendChild(createSVG('g'));
93
+ if (isShapes) svg.appendChild(createDefs());
94
+ return svg;
100
95
  }
101
96
 
102
97
  function renderCoords(elems: readonly string[], className: string): HTMLElement {