MediaWiki:HeroPlanner.js: Difference between revisions

From Heroes of Might and Magic: Olden Era Official Wiki
No edit summary
No edit summary
Line 1,467: Line 1,467:
     componentDidUpdate() {
     componentDidUpdate() {
       Persistence_default.remember(this.state);
       Persistence_default.remember(this.state);
    }
    componentWillUnmount() {
      console.log("componentWillUnmount:");
      window.removeEventListener("resize", this.onWindowResize);
     }
     }
     // -----------------------------------------------------------------------------------------------------------------
     // -----------------------------------------------------------------------------------------------------------------
Line 1,628: Line 1,632:
   async function planner() {
   async function planner() {
     const root = document.querySelector(".planner");
     const root = document.querySelector(".planner");
    console.log("planner:", root);
     if (!root) {
     if (!root) {
       document.addEventListener("DOMContentLoaded", onDomContentLoaded);
       window.addEventListener("load", onWindowLoad);
     } else {
     } else {
       await run(root);
       await run(root);
     }
     }
   }
   }
   async function onDomContentLoaded() {
   async function onWindowLoad() {
     document.removeEventListener("DOMContentLoaded", onDomContentLoaded);
     window.removeEventListener("load", onWindowLoad);
     const root = document.querySelector(".planner");
     const root = document.querySelector(".planner");
    console.log("onDomContentLoaded:", root);
     if (root) {
     if (root) {
       await run(root);
       await run(root);
Line 1,644: Line 1,646:
   }
   }
   async function run(root) {
   async function run(root) {
     console.log("run:");
     console.log("Mounting HeroPlanner...");
     mount_default(App_default, root, {
     mount_default(App_default, root, {
       bgUrl: root.querySelector(".background img").src,
       bgUrl: root.querySelector(".background img").src,

Revision as of 14:29, 11 September 2026

(() => {
  // node_modules/preact/dist/preact.module.js
  var n;
  var l;
  var u;
  var t;
  var i;
  var r;
  var o;
  var e;
  var f;
  var c;
  var a;
  var s;
  var h;
  var p;
  var v;
  var y;
  var d = {};
  var w = [];
  var _ = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
  var g = Array.isArray;
  function m(n3, l3) {
    for (var u4 in l3) n3[u4] = l3[u4];
    return n3;
  }
  function b(n3) {
    n3 && n3.parentNode && n3.parentNode.removeChild(n3);
  }
  function k(l3, u4, t3) {
    var i3, r2, o3, e3 = {};
    for (o3 in u4) "key" == o3 ? i3 = u4[o3] : "ref" == o3 ? r2 = u4[o3] : e3[o3] = u4[o3];
    if (arguments.length > 2 && (e3.children = arguments.length > 3 ? n.call(arguments, 2) : t3), "function" == typeof l3 && null != l3.defaultProps) for (o3 in l3.defaultProps) void 0 === e3[o3] && (e3[o3] = l3.defaultProps[o3]);
    return x(l3, e3, i3, r2, null);
  }
  function x(n3, t3, i3, r2, o3) {
    var e3 = { type: n3, props: t3, key: i3, ref: r2, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: null == o3 ? ++u : o3, __i: -1, __u: 0 };
    return null == o3 && null != l.vnode && l.vnode(e3), e3;
  }
  function M() {
    return { current: null };
  }
  function S(n3) {
    return n3.children;
  }
  function C(n3, l3) {
    this.props = n3, this.context = l3;
  }
  function $(n3, l3) {
    if (null == l3) return n3.__ ? $(n3.__, n3.__i + 1) : null;
    for (var u4; l3 < n3.__k.length; l3++) if (null != (u4 = n3.__k[l3]) && null != u4.__e) return u4.__e;
    return "function" == typeof n3.type ? $(n3) : null;
  }
  function I(n3) {
    if (n3.__P && n3.__d) {
      var u4 = n3.__v, t3 = u4.__e, i3 = [], r2 = [], o3 = m({}, u4);
      o3.__v = u4.__v + 1, l.vnode && l.vnode(o3), q(n3.__P, o3, u4, n3.__n, n3.__P.namespaceURI, 32 & u4.__u ? [t3] : null, i3, null == t3 ? $(u4) : t3, !!(32 & u4.__u), r2), o3.__v = u4.__v, o3.__.__k[o3.__i] = o3, D(i3, o3, r2), u4.__e = u4.__ = null, o3.__e != t3 && P(o3);
    }
  }
  function P(n3) {
    if (null != (n3 = n3.__) && null != n3.__c) return n3.__e = n3.__c.base = null, n3.__k.some(function(l3) {
      if (null != l3 && null != l3.__e) return n3.__e = n3.__c.base = l3.__e;
    }), P(n3);
  }
  function A(n3) {
    (!n3.__d && (n3.__d = true) && i.push(n3) && !H.__r++ || r != l.debounceRendering) && ((r = l.debounceRendering) || o)(H);
  }
  function H() {
    try {
      for (var n3, l3 = 1; i.length; ) i.length > l3 && i.sort(e), n3 = i.shift(), l3 = i.length, I(n3);
    } finally {
      i.length = H.__r = 0;
    }
  }
  function L(n3, l3, u4, t3, i3, r2, o3, e3, f3, c3, a3) {
    var s3, h3, p3, v2, y2, _2, g2 = t3 && t3.__k || w, m2 = l3.length;
    for (f3 = T(u4, l3, g2, f3, m2), s3 = 0; s3 < m2; s3++) null != (p3 = u4.__k[s3]) && (h3 = -1 != p3.__i && g2[p3.__i] || d, p3.__i = s3, _2 = q(n3, p3, h3, i3, r2, o3, e3, f3, c3, a3), v2 = p3.__e, p3.ref && h3.ref != p3.ref && (h3.ref && J(h3.ref, null, p3), a3.push(p3.ref, p3.__c || v2, p3)), null == y2 && null != v2 && (y2 = v2), 4 & p3.__u ? (f3 = j(p3, f3, n3), h3.__e && (h3.__e = null)) : "function" == typeof p3.type && void 0 !== _2 ? f3 = _2 : v2 && (f3 = v2.nextSibling), p3.__u &= -7);
    return u4.__e = y2, f3;
  }
  function T(n3, l3, u4, t3, i3) {
    var r2, o3, e3, f3, c3, a3 = u4.length, s3 = a3, h3 = 0;
    for (n3.__k = new Array(i3), r2 = 0; r2 < i3; r2++) null != (o3 = l3[r2]) && "boolean" != typeof o3 && "function" != typeof o3 ? ("string" == typeof o3 || "number" == typeof o3 || "bigint" == typeof o3 || o3.constructor == String ? o3 = n3.__k[r2] = x(null, o3, null, null, null) : g(o3) ? o3 = n3.__k[r2] = x(S, { children: o3 }, null, null, null) : void 0 === o3.constructor && o3.__b > 0 ? o3 = n3.__k[r2] = x(o3.type, o3.props, o3.key, o3.ref ? o3.ref : null, o3.__v) : n3.__k[r2] = o3, f3 = r2 + h3, o3.__ = n3, o3.__b = n3.__b + 1, e3 = null, -1 != (c3 = o3.__i = O(o3, u4, f3, s3)) && (s3--, (e3 = u4[c3]) && (e3.__u |= 2)), null == e3 || null == e3.__v ? (-1 == c3 && (i3 > a3 ? h3-- : i3 < a3 && h3++), "function" != typeof o3.type && (o3.__u |= 4)) : c3 != f3 && (c3 == f3 - 1 ? h3-- : c3 == f3 + 1 ? h3++ : (c3 > f3 ? h3-- : h3++, o3.__u |= 4))) : n3.__k[r2] = null;
    if (s3) for (r2 = 0; r2 < a3; r2++) null != (e3 = u4[r2]) && 0 == (2 & e3.__u) && (e3.__e == t3 && (t3 = $(e3)), K(e3, e3));
    return t3;
  }
  function j(n3, l3, u4) {
    var t3, i3;
    if ("function" == typeof n3.type) {
      for (t3 = n3.__k, i3 = 0; t3 && i3 < t3.length; i3++) t3[i3] && (t3[i3].__ = n3, l3 = j(t3[i3], l3, u4));
      return l3;
    }
    n3.__e != l3 && (l3 && n3.type && !l3.parentNode && (l3 = $(n3)), l3 = u4.insertBefore(n3.__e, l3 || null));
    do {
      l3 = l3 && l3.nextSibling;
    } while (null != l3 && 8 == l3.nodeType);
    return l3;
  }
  function O(n3, l3, u4, t3) {
    var i3, r2, o3, e3 = n3.key, f3 = n3.type, c3 = l3[u4], a3 = null != c3 && 0 == (2 & c3.__u);
    if (null === c3 && null == e3 || a3 && e3 == c3.key && f3 == c3.type) return u4;
    if (t3 > (a3 ? 1 : 0)) {
      for (i3 = u4 - 1, r2 = u4 + 1; i3 >= 0 || r2 < l3.length; ) if (null != (c3 = l3[o3 = i3 >= 0 ? i3-- : r2++]) && 0 == (2 & c3.__u) && e3 == c3.key && f3 == c3.type) return o3;
    }
    return -1;
  }
  function z(n3, l3, u4) {
    "-" == l3[0] ? n3.setProperty(l3, null == u4 ? "" : u4) : n3[l3] = null == u4 ? "" : "number" != typeof u4 || _.test(l3) ? u4 : u4 + "px";
  }
  function N(n3, l3, u4, t3, i3) {
    var r2, o3;
    n: if ("style" == l3) if ("string" == typeof u4) n3.style.cssText = u4;
    else {
      if ("string" == typeof t3 && (n3.style.cssText = t3 = ""), t3) for (l3 in t3) u4 && l3 in u4 || z(n3.style, l3, "");
      if (u4) for (l3 in u4) t3 && u4[l3] == t3[l3] || z(n3.style, l3, u4[l3]);
    }
    else if ("o" == l3[0] && "n" == l3[1]) r2 = l3 != (l3 = l3.replace(s, "$1")), o3 = l3.toLowerCase(), l3 = o3 in n3 || "onFocusOut" == l3 || "onFocusIn" == l3 ? o3.slice(2) : l3.slice(2), n3.l || (n3.l = {}), n3.l[l3 + r2] = u4, u4 ? t3 ? u4[a] = t3[a] : (u4[a] = h, n3.addEventListener(l3, r2 ? v : p, r2)) : n3.removeEventListener(l3, r2 ? v : p, r2);
    else {
      if ("http://www.w3.org/2000/svg" == i3) l3 = l3.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
      else if ("width" != l3 && "height" != l3 && "href" != l3 && "list" != l3 && "form" != l3 && "tabIndex" != l3 && "download" != l3 && "rowSpan" != l3 && "colSpan" != l3 && "role" != l3 && "popover" != l3 && l3 in n3) try {
        n3[l3] = null == u4 ? "" : u4;
        break n;
      } catch (n4) {
      }
      "function" == typeof u4 || (null == u4 || false === u4 && "-" != l3[4] ? n3.removeAttribute(l3) : n3.setAttribute(l3, "popover" == l3 && 1 == u4 ? "" : u4));
    }
  }
  function V(n3) {
    return function(u4) {
      if (this.l) {
        var t3 = this.l[u4.type + n3];
        if (null == u4[c]) u4[c] = h++;
        else if (u4[c] < t3[a]) return;
        return t3(l.event ? l.event(u4) : u4);
      }
    };
  }
  function q(n3, u4, t3, i3, r2, o3, e3, f3, c3, a3) {
    var s3, h3, p3, v2, y2, d2, _2, k2, x2, M2, I2, P2, A2, H2, T2, j2, F = u4.type;
    if (void 0 !== u4.constructor) return null;
    128 & t3.__u && (c3 = !!(32 & t3.__u), o3 = [f3 = u4.__e = t3.__e]), (s3 = l.__b) && s3(u4);
    n: if ("function" == typeof F) {
      h3 = e3.length;
      try {
        if (x2 = u4.props, M2 = F.prototype && F.prototype.render, I2 = (s3 = F.contextType) && i3[s3.__c], P2 = s3 ? I2 ? I2.props.value : s3.__ : i3, t3.__c ? k2 = (p3 = u4.__c = t3.__c).__ = p3.__E : (M2 ? u4.__c = p3 = new F(x2, P2) : (u4.__c = p3 = new C(x2, P2), p3.constructor = F, p3.render = Q), I2 && I2.sub(p3), p3.state || (p3.state = {}), p3.__n = i3, v2 = p3.__d = true, p3.__h = [], p3._sb = []), M2 && null == p3.__s && (p3.__s = p3.state), M2 && null != F.getDerivedStateFromProps && (p3.__s == p3.state && (p3.__s = m({}, p3.__s)), m(p3.__s, F.getDerivedStateFromProps(x2, p3.__s))), y2 = p3.props, d2 = p3.state, p3.__v = u4, v2) M2 && null == F.getDerivedStateFromProps && null != p3.componentWillMount && p3.componentWillMount(), M2 && null != p3.componentDidMount && p3.__h.push(p3.componentDidMount);
        else {
          if (M2 && null == F.getDerivedStateFromProps && x2 !== y2 && null != p3.componentWillReceiveProps && p3.componentWillReceiveProps(x2, P2), u4.__v == t3.__v || !p3.__e && null != p3.shouldComponentUpdate && false === p3.shouldComponentUpdate(x2, p3.__s, P2)) {
            u4.__v != t3.__v && (p3.props = x2, p3.state = p3.__s, p3.__d = false), u4.__e = t3.__e, u4.__k = t3.__k, u4.__k.some(function(n4) {
              n4 && (n4.__ = u4);
            }), w.push.apply(p3.__h, p3._sb), p3._sb = [], p3.__h.length && e3.push(p3), f3 = $(t3);
            break n;
          }
          null != p3.componentWillUpdate && p3.componentWillUpdate(x2, p3.__s, P2), M2 && null != p3.componentDidUpdate && p3.__h.push(function() {
            p3.componentDidUpdate(y2, d2, _2);
          });
        }
        if (p3.context = P2, p3.props = x2, p3.__P = n3, p3.__e = false, A2 = l.__r, H2 = 0, M2) p3.state = p3.__s, p3.__d = false, A2 && A2(u4), s3 = p3.render(p3.props, p3.state, p3.context), w.push.apply(p3.__h, p3._sb), p3._sb = [];
        else do {
          p3.__d = false, A2 && A2(u4), s3 = p3.render(p3.props, p3.state, p3.context), p3.state = p3.__s;
        } while (p3.__d && ++H2 < 25);
        p3.state = p3.__s, null != p3.getChildContext && (i3 = m(m({}, i3), p3.getChildContext())), M2 && !v2 && null != p3.getSnapshotBeforeUpdate && (_2 = p3.getSnapshotBeforeUpdate(y2, d2)), T2 = null != s3 && s3.type === S && null == s3.key ? E(s3.props.children) : s3, f3 = L(n3, g(T2) ? T2 : [T2], u4, t3, i3, r2, o3, e3, f3, c3, a3), p3.base = u4.__e, u4.__u &= -161, p3.__h.length && e3.push(p3), k2 && (p3.__E = p3.__ = null);
      } catch (n4) {
        if (e3.length = h3, u4.__v = null, c3 || null != o3) {
          if (n4.then) {
            for (u4.__u |= c3 ? 160 : 128; f3 && 8 == f3.nodeType && f3.nextSibling; ) f3 = f3.nextSibling;
            null != o3 && (o3[o3.indexOf(f3)] = null), u4.__e = f3;
          } else if (null != o3) for (j2 = o3.length; j2--; ) b(o3[j2]);
        } else u4.__e = t3.__e;
        null == u4.__k && (u4.__k = t3.__k || []), n4.then || B(u4), l.__e(n4, u4, t3);
      }
    } else null == o3 && u4.__v == t3.__v ? (u4.__k = t3.__k, u4.__e = t3.__e) : f3 = u4.__e = G(t3.__e, u4, t3, i3, r2, o3, e3, c3, a3);
    return (s3 = l.diffed) && s3(u4), 128 & u4.__u ? void 0 : f3;
  }
  function B(n3) {
    n3 && (n3.__c && (n3.__c.__e = true), n3.__k && n3.__k.some(B));
  }
  function D(n3, u4, t3) {
    for (var i3 = 0; i3 < t3.length; i3++) J(t3[i3], t3[++i3], t3[++i3]);
    l.__c && l.__c(u4, n3), n3.some(function(u5) {
      try {
        n3 = u5.__h, u5.__h = [], n3.some(function(n4) {
          n4.call(u5);
        });
      } catch (n4) {
        l.__e(n4, u5.__v);
      }
    });
  }
  function E(n3) {
    return "object" != typeof n3 || null == n3 || n3.__b > 0 ? n3 : g(n3) ? n3.map(E) : void 0 !== n3.constructor ? null : m({}, n3);
  }
  function G(u4, t3, i3, r2, o3, e3, f3, c3, a3) {
    var s3, h3, p3, v2, y2, w2, _2, m2 = i3.props || d, k2 = t3.props, x2 = t3.type;
    if ("svg" == x2 ? o3 = "http://www.w3.org/2000/svg" : "math" == x2 ? o3 = "http://www.w3.org/1998/Math/MathML" : o3 || (o3 = "http://www.w3.org/1999/xhtml"), null != e3) {
      for (s3 = 0; s3 < e3.length; s3++) if ((y2 = e3[s3]) && "setAttribute" in y2 == !!x2 && (x2 ? y2.localName == x2 : 3 == y2.nodeType)) {
        u4 = y2, e3[s3] = null;
        break;
      }
    }
    if (null == u4) {
      if (null == x2) return document.createTextNode(k2);
      u4 = document.createElementNS(o3, x2, k2.is && k2), c3 && (l.__m && l.__m(t3, e3), c3 = false), e3 = null;
    }
    if (null == x2) m2 === k2 || c3 && u4.data == k2 || (u4.data = k2);
    else {
      if (e3 = "textarea" == x2 && null != k2.defaultValue ? null : e3 && n.call(u4.childNodes), !c3 && null != e3) for (m2 = {}, s3 = 0; s3 < u4.attributes.length; s3++) m2[(y2 = u4.attributes[s3]).name] = y2.value;
      for (s3 in m2) y2 = m2[s3], "dangerouslySetInnerHTML" == s3 ? p3 = y2 : "children" == s3 || s3 in k2 || "value" == s3 && "defaultValue" in k2 || "checked" == s3 && "defaultChecked" in k2 || N(u4, s3, null, y2, o3);
      for (s3 in k2) y2 = k2[s3], "children" == s3 ? v2 = y2 : "dangerouslySetInnerHTML" == s3 ? h3 = y2 : "value" == s3 ? w2 = y2 : "checked" == s3 ? _2 = y2 : c3 && "function" != typeof y2 || m2[s3] === y2 || N(u4, s3, y2, m2[s3], o3);
      if (h3) c3 || p3 && (h3.__html == p3.__html || h3.__html == u4.innerHTML) || (u4.innerHTML = h3.__html), t3.__k = [];
      else if (p3 && (u4.innerHTML = ""), L("template" == t3.type ? u4.content : u4, g(v2) ? v2 : [v2], t3, i3, r2, "foreignObject" == x2 ? "http://www.w3.org/1999/xhtml" : o3, e3, f3, e3 ? e3[0] : i3.__k && $(i3, 0), c3, a3), null != e3) for (s3 = e3.length; s3--; ) b(e3[s3]);
      c3 && "textarea" != x2 || (s3 = "value", "progress" == x2 && null == w2 ? u4.removeAttribute("value") : null != w2 && (w2 !== u4[s3] || "progress" == x2 && !w2 || "option" == x2 && w2 != m2[s3]) && N(u4, s3, w2, m2[s3], o3), s3 = "checked", null != _2 && _2 != u4[s3] && N(u4, s3, _2, m2[s3], o3));
    }
    return u4;
  }
  function J(n3, u4, t3) {
    try {
      if ("function" == typeof n3) {
        var i3 = "function" == typeof n3.__u;
        i3 && n3.__u(), i3 && null == u4 || (n3.__u = n3(u4));
      } else n3.current = u4;
    } catch (n4) {
      l.__e(n4, t3);
    }
  }
  function K(n3, u4, t3) {
    var i3, r2;
    if (l.unmount && l.unmount(n3), (i3 = n3.ref) && (i3.current && i3.current != n3.__e || J(i3, null, u4)), null != (i3 = n3.__c)) {
      if (i3.componentWillUnmount) try {
        i3.componentWillUnmount();
      } catch (n4) {
        l.__e(n4, u4);
      }
      i3.base = i3.__P = i3.__n = null;
    }
    if (i3 = n3.__k) for (r2 = 0; r2 < i3.length; r2++) i3[r2] && K(i3[r2], u4, t3 || "function" != typeof n3.type);
    t3 || b(n3.__e), n3.__c = n3.__ = n3.__e = void 0;
  }
  function Q(n3, l3, u4) {
    return this.constructor(n3, u4);
  }
  function R(u4, t3, i3) {
    var r2, o3, e3, f3;
    t3 == document && (t3 = document.documentElement), l.__ && l.__(u4, t3), o3 = (r2 = "function" == typeof i3) ? null : i3 && i3.__k || t3.__k, e3 = [], f3 = [], q(t3, u4 = (!r2 && i3 || t3).__k = k(S, null, [u4]), o3 || d, d, t3.namespaceURI, !r2 && i3 ? [i3] : o3 ? null : t3.firstChild ? n.call(t3.childNodes) : null, e3, !r2 && i3 ? i3 : o3 ? o3.__e : t3.firstChild, r2, f3), D(e3, u4, f3), u4.props.children = null;
  }
  n = w.slice, l = { __e: function(n3, l3, u4, t3) {
    for (var i3, r2, o3; l3 = l3.__; ) if ((i3 = l3.__c) && !i3.__) try {
      if ((r2 = i3.constructor) && null != r2.getDerivedStateFromError && (i3.setState(r2.getDerivedStateFromError(n3)), o3 = i3.__d), null != i3.componentDidCatch && (i3.componentDidCatch(n3, t3 || {}), o3 = i3.__d), o3) return i3.__E = i3;
    } catch (l4) {
      n3 = l4;
    }
    throw n3;
  } }, u = 0, t = function(n3) {
    return null != n3 && void 0 === n3.constructor;
  }, C.prototype.setState = function(n3, l3) {
    var u4;
    u4 = null != this.__s && this.__s != this.state ? this.__s : this.__s = m({}, this.state), "function" == typeof n3 && (n3 = n3(m({}, u4), this.props)), n3 && m(u4, n3), null != n3 && this.__v && (l3 && this._sb.push(l3), A(this));
  }, C.prototype.forceUpdate = function(n3) {
    this.__v && (this.__e = true, n3 && this.__h.push(n3), A(this));
  }, C.prototype.render = S, i = [], o = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, e = function(n3, l3) {
    return n3.__v.__b - l3.__v.__b;
  }, H.__r = 0, f = Math.random().toString(8), c = "__d" + f, a = "__a" + f, s = /(PointerCapture)$|Capture$/i, h = 0, p = V(false), v = V(true), y = 0;

  // node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
  var f2 = 0;
  function u2(e3, t3, n3, o3, i3, u4) {
    t3 || (t3 = {});
    var a3, c3, p3 = t3;
    if ("ref" in p3) for (c3 in p3 = {}, t3) "ref" == c3 ? a3 = t3[c3] : p3[c3] = t3[c3];
    var l3 = { type: e3, props: p3, key: n3, ref: a3, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --f2, __i: -1, __u: 0, __source: i3, __self: u4 };
    if ("function" == typeof e3 && (a3 = e3.defaultProps)) for (c3 in a3) void 0 === p3[c3] && (p3[c3] = a3[c3]);
    return l.vnode && l.vnode(l3), l3;
  }

  // src/planner/helpers/mount.jsx
  function mount(App2, root, setup2) {
    root.innerHTML = "";
    R(/* @__PURE__ */ u2(App2, { setup: setup2 }), root);
    root.style.position = "relative";
    root.style.visibility = "visible";
  }
  var mount_default = mount;

  // src/planner/SETTINGS.js
  var WIDTH = 708;
  var HEIGHT = 809;

  // node_modules/goober/dist/goober.modern.js
  var e2 = { data: "" };
  var t2 = (t3) => {
    if ("object" == typeof window) {
      let e3 = (t3 ? t3.querySelector("#_goober") : window._goober) || Object.assign(document.createElement("style"), { innerHTML: " ", id: "_goober" });
      return e3.nonce = window.__nonce__, e3.parentNode || (t3 || document.head).appendChild(e3), e3.firstChild;
    }
    return t3 || e2;
  };
  var a2 = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
  var l2 = /\/\*[^]*?\*\/|  +/g;
  var n2 = /\n+/g;
  var o2 = (e3, t3) => {
    let r2 = "", a3 = "", l3 = "";
    for (let n3 in e3) {
      let c3 = e3[n3];
      "@" == n3[0] ? "i" == n3[1] ? r2 = n3 + " " + c3 + ";" : a3 += "f" == n3[1] ? o2(c3, n3) : n3 + "{" + o2(c3, "k" == n3[1] ? "" : t3) + "}" : "object" == typeof c3 ? a3 += o2(c3, t3 ? t3.replace(/([^,])+/g, (e4) => n3.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g, (t4) => /&/.test(t4) ? t4.replace(/&/g, e4) : e4 ? e4 + " " + t4 : t4)) : n3) : null != c3 && (n3 = "-" == n3[1] ? n3 : n3.replace(/[A-Z]/g, "-$&").toLowerCase(), l3 += o2.p ? o2.p(n3, c3) : n3 + ":" + c3 + ";");
    }
    return r2 + (t3 && l3 ? t3 + "{" + l3 + "}" : l3) + a3;
  };
  var c2 = {};
  var i2 = (e3) => {
    if ("object" == typeof e3) {
      let t3 = "";
      for (let r2 in e3) t3 += r2 + i2(e3[r2]);
      return t3;
    }
    return e3;
  };
  var s2 = (e3, t3, r2, s3, p3) => {
    let u4 = i2(e3), d2 = c2[u4] || (c2[u4] = ((e4) => {
      let t4 = 0, r3 = 11;
      for (; t4 < e4.length; ) r3 = 101 * r3 + e4.charCodeAt(t4++) >>> 0;
      return "go" + r3;
    })(u4));
    if (!c2[d2]) {
      let t4 = u4 !== e3 ? e3 : ((e4) => {
        let t5, r3, o3 = [{}];
        for (; t5 = a2.exec(e4.replace(l2, "")); ) t5[4] ? o3.shift() : t5[3] ? (r3 = t5[3].replace(n2, " ").trim(), o3.unshift(o3[0][r3] = o3[0][r3] || {})) : o3[0][t5[1]] = t5[2].replace(n2, " ").trim();
        return o3[0];
      })(e3);
      c2[d2] = o2(p3 ? { ["@keyframes " + d2]: t4 } : t4, r2 ? "" : "." + d2);
    }
    let f3 = r2 && c2.g;
    return r2 && (c2.g = c2[d2]), ((e4, t4, r3, a3) => {
      a3 ? t4.data = t4.data.replace(a3, e4) : -1 === t4.data.indexOf(e4) && (t4.data = r3 ? e4 + t4.data : t4.data + e4);
    })(c2[d2], t3, s3, f3), d2;
  };
  var p2 = (e3, t3, r2) => e3.reduce((e4, a3, l3) => {
    let n3 = t3[l3];
    if (n3 && n3.call) {
      let e5 = n3(r2), t4 = e5 && e5.props && e5.props.className || /^go/.test(e5) && e5;
      n3 = t4 ? "." + t4 : e5 && "object" == typeof e5 ? e5.props ? "" : o2(e5, "") : false === e5 ? "" : e5;
    }
    return e4 + a3 + (null == n3 ? "" : n3);
  }, "");
  function u3(e3) {
    let r2 = this || {}, a3 = e3.call ? e3(r2.p) : e3;
    return s2(a3.unshift ? a3.raw ? p2(a3, [].slice.call(arguments, 1), r2.p) : a3.reduce((e4, t3) => Object.assign(e4, t3 && t3.call ? t3(r2.p) : t3), {}) : a3, t2(r2.target), r2.g, r2.o, r2.k);
  }
  var b2 = u3.bind({ g: 1 });
  var h2 = u3.bind({ k: 1 });

  // src/planner/components/Menu.jsx
  var ROOT_CSS = u3`
    position: absolute;
    background: #1f3756;
    border: solid 1px #bcb096;
    filter: drop-shadow(0 0 0.3rem black);
    border-radius: 8px;
    overflow: auto;
    z-index: 100;

    & img {
        width: 56px;
        cursor: pointer;
    }
`;
  var Menu = class extends C {
    vars = {
      rootRef: M(),
      timeout: null
    };
    render() {
      const { list, left, top, width, height } = this.props;
      return /* @__PURE__ */ u2("div", { className: ROOT_CSS, ref: this.vars.rootRef, style: { left, top, width, height }, children: Object.values(list).map((hero) => /* @__PURE__ */ u2("img", { src: hero.icon, "data-id": hero.id, onClick: this.onIconClick }, hero.id)) });
    }
    componentDidMount() {
      this.vars.timeout = setTimeout(this.listenForClose, 100);
    }
    componentWillUnmount() {
      window.removeEventListener("click", this.onWindowClick);
      clearTimeout(this.vars.timeout);
      this.vars = null;
    }
    // -----------------------------------------------------------------------------------------------------------------
    // P R I V A T E
    // -----------------------------------------------------------------------------------------------------------------
    /**
     *
     */
    listenForClose = () => {
      window.addEventListener("click", this.onWindowClick);
    };
    /**
     *
     */
    onWindowClick = (event) => {
      const rootElement = this.vars.rootRef.current;
      const { target } = event;
      if (target instanceof Node && rootElement.contains(target)) {
        return;
      }
      this.props.onChoice();
    };
    /**
     *
     */
    onIconClick = (event) => {
      this.props.onChoice(event.target.dataset.id);
    };
  };
  var Menu_default = Menu;

  // src/planner/components/Portrait.jsx
  var ROOT_CSS2 = u3`
    position: absolute;
    left: 0;
    top: 0;
`;
  var PIC_CSS = u3`
    width: 100%;
`;
  var MEDALLION_CSS = u3`
    position: absolute;
    left: 0;
    top: -5px;
    width: 140px;
    height: 140px;
    border-bottom-left-radius: 50%;
    border-bottom-right-radius: 50%;
    -webkit-mask: url(#compoundMask);
    mask: url(#compoundMask);
    cursor: pointer;
    /*background: red;*/
    /*filter: drop-shadow(0 0 2px rgba(255,255,255,0.5));*/
`;
  var Portrait = class extends C {
    state = {
      isOpen: false
    };
    render() {
      const { hero, heroes } = this.props;
      const { isOpen } = this.state;
      return /* @__PURE__ */ u2("div", { className: ROOT_CSS2, children: [
        /* @__PURE__ */ u2("div", { className: MEDALLION_CSS, onClick: this.onMedallionClick, children: [
          /* @__PURE__ */ u2("svg", { width: "0", height: "0", style: "position:absolute", children: /* @__PURE__ */ u2("defs", { children: /* @__PURE__ */ u2("mask", { id: "compoundMask", maskContentUnits: "objectBoundingBox", children: [
            /* @__PURE__ */ u2("rect", { x: "0", y: "0", width: "1", height: "0.35", fill: "white" }),
            /* @__PURE__ */ u2("circle", { cx: "0.54", cy: "0.58", r: "0.41", fill: "white" })
          ] }) }) }),
          hero && /* @__PURE__ */ u2("img", { className: PIC_CSS, src: heroes[hero].portrait })
        ] }),
        isOpen && /* @__PURE__ */ u2(Menu_default, { list: heroes, onChoice: this.onMenuChoice, left: 152, top: 10, width: 508, height: 681 })
      ] });
    }
    // -----------------------------------------------------------------------------------------------------------------
    // P R I V A T E
    // -----------------------------------------------------------------------------------------------------------------
    /**
     *
     */
    onMedallionClick = () => {
      if (!this.state.isOpen) {
        this.setState({ isOpen: true });
      }
    };
    /**
     *
     */
    onMenuChoice = (choice) => {
      console.log("choice:", choice);
      this.setState({ isOpen: false });
      if (choice && choice !== this.state.hero) {
        this.props.onHeroChange(choice);
      }
    };
  };
  var Portrait_default = Portrait;

  // src/planner/components/Level.jsx
  var ROOT_CSS3 = u3`
    position: absolute;
    left: 29px;
    top: 90px;
    transform: scale(0.5);
    border-radius: 50%;
    cursor: pointer;
`;
  var Level = class extends C {
    render() {
      const { src } = this.props;
      return /* @__PURE__ */ u2("img", { className: ROOT_CSS3, src });
    }
    // -----------------------------------------------------------------------------------------------------------------
    // P R I V A T E
    // -----------------------------------------------------------------------------------------------------------------
  };
  var Level_default = Level;

  // src/planner/helpers/compression/SETTINGS.js
  var SYMBOLS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  var FIELD_INDEX_BITS = 6;

  // src/planner/helpers/compression/DICTIONARY.js
  var DICTIONARY = {
    heroes: [
      "human_hero_1",
      "human_hero_2",
      "human_hero_3",
      "human_hero_4",
      "human_hero_5",
      "human_hero_6",
      "human_hero_7",
      "human_hero_8",
      "human_hero_9",
      "human_hero_10",
      "human_hero_11",
      "human_hero_12",
      "human_hero_13",
      "human_hero_14",
      "human_hero_15",
      "human_hero_16",
      "human_hero_17",
      "human_hero_18",
      "necro_hero_1",
      "necro_hero_2",
      "necro_hero_3",
      "necro_hero_4",
      "necro_hero_5",
      "necro_hero_6",
      "necro_hero_7",
      "necro_hero_8",
      "necro_hero_9",
      "necro_hero_10",
      "necro_hero_11",
      "necro_hero_12",
      "necro_hero_13",
      "necro_hero_14",
      "necro_hero_15",
      "necro_hero_16",
      "necro_hero_17",
      "necro_hero_18",
      "nature_hero_1",
      "nature_hero_2",
      "nature_hero_3",
      "nature_hero_4",
      "nature_hero_5",
      "nature_hero_6",
      "nature_hero_7",
      "nature_hero_8",
      "nature_hero_9",
      "nature_hero_10",
      "nature_hero_11",
      "nature_hero_12",
      "nature_hero_13",
      "nature_hero_14",
      "nature_hero_15",
      "nature_hero_16",
      "nature_hero_17",
      "nature_hero_18",
      "demon_hero_1",
      "demon_hero_18",
      "demon_hero_2",
      "demon_hero_3",
      "demon_hero_4",
      "demon_hero_5",
      "demon_hero_7",
      "demon_hero_8",
      "demon_hero_9",
      "demon_hero_10",
      "demon_hero_11",
      "demon_hero_12",
      "demon_hero_13",
      "demon_hero_14",
      "demon_hero_15",
      "demon_hero_16",
      "demon_hero_17",
      "demon_hero_6",
      "unfrozen_hero_1",
      "unfrozen_hero_2",
      "unfrozen_hero_3",
      "unfrozen_hero_4",
      "unfrozen_hero_5",
      "unfrozen_hero_6",
      "unfrozen_hero_7",
      "unfrozen_hero_8",
      "unfrozen_hero_9",
      "unfrozen_hero_10",
      "unfrozen_hero_11",
      "unfrozen_hero_12",
      "unfrozen_hero_13",
      "unfrozen_hero_14",
      "unfrozen_hero_15",
      "unfrozen_hero_16",
      "unfrozen_hero_17",
      "unfrozen_hero_18",
      "dungeon_hero_1",
      "dungeon_hero_2",
      "dungeon_hero_3",
      "dungeon_hero_4",
      "dungeon_hero_5",
      "dungeon_hero_6",
      "dungeon_hero_7",
      "dungeon_hero_8",
      "dungeon_hero_9",
      "dungeon_hero_10",
      "dungeon_hero_11",
      "dungeon_hero_12",
      "dungeon_hero_13",
      "dungeon_hero_14",
      "dungeon_hero_15",
      "dungeon_hero_16",
      "dungeon_hero_17",
      "dungeon_hero_18"
    ],
    skills: [
      "skill_assault",
      "skill_protection",
      "skill_leadership",
      "skill_luck",
      "skill_resistance",
      "skill_tactics",
      "skill_formation",
      "skill_siege",
      "skill_trainer",
      "skill_battle_artistry",
      "skill_battlemage",
      "skill_sorcery",
      "skill_summoner",
      "skill_mastery",
      "skill_magic_day",
      "skill_magic_night",
      "skill_magic_space",
      "skill_magic_primal",
      "skill_wisdom",
      "skill_diplomacy",
      "skill_logistic",
      "skill_scouting",
      "skill_enlightenment",
      "skill_economy",
      "skill_faction_humans",
      "skill_faction_undead",
      "skill_faction_nature",
      "skill_faction_demons",
      "skill_faction_unfrozen",
      "skill_faction_dungeon"
    ],
    artifactSword: [
      "paupers_glory_dumb_club_artifact",
      "duelists_pride_rapier_artifact",
      "knights_honor_lance_artifact",
      "ogres_club_of_havoc_artifact",
      "power_of_the_dragon_father_red_dragon_flame_tongue_artifact",
      "garotte_artifact",
      "living_arrows_shroomwood_bow_artifact",
      "rule_of_shadow_the_truthmaker_artifact",
      "shadow_of_death_dark_hatchet_artifact",
      "shamaniac_soul_shaman_staff_artifact",
      "angelic_alliance_sword_of_judgement_artifact",
      "beelzebubs_blessing_demon_claw_artifact",
      "excalibur_artifact"
    ],
    artifactShield: [
      "duelists_pride_buckler_artifact",
      "inner_song_singing_pan_pipe_artifact",
      "knights_honor_misericorde_artifact",
      "shoddy_shield_artifact",
      "caduceus_artifact",
      "ethereal_knowledge_glass_dagger_artifact",
      "fine_wand_artifact",
      "hourglass_of_protection_artifact",
      "tarq_of_the_rampaging_ogre_artifact",
      "power_of_the_dragon_father_dragon_scale_shield_artifact",
      "rule_of_shadow_the_truthseeker_artifact",
      "angelic_alliance_lions_shield_of_courage_artifact",
      "beelzebubs_blessing_chitinous_shield_artifact"
    ],
    artifactArmor: [
      "chain_mail_artifact",
      "paupers_glory_rags_artifact",
      "eagle_armor_artifact",
      "ethereal_knowledge_vortex_dress_artifact",
      "knights_honor_plate_armor_artifact",
      "tunic_of_the_cyclops_king_artifact",
      "clothes_of_enlightenment_artifact",
      "shadow_of_death_cursed_armor_artifact",
      "shamaniac_soul_iridescent_cloak_artifact",
      "angelic_alliance_armor_of_wonder_artifact",
      "beelzebubs_blessing_heartbeat_artifact",
      "power_of_the_dragon_father_dragon_scale_armor_artifact"
    ],
    artifactHelmet: [
      "head_torch_artifact",
      "inner_song_fancy_mask_artifact",
      "knights_honor_armet_artifact",
      "paupers_glory_straw_hat_artifact",
      "crown_of_the_supreme_magi_artifact",
      "scholars_wisdom_scholars_tiara_artifact",
      "tranquility_brightmind_tiara_artifact",
      "angelic_alliance_helm_of_heavenly_enlightenment_artifact",
      "beelzebubs_blessing_demon_crest_artifact",
      "ethereal_knowledge_third_eye_artifact",
      "power_of_the_dragon_father_dragon_crest_artifact",
      "rule_of_shadow_nostrias_gaze_artifact",
      "shamaniac_soul_gemwood_mask_artifact",
      "spellbinders_hat_artifact",
      "two_faced_mask_artifact"
    ],
    artifactBoots: [
      "ethereal_knowledge_mirror_shoes_artifact",
      "power_of_the_dragon_father_dragonbone_greaves_artifact",
      "wanderers_way_boots_of_travel_artifact",
      "legions_step_artifact",
      "shadow_of_death_bone_boots_artifact",
      "swamp_boots_artifact",
      "angelic_alliance_sandals_of_the_saint_artifact",
      "seven_league_boots_artifact",
      "warlord_boots_artifact"
    ],
    artifactBelt: [
      "paupers_glory_rope_belt_artifact",
      "soulless_sash_artifact",
      "elixir_of_life_flask_of_oblivion_artifact",
      "endless_bag_artifact",
      "warriors_strength_warriors_belt_artifact",
      "gifts_of_dwarven_lords_protective_belt_artifact",
      "milos_curse_skull_of_milos_artifact",
      "power_of_the_dragon_father_slithering_sash_artifact",
      "angelic_alliance_celestial_sash_of_bliss_artifact",
      "magic_key_ring_artifact",
      "spells_in_a_bottle_artifact"
    ],
    artifactCape: [
      "omencaller_artifact",
      "gifts_of_dwarven_lords_automated_antimagic_shield_artifact",
      "monster_head_artifact",
      "power_of_the_dragon_father_dragon_wing_artifact",
      "wanderers_way_backpack_artifact",
      "wizards_might_wizards_cloak_artifact",
      "banner_of_four_winds_artifact",
      "living_arrows_light_and_shade_cloak_artifact",
      "shadow_of_death_second_shade_artifact",
      "ambassadors_word_ambassadors_sash_artifact",
      "fallen_angel_wings_artifact"
    ],
    artifactRing: [
      "paupers_glory_wooden_ring_artifact",
      "power_of_the_dragon_father_piercing_eye_of_a_dragon_artifact",
      "shamaniac_soul_clutching_ring_artifact",
      "chain_link_artifact",
      "elixir_of_life_ring_of_life_artifact",
      "gifts_of_dwarven_lords_emerald_resonance_controller_artifact",
      "keepers_fortitude_keepers_ring_artifact",
      "ring_of_neutrality_artifact",
      "sixth_finger_artifact",
      "tranquility_ring_of_serenity_artifact",
      "ukhtabar_seal_tabar_seal_artifact",
      "duelists_pride_brass_knuckles_artifact",
      "gifts_of_dwarven_lords_crimson_resonance_controller_artifact",
      "lords_ring_artifact",
      "seal_of_silence_artifact",
      "soulscaller_ring_artifact"
    ],
    artifactPouch: [
      "boreolos_foot_artifact",
      "boreolos_hand_artifact",
      "boreolos_head_artifact",
      "boreolos_heart_artifact",
      "inner_song_music_sheet_artifact",
      "magic_scroll_artifact",
      "milos_curse_golden_moth_artifact",
      "paupers_glory_last_coin_artifact",
      "rule_of_shadow_liquid_silence_artifact",
      "tranquility_magic_mirror_artifact",
      "ancient_idol_artifact",
      "cards_deck_artifact",
      "enchanted_magic_scroll_artifact",
      "keepers_fortitude_keepers_oberegus_artifact",
      "living_arrows_quivering_quiver_artifact",
      "milos_curse_golden_pig_artifact",
      "orb_of_destruction_artifact",
      "scholars_wisdom_scholars_oberegus_artifact",
      "spyglass_artifact",
      "ukhtabar_seal_ukh_seal_artifact",
      "voodoosh_doll_artifact",
      "warriors_strength_warriors_oberegus_artifact",
      "wizards_might_wizards_oberegus_artifact",
      "flag_of_truce_artifact",
      "golden_goose_egg_artifact",
      "knights_honor_drums_of_war_artifact",
      "mythic_scroll_box_artifact",
      "orb_of_inhibition_artifact",
      "resonant_sphere_orb_of_daylight_artifact",
      "resonant_sphere_orb_of_eternity_artifact",
      "resonant_sphere_orb_of_twilight_artifact",
      "resonant_sphere_primal_orb_artifact",
      "runestone_shards_artifact",
      "shackles_of_war_artifact",
      "tactical_guide_artifact",
      "ambassadors_word_diplomatic_gifts_artifact",
      "catechism_of_daylight_magic_artifact",
      "catechism_of_night_magic_artifact",
      "catechism_of_primal_magic_artifact",
      "catechism_of_spacetime_magic_artifact",
      "demonic_heart_artifact",
      "elixir_of_life_lifeblood_fairy_artifact",
      "pole_star_artifact"
    ],
    artifactBanner: [
      "holy_sigil_of_eridore_artifact",
      "holy_sigil_of_insara_artifact",
      "holy_sigil_of_mearea_artifact",
      "holy_sigil_of_quix_artifact",
      "holy_sigil_of_roph_artifact",
      "holy_sigil_of_the_second_man_artifact",
      "holy_sigil_of_the_seven_magi_artifact",
      "holy_sigil_of_uurdt_artifact"
    ],
    units: [
      "esquire",
      "esquire_upg",
      "esquire_upg_alt",
      "crossbowman",
      "crossbowman_upg",
      "crossbowman_upg_alt",
      "griffin",
      "griffin_upg",
      "griffin_upg_alt",
      "lightweaver",
      "lightweaver_upg",
      "lightweaver_upg_alt",
      "sunlight_cavalry",
      "sunlight_cavalry_upg",
      "sunlight_cavalry_upg_alt",
      "inquisitor",
      "inquisitor_upg",
      "inquisitor_upg_alt",
      "angel",
      "angel_upg",
      "angel_upg_alt",
      "skeleton",
      "skeleton_upg",
      "skeleton_upg_alt",
      "flicker",
      "flicker_upg",
      "flicker_upg_alt",
      "pet",
      "pet_upg",
      "pet_upg_alt",
      "graverobber",
      "graverobber_upg",
      "graverobber_upg_alt",
      "lich",
      "lich_upg",
      "lich_upg_alt",
      "avatar_of_war",
      "avatar_of_war_upg",
      "avatar_of_war_upg_alt",
      "vampire",
      "vampire_upg",
      "vampire_upg_alt",
      "elf_tracker",
      "elf_tracker_upg",
      "elf_tracker_upg_alt",
      "twinkle",
      "twinkle_upg",
      "twinkle_upg_alt",
      "ent",
      "ent_upg",
      "ent_upg_alt",
      "aqualotl",
      "aqualotl_upg",
      "aqualotl_upg_alt",
      "druid",
      "druid_upg",
      "druid_upg_alt",
      "qilin",
      "qilin_upg",
      "qilin_upg_alt",
      "phoenix",
      "phoenix_upg",
      "phoenix_upg_alt",
      "trick_demon",
      "trick_demon_upg",
      "trick_demon_upg_alt",
      "locust",
      "locust_upg",
      "locust_upg_alt",
      "wasp",
      "wasp_upg",
      "wasp_upg_alt",
      "lava_larva",
      "jaw",
      "jaw_upg",
      "jaw_upg_alt",
      "godslayer",
      "godslayer_upg",
      "godslayer_upg_alt",
      "olgoi",
      "olgoi_upg",
      "olgoi_upg_alt",
      "hive_queen",
      "hive_queen_upg",
      "hive_queen_upg_alt",
      "lesser_eldritch",
      "lesser_eldritch_upg",
      "lesser_eldritch_upg_alt",
      "unfrozen_cultist",
      "unfrozen_cultist_upg",
      "unfrozen_cultist_upg_alt",
      "frostworm_rider",
      "frostworm_rider_upg",
      "frostworm_rider_upg_alt",
      "eldritch_flyer",
      "eldritch_flyer_upg",
      "eldritch_flyer_upg_alt",
      "succubus",
      "succubus_upg",
      "succubus_upg_alt",
      "arbitrator",
      "arbitrator_upg",
      "arbitrator_upg_alt",
      "unspeakable",
      "unspeakable_upg",
      "unspeakable_upg_alt",
      "trogl",
      "trogl_upg",
      "trogl_upg_alt",
      "assassin",
      "assassin_upg",
      "assassin_upg_alt",
      "blade_dancer",
      "blade_dancer_upg",
      "blade_dancer_upg_alt",
      "minos",
      "minos_upg",
      "minos_upg_alt",
      "medusa",
      "medusa_upg",
      "medusa_upg_alt",
      "hydra",
      "hydra_upg",
      "hydra_upg_alt",
      "black_dragon",
      "black_dragon_upg",
      "black_dragon_upg_alt",
      "pixie",
      "gnat",
      "undead_peasant",
      "peasant",
      "halfling",
      "animated_armor",
      "gorilla",
      "star_child",
      "unicorn",
      "kitten_horn",
      "primal_remnant",
      "fairy_dragon",
      "giant_frog",
      "mech_guard",
      "dragon_hunter",
      "coatl",
      "sentinel",
      "dragon",
      "dragon_upg",
      "avatar",
      "lich_dragon"
    ]
  };
  var DICTIONARY_default = DICTIONARY;

  // src/planner/helpers/compression/FIELDS.js
  var FIELDS = [
    /*00*/
    { key: "hero", bits: 8, dictionary: DICTIONARY_default.heroes },
    /*01*/
    {
      key: "level",
      bits: 5
      /*32*/
    },
    /*02*/
    { key: "skill0Id", bits: 6, dictionary: DICTIONARY_default.skills },
    /*03*/
    {
      key: "skill0Sub1",
      bits: 3
      /*8*/
    },
    /*04*/
    {
      key: "skill0Sub2",
      bits: 3
      /*8*/
    },
    /*05*/
    { key: "skill1Id", bits: 6, dictionary: DICTIONARY_default.skills },
    /*06*/
    {
      key: "skill1Sub1",
      bits: 3
      /*8*/
    },
    /*07*/
    {
      key: "skill1Sub2",
      bits: 3
      /*8*/
    },
    /*08*/
    { key: "skill2Id", bits: 6, dictionary: DICTIONARY_default.skills },
    /*09*/
    {
      key: "skill2Sub1",
      bits: 3
      /*8*/
    },
    /*10*/
    {
      key: "skill2Sub2",
      bits: 3
      /*8*/
    },
    /*11*/
    { key: "skill3Id", bits: 6, dictionary: DICTIONARY_default.skills },
    /*12*/
    {
      key: "skill3Sub1",
      bits: 3
      /*8*/
    },
    /*13*/
    {
      key: "skill3Sub2",
      bits: 3
      /*8*/
    },
    /*14*/
    { key: "skill4Id", bits: 6, dictionary: DICTIONARY_default.skills },
    /*15*/
    {
      key: "skill4Sub1",
      bits: 3
      /*8*/
    },
    /*16*/
    {
      key: "skill4Sub2",
      bits: 3
      /*8*/
    },
    /*17*/
    { key: "skill5Id", bits: 6, dictionary: DICTIONARY_default.skills },
    /*18*/
    {
      key: "skill5Sub1",
      bits: 3
      /*8*/
    },
    /*19*/
    {
      key: "skill5Sub2",
      bits: 3
      /*8*/
    },
    /*20*/
    { key: "skill6Id", bits: 6, dictionary: DICTIONARY_default.skills },
    /*21*/
    {
      key: "skill6Sub1",
      bits: 3
      /*8*/
    },
    /*22*/
    {
      key: "skill6Sub2",
      bits: 3
      /*8*/
    },
    /*23*/
    { key: "skill7Id", bits: 6, dictionary: DICTIONARY_default.skills },
    /*24*/
    {
      key: "skill7Sub1",
      bits: 3
      /*8*/
    },
    /*25*/
    {
      key: "skill7Sub2",
      bits: 3
      /*8*/
    },
    /*26*/
    { key: "artifactSword", bits: 5, dictionary: DICTIONARY_default.artifactSword },
    /*27*/
    { key: "artifactShield", bits: 5, dictionary: DICTIONARY_default.artifactShield },
    /*28*/
    { key: "artifactArmor", bits: 5, dictionary: DICTIONARY_default.artifactArmor },
    /*29*/
    { key: "artifactHelmet", bits: 5, dictionary: DICTIONARY_default.artifactHelmet },
    /*30*/
    { key: "artifactBoots", bits: 5, dictionary: DICTIONARY_default.artifactBoots },
    /*31*/
    { key: "artifactBelt", bits: 5, dictionary: DICTIONARY_default.artifactBelt },
    /*32*/
    { key: "artifactCape", bits: 5, dictionary: DICTIONARY_default.artifactCape },
    /*33*/
    { key: "artifactRingL", bits: 5, dictionary: DICTIONARY_default.artifactRing },
    /*34*/
    { key: "artifactRingR", bits: 5, dictionary: DICTIONARY_default.artifactRing },
    /*35*/
    { key: "artifactPouchTL", bits: 6, dictionary: DICTIONARY_default.artifactPouch },
    /*36*/
    { key: "artifactPouchTR", bits: 6, dictionary: DICTIONARY_default.artifactPouch },
    /*37*/
    { key: "artifactPouchBL", bits: 6, dictionary: DICTIONARY_default.artifactPouch },
    /*38*/
    { key: "artifactPouchBR", bits: 6, dictionary: DICTIONARY_default.artifactPouch },
    /*39*/
    { key: "artifactBanner", bits: 5, dictionary: DICTIONARY_default.artifactBanner },
    /*40*/
    { key: "army0Id", bits: 8, dictionary: DICTIONARY_default.units },
    /*41*/
    {
      key: "army0Count",
      bits: 10
      /*1024*/
    },
    /*42*/
    { key: "army1Id", bits: 8, dictionary: DICTIONARY_default.units },
    /*43*/
    {
      key: "army1Count",
      bits: 10
      /*1024*/
    },
    /*44*/
    { key: "army2Id", bits: 8, dictionary: DICTIONARY_default.units },
    /*45*/
    {
      key: "army2Count",
      bits: 10
      /*1024*/
    },
    /*46*/
    { key: "army3Id", bits: 8, dictionary: DICTIONARY_default.units },
    /*47*/
    {
      key: "army3Count",
      bits: 10
      /*1024*/
    },
    /*48*/
    { key: "army4Id", bits: 8, dictionary: DICTIONARY_default.units },
    /*49*/
    {
      key: "army4Count",
      bits: 10
      /*1024*/
    },
    /*50*/
    { key: "army5Id", bits: 8, dictionary: DICTIONARY_default.units },
    /*51*/
    {
      key: "army5Count",
      bits: 10
      /*1024*/
    },
    /*52*/
    { key: "army6Id", bits: 8, dictionary: DICTIONARY_default.units },
    /*53*/
    {
      key: "army6Count",
      bits: 10
      /*1024*/
    }
  ];
  var FIELDS_default = FIELDS;

  // src/planner/helpers/compression/decode.js
  function decode(symbols) {
    if (!symbols) {
      return {};
    }
    const stream = convertSymbolsToBits(symbols);
    const result = {};
    let cursor = 0;
    let expectedIndex = 0;
    while (cursor < stream.length) {
      const isSequential = stream[cursor++] === "1";
      let currentIndex;
      if (isSequential) {
        currentIndex = expectedIndex;
      } else {
        const indexBits = stream.slice(cursor, cursor + FIELD_INDEX_BITS);
        cursor += FIELD_INDEX_BITS;
        currentIndex = parseInt(indexBits, 2);
      }
      const field = FIELDS_default[currentIndex];
      if (!field) {
        console.warn(`Invalid field index encountered: ${currentIndex}`);
        return result;
      }
      const valueBits = stream.slice(cursor, cursor + field.bits);
      cursor += field.bits;
      let value = parseInt(valueBits, 2);
      if (field.dictionary) {
        if (value >= field.dictionary.length) {
          console.warn(`Dictionary index ${value} out of bounds for field "${field.key}"!`);
          return result;
        }
        value = field.dictionary[value];
      }
      if (value) {
        result[field.key] = value;
      }
      expectedIndex = currentIndex + 1;
    }
    return result;
  }
  function convertSymbolsToBits(symbols) {
    if (!symbols) {
      return "";
    }
    const base = BigInt(SYMBOLS.length);
    let num = 0n;
    for (const char of symbols) {
      const index = SYMBOLS.indexOf(char);
      if (index === -1) {
        console.log(`Invalid symbol encountered: ${char}`);
        return "";
      }
      num = num * base + BigInt(index);
    }
    return num.toString(2).slice(1);
  }
  var decode_default = decode;

  // src/planner/utils/assume.js
  function assume(condition, ...message) {
    if (!condition) {
      throw new Error(stringify(message));
    }
  }
  function stringify(list) {
    const lines = [];
    for (const arg of list) {
      lines.push(typeof arg === "object" ? JSON.stringify(arg, null, 4) : arg);
    }
    return lines.join("\n");
  }
  var assume_default = assume;

  // src/planner/helpers/compression/encode.js
  function encode(hub) {
    let stream = "";
    let jumpPending = false;
    for (let i3 = 0; i3 < FIELDS_default.length; i3++) {
      const { key, bits, dictionary } = FIELDS_default[i3];
      let value = hub[key];
      if (value === void 0) {
        jumpPending = true;
        continue;
      }
      if (jumpPending) {
        stream += "0";
        stream += i3.toString(2).padStart(FIELD_INDEX_BITS, "0");
        jumpPending = false;
      } else {
        stream += "1";
      }
      if (dictionary) {
        const index = dictionary.indexOf(value);
        assume_default(index >= 0, `The value "${value}" is not present in the dictionary of "${key}"!`);
        value = index;
      }
      stream += value.toString(2).padStart(bits, "0");
    }
    return convertBitsToSymbols(stream);
  }
  function convertBitsToSymbols(bits) {
    if (!bits) {
      return "";
    }
    let num = BigInt("0b1" + bits);
    let res = "";
    const base = BigInt(SYMBOLS.length);
    while (num > 0n) {
      res = SYMBOLS[Number(num % base)] + res;
      num /= base;
    }
    return res;
  }
  var encode_default = encode;

  // src/planner/helpers/Persistence.js
  var STORAGE_KEY = "hero-planner";
  var changeHandler;
  var sourceOfTruth = null;
  function setup(onChange) {
    changeHandler = onChange;
    window.addEventListener("hashchange", onHashChange);
    const hash = window.location.hash.substring(1);
    if (hash) {
      parseSymbols(hash);
    } else {
      const stored = window.localStorage.getItem(STORAGE_KEY);
      parseSymbols(stored || "");
    }
  }
  function remember(state) {
    const symbols = encode_default(state);
    parseSymbols(symbols);
  }
  function onHashChange() {
    const hash = window.location.hash.substring(1) || "";
    parseSymbols(hash);
  }
  function parseSymbols(symbols) {
    if (symbols !== sourceOfTruth) {
      sourceOfTruth = symbols;
      window.localStorage.setItem(STORAGE_KEY, symbols);
      if (symbols) {
        window.location.hash = symbols;
      } else {
        history.pushState(null, "", window.location.pathname + window.location.search);
      }
      const decoded = decode_default(symbols);
      changeHandler(decoded);
    }
  }
  var Persistence = {
    setup,
    remember
  };
  var Persistence_default = Persistence;

  // src/planner/components/Reset.jsx
  var ROOT_CSS4 = u3`
    position: absolute;
    left: 673px;
    top: 38px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;

    &:hover {
        border: solid 2px yellow;
    }
    &:active {
        border: solid 2px red;
    }
`;
  var Reset = class extends C {
    render() {
      return /* @__PURE__ */ u2("div", { className: ROOT_CSS4, onClick: this.onRootClick });
    }
    // -----------------------------------------------------------------------------------------------------------------
    // P R I V A T E
    // -----------------------------------------------------------------------------------------------------------------
    /**
     *
     */
    onRootClick = () => {
      Persistence_default.remember({});
    };
  };
  var Reset_default = Reset;

  // src/planner/components/Specialization.jsx
  var ROOT_CSS5 = u3`
    position: absolute;
    left: 45px;
    top: 150px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;

    & img {
        width: 100%;
    }
`;
  var Specialization = class extends C {
    render() {
      const { heroData } = this.props;
      console.log("heroData:", heroData);
      return /* @__PURE__ */ u2("div", { className: ROOT_CSS5, children: heroData && /* @__PURE__ */ u2("img", { src: heroData.specIcon }) });
    }
    // -----------------------------------------------------------------------------------------------------------------
    // P R I V A T E
    // -----------------------------------------------------------------------------------------------------------------
  };
  var Specialization_default = Specialization;

  // src/planner/components/Labels.jsx
  var ROOT_CSS6 = u3`
    position: absolute;
    left: 0;
    top: 0;
    color: #fff;
    font-weight: bold;
    font-size: 18px;
    white-space: nowrap;

    & > * {
        position: absolute;
    }
`;
  var NAME_CSS = u3`
    left: 208px;
    top: 8px;
`;
  var CLASS_CSS = u3`
    left: 208px;
    top: 42px;
    font-size: 16px;
    font-weight: normal;
`;
  var Labels = class extends C {
    render() {
      const { heroData } = this.props;
      return /* @__PURE__ */ u2("div", { className: ROOT_CSS6, children: [
        heroData && /* @__PURE__ */ u2("div", { className: NAME_CSS, children: heroData.name }),
        heroData && /* @__PURE__ */ u2("div", { className: CLASS_CSS, children: heroData.className })
      ] });
    }
    // -----------------------------------------------------------------------------------------------------------------
    // P R I V A T E
    // -----------------------------------------------------------------------------------------------------------------
  };
  var Labels_default = Labels;

  // src/planner/components/App.jsx
  var APP_CSS = u3`
    position: absolute;
    width: ${WIDTH}px;
    height: ${HEIGHT}px;
    transform-origin: 0 0;
`;
  var BG_CSS = u3`
    width: 100%;
    filter: drop-shadow(0 0 0.3rem black);
`;
  var App = class extends C {
    vars = {
      appRef: M()
    };
    render() {
      const { hero } = this.state;
      const { appRef } = this.vars;
      const { bgUrl, levelUrl, heroes } = this.props.setup;
      const heroData = heroes[hero];
      return /* @__PURE__ */ u2("div", { className: APP_CSS, ref: appRef, children: [
        /* @__PURE__ */ u2("style", { children: CSS }),
        /* @__PURE__ */ u2("img", { className: BG_CSS, src: bgUrl, alt: "empty background" }),
        /* @__PURE__ */ u2(Portrait_default, { hero, heroes, onHeroChange: this.onHeroChange }),
        /* @__PURE__ */ u2(Specialization_default, { heroData }),
        /* @__PURE__ */ u2(Labels_default, { heroData }),
        /* @__PURE__ */ u2(Level_default, { src: levelUrl }),
        /* @__PURE__ */ u2(Reset_default, {})
      ] });
    }
    componentDidMount() {
      console.log("componentDidMount:");
      window.addEventListener("resize", this.onWindowResize);
      Persistence_default.setup(this.onHashChange);
      this.refreshScale();
    }
    componentDidUpdate() {
      Persistence_default.remember(this.state);
    }
    componentWillUnmount() {
      console.log("componentWillUnmount:");
      window.removeEventListener("resize", this.onWindowResize);
    }
    // -----------------------------------------------------------------------------------------------------------------
    // P R I V A T E
    // -----------------------------------------------------------------------------------------------------------------
    /**
     *
     */
    onWindowResize = () => {
      this.refreshScale();
    };
    /**
     *
     */
    refreshScale = () => {
      const appElement = this.vars.appRef.current;
      const rootElement = appElement.parentNode;
      const { width } = rootElement.getBoundingClientRect();
      const coreWidth = Math.min(width, WIDTH);
      const coreHeight = coreWidth * HEIGHT / WIDTH;
      rootElement.style.height = Math.ceil(coreHeight) + "px";
      const scaleRatio = coreWidth / WIDTH;
      appElement.style.transform = `scale(${scaleRatio})`;
      appElement.style.left = Math.floor((width - coreWidth) / 2) + "px";
    };
    /**
     *
     */
    onHeroChange = (hero) => {
      this.setState({ hero });
    };
    /**
     *
     */
    onHashChange = (stateFragment) => {
      this.setState({
        hero: stateFragment.hero
      });
    };
  };
  var App_default = App;

  // src/planner/utils/match.js
  function match(text, pattern) {
    if (pattern.global) {
      return [...text.matchAll(pattern)];
    } else {
      return text.match(pattern) || [];
    }
  }
  var match_default = match;

  // src/planner/helpers/downloadPage.js
  var wikiUrl = getWikiUrl();
  async function downloadPage(page) {
    let response;
    try {
      response = await fetch(wikiUrl + page);
    } catch (e3) {
      console.warn(`Failed to fetch ${page}!`);
      return "";
    }
    return await response.text();
  }
  function getWikiUrl() {
    let { href } = window.location;
    href = href.replace(/\/..$/, "");
    href = href.replace(/\/..-\w+$/, "");
    href = href.replace(/[^/]*$/, "");
    return href;
  }
  var downloadPage_default = downloadPage;

  // src/planner/data/getHeroes.js
  async function getHeroes() {
    const overview = await downloadPage_default("Heroes_Overview");
    const [table = ""] = match_default(overview, /<table[\s\S]*?<\/table>/);
    const rows = table.split("</tr>");
    rows.shift();
    const heroes = {};
    for (let i3 = 0; i3 < rows.length; i3++) {
      const hero = parseRow(rows[i3], rows[i3 + 1]);
      if (hero) {
        heroes[hero.id] = hero;
      }
    }
    return heroes;
  }
  function parseRow(row, extraRow) {
    const [iconColumn, nameColumn, , classColumn, specIconColumn, specInfoColumn, skillsColumn] = row.split("</td>");
    let [, id] = match_default(iconColumn, /data-id=['"]([^'"]*)/);
    if (!id) {
      return;
    }
    id = id.replaceAll("&#95;", "_");
    const [, icon] = match_default(iconColumn, /src=['"]([^'"]*)/);
    if (!icon) {
      return console.warn("No icon!");
    }
    const portrait = icon.replace(/\d*px/, "600px");
    let [, name] = match_default(nameColumn, /<a.*?>([^<]*)/);
    if (!name) {
      return console.warn("No name!");
    }
    const [, classIcon] = match_default(classColumn, /src=['"]([^'"]*)/);
    if (!classIcon) {
      return console.warn("No classIcon!");
    }
    const [, className] = match_default(classColumn, /<a.*?>([^<]+)/);
    if (!className) {
      return console.warn("No className!");
    }
    let [, specIcon] = match_default(specIconColumn, /src=['"]([^'"]*)/);
    if (!specIcon) {
      return console.warn("No specIcon!");
    }
    specIcon = specIcon.replace(/\d*px/, "128px");
    const [, specName] = match_default(specInfoColumn, /<b>([^<]+)/);
    if (!specName) {
      return console.warn("No specName!");
    }
    const [, specDescription] = match_default(extraRow || "", /<td.*?>([^<]+)/);
    if (!specDescription) {
      return console.warn("No specDescription!");
    }
    const skills = parseSkills(skillsColumn);
    if (!skills) {
      return;
    }
    return { id, icon, portrait, name, classIcon, className, specIcon, specName, specDescription, skills };
  }
  function parseSkills(column) {
    const divs = column.split("</div>");
    const skills = [];
    for (const div of divs) {
      if (!div) {
        continue;
      }
      const [, src] = match_default(div, /src=['"]([^'"]*)/);
      if (!src) {
        return console.warn("No skill src!");
      }
      let [, name] = match_default(src, /\d+px-(.*?)\.\w+$/);
      name = name.toLowerCase();
      let [, level = 1] = match_default(name, /_(\d+)$/);
      if (level !== 1) {
        name = name.replace(/_\d+$/, "");
        level = Number(level);
      }
      if (name.includes("faction")) {
        skills.unshift({ name, level });
      } else {
        skills.push({ name, level });
      }
    }
    return skills;
  }
  var getHeroes_default = getHeroes;

  // src/planner/planner.js
  async function planner() {
    const root = document.querySelector(".planner");
    if (!root) {
      window.addEventListener("load", onWindowLoad);
    } else {
      await run(root);
    }
  }
  async function onWindowLoad() {
    window.removeEventListener("load", onWindowLoad);
    const root = document.querySelector(".planner");
    if (root) {
      await run(root);
    }
  }
  async function run(root) {
    console.log("Mounting HeroPlanner...");
    mount_default(App_default, root, {
      bgUrl: root.querySelector(".background img").src,
      levelUrl: root.querySelector(".level img").src,
      heroes: await getHeroes_default()
    });
  }
  planner();
})();
//# sourceMappingURL=planner.js.map