diff --git a/app/templating/AssetHelper.scala b/app/templating/AssetHelper.scala index c91f5f730b..ac0208646f 100644 --- a/app/templating/AssetHelper.scala +++ b/app/templating/AssetHelper.scala @@ -56,7 +56,6 @@ trait AssetHelper { self: I18nHelper with SecurityHelper => def captchaTag = jsModule("captcha") def infiniteScrollTag = jsModule("infiniteScroll") - def chessgroundTag = jsAt("javascripts/vendor/chessground.min.js") def cashTag = jsAt("javascripts/vendor/cash.min.js") def fingerprintTag = jsAt("javascripts/fipr.js") def tagifyTag = jsAt("vendor/tagify/tagify.min.js") diff --git a/app/views/analyse/bits.scala b/app/views/analyse/bits.scala index 092855e406..5f0d7a2f30 100644 --- a/app/views/analyse/bits.scala +++ b/app/views/analyse/bits.scala @@ -19,7 +19,6 @@ object bits { moreCss = moreCss, moreJs = moreJs, openGraph = openGraph, - chessground = false, robots = false, zoomable = true, csp = defaultCsp.withWebAssembly.withPeer.some diff --git a/app/views/base/layout.scala b/app/views/base/layout.scala index 3c89168204..472c62b94f 100644 --- a/app/views/base/layout.scala +++ b/app/views/base/layout.scala @@ -154,9 +154,8 @@ object layout { nonce ) - private def loadScripts(moreJs: Frag, chessground: Boolean)(implicit ctx: Context) = + private def loadScripts(moreJs: Frag)(implicit ctx: Context) = frag( - chessground option chessgroundTag, ctx.requiresFingerprint option fingerprintTag, ctx.nonce map lichessJsObject, if (netConfig.minifiedAssets) @@ -193,7 +192,6 @@ object layout { moreJs: Frag = emptyFrag, playing: Boolean = false, openGraph: Option[lila.app.ui.OpenGraph] = None, - chessground: Boolean = true, zoomable: Boolean = false, csp: Option[ContentSecurityPolicy] = None, wrapClass: String = "" @@ -295,7 +293,7 @@ object layout { ) ), a(id := "reconnecting", cls := "link text", dataIcon := "B")(trans.reconnecting()), - loadScripts(moreJs, chessground) + loadScripts(moreJs) ) ) ) diff --git a/app/views/board/editor.scala b/app/views/board/editor.scala index 57ec3cf487..2c7380f297 100644 --- a/app/views/board/editor.scala +++ b/app/views/board/editor.scala @@ -25,7 +25,6 @@ LichessEditor(document.getElementById('board-editor'), data);""" ) ), moreCss = cssTag("editor"), - chessground = false, zoomable = true, openGraph = lila.app.ui .OpenGraph( diff --git a/app/views/board/userAnalysis.scala b/app/views/board/userAnalysis.scala index f8db75763c..0896eaace5 100644 --- a/app/views/board/userAnalysis.scala +++ b/app/views/board/userAnalysis.scala @@ -38,7 +38,6 @@ object userAnalysis { )}""") ), csp = defaultCsp.withWebAssembly.some, - chessground = false, openGraph = lila.app.ui .OpenGraph( title = "Chess analysis board", diff --git a/app/views/lobby/home.scala b/app/views/lobby/home.scala index 7d6e45d1e0..c19444b8c7 100644 --- a/app/views/lobby/home.scala +++ b/app/views/lobby/home.scala @@ -37,7 +37,6 @@ object home { ) ), moreCss = cssTag("lobby"), - chessground = false, openGraph = lila.app.ui .OpenGraph( image = assetUrl("logo/lichess-tile-wide.png").some, diff --git a/app/views/practice/show.scala b/app/views/practice/show.scala index c65daf43c8..02f694b7e0 100644 --- a/app/views/practice/show.scala +++ b/app/views/practice/show.scala @@ -34,7 +34,6 @@ object show { )}""") ), csp = defaultCsp.withWebAssembly.some, - chessground = false, zoomable = true ) { main(cls := "analyse") diff --git a/app/views/puzzle/show.scala b/app/views/puzzle/show.scala index 9e310f4196..34951eda7d 100644 --- a/app/views/puzzle/show.scala +++ b/app/views/puzzle/show.scala @@ -34,7 +34,6 @@ object show { )})""") ), csp = defaultCsp.withWebAssembly.some, - chessground = false, openGraph = lila.app.ui .OpenGraph( image = cdnUrl(routes.Export.puzzleThumbnail(puzzle.id.value).url).some, diff --git a/app/views/racer.scala b/app/views/racer.scala index 40a07ef6d4..f6dc620094 100644 --- a/app/views/racer.scala +++ b/app/views/racer.scala @@ -50,7 +50,6 @@ object racer { ), title = "Puzzle Racer", zoomable = true, - chessground = false ) { main( div(cls := "racer racer-app racer--play")( diff --git a/app/views/relay/show.scala b/app/views/relay/show.scala index 31b88095b3..4a720ea915 100644 --- a/app/views/relay/show.scala +++ b/app/views/relay/show.scala @@ -53,7 +53,6 @@ object show { ) )}""") ), - chessground = false, zoomable = true, csp = defaultCsp.withWebAssembly.some, openGraph = lila.app.ui diff --git a/app/views/round/bits.scala b/app/views/round/bits.scala index aade1a7475..f1281898a5 100644 --- a/app/views/round/bits.scala +++ b/app/views/round/bits.scala @@ -18,7 +18,6 @@ object bits { moreJs: Frag = emptyFrag, openGraph: Option[lila.app.ui.OpenGraph] = None, moreCss: Frag = emptyFrag, - chessground: Boolean = true, playing: Boolean = false, robots: Boolean = false )(body: Frag)(implicit ctx: Context) = @@ -31,7 +30,6 @@ object bits { ctx.blind option cssTag("round.nvui"), moreCss ), - chessground = chessground, playing = playing, robots = robots, zoomable = true, diff --git a/app/views/round/player.scala b/app/views/round/player.scala index a7a03a196d..263ed6e11b 100644 --- a/app/views/round/player.scala +++ b/app/views/round/player.scala @@ -60,7 +60,6 @@ object player { )})""") ), openGraph = povOpenGraph(pov).some, - chessground = false, playing = true )( main(cls := "round")( diff --git a/app/views/round/watcher.scala b/app/views/round/watcher.scala index f63859124f..3a3b8b6241 100644 --- a/app/views/round/watcher.scala +++ b/app/views/round/watcher.scala @@ -49,7 +49,6 @@ object watcher { )})""") ), openGraph = povOpenGraph(pov).some, - chessground = false )( main(cls := "round")( st.aside(cls := "round__side")( @@ -70,7 +69,6 @@ object watcher { variant = pov.game.variant, title = gameVsText(pov.game, withRatings = true), openGraph = povOpenGraph(pov).some, - chessground = false )( frag( main(cls := "round")( diff --git a/app/views/storm.scala b/app/views/storm.scala index 7fd3143000..bba070edb9 100644 --- a/app/views/storm.scala +++ b/app/views/storm.scala @@ -31,7 +31,6 @@ object storm { ), title = "Puzzle Storm", zoomable = true, - chessground = false ) { main( div(cls := "storm storm-app storm--play")( diff --git a/app/views/study/show.scala b/app/views/study/show.scala index aa79c51f14..1848dc1309 100644 --- a/app/views/study/show.scala +++ b/app/views/study/show.scala @@ -53,7 +53,6 @@ object show { )}""") ), robots = s.isPublic, - chessground = false, zoomable = true, csp = defaultCsp.withWebAssembly.withPeer.some, openGraph = lila.app.ui diff --git a/app/views/swiss/show.scala b/app/views/swiss/show.scala index 0d4afede3d..3fa83da2ed 100644 --- a/app/views/swiss/show.scala +++ b/app/views/swiss/show.scala @@ -56,7 +56,6 @@ object show { cssTag("swiss.show"), hasScheduleInput option cssTag("flatpickr") ), - chessground = false, openGraph = lila.app.ui .OpenGraph( title = s"${fullName(s)}: ${s.variant.name} ${s.clock.show} #${s.id}", diff --git a/app/views/tournament/show.scala b/app/views/tournament/show.scala index 6a98d90acd..740be6864b 100644 --- a/app/views/tournament/show.scala +++ b/app/views/tournament/show.scala @@ -48,7 +48,6 @@ object show { if (tour.isTeamBattle) "tournament.show.team-battle" else "tournament.show" }, - chessground = false, openGraph = lila.app.ui .OpenGraph( title = s"${tour.name()}: ${tour.variant.name} ${tour.clock.show} ${tour.mode.name} #${tour.id}", diff --git a/app/views/tv/index.scala b/app/views/tv/index.scala index 98fb2bdb80..d509b37849 100644 --- a/app/views/tv/index.scala +++ b/app/views/tv/index.scala @@ -35,7 +35,6 @@ object index { ) ), moreCss = cssTag("tv.single"), - chessground = false, openGraph = lila.app.ui .OpenGraph( title = s"Watch the best ${channel.name.toLowerCase} games of lichess.org", diff --git a/public/javascripts/vendor/chessground.min.js b/public/javascripts/vendor/chessground.min.js deleted file mode 100644 index 7585cd1277..0000000000 --- a/public/javascripts/vendor/chessground.min.js +++ /dev/null @@ -1 +0,0 @@ -var Chessground=function(){"use strict";function e(e,t,o){return e(o={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&o.path)}},o.exports),o.exports}var t=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ranks=t.files=t.colors=void 0,t.colors=["white","black"],t.files=["a","b","c","d","e","f","g","h"],t.ranks=["1","2","3","4","5","6","7","8"]})),o=e((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.createEl=o.isRightButton=o.eventPosition=o.setVisible=o.translateRel=o.translateAbs=o.posToTranslateRel=o.posToTranslateAbs=o.samePiece=o.distanceSq=o.opposite=o.timer=o.memo=o.allPos=o.key2pos=o.pos2key=o.allKeys=o.invRanks=void 0,o.invRanks=["8","7","6","5","4","3","2","1"],o.allKeys=Array.prototype.concat(...t.files.map(e=>t.ranks.map(t=>e+t))),o.pos2key=e=>o.allKeys[8*e[0]+e[1]],o.key2pos=e=>[e.charCodeAt(0)-97,e.charCodeAt(1)-49],o.allPos=o.allKeys.map(o.key2pos),o.memo=function(e){let t;const o=()=>(void 0===t&&(t=e()),t);return o.clear=()=>{t=void 0},o},o.timer=()=>{let e;return{start(){e=performance.now()},cancel(){e=void 0},stop(){if(!e)return 0;const t=performance.now()-e;return e=void 0,t}}},o.opposite=e=>"white"===e?"black":"white",o.distanceSq=(e,t)=>{const o=e[0]-t[0],n=e[1]-t[1];return o*o+n*n},o.samePiece=(e,t)=>e.role===t.role&&e.color===t.color;const n=(e,t,o,n)=>[(t?e[0]:7-e[0])*o,(t?7-e[1]:e[1])*n];o.posToTranslateAbs=e=>{const t=e.width/8,o=e.height/8;return(e,r)=>n(e,r,t,o)},o.posToTranslateRel=(e,t)=>n(e,t,100,100),o.translateAbs=(e,t)=>{e.style.transform=`translate(${t[0]}px,${t[1]}px)`},o.translateRel=(e,t)=>{e.style.transform=`translate(${t[0]}%,${t[1]}%)`},o.setVisible=(e,t)=>{e.style.visibility=t?"visible":"hidden"},o.eventPosition=e=>{var t;return e.clientX||0===e.clientX?[e.clientX,e.clientY]:(null===(t=e.targetTouches)||void 0===t?void 0:t[0])?[e.targetTouches[0].clientX,e.targetTouches[0].clientY]:void 0},o.isRightButton=e=>2===e.buttons||2===e.button,o.createEl=(e,t)=>{const o=document.createElement(e);return t&&(o.className=t),o}})),n=e((function(e,t){function n(e,t){return Math.abs(e-t)}Object.defineProperty(t,"__esModule",{value:!0}),t.premove=t.queen=t.knight=void 0,t.knight=(e,t,o,r)=>{const s=n(e,o),i=n(t,r);return 1===s&&2===i||2===s&&1===i};const r=(e,t,o,r)=>n(e,o)===n(t,r),s=(e,t,o,n)=>e===o||t===n;t.queen=(e,t,o,n)=>r(e,t,o,n)||s(e,t,o,n),t.premove=function(e,i,a){const c=e.get(i);if(!c)return[];const l=o.key2pos(i),d=c.role,u="pawn"===d?(p=c.color,(e,t,o,r)=>n(e,o)<2&&("white"===p?r===t+1||t<=1&&r===t+2&&e===o:r===t-1||t>=6&&r===t-2&&e===o)):"knight"===d?t.knight:"bishop"===d?r:"rook"===d?s:"queen"===d?t.queen:function(e,t,o){return(r,s,i,a)=>n(r,i)<2&&n(s,a)<2||o&&s===a&&s===("white"===e?0:7)&&(4===r&&(2===i&&t.includes(0)||6===i&&t.includes(7))||t.includes(i))}(c.color,function(e,t){const n="white"===t?"1":"8",r=[];for(const[s,i]of e)s[1]===n&&i.color===t&&"rook"===i.role&&r.push(o.key2pos(s)[0]);return r}(e,c.color),a);var p;return o.allPos.filter(e=>(l[0]!==e[0]||l[1]!==e[1])&&u(l[0],l[1],e[0],e[1])).map(o.pos2key)}})),r=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.clear=t.cancel=t.end=t.move=t.processDraw=t.start=void 0;const n=["green","red","blue","yellow"];function r(e){requestAnimationFrame(()=>{const t=e.drawable.current;if(t){const o=a.getKeyAtDomPos(t.pos,a.whitePov(e),e.dom.bounds());o||(t.snapToValidMove=!1);const n=t.snapToValidMove?a.getSnappedKeyAtDomPos(t.orig,t.pos,a.whitePov(e),e.dom.bounds()):o;n!==t.mouseSq&&(t.mouseSq=n,t.dest=n!==t.orig?n:void 0,e.dom.redrawNow()),r(e)}})}function s(e){e.drawable.current&&(e.drawable.current=void 0,e.dom.redraw())}function i(e){var t;const r=(e.shiftKey||e.ctrlKey)&&o.isRightButton(e),s=e.altKey||e.metaKey||(null===(t=e.getModifierState)||void 0===t?void 0:t.call(e,"AltGraph"));return n[(r?1:0)+(s?2:0)]}function c(e){e.onChange&&e.onChange(e.shapes)}t.start=function(e,t){if(t.touches&&t.touches.length>1)return;t.stopPropagation(),t.preventDefault(),t.ctrlKey?a.unselect(e):a.cancelMove(e);const n=o.eventPosition(t),s=a.getKeyAtDomPos(n,a.whitePov(e),e.dom.bounds());s&&(e.drawable.current={orig:s,pos:n,brush:i(t),snapToValidMove:e.drawable.defaultSnapToValidMove},r(e))},t.processDraw=r,t.move=function(e,t){e.drawable.current&&(e.drawable.current.pos=o.eventPosition(t))},t.end=function(e){const t=e.drawable.current;t&&(t.mouseSq&&function(e,t){const o=e=>e.orig===t.orig&&e.dest===t.dest,n=e.shapes.find(o);n&&(e.shapes=e.shapes.filter(e=>!o(e)));n&&n.brush===t.brush||e.shapes.push(t);c(e)}(e.drawable,t),s(e))},t.cancel=s,t.clear=function(e){e.drawable.shapes.length&&(e.drawable.shapes=[],e.dom.redraw(),c(e.drawable))}})),s=e((function(e,t){function n(e,t){const o=e(t);return t.dom.redraw(),o}function r(e,t){return{key:e,pos:o.key2pos(e),piece:t}}function s(e,t){return t.sort((t,n)=>o.distanceSq(e.pos,t.pos)-o.distanceSq(e.pos,n.pos))[0]}Object.defineProperty(t,"__esModule",{value:!0}),t.render=t.anim=void 0,t.anim=function(e,t){return t.animation.enabled?function(e,t){const n=new Map(t.pieces),i=e(t),a=function(e,t){const n=new Map,i=[],a=new Map,c=[],l=[],d=new Map;let u,p,f;for(const[o,s]of e)d.set(o,r(o,s));for(const s of o.allKeys)u=t.pieces.get(s),p=d.get(s),u?p?o.samePiece(u,p.piece)||(c.push(p),l.push(r(s,u))):l.push(r(s,u)):p&&c.push(p);for(const r of l)p=s(r,c.filter(e=>o.samePiece(r.piece,e.piece))),p&&(f=[p.pos[0]-r.pos[0],p.pos[1]-r.pos[1]],n.set(r.key,f.concat(f)),i.push(p.key));for(const o of c)i.includes(o.key)||a.set(o.key,o.piece);return{anims:n,fadings:a}}(n,t);if(a.anims.size||a.fadings.size){const e=t.animation.current&&t.animation.current.start;t.animation.current={start:performance.now(),frequency:1/t.animation.duration,plan:a},e||function e(t,o){const n=t.animation.current;if(void 0===n)return void(t.dom.destroyed||t.dom.redrawNow());const r=1-(o-n.start)*n.frequency;if(r<=0)t.animation.current=void 0,t.dom.redrawNow();else{const o=(s=r)<.5?4*s*s*s:(s-1)*(2*s-2)*(2*s-2)+1;for(const e of n.plan.anims.values())e[2]=e[0]*o,e[3]=e[1]*o;t.dom.redrawNow(!0),requestAnimationFrame((o=performance.now())=>e(t,o))}var s}(t,performance.now())}else t.dom.redraw();return i}(e,t):n(e,t)},t.render=n})),i=e((function(e,t){function n(e){requestAnimationFrame(()=>{var t;const r=e.draggable.current;if(!r)return;(null===(t=e.animation.current)||void 0===t?void 0:t.plan.anims.has(r.orig))&&(e.animation.current=void 0);const s=e.pieces.get(r.orig);if(s&&o.samePiece(s,r.piece)){if(!r.started&&o.distanceSq(r.pos,r.origPos)>=Math.pow(e.draggable.distance,2)&&(r.started=!0),r.started){if("function"==typeof r.element){const e=r.element();if(!e)return;e.cgDragging=!0,e.classList.add("dragging"),r.element=e}const t=e.dom.bounds();o.translateAbs(r.element,[r.pos[0]-t.left-t.width/16,r.pos[1]-t.top-t.height/16])}}else i(e);n(e)})}function i(e){const t=e.draggable.current;t&&(t.newPiece&&e.pieces.delete(t.orig),e.draggable.current=void 0,a.unselect(e),c(e),e.dom.redraw())}function c(e){const t=e.dom.elements;t.ghost&&o.setVisible(t.ghost,!1)}function l(e,t,n){const r=o.key2pos(e);return t||(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]}function d(e,t){let o=e.dom.elements.board.firstChild;for(;o;){if(o.cgKey===t&&"PIECE"===o.tagName)return o;o=o.nextSibling}}Object.defineProperty(t,"__esModule",{value:!0}),t.computeSquareCenter=t.cancel=t.end=t.move=t.dragNewPiece=t.start=void 0,t.start=function(e,t){if(void 0!==t.button&&0!==t.button)return;if(t.touches&&t.touches.length>1)return;const i=e.dom.bounds(),c=o.eventPosition(t),u=a.getKeyAtDomPos(c,a.whitePov(e),i);if(!u)return;const p=e.pieces.get(u),f=e.selected;f||!e.drawable.enabled||!e.drawable.eraseOnClick&&p&&p.color===e.turnColor||r.clear(e),!1===t.cancelable||t.touches&&e.movable.color&&!p&&!f&&!function(e,t){const n=a.whitePov(e),r=e.dom.bounds(),s=Math.pow(r.width/8,2);for(const i in e.pieces){const e=l(i,n,r);if(o.distanceSq(e,t)<=s)return!0}return!1}(e,c)||t.preventDefault();const g=!!e.premovable.current,v=!!e.predroppable.current;e.stats.ctrlKey=t.ctrlKey,e.selected&&a.canMove(e,e.selected,u)?s.anim(e=>a.selectSquare(e,u),e):a.selectSquare(e,u);const m=e.selected===u,h=d(e,u);if(p&&h&&m&&a.isDraggable(e,u)){e.draggable.current={orig:u,piece:p,origPos:c,pos:c,started:e.draggable.autoDistance&&e.stats.dragged,element:h,previouslySelected:f,originTarget:t.target},h.cgDragging=!0,h.classList.add("dragging");const r=e.dom.elements.ghost;r&&(r.className=`ghost ${p.color} ${p.role}`,o.translateAbs(r,o.posToTranslateAbs(i)(o.key2pos(u),a.whitePov(e))),o.setVisible(r,!0)),n(e)}else g&&a.unsetPremove(e),v&&a.unsetPredrop(e);e.dom.redraw()},t.dragNewPiece=function(e,t,r,s){e.pieces.set("a0",t),e.dom.redraw();const i=o.eventPosition(r);e.draggable.current={orig:"a0",piece:t,origPos:i,pos:i,started:!0,element:()=>d(e,"a0"),originTarget:r.target,newPiece:!0,force:!!s},n(e)},t.move=function(e,t){e.draggable.current&&(!t.touches||t.touches.length<2)&&(e.draggable.current.pos=o.eventPosition(t))},t.end=function(e,t){const n=e.draggable.current;if(!n)return;if("touchend"===t.type&&!1!==t.cancelable&&t.preventDefault(),"touchend"===t.type&&n.originTarget!==t.target&&!n.newPiece)return void(e.draggable.current=void 0);a.unsetPremove(e),a.unsetPredrop(e);const r=o.eventPosition(t)||n.pos,s=a.getKeyAtDomPos(r,a.whitePov(e),e.dom.bounds());s&&n.started&&n.orig!==s?n.newPiece?a.dropNewPiece(e,n.orig,s,n.force):(e.stats.ctrlKey=t.ctrlKey,a.userMove(e,n.orig,s)&&(e.stats.dragged=!0)):n.newPiece?e.pieces.delete(n.orig):e.draggable.deleteOnDropOff&&!s&&(e.pieces.delete(n.orig),a.callUserFunction(e.events.change)),(n.orig!==n.previouslySelected||n.orig!==s&&s)&&e.selectable.enabled||a.unselect(e),c(e),e.draggable.current=void 0,e.dom.redraw()},t.cancel=i,t.computeSquareCenter=l})),a=e((function(e,t){function r(e,...t){e&&setTimeout(()=>e(...t),1)}function s(e){e.premovable.current&&(e.premovable.current=void 0,r(e.premovable.events.unset))}function a(e){const t=e.predroppable;t.current&&(t.current=void 0,r(t.events.unset))}function c(e,t,n){const s=e.pieces.get(t),i=e.pieces.get(n);if(t===n||!s)return!1;const a=i&&i.color!==s.color?i:void 0;return n===e.selected&&f(e),r(e.events.move,t,n,a),function(e,t,n){if(!e.autoCastle)return!1;const r=e.pieces.get(t);if(!r||"king"!==r.role)return!1;const s=o.key2pos(t),i=o.key2pos(n);if(0!==s[1]&&7!==s[1]||s[1]!==i[1])return!1;4!==s[0]||e.pieces.has(n)||(6===i[0]?n=o.pos2key([7,i[1]]):2===i[0]&&(n=o.pos2key([0,i[1]])));const a=e.pieces.get(n);return!(!a||a.color!==r.color||"rook"!==a.role)&&(e.pieces.delete(t),e.pieces.delete(n),s[0]=0&&r<8&&s>=0&&s<8?o.pos2key([r,s]):void 0},t.getSnappedKeyAtDomPos=function(e,t,r,s){const a=o.key2pos(e),c=o.allPos.filter(e=>n.queen(a[0],a[1],e[0],e[1])||n.knight(a[0],a[1],e[0],e[1])),l=c.map(e=>i.computeSquareCenter(o.pos2key(e),r,s)).map(e=>o.distanceSq(t,e)),[,d]=l.reduce((e,t,o)=>e[0]t.files.map(t=>{const n=e.get(t+o);if(n){const e=s[n.role];return"white"===n.color?e.toUpperCase():e}return"1"}).join("")).join("/").replace(/1{2,}/g,e=>e.length.toString())}})),l=e((function(e,t){function o(e){return"object"==typeof e}Object.defineProperty(t,"__esModule",{value:!0}),t.configure=void 0,t.configure=function(e,t){var n;if((null===(n=t.movable)||void 0===n?void 0:n.dests)&&(e.movable.dests=void 0),function e(t,n){for(const r in n)o(t[r])&&o(n[r])?e(t[r],n[r]):t[r]=n[r]}(e,t),t.fen&&(e.pieces=c.read(t.fen),e.drawable.shapes=[]),t.hasOwnProperty("check")&&a.setCheck(e,t.check||!1),t.hasOwnProperty("lastMove")&&!t.lastMove?e.lastMove=void 0:t.lastMove&&(e.lastMove=t.lastMove),e.selected&&a.setSelected(e,e.selected),(!e.animation.duration||e.animation.duration<100)&&(e.animation.enabled=!1),!e.movable.rookCastle&&e.movable.dests){const t="white"===e.movable.color?"1":"8",o="e"+t,n=e.movable.dests.get(o),r=e.pieces.get(o);if(!n||!r||"king"!==r.role)return;e.movable.dests.set(o,n.filter(e=>!(e==="a"+t&&n.includes("c"+t)||e==="h"+t&&n.includes("g"+t))))}}})),d=e((function(e,t){function o(e,t){e.exploding&&(t?e.exploding.stage=t:e.exploding=void 0,e.dom.redraw())}Object.defineProperty(t,"__esModule",{value:!0}),t.explosion=void 0,t.explosion=function(e,t){e.exploding={stage:1,keys:t},e.dom.redraw(),setTimeout(()=>{o(e,2),setTimeout(()=>o(e,void 0),120)},120)}})),u=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.start=void 0,t.start=function(e,t){function o(){a.toggleOrientation(e),t()}return{set(t){t.orientation&&t.orientation!==e.orientation&&o(),(t.fen?s.anim:s.render)(e=>l.configure(e,t),e)},state:e,getFen:()=>c.write(e.pieces),toggleOrientation:o,setPieces(t){s.anim(e=>a.setPieces(e,t),e)},selectSquare(t,o){t?s.anim(e=>a.selectSquare(e,t,o),e):e.selected&&(a.unselect(e),e.dom.redraw())},move(t,o){s.anim(e=>a.baseMove(e,t,o),e)},newPiece(t,o){s.anim(e=>a.baseNewPiece(e,t,o),e)},playPremove(){if(e.premovable.current){if(s.anim(a.playPremove,e))return!0;e.dom.redraw()}return!1},playPredrop(t){if(e.predroppable.current){const o=a.playPredrop(e,t);return e.dom.redraw(),o}return!1},cancelPremove(){s.render(a.unsetPremove,e)},cancelPredrop(){s.render(a.unsetPredrop,e)},cancelMove(){s.render(e=>{a.cancelMove(e),i.cancel(e)},e)},stop(){s.render(e=>{a.stop(e),i.cancel(e)},e)},explode(t){d.explosion(e,t)},setAutoShapes(t){s.render(e=>e.drawable.autoShapes=t,e)},setShapes(t){s.render(e=>e.drawable.shapes=t,e)},getKeyAtDomPos:t=>a.getKeyAtDomPos(t,a.whitePov(e),e.dom.bounds()),redrawAll:t,dragNewPiece(t,o,n){i.dragNewPiece(e,t,o,n)},destroy(){a.stop(e),e.dom.unbind&&e.dom.unbind(),e.dom.destroyed=!0}}}})),p=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.defaults=void 0,t.defaults=function(){return{pieces:c.read(c.initial),orientation:"white",turnColor:"white",coordinates:!0,autoCastle:!0,viewOnly:!1,disableContextMenu:!1,resizable:!0,addPieceZIndex:!1,pieceKey:!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}},pieces:{baseUrl:"https://lichess1.org/assets/piece/cburnett/"},prevSvgHash:""},hold:o.timer()}}})),f=e((function(e,t){function n(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function r({orig:e,dest:t,brush:o,piece:n,modifiers:r},i,a,c){return[c.width,c.height,a,e,t,o,t&&(i.get(t)||0)>1,n&&s(n),r&&(l=r,""+(l.lineWidth||""))].filter(e=>e).join(",");var l}function s(e){return[e.color,e.role,e.scale].filter(e=>e).join(",")}function i(e,{shape:t,current:r,hash:s},i,a,g){let v;if(t.piece)v=function(e,t,o,r){const s=f(t,r),i=r.width/8*(o.scale||1),a=o.color[0]+("knight"===o.role?"n":o.role[0]).toUpperCase();return c(n("image"),{className:`${o.role} ${o.color}`,x:s[0]-i/2,y:s[1]-i/2,width:i,height:i,href:e+a+".svg"})}(e.drawable.pieces.baseUrl,l(o.key2pos(t.orig),e.orientation),t.piece,g);else{const s=l(o.key2pos(t.orig),e.orientation);if(t.dest){let m=i[t.brush];t.modifiers&&(m=d(m,t.modifiers)),v=function(e,t,o,r,s,i){const a=function(e,t){return(t?20:10)/512*e.width}(i,s&&!r),l=f(t,i),d=f(o,i),g=d[0]-l[0],v=d[1]-l[1],m=Math.atan2(v,g),h=Math.cos(m)*a,b=Math.sin(m)*a;return c(n("line"),{stroke:e.color,"stroke-width":u(e,r,i),"stroke-linecap":"round","marker-end":"url(#arrowhead-"+e.key+")",opacity:p(e,r),x1:l[0],y1:l[1],x2:d[0]-h,y2:d[1]-b})}(m,s,l(o.key2pos(t.dest),e.orientation),r,(a.get(t.dest)||0)>1,g)}else v=function(e,t,o,r){const s=f(t,r),i=function(e){const t=e.width/512;return[3*t,4*t]}(r),a=(r.width+r.height)/32;return c(n("circle"),{stroke:e.color,"stroke-width":i[o?0:1],fill:"none",opacity:p(e,o),cx:s[0],cy:s[1],r:a-i[1]/2})}(i[t.brush],s,r,g)}return v.setAttribute("cgHash",s),v}function a(e){const t=c(n("marker"),{id:"arrowhead-"+e.key,orient:"auto",markerWidth:4,markerHeight:8,refX:2.05,refY:2.01});return t.appendChild(c(n("path"),{d:"M0,0 V4 L3,2 Z",fill:e.color})),t.setAttribute("cgKey",e.key),t}function c(e,t){for(const o in t)e.setAttribute(o,t[o]);return e}function l(e,t){return"white"===t?e:[7-e[0],7-e[1]]}function d(e,t){return{color:e.color,opacity:Math.round(10*e.opacity)/10,lineWidth:Math.round(t.lineWidth||e.lineWidth),key:[e.key,t.lineWidth].filter(e=>e).join("")}}function u(e,t,o){return(e.lineWidth||10)*(t?.85:1)/512*o.width}function p(e,t){return(e.opacity||1)*(t?.9:1)}function f(e,t){return[(e[0]+.5)*t.width/8,(7.5-e[1])*t.height/8]}Object.defineProperty(t,"__esModule",{value:!0}),t.renderSvg=t.createElement=void 0,t.createElement=n,t.renderSvg=function(e,t){const o=e.drawable,n=o.current,s=n&&n.mouseSq?n:void 0,c=new Map,l=e.dom.bounds();for(const r of o.shapes.concat(o.autoShapes).concat(s?[s]:[]))r.dest&&c.set(r.dest,(c.get(r.dest)||0)+1);const u=o.shapes.concat(o.autoShapes).map(e=>({shape:e,current:!1,hash:r(e,c,!1,l)}));s&&u.push({shape:s,current:!0,hash:r(s,c,!0,l)});const p=u.map(e=>e.hash).join(";");if(p===e.drawable.prevSvgHash)return;e.drawable.prevSvgHash=p;const f=t.firstChild;!function(e,t,o){const n=new Map;let r;for(const a of t)a.shape.dest&&(r=e.brushes[a.shape.brush],a.shape.modifiers&&(r=d(r,a.shape.modifiers)),n.set(r.key,r));const s=new Set;let i=o.firstChild;for(;i;)s.add(i.getAttribute("cgKey")),i=i.nextSibling;for(const[c,l]of n.entries())s.has(c)||o.appendChild(a(l))}(o,u,f),function(e,t,o,n,r,s){const a=e.dom.bounds(),c=new Map,l=[];for(const i of t)c.set(i.hash,!1);let d,u=s.nextSibling;for(;u;)d=u.getAttribute("cgHash"),c.has(d)?c.set(d,!0):l.push(u),u=u.nextSibling;for(const i of l)r.removeChild(i);for(const p of t)c.get(p.hash)||r.appendChild(i(e,p,o,n,a))}(e,u,o.brushes,c,t,f)}})),g=e((function(e,n){function r(e,t){const n=o.createEl("coords",t);let r;for(const s of e)r=o.createEl("coord"),r.textContent=s,n.appendChild(r);return n}Object.defineProperty(n,"__esModule",{value:!0}),n.renderWrap=void 0,n.renderWrap=function(e,n,s){e.innerHTML="",e.classList.add("cg-wrap");for(const o of t.colors)e.classList.toggle("orientation-"+o,n.orientation===o);e.classList.toggle("manipulable",!n.viewOnly);const i=o.createEl("cg-helper");e.appendChild(i);const a=o.createEl("cg-container");i.appendChild(a);const c=o.createEl("cg-board");let l,d;if(a.appendChild(c),n.drawable.visible&&!s&&(l=f.createElement("svg"),l.appendChild(f.createElement("defs")),a.appendChild(l)),n.coordinates){const e="black"===n.orientation?" black":"";a.appendChild(r(t.ranks,"ranks"+e)),a.appendChild(r(t.files,"files"+e))}return n.draggable.showGhost&&!s&&(d=o.createEl("piece","ghost"),o.setVisible(d,!1),a.appendChild(d)),{board:c,container:a,ghost:d,svg:l}}})),v=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.drop=t.cancelDropMode=t.setDropMode=void 0,t.setDropMode=function(e,t){e.dropmode={active:!0,piece:t},i.cancel(e)},t.cancelDropMode=function(e){e.dropmode={active:!1}},t.drop=function(e,t){if(!e.dropmode.active)return;a.unsetPremove(e),a.unsetPredrop(e);const n=e.dropmode.piece;if(n){e.pieces.set("a0",n);const r=o.eventPosition(t),s=r&&a.getKeyAtDomPos(r,a.whitePov(e),e.dom.bounds());s&&a.dropNewPiece(e,"a0",s)}e.dom.redraw()}})),m=e((function(e,t){function n(e,t,o,n){return e.addEventListener(t,o,n),()=>e.removeEventListener(t,o,n)}function s(e,t,o){return n=>{e.drawable.current?e.drawable.enabled&&o(e,n):e.viewOnly||t(e,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.bindDocument=t.bindBoard=void 0,t.bindBoard=function(e,t){const n=e.dom.elements.board;if(!e.dom.relative&&e.resizable&&"ResizeObserver"in window){new window.ResizeObserver(t).observe(n)}if(e.viewOnly)return;const s=function(e){return t=>{e.draggable.current?i.cancel(e):e.drawable.current?r.cancel(e):t.shiftKey||o.isRightButton(t)?e.drawable.enabled&&r.start(e,t):e.viewOnly||(e.dropmode.active?v.drop(e,t):i.start(e,t))}}(e);n.addEventListener("touchstart",s,{passive:!1}),n.addEventListener("mousedown",s,{passive:!1}),(e.disableContextMenu||e.drawable.enabled)&&n.addEventListener("contextmenu",e=>e.preventDefault())},t.bindDocument=function(e,t){const o=[];if(e.dom.relative||!e.resizable||"ResizeObserver"in window||o.push(n(document.body,"chessground.resize",t)),!e.viewOnly){const t=s(e,i.move,r.move),a=s(e,i.end,r.end);for(const e of["touchmove","mousemove"])o.push(n(document,e,t));for(const e of["touchend","mouseup"])o.push(n(document,e,a));const c=()=>e.dom.bounds.clear();o.push(n(document,"scroll",c,{capture:!0,passive:!0})),o.push(n(window,"resize",c,{passive:!0}))}return()=>o.forEach(e=>e())}})),h=e((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.updateBounds=t.render=void 0;const n=o;function r(e){return"PIECE"===e.tagName}function s(e){return"SQUARE"===e.tagName}function i(e,t){for(const o of t)e.dom.elements.board.removeChild(o)}function c(e,t){let o=2+8*e[1]+(7-e[0]);return t&&(o=67-o),o+""}function l(e){return`${e.color} ${e.role}`}function d(e,t,o){const n=e.get(t);n?e.set(t,`${n} ${o}`):e.set(t,o)}function u(e,t,o){const n=e.get(t);n?n.push(o):e.set(t,[o])}t.render=function(e){const t=a.whitePov(e),p=e.dom.relative?n.posToTranslateRel:n.posToTranslateAbs(e.dom.bounds()),f=e.dom.relative?n.translateRel:n.translateAbs,g=e.dom.elements.board,v=e.pieces,m=e.animation.current,h=m?m.plan.anims:new Map,b=m?m.plan.fadings:new Map,w=e.draggable.current,y=function(e){var t;const o=new Map;if(e.lastMove&&e.highlight.lastMove)for(const s of e.lastMove)d(o,s,"last-move");e.check&&e.highlight.check&&d(o,e.check,"check");if(e.selected&&(d(o,e.selected,"selected"),e.movable.showDests)){const n=null===(t=e.movable.dests)||void 0===t?void 0:t.get(e.selected);if(n)for(const t of n)d(o,t,"move-dest"+(e.pieces.has(t)?" oc":""));const r=e.premovable.dests;if(r)for(const t of r)d(o,t,"premove-dest"+(e.pieces.has(t)?" oc":""))}const n=e.premovable.current;if(n)for(const s of n)d(o,s,"current-premove");else e.predroppable.current&&d(o,e.predroppable.current.key,"current-premove");const r=e.exploding;if(r)for(const s of r.keys)d(o,s,"exploding"+r.stage);return o}(e),P=new Set,k=new Set,M=new Map,C=new Map;let S,A,K,D,O,q,x,_,T,N;for(A=g.firstChild;A;){if(S=A.cgKey,r(A))if(K=v.get(S),O=h.get(S),q=b.get(S),D=A.cgPiece,!A.cgDragging||w&&w.orig===S||(A.classList.remove("dragging"),f(A,p(o.key2pos(S),t)),A.cgDragging=!1),!q&&A.cgFading&&(A.cgFading=!1,A.classList.remove("fading")),K){if(O&&A.cgAnimating&&D===l(K)){const e=o.key2pos(S);e[0]+=O[2],e[1]+=O[3],A.classList.add("anim"),f(A,p(e,t))}else A.cgAnimating&&(A.cgAnimating=!1,A.classList.remove("anim"),f(A,p(o.key2pos(S),t)),e.addPieceZIndex&&(A.style.zIndex=c(o.key2pos(S),t)));D!==l(K)||q&&A.cgFading?q&&D===l(q)?(A.classList.add("fading"),A.cgFading=!0):u(M,D,A):P.add(S)}else u(M,D,A);else if(s(A)){const e=A.className;y.get(S)===e?k.add(S):u(C,e,A)}A=A.nextSibling}for(const[n,r]of y)if(!k.has(n)){T=C.get(r),N=T&&T.pop();const e=p(o.key2pos(n),t);if(N)N.cgKey=n,f(N,e);else{const t=o.createEl("square",r);t.cgKey=n,f(t,e),g.insertBefore(t,g.firstChild)}}for(const[n,r]of v)if(O=h.get(n),!P.has(n))if(x=M.get(l(r)),_=x&&x.pop(),_){_.cgKey=n,_.cgFading&&(_.classList.remove("fading"),_.cgFading=!1);const r=o.key2pos(n);e.addPieceZIndex&&(_.style.zIndex=c(r,t)),O&&(_.cgAnimating=!0,_.classList.add("anim"),r[0]+=O[2],r[1]+=O[3]),f(_,p(r,t))}else{const s=l(r),i=o.createEl("piece",s),a=o.key2pos(n);i.cgPiece=s,i.cgKey=n,O&&(i.cgAnimating=!0,a[0]+=O[2],a[1]+=O[3]),f(i,p(a,t)),e.addPieceZIndex&&(i.style.zIndex=c(a,t)),g.appendChild(i)}for(const o of M.values())i(e,o);for(const o of C.values())i(e,o)},t.updateBounds=function(e){if(e.dom.relative)return;const t=a.whitePov(e),i=n.posToTranslateAbs(e.dom.bounds());let c=e.dom.elements.board.firstChild;for(;c;)(r(c)&&!c.cgAnimating||s(c))&&n.translateAbs(c,i(o.key2pos(c.cgKey),t)),c=c.nextSibling}}));return e((function(e,t){function n(e){let t=!1;return()=>{t||(t=!0,requestAnimationFrame(()=>{e(),t=!1}))}}Object.defineProperty(t,"__esModule",{value:!0}),t.Chessground=void 0,t.Chessground=function(e,t){const r=p.defaults();function s(){const t="dom"in r?r.dom.unbind:void 0,s=r.viewOnly&&!r.drawable.visible,i=g.renderWrap(e,r,s),a=o.memo(()=>i.board.getBoundingClientRect()),c=e=>{h.render(d),!e&&i.svg&&f.renderSvg(d,i.svg)},l=()=>{a.clear(),h.updateBounds(d),i.svg&&f.renderSvg(d,i.svg)},d=r;return d.dom={elements:i,bounds:a,redraw:n(c),redrawNow:c,unbind:t,relative:s},d.drawable.prevSvgHash="",c(!1),m.bindBoard(d,l),t||(d.dom.unbind=m.bindDocument(d,l)),d.events.insert&&d.events.insert(i),d}return l.configure(r,t||{}),u.start(s(),s)}})).Chessground}();