From be9cfe5fa34120f8e9cba94c8029dfe63f0afa06 Mon Sep 17 00:00:00 2001 From: Mu-Tsun Tsai Date: Tue, 31 Dec 2024 10:30:28 +0800 Subject: [PATCH] Chores --- docs/index.html | 2 +- .../{index.47bfa2f4.js => index.311dc183.js} | 2 +- .../js/{vue.fc524477.js => vue.504bd54c.js} | 2 +- docs/sw.js | 2 +- package.json | 12 +- pnpm-lock.yaml | 695 +++++++++--------- 6 files changed, 366 insertions(+), 349 deletions(-) rename docs/static/js/{index.47bfa2f4.js => index.311dc183.js} (99%) rename docs/static/js/{vue.fc524477.js => vue.504bd54c.js} (99%) diff --git a/docs/index.html b/docs/index.html index 4aceee2..1a39f7c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,4 +1,4 @@ -FEN Tool
 Save image
 Save
Embed mode
SDK mode
Turn:
Castling:
Tool:
To use this feature, we need to download Stockfish modules first.

For more information and API, see README.
Copyright © 2023-2024 Mu-Tsun Tsai
\ No newline at end of file diff --git a/docs/static/js/index.47bfa2f4.js b/docs/static/js/index.311dc183.js similarity index 99% rename from docs/static/js/index.47bfa2f4.js rename to docs/static/js/index.311dc183.js index e5b007d..98bca92 100644 --- a/docs/static/js/index.47bfa2f4.js +++ b/docs/static/js/index.311dc183.js @@ -1 +1 @@ -(()=>{"use strict";var e={9843:function(e,t,n){let o;n.d(t,{O:function(){return f},S:function(){return d}});var a=n(6919),l=n(737);let i=document.currentScript,r="img[fen]",s=document.createElement("iframe");function c(e){let t=new MessageChannel;t.port1.onmessage=t=>{e.src=t.data,e.title=o.getTitle(n,e.dataset)};let n=e.getAttribute("fen"),i=(0,l.D_)(Object.assign({},o.getDefault(),e.dataset)),r=(0,a.A1)(n);r&&Object.assign(i,r);let{w:c,h:u}=(0,l.t_)(i);e.width=c,e.height=u,s.contentWindow.postMessage({fen:n,options:i},"*",[t.port2])}function u(e){e instanceof Element&&(e.matches(r)?c(e):e.querySelectorAll(r).forEach(e=>c(e)))}async function d(e){let t=new URL(i.src).origin,n=new URL(t+"/fen-tool/api/");o=e,document.head.appendChild(s),await new Promise(e=>{let t=n=>{n.source==s.contentWindow&&(removeEventListener("message",t),e())};addEventListener("message",t),s.src=n.toString()});let a=document.documentElement;new MutationObserver(e=>{for(let t of e)if("attributes"==t.type){let e=t.attributeName.toLowerCase(),n=e.startsWith("data");t.target==i&&n&&u(document.body),"IMG"==t.target.nodeName&&("fen"==e||n)&&c(t.target)}else for(let e of t.addedNodes)u(e)}).observe(a,{childList:!0,attributes:!0,subtree:!0}),u(a)}function f(){u(document.body)}s.style.display="none"},4109:function(e,t,n){n.d(t,{Ar:function(){return U},SI:function(){return S},l:function(){return y},q_:function(){return _}});var o=n(4881),a=n(4097),l=n(899),i=n(9391),r=n(5547),s=n(3369),c=n(737),u=n(9683),d=n(9843),f=n(2506);let p=document.getElementById("Zone"),m=document.getElementById("DragZone"),h=document.getElementById("EditZone");function g(){return document.body.clientWidth/(i.SB.split?2:1)}async function y(e,t){let n=i.h.board,a={};for(let t in e)a[t]=e[t]!==n[t];Object.assign(n,e);let{border:p,margin:m,w:h,h:y}=(0,c.t_)(n),b=function(e,t,n){let o=w();return g()<(e.w+f._N)*e.size+t.x+4*n.size+4.2*o}(n,m,p);a.mode=b!==i.i7.hor,i.i7.hor=b;let _=a.w||a.h;(_||t)&&(0,s.co)();let k=t||a.set||a.size,U=k||a.border,x=U||_,B=U||a.mode;B&&function(e,t,n){let o=(f._N*e+2*t)*u.uN,a=(f.Dm*e+2*t)*u.uN;i.i7.hor?[o,a]=[a+n.x*u.uN,o]:a+=n.y*u.uN,(l.in.width!==o||l.in.height!==a)&&(l.Ab.width=l.in.width=o,l.Ab.height=l.in.height=a)}(n.size,p.size,m),x&&function(e,t){let n=e*u.uN,o=t*u.uN;(l.m8.width!==n||l.m8.height!==o)&&(l.ut.width=l.S8.width=l.m8.width=n,l.ut.height=l.S8.height=l.m8.height=o),(0,r.Sk)(l.ut.getContext("2d"))}(h,y),S(),k&&(await (0,r.zD)(),i.h.project.length&&(0,d.O)()),x&&(0,r.ii)(),B&&(0,r.t1)(),(0,o.Y3)(S)}document.addEventListener("visibilitychange",()=>{"visible"==document.visibilityState&&((0,r.ii)(),(0,r.t1)())});function b(e){let{w:t,h:n}=i.h.board,o=(0,s.Ox)();y(e),(0,s.v)(o,t,n)}function S(){p.style.maxWidth="calc(".concat(g(),"px + 1rem)"),l.m8.style.width=l.m8.width/u.uN+"px",l.in.style.width=l.in.width/u.uN+"px";let{w:e}=i.h.board,t=(0,i.nj)(void 0,void 0,f.Dm);if(i.i7.hor){if(e>f.Dm)l.in.style.width=t.width+"px";else if(ey({}));let e=i.yC.get("fen");await y({},!0),s.uz.draw=r.ii,s.uz.setOption=y,e?((0,s.dd)(e,!0),(0,s.qA)()):(0,s.uu)(),setTimeout(S,f.WT)}if(u.OB.isTop)window.resizeIframe=function(){let e=document.getElementsByTagName("iframe")[0];e&&(e.style.minHeight=e.contentDocument.body.scrollHeight+"px")};else{function k(){try{parent.resizeIframe()}catch{}}"undefined"!=typeof ResizeObserver?new ResizeObserver(k).observe(document.body):new MutationObserver(k).observe(document.body,{childList:!0}),k()}let U={setDimension:b,setBorder(e){let t=(0,c.By)(e.value);t?(e.value=t,y({border:t})):e.value=i.h.board.border},get set(){return i.h.board.set},set set(v){y({set:v})},get size(){return i.h.board.size},set size(v){y({size:v})},get height(){return i.h.board.h},set height(v){b({h:v})},get width(){return i.h.board.w},set width(v){b({w:v})}};addEventListener("storage",e=>{if(e.storageArea==localStorage&&"settings"==e.key){let e=localStorage.getItem("settings"),t=e?JSON.parse(e):null;(0,a.n)(i.h,t,!0),y({},!0)}})},3369:function(e,t,n){n.d(t,{Ox:function(){return D},Qt:function(){return j},RI:function(){return m},Wc:function(){return T},X4:function(){return L},ZD:function(){return M},co:function(){return y},dd:function(){return x},gg:function(){return g},gx:function(){return V},mj:function(){return I},nC:function(){return f},oO:function(){return W},qA:function(){return C},tZ:function(){return E},uu:function(){return P},uz:function(){return p},v:function(){return N},xG:function(){return d},xL:function(){return A},zF:function(){return U}});var o=n(4881),a=n(899),l=n(6919),i=n(9391),r=n(6384),s=n(2506),c=n(3276);let u=["K","Q","k","q"],d=Array(s.cb),f=document.getElementById("Squares"),p={},m=(0,o.XI)("");function h(e){var t;null===(t=p.draw)||void 0===t||t.call(p,e)}function g(e){for(let t of(f.style.width=a.m8.clientWidth+"px",f.style.height=a.m8.clientHeight+"px",d))t.style.fontSize=e-10+"px",t.style.lineHeight=e-10+"px"}function y(){let{w:e,h:t}=i.h.board,n=e*t;f.style.gridTemplateColumns="repeat(".concat(e,", 1fr)"),f.style.gridTemplateRows="repeat(".concat(t,", 1fr)");for(let e=0;ee.value)}function A(){return D().map(e=>(0,l.hv)(e,!1,!0))}function N(e,t,n){let{w:o,h:a}=i.h.board;for(let l=0;ld[t].value=e),P()}function T(){for(let e of(Object.assign(i.SB.play,{turn:c.Il.white,enPassant:"",halfMove:0,fullMove:1}),u))i.SB.play.castle[e]=!0}let L={update:()=>{B(m.value),O(!0)},empty(){for(let e of d)e.value="";P()},reset(e){var t;null===(t=p.setOption)||void 0===t||t.call(p,{w:8,h:8}),(i.h.board.fullFEN||e)&&T(),x(l.J7)},color(e){for(let t of d){let n=t.value;!n.startsWith("'")&&""!=n&&(n.startsWith("-")&&(n=n.substr(1)),n=n.toLowerCase(),0==e&&(n="-"+n),1==e&&(n=n.toUpperCase()),t.value=n)}P()},fixSN(){for(let e of(gtag("event","fen_fix_sn"),d)){let t=e.value;!t.startsWith("'")&&""!=t&&(e.value=t.replace("s","n").replace("S","N"))}P()},invert(e){V((0,l.U_)(D(),e))}}},3813:function(e,t,n){let o,a,l,i,r,s,c,u,d,f,p,m,h,g;var y=n("4881"),b=n("9391"),S=n("3369"),w=n("4109"),_=n("899"),k=n("5547"),U=n("6384"),x=n("9683"),B=n("375");async function C(e){if(x.OB.canCopyImg){let t=await e();return navigator.clipboard.write([new ClipboardItem({"image/png":t})])}throw(0,B.Z)('Image copying is not enabled in your browser.\n\nIf you\'re using Firefox, this can be enabled by the following.\n1. Visit "about:config" in your address bar.\n2. Search for "dom.events.asyncClipboard.clipboardItem".\n3. Toggle its value to true.\n4. Reload this tool.'),Error()}async function D(){if(x.OB.canPaste)return await navigator.clipboard.readText();throw(0,B.Z)('Pasting text is not enabled in your browser.\n\nIf you\'re using Firefox on desktops or Firefox Nightly on Android, this can be enabled by the following.\n1. Visit "about:config" in your address bar.\n2. Search for "dom.events.asyncClipboard.readText".\n3. Toggle its value to true.\n4. Reload this tool.'),Error()}var A=n("1450"),N=n("6919"),P=n("3276"),E=n("2506"),I=n("7739");function R(e){let t=b.SB.play,n=t.moveNumber;(n+=e)<-1&&(n=-1),n>t.history.length-1&&(n=t.history.length-1),n!=t.moveNumber&&O(n)}function O(e){let t=b.SB.play,n=t.moveNumber,o=e>=0||0==n;if(Q.goto(t.history[e],o),o){let o=e==n-1,a=t.history[o?n:e],l=a.from+a.to;("k"==a.flags||"q"==a.flags)&&(l+=","+W(a)),(0,U.jt)(a.before,a.after,l,o!=(b.SB.play.mode==P.jl.retro))}}function M(e,t,n){let o=(0,N.MA)(e),l=(0,N.MA)(t);if(b.SB.play.mode==P.jl.retro){let e=a.retract({from:o,to:l,...b.SB.play.retro});return e&&(z(),q()),e}try{let e=a.move({from:o,to:l,promotion:n});if(!e)return!1;if("k"==e.flags||"q"==e.flags)return function(e){let t=(0,N.S3)(e.before),n=e.color==P.Il.white;return t[(0,N.Di)(e.from)]="",t[(0,N.Di)(e.to)]=n?"K":"k",{before:(0,N.N0)(t),after:e.after,move:W(e)}}(e);return!0}catch{return!1}}(0,b.t4)(()=>{if(b.SB.play.playing){let e=b.SB.play;e.playing=!1,Promise.all([(0,k.zD)(),T()]).then(()=>{L(),Q.goto(e.history[e.moveNumber])})}});function W(e){let t=e.color==P.Il.white,n="k"==e.flags,o=t?I.zi:I.TF;return(n?"h":"a")+o+(n?"f":"d")+o}function j(){(0,S.dd)(a.fen())}function V(e){return a.get((0,N.MA)(e)).color}async function T(){if(!o){let e=await n.e("471").then(n.bind(n,102));!o&&((o=e).Chess.options=b.h.PLAY,a=new o.Chess(b.SB.play),b.i7.module.chess=!0)}return o}function L(){Object.assign(b.SB.play,{playing:!0,pendingPromotion:!1}),(0,S.Qt)(!0),b.SB.play.mode==P.jl.retro?(z(),q()):(0,k.t1)([])}function z(){b.SB.play.retro={uncapture:void 0,unpromote:!1,ep:!1}}function q(){(0,k.t1)(a.turn()==P.Il.black?I.th.wr:I.th.br)}async function F(e){await T();try{a.loadGame(e),j(),L()}catch(e){e instanceof Error&&(0,B.Z)(e.message)}}let Q={async start(){try{let e=(0,S.mj)();if(!e)throw Error("Only orthodox chess is supported.");await T(),a.init(e),b.SB.play.over=a.overState(),L()}catch(e){e instanceof Error&&(0,B.Z)(e.message)}gtag("event","fen_play_"+b.SB.play.mode)},exit(){let e=b.SB.play.initFEN;b.SB.play.playing=!1,b.SB.play.game="",(0,S.dd)(e),(0,S.ZD)(e),(0,S.Qt)(!1),(0,k.t1)([])},goto(e,t){b.SB.play.pendingPromotion&&(b.SB.play.pendingPromotion=!1,(0,k.t1)([]));let n=a.goto(e);!t&&((0,U.p_)(),(0,S.dd)(n)),b.SB.play.mode==P.jl.retro&&(z(),q())},move(e){e!=b.SB.play.moveNumber&&O(e)},moveBy(e){R(e)},copyGame:()=>a.copyGame(),copyPGN:()=>a.copyPGN(),number:e=>o.number(e,b.SB.play.mode),format:e=>o.format(e,b.SB.play.mode),async pasteMoves(){let e=await D();try{a.addMoves(o.parseMoves(e))}catch(e){e instanceof Error&&(0,B.Z)(e.message)}j()},async pasteGame(){let e=await D();await F(e)}},Y=new URL(location.href).searchParams.get("play");null!==Y&&setTimeout(()=>{b.SB.tab=P.mQ.play,F(Y)},0);var K=n("737"),G=n("5169");function H(e){if(e.targetTouches){let t=e.target.getBoundingClientRect(),n=e.targetTouches[0]||e.changedTouches[0];e.clientX=n.clientX,e.clientY=n.clientY,e.offsetX=e.clientX-t.x,e.offsetY=e.clientY-t.y}return e}function Z(e,t){let{s:n,offset:o}=(0,b.nj)(),a=t.getBoundingClientRect(),l=Math.floor((e.clientY-a.top-o.y)/n);return{x:Math.floor((e.clientX-a.left-o.x)/n),y:l}}function $(e,t,n){return(t.x-e.x)*(n.y-e.y)-(n.x-e.x)*(t.y-e.y)}let X={x:0,y:0},J={x:0,y:0},ee=0,et=0,en=performance.now();function eo(e){let t=H(e);"pending"==b.i7.dragging&&function(e,t){let n=e.offsetX-t.x,o=e.offsetY-t.y;return Math.sqrt(n*n+o*o)}(t,X)>5&&(et=0,s?(u=x.OB.isTouch?[]:null,function(e,t){ea(),r.style.display="block",t&&(t.value="",(0,S.uu)()),b.i7.dragging=!0,ec(e)}(t,i)):b.i7.dragging=!1),!0===b.i7.dragging&&(u&&u.push({x:t.clientX,y:t.clientY}),ec(t))}function ea(){b.i7.selection=null,(0,k.t1)([])}function el(e){(function(e){if(i&&"pending"==b.i7.dragging&&!b.SB.play.playing&&e.target==_.fr){let t=performance.now();t-ee<300&&i.focus(),ee=t,e.preventDefault(),b.i7.dragging=!1}})(e),r&&(r.style.display="none");let t=H(e);if(function(e){if(performance.now()-et>=250)return!1;if(e.target!=_.in||(0,b.I3)()){if(e.target==_.fr&&b.SB.popeye.playing){let{x:t}=Z(e,_.fr);return t<3&&G.wD.moveBy(-1),t>4&&G.wD.moveBy(1),!0}}else{let{x:t,y:n}=Z(e,_.in);if(b.i7.hor&&([t,n]=[n,t]),eu(t,n,E._N,E.Dm)){let e=k.Kv[n*E._N+t];b.i7.selection==e?b.i7.selection=null:b.i7.selection=e,(0,k.t1)([])}else ea();return b.i7.dragging=!1,!0}return!1}(t)||b.SB.popeye.playing||!b.i7.dragging)return;if(b.i7.dragging=!1,!s)return;let{w:n,h:o}=b.h.board,{x:d,y:f}=Z(t,_.m8),p=f*n+d,m=eu(d,f,n,o);if(b.SB.play.playing){let e;if(m){if(function(e,t){let n=b.SB.play.mode;return n!=P.jl.retro&&(n==P.jl.pass&&V(e)!=a.turn()&&a.switchSide(),!!a.checkPromotion((0,N.MA)(e),(0,N.MA)(t))&&(l=t,b.SB.play.pendingPromotion=!0,(0,k.t1)(a.turn()==P.Il.black?I.th.b:I.th.w),!0))}(c,p))return(0,S.zF)(S.xG[p],s);c!=p&&(e=M(c,p))}"object"==typeof e?(0,U.jt)(e.before,e.after,e.move):j()}else if(m){if((0,S.zF)(S.xG[p],s),i&&u&&u.length>10){var h;er(i,function(e,t){let n=0;for(let o=0,a=t.length-1;oe.y&&$(i,l,e)>0&&n++:l.y<=e.y&&0>$(i,l,e)&&n--}return n}(function(e){let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return t/=e.length,{x:t,y:n/=e.length}}(h=u),h)>0?P.mi.r90:P.mi.r270)}}else(0,S.qA)()}function ei(e){if((0,b.I3)())return;let{w:t,h:n}=b.h.board,{offset:o,s:a}=(0,b.nj)(),l=Math.floor((e.offsetX-o.x)/a),i=Math.floor((e.offsetY-o.y)/a);if(eu(l,i,t,n)){let n=S.xG[i*t+l];if(""==n.value)return;e.preventDefault();let o=performance.now();if(o-en<50)return;en=o,er(n,e.deltaY>0?P.mi.r90:P.mi.r270)}}function er(e,t){e.value=e.value.replace(/(^-?)(?:\*(\d))?([^-].*$)/,(e,n,o,a)=>{let l=(Number(o||0)+t)%P.mi.full;return n+(l?"*"+l:"")+a}),(0,S.uu)()}function es(e){if(et=performance.now(),b.SB.popeye.playing||b.i7.loading||0!=e.button&&!e.targetTouches||e.targetTouches&&e.targetTouches.length>1)return;let t=H(e);document.activeElement&&document.activeElement.blur();let n=this!=_.in,{offset:o,s:u}=n?(0,b.nj)():(0,b.nj)(_.in,b.i7.hor),{w:d,h:f}=b.h.board;X.x=t.offsetX,X.y=t.offsetY;let[p,m]=[o.x,o.y];J.x=Math.floor((X.x-p)/u),J.y=Math.floor((X.y-m)/u);let h=J.y*(n?d:E._N)+J.x;r=n?_.S8:_.Ab;let g=b.i7.selection;if(n&&g)return function(e,t,n,o,a){if(e.preventDefault(),eu(J.x,J.y,t,n)){let e=S.xG[a];e.value==o?e.value="":e.value=o,(0,S.uu)()}else ea()}(t,d,f,g,h);if(!b.SB.play.playing||(!n&&function(e){if(b.SB.play.pendingPromotion){b.i7.hor&&([J.x,J.y]=[J.y,J.x]);let e="p"==s?0:1;if(J.y>P.wg.k&&J.y-1&&t-1&&e{if(b.SB.stockfish.lines.length){let e=b.SB.stockfish.lines,t=b.SB.stockfish.header;b.SB.stockfish.lines=[],b.SB.stockfish.header=[],T().then(n=>{f=n,b.SB.stockfish.lines=e,b.SB.stockfish.header=t})}}),window.cmd=em;let eh="(".concat(ep.SQ,")(").concat(ep.SQ,")([qrbn]?)"),eg="modules/stockfish/",ey=x.OB.thread?"":"-single",eb=["".concat(eg,"stockfish-nnue-16.js#stockfish-nnue-16.wasm,worker"),"".concat(eg,"stockfish-nnue-16.wasm"),"".concat(eg,"stockfish-nnue-16-single.js#stockfish-nnue-16-single.wasm,worker"),"".concat(eg,"stockfish-nnue-16-single.wasm"),"".concat(eg,"nn-5af11540bbfe.nnue")];function ev(e){return d?Promise.resolve():new Promise((t,n)=>{b.i7.stockfish.running=P.MI.starting,(d=new Worker("".concat(eg,"stockfish-nnue-16").concat(ey,".js#stockfish-nnue-16").concat(ey,".wasm"))).onmessage=e=>{let n=e.data;console.info(n),"readyok"==n&&(b.i7.stockfish.running=P.MI.running,t()),n.startsWith("info ")&&function(e){let t;if(b.i7.stockfish.running!=P.MI.running)return;let n=e.match(/multipv (\d+)/);if(!n)return;let o=Number(n[1])-1,a=e.match(/mate (-?)(\d+)/),l=e.match(/score cp (-?\d+)/),i=Number(l&&l[1]||0)/100;if(a){let e="w"==m.split(" ")[1]==!!a[1]?"Black":"White";t=Number(a[2])+b.SB.stockfish.header.length/2,0==o&&(b.SB.stockfish.mate=[e,t])}if(0==o){let t=e.match(/depth (\d+)/);t&&(b.SB.stockfish.depth=t[1]),l&&(b.SB.stockfish.score=i)}let r=e.match(new RegExp("pv (".concat(eh,"(?: ").concat(eh,")*)")));if(r){var s;if((null===(s=b.SB.stockfish.lines[o])||void 0===s?void 0:s.raw)==r[1])return;let e=r[1].split(" ").map(e=>e.match(new RegExp(eh)));b.SB.stockfish.moves=[];let t=b.SB.stockfish.header;for(let n of(p.init(t.length?t[t.length-1].after:m),e))if(p.move({from:n[1],to:n[2],promotion:n[3]}).san.endsWith("=")){i=0;break}let n={rawScore:function(e,t){return e?e[1]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY:t}(a,i),score:a?a[1]+"#"+a[2]:i.toFixed(2),raw:r[1],moves:p.state.history.concat(),pgn:p.copyPGN(t)};b.SB.stockfish.lines[o]=n}b.h.Stockfish.study&&eS()}(n.substring(5)),n.match(new RegExp("^bestmove ".concat(eh)))&&function(){let e=b.h.Stockfish.depth;if(b.h.Stockfish.study&&!(e<4)&&eS()){let t=b.SB.stockfish.header;t.push(...b.SB.stockfish.lines["0"].moves.slice(0,2)),em("position fen "+t[t.length-1].after),em("go depth "+e)}else ek.stop()}()},d.onerror=e=>{e.message.includes("RangeError")?n(-1):e.message.includes("memory")?n("Not enough memory."):n("Unknown error has occurred.")},em("uci"),em("setoption name Use NNUE value true"),x.OB.thread&&em("setoption name Threads value "+Math.max(2,navigator.hardwareConcurrency-4)),em("setoption name Hash value "+e),em("isready")})}function eS(){let e=b.SB.stockfish.lines.filter(e=>e&&e.moves.length);if(e.length<=1)return!1;e.forEach(e=>e.moves[0]&&(e.moves[0].annotation=void 0));let t=e.filter(e=>e.rawScore>1);if(t.length>1)return!1;if(1==t.length)return t[0].moves[0].annotation="!",!0;let n=e.filter(e=>e.rawScore>-1);return 1==n.length&&(n[0].moves[0].annotation="!",!0)}async function ew(e){if(200!=(await fetch(e)).status)throw Error()}async function e_(e,t){try{await e}catch(e){if(-1!==e)throw e;if(ek.stop(),(t/=2)<4)throw Error("Not enough memory.");await e_(ev(t),t)}}let ek={async download(){gtag("event","fen_stockfish_download"),b.i7.stockfish.status=P.KO.downloading,isHttps&&"serviceWorker"in navigator&&await navigator.serviceWorker.ready;try{await Promise.all(eb.map(e=>ew(e)))}catch{(0,B.Z)("Download failed. Please check your network connection."),b.i7.stockfish.status=P.KO.notDownloaded;return}b.h.Stockfish.downloaded=!0,b.i7.stockfish.status=P.KO.needReload},async analyze(){try{gtag("event","fen_stockfish_run");let e=ev(128);if(!(m=(0,S.mj)()))throw Error("Only orthodox chess is supported.");if(!f){let e=await T();!f&&(f=e)}(p=new f.Chess).init(m),await e_(e,128),b.SB.stockfish=(0,ef.d)(b.bi),em("setoption name MultiPV value "+b.h.Stockfish.lines),em("ucinewgame"),em("position fen "+m),em("go depth "+b.h.Stockfish.depth)}catch(e){ek.stop(),(0,B.Z)(e instanceof Error?e.message:e),b.i7.stockfish.running=P.MI.stop}},play(e){gtag("event","fen_stockfish_play"),b.SB.play.mode="normal",b.SB.tab=6,F(e.pgn)},stop(){d&&d.terminate(),d=void 0,b.i7.stockfish.running=P.MI.stop},format:e=>f.formatGame(e)};(0,b.t4)(()=>{if(b.SB.syzygy.lines){let e=b.SB.syzygy.lines;e.forEach(e=>e.searching=!1),b.SB.syzygy.lines=[],T().then(t=>{h=t,b.SB.syzygy.lines=e})}});let eU=new Set;function ex(e){return new Promise(t=>{eU.add(t),setTimeout(()=>{eU.delete(t),t()},e*E.WT)})}async function eB(e,t){try{if(!t.running)return null;let n=t.ready;if(t.ready=n.then(()=>ex(1)),await n,!t.running)return null;let o=await fetch("https://tablebase.lichess.ovh/standard?fen="+e);if(429==o.status)return await ex(61),await eB(e,t);return await o.json()}catch{throw Error("Unable to connect to the server. Please check your network connection.")}}async function eC(e){let t=new(h=await T()).Chess;t.init(e.fen);let n=await eB(t.fen(),e),o="w"==t.turn()?"White":"Black",a=n.category;if(b.SB.syzygy.header="The position is a ".concat(a," for ").concat(o,"."),"unknown"==a||a.includes("loss")||!e.running)return;for(let o of(b.SB.syzygy.lines=[],e.outcome=a,e.op=function(e){return"draw"==e?e:eE[eP.indexOf(e)]}(a),n.moves.filter(t=>t.category==e.op))){t.init(e.fen);let[n,a,l]=o.uci.match(/..|./g);t.move({from:n,to:a,promotion:l});let i=t.fen();e.positions.add(eD(i));let r={fen:i,dtm:o.dtm,indent:0,history:t.state.history.concat(),leaf:!0,moves:t.state.history.concat(),pgn:t.copyPGN(),transpose:!1,searching:!t.isGameOver()};b.SB.syzygy.lines.push(r)}if(!e.running)return;let l=b.SB.syzygy.lines.filter(e=>e.searching);if(!(l.length>1))for(l[0].moves[0].annotation="!";l.length;){let t=l.map(t=>eA(t,e));if(await Promise.all(t),l=b.SB.syzygy.lines.filter(e=>e.searching),!e.running)return}}function eD(e){return e.replace(/ \d+ \d+$/,"")}async function eA(e,t){let n=new h.Chess;n.init(e.fen);let o="number"==typeof e.dtm,a=n.moves({verbose:!0}),l=new Set((await eB(e.fen,t)).moves.filter(e=>e.category==t.outcome).map(e=>e.uci)),i=a.filter(e=>l.has(e.from+e.to+(e.promotion||""))).map(e=>eN(e,t,o)),r=(await Promise.all(i)).filter(e=>e).sort((e,t)=>t.score-e.score).filter((e,t,n)=>e.score==n[0].score);if(e.searching&&(e.searching=!1),!t.running)return;let s=r.filter(e=>"draw"!=t.op&&e.moves.length>0||1==e.moves.length);if(0==s.length)return;let c=1==s.length,u=s.map(o=>(function(e,t,n,o,a){o.init(t.fen);let l=o.move(e.defense);n&&(l.annotation="!");let[i,r,s]=e.moves[0].uci.match(/..|./g),c=o.move({from:i,to:r,promotion:s});1==e.moves.length&&(c.annotation="!");let u=o.fen(),d=eD(u),f=a.positions.has(d);!f&&a.positions.add(d);let p=o.state.history.concat();return{dtm:"number"==typeof e.dtm?1-e.dtm:null,fen:u,transpose:f,leaf:!0,indent:t.indent+(n?0:1),history:t.history.concat(p),moves:n?t.moves.concat(p):p,pgn:o.copyPGN(t.history),searching:!o.isGameOver()&&!f}})(o,e,c,n,t)),d=b.SB.syzygy.lines.concat(),f=d.indexOf(e);c?d.splice(f,1,...u):(e.leaf=!1,d.splice(f+1,0,...u)),b.SB.syzygy.lines=d}async function eN(e,t,n){let o=await eB(e.after,t);if(!t.running)return null;let a=o.moves.filter(e=>e.category==t.op);return{score:(n?o.dtm:0)-a.length,json:o,dtm:o.dtm,defense:e,moves:a}}let eP=["win","maybe-win","cursed-win"],eE=["loss","maybe-loss","blessed-loss"],eI={async run(){let e={positions:new Set,running:!0,ready:Promise.resolve()};g=e;try{var t;if(gtag("event","fen_syzygy_run"),b.i7.syzygy.running=!0,b.SB.syzygy.header=null,b.SB.syzygy.lines=null,e.fen=(0,S.mj)(),!e.fen)throw Error("Only orthodox chess is supported.");if((null===(t=e.fen.split(" ")[0].match(/[a-z]/ig))||void 0===t?void 0:t.length)>7)throw Error("Only supports position with up to ".concat(7," pieces."));await eC(e)}catch(e){(0,B.Z)(e instanceof Error?e.message:e)}finally{e.running&&eI.stop()}},play(e){gtag("event","fen_syzygy_play"),b.SB.play.mode="normal",b.SB.tab=6,F(e.pgn)},stop(){var e;for(let e of(g&&(g.running=!1),eU))e();eU.clear(),null===(e=b.SB.syzygy.lines)||void 0===e||e.forEach(e=>e.searching=!1),b.i7.syzygy.running=!1},format(e){let t=h.formatGame(e.moves);return e.searching?t+=" ...":e.transpose&&(t+=" (transpose)"),t}};var eR=n("4486"),eO=n.n(eR);let eM={class:"modal-dialog modal-dialog-centered"},eW={class:"modal-content"},ej=["innerHTML"],eV={class:"modal-footer"},eT=Promise.resolve(),eL=(0,y.aZ)({name:"DialogModal",__name:"dialog",setup(e,t){let n,{expose:o}=t,a=(0,y.XI)();(0,y.bv)(()=>{n=new(eO())(a.value,{backdrop:"static"})});let l=(0,y.XI)("");return o({show:async function e(e,t){let o;let i=eT;return eT=new Promise(e=>{o=e}),await i,new Promise(i=>{l.value=e.replace(/\n/g,"
"),a.value.addEventListener("hide.bs.modal",()=>{i()},{once:!0}),a.value.addEventListener("hidden.bs.modal",o,{once:!0}),null==t||t(),n.show()})},hide:()=>n.hide()}),(e,t)=>((0,y.wg)(),(0,y.iD)("div",{class:"modal fade modal-second",ref_key:"el",ref:a},[(0,y._)("div",eM,[(0,y._)("div",eW,[(0,y._)("div",{class:"modal-body",innerHTML:l.value},null,8,ej),(0,y._)("div",eV,[(0,y.WI)(e.$slots,"default")])])])],512))}}),ez=(0,y.aZ)({name:"Alert",__name:"alert",setup(e,t){let{expose:n}=t,o=(0,y.XI)();function a(e){return o.value.show(e)}return(0,y.bv)(()=>B.Z.setup(a)),n({show:a}),(e,t)=>((0,y.wg)(),(0,y.j4)(eL,{ref_key:"dialog",ref:o},{default:(0,y.w5)(()=>t[0]||(t[0]=[(0,y._)("button",{type:"button",class:"btn btn-primary","data-bs-dismiss":"modal"},"OK",-1)])),_:1},512))}}),eq=(0,y.aZ)({name:"Confirm",__name:"confirm",setup(e,t){let{expose:n}=t,o=!1,a=(0,y.XI)();async function l(e){return await a.value.show(e,()=>o=!1),o}function i(){o=!0,a.value.hide()}return(0,y.bv)(()=>B.i.setup(l)),n({show:l}),(e,t)=>((0,y.wg)(),(0,y.j4)(eL,{ref_key:"dialog",ref:a},{default:(0,y.w5)(()=>[t[0]||(t[0]=(0,y._)("button",{type:"button",class:"btn btn-secondary","data-bs-dismiss":"modal"},"No",-1)),(0,y._)("button",{type:"button",class:"btn btn-primary",onClick:i},"Yes")]),_:1},512))}}),eF={class:"nav-item"},eQ=["title"],eY={class:"d-sm-none"},eK={class:"d-none d-sm-inline"},eG=(0,y.aZ)({__name:"menuTab",props:{index:{},icon:{},title:{}},setup:e=>(e,t)=>((0,y.wg)(),(0,y.iD)("li",eF,[(0,y._)("div",{class:(0,y.C_)(["nav-link",{active:(0,y.SU)(b.SB).tab==e.index}]),onClick:t[0]||(t[0]=t=>(0,y.SU)(b.SB).tab=e.index),title:e.title},[(0,y._)("span",eY,[(0,y._)("i",{class:(0,y.C_)(e.icon)},null,2)]),(0,y._)("span",eK,[(0,y.WI)(e.$slots,"default")])],10,eQ)]))}),eH={class:"nav nav-tabs pe-1",style:{"flex-wrap":"nowrap"}},eZ=(0,y.aZ)({__name:"menu",setup:e=>(e,t)=>((0,y.wg)(),(0,y.iD)("div",{class:(0,y.C_)(["mb-3 nav-container",{"mt-n3":(0,y.SU)(b.u8)()}])},[(0,y._)("ul",eH,[(0,y.Wm)(eG,{index:0,icon:"fa-solid fa-pen-to-square",title:"Edit"},{default:(0,y.w5)(()=>t[0]||(t[0]=[(0,y.Uk)("Edit")])),_:1}),(0,y.Wm)(eG,{index:8,icon:"fa-solid fa-chess-board",title:"Project"},{default:(0,y.w5)(()=>t[1]||(t[1]=[(0,y.Uk)("Project")])),_:1}),(0,y.Wm)(eG,{index:1,icon:"fa-solid fa-gear",title:"Options"},{default:(0,y.w5)(()=>t[2]||(t[2]=[(0,y.Uk)("Options")])),_:1}),(0,y.Wm)(eG,{index:7,icon:"fa-solid fa-calculator",title:"Compute"},{default:(0,y.w5)(()=>t[3]||(t[3]=[(0,y.Uk)("Compute")])),_:1}),(0,y.Wm)(eG,{index:6,icon:"fa-solid fa-gamepad",title:"Play"},{default:(0,y.w5)(()=>t[4]||(t[4]=[(0,y.Uk)("Play")])),_:1}),(0,y.Wm)(eG,{index:2,icon:"fa-solid fa-database",title:"Database"},{default:(0,y.w5)(()=>t[5]||(t[5]=[(0,y.Uk)("DB")])),_:1}),(0,y.SU)(b.i7).envReady&&(0,y.SU)(x.OB).isTaiwan?((0,y.wg)(),(0,y.j4)(eG,{key:0,index:4,icon:"fa-solid fa-terminal",title:"BBS"},{default:(0,y.w5)(()=>t[6]||(t[6]=[(0,y.Uk)("BBS")])),_:1})):(0,y.kq)("",!0),(0,y.Wm)(eG,{index:5,icon:"fa-solid fa-share-from-square",title:"API"},{default:(0,y.w5)(()=>t[7]||(t[7]=[(0,y.Uk)("API")])),_:1})])],2))});function e$(e){return new URL(e,location.href).toString()}function eX(){let{SN:e,w:t,h:n}=b.h.board;return e?(0,N.N0)((0,S.xL)(),t,n):S.RI.value}function eJ(){let e=b.h.board,t=eX(),n=e$("gen/?fen="+t);return e.size!=K.Cg&&(n+="&size="+e.size),e.set!=K.z6&&(n+="&set="+e.set),e.pattern&&(n+="&pattern="+e.pattern),e.bg&&(n+="&bg="+e.bg),"1"!=e.border&&(n+="&border="+e.border),e.blackWhite&&(n+="&blackWhite&knightOffset="+e.knightOffset),!(0,N.A1)(t)&&(n+="&w=".concat(e.w,"&h=").concat(e.h)),n}let e0={copyJanko:()=>(gtag("event","fen_copy_janko"),"https://www.janko.at/Retros/d.php?ff="+eX()),copyBase64:()=>(gtag("event","fen_link_copy64"),k.Uw.toDataURL()),copyBase64Img:()=>(gtag("event","fen_link_copy64img"),'')),async copyUrl(){gtag("event","fen_gen_link");let e=new FormData,t=await (0,k.Br)();e.append("key","7802c5da1788f2315222d44bfba20519"),e.append("image",t,"fen");try{let t=await fetch("https://api.imgbb.com/1/upload",{method:"post",body:e}),n=await t.json();if(!n.success)throw n.error.message;return n.data.url+"?="+eX()}catch(e){throw(0,B.Z)("string"==typeof e?e:"Internet connection failed. Please try again later."),e}},copyEmbed(){gtag("event","fen_copy_embed");let e=b.h.board,t=eJ(),{w:n,h:o}=(0,K.t_)(e);return'')},copyEmbedUrl:()=>(gtag("event","fen_copy_embedUrl"),eJ()),copyImg:()=>(gtag("event","fen_copy_sdkImg"),'')),copySDK(){gtag("event","fen_copy_sdk");let e=b.h.board,t="";return e.size!=K.Cg&&(t+=' data-size="'.concat(e.size,'"')),e.set!=K.z6&&(t+=' data-set="'.concat(e.set,'"')),e.bg&&(t+=' data-bg="'.concat(e.bg,'"')),"1"!=e.border&&(t+=' data-border="'.concat(e.border,'"')),e.blackWhite&&(t+=' data-black-white="true" data-knight-offset="'.concat(e.knightOffset,'"')),'