next-chessground 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -32,4 +32,4 @@ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import A,{create
|
|
|
32
32
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
33
33
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
34
34
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
35
|
-
*/!function(e,t){function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n}(hn,Error),hn.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var n,A=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){A=e[n].text.split(/\r\n|\n|\r/g);break}var o=this.location.start,r=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(o):o,i=this.location.source+":"+r.line+":"+r.column;if(A){var s=this.location.end,a=pn("",r.line.toString().length," "),c=A[o.line-1],l=(o.line===s.line?s.column:c.length+1)-o.column||1;t+="\n --\x3e "+i+"\n"+a+" |\n"+r.line+" | "+c+"\n"+a+" | "+pn("",o.column-1," ")+pn("",l,"^")}else t+="\n at "+i}return t},hn.buildMessage=function(e,t){var n={literal:function(e){return'"'+o(e.text)+'"'},class:function(e){var t=e.parts.map(function(e){return Array.isArray(e)?r(e[0])+"-"+r(e[1]):r(e)});return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function A(e){return e.charCodeAt(0).toString(16).toUpperCase()}function o(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+A(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+A(e)})}function r(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+A(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+A(e)})}function i(e){return n[e.type](e)}return"Expected "+function(e){var t,n,A=e.map(i);if(A.sort(),A.length>0){for(t=1,n=1;t<A.length;t++)A[t-1]!==A[t]&&(A[n]=A[t],n++);A.length=n}switch(A.length){case 1:return A[0];case 2:return A[0]+" or "+A[1];default:return A.slice(0,-1).join(", ")+", or "+A[A.length-1]}}(e)+" but "+function(e){return e?'"'+o(e)+'"':"end of input"}(t)+" found."};const dn=0xffffffffffffffffn;function mn(e,t){return 0xffffffffffffffffn&(e<<t|e>>64n-t)}function fn(e,t){return e*t&dn}const bn=(yn=0xa187eb39cdcaed8f31c4b365b102e01en,function(){let e=BigInt(yn&dn),t=BigInt(yn>>64n&dn);const n=fn(mn(fn(e,5n),7n),9n);return t^=e,e=(mn(e,24n)^t^t<<16n)&dn,t=mn(t,37n),yn=t<<64n|e,n});var yn;const In=Array.from({length:2},()=>Array.from({length:6},()=>Array.from({length:128},()=>bn()))),kn=Array.from({length:8},()=>bn()),wn=Array.from({length:16},()=>bn()),Cn=bn(),vn="w",Sn="b",En="p",Vn="b",Nn="r",Mn="q",xn="k",Bn="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";class Dn{color;from;to;piece;captured;promotion;flags;san;lan;before;after;constructor(e,t){const{color:n,piece:A,from:o,to:r,flags:i,captured:s,promotion:a}=t,c=$n(o),l=$n(r);this.color=n,this.piece=A,this.from=c,this.to=l,this.san=e._moveToSan(t,e._moves({legal:!0})),this.lan=c+l,this.before=e.fen(),e._makeMove(t),this.after=e.fen(),e._undoMove(),this.flags="";for(const e in jn)jn[e]&i&&(this.flags+=Qn[e]);s&&(this.captured=s),a&&(this.promotion=a,this.lan+=a)}isCapture(){return this.flags.indexOf(Qn.CAPTURE)>-1}isPromotion(){return this.flags.indexOf(Qn.PROMOTION)>-1}isEnPassant(){return this.flags.indexOf(Qn.EP_CAPTURE)>-1}isKingsideCastle(){return this.flags.indexOf(Qn.KSIDE_CASTLE)>-1}isQueensideCastle(){return this.flags.indexOf(Qn.QSIDE_CASTLE)>-1}isBigPawn(){return this.flags.indexOf(Qn.BIG_PAWN)>-1}}const Tn=-1,Qn={NORMAL:"n",CAPTURE:"c",BIG_PAWN:"b",EP_CAPTURE:"e",PROMOTION:"p",KSIDE_CASTLE:"k",QSIDE_CASTLE:"q",NULL_MOVE:"-"},Zn=["a8","b8","c8","d8","e8","f8","g8","h8","a7","b7","c7","d7","e7","f7","g7","h7","a6","b6","c6","d6","e6","f6","g6","h6","a5","b5","c5","d5","e5","f5","g5","h5","a4","b4","c4","d4","e4","f4","g4","h4","a3","b3","c3","d3","e3","f3","g3","h3","a2","b2","c2","d2","e2","f2","g2","h2","a1","b1","c1","d1","e1","f1","g1","h1"],jn={NORMAL:1,CAPTURE:2,BIG_PAWN:4,EP_CAPTURE:8,PROMOTION:16,KSIDE_CASTLE:32,QSIDE_CASTLE:64,NULL_MOVE:128},Pn={Event:"?",Site:"?",Date:"????.??.??",Round:"?",White:"?",Black:"?",Result:"*"},Un={...Pn,WhiteTitle:null,BlackTitle:null,WhiteElo:null,BlackElo:null,WhiteUSCF:null,BlackUSCF:null,WhiteNA:null,BlackNA:null,WhiteType:null,BlackType:null,EventDate:null,EventSponsor:null,Section:null,Stage:null,Board:null,Opening:null,Variation:null,SubVariation:null,ECO:null,NIC:null,Time:null,UTCTime:null,UTCDate:null,TimeControl:null,SetUp:null,FEN:null,Termination:null,Annotator:null,Mode:null,PlyCount:null},On={a8:0,b8:1,c8:2,d8:3,e8:4,f8:5,g8:6,h8:7,a7:16,b7:17,c7:18,d7:19,e7:20,f7:21,g7:22,h7:23,a6:32,b6:33,c6:34,d6:35,e6:36,f6:37,g6:38,h6:39,a5:48,b5:49,c5:50,d5:51,e5:52,f5:53,g5:54,h5:55,a4:64,b4:65,c4:66,d4:67,e4:68,f4:69,g4:70,h4:71,a3:80,b3:81,c3:82,d3:83,e3:84,f3:85,g3:86,h3:87,a2:96,b2:97,c2:98,d2:99,e2:100,f2:101,g2:102,h2:103,a1:112,b1:113,c1:114,d1:115,e1:116,f1:117,g1:118,h1:119},qn={b:[16,32,17,15],w:[-16,-32,-17,-15]},Jn={n:[-18,-33,-31,-14,18,33,31,14],b:[-17,-15,17,15],r:[-16,1,16,-1],q:[-17,-16,-15,1,17,16,15,-1],k:[-17,-16,-15,1,17,16,15,-1]},Kn=[20,0,0,0,0,0,0,24,0,0,0,0,0,0,20,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,24,24,24,24,24,24,56,0,56,24,24,24,24,24,24,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,20,0,0,0,0,0,0,24,0,0,0,0,0,0,20],Gn=[17,0,0,0,0,0,0,16,0,0,0,0,0,0,15,0,0,17,0,0,0,0,0,16,0,0,0,0,0,15,0,0,0,0,17,0,0,0,0,16,0,0,0,0,15,0,0,0,0,0,0,17,0,0,0,16,0,0,0,15,0,0,0,0,0,0,0,0,17,0,0,16,0,0,15,0,0,0,0,0,0,0,0,0,0,17,0,16,0,15,0,0,0,0,0,0,0,0,0,0,0,0,17,16,15,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,-15,-16,-17,0,0,0,0,0,0,0,0,0,0,0,0,-15,0,-16,0,-17,0,0,0,0,0,0,0,0,0,0,-15,0,0,-16,0,0,-17,0,0,0,0,0,0,0,0,-15,0,0,0,-16,0,0,0,-17,0,0,0,0,0,0,-15,0,0,0,0,-16,0,0,0,0,-17,0,0,0,0,-15,0,0,0,0,0,-16,0,0,0,0,0,-17,0,0,-15,0,0,0,0,0,0,-16,0,0,0,0,0,0,-17],Rn={p:1,n:2,b:4,r:8,q:16,k:32},Fn=["n",Vn,Nn,Mn],Ln={[xn]:jn.KSIDE_CASTLE,[Mn]:jn.QSIDE_CASTLE},zn={w:[{square:On.a1,flag:jn.QSIDE_CASTLE},{square:On.h1,flag:jn.KSIDE_CASTLE}],b:[{square:On.a8,flag:jn.QSIDE_CASTLE},{square:On.h8,flag:jn.KSIDE_CASTLE}]},Wn={b:1,w:6},Yn="--";function _n(e){return e>>4}function Hn(e){return 15&e}function Xn(e){return-1!=="0123456789".indexOf(e)}function $n(e){const t=Hn(e),n=_n(e);return"abcdefgh".substring(t,t+1)+"87654321".substring(n,n+1)}function eA(e){return e===vn?Sn:vn}function tA(e){const t=e.split(/\s+/);if(6!==t.length)return{ok:!1,error:"Invalid FEN: must contain six space-delimited fields"};const n=parseInt(t[5],10);if(isNaN(n)||n<=0)return{ok:!1,error:"Invalid FEN: move number must be a positive integer"};const A=parseInt(t[4],10);if(isNaN(A)||A<0)return{ok:!1,error:"Invalid FEN: half move counter number must be a non-negative integer"};if(!/^(-|[abcdefgh][36])$/.test(t[3]))return{ok:!1,error:"Invalid FEN: en-passant square is invalid"};if(/[^kKqQ-]/.test(t[2]))return{ok:!1,error:"Invalid FEN: castling availability is invalid"};if(!/^(w|b)$/.test(t[1]))return{ok:!1,error:"Invalid FEN: side-to-move is invalid"};const o=t[0].split("/");if(8!==o.length)return{ok:!1,error:"Invalid FEN: piece data does not contain 8 '/'-delimited rows"};for(let e=0;e<o.length;e++){let t=0,n=!1;for(let A=0;A<o[e].length;A++)if(Xn(o[e][A])){if(n)return{ok:!1,error:"Invalid FEN: piece data is invalid (consecutive number)"};t+=parseInt(o[e][A],10),n=!0}else{if(!/^[prnbqkPRNBQK]$/.test(o[e][A]))return{ok:!1,error:"Invalid FEN: piece data is invalid (invalid piece)"};t+=1,n=!1}if(8!==t)return{ok:!1,error:"Invalid FEN: piece data is invalid (too many squares in rank)"}}if("3"==t[3][1]&&"w"==t[1]||"6"==t[3][1]&&"b"==t[1])return{ok:!1,error:"Invalid FEN: illegal en-passant square"};const r=[{color:"white",regex:/K/g},{color:"black",regex:/k/g}];for(const{color:e,regex:n}of r){if(!n.test(t[0]))return{ok:!1,error:`Invalid FEN: missing ${e} king`};if((t[0].match(n)||[]).length>1)return{ok:!1,error:`Invalid FEN: too many ${e} kings`}}return Array.from(o[0]+o[7]).some(e=>"P"===e.toUpperCase())?{ok:!1,error:"Invalid FEN: some pawns are on the edge rows"}:{ok:!0}}function nA(e,t,n,A,o,r=void 0,i=jn.NORMAL){const s=_n(A);if(o!==En||7!==s&&0!==s)e.push({color:t,from:n,to:A,piece:o,captured:r,flags:i});else for(let s=0;s<Fn.length;s++){const a=Fn[s];e.push({color:t,from:n,to:A,piece:o,captured:r,promotion:a,flags:i|jn.PROMOTION})}}function AA(e){let t=e.charAt(0);if(t>="a"&&t<="h"){if(e.match(/[a-h]\d.*[a-h]\d/))return;return En}return t=t.toLowerCase(),"o"===t?xn:t}function oA(e){return e.replace(/=/,"").replace(/[+#]?[?!]*$/,"")}class rA{_board=new Array(128);_turn=vn;_header={};_kings={w:Tn,b:Tn};_epSquare=-1;_halfMoves=0;_moveNumber=0;_history=[];_comments={};_castling={w:0,b:0};_hash=0n;_positionCount=new Map;constructor(e=Bn,{skipValidation:t=!1}={}){this.load(e,{skipValidation:t})}clear({preserveHeaders:e=!1}={}){this._board=new Array(128),this._kings={w:Tn,b:Tn},this._turn=vn,this._castling={w:0,b:0},this._epSquare=Tn,this._halfMoves=0,this._moveNumber=1,this._history=[],this._comments={},this._header=e?this._header:{...Un},this._hash=this._computeHash(),this._positionCount=new Map,this._header.SetUp=null,this._header.FEN=null}load(e,{skipValidation:t=!1,preserveHeaders:n=!1}={}){let A=e.split(/\s+/);if(A.length>=2&&A.length<6){const t=["-","-","0","1"];e=A.concat(t.slice(-(6-A.length))).join(" ")}if(A=e.split(/\s+/),!t){const{ok:t,error:n}=tA(e);if(!t)throw new Error(n)}const o=A[0];let r=0;this.clear({preserveHeaders:n});for(let e=0;e<o.length;e++){const t=o.charAt(e);if("/"===t)r+=8;else if(Xn(t))r+=parseInt(t,10);else{const e=t<"a"?vn:Sn;this._put({type:t.toLowerCase(),color:e},$n(r)),r++}}this._turn=A[1],A[2].indexOf("K")>-1&&(this._castling.w|=jn.KSIDE_CASTLE),A[2].indexOf("Q")>-1&&(this._castling.w|=jn.QSIDE_CASTLE),A[2].indexOf("k")>-1&&(this._castling.b|=jn.KSIDE_CASTLE),A[2].indexOf("q")>-1&&(this._castling.b|=jn.QSIDE_CASTLE),this._epSquare="-"===A[3]?Tn:On[A[3]],this._halfMoves=parseInt(A[4],10),this._moveNumber=parseInt(A[5],10),this._hash=this._computeHash(),this._updateSetup(e),this._incPositionCount()}fen({forceEnpassantSquare:e=!1}={}){let t=0,n="";for(let e=On.a8;e<=On.h1;e++){if(this._board[e]){t>0&&(n+=t,t=0);const{color:A,type:o}=this._board[e];n+=A===vn?o.toUpperCase():o.toLowerCase()}else t++;e+1&136&&(t>0&&(n+=t),e!==On.h1&&(n+="/"),t=0,e+=8)}let A="";this._castling[vn]&jn.KSIDE_CASTLE&&(A+="K"),this._castling[vn]&jn.QSIDE_CASTLE&&(A+="Q"),this._castling[Sn]&jn.KSIDE_CASTLE&&(A+="k"),this._castling[Sn]&jn.QSIDE_CASTLE&&(A+="q"),A=A||"-";let o="-";if(this._epSquare!==Tn)if(e)o=$n(this._epSquare);else{const e=this._epSquare+(this._turn===vn?16:-16),t=[e+1,e-1];for(const e of t){if(136&e)continue;const t=this._turn;if(this._board[e]?.color===t&&this._board[e]?.type===En){this._makeMove({color:t,from:e,to:this._epSquare,piece:En,captured:En,flags:jn.EP_CAPTURE});const n=!this._isKingAttacked(t);if(this._undoMove(),n){o=$n(this._epSquare);break}}}}return[n,this._turn,A,o,this._halfMoves,this._moveNumber].join(" ")}_pieceKey(e){if(!this._board[e])return 0n;const{color:t,type:n}=this._board[e],A={p:0,n:1,b:2,r:3,q:4,k:5}[n];return In[{w:0,b:1}[t]][A][e]}_epKey(){return this._epSquare===Tn?0n:kn[7&this._epSquare]}_castlingKey(){const e=this._castling.w>>5|this._castling.b>>3;return wn[e]}_computeHash(){let e=0n;for(let t=On.a8;t<=On.h1;t++)136&t?t+=7:this._board[t]&&(e^=this._pieceKey(t));return e^=this._epKey(),e^=this._castlingKey(),"b"===this._turn&&(e^=Cn),e}_updateSetup(e){this._history.length>0||(e!==Bn?(this._header.SetUp="1",this._header.FEN=e):(this._header.SetUp=null,this._header.FEN=null))}reset(){this.load(Bn)}get(e){return this._board[On[e]]}findPiece(e){const t=[];for(let n=On.a8;n<=On.h1;n++)136&n?n+=7:this._board[n]&&this._board[n]?.color===e.color&&this._board[n].color===e.color&&this._board[n].type===e.type&&t.push($n(n));return t}put({type:e,color:t},n){return!!this._put({type:e,color:t},n)&&(this._updateCastlingRights(),this._updateEnPassantSquare(),this._updateSetup(this.fen()),!0)}_set(e,t){this._hash^=this._pieceKey(e),this._board[e]=t,this._hash^=this._pieceKey(e)}_put({type:e,color:t},n){if(-1==="pnbrqkPNBRQK".indexOf(e.toLowerCase()))return!1;if(!(n in On))return!1;const A=On[n];if(e==xn&&this._kings[t]!=Tn&&this._kings[t]!=A)return!1;const o=this._board[A];return o&&o.type===xn&&(this._kings[o.color]=Tn),this._set(A,{type:e,color:t}),e===xn&&(this._kings[t]=A),!0}_clear(e){this._hash^=this._pieceKey(e),delete this._board[e]}remove(e){const t=this.get(e);return this._clear(On[e]),t&&t.type===xn&&(this._kings[t.color]=Tn),this._updateCastlingRights(),this._updateEnPassantSquare(),this._updateSetup(this.fen()),t}_updateCastlingRights(){this._hash^=this._castlingKey();const e=this._board[On.e1]?.type===xn&&this._board[On.e1]?.color===vn,t=this._board[On.e8]?.type===xn&&this._board[On.e8]?.color===Sn;e&&this._board[On.a1]?.type===Nn&&this._board[On.a1]?.color===vn||(this._castling.w&=-65),e&&this._board[On.h1]?.type===Nn&&this._board[On.h1]?.color===vn||(this._castling.w&=-33),t&&this._board[On.a8]?.type===Nn&&this._board[On.a8]?.color===Sn||(this._castling.b&=-65),t&&this._board[On.h8]?.type===Nn&&this._board[On.h8]?.color===Sn||(this._castling.b&=-33),this._hash^=this._castlingKey()}_updateEnPassantSquare(){if(this._epSquare===Tn)return;const e=this._epSquare+(this._turn===vn?-16:16),t=this._epSquare+(this._turn===vn?16:-16),n=[t+1,t-1];if(null!==this._board[e]||null!==this._board[this._epSquare]||this._board[t]?.color!==eA(this._turn)||this._board[t]?.type!==En)return this._hash^=this._epKey(),void(this._epSquare=Tn);n.some(e=>!(136&e)&&this._board[e]?.color===this._turn&&this._board[e]?.type===En)||(this._hash^=this._epKey(),this._epSquare=Tn)}_attacked(e,t,n){const A=[];for(let o=On.a8;o<=On.h1;o++){if(136&o){o+=7;continue}if(void 0===this._board[o]||this._board[o].color!==e)continue;const r=this._board[o],i=o-t;if(0===i)continue;const s=i+119;if(Kn[s]&Rn[r.type]){if(r.type===En){if(i>0&&r.color===vn||i<=0&&r.color===Sn){if(!n)return!0;A.push($n(o))}continue}if("n"===r.type||"k"===r.type){if(n){A.push($n(o));continue}return!0}const e=Gn[s];let a=o+e,c=!1;for(;a!==t;){if(null!=this._board[a]){c=!0;break}a+=e}if(!c){if(n){A.push($n(o));continue}return!0}}}return!!n&&A}attackers(e,t){return t?this._attacked(t,On[e],!0):this._attacked(this._turn,On[e],!0)}_isKingAttacked(e){const t=this._kings[e];return-1!==t&&this._attacked(eA(e),t)}hash(){return this._hash.toString(16)}isAttacked(e,t){return this._attacked(t,On[e])}isCheck(){return this._isKingAttacked(this._turn)}inCheck(){return this.isCheck()}isCheckmate(){return this.isCheck()&&0===this._moves().length}isStalemate(){return!this.isCheck()&&0===this._moves().length}isInsufficientMaterial(){const e={b:0,n:0,r:0,q:0,k:0,p:0},t=[];let n=0,A=0;for(let o=On.a8;o<=On.h1;o++){if(A=(A+1)%2,136&o){o+=7;continue}const r=this._board[o];r&&(e[r.type]=r.type in e?e[r.type]+1:1,r.type===Vn&&t.push(A),n++)}if(2===n)return!0;if(3===n&&(1===e[Vn]||1===e.n))return!0;if(n===e[Vn]+2){let e=0;const n=t.length;for(let A=0;A<n;A++)e+=t[A];if(0===e||e===n)return!0}return!1}isThreefoldRepetition(){return this._getPositionCount(this._hash)>=3}isDrawByFiftyMoves(){return this._halfMoves>=100}isDraw(){return this.isDrawByFiftyMoves()||this.isStalemate()||this.isInsufficientMaterial()||this.isThreefoldRepetition()}isGameOver(){return this.isCheckmate()||this.isDraw()}moves({verbose:e=!1,square:t,piece:n}={}){const A=this._moves({square:t,piece:n});return e?A.map(e=>new Dn(this,e)):A.map(e=>this._moveToSan(e,A))}_moves({legal:e=!0,piece:t,square:n}={}){const A=n?n.toLowerCase():void 0,o=t?.toLowerCase(),r=[],i=this._turn,s=eA(i);let a=On.a8,c=On.h1,l=!1;if(A){if(!(A in On))return[];a=c=On[A],l=!0}for(let e=a;e<=c;e++){if(136&e){e+=7;continue}if(!this._board[e]||this._board[e].color===s)continue;const{type:t}=this._board[e];let n;if(t===En){if(o&&o!==t)continue;n=e+qn[i][0],this._board[n]||(nA(r,i,e,n,En),n=e+qn[i][1],Wn[i]!==_n(e)||this._board[n]||nA(r,i,e,n,En,void 0,jn.BIG_PAWN));for(let t=2;t<4;t++)n=e+qn[i][t],136&n||(this._board[n]?.color===s?nA(r,i,e,n,En,this._board[n].type,jn.CAPTURE):n===this._epSquare&&nA(r,i,e,n,En,En,jn.EP_CAPTURE))}else{if(o&&o!==t)continue;for(let A=0,o=Jn[t].length;A<o;A++){const o=Jn[t][A];for(n=e;n+=o,!(136&n);){if(this._board[n]){if(this._board[n].color===i)break;nA(r,i,e,n,t,this._board[n].type,jn.CAPTURE);break}if(nA(r,i,e,n,t),"n"===t||t===xn)break}}}}if(!(void 0!==o&&o!==xn||l&&c!==this._kings[i])){if(this._castling[i]&jn.KSIDE_CASTLE){const e=this._kings[i],t=e+2;this._board[e+1]||this._board[t]||this._attacked(s,this._kings[i])||this._attacked(s,e+1)||this._attacked(s,t)||nA(r,i,this._kings[i],t,xn,void 0,jn.KSIDE_CASTLE)}if(this._castling[i]&jn.QSIDE_CASTLE){const e=this._kings[i],t=e-2;this._board[e-1]||this._board[e-2]||this._board[e-3]||this._attacked(s,this._kings[i])||this._attacked(s,e-1)||this._attacked(s,t)||nA(r,i,this._kings[i],t,xn,void 0,jn.QSIDE_CASTLE)}}if(!e||-1===this._kings[i])return r;const u=[];for(let e=0,t=r.length;e<t;e++)this._makeMove(r[e]),this._isKingAttacked(i)||u.push(r[e]),this._undoMove();return u}move(e,{strict:t=!1}={}){let n=null;if("string"==typeof e)n=this._moveFromSan(e,t);else if(null===e)n=this._moveFromSan(Yn,t);else if("object"==typeof e){const t=this._moves();for(let A=0,o=t.length;A<o;A++)if(e.from===$n(t[A].from)&&e.to===$n(t[A].to)&&(!("promotion"in t[A])||e.promotion===t[A].promotion)){n=t[A];break}}if(!n)throw"string"==typeof e?new Error(`Invalid move: ${e}`):new Error(`Invalid move: ${JSON.stringify(e)}`);if(this.isCheck()&&n.flags&jn.NULL_MOVE)throw new Error("Null move not allowed when in check");const A=new Dn(this,n);return this._makeMove(n),this._incPositionCount(),A}_push(e){this._history.push({move:e,kings:{b:this._kings.b,w:this._kings.w},turn:this._turn,castling:{b:this._castling.b,w:this._castling.w},epSquare:this._epSquare,halfMoves:this._halfMoves,moveNumber:this._moveNumber})}_movePiece(e,t){this._hash^=this._pieceKey(e),this._board[t]=this._board[e],delete this._board[e],this._hash^=this._pieceKey(t)}_makeMove(e){const t=this._turn,n=eA(t);if(this._push(e),e.flags&jn.NULL_MOVE)return t===Sn&&this._moveNumber++,this._halfMoves++,this._turn=n,void(this._epSquare=Tn);if(this._hash^=this._epKey(),this._hash^=this._castlingKey(),e.captured&&(this._hash^=this._pieceKey(e.to)),this._movePiece(e.from,e.to),e.flags&jn.EP_CAPTURE&&(this._turn===Sn?this._clear(e.to-16):this._clear(e.to+16)),e.promotion&&(this._clear(e.to),this._set(e.to,{type:e.promotion,color:t})),this._board[e.to].type===xn){if(this._kings[t]=e.to,e.flags&jn.KSIDE_CASTLE){const t=e.to-1,n=e.to+1;this._movePiece(n,t)}else if(e.flags&jn.QSIDE_CASTLE){const t=e.to+1,n=e.to-2;this._movePiece(n,t)}this._castling[t]=0}if(this._castling[t])for(let n=0,A=zn[t].length;n<A;n++)if(e.from===zn[t][n].square&&this._castling[t]&zn[t][n].flag){this._castling[t]^=zn[t][n].flag;break}if(this._castling[n])for(let t=0,A=zn[n].length;t<A;t++)if(e.to===zn[n][t].square&&this._castling[n]&zn[n][t].flag){this._castling[n]^=zn[n][t].flag;break}if(this._hash^=this._castlingKey(),e.flags&jn.BIG_PAWN){let A;A=t===Sn?e.to-16:e.to+16,(e.to-1&136||this._board[e.to-1]?.type!==En||this._board[e.to-1]?.color!==n)&&(e.to+1&136||this._board[e.to+1]?.type!==En||this._board[e.to+1]?.color!==n)?this._epSquare=Tn:(this._epSquare=A,this._hash^=this._epKey())}else this._epSquare=Tn;e.piece===En||e.flags&(jn.CAPTURE|jn.EP_CAPTURE)?this._halfMoves=0:this._halfMoves++,t===Sn&&this._moveNumber++,this._turn=n,this._hash^=Cn}undo(){const e=this._hash,t=this._undoMove();if(t){const n=new Dn(this,t);return this._decPositionCount(e),n}return null}_undoMove(){const e=this._history.pop();if(void 0===e)return null;this._hash^=this._epKey(),this._hash^=this._castlingKey();const t=e.move;this._kings=e.kings,this._turn=e.turn,this._castling=e.castling,this._epSquare=e.epSquare,this._halfMoves=e.halfMoves,this._moveNumber=e.moveNumber,this._hash^=this._epKey(),this._hash^=this._castlingKey(),this._hash^=Cn;const n=this._turn,A=eA(n);if(t.flags&jn.NULL_MOVE)return t;if(this._movePiece(t.to,t.from),t.piece&&(this._clear(t.from),this._set(t.from,{type:t.piece,color:n})),t.captured)if(t.flags&jn.EP_CAPTURE){let e;e=n===Sn?t.to-16:t.to+16,this._set(e,{type:En,color:A})}else this._set(t.to,{type:t.captured,color:A});if(t.flags&(jn.KSIDE_CASTLE|jn.QSIDE_CASTLE)){let e,n;t.flags&jn.KSIDE_CASTLE?(e=t.to+1,n=t.to-1):(e=t.to-2,n=t.to+1),this._movePiece(n,e)}return t}pgn({newline:e="\n",maxWidth:t=0}={}){const n=[];let A=!1;for(const t in this._header){this._header[t]&&n.push(`[${t} "${this._header[t]}"]`+e),A=!0}A&&this._history.length&&n.push(e);const o=e=>{const t=this._comments[this.fen()];if(void 0!==t){e=`${e}${e.length>0?" ":""}{${t}}`}return e},r=[];for(;this._history.length>0;)r.push(this._undoMove());const i=[];let s="";for(0===r.length&&i.push(o(""));r.length>0;){s=o(s);const e=r.pop();if(!e)break;if(this._history.length||"b"!==e.color)"w"===e.color&&(s.length&&i.push(s),s=this._moveNumber+".");else{const e=`${this._moveNumber}. ...`;s=s?`${s} ${e}`:e}s=s+" "+this._moveToSan(e,this._moves({legal:!0})),this._makeMove(e)}if(s.length&&i.push(o(s)),i.push(this._header.Result||"*"),0===t)return n.join("")+i.join(" ");const a=function(){return n.length>0&&" "===n[n.length-1]&&(n.pop(),!0)},c=function(A,o){for(const r of o.split(" "))if(r){if(A+r.length>t){for(;a();)A--;n.push(e),A=0}n.push(r),A+=r.length,n.push(" "),A++}return a()&&A--,A};let l=0;for(let A=0;A<i.length;A++)l+i[A].length>t&&i[A].includes("{")?l=c(l,i[A]):(l+i[A].length>t&&0!==A?(" "===n[n.length-1]&&n.pop(),n.push(e),l=0):0!==A&&(n.push(" "),l++),n.push(i[A]),l+=i[A].length);return n.join("")}header(...e){for(let t=0;t<e.length;t+=2)"string"==typeof e[t]&&"string"==typeof e[t+1]&&(this._header[e[t]]=e[t+1]);return this._header}setHeader(e,t){return this._header[e]=t??Pn[e]??null,this.getHeaders()}removeHeader(e){return e in this._header&&(this._header[e]=Pn[e]||null,!0)}getHeaders(){const e={};for(const[t,n]of Object.entries(this._header))null!==n&&(e[t]=n);return e}loadPgn(e,{strict:t=!1,newlineChar:n="\r?\n"}={}){"\r?\n"!==n&&(e=e.replace(new RegExp(n,"g"),"\n"));const A=gn(e);this.reset();const o=A.headers;let r="";for(const e in o)"fen"===e.toLowerCase()&&(r=o[e]),this.header(e,o[e]);if(t){if("1"===o.SetUp){if(!("FEN"in o))throw new Error("Invalid PGN: FEN tag must be supplied with SetUp tag");this.load(o.FEN,{preserveHeaders:!0})}}else r&&this.load(r,{preserveHeaders:!0});let i=A.root;for(;i;){if(i.move){const e=this._moveFromSan(i.move,t);if(null==e)throw new Error(`Invalid move in PGN: ${i.move}`);this._makeMove(e),this._incPositionCount()}void 0!==i.comment&&(this._comments[this.fen()]=i.comment),i=i.variations[0]}const s=A.result;s&&Object.keys(this._header).length&&this._header.Result!==s&&this.setHeader("Result",s)}_moveToSan(e,t){let n="";if(e.flags&jn.KSIDE_CASTLE)n="O-O";else if(e.flags&jn.QSIDE_CASTLE)n="O-O-O";else{if(e.flags&jn.NULL_MOVE)return Yn;if(e.piece!==En){const A=function(e,t){const n=e.from,A=e.to,o=e.piece;let r=0,i=0,s=0;for(let e=0,a=t.length;e<a;e++){const a=t[e].from,c=t[e].to;o===t[e].piece&&n!==a&&A===c&&(r++,_n(n)===_n(a)&&i++,Hn(n)===Hn(a)&&s++)}return r>0?i>0&&s>0?$n(n):s>0?$n(n).charAt(1):$n(n).charAt(0):""}(e,t);n+=e.piece.toUpperCase()+A}e.flags&(jn.CAPTURE|jn.EP_CAPTURE)&&(e.piece===En&&(n+=$n(e.from)[0]),n+="x"),n+=$n(e.to),e.promotion&&(n+="="+e.promotion.toUpperCase())}return this._makeMove(e),this.isCheck()&&(this.isCheckmate()?n+="#":n+="+"),this._undoMove(),n}_moveFromSan(e,t=!1){let n=oA(e);if(t||("0-0"===n?n="O-O":"0-0-0"===n&&(n="O-O-O")),n==Yn){return{color:this._turn,from:0,to:0,piece:"k",flags:jn.NULL_MOVE}}let A,o,r,i,s,a=AA(n),c=this._moves({legal:!0,piece:a});for(let e=0,t=c.length;e<t;e++)if(n===oA(this._moveToSan(c[e],c)))return c[e];if(t)return null;let l=!1;if(o=n.match(/([pnbrqkPNBRQK])?([a-h][1-8])x?-?([a-h][1-8])([qrbnQRBN])?/),o?(A=o[1],r=o[2],i=o[3],s=o[4],1==r.length&&(l=!0)):(o=n.match(/([pnbrqkPNBRQK])?([a-h]?[1-8]?)x?-?([a-h][1-8])([qrbnQRBN])?/),o&&(A=o[1],r=o[2],i=o[3],s=o[4],1==r.length&&(l=!0))),a=AA(n),c=this._moves({legal:!0,piece:A||a}),!i)return null;for(let e=0,t=c.length;e<t;e++)if(r){if(!(A&&A.toLowerCase()!=c[e].piece||On[r]!=c[e].from||On[i]!=c[e].to||s&&s.toLowerCase()!=c[e].promotion))return c[e];if(l){const t=$n(c[e].from);if(!(A&&A.toLowerCase()!=c[e].piece||On[i]!=c[e].to||r!=t[0]&&r!=t[1]||s&&s.toLowerCase()!=c[e].promotion))return c[e]}}else if(n===oA(this._moveToSan(c[e],c)).replace("x",""))return c[e];return null}ascii(){let e=" +------------------------+\n";for(let t=On.a8;t<=On.h1;t++){if(0===Hn(t)&&(e+=" "+"87654321"[_n(t)]+" |"),this._board[t]){const n=this._board[t].type;e+=" "+(this._board[t].color===vn?n.toUpperCase():n.toLowerCase())+" "}else e+=" . ";t+1&136&&(e+="|\n",t+=8)}return e+=" +------------------------+\n",e+=" a b c d e f g h",e}perft(e){const t=this._moves({legal:!1});let n=0;const A=this._turn;for(let o=0,r=t.length;o<r;o++)this._makeMove(t[o]),this._isKingAttacked(A)||(e-1>0?n+=this.perft(e-1):n++),this._undoMove();return n}setTurn(e){return this._turn!=e&&(this.move("--"),!0)}turn(){return this._turn}board(){const e=[];let t=[];for(let n=On.a8;n<=On.h1;n++)null==this._board[n]?t.push(null):t.push({square:$n(n),type:this._board[n].type,color:this._board[n].color}),n+1&136&&(e.push(t),t=[],n+=8);return e}squareColor(e){if(e in On){const t=On[e];return(_n(t)+Hn(t))%2==0?"light":"dark"}return null}history({verbose:e=!1}={}){const t=[],n=[];for(;this._history.length>0;)t.push(this._undoMove());for(;;){const A=t.pop();if(!A)break;e?n.push(new Dn(this,A)):n.push(this._moveToSan(A,this._moves())),this._makeMove(A)}return n}_getPositionCount(e){return this._positionCount.get(e)??0}_incPositionCount(){this._positionCount.set(this._hash,(this._positionCount.get(this._hash)??0)+1)}_decPositionCount(e){const t=this._positionCount.get(e)??0;1===t?this._positionCount.delete(e):this._positionCount.set(e,t-1)}_pruneComments(){const e=[],t={},n=e=>{e in this._comments&&(t[e]=this._comments[e])};for(;this._history.length>0;)e.push(this._undoMove());for(n(this.fen());;){const t=e.pop();if(!t)break;this._makeMove(t),n(this.fen())}this._comments=t}getComment(){return this._comments[this.fen()]}setComment(e){this._comments[this.fen()]=e.replace("{","[").replace("}","]")}deleteComment(){return this.removeComment()}removeComment(){const e=this._comments[this.fen()];return delete this._comments[this.fen()],e}getComments(){return this._pruneComments(),Object.keys(this._comments).map(e=>({fen:e,comment:this._comments[e]}))}deleteComments(){return this.removeComments()}removeComments(){return this._pruneComments(),Object.keys(this._comments).map(e=>{const t=this._comments[e];return delete this._comments[e],{fen:e,comment:t}})}setCastlingRights(e,t){for(const n of[xn,Mn])void 0!==t[n]&&(t[n]?this._castling[e]|=Ln[n]:this._castling[e]&=~Ln[n]);this._updateCastlingRights();const n=this.getCastlingRights(e);return!(void 0!==t[xn]&&t[xn]!==n[xn]||void 0!==t[Mn]&&t[Mn]!==n[Mn])}getCastlingRights(e){return{[xn]:0!==(this._castling[e]&Ln[xn]),[Mn]:0!==(this._castling[e]&Ln[Mn])}}moveNumber(){return this._moveNumber}}const iA={initial:"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",empty:"8/8/8/8/8/8/8/8 w - - 0 1"},sA=iA.initial,aA={fen:iA,initialFen:sA,emptyFen:iA.empty},cA=e=>{const[t,n]=r(e.fen||sA),[A,o]=r(new rA(t));s(()=>{e.fen&&(n(e.fen),o(new rA(e.fen)),a([]))},[e.fen,e.reset]);const[i,a]=r([]),c=e.lastMove&&e.lastMove.promotion,l="w"===A.turn()?"white":"black",[u]=r(e.orientation||l),h=(e,t,o)=>{a([e,t]);try{const r=A.move({from:e,to:t,promotion:o});return n(A.fen()),r}catch{return!1}};return{chess:A,fen:t,turnColor:l,lastMove:i,orientation:u,promotion:c,onMove:h,onPromote:e=>h(i[0],i[1],e),onUndo:()=>{const e=A.undo();return e?(n(A.fen()),a([]),e):null}}};var lA=f(function(e,t){e.exports=((e,t)=>(()=>{var n={494:()=>{},156:t=>{t.exports=e},111:e=>{e.exports=t}},A={};function o(e){var t=A[e];if(void 0!==t)return t.exports;var r=A[e]={exports:{}};return n[e](r,r.exports,o),r.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{default:()=>a});var e=o(156),t=o.n(e),n=o(111);function A(e){const{children:n,replace:A,bodyClass:o,header:r,footer:i,onDragStart:s,onDragEnd:a,onClose:c,closeButton:l,closeButtonPosition:u}=e;return A?n:t().createElement("div",{className:"panel panel-default "+("bottom"===u?"additional-row":"")},t().createElement("div",{className:"panel-heading",onTouchStart:s,onMouseDown:s,onTouchEnd:a,onMouseUp:a},r&&t().createElement("h3",{className:"panel-title"},r)),t().createElement("div",{className:o},n),i&&t().createElement("div",{className:"panel-footer"},i),t().createElement("div",{className:"close",onClick:c,style:{position:"header"===u?"absolute":"static",margin:"bottom"===u?"10px auto":""}},l))}A.defaultProps={closeButton:"×",closeButtonPosition:"header",replace:!1,draggable:!1};const i=A;function s(A){let o=Math.random().toString();const[r,s]=(0,e.useState)(!1),[a,c]=(0,e.useState)(null),[l,u]=(0,e.useState)(null),[h,p]=(0,e.useState)(0),[g,d]=(0,e.useState)(0),[m,f]=(0,e.useState)(0),[b,y]=(0,e.useState)(0),{isOpen:I,onClose:k}=A,w=(0,e.useCallback)(()=>{document.body.classList.remove("body-modal-fix")},[]);(0,e.useEffect)(()=>(I&&(document.addEventListener("keydown",C),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),document.body.classList.add("body-modal-fix")),()=>{document.querySelector(".pure-modal")||(document.removeEventListener("keydown",C),w(),c(null),u(null),p(0),d(0),f(0),y(0))}),[I]);const C=(0,e.useCallback)(e=>{const t=document.querySelectorAll(".pure-modal"),n=t.length>1,A=t[t.length-1];return!(n&&!A.className.includes(o)||"Escape"!==e.key||!document.activeElement||(v(e),0))},[v,o]);if(!I)return null;function v(e){e&&(e.stopPropagation(),e.preventDefault()),null==k||k({isPassive:Boolean(e)})}function S(e){return e instanceof TouchEvent&&e.changedTouches.length>0?{pageX:e.changedTouches[0].pageX,pageY:e.changedTouches[0].pageY}:e instanceof MouseEvent?{pageX:e.pageX,pageY:e.pageY}:{pageX:0,pageY:0}}function E(e){if(e instanceof TouchEvent&&e.changedTouches&&e.changedTouches.length>1)return V();e.preventDefault();const{pageX:t,pageY:n}=S(e);"number"==typeof a&&"number"==typeof l&&(p(t-a-m),d(n-l-b))}function V(){return s(!1)}const{children:N,replace:M=!1,className:x,header:B,footer:D,scrollable:T=!0,draggable:Q=!1,width:Z,closeButton:j,closeButtonPosition:P,portal:U=!1}=A;let O=["pure-modal-backdrop"],q=["pure-modal",o],J=["panel-body"];x&&(q=q.concat(x)),T?J=J.concat("scrollable"):(O=O.concat("scrollable"),q=q.concat("auto-height")),Q&&(O=O.concat("backdrop-overflow-hidden"));const K=t().createElement("div",{className:O.join(" "),onMouseDown:function(e){if(e){if(!e.target.classList.contains("pure-modal-backdrop"))return;e.stopPropagation(),e.preventDefault()}v(e)},onTouchMove:r?E:void 0,onMouseMove:r?E:void 0},t().createElement("div",{className:q.join(" "),style:{transform:`translate(${h}px, ${g}px)`,transition:"none",width:Z}},t().createElement(i,{replace:M,header:B,footer:D,onDragStart:Q?function(e){if(e instanceof TouchEvent&&e.changedTouches&&e.changedTouches.length>1)return;e.preventDefault();const{pageX:t,pageY:n}=S(e),{top:A,left:o}=e.currentTarget.getBoundingClientRect();s(!0),c("number"==typeof a?a:o),u("number"==typeof l?l:A),f(t-o),y(n-A)}:void 0,onDragEnd:Q?V:void 0,onClose:v,bodyClass:J.join(" "),closeButton:j,closeButtonPosition:P},N)));return U?(0,n.createPortal)(K,document.body):K}o(494);const a=t().memo(s)})(),r})())(A,h)}),uA=m(lA);const hA=({role:t,color:n,highlighted:A,selectPiece:o})=>{const r="bin"===t;return e("div",{className:I("edit-square border border-gray-300 rounded",A&&"bg-orange-300"),children:e("piece",{className:I("spare-piece",t,n,r&&"next-trash"),onClick:()=>{"function"==typeof o&&o({role:t,color:n})}})})},pA=({isOpen:n,hide:A,onPromote:o,color:r="white"})=>{const i=e=>{o(e),A()};return e(uA,{closeButton:"",isOpen:n,onClose:A,children:t("div",{className:"promote flex gap-2 py-1.5 justify-center",children:[e(hA,{color:r,role:"queen",selectPiece:()=>i("q")}),e(hA,{color:r,role:"rook",selectPiece:()=>i("r")}),e(hA,{color:r,role:"bishop",selectPiece:()=>i("b")}),e(hA,{color:r,role:"knight",selectPiece:()=>i("n")})]})})},gA=(e=!1)=>{const[t,n]=r(e);return{isOpen:t,show:()=>{n(!0)},hide:()=>{n(!1)},toggle:()=>{n(!t)}}};var dA="object"==typeof global&&global&&global.Object===Object&&global,mA="object"==typeof self&&self&&self.Object===Object&&self,fA=dA||mA||Function("return this")(),bA=fA.Symbol,yA=Object.prototype,IA=yA.hasOwnProperty,kA=yA.toString,wA=bA?bA.toStringTag:void 0;var CA=Object.prototype.toString;var vA=bA?bA.toStringTag:void 0;function SA(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":vA&&vA in Object(e)?function(e){var t=IA.call(e,wA),n=e[wA];try{e[wA]=void 0;var A=!0}catch(e){}var o=kA.call(e);return A&&(t?e[wA]=n:delete e[wA]),o}(e):function(e){return CA.call(e)}(e)}function EA(e){return null!=e&&"object"==typeof e}var VA=Array.isArray;function NA(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function MA(e){if(!NA(e))return!1;var t=SA(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var xA,BA=fA["__core-js_shared__"],DA=(xA=/[^.]+$/.exec(BA&&BA.keys&&BA.keys.IE_PROTO||""))?"Symbol(src)_1."+xA:"";var TA=Function.prototype.toString;function QA(e){if(null!=e){try{return TA.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var ZA=/^\[object .+?Constructor\]$/,jA=Function.prototype,PA=Object.prototype,UA=jA.toString,OA=PA.hasOwnProperty,qA=RegExp("^"+UA.call(OA).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function JA(e){return!(!NA(e)||(t=e,DA&&DA in t))&&(MA(e)?qA:ZA).test(QA(e));var t}function KA(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return JA(n)?n:void 0}var GA=KA(fA,"WeakMap");function RA(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var FA=Object.prototype;function LA(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||FA)}function zA(e){return EA(e)&&"[object Arguments]"==SA(e)}var WA=Object.prototype,YA=WA.hasOwnProperty,_A=WA.propertyIsEnumerable,HA=zA(function(){return arguments}())?zA:function(e){return EA(e)&&YA.call(e,"callee")&&!_A.call(e,"callee")};var XA="object"==typeof exports&&exports&&!exports.nodeType&&exports,$A=XA&&"object"==typeof module&&module&&!module.nodeType&&module,eo=$A&&$A.exports===XA?fA.Buffer:void 0,to=(eo?eo.isBuffer:void 0)||function(){return!1},no={};no["[object Float32Array]"]=no["[object Float64Array]"]=no["[object Int8Array]"]=no["[object Int16Array]"]=no["[object Int32Array]"]=no["[object Uint8Array]"]=no["[object Uint8ClampedArray]"]=no["[object Uint16Array]"]=no["[object Uint32Array]"]=!0,no["[object Arguments]"]=no["[object Array]"]=no["[object ArrayBuffer]"]=no["[object Boolean]"]=no["[object DataView]"]=no["[object Date]"]=no["[object Error]"]=no["[object Function]"]=no["[object Map]"]=no["[object Number]"]=no["[object Object]"]=no["[object RegExp]"]=no["[object Set]"]=no["[object String]"]=no["[object WeakMap]"]=!1;var Ao,oo="object"==typeof exports&&exports&&!exports.nodeType&&exports,ro=oo&&"object"==typeof module&&module&&!module.nodeType&&module,io=ro&&ro.exports===oo&&dA.process,so=function(){try{var e=ro&&ro.require&&ro.require("util").types;return e||io&&io.binding&&io.binding("util")}catch(e){}}(),ao=so&&so.isTypedArray,co=ao?(Ao=ao,function(e){return Ao(e)}):function(e){return EA(e)&&RA(e.length)&&!!no[SA(e)]};var lo=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),uo=lo,ho=Object.prototype.hasOwnProperty;var po=KA(fA,"Map"),go=KA(fA,"DataView"),mo=KA(fA,"Promise"),fo=KA(fA,"Set"),bo="[object Map]",yo="[object Promise]",Io="[object Set]",ko="[object WeakMap]",wo="[object DataView]",Co=QA(go),vo=QA(po),So=QA(mo),Eo=QA(fo),Vo=QA(GA),No=SA;(go&&No(new go(new ArrayBuffer(1)))!=wo||po&&No(new po)!=bo||mo&&No(mo.resolve())!=yo||fo&&No(new fo)!=Io||GA&&No(new GA)!=ko)&&(No=function(e){var t=SA(e),n="[object Object]"==t?e.constructor:void 0,A=n?QA(n):"";if(A)switch(A){case Co:return wo;case vo:return bo;case So:return yo;case Eo:return Io;case Vo:return ko}return t});var Mo=No,xo=Object.prototype.hasOwnProperty;function Bo(e){if(null==e)return!0;if(function(e){return null!=e&&RA(e.length)&&!MA(e)}(e)&&(VA(e)||"string"==typeof e||"function"==typeof e.splice||to(e)||co(e)||HA(e)))return!e.length;var t=Mo(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(LA(e))return!function(e){if(!LA(e))return uo(e);var t=[];for(var n in Object(e))ho.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e).length;for(var n in e)if(xo.call(e,n))return!1;return!0}const Do=e=>{const t={};e.orientation&&(t.orientation=e.orientation,"w"===t.orientation&&(t.orientation="white"),"b"===t.orientation&&(t.orientation="black"));const n=["shapes","onSelect","drawable","lastMove"];for(const A of n)e[A]&&!Bo(e[A])&&(t[A]=e[A]);return!1===e.drawable&&(t.drawable={enabled:!1}),t.shapes&&(t.shapes=(e=>{try{return e.forEach(e=>{e.dest=e.dest.replace(/\]/g,"")}),e}catch{return e}})(t.shapes)),e.editing&&(t.movable={free:!1},t.drawable={enabled:!1}),e.viewOnly&&(t.draggable=!1,t.movable={free:!1},t.drawable={enabled:!1}),e.readOnly&&(t.draggable=!1,t.movable={free:!1},t.drawable={enabled:!1},t.coordinates=!1),t},To=e=>tA(e)&&(e=>{if(!e)return!1;const t=e.split(" ")[0];return 1===(t.match(/k/g)||[]).length&&1===(t.match(/K/g)||[]).length})(e),Qo=(e,t,n=!1)=>{if(!To(e.fen()))return{free:!1};const A=new Map,o="w"===e.turn()?"white":"black";Zn.forEach(t=>{const n=e.moves({square:t,verbose:!0});n.length&&A.set(t,n.map(e=>e.to))});const r={color:o,dests:A,free:!1};return n&&t&&t!==o&&(r.color=t,r.dests=new Map),r},Zo=(n,A)=>{const{theme:o}=un(),{isOpen:r,show:i,hide:l}=gA(),{chess:h,fen:p,turnColor:g,lastMove:d,orientation:m,promotion:f,onMove:b,onPromote:y,onUndo:k}=cA(n),w=async(e,t,A)=>b(e,t,A||f)?(o.playSounds&&ln(o.sounds),"function"==typeof n.onMove&&await n.onMove(h),!0):(A||i(),!1),{onSetPremove:C,onUnsetPremove:v,onPlayPremove:S,onCancelPremove:E,onPremovePromotion:V}=(e=>{const t=a(null),n=c((e,n,A)=>{t.current={orig:e,dest:n,promotion:A?.promotion||null}},[]),A=c(()=>{t.current=null},[]),o=c(()=>"q",[]);return{onSetPremove:n,onUnsetPremove:A,onPlayPremove:c(async()=>{if(t.current){const{orig:n,dest:A,promotion:o}=t.current,r={orig:n,dest:A,promotion:o};t.current=null;const i=r.promotion||"q";return await e(r.orig,r.dest,i)}return!1},[e]),onCancelPremove:c(()=>!!t.current&&(t.current=null,!0),[]),onPremovePromotion:o}})(w),N=a();u(A,()=>({board:N.current?.board,undo:k,move:b,playPremove:S,cancelPremove:E}));s(()=>{"function"==typeof n.setPromoting&&n.setPromoting(r)},[r]),s(()=>{"function"==typeof n.onFenChange&&n.onFenChange(p)},[p]);const M=n.premoves?{enabled:!0,showDests:!0,castle:!0,events:{set:C,unset:v},promote:V}:{enabled:!1};return t("div",{className:I("chessground",o.highlight&&"highlight",o.board,o.pieces),children:[e(an,{ref:N,coordinates:o.coordinates,onMove:w,fen:p,turnColor:g,lastMove:d,orientation:m,movable:Qo(h,m,n.premoves),premovable:M,...Do(n)}),e(pA,{isOpen:r,hide:l,color:g,onPromote:async e=>{if(!y(e))return!1;o.playSounds&&ln(o.sounds),"function"==typeof n.onMove&&await n.onMove(h)}})]})};var jo=l(Zo);const Po=e=>{try{return"w"===e.split(" ")[1]?"white":"black"}catch{return"white"}},Uo=e=>{const[t,n]=r((e=>{try{return e.orientation?e.orientation:e.fen?Po(e.fen):"white"}catch{return"white"}})(e));return s(()=>{e.reset&&n(Po(e.fen))},[e.reset]),[t,()=>{n(e=>"white"===e?"black":"white")}]},Oo=()=>{const{theme:A,handleChange:o}=un();return t(n,{children:[e("div",{children:"Board"}),t("select",{name:"board",className:"bg-white border border-gray-300 px-2 py-1.5 w-full text-gray-800 rounded",defaultValue:A.board,onChange:o,children:[e("option",{value:"green",children:"Green"}),e("option",{value:"brown",children:"Brown"}),e("option",{value:"ruby",children:"Ruby"}),e("option",{value:"purple",children:"Purple"}),e("option",{value:"teal",children:"Teal"})]})]})},qo=()=>{const{theme:A,handleChecked:o}=un();return t(n,{children:[e("div",{children:"Coordinates"}),e("div",{className:"flex",children:e("input",{name:"coordinates",type:"checkbox",className:"checkbox rounded border border-gray-300",defaultChecked:A.coordinates,onChange:o})})]})},Jo=()=>{const{theme:A,handleChecked:o}=un();return t(n,{children:[e("div",{children:"Highlight moves"}),e("div",{className:"flex",children:e("input",{name:"highlight",type:"checkbox",className:"checkbox rounded border border-gray-300",defaultChecked:A.highlight,onChange:o})})]})},Ko=()=>{const{theme:A,handleChange:o}=un();return t(n,{children:[e("div",{children:"Pieces"}),t("select",{name:"pieces",className:"bg-white border border-gray-300 px-2 py-1.5 w-full text-gray-800 rounded",defaultValue:A.pieces,onChange:o,children:[e("option",{value:"cburnett",children:"Cburnett"}),e("option",{value:"neo",children:"Neo"}),e("option",{value:"alpha",children:"Alpha"}),e("option",{value:"bases",children:"Bases"}),e("option",{value:"classic",children:"Classic"})]})]})},Go=()=>{const{theme:A,handleChecked:o}=un();return t(n,{children:[e("div",{children:"Play sounds"}),e("div",{className:"flex",children:e("input",{name:"playSounds",type:"checkbox",className:"checkbox rounded border border-gray-300",defaultChecked:A.playSounds,onChange:o})})]})},Ro=()=>{const{theme:A,handleChange:o}=un();return t(n,{children:[e("div",{children:"Sounds"}),t("select",{name:"sounds",className:"bg-white border border-gray-300 px-2 py-1.5 w-full text-gray-800 rounded",defaultValue:A.sounds,onChange:o,children:[e("option",{value:"robot",children:"Robot"}),e("option",{value:"piano",children:"Piano"}),e("option",{value:"lisp",children:"Lisp"}),e("option",{value:"sfx",children:"SFX"})]})]})},Fo=()=>{const{isOpen:A,show:o,hide:r}=gA();return t(n,{children:[e("button",{type:"button",className:"next-button next-settings",title:"Settings",onClick:o,children:e("i",{className:"next-cog"})}),e(uA,{header:"Settings",isOpen:A,onClose:r,children:t("div",{className:"grid grid-cols-2 gap-3 items-center text-sm",children:[e(Ko,{}),e(Oo,{}),e(Jo,{}),e(Go,{}),e(Ro,{}),e(qo,{})]})})]})},Lo=t=>e("button",{type:"button",className:"next-button next-flip",title:"Flip board",...t,children:e("i",{className:"next-sync"})}),zo=({flip:n,readOnly:A})=>A?null:t("div",{className:"chessground-footer text-gray-400 flex flex-row-reverse gap-2 py-1.5",children:[e(Fo,{}),e(Lo,{onClick:n})]});var Wo=l((n,A)=>{const[o,r]=Uo(n);return e(y,{children:t("div",{className:"next-chessground",children:[e(jo,{...n,ref:A,orientation:o}),e(zo,{flip:r,readOnly:n.readOnly})]})})});const Yo=t=>{const{theme:n}=un();return e("div",{className:I("spare-pieces flex gap-2",n.pieces),children:["bin","pawn","knight","bishop","rook","queen","king"].map(n=>((t,n)=>{const{color:A="white",selected:o={role:null,color:null}}=n,r=t===o.role&&A===o.color;return e(hA,{highlighted:r,role:t,color:A,...n},`${t}-${A}`)})(n,t))})},_o=e=>{const t=new Map;return t.set(e,null),t},Ho=({onChange:n})=>{const[A,o]=r("w"),[i,a]=r("-");s(()=>{"function"==typeof n&&n([A,i].join(" "))},[A,i]);const c=e=>{const{value:t}=e.target;o(t)},l=e=>{const{value:t}=e.target;a(((e,t)=>{if(!t)return e;const n=["K","Q","k","q"].map(n=>n!==t?e.includes(n)?n:"":e.includes(t)?"":t).join("");return n.length?n:"-"})(i,t))};return t("div",{className:"flex flex-col gap-2 w-full",children:[t("div",{className:"flex gap-2 w-full",children:[t("div",{children:[e("input",{defaultChecked:!0,className:"mx-1",type:"radio",id:"white-radio",name:"side-to-move",value:"w",onChange:c}),e("label",{htmlFor:"white-radio",children:"White to move"})]}),t("div",{children:[e("input",{className:"mx-1",type:"radio",id:"black-radio",name:"side-to-move",value:"b",onChange:c}),e("label",{htmlFor:"black-radio",children:"Black to move"})]})]}),t("div",{className:"flex flex-col gap-2 w-full",children:[t("div",{className:"flex w-full gap-4",children:[e("div",{children:e("span",{children:"White can"})}),t("div",{children:[e("input",{className:"mx-1",type:"checkbox",id:"white-short-castle",value:"K",onChange:l}),e("label",{htmlFor:"white-short-castle",children:"O-O"})]}),t("div",{children:[e("input",{className:"mx-1",type:"checkbox",id:"white-long-castle",value:"Q",onChange:l}),e("label",{htmlFor:"white-long-castle",children:"O-O-O"})]})]}),t("div",{className:"flex w-full gap-4",children:[e("div",{children:e("span",{children:"Black can"})}),t("div",{children:[e("input",{className:"mx-1",type:"checkbox",id:"black-short-castle",value:"k",onChange:l}),e("label",{htmlFor:"black-short-castle",children:"O-O"})]}),t("div",{children:[e("input",{className:"mx-1",type:"checkbox",id:"black-long-castle",value:"q",onChange:l}),e("label",{htmlFor:"black-long-castle",children:"O-O-O"})]})]})]})]})},Xo=(n,A)=>{const[o,i]=r(n.fen||aA.emptyFen),[a,c]=r({role:null,color:null});s(()=>{n.fen&&i(n.fen)},[n.fen]),s(()=>{"function"==typeof n.onSelect&&n.onSelect(o)},[o]);return e(y,{children:t("div",{className:"next-chessground gap-2",children:[e(Yo,{selected:a,selectPiece:c,color:"black"}),e(jo,{...n,ref:A,fen:o,onSelect:e=>{const t=o.split(" ");t.shift();const n=t.join(" "),r=((e,t,n)=>{if(!e)throw new Error("Chessground is not defined");if(!t||!t.role||!t.color)return e.getFen();if("bin"===t.role)return e.setPieces(_o(n)),e.getFen();const A=e.state.pieces.get(n);return A?A.role===t.role&&A.color===t.color?(e.setPieces(_o(n)),e.getFen()):(e.setPieces(_o(n)),e.newPiece(t,n),e.getFen()):(e.newPiece(t,n),e.getFen())})(A.current.board,a,e),s=[r,n].join(" ");i(s)},editing:!0}),e(Yo,{selected:a,selectPiece:c,color:"white"}),e(Ho,{onChange:e=>{const t=[o.split(" ")[0],e,"- 0 1"].join(" ");i(t)}})]})})};var $o=l(Xo);class er{constructor(e){if("undefined"==typeof window)return!1;if(!window.chessEngineWorker){const t=e??process.env.STOCKFISH_PATH;window.chessEngineWorker=new Worker(t)}this.skillLevel=20,this.maxDepth=40,this.resolveTimeout=null,this.isAnalyzing=!1,this.fen=aA.initialFen}getTurnFromFen(e){return e.split(" ")[1]}normalizeScoreValue(e){const{fen:t}=this;return"b"===this.getTurnFromFen(t)?-1*e:e}isInfoMessage(e){return!(!e||!e.data)&&e.data.startsWith("info")}setSkillLevel(){window.chessEngineWorker.postMessage("setoption name Skill Level value "+this.skillLevel),window.chessEngineWorker.postMessage("setoption name Skill Level Maximum Error value 5000"),window.chessEngineWorker.postMessage("setoption name Skill Level Probability value 1")}async init(){await this.use_uci(),await this.is_ready(),this.setSkillLevel()}getScoreFromInfo(e){if(e.startsWith("info depth 0")){const t=e.split(" "),n=t[4],A=this.normalizeScoreValue(Number(t[5]));return this.isAnalyzing=!1,{type:n,value:A}}if(e.startsWith("info depth ")){const t=e.split(" ");return{type:t[8],value:this.normalizeScoreValue(Number(t[9]))}}return{type:"cp",value:0}}parseData(e){const t=e.split(" ")[2];let n="";e.indexOf(" pv ")>-1&&(n=e.split(" pv ")[1].split(" bmc ")[0]);return{depth:t,pv:n,score:this.getScoreFromInfo(e)}}use_uci(){return new Promise(e=>{window.chessEngineWorker.postMessage("uci"),window.chessEngineWorker.onmessage=t=>{"uciok"===t.data&&e(t)}})}is_ready(){return new Promise(e=>{window.chessEngineWorker.postMessage("isready"),window.chessEngineWorker.onmessage=t=>{"readyok"===t.data&&e(t)}})}set_position(e){return new Promise(t=>{this.fen=e,window.chessEngineWorker.postMessage("position fen "+e),t()})}async new_position(e){await this.stop(),await this.is_ready(),this.set_position(e),this.go_infinite()}set_multipv(e){window.chessEngineWorker.postMessage("setoption name MultiPV value "+e)}get_score(e,t=15){return new Promise(n=>{window.chessEngineWorker.postMessage("position fen "+e),window.chessEngineWorker.postMessage("go depth 15"),window.chessEngineWorker.onmessage=e=>{if(e.data.startsWith("info depth "+t)){const t=e.data.split(" "),A=t[8],o=Number(t[9]);n({type:A,value:o})}else if(e.data.startsWith("info depth 0")){const t=e.data.split(" "),A=t[4],o=Number(t[5]);n({type:A,value:o})}}})}go_depth(e){return new Promise(t=>{window.chessEngineWorker.postMessage("go depth "+e),window.chessEngineWorker.onmessage=e=>{e.data.startsWith("bestmove")&&t(e.data)}})}go_time(e){return new Promise(t=>{window.chessEngineWorker.postMessage("go movetime "+e),window.chessEngineWorker.onmessage=e=>{e.data.startsWith("bestmove")&&t(e.data)}})}go_infinite(e){window.chessEngineWorker.postMessage("go infinite"),this.isAnalyzing=!0,window.chessEngineWorker.onmessage=t=>{if(this.isInfoMessage(t)&&"function"==typeof e){const n=this.parseData(t.data);n.depth>this.maxDepth&&this.stop(),e(n)}}}stop(){return new Promise(e=>{this.isAnalyzing||e(),window.chessEngineWorker.postMessage("stop"),window.chessEngineWorker.onmessage=t=>{t.data.startsWith("bestmove")&&(this.isAnalyzing=!1,e(t.data))}})}quit(){window.chessEngineWorker.postMessage("quit")}}function tr(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var A=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&A.firstChild?A.insertBefore(o,A.firstChild):A.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}tr(".brown .cg-wrap cg-board {\n background-image: url('data:image/svg+xml;base64,PHN2ZyAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgeG1sbnM6eD0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgI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G5PA+D2NABuTwPg9jQAbk8D4PY0AG5PA+D2NABuTwPg9jQAbk8D4PY0AG5PA+D2NABuTwPg9jQAbk8D4PY0AG5PA+D2NABuTwPg9twPA74bHvA2fP+w9v3T3t9n5wE3IEM/PIDVn+B9g5h6GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwe64c4HHxABwbgNEBTAPcu7/9AeG6Ae7d3/43CBoA9zcIGgD3nxA0AO4/IWgA3P+HQAPg/j8EGgD1AHx0AA2AwdMAqAfggwNoABSeBkA9AO8fQAPg8DQA6gF49wAaAImnAVAPwHsH0ABYPA2AegDeOYAGQONpANQDcP4AGgCPpwFQD8DZA2gARJ4GQD0A5w6gATB5GgD1AJw5gAZA5WkA1APw9gAaAJenAVAPwJsDaABkngZAPQCvD6ABsHkaAPUAvDqABkDnaQDUA/DyABoAn6cBUA/AiwNoAISeBkA9AM8PoAEwehoA9QA8O4AGQOlpANQD8P8AGgCnpwFQD8C/A2gApJ4GQD0Afw+gAbB6GgD1APw5gAZA62kA1APw+wAaAK+nAXD/tiANgPu3BWkA3D8uSgPg/nFRGgD3rwvTALh/XZgGwO1pANyeBsDtfwE/g8u1a15o2AAAAABJRU5ErkJggg==');\n}\n.teal .cg-wrap cg-board {\n background-image: url('data:image/svg+xml;base64,CjxzdmcgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgIHhtbG5zOng9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiICB2aWV3Qm94PSIwIDAgOCA4IiAgc2hhcGUtcmVuZGVyaW5nPSJnZW9tZXRyaWNQcmVjaXNpb24iPjxyZWN0IHdpZHRoPSI4IiBoZWlnaHQ9IjgiIGZpbGw9IiMxYzcyYWQiLz48ZyBpZD0iYSI+ICA8ZyBpZD0iYiI+ICAgIDxnIGlkPSJjIj4gICAgICA8ZyBpZD0iZCI+ICAgICAgICA8cmVjdCB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSIjZTNlYmYzIiBpZD0iZSIvPiAgICAgICAgPHVzZSB4PSIyIiBocmVmPSIjZSIgeDpocmVmPSIjZSIvPiAgICAgIDwvZz4gICAgICA8dXNlIHg9IjQiIGhyZWY9IiNkIiB4OmhyZWY9IiNkIi8+ICAgIDwvZz4gICAgPHVzZSB4PSIxIiB5PSIxIiBocmVmPSIjYyIgeDpocmVmPSIjYyIvPiAgPC9nPiAgPHVzZSB5PSIyIiBocmVmPSIjYiIgeDpocmVmPSIjYiIvPjwvZz48dXNlIHk9IjQiIGhyZWY9IiNhIiB4OmhyZWY9IiNhIi8+PC9zdmc+');\n}\n");tr(".next-chessground .chessground {\n grid-area: board;\n position: relative;\n display: block;\n height: 0;\n padding-bottom: 100%;\n padding-right: 100%;\n width: 100%;\n border-radius: 0.25rem;\n overflow: hidden;\n}\n\n.next-chessground .cg-wrap {\n display: table;\n position: absolute;\n width: 100%;\n height: 100%;\n}\n\n.next-chessground cg-helper {\n position: absolute;\n width: 12.5%;\n padding-bottom: 12.5%;\n display: table;\n bottom: 0;\n}\n\n.next-chessground cg-container {\n position: absolute;\n width: 800%;\n height: 800%;\n display: block;\n bottom: 0;\n}\n\n.next-chessground cg-board {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n line-height: 0;\n background-size: cover;\n cursor: pointer;\n}\n\n.next-chessground cg-board square {\n position: absolute;\n top: 0;\n left: 0;\n width: 12.5%;\n height: 12.5%;\n pointer-events: none;\n}\n.next-chessground .highlight cg-board square.last-move {\n will-change: transform;\n background-color: rgba(246, 246, 130, 0.5);\n}\n.next-chessground .highlight .correct cg-board square.last-move {\n background-color: rgba(155, 240, 0, 0.4);\n}\n.next-chessground .highlight .incorrect cg-board square.last-move {\n background-color: rgba(240, 0, 0, 0.4);\n}\n\n.next-chessground cg-board square.check {\n background: radial-gradient(\n ellipse at center,\n rgba(255, 0, 0, 1) 0%,\n rgba(231, 0, 0, 1) 25%,\n rgba(169, 0, 0, 0) 89%,\n rgba(158, 0, 0, 0) 100%\n );\n}\n.next-chessground cg-board square.current-premove {\n background-color: rgba(20, 30, 85, 0.5);\n}\n.next-chessground cg-board piece {\n position: absolute;\n top: 0;\n left: 0;\n width: 12.5%;\n height: 12.5%;\n background-size: cover;\n z-index: 2;\n will-change: transform;\n pointer-events: none;\n}\n.next-chessground cg-board piece.dragging {\n cursor: move;\n z-index: 9;\n}\n.next-chessground cg-board piece.anim {\n z-index: 8;\n}\n.next-chessground cg-board piece.fading {\n z-index: 1;\n opacity: 0.5;\n}\n.next-chessground cg-board piece.ghost {\n opacity: 0.3;\n}\n.next-chessground .cg-wrap svg {\n overflow: hidden;\n position: relative;\n top: 0px;\n left: 0px;\n width: 100%;\n height: 100%;\n pointer-events: none;\n z-index: 2;\n opacity: 0.6;\n}\n.next-chessground .cg-wrap svg image {\n opacity: 0.5;\n}\n\n.next-chessground .spare-pieces {\n width: 100%;\n display: flex;\n justify-content: center;\n}\n.next-chessground .spare-piece {\n top: 0;\n left: 0;\n padding-bottom: 100%;\n padding-left: 100%;\n position: absolute;\n background-size: contain;\n background-position: 0% -100%;\n cursor: pointer;\n}\n.next-chessground .edit-square {\n display: table;\n position: relative;\n width: 14.285%;\n padding-bottom: 13.285%;\n}\n.next-chessground .promote .edit-square {\n width: 20%;\n padding-bottom: 20%;\n}\n");tr("coords {\n position: absolute;\n display: flex;\n pointer-events: none;\n user-select: none;\n color: #fff;\n font-weight: bold;\n font-size: 0.5rem;\n opacity: 0.8;\n}\n.coords-no coords {\n display: none;\n}\n@media (min-width: 640px) {\n coords {\n font-size: 0.75rem;\n }\n}\ncoords.ranks {\n flex-flow: column-reverse;\n top: 0;\n right: 0;\n height: 100%;\n width: 0.8em;\n}\ncoords.ranks.black {\n flex-flow: column;\n}\ncoords.files {\n bottom: 0;\n left: 0;\n flex-flow: row;\n width: 100%;\n}\ncoords.files.black {\n flex-flow: row-reverse;\n}\ncoords.files coord {\n padding-left: 4px;\n}\ncoords coord {\n flex: 1 1 auto;\n}\n\n.orientation-white .files coord:nth-child(2n + 1),\n.orientation-white .ranks coord:nth-child(2n),\n.orientation-black .files coord:nth-child(2n),\n.orientation-black .ranks coord:nth-child(2n + 1) {\n color: #fff;\n}\n.orientation-white .files coord:nth-child(2n),\n.orientation-white .ranks coord:nth-child(2n + 1),\n.orientation-black .files coord:nth-child(2n + 1),\n.orientation-black .ranks coord:nth-child(2n) {\n color: #779556;\n}\n");tr(".next-chessground .next-cog {\n width: 1rem;\n height: 1rem;\n background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjOUY5REIwIiBkPSJNNDg3LjQgMzE1LjdsLTQyLjYtMjQuNmM0LjMtMjMuMiA0LjMtNDcgMC03MC4ybDQyLjYtMjQuNmM0LjktMi44IDcuMS04LjYgNS41LTE0LTExLjEtMzUuNi0zMC02Ny44LTU0LjctOTQuNi0zLjgtNC4xLTEwLTUuMS0xNC44LTIuM0wzODAuOCAxMTBjLTE3LjktMTUuNC0zOC41LTI3LjMtNjAuOC0zNS4xVjI1LjhjMC01LjYtMy45LTEwLjUtOS40LTExLjctMzYuNy04LjItNzQuMy03LjgtMTA5LjIgMC01LjUgMS4yLTkuNCA2LjEtOS40IDExLjdWNzVjLTIyLjIgNy45LTQyLjggMTkuOC02MC44IDM1LjFMODguNyA4NS41Yy00LjktMi44LTExLTEuOS0xNC44IDIuMy0yNC43IDI2LjctNDMuNiA1OC45LTU0LjcgOTQuNi0xLjcgNS40LjYgMTEuMiA1LjUgMTRMNjcuMyAyMjFjLTQuMyAyMy4yLTQuMyA0NyAwIDcwLjJsLTQyLjYgMjQuNmMtNC45IDIuOC03LjEgOC42LTUuNSAxNCAxMS4xIDM1LjYgMzAgNjcuOCA1NC43IDk0LjYgMy44IDQuMSAxMCA1LjEgMTQuOCAyLjNsNDIuNi0yNC42YzE3LjkgMTUuNCAzOC41IDI3LjMgNjAuOCAzNS4xdjQ5LjJjMCA1LjYgMy45IDEwLjUgOS40IDExLjcgMzYuNyA4LjIgNzQuMyA3LjggMTA5LjIgMCA1LjUtMS4yIDkuNC02LjEgOS40LTExLjd2LTQ5LjJjMjIuMi03LjkgNDIuOC0xOS44IDYwLjgtMzUuMWw0Mi42IDI0LjZjNC45IDIuOCAxMSAxLjkgMTQuOC0yLjMgMjQuNy0yNi43IDQzLjYtNTguOSA1NC43LTk0LjYgMS41LTUuNS0uNy0xMS4zLTUuNi0xNC4xek0yNTYgMzM2Yy00NC4xIDAtODAtMzUuOS04MC04MHMzNS45LTgwIDgwLTgwIDgwIDM1LjkgODAgODAtMzUuOSA4MC04MCA4MHoiLz48L3N2Zz4=');\n}\n.next-chessground .next-sync {\n width: 1rem;\n height: 1rem;\n background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjOUY5REIwIiBkPSJNMzcwLjcyIDEzMy4yOEMzMzkuNDU4IDEwNC4wMDggMjk4Ljg4OCA4Ny45NjIgMjU1Ljg0OCA4OGMtNzcuNDU4LjA2OC0xNDQuMzI4IDUzLjE3OC0xNjIuNzkxIDEyNi44NS0xLjM0NCA1LjM2My02LjEyMiA5LjE1LTExLjY1MSA5LjE1SDI0LjEwM2MtNy40OTggMC0xMy4xOTQtNi44MDctM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iAwIDAgMC0xMiAxMnYyMTZhMTIgMTIgMCAwIDAgMTIgMTJ6TTQzMiA4MGgtODIuNDFsLTM0LTU2LjdBNDggNDggMCAwIDAgMjc0LjQxIDBIMTczLjU5YTQ4IDQ4IDAgMCAwLTQxLjE2IDIzLjNMOTguNDEgODBIMTZBMTYgMTYgMCAwIDAgMCA5NnYxNmExNiAxNiAwIDAgMCAxNiAxNmgxNnYzMzZhNDggNDggMCAwIDAgNDggNDhoMjg4YTQ4IDQ4IDAgMCAwIDQ4LTQ4VjEyOGgxNmExNiAxNiAwIDAgMCAxNi0xNlY5NmExNiAxNiAwIDAgMC0xNi0xNnpNMTcxLjg0IDUwLjkxQTYgNiAwIDAgMSAxNzcgNDhoOTRhNiA2IDAgMCAxIDUuMTUgMi45MUwyOTMuNjEgODBIMTU0LjM5ek0zNjggNDY0SDgwVjEyOGgyODh6bS0yMTItNDhoMjRhMTIgMTIgMCAwIDAgMTItMTJWMTg4YTEyIDEyIDAgMCAwLTEyLTEyaC0yNGExMiAxMiAwIDAgMC0xMiAxMnYyMTZhMTIgMTIgMCAwIDAgMTIgMTJ6Ii8+PC9zdmc+');\n}\n");tr("*,\n::after,\n::before {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n}\n\n.next-chessground {\n display: flex;\n flex-direction: column;\n position: relative;\n width: 100%;\n}\n.next-chessground .checkbox {\n display: flex;\n margin: 0;\n align-items: center;\n padding-left: 0.25rem;\n width: 2.75rem;\n height: 1.75rem;\n outline: none;\n appearance: none;\n transition: 0.2s ease-in-out;\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n cursor: pointer;\n}\n.next-chessground .checkbox:before {\n background-color: rgba(156, 163, 175);\n width: 1rem;\n height: 1rem;\n border-radius: 999px;\n content: '';\n transition: 0.2s ease-in-out;\n}\n.next-chessground .checkbox:checked:before {\n background-color: rgba(4, 120, 87);\n transform: translate(1rem, 0);\n}\n.next-chessground .next-button {\n background-color: transparent;\n background-image: none;\n cursor: pointer;\n display: flex;\n outline: none;\n\n padding: 0;\n line-height: inherit;\n color: inherit;\n font-size: 100%;\n}\n.next-chessground .next-button:focus {\n outline: none;\n}\n");tr(".pure-modal {\n box-shadow: rgba(0, 0, 0, 0.5) 0px 5px 15px 0px;\n color: rgba(55, 65, 81);\n}\n.pure-modal-backdrop {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 1040;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n.backdrop-overflow-hidden {\n overflow: hidden !important;\n}\n.pure-modal-backdrop .pure-modal {\n width: 300px;\n max-width: 100%;\n box-sizing: border-box;\n transition: all 0.2s ease-in-out;\n max-height: 100%;\n}\n.pure-modal.auto-height {\n position: static;\n}\n.pure-modal-backdrop.scrollable {\n overflow-y: auto;\n}\n.pure-modal-backdrop .panel {\n display: grid;\n grid-template-rows: repeat(3, min-content);\n}\n.pure-modal-backdrop:not(.scrollable) .panel {\n grid-template-rows: min-content minmax(0, 1fr) min-content;\n max-height: -moz-available;\n max-height: -webkit-fill-available;\n max-height: fill-available;\n height: 100%;\n}\n.pure-modal > * > * {\n flex: 0 0 auto;\n}\n.pure-modal > * > .scrollable {\n overflow-x: hidden;\n overflow-scrolling: touch;\n}\n@media (max-width: 480px) {\n .pure-modal-backdrop .pure-modal {\n width: 100%;\n }\n}\n.pure-modal .panel-body {\n background-color: #fff;\n}\n.pure-modal .panel-heading {\n background: #f0f0f0;\n}\n.pure-modal .panel-title {\n padding: 12px 45px 12px 15px;\n margin: 0;\n}\n.pure-modal .close {\n right: 6px;\n top: 6px;\n z-index: 1;\n width: 30px;\n height: 30px;\n border-radius: 15px;\n text-align: center;\n line-height: 30px;\n cursor: pointer;\n font-size: 1.85rem;\n}\n.pure-modal .panel-heading .close:hover {\n color: #000;\n}\n.pure-modal .panel-body {\n padding: 15px;\n}\n.pure-modal .panel-footer {\n padding: 12px 45px 12px 15px;\n background: #f0f0f0;\n}\n.pure-modal .panel-body,\n.pure-modal .panel-footer,\n.pure-modal .panel-title {\n word-break: break-all;\n}\n.pure-modal-backdrop .additional-row,\n.pure-modal-backdrop:not(.scrollable) .additional-row {\n display: grid;\n grid-template-rows: min-content minmax(0, 1fr) min-content min-content;\n}\n");tr("/**\n * Cburnett\n */\n.cburnett piece.pawn.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wP.svg');\n}\n.cburnett piece.bishop.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wB.svg');\n}\n.cburnett piece.knight.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wN.svg');\n}\n.cburnett piece.rook.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wR.svg');\n}\n.cburnett piece.queen.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wQ.svg');\n}\n.cburnett piece.king.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wK.svg');\n}\n.cburnett piece.pawn.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bP.svg');\n}\n.cburnett piece.bishop.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bB.svg');\n}\n.cburnett piece.knight.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bN.svg');\n}\n.cburnett piece.rook.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bR.svg');\n}\n.cburnett piece.queen.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bQ.svg');\n}\n.cburnett piece.king.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bK.svg');\n}\n\n/**\n * Classic\n */\n.classic piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wp.png');\n}\n.classic piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wb.png');\n}\n.classic piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wn.png');\n}\n.classic piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wr.png');\n}\n.classic piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wq.png');\n}\n.classic piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wk.png');\n}\n.classic piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bp.png');\n}\n.classic piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bb.png');\n}\n.classic piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bn.png');\n}\n.classic piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/br.png');\n}\n.classic piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bq.png');\n}\n.classic piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bk.png');\n}\n\n/**\n * Neo\n */\n.neo piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wp.png');\n}\n.neo piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wb.png');\n}\n.neo piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wn.png');\n}\n.neo piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wr.png');\n}\n.neo piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wq.png');\n}\n.neo piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wk.png');\n}\n.neo piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bp.png');\n}\n.neo piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bb.png');\n}\n.neo piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bn.png');\n}\n.neo piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/br.png');\n}\n.neo piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bq.png');\n}\n.neo piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bk.png');\n}\n\n/**\n * Alpha\n */\n.alpha piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wp.png');\n}\n.alpha piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wb.png');\n}\n.alpha piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wn.png');\n}\n.alpha piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wr.png');\n}\n.alpha piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wq.png');\n}\n.alpha piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wk.png');\n}\n.alpha piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bp.png');\n}\n.alpha piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bb.png');\n}\n.alpha piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bn.png');\n}\n.alpha piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/br.png');\n}\n.alpha piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bq.png');\n}\n.alpha piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bk.png');\n}\n\n/**\n * Bases\n */\n.bases piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wp.png');\n}\n.bases piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wb.png');\n}\n.bases piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wn.png');\n}\n.bases piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wr.png');\n}\n.bases piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wq.png');\n}\n.bases piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wk.png');\n}\n.bases piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bp.png');\n}\n.bases piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bb.png');\n}\n.bases piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bn.png');\n}\n.bases piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/br.png');\n}\n.bases piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bq.png');\n}\n.bases piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bk.png');\n}\n");tr(".flex {\n display: flex;\n}\n.flex-col {\n flex-direction: column;\n}\n.flex-row-reverse {\n flex-direction: row-reverse;\n}\n.grid {\n display: grid;\n}\n.grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n.gap-2 {\n gap: 0.5rem;\n}\n.gap-3 {\n gap: 0.75rem;\n}\n.w-full {\n width: 100%;\n}\n.items-center {\n align-items: center;\n}\n.justify-center {\n justify-content: center;\n}\n.py-1\\.5 {\n padding-top: 0.375rem;\n padding-bottom: 0.375rem;\n}\n.px-2 {\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n}\n.cursor-pointer {\n cursor: pointer;\n}\n.cursor-resize {\n cursor: nesw-resize;\n}\n.outline-none,\n.outline-none:focus {\n outline: none;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-gray-400 {\n color: rgba(156, 163, 175);\n}\n.text-gray-800 {\n color: rgba(31, 41, 55);\n}\n.bg-white {\n background-color: #fff;\n}\n.bg-orange-300 {\n background-color: #fbd38d;\n}\n.border {\n border-width: 1px;\n border-style: solid;\n}\n.border-gray-300 {\n border-color: rgba(209, 213, 219);\n}\n.rounded {\n border-radius: 0.25rem;\n}\n");export{Wo as NextChessground,$o as NextEditor,er as Stockfish,aA as constants,Wo as default,To as isValidFen,cA as useChess,un as useChessground};
|
|
35
|
+
*/!function(e,t){function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n}(hn,Error),hn.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var n,A=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){A=e[n].text.split(/\r\n|\n|\r/g);break}var o=this.location.start,r=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(o):o,i=this.location.source+":"+r.line+":"+r.column;if(A){var s=this.location.end,a=pn("",r.line.toString().length," "),c=A[o.line-1],l=(o.line===s.line?s.column:c.length+1)-o.column||1;t+="\n --\x3e "+i+"\n"+a+" |\n"+r.line+" | "+c+"\n"+a+" | "+pn("",o.column-1," ")+pn("",l,"^")}else t+="\n at "+i}return t},hn.buildMessage=function(e,t){var n={literal:function(e){return'"'+o(e.text)+'"'},class:function(e){var t=e.parts.map(function(e){return Array.isArray(e)?r(e[0])+"-"+r(e[1]):r(e)});return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function A(e){return e.charCodeAt(0).toString(16).toUpperCase()}function o(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+A(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+A(e)})}function r(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+A(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+A(e)})}function i(e){return n[e.type](e)}return"Expected "+function(e){var t,n,A=e.map(i);if(A.sort(),A.length>0){for(t=1,n=1;t<A.length;t++)A[t-1]!==A[t]&&(A[n]=A[t],n++);A.length=n}switch(A.length){case 1:return A[0];case 2:return A[0]+" or "+A[1];default:return A.slice(0,-1).join(", ")+", or "+A[A.length-1]}}(e)+" but "+function(e){return e?'"'+o(e)+'"':"end of input"}(t)+" found."};const dn=0xffffffffffffffffn;function mn(e,t){return 0xffffffffffffffffn&(e<<t|e>>64n-t)}function fn(e,t){return e*t&dn}const bn=(yn=0xa187eb39cdcaed8f31c4b365b102e01en,function(){let e=BigInt(yn&dn),t=BigInt(yn>>64n&dn);const n=fn(mn(fn(e,5n),7n),9n);return t^=e,e=(mn(e,24n)^t^t<<16n)&dn,t=mn(t,37n),yn=t<<64n|e,n});var yn;const In=Array.from({length:2},()=>Array.from({length:6},()=>Array.from({length:128},()=>bn()))),kn=Array.from({length:8},()=>bn()),wn=Array.from({length:16},()=>bn()),Cn=bn(),vn="w",Sn="b",En="p",Vn="b",Nn="r",Mn="q",xn="k",Bn="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";class Dn{color;from;to;piece;captured;promotion;flags;san;lan;before;after;constructor(e,t){const{color:n,piece:A,from:o,to:r,flags:i,captured:s,promotion:a}=t,c=$n(o),l=$n(r);this.color=n,this.piece=A,this.from=c,this.to=l,this.san=e._moveToSan(t,e._moves({legal:!0})),this.lan=c+l,this.before=e.fen(),e._makeMove(t),this.after=e.fen(),e._undoMove(),this.flags="";for(const e in jn)jn[e]&i&&(this.flags+=Qn[e]);s&&(this.captured=s),a&&(this.promotion=a,this.lan+=a)}isCapture(){return this.flags.indexOf(Qn.CAPTURE)>-1}isPromotion(){return this.flags.indexOf(Qn.PROMOTION)>-1}isEnPassant(){return this.flags.indexOf(Qn.EP_CAPTURE)>-1}isKingsideCastle(){return this.flags.indexOf(Qn.KSIDE_CASTLE)>-1}isQueensideCastle(){return this.flags.indexOf(Qn.QSIDE_CASTLE)>-1}isBigPawn(){return this.flags.indexOf(Qn.BIG_PAWN)>-1}}const Tn=-1,Qn={NORMAL:"n",CAPTURE:"c",BIG_PAWN:"b",EP_CAPTURE:"e",PROMOTION:"p",KSIDE_CASTLE:"k",QSIDE_CASTLE:"q",NULL_MOVE:"-"},Zn=["a8","b8","c8","d8","e8","f8","g8","h8","a7","b7","c7","d7","e7","f7","g7","h7","a6","b6","c6","d6","e6","f6","g6","h6","a5","b5","c5","d5","e5","f5","g5","h5","a4","b4","c4","d4","e4","f4","g4","h4","a3","b3","c3","d3","e3","f3","g3","h3","a2","b2","c2","d2","e2","f2","g2","h2","a1","b1","c1","d1","e1","f1","g1","h1"],jn={NORMAL:1,CAPTURE:2,BIG_PAWN:4,EP_CAPTURE:8,PROMOTION:16,KSIDE_CASTLE:32,QSIDE_CASTLE:64,NULL_MOVE:128},Pn={Event:"?",Site:"?",Date:"????.??.??",Round:"?",White:"?",Black:"?",Result:"*"},Un={...Pn,WhiteTitle:null,BlackTitle:null,WhiteElo:null,BlackElo:null,WhiteUSCF:null,BlackUSCF:null,WhiteNA:null,BlackNA:null,WhiteType:null,BlackType:null,EventDate:null,EventSponsor:null,Section:null,Stage:null,Board:null,Opening:null,Variation:null,SubVariation:null,ECO:null,NIC:null,Time:null,UTCTime:null,UTCDate:null,TimeControl:null,SetUp:null,FEN:null,Termination:null,Annotator:null,Mode:null,PlyCount:null},On={a8:0,b8:1,c8:2,d8:3,e8:4,f8:5,g8:6,h8:7,a7:16,b7:17,c7:18,d7:19,e7:20,f7:21,g7:22,h7:23,a6:32,b6:33,c6:34,d6:35,e6:36,f6:37,g6:38,h6:39,a5:48,b5:49,c5:50,d5:51,e5:52,f5:53,g5:54,h5:55,a4:64,b4:65,c4:66,d4:67,e4:68,f4:69,g4:70,h4:71,a3:80,b3:81,c3:82,d3:83,e3:84,f3:85,g3:86,h3:87,a2:96,b2:97,c2:98,d2:99,e2:100,f2:101,g2:102,h2:103,a1:112,b1:113,c1:114,d1:115,e1:116,f1:117,g1:118,h1:119},qn={b:[16,32,17,15],w:[-16,-32,-17,-15]},Jn={n:[-18,-33,-31,-14,18,33,31,14],b:[-17,-15,17,15],r:[-16,1,16,-1],q:[-17,-16,-15,1,17,16,15,-1],k:[-17,-16,-15,1,17,16,15,-1]},Kn=[20,0,0,0,0,0,0,24,0,0,0,0,0,0,20,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,24,24,24,24,24,24,56,0,56,24,24,24,24,24,24,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,20,0,0,0,0,0,0,24,0,0,0,0,0,0,20],Gn=[17,0,0,0,0,0,0,16,0,0,0,0,0,0,15,0,0,17,0,0,0,0,0,16,0,0,0,0,0,15,0,0,0,0,17,0,0,0,0,16,0,0,0,0,15,0,0,0,0,0,0,17,0,0,0,16,0,0,0,15,0,0,0,0,0,0,0,0,17,0,0,16,0,0,15,0,0,0,0,0,0,0,0,0,0,17,0,16,0,15,0,0,0,0,0,0,0,0,0,0,0,0,17,16,15,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,-15,-16,-17,0,0,0,0,0,0,0,0,0,0,0,0,-15,0,-16,0,-17,0,0,0,0,0,0,0,0,0,0,-15,0,0,-16,0,0,-17,0,0,0,0,0,0,0,0,-15,0,0,0,-16,0,0,0,-17,0,0,0,0,0,0,-15,0,0,0,0,-16,0,0,0,0,-17,0,0,0,0,-15,0,0,0,0,0,-16,0,0,0,0,0,-17,0,0,-15,0,0,0,0,0,0,-16,0,0,0,0,0,0,-17],Rn={p:1,n:2,b:4,r:8,q:16,k:32},Fn=["n",Vn,Nn,Mn],Ln={[xn]:jn.KSIDE_CASTLE,[Mn]:jn.QSIDE_CASTLE},zn={w:[{square:On.a1,flag:jn.QSIDE_CASTLE},{square:On.h1,flag:jn.KSIDE_CASTLE}],b:[{square:On.a8,flag:jn.QSIDE_CASTLE},{square:On.h8,flag:jn.KSIDE_CASTLE}]},Wn={b:1,w:6},Yn="--";function _n(e){return e>>4}function Hn(e){return 15&e}function Xn(e){return-1!=="0123456789".indexOf(e)}function $n(e){const t=Hn(e),n=_n(e);return"abcdefgh".substring(t,t+1)+"87654321".substring(n,n+1)}function eA(e){return e===vn?Sn:vn}function tA(e){const t=e.split(/\s+/);if(6!==t.length)return{ok:!1,error:"Invalid FEN: must contain six space-delimited fields"};const n=parseInt(t[5],10);if(isNaN(n)||n<=0)return{ok:!1,error:"Invalid FEN: move number must be a positive integer"};const A=parseInt(t[4],10);if(isNaN(A)||A<0)return{ok:!1,error:"Invalid FEN: half move counter number must be a non-negative integer"};if(!/^(-|[abcdefgh][36])$/.test(t[3]))return{ok:!1,error:"Invalid FEN: en-passant square is invalid"};if(/[^kKqQ-]/.test(t[2]))return{ok:!1,error:"Invalid FEN: castling availability is invalid"};if(!/^(w|b)$/.test(t[1]))return{ok:!1,error:"Invalid FEN: side-to-move is invalid"};const o=t[0].split("/");if(8!==o.length)return{ok:!1,error:"Invalid FEN: piece data does not contain 8 '/'-delimited rows"};for(let e=0;e<o.length;e++){let t=0,n=!1;for(let A=0;A<o[e].length;A++)if(Xn(o[e][A])){if(n)return{ok:!1,error:"Invalid FEN: piece data is invalid (consecutive number)"};t+=parseInt(o[e][A],10),n=!0}else{if(!/^[prnbqkPRNBQK]$/.test(o[e][A]))return{ok:!1,error:"Invalid FEN: piece data is invalid (invalid piece)"};t+=1,n=!1}if(8!==t)return{ok:!1,error:"Invalid FEN: piece data is invalid (too many squares in rank)"}}if("3"==t[3][1]&&"w"==t[1]||"6"==t[3][1]&&"b"==t[1])return{ok:!1,error:"Invalid FEN: illegal en-passant square"};const r=[{color:"white",regex:/K/g},{color:"black",regex:/k/g}];for(const{color:e,regex:n}of r){if(!n.test(t[0]))return{ok:!1,error:`Invalid FEN: missing ${e} king`};if((t[0].match(n)||[]).length>1)return{ok:!1,error:`Invalid FEN: too many ${e} kings`}}return Array.from(o[0]+o[7]).some(e=>"P"===e.toUpperCase())?{ok:!1,error:"Invalid FEN: some pawns are on the edge rows"}:{ok:!0}}function nA(e,t,n,A,o,r=void 0,i=jn.NORMAL){const s=_n(A);if(o!==En||7!==s&&0!==s)e.push({color:t,from:n,to:A,piece:o,captured:r,flags:i});else for(let s=0;s<Fn.length;s++){const a=Fn[s];e.push({color:t,from:n,to:A,piece:o,captured:r,promotion:a,flags:i|jn.PROMOTION})}}function AA(e){let t=e.charAt(0);if(t>="a"&&t<="h"){if(e.match(/[a-h]\d.*[a-h]\d/))return;return En}return t=t.toLowerCase(),"o"===t?xn:t}function oA(e){return e.replace(/=/,"").replace(/[+#]?[?!]*$/,"")}class rA{_board=new Array(128);_turn=vn;_header={};_kings={w:Tn,b:Tn};_epSquare=-1;_halfMoves=0;_moveNumber=0;_history=[];_comments={};_castling={w:0,b:0};_hash=0n;_positionCount=new Map;constructor(e=Bn,{skipValidation:t=!1}={}){this.load(e,{skipValidation:t})}clear({preserveHeaders:e=!1}={}){this._board=new Array(128),this._kings={w:Tn,b:Tn},this._turn=vn,this._castling={w:0,b:0},this._epSquare=Tn,this._halfMoves=0,this._moveNumber=1,this._history=[],this._comments={},this._header=e?this._header:{...Un},this._hash=this._computeHash(),this._positionCount=new Map,this._header.SetUp=null,this._header.FEN=null}load(e,{skipValidation:t=!1,preserveHeaders:n=!1}={}){let A=e.split(/\s+/);if(A.length>=2&&A.length<6){const t=["-","-","0","1"];e=A.concat(t.slice(-(6-A.length))).join(" ")}if(A=e.split(/\s+/),!t){const{ok:t,error:n}=tA(e);if(!t)throw new Error(n)}const o=A[0];let r=0;this.clear({preserveHeaders:n});for(let e=0;e<o.length;e++){const t=o.charAt(e);if("/"===t)r+=8;else if(Xn(t))r+=parseInt(t,10);else{const e=t<"a"?vn:Sn;this._put({type:t.toLowerCase(),color:e},$n(r)),r++}}this._turn=A[1],A[2].indexOf("K")>-1&&(this._castling.w|=jn.KSIDE_CASTLE),A[2].indexOf("Q")>-1&&(this._castling.w|=jn.QSIDE_CASTLE),A[2].indexOf("k")>-1&&(this._castling.b|=jn.KSIDE_CASTLE),A[2].indexOf("q")>-1&&(this._castling.b|=jn.QSIDE_CASTLE),this._epSquare="-"===A[3]?Tn:On[A[3]],this._halfMoves=parseInt(A[4],10),this._moveNumber=parseInt(A[5],10),this._hash=this._computeHash(),this._updateSetup(e),this._incPositionCount()}fen({forceEnpassantSquare:e=!1}={}){let t=0,n="";for(let e=On.a8;e<=On.h1;e++){if(this._board[e]){t>0&&(n+=t,t=0);const{color:A,type:o}=this._board[e];n+=A===vn?o.toUpperCase():o.toLowerCase()}else t++;e+1&136&&(t>0&&(n+=t),e!==On.h1&&(n+="/"),t=0,e+=8)}let A="";this._castling[vn]&jn.KSIDE_CASTLE&&(A+="K"),this._castling[vn]&jn.QSIDE_CASTLE&&(A+="Q"),this._castling[Sn]&jn.KSIDE_CASTLE&&(A+="k"),this._castling[Sn]&jn.QSIDE_CASTLE&&(A+="q"),A=A||"-";let o="-";if(this._epSquare!==Tn)if(e)o=$n(this._epSquare);else{const e=this._epSquare+(this._turn===vn?16:-16),t=[e+1,e-1];for(const e of t){if(136&e)continue;const t=this._turn;if(this._board[e]?.color===t&&this._board[e]?.type===En){this._makeMove({color:t,from:e,to:this._epSquare,piece:En,captured:En,flags:jn.EP_CAPTURE});const n=!this._isKingAttacked(t);if(this._undoMove(),n){o=$n(this._epSquare);break}}}}return[n,this._turn,A,o,this._halfMoves,this._moveNumber].join(" ")}_pieceKey(e){if(!this._board[e])return 0n;const{color:t,type:n}=this._board[e],A={p:0,n:1,b:2,r:3,q:4,k:5}[n];return In[{w:0,b:1}[t]][A][e]}_epKey(){return this._epSquare===Tn?0n:kn[7&this._epSquare]}_castlingKey(){const e=this._castling.w>>5|this._castling.b>>3;return wn[e]}_computeHash(){let e=0n;for(let t=On.a8;t<=On.h1;t++)136&t?t+=7:this._board[t]&&(e^=this._pieceKey(t));return e^=this._epKey(),e^=this._castlingKey(),"b"===this._turn&&(e^=Cn),e}_updateSetup(e){this._history.length>0||(e!==Bn?(this._header.SetUp="1",this._header.FEN=e):(this._header.SetUp=null,this._header.FEN=null))}reset(){this.load(Bn)}get(e){return this._board[On[e]]}findPiece(e){const t=[];for(let n=On.a8;n<=On.h1;n++)136&n?n+=7:this._board[n]&&this._board[n]?.color===e.color&&this._board[n].color===e.color&&this._board[n].type===e.type&&t.push($n(n));return t}put({type:e,color:t},n){return!!this._put({type:e,color:t},n)&&(this._updateCastlingRights(),this._updateEnPassantSquare(),this._updateSetup(this.fen()),!0)}_set(e,t){this._hash^=this._pieceKey(e),this._board[e]=t,this._hash^=this._pieceKey(e)}_put({type:e,color:t},n){if(-1==="pnbrqkPNBRQK".indexOf(e.toLowerCase()))return!1;if(!(n in On))return!1;const A=On[n];if(e==xn&&this._kings[t]!=Tn&&this._kings[t]!=A)return!1;const o=this._board[A];return o&&o.type===xn&&(this._kings[o.color]=Tn),this._set(A,{type:e,color:t}),e===xn&&(this._kings[t]=A),!0}_clear(e){this._hash^=this._pieceKey(e),delete this._board[e]}remove(e){const t=this.get(e);return this._clear(On[e]),t&&t.type===xn&&(this._kings[t.color]=Tn),this._updateCastlingRights(),this._updateEnPassantSquare(),this._updateSetup(this.fen()),t}_updateCastlingRights(){this._hash^=this._castlingKey();const e=this._board[On.e1]?.type===xn&&this._board[On.e1]?.color===vn,t=this._board[On.e8]?.type===xn&&this._board[On.e8]?.color===Sn;e&&this._board[On.a1]?.type===Nn&&this._board[On.a1]?.color===vn||(this._castling.w&=-65),e&&this._board[On.h1]?.type===Nn&&this._board[On.h1]?.color===vn||(this._castling.w&=-33),t&&this._board[On.a8]?.type===Nn&&this._board[On.a8]?.color===Sn||(this._castling.b&=-65),t&&this._board[On.h8]?.type===Nn&&this._board[On.h8]?.color===Sn||(this._castling.b&=-33),this._hash^=this._castlingKey()}_updateEnPassantSquare(){if(this._epSquare===Tn)return;const e=this._epSquare+(this._turn===vn?-16:16),t=this._epSquare+(this._turn===vn?16:-16),n=[t+1,t-1];if(null!==this._board[e]||null!==this._board[this._epSquare]||this._board[t]?.color!==eA(this._turn)||this._board[t]?.type!==En)return this._hash^=this._epKey(),void(this._epSquare=Tn);n.some(e=>!(136&e)&&this._board[e]?.color===this._turn&&this._board[e]?.type===En)||(this._hash^=this._epKey(),this._epSquare=Tn)}_attacked(e,t,n){const A=[];for(let o=On.a8;o<=On.h1;o++){if(136&o){o+=7;continue}if(void 0===this._board[o]||this._board[o].color!==e)continue;const r=this._board[o],i=o-t;if(0===i)continue;const s=i+119;if(Kn[s]&Rn[r.type]){if(r.type===En){if(i>0&&r.color===vn||i<=0&&r.color===Sn){if(!n)return!0;A.push($n(o))}continue}if("n"===r.type||"k"===r.type){if(n){A.push($n(o));continue}return!0}const e=Gn[s];let a=o+e,c=!1;for(;a!==t;){if(null!=this._board[a]){c=!0;break}a+=e}if(!c){if(n){A.push($n(o));continue}return!0}}}return!!n&&A}attackers(e,t){return t?this._attacked(t,On[e],!0):this._attacked(this._turn,On[e],!0)}_isKingAttacked(e){const t=this._kings[e];return-1!==t&&this._attacked(eA(e),t)}hash(){return this._hash.toString(16)}isAttacked(e,t){return this._attacked(t,On[e])}isCheck(){return this._isKingAttacked(this._turn)}inCheck(){return this.isCheck()}isCheckmate(){return this.isCheck()&&0===this._moves().length}isStalemate(){return!this.isCheck()&&0===this._moves().length}isInsufficientMaterial(){const e={b:0,n:0,r:0,q:0,k:0,p:0},t=[];let n=0,A=0;for(let o=On.a8;o<=On.h1;o++){if(A=(A+1)%2,136&o){o+=7;continue}const r=this._board[o];r&&(e[r.type]=r.type in e?e[r.type]+1:1,r.type===Vn&&t.push(A),n++)}if(2===n)return!0;if(3===n&&(1===e[Vn]||1===e.n))return!0;if(n===e[Vn]+2){let e=0;const n=t.length;for(let A=0;A<n;A++)e+=t[A];if(0===e||e===n)return!0}return!1}isThreefoldRepetition(){return this._getPositionCount(this._hash)>=3}isDrawByFiftyMoves(){return this._halfMoves>=100}isDraw(){return this.isDrawByFiftyMoves()||this.isStalemate()||this.isInsufficientMaterial()||this.isThreefoldRepetition()}isGameOver(){return this.isCheckmate()||this.isDraw()}moves({verbose:e=!1,square:t,piece:n}={}){const A=this._moves({square:t,piece:n});return e?A.map(e=>new Dn(this,e)):A.map(e=>this._moveToSan(e,A))}_moves({legal:e=!0,piece:t,square:n}={}){const A=n?n.toLowerCase():void 0,o=t?.toLowerCase(),r=[],i=this._turn,s=eA(i);let a=On.a8,c=On.h1,l=!1;if(A){if(!(A in On))return[];a=c=On[A],l=!0}for(let e=a;e<=c;e++){if(136&e){e+=7;continue}if(!this._board[e]||this._board[e].color===s)continue;const{type:t}=this._board[e];let n;if(t===En){if(o&&o!==t)continue;n=e+qn[i][0],this._board[n]||(nA(r,i,e,n,En),n=e+qn[i][1],Wn[i]!==_n(e)||this._board[n]||nA(r,i,e,n,En,void 0,jn.BIG_PAWN));for(let t=2;t<4;t++)n=e+qn[i][t],136&n||(this._board[n]?.color===s?nA(r,i,e,n,En,this._board[n].type,jn.CAPTURE):n===this._epSquare&&nA(r,i,e,n,En,En,jn.EP_CAPTURE))}else{if(o&&o!==t)continue;for(let A=0,o=Jn[t].length;A<o;A++){const o=Jn[t][A];for(n=e;n+=o,!(136&n);){if(this._board[n]){if(this._board[n].color===i)break;nA(r,i,e,n,t,this._board[n].type,jn.CAPTURE);break}if(nA(r,i,e,n,t),"n"===t||t===xn)break}}}}if(!(void 0!==o&&o!==xn||l&&c!==this._kings[i])){if(this._castling[i]&jn.KSIDE_CASTLE){const e=this._kings[i],t=e+2;this._board[e+1]||this._board[t]||this._attacked(s,this._kings[i])||this._attacked(s,e+1)||this._attacked(s,t)||nA(r,i,this._kings[i],t,xn,void 0,jn.KSIDE_CASTLE)}if(this._castling[i]&jn.QSIDE_CASTLE){const e=this._kings[i],t=e-2;this._board[e-1]||this._board[e-2]||this._board[e-3]||this._attacked(s,this._kings[i])||this._attacked(s,e-1)||this._attacked(s,t)||nA(r,i,this._kings[i],t,xn,void 0,jn.QSIDE_CASTLE)}}if(!e||-1===this._kings[i])return r;const u=[];for(let e=0,t=r.length;e<t;e++)this._makeMove(r[e]),this._isKingAttacked(i)||u.push(r[e]),this._undoMove();return u}move(e,{strict:t=!1}={}){let n=null;if("string"==typeof e)n=this._moveFromSan(e,t);else if(null===e)n=this._moveFromSan(Yn,t);else if("object"==typeof e){const t=this._moves();for(let A=0,o=t.length;A<o;A++)if(e.from===$n(t[A].from)&&e.to===$n(t[A].to)&&(!("promotion"in t[A])||e.promotion===t[A].promotion)){n=t[A];break}}if(!n)throw"string"==typeof e?new Error(`Invalid move: ${e}`):new Error(`Invalid move: ${JSON.stringify(e)}`);if(this.isCheck()&&n.flags&jn.NULL_MOVE)throw new Error("Null move not allowed when in check");const A=new Dn(this,n);return this._makeMove(n),this._incPositionCount(),A}_push(e){this._history.push({move:e,kings:{b:this._kings.b,w:this._kings.w},turn:this._turn,castling:{b:this._castling.b,w:this._castling.w},epSquare:this._epSquare,halfMoves:this._halfMoves,moveNumber:this._moveNumber})}_movePiece(e,t){this._hash^=this._pieceKey(e),this._board[t]=this._board[e],delete this._board[e],this._hash^=this._pieceKey(t)}_makeMove(e){const t=this._turn,n=eA(t);if(this._push(e),e.flags&jn.NULL_MOVE)return t===Sn&&this._moveNumber++,this._halfMoves++,this._turn=n,void(this._epSquare=Tn);if(this._hash^=this._epKey(),this._hash^=this._castlingKey(),e.captured&&(this._hash^=this._pieceKey(e.to)),this._movePiece(e.from,e.to),e.flags&jn.EP_CAPTURE&&(this._turn===Sn?this._clear(e.to-16):this._clear(e.to+16)),e.promotion&&(this._clear(e.to),this._set(e.to,{type:e.promotion,color:t})),this._board[e.to].type===xn){if(this._kings[t]=e.to,e.flags&jn.KSIDE_CASTLE){const t=e.to-1,n=e.to+1;this._movePiece(n,t)}else if(e.flags&jn.QSIDE_CASTLE){const t=e.to+1,n=e.to-2;this._movePiece(n,t)}this._castling[t]=0}if(this._castling[t])for(let n=0,A=zn[t].length;n<A;n++)if(e.from===zn[t][n].square&&this._castling[t]&zn[t][n].flag){this._castling[t]^=zn[t][n].flag;break}if(this._castling[n])for(let t=0,A=zn[n].length;t<A;t++)if(e.to===zn[n][t].square&&this._castling[n]&zn[n][t].flag){this._castling[n]^=zn[n][t].flag;break}if(this._hash^=this._castlingKey(),e.flags&jn.BIG_PAWN){let A;A=t===Sn?e.to-16:e.to+16,(e.to-1&136||this._board[e.to-1]?.type!==En||this._board[e.to-1]?.color!==n)&&(e.to+1&136||this._board[e.to+1]?.type!==En||this._board[e.to+1]?.color!==n)?this._epSquare=Tn:(this._epSquare=A,this._hash^=this._epKey())}else this._epSquare=Tn;e.piece===En||e.flags&(jn.CAPTURE|jn.EP_CAPTURE)?this._halfMoves=0:this._halfMoves++,t===Sn&&this._moveNumber++,this._turn=n,this._hash^=Cn}undo(){const e=this._hash,t=this._undoMove();if(t){const n=new Dn(this,t);return this._decPositionCount(e),n}return null}_undoMove(){const e=this._history.pop();if(void 0===e)return null;this._hash^=this._epKey(),this._hash^=this._castlingKey();const t=e.move;this._kings=e.kings,this._turn=e.turn,this._castling=e.castling,this._epSquare=e.epSquare,this._halfMoves=e.halfMoves,this._moveNumber=e.moveNumber,this._hash^=this._epKey(),this._hash^=this._castlingKey(),this._hash^=Cn;const n=this._turn,A=eA(n);if(t.flags&jn.NULL_MOVE)return t;if(this._movePiece(t.to,t.from),t.piece&&(this._clear(t.from),this._set(t.from,{type:t.piece,color:n})),t.captured)if(t.flags&jn.EP_CAPTURE){let e;e=n===Sn?t.to-16:t.to+16,this._set(e,{type:En,color:A})}else this._set(t.to,{type:t.captured,color:A});if(t.flags&(jn.KSIDE_CASTLE|jn.QSIDE_CASTLE)){let e,n;t.flags&jn.KSIDE_CASTLE?(e=t.to+1,n=t.to-1):(e=t.to-2,n=t.to+1),this._movePiece(n,e)}return t}pgn({newline:e="\n",maxWidth:t=0}={}){const n=[];let A=!1;for(const t in this._header){this._header[t]&&n.push(`[${t} "${this._header[t]}"]`+e),A=!0}A&&this._history.length&&n.push(e);const o=e=>{const t=this._comments[this.fen()];if(void 0!==t){e=`${e}${e.length>0?" ":""}{${t}}`}return e},r=[];for(;this._history.length>0;)r.push(this._undoMove());const i=[];let s="";for(0===r.length&&i.push(o(""));r.length>0;){s=o(s);const e=r.pop();if(!e)break;if(this._history.length||"b"!==e.color)"w"===e.color&&(s.length&&i.push(s),s=this._moveNumber+".");else{const e=`${this._moveNumber}. ...`;s=s?`${s} ${e}`:e}s=s+" "+this._moveToSan(e,this._moves({legal:!0})),this._makeMove(e)}if(s.length&&i.push(o(s)),i.push(this._header.Result||"*"),0===t)return n.join("")+i.join(" ");const a=function(){return n.length>0&&" "===n[n.length-1]&&(n.pop(),!0)},c=function(A,o){for(const r of o.split(" "))if(r){if(A+r.length>t){for(;a();)A--;n.push(e),A=0}n.push(r),A+=r.length,n.push(" "),A++}return a()&&A--,A};let l=0;for(let A=0;A<i.length;A++)l+i[A].length>t&&i[A].includes("{")?l=c(l,i[A]):(l+i[A].length>t&&0!==A?(" "===n[n.length-1]&&n.pop(),n.push(e),l=0):0!==A&&(n.push(" "),l++),n.push(i[A]),l+=i[A].length);return n.join("")}header(...e){for(let t=0;t<e.length;t+=2)"string"==typeof e[t]&&"string"==typeof e[t+1]&&(this._header[e[t]]=e[t+1]);return this._header}setHeader(e,t){return this._header[e]=t??Pn[e]??null,this.getHeaders()}removeHeader(e){return e in this._header&&(this._header[e]=Pn[e]||null,!0)}getHeaders(){const e={};for(const[t,n]of Object.entries(this._header))null!==n&&(e[t]=n);return e}loadPgn(e,{strict:t=!1,newlineChar:n="\r?\n"}={}){"\r?\n"!==n&&(e=e.replace(new RegExp(n,"g"),"\n"));const A=gn(e);this.reset();const o=A.headers;let r="";for(const e in o)"fen"===e.toLowerCase()&&(r=o[e]),this.header(e,o[e]);if(t){if("1"===o.SetUp){if(!("FEN"in o))throw new Error("Invalid PGN: FEN tag must be supplied with SetUp tag");this.load(o.FEN,{preserveHeaders:!0})}}else r&&this.load(r,{preserveHeaders:!0});let i=A.root;for(;i;){if(i.move){const e=this._moveFromSan(i.move,t);if(null==e)throw new Error(`Invalid move in PGN: ${i.move}`);this._makeMove(e),this._incPositionCount()}void 0!==i.comment&&(this._comments[this.fen()]=i.comment),i=i.variations[0]}const s=A.result;s&&Object.keys(this._header).length&&this._header.Result!==s&&this.setHeader("Result",s)}_moveToSan(e,t){let n="";if(e.flags&jn.KSIDE_CASTLE)n="O-O";else if(e.flags&jn.QSIDE_CASTLE)n="O-O-O";else{if(e.flags&jn.NULL_MOVE)return Yn;if(e.piece!==En){const A=function(e,t){const n=e.from,A=e.to,o=e.piece;let r=0,i=0,s=0;for(let e=0,a=t.length;e<a;e++){const a=t[e].from,c=t[e].to;o===t[e].piece&&n!==a&&A===c&&(r++,_n(n)===_n(a)&&i++,Hn(n)===Hn(a)&&s++)}return r>0?i>0&&s>0?$n(n):s>0?$n(n).charAt(1):$n(n).charAt(0):""}(e,t);n+=e.piece.toUpperCase()+A}e.flags&(jn.CAPTURE|jn.EP_CAPTURE)&&(e.piece===En&&(n+=$n(e.from)[0]),n+="x"),n+=$n(e.to),e.promotion&&(n+="="+e.promotion.toUpperCase())}return this._makeMove(e),this.isCheck()&&(this.isCheckmate()?n+="#":n+="+"),this._undoMove(),n}_moveFromSan(e,t=!1){let n=oA(e);if(t||("0-0"===n?n="O-O":"0-0-0"===n&&(n="O-O-O")),n==Yn){return{color:this._turn,from:0,to:0,piece:"k",flags:jn.NULL_MOVE}}let A,o,r,i,s,a=AA(n),c=this._moves({legal:!0,piece:a});for(let e=0,t=c.length;e<t;e++)if(n===oA(this._moveToSan(c[e],c)))return c[e];if(t)return null;let l=!1;if(o=n.match(/([pnbrqkPNBRQK])?([a-h][1-8])x?-?([a-h][1-8])([qrbnQRBN])?/),o?(A=o[1],r=o[2],i=o[3],s=o[4],1==r.length&&(l=!0)):(o=n.match(/([pnbrqkPNBRQK])?([a-h]?[1-8]?)x?-?([a-h][1-8])([qrbnQRBN])?/),o&&(A=o[1],r=o[2],i=o[3],s=o[4],1==r.length&&(l=!0))),a=AA(n),c=this._moves({legal:!0,piece:A||a}),!i)return null;for(let e=0,t=c.length;e<t;e++)if(r){if(!(A&&A.toLowerCase()!=c[e].piece||On[r]!=c[e].from||On[i]!=c[e].to||s&&s.toLowerCase()!=c[e].promotion))return c[e];if(l){const t=$n(c[e].from);if(!(A&&A.toLowerCase()!=c[e].piece||On[i]!=c[e].to||r!=t[0]&&r!=t[1]||s&&s.toLowerCase()!=c[e].promotion))return c[e]}}else if(n===oA(this._moveToSan(c[e],c)).replace("x",""))return c[e];return null}ascii(){let e=" +------------------------+\n";for(let t=On.a8;t<=On.h1;t++){if(0===Hn(t)&&(e+=" "+"87654321"[_n(t)]+" |"),this._board[t]){const n=this._board[t].type;e+=" "+(this._board[t].color===vn?n.toUpperCase():n.toLowerCase())+" "}else e+=" . ";t+1&136&&(e+="|\n",t+=8)}return e+=" +------------------------+\n",e+=" a b c d e f g h",e}perft(e){const t=this._moves({legal:!1});let n=0;const A=this._turn;for(let o=0,r=t.length;o<r;o++)this._makeMove(t[o]),this._isKingAttacked(A)||(e-1>0?n+=this.perft(e-1):n++),this._undoMove();return n}setTurn(e){return this._turn!=e&&(this.move("--"),!0)}turn(){return this._turn}board(){const e=[];let t=[];for(let n=On.a8;n<=On.h1;n++)null==this._board[n]?t.push(null):t.push({square:$n(n),type:this._board[n].type,color:this._board[n].color}),n+1&136&&(e.push(t),t=[],n+=8);return e}squareColor(e){if(e in On){const t=On[e];return(_n(t)+Hn(t))%2==0?"light":"dark"}return null}history({verbose:e=!1}={}){const t=[],n=[];for(;this._history.length>0;)t.push(this._undoMove());for(;;){const A=t.pop();if(!A)break;e?n.push(new Dn(this,A)):n.push(this._moveToSan(A,this._moves())),this._makeMove(A)}return n}_getPositionCount(e){return this._positionCount.get(e)??0}_incPositionCount(){this._positionCount.set(this._hash,(this._positionCount.get(this._hash)??0)+1)}_decPositionCount(e){const t=this._positionCount.get(e)??0;1===t?this._positionCount.delete(e):this._positionCount.set(e,t-1)}_pruneComments(){const e=[],t={},n=e=>{e in this._comments&&(t[e]=this._comments[e])};for(;this._history.length>0;)e.push(this._undoMove());for(n(this.fen());;){const t=e.pop();if(!t)break;this._makeMove(t),n(this.fen())}this._comments=t}getComment(){return this._comments[this.fen()]}setComment(e){this._comments[this.fen()]=e.replace("{","[").replace("}","]")}deleteComment(){return this.removeComment()}removeComment(){const e=this._comments[this.fen()];return delete this._comments[this.fen()],e}getComments(){return this._pruneComments(),Object.keys(this._comments).map(e=>({fen:e,comment:this._comments[e]}))}deleteComments(){return this.removeComments()}removeComments(){return this._pruneComments(),Object.keys(this._comments).map(e=>{const t=this._comments[e];return delete this._comments[e],{fen:e,comment:t}})}setCastlingRights(e,t){for(const n of[xn,Mn])void 0!==t[n]&&(t[n]?this._castling[e]|=Ln[n]:this._castling[e]&=~Ln[n]);this._updateCastlingRights();const n=this.getCastlingRights(e);return!(void 0!==t[xn]&&t[xn]!==n[xn]||void 0!==t[Mn]&&t[Mn]!==n[Mn])}getCastlingRights(e){return{[xn]:0!==(this._castling[e]&Ln[xn]),[Mn]:0!==(this._castling[e]&Ln[Mn])}}moveNumber(){return this._moveNumber}}const iA={initial:"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",empty:"8/8/8/8/8/8/8/8 w - - 0 1"},sA=iA.initial,aA={fen:iA,initialFen:sA,emptyFen:iA.empty},cA=e=>{const[t,n]=r(e.fen||sA),[A,o]=r(new rA(t));s(()=>{e.fen&&(n(e.fen),o(new rA(e.fen)),a([]))},[e.fen,e.reset]);const[i,a]=r([]),c=e.lastMove&&e.lastMove.promotion,l="w"===A.turn()?"white":"black",[u]=r(e.orientation||l),h=(e,t,o)=>{a([e,t]);try{const r=A.move({from:e,to:t,promotion:o});return n(A.fen()),r}catch{return!1}};return{chess:A,fen:t,turnColor:l,lastMove:i,orientation:u,promotion:c,onMove:h,onPromote:e=>h(i[0],i[1],e),onUndo:()=>{const e=A.undo();return e?(n(A.fen()),a([]),e):null}}};var lA=f(function(e,t){e.exports=((e,t)=>(()=>{var n={494:()=>{},156:t=>{t.exports=e},111:e=>{e.exports=t}},A={};function o(e){var t=A[e];if(void 0!==t)return t.exports;var r=A[e]={exports:{}};return n[e](r,r.exports,o),r.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{default:()=>a});var e=o(156),t=o.n(e),n=o(111);function A(e){const{children:n,replace:A,bodyClass:o,header:r,footer:i,onDragStart:s,onDragEnd:a,onClose:c,closeButton:l,closeButtonPosition:u}=e;return A?n:t().createElement("div",{className:"panel panel-default "+("bottom"===u?"additional-row":"")},t().createElement("div",{className:"panel-heading",onTouchStart:s,onMouseDown:s,onTouchEnd:a,onMouseUp:a},r&&t().createElement("h3",{className:"panel-title"},r)),t().createElement("div",{className:o},n),i&&t().createElement("div",{className:"panel-footer"},i),t().createElement("div",{className:"close",onClick:c,style:{position:"header"===u?"absolute":"static",margin:"bottom"===u?"10px auto":""}},l))}A.defaultProps={closeButton:"×",closeButtonPosition:"header",replace:!1,draggable:!1};const i=A;function s(A){let o=Math.random().toString();const[r,s]=(0,e.useState)(!1),[a,c]=(0,e.useState)(null),[l,u]=(0,e.useState)(null),[h,p]=(0,e.useState)(0),[g,d]=(0,e.useState)(0),[m,f]=(0,e.useState)(0),[b,y]=(0,e.useState)(0),{isOpen:I,onClose:k}=A,w=(0,e.useCallback)(()=>{document.body.classList.remove("body-modal-fix")},[]);(0,e.useEffect)(()=>(I&&(document.addEventListener("keydown",C),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),document.body.classList.add("body-modal-fix")),()=>{document.querySelector(".pure-modal")||(document.removeEventListener("keydown",C),w(),c(null),u(null),p(0),d(0),f(0),y(0))}),[I]);const C=(0,e.useCallback)(e=>{const t=document.querySelectorAll(".pure-modal"),n=t.length>1,A=t[t.length-1];return!(n&&!A.className.includes(o)||"Escape"!==e.key||!document.activeElement||(v(e),0))},[v,o]);if(!I)return null;function v(e){e&&(e.stopPropagation(),e.preventDefault()),null==k||k({isPassive:Boolean(e)})}function S(e){return e instanceof TouchEvent&&e.changedTouches.length>0?{pageX:e.changedTouches[0].pageX,pageY:e.changedTouches[0].pageY}:e instanceof MouseEvent?{pageX:e.pageX,pageY:e.pageY}:{pageX:0,pageY:0}}function E(e){if(e instanceof TouchEvent&&e.changedTouches&&e.changedTouches.length>1)return V();e.preventDefault();const{pageX:t,pageY:n}=S(e);"number"==typeof a&&"number"==typeof l&&(p(t-a-m),d(n-l-b))}function V(){return s(!1)}const{children:N,replace:M=!1,className:x,header:B,footer:D,scrollable:T=!0,draggable:Q=!1,width:Z,closeButton:j,closeButtonPosition:P,portal:U=!1}=A;let O=["pure-modal-backdrop"],q=["pure-modal",o],J=["panel-body"];x&&(q=q.concat(x)),T?J=J.concat("scrollable"):(O=O.concat("scrollable"),q=q.concat("auto-height")),Q&&(O=O.concat("backdrop-overflow-hidden"));const K=t().createElement("div",{className:O.join(" "),onMouseDown:function(e){if(e){if(!e.target.classList.contains("pure-modal-backdrop"))return;e.stopPropagation(),e.preventDefault()}v(e)},onTouchMove:r?E:void 0,onMouseMove:r?E:void 0},t().createElement("div",{className:q.join(" "),style:{transform:`translate(${h}px, ${g}px)`,transition:"none",width:Z}},t().createElement(i,{replace:M,header:B,footer:D,onDragStart:Q?function(e){if(e instanceof TouchEvent&&e.changedTouches&&e.changedTouches.length>1)return;e.preventDefault();const{pageX:t,pageY:n}=S(e),{top:A,left:o}=e.currentTarget.getBoundingClientRect();s(!0),c("number"==typeof a?a:o),u("number"==typeof l?l:A),f(t-o),y(n-A)}:void 0,onDragEnd:Q?V:void 0,onClose:v,bodyClass:J.join(" "),closeButton:j,closeButtonPosition:P},N)));return U?(0,n.createPortal)(K,document.body):K}o(494);const a=t().memo(s)})(),r})())(A,h)}),uA=m(lA);const hA=({role:t,color:n,highlighted:A,selectPiece:o})=>{const r="bin"===t;return e("div",{className:I("edit-square border border-gray-300 rounded",A&&"bg-orange-300"),children:e("piece",{className:I("spare-piece",t,n,r&&"next-trash"),onClick:()=>{"function"==typeof o&&o({role:t,color:n})}})})},pA=({isOpen:n,hide:A,onPromote:o,color:r="white"})=>{const i=e=>{o(e),A()};return e(uA,{closeButton:"",isOpen:n,onClose:A,children:t("div",{className:"promote flex gap-2 py-1.5 justify-center",children:[e(hA,{color:r,role:"queen",selectPiece:()=>i("q")}),e(hA,{color:r,role:"rook",selectPiece:()=>i("r")}),e(hA,{color:r,role:"bishop",selectPiece:()=>i("b")}),e(hA,{color:r,role:"knight",selectPiece:()=>i("n")})]})})},gA=(e=!1)=>{const[t,n]=r(e);return{isOpen:t,show:()=>{n(!0)},hide:()=>{n(!1)},toggle:()=>{n(!t)}}};var dA="object"==typeof global&&global&&global.Object===Object&&global,mA="object"==typeof self&&self&&self.Object===Object&&self,fA=dA||mA||Function("return this")(),bA=fA.Symbol,yA=Object.prototype,IA=yA.hasOwnProperty,kA=yA.toString,wA=bA?bA.toStringTag:void 0;var CA=Object.prototype.toString;var vA=bA?bA.toStringTag:void 0;function SA(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":vA&&vA in Object(e)?function(e){var t=IA.call(e,wA),n=e[wA];try{e[wA]=void 0;var A=!0}catch(e){}var o=kA.call(e);return A&&(t?e[wA]=n:delete e[wA]),o}(e):function(e){return CA.call(e)}(e)}function EA(e){return null!=e&&"object"==typeof e}var VA=Array.isArray;function NA(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function MA(e){if(!NA(e))return!1;var t=SA(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var xA,BA=fA["__core-js_shared__"],DA=(xA=/[^.]+$/.exec(BA&&BA.keys&&BA.keys.IE_PROTO||""))?"Symbol(src)_1."+xA:"";var TA=Function.prototype.toString;function QA(e){if(null!=e){try{return TA.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var ZA=/^\[object .+?Constructor\]$/,jA=Function.prototype,PA=Object.prototype,UA=jA.toString,OA=PA.hasOwnProperty,qA=RegExp("^"+UA.call(OA).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function JA(e){return!(!NA(e)||(t=e,DA&&DA in t))&&(MA(e)?qA:ZA).test(QA(e));var t}function KA(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return JA(n)?n:void 0}var GA=KA(fA,"WeakMap");function RA(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var FA=Object.prototype;function LA(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||FA)}function zA(e){return EA(e)&&"[object Arguments]"==SA(e)}var WA=Object.prototype,YA=WA.hasOwnProperty,_A=WA.propertyIsEnumerable,HA=zA(function(){return arguments}())?zA:function(e){return EA(e)&&YA.call(e,"callee")&&!_A.call(e,"callee")};var XA="object"==typeof exports&&exports&&!exports.nodeType&&exports,$A=XA&&"object"==typeof module&&module&&!module.nodeType&&module,eo=$A&&$A.exports===XA?fA.Buffer:void 0,to=(eo?eo.isBuffer:void 0)||function(){return!1},no={};no["[object Float32Array]"]=no["[object Float64Array]"]=no["[object Int8Array]"]=no["[object Int16Array]"]=no["[object Int32Array]"]=no["[object Uint8Array]"]=no["[object Uint8ClampedArray]"]=no["[object Uint16Array]"]=no["[object Uint32Array]"]=!0,no["[object Arguments]"]=no["[object Array]"]=no["[object ArrayBuffer]"]=no["[object Boolean]"]=no["[object DataView]"]=no["[object Date]"]=no["[object Error]"]=no["[object Function]"]=no["[object Map]"]=no["[object Number]"]=no["[object Object]"]=no["[object RegExp]"]=no["[object Set]"]=no["[object String]"]=no["[object WeakMap]"]=!1;var Ao,oo="object"==typeof exports&&exports&&!exports.nodeType&&exports,ro=oo&&"object"==typeof module&&module&&!module.nodeType&&module,io=ro&&ro.exports===oo&&dA.process,so=function(){try{var e=ro&&ro.require&&ro.require("util").types;return e||io&&io.binding&&io.binding("util")}catch(e){}}(),ao=so&&so.isTypedArray,co=ao?(Ao=ao,function(e){return Ao(e)}):function(e){return EA(e)&&RA(e.length)&&!!no[SA(e)]};var lo=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),uo=lo,ho=Object.prototype.hasOwnProperty;var po=KA(fA,"Map"),go=KA(fA,"DataView"),mo=KA(fA,"Promise"),fo=KA(fA,"Set"),bo="[object Map]",yo="[object Promise]",Io="[object Set]",ko="[object WeakMap]",wo="[object DataView]",Co=QA(go),vo=QA(po),So=QA(mo),Eo=QA(fo),Vo=QA(GA),No=SA;(go&&No(new go(new ArrayBuffer(1)))!=wo||po&&No(new po)!=bo||mo&&No(mo.resolve())!=yo||fo&&No(new fo)!=Io||GA&&No(new GA)!=ko)&&(No=function(e){var t=SA(e),n="[object Object]"==t?e.constructor:void 0,A=n?QA(n):"";if(A)switch(A){case Co:return wo;case vo:return bo;case So:return yo;case Eo:return Io;case Vo:return ko}return t});var Mo=No,xo=Object.prototype.hasOwnProperty;function Bo(e){if(null==e)return!0;if(function(e){return null!=e&&RA(e.length)&&!MA(e)}(e)&&(VA(e)||"string"==typeof e||"function"==typeof e.splice||to(e)||co(e)||HA(e)))return!e.length;var t=Mo(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(LA(e))return!function(e){if(!LA(e))return uo(e);var t=[];for(var n in Object(e))ho.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e).length;for(var n in e)if(xo.call(e,n))return!1;return!0}const Do=e=>{const t={};e.orientation&&(t.orientation=e.orientation,"w"===t.orientation&&(t.orientation="white"),"b"===t.orientation&&(t.orientation="black"));const n=["shapes","onSelect","drawable","lastMove"];for(const A of n)e[A]&&!Bo(e[A])&&(t[A]=e[A]);return!1===e.drawable&&(t.drawable={enabled:!1}),t.shapes&&(t.shapes=(e=>{try{return e.forEach(e=>{e.dest=e.dest.replace(/\]/g,"")}),e}catch{return e}})(t.shapes)),e.editing&&(t.movable={free:!1},t.drawable={enabled:!1}),e.viewOnly&&(t.draggable=!1,t.movable={free:!1},t.drawable={enabled:!1}),e.readOnly&&(t.draggable=!1,t.movable={free:!1},t.drawable={enabled:!1},t.coordinates=!1),t},To=e=>tA(e)&&(e=>{if(!e)return!1;const t=e.split(" ")[0];return 1===(t.match(/k/g)||[]).length&&1===(t.match(/K/g)||[]).length})(e),Qo=(e,t,n=!1)=>{if(!To(e.fen()))return{free:!1};const A=new Map,o="w"===e.turn()?"white":"black";Zn.forEach(t=>{const n=e.moves({square:t,verbose:!0});n.length&&A.set(t,n.map(e=>e.to))});const r={color:o,dests:A,free:!1};return n&&t&&t!==o&&(r.color=t,r.dests=new Map),r},Zo=(n,A)=>{const{theme:o}=un(),{isOpen:r,show:i,hide:l}=gA(),{chess:h,fen:p,turnColor:g,lastMove:d,orientation:m,promotion:f,onMove:b,onPromote:y,onUndo:k}=cA(n),w=async(e,t,A)=>{const r=!0===A?.isPremove?A.promotion:f;return b(e,t,r)?(o.playSounds&&ln(o.sounds),"function"==typeof n.onMove&&await n.onMove(h),!0):!0!==A?.isPremove&&(i(),!1)},{onSetPremove:C,onUnsetPremove:v,onPlayPremove:S,onCancelPremove:E,onPremovePromotion:V}=(e=>{const t=a(null),n=c((e,n,A)=>{t.current={orig:e,dest:n,promotion:A?.promotion||null}},[]),A=c(()=>{t.current=null},[]),o=c(()=>"q",[]);return{onSetPremove:n,onUnsetPremove:A,onPlayPremove:c(async()=>{if(t.current){const{orig:n,dest:A,promotion:o}=t.current,r={orig:n,dest:A,promotion:o};t.current=null;const i={isPremove:!0,promotion:r.promotion||"q"};return await e(r.orig,r.dest,i)}return!1},[e]),onCancelPremove:c(()=>!!t.current&&(t.current=null,!0),[]),onPremovePromotion:o}})(w),N=a();u(A,()=>({board:N.current?.board,undo:k,move:b,playPremove:S,cancelPremove:E}));s(()=>{"function"==typeof n.setPromoting&&n.setPromoting(r)},[r]),s(()=>{"function"==typeof n.onFenChange&&n.onFenChange(p)},[p]);const M=n.premoves?{enabled:!0,showDests:!0,castle:!0,events:{set:C,unset:v},promote:V}:{enabled:!1};return t("div",{className:I("chessground",o.highlight&&"highlight",o.board,o.pieces),children:[e(an,{ref:N,coordinates:o.coordinates,onMove:w,fen:p,turnColor:g,lastMove:d,orientation:m,movable:Qo(h,m,n.premoves),premovable:M,...Do(n)}),e(pA,{isOpen:r,hide:l,color:g,onPromote:async e=>{if(!y(e))return!1;o.playSounds&&ln(o.sounds),"function"==typeof n.onMove&&await n.onMove(h)}})]})};var jo=l(Zo);const Po=e=>{try{return"w"===e.split(" ")[1]?"white":"black"}catch{return"white"}},Uo=e=>{const[t,n]=r((e=>{try{return e.orientation?e.orientation:e.fen?Po(e.fen):"white"}catch{return"white"}})(e));return s(()=>{e.reset&&n(Po(e.fen))},[e.reset]),[t,()=>{n(e=>"white"===e?"black":"white")}]},Oo=()=>{const{theme:A,handleChange:o}=un();return t(n,{children:[e("div",{children:"Board"}),t("select",{name:"board",className:"bg-white border border-gray-300 px-2 py-1.5 w-full text-gray-800 rounded",defaultValue:A.board,onChange:o,children:[e("option",{value:"green",children:"Green"}),e("option",{value:"brown",children:"Brown"}),e("option",{value:"ruby",children:"Ruby"}),e("option",{value:"purple",children:"Purple"}),e("option",{value:"teal",children:"Teal"})]})]})},qo=()=>{const{theme:A,handleChecked:o}=un();return t(n,{children:[e("div",{children:"Coordinates"}),e("div",{className:"flex",children:e("input",{name:"coordinates",type:"checkbox",className:"checkbox rounded border border-gray-300",defaultChecked:A.coordinates,onChange:o})})]})},Jo=()=>{const{theme:A,handleChecked:o}=un();return t(n,{children:[e("div",{children:"Highlight moves"}),e("div",{className:"flex",children:e("input",{name:"highlight",type:"checkbox",className:"checkbox rounded border border-gray-300",defaultChecked:A.highlight,onChange:o})})]})},Ko=()=>{const{theme:A,handleChange:o}=un();return t(n,{children:[e("div",{children:"Pieces"}),t("select",{name:"pieces",className:"bg-white border border-gray-300 px-2 py-1.5 w-full text-gray-800 rounded",defaultValue:A.pieces,onChange:o,children:[e("option",{value:"cburnett",children:"Cburnett"}),e("option",{value:"neo",children:"Neo"}),e("option",{value:"alpha",children:"Alpha"}),e("option",{value:"bases",children:"Bases"}),e("option",{value:"classic",children:"Classic"})]})]})},Go=()=>{const{theme:A,handleChecked:o}=un();return t(n,{children:[e("div",{children:"Play sounds"}),e("div",{className:"flex",children:e("input",{name:"playSounds",type:"checkbox",className:"checkbox rounded border border-gray-300",defaultChecked:A.playSounds,onChange:o})})]})},Ro=()=>{const{theme:A,handleChange:o}=un();return t(n,{children:[e("div",{children:"Sounds"}),t("select",{name:"sounds",className:"bg-white border border-gray-300 px-2 py-1.5 w-full text-gray-800 rounded",defaultValue:A.sounds,onChange:o,children:[e("option",{value:"robot",children:"Robot"}),e("option",{value:"piano",children:"Piano"}),e("option",{value:"lisp",children:"Lisp"}),e("option",{value:"sfx",children:"SFX"})]})]})},Fo=()=>{const{isOpen:A,show:o,hide:r}=gA();return t(n,{children:[e("button",{type:"button",className:"next-button next-settings",title:"Settings",onClick:o,children:e("i",{className:"next-cog"})}),e(uA,{header:"Settings",isOpen:A,onClose:r,children:t("div",{className:"grid grid-cols-2 gap-3 items-center text-sm",children:[e(Ko,{}),e(Oo,{}),e(Jo,{}),e(Go,{}),e(Ro,{}),e(qo,{})]})})]})},Lo=t=>e("button",{type:"button",className:"next-button next-flip",title:"Flip board",...t,children:e("i",{className:"next-sync"})}),zo=({flip:n,readOnly:A})=>A?null:t("div",{className:"chessground-footer text-gray-400 flex flex-row-reverse gap-2 py-1.5",children:[e(Fo,{}),e(Lo,{onClick:n})]});var Wo=l((n,A)=>{const[o,r]=Uo(n);return e(y,{children:t("div",{className:"next-chessground",children:[e(jo,{...n,ref:A,orientation:o}),e(zo,{flip:r,readOnly:n.readOnly})]})})});const Yo=t=>{const{theme:n}=un();return e("div",{className:I("spare-pieces flex gap-2",n.pieces),children:["bin","pawn","knight","bishop","rook","queen","king"].map(n=>((t,n)=>{const{color:A="white",selected:o={role:null,color:null}}=n,r=t===o.role&&A===o.color;return e(hA,{highlighted:r,role:t,color:A,...n},`${t}-${A}`)})(n,t))})},_o=e=>{const t=new Map;return t.set(e,null),t},Ho=({onChange:n})=>{const[A,o]=r("w"),[i,a]=r("-");s(()=>{"function"==typeof n&&n([A,i].join(" "))},[A,i]);const c=e=>{const{value:t}=e.target;o(t)},l=e=>{const{value:t}=e.target;a(((e,t)=>{if(!t)return e;const n=["K","Q","k","q"].map(n=>n!==t?e.includes(n)?n:"":e.includes(t)?"":t).join("");return n.length?n:"-"})(i,t))};return t("div",{className:"flex flex-col gap-2 w-full",children:[t("div",{className:"flex gap-2 w-full",children:[t("div",{children:[e("input",{defaultChecked:!0,className:"mx-1",type:"radio",id:"white-radio",name:"side-to-move",value:"w",onChange:c}),e("label",{htmlFor:"white-radio",children:"White to move"})]}),t("div",{children:[e("input",{className:"mx-1",type:"radio",id:"black-radio",name:"side-to-move",value:"b",onChange:c}),e("label",{htmlFor:"black-radio",children:"Black to move"})]})]}),t("div",{className:"flex flex-col gap-2 w-full",children:[t("div",{className:"flex w-full gap-4",children:[e("div",{children:e("span",{children:"White can"})}),t("div",{children:[e("input",{className:"mx-1",type:"checkbox",id:"white-short-castle",value:"K",onChange:l}),e("label",{htmlFor:"white-short-castle",children:"O-O"})]}),t("div",{children:[e("input",{className:"mx-1",type:"checkbox",id:"white-long-castle",value:"Q",onChange:l}),e("label",{htmlFor:"white-long-castle",children:"O-O-O"})]})]}),t("div",{className:"flex w-full gap-4",children:[e("div",{children:e("span",{children:"Black can"})}),t("div",{children:[e("input",{className:"mx-1",type:"checkbox",id:"black-short-castle",value:"k",onChange:l}),e("label",{htmlFor:"black-short-castle",children:"O-O"})]}),t("div",{children:[e("input",{className:"mx-1",type:"checkbox",id:"black-long-castle",value:"q",onChange:l}),e("label",{htmlFor:"black-long-castle",children:"O-O-O"})]})]})]})]})},Xo=(n,A)=>{const[o,i]=r(n.fen||aA.emptyFen),[a,c]=r({role:null,color:null});s(()=>{n.fen&&i(n.fen)},[n.fen]),s(()=>{"function"==typeof n.onSelect&&n.onSelect(o)},[o]);return e(y,{children:t("div",{className:"next-chessground gap-2",children:[e(Yo,{selected:a,selectPiece:c,color:"black"}),e(jo,{...n,ref:A,fen:o,onSelect:e=>{const t=o.split(" ");t.shift();const n=t.join(" "),r=((e,t,n)=>{if(!e)throw new Error("Chessground is not defined");if(!t||!t.role||!t.color)return e.getFen();if("bin"===t.role)return e.setPieces(_o(n)),e.getFen();const A=e.state.pieces.get(n);return A?A.role===t.role&&A.color===t.color?(e.setPieces(_o(n)),e.getFen()):(e.setPieces(_o(n)),e.newPiece(t,n),e.getFen()):(e.newPiece(t,n),e.getFen())})(A.current.board,a,e),s=[r,n].join(" ");i(s)},editing:!0}),e(Yo,{selected:a,selectPiece:c,color:"white"}),e(Ho,{onChange:e=>{const t=[o.split(" ")[0],e,"- 0 1"].join(" ");i(t)}})]})})};var $o=l(Xo);class er{constructor(e){if("undefined"==typeof window)return!1;if(!window.chessEngineWorker){const t=e??process.env.STOCKFISH_PATH;window.chessEngineWorker=new Worker(t)}this.skillLevel=20,this.maxDepth=40,this.resolveTimeout=null,this.isAnalyzing=!1,this.fen=aA.initialFen}getTurnFromFen(e){return e.split(" ")[1]}normalizeScoreValue(e){const{fen:t}=this;return"b"===this.getTurnFromFen(t)?-1*e:e}isInfoMessage(e){return!(!e||!e.data)&&e.data.startsWith("info")}setSkillLevel(){window.chessEngineWorker.postMessage("setoption name Skill Level value "+this.skillLevel),window.chessEngineWorker.postMessage("setoption name Skill Level Maximum Error value 5000"),window.chessEngineWorker.postMessage("setoption name Skill Level Probability value 1")}async init(){await this.use_uci(),await this.is_ready(),this.setSkillLevel()}getScoreFromInfo(e){if(e.startsWith("info depth 0")){const t=e.split(" "),n=t[4],A=this.normalizeScoreValue(Number(t[5]));return this.isAnalyzing=!1,{type:n,value:A}}if(e.startsWith("info depth ")){const t=e.split(" ");return{type:t[8],value:this.normalizeScoreValue(Number(t[9]))}}return{type:"cp",value:0}}parseData(e){const t=e.split(" ")[2];let n="";e.indexOf(" pv ")>-1&&(n=e.split(" pv ")[1].split(" bmc ")[0]);return{depth:t,pv:n,score:this.getScoreFromInfo(e)}}use_uci(){return new Promise(e=>{window.chessEngineWorker.postMessage("uci"),window.chessEngineWorker.onmessage=t=>{"uciok"===t.data&&e(t)}})}is_ready(){return new Promise(e=>{window.chessEngineWorker.postMessage("isready"),window.chessEngineWorker.onmessage=t=>{"readyok"===t.data&&e(t)}})}set_position(e){return new Promise(t=>{this.fen=e,window.chessEngineWorker.postMessage("position fen "+e),t()})}async new_position(e){await this.stop(),await this.is_ready(),this.set_position(e),this.go_infinite()}set_multipv(e){window.chessEngineWorker.postMessage("setoption name MultiPV value "+e)}get_score(e,t=15){return new Promise(n=>{window.chessEngineWorker.postMessage("position fen "+e),window.chessEngineWorker.postMessage("go depth 15"),window.chessEngineWorker.onmessage=e=>{if(e.data.startsWith("info depth "+t)){const t=e.data.split(" "),A=t[8],o=Number(t[9]);n({type:A,value:o})}else if(e.data.startsWith("info depth 0")){const t=e.data.split(" "),A=t[4],o=Number(t[5]);n({type:A,value:o})}}})}go_depth(e){return new Promise(t=>{window.chessEngineWorker.postMessage("go depth "+e),window.chessEngineWorker.onmessage=e=>{e.data.startsWith("bestmove")&&t(e.data)}})}go_time(e){return new Promise(t=>{window.chessEngineWorker.postMessage("go movetime "+e),window.chessEngineWorker.onmessage=e=>{e.data.startsWith("bestmove")&&t(e.data)}})}go_infinite(e){window.chessEngineWorker.postMessage("go infinite"),this.isAnalyzing=!0,window.chessEngineWorker.onmessage=t=>{if(this.isInfoMessage(t)&&"function"==typeof e){const n=this.parseData(t.data);n.depth>this.maxDepth&&this.stop(),e(n)}}}stop(){return new Promise(e=>{this.isAnalyzing||e(),window.chessEngineWorker.postMessage("stop"),window.chessEngineWorker.onmessage=t=>{t.data.startsWith("bestmove")&&(this.isAnalyzing=!1,e(t.data))}})}quit(){window.chessEngineWorker.postMessage("quit")}}function tr(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var A=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&A.firstChild?A.insertBefore(o,A.firstChild):A.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}tr(".brown .cg-wrap cg-board {\n background-image: url('data:image/svg+xml;base64,PHN2ZyAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgeG1sbnM6eD0iaHR0cDovL3d3dy53My5vcmcvM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9jQAbk8D4PY0AG5PA+D2NABuTwPg9jQAbk8D4PY0AG5PA+D2NABuTwPg9jQAbk8D4PY0AG5PA+D2NABuTwPg9jQAbk8D4PY0AG5PA+D2NABuTwPg9twPA74bHvA2fP+w9v3T3t9n5wE3IEM/PIDVn+B9g5h6GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwe64c4HHxABwbgNEBTAPcu7/9AeG6Ae7d3/43CBoA9zcIGgD3nxA0AO4/IWgA3P+HQAPg/j8EGgD1AHx0AA2AwdMAqAfggwNoABSeBkA9AO8fQAPg8DQA6gF49wAaAImnAVAPwHsH0ABYPA2AegDeOYAGQONpANQDcP4AGgCPpwFQD8DZA2gARJ4GQD0A5w6gATB5GgD1AJw5gAZA5WkA1APw9gAaAJenAVAPwJsDaABkngZAPQCvD6ABsHkaAPUAvDqABkDnaQDUA/DyABoAn6cBUA/AiwNoAISeBkA9AM8PoAEwehoA9QA8O4AGQOlpANQD8P8AGgCnpwFQD8C/A2gApJ4GQD0Afw+gAbB6GgD1APw5gAZA62kA1APw+wAaAK+nAXD/tiANgPu3BWkA3D8uSgPg/nFRGgD3rwvTALh/XZgGwO1pANyeBsDtfwE/g8u1a15o2AAAAABJRU5ErkJggg==');\n}\n.teal .cg-wrap cg-board {\n background-image: url('data:image/svg+xml;base64,CjxzdmcgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgIHhtbG5zOng9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiICB2aWV3Qm94PSIwIDAgOCA4IiAgc2hhcGUtcmVuZGVyaW5nPSJnZW9tZXRyaWNQcmVjaXNpb24iPjxyZWN0IHdpZHRoPSI4IiBoZWlnaHQ9IjgiIGZpbGw9IiMxYzcyYWQiLz48ZyBpZD0iYSI+ICA8ZyBpZD0iYiI+ICAgIDxnIGlkPSJjIj4gICAgICA8ZyBpZD0iZCI+ICAgICAgICA8cmVjdCB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSIjZTNlYmYzIiBpZD0iZSIvPiAgICAgICAgPHVzZSB4PSIyIiBocmVmPSIjZSIgeDpocmVmPSIjZSIvPiAgICAgIDwvZz4gICAgICA8dXNlIHg9IjQiIGhyZWY9IiNkIiB4OmhyZWY9IiNkIi8+ICAgIDwvZz4gICAgPHVzZSB4PSIxIiB5PSIxIiBocmVmPSIjYyIgeDpocmVmPSIjYyIvPiAgPC9nPiAgPHVzZSB5PSIyIiBocmVmPSIjYiIgeDpocmVmPSIjYiIvPjwvZz48dXNlIHk9IjQiIGhyZWY9IiNhIiB4OmhyZWY9IiNhIi8+PC9zdmc+');\n}\n");tr(".next-chessground .chessground {\n grid-area: board;\n position: relative;\n display: block;\n height: 0;\n padding-bottom: 100%;\n padding-right: 100%;\n width: 100%;\n border-radius: 0.25rem;\n overflow: hidden;\n}\n\n.next-chessground .cg-wrap {\n display: table;\n position: absolute;\n width: 100%;\n height: 100%;\n}\n\n.next-chessground cg-helper {\n position: absolute;\n width: 12.5%;\n padding-bottom: 12.5%;\n display: table;\n bottom: 0;\n}\n\n.next-chessground cg-container {\n position: absolute;\n width: 800%;\n height: 800%;\n display: block;\n bottom: 0;\n}\n\n.next-chessground cg-board {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n line-height: 0;\n background-size: cover;\n cursor: pointer;\n}\n\n.next-chessground cg-board square {\n position: absolute;\n top: 0;\n left: 0;\n width: 12.5%;\n height: 12.5%;\n pointer-events: none;\n}\n.next-chessground .highlight cg-board square.last-move {\n will-change: transform;\n background-color: rgba(246, 246, 130, 0.5);\n}\n.next-chessground .highlight .correct cg-board square.last-move {\n background-color: rgba(155, 240, 0, 0.4);\n}\n.next-chessground .highlight .incorrect cg-board square.last-move {\n background-color: rgba(240, 0, 0, 0.4);\n}\n\n.next-chessground cg-board square.check {\n background: radial-gradient(\n ellipse at center,\n rgba(255, 0, 0, 1) 0%,\n rgba(231, 0, 0, 1) 25%,\n rgba(169, 0, 0, 0) 89%,\n rgba(158, 0, 0, 0) 100%\n );\n}\n.next-chessground cg-board square.current-premove {\n background-color: rgba(20, 30, 85, 0.5);\n}\n.next-chessground cg-board piece {\n position: absolute;\n top: 0;\n left: 0;\n width: 12.5%;\n height: 12.5%;\n background-size: cover;\n z-index: 2;\n will-change: transform;\n pointer-events: none;\n}\n.next-chessground cg-board piece.dragging {\n cursor: move;\n z-index: 9;\n}\n.next-chessground cg-board piece.anim {\n z-index: 8;\n}\n.next-chessground cg-board piece.fading {\n z-index: 1;\n opacity: 0.5;\n}\n.next-chessground cg-board piece.ghost {\n opacity: 0.3;\n}\n.next-chessground .cg-wrap svg {\n overflow: hidden;\n position: relative;\n top: 0px;\n left: 0px;\n width: 100%;\n height: 100%;\n pointer-events: none;\n z-index: 2;\n opacity: 0.6;\n}\n.next-chessground .cg-wrap svg image {\n opacity: 0.5;\n}\n\n.next-chessground .spare-pieces {\n width: 100%;\n display: flex;\n justify-content: center;\n}\n.next-chessground .spare-piece {\n top: 0;\n left: 0;\n padding-bottom: 100%;\n padding-left: 100%;\n position: absolute;\n background-size: contain;\n background-position: 0% -100%;\n cursor: pointer;\n}\n.next-chessground .edit-square {\n display: table;\n position: relative;\n width: 14.285%;\n padding-bottom: 13.285%;\n}\n.next-chessground .promote .edit-square {\n width: 20%;\n padding-bottom: 20%;\n}\n");tr("coords {\n position: absolute;\n display: flex;\n pointer-events: none;\n user-select: none;\n color: #fff;\n font-weight: bold;\n font-size: 0.5rem;\n opacity: 0.8;\n}\n.coords-no coords {\n display: none;\n}\n@media (min-width: 640px) {\n coords {\n font-size: 0.75rem;\n }\n}\ncoords.ranks {\n flex-flow: column-reverse;\n top: 0;\n right: 0;\n height: 100%;\n width: 0.8em;\n}\ncoords.ranks.black {\n flex-flow: column;\n}\ncoords.files {\n bottom: 0;\n left: 0;\n flex-flow: row;\n width: 100%;\n}\ncoords.files.black {\n flex-flow: row-reverse;\n}\ncoords.files coord {\n padding-left: 4px;\n}\ncoords coord {\n flex: 1 1 auto;\n}\n\n.orientation-white .files coord:nth-child(2n + 1),\n.orientation-white .ranks coord:nth-child(2n),\n.orientation-black .files coord:nth-child(2n),\n.orientation-black .ranks coord:nth-child(2n + 1) {\n color: #fff;\n}\n.orientation-white .files coord:nth-child(2n),\n.orientation-white .ranks coord:nth-child(2n + 1),\n.orientation-black .files coord:nth-child(2n + 1),\n.orientation-black .ranks coord:nth-child(2n) {\n color: #779556;\n}\n");tr(".next-chessground .next-cog {\n width: 1rem;\n height: 1rem;\n background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjOUY5REIwIiBkPSJNNDg3LjQgMzE1LjdsLTQyLjYtMjQuNmM0LjMtMjMuMiA0LjMtNDcgMC03MC4ybDQyLjYtMjQuNmM0LjktMi44IDcuMS04LjYgNS41LTE0LTExLjEtMzUuNi0zMC02Ny44LTU0LjctOTQuNi0zLjgtNC4xLTEwLTUuMS0xNC44LTIuM0wzODAuOCAxMTBjLTE3LjktMTUuNC0zOC41LTI3LjMtNjAuOC0zNS4xVjI1LjhjMC01LjYtMy45LTEwLjUtOS40LTExLjctMzYuNy04LjItNzQuMy03LjgtMTA5LjIgMC01LjUgMS4yLTkuNCA2LjEtOS40IDExLjdWNzVjLTIyLjIgNy45LTQyLjggMTkuOC02MC44IDM1LjFMODguNyA4NS41Yy00LjktMi44LTExLTEuOS0xNC44IDIuMy0yNC43IDI2LjctNDMuNiA1OC45LTU0LjcgOTQuNi0xLjcgNS40LjYgMTEuMiA1LjUgMTRMNjcuMyAyMjFjLTQuMyAyMy4yLTQuMyA0NyAwIDcwLjJsLTQyLjYgMjQuNmMtNC45IDIuOC03LjEgOC42LTUuNSAxNCAxMS4xIDM1LjYgMzAgNjcuOCA1NC43IDk0LjYgMy44IDQuMSAxMCA1LjEgMTQuOCAyLjNsNDIuNi0yNC42YzE3LjkgMTUuNCAzOC41IDI3LjMgNjAuOCAzNS4xdjQ5LjJjMCA1LjYgMy45IDEwLjUgOS40IDExLjcgMzYuNyA4LjIgNzQuMyA3LjggMTA5LjIgMCA1LjUtMS4yIDkuNC02LjEgOS40LTExLjd2LTQ5LjJjMjIuMi03LjkgNDIuOC0xOS44IDYwLjgtMzUuMWw0Mi42IDI0LjZjNC45IDIuOCAxMSAxLjkgMTQuOC0yLjMgMjQuNy0yNi43IDQzLjYtNTguOSA1NC43LTk0LjYgMS41LTUuNS0uNy0xMS4zLTUuNi0xNC4xek0yNTYgMzM2Yy00NC4xIDAtODAtMzUuOS04MC04MHMzNS45LTgwIDgwLTgwIDgwIDM1LjkgODAgODAtMzUuOSA4MC04MCA4MHoiLz48L3N2Zz4=');\n}\n.next-chessground .next-sync {\n width: 1rem;\n height: 1rem;\n background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjOUY5REIwIiBkPSJNMzcwLjcyIDEzMy4yOEMzMzkuNDU4IDEwNC4wMDggMjk4Ljg4OCA4Ny45NjIgMjU1Ljg0OCA4OGMtNzcuNDU4LjA2OC0xNDQuMzI4IDUzLjE3OC0xNjIuNzkxIDEyNi44NS0xLjM0NCA1LjM2My02LjEyMiA5LjE1LTExLjY1MSA5LjE1SDI0LjEwM2MtNy40OTggMC0xMy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yaC0yNGExMiAxMiAwIDAgMC0xMiAxMnYyMTZhMTIgMTIgMCAwIDAgMTIgMTJ6TTQzMiA4MGgtODIuNDFsLTM0LTU2LjdBNDggNDggMCAwIDAgMjc0LjQxIDBIMTczLjU5YTQ4IDQ4IDAgMCAwLTQxLjE2IDIzLjNMOTguNDEgODBIMTZBMTYgMTYgMCAwIDAgMCA5NnYxNmExNiAxNiAwIDAgMCAxNiAxNmgxNnYzMzZhNDggNDggMCAwIDAgNDggNDhoMjg4YTQ4IDQ4IDAgMCAwIDQ4LTQ4VjEyOGgxNmExNiAxNiAwIDAgMCAxNi0xNlY5NmExNiAxNiAwIDAgMC0xNi0xNnpNMTcxLjg0IDUwLjkxQTYgNiAwIDAgMSAxNzcgNDhoOTRhNiA2IDAgMCAxIDUuMTUgMi45MUwyOTMuNjEgODBIMTU0LjM5ek0zNjggNDY0SDgwVjEyOGgyODh6bS0yMTItNDhoMjRhMTIgMTIgMCAwIDAgMTItMTJWMTg4YTEyIDEyIDAgMCAwLTEyLTEyaC0yNGExMiAxMiAwIDAgMC0xMiAxMnYyMTZhMTIgMTIgMCAwIDAgMTIgMTJ6Ii8+PC9zdmc+');\n}\n");tr("*,\n::after,\n::before {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n}\n\n.next-chessground {\n display: flex;\n flex-direction: column;\n position: relative;\n width: 100%;\n}\n.next-chessground .checkbox {\n display: flex;\n margin: 0;\n align-items: center;\n padding-left: 0.25rem;\n width: 2.75rem;\n height: 1.75rem;\n outline: none;\n appearance: none;\n transition: 0.2s ease-in-out;\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n cursor: pointer;\n}\n.next-chessground .checkbox:before {\n background-color: rgba(156, 163, 175);\n width: 1rem;\n height: 1rem;\n border-radius: 999px;\n content: '';\n transition: 0.2s ease-in-out;\n}\n.next-chessground .checkbox:checked:before {\n background-color: rgba(4, 120, 87);\n transform: translate(1rem, 0);\n}\n.next-chessground .next-button {\n background-color: transparent;\n background-image: none;\n cursor: pointer;\n display: flex;\n outline: none;\n\n padding: 0;\n line-height: inherit;\n color: inherit;\n font-size: 100%;\n}\n.next-chessground .next-button:focus {\n outline: none;\n}\n");tr(".pure-modal {\n box-shadow: rgba(0, 0, 0, 0.5) 0px 5px 15px 0px;\n color: rgba(55, 65, 81);\n}\n.pure-modal-backdrop {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 1040;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n.backdrop-overflow-hidden {\n overflow: hidden !important;\n}\n.pure-modal-backdrop .pure-modal {\n width: 300px;\n max-width: 100%;\n box-sizing: border-box;\n transition: all 0.2s ease-in-out;\n max-height: 100%;\n}\n.pure-modal.auto-height {\n position: static;\n}\n.pure-modal-backdrop.scrollable {\n overflow-y: auto;\n}\n.pure-modal-backdrop .panel {\n display: grid;\n grid-template-rows: repeat(3, min-content);\n}\n.pure-modal-backdrop:not(.scrollable) .panel {\n grid-template-rows: min-content minmax(0, 1fr) min-content;\n max-height: -moz-available;\n max-height: -webkit-fill-available;\n max-height: fill-available;\n height: 100%;\n}\n.pure-modal > * > * {\n flex: 0 0 auto;\n}\n.pure-modal > * > .scrollable {\n overflow-x: hidden;\n overflow-scrolling: touch;\n}\n@media (max-width: 480px) {\n .pure-modal-backdrop .pure-modal {\n width: 100%;\n }\n}\n.pure-modal .panel-body {\n background-color: #fff;\n}\n.pure-modal .panel-heading {\n background: #f0f0f0;\n}\n.pure-modal .panel-title {\n padding: 12px 45px 12px 15px;\n margin: 0;\n}\n.pure-modal .close {\n right: 6px;\n top: 6px;\n z-index: 1;\n width: 30px;\n height: 30px;\n border-radius: 15px;\n text-align: center;\n line-height: 30px;\n cursor: pointer;\n font-size: 1.85rem;\n}\n.pure-modal .panel-heading .close:hover {\n color: #000;\n}\n.pure-modal .panel-body {\n padding: 15px;\n}\n.pure-modal .panel-footer {\n padding: 12px 45px 12px 15px;\n background: #f0f0f0;\n}\n.pure-modal .panel-body,\n.pure-modal .panel-footer,\n.pure-modal .panel-title {\n word-break: break-all;\n}\n.pure-modal-backdrop .additional-row,\n.pure-modal-backdrop:not(.scrollable) .additional-row {\n display: grid;\n grid-template-rows: min-content minmax(0, 1fr) min-content min-content;\n}\n");tr("/**\n * Cburnett\n */\n.cburnett piece.pawn.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wP.svg');\n}\n.cburnett piece.bishop.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wB.svg');\n}\n.cburnett piece.knight.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wN.svg');\n}\n.cburnett piece.rook.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wR.svg');\n}\n.cburnett piece.queen.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wQ.svg');\n}\n.cburnett piece.king.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wK.svg');\n}\n.cburnett piece.pawn.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bP.svg');\n}\n.cburnett piece.bishop.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bB.svg');\n}\n.cburnett piece.knight.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bN.svg');\n}\n.cburnett piece.rook.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bR.svg');\n}\n.cburnett piece.queen.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bQ.svg');\n}\n.cburnett piece.king.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bK.svg');\n}\n\n/**\n * Classic\n */\n.classic piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wp.png');\n}\n.classic piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wb.png');\n}\n.classic piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wn.png');\n}\n.classic piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wr.png');\n}\n.classic piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wq.png');\n}\n.classic piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wk.png');\n}\n.classic piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bp.png');\n}\n.classic piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bb.png');\n}\n.classic piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bn.png');\n}\n.classic piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/br.png');\n}\n.classic piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bq.png');\n}\n.classic piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bk.png');\n}\n\n/**\n * Neo\n */\n.neo piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wp.png');\n}\n.neo piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wb.png');\n}\n.neo piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wn.png');\n}\n.neo piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wr.png');\n}\n.neo piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wq.png');\n}\n.neo piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wk.png');\n}\n.neo piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bp.png');\n}\n.neo piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bb.png');\n}\n.neo piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bn.png');\n}\n.neo piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/br.png');\n}\n.neo piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bq.png');\n}\n.neo piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bk.png');\n}\n\n/**\n * Alpha\n */\n.alpha piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wp.png');\n}\n.alpha piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wb.png');\n}\n.alpha piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wn.png');\n}\n.alpha piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wr.png');\n}\n.alpha piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wq.png');\n}\n.alpha piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wk.png');\n}\n.alpha piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bp.png');\n}\n.alpha piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bb.png');\n}\n.alpha piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bn.png');\n}\n.alpha piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/br.png');\n}\n.alpha piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bq.png');\n}\n.alpha piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bk.png');\n}\n\n/**\n * Bases\n */\n.bases piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wp.png');\n}\n.bases piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wb.png');\n}\n.bases piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wn.png');\n}\n.bases piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wr.png');\n}\n.bases piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wq.png');\n}\n.bases piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wk.png');\n}\n.bases piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bp.png');\n}\n.bases piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bb.png');\n}\n.bases piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bn.png');\n}\n.bases piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/br.png');\n}\n.bases piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bq.png');\n}\n.bases piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bk.png');\n}\n");tr(".flex {\n display: flex;\n}\n.flex-col {\n flex-direction: column;\n}\n.flex-row-reverse {\n flex-direction: row-reverse;\n}\n.grid {\n display: grid;\n}\n.grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n.gap-2 {\n gap: 0.5rem;\n}\n.gap-3 {\n gap: 0.75rem;\n}\n.w-full {\n width: 100%;\n}\n.items-center {\n align-items: center;\n}\n.justify-center {\n justify-content: center;\n}\n.py-1\\.5 {\n padding-top: 0.375rem;\n padding-bottom: 0.375rem;\n}\n.px-2 {\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n}\n.cursor-pointer {\n cursor: pointer;\n}\n.cursor-resize {\n cursor: nesw-resize;\n}\n.outline-none,\n.outline-none:focus {\n outline: none;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-gray-400 {\n color: rgba(156, 163, 175);\n}\n.text-gray-800 {\n color: rgba(31, 41, 55);\n}\n.bg-white {\n background-color: #fff;\n}\n.bg-orange-300 {\n background-color: #fbd38d;\n}\n.border {\n border-width: 1px;\n border-style: solid;\n}\n.border-gray-300 {\n border-color: rgba(209, 213, 219);\n}\n.rounded {\n border-radius: 0.25rem;\n}\n");export{Wo as NextChessground,$o as NextEditor,er as Stockfish,aA as constants,Wo as default,To as isValidFen,cA as useChess,un as useChessground};
|
package/dist/index.js
CHANGED
|
@@ -32,4 +32,4 @@
|
|
|
32
32
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
33
33
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
34
34
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
35
|
-
*/!function(e,t){function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n}(on,Error),on.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var n,A=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){A=e[n].text.split(/\r\n|\n|\r/g);break}var o=this.location.start,r=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(o):o,i=this.location.source+":"+r.line+":"+r.column;if(A){var s=this.location.end,a=rn("",r.line.toString().length," "),c=A[o.line-1],l=(o.line===s.line?s.column:c.length+1)-o.column||1;t+="\n --\x3e "+i+"\n"+a+" |\n"+r.line+" | "+c+"\n"+a+" | "+rn("",o.column-1," ")+rn("",l,"^")}else t+="\n at "+i}return t},on.buildMessage=function(e,t){var n={literal:function(e){return'"'+o(e.text)+'"'},class:function(e){var t=e.parts.map(function(e){return Array.isArray(e)?r(e[0])+"-"+r(e[1]):r(e)});return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function A(e){return e.charCodeAt(0).toString(16).toUpperCase()}function o(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+A(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+A(e)})}function r(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+A(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+A(e)})}function i(e){return n[e.type](e)}return"Expected "+function(e){var t,n,A=e.map(i);if(A.sort(),A.length>0){for(t=1,n=1;t<A.length;t++)A[t-1]!==A[t]&&(A[n]=A[t],n++);A.length=n}switch(A.length){case 1:return A[0];case 2:return A[0]+" or "+A[1];default:return A.slice(0,-1).join(", ")+", or "+A[A.length-1]}}(e)+" but "+function(e){return e?'"'+o(e)+'"':"end of input"}(t)+" found."};const an=0xffffffffffffffffn;function cn(e,t){return 0xffffffffffffffffn&(e<<t|e>>64n-t)}function ln(e,t){return e*t&an}const un=(hn=0xa187eb39cdcaed8f31c4b365b102e01en,function(){let e=BigInt(hn&an),t=BigInt(hn>>64n&an);const n=ln(cn(ln(e,5n),7n),9n);return t^=e,e=(cn(e,24n)^t^t<<16n)&an,t=cn(t,37n),hn=t<<64n|e,n});var hn;const pn=Array.from({length:2},()=>Array.from({length:6},()=>Array.from({length:128},()=>un()))),gn=Array.from({length:8},()=>un()),dn=Array.from({length:16},()=>un()),mn=un(),fn="w",bn="b",yn="p",In="b",kn="r",wn="q",Cn="k",vn="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";class Sn{color;from;to;piece;captured;promotion;flags;san;lan;before;after;constructor(e,t){const{color:n,piece:A,from:o,to:r,flags:i,captured:s,promotion:a}=t,c=Ln(o),l=Ln(r);this.color=n,this.piece=A,this.from=c,this.to=l,this.san=e._moveToSan(t,e._moves({legal:!0})),this.lan=c+l,this.before=e.fen(),e._makeMove(t),this.after=e.fen(),e._undoMove(),this.flags="";for(const e in Nn)Nn[e]&i&&(this.flags+=xn[e]);s&&(this.captured=s),a&&(this.promotion=a,this.lan+=a)}isCapture(){return this.flags.indexOf(xn.CAPTURE)>-1}isPromotion(){return this.flags.indexOf(xn.PROMOTION)>-1}isEnPassant(){return this.flags.indexOf(xn.EP_CAPTURE)>-1}isKingsideCastle(){return this.flags.indexOf(xn.KSIDE_CASTLE)>-1}isQueensideCastle(){return this.flags.indexOf(xn.QSIDE_CASTLE)>-1}isBigPawn(){return this.flags.indexOf(xn.BIG_PAWN)>-1}}const En=-1,xn={NORMAL:"n",CAPTURE:"c",BIG_PAWN:"b",EP_CAPTURE:"e",PROMOTION:"p",KSIDE_CASTLE:"k",QSIDE_CASTLE:"q",NULL_MOVE:"-"},Vn=["a8","b8","c8","d8","e8","f8","g8","h8","a7","b7","c7","d7","e7","f7","g7","h7","a6","b6","c6","d6","e6","f6","g6","h6","a5","b5","c5","d5","e5","f5","g5","h5","a4","b4","c4","d4","e4","f4","g4","h4","a3","b3","c3","d3","e3","f3","g3","h3","a2","b2","c2","d2","e2","f2","g2","h2","a1","b1","c1","d1","e1","f1","g1","h1"],Nn={NORMAL:1,CAPTURE:2,BIG_PAWN:4,EP_CAPTURE:8,PROMOTION:16,KSIDE_CASTLE:32,QSIDE_CASTLE:64,NULL_MOVE:128},Mn={Event:"?",Site:"?",Date:"????.??.??",Round:"?",White:"?",Black:"?",Result:"*"},Bn={...Mn,WhiteTitle:null,BlackTitle:null,WhiteElo:null,BlackElo:null,WhiteUSCF:null,BlackUSCF:null,WhiteNA:null,BlackNA:null,WhiteType:null,BlackType:null,EventDate:null,EventSponsor:null,Section:null,Stage:null,Board:null,Opening:null,Variation:null,SubVariation:null,ECO:null,NIC:null,Time:null,UTCTime:null,UTCDate:null,TimeControl:null,SetUp:null,FEN:null,Termination:null,Annotator:null,Mode:null,PlyCount:null},jn={a8:0,b8:1,c8:2,d8:3,e8:4,f8:5,g8:6,h8:7,a7:16,b7:17,c7:18,d7:19,e7:20,f7:21,g7:22,h7:23,a6:32,b6:33,c6:34,d6:35,e6:36,f6:37,g6:38,h6:39,a5:48,b5:49,c5:50,d5:51,e5:52,f5:53,g5:54,h5:55,a4:64,b4:65,c4:66,d4:67,e4:68,f4:69,g4:70,h4:71,a3:80,b3:81,c3:82,d3:83,e3:84,f3:85,g3:86,h3:87,a2:96,b2:97,c2:98,d2:99,e2:100,f2:101,g2:102,h2:103,a1:112,b1:113,c1:114,d1:115,e1:116,f1:117,g1:118,h1:119},Dn={b:[16,32,17,15],w:[-16,-32,-17,-15]},Tn={n:[-18,-33,-31,-14,18,33,31,14],b:[-17,-15,17,15],r:[-16,1,16,-1],q:[-17,-16,-15,1,17,16,15,-1],k:[-17,-16,-15,1,17,16,15,-1]},Qn=[20,0,0,0,0,0,0,24,0,0,0,0,0,0,20,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,24,24,24,24,24,24,56,0,56,24,24,24,24,24,24,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,20,0,0,0,0,0,0,24,0,0,0,0,0,0,20],Zn=[17,0,0,0,0,0,0,16,0,0,0,0,0,0,15,0,0,17,0,0,0,0,0,16,0,0,0,0,0,15,0,0,0,0,17,0,0,0,0,16,0,0,0,0,15,0,0,0,0,0,0,17,0,0,0,16,0,0,0,15,0,0,0,0,0,0,0,0,17,0,0,16,0,0,15,0,0,0,0,0,0,0,0,0,0,17,0,16,0,15,0,0,0,0,0,0,0,0,0,0,0,0,17,16,15,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,-15,-16,-17,0,0,0,0,0,0,0,0,0,0,0,0,-15,0,-16,0,-17,0,0,0,0,0,0,0,0,0,0,-15,0,0,-16,0,0,-17,0,0,0,0,0,0,0,0,-15,0,0,0,-16,0,0,0,-17,0,0,0,0,0,0,-15,0,0,0,0,-16,0,0,0,0,-17,0,0,0,0,-15,0,0,0,0,0,-16,0,0,0,0,0,-17,0,0,-15,0,0,0,0,0,0,-16,0,0,0,0,0,0,-17],Pn={p:1,n:2,b:4,r:8,q:16,k:32},On=["n",In,kn,wn],Un={[Cn]:Nn.KSIDE_CASTLE,[wn]:Nn.QSIDE_CASTLE},qn={w:[{square:jn.a1,flag:Nn.QSIDE_CASTLE},{square:jn.h1,flag:Nn.KSIDE_CASTLE}],b:[{square:jn.a8,flag:Nn.QSIDE_CASTLE},{square:jn.h8,flag:Nn.KSIDE_CASTLE}]},Jn={b:1,w:6},Kn="--";function Gn(e){return e>>4}function Rn(e){return 15&e}function Fn(e){return-1!=="0123456789".indexOf(e)}function Ln(e){const t=Rn(e),n=Gn(e);return"abcdefgh".substring(t,t+1)+"87654321".substring(n,n+1)}function zn(e){return e===fn?bn:fn}function Wn(e){const t=e.split(/\s+/);if(6!==t.length)return{ok:!1,error:"Invalid FEN: must contain six space-delimited fields"};const n=parseInt(t[5],10);if(isNaN(n)||n<=0)return{ok:!1,error:"Invalid FEN: move number must be a positive integer"};const A=parseInt(t[4],10);if(isNaN(A)||A<0)return{ok:!1,error:"Invalid FEN: half move counter number must be a non-negative integer"};if(!/^(-|[abcdefgh][36])$/.test(t[3]))return{ok:!1,error:"Invalid FEN: en-passant square is invalid"};if(/[^kKqQ-]/.test(t[2]))return{ok:!1,error:"Invalid FEN: castling availability is invalid"};if(!/^(w|b)$/.test(t[1]))return{ok:!1,error:"Invalid FEN: side-to-move is invalid"};const o=t[0].split("/");if(8!==o.length)return{ok:!1,error:"Invalid FEN: piece data does not contain 8 '/'-delimited rows"};for(let e=0;e<o.length;e++){let t=0,n=!1;for(let A=0;A<o[e].length;A++)if(Fn(o[e][A])){if(n)return{ok:!1,error:"Invalid FEN: piece data is invalid (consecutive number)"};t+=parseInt(o[e][A],10),n=!0}else{if(!/^[prnbqkPRNBQK]$/.test(o[e][A]))return{ok:!1,error:"Invalid FEN: piece data is invalid (invalid piece)"};t+=1,n=!1}if(8!==t)return{ok:!1,error:"Invalid FEN: piece data is invalid (too many squares in rank)"}}if("3"==t[3][1]&&"w"==t[1]||"6"==t[3][1]&&"b"==t[1])return{ok:!1,error:"Invalid FEN: illegal en-passant square"};const r=[{color:"white",regex:/K/g},{color:"black",regex:/k/g}];for(const{color:e,regex:n}of r){if(!n.test(t[0]))return{ok:!1,error:`Invalid FEN: missing ${e} king`};if((t[0].match(n)||[]).length>1)return{ok:!1,error:`Invalid FEN: too many ${e} kings`}}return Array.from(o[0]+o[7]).some(e=>"P"===e.toUpperCase())?{ok:!1,error:"Invalid FEN: some pawns are on the edge rows"}:{ok:!0}}function Yn(e,t,n,A,o,r=void 0,i=Nn.NORMAL){const s=Gn(A);if(o!==yn||7!==s&&0!==s)e.push({color:t,from:n,to:A,piece:o,captured:r,flags:i});else for(let s=0;s<On.length;s++){const a=On[s];e.push({color:t,from:n,to:A,piece:o,captured:r,promotion:a,flags:i|Nn.PROMOTION})}}function _n(e){let t=e.charAt(0);if(t>="a"&&t<="h"){if(e.match(/[a-h]\d.*[a-h]\d/))return;return yn}return t=t.toLowerCase(),"o"===t?Cn:t}function Hn(e){return e.replace(/=/,"").replace(/[+#]?[?!]*$/,"")}class Xn{_board=new Array(128);_turn=fn;_header={};_kings={w:En,b:En};_epSquare=-1;_halfMoves=0;_moveNumber=0;_history=[];_comments={};_castling={w:0,b:0};_hash=0n;_positionCount=new Map;constructor(e=vn,{skipValidation:t=!1}={}){this.load(e,{skipValidation:t})}clear({preserveHeaders:e=!1}={}){this._board=new Array(128),this._kings={w:En,b:En},this._turn=fn,this._castling={w:0,b:0},this._epSquare=En,this._halfMoves=0,this._moveNumber=1,this._history=[],this._comments={},this._header=e?this._header:{...Bn},this._hash=this._computeHash(),this._positionCount=new Map,this._header.SetUp=null,this._header.FEN=null}load(e,{skipValidation:t=!1,preserveHeaders:n=!1}={}){let A=e.split(/\s+/);if(A.length>=2&&A.length<6){const t=["-","-","0","1"];e=A.concat(t.slice(-(6-A.length))).join(" ")}if(A=e.split(/\s+/),!t){const{ok:t,error:n}=Wn(e);if(!t)throw new Error(n)}const o=A[0];let r=0;this.clear({preserveHeaders:n});for(let e=0;e<o.length;e++){const t=o.charAt(e);if("/"===t)r+=8;else if(Fn(t))r+=parseInt(t,10);else{const e=t<"a"?fn:bn;this._put({type:t.toLowerCase(),color:e},Ln(r)),r++}}this._turn=A[1],A[2].indexOf("K")>-1&&(this._castling.w|=Nn.KSIDE_CASTLE),A[2].indexOf("Q")>-1&&(this._castling.w|=Nn.QSIDE_CASTLE),A[2].indexOf("k")>-1&&(this._castling.b|=Nn.KSIDE_CASTLE),A[2].indexOf("q")>-1&&(this._castling.b|=Nn.QSIDE_CASTLE),this._epSquare="-"===A[3]?En:jn[A[3]],this._halfMoves=parseInt(A[4],10),this._moveNumber=parseInt(A[5],10),this._hash=this._computeHash(),this._updateSetup(e),this._incPositionCount()}fen({forceEnpassantSquare:e=!1}={}){let t=0,n="";for(let e=jn.a8;e<=jn.h1;e++){if(this._board[e]){t>0&&(n+=t,t=0);const{color:A,type:o}=this._board[e];n+=A===fn?o.toUpperCase():o.toLowerCase()}else t++;e+1&136&&(t>0&&(n+=t),e!==jn.h1&&(n+="/"),t=0,e+=8)}let A="";this._castling[fn]&Nn.KSIDE_CASTLE&&(A+="K"),this._castling[fn]&Nn.QSIDE_CASTLE&&(A+="Q"),this._castling[bn]&Nn.KSIDE_CASTLE&&(A+="k"),this._castling[bn]&Nn.QSIDE_CASTLE&&(A+="q"),A=A||"-";let o="-";if(this._epSquare!==En)if(e)o=Ln(this._epSquare);else{const e=this._epSquare+(this._turn===fn?16:-16),t=[e+1,e-1];for(const e of t){if(136&e)continue;const t=this._turn;if(this._board[e]?.color===t&&this._board[e]?.type===yn){this._makeMove({color:t,from:e,to:this._epSquare,piece:yn,captured:yn,flags:Nn.EP_CAPTURE});const n=!this._isKingAttacked(t);if(this._undoMove(),n){o=Ln(this._epSquare);break}}}}return[n,this._turn,A,o,this._halfMoves,this._moveNumber].join(" ")}_pieceKey(e){if(!this._board[e])return 0n;const{color:t,type:n}=this._board[e],A={p:0,n:1,b:2,r:3,q:4,k:5}[n];return pn[{w:0,b:1}[t]][A][e]}_epKey(){return this._epSquare===En?0n:gn[7&this._epSquare]}_castlingKey(){const e=this._castling.w>>5|this._castling.b>>3;return dn[e]}_computeHash(){let e=0n;for(let t=jn.a8;t<=jn.h1;t++)136&t?t+=7:this._board[t]&&(e^=this._pieceKey(t));return e^=this._epKey(),e^=this._castlingKey(),"b"===this._turn&&(e^=mn),e}_updateSetup(e){this._history.length>0||(e!==vn?(this._header.SetUp="1",this._header.FEN=e):(this._header.SetUp=null,this._header.FEN=null))}reset(){this.load(vn)}get(e){return this._board[jn[e]]}findPiece(e){const t=[];for(let n=jn.a8;n<=jn.h1;n++)136&n?n+=7:this._board[n]&&this._board[n]?.color===e.color&&this._board[n].color===e.color&&this._board[n].type===e.type&&t.push(Ln(n));return t}put({type:e,color:t},n){return!!this._put({type:e,color:t},n)&&(this._updateCastlingRights(),this._updateEnPassantSquare(),this._updateSetup(this.fen()),!0)}_set(e,t){this._hash^=this._pieceKey(e),this._board[e]=t,this._hash^=this._pieceKey(e)}_put({type:e,color:t},n){if(-1==="pnbrqkPNBRQK".indexOf(e.toLowerCase()))return!1;if(!(n in jn))return!1;const A=jn[n];if(e==Cn&&this._kings[t]!=En&&this._kings[t]!=A)return!1;const o=this._board[A];return o&&o.type===Cn&&(this._kings[o.color]=En),this._set(A,{type:e,color:t}),e===Cn&&(this._kings[t]=A),!0}_clear(e){this._hash^=this._pieceKey(e),delete this._board[e]}remove(e){const t=this.get(e);return this._clear(jn[e]),t&&t.type===Cn&&(this._kings[t.color]=En),this._updateCastlingRights(),this._updateEnPassantSquare(),this._updateSetup(this.fen()),t}_updateCastlingRights(){this._hash^=this._castlingKey();const e=this._board[jn.e1]?.type===Cn&&this._board[jn.e1]?.color===fn,t=this._board[jn.e8]?.type===Cn&&this._board[jn.e8]?.color===bn;e&&this._board[jn.a1]?.type===kn&&this._board[jn.a1]?.color===fn||(this._castling.w&=-65),e&&this._board[jn.h1]?.type===kn&&this._board[jn.h1]?.color===fn||(this._castling.w&=-33),t&&this._board[jn.a8]?.type===kn&&this._board[jn.a8]?.color===bn||(this._castling.b&=-65),t&&this._board[jn.h8]?.type===kn&&this._board[jn.h8]?.color===bn||(this._castling.b&=-33),this._hash^=this._castlingKey()}_updateEnPassantSquare(){if(this._epSquare===En)return;const e=this._epSquare+(this._turn===fn?-16:16),t=this._epSquare+(this._turn===fn?16:-16),n=[t+1,t-1];if(null!==this._board[e]||null!==this._board[this._epSquare]||this._board[t]?.color!==zn(this._turn)||this._board[t]?.type!==yn)return this._hash^=this._epKey(),void(this._epSquare=En);n.some(e=>!(136&e)&&this._board[e]?.color===this._turn&&this._board[e]?.type===yn)||(this._hash^=this._epKey(),this._epSquare=En)}_attacked(e,t,n){const A=[];for(let o=jn.a8;o<=jn.h1;o++){if(136&o){o+=7;continue}if(void 0===this._board[o]||this._board[o].color!==e)continue;const r=this._board[o],i=o-t;if(0===i)continue;const s=i+119;if(Qn[s]&Pn[r.type]){if(r.type===yn){if(i>0&&r.color===fn||i<=0&&r.color===bn){if(!n)return!0;A.push(Ln(o))}continue}if("n"===r.type||"k"===r.type){if(n){A.push(Ln(o));continue}return!0}const e=Zn[s];let a=o+e,c=!1;for(;a!==t;){if(null!=this._board[a]){c=!0;break}a+=e}if(!c){if(n){A.push(Ln(o));continue}return!0}}}return!!n&&A}attackers(e,t){return t?this._attacked(t,jn[e],!0):this._attacked(this._turn,jn[e],!0)}_isKingAttacked(e){const t=this._kings[e];return-1!==t&&this._attacked(zn(e),t)}hash(){return this._hash.toString(16)}isAttacked(e,t){return this._attacked(t,jn[e])}isCheck(){return this._isKingAttacked(this._turn)}inCheck(){return this.isCheck()}isCheckmate(){return this.isCheck()&&0===this._moves().length}isStalemate(){return!this.isCheck()&&0===this._moves().length}isInsufficientMaterial(){const e={b:0,n:0,r:0,q:0,k:0,p:0},t=[];let n=0,A=0;for(let o=jn.a8;o<=jn.h1;o++){if(A=(A+1)%2,136&o){o+=7;continue}const r=this._board[o];r&&(e[r.type]=r.type in e?e[r.type]+1:1,r.type===In&&t.push(A),n++)}if(2===n)return!0;if(3===n&&(1===e[In]||1===e.n))return!0;if(n===e[In]+2){let e=0;const n=t.length;for(let A=0;A<n;A++)e+=t[A];if(0===e||e===n)return!0}return!1}isThreefoldRepetition(){return this._getPositionCount(this._hash)>=3}isDrawByFiftyMoves(){return this._halfMoves>=100}isDraw(){return this.isDrawByFiftyMoves()||this.isStalemate()||this.isInsufficientMaterial()||this.isThreefoldRepetition()}isGameOver(){return this.isCheckmate()||this.isDraw()}moves({verbose:e=!1,square:t,piece:n}={}){const A=this._moves({square:t,piece:n});return e?A.map(e=>new Sn(this,e)):A.map(e=>this._moveToSan(e,A))}_moves({legal:e=!0,piece:t,square:n}={}){const A=n?n.toLowerCase():void 0,o=t?.toLowerCase(),r=[],i=this._turn,s=zn(i);let a=jn.a8,c=jn.h1,l=!1;if(A){if(!(A in jn))return[];a=c=jn[A],l=!0}for(let e=a;e<=c;e++){if(136&e){e+=7;continue}if(!this._board[e]||this._board[e].color===s)continue;const{type:t}=this._board[e];let n;if(t===yn){if(o&&o!==t)continue;n=e+Dn[i][0],this._board[n]||(Yn(r,i,e,n,yn),n=e+Dn[i][1],Jn[i]!==Gn(e)||this._board[n]||Yn(r,i,e,n,yn,void 0,Nn.BIG_PAWN));for(let t=2;t<4;t++)n=e+Dn[i][t],136&n||(this._board[n]?.color===s?Yn(r,i,e,n,yn,this._board[n].type,Nn.CAPTURE):n===this._epSquare&&Yn(r,i,e,n,yn,yn,Nn.EP_CAPTURE))}else{if(o&&o!==t)continue;for(let A=0,o=Tn[t].length;A<o;A++){const o=Tn[t][A];for(n=e;n+=o,!(136&n);){if(this._board[n]){if(this._board[n].color===i)break;Yn(r,i,e,n,t,this._board[n].type,Nn.CAPTURE);break}if(Yn(r,i,e,n,t),"n"===t||t===Cn)break}}}}if(!(void 0!==o&&o!==Cn||l&&c!==this._kings[i])){if(this._castling[i]&Nn.KSIDE_CASTLE){const e=this._kings[i],t=e+2;this._board[e+1]||this._board[t]||this._attacked(s,this._kings[i])||this._attacked(s,e+1)||this._attacked(s,t)||Yn(r,i,this._kings[i],t,Cn,void 0,Nn.KSIDE_CASTLE)}if(this._castling[i]&Nn.QSIDE_CASTLE){const e=this._kings[i],t=e-2;this._board[e-1]||this._board[e-2]||this._board[e-3]||this._attacked(s,this._kings[i])||this._attacked(s,e-1)||this._attacked(s,t)||Yn(r,i,this._kings[i],t,Cn,void 0,Nn.QSIDE_CASTLE)}}if(!e||-1===this._kings[i])return r;const u=[];for(let e=0,t=r.length;e<t;e++)this._makeMove(r[e]),this._isKingAttacked(i)||u.push(r[e]),this._undoMove();return u}move(e,{strict:t=!1}={}){let n=null;if("string"==typeof e)n=this._moveFromSan(e,t);else if(null===e)n=this._moveFromSan(Kn,t);else if("object"==typeof e){const t=this._moves();for(let A=0,o=t.length;A<o;A++)if(e.from===Ln(t[A].from)&&e.to===Ln(t[A].to)&&(!("promotion"in t[A])||e.promotion===t[A].promotion)){n=t[A];break}}if(!n)throw"string"==typeof e?new Error(`Invalid move: ${e}`):new Error(`Invalid move: ${JSON.stringify(e)}`);if(this.isCheck()&&n.flags&Nn.NULL_MOVE)throw new Error("Null move not allowed when in check");const A=new Sn(this,n);return this._makeMove(n),this._incPositionCount(),A}_push(e){this._history.push({move:e,kings:{b:this._kings.b,w:this._kings.w},turn:this._turn,castling:{b:this._castling.b,w:this._castling.w},epSquare:this._epSquare,halfMoves:this._halfMoves,moveNumber:this._moveNumber})}_movePiece(e,t){this._hash^=this._pieceKey(e),this._board[t]=this._board[e],delete this._board[e],this._hash^=this._pieceKey(t)}_makeMove(e){const t=this._turn,n=zn(t);if(this._push(e),e.flags&Nn.NULL_MOVE)return t===bn&&this._moveNumber++,this._halfMoves++,this._turn=n,void(this._epSquare=En);if(this._hash^=this._epKey(),this._hash^=this._castlingKey(),e.captured&&(this._hash^=this._pieceKey(e.to)),this._movePiece(e.from,e.to),e.flags&Nn.EP_CAPTURE&&(this._turn===bn?this._clear(e.to-16):this._clear(e.to+16)),e.promotion&&(this._clear(e.to),this._set(e.to,{type:e.promotion,color:t})),this._board[e.to].type===Cn){if(this._kings[t]=e.to,e.flags&Nn.KSIDE_CASTLE){const t=e.to-1,n=e.to+1;this._movePiece(n,t)}else if(e.flags&Nn.QSIDE_CASTLE){const t=e.to+1,n=e.to-2;this._movePiece(n,t)}this._castling[t]=0}if(this._castling[t])for(let n=0,A=qn[t].length;n<A;n++)if(e.from===qn[t][n].square&&this._castling[t]&qn[t][n].flag){this._castling[t]^=qn[t][n].flag;break}if(this._castling[n])for(let t=0,A=qn[n].length;t<A;t++)if(e.to===qn[n][t].square&&this._castling[n]&qn[n][t].flag){this._castling[n]^=qn[n][t].flag;break}if(this._hash^=this._castlingKey(),e.flags&Nn.BIG_PAWN){let A;A=t===bn?e.to-16:e.to+16,(e.to-1&136||this._board[e.to-1]?.type!==yn||this._board[e.to-1]?.color!==n)&&(e.to+1&136||this._board[e.to+1]?.type!==yn||this._board[e.to+1]?.color!==n)?this._epSquare=En:(this._epSquare=A,this._hash^=this._epKey())}else this._epSquare=En;e.piece===yn||e.flags&(Nn.CAPTURE|Nn.EP_CAPTURE)?this._halfMoves=0:this._halfMoves++,t===bn&&this._moveNumber++,this._turn=n,this._hash^=mn}undo(){const e=this._hash,t=this._undoMove();if(t){const n=new Sn(this,t);return this._decPositionCount(e),n}return null}_undoMove(){const e=this._history.pop();if(void 0===e)return null;this._hash^=this._epKey(),this._hash^=this._castlingKey();const t=e.move;this._kings=e.kings,this._turn=e.turn,this._castling=e.castling,this._epSquare=e.epSquare,this._halfMoves=e.halfMoves,this._moveNumber=e.moveNumber,this._hash^=this._epKey(),this._hash^=this._castlingKey(),this._hash^=mn;const n=this._turn,A=zn(n);if(t.flags&Nn.NULL_MOVE)return t;if(this._movePiece(t.to,t.from),t.piece&&(this._clear(t.from),this._set(t.from,{type:t.piece,color:n})),t.captured)if(t.flags&Nn.EP_CAPTURE){let e;e=n===bn?t.to-16:t.to+16,this._set(e,{type:yn,color:A})}else this._set(t.to,{type:t.captured,color:A});if(t.flags&(Nn.KSIDE_CASTLE|Nn.QSIDE_CASTLE)){let e,n;t.flags&Nn.KSIDE_CASTLE?(e=t.to+1,n=t.to-1):(e=t.to-2,n=t.to+1),this._movePiece(n,e)}return t}pgn({newline:e="\n",maxWidth:t=0}={}){const n=[];let A=!1;for(const t in this._header){this._header[t]&&n.push(`[${t} "${this._header[t]}"]`+e),A=!0}A&&this._history.length&&n.push(e);const o=e=>{const t=this._comments[this.fen()];if(void 0!==t){e=`${e}${e.length>0?" ":""}{${t}}`}return e},r=[];for(;this._history.length>0;)r.push(this._undoMove());const i=[];let s="";for(0===r.length&&i.push(o(""));r.length>0;){s=o(s);const e=r.pop();if(!e)break;if(this._history.length||"b"!==e.color)"w"===e.color&&(s.length&&i.push(s),s=this._moveNumber+".");else{const e=`${this._moveNumber}. ...`;s=s?`${s} ${e}`:e}s=s+" "+this._moveToSan(e,this._moves({legal:!0})),this._makeMove(e)}if(s.length&&i.push(o(s)),i.push(this._header.Result||"*"),0===t)return n.join("")+i.join(" ");const a=function(){return n.length>0&&" "===n[n.length-1]&&(n.pop(),!0)},c=function(A,o){for(const r of o.split(" "))if(r){if(A+r.length>t){for(;a();)A--;n.push(e),A=0}n.push(r),A+=r.length,n.push(" "),A++}return a()&&A--,A};let l=0;for(let A=0;A<i.length;A++)l+i[A].length>t&&i[A].includes("{")?l=c(l,i[A]):(l+i[A].length>t&&0!==A?(" "===n[n.length-1]&&n.pop(),n.push(e),l=0):0!==A&&(n.push(" "),l++),n.push(i[A]),l+=i[A].length);return n.join("")}header(...e){for(let t=0;t<e.length;t+=2)"string"==typeof e[t]&&"string"==typeof e[t+1]&&(this._header[e[t]]=e[t+1]);return this._header}setHeader(e,t){return this._header[e]=t??Mn[e]??null,this.getHeaders()}removeHeader(e){return e in this._header&&(this._header[e]=Mn[e]||null,!0)}getHeaders(){const e={};for(const[t,n]of Object.entries(this._header))null!==n&&(e[t]=n);return e}loadPgn(e,{strict:t=!1,newlineChar:n="\r?\n"}={}){"\r?\n"!==n&&(e=e.replace(new RegExp(n,"g"),"\n"));const A=sn(e);this.reset();const o=A.headers;let r="";for(const e in o)"fen"===e.toLowerCase()&&(r=o[e]),this.header(e,o[e]);if(t){if("1"===o.SetUp){if(!("FEN"in o))throw new Error("Invalid PGN: FEN tag must be supplied with SetUp tag");this.load(o.FEN,{preserveHeaders:!0})}}else r&&this.load(r,{preserveHeaders:!0});let i=A.root;for(;i;){if(i.move){const e=this._moveFromSan(i.move,t);if(null==e)throw new Error(`Invalid move in PGN: ${i.move}`);this._makeMove(e),this._incPositionCount()}void 0!==i.comment&&(this._comments[this.fen()]=i.comment),i=i.variations[0]}const s=A.result;s&&Object.keys(this._header).length&&this._header.Result!==s&&this.setHeader("Result",s)}_moveToSan(e,t){let n="";if(e.flags&Nn.KSIDE_CASTLE)n="O-O";else if(e.flags&Nn.QSIDE_CASTLE)n="O-O-O";else{if(e.flags&Nn.NULL_MOVE)return Kn;if(e.piece!==yn){const A=function(e,t){const n=e.from,A=e.to,o=e.piece;let r=0,i=0,s=0;for(let e=0,a=t.length;e<a;e++){const a=t[e].from,c=t[e].to;o===t[e].piece&&n!==a&&A===c&&(r++,Gn(n)===Gn(a)&&i++,Rn(n)===Rn(a)&&s++)}return r>0?i>0&&s>0?Ln(n):s>0?Ln(n).charAt(1):Ln(n).charAt(0):""}(e,t);n+=e.piece.toUpperCase()+A}e.flags&(Nn.CAPTURE|Nn.EP_CAPTURE)&&(e.piece===yn&&(n+=Ln(e.from)[0]),n+="x"),n+=Ln(e.to),e.promotion&&(n+="="+e.promotion.toUpperCase())}return this._makeMove(e),this.isCheck()&&(this.isCheckmate()?n+="#":n+="+"),this._undoMove(),n}_moveFromSan(e,t=!1){let n=Hn(e);if(t||("0-0"===n?n="O-O":"0-0-0"===n&&(n="O-O-O")),n==Kn){return{color:this._turn,from:0,to:0,piece:"k",flags:Nn.NULL_MOVE}}let A,o,r,i,s,a=_n(n),c=this._moves({legal:!0,piece:a});for(let e=0,t=c.length;e<t;e++)if(n===Hn(this._moveToSan(c[e],c)))return c[e];if(t)return null;let l=!1;if(o=n.match(/([pnbrqkPNBRQK])?([a-h][1-8])x?-?([a-h][1-8])([qrbnQRBN])?/),o?(A=o[1],r=o[2],i=o[3],s=o[4],1==r.length&&(l=!0)):(o=n.match(/([pnbrqkPNBRQK])?([a-h]?[1-8]?)x?-?([a-h][1-8])([qrbnQRBN])?/),o&&(A=o[1],r=o[2],i=o[3],s=o[4],1==r.length&&(l=!0))),a=_n(n),c=this._moves({legal:!0,piece:A||a}),!i)return null;for(let e=0,t=c.length;e<t;e++)if(r){if(!(A&&A.toLowerCase()!=c[e].piece||jn[r]!=c[e].from||jn[i]!=c[e].to||s&&s.toLowerCase()!=c[e].promotion))return c[e];if(l){const t=Ln(c[e].from);if(!(A&&A.toLowerCase()!=c[e].piece||jn[i]!=c[e].to||r!=t[0]&&r!=t[1]||s&&s.toLowerCase()!=c[e].promotion))return c[e]}}else if(n===Hn(this._moveToSan(c[e],c)).replace("x",""))return c[e];return null}ascii(){let e=" +------------------------+\n";for(let t=jn.a8;t<=jn.h1;t++){if(0===Rn(t)&&(e+=" "+"87654321"[Gn(t)]+" |"),this._board[t]){const n=this._board[t].type;e+=" "+(this._board[t].color===fn?n.toUpperCase():n.toLowerCase())+" "}else e+=" . ";t+1&136&&(e+="|\n",t+=8)}return e+=" +------------------------+\n",e+=" a b c d e f g h",e}perft(e){const t=this._moves({legal:!1});let n=0;const A=this._turn;for(let o=0,r=t.length;o<r;o++)this._makeMove(t[o]),this._isKingAttacked(A)||(e-1>0?n+=this.perft(e-1):n++),this._undoMove();return n}setTurn(e){return this._turn!=e&&(this.move("--"),!0)}turn(){return this._turn}board(){const e=[];let t=[];for(let n=jn.a8;n<=jn.h1;n++)null==this._board[n]?t.push(null):t.push({square:Ln(n),type:this._board[n].type,color:this._board[n].color}),n+1&136&&(e.push(t),t=[],n+=8);return e}squareColor(e){if(e in jn){const t=jn[e];return(Gn(t)+Rn(t))%2==0?"light":"dark"}return null}history({verbose:e=!1}={}){const t=[],n=[];for(;this._history.length>0;)t.push(this._undoMove());for(;;){const A=t.pop();if(!A)break;e?n.push(new Sn(this,A)):n.push(this._moveToSan(A,this._moves())),this._makeMove(A)}return n}_getPositionCount(e){return this._positionCount.get(e)??0}_incPositionCount(){this._positionCount.set(this._hash,(this._positionCount.get(this._hash)??0)+1)}_decPositionCount(e){const t=this._positionCount.get(e)??0;1===t?this._positionCount.delete(e):this._positionCount.set(e,t-1)}_pruneComments(){const e=[],t={},n=e=>{e in this._comments&&(t[e]=this._comments[e])};for(;this._history.length>0;)e.push(this._undoMove());for(n(this.fen());;){const t=e.pop();if(!t)break;this._makeMove(t),n(this.fen())}this._comments=t}getComment(){return this._comments[this.fen()]}setComment(e){this._comments[this.fen()]=e.replace("{","[").replace("}","]")}deleteComment(){return this.removeComment()}removeComment(){const e=this._comments[this.fen()];return delete this._comments[this.fen()],e}getComments(){return this._pruneComments(),Object.keys(this._comments).map(e=>({fen:e,comment:this._comments[e]}))}deleteComments(){return this.removeComments()}removeComments(){return this._pruneComments(),Object.keys(this._comments).map(e=>{const t=this._comments[e];return delete this._comments[e],{fen:e,comment:t}})}setCastlingRights(e,t){for(const n of[Cn,wn])void 0!==t[n]&&(t[n]?this._castling[e]|=Un[n]:this._castling[e]&=~Un[n]);this._updateCastlingRights();const n=this.getCastlingRights(e);return!(void 0!==t[Cn]&&t[Cn]!==n[Cn]||void 0!==t[wn]&&t[wn]!==n[wn])}getCastlingRights(e){return{[Cn]:0!==(this._castling[e]&Un[Cn]),[wn]:0!==(this._castling[e]&Un[wn])}}moveNumber(){return this._moveNumber}}const $n={initial:"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",empty:"8/8/8/8/8/8/8/8 w - - 0 1"},eA=$n.initial,tA={fen:$n,initialFen:eA,emptyFen:$n.empty},nA=e=>{const[n,A]=t.useState(e.fen||eA),[o,r]=t.useState(new Xn(n));t.useEffect(()=>{e.fen&&(A(e.fen),r(new Xn(e.fen)),s([]))},[e.fen,e.reset]);const[i,s]=t.useState([]),a=e.lastMove&&e.lastMove.promotion,c="w"===o.turn()?"white":"black",[l]=t.useState(e.orientation||c),u=(e,t,n)=>{s([e,t]);try{const r=o.move({from:e,to:t,promotion:n});return A(o.fen()),r}catch{return!1}};return{chess:o,fen:n,turnColor:c,lastMove:i,orientation:l,promotion:a,onMove:u,onPromote:e=>u(i[0],i[1],e),onUndo:()=>{const e=o.undo();return e?(A(o.fen()),s([]),e):null}}};var AA=l(function(e,t){e.exports=((e,t)=>(()=>{var n={494:()=>{},156:t=>{t.exports=e},111:e=>{e.exports=t}},A={};function o(e){var t=A[e];if(void 0!==t)return t.exports;var r=A[e]={exports:{}};return n[e](r,r.exports,o),r.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{default:()=>a});var e=o(156),t=o.n(e),n=o(111);function A(e){const{children:n,replace:A,bodyClass:o,header:r,footer:i,onDragStart:s,onDragEnd:a,onClose:c,closeButton:l,closeButtonPosition:u}=e;return A?n:t().createElement("div",{className:"panel panel-default "+("bottom"===u?"additional-row":"")},t().createElement("div",{className:"panel-heading",onTouchStart:s,onMouseDown:s,onTouchEnd:a,onMouseUp:a},r&&t().createElement("h3",{className:"panel-title"},r)),t().createElement("div",{className:o},n),i&&t().createElement("div",{className:"panel-footer"},i),t().createElement("div",{className:"close",onClick:c,style:{position:"header"===u?"absolute":"static",margin:"bottom"===u?"10px auto":""}},l))}A.defaultProps={closeButton:"×",closeButtonPosition:"header",replace:!1,draggable:!1};const i=A;function s(A){let o=Math.random().toString();const[r,s]=(0,e.useState)(!1),[a,c]=(0,e.useState)(null),[l,u]=(0,e.useState)(null),[h,p]=(0,e.useState)(0),[g,d]=(0,e.useState)(0),[m,f]=(0,e.useState)(0),[b,y]=(0,e.useState)(0),{isOpen:I,onClose:k}=A,w=(0,e.useCallback)(()=>{document.body.classList.remove("body-modal-fix")},[]);(0,e.useEffect)(()=>(I&&(document.addEventListener("keydown",C),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),document.body.classList.add("body-modal-fix")),()=>{document.querySelector(".pure-modal")||(document.removeEventListener("keydown",C),w(),c(null),u(null),p(0),d(0),f(0),y(0))}),[I]);const C=(0,e.useCallback)(e=>{const t=document.querySelectorAll(".pure-modal"),n=t.length>1,A=t[t.length-1];return!(n&&!A.className.includes(o)||"Escape"!==e.key||!document.activeElement||(v(e),0))},[v,o]);if(!I)return null;function v(e){e&&(e.stopPropagation(),e.preventDefault()),null==k||k({isPassive:Boolean(e)})}function S(e){return e instanceof TouchEvent&&e.changedTouches.length>0?{pageX:e.changedTouches[0].pageX,pageY:e.changedTouches[0].pageY}:e instanceof MouseEvent?{pageX:e.pageX,pageY:e.pageY}:{pageX:0,pageY:0}}function E(e){if(e instanceof TouchEvent&&e.changedTouches&&e.changedTouches.length>1)return x();e.preventDefault();const{pageX:t,pageY:n}=S(e);"number"==typeof a&&"number"==typeof l&&(p(t-a-m),d(n-l-b))}function x(){return s(!1)}const{children:V,replace:N=!1,className:M,header:B,footer:j,scrollable:D=!0,draggable:T=!1,width:Q,closeButton:Z,closeButtonPosition:P,portal:O=!1}=A;let U=["pure-modal-backdrop"],q=["pure-modal",o],J=["panel-body"];M&&(q=q.concat(M)),D?J=J.concat("scrollable"):(U=U.concat("scrollable"),q=q.concat("auto-height")),T&&(U=U.concat("backdrop-overflow-hidden"));const K=t().createElement("div",{className:U.join(" "),onMouseDown:function(e){if(e){if(!e.target.classList.contains("pure-modal-backdrop"))return;e.stopPropagation(),e.preventDefault()}v(e)},onTouchMove:r?E:void 0,onMouseMove:r?E:void 0},t().createElement("div",{className:q.join(" "),style:{transform:`translate(${h}px, ${g}px)`,transition:"none",width:Q}},t().createElement(i,{replace:N,header:B,footer:j,onDragStart:T?function(e){if(e instanceof TouchEvent&&e.changedTouches&&e.changedTouches.length>1)return;e.preventDefault();const{pageX:t,pageY:n}=S(e),{top:A,left:o}=e.currentTarget.getBoundingClientRect();s(!0),c("number"==typeof a?a:o),u("number"==typeof l?l:A),f(t-o),y(n-A)}:void 0,onDragEnd:T?x:void 0,onClose:v,bodyClass:J.join(" "),closeButton:Z,closeButtonPosition:P},V)));return O?(0,n.createPortal)(K,document.body):K}o(494);const a=t().memo(s)})(),r})())(o.default,r.default)}),oA=c(AA);const rA=({role:t,color:n,highlighted:A,selectPiece:o})=>{const r="bin"===t;return e.jsx("div",{className:p("edit-square border border-gray-300 rounded",A&&"bg-orange-300"),children:e.jsx("piece",{className:p("spare-piece",t,n,r&&"next-trash"),onClick:()=>{"function"==typeof o&&o({role:t,color:n})}})})},iA=({isOpen:t,hide:n,onPromote:A,color:o="white"})=>{const r=e=>{A(e),n()};return e.jsx(oA,{closeButton:"",isOpen:t,onClose:n,children:e.jsxs("div",{className:"promote flex gap-2 py-1.5 justify-center",children:[e.jsx(rA,{color:o,role:"queen",selectPiece:()=>r("q")}),e.jsx(rA,{color:o,role:"rook",selectPiece:()=>r("r")}),e.jsx(rA,{color:o,role:"bishop",selectPiece:()=>r("b")}),e.jsx(rA,{color:o,role:"knight",selectPiece:()=>r("n")})]})})},sA=(e=!1)=>{const[n,A]=t.useState(e);return{isOpen:n,show:()=>{A(!0)},hide:()=>{A(!1)},toggle:()=>{A(!n)}}};var aA="object"==typeof global&&global&&global.Object===Object&&global,cA="object"==typeof self&&self&&self.Object===Object&&self,lA=aA||cA||Function("return this")(),uA=lA.Symbol,hA=Object.prototype,pA=hA.hasOwnProperty,gA=hA.toString,dA=uA?uA.toStringTag:void 0;var mA=Object.prototype.toString;var fA=uA?uA.toStringTag:void 0;function bA(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":fA&&fA in Object(e)?function(e){var t=pA.call(e,dA),n=e[dA];try{e[dA]=void 0;var A=!0}catch(e){}var o=gA.call(e);return A&&(t?e[dA]=n:delete e[dA]),o}(e):function(e){return mA.call(e)}(e)}function yA(e){return null!=e&&"object"==typeof e}var IA=Array.isArray;function kA(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function wA(e){if(!kA(e))return!1;var t=bA(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var CA,vA=lA["__core-js_shared__"],SA=(CA=/[^.]+$/.exec(vA&&vA.keys&&vA.keys.IE_PROTO||""))?"Symbol(src)_1."+CA:"";var EA=Function.prototype.toString;function xA(e){if(null!=e){try{return EA.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var VA=/^\[object .+?Constructor\]$/,NA=Function.prototype,MA=Object.prototype,BA=NA.toString,jA=MA.hasOwnProperty,DA=RegExp("^"+BA.call(jA).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function TA(e){return!(!kA(e)||(t=e,SA&&SA in t))&&(wA(e)?DA:VA).test(xA(e));var t}function QA(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return TA(n)?n:void 0}var ZA=QA(lA,"WeakMap");function PA(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var OA=Object.prototype;function UA(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||OA)}function qA(e){return yA(e)&&"[object Arguments]"==bA(e)}var JA=Object.prototype,KA=JA.hasOwnProperty,GA=JA.propertyIsEnumerable,RA=qA(function(){return arguments}())?qA:function(e){return yA(e)&&KA.call(e,"callee")&&!GA.call(e,"callee")};var FA="object"==typeof exports&&exports&&!exports.nodeType&&exports,LA=FA&&"object"==typeof module&&module&&!module.nodeType&&module,zA=LA&&LA.exports===FA?lA.Buffer:void 0,WA=(zA?zA.isBuffer:void 0)||function(){return!1},YA={};YA["[object Float32Array]"]=YA["[object Float64Array]"]=YA["[object Int8Array]"]=YA["[object Int16Array]"]=YA["[object Int32Array]"]=YA["[object Uint8Array]"]=YA["[object Uint8ClampedArray]"]=YA["[object Uint16Array]"]=YA["[object Uint32Array]"]=!0,YA["[object Arguments]"]=YA["[object Array]"]=YA["[object ArrayBuffer]"]=YA["[object Boolean]"]=YA["[object DataView]"]=YA["[object Date]"]=YA["[object Error]"]=YA["[object Function]"]=YA["[object Map]"]=YA["[object Number]"]=YA["[object Object]"]=YA["[object RegExp]"]=YA["[object Set]"]=YA["[object String]"]=YA["[object WeakMap]"]=!1;var _A,HA="object"==typeof exports&&exports&&!exports.nodeType&&exports,XA=HA&&"object"==typeof module&&module&&!module.nodeType&&module,$A=XA&&XA.exports===HA&&aA.process,eo=function(){try{var e=XA&&XA.require&&XA.require("util").types;return e||$A&&$A.binding&&$A.binding("util")}catch(e){}}(),to=eo&&eo.isTypedArray,no=to?(_A=to,function(e){return _A(e)}):function(e){return yA(e)&&PA(e.length)&&!!YA[bA(e)]};var Ao=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),oo=Ao,ro=Object.prototype.hasOwnProperty;var io=QA(lA,"Map"),so=QA(lA,"DataView"),ao=QA(lA,"Promise"),co=QA(lA,"Set"),lo="[object Map]",uo="[object Promise]",ho="[object Set]",po="[object WeakMap]",go="[object DataView]",mo=xA(so),fo=xA(io),bo=xA(ao),yo=xA(co),Io=xA(ZA),ko=bA;(so&&ko(new so(new ArrayBuffer(1)))!=go||io&&ko(new io)!=lo||ao&&ko(ao.resolve())!=uo||co&&ko(new co)!=ho||ZA&&ko(new ZA)!=po)&&(ko=function(e){var t=bA(e),n="[object Object]"==t?e.constructor:void 0,A=n?xA(n):"";if(A)switch(A){case mo:return go;case fo:return lo;case bo:return uo;case yo:return ho;case Io:return po}return t});var wo=ko,Co=Object.prototype.hasOwnProperty;function vo(e){if(null==e)return!0;if(function(e){return null!=e&&PA(e.length)&&!wA(e)}(e)&&(IA(e)||"string"==typeof e||"function"==typeof e.splice||WA(e)||no(e)||RA(e)))return!e.length;var t=wo(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(UA(e))return!function(e){if(!UA(e))return oo(e);var t=[];for(var n in Object(e))ro.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e).length;for(var n in e)if(Co.call(e,n))return!1;return!0}const So=e=>{const t={};e.orientation&&(t.orientation=e.orientation,"w"===t.orientation&&(t.orientation="white"),"b"===t.orientation&&(t.orientation="black"));const n=["shapes","onSelect","drawable","lastMove"];for(const A of n)e[A]&&!vo(e[A])&&(t[A]=e[A]);return!1===e.drawable&&(t.drawable={enabled:!1}),t.shapes&&(t.shapes=(e=>{try{return e.forEach(e=>{e.dest=e.dest.replace(/\]/g,"")}),e}catch{return e}})(t.shapes)),e.editing&&(t.movable={free:!1},t.drawable={enabled:!1}),e.viewOnly&&(t.draggable=!1,t.movable={free:!1},t.drawable={enabled:!1}),e.readOnly&&(t.draggable=!1,t.movable={free:!1},t.drawable={enabled:!1},t.coordinates=!1),t},Eo=e=>Wn(e)&&(e=>{if(!e)return!1;const t=e.split(" ")[0];return 1===(t.match(/k/g)||[]).length&&1===(t.match(/K/g)||[]).length})(e),xo=(e,t,n=!1)=>{if(!Eo(e.fen()))return{free:!1};const A=new Map,o="w"===e.turn()?"white":"black";Vn.forEach(t=>{const n=e.moves({square:t,verbose:!0});n.length&&A.set(t,n.map(e=>e.to))});const r={color:o,dests:A,free:!1};return n&&t&&t!==o&&(r.color=t,r.dests=new Map),r},Vo=(n,A)=>{const{theme:o}=An(),{isOpen:r,show:i,hide:s}=sA(),{chess:a,fen:c,turnColor:l,lastMove:u,orientation:h,promotion:g,onMove:d,onPromote:m,onUndo:f}=nA(n),b=async(e,t,A)=>d(e,t,A||g)?(o.playSounds&&nn(o.sounds),"function"==typeof n.onMove&&await n.onMove(a),!0):(A||i(),!1),{onSetPremove:y,onUnsetPremove:I,onPlayPremove:k,onCancelPremove:w,onPremovePromotion:C}=(e=>{const n=t.useRef(null),A=t.useCallback((e,t,A)=>{n.current={orig:e,dest:t,promotion:A?.promotion||null}},[]),o=t.useCallback(()=>{n.current=null},[]),r=t.useCallback(()=>"q",[]);return{onSetPremove:A,onUnsetPremove:o,onPlayPremove:t.useCallback(async()=>{if(n.current){const{orig:t,dest:A,promotion:o}=n.current,r={orig:t,dest:A,promotion:o};n.current=null;const i=r.promotion||"q";return await e(r.orig,r.dest,i)}return!1},[e]),onCancelPremove:t.useCallback(()=>!!n.current&&(n.current=null,!0),[]),onPremovePromotion:r}})(b),v=t.useRef();t.useImperativeHandle(A,()=>({board:v.current?.board,undo:f,move:d,playPremove:k,cancelPremove:w}));t.useEffect(()=>{"function"==typeof n.setPromoting&&n.setPromoting(r)},[r]),t.useEffect(()=>{"function"==typeof n.onFenChange&&n.onFenChange(c)},[c]);const S=n.premoves?{enabled:!0,showDests:!0,castle:!0,events:{set:y,unset:I},promote:C}:{enabled:!1};return e.jsxs("div",{className:p("chessground",o.highlight&&"highlight",o.board,o.pieces),children:[e.jsx(en,{ref:v,coordinates:o.coordinates,onMove:b,fen:c,turnColor:l,lastMove:u,orientation:h,movable:xo(a,h,n.premoves),premovable:S,...So(n)}),e.jsx(iA,{isOpen:r,hide:s,color:l,onPromote:async e=>{if(!m(e))return!1;o.playSounds&&nn(o.sounds),"function"==typeof n.onMove&&await n.onMove(a)}})]})};var No=t.forwardRef(Vo);const Mo=e=>{try{return"w"===e.split(" ")[1]?"white":"black"}catch{return"white"}},Bo=e=>{const[n,A]=t.useState((e=>{try{return e.orientation?e.orientation:e.fen?Mo(e.fen):"white"}catch{return"white"}})(e));return t.useEffect(()=>{e.reset&&A(Mo(e.fen))},[e.reset]),[n,()=>{A(e=>"white"===e?"black":"white")}]},jo=()=>{const{theme:t,handleChange:n}=An();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Board"}),e.jsxs("select",{name:"board",className:"bg-white border border-gray-300 px-2 py-1.5 w-full text-gray-800 rounded",defaultValue:t.board,onChange:n,children:[e.jsx("option",{value:"green",children:"Green"}),e.jsx("option",{value:"brown",children:"Brown"}),e.jsx("option",{value:"ruby",children:"Ruby"}),e.jsx("option",{value:"purple",children:"Purple"}),e.jsx("option",{value:"teal",children:"Teal"})]})]})},Do=()=>{const{theme:t,handleChecked:n}=An();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Coordinates"}),e.jsx("div",{className:"flex",children:e.jsx("input",{name:"coordinates",type:"checkbox",className:"checkbox rounded border border-gray-300",defaultChecked:t.coordinates,onChange:n})})]})},To=()=>{const{theme:t,handleChecked:n}=An();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Highlight moves"}),e.jsx("div",{className:"flex",children:e.jsx("input",{name:"highlight",type:"checkbox",className:"checkbox rounded border border-gray-300",defaultChecked:t.highlight,onChange:n})})]})},Qo=()=>{const{theme:t,handleChange:n}=An();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Pieces"}),e.jsxs("select",{name:"pieces",className:"bg-white border border-gray-300 px-2 py-1.5 w-full text-gray-800 rounded",defaultValue:t.pieces,onChange:n,children:[e.jsx("option",{value:"cburnett",children:"Cburnett"}),e.jsx("option",{value:"neo",children:"Neo"}),e.jsx("option",{value:"alpha",children:"Alpha"}),e.jsx("option",{value:"bases",children:"Bases"}),e.jsx("option",{value:"classic",children:"Classic"})]})]})},Zo=()=>{const{theme:t,handleChecked:n}=An();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Play sounds"}),e.jsx("div",{className:"flex",children:e.jsx("input",{name:"playSounds",type:"checkbox",className:"checkbox rounded border border-gray-300",defaultChecked:t.playSounds,onChange:n})})]})},Po=()=>{const{theme:t,handleChange:n}=An();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Sounds"}),e.jsxs("select",{name:"sounds",className:"bg-white border border-gray-300 px-2 py-1.5 w-full text-gray-800 rounded",defaultValue:t.sounds,onChange:n,children:[e.jsx("option",{value:"robot",children:"Robot"}),e.jsx("option",{value:"piano",children:"Piano"}),e.jsx("option",{value:"lisp",children:"Lisp"}),e.jsx("option",{value:"sfx",children:"SFX"})]})]})},Oo=()=>{const{isOpen:t,show:n,hide:A}=sA();return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"next-button next-settings",title:"Settings",onClick:n,children:e.jsx("i",{className:"next-cog"})}),e.jsx(oA,{header:"Settings",isOpen:t,onClose:A,children:e.jsxs("div",{className:"grid grid-cols-2 gap-3 items-center text-sm",children:[e.jsx(Qo,{}),e.jsx(jo,{}),e.jsx(To,{}),e.jsx(Zo,{}),e.jsx(Po,{}),e.jsx(Do,{})]})})]})},Uo=t=>e.jsx("button",{type:"button",className:"next-button next-flip",title:"Flip board",...t,children:e.jsx("i",{className:"next-sync"})}),qo=({flip:t,readOnly:n})=>n?null:e.jsxs("div",{className:"chessground-footer text-gray-400 flex flex-row-reverse gap-2 py-1.5",children:[e.jsx(Oo,{}),e.jsx(Uo,{onClick:t})]}),Jo=(t,n)=>{const[A,o]=Bo(t);return e.jsx(h,{children:e.jsxs("div",{className:"next-chessground",children:[e.jsx(No,{...t,ref:n,orientation:A}),e.jsx(qo,{flip:o,readOnly:t.readOnly})]})})};var Ko=t.forwardRef(Jo);const Go=t=>{const{theme:n}=An();return e.jsx("div",{className:p("spare-pieces flex gap-2",n.pieces),children:["bin","pawn","knight","bishop","rook","queen","king"].map(n=>((t,n)=>{const{color:A="white",selected:o={role:null,color:null}}=n,r=t===o.role&&A===o.color;return e.jsx(rA,{highlighted:r,role:t,color:A,...n},`${t}-${A}`)})(n,t))})},Ro=e=>{const t=new Map;return t.set(e,null),t},Fo=({onChange:n})=>{const[A,o]=t.useState("w"),[r,i]=t.useState("-");t.useEffect(()=>{"function"==typeof n&&n([A,r].join(" "))},[A,r]);const s=e=>{const{value:t}=e.target;o(t)},a=e=>{const{value:t}=e.target;i(((e,t)=>{if(!t)return e;const n=["K","Q","k","q"].map(n=>n!==t?e.includes(n)?n:"":e.includes(t)?"":t).join("");return n.length?n:"-"})(r,t))};return e.jsxs("div",{className:"flex flex-col gap-2 w-full",children:[e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs("div",{children:[e.jsx("input",{defaultChecked:!0,className:"mx-1",type:"radio",id:"white-radio",name:"side-to-move",value:"w",onChange:s}),e.jsx("label",{htmlFor:"white-radio",children:"White to move"})]}),e.jsxs("div",{children:[e.jsx("input",{className:"mx-1",type:"radio",id:"black-radio",name:"side-to-move",value:"b",onChange:s}),e.jsx("label",{htmlFor:"black-radio",children:"Black to move"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 w-full",children:[e.jsxs("div",{className:"flex w-full gap-4",children:[e.jsx("div",{children:e.jsx("span",{children:"White can"})}),e.jsxs("div",{children:[e.jsx("input",{className:"mx-1",type:"checkbox",id:"white-short-castle",value:"K",onChange:a}),e.jsx("label",{htmlFor:"white-short-castle",children:"O-O"})]}),e.jsxs("div",{children:[e.jsx("input",{className:"mx-1",type:"checkbox",id:"white-long-castle",value:"Q",onChange:a}),e.jsx("label",{htmlFor:"white-long-castle",children:"O-O-O"})]})]}),e.jsxs("div",{className:"flex w-full gap-4",children:[e.jsx("div",{children:e.jsx("span",{children:"Black can"})}),e.jsxs("div",{children:[e.jsx("input",{className:"mx-1",type:"checkbox",id:"black-short-castle",value:"k",onChange:a}),e.jsx("label",{htmlFor:"black-short-castle",children:"O-O"})]}),e.jsxs("div",{children:[e.jsx("input",{className:"mx-1",type:"checkbox",id:"black-long-castle",value:"q",onChange:a}),e.jsx("label",{htmlFor:"black-long-castle",children:"O-O-O"})]})]})]})]})},Lo=(n,A)=>{const[o,r]=t.useState(n.fen||tA.emptyFen),[i,s]=t.useState({role:null,color:null});t.useEffect(()=>{n.fen&&r(n.fen)},[n.fen]),t.useEffect(()=>{"function"==typeof n.onSelect&&n.onSelect(o)},[o]);return e.jsx(h,{children:e.jsxs("div",{className:"next-chessground gap-2",children:[e.jsx(Go,{selected:i,selectPiece:s,color:"black"}),e.jsx(No,{...n,ref:A,fen:o,onSelect:e=>{const t=o.split(" ");t.shift();const n=t.join(" "),s=((e,t,n)=>{if(!e)throw new Error("Chessground is not defined");if(!t||!t.role||!t.color)return e.getFen();if("bin"===t.role)return e.setPieces(Ro(n)),e.getFen();const A=e.state.pieces.get(n);return A?A.role===t.role&&A.color===t.color?(e.setPieces(Ro(n)),e.getFen()):(e.setPieces(Ro(n)),e.newPiece(t,n),e.getFen()):(e.newPiece(t,n),e.getFen())})(A.current.board,i,e),a=[s,n].join(" ");r(a)},editing:!0}),e.jsx(Go,{selected:i,selectPiece:s,color:"white"}),e.jsx(Fo,{onChange:e=>{const t=[o.split(" ")[0],e,"- 0 1"].join(" ");r(t)}})]})})};var zo=t.forwardRef(Lo);function Wo(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var A=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&A.firstChild?A.insertBefore(o,A.firstChild):A.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}Wo(".brown .cg-wrap cg-board {\n background-image: url('data:image/svg+xml;base64,PHN2ZyAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgeG1sbnM6eD0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgIHZpZXdCb3g9IjAgMCA4IDgiICBzaGFwZS1yZW5kZXJpbmc9Imdlb21ldHJpY1ByZWNpc2lvbiI+PHJlY3Qgd2lkdGg9IjgiIGhlaWdodD0iOCIgZmlsbD0iI2I1ODg2MyIvPjxnIGlkPSJhIj4gIDxnIGlkPSJiIj4gICAgPGcgaWQ9ImMiPiAgICAgIDxnIGlkPSJkIj4gICAgICAgIDxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9IiNmMGQ5YjUiIGlkPSJlIi8+ICAgICAgICA8dXNlIHg9IjIiIGhyZWY9IiNlIiB4OmhyZWY9IiNlIi8+ICAgICAgPC9nPiAgICAgIDx1c2UgeD0iNCIgaHJlZj0iI2QiIHg6aHJlZj0iI2QiLz4gICAgPC9nPiAgICA8dXNlIHg9IjEiIHk9IjEiIGhyZWY9IiNjIiB4OmhyZWY9IiNjIi8+ICA8L2c+ICA8dXNlIHk9IjIiIGhyZWY9IiNiIiB4OmhyZWY9IiNiIi8+PC9nPjx1c2UgeT0iNCIgaHJlZj0iI2EiIHg6aHJlZj0iI2EiLz48L3N2Zz4=');\n}\n.green .cg-wrap cg-board {\n background-image: url('data:image/svg+xml;base64,PHN2ZyAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgeG1sbnM6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oA9QA8O4AGQOlpANQD8P8AGgCnpwFQD8C/A2gApJ4GQD0Afw+gAbB6GgD1APw5gAZA62kA1APw+wAaAK+nAXD/tiANgPu3BWkA3D8uSgPg/nFRGgD3rwvTALh/XZgGwO1pANyeBsDtfwE/g8u1a15o2AAAAABJRU5ErkJggg==');\n}\n.teal .cg-wrap cg-board {\n background-image: url('data:image/svg+xml;base64,CjxzdmcgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgIHhtbG5zOng9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiICB2aWV3Qm94PSIwIDAgOCA4IiAgc2hhcGUtcmVuZGVyaW5nPSJnZW9tZXRyaWNQcmVjaXNpb24iPjxyZWN0IHdpZHRoPSI4IiBoZWlnaHQ9IjgiIGZpbGw9IiMxYzcyYWQiLz48ZyBpZD0iYSI+ICA8ZyBpZD0iYiI+ICAgIDxnIGlkPSJjIj4gICAgICA8ZyBpZD0iZCI+ICAgICAgICA8cmVjdCB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSIjZTNlYmYzIiBpZD0iZSIvPiAgICAgICAgPHVzZSB4PSIyIiBocmVmPSIjZSIgeDpocmVmPSIjZSIvPiAgICAgIDwvZz4gICAgICA8dXNlIHg9IjQiIGhyZWY9IiNkIiB4OmhyZWY9IiNkIi8+ICAgIDwvZz4gICAgPHVzZSB4PSIxIiB5PSIxIiBocmVmPSIjYyIgeDpocmVmPSIjYyIvPiAgPC9nPiAgPHVzZSB5PSIyIiBocmVmPSIjYiIgeDpocmVmPSIjYiIvPjwvZz48dXNlIHk9IjQiIGhyZWY9IiNhIiB4OmhyZWY9IiNhIi8+PC9zdmc+');\n}\n");Wo(".next-chessground .chessground {\n grid-area: board;\n position: relative;\n display: block;\n height: 0;\n padding-bottom: 100%;\n padding-right: 100%;\n width: 100%;\n border-radius: 0.25rem;\n overflow: hidden;\n}\n\n.next-chessground .cg-wrap {\n display: table;\n position: absolute;\n width: 100%;\n height: 100%;\n}\n\n.next-chessground cg-helper {\n position: absolute;\n width: 12.5%;\n padding-bottom: 12.5%;\n display: table;\n bottom: 0;\n}\n\n.next-chessground cg-container {\n position: absolute;\n width: 800%;\n height: 800%;\n display: block;\n bottom: 0;\n}\n\n.next-chessground cg-board {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n line-height: 0;\n background-size: cover;\n cursor: pointer;\n}\n\n.next-chessground cg-board square {\n position: absolute;\n top: 0;\n left: 0;\n width: 12.5%;\n height: 12.5%;\n pointer-events: none;\n}\n.next-chessground .highlight cg-board square.last-move {\n will-change: transform;\n background-color: rgba(246, 246, 130, 0.5);\n}\n.next-chessground .highlight .correct cg-board square.last-move {\n background-color: rgba(155, 240, 0, 0.4);\n}\n.next-chessground .highlight .incorrect cg-board square.last-move {\n background-color: rgba(240, 0, 0, 0.4);\n}\n\n.next-chessground cg-board square.check {\n background: radial-gradient(\n ellipse at center,\n rgba(255, 0, 0, 1) 0%,\n rgba(231, 0, 0, 1) 25%,\n rgba(169, 0, 0, 0) 89%,\n rgba(158, 0, 0, 0) 100%\n );\n}\n.next-chessground cg-board square.current-premove {\n background-color: rgba(20, 30, 85, 0.5);\n}\n.next-chessground cg-board piece {\n position: absolute;\n top: 0;\n left: 0;\n width: 12.5%;\n height: 12.5%;\n background-size: cover;\n z-index: 2;\n will-change: transform;\n pointer-events: none;\n}\n.next-chessground cg-board piece.dragging {\n cursor: move;\n z-index: 9;\n}\n.next-chessground cg-board piece.anim {\n z-index: 8;\n}\n.next-chessground cg-board piece.fading {\n z-index: 1;\n opacity: 0.5;\n}\n.next-chessground cg-board piece.ghost {\n opacity: 0.3;\n}\n.next-chessground .cg-wrap svg {\n overflow: hidden;\n position: relative;\n top: 0px;\n left: 0px;\n width: 100%;\n height: 100%;\n pointer-events: none;\n z-index: 2;\n opacity: 0.6;\n}\n.next-chessground .cg-wrap svg image {\n opacity: 0.5;\n}\n\n.next-chessground .spare-pieces {\n width: 100%;\n display: flex;\n justify-content: center;\n}\n.next-chessground .spare-piece {\n top: 0;\n left: 0;\n padding-bottom: 100%;\n padding-left: 100%;\n position: absolute;\n background-size: contain;\n background-position: 0% -100%;\n cursor: pointer;\n}\n.next-chessground .edit-square {\n display: table;\n position: relative;\n width: 14.285%;\n padding-bottom: 13.285%;\n}\n.next-chessground .promote .edit-square {\n width: 20%;\n padding-bottom: 20%;\n}\n");Wo("coords {\n position: absolute;\n display: flex;\n pointer-events: none;\n user-select: none;\n color: #fff;\n font-weight: bold;\n font-size: 0.5rem;\n opacity: 0.8;\n}\n.coords-no coords {\n display: none;\n}\n@media (min-width: 640px) {\n coords {\n font-size: 0.75rem;\n }\n}\ncoords.ranks {\n flex-flow: column-reverse;\n top: 0;\n right: 0;\n height: 100%;\n width: 0.8em;\n}\ncoords.ranks.black {\n flex-flow: column;\n}\ncoords.files {\n bottom: 0;\n left: 0;\n flex-flow: row;\n width: 100%;\n}\ncoords.files.black {\n flex-flow: row-reverse;\n}\ncoords.files coord {\n padding-left: 4px;\n}\ncoords coord {\n flex: 1 1 auto;\n}\n\n.orientation-white .files coord:nth-child(2n + 1),\n.orientation-white .ranks coord:nth-child(2n),\n.orientation-black .files coord:nth-child(2n),\n.orientation-black .ranks coord:nth-child(2n + 1) {\n color: #fff;\n}\n.orientation-white .files coord:nth-child(2n),\n.orientation-white .ranks coord:nth-child(2n + 1),\n.orientation-black .files coord:nth-child(2n + 1),\n.orientation-black .ranks coord:nth-child(2n) {\n color: #779556;\n}\n");Wo(".next-chessground .next-cog {\n width: 1rem;\n height: 1rem;\n background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjOUY5REIwIiBkPSJNNDg3LjQgMzE1LjdsLTQyLjYtMjQuNmM0LjMt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TcgNDcxLjAzQzMzLjg1MSA0ODYuMTQ5IDggNDc1LjQ0MSA4IDQ1NC4wNTlWMzIwYzAtMTMuMjU1IDEwLjc0NS0yNCAyNC0yNHoiLz48L3N2Zz4=');\n}\n.next-chessground .next-trash {\n width: 1rem;\n height: 1rem;\n background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ii05NiAtOTYgNjQwIDY0MCI+PHBhdGggZD0iTTI2OCA0MTZoMjRhMTIgMTIgMCAwIDAgMTItMTJWMTg4YTEyIDEyIDAgMCAwLTEyLTEyaC0yNGExMiAxMiAwIDAgMC0xMiAxMnYyMTZhMTIgMTIgMCAwIDAgMTIgMTJ6TTQzMiA4MGgtODIuNDFsLTM0LTU2LjdBNDggNDggMCAwIDAgMjc0LjQxIDBIMTczLjU5YTQ4IDQ4IDAgMCAwLTQxLjE2IDIzLjNMOTguNDEgODBIMTZBMTYgMTYgMCAwIDAgMCA5NnYxNmExNiAxNiAwIDAgMCAxNiAxNmgxNnYzMzZhNDggNDggMCAwIDAgNDggNDhoMjg4YTQ4IDQ4IDAgMCAwIDQ4LTQ4VjEyOGgxNmExNiAxNiAwIDAgMCAxNi0xNlY5NmExNiAxNiAwIDAgMC0xNi0xNnpNMTcxLjg0IDUwLjkxQTYgNiAwIDAgMSAxNzcgNDhoOTRhNiA2IDAgMCAxIDUuMTUgMi45MUwyOTMuNjEgODBIMTU0LjM5ek0zNjggNDY0SDgwVjEyOGgyODh6bS0yMTItNDhoMjRhMTIgMTIgMCAwIDAgMTItMTJWMTg4YTEyIDEyIDAgMCAwLTEyLTEyaC0yNGExMiAxMiAwIDAgMC0xMiAxMnYyMTZhMTIgMTIgMCAwIDAgMTIgMTJ6Ii8+PC9zdmc+');\n}\n");Wo("*,\n::after,\n::before {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n}\n\n.next-chessground {\n display: flex;\n flex-direction: column;\n position: relative;\n width: 100%;\n}\n.next-chessground .checkbox {\n display: flex;\n margin: 0;\n align-items: center;\n padding-left: 0.25rem;\n width: 2.75rem;\n height: 1.75rem;\n outline: none;\n appearance: none;\n transition: 0.2s ease-in-out;\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n cursor: pointer;\n}\n.next-chessground .checkbox:before {\n background-color: rgba(156, 163, 175);\n width: 1rem;\n height: 1rem;\n border-radius: 999px;\n content: '';\n transition: 0.2s ease-in-out;\n}\n.next-chessground .checkbox:checked:before {\n background-color: rgba(4, 120, 87);\n transform: translate(1rem, 0);\n}\n.next-chessground .next-button {\n background-color: transparent;\n background-image: none;\n cursor: pointer;\n display: flex;\n outline: none;\n\n padding: 0;\n line-height: inherit;\n color: inherit;\n font-size: 100%;\n}\n.next-chessground .next-button:focus {\n outline: none;\n}\n");Wo(".pure-modal {\n box-shadow: rgba(0, 0, 0, 0.5) 0px 5px 15px 0px;\n color: rgba(55, 65, 81);\n}\n.pure-modal-backdrop {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 1040;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n.backdrop-overflow-hidden {\n overflow: hidden !important;\n}\n.pure-modal-backdrop .pure-modal {\n width: 300px;\n max-width: 100%;\n box-sizing: border-box;\n transition: all 0.2s ease-in-out;\n max-height: 100%;\n}\n.pure-modal.auto-height {\n position: static;\n}\n.pure-modal-backdrop.scrollable {\n overflow-y: auto;\n}\n.pure-modal-backdrop .panel {\n display: grid;\n grid-template-rows: repeat(3, min-content);\n}\n.pure-modal-backdrop:not(.scrollable) .panel {\n grid-template-rows: min-content minmax(0, 1fr) min-content;\n max-height: -moz-available;\n max-height: -webkit-fill-available;\n max-height: fill-available;\n height: 100%;\n}\n.pure-modal > * > * {\n flex: 0 0 auto;\n}\n.pure-modal > * > .scrollable {\n overflow-x: hidden;\n overflow-scrolling: touch;\n}\n@media (max-width: 480px) {\n .pure-modal-backdrop .pure-modal {\n width: 100%;\n }\n}\n.pure-modal .panel-body {\n background-color: #fff;\n}\n.pure-modal .panel-heading {\n background: #f0f0f0;\n}\n.pure-modal .panel-title {\n padding: 12px 45px 12px 15px;\n margin: 0;\n}\n.pure-modal .close {\n right: 6px;\n top: 6px;\n z-index: 1;\n width: 30px;\n height: 30px;\n border-radius: 15px;\n text-align: center;\n line-height: 30px;\n cursor: pointer;\n font-size: 1.85rem;\n}\n.pure-modal .panel-heading .close:hover {\n color: #000;\n}\n.pure-modal .panel-body {\n padding: 15px;\n}\n.pure-modal .panel-footer {\n padding: 12px 45px 12px 15px;\n background: #f0f0f0;\n}\n.pure-modal .panel-body,\n.pure-modal .panel-footer,\n.pure-modal .panel-title {\n word-break: break-all;\n}\n.pure-modal-backdrop .additional-row,\n.pure-modal-backdrop:not(.scrollable) .additional-row {\n display: grid;\n grid-template-rows: min-content minmax(0, 1fr) min-content min-content;\n}\n");Wo("/**\n * Cburnett\n */\n.cburnett piece.pawn.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wP.svg');\n}\n.cburnett piece.bishop.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wB.svg');\n}\n.cburnett piece.knight.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wN.svg');\n}\n.cburnett piece.rook.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wR.svg');\n}\n.cburnett piece.queen.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wQ.svg');\n}\n.cburnett piece.king.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wK.svg');\n}\n.cburnett piece.pawn.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bP.svg');\n}\n.cburnett piece.bishop.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bB.svg');\n}\n.cburnett piece.knight.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bN.svg');\n}\n.cburnett piece.rook.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bR.svg');\n}\n.cburnett piece.queen.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bQ.svg');\n}\n.cburnett piece.king.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bK.svg');\n}\n\n/**\n * Classic\n */\n.classic piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wp.png');\n}\n.classic piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wb.png');\n}\n.classic piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wn.png');\n}\n.classic piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wr.png');\n}\n.classic piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wq.png');\n}\n.classic piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wk.png');\n}\n.classic piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bp.png');\n}\n.classic piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bb.png');\n}\n.classic piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bn.png');\n}\n.classic piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/br.png');\n}\n.classic piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bq.png');\n}\n.classic piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bk.png');\n}\n\n/**\n * Neo\n */\n.neo piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wp.png');\n}\n.neo piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wb.png');\n}\n.neo piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wn.png');\n}\n.neo piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wr.png');\n}\n.neo piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wq.png');\n}\n.neo piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wk.png');\n}\n.neo piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bp.png');\n}\n.neo piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bb.png');\n}\n.neo piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bn.png');\n}\n.neo piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/br.png');\n}\n.neo piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bq.png');\n}\n.neo piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bk.png');\n}\n\n/**\n * Alpha\n */\n.alpha piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wp.png');\n}\n.alpha piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wb.png');\n}\n.alpha piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wn.png');\n}\n.alpha piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wr.png');\n}\n.alpha piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wq.png');\n}\n.alpha piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wk.png');\n}\n.alpha piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bp.png');\n}\n.alpha piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bb.png');\n}\n.alpha piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bn.png');\n}\n.alpha piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/br.png');\n}\n.alpha piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bq.png');\n}\n.alpha piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bk.png');\n}\n\n/**\n * Bases\n */\n.bases piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wp.png');\n}\n.bases piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wb.png');\n}\n.bases piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wn.png');\n}\n.bases piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wr.png');\n}\n.bases piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wq.png');\n}\n.bases piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wk.png');\n}\n.bases piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bp.png');\n}\n.bases piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bb.png');\n}\n.bases piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bn.png');\n}\n.bases piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/br.png');\n}\n.bases piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bq.png');\n}\n.bases piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bk.png');\n}\n");Wo(".flex {\n display: flex;\n}\n.flex-col {\n flex-direction: column;\n}\n.flex-row-reverse {\n flex-direction: row-reverse;\n}\n.grid {\n display: grid;\n}\n.grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n.gap-2 {\n gap: 0.5rem;\n}\n.gap-3 {\n gap: 0.75rem;\n}\n.w-full {\n width: 100%;\n}\n.items-center {\n align-items: center;\n}\n.justify-center {\n justify-content: center;\n}\n.py-1\\.5 {\n padding-top: 0.375rem;\n padding-bottom: 0.375rem;\n}\n.px-2 {\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n}\n.cursor-pointer {\n cursor: pointer;\n}\n.cursor-resize {\n cursor: nesw-resize;\n}\n.outline-none,\n.outline-none:focus {\n outline: none;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-gray-400 {\n color: rgba(156, 163, 175);\n}\n.text-gray-800 {\n color: rgba(31, 41, 55);\n}\n.bg-white {\n background-color: #fff;\n}\n.bg-orange-300 {\n background-color: #fbd38d;\n}\n.border {\n border-width: 1px;\n border-style: solid;\n}\n.border-gray-300 {\n border-color: rgba(209, 213, 219);\n}\n.rounded {\n border-radius: 0.25rem;\n}\n"),exports.NextChessground=Ko,exports.NextEditor=zo,exports.Stockfish=class{constructor(e){if("undefined"==typeof window)return!1;if(!window.chessEngineWorker){const t=e??process.env.STOCKFISH_PATH;window.chessEngineWorker=new Worker(t)}this.skillLevel=20,this.maxDepth=40,this.resolveTimeout=null,this.isAnalyzing=!1,this.fen=tA.initialFen}getTurnFromFen(e){return e.split(" ")[1]}normalizeScoreValue(e){const{fen:t}=this;return"b"===this.getTurnFromFen(t)?-1*e:e}isInfoMessage(e){return!(!e||!e.data)&&e.data.startsWith("info")}setSkillLevel(){window.chessEngineWorker.postMessage("setoption name Skill Level value "+this.skillLevel),window.chessEngineWorker.postMessage("setoption name Skill Level Maximum Error value 5000"),window.chessEngineWorker.postMessage("setoption name Skill Level Probability value 1")}async init(){await this.use_uci(),await this.is_ready(),this.setSkillLevel()}getScoreFromInfo(e){if(e.startsWith("info depth 0")){const t=e.split(" "),n=t[4],A=this.normalizeScoreValue(Number(t[5]));return this.isAnalyzing=!1,{type:n,value:A}}if(e.startsWith("info depth ")){const t=e.split(" ");return{type:t[8],value:this.normalizeScoreValue(Number(t[9]))}}return{type:"cp",value:0}}parseData(e){const t=e.split(" ")[2];let n="";e.indexOf(" pv ")>-1&&(n=e.split(" pv ")[1].split(" bmc ")[0]);return{depth:t,pv:n,score:this.getScoreFromInfo(e)}}use_uci(){return new Promise(e=>{window.chessEngineWorker.postMessage("uci"),window.chessEngineWorker.onmessage=t=>{"uciok"===t.data&&e(t)}})}is_ready(){return new Promise(e=>{window.chessEngineWorker.postMessage("isready"),window.chessEngineWorker.onmessage=t=>{"readyok"===t.data&&e(t)}})}set_position(e){return new Promise(t=>{this.fen=e,window.chessEngineWorker.postMessage("position fen "+e),t()})}async new_position(e){await this.stop(),await this.is_ready(),this.set_position(e),this.go_infinite()}set_multipv(e){window.chessEngineWorker.postMessage("setoption name MultiPV value "+e)}get_score(e,t=15){return new Promise(n=>{window.chessEngineWorker.postMessage("position fen "+e),window.chessEngineWorker.postMessage("go depth 15"),window.chessEngineWorker.onmessage=e=>{if(e.data.startsWith("info depth "+t)){const t=e.data.split(" "),A=t[8],o=Number(t[9]);n({type:A,value:o})}else if(e.data.startsWith("info depth 0")){const t=e.data.split(" "),A=t[4],o=Number(t[5]);n({type:A,value:o})}}})}go_depth(e){return new Promise(t=>{window.chessEngineWorker.postMessage("go depth "+e),window.chessEngineWorker.onmessage=e=>{e.data.startsWith("bestmove")&&t(e.data)}})}go_time(e){return new Promise(t=>{window.chessEngineWorker.postMessage("go movetime "+e),window.chessEngineWorker.onmessage=e=>{e.data.startsWith("bestmove")&&t(e.data)}})}go_infinite(e){window.chessEngineWorker.postMessage("go infinite"),this.isAnalyzing=!0,window.chessEngineWorker.onmessage=t=>{if(this.isInfoMessage(t)&&"function"==typeof e){const n=this.parseData(t.data);n.depth>this.maxDepth&&this.stop(),e(n)}}}stop(){return new Promise(e=>{this.isAnalyzing||e(),window.chessEngineWorker.postMessage("stop"),window.chessEngineWorker.onmessage=t=>{t.data.startsWith("bestmove")&&(this.isAnalyzing=!1,e(t.data))}})}quit(){window.chessEngineWorker.postMessage("quit")}},exports.constants=tA,exports.default=Ko,exports.isValidFen=Eo,exports.useChess=nA,exports.useChessground=An;
|
|
35
|
+
*/!function(e,t){function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n}(on,Error),on.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var n,A=null;for(n=0;n<e.length;n++)if(e[n].source===this.location.source){A=e[n].text.split(/\r\n|\n|\r/g);break}var o=this.location.start,r=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(o):o,i=this.location.source+":"+r.line+":"+r.column;if(A){var s=this.location.end,a=rn("",r.line.toString().length," "),c=A[o.line-1],l=(o.line===s.line?s.column:c.length+1)-o.column||1;t+="\n --\x3e "+i+"\n"+a+" |\n"+r.line+" | "+c+"\n"+a+" | "+rn("",o.column-1," ")+rn("",l,"^")}else t+="\n at "+i}return t},on.buildMessage=function(e,t){var n={literal:function(e){return'"'+o(e.text)+'"'},class:function(e){var t=e.parts.map(function(e){return Array.isArray(e)?r(e[0])+"-"+r(e[1]):r(e)});return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function A(e){return e.charCodeAt(0).toString(16).toUpperCase()}function o(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+A(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+A(e)})}function r(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+A(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+A(e)})}function i(e){return n[e.type](e)}return"Expected "+function(e){var t,n,A=e.map(i);if(A.sort(),A.length>0){for(t=1,n=1;t<A.length;t++)A[t-1]!==A[t]&&(A[n]=A[t],n++);A.length=n}switch(A.length){case 1:return A[0];case 2:return A[0]+" or "+A[1];default:return A.slice(0,-1).join(", ")+", or "+A[A.length-1]}}(e)+" but "+function(e){return e?'"'+o(e)+'"':"end of input"}(t)+" found."};const an=0xffffffffffffffffn;function cn(e,t){return 0xffffffffffffffffn&(e<<t|e>>64n-t)}function ln(e,t){return e*t&an}const un=(hn=0xa187eb39cdcaed8f31c4b365b102e01en,function(){let e=BigInt(hn&an),t=BigInt(hn>>64n&an);const n=ln(cn(ln(e,5n),7n),9n);return t^=e,e=(cn(e,24n)^t^t<<16n)&an,t=cn(t,37n),hn=t<<64n|e,n});var hn;const pn=Array.from({length:2},()=>Array.from({length:6},()=>Array.from({length:128},()=>un()))),gn=Array.from({length:8},()=>un()),dn=Array.from({length:16},()=>un()),mn=un(),fn="w",bn="b",yn="p",In="b",kn="r",wn="q",Cn="k",vn="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";class Sn{color;from;to;piece;captured;promotion;flags;san;lan;before;after;constructor(e,t){const{color:n,piece:A,from:o,to:r,flags:i,captured:s,promotion:a}=t,c=Ln(o),l=Ln(r);this.color=n,this.piece=A,this.from=c,this.to=l,this.san=e._moveToSan(t,e._moves({legal:!0})),this.lan=c+l,this.before=e.fen(),e._makeMove(t),this.after=e.fen(),e._undoMove(),this.flags="";for(const e in Nn)Nn[e]&i&&(this.flags+=xn[e]);s&&(this.captured=s),a&&(this.promotion=a,this.lan+=a)}isCapture(){return this.flags.indexOf(xn.CAPTURE)>-1}isPromotion(){return this.flags.indexOf(xn.PROMOTION)>-1}isEnPassant(){return this.flags.indexOf(xn.EP_CAPTURE)>-1}isKingsideCastle(){return this.flags.indexOf(xn.KSIDE_CASTLE)>-1}isQueensideCastle(){return this.flags.indexOf(xn.QSIDE_CASTLE)>-1}isBigPawn(){return this.flags.indexOf(xn.BIG_PAWN)>-1}}const En=-1,xn={NORMAL:"n",CAPTURE:"c",BIG_PAWN:"b",EP_CAPTURE:"e",PROMOTION:"p",KSIDE_CASTLE:"k",QSIDE_CASTLE:"q",NULL_MOVE:"-"},Vn=["a8","b8","c8","d8","e8","f8","g8","h8","a7","b7","c7","d7","e7","f7","g7","h7","a6","b6","c6","d6","e6","f6","g6","h6","a5","b5","c5","d5","e5","f5","g5","h5","a4","b4","c4","d4","e4","f4","g4","h4","a3","b3","c3","d3","e3","f3","g3","h3","a2","b2","c2","d2","e2","f2","g2","h2","a1","b1","c1","d1","e1","f1","g1","h1"],Nn={NORMAL:1,CAPTURE:2,BIG_PAWN:4,EP_CAPTURE:8,PROMOTION:16,KSIDE_CASTLE:32,QSIDE_CASTLE:64,NULL_MOVE:128},Mn={Event:"?",Site:"?",Date:"????.??.??",Round:"?",White:"?",Black:"?",Result:"*"},Bn={...Mn,WhiteTitle:null,BlackTitle:null,WhiteElo:null,BlackElo:null,WhiteUSCF:null,BlackUSCF:null,WhiteNA:null,BlackNA:null,WhiteType:null,BlackType:null,EventDate:null,EventSponsor:null,Section:null,Stage:null,Board:null,Opening:null,Variation:null,SubVariation:null,ECO:null,NIC:null,Time:null,UTCTime:null,UTCDate:null,TimeControl:null,SetUp:null,FEN:null,Termination:null,Annotator:null,Mode:null,PlyCount:null},jn={a8:0,b8:1,c8:2,d8:3,e8:4,f8:5,g8:6,h8:7,a7:16,b7:17,c7:18,d7:19,e7:20,f7:21,g7:22,h7:23,a6:32,b6:33,c6:34,d6:35,e6:36,f6:37,g6:38,h6:39,a5:48,b5:49,c5:50,d5:51,e5:52,f5:53,g5:54,h5:55,a4:64,b4:65,c4:66,d4:67,e4:68,f4:69,g4:70,h4:71,a3:80,b3:81,c3:82,d3:83,e3:84,f3:85,g3:86,h3:87,a2:96,b2:97,c2:98,d2:99,e2:100,f2:101,g2:102,h2:103,a1:112,b1:113,c1:114,d1:115,e1:116,f1:117,g1:118,h1:119},Dn={b:[16,32,17,15],w:[-16,-32,-17,-15]},Tn={n:[-18,-33,-31,-14,18,33,31,14],b:[-17,-15,17,15],r:[-16,1,16,-1],q:[-17,-16,-15,1,17,16,15,-1],k:[-17,-16,-15,1,17,16,15,-1]},Qn=[20,0,0,0,0,0,0,24,0,0,0,0,0,0,20,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,24,24,24,24,24,24,56,0,56,24,24,24,24,24,24,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,20,0,0,0,0,0,0,24,0,0,0,0,0,0,20],Zn=[17,0,0,0,0,0,0,16,0,0,0,0,0,0,15,0,0,17,0,0,0,0,0,16,0,0,0,0,0,15,0,0,0,0,17,0,0,0,0,16,0,0,0,0,15,0,0,0,0,0,0,17,0,0,0,16,0,0,0,15,0,0,0,0,0,0,0,0,17,0,0,16,0,0,15,0,0,0,0,0,0,0,0,0,0,17,0,16,0,15,0,0,0,0,0,0,0,0,0,0,0,0,17,16,15,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,-15,-16,-17,0,0,0,0,0,0,0,0,0,0,0,0,-15,0,-16,0,-17,0,0,0,0,0,0,0,0,0,0,-15,0,0,-16,0,0,-17,0,0,0,0,0,0,0,0,-15,0,0,0,-16,0,0,0,-17,0,0,0,0,0,0,-15,0,0,0,0,-16,0,0,0,0,-17,0,0,0,0,-15,0,0,0,0,0,-16,0,0,0,0,0,-17,0,0,-15,0,0,0,0,0,0,-16,0,0,0,0,0,0,-17],Pn={p:1,n:2,b:4,r:8,q:16,k:32},On=["n",In,kn,wn],Un={[Cn]:Nn.KSIDE_CASTLE,[wn]:Nn.QSIDE_CASTLE},qn={w:[{square:jn.a1,flag:Nn.QSIDE_CASTLE},{square:jn.h1,flag:Nn.KSIDE_CASTLE}],b:[{square:jn.a8,flag:Nn.QSIDE_CASTLE},{square:jn.h8,flag:Nn.KSIDE_CASTLE}]},Jn={b:1,w:6},Kn="--";function Gn(e){return e>>4}function Rn(e){return 15&e}function Fn(e){return-1!=="0123456789".indexOf(e)}function Ln(e){const t=Rn(e),n=Gn(e);return"abcdefgh".substring(t,t+1)+"87654321".substring(n,n+1)}function zn(e){return e===fn?bn:fn}function Wn(e){const t=e.split(/\s+/);if(6!==t.length)return{ok:!1,error:"Invalid FEN: must contain six space-delimited fields"};const n=parseInt(t[5],10);if(isNaN(n)||n<=0)return{ok:!1,error:"Invalid FEN: move number must be a positive integer"};const A=parseInt(t[4],10);if(isNaN(A)||A<0)return{ok:!1,error:"Invalid FEN: half move counter number must be a non-negative integer"};if(!/^(-|[abcdefgh][36])$/.test(t[3]))return{ok:!1,error:"Invalid FEN: en-passant square is invalid"};if(/[^kKqQ-]/.test(t[2]))return{ok:!1,error:"Invalid FEN: castling availability is invalid"};if(!/^(w|b)$/.test(t[1]))return{ok:!1,error:"Invalid FEN: side-to-move is invalid"};const o=t[0].split("/");if(8!==o.length)return{ok:!1,error:"Invalid FEN: piece data does not contain 8 '/'-delimited rows"};for(let e=0;e<o.length;e++){let t=0,n=!1;for(let A=0;A<o[e].length;A++)if(Fn(o[e][A])){if(n)return{ok:!1,error:"Invalid FEN: piece data is invalid (consecutive number)"};t+=parseInt(o[e][A],10),n=!0}else{if(!/^[prnbqkPRNBQK]$/.test(o[e][A]))return{ok:!1,error:"Invalid FEN: piece data is invalid (invalid piece)"};t+=1,n=!1}if(8!==t)return{ok:!1,error:"Invalid FEN: piece data is invalid (too many squares in rank)"}}if("3"==t[3][1]&&"w"==t[1]||"6"==t[3][1]&&"b"==t[1])return{ok:!1,error:"Invalid FEN: illegal en-passant square"};const r=[{color:"white",regex:/K/g},{color:"black",regex:/k/g}];for(const{color:e,regex:n}of r){if(!n.test(t[0]))return{ok:!1,error:`Invalid FEN: missing ${e} king`};if((t[0].match(n)||[]).length>1)return{ok:!1,error:`Invalid FEN: too many ${e} kings`}}return Array.from(o[0]+o[7]).some(e=>"P"===e.toUpperCase())?{ok:!1,error:"Invalid FEN: some pawns are on the edge rows"}:{ok:!0}}function Yn(e,t,n,A,o,r=void 0,i=Nn.NORMAL){const s=Gn(A);if(o!==yn||7!==s&&0!==s)e.push({color:t,from:n,to:A,piece:o,captured:r,flags:i});else for(let s=0;s<On.length;s++){const a=On[s];e.push({color:t,from:n,to:A,piece:o,captured:r,promotion:a,flags:i|Nn.PROMOTION})}}function _n(e){let t=e.charAt(0);if(t>="a"&&t<="h"){if(e.match(/[a-h]\d.*[a-h]\d/))return;return yn}return t=t.toLowerCase(),"o"===t?Cn:t}function Hn(e){return e.replace(/=/,"").replace(/[+#]?[?!]*$/,"")}class Xn{_board=new Array(128);_turn=fn;_header={};_kings={w:En,b:En};_epSquare=-1;_halfMoves=0;_moveNumber=0;_history=[];_comments={};_castling={w:0,b:0};_hash=0n;_positionCount=new Map;constructor(e=vn,{skipValidation:t=!1}={}){this.load(e,{skipValidation:t})}clear({preserveHeaders:e=!1}={}){this._board=new Array(128),this._kings={w:En,b:En},this._turn=fn,this._castling={w:0,b:0},this._epSquare=En,this._halfMoves=0,this._moveNumber=1,this._history=[],this._comments={},this._header=e?this._header:{...Bn},this._hash=this._computeHash(),this._positionCount=new Map,this._header.SetUp=null,this._header.FEN=null}load(e,{skipValidation:t=!1,preserveHeaders:n=!1}={}){let A=e.split(/\s+/);if(A.length>=2&&A.length<6){const t=["-","-","0","1"];e=A.concat(t.slice(-(6-A.length))).join(" ")}if(A=e.split(/\s+/),!t){const{ok:t,error:n}=Wn(e);if(!t)throw new Error(n)}const o=A[0];let r=0;this.clear({preserveHeaders:n});for(let e=0;e<o.length;e++){const t=o.charAt(e);if("/"===t)r+=8;else if(Fn(t))r+=parseInt(t,10);else{const e=t<"a"?fn:bn;this._put({type:t.toLowerCase(),color:e},Ln(r)),r++}}this._turn=A[1],A[2].indexOf("K")>-1&&(this._castling.w|=Nn.KSIDE_CASTLE),A[2].indexOf("Q")>-1&&(this._castling.w|=Nn.QSIDE_CASTLE),A[2].indexOf("k")>-1&&(this._castling.b|=Nn.KSIDE_CASTLE),A[2].indexOf("q")>-1&&(this._castling.b|=Nn.QSIDE_CASTLE),this._epSquare="-"===A[3]?En:jn[A[3]],this._halfMoves=parseInt(A[4],10),this._moveNumber=parseInt(A[5],10),this._hash=this._computeHash(),this._updateSetup(e),this._incPositionCount()}fen({forceEnpassantSquare:e=!1}={}){let t=0,n="";for(let e=jn.a8;e<=jn.h1;e++){if(this._board[e]){t>0&&(n+=t,t=0);const{color:A,type:o}=this._board[e];n+=A===fn?o.toUpperCase():o.toLowerCase()}else t++;e+1&136&&(t>0&&(n+=t),e!==jn.h1&&(n+="/"),t=0,e+=8)}let A="";this._castling[fn]&Nn.KSIDE_CASTLE&&(A+="K"),this._castling[fn]&Nn.QSIDE_CASTLE&&(A+="Q"),this._castling[bn]&Nn.KSIDE_CASTLE&&(A+="k"),this._castling[bn]&Nn.QSIDE_CASTLE&&(A+="q"),A=A||"-";let o="-";if(this._epSquare!==En)if(e)o=Ln(this._epSquare);else{const e=this._epSquare+(this._turn===fn?16:-16),t=[e+1,e-1];for(const e of t){if(136&e)continue;const t=this._turn;if(this._board[e]?.color===t&&this._board[e]?.type===yn){this._makeMove({color:t,from:e,to:this._epSquare,piece:yn,captured:yn,flags:Nn.EP_CAPTURE});const n=!this._isKingAttacked(t);if(this._undoMove(),n){o=Ln(this._epSquare);break}}}}return[n,this._turn,A,o,this._halfMoves,this._moveNumber].join(" ")}_pieceKey(e){if(!this._board[e])return 0n;const{color:t,type:n}=this._board[e],A={p:0,n:1,b:2,r:3,q:4,k:5}[n];return pn[{w:0,b:1}[t]][A][e]}_epKey(){return this._epSquare===En?0n:gn[7&this._epSquare]}_castlingKey(){const e=this._castling.w>>5|this._castling.b>>3;return dn[e]}_computeHash(){let e=0n;for(let t=jn.a8;t<=jn.h1;t++)136&t?t+=7:this._board[t]&&(e^=this._pieceKey(t));return e^=this._epKey(),e^=this._castlingKey(),"b"===this._turn&&(e^=mn),e}_updateSetup(e){this._history.length>0||(e!==vn?(this._header.SetUp="1",this._header.FEN=e):(this._header.SetUp=null,this._header.FEN=null))}reset(){this.load(vn)}get(e){return this._board[jn[e]]}findPiece(e){const t=[];for(let n=jn.a8;n<=jn.h1;n++)136&n?n+=7:this._board[n]&&this._board[n]?.color===e.color&&this._board[n].color===e.color&&this._board[n].type===e.type&&t.push(Ln(n));return t}put({type:e,color:t},n){return!!this._put({type:e,color:t},n)&&(this._updateCastlingRights(),this._updateEnPassantSquare(),this._updateSetup(this.fen()),!0)}_set(e,t){this._hash^=this._pieceKey(e),this._board[e]=t,this._hash^=this._pieceKey(e)}_put({type:e,color:t},n){if(-1==="pnbrqkPNBRQK".indexOf(e.toLowerCase()))return!1;if(!(n in jn))return!1;const A=jn[n];if(e==Cn&&this._kings[t]!=En&&this._kings[t]!=A)return!1;const o=this._board[A];return o&&o.type===Cn&&(this._kings[o.color]=En),this._set(A,{type:e,color:t}),e===Cn&&(this._kings[t]=A),!0}_clear(e){this._hash^=this._pieceKey(e),delete this._board[e]}remove(e){const t=this.get(e);return this._clear(jn[e]),t&&t.type===Cn&&(this._kings[t.color]=En),this._updateCastlingRights(),this._updateEnPassantSquare(),this._updateSetup(this.fen()),t}_updateCastlingRights(){this._hash^=this._castlingKey();const e=this._board[jn.e1]?.type===Cn&&this._board[jn.e1]?.color===fn,t=this._board[jn.e8]?.type===Cn&&this._board[jn.e8]?.color===bn;e&&this._board[jn.a1]?.type===kn&&this._board[jn.a1]?.color===fn||(this._castling.w&=-65),e&&this._board[jn.h1]?.type===kn&&this._board[jn.h1]?.color===fn||(this._castling.w&=-33),t&&this._board[jn.a8]?.type===kn&&this._board[jn.a8]?.color===bn||(this._castling.b&=-65),t&&this._board[jn.h8]?.type===kn&&this._board[jn.h8]?.color===bn||(this._castling.b&=-33),this._hash^=this._castlingKey()}_updateEnPassantSquare(){if(this._epSquare===En)return;const e=this._epSquare+(this._turn===fn?-16:16),t=this._epSquare+(this._turn===fn?16:-16),n=[t+1,t-1];if(null!==this._board[e]||null!==this._board[this._epSquare]||this._board[t]?.color!==zn(this._turn)||this._board[t]?.type!==yn)return this._hash^=this._epKey(),void(this._epSquare=En);n.some(e=>!(136&e)&&this._board[e]?.color===this._turn&&this._board[e]?.type===yn)||(this._hash^=this._epKey(),this._epSquare=En)}_attacked(e,t,n){const A=[];for(let o=jn.a8;o<=jn.h1;o++){if(136&o){o+=7;continue}if(void 0===this._board[o]||this._board[o].color!==e)continue;const r=this._board[o],i=o-t;if(0===i)continue;const s=i+119;if(Qn[s]&Pn[r.type]){if(r.type===yn){if(i>0&&r.color===fn||i<=0&&r.color===bn){if(!n)return!0;A.push(Ln(o))}continue}if("n"===r.type||"k"===r.type){if(n){A.push(Ln(o));continue}return!0}const e=Zn[s];let a=o+e,c=!1;for(;a!==t;){if(null!=this._board[a]){c=!0;break}a+=e}if(!c){if(n){A.push(Ln(o));continue}return!0}}}return!!n&&A}attackers(e,t){return t?this._attacked(t,jn[e],!0):this._attacked(this._turn,jn[e],!0)}_isKingAttacked(e){const t=this._kings[e];return-1!==t&&this._attacked(zn(e),t)}hash(){return this._hash.toString(16)}isAttacked(e,t){return this._attacked(t,jn[e])}isCheck(){return this._isKingAttacked(this._turn)}inCheck(){return this.isCheck()}isCheckmate(){return this.isCheck()&&0===this._moves().length}isStalemate(){return!this.isCheck()&&0===this._moves().length}isInsufficientMaterial(){const e={b:0,n:0,r:0,q:0,k:0,p:0},t=[];let n=0,A=0;for(let o=jn.a8;o<=jn.h1;o++){if(A=(A+1)%2,136&o){o+=7;continue}const r=this._board[o];r&&(e[r.type]=r.type in e?e[r.type]+1:1,r.type===In&&t.push(A),n++)}if(2===n)return!0;if(3===n&&(1===e[In]||1===e.n))return!0;if(n===e[In]+2){let e=0;const n=t.length;for(let A=0;A<n;A++)e+=t[A];if(0===e||e===n)return!0}return!1}isThreefoldRepetition(){return this._getPositionCount(this._hash)>=3}isDrawByFiftyMoves(){return this._halfMoves>=100}isDraw(){return this.isDrawByFiftyMoves()||this.isStalemate()||this.isInsufficientMaterial()||this.isThreefoldRepetition()}isGameOver(){return this.isCheckmate()||this.isDraw()}moves({verbose:e=!1,square:t,piece:n}={}){const A=this._moves({square:t,piece:n});return e?A.map(e=>new Sn(this,e)):A.map(e=>this._moveToSan(e,A))}_moves({legal:e=!0,piece:t,square:n}={}){const A=n?n.toLowerCase():void 0,o=t?.toLowerCase(),r=[],i=this._turn,s=zn(i);let a=jn.a8,c=jn.h1,l=!1;if(A){if(!(A in jn))return[];a=c=jn[A],l=!0}for(let e=a;e<=c;e++){if(136&e){e+=7;continue}if(!this._board[e]||this._board[e].color===s)continue;const{type:t}=this._board[e];let n;if(t===yn){if(o&&o!==t)continue;n=e+Dn[i][0],this._board[n]||(Yn(r,i,e,n,yn),n=e+Dn[i][1],Jn[i]!==Gn(e)||this._board[n]||Yn(r,i,e,n,yn,void 0,Nn.BIG_PAWN));for(let t=2;t<4;t++)n=e+Dn[i][t],136&n||(this._board[n]?.color===s?Yn(r,i,e,n,yn,this._board[n].type,Nn.CAPTURE):n===this._epSquare&&Yn(r,i,e,n,yn,yn,Nn.EP_CAPTURE))}else{if(o&&o!==t)continue;for(let A=0,o=Tn[t].length;A<o;A++){const o=Tn[t][A];for(n=e;n+=o,!(136&n);){if(this._board[n]){if(this._board[n].color===i)break;Yn(r,i,e,n,t,this._board[n].type,Nn.CAPTURE);break}if(Yn(r,i,e,n,t),"n"===t||t===Cn)break}}}}if(!(void 0!==o&&o!==Cn||l&&c!==this._kings[i])){if(this._castling[i]&Nn.KSIDE_CASTLE){const e=this._kings[i],t=e+2;this._board[e+1]||this._board[t]||this._attacked(s,this._kings[i])||this._attacked(s,e+1)||this._attacked(s,t)||Yn(r,i,this._kings[i],t,Cn,void 0,Nn.KSIDE_CASTLE)}if(this._castling[i]&Nn.QSIDE_CASTLE){const e=this._kings[i],t=e-2;this._board[e-1]||this._board[e-2]||this._board[e-3]||this._attacked(s,this._kings[i])||this._attacked(s,e-1)||this._attacked(s,t)||Yn(r,i,this._kings[i],t,Cn,void 0,Nn.QSIDE_CASTLE)}}if(!e||-1===this._kings[i])return r;const u=[];for(let e=0,t=r.length;e<t;e++)this._makeMove(r[e]),this._isKingAttacked(i)||u.push(r[e]),this._undoMove();return u}move(e,{strict:t=!1}={}){let n=null;if("string"==typeof e)n=this._moveFromSan(e,t);else if(null===e)n=this._moveFromSan(Kn,t);else if("object"==typeof e){const t=this._moves();for(let A=0,o=t.length;A<o;A++)if(e.from===Ln(t[A].from)&&e.to===Ln(t[A].to)&&(!("promotion"in t[A])||e.promotion===t[A].promotion)){n=t[A];break}}if(!n)throw"string"==typeof e?new Error(`Invalid move: ${e}`):new Error(`Invalid move: ${JSON.stringify(e)}`);if(this.isCheck()&&n.flags&Nn.NULL_MOVE)throw new Error("Null move not allowed when in check");const A=new Sn(this,n);return this._makeMove(n),this._incPositionCount(),A}_push(e){this._history.push({move:e,kings:{b:this._kings.b,w:this._kings.w},turn:this._turn,castling:{b:this._castling.b,w:this._castling.w},epSquare:this._epSquare,halfMoves:this._halfMoves,moveNumber:this._moveNumber})}_movePiece(e,t){this._hash^=this._pieceKey(e),this._board[t]=this._board[e],delete this._board[e],this._hash^=this._pieceKey(t)}_makeMove(e){const t=this._turn,n=zn(t);if(this._push(e),e.flags&Nn.NULL_MOVE)return t===bn&&this._moveNumber++,this._halfMoves++,this._turn=n,void(this._epSquare=En);if(this._hash^=this._epKey(),this._hash^=this._castlingKey(),e.captured&&(this._hash^=this._pieceKey(e.to)),this._movePiece(e.from,e.to),e.flags&Nn.EP_CAPTURE&&(this._turn===bn?this._clear(e.to-16):this._clear(e.to+16)),e.promotion&&(this._clear(e.to),this._set(e.to,{type:e.promotion,color:t})),this._board[e.to].type===Cn){if(this._kings[t]=e.to,e.flags&Nn.KSIDE_CASTLE){const t=e.to-1,n=e.to+1;this._movePiece(n,t)}else if(e.flags&Nn.QSIDE_CASTLE){const t=e.to+1,n=e.to-2;this._movePiece(n,t)}this._castling[t]=0}if(this._castling[t])for(let n=0,A=qn[t].length;n<A;n++)if(e.from===qn[t][n].square&&this._castling[t]&qn[t][n].flag){this._castling[t]^=qn[t][n].flag;break}if(this._castling[n])for(let t=0,A=qn[n].length;t<A;t++)if(e.to===qn[n][t].square&&this._castling[n]&qn[n][t].flag){this._castling[n]^=qn[n][t].flag;break}if(this._hash^=this._castlingKey(),e.flags&Nn.BIG_PAWN){let A;A=t===bn?e.to-16:e.to+16,(e.to-1&136||this._board[e.to-1]?.type!==yn||this._board[e.to-1]?.color!==n)&&(e.to+1&136||this._board[e.to+1]?.type!==yn||this._board[e.to+1]?.color!==n)?this._epSquare=En:(this._epSquare=A,this._hash^=this._epKey())}else this._epSquare=En;e.piece===yn||e.flags&(Nn.CAPTURE|Nn.EP_CAPTURE)?this._halfMoves=0:this._halfMoves++,t===bn&&this._moveNumber++,this._turn=n,this._hash^=mn}undo(){const e=this._hash,t=this._undoMove();if(t){const n=new Sn(this,t);return this._decPositionCount(e),n}return null}_undoMove(){const e=this._history.pop();if(void 0===e)return null;this._hash^=this._epKey(),this._hash^=this._castlingKey();const t=e.move;this._kings=e.kings,this._turn=e.turn,this._castling=e.castling,this._epSquare=e.epSquare,this._halfMoves=e.halfMoves,this._moveNumber=e.moveNumber,this._hash^=this._epKey(),this._hash^=this._castlingKey(),this._hash^=mn;const n=this._turn,A=zn(n);if(t.flags&Nn.NULL_MOVE)return t;if(this._movePiece(t.to,t.from),t.piece&&(this._clear(t.from),this._set(t.from,{type:t.piece,color:n})),t.captured)if(t.flags&Nn.EP_CAPTURE){let e;e=n===bn?t.to-16:t.to+16,this._set(e,{type:yn,color:A})}else this._set(t.to,{type:t.captured,color:A});if(t.flags&(Nn.KSIDE_CASTLE|Nn.QSIDE_CASTLE)){let e,n;t.flags&Nn.KSIDE_CASTLE?(e=t.to+1,n=t.to-1):(e=t.to-2,n=t.to+1),this._movePiece(n,e)}return t}pgn({newline:e="\n",maxWidth:t=0}={}){const n=[];let A=!1;for(const t in this._header){this._header[t]&&n.push(`[${t} "${this._header[t]}"]`+e),A=!0}A&&this._history.length&&n.push(e);const o=e=>{const t=this._comments[this.fen()];if(void 0!==t){e=`${e}${e.length>0?" ":""}{${t}}`}return e},r=[];for(;this._history.length>0;)r.push(this._undoMove());const i=[];let s="";for(0===r.length&&i.push(o(""));r.length>0;){s=o(s);const e=r.pop();if(!e)break;if(this._history.length||"b"!==e.color)"w"===e.color&&(s.length&&i.push(s),s=this._moveNumber+".");else{const e=`${this._moveNumber}. ...`;s=s?`${s} ${e}`:e}s=s+" "+this._moveToSan(e,this._moves({legal:!0})),this._makeMove(e)}if(s.length&&i.push(o(s)),i.push(this._header.Result||"*"),0===t)return n.join("")+i.join(" ");const a=function(){return n.length>0&&" "===n[n.length-1]&&(n.pop(),!0)},c=function(A,o){for(const r of o.split(" "))if(r){if(A+r.length>t){for(;a();)A--;n.push(e),A=0}n.push(r),A+=r.length,n.push(" "),A++}return a()&&A--,A};let l=0;for(let A=0;A<i.length;A++)l+i[A].length>t&&i[A].includes("{")?l=c(l,i[A]):(l+i[A].length>t&&0!==A?(" "===n[n.length-1]&&n.pop(),n.push(e),l=0):0!==A&&(n.push(" "),l++),n.push(i[A]),l+=i[A].length);return n.join("")}header(...e){for(let t=0;t<e.length;t+=2)"string"==typeof e[t]&&"string"==typeof e[t+1]&&(this._header[e[t]]=e[t+1]);return this._header}setHeader(e,t){return this._header[e]=t??Mn[e]??null,this.getHeaders()}removeHeader(e){return e in this._header&&(this._header[e]=Mn[e]||null,!0)}getHeaders(){const e={};for(const[t,n]of Object.entries(this._header))null!==n&&(e[t]=n);return e}loadPgn(e,{strict:t=!1,newlineChar:n="\r?\n"}={}){"\r?\n"!==n&&(e=e.replace(new RegExp(n,"g"),"\n"));const A=sn(e);this.reset();const o=A.headers;let r="";for(const e in o)"fen"===e.toLowerCase()&&(r=o[e]),this.header(e,o[e]);if(t){if("1"===o.SetUp){if(!("FEN"in o))throw new Error("Invalid PGN: FEN tag must be supplied with SetUp tag");this.load(o.FEN,{preserveHeaders:!0})}}else r&&this.load(r,{preserveHeaders:!0});let i=A.root;for(;i;){if(i.move){const e=this._moveFromSan(i.move,t);if(null==e)throw new Error(`Invalid move in PGN: ${i.move}`);this._makeMove(e),this._incPositionCount()}void 0!==i.comment&&(this._comments[this.fen()]=i.comment),i=i.variations[0]}const s=A.result;s&&Object.keys(this._header).length&&this._header.Result!==s&&this.setHeader("Result",s)}_moveToSan(e,t){let n="";if(e.flags&Nn.KSIDE_CASTLE)n="O-O";else if(e.flags&Nn.QSIDE_CASTLE)n="O-O-O";else{if(e.flags&Nn.NULL_MOVE)return Kn;if(e.piece!==yn){const A=function(e,t){const n=e.from,A=e.to,o=e.piece;let r=0,i=0,s=0;for(let e=0,a=t.length;e<a;e++){const a=t[e].from,c=t[e].to;o===t[e].piece&&n!==a&&A===c&&(r++,Gn(n)===Gn(a)&&i++,Rn(n)===Rn(a)&&s++)}return r>0?i>0&&s>0?Ln(n):s>0?Ln(n).charAt(1):Ln(n).charAt(0):""}(e,t);n+=e.piece.toUpperCase()+A}e.flags&(Nn.CAPTURE|Nn.EP_CAPTURE)&&(e.piece===yn&&(n+=Ln(e.from)[0]),n+="x"),n+=Ln(e.to),e.promotion&&(n+="="+e.promotion.toUpperCase())}return this._makeMove(e),this.isCheck()&&(this.isCheckmate()?n+="#":n+="+"),this._undoMove(),n}_moveFromSan(e,t=!1){let n=Hn(e);if(t||("0-0"===n?n="O-O":"0-0-0"===n&&(n="O-O-O")),n==Kn){return{color:this._turn,from:0,to:0,piece:"k",flags:Nn.NULL_MOVE}}let A,o,r,i,s,a=_n(n),c=this._moves({legal:!0,piece:a});for(let e=0,t=c.length;e<t;e++)if(n===Hn(this._moveToSan(c[e],c)))return c[e];if(t)return null;let l=!1;if(o=n.match(/([pnbrqkPNBRQK])?([a-h][1-8])x?-?([a-h][1-8])([qrbnQRBN])?/),o?(A=o[1],r=o[2],i=o[3],s=o[4],1==r.length&&(l=!0)):(o=n.match(/([pnbrqkPNBRQK])?([a-h]?[1-8]?)x?-?([a-h][1-8])([qrbnQRBN])?/),o&&(A=o[1],r=o[2],i=o[3],s=o[4],1==r.length&&(l=!0))),a=_n(n),c=this._moves({legal:!0,piece:A||a}),!i)return null;for(let e=0,t=c.length;e<t;e++)if(r){if(!(A&&A.toLowerCase()!=c[e].piece||jn[r]!=c[e].from||jn[i]!=c[e].to||s&&s.toLowerCase()!=c[e].promotion))return c[e];if(l){const t=Ln(c[e].from);if(!(A&&A.toLowerCase()!=c[e].piece||jn[i]!=c[e].to||r!=t[0]&&r!=t[1]||s&&s.toLowerCase()!=c[e].promotion))return c[e]}}else if(n===Hn(this._moveToSan(c[e],c)).replace("x",""))return c[e];return null}ascii(){let e=" +------------------------+\n";for(let t=jn.a8;t<=jn.h1;t++){if(0===Rn(t)&&(e+=" "+"87654321"[Gn(t)]+" |"),this._board[t]){const n=this._board[t].type;e+=" "+(this._board[t].color===fn?n.toUpperCase():n.toLowerCase())+" "}else e+=" . ";t+1&136&&(e+="|\n",t+=8)}return e+=" +------------------------+\n",e+=" a b c d e f g h",e}perft(e){const t=this._moves({legal:!1});let n=0;const A=this._turn;for(let o=0,r=t.length;o<r;o++)this._makeMove(t[o]),this._isKingAttacked(A)||(e-1>0?n+=this.perft(e-1):n++),this._undoMove();return n}setTurn(e){return this._turn!=e&&(this.move("--"),!0)}turn(){return this._turn}board(){const e=[];let t=[];for(let n=jn.a8;n<=jn.h1;n++)null==this._board[n]?t.push(null):t.push({square:Ln(n),type:this._board[n].type,color:this._board[n].color}),n+1&136&&(e.push(t),t=[],n+=8);return e}squareColor(e){if(e in jn){const t=jn[e];return(Gn(t)+Rn(t))%2==0?"light":"dark"}return null}history({verbose:e=!1}={}){const t=[],n=[];for(;this._history.length>0;)t.push(this._undoMove());for(;;){const A=t.pop();if(!A)break;e?n.push(new Sn(this,A)):n.push(this._moveToSan(A,this._moves())),this._makeMove(A)}return n}_getPositionCount(e){return this._positionCount.get(e)??0}_incPositionCount(){this._positionCount.set(this._hash,(this._positionCount.get(this._hash)??0)+1)}_decPositionCount(e){const t=this._positionCount.get(e)??0;1===t?this._positionCount.delete(e):this._positionCount.set(e,t-1)}_pruneComments(){const e=[],t={},n=e=>{e in this._comments&&(t[e]=this._comments[e])};for(;this._history.length>0;)e.push(this._undoMove());for(n(this.fen());;){const t=e.pop();if(!t)break;this._makeMove(t),n(this.fen())}this._comments=t}getComment(){return this._comments[this.fen()]}setComment(e){this._comments[this.fen()]=e.replace("{","[").replace("}","]")}deleteComment(){return this.removeComment()}removeComment(){const e=this._comments[this.fen()];return delete this._comments[this.fen()],e}getComments(){return this._pruneComments(),Object.keys(this._comments).map(e=>({fen:e,comment:this._comments[e]}))}deleteComments(){return this.removeComments()}removeComments(){return this._pruneComments(),Object.keys(this._comments).map(e=>{const t=this._comments[e];return delete this._comments[e],{fen:e,comment:t}})}setCastlingRights(e,t){for(const n of[Cn,wn])void 0!==t[n]&&(t[n]?this._castling[e]|=Un[n]:this._castling[e]&=~Un[n]);this._updateCastlingRights();const n=this.getCastlingRights(e);return!(void 0!==t[Cn]&&t[Cn]!==n[Cn]||void 0!==t[wn]&&t[wn]!==n[wn])}getCastlingRights(e){return{[Cn]:0!==(this._castling[e]&Un[Cn]),[wn]:0!==(this._castling[e]&Un[wn])}}moveNumber(){return this._moveNumber}}const $n={initial:"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",empty:"8/8/8/8/8/8/8/8 w - - 0 1"},eA=$n.initial,tA={fen:$n,initialFen:eA,emptyFen:$n.empty},nA=e=>{const[n,A]=t.useState(e.fen||eA),[o,r]=t.useState(new Xn(n));t.useEffect(()=>{e.fen&&(A(e.fen),r(new Xn(e.fen)),s([]))},[e.fen,e.reset]);const[i,s]=t.useState([]),a=e.lastMove&&e.lastMove.promotion,c="w"===o.turn()?"white":"black",[l]=t.useState(e.orientation||c),u=(e,t,n)=>{s([e,t]);try{const r=o.move({from:e,to:t,promotion:n});return A(o.fen()),r}catch{return!1}};return{chess:o,fen:n,turnColor:c,lastMove:i,orientation:l,promotion:a,onMove:u,onPromote:e=>u(i[0],i[1],e),onUndo:()=>{const e=o.undo();return e?(A(o.fen()),s([]),e):null}}};var AA=l(function(e,t){e.exports=((e,t)=>(()=>{var n={494:()=>{},156:t=>{t.exports=e},111:e=>{e.exports=t}},A={};function o(e){var t=A[e];if(void 0!==t)return t.exports;var r=A[e]={exports:{}};return n[e](r,r.exports,o),r.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{default:()=>a});var e=o(156),t=o.n(e),n=o(111);function A(e){const{children:n,replace:A,bodyClass:o,header:r,footer:i,onDragStart:s,onDragEnd:a,onClose:c,closeButton:l,closeButtonPosition:u}=e;return A?n:t().createElement("div",{className:"panel panel-default "+("bottom"===u?"additional-row":"")},t().createElement("div",{className:"panel-heading",onTouchStart:s,onMouseDown:s,onTouchEnd:a,onMouseUp:a},r&&t().createElement("h3",{className:"panel-title"},r)),t().createElement("div",{className:o},n),i&&t().createElement("div",{className:"panel-footer"},i),t().createElement("div",{className:"close",onClick:c,style:{position:"header"===u?"absolute":"static",margin:"bottom"===u?"10px auto":""}},l))}A.defaultProps={closeButton:"×",closeButtonPosition:"header",replace:!1,draggable:!1};const i=A;function s(A){let o=Math.random().toString();const[r,s]=(0,e.useState)(!1),[a,c]=(0,e.useState)(null),[l,u]=(0,e.useState)(null),[h,p]=(0,e.useState)(0),[g,d]=(0,e.useState)(0),[m,f]=(0,e.useState)(0),[b,y]=(0,e.useState)(0),{isOpen:I,onClose:k}=A,w=(0,e.useCallback)(()=>{document.body.classList.remove("body-modal-fix")},[]);(0,e.useEffect)(()=>(I&&(document.addEventListener("keydown",C),document.activeElement instanceof HTMLElement&&document.activeElement.blur(),document.body.classList.add("body-modal-fix")),()=>{document.querySelector(".pure-modal")||(document.removeEventListener("keydown",C),w(),c(null),u(null),p(0),d(0),f(0),y(0))}),[I]);const C=(0,e.useCallback)(e=>{const t=document.querySelectorAll(".pure-modal"),n=t.length>1,A=t[t.length-1];return!(n&&!A.className.includes(o)||"Escape"!==e.key||!document.activeElement||(v(e),0))},[v,o]);if(!I)return null;function v(e){e&&(e.stopPropagation(),e.preventDefault()),null==k||k({isPassive:Boolean(e)})}function S(e){return e instanceof TouchEvent&&e.changedTouches.length>0?{pageX:e.changedTouches[0].pageX,pageY:e.changedTouches[0].pageY}:e instanceof MouseEvent?{pageX:e.pageX,pageY:e.pageY}:{pageX:0,pageY:0}}function E(e){if(e instanceof TouchEvent&&e.changedTouches&&e.changedTouches.length>1)return x();e.preventDefault();const{pageX:t,pageY:n}=S(e);"number"==typeof a&&"number"==typeof l&&(p(t-a-m),d(n-l-b))}function x(){return s(!1)}const{children:V,replace:N=!1,className:M,header:B,footer:j,scrollable:D=!0,draggable:T=!1,width:Q,closeButton:Z,closeButtonPosition:P,portal:O=!1}=A;let U=["pure-modal-backdrop"],q=["pure-modal",o],J=["panel-body"];M&&(q=q.concat(M)),D?J=J.concat("scrollable"):(U=U.concat("scrollable"),q=q.concat("auto-height")),T&&(U=U.concat("backdrop-overflow-hidden"));const K=t().createElement("div",{className:U.join(" "),onMouseDown:function(e){if(e){if(!e.target.classList.contains("pure-modal-backdrop"))return;e.stopPropagation(),e.preventDefault()}v(e)},onTouchMove:r?E:void 0,onMouseMove:r?E:void 0},t().createElement("div",{className:q.join(" "),style:{transform:`translate(${h}px, ${g}px)`,transition:"none",width:Q}},t().createElement(i,{replace:N,header:B,footer:j,onDragStart:T?function(e){if(e instanceof TouchEvent&&e.changedTouches&&e.changedTouches.length>1)return;e.preventDefault();const{pageX:t,pageY:n}=S(e),{top:A,left:o}=e.currentTarget.getBoundingClientRect();s(!0),c("number"==typeof a?a:o),u("number"==typeof l?l:A),f(t-o),y(n-A)}:void 0,onDragEnd:T?x:void 0,onClose:v,bodyClass:J.join(" "),closeButton:Z,closeButtonPosition:P},V)));return O?(0,n.createPortal)(K,document.body):K}o(494);const a=t().memo(s)})(),r})())(o.default,r.default)}),oA=c(AA);const rA=({role:t,color:n,highlighted:A,selectPiece:o})=>{const r="bin"===t;return e.jsx("div",{className:p("edit-square border border-gray-300 rounded",A&&"bg-orange-300"),children:e.jsx("piece",{className:p("spare-piece",t,n,r&&"next-trash"),onClick:()=>{"function"==typeof o&&o({role:t,color:n})}})})},iA=({isOpen:t,hide:n,onPromote:A,color:o="white"})=>{const r=e=>{A(e),n()};return e.jsx(oA,{closeButton:"",isOpen:t,onClose:n,children:e.jsxs("div",{className:"promote flex gap-2 py-1.5 justify-center",children:[e.jsx(rA,{color:o,role:"queen",selectPiece:()=>r("q")}),e.jsx(rA,{color:o,role:"rook",selectPiece:()=>r("r")}),e.jsx(rA,{color:o,role:"bishop",selectPiece:()=>r("b")}),e.jsx(rA,{color:o,role:"knight",selectPiece:()=>r("n")})]})})},sA=(e=!1)=>{const[n,A]=t.useState(e);return{isOpen:n,show:()=>{A(!0)},hide:()=>{A(!1)},toggle:()=>{A(!n)}}};var aA="object"==typeof global&&global&&global.Object===Object&&global,cA="object"==typeof self&&self&&self.Object===Object&&self,lA=aA||cA||Function("return this")(),uA=lA.Symbol,hA=Object.prototype,pA=hA.hasOwnProperty,gA=hA.toString,dA=uA?uA.toStringTag:void 0;var mA=Object.prototype.toString;var fA=uA?uA.toStringTag:void 0;function bA(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":fA&&fA in Object(e)?function(e){var t=pA.call(e,dA),n=e[dA];try{e[dA]=void 0;var A=!0}catch(e){}var o=gA.call(e);return A&&(t?e[dA]=n:delete e[dA]),o}(e):function(e){return mA.call(e)}(e)}function yA(e){return null!=e&&"object"==typeof e}var IA=Array.isArray;function kA(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function wA(e){if(!kA(e))return!1;var t=bA(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var CA,vA=lA["__core-js_shared__"],SA=(CA=/[^.]+$/.exec(vA&&vA.keys&&vA.keys.IE_PROTO||""))?"Symbol(src)_1."+CA:"";var EA=Function.prototype.toString;function xA(e){if(null!=e){try{return EA.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var VA=/^\[object .+?Constructor\]$/,NA=Function.prototype,MA=Object.prototype,BA=NA.toString,jA=MA.hasOwnProperty,DA=RegExp("^"+BA.call(jA).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function TA(e){return!(!kA(e)||(t=e,SA&&SA in t))&&(wA(e)?DA:VA).test(xA(e));var t}function QA(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return TA(n)?n:void 0}var ZA=QA(lA,"WeakMap");function PA(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var OA=Object.prototype;function UA(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||OA)}function qA(e){return yA(e)&&"[object Arguments]"==bA(e)}var JA=Object.prototype,KA=JA.hasOwnProperty,GA=JA.propertyIsEnumerable,RA=qA(function(){return arguments}())?qA:function(e){return yA(e)&&KA.call(e,"callee")&&!GA.call(e,"callee")};var FA="object"==typeof exports&&exports&&!exports.nodeType&&exports,LA=FA&&"object"==typeof module&&module&&!module.nodeType&&module,zA=LA&&LA.exports===FA?lA.Buffer:void 0,WA=(zA?zA.isBuffer:void 0)||function(){return!1},YA={};YA["[object Float32Array]"]=YA["[object Float64Array]"]=YA["[object Int8Array]"]=YA["[object Int16Array]"]=YA["[object Int32Array]"]=YA["[object Uint8Array]"]=YA["[object Uint8ClampedArray]"]=YA["[object Uint16Array]"]=YA["[object Uint32Array]"]=!0,YA["[object Arguments]"]=YA["[object Array]"]=YA["[object ArrayBuffer]"]=YA["[object Boolean]"]=YA["[object DataView]"]=YA["[object Date]"]=YA["[object Error]"]=YA["[object Function]"]=YA["[object Map]"]=YA["[object Number]"]=YA["[object Object]"]=YA["[object RegExp]"]=YA["[object Set]"]=YA["[object String]"]=YA["[object WeakMap]"]=!1;var _A,HA="object"==typeof exports&&exports&&!exports.nodeType&&exports,XA=HA&&"object"==typeof module&&module&&!module.nodeType&&module,$A=XA&&XA.exports===HA&&aA.process,eo=function(){try{var e=XA&&XA.require&&XA.require("util").types;return e||$A&&$A.binding&&$A.binding("util")}catch(e){}}(),to=eo&&eo.isTypedArray,no=to?(_A=to,function(e){return _A(e)}):function(e){return yA(e)&&PA(e.length)&&!!YA[bA(e)]};var Ao=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),oo=Ao,ro=Object.prototype.hasOwnProperty;var io=QA(lA,"Map"),so=QA(lA,"DataView"),ao=QA(lA,"Promise"),co=QA(lA,"Set"),lo="[object Map]",uo="[object Promise]",ho="[object Set]",po="[object WeakMap]",go="[object DataView]",mo=xA(so),fo=xA(io),bo=xA(ao),yo=xA(co),Io=xA(ZA),ko=bA;(so&&ko(new so(new ArrayBuffer(1)))!=go||io&&ko(new io)!=lo||ao&&ko(ao.resolve())!=uo||co&&ko(new co)!=ho||ZA&&ko(new ZA)!=po)&&(ko=function(e){var t=bA(e),n="[object Object]"==t?e.constructor:void 0,A=n?xA(n):"";if(A)switch(A){case mo:return go;case fo:return lo;case bo:return uo;case yo:return ho;case Io:return po}return t});var wo=ko,Co=Object.prototype.hasOwnProperty;function vo(e){if(null==e)return!0;if(function(e){return null!=e&&PA(e.length)&&!wA(e)}(e)&&(IA(e)||"string"==typeof e||"function"==typeof e.splice||WA(e)||no(e)||RA(e)))return!e.length;var t=wo(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(UA(e))return!function(e){if(!UA(e))return oo(e);var t=[];for(var n in Object(e))ro.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e).length;for(var n in e)if(Co.call(e,n))return!1;return!0}const So=e=>{const t={};e.orientation&&(t.orientation=e.orientation,"w"===t.orientation&&(t.orientation="white"),"b"===t.orientation&&(t.orientation="black"));const n=["shapes","onSelect","drawable","lastMove"];for(const A of n)e[A]&&!vo(e[A])&&(t[A]=e[A]);return!1===e.drawable&&(t.drawable={enabled:!1}),t.shapes&&(t.shapes=(e=>{try{return e.forEach(e=>{e.dest=e.dest.replace(/\]/g,"")}),e}catch{return e}})(t.shapes)),e.editing&&(t.movable={free:!1},t.drawable={enabled:!1}),e.viewOnly&&(t.draggable=!1,t.movable={free:!1},t.drawable={enabled:!1}),e.readOnly&&(t.draggable=!1,t.movable={free:!1},t.drawable={enabled:!1},t.coordinates=!1),t},Eo=e=>Wn(e)&&(e=>{if(!e)return!1;const t=e.split(" ")[0];return 1===(t.match(/k/g)||[]).length&&1===(t.match(/K/g)||[]).length})(e),xo=(e,t,n=!1)=>{if(!Eo(e.fen()))return{free:!1};const A=new Map,o="w"===e.turn()?"white":"black";Vn.forEach(t=>{const n=e.moves({square:t,verbose:!0});n.length&&A.set(t,n.map(e=>e.to))});const r={color:o,dests:A,free:!1};return n&&t&&t!==o&&(r.color=t,r.dests=new Map),r},Vo=(n,A)=>{const{theme:o}=An(),{isOpen:r,show:i,hide:s}=sA(),{chess:a,fen:c,turnColor:l,lastMove:u,orientation:h,promotion:g,onMove:d,onPromote:m,onUndo:f}=nA(n),b=async(e,t,A)=>{const r=!0===A?.isPremove?A.promotion:g;return d(e,t,r)?(o.playSounds&&nn(o.sounds),"function"==typeof n.onMove&&await n.onMove(a),!0):!0!==A?.isPremove&&(i(),!1)},{onSetPremove:y,onUnsetPremove:I,onPlayPremove:k,onCancelPremove:w,onPremovePromotion:C}=(e=>{const n=t.useRef(null),A=t.useCallback((e,t,A)=>{n.current={orig:e,dest:t,promotion:A?.promotion||null}},[]),o=t.useCallback(()=>{n.current=null},[]),r=t.useCallback(()=>"q",[]);return{onSetPremove:A,onUnsetPremove:o,onPlayPremove:t.useCallback(async()=>{if(n.current){const{orig:t,dest:A,promotion:o}=n.current,r={orig:t,dest:A,promotion:o};n.current=null;const i={isPremove:!0,promotion:r.promotion||"q"};return await e(r.orig,r.dest,i)}return!1},[e]),onCancelPremove:t.useCallback(()=>!!n.current&&(n.current=null,!0),[]),onPremovePromotion:r}})(b),v=t.useRef();t.useImperativeHandle(A,()=>({board:v.current?.board,undo:f,move:d,playPremove:k,cancelPremove:w}));t.useEffect(()=>{"function"==typeof n.setPromoting&&n.setPromoting(r)},[r]),t.useEffect(()=>{"function"==typeof n.onFenChange&&n.onFenChange(c)},[c]);const S=n.premoves?{enabled:!0,showDests:!0,castle:!0,events:{set:y,unset:I},promote:C}:{enabled:!1};return e.jsxs("div",{className:p("chessground",o.highlight&&"highlight",o.board,o.pieces),children:[e.jsx(en,{ref:v,coordinates:o.coordinates,onMove:b,fen:c,turnColor:l,lastMove:u,orientation:h,movable:xo(a,h,n.premoves),premovable:S,...So(n)}),e.jsx(iA,{isOpen:r,hide:s,color:l,onPromote:async e=>{if(!m(e))return!1;o.playSounds&&nn(o.sounds),"function"==typeof n.onMove&&await n.onMove(a)}})]})};var No=t.forwardRef(Vo);const Mo=e=>{try{return"w"===e.split(" ")[1]?"white":"black"}catch{return"white"}},Bo=e=>{const[n,A]=t.useState((e=>{try{return e.orientation?e.orientation:e.fen?Mo(e.fen):"white"}catch{return"white"}})(e));return t.useEffect(()=>{e.reset&&A(Mo(e.fen))},[e.reset]),[n,()=>{A(e=>"white"===e?"black":"white")}]},jo=()=>{const{theme:t,handleChange:n}=An();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Board"}),e.jsxs("select",{name:"board",className:"bg-white border border-gray-300 px-2 py-1.5 w-full text-gray-800 rounded",defaultValue:t.board,onChange:n,children:[e.jsx("option",{value:"green",children:"Green"}),e.jsx("option",{value:"brown",children:"Brown"}),e.jsx("option",{value:"ruby",children:"Ruby"}),e.jsx("option",{value:"purple",children:"Purple"}),e.jsx("option",{value:"teal",children:"Teal"})]})]})},Do=()=>{const{theme:t,handleChecked:n}=An();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Coordinates"}),e.jsx("div",{className:"flex",children:e.jsx("input",{name:"coordinates",type:"checkbox",className:"checkbox rounded border border-gray-300",defaultChecked:t.coordinates,onChange:n})})]})},To=()=>{const{theme:t,handleChecked:n}=An();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Highlight moves"}),e.jsx("div",{className:"flex",children:e.jsx("input",{name:"highlight",type:"checkbox",className:"checkbox rounded border border-gray-300",defaultChecked:t.highlight,onChange:n})})]})},Qo=()=>{const{theme:t,handleChange:n}=An();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Pieces"}),e.jsxs("select",{name:"pieces",className:"bg-white border border-gray-300 px-2 py-1.5 w-full text-gray-800 rounded",defaultValue:t.pieces,onChange:n,children:[e.jsx("option",{value:"cburnett",children:"Cburnett"}),e.jsx("option",{value:"neo",children:"Neo"}),e.jsx("option",{value:"alpha",children:"Alpha"}),e.jsx("option",{value:"bases",children:"Bases"}),e.jsx("option",{value:"classic",children:"Classic"})]})]})},Zo=()=>{const{theme:t,handleChecked:n}=An();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Play sounds"}),e.jsx("div",{className:"flex",children:e.jsx("input",{name:"playSounds",type:"checkbox",className:"checkbox rounded border border-gray-300",defaultChecked:t.playSounds,onChange:n})})]})},Po=()=>{const{theme:t,handleChange:n}=An();return e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Sounds"}),e.jsxs("select",{name:"sounds",className:"bg-white border border-gray-300 px-2 py-1.5 w-full text-gray-800 rounded",defaultValue:t.sounds,onChange:n,children:[e.jsx("option",{value:"robot",children:"Robot"}),e.jsx("option",{value:"piano",children:"Piano"}),e.jsx("option",{value:"lisp",children:"Lisp"}),e.jsx("option",{value:"sfx",children:"SFX"})]})]})},Oo=()=>{const{isOpen:t,show:n,hide:A}=sA();return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"next-button next-settings",title:"Settings",onClick:n,children:e.jsx("i",{className:"next-cog"})}),e.jsx(oA,{header:"Settings",isOpen:t,onClose:A,children:e.jsxs("div",{className:"grid grid-cols-2 gap-3 items-center text-sm",children:[e.jsx(Qo,{}),e.jsx(jo,{}),e.jsx(To,{}),e.jsx(Zo,{}),e.jsx(Po,{}),e.jsx(Do,{})]})})]})},Uo=t=>e.jsx("button",{type:"button",className:"next-button next-flip",title:"Flip board",...t,children:e.jsx("i",{className:"next-sync"})}),qo=({flip:t,readOnly:n})=>n?null:e.jsxs("div",{className:"chessground-footer text-gray-400 flex flex-row-reverse gap-2 py-1.5",children:[e.jsx(Oo,{}),e.jsx(Uo,{onClick:t})]}),Jo=(t,n)=>{const[A,o]=Bo(t);return e.jsx(h,{children:e.jsxs("div",{className:"next-chessground",children:[e.jsx(No,{...t,ref:n,orientation:A}),e.jsx(qo,{flip:o,readOnly:t.readOnly})]})})};var Ko=t.forwardRef(Jo);const Go=t=>{const{theme:n}=An();return e.jsx("div",{className:p("spare-pieces flex gap-2",n.pieces),children:["bin","pawn","knight","bishop","rook","queen","king"].map(n=>((t,n)=>{const{color:A="white",selected:o={role:null,color:null}}=n,r=t===o.role&&A===o.color;return e.jsx(rA,{highlighted:r,role:t,color:A,...n},`${t}-${A}`)})(n,t))})},Ro=e=>{const t=new Map;return t.set(e,null),t},Fo=({onChange:n})=>{const[A,o]=t.useState("w"),[r,i]=t.useState("-");t.useEffect(()=>{"function"==typeof n&&n([A,r].join(" "))},[A,r]);const s=e=>{const{value:t}=e.target;o(t)},a=e=>{const{value:t}=e.target;i(((e,t)=>{if(!t)return e;const n=["K","Q","k","q"].map(n=>n!==t?e.includes(n)?n:"":e.includes(t)?"":t).join("");return n.length?n:"-"})(r,t))};return e.jsxs("div",{className:"flex flex-col gap-2 w-full",children:[e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs("div",{children:[e.jsx("input",{defaultChecked:!0,className:"mx-1",type:"radio",id:"white-radio",name:"side-to-move",value:"w",onChange:s}),e.jsx("label",{htmlFor:"white-radio",children:"White to move"})]}),e.jsxs("div",{children:[e.jsx("input",{className:"mx-1",type:"radio",id:"black-radio",name:"side-to-move",value:"b",onChange:s}),e.jsx("label",{htmlFor:"black-radio",children:"Black to move"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 w-full",children:[e.jsxs("div",{className:"flex w-full gap-4",children:[e.jsx("div",{children:e.jsx("span",{children:"White can"})}),e.jsxs("div",{children:[e.jsx("input",{className:"mx-1",type:"checkbox",id:"white-short-castle",value:"K",onChange:a}),e.jsx("label",{htmlFor:"white-short-castle",children:"O-O"})]}),e.jsxs("div",{children:[e.jsx("input",{className:"mx-1",type:"checkbox",id:"white-long-castle",value:"Q",onChange:a}),e.jsx("label",{htmlFor:"white-long-castle",children:"O-O-O"})]})]}),e.jsxs("div",{className:"flex w-full gap-4",children:[e.jsx("div",{children:e.jsx("span",{children:"Black can"})}),e.jsxs("div",{children:[e.jsx("input",{className:"mx-1",type:"checkbox",id:"black-short-castle",value:"k",onChange:a}),e.jsx("label",{htmlFor:"black-short-castle",children:"O-O"})]}),e.jsxs("div",{children:[e.jsx("input",{className:"mx-1",type:"checkbox",id:"black-long-castle",value:"q",onChange:a}),e.jsx("label",{htmlFor:"black-long-castle",children:"O-O-O"})]})]})]})]})},Lo=(n,A)=>{const[o,r]=t.useState(n.fen||tA.emptyFen),[i,s]=t.useState({role:null,color:null});t.useEffect(()=>{n.fen&&r(n.fen)},[n.fen]),t.useEffect(()=>{"function"==typeof n.onSelect&&n.onSelect(o)},[o]);return e.jsx(h,{children:e.jsxs("div",{className:"next-chessground gap-2",children:[e.jsx(Go,{selected:i,selectPiece:s,color:"black"}),e.jsx(No,{...n,ref:A,fen:o,onSelect:e=>{const t=o.split(" ");t.shift();const n=t.join(" "),s=((e,t,n)=>{if(!e)throw new Error("Chessground is not defined");if(!t||!t.role||!t.color)return e.getFen();if("bin"===t.role)return e.setPieces(Ro(n)),e.getFen();const A=e.state.pieces.get(n);return A?A.role===t.role&&A.color===t.color?(e.setPieces(Ro(n)),e.getFen()):(e.setPieces(Ro(n)),e.newPiece(t,n),e.getFen()):(e.newPiece(t,n),e.getFen())})(A.current.board,i,e),a=[s,n].join(" ");r(a)},editing:!0}),e.jsx(Go,{selected:i,selectPiece:s,color:"white"}),e.jsx(Fo,{onChange:e=>{const t=[o.split(" ")[0],e,"- 0 1"].join(" ");r(t)}})]})})};var zo=t.forwardRef(Lo);function Wo(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var A=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&A.firstChild?A.insertBefore(o,A.firstChild):A.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}Wo(".brown .cg-wrap cg-board {\n background-image: url('data:image/svg+xml;base64,PHN2ZyAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3Jn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Abk8D4PY0AG5PA+D2NABuTwPg9jQAbk8D4PY0AG5PA+D2NABuTwPg9jQAbk8D4PY0AG5PA+D2NABuTwPg9jQAbk8D4PY0AG5PA+D2NABuTwPg9jQAbk8D4PY0AG5PA+D2NABuTwPg9jQAbk8D4PY0AG5PA+D2NABuTwPg9twPA74bHvA2fP+w9v3T3t9n5wE3IEM/PIDVn+B9g5h6GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwexoAt6cBcHsaALenAXB7GgC3pwFwe64c4HHxABwbgNEBTAPcu7/9AeG6Ae7d3/43CBoA9zcIGgD3nxA0AO4/IWgA3P+HQAPg/j8EGgD1AHx0AA2AwdMAqAfggwNoABSeBkA9AO8fQAPg8DQA6gF49wAaAImnAVAPwHsH0ABYPA2AegDeOYAGQONpANQDcP4AGgCPpwFQD8DZA2gARJ4GQD0A5w6gATB5GgD1AJw5gAZA5WkA1APw9gAaAJenAVAPwJsDaABkngZAPQCvD6ABsHkaAPUAvDqABkDnaQDUA/DyABoAn6cBUA/AiwNoAISeBkA9AM8PoAEwehoA9QA8O4AGQOlpANQD8P8AGgCnpwFQD8C/A2gApJ4GQD0Afw+gAbB6GgD1APw5gAZA62kA1APw+wAaAK+nAXD/tiANgPu3BWkA3D8uSgPg/nFRGgD3rwvTALh/XZgGwO1pANyeBsDtfwE/g8u1a15o2AAAAABJRU5ErkJggg==');\n}\n.teal .cg-wrap cg-board {\n background-image: url('data:image/svg+xml;base64,CjxzdmcgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgIHhtbG5zOng9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiICB2aWV3Qm94PSIwIDAgOCA4IiAgc2hhcGUtcmVuZGVyaW5nPSJnZW9tZXRyaWNQcmVjaXNpb24iPjxyZWN0IHdpZHRoPSI4IiBoZWlnaHQ9IjgiIGZpbGw9IiMxYzcyYWQiLz48ZyBpZD0iYSI+ICA8ZyBpZD0iYiI+ICAgIDxnIGlkPSJjIj4gICAgICA8ZyBpZD0iZCI+ICAgICAgICA8cmVjdCB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSIjZTNlYmYzIiBpZD0iZSIvPiAgICAgICAgPHVzZSB4PSIyIiBocmVmPSIjZSIgeDpocmVmPSIjZSIvPiAgICAgIDwvZz4gICAgICA8dXNlIHg9IjQiIGhyZWY9IiNkIiB4OmhyZWY9IiNkIi8+ICAgIDwvZz4gICAgPHVzZSB4PSIxIiB5PSIxIiBocmVmPSIjYyIgeDpocmVmPSIjYyIvPiAgPC9nPiAgPHVzZSB5PSIyIiBocmVmPSIjYiIgeDpocmVmPSIjYiIvPjwvZz48dXNlIHk9IjQiIGhyZWY9IiNhIiB4OmhyZWY9IiNhIi8+PC9zdmc+');\n}\n");Wo(".next-chessground .chessground {\n grid-area: board;\n position: relative;\n display: block;\n height: 0;\n padding-bottom: 100%;\n padding-right: 100%;\n width: 100%;\n border-radius: 0.25rem;\n overflow: hidden;\n}\n\n.next-chessground .cg-wrap {\n display: table;\n position: absolute;\n width: 100%;\n height: 100%;\n}\n\n.next-chessground cg-helper {\n position: absolute;\n width: 12.5%;\n padding-bottom: 12.5%;\n display: table;\n bottom: 0;\n}\n\n.next-chessground cg-container {\n position: absolute;\n width: 800%;\n height: 800%;\n display: block;\n bottom: 0;\n}\n\n.next-chessground cg-board {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n line-height: 0;\n background-size: cover;\n cursor: pointer;\n}\n\n.next-chessground cg-board square {\n position: absolute;\n top: 0;\n left: 0;\n width: 12.5%;\n height: 12.5%;\n pointer-events: none;\n}\n.next-chessground .highlight cg-board square.last-move {\n will-change: transform;\n background-color: rgba(246, 246, 130, 0.5);\n}\n.next-chessground .highlight .correct cg-board square.last-move {\n background-color: rgba(155, 240, 0, 0.4);\n}\n.next-chessground .highlight .incorrect cg-board square.last-move {\n background-color: rgba(240, 0, 0, 0.4);\n}\n\n.next-chessground cg-board square.check {\n background: radial-gradient(\n ellipse at center,\n rgba(255, 0, 0, 1) 0%,\n rgba(231, 0, 0, 1) 25%,\n rgba(169, 0, 0, 0) 89%,\n rgba(158, 0, 0, 0) 100%\n );\n}\n.next-chessground cg-board square.current-premove {\n background-color: rgba(20, 30, 85, 0.5);\n}\n.next-chessground cg-board piece {\n position: absolute;\n top: 0;\n left: 0;\n width: 12.5%;\n height: 12.5%;\n background-size: cover;\n z-index: 2;\n will-change: transform;\n pointer-events: none;\n}\n.next-chessground cg-board piece.dragging {\n cursor: move;\n z-index: 9;\n}\n.next-chessground cg-board piece.anim {\n z-index: 8;\n}\n.next-chessground cg-board piece.fading {\n z-index: 1;\n opacity: 0.5;\n}\n.next-chessground cg-board piece.ghost {\n opacity: 0.3;\n}\n.next-chessground .cg-wrap svg {\n overflow: hidden;\n position: relative;\n top: 0px;\n left: 0px;\n width: 100%;\n height: 100%;\n pointer-events: none;\n z-index: 2;\n opacity: 0.6;\n}\n.next-chessground .cg-wrap svg image {\n opacity: 0.5;\n}\n\n.next-chessground .spare-pieces {\n width: 100%;\n display: flex;\n justify-content: center;\n}\n.next-chessground .spare-piece {\n top: 0;\n left: 0;\n padding-bottom: 100%;\n padding-left: 100%;\n position: absolute;\n background-size: contain;\n background-position: 0% -100%;\n cursor: pointer;\n}\n.next-chessground .edit-square {\n display: table;\n position: relative;\n width: 14.285%;\n padding-bottom: 13.285%;\n}\n.next-chessground .promote .edit-square {\n width: 20%;\n padding-bottom: 20%;\n}\n");Wo("coords {\n position: absolute;\n display: flex;\n pointer-events: none;\n user-select: none;\n color: #fff;\n font-weight: bold;\n font-size: 0.5rem;\n opacity: 0.8;\n}\n.coords-no coords {\n display: none;\n}\n@media (min-width: 640px) {\n coords {\n font-size: 0.75rem;\n }\n}\ncoords.ranks {\n flex-flow: column-reverse;\n top: 0;\n right: 0;\n height: 100%;\n width: 0.8em;\n}\ncoords.ranks.black {\n flex-flow: column;\n}\ncoords.files {\n bottom: 0;\n left: 0;\n flex-flow: row;\n width: 100%;\n}\ncoords.files.black {\n flex-flow: row-reverse;\n}\ncoords.files coord {\n padding-left: 4px;\n}\ncoords coord {\n flex: 1 1 auto;\n}\n\n.orientation-white .files coord:nth-child(2n + 1),\n.orientation-white .ranks coord:nth-child(2n),\n.orientation-black .files coord:nth-child(2n),\n.orientation-black .ranks coord:nth-child(2n + 1) {\n color: #fff;\n}\n.orientation-white .files coord:nth-child(2n),\n.orientation-white .ranks coord:nth-child(2n + 1),\n.orientation-black .files coord:nth-child(2n + 1),\n.orientation-black .ranks coord:nth-child(2n) {\n color: #779556;\n}\n");Wo(".next-chessground .next-cog {\n width: 1rem;\n height: 1rem;\n background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjOUY5REIwIiBkPSJNNDg3LjQgMzE1LjdsLTQyLjYtMjQuNmM0LjMtMjMuMiA0LjMtNDcgMC03MC4ybDQyLjYtMjQuNmM0LjktMi44IDcuMS04LjYgNS41LTE0LTExLjEtMzUuNi0zMC02Ny44LTU0LjctOTQuNi0zLjgtNC4xLTEwLTUuMS0xNC44LTIuM0wzODAuOCAxMTBjLTE3LjktMTUuNC0zOC41LTI3LjMtNjAuOC0zNS4xVjI1LjhjMC01LjYtMy45LTEwLjUtOS40LTExLjctMzYuNy04LjItNzQuMy03LjgtMTA5LjIgMC01LjUgMS4yLTkuNCA2LjEtOS40IDExLjdWNzVjLTIyLjIgNy45LTQyLjggMTkuOC02MC44IDM1LjFMODguNyA4NS41Yy00LjktMi44LTExLTEuOS0xNC44IDIuMy0yNC43IDI2LjctNDMuNiA1OC45LTU0LjcgOTQuNi0xLjcgNS40LjYgMTEuMiA1LjUgMTRMNjcuMyAyMjFjLTQuMyAyMy4yLTQuMyA0NyAwIDcwLjJsLTQyLjYgMjQuNmMtNC45IDIuOC03LjEgOC42LTUuNSAxNCAxMS4xIDM1LjYgMzAgNjcuOCA1NC43IDk0LjYgMy44IDQuMSAxMCA1LjEgMTQuOCAyLjNsNDIuNi0yNC42YzE3LjkgMTUuNCAzOC41IDI3LjMgNjAuOCAzNS4xdjQ5LjJjMCA1LjYgMy45IDEwLjUgOS40IDExLjcgMzYuNyA4LjIgNzQuMyA3LjggMTA5LjIgMCA1LjUtMS4yIDkuNC02LjEgOS40LTExLjd2LTQ5LjJjMjIuMi03LjkgNDIuOC0xOS44IDYwLjgtMzUuMWw0Mi42IDI0LjZjNC45IDIuOCAxMSAxLjkgMTQuOC0yLjMgMjQuNy0yNi43IDQzLjYtNTguOSA1NC43LTk0LjYgMS41LTUuNS0uNy0xMS4zLTUuNi0xNC4xek0yNTYgMzM2Yy00NC4xIDAtODAtMzUuOS04MC04MHMzNS45LTgwIDgwLTgwIDgwIDM1LjkgODAgODAtMzUuOSA4MC04MCA4MHoiLz48L3N2Zz4=');\n}\n.next-chessground .next-sync {\n width: 1rem;\n height: 1rem;\n background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjOUY5REIwIiBkPSJNMzcwLjcyIDEzMy4yOEMzMzkuNDU4IDEwNC4wMDggMjk4Ljg4OCA4Ny45NjIgMjU1Ljg0OCA4OGMtNzcuNDU4LjA2OC0xNDQuMzI4IDUzLjE3OC0xNjIuNzkxIDEyNi44NS0xLjM0NCA1LjM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MjRhMTIgMTIgMCAwIDAgMTItMTJWMTg4YTEyIDEyIDAgMCAwLTEyLTEyaC0yNGExMiAxMiAwIDAgMC0xMiAxMnYyMTZhMTIgMTIgMCAwIDAgMTIgMTJ6TTQzMiA4MGgtODIuNDFsLTM0LTU2LjdBNDggNDggMCAwIDAgMjc0LjQxIDBIMTczLjU5YTQ4IDQ4IDAgMCAwLTQxLjE2IDIzLjNMOTguNDEgODBIMTZBMTYgMTYgMCAwIDAgMCA5NnYxNmExNiAxNiAwIDAgMCAxNiAxNmgxNnYzMzZhNDggNDggMCAwIDAgNDggNDhoMjg4YTQ4IDQ4IDAgMCAwIDQ4LTQ4VjEyOGgxNmExNiAxNiAwIDAgMCAxNi0xNlY5NmExNiAxNiAwIDAgMC0xNi0xNnpNMTcxLjg0IDUwLjkxQTYgNiAwIDAgMSAxNzcgNDhoOTRhNiA2IDAgMCAxIDUuMTUgMi45MUwyOTMuNjEgODBIMTU0LjM5ek0zNjggNDY0SDgwVjEyOGgyODh6bS0yMTItNDhoMjRhMTIgMTIgMCAwIDAgMTItMTJWMTg4YTEyIDEyIDAgMCAwLTEyLTEyaC0yNGExMiAxMiAwIDAgMC0xMiAxMnYyMTZhMTIgMTIgMCAwIDAgMTIgMTJ6Ii8+PC9zdmc+');\n}\n");Wo("*,\n::after,\n::before {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n}\n\n.next-chessground {\n display: flex;\n flex-direction: column;\n position: relative;\n width: 100%;\n}\n.next-chessground .checkbox {\n display: flex;\n margin: 0;\n align-items: center;\n padding-left: 0.25rem;\n width: 2.75rem;\n height: 1.75rem;\n outline: none;\n appearance: none;\n transition: 0.2s ease-in-out;\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n cursor: pointer;\n}\n.next-chessground .checkbox:before {\n background-color: rgba(156, 163, 175);\n width: 1rem;\n height: 1rem;\n border-radius: 999px;\n content: '';\n transition: 0.2s ease-in-out;\n}\n.next-chessground .checkbox:checked:before {\n background-color: rgba(4, 120, 87);\n transform: translate(1rem, 0);\n}\n.next-chessground .next-button {\n background-color: transparent;\n background-image: none;\n cursor: pointer;\n display: flex;\n outline: none;\n\n padding: 0;\n line-height: inherit;\n color: inherit;\n font-size: 100%;\n}\n.next-chessground .next-button:focus {\n outline: none;\n}\n");Wo(".pure-modal {\n box-shadow: rgba(0, 0, 0, 0.5) 0px 5px 15px 0px;\n color: rgba(55, 65, 81);\n}\n.pure-modal-backdrop {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 1040;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n.backdrop-overflow-hidden {\n overflow: hidden !important;\n}\n.pure-modal-backdrop .pure-modal {\n width: 300px;\n max-width: 100%;\n box-sizing: border-box;\n transition: all 0.2s ease-in-out;\n max-height: 100%;\n}\n.pure-modal.auto-height {\n position: static;\n}\n.pure-modal-backdrop.scrollable {\n overflow-y: auto;\n}\n.pure-modal-backdrop .panel {\n display: grid;\n grid-template-rows: repeat(3, min-content);\n}\n.pure-modal-backdrop:not(.scrollable) .panel {\n grid-template-rows: min-content minmax(0, 1fr) min-content;\n max-height: -moz-available;\n max-height: -webkit-fill-available;\n max-height: fill-available;\n height: 100%;\n}\n.pure-modal > * > * {\n flex: 0 0 auto;\n}\n.pure-modal > * > .scrollable {\n overflow-x: hidden;\n overflow-scrolling: touch;\n}\n@media (max-width: 480px) {\n .pure-modal-backdrop .pure-modal {\n width: 100%;\n }\n}\n.pure-modal .panel-body {\n background-color: #fff;\n}\n.pure-modal .panel-heading {\n background: #f0f0f0;\n}\n.pure-modal .panel-title {\n padding: 12px 45px 12px 15px;\n margin: 0;\n}\n.pure-modal .close {\n right: 6px;\n top: 6px;\n z-index: 1;\n width: 30px;\n height: 30px;\n border-radius: 15px;\n text-align: center;\n line-height: 30px;\n cursor: pointer;\n font-size: 1.85rem;\n}\n.pure-modal .panel-heading .close:hover {\n color: #000;\n}\n.pure-modal .panel-body {\n padding: 15px;\n}\n.pure-modal .panel-footer {\n padding: 12px 45px 12px 15px;\n background: #f0f0f0;\n}\n.pure-modal .panel-body,\n.pure-modal .panel-footer,\n.pure-modal .panel-title {\n word-break: break-all;\n}\n.pure-modal-backdrop .additional-row,\n.pure-modal-backdrop:not(.scrollable) .additional-row {\n display: grid;\n grid-template-rows: min-content minmax(0, 1fr) min-content min-content;\n}\n");Wo("/**\n * Cburnett\n */\n.cburnett piece.pawn.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wP.svg');\n}\n.cburnett piece.bishop.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wB.svg');\n}\n.cburnett piece.knight.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wN.svg');\n}\n.cburnett piece.rook.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wR.svg');\n}\n.cburnett piece.queen.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wQ.svg');\n}\n.cburnett piece.king.white {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/wK.svg');\n}\n.cburnett piece.pawn.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bP.svg');\n}\n.cburnett piece.bishop.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bB.svg');\n}\n.cburnett piece.knight.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bN.svg');\n}\n.cburnett piece.rook.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bR.svg');\n}\n.cburnett piece.queen.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bQ.svg');\n}\n.cburnett piece.king.black {\n background-image: url('https://lichess1.org/assets/_MKI2V3/piece/cburnett/bK.svg');\n}\n\n/**\n * Classic\n */\n.classic piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wp.png');\n}\n.classic piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wb.png');\n}\n.classic piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wn.png');\n}\n.classic piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wr.png');\n}\n.classic piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wq.png');\n}\n.classic piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/wk.png');\n}\n.classic piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bp.png');\n}\n.classic piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bb.png');\n}\n.classic piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bn.png');\n}\n.classic piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/br.png');\n}\n.classic piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bq.png');\n}\n.classic piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/classic/150/bk.png');\n}\n\n/**\n * Neo\n */\n.neo piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wp.png');\n}\n.neo piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wb.png');\n}\n.neo piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wn.png');\n}\n.neo piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wr.png');\n}\n.neo piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wq.png');\n}\n.neo piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/wk.png');\n}\n.neo piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bp.png');\n}\n.neo piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bb.png');\n}\n.neo piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bn.png');\n}\n.neo piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/br.png');\n}\n.neo piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bq.png');\n}\n.neo piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/neo/150/bk.png');\n}\n\n/**\n * Alpha\n */\n.alpha piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wp.png');\n}\n.alpha piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wb.png');\n}\n.alpha piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wn.png');\n}\n.alpha piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wr.png');\n}\n.alpha piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wq.png');\n}\n.alpha piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/wk.png');\n}\n.alpha piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bp.png');\n}\n.alpha piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bb.png');\n}\n.alpha piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bn.png');\n}\n.alpha piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/br.png');\n}\n.alpha piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bq.png');\n}\n.alpha piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/alpha/150/bk.png');\n}\n\n/**\n * Bases\n */\n.bases piece.pawn.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wp.png');\n}\n.bases piece.bishop.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wb.png');\n}\n.bases piece.knight.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wn.png');\n}\n.bases piece.rook.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wr.png');\n}\n.bases piece.queen.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wq.png');\n}\n.bases piece.king.white {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/wk.png');\n}\n.bases piece.pawn.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bp.png');\n}\n.bases piece.bishop.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bb.png');\n}\n.bases piece.knight.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bn.png');\n}\n.bases piece.rook.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/br.png');\n}\n.bases piece.queen.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bq.png');\n}\n.bases piece.king.black {\n background-image: url('https://images.chesscomfiles.com/chess-themes/pieces/bases/150/bk.png');\n}\n");Wo(".flex {\n display: flex;\n}\n.flex-col {\n flex-direction: column;\n}\n.flex-row-reverse {\n flex-direction: row-reverse;\n}\n.grid {\n display: grid;\n}\n.grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n.gap-2 {\n gap: 0.5rem;\n}\n.gap-3 {\n gap: 0.75rem;\n}\n.w-full {\n width: 100%;\n}\n.items-center {\n align-items: center;\n}\n.justify-center {\n justify-content: center;\n}\n.py-1\\.5 {\n padding-top: 0.375rem;\n padding-bottom: 0.375rem;\n}\n.px-2 {\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n}\n.cursor-pointer {\n cursor: pointer;\n}\n.cursor-resize {\n cursor: nesw-resize;\n}\n.outline-none,\n.outline-none:focus {\n outline: none;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-gray-400 {\n color: rgba(156, 163, 175);\n}\n.text-gray-800 {\n color: rgba(31, 41, 55);\n}\n.bg-white {\n background-color: #fff;\n}\n.bg-orange-300 {\n background-color: #fbd38d;\n}\n.border {\n border-width: 1px;\n border-style: solid;\n}\n.border-gray-300 {\n border-color: rgba(209, 213, 219);\n}\n.rounded {\n border-radius: 0.25rem;\n}\n"),exports.NextChessground=Ko,exports.NextEditor=zo,exports.Stockfish=class{constructor(e){if("undefined"==typeof window)return!1;if(!window.chessEngineWorker){const t=e??process.env.STOCKFISH_PATH;window.chessEngineWorker=new Worker(t)}this.skillLevel=20,this.maxDepth=40,this.resolveTimeout=null,this.isAnalyzing=!1,this.fen=tA.initialFen}getTurnFromFen(e){return e.split(" ")[1]}normalizeScoreValue(e){const{fen:t}=this;return"b"===this.getTurnFromFen(t)?-1*e:e}isInfoMessage(e){return!(!e||!e.data)&&e.data.startsWith("info")}setSkillLevel(){window.chessEngineWorker.postMessage("setoption name Skill Level value "+this.skillLevel),window.chessEngineWorker.postMessage("setoption name Skill Level Maximum Error value 5000"),window.chessEngineWorker.postMessage("setoption name Skill Level Probability value 1")}async init(){await this.use_uci(),await this.is_ready(),this.setSkillLevel()}getScoreFromInfo(e){if(e.startsWith("info depth 0")){const t=e.split(" "),n=t[4],A=this.normalizeScoreValue(Number(t[5]));return this.isAnalyzing=!1,{type:n,value:A}}if(e.startsWith("info depth ")){const t=e.split(" ");return{type:t[8],value:this.normalizeScoreValue(Number(t[9]))}}return{type:"cp",value:0}}parseData(e){const t=e.split(" ")[2];let n="";e.indexOf(" pv ")>-1&&(n=e.split(" pv ")[1].split(" bmc ")[0]);return{depth:t,pv:n,score:this.getScoreFromInfo(e)}}use_uci(){return new Promise(e=>{window.chessEngineWorker.postMessage("uci"),window.chessEngineWorker.onmessage=t=>{"uciok"===t.data&&e(t)}})}is_ready(){return new Promise(e=>{window.chessEngineWorker.postMessage("isready"),window.chessEngineWorker.onmessage=t=>{"readyok"===t.data&&e(t)}})}set_position(e){return new Promise(t=>{this.fen=e,window.chessEngineWorker.postMessage("position fen "+e),t()})}async new_position(e){await this.stop(),await this.is_ready(),this.set_position(e),this.go_infinite()}set_multipv(e){window.chessEngineWorker.postMessage("setoption name MultiPV value "+e)}get_score(e,t=15){return new Promise(n=>{window.chessEngineWorker.postMessage("position fen "+e),window.chessEngineWorker.postMessage("go depth 15"),window.chessEngineWorker.onmessage=e=>{if(e.data.startsWith("info depth "+t)){const t=e.data.split(" "),A=t[8],o=Number(t[9]);n({type:A,value:o})}else if(e.data.startsWith("info depth 0")){const t=e.data.split(" "),A=t[4],o=Number(t[5]);n({type:A,value:o})}}})}go_depth(e){return new Promise(t=>{window.chessEngineWorker.postMessage("go depth "+e),window.chessEngineWorker.onmessage=e=>{e.data.startsWith("bestmove")&&t(e.data)}})}go_time(e){return new Promise(t=>{window.chessEngineWorker.postMessage("go movetime "+e),window.chessEngineWorker.onmessage=e=>{e.data.startsWith("bestmove")&&t(e.data)}})}go_infinite(e){window.chessEngineWorker.postMessage("go infinite"),this.isAnalyzing=!0,window.chessEngineWorker.onmessage=t=>{if(this.isInfoMessage(t)&&"function"==typeof e){const n=this.parseData(t.data);n.depth>this.maxDepth&&this.stop(),e(n)}}}stop(){return new Promise(e=>{this.isAnalyzing||e(),window.chessEngineWorker.postMessage("stop"),window.chessEngineWorker.onmessage=t=>{t.data.startsWith("bestmove")&&(this.isAnalyzing=!1,e(t.data))}})}quit(){window.chessEngineWorker.postMessage("quit")}},exports.constants=tA,exports.default=Ko,exports.isValidFen=Eo,exports.useChess=nA,exports.useChessground=An;
|