Guest User

Fixed Lichess Script

a guest
Apr 9th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. console.log(2);
  2. var LichessRound = function(e) {
  3.     "use strict";
  4.     const t = {
  5.         createElement: function(e, t) {
  6.             return document.createElement(e, t)
  7.         },
  8.         createElementNS: function(e, t, o) {
  9.             return document.createElementNS(e, t, o)
  10.         },
  11.         createTextNode: function(e) {
  12.             return document.createTextNode(e)
  13.         },
  14.         createComment: function(e) {
  15.             return document.createComment(e)
  16.         },
  17.         insertBefore: function(e, t, o) {
  18.             e.insertBefore(t, o)
  19.         },
  20.         removeChild: function(e, t) {
  21.             e.removeChild(t)
  22.         },
  23.         appendChild: function(e, t) {
  24.             e.appendChild(t)
  25.         },
  26.         parentNode: function(e) {
  27.             return e.parentNode
  28.         },
  29.         nextSibling: function(e) {
  30.             return e.nextSibling
  31.         },
  32.         tagName: function(e) {
  33.             return e.tagName
  34.         },
  35.         setTextContent: function(e, t) {
  36.             e.textContent = t
  37.         },
  38.         getTextContent: function(e) {
  39.             return e.textContent
  40.         },
  41.         isElement: function(e) {
  42.             return 1 === e.nodeType
  43.         },
  44.         isText: function(e) {
  45.             return 3 === e.nodeType
  46.         },
  47.         isComment: function(e) {
  48.             return 8 === e.nodeType
  49.         }
  50.     };
  51.  
  52.     function o(e, t, o, n, s) {
  53.         return {
  54.             sel: e,
  55.             data: t,
  56.             children: o,
  57.             text: n,
  58.             elm: s,
  59.             key: void 0 === t ? void 0 : t.key
  60.         }
  61.     }
  62.     const n = Array.isArray;
  63.  
  64.     function s(e) {
  65.         return "string" == typeof e || "number" == typeof e
  66.     }
  67.  
  68.     function r(e) {
  69.         return void 0 === e
  70.     }
  71.  
  72.     function i(e) {
  73.         return void 0 !== e
  74.     }
  75.     const a = o("", {}, [], void 0, void 0);
  76.  
  77.     function c(e, t) {
  78.         var o, n;
  79.         const s = e.key === t.key,
  80.             r = (null === (o = e.data) || void 0 === o ? void 0 : o.is) === (null === (n = t.data) || void 0 === n ? void 0 : n.is);
  81.         return e.sel === t.sel && s && r
  82.     }
  83.  
  84.     function l(e, t, o) {
  85.         var n;
  86.         const s = {};
  87.         for (let r = t; r <= o; ++r) {
  88.             const t = null === (n = e[r]) || void 0 === n ? void 0 : n.key;
  89.             void 0 !== t && (s[t] = r)
  90.         }
  91.         return s
  92.     }
  93.     const d = ["create", "update", "remove", "destroy", "pre", "post"];
  94.  
  95.     function u(e, u) {
  96.         let h, p;
  97.         const m = {
  98.                 create: [],
  99.                 update: [],
  100.                 remove: [],
  101.                 destroy: [],
  102.                 pre: [],
  103.                 post: []
  104.             },
  105.             f = void 0 !== u ? u : t;
  106.         for (h = 0; h < d.length; ++h)
  107.             for (m[d[h]] = [], p = 0; p < e.length; ++p) {
  108.                 const t = e[p][d[h]];
  109.                 void 0 !== t && m[d[h]].push(t)
  110.             }
  111.  
  112.         function g(e) {
  113.             const t = e.id ? "#" + e.id : "",
  114.                 n = e.className ? "." + e.className.split(" ").join(".") : "";
  115.             return o(f.tagName(e).toLowerCase() + t + n, {}, [], void 0, e)
  116.         }
  117.  
  118.         function v(e, t) {
  119.             return function() {
  120.                 if (0 == --t) {
  121.                     const t = f.parentNode(e);
  122.                     f.removeChild(t, e)
  123.                 }
  124.             }
  125.         }
  126.  
  127.         function b(e, t) {
  128.             var o, c;
  129.             let l, d = e.data;
  130.             if (void 0 !== d) {
  131.                 const t = null === (o = d.hook) || void 0 === o ? void 0 : o.init;
  132.                 i(t) && (t(e), d = e.data)
  133.             }
  134.             const u = e.children,
  135.                 h = e.sel;
  136.             if ("!" === h) r(e.text) && (e.text = ""), e.elm = f.createComment(e.text);
  137.             else if (void 0 !== h) {
  138.                 const o = h.indexOf("#"),
  139.                     r = h.indexOf(".", o),
  140.                     p = o > 0 ? o : h.length,
  141.                     g = r > 0 ? r : h.length,
  142.                     v = -1 !== o || -1 !== r ? h.slice(0, Math.min(p, g)) : h,
  143.                     y = e.elm = i(d) && i(l = d.ns) ? f.createElementNS(l, v, d) : f.createElement(v, d);
  144.                 for (p < g && y.setAttribute("id", h.slice(p + 1, g)), r > 0 && y.setAttribute("class", h.slice(g + 1).replace(/\./g, " ")), l = 0; l < m.create.length; ++l) m.create[l](a, e);
  145.                 if (n(u))
  146.                     for (l = 0; l < u.length; ++l) {
  147.                         const e = u[l];
  148.                         null != e && f.appendChild(y, b(e, t))
  149.                     } else s(e.text) && f.appendChild(y, f.createTextNode(e.text));
  150.                 const w = e.data.hook;
  151.                 i(w) && (null === (c = w.create) || void 0 === c || c.call(w, a, e), w.insert && t.push(e))
  152.             } else e.elm = f.createTextNode(e.text);
  153.             return e.elm
  154.         }
  155.  
  156.         function y(e, t, o, n, s, r) {
  157.             for (; n <= s; ++n) {
  158.                 const s = o[n];
  159.                 null != s && f.insertBefore(e, b(s, r), t)
  160.             }
  161.         }
  162.  
  163.         function w(e) {
  164.             var t, o;
  165.             const n = e.data;
  166.             if (void 0 !== n) {
  167.                 null === (o = null === (t = null == n ? void 0 : n.hook) || void 0 === t ? void 0 : t.destroy) || void 0 === o || o.call(t, e);
  168.                 for (let t = 0; t < m.destroy.length; ++t) m.destroy[t](e);
  169.                 if (void 0 !== e.children)
  170.                     for (let t = 0; t < e.children.length; ++t) {
  171.                         const o = e.children[t];
  172.                         null != o && "string" != typeof o && w(o)
  173.                     }
  174.             }
  175.         }
  176.  
  177.         function k(e, t, o, n) {
  178.             for (var s, r; o <= n; ++o) {
  179.                 let n, a;
  180.                 const c = t[o];
  181.                 if (null != c)
  182.                     if (i(c.sel)) {
  183.                         w(c), n = m.remove.length + 1, a = v(c.elm, n);
  184.                         for (let e = 0; e < m.remove.length; ++e) m.remove[e](c, a);
  185.                         const e = null === (r = null === (s = null == c ? void 0 : c.data) || void 0 === s ? void 0 : s.hook) || void 0 === r ? void 0 : r.remove;
  186.                         i(e) ? e(c, a) : a()
  187.                     } else f.removeChild(e, c.elm)
  188.             }
  189.         }
  190.  
  191.         function P(e, t, o) {
  192.             var n, s, a, d, u;
  193.             const h = null === (n = t.data) || void 0 === n ? void 0 : n.hook;
  194.             null === (s = null == h ? void 0 : h.prepatch) || void 0 === s || s.call(h, e, t);
  195.             const p = t.elm = e.elm,
  196.                 g = e.children,
  197.                 v = t.children;
  198.             if (e !== t) {
  199.                 if (void 0 !== t.data) {
  200.                     for (let o = 0; o < m.update.length; ++o) m.update[o](e, t);
  201.                     null === (d = null === (a = t.data.hook) || void 0 === a ? void 0 : a.update) || void 0 === d || d.call(a, e, t)
  202.                 }
  203.                 r(t.text) ? i(g) && i(v) ? g !== v && function(e, t, o, n) {
  204.                     let s, i, a, d, u = 0,
  205.                         h = 0,
  206.                         p = t.length - 1,
  207.                         m = t[0],
  208.                         g = t[p],
  209.                         v = o.length - 1,
  210.                         w = o[0],
  211.                         M = o[v];
  212.                     for (; u <= p && h <= v;) null == m ? m = t[++u] : null == g ? g = t[--p] : null == w ? w = o[++h] : null == M ? M = o[--v] : c(m, w) ? (P(m, w, n), m = t[++u], w = o[++h]) : c(g, M) ? (P(g, M, n), g = t[--p], M = o[--v]) : c(m, M) ? (P(m, M, n), f.insertBefore(e, m.elm, f.nextSibling(g.elm)), m = t[++u], M = o[--v]) : c(g, w) ? (P(g, w, n), f.insertBefore(e, g.elm, m.elm), g = t[--p], w = o[++h]) : (void 0 === s && (s = l(t, u, p)), i = s[w.key], r(i) ? f.insertBefore(e, b(w, n), m.elm) : (a = t[i], a.sel !== w.sel ? f.insertBefore(e, b(w, n), m.elm) : (P(a, w, n), t[i] = void 0, f.insertBefore(e, a.elm, m.elm))), w = o[++h]);
  213.                     (u <= p || h <= v) && (u > p ? (d = null == o[v + 1] ? null : o[v + 1].elm, y(e, d, o, h, v, n)) : k(e, t, u, p))
  214.                 }(p, g, v, o) : i(v) ? (i(e.text) && f.setTextContent(p, ""), y(p, null, v, 0, v.length - 1, o)) : i(g) ? k(p, g, 0, g.length - 1) : i(e.text) && f.setTextContent(p, "") : e.text !== t.text && (i(g) && k(p, g, 0, g.length - 1), f.setTextContent(p, t.text)), null === (u = null == h ? void 0 : h.postpatch) || void 0 === u || u.call(h, e, t)
  215.             }
  216.         }
  217.         return function(e, t) {
  218.             let o, n, s;
  219.             const r = [];
  220.             for (o = 0; o < m.pre.length; ++o) m.pre[o]();
  221.             for (function(e) {
  222.                     return void 0 !== e.sel
  223.                 }(e) || (e = g(e)), c(e, t) ? P(e, t, r) : (n = e.elm, s = f.parentNode(n), b(t, r), null !== s && (f.insertBefore(s, t.elm, f.nextSibling(n)), k(s, [e], 0, 0))), o = 0; o < r.length; ++o) r[o].data.hook.insert(r[o]);
  224.             for (o = 0; o < m.post.length; ++o) m.post[o]();
  225.             return t
  226.         }
  227.     }
  228.  
  229.     function h(e, t, o) {
  230.         if (e.ns = "http://www.w3.org/2000/svg", "foreignObject" !== o && void 0 !== t)
  231.             for (let e = 0; e < t.length; ++e) {
  232.                 const o = t[e].data;
  233.                 void 0 !== o && h(o, t[e].children, t[e].sel)
  234.             }
  235.     }
  236.  
  237.     function p(e, t, r) {
  238.         let i, a, c, l = {};
  239.         if (void 0 !== r ? (null !== t && (l = t), n(r) ? i = r : s(r) ? a = r : r && r.sel && (i = [r])) : null != t && (n(t) ? i = t : s(t) ? a = t : t && t.sel ? i = [t] : l = t), void 0 !== i)
  240.             for (c = 0; c < i.length; ++c) s(i[c]) && (i[c] = o(void 0, void 0, void 0, i[c], void 0));
  241.         return "s" !== e[0] || "v" !== e[1] || "g" !== e[2] || 3 !== e.length && "." !== e[3] && "#" !== e[3] || h(l, i, e), o(e, l, i, a, void 0)
  242.     }
  243.  
  244.     function m(e, t) {
  245.         e.data.fn = t.data.fn, e.data.args = t.data.args, t.data = e.data, t.children = e.children, t.text = e.text, t.elm = e.elm
  246.     }
  247.  
  248.     function f(e) {
  249.         const t = e.data;
  250.         m(t.fn(...t.args), e)
  251.     }
  252.  
  253.     function g(e, t) {
  254.         let o;
  255.         const n = e.data,
  256.             s = t.data,
  257.             r = n.args,
  258.             i = s.args;
  259.         if (n.fn === s.fn && r.length === i.length) {
  260.             for (o = 0; o < i.length; ++o)
  261.                 if (r[o] !== i[o]) return void m(s.fn(...i), t);
  262.             m(e, t)
  263.         } else m(s.fn(...i), t)
  264.     }
  265.  
  266.     function v(e, t) {
  267.         const o = e.data.attachData;
  268.         t.data.attachData.placeholder = o.placeholder, t.data.attachData.real = o.real, e.elm = e.data.attachData.real
  269.     }
  270.  
  271.     function b(e, t) {
  272.         t.elm = t.data.attachData.placeholder
  273.     }
  274.  
  275.     function y(e) {
  276.         void 0 !== e.elm && e.elm.parentNode.removeChild(e.elm), e.elm = e.data.attachData.real
  277.     }
  278.  
  279.     function w(e, t) {
  280.         const o = t.elm,
  281.             n = t.data.attachData,
  282.             s = document.createElement("span");
  283.         t.elm = s, n.target.appendChild(o), n.real = o, n.placeholder = s
  284.     }
  285.  
  286.     function k(e, t) {
  287.         let o;
  288.         const n = t.elm;
  289.         let s = e.data.attrs,
  290.             r = t.data.attrs;
  291.         if ((s || r) && s !== r) {
  292.             for (o in s = s || {}, r = r || {}, r) {
  293.                 const e = r[o];
  294.                 s[o] !== e && (!0 === e ? n.setAttribute(o, "") : !1 === e ? n.removeAttribute(o) : 120 !== o.charCodeAt(0) ? n.setAttribute(o, e) : 58 === o.charCodeAt(3) ? n.setAttributeNS("http://www.w3.org/XML/1998/namespace", o, e) : 58 === o.charCodeAt(5) ? n.setAttributeNS("http://www.w3.org/1999/xlink", o, e) : n.setAttribute(o, e))
  295.             }
  296.             for (o in s) o in r || n.removeAttribute(o)
  297.         }
  298.     }
  299.     const P = {
  300.         create: k,
  301.         update: k
  302.     };
  303.  
  304.     function M(e, t) {
  305.         let o, n;
  306.         const s = t.elm;
  307.         let r = e.data.class,
  308.             i = t.data.class;
  309.         if ((r || i) && r !== i) {
  310.             for (n in r = r || {}, i = i || {}, r) r[n] && !Object.prototype.hasOwnProperty.call(i, n) && s.classList.remove(n);
  311.             for (n in i) o = i[n], o !== r[n] && s.classList[o ? "add" : "remove"](n)
  312.         }
  313.     }
  314.     const C = {
  315.             create: M,
  316.             update: M
  317.         },
  318.         T = /[A-Z]/g;
  319.  
  320.     function x(e, t) {
  321.         const o = t.elm;
  322.         let n, s = e.data.dataset,
  323.             r = t.data.dataset;
  324.         if (!s && !r) return;
  325.         if (s === r) return;
  326.         s = s || {}, r = r || {};
  327.         const i = o.dataset;
  328.         for (n in s) r[n] || (i ? n in i && delete i[n] : o.removeAttribute("data-" + n.replace(T, "-$&").toLowerCase()));
  329.         for (n in r) s[n] !== r[n] && (i ? i[n] = r[n] : o.setAttribute("data-" + n.replace(T, "-$&").toLowerCase(), r[n]))
  330.     }
  331.     const S = {
  332.         create: x,
  333.         update: x
  334.     };
  335.  
  336.     function O(e, t, o) {
  337.         if ("function" == typeof e) e.call(t, o, t);
  338.         else if ("object" == typeof e)
  339.             for (let n = 0; n < e.length; n++) O(e[n], t, o)
  340.     }
  341.  
  342.     function _(e, t) {
  343.         const o = e.type,
  344.             n = t.data.on;
  345.         n && n[o] && O(n[o], t, e)
  346.     }
  347.  
  348.     function A(e, t) {
  349.         const o = e.data.on,
  350.             n = e.listener,
  351.             s = e.elm,
  352.             r = t && t.data.on,
  353.             i = t && t.elm;
  354.         let a;
  355.         if (o !== r) {
  356.             if (o && n)
  357.                 if (r)
  358.                     for (a in o) r[a] || s.removeEventListener(a, n, !1);
  359.                 else
  360.                     for (a in o) s.removeEventListener(a, n, !1);
  361.             if (r) {
  362.                 const n = t.listener = e.listener || function e(t) {
  363.                     _(t, e.vnode)
  364.                 };
  365.                 if (n.vnode = t, o)
  366.                     for (a in r) o[a] || i.addEventListener(a, n, !1);
  367.                 else
  368.                     for (a in r) i.addEventListener(a, n, !1)
  369.             }
  370.         }
  371.     }
  372.     const j = {
  373.             create: A,
  374.             update: A,
  375.             destroy: A
  376.         },
  377.         L = "undefined" != typeof window && window.requestAnimationFrame || setTimeout;
  378.  
  379.     function D(e, t, o) {
  380.         var n;
  381.         n = function() {
  382.             e[t] = o
  383.         }, L((function() {
  384.             L(n)
  385.         }))
  386.     }
  387.  
  388.     function E(e) {
  389.         let t;
  390.         if (document.createRange) {
  391.             const o = document.createRange();
  392.             o.selectNodeContents(e), o.getBoundingClientRect && (t = o.getBoundingClientRect())
  393.         }
  394.         return t
  395.     }
  396.  
  397.     function N(e, t, o) {
  398.         if (e && t) {
  399.             return `${t.left+t.width/2-o.left}px ${t.top+t.height/2-o.top}px`
  400.         }
  401.         return "0 0"
  402.     }
  403.  
  404.     function R(e, t) {
  405.         return e && t ? e.left + e.width / 2 - (t.left + t.width / 2) : 0
  406.     }
  407.  
  408.     function B(e, t) {
  409.         return e && t ? e.top + e.height / 2 - (t.top + t.height / 2) : 0
  410.     }
  411.  
  412.     function I(e) {
  413.         return 1 === e.childNodes.length && 3 === e.childNodes[0].nodeType
  414.     }
  415.     let q, F;
  416.     const G = {
  417.         pre: function() {
  418.             q = {}, F = []
  419.         },
  420.         create: function(e, t) {
  421.             const o = t.data.hero;
  422.             o && o.id && (F.push(o.id), F.push(t))
  423.         },
  424.         destroy: function(e) {
  425.             const t = e.data.hero;
  426.             if (t && t.id) {
  427.                 const o = e.elm;
  428.                 e.isTextNode = I(o), e.boundingRect = o.getBoundingClientRect(), e.textRect = e.isTextNode ? E(o.childNodes[0]) : null;
  429.                 const n = window.getComputedStyle(o, void 0);
  430.                 e.savedStyle = JSON.parse(JSON.stringify(n)), q[t.id] = e
  431.             }
  432.         },
  433.         post: function() {
  434.             let e, t, o, n, s, r, i, a, c, l, d, u, h, p, m, f, g, v, b;
  435.             for (e = 0; e < F.length; e += 2)
  436.                 if (t = F[e], o = F[e + 1].elm, n = q[t], n) {
  437.                     g = n.isTextNode && I(o), p = o.style, f = window.getComputedStyle(o, void 0), s = n.elm, m = s.style, c = o.getBoundingClientRect(), a = n.boundingRect, g ? (v = E(o.childNodes[0]), b = n.textRect, l = R(b, v), d = B(b, v)) : (l = a.left - c.left, d = a.top - c.top), r = c.height / Math.max(a.height, 1), i = g ? r : c.width / Math.max(a.width, 1), u = p.transform, h = p.transition, "inline" === f.display && (p.display = "inline-block"), p.transition = h + "transform 0s", p.transformOrigin = N(g, v, c), p.opacity = "0", p.transform = `${u}translate(${l}px, ${d}px) scale(${1/i}, ${1/r})`, D(p, "transition", h), D(p, "transform", u), D(p, "opacity", "1");
  438.                     for (const e in n.savedStyle)
  439.                         if (String(parseInt(e)) !== e) {
  440.                             const t = "ms" === e.substring(0, 2),
  441.                                 o = "moz" === e.substring(0, 3),
  442.                                 s = "webkit" === e.substring(0, 6);
  443.                             t || o || s || (m[e] = n.savedStyle[e])
  444.                         } m.position = "absolute", m.top = `${a.top}px`, m.left = `${a.left}px`, m.width = `${a.width}px`, m.height = `${a.height}px`, m.margin = "0", m.transformOrigin = N(g, b, a), m.transform = "", m.opacity = "1", document.body.appendChild(s), D(m, "transform", `translate(${-l}px, ${-d}px) scale(${i}, ${r})`), D(m, "opacity", "0"), s.addEventListener("transitionend", (function(e) {
  445.                         "transform" === e.propertyName && document.body.removeChild(e.target)
  446.                     }))
  447.                 } q = F = void 0
  448.         }
  449.     };
  450.  
  451.     function z(e, t) {
  452.         let o, n, s;
  453.         const r = t.elm;
  454.         let i = e.data.props,
  455.             a = t.data.props;
  456.         if ((i || a) && i !== a)
  457.             for (o in i = i || {}, a = a || {}, a) n = a[o], s = i[o], s === n || "value" === o && r[o] === n || (r[o] = n)
  458.     }
  459.     const K = {
  460.             create: z,
  461.             update: z
  462.         },
  463.         H = "undefined" != typeof window && window.requestAnimationFrame.bind(window) || setTimeout;
  464.     let V = !1;
  465.  
  466.     function U(e, t, o) {
  467.         var n;
  468.         n = function() {
  469.             e[t] = o
  470.         }, H((function() {
  471.             H(n)
  472.         }))
  473.     }
  474.  
  475.     function W(e, t) {
  476.         let o, n;
  477.         const s = t.elm;
  478.         let r = e.data.style,
  479.             i = t.data.style;
  480.         if (!r && !i) return;
  481.         if (r === i) return;
  482.         r = r || {}, i = i || {};
  483.         const a = "delayed" in r;
  484.         for (n in r) i[n] || ("-" === n[0] && "-" === n[1] ? s.style.removeProperty(n) : s.style[n] = "");
  485.         for (n in i)
  486.             if (o = i[n], "delayed" === n && i.delayed)
  487.                 for (const e in i.delayed) o = i.delayed[e], a && o === r.delayed[e] || U(s.style, e, o);
  488.             else "remove" !== n && o !== r[n] && ("-" === n[0] && "-" === n[1] ? s.style.setProperty(n, o) : s.style[n] = o)
  489.     }
  490.     const Y = {
  491.         pre: function() {
  492.             V = !1
  493.         },
  494.         create: W,
  495.         update: W,
  496.         destroy: function(e) {
  497.             let t, o;
  498.             const n = e.elm,
  499.                 s = e.data.style;
  500.             if (s && (t = s.destroy))
  501.                 for (o in t) n.style[o] = t[o]
  502.         },
  503.         remove: function(e, t) {
  504.             const o = e.data.style;
  505.             if (!o || !o.remove) return void t();
  506.             let n;
  507.             V || (e.elm.offsetLeft, V = !0);
  508.             const s = e.elm;
  509.             let r = 0;
  510.             const i = o.remove;
  511.             let a = 0;
  512.             const c = [];
  513.             for (n in i) c.push(n), s.style[n] = i[n];
  514.             const l = getComputedStyle(s)["transition-property"].split(", ");
  515.             for (; r < l.length; ++r) - 1 !== c.indexOf(l[r]) && a++;
  516.             s.addEventListener("transitionend", (function(e) {
  517.                 e.target === s && --a, 0 === a && t()
  518.             }))
  519.         }
  520.     };
  521.  
  522.     function X(e, t) {
  523.         for (const n of e) null != n && !1 !== n && "" !== n && (Array.isArray(n) ? X(n, t) : "string" == typeof n || "number" == typeof n || "boolean" == typeof n ? t.push(o(void 0, void 0, void 0, String(n), void 0)) : t.push(n));
  524.         return t
  525.     }
  526.  
  527.     function J(e, t, ...o) {
  528.         const n = X(o, []);
  529.         return "function" == typeof e ? e(t, n) : 1 === n.length && !n[0].sel && n[0].text ? p(e, t, n[0].text) : p(e, t, n)
  530.     }
  531.     J || (J = {});
  532.     var Z = Object.freeze({
  533.             __proto__: null,
  534.             htmlDomApi: t,
  535.             init: u,
  536.             thunk: function(e, t, o, n) {
  537.                 return void 0 === n && (n = o, o = t, t = void 0), p(e, {
  538.                     key: t,
  539.                     hook: {
  540.                         init: f,
  541.                         prepatch: g
  542.                     },
  543.                     fn: o,
  544.                     args: n
  545.                 })
  546.             },
  547.             vnode: o,
  548.             attachTo: function(e, t) {
  549.                 void 0 === t.data && (t.data = {}), void 0 === t.data.hook && (t.data.hook = {});
  550.                 const o = t.data,
  551.                     n = t.data.hook;
  552.                 return o.attachData = {
  553.                     target: e,
  554.                     placeholder: void 0,
  555.                     real: void 0
  556.                 }, n.create = w, n.prepatch = v, n.postpatch = b, n.destroy = y, t
  557.             },
  558.             array: n,
  559.             primitive: s,
  560.             toVNode: function e(n, s) {
  561.                 const r = void 0 !== s ? s : t;
  562.                 let i;
  563.                 if (r.isElement(n)) {
  564.                     const t = n.id ? "#" + n.id : "",
  565.                         i = n.getAttribute("class"),
  566.                         a = i ? "." + i.split(" ").join(".") : "",
  567.                         c = r.tagName(n).toLowerCase() + t + a,
  568.                         l = {},
  569.                         d = [];
  570.                     let u, h, p;
  571.                     const m = n.attributes,
  572.                         f = n.childNodes;
  573.                     for (h = 0, p = m.length; h < p; h++) u = m[h].nodeName, "id" !== u && "class" !== u && (l[u] = m[h].nodeValue);
  574.                     for (h = 0, p = f.length; h < p; h++) d.push(e(f[h], s));
  575.                     return o(c, {
  576.                         attrs: l
  577.                     }, d, void 0, n)
  578.                 }
  579.                 return r.isText(n) ? (i = r.getTextContent(n), o(void 0, void 0, void 0, i, n)) : r.isComment(n) ? (i = r.getTextContent(n), o("!", {}, [], i, n)) : o("", {}, [], void 0, n)
  580.             },
  581.             h: p,
  582.             attributesModule: P,
  583.             classModule: C,
  584.             datasetModule: S,
  585.             eventListenersModule: j,
  586.             heroModule: G,
  587.             propsModule: K,
  588.             styleModule: Y,
  589.             get jsx() {
  590.                 return J
  591.             }
  592.         }),
  593.         Q = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {};
  594.  
  595.     function ee(e) {
  596.         return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e
  597.     }
  598.  
  599.     function te(e, t, o) {
  600.         return e(o = {
  601.             path: t,
  602.             exports: {},
  603.             require: function(e, t) {
  604.                 return function() {
  605.                     throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")
  606.                 }(null == t && o.path)
  607.             }
  608.         }, o.exports), o.exports
  609.     }
  610.  
  611.     function oe(e) {
  612.         if (e.__esModule) return e;
  613.         var t = Object.defineProperty({}, "__esModule", {
  614.             value: !0
  615.         });
  616.         return Object.keys(e).forEach((function(o) {
  617.             var n = Object.getOwnPropertyDescriptor(e, o);
  618.             Object.defineProperty(t, o, n.get ? n : {
  619.                 enumerable: !0,
  620.                 get: function() {
  621.                     return e[o]
  622.                 }
  623.             })
  624.         })), t
  625.     }
  626.     var ne = te((function(e, t) {
  627.             Object.defineProperty(t, "__esModule", {
  628.                 value: !0
  629.             }), t.prop = t.notEmpty = t.isEmpty = t.notNull = t.defined = void 0;
  630.             t.defined = e => void 0 !== e;
  631.             t.notNull = e => null != e;
  632.             t.isEmpty = e => !e || 0 === e.length;
  633.             t.notEmpty = e => !t.isEmpty(e);
  634.             t.prop = e => {
  635.                 let o = e;
  636.                 return function(e) {
  637.                     return t.defined(e) && (o = e), o
  638.                 }
  639.             }
  640.         })),
  641.         se = te((function(e, t) {
  642.             Object.defineProperty(t, "__esModule", {
  643.                 value: !0
  644.             }), t.formToXhr = t.url = t.form = t.script = t.textRaw = t.text = t.json = t.xhrHeader = t.defaultInit = void 0;
  645.             const o = {
  646.                 Accept: "application/vnd.lichess.v5+json"
  647.             };
  648.             t.defaultInit = {
  649.                 cache: "no-cache",
  650.                 credentials: "same-origin"
  651.             }, t.xhrHeader = {
  652.                 "X-Requested-With": "XMLHttpRequest"
  653.             };
  654.             t.json = (e, n = {}) => fetch(e, Object.assign(Object.assign(Object.assign({}, t.defaultInit), {
  655.                 headers: Object.assign(Object.assign({}, o), t.xhrHeader)
  656.             }), n)).then((e => {
  657.                 if (e.ok) return e.json();
  658.                 throw e.statusText
  659.             }));
  660.             t.text = (e, o = {}) => t.textRaw(e, o).then((e => {
  661.                 if (e.ok) return e.text();
  662.                 throw e.statusText
  663.             }));
  664.             t.textRaw = (e, o = {}) => fetch(e, Object.assign(Object.assign(Object.assign({}, t.defaultInit), {
  665.                 headers: Object.assign({}, t.xhrHeader)
  666.             }), o));
  667.             t.script = e => new Promise(((t, o) => {
  668.                 const n = document.body.getAttribute("data-nonce"),
  669.                     s = document.createElement("script");
  670.                 n && s.setAttribute("nonce", n), s.onload = t, s.onerror = o, s.src = e, document.head.append(s)
  671.             }));
  672.             t.form = e => {
  673.                 const t = new FormData;
  674.                 for (const o of Object.keys(e)) t.append(o, e[o]);
  675.                 return t
  676.             };
  677.             t.url = (e, t) => {
  678.                 const o = new URLSearchParams;
  679.                 for (const e of Object.keys(t)) ne.defined(t[e]) && o.append(e, t[e]);
  680.                 const n = o.toString();
  681.                 return n ? `${e}?${n}` : e
  682.             };
  683.             t.formToXhr = e => {
  684.                 const o = e.getAttribute("action");
  685.                 return o ? t.text(o, {
  686.                     method: e.method,
  687.                     body: new FormData(e)
  688.                 }) : Promise.reject(`Form has no action: ${e}`)
  689.             }
  690.         })),
  691.         re = te((function(e, t) {
  692.             Object.defineProperty(t, "__esModule", {
  693.                 value: !0
  694.             }), t.ranks = t.files = t.colors = void 0, t.colors = ["white", "black"], t.files = ["a", "b", "c", "d", "e", "f", "g", "h"], t.ranks = ["1", "2", "3", "4", "5", "6", "7", "8"]
  695.         })),
  696.         ie = te((function(e, t) {
  697.             Object.defineProperty(t, "__esModule", {
  698.                 value: !0
  699.             }), t.computeSquareCenter = t.createEl = t.isRightButton = t.eventPosition = t.setVisible = t.translateRel = t.translateAbs = t.posToTranslateRel = t.posToTranslateAbs = t.samePiece = t.distanceSq = t.opposite = t.timer = t.memo = t.allPos = t.key2pos = t.pos2key = t.allKeys = t.invRanks = void 0, t.invRanks = [...re.ranks].reverse(), t.allKeys = Array.prototype.concat(...re.files.map((e => re.ranks.map((t => e + t)))));
  700.             t.pos2key = e => t.allKeys[8 * e[0] + e[1]];
  701.             t.key2pos = e => [e.charCodeAt(0) - 97, e.charCodeAt(1) - 49], t.allPos = t.allKeys.map(t.key2pos), t.memo = function(e) {
  702.                 let t;
  703.                 const o = () => (void 0 === t && (t = e()), t);
  704.                 return o.clear = () => {
  705.                     t = void 0
  706.                 }, o
  707.             };
  708.             t.timer = () => {
  709.                 let e;
  710.                 return {
  711.                     start() {
  712.                         e = performance.now()
  713.                     },
  714.                     cancel() {
  715.                         e = void 0
  716.                     },
  717.                     stop() {
  718.                         if (!e) return 0;
  719.                         const t = performance.now() - e;
  720.                         return e = void 0, t
  721.                     }
  722.                 }
  723.             };
  724.             t.opposite = e => "white" === e ? "black" : "white";
  725.             t.distanceSq = (e, t) => {
  726.                 const o = e[0] - t[0],
  727.                     n = e[1] - t[1];
  728.                 return o * o + n * n
  729.             };
  730.             t.samePiece = (e, t) => e.role === t.role && e.color === t.color;
  731.             const o = (e, t, o, n) => [(t ? e[0] : 7 - e[0]) * o, (t ? 7 - e[1] : e[1]) * n];
  732.             t.posToTranslateAbs = e => {
  733.                 const t = e.width / 8,
  734.                     n = e.height / 8;
  735.                 return (e, s) => o(e, s, t, n)
  736.             };
  737.             t.posToTranslateRel = (e, t) => o(e, t, 100, 100);
  738.             t.translateAbs = (e, t) => {
  739.                 e.style.transform = `translate(${t[0]}px,${t[1]}px)`
  740.             };
  741.             t.translateRel = (e, t) => {
  742.                 e.style.transform = `translate(${t[0]}%,${t[1]}%)`
  743.             };
  744.             t.setVisible = (e, t) => {
  745.                 e.style.visibility = t ? "visible" : "hidden"
  746.             };
  747.             t.eventPosition = e => {
  748.                 var t;
  749.                 return e.clientX || 0 === e.clientX ? [e.clientX, e.clientY] : (null === (t = e.targetTouches) || void 0 === t ? void 0 : t[0]) ? [e.targetTouches[0].clientX, e.targetTouches[0].clientY] : void 0
  750.             };
  751.             t.isRightButton = e => 2 === e.buttons || 2 === e.button;
  752.             t.createEl = (e, t) => {
  753.                 const o = document.createElement(e);
  754.                 return t && (o.className = t), o
  755.             }, t.computeSquareCenter = function(e, o, n) {
  756.                 const s = t.key2pos(e);
  757.                 return o || (s[0] = 7 - s[0], s[1] = 7 - s[1]), [n.left + n.width * s[0] / 8 + n.width / 16, n.top + n.height * (7 - s[1]) / 8 + n.height / 16]
  758.             }
  759.         }));
  760.     const ae = {
  761.             pawn: 1,
  762.             knight: 3,
  763.             bishop: 3,
  764.             rook: 5,
  765.             queen: 9,
  766.             king: 0
  767.         },
  768.         ce = e => ({
  769.             attrs: {
  770.                 "data-icon": e
  771.             }
  772.         }),
  773.         le = e => {
  774.             if (e) return "@" === e[1] ? [e.slice(2, 4)] : [e.slice(0, 2), e.slice(2, 4)]
  775.         },
  776.         de = e => ({
  777.             insert(t) {
  778.                 e(t.elm)
  779.             }
  780.         }),
  781.         ue = (e, t, o, n = !0) => de((s => {
  782.             s.addEventListener(e, (e => {
  783.                 t(e), o && o()
  784.             }), {
  785.                 passive: n
  786.             })
  787.         }));
  788.  
  789.     function he(e) {
  790.         const t = new Map;
  791.         if (!e) return t;
  792.         if ("string" == typeof e)
  793.             for (const o of e.split(" ")) t.set(o.slice(0, 2), o.slice(2).match(/.{2}/g));
  794.         else
  795.             for (const o in e) t.set(o, e[o].match(/.{2}/g));
  796.         return t
  797.     }
  798.     const pe = {
  799.         white: 0,
  800.         black: 0
  801.     };
  802.     var me = oe(Z),
  803.         fe = te((function(e, t) {
  804.             Object.defineProperty(t, "__esModule", {
  805.                 value: !0
  806.             }), t.bind = t.userLink = void 0, t.userLink = function(e, t) {
  807.                 const o = e.substring(0, 14);
  808.                 return me.h("a", {
  809.                     class: {
  810.                         "user-link": !0, ulpt: !0
  811.                     },
  812.                     attrs: {
  813.                         href: "/@/" + e
  814.                     }
  815.                 }, t && "BOT" != t ? [me.h("span.utitle", t), o] : [o])
  816.             }, t.bind = function(e, t) {
  817.                 return {
  818.                     insert(o) {
  819.                         o.elm.addEventListener(e, t)
  820.                     }
  821.                 }
  822.             }
  823.         })),
  824.         ge = te((function(e, t) {
  825.             Object.defineProperty(t, "__esModule", {
  826.                 value: !0
  827.             }), t.presetView = t.presetCtrl = void 0;
  828.             const o = {
  829.                 start: ["hi/Hello", "gl/Good luck", "hf/Have fun!", "u2/You too!"].map(n),
  830.                 end: ["gg/Good game", "wp/Well played", "ty/Thank you", "gtg/I've got to go", "bye/Bye!"].map(n)
  831.             };
  832.  
  833.             function n(e) {
  834.                 const t = e.split("/");
  835.                 return {
  836.                     key: t[0],
  837.                     text: t[1]
  838.                 }
  839.             }
  840.             t.presetCtrl = function(e) {
  841.                 let t = e.initialGroup,
  842.                     n = [];
  843.                 return {
  844.                     group: () => t,
  845.                     said: () => n,
  846.                     setGroup(o) {
  847.                         o !== t && (t = o, o || (n = []), e.redraw())
  848.                     },
  849.                     post(s) {
  850.                         if (!t) return;
  851.                         o[t] && (n.includes(s.key) || e.post(s.text) && n.push(s.key))
  852.                     }
  853.                 }
  854.             }, t.presetView = function(e) {
  855.                 const t = e.group();
  856.                 if (!t) return;
  857.                 const n = o[t],
  858.                     s = e.said();
  859.                 return n && s.length < 2 ? me.h("div.mchat__presets", n.map((t => {
  860.                     const o = s.includes(t.key);
  861.                     return me.h("span", {
  862.                         class: {
  863.                             disabled: o
  864.                         },
  865.                         attrs: {
  866.                             title: t.text,
  867.                             disabled: o
  868.                         },
  869.                         hook: fe.bind("click", (() => {
  870.                             !o && e.post(t)
  871.                         }))
  872.                     }, t.key)
  873.                 }))) : void 0
  874.             }
  875.         })),
  876.         ve = te((function(e, t) {
  877.             Object.defineProperty(t, "__esModule", {
  878.                 value: !0
  879.             }), t.setNote = t.getNote = t.flag = t.userModInfo = void 0;
  880.             t.userModInfo = e => se.json("/mod/chat-user/" + e);
  881.             t.flag = (e, t, o) => se.json("/report/flag", {
  882.                 method: "post",
  883.                 body: se.form({
  884.                     username: t,
  885.                     resource: e,
  886.                     text: o
  887.                 })
  888.             });
  889.             t.getNote = e => se.text(o(e));
  890.             t.setNote = (e, t) => se.json(o(e), {
  891.                 method: "post",
  892.                 body: se.form({
  893.                     text: t
  894.                 })
  895.             });
  896.             const o = e => `/${e}/note`
  897.         })),
  898.         be = te((function(e, t) {
  899.             Object.defineProperty(t, "__esModule", {
  900.                 value: !0
  901.             }), t.default = function(e, t, o = !1) {
  902.                 let n, s = 0;
  903.                 return function(...r) {
  904.                     const i = this;
  905.                     n && clearTimeout(n), n = void 0;
  906.                     const a = performance.now() - s;
  907.                     s = performance.now(), o && a > t ? e.apply(i, r) : n = setTimeout((() => {
  908.                         n = void 0, e.apply(i, r)
  909.                     }), t)
  910.                 }
  911.             }
  912.         })),
  913.         ye = te((function(e, t) {
  914.             Object.defineProperty(t, "__esModule", {
  915.                 value: !0
  916.             }), t.noteView = t.noteCtrl = void 0, t.noteCtrl = function(e) {
  917.                 let t = e.text;
  918.                 const o = be.default((() => {
  919.                     ve.setNote(e.id, t || "")
  920.                 }), 1e3);
  921.                 return {
  922.                     id: e.id,
  923.                     trans: e.trans,
  924.                     text: () => t,
  925.                     fetch() {
  926.                         ve.getNote(e.id).then((o => {
  927.                             t = o || "", e.redraw()
  928.                         }))
  929.                     },
  930.                     post(e) {
  931.                         t = e, o()
  932.                     }
  933.                 }
  934.             }, t.noteView = function(e) {
  935.                 const t = e.text();
  936.                 return null == t ? me.h("div.loading", {
  937.                     hook: {
  938.                         insert: e.fetch
  939.                     }
  940.                 }) : me.h("textarea", {
  941.                     attrs: {
  942.                         placeholder: e.trans("typePrivateNotesHere")
  943.                     },
  944.                     hook: {
  945.                         insert(o) {
  946.                             const n = $(o.elm);
  947.                             n.val(t).on("change keyup paste", (() => e.post(n.val())))
  948.                         }
  949.                     }
  950.                 })
  951.             }
  952.         })),
  953.         we = te((function(e, t) {
  954.             Object.defineProperty(t, "__esModule", {
  955.                 value: !0
  956.             }), t.numberSpread = t.numberFormat = void 0;
  957.             let o = !1;
  958.             t.numberFormat = e => (!1 === o && (o = window.Intl && Intl.NumberFormat ? new Intl.NumberFormat : null), null === o ? "" + e : o.format(e));
  959.             t.numberSpread = (e, o, n, s) => {
  960.                 let r;
  961.                 const i = (n, s, i) => {
  962.                     const a = t.numberFormat(Math.round((n * (o - 1 - i) + s * (i + 1)) / o));
  963.                     a !== r && (e.textContent = a, r = a)
  964.                 };
  965.                 let a = [];
  966.                 return (t, r) => {
  967.                     if (!e || !t && 0 !== t) return;
  968.                     r && (o = Math.abs(r)), a.forEach(clearTimeout), a = [];
  969.                     const c = 0 === s ? 0 : s || t;
  970.                     s = t;
  971.                     const l = Math.abs(n / o);
  972.                     for (let e = 0; e < o; e++) a.push(setTimeout(i.bind(null, c, t, e), Math.round(e * l)))
  973.                 }
  974.             }
  975.         })),
  976.         ke = te((function(e, t) {
  977.             Object.defineProperty(t, "__esModule", {
  978.                 value: !0
  979.             }), t.moderationView = t.lineAction = t.moderationCtrl = void 0, t.moderationCtrl = function(e) {
  980.                 let t, o = !1;
  981.                 const n = () => {
  982.                     t = void 0, o = !1, e.redraw()
  983.                 };
  984.                 return {
  985.                     loading: () => o,
  986.                     data: () => t,
  987.                     reasons: e.reasons,
  988.                     permissions: () => e.permissions,
  989.                     open: n => {
  990.                         const s = n.querySelector("a.user-link"),
  991.                             r = n.querySelector("t").innerText,
  992.                             i = s.href.split("/")[4];
  993.                         e.permissions.timeout ? (o = !0, ve.userModInfo(i).then((n => {
  994.                             t = Object.assign(Object.assign({}, n), {
  995.                                 text: r
  996.                             }), o = !1, e.redraw()
  997.                         }))) : t = {
  998.                             id: i.toLowerCase(),
  999.                             username: i,
  1000.                             text: r
  1001.                         }, e.redraw()
  1002.                     },
  1003.                     close: n,
  1004.                     timeout(o, s) {
  1005.                         t && lichess.pubsub.emit("socket.send", "timeout", {
  1006.                             userId: t.id,
  1007.                             reason: o.key,
  1008.                             text: s
  1009.                         }), n(), e.redraw()
  1010.                     }
  1011.                 }
  1012.             };
  1013.             t.lineAction = () => me.h("i.mod", {
  1014.                 attrs: {
  1015.                     "data-icon": ""
  1016.                 }
  1017.             }), t.moderationView = function(e) {
  1018.                 if (!e) return;
  1019.                 if (e.loading()) return [me.h("div.loading")];
  1020.                 const t = e.data();
  1021.                 if (!t) return;
  1022.                 const o = e.permissions(),
  1023.                     n = t.history ? me.h("div.infos.block", [we.numberFormat(t.games || 0) + " games", t.troll ? "TROLL" : void 0, t.engine ? "ENGINE" : void 0, t.booster ? "BOOSTER" : void 0].map((e => e && me.h("span", e))).concat([me.h("a", {
  1024.                         attrs: {
  1025.                             href: "/@/" + t.username + "?mod"
  1026.                         }
  1027.                     }, "profile")]).concat(o.shadowban ? [me.h("a", {
  1028.                         attrs: {
  1029.                             href: "/mod/" + t.username + "/communication"
  1030.                         }
  1031.                     }, "coms")] : [])) : void 0,
  1032.                     s = o.timeout ? me.h("div.timeout.block", [me.h("strong", "Timeout 15 minutes for"), ...e.reasons.map((o => me.h("a.text", {
  1033.                         attrs: {
  1034.                             "data-icon": "p"
  1035.                         },
  1036.                         hook: fe.bind("click", (() => e.timeout(o, t.text)))
  1037.                     }, o.name)))]) : me.h("div.timeout.block", [me.h("strong", "Moderation"), me.h("a.text", {
  1038.                         attrs: {
  1039.                             "data-icon": "p"
  1040.                         },
  1041.                         hook: fe.bind("click", (() => e.timeout(e.reasons[0], t.text)))
  1042.                     }, "Timeout 15 minutes")]),
  1043.                     r = t.history ? me.h("div.history.block", [me.h("strong", "Timeout history"), me.h("table", me.h("tbody.slist", {
  1044.                         hook: {
  1045.                             insert() {
  1046.                                 lichess.contentLoaded()
  1047.                             }
  1048.                         }
  1049.                     }, t.history.map((function(e) {
  1050.                         return me.h("tr", [me.h("td.reason", e.reason), me.h("td.mod", e.mod), me.h("td", me.h("time.timeago", {
  1051.                             attrs: {
  1052.                                 datetime: e.date
  1053.                             }
  1054.                         }))])
  1055.                     }))))]) : void 0;
  1056.                 return [me.h("div.top", {
  1057.                     key: "mod-" + t.id
  1058.                 }, [me.h("span.text", {
  1059.                     attrs: {
  1060.                         "data-icon": ""
  1061.                     }
  1062.                 }, [fe.userLink(t.username)]), me.h("a", {
  1063.                     attrs: {
  1064.                         "data-icon": "L"
  1065.                     },
  1066.                     hook: fe.bind("click", e.close)
  1067.                 })]), me.h("div.mchat__content.moderation", [me.h("i.line-text.block", ['"', t.text, '"']), n, s, r])]
  1068.             }
  1069.         })),
  1070.         Pe = te((function(e, t) {
  1071.             Object.defineProperty(t, "__esModule", {
  1072.                 value: !0
  1073.             }), t.default = function(e, t) {
  1074.                 const o = e.data;
  1075.                 o.domVersion = 1;
  1076.                 const n = {
  1077.                         instance: void 0,
  1078.                         loaded: !1,
  1079.                         enabled: ne.prop(!!o.palantir)
  1080.                     },
  1081.                     s = ["discussion"];
  1082.                 e.noteId && s.push("note"), e.plugin && s.push(e.plugin.tab.key);
  1083.                 const r = lichess.storage.make("chat.tab"),
  1084.                     i = r.get();
  1085.                 let a;
  1086.                 const c = {
  1087.                     tab: s.find((e => e === i)) || s[0],
  1088.                     enabled: e.alwaysEnabled || !lichess.storage.get("nochat"),
  1089.                     placeholderKey: "talkInChat",
  1090.                     loading: !1,
  1091.                     timeout: e.timeout,
  1092.                     writeable: e.writeable
  1093.                 };
  1094.                 s.length > 1 && "discussion" === c.tab && lichess.storage.get("nochat") && (c.tab = s[1]);
  1095.                 const l = e => !!(e = e.trim()) && (!("You too!" == e && !o.lines.some((e => e.u != o.userId))) && (e.length > 140 ? (alert("Max length: 140 chars. " + e.length + " chars used."), !1) : (lichess.pubsub.emit("socket.send", "talk", e), !0))),
  1096.                     d = lichess.trans(e.i18n);
  1097.  
  1098.                 function u() {
  1099.                     (e.permissions.timeout || e.permissions.local) && (a = ke.moderationCtrl({
  1100.                         reasons: e.timeoutReasons || [{
  1101.                             key: "other",
  1102.                             name: "Inappropriate behavior"
  1103.                         }],
  1104.                         permissions: e.permissions,
  1105.                         redraw: t
  1106.                     }), e.loadCss("chat.mod"))
  1107.                 }
  1108.                 u();
  1109.                 const h = e.noteId ? ye.noteCtrl({
  1110.                         id: e.noteId,
  1111.                         text: e.noteText,
  1112.                         trans: d,
  1113.                         redraw: t
  1114.                     }) : void 0,
  1115.                     p = ge.presetCtrl({
  1116.                         initialGroup: e.preset,
  1117.                         post: l,
  1118.                         redraw: t
  1119.                     }),
  1120.                     m = [
  1121.                         ["socket.in.message", e => {
  1122.                             o.lines.push(e);
  1123.                             const n = o.lines.length;
  1124.                             n > 200 && (o.lines.splice(0, n - 200 + 50), o.domVersion++), t()
  1125.                         }],
  1126.                         ["socket.in.chat_timeout", e => {
  1127.                             let n = !1;
  1128.                             o.lines.forEach((t => {
  1129.                                 t.u && t.u.toLowerCase() == e && (t.d = !0, n = !0)
  1130.                             })), e == o.userId && (c.timeout = n = !0), n && (o.domVersion++, t())
  1131.                         }],
  1132.                         ["socket.in.chat_reinstate", e => {
  1133.                             e == o.userId && (c.timeout = !1, t())
  1134.                         }],
  1135.                         ["chat.writeable", e => {
  1136.                             c.writeable = e, t()
  1137.                         }],
  1138.                         ["chat.permissions", o => {
  1139.                             let n;
  1140.                             for (n in o) e.permissions[n] = o[n];
  1141.                             u(), t()
  1142.                         }],
  1143.                         ["palantir.toggle", n.enabled]
  1144.                     ];
  1145.                 m.forEach((([e, t]) => lichess.pubsub.on(e, t)));
  1146.                 const f = () => lichess.pubsub.emit("chat.enabled", c.enabled);
  1147.                 return f(), {
  1148.                     data: o,
  1149.                     opts: e,
  1150.                     vm: c,
  1151.                     allTabs: s,
  1152.                     setTab(e) {
  1153.                         c.tab = e, r.set(e), "discussion" === e && lichess.requestIdleCallback((() => $(".mchat__say").each((function() {
  1154.                             this.focus()
  1155.                         }))), 500), t()
  1156.                     },
  1157.                     moderation: () => a,
  1158.                     note: h,
  1159.                     preset: p,
  1160.                     post: l,
  1161.                     trans: d,
  1162.                     plugin: e.plugin,
  1163.                     setEnabled(e) {
  1164.                         c.enabled = e, f(), e ? lichess.storage.remove("nochat") : lichess.storage.set("nochat", "1"), t()
  1165.                     },
  1166.                     redraw: t,
  1167.                     palantir: n,
  1168.                     destroy: () => {
  1169.                         m.forEach((([e, t]) => lichess.pubsub.off(e, t)))
  1170.                     }
  1171.                 }
  1172.             }
  1173.         })),
  1174.         Me = te((function(e, t) {
  1175.             Object.defineProperty(t, "__esModule", {
  1176.                 value: !0
  1177.             }), t.isMoreThanText = t.enhance = void 0, t.enhance = function(e, t) {
  1178.                 const o = lichess.escapeHtml(e),
  1179.                     n = o.replace(i, c).replace(s, r);
  1180.                 return t && n === o ? function(e) {
  1181.                     return e.replace(l, d)
  1182.                 }(n) : n
  1183.             };
  1184.             const o = /[&<>"@]/,
  1185.                 n = /\.\w/;
  1186.             t.isMoreThanText = function(e) {
  1187.                 return o.test(e) || n.test(e)
  1188.             };
  1189.             const s = /\b\b(?:https?:\/\/)?(lichess\.org\/[-–—\w+&'@#\/%?=()~|!:,.;]+[\w+&@#\/%=~|])/gi;
  1190.  
  1191.             function r(e, t) {
  1192.                 return t.includes("&quot;") ? t : `<a target="_blank" rel="nofollow noopener noreferrer" href="https://${t}">${t}</a>`
  1193.             }
  1194.             const i = /(^|[^\w@#/])@([\w-]{2,})/g,
  1195.                 a = /^[a-h][2-7]$/;
  1196.  
  1197.             function c(e, t, o) {
  1198.                 return o.length > 20 || o.match(a) ? e : t + '<a href="/@/' + o + '">@' + o + "</a>"
  1199.             }
  1200.             const l = /\b(\d+)\s*(\.+)\s*(?:[o0-]+[o0]|[NBRQKP\u2654\u2655\u2656\u2657\u2658\u2659]?[a-h]?[1-8]?[x@]?[a-z][1-8](?:=[NBRQK\u2654\u2655\u2656\u2657\u2658\u2659])?)\+?#?[!\?=]{0,5}/gi;
  1201.  
  1202.             function d(e, t, o) {
  1203.                 if (t < 1 || t > 200) return e;
  1204.                 return '<a class="jump" data-ply="' + (2 * t - (o.length > 1 ? 0 : 1)) + '">' + e + "</a>"
  1205.             }
  1206.         })),
  1207.         Ce = te((function(e, t) {
  1208.             Object.defineProperty(t, "__esModule", {
  1209.                 value: !0
  1210.             }), t.hasTeamUrl = t.selfReport = t.skip = void 0;
  1211.             t.skip = e => (s(e) || i(e)) && !o();
  1212.             t.selfReport = e => {
  1213.                 if (o()) return;
  1214.                 const t = s(e);
  1215.                 t && se.text(`/jslog/${window.location.href.substr(-12)}?n=spam`, {
  1216.                     method: "post"
  1217.                 }), (t || i(e)) && lichess.storage.set("chat-spam", "1")
  1218.             };
  1219.             const o = () => "1" == lichess.storage.get("chat-spam"),
  1220.                 n = new RegExp(["xcamweb.com", "(^|[^i])chess-bot", "chess-cheat", "coolteenbitch", "letcafa.webcam", "tinyurl.com/", "wooga.info/", "bit.ly/", "wbt.link/", "eb.by/", "001.rs/", "shr.name/", "u.to/", ".3-a.net", ".ssl443.org", ".ns02.us", ".myftp.info", ".flinkup.com", ".serveusers.com", "badoogirls.com", "hide.su", "wyon.de", "sexdatingcz.club", "qps.ru", "tiny.cc/"].map((e => e.replace(/\./g, "\\.").replace(/\//g, "\\/"))).join("|")),
  1221.                 s = e => !!e.match(n),
  1222.                 r = /follow me|join my team/i,
  1223.                 i = e => !!e.match(r),
  1224.                 a = /lichess\.org\/team\//i;
  1225.             t.hasTeamUrl = e => !!e.match(a)
  1226.         })),
  1227.         Te = te((function(e, t) {
  1228.             Object.defineProperty(t, "__esModule", {
  1229.                 value: !0
  1230.             });
  1231.             const o = /^\/[wW](?:hisper)?\s/;
  1232.  
  1233.             function n(e) {
  1234.                 if (!e.vm.writeable) return;
  1235.                 if (e.data.loginRequired && !e.data.userId || e.data.restricted) return me.h("input.mchat__say", {
  1236.                     attrs: {
  1237.                         placeholder: e.trans("loginToChat"),
  1238.                         disabled: !0
  1239.                     }
  1240.                 });
  1241.                 let t;
  1242.                 return t = e.vm.timeout ? e.trans("youHaveBeenTimedOut") : e.opts.blind ? "Chat" : e.trans.noarg(e.vm.placeholderKey), me.h("input.mchat__say", {
  1243.                     attrs: {
  1244.                         placeholder: t,
  1245.                         autocomplete: "off",
  1246.                         maxlength: 140,
  1247.                         disabled: e.vm.timeout || !e.vm.writeable,
  1248.                         "aria-label": "Chat input"
  1249.                     },
  1250.                     hook: {
  1251.                         insert(t) {
  1252.                             r(e, t.elm)
  1253.                         }
  1254.                     }
  1255.                 })
  1256.             }
  1257.             let s;
  1258.             t.default = function(e) {
  1259.                 if (!e.vm.enabled) return [];
  1260.                 const t = t => {
  1261.                         const o = t.elm;
  1262.                         if (e.data.lines.length > 5) {
  1263.                             (0 === o.scrollTop || o.scrollTop > o.scrollHeight - o.clientHeight - 100) && (o.scrollTop = 999999, setTimeout((e => o.scrollTop = 999999), 300))
  1264.                         }
  1265.                     },
  1266.                     o = !!e.moderation(),
  1267.                     s = [me.h("ol.mchat__messages.chat-v-" + e.data.domVersion, {
  1268.                         attrs: {
  1269.                             role: "log",
  1270.                             "aria-live": "polite",
  1271.                             "aria-atomic": !1
  1272.                         },
  1273.                         hook: {
  1274.                             insert(n) {
  1275.                                 const s = $(n.elm).on("click", "a.jump", (e => {
  1276.                                     lichess.pubsub.emit("jump", e.target.getAttribute("data-ply"))
  1277.                                 }));
  1278.                                 o ? s.on("click", ".mod", (t => {
  1279.                                     var o;
  1280.                                     return null === (o = e.moderation()) || void 0 === o ? void 0 : o.open(t.target.parentNode)
  1281.                                 })) : s.on("click", ".flag", (t => function(e, t) {
  1282.                                     const o = t.querySelector("a.user-link"),
  1283.                                         n = t.querySelector("t").innerText;
  1284.                                     o && confirm(`Report "${n}" to moderators?`) && ve.flag(e.data.resourceId, o.href.split("/")[4], n)
  1285.                                 }(e, t.target.parentNode))), t(n)
  1286.                             },
  1287.                             postpatch: (e, o) => t(o)
  1288.                         }
  1289.                     }, i(e).map((t => function(e, t) {
  1290.                         const o = function(e, t) {
  1291.                             if (Me.isMoreThanText(e)) {
  1292.                                 const o = function(e) {
  1293.                                     return (t, o) => {
  1294.                                         o.data.lichessChat !== t.data.lichessChat && (o.elm.innerHTML = Me.enhance(o.data.lichessChat, e))
  1295.                                     }
  1296.                                 }(t);
  1297.                                 return me.h("t", {
  1298.                                     lichessChat: e,
  1299.                                     hook: {
  1300.                                         create: o,
  1301.                                         update: o
  1302.                                     }
  1303.                                 })
  1304.                             }
  1305.                             return me.h("t", e)
  1306.                         }(t.t, e.opts.parseMoves);
  1307.                         if ("lichess" === t.u) return me.h("li.system", o);
  1308.                         if (t.c) return me.h("li", [me.h("span.color", "[" + t.c + "]"), o]);
  1309.                         const n = me.thunk("a", t.u, fe.userLink, [t.u, t.title]);
  1310.                         return me.h("li", e.moderation() ? [t.u ? ke.lineAction() : null, n, " ", o] : [e.data.userId && t.u && e.data.userId != t.u ? me.h("i.flag", {
  1311.                             attrs: {
  1312.                                 "data-icon": "!",
  1313.                                 title: "Report"
  1314.                             }
  1315.                         }) : null, n, " ", o])
  1316.                     }(e, t)))), n(e)],
  1317.                     r = ge.presetView(e.preset);
  1318.                 return r && s.push(r), s
  1319.             };
  1320.             const r = (e, t) => {
  1321.                 const n = lichess.tempStorage.make("chatInput");
  1322.                 n.get() && (t.value = n.get(), n.remove(), t.focus()), t.addEventListener("keypress", (t => setTimeout((() => {
  1323.                     const s = t.target,
  1324.                         r = s.value,
  1325.                         i = e.opts.public;
  1326.                     n.set(s.value), 10 == t.which || 13 == t.which ? "" === r ? $(".keyboard-move input").each((function() {
  1327.                         this.focus()
  1328.                     })) : (e.opts.kobold || Ce.selfReport(r), i && Ce.hasTeamUrl(r) ? alert("Please don't advertise teams in the chat.") : e.post(r), s.value = "", n.remove(), i || s.classList.remove("whisper")) : (s.removeAttribute("placeholder"), i || s.classList.toggle("whisper", !!r.match(o)))
  1329.                 })))), window.Mousetrap.bind("c", (() => t.focus()));
  1330.                 const r = ["touchstart", "mousedown"];
  1331.                 s && r.forEach((e => document.body.removeEventListener(e, s, {
  1332.                     capture: !0
  1333.                 }))), s = e => {
  1334.                     e.shiftKey || 2 === e.buttons || 2 === e.button || t.blur()
  1335.                 }, t.onfocus = () => r.forEach((e => document.body.addEventListener(e, s, {
  1336.                     passive: !0,
  1337.                     capture: !0
  1338.                 }))), t.onblur = () => r.forEach((e => document.body.removeEventListener(e, s, {
  1339.                     capture: !0
  1340.                 })))
  1341.             };
  1342.  
  1343.             function i(e) {
  1344.                 const t = [];
  1345.                 let o;
  1346.                 return e.data.lines.forEach((n => {
  1347.                     var s, r;
  1348.                     n.d || o && (r = n, (s = o).d && r.d && s.u === r.u) || n.r && (n.u || "").toLowerCase() != e.data.userId || Ce.skip(n.t) || t.push(n), o = n
  1349.                 })), t
  1350.             }
  1351.         })),
  1352.         xe = te((function(e, t) {
  1353.             function o(e) {
  1354.                 const t = e.palantir;
  1355.                 if (t.enabled()) return t.instance ? t.instance.render(me.h) : me.h("div.mchat__tab.palantir.palantir-slot", {
  1356.                     attrs: {
  1357.                         "data-icon": "",
  1358.                         title: "Voice chat"
  1359.                     },
  1360.                     hook: fe.bind("click", (() => {
  1361.                         t.loaded || (t.loaded = !0, lichess.loadScript("javascripts/vendor/peerjs.min.js").then((() => {
  1362.                             lichess.loadModule("palantir").then((() => {
  1363.                                 t.instance = window.Palantir.palantir({
  1364.                                     uid: e.data.userId,
  1365.                                     redraw: e.redraw
  1366.                                 }), e.redraw()
  1367.                             }))
  1368.                         })))
  1369.                     }))
  1370.                 })
  1371.             }
  1372.             Object.defineProperty(t, "__esModule", {
  1373.                 value: !0
  1374.             }), t.default = function(e) {
  1375.                 const t = e.moderation();
  1376.                 return me.h("section.mchat" + (e.opts.alwaysEnabled ? "" : ".mchat-optional"), {
  1377.                     class: {
  1378.                         "mchat-mod": !!t
  1379.                     },
  1380.                     hook: {
  1381.                         destroy: e.destroy
  1382.                     }
  1383.                 }, ke.moderationView(t) || function(e) {
  1384.                     const t = e.vm.tab;
  1385.                     return [me.h("div.mchat__tabs.nb_" + e.allTabs.length, [...e.allTabs.map((o => function(e, t, o) {
  1386.                         return me.h("div.mchat__tab." + t, {
  1387.                             class: {
  1388.                                 "mchat__tab-active": t === o
  1389.                             },
  1390.                             hook: fe.bind("click", (() => e.setTab(t)))
  1391.                         }, function(e, t) {
  1392.                             return "discussion" === t ? [me.h("span", e.data.name), e.opts.alwaysEnabled ? void 0 : me.h("input", {
  1393.                                 attrs: {
  1394.                                     type: "checkbox",
  1395.                                     title: e.trans.noarg("toggleTheChat"),
  1396.                                     checked: e.vm.enabled
  1397.                                 },
  1398.                                 hook: fe.bind("change", (t => {
  1399.                                     e.setEnabled(t.target.checked)
  1400.                                 }))
  1401.                             })] : "note" === t ? [me.h("span", e.trans.noarg("notes"))] : e.plugin && t === e.plugin.tab.key ? [me.h("span", e.plugin.tab.name)] : []
  1402.                         }(e, t))
  1403.                     }(e, o, t))), o(e)]), me.h("div.mchat__content." + t, "note" === t && e.note ? [ye.noteView(e.note)] : e.plugin && t === e.plugin.tab.key ? [e.plugin.view()] : Te.default(e))]
  1404.                 }(e))
  1405.             }
  1406.         })),
  1407.         Se = ee(te((function(e, t) {
  1408.             Object.defineProperty(t, "__esModule", {
  1409.                 value: !0
  1410.             }), t.default = function(e, t) {
  1411.                 const o = me.init([me.classModule, me.attributesModule]),
  1412.                     n = Pe.default(t, (function() {
  1413.                         r = o(r, xe.default(n))
  1414.                     })),
  1415.                     s = xe.default(n);
  1416.                 e.innerHTML = "";
  1417.                 let r = o(e, s);
  1418.                 return n
  1419.             }
  1420.         }))),
  1421.         Oe = ee(te((function(e, t) {
  1422.             Object.defineProperty(t, "__esModule", {
  1423.                 value: !0
  1424.             }), t.default = function() {
  1425.                 if ("ontouchstart" in window) return;
  1426.                 let e, t;
  1427.                 const o = o => {
  1428.                     e = o.pageX, t = o.pageY
  1429.                 };
  1430.                 let n = {};
  1431.                 $("#topnav.hover").each((function() {
  1432.                     const s = $(this).removeClass("hover"),
  1433.                         r = () => s.toggleClass("hover"),
  1434.                         i = () => {
  1435.                             Math.sqrt((n.pX - e) * (n.pX - e) + (n.pY - t) * (n.pY - t)) < 8 ? (s.off(n.event, o), delete n.timeoutId, n.isActive = !0, r()) : (n.pX = e, n.pY = t, n.timeoutId = setTimeout(i, 200))
  1436.                         },
  1437.                         a = function(e) {
  1438.                             n.timeoutId && (n.timeoutId = clearTimeout(n.timeoutId));
  1439.                             const t = n.event = "mousemove";
  1440.                             if ("mouseover" == e.type) {
  1441.                                 if (n.isActive || e.buttons) return;
  1442.                                 n.pX = e.pageX, n.pY = e.pageY, s.off(t, o).on(t, o), n.timeoutId = setTimeout(i, 200)
  1443.                             } else {
  1444.                                 if (!n.isActive) return;
  1445.                                 s.off(t, o), n = {}, r()
  1446.                             }
  1447.                         };
  1448.                     s.on("mouseover", a).on("mouseleave", a)
  1449.                 }))
  1450.             }
  1451.         })));
  1452.     const _e = (() => {
  1453.         const e = "mousemove";
  1454.         let t = !1,
  1455.             o = [],
  1456.             n = 0;
  1457.  
  1458.         function s(e) {
  1459.             var t;
  1460.             o.push({
  1461.                 b: 0 != e.buttons,
  1462.                 x: e.clientX,
  1463.                 y: e.clientY
  1464.             }), o.length > 4 && (o.shift(), !(t = o)[0].b && t[1].b && t[2].b && !t[3].b && r(t[0], t[1]) > 900 && 0 === r(t[1], t[2]) && 0 === r(t[2], t[3]) && n++)
  1465.         }
  1466.  
  1467.         function r(e, t) {
  1468.             return Math.pow(t.x - e.x, 2) + Math.pow(t.y - e.y, 2)
  1469.         }
  1470.         return {
  1471.             start() {
  1472.                 t || (t = !1, document.addEventListener(e, s))
  1473.             },
  1474.             stop() {
  1475.                 t && (t = !1, document.removeEventListener(e, s))
  1476.             },
  1477.             hits: () => n
  1478.         }
  1479.     })();
  1480.     let Ae = [],
  1481.         je = !1,
  1482.         Le = {
  1483.             holdAcc: 0
  1484.         },
  1485.         De = !1;
  1486.     const Ee = (e, t) => fetch("/jslog/" + e.game.id + e.player.id + "?n=" + t, {
  1487.             method: "post"
  1488.         }),
  1489.         Ne = e => $(atob(e)).length,
  1490.         $e = () => $("u8t").first().append("<j>"),
  1491.         Re = 10 + Math.round(Math.random(11));
  1492.     var Be = (e, t) => {
  1493.             ! function(e, t) {
  1494.                 if (t.premove && e.ply > 1 && (De = !0), De || !t.holdTime || e.ply > 30) return void _e.stop();
  1495.                 if (Ae.push(t.holdTime), Ae.length <= 6) return;
  1496.                 let o, n = !1;
  1497.                 Ae.shift();
  1498.                 const s = Ae.reduce(((e, t) => e + t)) / 6;
  1499.                 s > 2 && s < 140 && (o = Ae.map((e => Math.pow(e - s, 2))).reduce(((e, t) => e + t)) / 5, n = o < 256);
  1500.                 (n || je) && $(".manipulable .cg-board").toggleClass("bh1", n && _e.hits() > 2), n ? (Le.hold || (Le.holdAcc++, Le.holdAcc > 5 && (e.socket.send("hold", {
  1501.                     mean: Math.round(s),
  1502.                     sd: Math.round(Math.sqrt(o))
  1503.                 }), Le.hold = !0)), _e.start(), _e.hits() > 2 && !Le.ick && (e.socket.send("bye2"), Ee(e.data, "ick2"), Le.ick = !0)) : Le.holdAcc = 0, je = n
  1504.             }(e, t), e.ply <= Re + 2 && e.ply > Re && (($(atob("TWVudUFwcGVuZA==")).length || $(atob("LmNnLWJvYXJkIGNhbnZhcw==")).length) && Ee(e.data, "mcb"), Ne("I2NoZXNzX2J0bl9jb250YWluZXI") && Ee(e.data, "cma0"), Ne("bGFiZWwgPiBpbnB1dFt2YWx1ZT0id2hpdGUiXQ==") && Ee(e.data, "cma1"), Ne("bGFiZWw+c3Bhbi5jaC1jaGVja21hcms=") && setTimeout((() => Ee(e.data, "cma2")), 2e4), Ne("YVtocmVmPSJodHRwOi8vdGhhcGF3bmd1bi5saXZlIl0=") && Ee(e.data, "lga"), (Ne("I2F1dGhCYXI=") || Ne("I21vdmVfc3VnZ2VzdF9ib3g=")) && Ee(e.data, "los")), 6 != e.ply && 7 != e.ply || $e()
  1505.         },
  1506.         Ie = e => setTimeout((() => {
  1507.             Object.keys(window.WebSocket).length || Ee(e.data, "ih1"), e.ply >= 6 && $e()
  1508.         }), 1e3);
  1509.     const qe = e => e.steps[0].ply,
  1510.         Fe = e => Ge(e).ply,
  1511.         Ge = e => e.steps[e.steps.length - 1],
  1512.         ze = (e, t) => e.steps[t - qe(e)],
  1513.         Ke = e => {
  1514.             e.clock && (e.clock.showTenths = e.pref.clockTenths, e.clock.showBar = e.pref.clockBar), e.correspondence && (e.correspondence.showBar = e.pref.clockBar), ["horde", "crazyhouse"].includes(e.game.variant.key) && (e.pref.showCaptured = !1), e.expiration && (e.expiration.movedAt = Date.now() - e.expiration.idleMillis)
  1515.         };
  1516.     var He = te((function(e, t) {
  1517.             function o(e) {
  1518.                 return e.game.status.id >= t.ids.started
  1519.             }
  1520.  
  1521.             function n(e) {
  1522.                 return e.game.status.id >= t.ids.mate
  1523.             }
  1524.  
  1525.             function s(e) {
  1526.                 return e.game.status.id === t.ids.aborted
  1527.             }
  1528.             Object.defineProperty(t, "__esModule", {
  1529.                 value: !0
  1530.             }), t.playing = t.aborted = t.finished = t.started = t.ids = void 0, t.ids = {
  1531.                 created: 10,
  1532.                 started: 20,
  1533.                 aborted: 25,
  1534.                 mate: 30,
  1535.                 resign: 31,
  1536.                 stalemate: 32,
  1537.                 timeout: 33,
  1538.                 draw: 34,
  1539.                 outoftime: 35,
  1540.                 cheat: 36,
  1541.                 noStart: 37,
  1542.                 variantEnd: 60
  1543.             }, t.started = o, t.finished = n, t.aborted = s, t.playing = function(e) {
  1544.                 return o(e) && !n(e) && !s(e)
  1545.             }
  1546.         })),
  1547.         Ve = te((function(e, t) {
  1548.             Object.defineProperty(t, "__esModule", {
  1549.                 value: !0
  1550.             })
  1551.         })),
  1552.         Ue = te((function(e, t) {
  1553.             var o = Q && Q.__createBinding || (Object.create ? function(e, t, o, n) {
  1554.                     void 0 === n && (n = o), Object.defineProperty(e, n, {
  1555.                         enumerable: !0,
  1556.                         get: function() {
  1557.                             return t[o]
  1558.                         }
  1559.                     })
  1560.                 } : function(e, t, o, n) {
  1561.                     void 0 === n && (n = o), e[n] = t[o]
  1562.                 }),
  1563.                 n = Q && Q.__exportStar || function(e, t) {
  1564.                     for (var n in e) "default" === n || Object.prototype.hasOwnProperty.call(t, n) || o(t, e, n)
  1565.                 };
  1566.             Object.defineProperty(t, "__esModule", {
  1567.                 value: !0
  1568.             }), t.isSwitchable = t.nbMoves = t.setGone = t.setOnGame = t.isCorrespondence = t.userAnalysable = t.hasAi = t.getPlayer = t.replayable = t.moretimeable = t.berserkableBy = t.resignable = t.drawable = t.takebackable = t.abortable = t.bothPlayersHavePlayed = t.playedTurns = t.mandatory = t.isPlayerTurn = t.isPlayerPlaying = t.playable = void 0, n(Ve, t);
  1569.             t.playable = e => e.game.status.id < He.ids.aborted && !s(e);
  1570.             t.isPlayerPlaying = e => t.playable(e) && !e.player.spectator;
  1571.             t.isPlayerTurn = e => t.isPlayerPlaying(e) && e.game.player == e.player.color;
  1572.             t.mandatory = e => !!e.tournament || !!e.simul || !!e.swiss;
  1573.             t.playedTurns = e => e.game.turns - (e.game.startedAtTurn || 0);
  1574.             t.bothPlayersHavePlayed = e => t.playedTurns(e) > 1;
  1575.             t.abortable = e => t.playable(e) && !t.bothPlayersHavePlayed(e) && !t.mandatory(e);
  1576.             t.takebackable = e => t.playable(e) && e.takebackable && t.bothPlayersHavePlayed(e) && !e.player.proposingTakeback && !e.opponent.proposingTakeback;
  1577.             t.drawable = e => t.playable(e) && e.game.turns >= 2 && !e.player.offeringDraw && !t.hasAi(e);
  1578.             t.resignable = e => t.playable(e) && !t.abortable(e);
  1579.             t.berserkableBy = e => !!e.tournament && e.tournament.berserkable && t.isPlayerPlaying(e) && !t.bothPlayersHavePlayed(e);
  1580.             t.moretimeable = e => t.isPlayerPlaying(e) && e.moretimeable && (!!e.clock || !!e.correspondence && e.correspondence[e.opponent.color] < e.correspondence.increment - 3600);
  1581.             const s = e => "import" === e.game.source;
  1582.  
  1583.             function r(e, t) {
  1584.                 return e.player.color === t ? e.player : e.opponent.color === t ? e.opponent : null
  1585.             }
  1586.             t.replayable = e => s(e) || He.finished(e) || He.aborted(e) && t.bothPlayersHavePlayed(e), t.getPlayer = r;
  1587.             t.hasAi = e => !(!e.player.ai && !e.opponent.ai);
  1588.             t.userAnalysable = e => He.finished(e) || t.playable(e) && (!e.clock || !t.isPlayerPlaying(e));
  1589.             t.isCorrespondence = e => "correspondence" === e.game.speed;
  1590.             t.setOnGame = (e, o, n) => {
  1591.                 const s = r(e, o);
  1592.                 n = n || !!s.ai, s.onGame = n, n && t.setGone(e, o, !1)
  1593.             };
  1594.             t.setGone = (e, t, o) => {
  1595.                 const n = r(e, t);
  1596.                 n.gone = !n.ai && o, !1 === n.gone && n.user && (n.user.online = !0)
  1597.             };
  1598.             t.nbMoves = (e, t) => Math.floor((e.game.turns + ("white" == t ? 1 : 0)) / 2);
  1599.             t.isSwitchable = e => !t.hasAi(e) && (!!e.simul || t.isCorrespondence(e))
  1600.         })),
  1601.         We = te((function(e, t) {
  1602.             function o(e, t) {
  1603.                 return Math.abs(e - t)
  1604.             }
  1605.             Object.defineProperty(t, "__esModule", {
  1606.                 value: !0
  1607.             }), t.premove = t.queen = t.knight = void 0;
  1608.             t.knight = (e, t, n, s) => {
  1609.                 const r = o(e, n),
  1610.                     i = o(t, s);
  1611.                 return 1 === r && 2 === i || 2 === r && 1 === i
  1612.             };
  1613.             const n = (e, t, n, s) => o(e, n) === o(t, s),
  1614.                 s = (e, t, o, n) => e === o || t === n;
  1615.             t.queen = (e, t, o, r) => n(e, t, o, r) || s(e, t, o, r), t.premove = function(e, r, i) {
  1616.                 const a = e.get(r);
  1617.                 if (!a) return [];
  1618.                 const c = ie.key2pos(r),
  1619.                     l = a.role,
  1620.                     d = "pawn" === l ? (u = a.color, (e, t, n, s) => o(e, n) < 2 && ("white" === u ? s === t + 1 || t <= 1 && s === t + 2 && e === n : s === t - 1 || t >= 6 && s === t - 2 && e === n)) : "knight" === l ? t.knight : "bishop" === l ? n : "rook" === l ? s : "queen" === l ? t.queen : function(e, t, n) {
  1621.                         return (s, r, i, a) => o(s, i) < 2 && o(r, a) < 2 || n && r === a && r === ("white" === e ? 0 : 7) && (4 === s && (2 === i && t.includes(0) || 6 === i && t.includes(7)) || t.includes(i))
  1622.                     }(a.color, function(e, t) {
  1623.                         const o = "white" === t ? "1" : "8",
  1624.                             n = [];
  1625.                         for (const [s, r] of e) s[1] === o && r.color === t && "rook" === r.role && n.push(ie.key2pos(s)[0]);
  1626.                         return n
  1627.                     }(e, a.color), i);
  1628.                 var u;
  1629.                 return ie.allPos.filter((e => (c[0] !== e[0] || c[1] !== e[1]) && d(c[0], c[1], e[0], e[1]))).map(ie.pos2key)
  1630.             }
  1631.         })),
  1632.         Ye = te((function(e, t) {
  1633.             function o(e, ...t) {
  1634.                 e && setTimeout((() => e(...t)), 1)
  1635.             }
  1636.  
  1637.             function n(e) {
  1638.                 e.premovable.current && (e.premovable.current = void 0, o(e.premovable.events.unset))
  1639.             }
  1640.  
  1641.             function s(e) {
  1642.                 const t = e.predroppable;
  1643.                 t.current && (t.current = void 0, o(t.events.unset))
  1644.             }
  1645.  
  1646.             function r(e, t, n) {
  1647.                 const s = e.pieces.get(t),
  1648.                     r = e.pieces.get(n);
  1649.                 if (t === n || !s) return !1;
  1650.                 const i = r && r.color !== s.color ? r : void 0;
  1651.                 return n === e.selected && d(e), o(e.events.move, t, n, i),
  1652.                     function(e, t, o) {
  1653.                         if (!e.autoCastle) return !1;
  1654.                         const n = e.pieces.get(t);
  1655.                         if (!n || "king" !== n.role) return !1;
  1656.                         const s = ie.key2pos(t),
  1657.                             r = ie.key2pos(o);
  1658.                         if (0 !== s[1] && 7 !== s[1] || s[1] !== r[1]) return !1;
  1659.                         4 !== s[0] || e.pieces.has(o) || (6 === r[0] ? o = ie.pos2key([7, r[1]]) : 2 === r[0] && (o = ie.pos2key([0, r[1]])));
  1660.                         const i = e.pieces.get(o);
  1661.                         return !(!i || i.color !== n.color || "rook" !== i.role || (e.pieces.delete(t), e.pieces.delete(o), s[0] < r[0] ? (e.pieces.set(ie.pos2key([6, r[1]]), n), e.pieces.set(ie.pos2key([5, r[1]]), i)) : (e.pieces.set(ie.pos2key([2, r[1]]), n), e.pieces.set(ie.pos2key([3, r[1]]), i)), 0))
  1662.                     }(e, t, n) || (e.pieces.set(n, s), e.pieces.delete(t)), e.lastMove = [t, n], e.check = void 0, o(e.events.change), i || !0
  1663.             }
  1664.  
  1665.             function i(e, t, n, s) {
  1666.                 if (e.pieces.has(n)) {
  1667.                     if (!s) return !1;
  1668.                     e.pieces.delete(n)
  1669.                 }
  1670.                 return o(e.events.dropNewPiece, t, n), e.pieces.set(n, t), e.lastMove = [n], e.check = void 0, o(e.events.change), e.movable.dests = void 0, e.turnColor = ie.opposite(e.turnColor), !0
  1671.             }
  1672.  
  1673.             function a(e, t, o) {
  1674.                 const n = r(e, t, o);
  1675.                 return n && (e.movable.dests = void 0, e.turnColor = ie.opposite(e.turnColor), e.animation.current = void 0), n
  1676.             }
  1677.  
  1678.             function c(e, t, n) {
  1679.                 if (h(e, t, n)) {
  1680.                     const s = a(e, t, n);
  1681.                     if (s) {
  1682.                         const r = e.hold.stop();
  1683.                         d(e);
  1684.                         const i = {
  1685.                             premove: !1,
  1686.                             ctrlKey: e.stats.ctrlKey,
  1687.                             holdTime: r
  1688.                         };
  1689.                         return !0 !== s && (i.captured = s), o(e.movable.events.after, t, n, i), !0
  1690.                     }
  1691.                 } else if (function(e, t, o) {
  1692.                         return t !== o && p(e, t) && We.premove(e.pieces, t, e.premovable.castle).includes(o)
  1693.                     }(e, t, n)) return function(e, t, n, r) {
  1694.                     s(e), e.premovable.current = [t, n], o(e.premovable.events.set, t, n, r)
  1695.                 }(e, t, n, {
  1696.                     ctrlKey: e.stats.ctrlKey
  1697.                 }), d(e), !0;
  1698.                 return d(e), !1
  1699.             }
  1700.  
  1701.             function l(e, t) {
  1702.                 e.selected = t, p(e, t) ? e.premovable.dests = We.premove(e.pieces, t, e.premovable.castle) : e.premovable.dests = void 0
  1703.             }
  1704.  
  1705.             function d(e) {
  1706.                 e.selected = void 0, e.premovable.dests = void 0, e.hold.cancel()
  1707.             }
  1708.  
  1709.             function u(e, t) {
  1710.                 const o = e.pieces.get(t);
  1711.                 return !!o && ("both" === e.movable.color || e.movable.color === o.color && e.turnColor === o.color)
  1712.             }
  1713.  
  1714.             function h(e, t, o) {
  1715.                 var n, s;
  1716.                 return t !== o && u(e, t) && (e.movable.free || !!(null === (s = null === (n = e.movable.dests) || void 0 === n ? void 0 : n.get(t)) || void 0 === s ? void 0 : s.includes(o)))
  1717.             }
  1718.  
  1719.             function p(e, t) {
  1720.                 const o = e.pieces.get(t);
  1721.                 return !!o && e.premovable.enabled && e.movable.color === o.color && e.turnColor !== o.color
  1722.             }
  1723.  
  1724.             function m(e) {
  1725.                 n(e), s(e), d(e)
  1726.             }
  1727.             Object.defineProperty(t, "__esModule", {
  1728.                 value: !0
  1729.             }), t.whitePov = t.getSnappedKeyAtDomPos = t.getKeyAtDomPos = t.stop = t.cancelMove = t.playPredrop = t.playPremove = t.isDraggable = t.canMove = t.unselect = t.setSelected = t.selectSquare = t.dropNewPiece = t.userMove = t.baseNewPiece = t.baseMove = t.unsetPredrop = t.unsetPremove = t.setCheck = t.setPieces = t.reset = t.toggleOrientation = t.callUserFunction = void 0, t.callUserFunction = o, t.toggleOrientation = function(e) {
  1730.                 e.orientation = ie.opposite(e.orientation), e.animation.current = e.draggable.current = e.selected = void 0
  1731.             }, t.reset = function(e) {
  1732.                 e.lastMove = void 0, d(e), n(e), s(e)
  1733.             }, t.setPieces = function(e, t) {
  1734.                 for (const [o, n] of t) n ? e.pieces.set(o, n) : e.pieces.delete(o)
  1735.             }, t.setCheck = function(e, t) {
  1736.                 if (e.check = void 0, !0 === t && (t = e.turnColor), t)
  1737.                     for (const [o, n] of e.pieces) "king" === n.role && n.color === t && (e.check = o)
  1738.             }, t.unsetPremove = n, t.unsetPredrop = s, t.baseMove = r, t.baseNewPiece = i, t.userMove = c, t.dropNewPiece = function(e, t, r, a) {
  1739.                 const c = e.pieces.get(t);
  1740.                 c && (function(e, t, o) {
  1741.                     const n = e.pieces.get(t);
  1742.                     return !(!n || t !== o && e.pieces.has(o) || "both" !== e.movable.color && (e.movable.color !== n.color || e.turnColor !== n.color))
  1743.                 }(e, t, r) || a) ? (e.pieces.delete(t), i(e, c, r, a), o(e.movable.events.afterNewPiece, c.role, r, {
  1744.                     premove: !1,
  1745.                     predrop: !1
  1746.                 })) : c && function(e, t, o) {
  1747.                     const n = e.pieces.get(t),
  1748.                         s = e.pieces.get(o);
  1749.                     return !!n && (!s || s.color !== e.movable.color) && e.predroppable.enabled && ("pawn" !== n.role || "1" !== o[1] && "8" !== o[1]) && e.movable.color === n.color && e.turnColor !== n.color
  1750.                 }(e, t, r) ? function(e, t, s) {
  1751.                     n(e), e.predroppable.current = {
  1752.                         role: t,
  1753.                         key: s
  1754.                     }, o(e.predroppable.events.set, t, s)
  1755.                 }(e, c.role, r) : (n(e), s(e)), e.pieces.delete(t), d(e)
  1756.             }, t.selectSquare = function(e, t, n) {
  1757.                 if (o(e.events.select, t), e.selected) {
  1758.                     if (e.selected === t && !e.draggable.enabled) return d(e), void e.hold.cancel();
  1759.                     if ((e.selectable.enabled || n) && e.selected !== t && c(e, e.selected, t)) return void(e.stats.dragged = !1)
  1760.                 }(u(e, t) || p(e, t)) && (l(e, t), e.hold.start())
  1761.             }, t.setSelected = l, t.unselect = d, t.canMove = h, t.isDraggable = function(e, t) {
  1762.                 const o = e.pieces.get(t);
  1763.                 return !!o && e.draggable.enabled && ("both" === e.movable.color || e.movable.color === o.color && (e.turnColor === o.color || e.premovable.enabled))
  1764.             }, t.playPremove = function(e) {
  1765.                 const t = e.premovable.current;
  1766.                 if (!t) return !1;
  1767.                 const s = t[0],
  1768.                     r = t[1];
  1769.                 let i = !1;
  1770.                 if (h(e, s, r)) {
  1771.                     const t = a(e, s, r);
  1772.                     if (t) {
  1773.                         const n = {
  1774.                             premove: !0
  1775.                         };
  1776.                         !0 !== t && (n.captured = t), o(e.movable.events.after, s, r, n), i = !0
  1777.                     }
  1778.                 }
  1779.                 return n(e), i
  1780.             }, t.playPredrop = function(e, t) {
  1781.                 const n = e.predroppable.current;
  1782.                 let r = !1;
  1783.                 if (!n) return !1;
  1784.                 if (t(n)) {
  1785.                     i(e, {
  1786.                         role: n.role,
  1787.                         color: e.movable.color
  1788.                     }, n.key) && (o(e.movable.events.afterNewPiece, n.role, n.key, {
  1789.                         premove: !1,
  1790.                         predrop: !0
  1791.                     }), r = !0)
  1792.                 }
  1793.                 return s(e), r
  1794.             }, t.cancelMove = m, t.stop = function(e) {
  1795.                 e.movable.color = e.movable.dests = e.animation.current = void 0, m(e)
  1796.             }, t.getKeyAtDomPos = function(e, t, o) {
  1797.                 let n = Math.floor(8 * (e[0] - o.left) / o.width);
  1798.                 t || (n = 7 - n);
  1799.                 let s = 7 - Math.floor(8 * (e[1] - o.top) / o.height);
  1800.                 return t || (s = 7 - s), n >= 0 && n < 8 && s >= 0 && s < 8 ? ie.pos2key([n, s]) : void 0
  1801.             }, t.getSnappedKeyAtDomPos = function(e, t, o, n) {
  1802.                 const s = ie.key2pos(e),
  1803.                     r = ie.allPos.filter((e => We.queen(s[0], s[1], e[0], e[1]) || We.knight(s[0], s[1], e[0], e[1]))),
  1804.                     i = r.map((e => ie.computeSquareCenter(ie.pos2key(e), o, n))).map((e => ie.distanceSq(t, e))),
  1805.                     [, a] = i.reduce(((e, t, o) => e[0] < t ? e : [t, o]), [i[0], 0]);
  1806.                 return ie.pos2key(r[a])
  1807.             }, t.whitePov = function(e) {
  1808.                 return "white" === e.orientation
  1809.             }
  1810.         })),
  1811.         Xe = te((function(e, t) {
  1812.             Object.defineProperty(t, "__esModule", {
  1813.                 value: !0
  1814.             }), t.write = t.read = t.initial = void 0, t.initial = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR";
  1815.             const o = {
  1816.                     p: "pawn",
  1817.                     r: "rook",
  1818.                     n: "knight",
  1819.                     b: "bishop",
  1820.                     q: "queen",
  1821.                     k: "king"
  1822.                 },
  1823.                 n = {
  1824.                     pawn: "p",
  1825.                     rook: "r",
  1826.                     knight: "n",
  1827.                     bishop: "b",
  1828.                     queen: "q",
  1829.                     king: "k"
  1830.                 };
  1831.             t.read = function(e) {
  1832.                 "start" === e && (e = t.initial);
  1833.                 const n = new Map;
  1834.                 let s = 7,
  1835.                     r = 0;
  1836.                 for (const t of e) switch (t) {
  1837.                     case " ":
  1838.                         return n;
  1839.                     case "/":
  1840.                         if (--s, s < 0) return n;
  1841.                         r = 0;
  1842.                         break;
  1843.                     case "~":
  1844.                         const e = n.get(ie.pos2key([r, s]));
  1845.                         e && (e.promoted = !0);
  1846.                         break;
  1847.                     default:
  1848.                         const i = t.charCodeAt(0);
  1849.                         if (i < 57) r += i - 48;
  1850.                         else {
  1851.                             const e = t.toLowerCase();
  1852.                             n.set(ie.pos2key([r, s]), {
  1853.                                 role: o[e],
  1854.                                 color: t === e ? "black" : "white"
  1855.                             }), ++r
  1856.                         }
  1857.                 }
  1858.                 return n
  1859.             }, t.write = function(e) {
  1860.                 return ie.invRanks.map((t => re.files.map((o => {
  1861.                     const s = e.get(o + t);
  1862.                     if (s) {
  1863.                         const e = n[s.role];
  1864.                         return "white" === s.color ? e.toUpperCase() : e
  1865.                     }
  1866.                     return "1"
  1867.                 })).join(""))).join("/").replace(/1{2,}/g, (e => e.length.toString()))
  1868.             }
  1869.         })),
  1870.         Je = te((function(e, t) {
  1871.             function o(e, t) {
  1872.                 for (const s in t) n(e[s]) && n(t[s]) ? o(e[s], t[s]) : e[s] = t[s]
  1873.             }
  1874.  
  1875.             function n(e) {
  1876.                 return "object" == typeof e
  1877.             }
  1878.             Object.defineProperty(t, "__esModule", {
  1879.                 value: !0
  1880.             }), t.configure = void 0, t.configure = function(e, t) {
  1881.                 var n;
  1882.                 if ((null === (n = t.movable) || void 0 === n ? void 0 : n.dests) && (e.movable.dests = void 0), o(e, t), t.fen && (e.pieces = Xe.read(t.fen), e.drawable.shapes = []), t.hasOwnProperty("check") && Ye.setCheck(e, t.check || !1), t.hasOwnProperty("lastMove") && !t.lastMove ? e.lastMove = void 0 : t.lastMove && (e.lastMove = t.lastMove), e.selected && Ye.setSelected(e, e.selected), (!e.animation.duration || e.animation.duration < 100) && (e.animation.enabled = !1), !e.movable.rookCastle && e.movable.dests) {
  1883.                     const t = "white" === e.movable.color ? "1" : "8",
  1884.                         o = "e" + t,
  1885.                         n = e.movable.dests.get(o),
  1886.                         s = e.pieces.get(o);
  1887.                     if (!n || !s || "king" !== s.role) return;
  1888.                     e.movable.dests.set(o, n.filter((e => !(e === "a" + t && n.includes("c" + t) || e === "h" + t && n.includes("g" + t)))))
  1889.                 }
  1890.             }
  1891.         })),
  1892.         Ze = te((function(e, t) {
  1893.             function o(e, t) {
  1894.                 const o = e(t);
  1895.                 return t.dom.redraw(), o
  1896.             }
  1897.  
  1898.             function n(e, t) {
  1899.                 return {
  1900.                     key: e,
  1901.                     pos: ie.key2pos(e),
  1902.                     piece: t
  1903.                 }
  1904.             }
  1905.  
  1906.             function s(e, t) {
  1907.                 return t.sort(((t, o) => ie.distanceSq(e.pos, t.pos) - ie.distanceSq(e.pos, o.pos)))[0]
  1908.             }
  1909.  
  1910.             function r(e, t) {
  1911.                 const o = e.animation.current;
  1912.                 if (void 0 === o) return void(e.dom.destroyed || e.dom.redrawNow());
  1913.                 const n = 1 - (t - o.start) * o.frequency;
  1914.                 if (n <= 0) e.animation.current = void 0, e.dom.redrawNow();
  1915.                 else {
  1916.                     const t = (s = n) < .5 ? 4 * s * s * s : (s - 1) * (2 * s - 2) * (2 * s - 2) + 1;
  1917.                     for (const e of o.plan.anims.values()) e[2] = e[0] * t, e[3] = e[1] * t;
  1918.                     e.dom.redrawNow(!0), requestAnimationFrame(((t = performance.now()) => r(e, t)))
  1919.                 }
  1920.                 var s
  1921.             }
  1922.             Object.defineProperty(t, "__esModule", {
  1923.                 value: !0
  1924.             }), t.render = t.anim = void 0, t.anim = function(e, t) {
  1925.                 return t.animation.enabled ? function(e, t) {
  1926.                     const o = new Map(t.pieces),
  1927.                         i = e(t),
  1928.                         a = function(e, t) {
  1929.                             const o = new Map,
  1930.                                 r = [],
  1931.                                 i = new Map,
  1932.                                 a = [],
  1933.                                 c = [],
  1934.                                 l = new Map;
  1935.                             let d, u, h;
  1936.                             for (const [t, o] of e) l.set(t, n(t, o));
  1937.                             for (const e of ie.allKeys) d = t.pieces.get(e), u = l.get(e), d ? u ? ie.samePiece(d, u.piece) || (a.push(u), c.push(n(e, d))) : c.push(n(e, d)) : u && a.push(u);
  1938.                             for (const e of c) u = s(e, a.filter((t => ie.samePiece(e.piece, t.piece)))), u && (h = [u.pos[0] - e.pos[0], u.pos[1] - e.pos[1]], o.set(e.key, h.concat(h)), r.push(u.key));
  1939.                             for (const e of a) r.includes(e.key) || i.set(e.key, e.piece);
  1940.                             return {
  1941.                                 anims: o,
  1942.                                 fadings: i
  1943.                             }
  1944.                         }(o, t);
  1945.                     if (a.anims.size || a.fadings.size) {
  1946.                         const e = t.animation.current && t.animation.current.start;
  1947.                         t.animation.current = {
  1948.                             start: performance.now(),
  1949.                             frequency: 1 / t.animation.duration,
  1950.                             plan: a
  1951.                         }, e || r(t, performance.now())
  1952.                     } else t.dom.redraw();
  1953.                     return i
  1954.                 }(e, t) : o(e, t)
  1955.             }, t.render = o
  1956.         })),
  1957.         Qe = te((function(e, t) {
  1958.             Object.defineProperty(t, "__esModule", {
  1959.                 value: !0
  1960.             }), t.clear = t.cancel = t.end = t.move = t.processDraw = t.start = void 0;
  1961.             const o = ["green", "red", "blue", "yellow"];
  1962.  
  1963.             function n(e) {
  1964.                 requestAnimationFrame((() => {
  1965.                     const t = e.drawable.current;
  1966.                     if (t) {
  1967.                         const o = Ye.getKeyAtDomPos(t.pos, Ye.whitePov(e), e.dom.bounds());
  1968.                         o || (t.snapToValidMove = !1);
  1969.                         const s = t.snapToValidMove ? Ye.getSnappedKeyAtDomPos(t.orig, t.pos, Ye.whitePov(e), e.dom.bounds()) : o;
  1970.                         s !== t.mouseSq && (t.mouseSq = s, t.dest = s !== t.orig ? s : void 0, e.dom.redrawNow()), n(e)
  1971.                     }
  1972.                 }))
  1973.             }
  1974.  
  1975.             function s(e) {
  1976.                 e.drawable.current && (e.drawable.current = void 0, e.dom.redraw())
  1977.             }
  1978.  
  1979.             function r(e) {
  1980.                 var t;
  1981.                 const n = (e.shiftKey || e.ctrlKey) && ie.isRightButton(e),
  1982.                     s = e.altKey || e.metaKey || (null === (t = e.getModifierState) || void 0 === t ? void 0 : t.call(e, "AltGraph"));
  1983.                 return o[(n ? 1 : 0) + (s ? 2 : 0)]
  1984.             }
  1985.  
  1986.             function i(e) {
  1987.                 e.onChange && e.onChange(e.shapes)
  1988.             }
  1989.             t.start = function(e, t) {
  1990.                 if (t.touches && t.touches.length > 1) return;
  1991.                 t.stopPropagation(), t.preventDefault(), t.ctrlKey ? Ye.unselect(e) : Ye.cancelMove(e);
  1992.                 const o = ie.eventPosition(t),
  1993.                     s = Ye.getKeyAtDomPos(o, Ye.whitePov(e), e.dom.bounds());
  1994.                 s && (e.drawable.current = {
  1995.                     orig: s,
  1996.                     pos: o,
  1997.                     brush: r(t),
  1998.                     snapToValidMove: e.drawable.defaultSnapToValidMove
  1999.                 }, n(e))
  2000.             }, t.processDraw = n, t.move = function(e, t) {
  2001.                 e.drawable.current && (e.drawable.current.pos = ie.eventPosition(t))
  2002.             }, t.end = function(e) {
  2003.                 const t = e.drawable.current;
  2004.                 t && (t.mouseSq && function(e, t) {
  2005.                     const o = e => e.orig === t.orig && e.dest === t.dest,
  2006.                         n = e.shapes.find(o);
  2007.                     n && (e.shapes = e.shapes.filter((e => !o(e))));
  2008.                     n && n.brush === t.brush || e.shapes.push(t);
  2009.                     i(e)
  2010.                 }(e.drawable, t), s(e))
  2011.             }, t.cancel = s, t.clear = function(e) {
  2012.                 e.drawable.shapes.length && (e.drawable.shapes = [], e.dom.redraw(), i(e.drawable))
  2013.             }
  2014.         })),
  2015.         et = te((function(e, t) {
  2016.             function o(e) {
  2017.                 requestAnimationFrame((() => {
  2018.                     var t;
  2019.                     const s = e.draggable.current;
  2020.                     if (!s) return;
  2021.                     (null === (t = e.animation.current) || void 0 === t ? void 0 : t.plan.anims.has(s.orig)) && (e.animation.current = void 0);
  2022.                     const r = e.pieces.get(s.orig);
  2023.                     if (r && ie.samePiece(r, s.piece)) {
  2024.                         if (!s.started && ie.distanceSq(s.pos, s.origPos) >= Math.pow(e.draggable.distance, 2) && (s.started = !0), s.started) {
  2025.                             if ("function" == typeof s.element) {
  2026.                                 const e = s.element();
  2027.                                 if (!e) return;
  2028.                                 e.cgDragging = !0, e.classList.add("dragging"), s.element = e
  2029.                             }
  2030.                             const t = e.dom.bounds();
  2031.                             ie.translateAbs(s.element, [s.pos[0] - t.left - t.width / 16, s.pos[1] - t.top - t.height / 16])
  2032.                         }
  2033.                     } else n(e);
  2034.                     o(e)
  2035.                 }))
  2036.             }
  2037.  
  2038.             function n(e) {
  2039.                 const t = e.draggable.current;
  2040.                 t && (t.newPiece && e.pieces.delete(t.orig), e.draggable.current = void 0, Ye.unselect(e), s(e), e.dom.redraw())
  2041.             }
  2042.  
  2043.             function s(e) {
  2044.                 const t = e.dom.elements;
  2045.                 t.ghost && ie.setVisible(t.ghost, !1)
  2046.             }
  2047.  
  2048.             function r(e, t) {
  2049.                 let o = e.dom.elements.board.firstChild;
  2050.                 for (; o;) {
  2051.                     if (o.cgKey === t && "PIECE" === o.tagName) return o;
  2052.                     o = o.nextSibling
  2053.                 }
  2054.             }
  2055.             Object.defineProperty(t, "__esModule", {
  2056.                 value: !0
  2057.             }), t.cancel = t.end = t.move = t.dragNewPiece = t.start = void 0, t.start = function(e, t) {
  2058.                 if (( (data || data[5] !== '-')) || void 0 !== t.button && 0 !== t.button) return;
  2059.                 if (t.touches && t.touches.length > 1) return;
  2060.                 const n = e.dom.bounds(),
  2061.                     s = ie.eventPosition(t),
  2062.                     i = Ye.getKeyAtDomPos(s, Ye.whitePov(e), n);
  2063.                 if (!i) return;
  2064.                 const a = e.pieces.get(i),
  2065.                     c = e.selected;
  2066.                 c || !e.drawable.enabled || !e.drawable.eraseOnClick && a && a.color === e.turnColor || Qe.clear(e), !1 === t.cancelable || t.touches && e.movable.color && !a && !c && ! function(e, t) {
  2067.                     const o = Ye.whitePov(e),
  2068.                         n = e.dom.bounds(),
  2069.                         s = Math.pow(n.width / 8, 2);
  2070.                     for (const r in e.pieces) {
  2071.                         const e = ie.computeSquareCenter(r, o, n);
  2072.                         if (ie.distanceSq(e, t) <= s) return !0
  2073.                     }
  2074.                     return !1
  2075.                 }(e, s) || t.preventDefault();
  2076.                 const l = !!e.premovable.current,
  2077.                     d = !!e.predroppable.current;
  2078.                 e.stats.ctrlKey = t.ctrlKey, e.selected && Ye.canMove(e, e.selected, i) ? Ze.anim((e => Ye.selectSquare(e, i)), e) : Ye.selectSquare(e, i);
  2079.                 const u = e.selected === i,
  2080.                     h = r(e, i);
  2081.                 if (a && h && u && Ye.isDraggable(e, i)) {
  2082.                     e.draggable.current = {
  2083.                         orig: i,
  2084.                         piece: a,
  2085.                         origPos: s,
  2086.                         pos: s,
  2087.                         started: e.draggable.autoDistance && e.stats.dragged,
  2088.                         element: h,
  2089.                         previouslySelected: c,
  2090.                         originTarget: t.target
  2091.                     }, h.cgDragging = !0, h.classList.add("dragging");
  2092.                     const r = e.dom.elements.ghost;
  2093.                     r && (r.className = `ghost ${a.color} ${a.role}`, ie.translateAbs(r, ie.posToTranslateAbs(n)(ie.key2pos(i), Ye.whitePov(e))), ie.setVisible(r, !0)), o(e)
  2094.                 } else l && Ye.unsetPremove(e), d && Ye.unsetPredrop(e);
  2095.                 e.dom.redraw()
  2096.             }, t.dragNewPiece = function(e, t, n, s) {
  2097.                 const i = "a0";
  2098.                 e.pieces.set(i, t), e.dom.redraw();
  2099.                 const a = ie.eventPosition(n);
  2100.                 e.draggable.current = {
  2101.                     orig: i,
  2102.                     piece: t,
  2103.                     origPos: a,
  2104.                     pos: a,
  2105.                     started: !0,
  2106.                     element: () => r(e, i),
  2107.                     originTarget: n.target,
  2108.                     newPiece: !0,
  2109.                     force: !!s
  2110.                 }, o(e)
  2111.             }, t.move = function(e, t) {
  2112.                 e.draggable.current && (!t.touches || t.touches.length < 2) && (e.draggable.current.pos = ie.eventPosition(t))
  2113.             }, t.end = function(e, t) {
  2114.                 const o = e.draggable.current;
  2115.                 if (!o) return;
  2116.                 if ("touchend" === t.type && !1 !== t.cancelable && t.preventDefault(), "touchend" === t.type && o.originTarget !== t.target && !o.newPiece) return void(e.draggable.current = void 0);
  2117.                 Ye.unsetPremove(e), Ye.unsetPredrop(e);
  2118.                 const n = ie.eventPosition(t) || o.pos,
  2119.                     r = Ye.getKeyAtDomPos(n, Ye.whitePov(e), e.dom.bounds());
  2120.                 r && o.started && o.orig !== r ? o.newPiece ? Ye.dropNewPiece(e, o.orig, r, o.force) : (e.stats.ctrlKey = t.ctrlKey, Ye.userMove(e, o.orig, r) && (e.stats.dragged = !0)) : o.newPiece ? e.pieces.delete(o.orig) : e.draggable.deleteOnDropOff && !r && (e.pieces.delete(o.orig), Ye.callUserFunction(e.events.change)), (o.orig !== o.previouslySelected || o.orig !== r && r) && e.selectable.enabled || Ye.unselect(e), s(e), e.draggable.current = void 0, e.dom.redraw()
  2121.             }, t.cancel = n
  2122.         })),
  2123.         tt = te((function(e, t) {
  2124.             function o(e, t) {
  2125.                 e.exploding && (t ? e.exploding.stage = t : e.exploding = void 0, e.dom.redraw())
  2126.             }
  2127.             Object.defineProperty(t, "__esModule", {
  2128.                 value: !0
  2129.             }), t.explosion = void 0, t.explosion = function(e, t) {
  2130.                 e.exploding = {
  2131.                     stage: 1,
  2132.                     keys: t
  2133.                 }, e.dom.redraw(), setTimeout((() => {
  2134.                     o(e, 2), setTimeout((() => o(e, void 0)), 120)
  2135.                 }), 120)
  2136.             }
  2137.         })),
  2138.         ot = te((function(e, t) {
  2139.             Object.defineProperty(t, "__esModule", {
  2140.                 value: !0
  2141.             }), t.start = void 0, t.start = function(e, t) {
  2142.                 function o() {
  2143.                     Ye.toggleOrientation(e), t()
  2144.                 }
  2145.                 return {
  2146.                     set(t) {
  2147.                         t.orientation && t.orientation !== e.orientation && o(), (t.fen ? Ze.anim : Ze.render)((e => Je.configure(e, t)), e)
  2148.                     },
  2149.                     state: e,
  2150.                     getFen: () => Xe.write(e.pieces),
  2151.                     toggleOrientation: o,
  2152.                     setPieces(t) {
  2153.                         Ze.anim((e => Ye.setPieces(e, t)), e)
  2154.                     },
  2155.                     selectSquare(t, o) {
  2156.                         t ? Ze.anim((e => Ye.selectSquare(e, t, o)), e) : e.selected && (Ye.unselect(e), e.dom.redraw())
  2157.                     },
  2158.                     move(t, o) {
  2159.                         Ze.anim((e => Ye.baseMove(e, t, o)), e)
  2160.                     },
  2161.                     newPiece(t, o) {
  2162.                         Ze.anim((e => Ye.baseNewPiece(e, t, o)), e)
  2163.                     },
  2164.                     playPremove() {
  2165.                         if (e.premovable.current) {
  2166.                             if (Ze.anim(Ye.playPremove, e)) return !0;
  2167.                             e.dom.redraw()
  2168.                         }
  2169.                         return !1
  2170.                     },
  2171.                     playPredrop(t) {
  2172.                         if (e.predroppable.current) {
  2173.                             const o = Ye.playPredrop(e, t);
  2174.                             return e.dom.redraw(), o
  2175.                         }
  2176.                         return !1
  2177.                     },
  2178.                     cancelPremove() {
  2179.                         Ze.render(Ye.unsetPremove, e)
  2180.                     },
  2181.                     cancelPredrop() {
  2182.                         Ze.render(Ye.unsetPredrop, e)
  2183.                     },
  2184.                     cancelMove() {
  2185.                         Ze.render((e => {
  2186.                             Ye.cancelMove(e), et.cancel(e)
  2187.                         }), e)
  2188.                     },
  2189.                     stop() {
  2190.                         Ze.render((e => {
  2191.                             Ye.stop(e), et.cancel(e)
  2192.                         }), e)
  2193.                     },
  2194.                     explode(t) {
  2195.                         tt.explosion(e, t)
  2196.                     },
  2197.                     setAutoShapes(t) {
  2198.                         Ze.render((e => e.drawable.autoShapes = t), e)
  2199.                     },
  2200.                     setShapes(t) {
  2201.                         Ze.render((e => e.drawable.shapes = t), e)
  2202.                     },
  2203.                     getKeyAtDomPos: t => Ye.getKeyAtDomPos(t, Ye.whitePov(e), e.dom.bounds()),
  2204.                     redrawAll: t,
  2205.                     dragNewPiece(t, o, n) {
  2206.                         et.dragNewPiece(e, t, o, n)
  2207.                     },
  2208.                     destroy() {
  2209.                         Ye.stop(e), e.dom.unbind && e.dom.unbind(), e.dom.destroyed = !0
  2210.                     }
  2211.                 }
  2212.             }
  2213.         })),
  2214.         nt = te((function(e, t) {
  2215.             Object.defineProperty(t, "__esModule", {
  2216.                 value: !0
  2217.             }), t.defaults = void 0, t.defaults = function() {
  2218.                 return {
  2219.                     pieces: Xe.read(Xe.initial),
  2220.                     orientation: "white",
  2221.                     turnColor: "white",
  2222.                     coordinates: !0,
  2223.                     autoCastle: !0,
  2224.                     viewOnly: !1,
  2225.                     disableContextMenu: !1,
  2226.                     resizable: !0,
  2227.                     addPieceZIndex: !1,
  2228.                     pieceKey: !1,
  2229.                     highlight: {
  2230.                         lastMove: !0,
  2231.                         check: !0
  2232.                     },
  2233.                     animation: {
  2234.                         enabled: !0,
  2235.                         duration: 200
  2236.                     },
  2237.                     movable: {
  2238.                         free: !0,
  2239.                         color: "both",
  2240.                         showDests: !0,
  2241.                         events: {},
  2242.                         rookCastle: !0
  2243.                     },
  2244.                     premovable: {
  2245.                         enabled: !0,
  2246.                         showDests: !0,
  2247.                         castle: !0,
  2248.                         events: {}
  2249.                     },
  2250.                     predroppable: {
  2251.                         enabled: !1,
  2252.                         events: {}
  2253.                     },
  2254.                     draggable: {
  2255.                         enabled: !0,
  2256.                         distance: 3,
  2257.                         autoDistance: !0,
  2258.                         showGhost: !0,
  2259.                         deleteOnDropOff: !1
  2260.                     },
  2261.                     dropmode: {
  2262.                         active: !1
  2263.                     },
  2264.                     selectable: {
  2265.                         enabled: !0
  2266.                     },
  2267.                     stats: {
  2268.                         dragged: !("ontouchstart" in window)
  2269.                     },
  2270.                     events: {},
  2271.                     drawable: {
  2272.                         enabled: !0,
  2273.                         visible: !0,
  2274.                         defaultSnapToValidMove: !0,
  2275.                         eraseOnClick: !0,
  2276.                         shapes: [],
  2277.                         autoShapes: [],
  2278.                         brushes: {
  2279.                             green: {
  2280.                                 key: "g",
  2281.                                 color: "#15781B",
  2282.                                 opacity: 1,
  2283.                                 lineWidth: 10
  2284.                             },
  2285.                             red: {
  2286.                                 key: "r",
  2287.                                 color: "#882020",
  2288.                                 opacity: 1,
  2289.                                 lineWidth: 10
  2290.                             },
  2291.                             blue: {
  2292.                                 key: "b",
  2293.                                 color: "#003088",
  2294.                                 opacity: 1,
  2295.                                 lineWidth: 10
  2296.                             },
  2297.                             yellow: {
  2298.                                 key: "y",
  2299.                                 color: "#e68f00",
  2300.                                 opacity: 1,
  2301.                                 lineWidth: 10
  2302.                             },
  2303.                             paleBlue: {
  2304.                                 key: "pb",
  2305.                                 color: "#003088",
  2306.                                 opacity: .4,
  2307.                                 lineWidth: 15
  2308.                             },
  2309.                             paleGreen: {
  2310.                                 key: "pg",
  2311.                                 color: "#15781B",
  2312.                                 opacity: .4,
  2313.                                 lineWidth: 15
  2314.                             },
  2315.                             paleRed: {
  2316.                                 key: "pr",
  2317.                                 color: "#882020",
  2318.                                 opacity: .4,
  2319.                                 lineWidth: 15
  2320.                             },
  2321.                             paleGrey: {
  2322.                                 key: "pgr",
  2323.                                 color: "#4a4a4a",
  2324.                                 opacity: .35,
  2325.                                 lineWidth: 15
  2326.                             }
  2327.                         },
  2328.                         pieces: {
  2329.                             baseUrl: "https://lichess1.org/assets/piece/cburnett/"
  2330.                         },
  2331.                         prevSvgHash: ""
  2332.                     },
  2333.                     hold: ie.timer()
  2334.                 }
  2335.             }
  2336.         })),
  2337.         st = te((function(e, t) {
  2338.             function o(e) {
  2339.                 return document.createElementNS("http://www.w3.org/2000/svg", e)
  2340.             }
  2341.  
  2342.             function n(e, t, o, n, s) {
  2343.                 const r = e.dom.bounds(),
  2344.                     i = new Map,
  2345.                     c = [];
  2346.                 for (const e of t) i.set(e.hash, !1);
  2347.                 let l, d = s.firstChild;
  2348.                 for (; d;) l = d.getAttribute("cgHash"), i.has(l) ? i.set(l, !0) : c.push(d), d = d.nextSibling;
  2349.                 for (const e of c) s.removeChild(e);
  2350.                 for (const c of t) i.get(c.hash) || s.appendChild(a(e, c, o, n, r))
  2351.             }
  2352.  
  2353.             function s({
  2354.                 orig: e,
  2355.                 dest: t,
  2356.                 brush: o,
  2357.                 piece: n,
  2358.                 modifiers: s,
  2359.                 customSvg: a
  2360.             }, c, l, d) {
  2361.                 return [d.width, d.height, l, e, t, o, t && (c.get(t) || 0) > 1, n && r(n), s && (u = s, "" + (u.lineWidth || "")), a && i(a)].filter((e => e)).join(",");
  2362.                 var u
  2363.             }
  2364.  
  2365.             function r(e) {
  2366.                 return [e.color, e.role, e.scale].filter((e => e)).join(",")
  2367.             }
  2368.  
  2369.             function i(e) {
  2370.                 let t = 0;
  2371.                 for (let o = 0; o < e.length; o++) t = (t << 5) - t + e.charCodeAt(o) >>> 0;
  2372.                 return "custom-" + t.toString()
  2373.             }
  2374.  
  2375.             function a(e, {
  2376.                 shape: t,
  2377.                 current: n,
  2378.                 hash: s
  2379.             }, r, i, a) {
  2380.                 let c;
  2381.                 if (t.customSvg) {
  2382.                     const n = d(ie.key2pos(t.orig), e.orientation);
  2383.                     c = function(e, t, n) {
  2384.                         const {
  2385.                             width: s,
  2386.                             height: r
  2387.                         } = n, i = s / 8, a = r / 8, c = t[0] * i, d = (7 - t[1]) * a, u = l(o("g"), {
  2388.                             transform: `translate(${c},${d})`
  2389.                         }), h = l(o("svg"), {
  2390.                             width: i,
  2391.                             height: a,
  2392.                             viewBox: "0 0 100 100"
  2393.                         });
  2394.                         return u.appendChild(h), h.innerHTML = e, u
  2395.                     }(t.customSvg, n, a)
  2396.                 } else if (t.piece) c = function(e, t, n, s) {
  2397.                     const r = m(t, s),
  2398.                         i = s.width / 8 * (n.scale || 1),
  2399.                         a = n.color[0] + ("knight" === n.role ? "n" : n.role[0]).toUpperCase();
  2400.                     return l(o("image"), {
  2401.                         className: `${n.role} ${n.color}`,
  2402.                         x: r[0] - i / 2,
  2403.                         y: r[1] - i / 2,
  2404.                         width: i,
  2405.                         height: i,
  2406.                         href: e + a + ".svg"
  2407.                     })
  2408.                 }(e.drawable.pieces.baseUrl, d(ie.key2pos(t.orig), e.orientation), t.piece, a);
  2409.                 else {
  2410.                     const s = d(ie.key2pos(t.orig), e.orientation);
  2411.                     if (t.dest) {
  2412.                         let f = r[t.brush];
  2413.                         t.modifiers && (f = u(f, t.modifiers)), c = function(e, t, n, s, r, i) {
  2414.                             const a = function(e, t) {
  2415.                                     return (t ? 20 : 10) / 512 * e.width
  2416.                                 }(i, r && !s),
  2417.                                 c = m(t, i),
  2418.                                 d = m(n, i),
  2419.                                 u = d[0] - c[0],
  2420.                                 f = d[1] - c[1],
  2421.                                 g = Math.atan2(f, u),
  2422.                                 v = Math.cos(g) * a,
  2423.                                 b = Math.sin(g) * a;
  2424.                             return l(o("line"), {
  2425.                                 stroke: e.color,
  2426.                                 "stroke-width": h(e, s, i),
  2427.                                 "stroke-linecap": "round",
  2428.                                 "marker-end": "url(#arrowhead-" + e.key + ")",
  2429.                                 opacity: p(e, s),
  2430.                                 x1: c[0],
  2431.                                 y1: c[1],
  2432.                                 x2: d[0] - v,
  2433.                                 y2: d[1] - b
  2434.                             })
  2435.                         }(f, s, d(ie.key2pos(t.dest), e.orientation), n, (i.get(t.dest) || 0) > 1, a)
  2436.                     } else c = function(e, t, n, s) {
  2437.                         const r = m(t, s),
  2438.                             i = function(e) {
  2439.                                 const t = e.width / 512;
  2440.                                 return [3 * t, 4 * t]
  2441.                             }(s),
  2442.                             a = (s.width + s.height) / 32;
  2443.                         return l(o("circle"), {
  2444.                             stroke: e.color,
  2445.                             "stroke-width": i[n ? 0 : 1],
  2446.                             fill: "none",
  2447.                             opacity: p(e, n),
  2448.                             cx: r[0],
  2449.                             cy: r[1],
  2450.                             r: a - i[1] / 2
  2451.                         })
  2452.                     }(r[t.brush], s, n, a)
  2453.                 }
  2454.                 return c.setAttribute("cgHash", s), c
  2455.             }
  2456.  
  2457.             function c(e) {
  2458.                 const t = l(o("marker"), {
  2459.                     id: "arrowhead-" + e.key,
  2460.                     orient: "auto",
  2461.                     markerWidth: 4,
  2462.                     markerHeight: 8,
  2463.                     refX: 2.05,
  2464.                     refY: 2.01
  2465.                 });
  2466.                 return t.appendChild(l(o("path"), {
  2467.                     d: "M0,0 V4 L3,2 Z",
  2468.                     fill: e.color
  2469.                 })), t.setAttribute("cgKey", e.key), t
  2470.             }
  2471.  
  2472.             function l(e, t) {
  2473.                 for (const o in t) e.setAttribute(o, t[o]);
  2474.                 return e
  2475.             }
  2476.  
  2477.             function d(e, t) {
  2478.                 return "white" === t ? e : [7 - e[0], 7 - e[1]]
  2479.             }
  2480.  
  2481.             function u(e, t) {
  2482.                 return {
  2483.                     color: e.color,
  2484.                     opacity: Math.round(10 * e.opacity) / 10,
  2485.                     lineWidth: Math.round(t.lineWidth || e.lineWidth),
  2486.                     key: [e.key, t.lineWidth].filter((e => e)).join("")
  2487.                 }
  2488.             }
  2489.  
  2490.             function h(e, t, o) {
  2491.                 return (e.lineWidth || 10) * (t ? .85 : 1) / 512 * o.width
  2492.             }
  2493.  
  2494.             function p(e, t) {
  2495.                 return (e.opacity || 1) * (t ? .9 : 1)
  2496.             }
  2497.  
  2498.             function m(e, t) {
  2499.                 return [(e[0] + .5) * t.width / 8, (7.5 - e[1]) * t.height / 8]
  2500.             }
  2501.             Object.defineProperty(t, "__esModule", {
  2502.                 value: !0
  2503.             }), t.setAttributes = t.renderSvg = t.createElement = void 0, t.createElement = o, t.renderSvg = function(e, t, o) {
  2504.                 const r = e.drawable,
  2505.                     i = r.current,
  2506.                     a = i && i.mouseSq ? i : void 0,
  2507.                     l = new Map,
  2508.                     d = e.dom.bounds();
  2509.                 for (const e of r.shapes.concat(r.autoShapes).concat(a ? [a] : [])) e.dest && l.set(e.dest, (l.get(e.dest) || 0) + 1);
  2510.                 const h = r.shapes.concat(r.autoShapes).map((e => ({
  2511.                     shape: e,
  2512.                     current: !1,
  2513.                     hash: s(e, l, !1, d)
  2514.                 })));
  2515.                 a && h.push({
  2516.                     shape: a,
  2517.                     current: !0,
  2518.                     hash: s(a, l, !0, d)
  2519.                 });
  2520.                 const p = h.map((e => e.hash)).join(";");
  2521.                 if (p === e.drawable.prevSvgHash) return;
  2522.                 e.drawable.prevSvgHash = p;
  2523.                 const m = t.querySelector("defs"),
  2524.                     f = t.querySelector("g"),
  2525.                     g = o.querySelector("g");
  2526.                 ! function(e, t, o) {
  2527.                     const n = new Map;
  2528.                     let s;
  2529.                     for (const o of t) o.shape.dest && (s = e.brushes[o.shape.brush], o.shape.modifiers && (s = u(s, o.shape.modifiers)), n.set(s.key, s));
  2530.                     const r = new Set;
  2531.                     let i = o.firstChild;
  2532.                     for (; i;) r.add(i.getAttribute("cgKey")), i = i.nextSibling;
  2533.                     for (const [e, t] of n.entries()) r.has(e) || o.appendChild(c(t))
  2534.                 }(r, h, m), n(e, h.filter((e => !e.shape.customSvg)), r.brushes, l, f), n(e, h.filter((e => e.shape.customSvg)), r.brushes, l, g)
  2535.             }, t.setAttributes = l
  2536.         })),
  2537.         rt = te((function(e, t) {
  2538.             function o(e, t) {
  2539.                 const o = ie.createEl("coords", t);
  2540.                 let n;
  2541.                 for (const t of e) n = ie.createEl("coord"), n.textContent = t, o.appendChild(n);
  2542.                 return o
  2543.             }
  2544.             Object.defineProperty(t, "__esModule", {
  2545.                 value: !0
  2546.             }), t.renderWrap = void 0, t.renderWrap = function(e, t, n) {
  2547.                 e.innerHTML = "", e.classList.add("cg-wrap");
  2548.                 for (const o of re.colors) e.classList.toggle("orientation-" + o, t.orientation === o);
  2549.                 e.classList.toggle("manipulable", !t.viewOnly);
  2550.                 const s = ie.createEl("cg-helper");
  2551.                 e.appendChild(s);
  2552.                 const r = ie.createEl("cg-container");
  2553.                 s.appendChild(r);
  2554.                 const i = ie.createEl("cg-board");
  2555.                 let a, c, l;
  2556.                 if (r.appendChild(i), t.drawable.visible && !n && (a = st.setAttributes(st.createElement("svg"), {
  2557.                         class: "cg-shapes"
  2558.                     }), a.appendChild(st.createElement("defs")), a.appendChild(st.createElement("g")), c = st.setAttributes(st.createElement("svg"), {
  2559.                         class: "cg-custom-svgs"
  2560.                     }), c.appendChild(st.createElement("g")), r.appendChild(a), r.appendChild(c)), t.coordinates) {
  2561.                     const e = "black" === t.orientation ? " black" : "";
  2562.                     r.appendChild(o(re.ranks, "ranks" + e)), r.appendChild(o(re.files, "files" + e))
  2563.                 }
  2564.                 return t.draggable.showGhost && !n && (l = ie.createEl("piece", "ghost"), ie.setVisible(l, !1), r.appendChild(l)), {
  2565.                     board: i,
  2566.                     container: r,
  2567.                     ghost: l,
  2568.                     svg: a,
  2569.                     customSvg: c
  2570.                 }
  2571.             }
  2572.         })),
  2573.         it = te((function(e, t) {
  2574.             Object.defineProperty(t, "__esModule", {
  2575.                 value: !0
  2576.             }), t.drop = t.cancelDropMode = t.setDropMode = void 0, t.setDropMode = function(e, t) {
  2577.                 e.dropmode = {
  2578.                     active: !0,
  2579.                     piece: t
  2580.                 }, et.cancel(e)
  2581.             }, t.cancelDropMode = function(e) {
  2582.                 e.dropmode = {
  2583.                     active: !1
  2584.                 }
  2585.             }, t.drop = function(e, t) {
  2586.                 if (!e.dropmode.active) return;
  2587.                 Ye.unsetPremove(e), Ye.unsetPredrop(e);
  2588.                 const o = e.dropmode.piece;
  2589.                 if (o) {
  2590.                     e.pieces.set("a0", o);
  2591.                     const n = ie.eventPosition(t),
  2592.                         s = n && Ye.getKeyAtDomPos(n, Ye.whitePov(e), e.dom.bounds());
  2593.                     s && Ye.dropNewPiece(e, "a0", s)
  2594.                 }
  2595.                 e.dom.redraw()
  2596.             }
  2597.         })),
  2598.         at = te((function(e, t) {
  2599.             function o(e, t, o, n) {
  2600.                 return e.addEventListener(t, o, n), () => e.removeEventListener(t, o, n)
  2601.             }
  2602.  
  2603.             function n(e, t, o) {
  2604.                 return n => {
  2605.                     e.drawable.current ? e.drawable.enabled && o(e, n) : e.viewOnly || t(e, n)
  2606.                 }
  2607.             }
  2608.             Object.defineProperty(t, "__esModule", {
  2609.                 value: !0
  2610.             }), t.bindDocument = t.bindBoard = void 0, t.bindBoard = function(e, t) {
  2611.                 const o = e.dom.elements.board;
  2612.                 if (!e.dom.relative && e.resizable && "ResizeObserver" in window) {
  2613.                     new window.ResizeObserver(t).observe(o)
  2614.                 }
  2615.                 if (e.viewOnly) return;
  2616.                 const n = function(e) {
  2617.                     return t => {
  2618.                         e.draggable.current ? et.cancel(e) : e.drawable.current ? Qe.cancel(e) : t.shiftKey || ie.isRightButton(t) ? e.drawable.enabled && Qe.start(e, t) : e.viewOnly || (e.dropmode.active ? it.drop(e, t) : et.start(e, t))
  2619.                     }
  2620.                 }(e);
  2621.                 o.addEventListener("touchstart", n, {
  2622.                     passive: !1
  2623.                 }), o.addEventListener("mousedown", n, {
  2624.                     passive: !1
  2625.                 }), (e.disableContextMenu || e.drawable.enabled) && o.addEventListener("contextmenu", (e => e.preventDefault()))
  2626.             }, t.bindDocument = function(e, t) {
  2627.                 const s = [];
  2628.                 if (e.dom.relative || !e.resizable || "ResizeObserver" in window || s.push(o(document.body, "chessground.resize", t)), !e.viewOnly) {
  2629.                     const t = n(e, et.move, Qe.move),
  2630.                         r = n(e, et.end, Qe.end);
  2631.                     for (const e of ["touchmove", "mousemove"]) s.push(o(document, e, t));
  2632.                     for (const e of ["touchend", "mouseup"]) s.push(o(document, e, r));
  2633.                     const i = () => e.dom.bounds.clear();
  2634.                     s.push(o(document, "scroll", i, {
  2635.                         capture: !0,
  2636.                         passive: !0
  2637.                     })), s.push(o(window, "resize", i, {
  2638.                         passive: !0
  2639.                     }))
  2640.                 }
  2641.                 return () => s.forEach((e => e()))
  2642.             }
  2643.         })),
  2644.         ct = te((function(e, t) {
  2645.             Object.defineProperty(t, "__esModule", {
  2646.                 value: !0
  2647.             }), t.updateBounds = t.render = void 0;
  2648.             const o = ie;
  2649.  
  2650.             function n(e) {
  2651.                 return "PIECE" === e.tagName
  2652.             }
  2653.  
  2654.             function s(e) {
  2655.                 return "SQUARE" === e.tagName
  2656.             }
  2657.  
  2658.             function r(e, t) {
  2659.                 for (const o of t) e.dom.elements.board.removeChild(o)
  2660.             }
  2661.  
  2662.             function i(e, t) {
  2663.                 let o = 2 + 8 * e[1] + (7 - e[0]);
  2664.                 return t && (o = 67 - o), o + ""
  2665.             }
  2666.  
  2667.             function a(e) {
  2668.                 return `${e.color} ${e.role}`
  2669.             }
  2670.  
  2671.             function c(e, t, o) {
  2672.                 const n = e.get(t);
  2673.                 n ? e.set(t, `${n} ${o}`) : e.set(t, o)
  2674.             }
  2675.  
  2676.             function l(e, t, o) {
  2677.                 const n = e.get(t);
  2678.                 n ? n.push(o) : e.set(t, [o])
  2679.             }
  2680.             t.render = function(e) {
  2681.                 const t = Ye.whitePov(e),
  2682.                     d = e.dom.relative ? o.posToTranslateRel : o.posToTranslateAbs(e.dom.bounds()),
  2683.                     u = e.dom.relative ? o.translateRel : o.translateAbs,
  2684.                     h = e.dom.elements.board,
  2685.                     p = e.pieces,
  2686.                     m = e.animation.current,
  2687.                     f = m ? m.plan.anims : new Map,
  2688.                     g = m ? m.plan.fadings : new Map,
  2689.                     v = e.draggable.current,
  2690.                     b = function(e) {
  2691.                         var t;
  2692.                         const o = new Map;
  2693.                         if (e.lastMove && e.highlight.lastMove)
  2694.                             for (const t of e.lastMove) c(o, t, "last-move");
  2695.                         e.check && e.highlight.check && c(o, e.check, "check");
  2696.                         if (e.selected && (c(o, e.selected, "selected"), e.movable.showDests)) {
  2697.                             const n = null === (t = e.movable.dests) || void 0 === t ? void 0 : t.get(e.selected);
  2698.                             if (n)
  2699.                                 for (const t of n) c(o, t, "move-dest" + (e.pieces.has(t) ? " oc" : ""));
  2700.                             const s = e.premovable.dests;
  2701.                             if (s)
  2702.                                 for (const t of s) c(o, t, "premove-dest" + (e.pieces.has(t) ? " oc" : ""))
  2703.                         }
  2704.                         const n = e.premovable.current;
  2705.                         if (n)
  2706.                             for (const e of n) c(o, e, "current-premove");
  2707.                         else e.predroppable.current && c(o, e.predroppable.current.key, "current-premove");
  2708.                         const s = e.exploding;
  2709.                         if (s)
  2710.                             for (const e of s.keys) c(o, e, "exploding" + s.stage);
  2711.                         return o
  2712.                     }(e),
  2713.                     y = new Set,
  2714.                     w = new Set,
  2715.                     k = new Map,
  2716.                     P = new Map;
  2717.                 let M, C, T, x, S, O, _, A, j, L;
  2718.                 for (C = h.firstChild; C;) {
  2719.                     if (M = C.cgKey, n(C))
  2720.                         if (T = p.get(M), S = f.get(M), O = g.get(M), x = C.cgPiece, !C.cgDragging || v && v.orig === M || (C.classList.remove("dragging"), u(C, d(ie.key2pos(M), t)), C.cgDragging = !1), !O && C.cgFading && (C.cgFading = !1, C.classList.remove("fading")), T) {
  2721.                             if (S && C.cgAnimating && x === a(T)) {
  2722.                                 const e = ie.key2pos(M);
  2723.                                 e[0] += S[2], e[1] += S[3], C.classList.add("anim"), u(C, d(e, t))
  2724.                             } else C.cgAnimating && (C.cgAnimating = !1, C.classList.remove("anim"), u(C, d(ie.key2pos(M), t)), e.addPieceZIndex && (C.style.zIndex = i(ie.key2pos(M), t)));
  2725.                             x !== a(T) || O && C.cgFading ? O && x === a(O) ? (C.classList.add("fading"), C.cgFading = !0) : l(k, x, C) : y.add(M)
  2726.                         } else l(k, x, C);
  2727.                     else if (s(C)) {
  2728.                         const e = C.className;
  2729.                         b.get(M) === e ? w.add(M) : l(P, e, C)
  2730.                     }
  2731.                     C = C.nextSibling
  2732.                 }
  2733.                 for (const [e, o] of b)
  2734.                     if (!w.has(e)) {
  2735.                         j = P.get(o), L = j && j.pop();
  2736.                         const n = d(ie.key2pos(e), t);
  2737.                         if (L) L.cgKey = e, u(L, n);
  2738.                         else {
  2739.                             const t = ie.createEl("square", o);
  2740.                             t.cgKey = e, u(t, n), h.insertBefore(t, h.firstChild)
  2741.                         }
  2742.                     } for (const [o, n] of p)
  2743.                     if (S = f.get(o), !y.has(o))
  2744.                         if (_ = k.get(a(n)), A = _ && _.pop(), A) {
  2745.                             A.cgKey = o, A.cgFading && (A.classList.remove("fading"), A.cgFading = !1);
  2746.                             const n = ie.key2pos(o);
  2747.                             e.addPieceZIndex && (A.style.zIndex = i(n, t)), S && (A.cgAnimating = !0, A.classList.add("anim"), n[0] += S[2], n[1] += S[3]), u(A, d(n, t))
  2748.                         } else {
  2749.                             const s = a(n),
  2750.                                 r = ie.createEl("piece", s),
  2751.                                 c = ie.key2pos(o);
  2752.                             r.cgPiece = s, r.cgKey = o, S && (r.cgAnimating = !0, c[0] += S[2], c[1] += S[3]), u(r, d(c, t)), e.addPieceZIndex && (r.style.zIndex = i(c, t)), h.appendChild(r)
  2753.                         } for (const t of k.values()) r(e, t);
  2754.                 for (const t of P.values()) r(e, t)
  2755.             }, t.updateBounds = function(e) {
  2756.                 if (e.dom.relative) return;
  2757.                 const t = Ye.whitePov(e),
  2758.                     r = o.posToTranslateAbs(e.dom.bounds());
  2759.                 let i = e.dom.elements.board.firstChild;
  2760.                 for (; i;)(n(i) && !i.cgAnimating || s(i)) && o.translateAbs(i, r(ie.key2pos(i.cgKey), t)), i = i.nextSibling
  2761.             }
  2762.         })),
  2763.         lt = te((function(e, t) {
  2764.             function o(e) {
  2765.                 let t = !1;
  2766.                 return () => {
  2767.                     t || (t = !0, requestAnimationFrame((() => {
  2768.                         e(), t = !1
  2769.                     })))
  2770.                 }
  2771.             }
  2772.             Object.defineProperty(t, "__esModule", {
  2773.                 value: !0
  2774.             }), t.Chessground = void 0, t.Chessground = function(e, t) {
  2775.                 const n = nt.defaults();
  2776.  
  2777.                 function s() {
  2778.                     const t = "dom" in n ? n.dom.unbind : void 0,
  2779.                         s = n.viewOnly && !n.drawable.visible,
  2780.                         r = rt.renderWrap(e, n, s),
  2781.                         i = ie.memo((() => r.board.getBoundingClientRect())),
  2782.                         a = e => {
  2783.                             ct.render(l), !e && r.svg && st.renderSvg(l, r.svg, r.customSvg)
  2784.                         },
  2785.                         c = () => {
  2786.                             i.clear(), ct.updateBounds(l), r.svg && st.renderSvg(l, r.svg, r.customSvg)
  2787.                         },
  2788.                         l = n;
  2789.                     return l.dom = {
  2790.                         elements: r,
  2791.                         bounds: i,
  2792.                         redraw: o(a),
  2793.                         redrawNow: a,
  2794.                         unbind: t,
  2795.                         relative: s
  2796.                     }, l.drawable.prevSvgHash = "", a(!1), at.bindBoard(l, c), t || (l.dom.unbind = at.bindDocument(l, c)), l.events.insert && l.events.insert(r), l
  2797.                 }
  2798.                 return Je.configure(n, t || {}), ot.start(s(), s)
  2799.             }
  2800.         })),
  2801.         dt = ee(te((function(e, t) {
  2802.             Object.defineProperty(t, "__esModule", {
  2803.                 value: !0
  2804.             });
  2805.             t.default = () => {
  2806.                 const e = {
  2807.                     blue: "#DEE3E6 #788a94",
  2808.                     blue2: "#97b2c7 #546f82",
  2809.                     blue3: "#d9e0e6 #315991",
  2810.                     canvas: "#d7daeb #547388",
  2811.                     wood: "#d8a45b #9b4d0f",
  2812.                     wood2: "#a38b5d #6c5017",
  2813.                     wood3: "#d0ceca #755839",
  2814.                     wood4: "#caaf7d #7b5330",
  2815.                     maple: "#e8ceab #bc7944",
  2816.                     maple2: "#E2C89F #996633",
  2817.                     leather: "#d1d1c9 #c28e16",
  2818.                     green: "#FFFFDD #6d8753",
  2819.                     brown: "#F0D9B5 #946f51",
  2820.                     pink: "#E8E9B7 #ED7272",
  2821.                     marble: "#93ab91 #4f644e",
  2822.                     "blue-marble": "#EAE6DD #7C7F87",
  2823.                     "green-plastic": "#f2f9bb #59935d",
  2824.                     grey: "#b8b8b8 #7d7d7d",
  2825.                     metal: "#c9c9c9 #727272",
  2826.                     olive: "#b8b19f #6d6655",
  2827.                     newspaper: "#fff #8d8d8d",
  2828.                     purple: "#9f90b0 #7d4a8d",
  2829.                     "purple-diag": "#E5DAF0 #957AB0",
  2830.                     ic: "#ececec #c1c18e",
  2831.                     horsey: "#F0D9B5 #946f51"
  2832.                 };
  2833.                 for (const t of document.body.className.split(" "))
  2834.                     if (t in e) {
  2835.                         const o = document.documentElement.style,
  2836.                             n = e[t].split(" ");
  2837.                         o.setProperty("--cg-coord-color-white", n[0]), o.setProperty("--cg-coord-color-black", n[1]), o.setProperty("--cg-coord-shadow", "none")
  2838.                     }
  2839.             }
  2840.         }))),
  2841.         ut = ee(te((function(e, t) {
  2842.             function o(e) {
  2843.                 var t;
  2844.                 return e.clientX || 0 === e.clientX ? [e.clientX, e.clientY] : (null === (t = e.targetTouches) || void 0 === t ? void 0 : t[0]) ? [e.targetTouches[0].clientX, e.targetTouches[0].clientY] : void 0
  2845.             }
  2846.             Object.defineProperty(t, "__esModule", {
  2847.                 value: !0
  2848.             }), t.default = function(e, t, n, s) {
  2849.                 if (!t) return;
  2850.                 const r = document.createElement("cg-resize");
  2851.                 e.container.appendChild(r);
  2852.                 const i = e => {
  2853.                     e.preventDefault();
  2854.                     const t = "touchstart" === e.type ? "touchmove" : "mousemove",
  2855.                         n = "touchstart" === e.type ? "touchend" : "mouseup",
  2856.                         s = o(e),
  2857.                         r = parseInt(getComputedStyle(document.body).getPropertyValue("--zoom"));
  2858.                     let i = r;
  2859.                     const a = be.default((() => se.text(`/pref/zoom?v=${100+i}`, {
  2860.                             method: "post"
  2861.                         })), 700),
  2862.                         c = e => {
  2863.                             const t = o(e),
  2864.                                 n = t[0] - s[0] + t[1] - s[1];
  2865.                             i = Math.round(Math.min(100, Math.max(0, r + n / 10))), document.body.setAttribute("style", "--zoom:" + i), window.dispatchEvent(new Event("resize")), a()
  2866.                         };
  2867.                     document.body.classList.add("resizing"), document.addEventListener(t, c), document.addEventListener(n, (() => {
  2868.                         document.removeEventListener(t, c), document.body.classList.remove("resizing")
  2869.                     }), {
  2870.                         once: !0
  2871.                     })
  2872.                 };
  2873.                 if (r.addEventListener("touchstart", i, {
  2874.                         passive: !1
  2875.                     }), r.addEventListener("mousedown", i, {
  2876.                         passive: !1
  2877.                     }), 1 == t) {
  2878.                     const e = e => r.classList.toggle("none", s ? !s(e) : e >= 2);
  2879.                     e(n), lichess.pubsub.on("ply", e)
  2880.                 }
  2881.             }
  2882.         })));
  2883.  
  2884.     function ht(e) {
  2885.         const t = e.data,
  2886.             o = e.makeCgHooks(),
  2887.             n = ze(t, e.ply),
  2888.             s = e.isPlaying();
  2889.         return {
  2890.             fen: n.fen,
  2891.             orientation: mt(t, e.flip),
  2892.             turnColor: n.ply % 2 == 0 ? "white" : "black",
  2893.             lastMove: le(n.uci),
  2894.             check: !!n.check,
  2895.             coordinates: 0 !== t.pref.coords,
  2896.             addPieceZIndex: e.data.pref.is3d,
  2897.             highlight: {
  2898.                 lastMove: t.pref.highlight,
  2899.                 check: t.pref.highlight
  2900.             },
  2901.             events: {
  2902.                 move: o.onMove,
  2903.                 dropNewPiece: o.onNewPiece,
  2904.                 insert(o) {
  2905.                     ut(o, e.data.pref.resizeHandle, e.ply), 1 == t.pref.coords && dt()
  2906.                 }
  2907.             },
  2908.             movable: {
  2909.                 free: !1,
  2910.                 color: s ? t.player.color : void 0,
  2911.                 dests: s ? he(t.possibleMoves) : new Map,
  2912.                 showDests: t.pref.destination,
  2913.                 rookCastle: t.pref.rookCastle,
  2914.                 events: {
  2915.                     after: o.onUserMove,
  2916.                     afterNewPiece: o.onUserNewPiece
  2917.                 }
  2918.             },
  2919.             animation: {
  2920.                 enabled: !0,
  2921.                 duration: t.pref.animationDuration
  2922.             },
  2923.             premovable: {
  2924.                 enabled: t.pref.enablePremove,
  2925.                 showDests: t.pref.destination,
  2926.                 castle: "antichess" !== t.game.variant.key,
  2927.                 events: {
  2928.                     set: o.onPremove,
  2929.                     unset: o.onCancelPremove
  2930.                 }
  2931.             },
  2932.             predroppable: {
  2933.                 enabled: t.pref.enablePremove && "crazyhouse" === t.game.variant.key,
  2934.                 events: {
  2935.                     set: o.onPredrop,
  2936.                     unset() {
  2937.                         o.onPredrop(void 0)
  2938.                     }
  2939.                 }
  2940.             },
  2941.             draggable: {
  2942.                 enabled: t.pref.moveEvent > 0,
  2943.                 showGhost: t.pref.highlight
  2944.             },
  2945.             selectable: {
  2946.                 enabled: 1 !== t.pref.moveEvent
  2947.             },
  2948.             drawable: {
  2949.                 enabled: !0,
  2950.                 defaultSnapToValidMove: "0" != (lichess.storage.get("arrow.snap") || 1)
  2951.             },
  2952.             disableContextMenu: !0
  2953.         }
  2954.     }
  2955.  
  2956.     function pt(e, t, o) {
  2957.         const n = e.state.pieces.get(t);
  2958.         n && "pawn" === n.role && e.setPieces(new Map([
  2959.             [t, {
  2960.                 color: n.color,
  2961.                 role: o,
  2962.                 promoted: !0
  2963.             }]
  2964.         ]))
  2965.     }
  2966.  
  2967.     function mt(e, t) {
  2968.         return "racingKings" === e.game.variant.key ? t ? "black" : "white" : t ? e.opponent.color : e.player.color
  2969.     }
  2970.  
  2971.     function ft(e) {
  2972.         return p("div.cg-wrap", {
  2973.             hook: de((t => e.setChessground(lt.Chessground(t, ht(e)))))
  2974.         })
  2975.     }
  2976.     var gt = ee(te((function(e, t) {
  2977.             Object.defineProperty(t, "__esModule", {
  2978.                 value: !0
  2979.             });
  2980.             let o = [],
  2981.                 n = !1;
  2982.  
  2983.             function s(e) {
  2984.                 const t = lichess.storage.make("just-notified");
  2985.                 if (document.hasFocus() || Date.now() - parseInt(t.get(), 10) < 1e3) return;
  2986.                 t.set("" + Date.now()), $.isFunction(e) && (e = e());
  2987.                 const s = new Notification("lichess.org", {
  2988.                     icon: lichess.assetUrl("logo/lichess-favicon-256.png", {
  2989.                         noVersion: !0
  2990.                     }),
  2991.                     body: e
  2992.                 });
  2993.                 s.onclick = () => window.focus(), o.push(s), n || (n = !0, window.addEventListener("focus", (() => {
  2994.                     o.forEach((e => e.close())), o = []
  2995.                 })))
  2996.             }
  2997.             t.default = function(e) {
  2998.                 !document.hasFocus() && "Notification" in window && "granted" === Notification.permission && setTimeout(s, 10 + 500 * Math.random(), e)
  2999.             }
  3000.         }))),
  3001.         vt = ee(te((function(e, t) {
  3002.             Object.defineProperty(t, "__esModule", {
  3003.                 value: !0
  3004.             }), t.default = function(e, t) {
  3005.                 let o, n = 0;
  3006.                 return function(...s) {
  3007.                     const r = this,
  3008.                         i = performance.now() - n;
  3009.  
  3010.                     function a() {
  3011.                         o = void 0, n = performance.now(), t.apply(r, s)
  3012.                     }
  3013.                     o && clearTimeout(o), i > e ? a() : o = setTimeout(a, e - i)
  3014.                 }
  3015.             }
  3016.         }))),
  3017.         bt = ee(te((function(e, t) {
  3018.             function o(e, t, n) {
  3019.                 o.close();
  3020.                 const s = $('<div id="modal-wrap"><span class="close" data-icon="L"></span></div>'),
  3021.                     r = $(`<div id="modal-overlay" class="${t}">`).on("click", o.close);
  3022.                 return s.appendTo(r), e.clone().removeClass("none").appendTo(s), o.onClose = n, s.find(".close").on("click", o.close), s.on("click", (e => e.stopPropagation())), $("body").addClass("overlayed").prepend(r), s
  3023.             }
  3024.             Object.defineProperty(t, "__esModule", {
  3025.                 value: !0
  3026.             }), t.default = o, o.close = () => {
  3027.                 $("body").removeClass("overlayed"), $("#modal-overlay").each((function() {
  3028.                     o.onClose && o.onClose(), $(this).remove()
  3029.                 })), delete o.onClose
  3030.             }, o.onClose = void 0
  3031.         })));
  3032.     const yt = e => se.json(e.data.url.round),
  3033.         wt = vt(1e3, (e => se.text("/pref/zen", {
  3034.             method: "post",
  3035.             body: se.form({
  3036.                 zen: e ? 1 : 0
  3037.             })
  3038.         }))),
  3039.         kt = e => vt(100, (() => lichess.sound.play(e))),
  3040.         Pt = kt("move"),
  3041.         Mt = kt("capture"),
  3042.         Ct = kt("check"),
  3043.         Tt = kt("explosion");
  3044.  
  3045.     function xt(e, t, o) {
  3046.         let n, s = 0;
  3047.         return function(...r) {
  3048.             const i = this,
  3049.                 a = performance.now() - s;
  3050.  
  3051.             function c() {
  3052.                 n = void 0, s = performance.now(), e *= t, o.apply(i, r)
  3053.             }
  3054.             n && clearTimeout(n), a > e ? c() : n = setTimeout(c, e - a)
  3055.         }
  3056.     }
  3057.     const St = document.title;
  3058.     let Ot = 0;
  3059.     const _t = ["/assets/logo/lichess-favicon-32.png", "/assets/logo/lichess-favicon-32-invert.png"].map(((e, t) => () => {
  3060.         Ot !== t && (document.getElementById("favicon").href = e, Ot = t)
  3061.     }));
  3062.     let At, jt, Lt;
  3063.  
  3064.     function Dt() {
  3065.         At && clearTimeout(At), At = void 0, _t[0]()
  3066.     }
  3067.  
  3068.     function Et(e, t) {
  3069.         e.data.player.spectator || (t || (He.aborted(e.data) || He.finished(e.data) ? t = e.noarg("gameOver") : Ue.isPlayerTurn(e.data) ? (t = e.noarg("yourTurn"), document.hasFocus() || At || (At = setTimeout((function e() {
  3070.             document.hasFocus() || (_t[1 - Ot](), At = setTimeout(e, 1e3))
  3071.         }), 200))) : (t = e.noarg("waitingForOpponent"), Dt())), document.title = `${t} - ${St}`)
  3072.     }
  3073.  
  3074.     function Nt(e, t, o, n, s) {
  3075.         return pt(e.chessground, o, n), e.sendMove(t, o, n, s), !0
  3076.     }
  3077.  
  3078.     function $t(e, t, o, n = {}) {
  3079.         var s;
  3080.         const r = e.data,
  3081.             i = e.chessground.state.pieces.get(o),
  3082.             a = e.chessground.state.pieces.get(t);
  3083.         return !(!(i && "pawn" === i.role && !a || a && "pawn" === a.role) || !("8" === o[1] && "white" === r.player.color || "1" === o[1] && "black" === r.player.color)) && (Lt && n && n.premove ? Nt(e, t, o, Lt, n) : n.ctrlKey || jt || !(3 === r.pref.autoQueen || 2 === r.pref.autoQueen && a || (null === (s = e.keyboardMove) || void 0 === s ? void 0 : s.justSelected())) ? (jt = {
  3084.             move: [t, o],
  3085.             pre: !!a,
  3086.             meta: n
  3087.         }, e.redraw(), !0) : (a ? Rt(e, o, "queen") : Nt(e, t, o, "queen", n), !0))
  3088.     }
  3089.  
  3090.     function Rt(e, t, o) {
  3091.         Lt = o, e.chessground.setAutoShapes([{
  3092.             orig: t,
  3093.             piece: {
  3094.                 color: e.data.player.color,
  3095.                 role: o,
  3096.                 opacity: .8
  3097.             },
  3098.             brush: ""
  3099.         }])
  3100.     }
  3101.  
  3102.     function Bt(e) {
  3103.         Lt && (e.chessground.setAutoShapes([]), Lt = void 0, e.redraw())
  3104.     }
  3105.  
  3106.     function It(e) {
  3107.         Bt(e), e.chessground.cancelPremove(), jt && yt(e).then(e.reload, lichess.reload), jt = void 0
  3108.     }
  3109.  
  3110.     function qt(e, t, o, n, s) {
  3111.         let r = 12.5 * (7 - ie.key2pos(t)[0]);
  3112.         "white" === s && (r = 87.5 - r);
  3113.         return p("div#promotion-choice." + (n === s ? "top" : "bottom"), {
  3114.             hook: de((t => {
  3115.                 t.addEventListener("click", (() => It(e))), t.addEventListener("contextmenu", (e => (e.preventDefault(), !1)))
  3116.             }))
  3117.         }, o.map(((t, o) => p("square", {
  3118.             attrs: {
  3119.                 style: `top:${12.5*(n===s?o:7-o)}%;left:${r}%`
  3120.             },
  3121.             hook: ue("click", (o => {
  3122.                 o.stopPropagation(),
  3123.                     function(e, t) {
  3124.                         if (jt) {
  3125.                             const o = jt;
  3126.                             jt = void 0, o.pre ? Rt(e, o.move[1], t) : Nt(e, o.move[0], o.move[1], t, o.meta), e.redraw()
  3127.                         }
  3128.                     }(e, t)
  3129.             }))
  3130.         }, [p(`piece.${t}.${n}`)]))))
  3131.     }
  3132.     const Ft = ["queen", "knight", "rook", "bishop"];
  3133.  
  3134.     function Gt(e) {
  3135.         if (jt) return qt(e, jt.move[1], "antichess" === e.data.game.variant.key ? Ft.concat("king") : Ft, e.data.player.color, e.chessground.state.orientation)
  3136.     }
  3137.     let zt = 0,
  3138.         Kt = 0;
  3139.  
  3140.     function Ht() {
  3141.         return zt >= Kt
  3142.     }
  3143.     var Vt = ee(te((function(e, t) {
  3144.         Object.defineProperty(t, "__esModule", {
  3145.             value: !0
  3146.         }), t.default = function(e) {
  3147.             const t = e.trans.noarg,
  3148.                 o = e.data;
  3149.             switch (o.game.status.name) {
  3150.                 case "started":
  3151.                     return t("playingRightNow");
  3152.                 case "aborted":
  3153.                     return t("gameAborted");
  3154.                 case "mate":
  3155.                     return t("checkmate");
  3156.                 case "resign":
  3157.                     return t("white" == o.game.winner ? "blackResigned" : "whiteResigned");
  3158.                 case "stalemate":
  3159.                     return t("stalemate");
  3160.                 case "timeout":
  3161.                     switch (o.game.winner) {
  3162.                         case "white":
  3163.                             return t("blackLeftTheGame");
  3164.                         case "black":
  3165.                             return t("whiteLeftTheGame")
  3166.                     }
  3167.                     return t("draw");
  3168.                 case "draw":
  3169.                     return t("draw");
  3170.                 case "outoftime":
  3171.                     return `${o.game.turns%2==0?t("whiteTimeOut"):t("blackTimeOut")}${o.game.winner?"":` • ${t("draw")}`}`;
  3172.                 case "noStart":
  3173.                     return ("white" == o.game.winner ? "Black" : "White") + " didn't move";
  3174.                 case "cheat":
  3175.                     return "Cheat detected";
  3176.                 case "variantEnd":
  3177.                     switch (o.game.variant.key) {
  3178.                         case "kingOfTheHill":
  3179.                             return t("kingInTheCenter");
  3180.                         case "threeCheck":
  3181.                             return t("threeChecks")
  3182.                     }
  3183.                     return t("variantEnding");
  3184.                 case "unknownFinish":
  3185.                     return "Finished";
  3186.                 default:
  3187.                     return o.game.status.name
  3188.             }
  3189.         }
  3190.     })));
  3191.     const Ut = e => t => {
  3192.             !window.LichessSpeech && t ? lichess.loadModule("speech").then((() => Wt(e))) : window.LichessSpeech && !t && (window.LichessSpeech = void 0)
  3193.         },
  3194.         Wt = e => {
  3195.             const t = Vt(e);
  3196.             if ("playingRightNow" == t) window.LichessSpeech.step(e.stepAt(e.ply), !1);
  3197.             else {
  3198.                 Yt((e => e.say(t, !1)));
  3199.                 const o = e.data.game.winner;
  3200.                 o && Yt((t => t.say(e.noarg(o + "IsVictorious"), !1)))
  3201.             }
  3202.         },
  3203.         Yt = e => window.LichessSpeech && e(window.LichessSpeech);
  3204.     var Xt = te((function(e, t) {
  3205.         function o(e, t, o) {
  3206.             return (o ? "/embed/" : "/") + (e.game ? e.game.id : e) + (t ? "/" + t : "")
  3207.         }
  3208.         Object.defineProperty(t, "__esModule", {
  3209.             value: !0
  3210.         }), t.cont = t.game = void 0, t.game = o, t.cont = function(e, t) {
  3211.             return o(e) + "/continue/" + t
  3212.         }
  3213.     }));
  3214.  
  3215.     function Jt(e) {
  3216.         const t = e.data,
  3217.             o = Xt.game(t, "racingKings" === (n = t).game.variant.key ? "white" : n.player.color) + "#" + e.ply;
  3218.         var n;
  3219.         return Ue.replayable(t) ? p("a.fbt", {
  3220.             attrs: {
  3221.                 href: o
  3222.             },
  3223.             hook: ue("click", (e => {
  3224.                 location.pathname === o.split("#")[0] && location.reload()
  3225.             }))
  3226.         }, e.noarg("analysis")) : null
  3227.     }
  3228.  
  3229.     function Zt(e, t, o, n, s, r) {
  3230.         const i = () => !t || t(e.data);
  3231.         return p("button.fbt." + s, {
  3232.             attrs: {
  3233.                 disabled: !i(),
  3234.                 title: e.noarg(n)
  3235.             },
  3236.             hook: ue("click", (t => {
  3237.                 i() && (r ? r() : e.socket.sendLoading(s))
  3238.             }))
  3239.         }, [p("span", "offerDraw" == n ? ["½"] : e.nvui ? [e.noarg(n)] : ce(o))])
  3240.     }
  3241.  
  3242.     function Qt(e) {
  3243.         const t = e.opponentGone();
  3244.         return !0 === t ? p("div.suggestion", [p("p", {
  3245.             hook: go
  3246.         }, e.noarg("opponentLeftChoices")), p("button.button", {
  3247.             hook: ue("click", (() => e.socket.sendLoading("resign-force")))
  3248.         }, e.noarg("forceResignation")), p("button.button", {
  3249.             hook: ue("click", (() => e.socket.sendLoading("draw-force")))
  3250.         }, e.noarg("forceDraw"))]) : t ? p("div.suggestion", [p("p", e.trans.vdomPlural("opponentLeftCounter", t, p("strong", "" + t)))]) : null
  3251.     }
  3252.     const eo = (e, t) => p("button.fbt.no", {
  3253.             attrs: {
  3254.                 title: e.noarg("cancel"),
  3255.                 "data-icon": "L"
  3256.             },
  3257.             hook: ue("click", (() => t(!1)))
  3258.         }),
  3259.         to = e => p("div.act-confirm", [p("button.fbt.yes", {
  3260.             attrs: {
  3261.                 title: e.noarg("resign"),
  3262.                 "data-icon": "b"
  3263.             },
  3264.             hook: ue("click", (() => e.resign(!0)))
  3265.         }), eo(e, e.resign)]),
  3266.         oo = e => p("div.act-confirm", [p("button.fbt.yes.draw-yes", {
  3267.             attrs: {
  3268.                 title: e.noarg("offerDraw")
  3269.             },
  3270.             hook: ue("click", (() => e.offerDraw(!0)))
  3271.         }, p("span", "½")), eo(e, e.offerDraw)]);
  3272.  
  3273.     function no(e) {
  3274.         return e.data.game.threefold ? p("div.suggestion", [p("p", {
  3275.             hook: go
  3276.         }, e.noarg("threefoldRepetition")), p("button.button", {
  3277.             hook: ue("click", (() => e.socket.sendLoading("draw-claim")))
  3278.         }, e.noarg("claimADraw"))]) : null
  3279.     }
  3280.  
  3281.     function so(e) {
  3282.         return e.data.player.offeringDraw ? p("div.pending", [p("p", e.noarg("drawOfferSent"))]) : null
  3283.     }
  3284.  
  3285.     function ro(e) {
  3286.         return e.data.opponent.offeringDraw ? p("div.negotiation.draw", [co(e, (() => e.socket.sendLoading("draw-no"))), p("p", e.noarg("yourOpponentOffersADraw")), ao(e, "draw-yes", (() => e.socket.sendLoading("draw-yes")))]) : null
  3287.     }
  3288.  
  3289.     function io(e) {
  3290.         return e.data.player.proposingTakeback ? p("div.pending", [p("p", e.noarg("takebackPropositionSent")), p("button.button", {
  3291.             hook: ue("click", (() => e.socket.sendLoading("takeback-no")))
  3292.         }, e.noarg("cancel"))]) : null
  3293.     }
  3294.  
  3295.     function ao(e, t, o, n = "accept") {
  3296.         const s = e.noarg(n);
  3297.         return e.nvui ? p("button." + t, {
  3298.             hook: ue("click", o)
  3299.         }, s) : p("a.accept", {
  3300.             attrs: {
  3301.                 "data-icon": "E",
  3302.                 title: s
  3303.             },
  3304.             hook: ue("click", o)
  3305.         })
  3306.     }
  3307.  
  3308.     function co(e, t, o = "decline") {
  3309.         const n = e.noarg(o);
  3310.         return e.nvui ? p("button", {
  3311.             hook: ue("click", t)
  3312.         }, n) : p("a.decline", {
  3313.             attrs: {
  3314.                 "data-icon": "L",
  3315.                 title: n
  3316.             },
  3317.             hook: ue("click", t)
  3318.         })
  3319.     }
  3320.  
  3321.     function lo(e) {
  3322.         return e.data.opponent.proposingTakeback ? p("div.negotiation.takeback", [co(e, (() => e.socket.sendLoading("takeback-no"))), p("p", e.noarg("yourOpponentProposesATakeback")), ao(e, "takeback-yes", e.takebackYes)]) : null
  3323.     }
  3324.  
  3325.     function uo(e) {
  3326.         var t;
  3327.         const o = e.data;
  3328.         return (null === (t = o.tournament) || void 0 === t ? void 0 : t.running) ? p("div.follow-up", [p("a.text.fbt.strong.glowing", {
  3329.             attrs: {
  3330.                 "data-icon": "G",
  3331.                 href: "/tournament/" + o.tournament.id
  3332.             },
  3333.             hook: ue("click", e.setRedirecting)
  3334.         }, e.noarg("backToTournament")), p("form", {
  3335.             attrs: {
  3336.                 method: "post",
  3337.                 action: "/tournament/" + o.tournament.id + "/withdraw"
  3338.             }
  3339.         }, [p("button.text.fbt.weak", ce("Z"), "Pause")]), Jt(e)]) : void 0
  3340.     }
  3341.  
  3342.     function ho(e) {
  3343.         var t;
  3344.         const o = e.data;
  3345.         return (null === (t = o.swiss) || void 0 === t ? void 0 : t.running) ? p("div.follow-up", [p("a.text.fbt.strong.glowing", {
  3346.             attrs: {
  3347.                 "data-icon": "G",
  3348.                 href: "/swiss/" + o.swiss.id
  3349.             },
  3350.             hook: ue("click", e.setRedirecting)
  3351.         }, e.noarg("backToTournament")), Jt(e)]) : void 0
  3352.     }
  3353.  
  3354.     function po(e) {
  3355.         return Ue.moretimeable(e.data) ? p("a.moretime", {
  3356.             attrs: {
  3357.                 title: e.data.clock ? e.trans("giveNbSeconds", e.data.clock.moretime) : e.noarg("giveMoreTime"),
  3358.                 "data-icon": "O"
  3359.             },
  3360.             hook: ue("click", e.socket.moreTime)
  3361.         }) : null
  3362.     }
  3363.  
  3364.     function mo(e) {
  3365.         const t = e.data,
  3366.             o = !t.game.rematch && (He.finished(t) || He.aborted(t)) && !t.tournament && !t.simul && !t.swiss && !t.game.boosted,
  3367.             n = (He.finished(t) || He.aborted(t)) && ("lobby" === t.game.source || "pool" === t.game.source),
  3368.             s = e.challengeRematched ? [p("div.suggestion.text", {
  3369.                 hook: go
  3370.             }, e.noarg("rematchOfferSent"))] : o || t.game.rematch ? function(e) {
  3371.                 const t = e.data,
  3372.                     o = !!t.player.offeringRematch,
  3373.                     n = !!t.opponent.offeringRematch,
  3374.                     s = e.noarg;
  3375.                 return [n ? p("button.rematch-decline", {
  3376.                     attrs: {
  3377.                         "data-icon": "L",
  3378.                         title: s("decline")
  3379.                     },
  3380.                     hook: ue("click", (() => e.socket.send("rematch-no")))
  3381.                 }, e.nvui ? s("decline") : "") : null, p("button.fbt.rematch.white", {
  3382.                     class: {
  3383.                         me: o, glowing: n, disabled: !o && !(t.opponent.onGame || !t.clock && t.player.user && t.opponent.user)
  3384.                     },
  3385.                     attrs: {
  3386.                         title: n ? s("yourOpponentWantsToPlayANewGameWithYou") : o ? s("rematchOfferSent") : ""
  3387.                     },
  3388.                     hook: ue("click", (t => {
  3389.                         const o = e.data;
  3390.                         o.game.rematch ? location.href = Xt.game(o.game.rematch, o.opponent.color) : o.player.offeringRematch ? (o.player.offeringRematch = !1, e.socket.send("rematch-no")) : o.opponent.onGame ? (o.player.offeringRematch = !0, e.socket.send("rematch-yes")) : t.currentTarget.classList.contains("disabled") || e.challengeRematch()
  3391.                     }), e.redraw)
  3392.                 }, [o ? p("div.spinner", {
  3393.                     "aria-label": "loading"
  3394.                 }, [p("svg", {
  3395.                     attrs: {
  3396.                         viewBox: "0 0 40 40"
  3397.                     }
  3398.                 }, [p("circle", {
  3399.                     attrs: {
  3400.                         cx: 20,
  3401.                         cy: 20,
  3402.                         r: 18,
  3403.                         fill: "none"
  3404.                     }
  3405.                 })])]) : p("span", s("rematch"))])]
  3406.             }(e) : [];
  3407.         return p("div.follow-up", [...s, t.tournament ? p("a.fbt", {
  3408.             attrs: {
  3409.                 href: "/tournament/" + t.tournament.id
  3410.             }
  3411.         }, e.noarg("viewTournament")) : null, t.swiss ? p("a.fbt", {
  3412.             attrs: {
  3413.                 href: "/swiss/" + t.swiss.id
  3414.             }
  3415.         }, e.noarg("viewTournament")) : null, n ? p("a.fbt", {
  3416.             attrs: {
  3417.                 href: "pool" === t.game.source ? (r = t.clock, i = t.opponent.user, "/#pool/" + r.initial / 60 + "+" + r.increment + (i ? "/" + i.id : "")) : "/?hook_like=" + t.game.id
  3418.             }
  3419.         }, e.noarg("newOpponent")) : null, Jt(e)]);
  3420.         var r, i
  3421.     }
  3422.  
  3423.     function fo(e) {
  3424.         const t = e.data,
  3425.             o = [t.game.rematch ? p("a.fbt.text", {
  3426.                 attrs: {
  3427.                     href: `/${t.game.rematch}/${t.opponent.color}`
  3428.                 }
  3429.             }, e.noarg("viewRematch")) : null, t.tournament ? p("a.fbt", {
  3430.                 attrs: {
  3431.                     href: "/tournament/" + t.tournament.id
  3432.                 }
  3433.             }, e.noarg("viewTournament")) : null, t.swiss ? p("a.fbt", {
  3434.                 attrs: {
  3435.                     href: "/swiss/" + t.swiss.id
  3436.                 }
  3437.             }, e.noarg("viewTournament")) : null, Jt(e)];
  3438.         return o.find((e => !!e)) ? p("div.follow-up", o) : null
  3439.     }
  3440.     const go = de((e => lichess.pubsub.emit("round.suggestion", e.textContent)));
  3441.     const vo = e => (e < 10 ? "0" : "") + e,
  3442.         bo = "<sep>:</sep>";
  3443.  
  3444.     function yo(e, t, o, n) {
  3445.         const s = new Date(e);
  3446.         if (n) return (e >= 36e5 ? Math.floor(e / 36e5) + "H:" : "") + s.getUTCMinutes() + "M:" + s.getUTCSeconds() + "S";
  3447.         const r = s.getUTCMilliseconds(),
  3448.             i = o && r < 500 ? '<sep class="low">:</sep>' : bo,
  3449.             a = vo(s.getUTCMinutes()) + i + vo(s.getUTCSeconds());
  3450.         if (e >= 36e5) {
  3451.             return vo(Math.floor(e / 36e5)) + bo + a
  3452.         }
  3453.         if (t) {
  3454.             let t = Math.floor(r / 100).toString();
  3455.             return !o && e < 1e3 && (t += "<huns>" + Math.floor(r / 10) % 10 + "</huns>"), a + "<tenths><sep>.</sep>" + t + "</tenths>"
  3456.         }
  3457.         return a
  3458.     }
  3459.  
  3460.     function wo(e, t) {
  3461.         const o = e.clock,
  3462.             n = e => {
  3463.                 if (void 0 !== e.animate) {
  3464.                     let n = o.elements[t].barAnim;
  3465.                     void 0 !== n && n.effect && n.effect.target === e || (n = e.animate([{
  3466.                         transform: "scale(1)"
  3467.                     }, {
  3468.                         transform: "scale(0, 1)"
  3469.                     }], {
  3470.                         duration: o.barTime,
  3471.                         fill: "both"
  3472.                     }), o.elements[t].barAnim = n);
  3473.                     const s = o.millisOf(t);
  3474.                     n.currentTime = o.barTime - s, t === o.times.activeColor ? s > 0 && n.play() : n.pause()
  3475.                 } else o.elements[t].bar = e, e.style.transform = "scale(" + o.timeRatio(o.millisOf(t)) + ",1)"
  3476.             };
  3477.         return p("div.bar", {
  3478.             class: {
  3479.                 berserk: !!e.goneBerserk[t]
  3480.             },
  3481.             hook: {
  3482.                 insert: e => n(e.elm),
  3483.                 postpatch: (e, t) => n(t.elm)
  3484.             }
  3485.         })
  3486.     }
  3487.  
  3488.     function ko(e, t) {
  3489.         return !!e.goneBerserk[t] && e.data.game.turns <= 1 && Ue.playable(e.data)
  3490.     }
  3491.  
  3492.     function Po(e, t, o) {
  3493.         return ko(e, t) ? p("div.berserked." + o, ce("`")) : null
  3494.     }
  3495.  
  3496.     function Mo(e) {
  3497.         if (Ue.berserkableBy(e.data) && !e.goneBerserk[e.data.player.color]) return p("button.fbt.go-berserk", {
  3498.             attrs: {
  3499.                 title: "GO BERSERK! Half the time, no increment, bonus point",
  3500.                 "data-icon": "`"
  3501.             },
  3502.             hook: ue("click", e.goBerserk)
  3503.         })
  3504.     }
  3505.  
  3506.     function Co(e, t, o) {
  3507.         var n, s;
  3508.         const r = e.data,
  3509.             i = (null === (n = r.tournament) || void 0 === n ? void 0 : n.ranks) || (null === (s = r.swiss) || void 0 === s ? void 0 : s.ranks);
  3510.         return i && !ko(e, t) ? p("div.tour-rank." + o, {
  3511.             attrs: {
  3512.                 title: "Current tournament rank"
  3513.             }
  3514.         }, "#" + i[t]) : null
  3515.     }
  3516.     class To {
  3517.         constructor(e, t) {
  3518.             this.opts = t, this.emergSound = {
  3519.                 play: () => lichess.sound.play("lowTime"),
  3520.                 delay: 2e4,
  3521.                 playable: {
  3522.                     white: !0,
  3523.                     black: !0
  3524.                 }
  3525.             }, this.elements = {
  3526.                 white: {},
  3527.                 black: {}
  3528.             }, this.timeRatio = e => Math.min(1, e * this.timeRatioDivisor), this.setClock = (e, t, o, n = 0) => {
  3529.                 const s = Ue.playable(e) && (Ue.playedTurns(e) > 1 || e.clock.running),
  3530.                     r = 10 * n;
  3531.                 this.times = {
  3532.                     white: 1e3 * t,
  3533.                     black: 1e3 * o,
  3534.                     activeColor: s ? e.game.player : void 0,
  3535.                     lastUpdate: performance.now() + r
  3536.                 }, s && this.scheduleTick(this.times[e.game.player], r)
  3537.             }, this.addTime = (e, t) => {
  3538.                 this.times[e] += 10 * t
  3539.             }, this.stopClock = () => {
  3540.                 const e = this.times.activeColor;
  3541.                 if (e) {
  3542.                     const t = this.elapsed();
  3543.                     return this.times[e] = Math.max(0, this.times[e] - t), this.times.activeColor = void 0, t
  3544.                 }
  3545.             }, this.hardStopClock = () => this.times.activeColor = void 0, this.scheduleTick = (e, t) => {
  3546.                 void 0 !== this.tickCallback && clearTimeout(this.tickCallback), this.tickCallback = setTimeout(this.tick, this.opts.nvui ? 1e3 : e % (this.showTenths(e) ? 100 : 500) + 1 + t)
  3547.             }, this.tick = () => {
  3548.                 this.tickCallback = void 0;
  3549.                 const e = this.times.activeColor;
  3550.                 if (void 0 === e) return;
  3551.                 const t = performance.now(),
  3552.                     o = Math.max(0, this.times[e] - this.elapsed(t));
  3553.                 this.scheduleTick(o, 0), 0 === o ? this.opts.onFlag() : function(e, t, o) {
  3554.                     if (t.time && (t.time.innerHTML = yo(o, e.showTenths(o), !0, e.opts.nvui)), t.bar && (t.bar.style.transform = "scale(" + e.timeRatio(o) + ",1)"), t.clock) {
  3555.                         const n = t.clock.classList;
  3556.                         o < e.emergMs ? n.add("emerg") : n.contains("emerg") && n.remove("emerg")
  3557.                     }
  3558.                 }(this, this.elements[e], o), this.opts.soundColor === e && (this.emergSound.playable[e] ? o < this.emergMs && !(t < this.emergSound.next) && (this.emergSound.play(), this.emergSound.next = t + this.emergSound.delay, this.emergSound.playable[e] = !1) : o > 1.5 * this.emergMs && (this.emergSound.playable[e] = !0))
  3559.             }, this.elapsed = (e = performance.now()) => Math.max(0, e - this.times.lastUpdate), this.millisOf = e => this.times.activeColor === e ? Math.max(0, this.times[e] - this.elapsed()) : this.times[e], this.isRunning = () => void 0 !== this.times.activeColor;
  3560.             const o = e.clock;
  3561.             if (0 === o.showTenths) this.showTenths = () => !1;
  3562.             else {
  3563.                 const e = 1 === o.showTenths ? 1e4 : 36e5;
  3564.                 this.showTenths = t => t < e
  3565.             }
  3566.             this.showBar = o.showBar && !this.opts.nvui, this.barTime = 1e3 * (Math.max(o.initial, 2) + 5 * o.increment), this.timeRatioDivisor = 1 / this.barTime, this.emergMs = 1e3 * Math.min(60, Math.max(10, .125 * o.initial)), this.setClock(e, o.white, o.black)
  3567.         }
  3568.     }
  3569.     class xo {
  3570.         constructor(e, t) {
  3571.             this.ctrl = e, this.key = t, this.storage = lichess.storage.makeBoolean(this.key), this.toggle = () => {
  3572.                 this.storage.toggle(), this.next(!0)
  3573.             }, this.get = this.storage.get, this.redirect = e => {
  3574.                 this.ctrl.setRedirecting(), window.location.href = e
  3575.             }, this.next = e => {
  3576.                 const t = this.ctrl.data;
  3577.                 !t.player.spectator && Ue.isSwitchable(t) && !Ue.isPlayerTurn(t) && this.get() && (e ? this.redirect("/round-next/" + t.game.id) : t.simul ? t.simul.hostId === this.ctrl.opts.userId && t.simul.nbPlaying > 1 && this.redirect("/round-next/" + t.game.id) : (e => se.json(`/whats-next/${e.data.game.id}${e.data.player.id}`))(this.ctrl).then((e => {
  3578.                     e.next && this.redirect("/" + e.next)
  3579.                 })))
  3580.             }
  3581.         }
  3582.     }
  3583.     class So {
  3584.         constructor(e) {
  3585.             this.socket = e, this.current = void 0, this.register = () => {
  3586.                 this.current = setTimeout(this.expire, 1e4)
  3587.             }, this.clear = () => {
  3588.                 this.current && clearTimeout(this.current)
  3589.             }, this.expire = () => {
  3590.                 se.text("/statlog?e=roundTransientExpire", {
  3591.                     method: "post"
  3592.                 }), this.socket.reload({})
  3593.             }
  3594.         }
  3595.     }
  3596.  
  3597.     function Oo(e, t) {
  3598.         const o = [],
  3599.             n = new Map,
  3600.             s = ie.key2pos(t),
  3601.             r = Math.max(0, s[0] - 1),
  3602.             i = Math.min(7, s[0] + 1),
  3603.             a = Math.max(0, s[1] - 1),
  3604.             c = Math.min(7, s[1] + 1);
  3605.         for (let s = r; s <= i; s++)
  3606.             for (let r = a; r <= c; r++) {
  3607.                 const i = ie.pos2key([s, r]);
  3608.                 o.push(i);
  3609.                 const a = e.chessground.state.pieces.get(i);
  3610.                 a && (i === t || "pawn" !== a.role) && n.set(i, void 0)
  3611.             }
  3612.         e.chessground.setPieces(n), e.chessground.explode(o)
  3613.     }
  3614.     const _o = ["pawn", "knight", "bishop", "rook", "queen"];
  3615.     let Ao = !1,
  3616.         jo = !1,
  3617.         Lo = !1;
  3618.  
  3619.     function Do(e, t, o) {
  3620.         if (0 === Eo.length ? jo = !0 : (Ao = !0, Lo || No(e)), !Ue.isPlayerTurn(e)) return !1;
  3621.         if ("pawn" === t && ("1" === o[1] || "8" === o[1])) return !1;
  3622.         const n = e.possibleDrops;
  3623.         if (null == n) return !0;
  3624.         return (n.match(/.{2}/g) || []).includes(o)
  3625.     }
  3626.     const Eo = [];
  3627.  
  3628.     function No(e) {
  3629.         const t = e.player.color[0];
  3630.         for (const e of "PNBRQ") fetch(lichess.assetUrl(`piece/cburnett/${t}${e}.svg`));
  3631.         Lo = !0
  3632.     }
  3633.     const $o = {
  3634.         P: "pawn",
  3635.         N: "knight",
  3636.         B: "bishop",
  3637.         R: "rook",
  3638.         Q: "queen",
  3639.         K: "king"
  3640.     };
  3641.  
  3642.     function Ro(e) {
  3643.         return p("div.keyboard-move", [p("input", {
  3644.             attrs: {
  3645.                 spellcheck: !1,
  3646.                 autocomplete: !1
  3647.             },
  3648.             hook: de((t => lichess.loadModule("round.keyboardMove").then((() => e.registerHandler(lichess.keyboardMove({
  3649.                 input: t,
  3650.                 ctrl: e
  3651.             }))))))
  3652.         }), e.hasFocus() ? p("em", "Enter SAN (Nc3) or UCI (b1c3) moves, or type / to focus chat") : p("strong", "Press <enter> to focus")])
  3653.     }
  3654.  
  3655.     function Bo(e, t) {
  3656.         return e.trans("aiNameLevelAiLevel", "Stockfish", t)
  3657.     }
  3658.  
  3659.     function Io(e, t) {
  3660.         return t.user ? (t.user.title ? t.user.title + " " : "") + t.user.username : t.ai ? Bo(e, t.ai) : e.noarg("anonymous")
  3661.     }
  3662.     let qo = !1;
  3663.  
  3664.     function Fo(e) {
  3665.         return e.split(" ")[0]
  3666.     }
  3667.     const Go = e => e.userJump(e.ply - 1),
  3668.         zo = e => e.userJump(e.ply + 1);
  3669.     class Ko {
  3670.         constructor(e, t) {
  3671.             var o;
  3672.             this.opts = e, this.redraw = t, this.firstSeconds = !0, this.flip = !1, this.loading = !1, this.redirecting = !1, this.goneBerserk = {}, this.resignConfirm = void 0, this.drawConfirm = void 0, this.autoScroll = () => {}, this.challengeRematched = !1, this.shouldSendMoveTime = !1, this.sign = Math.random().toString(36), this.showExpiration = () => {
  3673.                 this.data.expiration && (this.redraw(), setTimeout(this.showExpiration, 250))
  3674.             }, this.onUserMove = (e, t, o) => {
  3675.                 this.keyboardMove && this.keyboardMove.usedSan || Be(this, o), $t(this, e, t, o) || this.sendMove(e, t, void 0, o)
  3676.             }, this.onUserNewPiece = (e, t, o) => {
  3677.                 !this.replaying() && Do(this.data, e, t) ? this.sendNewPiece(e, t, !!o.predrop) : this.jump(this.ply)
  3678.             }, this.onMove = (e, t, o) => {
  3679.                 o ? "atomic" === this.data.game.variant.key ? (Tt(), Oo(this, t)) : Mt() : Pt()
  3680.             }, this.onPremove = (e, t, o) => {
  3681.                 $t(this, e, t, o)
  3682.             }, this.onCancelPremove = () => {
  3683.                 Bt(this)
  3684.             }, this.onPredrop = (e, t) => {
  3685.                 this.preDrop = e, this.redraw()
  3686.             }, this.isSimulHost = () => this.data.simul && this.data.simul.hostId === this.opts.userId, this.lastPly = () => Fe(this.data), this.makeCgHooks = () => ({
  3687.                 onUserMove: this.onUserMove,
  3688.                 onUserNewPiece: this.onUserNewPiece,
  3689.                 onMove: this.onMove,
  3690.                 onNewPiece: Pt,
  3691.                 onPremove: this.onPremove,
  3692.                 onCancelPremove: this.onCancelPremove,
  3693.                 onPredrop: this.onPredrop
  3694.             }), this.replaying = () => this.ply !== this.lastPly(), this.userJump = e => {
  3695.                 this.cancelMove(), this.chessground.selectSquare(null), e != this.ply && this.jump(e) ? ((e, t) => {
  3696.                     Yt((o => o.step(e.stepAt(t), !0)))
  3697.                 })(this, this.ply) : this.redraw()
  3698.             }, this.isPlaying = () => Ue.isPlayerPlaying(this.data), this.jump = e => {
  3699.                 const t = (e = Math.max(qe(this.data), Math.min(this.lastPly(), e))) === this.ply + 1;
  3700.                 this.ply = e, this.justDropped = void 0, this.preDrop = void 0;
  3701.                 const o = this.stepAt(e),
  3702.                     n = {
  3703.                         fen: o.fen,
  3704.                         lastMove: le(o.uci),
  3705.                         check: !!o.check,
  3706.                         turnColor: this.ply % 2 == 0 ? "white" : "black"
  3707.                     };
  3708.                 return this.replaying() ? this.chessground.stop() : n.movable = {
  3709.                     color: this.isPlaying() ? this.data.player.color : void 0,
  3710.                     dests: he(this.data.possibleMoves)
  3711.                 }, this.chessground.set(n), o.san && t && (o.san.includes("x") ? Mt() : Pt(), /[+#]/.test(o.san) && Ct()), this.autoScroll(), this.keyboardMove && this.keyboardMove.update(o), lichess.pubsub.emit("ply", e), !0
  3712.             }, this.replayEnabledByPref = () => {
  3713.                 const e = this.data;
  3714.                 return 2 === e.pref.replay || 1 === e.pref.replay && ("classical" === e.game.speed || "unlimited" === e.game.speed || "correspondence" === e.game.speed)
  3715.             }, this.isLate = () => this.replaying() && He.playing(this.data), this.playerAt = e => this.flip ^ "top" === e ? this.data.opponent : this.data.player, this.flipNow = () => {
  3716.                 this.flip = !this.nvui && !this.flip, this.chessground.set({
  3717.                     orientation: mt(this.data, this.flip)
  3718.                 }), this.redraw()
  3719.             }, this.setTitle = () => Et(this), this.actualSendMove = (e, t, o = {}) => {
  3720.                 const n = {
  3721.                     sign: this.sign,
  3722.                     ackable: !0
  3723.                 };
  3724.                 if (this.clock)
  3725.                     if (n.withLag = !this.shouldSendMoveTime || !this.clock.isRunning(), o.premove && this.shouldSendMoveTime) this.clock.hardStopClock(), n.millis = 0;
  3726.                     else {
  3727.                         const e = this.clock.stopClock();
  3728.                         void 0 !== e && this.shouldSendMoveTime && (n.millis = e)
  3729.                     } this.socket.send(e, t, n), this.justDropped = o.justDropped, this.justCaptured = o.justCaptured, this.preDrop = void 0, this.transientMove.register(), this.redraw()
  3730.             }, this.sendMove = (e, t, o, n) => {
  3731.                 const s = {
  3732.                     u: e + t
  3733.                 };
  3734.                 o && (s.u += "knight" === o ? "n" : o[0]), Ht() && (s.b = 1), this.resign(!1), this.data.pref.submitMove && !n.premove ? (this.moveToSubmit = s, this.redraw()) : this.actualSendMove("move", s, {
  3735.                     justCaptured: n.captured,
  3736.                     premove: n.premove
  3737.                 })
  3738.             }, this.sendNewPiece = (e, t, o) => {
  3739.                 const n = {
  3740.                     role: e,
  3741.                     pos: t
  3742.                 };
  3743.                 Ht() && (n.b = 1), this.resign(!1), this.data.pref.submitMove && !o ? (this.dropToSubmit = n, this.redraw()) : this.actualSendMove("drop", n, {
  3744.                     justDropped: e,
  3745.                     premove: o
  3746.                 })
  3747.             }, this.showYourMoveNotification = () => {
  3748.                 const e = this.data;
  3749.                 Ue.isPlayerTurn(e) ? gt((() => {
  3750.                     let t = this.noarg("yourTurn");
  3751.                     const o = Io(this, e.opponent);
  3752.                     if (this.ply < 1) t = `${o}\njoined the game.\n${t}`;
  3753.                     else {
  3754.                         let n = e.steps[e.steps.length - 1].san;
  3755.                         n = `${Math.floor((this.ply-1)/2)+1}${this.ply%2==1?".":"..."} ${n}`, t = `${o}\nplayed ${n}.\n${t}`
  3756.                     }
  3757.                     return t
  3758.                 })) : this.isPlaying() && this.ply < 1 && gt((() => Io(this, e.opponent) + "\njoined the game."))
  3759.             }, this.playerByColor = e => this.data[e === this.data.player.color ? "player" : "opponent"], this.apiMove = e => {
  3760.                 var t, o;
  3761.                 const n = this.data,
  3762.                     s = this.isPlaying();
  3763.                 n.game.turns = e.ply, n.game.player = e.ply % 2 == 0 ? "white" : "black";
  3764.                 const r = e.ply % 2 == 0 ? "black" : "white",
  3765.                     i = n.player.color === n.game.player;
  3766.                 if (e.status && (n.game.status = e.status), e.winner && (n.game.winner = e.winner), this.playerByColor("white").offeringDraw = e.wDraw, this.playerByColor("black").offeringDraw = e.bDraw, n.possibleMoves = i ? e.dests : void 0, n.possibleDrops = i ? e.drops : void 0, n.crazyhouse = e.crazyhouse, this.setTitle(), !this.replaying()) {
  3767.                     if (this.ply++, e.role) this.chessground.newPiece({
  3768.                         role: e.role,
  3769.                         color: r
  3770.                     }, e.uci.substr(2, 2));
  3771.                     else {
  3772.                         const n = le(e.uci),
  3773.                             s = this.chessground.state.pieces;
  3774.                         (!e.castle || "king" === (null === (t = s.get(e.castle.king[0])) || void 0 === t ? void 0 : t.role) && "rook" === (null === (o = s.get(e.castle.rook[0])) || void 0 === o ? void 0 : o.role)) && this.chessground.move(n[0], n[1])
  3775.                     }
  3776.                     if (e.enpassant) {
  3777.                         const t = e.enpassant;
  3778.                         this.chessground.setPieces(new Map([
  3779.                             [t.key, void 0]
  3780.                         ])), "atomic" === n.game.variant.key ? (! function(e, t, o) {
  3781.                             const n = ie.key2pos(t),
  3782.                                 s = [n[0], n[1] + ("white" === o ? -1 : 1)];
  3783.                             Oo(e, ie.pos2key(s))
  3784.                         }(this, t.key, t.color), Tt()) : Mt()
  3785.                     }
  3786.                     e.promotion && pt(this.chessground, e.promotion.key, e.promotion.pieceClass), this.chessground.set({
  3787.                         turnColor: n.game.player,
  3788.                         movable: {
  3789.                             dests: s ? he(n.possibleMoves) : new Map
  3790.                         },
  3791.                         check: !!e.check
  3792.                     }), e.check && Ct(), Kt = Date.now() + 1e3, lichess.pubsub.emit("ply", this.ply)
  3793.                 }
  3794.                 n.game.threefold = !!e.threefold;
  3795.                 const a = {
  3796.                     ply: this.lastPly() + 1,
  3797.                     fen: e.fen,
  3798.                     san: e.san,
  3799.                     uci: e.uci,
  3800.                     check: e.check,
  3801.                     crazy: e.crazyhouse
  3802.                 };
  3803.                 if (n.steps.push(a), this.justDropped = void 0, this.justCaptured = void 0, Ue.setOnGame(n, r, !0), this.data.forecastCount = void 0, e.clock) {
  3804.                     this.shouldSendMoveTime = !0;
  3805.                     const t = e.clock,
  3806.                         o = s && i ? 0 : t.lag || 1;
  3807.                     this.clock ? this.clock.setClock(n, t.white, t.black, o) : this.corresClock && this.corresClock.update(t.white, t.black)
  3808.                 }
  3809.                 if (this.data.expiration && (this.data.steps.length > 2 ? this.data.expiration = void 0 : this.data.expiration.movedAt = Date.now()), this.redraw(), s && r == n.player.color && (this.transientMove.clear(), this.moveOn.next(), function(e, t) {
  3810.                         e.opponent.ai && lichess.storage.fire("ceval.fen", t.fen)
  3811.                     }(n, e)), !this.replaying() && r != n.player.color) {
  3812.                     const e = "atomic" === n.game.variant.key ? 100 : 1;
  3813.                     setTimeout((() => {
  3814.                         this.chessground.playPremove() || this.playPredrop() || (It(this), this.showYourMoveNotification())
  3815.                     }), e)
  3816.                 }
  3817.                 return this.autoScroll(), this.onChange(), this.keyboardMove && this.keyboardMove.update(a, r != n.player.color), this.music && this.music.jump(e), (e => {
  3818.                     Yt((t => t.step(e, !1)))
  3819.                 })(a), !0
  3820.             }, this.playPredrop = () => this.chessground.playPredrop((e => Do(this.data, e.role, e.key))), this.reload = e => {
  3821.                 e.steps.length !== this.data.steps.length && (this.ply = e.steps[e.steps.length - 1].ply), Ke(e), this.data = e, this.clearJust(), this.shouldSendMoveTime = !1, this.clock && this.clock.setClock(e, e.clock.white, e.clock.black), this.corresClock && this.corresClock.update(e.correspondence.white, e.correspondence.black), this.replaying() || function(e) {
  3822.                     e.chessground.set(ht(e))
  3823.                 }(this), this.setTitle(), this.moveOn.next(), this.setQuietMode(), this.redraw(), this.autoScroll(), this.onChange(), this.setLoading(!1), this.keyboardMove && this.keyboardMove.update(e.steps[e.steps.length - 1])
  3824.             }, this.endWithData = e => {
  3825.                 var t, o;
  3826.                 const n = this.data;
  3827.                 if (n.game.winner = e.winner, n.game.status = e.status, n.game.boosted = e.boosted, this.userJump(this.lastPly()), this.chessground.stop(), e.ratingDiff && (n.player.ratingDiff = e.ratingDiff[n.player.color], n.opponent.ratingDiff = e.ratingDiff[n.opponent.color]), !n.player.spectator && n.game.turns > 1) {
  3828.                     const s = e.winner ? n.player.color === e.winner ? "victory" : "defeat" : "draw";
  3829.                     lichess.sound.play(s), "victory" != s && n.game.turns > 6 && !n.tournament && !n.swiss && "1" == lichess.storage.get("courtesy") && (null === (o = null === (t = this.opts.chat) || void 0 === t ? void 0 : t.instance) || void 0 === o || o.then((e => e.post("Good game, well played"))))
  3830.                 }
  3831.                 n.crazyhouse && function() {
  3832.                     const e = lichess.storage.make("crazyKeyHist");
  3833.                     if (Ao) e.set(10);
  3834.                     else if (jo) {
  3835.                         const t = parseInt(e.get());
  3836.                         t > 0 && t <= 10 ? e.set(t - 1) : 0 !== t && e.set(3)
  3837.                     }
  3838.                 }(), this.clearJust(), this.setTitle(), this.moveOn.next(), this.setQuietMode(), this.setLoading(!1), this.clock && e.clock && this.clock.setClock(n, .01 * e.clock.wc, .01 * e.clock.bc), this.redraw(), this.autoScroll(), this.onChange(), n.tv && setTimeout(lichess.reload, 1e4), Wt(this)
  3839.             }, this.challengeRematch = () => {
  3840.                 var e;
  3841.                 this.challengeRematched = !0, (e = this.data.game.id, se.json("/challenge/rematch-of/" + e, {
  3842.                     method: "post"
  3843.                 })).then((() => {
  3844.                     lichess.pubsub.emit("challenge-app.open"), lichess.once("rematch-challenge") && setTimeout((() => {
  3845.                         lichess.hopscotch((function() {
  3846.                             window.hopscotch.configure({
  3847.                                 i18n: {
  3848.                                     doneBtn: "OK, got it"
  3849.                                 }
  3850.                             }).startTour({
  3851.                                 id: "rematch-challenge",
  3852.                                 showPrevButton: !0,
  3853.                                 steps: [{
  3854.                                     title: "Challenged to a rematch",
  3855.                                     content: "Your opponent is offline, but they can accept this challenge later!",
  3856.                                     target: "#challenge-app",
  3857.                                     placement: "bottom"
  3858.                                 }]
  3859.                             })
  3860.                         }))
  3861.                     }), 1e3)
  3862.                 }), (e => {
  3863.                     this.challengeRematched = !1
  3864.                 }))
  3865.             }, this.makeCorrespondenceClock = () => {
  3866.                 this.data.correspondence && !this.corresClock && (this.corresClock = function(e, t, o) {
  3867.                     const n = .1 / t.increment;
  3868.                     let s;
  3869.  
  3870.                     function r(e, t) {
  3871.                         s = {
  3872.                             white: 1e3 * e,
  3873.                             black: 1e3 * t,
  3874.                             lastUpdate: performance.now()
  3875.                         }
  3876.                     }
  3877.                     return r(t.white, t.black), {
  3878.                         root: e,
  3879.                         data: t,
  3880.                         timePercent: e => Math.max(0, Math.min(100, s[e] * n)),
  3881.                         millisOf: e => Math.max(0, s[e]),
  3882.                         update: r,
  3883.                         tick: function(e) {
  3884.                             const t = performance.now();
  3885.                             s[e] -= t - s.lastUpdate, s.lastUpdate = t, s[e] <= 0 && o()
  3886.                         }
  3887.                     }
  3888.                 }(this, this.data.correspondence, this.socket.outoftime))
  3889.             }, this.corresClockTick = () => {
  3890.                 this.corresClock && Ue.playable(this.data) && this.corresClock.tick(this.data.game.player)
  3891.             }, this.setQuietMode = () => {
  3892.                 const e = lichess.quietMode,
  3893.                     t = this.isPlaying();
  3894.                 e !== t && (lichess.quietMode = t, $("body").toggleClass("playing", t).toggleClass("no-select", t && this.clock && this.clock.millisOf(this.data.player.color) <= 3e5))
  3895.             }, this.takebackYes = () => {
  3896.                 this.socket.sendLoading("takeback-yes"), this.chessground.cancelPremove(), It(this)
  3897.             }, this.resign = (e, t) => {
  3898.                 e ? (this.resignConfirm || !this.data.pref.confirmResign || t ? (this.socket.sendLoading("resign"), clearTimeout(this.resignConfirm)) : this.resignConfirm = setTimeout((() => this.resign(!1)), 3e3), this.redraw()) : this.resignConfirm && (clearTimeout(this.resignConfirm), this.resignConfirm = void 0, this.redraw())
  3899.             }, this.goBerserk = () => {
  3900.                 this.socket.berserk(), lichess.sound.play("berserk")
  3901.             }, this.setBerserk = e => {
  3902.                 this.goneBerserk[e] || (this.goneBerserk[e] = !0, e !== this.data.player.color && lichess.sound.play("berserk"), this.redraw())
  3903.             }, this.setLoading = (e, t = 1500) => {
  3904.                 clearTimeout(this.loadingTimeout), e ? (this.loading = !0, this.loadingTimeout = setTimeout((() => {
  3905.                     this.loading = !1, this.redraw()
  3906.                 }), t), this.redraw()) : this.loading && (this.loading = !1, this.redraw())
  3907.             }, this.setRedirecting = () => {
  3908.                 this.redirecting = !0, lichess.unload.expected = !0, setTimeout((() => {
  3909.                     this.redirecting = !1, this.redraw()
  3910.                 }), 2500), this.redraw()
  3911.             }, this.submitMove = e => {
  3912.                 const t = this.moveToSubmit || this.dropToSubmit;
  3913.                 e && t ? (this.moveToSubmit ? this.actualSendMove("move", this.moveToSubmit) : this.actualSendMove("drop", this.dropToSubmit), lichess.sound.play("confirmation")) : this.jump(this.ply), this.cancelMove(), t && this.setLoading(!0, 300)
  3914.             }, this.cancelMove = () => {
  3915.                 this.moveToSubmit = void 0, this.dropToSubmit = void 0
  3916.             }, this.onChange = () => {
  3917.                 this.opts.onChange && setTimeout((() => this.opts.onChange(this.data)), 150)
  3918.             }, this.setGone = e => {
  3919.                 Ue.setGone(this.data, this.data.opponent.color, e), clearTimeout(this.goneTick), Number(e) > 1 && (this.goneTick = setTimeout((() => {
  3920.                     const e = Number(this.opponentGone());
  3921.                     e > 1 && this.setGone(e - 1)
  3922.                 }), 1e3)), this.redraw()
  3923.             }, this.opponentGone = () => {
  3924.                 const e = this.data;
  3925.                 return !1 !== e.opponent.gone && !Ue.isPlayerTurn(e) && Ue.resignable(e) && e.opponent.gone
  3926.             }, this.canOfferDraw = () => Ue.drawable(this.data) && (this.lastDrawOfferAtPly || -99) < this.ply - 20, this.offerDraw = e => {
  3927.                 this.canOfferDraw() && (this.drawConfirm ? (e && this.doOfferDraw(), clearTimeout(this.drawConfirm), this.drawConfirm = void 0) : e && (this.data.pref.confirmResign ? this.drawConfirm = setTimeout((() => {
  3928.                     this.offerDraw(!1)
  3929.                 }), 3e3) : this.doOfferDraw())), this.redraw()
  3930.             }, this.doOfferDraw = () => {
  3931.                 this.lastDrawOfferAtPly = this.ply, this.socket.sendLoading("draw-yes", null)
  3932.             }, this.setChessground = e => {
  3933.                 this.chessground = e, this.data.pref.keyboardMove && (this.keyboardMove = function(e, t, o) {
  3934.                     let n, s = !1,
  3935.                         r = t.fen,
  3936.                         i = performance.now();
  3937.                     const a = e.chessground.state,
  3938.                         c = t => {
  3939.                             a.selected === t ? e.chessground.cancelMove() : (e.chessground.selectSquare(t, !0), i = performance.now())
  3940.                         };
  3941.                     let l = !1;
  3942.                     return {
  3943.                         drop(t, o) {
  3944.                             const n = $o[o],
  3945.                                 s = e.data.crazyhouse,
  3946.                                 r = e.data.player.color;
  3947.                             n && s && !a.pieces.has(t) && s.pockets["white" === r ? 0 : 1][n] && Do(e.data, n, t) && (e.chessground.cancelMove(), e.chessground.newPiece({
  3948.                                 role: n,
  3949.                                 color: r
  3950.                             }, t), e.sendNewPiece(n, t, !1))
  3951.                         },
  3952.                         promote(t, o, n) {
  3953.                             const s = $o[n];
  3954.                             s && "pawn" != s && (e.chessground.cancelMove(), Nt(e, t, o, s, {
  3955.                                 premove: !1
  3956.                             }))
  3957.                         },
  3958.                         update(e, t = !1) {
  3959.                             n ? n(e.fen, a.movable.dests, t) : r = e.fen
  3960.                         },
  3961.                         registerHandler(e) {
  3962.                             n = e, r && n(r, a.movable.dests)
  3963.                         },
  3964.                         hasFocus: () => s,
  3965.                         setFocus(e) {
  3966.                             s = e, o()
  3967.                         },
  3968.                         san(t, o) {
  3969.                             l = !0, e.chessground.cancelMove(), c(t), c(o)
  3970.                         },
  3971.                         select: c,
  3972.                         hasSelected: () => a.selected,
  3973.                         confirmMove() {
  3974.                             e.submitMove(!0)
  3975.                         },
  3976.                         usedSan: l,
  3977.                         jump(t) {
  3978.                             e.userJump(e.ply + t), o()
  3979.                         },
  3980.                         justSelected: () => performance.now() - i < 500,
  3981.                         clock: () => e.clock,
  3982.                         resign: e.resign
  3983.                     }
  3984.                 }(this, this.stepAt(this.ply), this.redraw), requestAnimationFrame((() => this.redraw())))
  3985.             }, this.stepAt = e => ze(this.data, e), this.delayedInit = () => {
  3986.                 const e = this.data;
  3987.                 this.isPlaying() && 0 === Ue.nbMoves(e, e.player.color) && !this.isSimulHost() && lichess.sound.play("genericNotify"), lichess.requestIdleCallback((() => {
  3988.                     const e = this.data;
  3989.                     this.isPlaying() && (e.simul || (e.steps.length > 2 || (Kt = Date.now() + 1e4), window.addEventListener("focus", (() => zt = Date.now()))), window.addEventListener("focus", Dt), this.setTitle(), e.crazyhouse && function(e) {
  3990.                         const t = window.Mousetrap;
  3991.                         let o;
  3992.                         const n = () => {
  3993.                             if (o && document.body.classList.remove(o), Eo.length > 0) {
  3994.                                 const t = _o[Eo[Eo.length - 1] - 1],
  3995.                                     n = e.data.player.color,
  3996.                                     s = e.data.crazyhouse;
  3997.                                 if (!s) return;
  3998.                                 const r = s.pockets["white" === n ? 0 : 1][t];
  3999.                                 it.setDropMode(e.chessground.state, r > 0 ? {
  4000.                                     color: n,
  4001.                                     role: t
  4002.                                 } : void 0), o = `cursor-${n}-${t}`, document.body.classList.add(o)
  4003.                             } else it.cancelDropMode(e.chessground.state), o = void 0
  4004.                         };
  4005.                         lichess.pubsub.on("ply", (() => {
  4006.                             Eo.length > 0 && n()
  4007.                         }));
  4008.                         for (let e = 1; e <= 5; e++) {
  4009.                             const o = e.toString();
  4010.                             t.bind(o, (() => {
  4011.                                 Eo.includes(e) || (Eo.push(e), n())
  4012.                             })).bind(o, (() => {
  4013.                                 const t = Eo.indexOf(e);
  4014.                                 t >= 0 && (Eo.splice(t, 1), t === Eo.length && n())
  4015.                             }), "keyup")
  4016.                         }
  4017.                         const s = () => {
  4018.                             Eo.length > 0 && (Eo.length = 0, n())
  4019.                         };
  4020.                         window.addEventListener("blur", s), window.addEventListener("focus", (e => {
  4021.                             e.target && "input" === e.target.localName && s()
  4022.                         }), {
  4023.                             capture: !0
  4024.                         }), "0" !== lichess.storage.get("crazyKeyHist") && No(e.data)
  4025.                     }(this), window.addEventListener("beforeunload", (e => {
  4026.                         const t = this.data;
  4027.                         if (lichess.unload.expected || this.nvui || !Ue.playable(t) || !t.clock || t.opponent.ai || this.isSimulHost()) return;
  4028.                         this.socket.send("bye2");
  4029.                         const o = "There is a game in progress!";
  4030.                         return (e || window.event).returnValue = o, o
  4031.                     })), !this.nvui && e.pref.submitMove && window.Mousetrap.bind("esc", (() => {
  4032.                         this.submitMove(!1), this.chessground.cancelMove()
  4033.                     })).bind("return", (() => this.submitMove(!0))), function(e) {
  4034.                         e.data.opponent.ai || !e.data.game.rated && e.opts.userId || e.data.player.user && "BOT" === e.data.player.user.title || (lichess.storage.fire("ceval.disable"), lichess.storage.make("ceval.fen").listen((t => {
  4035.                             const o = e.data,
  4036.                                 n = Ge(e.data);
  4037.                             !qo && n.ply > 14 && e.isPlaying() && t.value && Fo(n.fen) === Fo(t.value) && (se.text(`/jslog/${o.game.id}${o.player.id}?n=ceval`, {
  4038.                                 method: "post"
  4039.                             }), qo = !0)
  4040.                         })))
  4041.                     }(this)), this.nvui || (e => {
  4042.                         window.Mousetrap.bind(["left", "h"], (() => {
  4043.                             Go(e), e.redraw()
  4044.                         })).bind(["right", "l"], (() => {
  4045.                             zo(e), e.redraw()
  4046.                         })).bind(["up", "k"], (() => {
  4047.                             e.userJump(0), e.redraw()
  4048.                         })).bind(["down", "j"], (() => {
  4049.                             e.userJump(e.data.steps.length - 1), e.redraw()
  4050.                         })).bind("f", e.flipNow).bind("z", (() => lichess.pubsub.emit("zen")))
  4051.                     })(this), (e => {
  4052.                         lichess.pubsub.on("speech.enabled", Ut(e)), Ut(e)(lichess.sound.speech())
  4053.                     })(this), this.onChange()
  4054.                 }), 800)
  4055.             }, Ke(e.data);
  4056.             const n = this.data = e.data;
  4057.             this.ply = Fe(n), this.goneBerserk[n.player.color] = n.player.berserk, this.goneBerserk[n.opponent.color] = n.opponent.berserk, setTimeout((() => {
  4058.                 this.firstSeconds = !1, this.redraw()
  4059.             }), 3e3), this.socket = function(e, t) {
  4060.                 function o(e, s) {
  4061.                     e && e.t ? (t.setLoading(!1), n[e.t](e.d)) : yt(t).then((n => {
  4062.                         lichess.socket.getVersion() > n.player.version ? s ? lichess.reload() : o(e, !0) : t.reload(n)
  4063.                     }), lichess.reload)
  4064.                 }
  4065.                 lichess.socket.sign(t.sign);
  4066.                 const n = {
  4067.                     takebackOffers(e) {
  4068.                         t.setLoading(!1), t.data.player.proposingTakeback = e[t.data.player.color], (t.data.opponent.proposingTakeback = e[t.data.opponent.color]) && gt(t.noarg("yourOpponentProposesATakeback")), t.redraw()
  4069.                     },
  4070.                     move: t.apiMove,
  4071.                     drop: t.apiMove,
  4072.                     reload: o,
  4073.                     redirect: t.setRedirecting,
  4074.                     clockInc(e) {
  4075.                         t.clock && (t.clock.addTime(e.color, e.time), t.redraw())
  4076.                     },
  4077.                     cclock(e) {
  4078.                         t.corresClock && (t.data.correspondence.white = e.white, t.data.correspondence.black = e.black, t.corresClock.update(e.white, e.black), t.redraw())
  4079.                     },
  4080.                     crowd(e) {
  4081.                         ["white", "black"].forEach((o => {
  4082.                             ne.defined(e[o]) && Ue.setOnGame(t.data, o, e[o])
  4083.                         })), t.redraw()
  4084.                     },
  4085.                     endData: t.endWithData,
  4086.                     rematchOffer(e) {
  4087.                         t.data.player.offeringRematch = e === t.data.player.color, (t.data.opponent.offeringRematch = e === t.data.opponent.color) && gt(t.noarg("yourOpponentWantsToPlayANewGameWithYou")), t.redraw()
  4088.                     },
  4089.                     rematchTaken(e) {
  4090.                         t.data.game.rematch = e, t.data.player.spectator ? t.redraw() : t.setLoading(!0)
  4091.                     },
  4092.                     drawOffer(e) {
  4093.                         if (t.isPlaying() && (t.data.player.offeringDraw = e === t.data.player.color, (t.data.opponent.offeringDraw = e === t.data.opponent.color) && gt(t.noarg("yourOpponentOffersADraw"))), e) {
  4094.                             let o = t.lastPly();
  4095.                             "white" == e == (o % 2 == 0) && o++, t.data.game.drawOffers = (t.data.game.drawOffers || []).concat([o])
  4096.                         }
  4097.                         t.redraw()
  4098.                     },
  4099.                     berserk(e) {
  4100.                         t.setBerserk(e)
  4101.                     },
  4102.                     gone: t.setGone,
  4103.                     goneIn: t.setGone,
  4104.                     checkCount(e) {
  4105.                         t.data.player.checks = "white" == t.data.player.color ? e.white : e.black, t.data.opponent.checks = "white" == t.data.opponent.color ? e.white : e.black, t.redraw()
  4106.                     },
  4107.                     simulPlayerMove(e) {
  4108.                         t.opts.userId && t.data.simul && t.opts.userId == t.data.simul.hostId && e !== t.data.game.id && t.moveOn.get() && !Ue.isPlayerTurn(t.data) && (t.setRedirecting(), Pt(), location.href = "/" + e)
  4109.                     },
  4110.                     simulEnd(e) {
  4111.                         lichess.loadCssPath("modal"), bt($(`<p>Simul complete!</p><br /><br /><a class="button" href="/simul/${e.id}">Back to ${e.name} simul</a>`))
  4112.                     }
  4113.                 };
  4114.                 return lichess.pubsub.on("ab.rep", (t => e("rep", {
  4115.                     n: t
  4116.                 }))), {
  4117.                     send: e,
  4118.                     handlers: n,
  4119.                     moreTime: vt(300, (() => e("moretime"))),
  4120.                     outoftime: xt(500, 1.1, (() => e("flag", t.data.game.player))),
  4121.                     berserk: vt(200, (() => e("berserk", null, {
  4122.                         ackable: !0
  4123.                     }))),
  4124.                     sendLoading(o, n) {
  4125.                         t.setLoading(!0), e(o, n)
  4126.                     },
  4127.                     receive: (e, t) => !!n[e] && (n[e](t), !0),
  4128.                     reload: o
  4129.                 }
  4130.             }(e.socketSend, this), lichess.RoundNVUI && (this.nvui = lichess.RoundNVUI(t)), n.clock ? this.clock = new To(n, {
  4131.                 onFlag: this.socket.outoftime,
  4132.                 soundColor: n.simul || n.player.spectator || !n.pref.clockSound ? void 0 : n.player.color,
  4133.                 nvui: !!this.nvui
  4134.             }) : (this.makeCorrespondenceClock(), setInterval(this.corresClockTick, 1e3)), this.setQuietMode(), this.moveOn = new xo(this, "move-on"), this.transientMove = new So(this.socket), this.trans = lichess.trans(e.i18n), this.noarg = this.trans.noarg, setTimeout(this.delayedInit, 200), setTimeout(this.showExpiration, 350), (null === (o = document.referrer) || void 0 === o ? void 0 : o.includes("/serviceWorker.")) || setTimeout(this.showYourMoveNotification, 500), lichess.pubsub.on("jump", (e => {
  4135.                 this.jump(parseInt(e)), this.redraw()
  4136.             })), lichess.pubsub.on("sound_set", (e => {
  4137.                 this.music || "music" !== e || lichess.loadScript("javascripts/music/play.js").then((() => {
  4138.                     this.music = lichess.playMusic()
  4139.                 })), this.music && "music" !== e && (this.music = void 0)
  4140.             })), lichess.pubsub.on("zen", (() => {
  4141.                 if (this.isPlaying()) {
  4142.                     const e = !$("body").hasClass("zen");
  4143.                     $("body").toggleClass("zen", e), window.dispatchEvent(new Event("resize")), wt(e)
  4144.                 }
  4145.             })), this.isPlaying() && Ie(this)
  4146.         }
  4147.         clearJust() {
  4148.             this.justDropped = void 0, this.justCaptured = void 0, this.preDrop = void 0
  4149.         }
  4150.     }
  4151.     const Ho = ["mousedown", "touchstart"];
  4152.  
  4153.     function Vo(e, t, o) {
  4154.         const n = ze(e.data, e.ply);
  4155.         if (!n.crazy) return;
  4156.         const s = e.justDropped,
  4157.             r = e.preDrop,
  4158.             i = n.crazy.pockets["white" === t ? 0 : 1],
  4159.             a = o === (e.flip ? "top" : "bottom") && !e.replaying() && e.isPlaying(),
  4160.             c = t === e.data.player.color,
  4161.             l = e.justCaptured,
  4162.             d = l && (l.promoted ? "pawn" : l.role);
  4163.         return p("div.pocket.is2d.pocket-" + o, {
  4164.             class: {
  4165.                 usable: a
  4166.             },
  4167.             hook: de((t => Ho.forEach((n => t.addEventListener(n, (t => {
  4168.                 o === (e.flip ? "top" : "bottom") && 0 == Eo.length && function(e, t) {
  4169.                     if (void 0 !== t.button && 0 !== t.button) return;
  4170.                     if (e.replaying() || !e.isPlaying()) return;
  4171.                     const o = t.target,
  4172.                         n = o.getAttribute("data-role"),
  4173.                         s = o.getAttribute("data-color"),
  4174.                         r = o.getAttribute("data-nb");
  4175.                     n && s && "0" !== r && (t.stopPropagation(), t.preventDefault(), et.dragNewPiece(e.chessground.state, {
  4176.                         color: s,
  4177.                         role: n
  4178.                     }, t))
  4179.                 }(e, t)
  4180.             }))))))
  4181.         }, _o.map((e => {
  4182.             let o = i[e] || 0;
  4183.             return c && (s === e && o--, d === e && o++), p("div.pocket-c1", p("div.pocket-c2", p("piece." + e + "." + t, {
  4184.                 class: {
  4185.                     premove: c && r === e
  4186.                 },
  4187.                 attrs: {
  4188.                     "data-role": e,
  4189.                     "data-color": t,
  4190.                     "data-nb": o
  4191.                 }
  4192.             })))
  4193.         })))
  4194.     }
  4195.     const Uo = (e, t) => (e / Math.pow(10, t)).toFixed(t).substr(2),
  4196.         Wo = e => `<b>${e}</b>`;
  4197.  
  4198.     function Yo(e, t, o, n, s) {
  4199.         const r = e.millisOf(o),
  4200.             i = e => {
  4201.                 e.innerHTML = function(e, t) {
  4202.                     const o = new Date(t),
  4203.                         n = Uo(o.getUTCMinutes(), 2),
  4204.                         s = Uo(o.getSeconds(), 2);
  4205.                     let r, i = "";
  4206.                     if (t >= 864e5) {
  4207.                         const t = o.getUTCDate() - 1;
  4208.                         r = o.getUTCHours(), i += (1 === t ? e("oneDay") : e.plural("nbDays", t)) + " ", 0 !== r && (i += e.plural("nbHours", r))
  4209.                     } else t >= 36e5 ? (r = o.getUTCHours(), i += Wo(Uo(r, 2)) + ":" + Wo(n)) : i += Wo(n) + ":" + Wo(s);
  4210.                     return i
  4211.                 }(t, r)
  4212.             },
  4213.             a = e.root.data.player.color === o;
  4214.         return p("div.rclock.rclock-correspondence.rclock-" + n, {
  4215.             class: {
  4216.                 outoftime: r <= 0, running: s === o
  4217.             }
  4218.         }, [e.data.showBar ? p("div.bar", [p("span", {
  4219.             attrs: {
  4220.                 style: `width: ${e.timePercent(o)}%`
  4221.             }
  4222.         })]) : null, p("div.time", {
  4223.             hook: {
  4224.                 insert: e => i(e.elm),
  4225.                 postpatch: (e, t) => i(t.elm)
  4226.             }
  4227.         }), a ? null : po(e.root)])
  4228.     }
  4229.     var Xo = ee(te((function(e, t) {
  4230.         Object.defineProperty(t, "__esModule", {
  4231.             value: !0
  4232.         });
  4233.         let o = "init";
  4234.         t.default = function() {
  4235.             return "string" == typeof o && ("init" == o && (window.addEventListener("resize", (() => {
  4236.                 o = "rec"
  4237.             })), navigator.userAgent.indexOf("Edge/") > -1 && requestAnimationFrame((() => {
  4238.                 o = "rec"
  4239.             }))), o = !!getComputedStyle(document.body).getPropertyValue("--col1")), o
  4240.         }
  4241.     })));
  4242.     const Jo = "u8t",
  4243.         Zo = "i5z".toUpperCase(),
  4244.         Qo = vt(100, ((e, t) => window.requestAnimationFrame((() => {
  4245.             if (t.data.steps.length < 7) return;
  4246.             let o;
  4247.             if (t.ply < 3) o = 0;
  4248.             else if (t.ply == Fe(t.data)) o = 99999;
  4249.             else {
  4250.                 const t = e.querySelector(".a1t");
  4251.                 t && (o = Xo() ? t.offsetLeft - e.offsetWidth / 2 + t.offsetWidth / 2 : t.offsetTop - e.offsetHeight / 2 + t.offsetHeight / 2)
  4252.             }
  4253.             "number" == typeof o && (99999 == o ? e.scrollLeft = e.scrollTop = o : Xo() ? e.scrollLeft = o : e.scrollTop = o)
  4254.         }))));
  4255.  
  4256.     function en(e, t, o, n) {
  4257.         return e ? p(Jo, {
  4258.             class: {
  4259.                 a1t: e.ply === t
  4260.             }
  4261.         }, ["P" === e.san[0] ? e.san.slice(1) : e.san, n.has(e.ply) ? p("draw", {
  4262.             attrs: {
  4263.                 title: "Draw offer"
  4264.             }
  4265.         }, "½?") : void 0]) : o ? p(Jo, "…") : void 0
  4266.     }
  4267.  
  4268.     function tn(e) {
  4269.         let t;
  4270.         if (He.finished(e.data)) switch (e.data.game.winner) {
  4271.             case "white":
  4272.                 t = "1-0";
  4273.                 break;
  4274.             case "black":
  4275.                 t = "0-1";
  4276.                 break;
  4277.             default:
  4278.                 t = "½-½"
  4279.         }
  4280.         if (t || He.aborted(e.data)) {
  4281.             const o = e.data.game.winner;
  4282.             return p("div.result-wrap", [p("p.result", t || ""), p("p.status", {
  4283.                 hook: de((() => {
  4284.                     e.autoScroll ? e.autoScroll() : setTimeout((() => e.autoScroll()), 200)
  4285.                 }))
  4286.             }, [Vt(e), o ? " • " + e.noarg(o + "IsVictorious") : ""])])
  4287.         }
  4288.     }
  4289.  
  4290.     function on(e) {
  4291.         const t = e.data.forecastCount;
  4292.         return Ue.userAnalysable(e.data) ? p("a.fbt.analysis", {
  4293.             class: {
  4294.                 text: !!t
  4295.             },
  4296.             attrs: {
  4297.                 title: e.noarg("analysis"),
  4298.                 href: Xt.game(e.data, e.data.player.color) + "/analysis#" + e.ply,
  4299.                 "data-icon": "A"
  4300.             }
  4301.         }, t ? ["" + t] : []) : void 0
  4302.     }
  4303.  
  4304.     function nn(e) {
  4305.         const t = e.data,
  4306.             o = qe(t),
  4307.             n = Fe(t);
  4308.         return p("div.buttons", {
  4309.             hook: ue("mousedown", (o => {
  4310.                 const n = o.target,
  4311.                     s = parseInt(n.getAttribute("data-ply") || "");
  4312.                 if (isNaN(s)) {
  4313.                     "flip" === (n.getAttribute("data-act") || n.parentNode.getAttribute("data-act")) && (t.tv ? location.href = "/tv/" + t.tv.channel + (t.tv.flip ? "" : "?flip=1") : t.player.spectator ? location.href = Xt.game(t, t.opponent.color) : e.flipNow())
  4314.                 } else e.userJump(s)
  4315.             }), e.redraw)
  4316.         }, [p("button.fbt.flip", {
  4317.             class: {
  4318.                 active: e.flip
  4319.             },
  4320.             attrs: {
  4321.                 title: e.noarg("flipBoard"),
  4322.                 "data-act": "flip",
  4323.                 "data-icon": "B"
  4324.             }
  4325.         }), ...[
  4326.             ["W", o],
  4327.             ["Y", e.ply - 1],
  4328.             ["X", e.ply + 1],
  4329.             ["V", n]
  4330.         ].map(((t, s) => {
  4331.             const r = e.ply !== t[1] && t[1] >= o && t[1] <= n;
  4332.             return p("button.fbt", {
  4333.                 class: {
  4334.                     glowing: 3 === s && e.isLate()
  4335.                 },
  4336.                 attrs: {
  4337.                     disabled: !r,
  4338.                     "data-icon": t[0],
  4339.                     "data-ply": r ? t[1] : "-"
  4340.                 }
  4341.             })
  4342.         })), on(e) || p("div.noop")])
  4343.     }
  4344.  
  4345.     function sn(e, t) {
  4346.         return Ue.playable(e) && 0 === e.game.turns && !e.player.spectator ? p("div.message", ce(""), [p("div", [t("white" === e.player.color ? "youPlayTheWhitePieces" : "youPlayTheBlackPieces"), ..."white" === e.player.color ? [p("br"), p("strong", t("itsYourTurn"))] : []])]) : null
  4347.     }
  4348.  
  4349.     function rn(e, t, o, n) {
  4350.         return n ? null : p("button.fbt", {
  4351.             attrs: {
  4352.                 disabled: n,
  4353.                 "data-icon": o,
  4354.                 "data-ply": e.ply + t
  4355.             },
  4356.             hook: ue("mousedown", (o => {
  4357.                 o.preventDefault(), e.userJump(e.ply + t), e.redraw()
  4358.             }))
  4359.         })
  4360.     }
  4361.  
  4362.     function an(e) {
  4363.         const t = e.data,
  4364.             o = e.replayEnabledByPref() && p("l4x", {
  4365.                 hook: de((t => {
  4366.                     t.addEventListener("mousedown", (t => {
  4367.                         let o = t.target,
  4368.                             n = -2;
  4369.                         if (o.tagName === Jo.toUpperCase())
  4370.                             for (; o = o.previousSibling;)
  4371.                                 if (n++, o.tagName === Zo) {
  4372.                                     e.userJump(2 * parseInt(o.textContent || "") + n), e.redraw();
  4373.                                     break
  4374.                                 }
  4375.                     })), e.autoScroll = () => Qo(t, e), e.autoScroll()
  4376.                 }))
  4377.             }, function(e) {
  4378.                 const t = e.data.steps,
  4379.                     o = qe(e.data),
  4380.                     n = Fe(e.data),
  4381.                     s = new Set(e.data.game.drawOffers || []);
  4382.                 if (void 0 === n) return [];
  4383.                 const r = [];
  4384.                 let i = 1;
  4385.                 o % 2 == 1 && (r.push([null, t[1]]), i = 2);
  4386.                 for (let e = i; e < t.length; e += 2) r.push([t[e], t[e + 1]]);
  4387.                 const a = [],
  4388.                     c = e.ply;
  4389.                 for (let e = 0; e < r.length; e++) a.push(p("i5z", e + 1 + "")), a.push(en(r[e][0], c, !0, s)), a.push(en(r[e][1], c, !1, s));
  4390.                 return a.push(tn(e)), a
  4391.             }(e));
  4392.         return e.nvui ? void 0 : p("rm6", [nn(e), sn(t, e.trans.noarg) || (o ? Xo() ? p("div.col1-moves", [rn(e, -1, "Y", e.ply == qe(t)), o, rn(e, 1, "X", e.ply == Fe(t))]) : o : tn(e))])
  4393.     }
  4394.     let cn = !1;
  4395.  
  4396.     function ln(e) {
  4397.         const t = Ue.playable(e.data) && e.data.expiration;
  4398.         if (!t) return;
  4399.         const o = Math.max(0, t.movedAt - Date.now() + t.millisToMove),
  4400.             n = Math.floor(o / 1e3),
  4401.             s = Ue.isPlayerTurn(e.data),
  4402.             r = s && o < 8e3;
  4403.         !cn && r && (lichess.sound.play("lowTime"), cn = !0);
  4404.         return p("div.expiration.expiration-" + (s != e.flip ? "bottom" : "top"), {
  4405.             class: {
  4406.                 emerg: r, "bar-glider": s
  4407.             }
  4408.         }, e.trans.vdomPlural("nbSecondsToPlayTheFirstMove", n, p("strong", "" + n)))
  4409.     }
  4410.  
  4411.     function dn(e, t) {
  4412.         const o = e.playerAt(t);
  4413.         return e.nvui ? void 0 : o.ai ? p("div.user-link.online.ruser.ruser-" + t, [p("i.line"), p("name", Bo(e, o.ai))]) : function(e, t, o) {
  4414.             const n = e.data,
  4415.                 s = t.user,
  4416.                 r = s ? s.perfs[n.game.perf] : null,
  4417.                 i = t.rating ? t.rating : r && r.rating,
  4418.                 a = t.ratingDiff,
  4419.                 c = 0 === a ? p("span", "±0") : a && a > 0 ? p("good", "+" + a) : a && a < 0 ? p("bad", "−" + -a) : void 0;
  4420.             if (s) {
  4421.                 const n = !t.onGame && e.firstSeconds && s.online;
  4422.                 return p(`div.ruser-${o}.ruser.user-link`, {
  4423.                     class: {
  4424.                         online: t.onGame, offline: !t.onGame, long: s.username.length > 16, connecting: n
  4425.                     }
  4426.                 }, [p("i.line" + (s.patron ? ".patron" : ""), {
  4427.                     attrs: {
  4428.                         title: n ? "Connecting to the game" : t.onGame ? "Joined the game" : "Left the game"
  4429.                     }
  4430.                 }), p("a.text.ulpt", {
  4431.                     attrs: Object.assign({
  4432.                         "data-pt-pos": "s",
  4433.                         href: "/@/" + s.username
  4434.                     }, e.isPlaying() ? {
  4435.                         target: "_blank",
  4436.                         rel: "noopener"
  4437.                     } : {})
  4438.                 }, s.title ? [p("span.utitle", "BOT" == s.title ? {
  4439.                     attrs: {
  4440.                         "data-bot": !0
  4441.                     }
  4442.                 } : {}, s.title), " ", s.username] : [s.username]), i ? p("rating", i + (t.provisional ? "?" : "")) : null, c, t.engine ? p("span", {
  4443.                     attrs: {
  4444.                         "data-icon": "j",
  4445.                         title: e.noarg("thisAccountViolatedTos")
  4446.                     }
  4447.                 }) : null])
  4448.             }
  4449.             const l = !t.onGame && e.firstSeconds;
  4450.             return p(`div.ruser-${o}.ruser.user-link`, {
  4451.                 class: {
  4452.                     online: t.onGame, offline: !t.onGame, connecting: l
  4453.                 }
  4454.             }, [p("i.line", {
  4455.                 attrs: {
  4456.                     title: l ? "Connecting to the game" : t.onGame ? "Joined the game" : "Left the game"
  4457.                 }
  4458.             }), p("name", t.name || e.noarg("anonymous"))])
  4459.         }(e, o, t)
  4460.     }
  4461.     const un = e => e.loading || e.redirecting,
  4462.         hn = () => p("i.ddloader"),
  4463.         pn = (e, t) => [an(e), t.find((e => !!e)) ? p("div.rcontrols", t) : null],
  4464.         mn = e => pn(e, [un(e) ? hn() : uo(e) || ho(e) || mo(e)]),
  4465.         fn = e => pn(e, [un(e) ? hn() : Ue.playable(e.data) ? void 0 : fo(e)]),
  4466.         gn = e => {
  4467.             const t = e.data,
  4468.                 o = un(e),
  4469.                 n = function(e) {
  4470.                     return e.moveToSubmit || e.dropToSubmit ? p("div.negotiation.move-confirm", [co(e, (() => e.submitMove(!1)), "cancel"), p("p", e.noarg("confirmMove")), ao(e, "confirm-yes", (() => e.submitMove(!0)))]) : void 0
  4471.                 }(e),
  4472.                 s = o || n ? [] : [Ue.abortable(t) ? Zt(e, void 0, "L", "abortGame", "abort") : Zt(e, Ue.takebackable, "i", "proposeATakeback", "takeback-yes", e.takebackYes), e.drawConfirm ? oo(e) : Zt(e, e.canOfferDraw, "2", "offerDraw", "draw-yes", (() => e.offerDraw(!0))), e.resignConfirm ? to(e) : Zt(e, Ue.resignable, "b", "resign", "resign", (() => e.resign(!0))), on(e)],
  4473.                 r = o ? [hn()] : n ? [n] : [Qt(e), no(e), so(e), ro(e), io(e), lo(e)];
  4474.             return [an(e), p("div.rcontrols", [...r, p("div.ricons", {
  4475.                 class: {
  4476.                     confirm: !(!e.drawConfirm && !e.resignConfirm)
  4477.                 }
  4478.             }, s)])]
  4479.         };
  4480.  
  4481.     function vn(e, t) {
  4482.         const o = e.playerAt(t);
  4483.         return e.clock ? function(e, t, o) {
  4484.             const n = e.clock,
  4485.                 s = n.millisOf(t.color),
  4486.                 r = e.data.player.color === t.color,
  4487.                 i = t.color === n.times.activeColor,
  4488.                 a = e => {
  4489.                     const o = n.elements[t.color],
  4490.                         s = n.millisOf(t.color),
  4491.                         r = t.color === n.times.activeColor;
  4492.                     o.time = e, o.clock = e.parentElement, e.innerHTML = yo(s, n.showTenths(s), r, n.opts.nvui)
  4493.                 },
  4494.                 c = {
  4495.                     insert: e => a(e.elm),
  4496.                     postpatch: (e, t) => a(t.elm)
  4497.                 };
  4498.             return p("div.rclock.rclock-" + o, {
  4499.                 class: {
  4500.                     outoftime: s <= 0, running: i, emerg: s < n.emergMs
  4501.                 }
  4502.             }, n.opts.nvui ? [p("div.time", {
  4503.                 attrs: {
  4504.                     role: "timer"
  4505.                 },
  4506.                 hook: c
  4507.             })] : [n.showBar && Ue.bothPlayersHavePlayed(e.data) ? wo(e, t.color) : void 0, p("div.time", {
  4508.                 class: {
  4509.                     hour: s > 36e5
  4510.                 },
  4511.                 hook: c
  4512.             }), Po(e, t.color, o), r ? Mo(e) : po(e), Co(e, t.color, o)])
  4513.         }(e, o, t) : e.data.correspondence && e.data.game.turns > 1 ? Yo(e.corresClock, e.trans, o.color, t, e.data.game.player) : function(e, t, o) {
  4514.             const n = e.data;
  4515.             if (!He.finished(n) && !He.aborted(n)) return p("div.rclock.rclock-turn.rclock-" + o, [n.game.player === t ? p("div.rclock-turn__text", n.player.spectator ? e.trans(n.game.player + "Plays") : e.trans(n.game.player === n.player.color ? "yourTurn" : "waitingForOpponent")) : null])
  4516.         }(e, o.color, t)
  4517.     }
  4518.     const bn = e => [p("div.round__app__table"), ln(e), dn(e, "top"), ...e.data.player.spectator ? fn(e) : Ue.playable(e.data) ? gn(e) : mn(e), dn(e, "bottom"), vn(e, "top"), vn(e, "bottom")];
  4519.  
  4520.     function yn(e, t, o, n) {
  4521.         const s = [];
  4522.         let r, i;
  4523.         for (r in e)
  4524.             if (e[r] > 0) {
  4525.                 const t = [];
  4526.                 for (i = 0; i < e[r]; i++) t.push(p("mpiece." + r));
  4527.                 s.push(p("div", t))
  4528.             } if (n)
  4529.             for (i = 0; i < n; i++) s.push(p("div", p("mpiece.king")));
  4530.         return t > 0 && s.push(p("score", "+" + t)), p("div.material.material-" + o, s)
  4531.     }
  4532.     const wn = {
  4533.         white: {},
  4534.         black: {}
  4535.     };
  4536.  
  4537.     function kn(e) {
  4538.         const t = e.data,
  4539.             o = e.chessground && e.chessground.state,
  4540.             n = t[e.flip ? "player" : "opponent"].color,
  4541.             s = t[e.flip ? "opponent" : "player"].color;
  4542.         let r, i = 0;
  4543.         if (t.pref.showCaptured) {
  4544.             const t = o ? o.pieces : Xe.read(ze(e.data, e.ply).fen);
  4545.             r = function(e) {
  4546.                 const t = {
  4547.                     white: {
  4548.                         king: 0,
  4549.                         queen: 0,
  4550.                         rook: 0,
  4551.                         bishop: 0,
  4552.                         knight: 0,
  4553.                         pawn: 0
  4554.                     },
  4555.                     black: {
  4556.                         king: 0,
  4557.                         queen: 0,
  4558.                         rook: 0,
  4559.                         bishop: 0,
  4560.                         knight: 0,
  4561.                         pawn: 0
  4562.                     }
  4563.                 };
  4564.                 for (const o of e.values()) {
  4565.                     const e = t[ie.opposite(o.color)];
  4566.                     e[o.role] > 0 ? e[o.role]-- : t[o.color][o.role]++
  4567.                 }
  4568.                 return t
  4569.             }(t), i = function(e) {
  4570.                 let t = 0;
  4571.                 for (const o of e.values()) t += ae[o.role] * ("white" === o.color ? 1 : -1);
  4572.                 return t
  4573.             }(t) * ("white" === s ? 1 : -1)
  4574.         } else r = wn;
  4575.         const a = t.player.checks || t.opponent.checks ? function(e, t) {
  4576.             const o = Object.assign({}, pe);
  4577.             for (const n of e) {
  4578.                 if (t < n.ply) break;
  4579.                 n.check && (n.ply % 2 == 1 ? o.white++ : o.black++)
  4580.             }
  4581.             return o
  4582.         }(e.data.steps, e.ply) : pe;
  4583.         return e.nvui ? e.nvui.render(e) : p("div.round__app.variant-" + t.game.variant.key, {
  4584.             class: {
  4585.                 "move-confirm": !(!e.moveToSubmit && !e.dropToSubmit)
  4586.             }
  4587.         }, [p("div.round__app__board.main-board" + (e.data.pref.blindfold ? ".blindfold" : ""), {
  4588.             hook: "ontouchstart" in window ? void 0 : ue("wheel", (t => function(e, t) {
  4589.                 e.isPlaying() || (t.preventDefault(), t.deltaY > 0 ? zo(e) : t.deltaY < 0 && Go(e), e.redraw())
  4590.             }(e, t)), void 0, !1)
  4591.         }, [ft(e), Gt(e)]), Vo(e, n, "top") || yn(r[n], -i, "top", a[n]), ...bn(e), Vo(e, s, "bottom") || yn(r[s], i, "bottom", a[s]), e.keyboardMove ? Ro(e.keyboardMove) : null])
  4592.     }
  4593.     const Pn = u([C, P]);
  4594.     return window.LichessChat = Se, window.Chessground = lt.Chessground, e.app = function(e) {
  4595.         const t = new Ko(e, s),
  4596.             o = kn(t);
  4597.         e.element.innerHTML = "";
  4598.         let n = Pn(e.element, o);
  4599.  
  4600.         function s() {
  4601.             n = Pn(n, kn(t))
  4602.         }
  4603.         return window.addEventListener("resize", s), t.isPlaying() && Oe(), {
  4604.             socketReceive: t.socket.receive,
  4605.             moveOn: t.moveOn
  4606.         }
  4607.     }, e.boot = function(e) {
  4608.         var t;
  4609.         const o = document.querySelector(".round__app"),
  4610.             n = e.data;
  4611.  
  4612.         function s() {
  4613.             n.tournament && $(".game__tournament .clock").each((function() {
  4614.                 $(this).clock({
  4615.                     time: parseFloat($(this).data("time"))
  4616.                 })
  4617.             }))
  4618.         }
  4619.  
  4620.         function r(e) {
  4621.             if (!e.player.spectator) return e.steps.length < 4 ? "start" : e.game.status.id >= 30 ? "end" : void 0
  4622.         }
  4623.         n.tournament && $("body").data("tournament-id", n.tournament.id), lichess.socket = new lichess.StrongSocket(n.url.socket, n.player.version, {
  4624.             params: {
  4625.                 userTv: n.userTv && n.userTv.id
  4626.             },
  4627.             receive(e, t) {
  4628.                 i.socketReceive(e, t)
  4629.             },
  4630.             events: {
  4631.                 tvSelect(e) {
  4632.                     n.tv && n.tv.channel == e.channel ? lichess.reload() : $(".tv-channels ." + e.channel + " .champion").html(e.player ? [e.player.title, e.player.name, e.player.rating].filter((e => e)).join("&nbsp") : "Anonymous")
  4633.                 },
  4634.                 end() {
  4635.                     se.text(`${n.tv?"/tv":""}/${n.game.id}/${n.player.color}/sides`).then((e => {
  4636.                         const t = $(e),
  4637.                             o = t.find(".game__meta");
  4638.                         o.length && $(".game__meta").replaceWith(o), $(".crosstable").replaceWith(t.find(".crosstable")), s(), lichess.contentLoaded()
  4639.                     }))
  4640.                 },
  4641.                 tourStanding(t) {
  4642.                     var o, n, s;
  4643.                     (null === (o = e.chat) || void 0 === o ? void 0 : o.plugin) && (null === (s = null === (n = e.chat) || void 0 === n ? void 0 : n.instance) || void 0 === s || s.then((o => {
  4644.                         e.chat.plugin.set(t), o.redraw()
  4645.                     })))
  4646.                 }
  4647.             }
  4648.         }), e.element = o, e.socketSend = lichess.socket.send;
  4649.         const i = window.LichessRound.app(e),
  4650.             a = e.chat;
  4651.         var c, l;
  4652.         a && ((null === (t = n.tournament) || void 0 === t ? void 0 : t.top) ? (a.plugin = (c = n.tournament.top, l = n.tournament.team, {
  4653.             set(e) {
  4654.                 c = e
  4655.             },
  4656.             tab: {
  4657.                 key: "tourStanding",
  4658.                 name: e.i18n.standing
  4659.             },
  4660.             view: () => p("div", {
  4661.                 hook: de((e => {
  4662.                     lichess.loadCssPath("round.tour-standing")
  4663.                 }))
  4664.             }, [l ? p("h3.text", {
  4665.                 attrs: {
  4666.                     "data-icon": "f"
  4667.                 }
  4668.             }, l.name) : null, p("table.slist", [p("tbody", c.map(((e, t) => p("tr." + e.n, [p("td.name", [p("span.rank", "" + (t + 1)), p("a.user-link.ulpt", {
  4669.                 attrs: {
  4670.                     href: `/@/${e.n}`
  4671.                 }
  4672.             }, (e.t ? e.t + " " : "") + e.n)]), p("td.total", e.f ? {
  4673.                 class: {
  4674.                     "is-gold": !0
  4675.                 },
  4676.                 attrs: {
  4677.                     "data-icon": "Q"
  4678.                 }
  4679.             } : {}, "" + e.s)]))))])])
  4680.         }), a.alwaysEnabled = !0) : n.simul || n.swiss || (a.preset = r(n), a.parseMoves = !0), a.noteId && (a.noteAge || 0) < 10 && (a.noteText = ""), a.instance = lichess.makeChat(a), n.tournament || n.simul || n.swiss || (e.onChange = e => a.instance.then((t => t.preset.setGroup(r(e)))))), s(), $(".round__now-playing .move-on input").on("change", i.moveOn.toggle).prop("checked", i.moveOn.get()).on("click", "a", (() => (lichess.unload.expected = !0, !0))), 0 === location.pathname.lastIndexOf("/round-next/", 0) && history.replaceState(null, "", "/" + n.game.id), $("#zentog").on("click", (() => lichess.pubsub.emit("zen"))), lichess.storage.make("reload-round-tabs").listen(lichess.reload)
  4681.     }, Object.defineProperty(e, "__esModule", {
  4682.         value: !0
  4683.     }), e
  4684. }({});
Add Comment
Please, Sign In to add comment